forked from Archives/langchain
767fa91eae
Fix the document page to open both search and Mendable when pressing Ctrl+K. I have changed the shortcut for Mendable to Ctrl+J. <!-- If you're adding a new integration, please include: 1. a test for the integration - favor unit tests that does not rely on network access. 2. an example notebook showing its use See contribution guidelines for more information on how to write tests, lint etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md --> #### Who can review? @hwchase17 Tag maintainers/contributors who might be interested: <!-- For a quicker response, figure out the right person to tag with @ @hwchase17 - project lead Tracing / Callbacks - @agola11 Async - @agola11 DataLoaders - @eyurtsev Models - @hwchase17 - @agola11 Agents / Tools / Toolkits - @vowelparrot VectorStores / Retrievers / Memory - @dev2049 -->
58 lines
1.9 KiB
JavaScript
58 lines
1.9 KiB
JavaScript
document.addEventListener('DOMContentLoaded', () => {
|
|
// Load the external dependencies
|
|
function loadScript(src, onLoadCallback) {
|
|
const script = document.createElement('script');
|
|
script.src = src;
|
|
script.onload = onLoadCallback;
|
|
document.head.appendChild(script);
|
|
}
|
|
|
|
function createRootElement() {
|
|
const rootElement = document.createElement('div');
|
|
rootElement.id = 'my-component-root';
|
|
document.body.appendChild(rootElement);
|
|
return rootElement;
|
|
}
|
|
|
|
|
|
|
|
function initializeMendable() {
|
|
const rootElement = createRootElement();
|
|
const { MendableFloatingButton } = Mendable;
|
|
|
|
|
|
const iconSpan1 = React.createElement('span', {
|
|
}, '🦜');
|
|
|
|
const iconSpan2 = React.createElement('span', {
|
|
}, '🔗');
|
|
|
|
const icon = React.createElement('p', {
|
|
style: { color: '#ffffff', fontSize: '22px',width: '48px', height: '48px', margin: '0px', padding: '0px', display: 'flex', alignItems: 'center', justifyContent: 'center', textAlign: 'center' },
|
|
}, [iconSpan1, iconSpan2]);
|
|
|
|
const mendableFloatingButton = React.createElement(
|
|
MendableFloatingButton,
|
|
{
|
|
style: { darkMode: false, accentColor: '#010810' },
|
|
floatingButtonStyle: { color: '#ffffff', backgroundColor: '#010810' },
|
|
anon_key: '82842b36-3ea6-49b2-9fb8-52cfc4bde6bf', // Mendable Search Public ANON key, ok to be public
|
|
cmdShortcutKey:'j',
|
|
messageSettings: {
|
|
openSourcesInNewTab: false,
|
|
prettySources: true // Prettify the sources displayed now
|
|
},
|
|
icon: icon,
|
|
}
|
|
);
|
|
|
|
ReactDOM.render(mendableFloatingButton, rootElement);
|
|
}
|
|
|
|
loadScript('https://unpkg.com/react@17/umd/react.production.min.js', () => {
|
|
loadScript('https://unpkg.com/react-dom@17/umd/react-dom.production.min.js', () => {
|
|
loadScript('https://unpkg.com/@mendable/search@0.0.102/dist/umd/mendable.min.js', initializeMendable);
|
|
});
|
|
});
|
|
});
|