| 1 |
import React from 'react'; |
| 2 |
import { createRoot } from 'react-dom/client'; |
| 3 |
import SearchField from './SearchField'; // Adjust the path as necessary |
| 4 |
|
| 5 |
document.addEventListener('DOMContentLoaded', () => { |
| 6 |
const searchDiv = document.querySelectorAll('[id=betterdocs-search-modal]'); |
| 7 |
if (searchDiv) { |
| 8 |
for( let node of searchDiv ) { |
| 9 |
const className = node?.className; |
| 10 |
const dataAttributes = { |
| 11 |
placeholder: node.getAttribute('data-placeholder'), |
| 12 |
heading: node.getAttribute('data-heading'), |
| 13 |
subheading: node.getAttribute('data-subheading'), |
| 14 |
headingTag: node.getAttribute('data-headingtag'), |
| 15 |
subheadingTag: node.getAttribute('data-subheadingtag'), |
| 16 |
buttonText: node.getAttribute('data-buttontext'), |
| 17 |
numberofdocs:node.getAttribute('data-numberofdocs'), |
| 18 |
numberoffaqs:node.getAttribute('data-numberoffaqs'), |
| 19 |
docterms:node.getAttribute('data-docterms'), |
| 20 |
faqterms:node.getAttribute('data-faqterms'), |
| 21 |
searchButton:node.getAttribute('data-searchbutton'), |
| 22 |
doc_ids:node.getAttribute('data-doc_ids'), |
| 23 |
doc_categories_ids:node.getAttribute('data-doc_categories_ids'), |
| 24 |
faq_categories_ids:node.getAttribute('data-faq_categories_ids'), |
| 25 |
enable_faq_search:node.getAttribute('data-enable_faq_search'), |
| 26 |
enable_docs_search:node.getAttribute('data-enable_docs_search'), |
| 27 |
enable_ai_powered_search:node.getAttribute('data-enable_ai_powered_search'), |
| 28 |
kbBasedSearch:node.getAttribute('data-kb_based_search') |
| 29 |
}; |
| 30 |
const root = createRoot(node); |
| 31 |
root.render(<SearchField layout={className} {...dataAttributes} />); |
| 32 |
} |
| 33 |
} |
| 34 |
}); |
| 35 |
|