| | |
| | | import { Document } from "flexsearch" |
| | | import { ContentDetails } from "../../plugins/emitters/contentIndex" |
| | | import { registerEscapeHandler, removeAllChildren } from "./util" |
| | | import { FullSlug, getFullSlug, resolveRelative, simplifySlug } from "../../util/path" |
| | | import { FullSlug, resolveRelative } from "../../util/path" |
| | | |
| | | interface Item { |
| | | id: number |
| | |
| | | }) |
| | | .join(" ") |
| | | |
| | | return `${startIndex === 0 ? "" : "..."}${slice}${ |
| | | endIndex === tokenizedText.length - 1 ? "" : "..." |
| | | }` |
| | | return `${startIndex === 0 ? "" : "..."}${slice}${endIndex === tokenizedText.length - 1 ? "" : "..." |
| | | }` |
| | | } |
| | | |
| | | const encoder = (str: string) => str.toLowerCase().split(/([^a-z]|[^\x00-\x7F])/) |
| | | let prevShortcutHandler: ((e: HTMLElementEventMap["keydown"]) => void) | undefined = undefined |
| | | document.addEventListener("nav", async (e: unknown) => { |
| | | const currentSlug = (e as CustomEventMap["nav"]).detail.url |
| | | |
| | |
| | | displayResults(finalResults) |
| | | } |
| | | |
| | | document.removeEventListener("keydown", shortcutHandler) |
| | | if (prevShortcutHandler) { |
| | | document.removeEventListener("keydown", prevShortcutHandler) |
| | | } |
| | | |
| | | document.addEventListener("keydown", shortcutHandler) |
| | | prevShortcutHandler = shortcutHandler |
| | | searchIcon?.removeEventListener("click", showSearch) |
| | | searchIcon?.addEventListener("click", showSearch) |
| | | searchBar?.removeEventListener("input", onType) |