@harbour-enterprises/superdoc 0.21.0-next.1 → 0.21.0-next.2
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.
- package/dist/chunks/{PdfViewer-Bn3Lvd0m.cjs → PdfViewer-1mNuyy3m.cjs} +1 -1
- package/dist/chunks/{PdfViewer-0jdn-cVx.es.js → PdfViewer-BkXBRXPs.es.js} +1 -1
- package/dist/chunks/{index-C0XOj4vH.cjs → index-BB3Qn69u.cjs} +2 -2
- package/dist/chunks/{index-BiZcP3bK.es.js → index-C-44kxYe.es.js} +2 -2
- package/dist/chunks/{super-editor.es-DQx0kzCl.es.js → super-editor.es-CKw7iZcz.es.js} +151 -89
- package/dist/chunks/{super-editor.es-BWdUsCXq.cjs → super-editor.es-Dd0joLAR.cjs} +151 -89
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-DMpIH4c0.js → converter-FESR2WO7.js} +1 -1
- package/dist/super-editor/chunks/{docx-zipper-CDrFfcVc.js → docx-zipper-BWZ2o1H5.js} +1 -1
- package/dist/super-editor/chunks/{editor-DrzPfOIy.js → editor-XsrBXzy-.js} +149 -87
- package/dist/super-editor/chunks/{toolbar-NxB-WhNb.js → toolbar-tBWlOBPh.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/src/extensions/comment/comment-import-helpers.d.ts +15 -0
- package/dist/super-editor/src/extensions/search/prosemirror-search-patched.d.ts +110 -0
- package/dist/super-editor/super-editor.es.js +6 -6
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +151 -89
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const vue = require("./vue-DWle4Cai.cjs");
|
|
4
|
-
const superdoc = require("./index-
|
|
4
|
+
const superdoc = require("./index-BB3Qn69u.cjs");
|
|
5
5
|
function self(vars) {
|
|
6
6
|
const {
|
|
7
7
|
opacityDisabled,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { m as defineComponent, B as h, O as Transition, $ as process$1, I as watchEffect, d as computed, r as ref, j as onMounted, W as onUnmounted, c as createElementBlock, o as openBlock, a as createBaseVNode, f as createCommentVNode, v as createVNode, x as unref } from "./vue-CXxsqYcP.es.js";
|
|
2
|
-
import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-
|
|
2
|
+
import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-C-44kxYe.es.js";
|
|
3
3
|
function self(vars) {
|
|
4
4
|
const {
|
|
5
5
|
opacityDisabled,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const superEditor_es = require("./super-editor.es-
|
|
2
|
+
const superEditor_es = require("./super-editor.es-Dd0joLAR.cjs");
|
|
3
3
|
const vue = require("./vue-DWle4Cai.cjs");
|
|
4
4
|
const jszip = require("./jszip-b7l8QkfH.cjs");
|
|
5
5
|
const blankDocx = require("./blank-docx-CPqX9RF5.cjs");
|
|
@@ -17409,7 +17409,7 @@ const _sfc_main = {
|
|
|
17409
17409
|
__name: "SuperDoc",
|
|
17410
17410
|
emits: ["selection-update"],
|
|
17411
17411
|
setup(__props, { emit: __emit }) {
|
|
17412
|
-
const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-
|
|
17412
|
+
const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-1mNuyy3m.cjs")));
|
|
17413
17413
|
const superdocStore = useSuperdocStore();
|
|
17414
17414
|
const commentsStore = useCommentsStore();
|
|
17415
17415
|
const {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { q as index$1, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-
|
|
1
|
+
import { q as index$1, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-CKw7iZcz.es.js";
|
|
2
2
|
import { a0 as effectScope, r as ref, _ as markRaw, $ as process$1, a1 as toRaw, d as computed, a2 as isRef, a3 as isReactive, C as toRef, i as inject, p as getCurrentInstance, l as watch, x as unref, a4 as hasInjectionContext, M as reactive, s as nextTick, a5 as getCurrentScope, a6 as onScopeDispose, a7 as toRefs, g as global$1, J as shallowRef, N as readonly, j as onMounted, k as onBeforeUnmount, h as onBeforeMount, S as onActivated, q as onDeactivated, z as createTextVNode, F as Fragment, Q as Comment, m as defineComponent, D as provide, H as withDirectives, B as h, U as Teleport, R as renderSlot, V as isVNode, I as watchEffect, O as Transition, a8 as TransitionGroup, E as mergeProps, P as vShow, G as cloneVNode, T as Text, c as createElementBlock, o as openBlock, t as toDisplayString, v as createVNode, y as withCtx, a as createBaseVNode, A as normalizeStyle, f as createCommentVNode, u as createBlock, w as withModifiers, n as normalizeClass, a9 as resolveDirective, e as renderList, b as createApp, X as resolveDynamicComponent, aa as defineAsyncComponent } from "./vue-CXxsqYcP.es.js";
|
|
3
3
|
import { B as Buffer$2 } from "./jszip-B8KIZSNe.es.js";
|
|
4
4
|
import { B as BlankDOCX } from "./blank-docx-iwdyG9RH.es.js";
|
|
@@ -17392,7 +17392,7 @@ const _sfc_main = {
|
|
|
17392
17392
|
__name: "SuperDoc",
|
|
17393
17393
|
emits: ["selection-update"],
|
|
17394
17394
|
setup(__props, { emit: __emit }) {
|
|
17395
|
-
const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-
|
|
17395
|
+
const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-BkXBRXPs.es.js"));
|
|
17396
17396
|
const superdocStore = useSuperdocStore();
|
|
17397
17397
|
const commentsStore = useCommentsStore();
|
|
17398
17398
|
const {
|
|
@@ -11384,7 +11384,7 @@ const isIOS = () => {
|
|
|
11384
11384
|
navigator.platform
|
|
11385
11385
|
);
|
|
11386
11386
|
};
|
|
11387
|
-
const isRegExp = (value) => {
|
|
11387
|
+
const isRegExp$1 = (value) => {
|
|
11388
11388
|
return Object.prototype.toString.call(value) === "[object RegExp]";
|
|
11389
11389
|
};
|
|
11390
11390
|
function objectIncludes(obj1, obj2, options = { strict: true }) {
|
|
@@ -11392,7 +11392,7 @@ function objectIncludes(obj1, obj2, options = { strict: true }) {
|
|
|
11392
11392
|
if (!keys2.length) return true;
|
|
11393
11393
|
return keys2.every((key2) => {
|
|
11394
11394
|
if (options.strict) return obj2[key2] === obj1[key2];
|
|
11395
|
-
if (isRegExp(obj2[key2])) return obj2[key2].test(obj1[key2]);
|
|
11395
|
+
if (isRegExp$1(obj2[key2])) return obj2[key2].test(obj1[key2]);
|
|
11396
11396
|
return obj2[key2] === obj1[key2];
|
|
11397
11397
|
});
|
|
11398
11398
|
}
|
|
@@ -27819,7 +27819,7 @@ const encode$d = (params2, encodedAttrs) => {
|
|
|
27819
27819
|
if (filteredMarks.length !== existingMarks2.length) {
|
|
27820
27820
|
if (filteredMarks.length) child = { ...child, marks: filteredMarks };
|
|
27821
27821
|
else {
|
|
27822
|
-
const { marks, ...rest } = child;
|
|
27822
|
+
const { marks: _removedMarks, ...rest } = child;
|
|
27823
27823
|
child = rest;
|
|
27824
27824
|
}
|
|
27825
27825
|
}
|
|
@@ -29536,7 +29536,7 @@ class InputRule {
|
|
|
29536
29536
|
}
|
|
29537
29537
|
}
|
|
29538
29538
|
const inputRuleMatcherHandler = (text, match) => {
|
|
29539
|
-
if (isRegExp(match)) {
|
|
29539
|
+
if (isRegExp$1(match)) {
|
|
29540
29540
|
return match.exec(text);
|
|
29541
29541
|
}
|
|
29542
29542
|
const inputRuleMatch = match(text);
|
|
@@ -47451,6 +47451,33 @@ const getTrackChangesDecorations = (state2, onlyOriginalShown, onlyModifiedShown
|
|
|
47451
47451
|
return DecorationSet.create(state2.doc, decorations);
|
|
47452
47452
|
};
|
|
47453
47453
|
const CommentMarkName = "commentMark";
|
|
47454
|
+
const resolveCommentMeta = ({ converter, importedId }) => {
|
|
47455
|
+
const comments = converter?.comments || [];
|
|
47456
|
+
const matchingImportedComment = comments.find((c2) => c2.importedId == importedId);
|
|
47457
|
+
const resolvedCommentId = matchingImportedComment?.commentId ?? (importedId ? String(importedId) : v4());
|
|
47458
|
+
const internal = matchingImportedComment?.internal ?? matchingImportedComment?.isInternal ?? false;
|
|
47459
|
+
return {
|
|
47460
|
+
resolvedCommentId,
|
|
47461
|
+
importedId,
|
|
47462
|
+
internal,
|
|
47463
|
+
matchingImportedComment
|
|
47464
|
+
};
|
|
47465
|
+
};
|
|
47466
|
+
const ensureFallbackComment = ({ converter, matchingImportedComment, commentId, importedId }) => {
|
|
47467
|
+
if (matchingImportedComment || !converter) return;
|
|
47468
|
+
converter.comments = converter.comments || [];
|
|
47469
|
+
const alreadyExists = converter.comments.some((comment) => comment.commentId === commentId);
|
|
47470
|
+
if (alreadyExists) return;
|
|
47471
|
+
converter.comments.push({
|
|
47472
|
+
commentId,
|
|
47473
|
+
importedId,
|
|
47474
|
+
textJson: null,
|
|
47475
|
+
creatorName: null,
|
|
47476
|
+
creatorEmail: null,
|
|
47477
|
+
createdTime: null,
|
|
47478
|
+
isDone: false
|
|
47479
|
+
});
|
|
47480
|
+
};
|
|
47454
47481
|
const removeCommentsById = ({ commentId, state: state2, tr, dispatch }) => {
|
|
47455
47482
|
const positions = getCommentPositionsById(commentId, state2.doc);
|
|
47456
47483
|
positions.forEach(({ from: from2, to }) => {
|
|
@@ -47544,24 +47571,31 @@ const prepareCommentsForImport = (doc2, tr, schema, converter) => {
|
|
|
47544
47571
|
const { type: type2 } = node;
|
|
47545
47572
|
const commentNodes = ["commentRangeStart", "commentRangeEnd", "commentReference"];
|
|
47546
47573
|
if (!commentNodes.includes(type2.name)) return;
|
|
47547
|
-
const
|
|
47548
|
-
|
|
47549
|
-
|
|
47574
|
+
const { resolvedCommentId, importedId, internal, matchingImportedComment } = resolveCommentMeta({
|
|
47575
|
+
converter,
|
|
47576
|
+
importedId: node.attrs["w:id"]
|
|
47577
|
+
});
|
|
47550
47578
|
if (type2.name === "commentRangeStart") {
|
|
47551
47579
|
toMark.push({
|
|
47552
|
-
|
|
47553
|
-
importedId
|
|
47554
|
-
internal
|
|
47580
|
+
commentId: resolvedCommentId,
|
|
47581
|
+
importedId,
|
|
47582
|
+
internal,
|
|
47555
47583
|
start: pos
|
|
47556
47584
|
});
|
|
47585
|
+
ensureFallbackComment({
|
|
47586
|
+
converter,
|
|
47587
|
+
matchingImportedComment,
|
|
47588
|
+
commentId: resolvedCommentId,
|
|
47589
|
+
importedId
|
|
47590
|
+
});
|
|
47557
47591
|
toDelete.push({ start: pos, end: pos + 1 });
|
|
47558
47592
|
} else if (type2.name === "commentRangeEnd") {
|
|
47559
|
-
const itemToMark = toMark.find((p) => p.importedId ===
|
|
47593
|
+
const itemToMark = toMark.find((p) => p.importedId === importedId);
|
|
47560
47594
|
if (!itemToMark) return;
|
|
47561
47595
|
const { start: start2 } = itemToMark;
|
|
47562
47596
|
const markAttrs = {
|
|
47563
|
-
commentId,
|
|
47564
|
-
importedId
|
|
47597
|
+
commentId: itemToMark.commentId,
|
|
47598
|
+
importedId,
|
|
47565
47599
|
internal: itemToMark.internal
|
|
47566
47600
|
};
|
|
47567
47601
|
tr.addMark(start2, pos + 1, schema.marks[CommentMarkName].create(markAttrs));
|
|
@@ -68848,8 +68882,8 @@ function getScaleFactor(element) {
|
|
|
68848
68882
|
}
|
|
68849
68883
|
class SearchQuery {
|
|
68850
68884
|
/**
|
|
68851
|
-
|
|
68852
|
-
|
|
68885
|
+
Create a query object.
|
|
68886
|
+
*/
|
|
68853
68887
|
constructor(config2) {
|
|
68854
68888
|
this.search = config2.search;
|
|
68855
68889
|
this.caseSensitive = !!config2.caseSensitive;
|
|
@@ -68862,72 +68896,70 @@ class SearchQuery {
|
|
|
68862
68896
|
this.impl = !this.valid ? nullQuery : this.regexp ? new RegExpQuery(this) : new StringQuery(this);
|
|
68863
68897
|
}
|
|
68864
68898
|
/**
|
|
68865
|
-
|
|
68866
|
-
|
|
68899
|
+
Compare this query to another query.
|
|
68900
|
+
*/
|
|
68867
68901
|
eq(other) {
|
|
68868
68902
|
return this.search == other.search && this.replace == other.replace && this.caseSensitive == other.caseSensitive && this.regexp == other.regexp && this.wholeWord == other.wholeWord;
|
|
68869
68903
|
}
|
|
68870
68904
|
/**
|
|
68871
|
-
|
|
68872
|
-
|
|
68905
|
+
Find the next occurrence of this query in the given range.
|
|
68906
|
+
*/
|
|
68873
68907
|
findNext(state2, from2 = 0, to = state2.doc.content.size) {
|
|
68874
68908
|
for (; ; ) {
|
|
68875
|
-
if (from2 >= to)
|
|
68876
|
-
return null;
|
|
68909
|
+
if (from2 >= to) return null;
|
|
68877
68910
|
let result = this.impl.findNext(state2, from2, to);
|
|
68878
|
-
if (!result || this.checkResult(state2, result))
|
|
68879
|
-
return result;
|
|
68911
|
+
if (!result || this.checkResult(state2, result)) return result;
|
|
68880
68912
|
from2 = result.from + 1;
|
|
68881
68913
|
}
|
|
68882
68914
|
}
|
|
68883
68915
|
/**
|
|
68884
|
-
|
|
68885
|
-
|
|
68886
|
-
|
|
68916
|
+
Find the previous occurrence of this query in the given range.
|
|
68917
|
+
Note that, if `to` is given, it should be _less_ than `from`.
|
|
68918
|
+
*/
|
|
68887
68919
|
findPrev(state2, from2 = state2.doc.content.size, to = 0) {
|
|
68888
68920
|
for (; ; ) {
|
|
68889
|
-
if (from2 <= to)
|
|
68890
|
-
return null;
|
|
68921
|
+
if (from2 <= to) return null;
|
|
68891
68922
|
let result = this.impl.findPrev(state2, from2, to);
|
|
68892
|
-
if (!result || this.checkResult(state2, result))
|
|
68893
|
-
return result;
|
|
68923
|
+
if (!result || this.checkResult(state2, result)) return result;
|
|
68894
68924
|
from2 = result.to - 1;
|
|
68895
68925
|
}
|
|
68896
68926
|
}
|
|
68897
68927
|
/**
|
|
68898
|
-
|
|
68899
|
-
|
|
68928
|
+
@internal
|
|
68929
|
+
*/
|
|
68900
68930
|
checkResult(state2, result) {
|
|
68901
68931
|
return (!this.wholeWord || checkWordBoundary(state2, result.from) && checkWordBoundary(state2, result.to)) && (!this.filter || this.filter(state2, result));
|
|
68902
68932
|
}
|
|
68903
68933
|
/**
|
|
68904
|
-
|
|
68905
|
-
|
|
68934
|
+
@internal
|
|
68935
|
+
*/
|
|
68906
68936
|
unquote(string) {
|
|
68907
68937
|
return this.literal ? string : string.replace(/\\([nrt\\])/g, (_2, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? " " : "\\");
|
|
68908
68938
|
}
|
|
68909
68939
|
/**
|
|
68910
|
-
|
|
68911
|
-
|
|
68912
|
-
|
|
68913
|
-
|
|
68914
|
-
|
|
68915
|
-
|
|
68916
|
-
|
|
68917
|
-
|
|
68918
|
-
|
|
68919
|
-
|
|
68940
|
+
Get the ranges that should be replaced for this result. This can
|
|
68941
|
+
return multiple ranges when `this.replace` contains
|
|
68942
|
+
`$1`/`$&`-style placeholders, in which case the preserved
|
|
68943
|
+
content is skipped by the replacements.
|
|
68944
|
+
|
|
68945
|
+
Ranges are sorted by position, and `from`/`to` positions all
|
|
68946
|
+
refer to positions in `state.doc`. When applying these, you'll
|
|
68947
|
+
want to either apply them from back to front, or map these
|
|
68948
|
+
positions through your transaction's current mapping.
|
|
68949
|
+
*/
|
|
68920
68950
|
getReplacements(state2, result) {
|
|
68921
68951
|
let $from = state2.doc.resolve(result.from);
|
|
68922
68952
|
let marks = $from.marksAcross(state2.doc.resolve(result.to));
|
|
68923
68953
|
let ranges = [];
|
|
68924
68954
|
let frag = Fragment.empty, pos = result.from, { match } = result;
|
|
68925
68955
|
let groups = match ? getGroupIndices(match) : [[0, result.to - result.from]];
|
|
68926
|
-
let replParts = parseReplacement(this.unquote(this.replace))
|
|
68956
|
+
let replParts = parseReplacement(this.unquote(this.replace));
|
|
68927
68957
|
for (let part of replParts) {
|
|
68928
68958
|
if (typeof part == "string") {
|
|
68929
68959
|
frag = frag.addToEnd(state2.schema.text(part, marks));
|
|
68930
|
-
} else
|
|
68960
|
+
} else {
|
|
68961
|
+
const groupSpan = groups[part.group];
|
|
68962
|
+
if (!groupSpan) continue;
|
|
68931
68963
|
let from2 = result.matchStart + groupSpan[0], to = result.matchStart + groupSpan[1];
|
|
68932
68964
|
if (part.copy) {
|
|
68933
68965
|
frag = frag.append(state2.doc.slice(from2, to).content);
|
|
@@ -68957,8 +68989,7 @@ class StringQuery {
|
|
|
68957
68989
|
constructor(query) {
|
|
68958
68990
|
this.query = query;
|
|
68959
68991
|
let string = query.unquote(query.search);
|
|
68960
|
-
if (!query.caseSensitive)
|
|
68961
|
-
string = string.toLowerCase();
|
|
68992
|
+
if (!query.caseSensitive) string = string.toLowerCase();
|
|
68962
68993
|
this.string = string;
|
|
68963
68994
|
}
|
|
68964
68995
|
findNext(state2, from2, to) {
|
|
@@ -68966,17 +68997,26 @@ class StringQuery {
|
|
|
68966
68997
|
let off2 = Math.max(from2, start2);
|
|
68967
68998
|
let content = textContent(node).slice(off2 - start2, Math.min(node.content.size, to - start2));
|
|
68968
68999
|
let index2 = (this.query.caseSensitive ? content : content.toLowerCase()).indexOf(this.string);
|
|
68969
|
-
|
|
69000
|
+
if (index2 < 0) return null;
|
|
69001
|
+
const startOffset = off2 - start2;
|
|
69002
|
+
const absoluteIndex = startOffset + index2;
|
|
69003
|
+
const fromPos = mapIndexToDocPos(node, start2, absoluteIndex);
|
|
69004
|
+
const toPos = mapIndexToDocPos(node, start2, absoluteIndex + this.string.length);
|
|
69005
|
+
return { from: fromPos, to: toPos, match: null, matchStart: start2 };
|
|
68970
69006
|
});
|
|
68971
69007
|
}
|
|
68972
69008
|
findPrev(state2, from2, to) {
|
|
68973
69009
|
return scanTextblocks(state2.doc, from2, to, (node, start2) => {
|
|
68974
69010
|
let off2 = Math.max(start2, to);
|
|
68975
69011
|
let content = textContent(node).slice(off2 - start2, Math.min(node.content.size, from2 - start2));
|
|
68976
|
-
if (!this.query.caseSensitive)
|
|
68977
|
-
content = content.toLowerCase();
|
|
69012
|
+
if (!this.query.caseSensitive) content = content.toLowerCase();
|
|
68978
69013
|
let index2 = content.lastIndexOf(this.string);
|
|
68979
|
-
|
|
69014
|
+
if (index2 < 0) return null;
|
|
69015
|
+
const startOffset = off2 - start2;
|
|
69016
|
+
const absoluteIndex = startOffset + index2;
|
|
69017
|
+
const fromPos = mapIndexToDocPos(node, start2, absoluteIndex);
|
|
69018
|
+
const toPos = mapIndexToDocPos(node, start2, absoluteIndex + this.string.length);
|
|
69019
|
+
return { from: fromPos, to: toPos, match: null, matchStart: start2 };
|
|
68980
69020
|
});
|
|
68981
69021
|
}
|
|
68982
69022
|
}
|
|
@@ -68991,7 +69031,11 @@ class RegExpQuery {
|
|
|
68991
69031
|
let content = textContent(node).slice(0, Math.min(node.content.size, to - start2));
|
|
68992
69032
|
this.regexp.lastIndex = from2 - start2;
|
|
68993
69033
|
let match = this.regexp.exec(content);
|
|
68994
|
-
|
|
69034
|
+
if (!match) return null;
|
|
69035
|
+
const absoluteIndex = match.index;
|
|
69036
|
+
const fromPos = mapIndexToDocPos(node, start2, absoluteIndex);
|
|
69037
|
+
const toPos = mapIndexToDocPos(node, start2, absoluteIndex + match[0].length);
|
|
69038
|
+
return { from: fromPos, to: toPos, match, matchStart: start2 };
|
|
68995
69039
|
});
|
|
68996
69040
|
}
|
|
68997
69041
|
findPrev(state2, from2, to) {
|
|
@@ -69001,18 +69045,20 @@ class RegExpQuery {
|
|
|
69001
69045
|
for (let off2 = 0; ; ) {
|
|
69002
69046
|
this.regexp.lastIndex = off2;
|
|
69003
69047
|
let next = this.regexp.exec(content);
|
|
69004
|
-
if (!next)
|
|
69005
|
-
break;
|
|
69048
|
+
if (!next) break;
|
|
69006
69049
|
match = next;
|
|
69007
69050
|
off2 = next.index + 1;
|
|
69008
69051
|
}
|
|
69009
|
-
|
|
69052
|
+
if (!match) return null;
|
|
69053
|
+
const absoluteIndex = match.index;
|
|
69054
|
+
const fromPos = mapIndexToDocPos(node, start2, absoluteIndex);
|
|
69055
|
+
const toPos = mapIndexToDocPos(node, start2, absoluteIndex + match[0].length);
|
|
69056
|
+
return { from: fromPos, to: toPos, match, matchStart: start2 };
|
|
69010
69057
|
});
|
|
69011
69058
|
}
|
|
69012
69059
|
}
|
|
69013
69060
|
function getGroupIndices(match) {
|
|
69014
|
-
if (match.indices)
|
|
69015
|
-
return match.indices;
|
|
69061
|
+
if (match.indices) return match.indices;
|
|
69016
69062
|
let result = [[0, match[0].length]];
|
|
69017
69063
|
for (let i = 1, pos = 0; i < match.length; i++) {
|
|
69018
69064
|
let found2 = match[i] ? match[0].indexOf(match[i], pos) : -1;
|
|
@@ -69024,10 +69070,8 @@ function parseReplacement(text) {
|
|
|
69024
69070
|
let result = [], highestSeen = -1;
|
|
69025
69071
|
function add(text2) {
|
|
69026
69072
|
let last = result.length - 1;
|
|
69027
|
-
if (last > -1 && typeof result[last] == "string")
|
|
69028
|
-
|
|
69029
|
-
else
|
|
69030
|
-
result.push(text2);
|
|
69073
|
+
if (last > -1 && typeof result[last] == "string") result[last] += text2;
|
|
69074
|
+
else result.push(text2);
|
|
69031
69075
|
}
|
|
69032
69076
|
while (text.length) {
|
|
69033
69077
|
let m2 = /\$([$&\d+])/.exec(text);
|
|
@@ -69035,8 +69079,7 @@ function parseReplacement(text) {
|
|
|
69035
69079
|
add(text);
|
|
69036
69080
|
return result;
|
|
69037
69081
|
}
|
|
69038
|
-
if (m2.index > 0)
|
|
69039
|
-
add(text.slice(0, m2.index + (m2[1] == "$" ? 1 : 0)));
|
|
69082
|
+
if (m2.index > 0) add(text.slice(0, m2.index + (m2[1] == "$" ? 1 : 0)));
|
|
69040
69083
|
if (m2[1] != "$") {
|
|
69041
69084
|
let n = m2[1] == "&" ? 0 : +m2[1];
|
|
69042
69085
|
if (highestSeen >= n) {
|
|
@@ -69054,30 +69097,50 @@ function validRegExp(source) {
|
|
|
69054
69097
|
try {
|
|
69055
69098
|
new RegExp(source, baseFlags);
|
|
69056
69099
|
return true;
|
|
69057
|
-
} catch
|
|
69100
|
+
} catch {
|
|
69058
69101
|
return false;
|
|
69059
69102
|
}
|
|
69060
69103
|
}
|
|
69061
69104
|
const TextContentCache = /* @__PURE__ */ new WeakMap();
|
|
69062
69105
|
function textContent(node) {
|
|
69063
69106
|
let cached = TextContentCache.get(node);
|
|
69064
|
-
if (cached)
|
|
69065
|
-
return cached;
|
|
69107
|
+
if (cached) return cached;
|
|
69066
69108
|
let content = "";
|
|
69067
69109
|
for (let i = 0; i < node.childCount; i++) {
|
|
69068
69110
|
let child = node.child(i);
|
|
69069
|
-
if (child.isText)
|
|
69070
|
-
|
|
69071
|
-
else if (child.
|
|
69072
|
-
|
|
69073
|
-
else
|
|
69074
|
-
content += " " + textContent(child) + " ";
|
|
69111
|
+
if (child.isText) content += child.text;
|
|
69112
|
+
else if (child.isLeaf) content += "";
|
|
69113
|
+
else if (child.type && child.type.name === "run") content += textContent(child);
|
|
69114
|
+
else content += " " + textContent(child) + " ";
|
|
69075
69115
|
}
|
|
69076
69116
|
TextContentCache.set(node, content);
|
|
69077
69117
|
return content;
|
|
69078
69118
|
}
|
|
69119
|
+
function mapIndexToDocPos(node, start2, index2) {
|
|
69120
|
+
if (index2 <= 0) return start2;
|
|
69121
|
+
const fullText = textContent(node);
|
|
69122
|
+
if (index2 >= fullText.length) return start2 + node.content.size;
|
|
69123
|
+
let target = start2;
|
|
69124
|
+
let remaining = index2;
|
|
69125
|
+
let found2 = false;
|
|
69126
|
+
node.descendants((child, pos) => {
|
|
69127
|
+
if (found2) return false;
|
|
69128
|
+
if (!child.isText) return true;
|
|
69129
|
+
const len = child.text.length;
|
|
69130
|
+
if (remaining <= len) {
|
|
69131
|
+
target = start2 + pos + remaining;
|
|
69132
|
+
found2 = true;
|
|
69133
|
+
return false;
|
|
69134
|
+
}
|
|
69135
|
+
remaining -= len;
|
|
69136
|
+
return true;
|
|
69137
|
+
});
|
|
69138
|
+
return found2 ? target : start2 + node.content.size;
|
|
69139
|
+
}
|
|
69140
|
+
const transparentInlineNodes = /* @__PURE__ */ new Set(["run"]);
|
|
69079
69141
|
function scanTextblocks(node, from2, to, f, nodeStart = 0) {
|
|
69080
|
-
|
|
69142
|
+
const isTransparentInline = node.inlineContent && node.type && transparentInlineNodes.has(node.type.name);
|
|
69143
|
+
if (node.inlineContent && !isTransparentInline) {
|
|
69081
69144
|
return f(node, nodeStart);
|
|
69082
69145
|
} else if (!node.isLeaf) {
|
|
69083
69146
|
if (from2 > to) {
|
|
@@ -69086,8 +69149,7 @@ function scanTextblocks(node, from2, to, f, nodeStart = 0) {
|
|
|
69086
69149
|
pos -= child.nodeSize;
|
|
69087
69150
|
if (pos < from2) {
|
|
69088
69151
|
let result = scanTextblocks(child, from2, to, f, pos + 1);
|
|
69089
|
-
if (result != null)
|
|
69090
|
-
return result;
|
|
69152
|
+
if (result != null) return result;
|
|
69091
69153
|
}
|
|
69092
69154
|
}
|
|
69093
69155
|
} else {
|
|
@@ -69096,8 +69158,7 @@ function scanTextblocks(node, from2, to, f, nodeStart = 0) {
|
|
|
69096
69158
|
pos += child.nodeSize;
|
|
69097
69159
|
if (pos > from2) {
|
|
69098
69160
|
let result = scanTextblocks(child, from2, to, f, start2 + 1);
|
|
69099
|
-
if (result != null)
|
|
69100
|
-
return result;
|
|
69161
|
+
if (result != null) return result;
|
|
69101
69162
|
}
|
|
69102
69163
|
}
|
|
69103
69164
|
}
|
|
@@ -69107,8 +69168,7 @@ function scanTextblocks(node, from2, to, f, nodeStart = 0) {
|
|
|
69107
69168
|
function checkWordBoundary(state2, pos) {
|
|
69108
69169
|
let $pos = state2.doc.resolve(pos);
|
|
69109
69170
|
let before = $pos.nodeBefore, after = $pos.nodeAfter;
|
|
69110
|
-
if (!before || !after || !before.isText || !after.isText)
|
|
69111
|
-
return true;
|
|
69171
|
+
if (!before || !after || !before.isText || !after.isText) return true;
|
|
69112
69172
|
return !/\p{L}$/u.test(before.text) || !/^\p{L}/u.test(after.text);
|
|
69113
69173
|
}
|
|
69114
69174
|
class SearchState {
|
|
@@ -69119,14 +69179,12 @@ class SearchState {
|
|
|
69119
69179
|
}
|
|
69120
69180
|
}
|
|
69121
69181
|
function buildMatchDeco(state2, query, range2) {
|
|
69122
|
-
if (!query.valid)
|
|
69123
|
-
return DecorationSet.empty;
|
|
69182
|
+
if (!query.valid) return DecorationSet.empty;
|
|
69124
69183
|
let deco = [];
|
|
69125
69184
|
let sel = state2.selection;
|
|
69126
69185
|
for (let pos = range2 ? range2.from : 0, end2 = range2 ? range2.to : state2.doc.content.size; ; ) {
|
|
69127
69186
|
let next = query.findNext(state2, pos, end2);
|
|
69128
|
-
if (!next)
|
|
69129
|
-
break;
|
|
69187
|
+
if (!next) break;
|
|
69130
69188
|
let cls = next.from == sel.from && next.to == sel.to ? "ProseMirror-active-search-match" : "ProseMirror-search-match";
|
|
69131
69189
|
deco.push(Decoration.inline(next.from, next.to, { class: cls }));
|
|
69132
69190
|
pos = next.to;
|
|
@@ -69145,8 +69203,7 @@ function search(options = {}) {
|
|
|
69145
69203
|
},
|
|
69146
69204
|
apply(tr, search2, _oldState, state2) {
|
|
69147
69205
|
let set = tr.getMeta(searchKey);
|
|
69148
|
-
if (set)
|
|
69149
|
-
return new SearchState(set.query, set.range, buildMatchDeco(state2, set.query, set.range));
|
|
69206
|
+
if (set) return new SearchState(set.query, set.range, buildMatchDeco(state2, set.query, set.range));
|
|
69150
69207
|
if (tr.docChanged || tr.selectionSet) {
|
|
69151
69208
|
let range2 = search2.range;
|
|
69152
69209
|
if (range2) {
|
|
@@ -69171,6 +69228,7 @@ function getMatchHighlights(state2) {
|
|
|
69171
69228
|
function setSearchState(tr, query, range2 = null) {
|
|
69172
69229
|
return tr.setMeta(searchKey, { query, range: range2 });
|
|
69173
69230
|
}
|
|
69231
|
+
const isRegExp = (value) => Object.prototype.toString.call(value) === "[object RegExp]";
|
|
69174
69232
|
const Search = Extension.create({
|
|
69175
69233
|
addStorage() {
|
|
69176
69234
|
return {
|
|
@@ -69240,10 +69298,14 @@ const Search = Extension.create({
|
|
|
69240
69298
|
let caseSensitive = false;
|
|
69241
69299
|
let regexp = false;
|
|
69242
69300
|
const wholeWord = false;
|
|
69243
|
-
if (patternInput
|
|
69301
|
+
if (isRegExp(patternInput)) {
|
|
69302
|
+
const regexPattern = (
|
|
69303
|
+
/** @type {RegExp} */
|
|
69304
|
+
patternInput
|
|
69305
|
+
);
|
|
69244
69306
|
regexp = true;
|
|
69245
|
-
pattern =
|
|
69246
|
-
caseSensitive = !
|
|
69307
|
+
pattern = regexPattern.source;
|
|
69308
|
+
caseSensitive = !regexPattern.flags.includes("i");
|
|
69247
69309
|
} else if (typeof patternInput === "string" && /^\/(.+)\/([gimsuy]*)$/.test(patternInput)) {
|
|
69248
69310
|
const [, body, flags] = patternInput.match(/^\/(.+)\/([gimsuy]*)$/);
|
|
69249
69311
|
regexp = true;
|