Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 14 additions & 26 deletions fern/assets/inkeep.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const searchButtonContainerIds = [
"fern-search-bar",
"fern-search-button",
"fern-search-bar"
];

// Define the base settings
const inkeepSettings = {
isOpen: true,
baseSettings: {
apiKey: "a58574ddc0e41c75990d1c0e890ad3c8725dc9e7c8ee3d3e",
integrationId: "clthv1rgg000sdjil26l2vg03",
Expand Down Expand Up @@ -34,26 +33,6 @@ const inkeepSettings = {
}
};

// Function to initialize search containers
function initializeSearchContainers() {
// Clone and replace search buttons to remove existing listeners
// Only process elements that exist
const clonedSearchButtonContainers = searchButtonContainerIds
.map((id) => {
const originalElement = document.getElementById(id);
if (!originalElement) {
console.log(`Search container ${id} not found, skipping...`);
return null;
}
const clonedElement = originalElement.cloneNode(true);
originalElement.parentNode.replaceChild(clonedElement, originalElement);
return clonedElement;
})
.filter(Boolean); // Remove null entries

return clonedSearchButtonContainers;
}

// Function to initialize Inkeep
function initializeInkeep() {
// Color mode sync settings
Expand Down Expand Up @@ -88,13 +67,23 @@ function initializeInkeep() {
},
},
});

// Get search containers after DOM is ready
const clonedSearchButtonContainers = initializeSearchContainers();

const clonedSearchButtonContainers = searchButtonContainerIds
.map((id) => {
const originalElement = document.getElementById(id);
if (!originalElement) {
console.log(`Search container ${id} not found, skipping...`);
return null;
}
originalElement.disabled = false;
return originalElement
}).filter(Boolean);

// Add click listeners to search buttons
clonedSearchButtonContainers.forEach((trigger) => {
console.log("adding trigger")
trigger.addEventListener("click", function () {
console.log("clicked")
inkeepSearchModal.render({
isOpen: true,
});
Expand All @@ -106,7 +95,6 @@ function initializeInkeep() {
"keydown",
(event) => {
if (
(event.metaKey || event.ctrlKey) &&
(event.key === "/")
) {
event.stopPropagation();
Expand Down
Loading