@aicayzer/inkkit 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -48733,6 +48733,11 @@ function formattedQuery(text) {
|
|
|
48733
48733
|
const from = state.doc.resolve(match.from);
|
|
48734
48734
|
const to = state.doc.resolve(match.to);
|
|
48735
48735
|
if (from.parent !== to.parent || !from.parent.inlineContent) return false;
|
|
48736
|
+
if ([
|
|
48737
|
+
"comment_inline",
|
|
48738
|
+
"comment_block",
|
|
48739
|
+
"reference_definition"
|
|
48740
|
+
].includes(from.parent.type.name)) return false;
|
|
48736
48741
|
const content = state.doc.slice(match.from, match.to).content;
|
|
48737
48742
|
let textOnly = true;
|
|
48738
48743
|
content.forEach((node) => {
|
|
@@ -48742,6 +48747,22 @@ function formattedQuery(text) {
|
|
|
48742
48747
|
}
|
|
48743
48748
|
});
|
|
48744
48749
|
}
|
|
48750
|
+
function formattedMatches(state, text) {
|
|
48751
|
+
if (!text) return [];
|
|
48752
|
+
const query = formattedQuery(text);
|
|
48753
|
+
const matches = [];
|
|
48754
|
+
if (!query.valid) return matches;
|
|
48755
|
+
for (let position = 0;;) {
|
|
48756
|
+
const match = query.findNext(state, position);
|
|
48757
|
+
if (!match) break;
|
|
48758
|
+
matches.push({
|
|
48759
|
+
from: match.from,
|
|
48760
|
+
to: match.to
|
|
48761
|
+
});
|
|
48762
|
+
position = match.to;
|
|
48763
|
+
}
|
|
48764
|
+
return matches;
|
|
48765
|
+
}
|
|
48745
48766
|
function findFormatted(view, text) {
|
|
48746
48767
|
const query = formattedQuery(text);
|
|
48747
48768
|
const previous = getSearchState(view.state)?.query.search;
|
|
@@ -48847,6 +48868,33 @@ var EditorSearch = class {
|
|
|
48847
48868
|
restore(match) {
|
|
48848
48869
|
this.literalMatch = match;
|
|
48849
48870
|
}
|
|
48871
|
+
matches(text, snapshotId, projection) {
|
|
48872
|
+
const raw = this.runtime.literal() ? this.runtime.currentText() : void 0;
|
|
48873
|
+
const matches = raw === void 0 ? formattedMatches(this.runtime.view().state, text) : literalMatches(raw, text);
|
|
48874
|
+
let rawPosition = 0, normalizedPosition = 0, spanIndex = 0;
|
|
48875
|
+
const offset = (position) => {
|
|
48876
|
+
if (raw !== void 0) {
|
|
48877
|
+
while (rawPosition < position) {
|
|
48878
|
+
if (raw[rawPosition] !== "\n" || raw[rawPosition - 1] !== "\r") normalizedPosition++;
|
|
48879
|
+
rawPosition++;
|
|
48880
|
+
}
|
|
48881
|
+
return normalizedPosition;
|
|
48882
|
+
}
|
|
48883
|
+
while (spanIndex < projection.spans.length && projection.spans[spanIndex].end < position) spanIndex++;
|
|
48884
|
+
const span = projection.spans[spanIndex];
|
|
48885
|
+
if (!span) return projection.text.length;
|
|
48886
|
+
if (position < span.start) return span.from;
|
|
48887
|
+
return span.kind === "text" ? span.from + Math.max(0, position - span.start) : position === span.start ? span.from : span.to;
|
|
48888
|
+
};
|
|
48889
|
+
return Object.freeze(matches.map((match) => {
|
|
48890
|
+
const start = raw !== void 0 && raw[match.from] === "\n" && raw[match.from - 1] === "\r" ? match.from - 1 : match.from;
|
|
48891
|
+
return Object.freeze({
|
|
48892
|
+
snapshotId,
|
|
48893
|
+
from: offset(start),
|
|
48894
|
+
to: offset(match.to)
|
|
48895
|
+
});
|
|
48896
|
+
}));
|
|
48897
|
+
}
|
|
48850
48898
|
find(text) {
|
|
48851
48899
|
if (this.runtime.literal()) {
|
|
48852
48900
|
const from = this.plainSearch === text ? this.runtime.element().selectionEnd : this.runtime.element().selectionStart;
|
|
@@ -57233,7 +57281,7 @@ async function createMilkdownEditor(root, options, runtime) {
|
|
|
57233
57281
|
return true;
|
|
57234
57282
|
}
|
|
57235
57283
|
}));
|
|
57236
|
-
}).use(labelsCtx).use(linkSchemesCtx).use(formatInputCtx).use(richTextGuard).use(runtime.plugins.paste).use(visibleClipboard).use(runtime.plugins.suggestions).use(runtime.plugins.keymap).use(createDialect(Boolean(options.images || options.files), Boolean(options.wikiLinks), Boolean(options.files))).use(codeControlCtx).use(codeControlsPlugin(() => runtime.visibleRect())).use(tablePlugins).use(tableBlock).use(runtime.plugins.change).use(runtime.plugins.historyInput).use(history).use(clipboard).use(cursor).use(taskListPlugin((operation) => runtime.mutate(operation))).use(undoTypedRule).use(quoteBackspace).use(calloutEnter).use(literalEnter).use(literalReread).use(listItemBackspace).use(nestedItemEnter).use(rejoinLists).use(movedListItems).use(textInputPolicy).use(runtime.copy ? codeCopyPlugin((text) => runtime.copy?.(text)) : []).use(placeholderPlugin).use(options.rendering?.codeHighlighting === false ? [] : (await import("./highlight-
|
|
57284
|
+
}).use(labelsCtx).use(linkSchemesCtx).use(formatInputCtx).use(richTextGuard).use(runtime.plugins.paste).use(visibleClipboard).use(runtime.plugins.suggestions).use(runtime.plugins.keymap).use(createDialect(Boolean(options.images || options.files), Boolean(options.wikiLinks), Boolean(options.files))).use(codeControlCtx).use(codeControlsPlugin(() => runtime.visibleRect())).use(tablePlugins).use(tableBlock).use(runtime.plugins.change).use(runtime.plugins.historyInput).use(history).use(clipboard).use(cursor).use(taskListPlugin((operation) => runtime.mutate(operation))).use(undoTypedRule).use(quoteBackspace).use(calloutEnter).use(literalEnter).use(literalReread).use(listItemBackspace).use(nestedItemEnter).use(rejoinLists).use(movedListItems).use(textInputPolicy).use(runtime.copy ? codeCopyPlugin((text) => runtime.copy?.(text)) : []).use(placeholderPlugin).use(options.rendering?.codeHighlighting === false ? [] : (await import("./highlight-C-9lbVMU.js")).highlightPlugin).use(options.rendering?.diagramPreview === false || !diagramsAvailable() ? [] : mermaidPreview(runtime.diagrams, (error) => runtime.report(error))).use(selectionPlugin).use($prose(() => search())).use(runtime.plugins.policy).use(options.wikiLinks ? wikiLinkView(options.wikiLinks, {
|
|
57237
57285
|
capture: () => runtime.capture(),
|
|
57238
57286
|
active: () => runtime.active(),
|
|
57239
57287
|
labels: {
|
|
@@ -60970,6 +61018,14 @@ var InkKitEditor = class InkKitEditor {
|
|
|
60970
61018
|
this.lastMarkdown = markdown;
|
|
60971
61019
|
view.dispatch(initialDocumentSelection(view.state));
|
|
60972
61020
|
}
|
|
61021
|
+
/** Returns every non-overlapping match without changing selection, focus or highlights. */
|
|
61022
|
+
searchMatches(text, expectedGeneration) {
|
|
61023
|
+
this.assertAlive();
|
|
61024
|
+
expectString(text, "text");
|
|
61025
|
+
this.assertCurrent(expectedGeneration);
|
|
61026
|
+
const scope = this.text.scope();
|
|
61027
|
+
return this.search.matches(text, scope.id, scope.projection);
|
|
61028
|
+
}
|
|
60973
61029
|
/** Selects the next match and returns whether there was one. */
|
|
60974
61030
|
find(text, expectedGeneration) {
|
|
60975
61031
|
this.assertAlive();
|
|
@@ -61306,6 +61362,7 @@ var InkKitEditor = class InkKitEditor {
|
|
|
61306
61362
|
"undo",
|
|
61307
61363
|
"redo",
|
|
61308
61364
|
"find",
|
|
61365
|
+
"searchMatches",
|
|
61309
61366
|
"replace",
|
|
61310
61367
|
"replaceAll",
|
|
61311
61368
|
"format",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as Decoration, c as PluginKey, d as __toESM, i as $prose, o as DecorationSet, s as Plugin, u as __commonJSMin } from "./core-
|
|
1
|
+
import { a as Decoration, c as PluginKey, d as __toESM, i as $prose, o as DecorationSet, s as Plugin, u as __commonJSMin } from "./core-CbHV2KPY.js";
|
|
2
2
|
//#region node_modules/.pnpm/highlight.js@11.11.2/node_modules/highlight.js/es/languages/arduino.js
|
|
3
3
|
/** @type LanguageFn */
|
|
4
4
|
function cPlusPlus(hljs) {
|
package/dist/core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { r as InkKitError, t as InkKitEditor } from "./chunks/core-
|
|
1
|
+
import { r as InkKitError, t as InkKitEditor } from "./chunks/core-CbHV2KPY.js";
|
|
2
2
|
export { InkKitEditor, InkKitError };
|
package/dist/editor.d.ts
CHANGED
|
@@ -371,6 +371,8 @@ export declare class InkKitEditor<F extends DocumentFormat = TextDocumentFormat>
|
|
|
371
371
|
private revealCurrentSelection;
|
|
372
372
|
private revealLiteralSelection;
|
|
373
373
|
private load;
|
|
374
|
+
/** Returns every non-overlapping match without changing selection, focus or highlights. */
|
|
375
|
+
searchMatches(text: string, expectedGeneration?: number): readonly TextRange[];
|
|
374
376
|
/** Selects the next match and returns whether there was one. */
|
|
375
377
|
find(text: string, expectedGeneration?: number): boolean;
|
|
376
378
|
/** Replaces the selected match, or the next one, and returns whether text changed. */
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as registerDiagram, r as InkKitError, t as InkKitEditor } from "./chunks/core-
|
|
1
|
+
import { n as registerDiagram, r as InkKitError, t as InkKitEditor } from "./chunks/core-CbHV2KPY.js";
|
|
2
2
|
//#region node_modules/.pnpm/dompurify@3.4.17/node_modules/dompurify/dist/purify.es.mjs
|
|
3
3
|
/*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE */
|
|
4
4
|
function _OverloadYield(e, d) {
|