Skip to content

Commit

Permalink
Expose search APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
FIameCaster committed Dec 19, 2023
1 parent ea955f7 commit 38e9f0b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions package/src/extensions/search/selection.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
import { EditorEventMap, Extension, PrismEditor } from "../.."
import { SearchAPI, SearchFilter, createSearchAPI } from "./search"

export interface WordHighlighter extends Extension {
export interface SelectionMatchHighlighter extends Extension {
/**
* Search API used by the extension.
* Can be used get the position of the matches for example.
* This property is only present after the extension is added to an editor.
*/
api?: SearchAPI
}

export interface WordHighlighter extends SelectionMatchHighlighter {
/** Sets the search filter used. Useful for updating the filter after changing an editor's language. */
setFilter(newFilter: SearchFilter): void
}

const extensionTemplate = (
className: string,
handler: (editor: PrismEditor, api: SearchAPI) => EditorEventMap["selectionChange"],
): Extension => ({
): SelectionMatchHighlighter => ({
update(editor: PrismEditor) {
this.update = () => {}
const searchAPI = createSearchAPI(editor),
const searchAPI = (this.api = createSearchAPI(editor)),
container = searchAPI.container

container.style.zIndex = <any>-1
Expand Down

0 comments on commit 38e9f0b

Please sign in to comment.