RuneStone 1.0.0

This commit is contained in:
Knotty Wyvern
2026-11-16 04:21:21 -07:00
commit b52eeb14a1
827 changed files with 241421 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
import { EditorState } from "@codemirror/state";
import { SearchQuery } from "@codemirror/search";
/** Commands for the shared document search controls. */
export interface FindTarget {
query: SearchQuery;
readOnly: boolean;
canSelectAll?: boolean;
setQuery(query: SearchQuery): void;
next(backward?: boolean): void;
selectAll(): void;
replace(all?: boolean): void;
close(): void;
keydown?(event: KeyboardEvent): boolean;
}
export function documentMatches(source: string, query: SearchQuery) {
const state = EditorState.create({ doc: source });
const matches: { from: number; to: number }[] = [];
if (query.valid) {
const cursor = query.getCursor(state);
for (let match = cursor.next(); !match.done; match = cursor.next()) matches.push(match.value);
}
return { state, matches };
}