@harbour-enterprises/superdoc 0.21.0-next.1 → 0.21.0-next.3
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-0jdn-cVx.es.js → PdfViewer-D3zo7tPo.es.js} +1 -1
- package/dist/chunks/{PdfViewer-Bn3Lvd0m.cjs → PdfViewer-OZDJ7gwT.cjs} +1 -1
- package/dist/chunks/{index-C0XOj4vH.cjs → index-CfYf4T_z.cjs} +2 -2
- package/dist/chunks/{index-BiZcP3bK.es.js → index-MzW5BVNd.es.js} +2 -2
- package/dist/chunks/{super-editor.es-DQx0kzCl.es.js → super-editor.es-Bntob7Wd.es.js} +163 -101
- package/dist/chunks/{super-editor.es-BWdUsCXq.cjs → super-editor.es-U-GVCd_F.cjs} +163 -101
- package/dist/core/SuperDoc.d.ts +21 -569
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/core/types/index.d.ts +396 -0
- package/dist/core/types/index.d.ts.map +1 -0
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-DMpIH4c0.js → converter-3xnF_NHq.js} +13 -13
- package/dist/super-editor/chunks/{docx-zipper-CDrFfcVc.js → docx-zipper-CZdELYi-.js} +1 -1
- package/dist/super-editor/chunks/{editor-DrzPfOIy.js → editor-BqYH4kDD.js} +149 -87
- package/dist/super-editor/chunks/{toolbar-NxB-WhNb.js → toolbar-TkaE2kKM.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 +163 -101
- package/dist/superdoc.umd.js.map +1 -1
- package/npm-deprecation-notice.cjs +1 -9
- package/package.json +1 -1
|
@@ -11401,7 +11401,7 @@ const isIOS = () => {
|
|
|
11401
11401
|
navigator.platform
|
|
11402
11402
|
);
|
|
11403
11403
|
};
|
|
11404
|
-
const isRegExp = (value) => {
|
|
11404
|
+
const isRegExp$1 = (value) => {
|
|
11405
11405
|
return Object.prototype.toString.call(value) === "[object RegExp]";
|
|
11406
11406
|
};
|
|
11407
11407
|
function objectIncludes(obj1, obj2, options = { strict: true }) {
|
|
@@ -11409,7 +11409,7 @@ function objectIncludes(obj1, obj2, options = { strict: true }) {
|
|
|
11409
11409
|
if (!keys2.length) return true;
|
|
11410
11410
|
return keys2.every((key2) => {
|
|
11411
11411
|
if (options.strict) return obj2[key2] === obj1[key2];
|
|
11412
|
-
if (isRegExp(obj2[key2])) return obj2[key2].test(obj1[key2]);
|
|
11412
|
+
if (isRegExp$1(obj2[key2])) return obj2[key2].test(obj1[key2]);
|
|
11413
11413
|
return obj2[key2] === obj1[key2];
|
|
11414
11414
|
});
|
|
11415
11415
|
}
|
|
@@ -24213,18 +24213,6 @@ const baseNumbering = {
|
|
|
24213
24213
|
}
|
|
24214
24214
|
]
|
|
24215
24215
|
};
|
|
24216
|
-
const sanitizeDocxMediaName = (value, fallback = "image") => {
|
|
24217
|
-
if (!value) return fallback;
|
|
24218
|
-
const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
24219
|
-
return sanitized || fallback;
|
|
24220
|
-
};
|
|
24221
|
-
const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
|
|
24222
|
-
if (!src || typeof src !== "string") return fallback;
|
|
24223
|
-
const [prefix2] = src.split(";");
|
|
24224
|
-
const [, maybeType] = prefix2.split("/");
|
|
24225
|
-
const extension = maybeType?.toLowerCase();
|
|
24226
|
-
return extension ? `${fallback}.${extension}` : fallback;
|
|
24227
|
-
};
|
|
24228
24216
|
const TranslatorTypes = Object.freeze({
|
|
24229
24217
|
NODE: "node",
|
|
24230
24218
|
ATTRIBUTE: "attribute"
|
|
@@ -27836,7 +27824,7 @@ const encode$d = (params2, encodedAttrs) => {
|
|
|
27836
27824
|
if (filteredMarks.length !== existingMarks2.length) {
|
|
27837
27825
|
if (filteredMarks.length) child = { ...child, marks: filteredMarks };
|
|
27838
27826
|
else {
|
|
27839
|
-
const { marks, ...rest } = child;
|
|
27827
|
+
const { marks: _removedMarks, ...rest } = child;
|
|
27840
27828
|
child = rest;
|
|
27841
27829
|
}
|
|
27842
27830
|
}
|
|
@@ -28346,6 +28334,18 @@ function handleAnchorNode(params2) {
|
|
|
28346
28334
|
}
|
|
28347
28335
|
return handleImageNode(node, params2, true);
|
|
28348
28336
|
}
|
|
28337
|
+
const sanitizeDocxMediaName = (value, fallback = "image") => {
|
|
28338
|
+
if (!value) return fallback;
|
|
28339
|
+
const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
28340
|
+
return sanitized || fallback;
|
|
28341
|
+
};
|
|
28342
|
+
const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
|
|
28343
|
+
if (!src || typeof src !== "string") return fallback;
|
|
28344
|
+
const [prefix2] = src.split(";");
|
|
28345
|
+
const [, maybeType] = prefix2.split("/");
|
|
28346
|
+
const extension = maybeType?.toLowerCase();
|
|
28347
|
+
return extension ? `${fallback}.${extension}` : fallback;
|
|
28348
|
+
};
|
|
28349
28349
|
const translateImageNode = (params2) => {
|
|
28350
28350
|
const {
|
|
28351
28351
|
node: { attrs = {} },
|
|
@@ -29553,7 +29553,7 @@ class InputRule {
|
|
|
29553
29553
|
}
|
|
29554
29554
|
}
|
|
29555
29555
|
const inputRuleMatcherHandler = (text, match) => {
|
|
29556
|
-
if (isRegExp(match)) {
|
|
29556
|
+
if (isRegExp$1(match)) {
|
|
29557
29557
|
return match.exec(text);
|
|
29558
29558
|
}
|
|
29559
29559
|
const inputRuleMatch = match(text);
|
|
@@ -47468,6 +47468,33 @@ const getTrackChangesDecorations = (state2, onlyOriginalShown, onlyModifiedShown
|
|
|
47468
47468
|
return DecorationSet.create(state2.doc, decorations);
|
|
47469
47469
|
};
|
|
47470
47470
|
const CommentMarkName = "commentMark";
|
|
47471
|
+
const resolveCommentMeta = ({ converter, importedId }) => {
|
|
47472
|
+
const comments = converter?.comments || [];
|
|
47473
|
+
const matchingImportedComment = comments.find((c2) => c2.importedId == importedId);
|
|
47474
|
+
const resolvedCommentId = matchingImportedComment?.commentId ?? (importedId ? String(importedId) : v4());
|
|
47475
|
+
const internal = matchingImportedComment?.internal ?? matchingImportedComment?.isInternal ?? false;
|
|
47476
|
+
return {
|
|
47477
|
+
resolvedCommentId,
|
|
47478
|
+
importedId,
|
|
47479
|
+
internal,
|
|
47480
|
+
matchingImportedComment
|
|
47481
|
+
};
|
|
47482
|
+
};
|
|
47483
|
+
const ensureFallbackComment = ({ converter, matchingImportedComment, commentId, importedId }) => {
|
|
47484
|
+
if (matchingImportedComment || !converter) return;
|
|
47485
|
+
converter.comments = converter.comments || [];
|
|
47486
|
+
const alreadyExists = converter.comments.some((comment) => comment.commentId === commentId);
|
|
47487
|
+
if (alreadyExists) return;
|
|
47488
|
+
converter.comments.push({
|
|
47489
|
+
commentId,
|
|
47490
|
+
importedId,
|
|
47491
|
+
textJson: null,
|
|
47492
|
+
creatorName: null,
|
|
47493
|
+
creatorEmail: null,
|
|
47494
|
+
createdTime: null,
|
|
47495
|
+
isDone: false
|
|
47496
|
+
});
|
|
47497
|
+
};
|
|
47471
47498
|
const removeCommentsById = ({ commentId, state: state2, tr, dispatch }) => {
|
|
47472
47499
|
const positions = getCommentPositionsById(commentId, state2.doc);
|
|
47473
47500
|
positions.forEach(({ from: from2, to }) => {
|
|
@@ -47561,24 +47588,31 @@ const prepareCommentsForImport = (doc2, tr, schema, converter) => {
|
|
|
47561
47588
|
const { type: type2 } = node;
|
|
47562
47589
|
const commentNodes = ["commentRangeStart", "commentRangeEnd", "commentReference"];
|
|
47563
47590
|
if (!commentNodes.includes(type2.name)) return;
|
|
47564
|
-
const
|
|
47565
|
-
|
|
47566
|
-
|
|
47591
|
+
const { resolvedCommentId, importedId, internal, matchingImportedComment } = resolveCommentMeta({
|
|
47592
|
+
converter,
|
|
47593
|
+
importedId: node.attrs["w:id"]
|
|
47594
|
+
});
|
|
47567
47595
|
if (type2.name === "commentRangeStart") {
|
|
47568
47596
|
toMark.push({
|
|
47569
|
-
|
|
47570
|
-
importedId
|
|
47571
|
-
internal
|
|
47597
|
+
commentId: resolvedCommentId,
|
|
47598
|
+
importedId,
|
|
47599
|
+
internal,
|
|
47572
47600
|
start: pos
|
|
47573
47601
|
});
|
|
47602
|
+
ensureFallbackComment({
|
|
47603
|
+
converter,
|
|
47604
|
+
matchingImportedComment,
|
|
47605
|
+
commentId: resolvedCommentId,
|
|
47606
|
+
importedId
|
|
47607
|
+
});
|
|
47574
47608
|
toDelete.push({ start: pos, end: pos + 1 });
|
|
47575
47609
|
} else if (type2.name === "commentRangeEnd") {
|
|
47576
|
-
const itemToMark = toMark.find((p) => p.importedId ===
|
|
47610
|
+
const itemToMark = toMark.find((p) => p.importedId === importedId);
|
|
47577
47611
|
if (!itemToMark) return;
|
|
47578
47612
|
const { start: start2 } = itemToMark;
|
|
47579
47613
|
const markAttrs = {
|
|
47580
|
-
commentId,
|
|
47581
|
-
importedId
|
|
47614
|
+
commentId: itemToMark.commentId,
|
|
47615
|
+
importedId,
|
|
47582
47616
|
internal: itemToMark.internal
|
|
47583
47617
|
};
|
|
47584
47618
|
tr.addMark(start2, pos + 1, schema.marks[CommentMarkName].create(markAttrs));
|
|
@@ -68865,8 +68899,8 @@ function getScaleFactor(element) {
|
|
|
68865
68899
|
}
|
|
68866
68900
|
class SearchQuery {
|
|
68867
68901
|
/**
|
|
68868
|
-
|
|
68869
|
-
|
|
68902
|
+
Create a query object.
|
|
68903
|
+
*/
|
|
68870
68904
|
constructor(config2) {
|
|
68871
68905
|
this.search = config2.search;
|
|
68872
68906
|
this.caseSensitive = !!config2.caseSensitive;
|
|
@@ -68879,72 +68913,70 @@ class SearchQuery {
|
|
|
68879
68913
|
this.impl = !this.valid ? nullQuery : this.regexp ? new RegExpQuery(this) : new StringQuery(this);
|
|
68880
68914
|
}
|
|
68881
68915
|
/**
|
|
68882
|
-
|
|
68883
|
-
|
|
68916
|
+
Compare this query to another query.
|
|
68917
|
+
*/
|
|
68884
68918
|
eq(other) {
|
|
68885
68919
|
return this.search == other.search && this.replace == other.replace && this.caseSensitive == other.caseSensitive && this.regexp == other.regexp && this.wholeWord == other.wholeWord;
|
|
68886
68920
|
}
|
|
68887
68921
|
/**
|
|
68888
|
-
|
|
68889
|
-
|
|
68922
|
+
Find the next occurrence of this query in the given range.
|
|
68923
|
+
*/
|
|
68890
68924
|
findNext(state2, from2 = 0, to = state2.doc.content.size) {
|
|
68891
68925
|
for (; ; ) {
|
|
68892
|
-
if (from2 >= to)
|
|
68893
|
-
return null;
|
|
68926
|
+
if (from2 >= to) return null;
|
|
68894
68927
|
let result = this.impl.findNext(state2, from2, to);
|
|
68895
|
-
if (!result || this.checkResult(state2, result))
|
|
68896
|
-
return result;
|
|
68928
|
+
if (!result || this.checkResult(state2, result)) return result;
|
|
68897
68929
|
from2 = result.from + 1;
|
|
68898
68930
|
}
|
|
68899
68931
|
}
|
|
68900
68932
|
/**
|
|
68901
|
-
|
|
68902
|
-
|
|
68903
|
-
|
|
68933
|
+
Find the previous occurrence of this query in the given range.
|
|
68934
|
+
Note that, if `to` is given, it should be _less_ than `from`.
|
|
68935
|
+
*/
|
|
68904
68936
|
findPrev(state2, from2 = state2.doc.content.size, to = 0) {
|
|
68905
68937
|
for (; ; ) {
|
|
68906
|
-
if (from2 <= to)
|
|
68907
|
-
return null;
|
|
68938
|
+
if (from2 <= to) return null;
|
|
68908
68939
|
let result = this.impl.findPrev(state2, from2, to);
|
|
68909
|
-
if (!result || this.checkResult(state2, result))
|
|
68910
|
-
return result;
|
|
68940
|
+
if (!result || this.checkResult(state2, result)) return result;
|
|
68911
68941
|
from2 = result.to - 1;
|
|
68912
68942
|
}
|
|
68913
68943
|
}
|
|
68914
68944
|
/**
|
|
68915
|
-
|
|
68916
|
-
|
|
68945
|
+
@internal
|
|
68946
|
+
*/
|
|
68917
68947
|
checkResult(state2, result) {
|
|
68918
68948
|
return (!this.wholeWord || checkWordBoundary(state2, result.from) && checkWordBoundary(state2, result.to)) && (!this.filter || this.filter(state2, result));
|
|
68919
68949
|
}
|
|
68920
68950
|
/**
|
|
68921
|
-
|
|
68922
|
-
|
|
68951
|
+
@internal
|
|
68952
|
+
*/
|
|
68923
68953
|
unquote(string) {
|
|
68924
68954
|
return this.literal ? string : string.replace(/\\([nrt\\])/g, (_2, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? " " : "\\");
|
|
68925
68955
|
}
|
|
68926
68956
|
/**
|
|
68927
|
-
|
|
68928
|
-
|
|
68929
|
-
|
|
68930
|
-
|
|
68931
|
-
|
|
68932
|
-
|
|
68933
|
-
|
|
68934
|
-
|
|
68935
|
-
|
|
68936
|
-
|
|
68957
|
+
Get the ranges that should be replaced for this result. This can
|
|
68958
|
+
return multiple ranges when `this.replace` contains
|
|
68959
|
+
`$1`/`$&`-style placeholders, in which case the preserved
|
|
68960
|
+
content is skipped by the replacements.
|
|
68961
|
+
|
|
68962
|
+
Ranges are sorted by position, and `from`/`to` positions all
|
|
68963
|
+
refer to positions in `state.doc`. When applying these, you'll
|
|
68964
|
+
want to either apply them from back to front, or map these
|
|
68965
|
+
positions through your transaction's current mapping.
|
|
68966
|
+
*/
|
|
68937
68967
|
getReplacements(state2, result) {
|
|
68938
68968
|
let $from = state2.doc.resolve(result.from);
|
|
68939
68969
|
let marks = $from.marksAcross(state2.doc.resolve(result.to));
|
|
68940
68970
|
let ranges = [];
|
|
68941
68971
|
let frag = Fragment.empty, pos = result.from, { match } = result;
|
|
68942
68972
|
let groups = match ? getGroupIndices(match) : [[0, result.to - result.from]];
|
|
68943
|
-
let replParts = parseReplacement(this.unquote(this.replace))
|
|
68973
|
+
let replParts = parseReplacement(this.unquote(this.replace));
|
|
68944
68974
|
for (let part of replParts) {
|
|
68945
68975
|
if (typeof part == "string") {
|
|
68946
68976
|
frag = frag.addToEnd(state2.schema.text(part, marks));
|
|
68947
|
-
} else
|
|
68977
|
+
} else {
|
|
68978
|
+
const groupSpan = groups[part.group];
|
|
68979
|
+
if (!groupSpan) continue;
|
|
68948
68980
|
let from2 = result.matchStart + groupSpan[0], to = result.matchStart + groupSpan[1];
|
|
68949
68981
|
if (part.copy) {
|
|
68950
68982
|
frag = frag.append(state2.doc.slice(from2, to).content);
|
|
@@ -68974,8 +69006,7 @@ class StringQuery {
|
|
|
68974
69006
|
constructor(query) {
|
|
68975
69007
|
this.query = query;
|
|
68976
69008
|
let string = query.unquote(query.search);
|
|
68977
|
-
if (!query.caseSensitive)
|
|
68978
|
-
string = string.toLowerCase();
|
|
69009
|
+
if (!query.caseSensitive) string = string.toLowerCase();
|
|
68979
69010
|
this.string = string;
|
|
68980
69011
|
}
|
|
68981
69012
|
findNext(state2, from2, to) {
|
|
@@ -68983,17 +69014,26 @@ class StringQuery {
|
|
|
68983
69014
|
let off2 = Math.max(from2, start2);
|
|
68984
69015
|
let content = textContent(node).slice(off2 - start2, Math.min(node.content.size, to - start2));
|
|
68985
69016
|
let index2 = (this.query.caseSensitive ? content : content.toLowerCase()).indexOf(this.string);
|
|
68986
|
-
|
|
69017
|
+
if (index2 < 0) return null;
|
|
69018
|
+
const startOffset = off2 - start2;
|
|
69019
|
+
const absoluteIndex = startOffset + index2;
|
|
69020
|
+
const fromPos = mapIndexToDocPos(node, start2, absoluteIndex);
|
|
69021
|
+
const toPos = mapIndexToDocPos(node, start2, absoluteIndex + this.string.length);
|
|
69022
|
+
return { from: fromPos, to: toPos, match: null, matchStart: start2 };
|
|
68987
69023
|
});
|
|
68988
69024
|
}
|
|
68989
69025
|
findPrev(state2, from2, to) {
|
|
68990
69026
|
return scanTextblocks(state2.doc, from2, to, (node, start2) => {
|
|
68991
69027
|
let off2 = Math.max(start2, to);
|
|
68992
69028
|
let content = textContent(node).slice(off2 - start2, Math.min(node.content.size, from2 - start2));
|
|
68993
|
-
if (!this.query.caseSensitive)
|
|
68994
|
-
content = content.toLowerCase();
|
|
69029
|
+
if (!this.query.caseSensitive) content = content.toLowerCase();
|
|
68995
69030
|
let index2 = content.lastIndexOf(this.string);
|
|
68996
|
-
|
|
69031
|
+
if (index2 < 0) return null;
|
|
69032
|
+
const startOffset = off2 - start2;
|
|
69033
|
+
const absoluteIndex = startOffset + index2;
|
|
69034
|
+
const fromPos = mapIndexToDocPos(node, start2, absoluteIndex);
|
|
69035
|
+
const toPos = mapIndexToDocPos(node, start2, absoluteIndex + this.string.length);
|
|
69036
|
+
return { from: fromPos, to: toPos, match: null, matchStart: start2 };
|
|
68997
69037
|
});
|
|
68998
69038
|
}
|
|
68999
69039
|
}
|
|
@@ -69008,7 +69048,11 @@ class RegExpQuery {
|
|
|
69008
69048
|
let content = textContent(node).slice(0, Math.min(node.content.size, to - start2));
|
|
69009
69049
|
this.regexp.lastIndex = from2 - start2;
|
|
69010
69050
|
let match = this.regexp.exec(content);
|
|
69011
|
-
|
|
69051
|
+
if (!match) return null;
|
|
69052
|
+
const absoluteIndex = match.index;
|
|
69053
|
+
const fromPos = mapIndexToDocPos(node, start2, absoluteIndex);
|
|
69054
|
+
const toPos = mapIndexToDocPos(node, start2, absoluteIndex + match[0].length);
|
|
69055
|
+
return { from: fromPos, to: toPos, match, matchStart: start2 };
|
|
69012
69056
|
});
|
|
69013
69057
|
}
|
|
69014
69058
|
findPrev(state2, from2, to) {
|
|
@@ -69018,18 +69062,20 @@ class RegExpQuery {
|
|
|
69018
69062
|
for (let off2 = 0; ; ) {
|
|
69019
69063
|
this.regexp.lastIndex = off2;
|
|
69020
69064
|
let next = this.regexp.exec(content);
|
|
69021
|
-
if (!next)
|
|
69022
|
-
break;
|
|
69065
|
+
if (!next) break;
|
|
69023
69066
|
match = next;
|
|
69024
69067
|
off2 = next.index + 1;
|
|
69025
69068
|
}
|
|
69026
|
-
|
|
69069
|
+
if (!match) return null;
|
|
69070
|
+
const absoluteIndex = match.index;
|
|
69071
|
+
const fromPos = mapIndexToDocPos(node, start2, absoluteIndex);
|
|
69072
|
+
const toPos = mapIndexToDocPos(node, start2, absoluteIndex + match[0].length);
|
|
69073
|
+
return { from: fromPos, to: toPos, match, matchStart: start2 };
|
|
69027
69074
|
});
|
|
69028
69075
|
}
|
|
69029
69076
|
}
|
|
69030
69077
|
function getGroupIndices(match) {
|
|
69031
|
-
if (match.indices)
|
|
69032
|
-
return match.indices;
|
|
69078
|
+
if (match.indices) return match.indices;
|
|
69033
69079
|
let result = [[0, match[0].length]];
|
|
69034
69080
|
for (let i = 1, pos = 0; i < match.length; i++) {
|
|
69035
69081
|
let found2 = match[i] ? match[0].indexOf(match[i], pos) : -1;
|
|
@@ -69041,10 +69087,8 @@ function parseReplacement(text) {
|
|
|
69041
69087
|
let result = [], highestSeen = -1;
|
|
69042
69088
|
function add(text2) {
|
|
69043
69089
|
let last = result.length - 1;
|
|
69044
|
-
if (last > -1 && typeof result[last] == "string")
|
|
69045
|
-
|
|
69046
|
-
else
|
|
69047
|
-
result.push(text2);
|
|
69090
|
+
if (last > -1 && typeof result[last] == "string") result[last] += text2;
|
|
69091
|
+
else result.push(text2);
|
|
69048
69092
|
}
|
|
69049
69093
|
while (text.length) {
|
|
69050
69094
|
let m2 = /\$([$&\d+])/.exec(text);
|
|
@@ -69052,8 +69096,7 @@ function parseReplacement(text) {
|
|
|
69052
69096
|
add(text);
|
|
69053
69097
|
return result;
|
|
69054
69098
|
}
|
|
69055
|
-
if (m2.index > 0)
|
|
69056
|
-
add(text.slice(0, m2.index + (m2[1] == "$" ? 1 : 0)));
|
|
69099
|
+
if (m2.index > 0) add(text.slice(0, m2.index + (m2[1] == "$" ? 1 : 0)));
|
|
69057
69100
|
if (m2[1] != "$") {
|
|
69058
69101
|
let n = m2[1] == "&" ? 0 : +m2[1];
|
|
69059
69102
|
if (highestSeen >= n) {
|
|
@@ -69071,30 +69114,50 @@ function validRegExp(source) {
|
|
|
69071
69114
|
try {
|
|
69072
69115
|
new RegExp(source, baseFlags);
|
|
69073
69116
|
return true;
|
|
69074
|
-
} catch
|
|
69117
|
+
} catch {
|
|
69075
69118
|
return false;
|
|
69076
69119
|
}
|
|
69077
69120
|
}
|
|
69078
69121
|
const TextContentCache = /* @__PURE__ */ new WeakMap();
|
|
69079
69122
|
function textContent(node) {
|
|
69080
69123
|
let cached = TextContentCache.get(node);
|
|
69081
|
-
if (cached)
|
|
69082
|
-
return cached;
|
|
69124
|
+
if (cached) return cached;
|
|
69083
69125
|
let content = "";
|
|
69084
69126
|
for (let i = 0; i < node.childCount; i++) {
|
|
69085
69127
|
let child = node.child(i);
|
|
69086
|
-
if (child.isText)
|
|
69087
|
-
|
|
69088
|
-
else if (child.
|
|
69089
|
-
|
|
69090
|
-
else
|
|
69091
|
-
content += " " + textContent(child) + " ";
|
|
69128
|
+
if (child.isText) content += child.text;
|
|
69129
|
+
else if (child.isLeaf) content += "";
|
|
69130
|
+
else if (child.type && child.type.name === "run") content += textContent(child);
|
|
69131
|
+
else content += " " + textContent(child) + " ";
|
|
69092
69132
|
}
|
|
69093
69133
|
TextContentCache.set(node, content);
|
|
69094
69134
|
return content;
|
|
69095
69135
|
}
|
|
69136
|
+
function mapIndexToDocPos(node, start2, index2) {
|
|
69137
|
+
if (index2 <= 0) return start2;
|
|
69138
|
+
const fullText = textContent(node);
|
|
69139
|
+
if (index2 >= fullText.length) return start2 + node.content.size;
|
|
69140
|
+
let target = start2;
|
|
69141
|
+
let remaining = index2;
|
|
69142
|
+
let found2 = false;
|
|
69143
|
+
node.descendants((child, pos) => {
|
|
69144
|
+
if (found2) return false;
|
|
69145
|
+
if (!child.isText) return true;
|
|
69146
|
+
const len = child.text.length;
|
|
69147
|
+
if (remaining <= len) {
|
|
69148
|
+
target = start2 + pos + remaining;
|
|
69149
|
+
found2 = true;
|
|
69150
|
+
return false;
|
|
69151
|
+
}
|
|
69152
|
+
remaining -= len;
|
|
69153
|
+
return true;
|
|
69154
|
+
});
|
|
69155
|
+
return found2 ? target : start2 + node.content.size;
|
|
69156
|
+
}
|
|
69157
|
+
const transparentInlineNodes = /* @__PURE__ */ new Set(["run"]);
|
|
69096
69158
|
function scanTextblocks(node, from2, to, f, nodeStart = 0) {
|
|
69097
|
-
|
|
69159
|
+
const isTransparentInline = node.inlineContent && node.type && transparentInlineNodes.has(node.type.name);
|
|
69160
|
+
if (node.inlineContent && !isTransparentInline) {
|
|
69098
69161
|
return f(node, nodeStart);
|
|
69099
69162
|
} else if (!node.isLeaf) {
|
|
69100
69163
|
if (from2 > to) {
|
|
@@ -69103,8 +69166,7 @@ function scanTextblocks(node, from2, to, f, nodeStart = 0) {
|
|
|
69103
69166
|
pos -= child.nodeSize;
|
|
69104
69167
|
if (pos < from2) {
|
|
69105
69168
|
let result = scanTextblocks(child, from2, to, f, pos + 1);
|
|
69106
|
-
if (result != null)
|
|
69107
|
-
return result;
|
|
69169
|
+
if (result != null) return result;
|
|
69108
69170
|
}
|
|
69109
69171
|
}
|
|
69110
69172
|
} else {
|
|
@@ -69113,8 +69175,7 @@ function scanTextblocks(node, from2, to, f, nodeStart = 0) {
|
|
|
69113
69175
|
pos += child.nodeSize;
|
|
69114
69176
|
if (pos > from2) {
|
|
69115
69177
|
let result = scanTextblocks(child, from2, to, f, start2 + 1);
|
|
69116
|
-
if (result != null)
|
|
69117
|
-
return result;
|
|
69178
|
+
if (result != null) return result;
|
|
69118
69179
|
}
|
|
69119
69180
|
}
|
|
69120
69181
|
}
|
|
@@ -69124,8 +69185,7 @@ function scanTextblocks(node, from2, to, f, nodeStart = 0) {
|
|
|
69124
69185
|
function checkWordBoundary(state2, pos) {
|
|
69125
69186
|
let $pos = state2.doc.resolve(pos);
|
|
69126
69187
|
let before = $pos.nodeBefore, after = $pos.nodeAfter;
|
|
69127
|
-
if (!before || !after || !before.isText || !after.isText)
|
|
69128
|
-
return true;
|
|
69188
|
+
if (!before || !after || !before.isText || !after.isText) return true;
|
|
69129
69189
|
return !/\p{L}$/u.test(before.text) || !/^\p{L}/u.test(after.text);
|
|
69130
69190
|
}
|
|
69131
69191
|
class SearchState {
|
|
@@ -69136,14 +69196,12 @@ class SearchState {
|
|
|
69136
69196
|
}
|
|
69137
69197
|
}
|
|
69138
69198
|
function buildMatchDeco(state2, query, range2) {
|
|
69139
|
-
if (!query.valid)
|
|
69140
|
-
return DecorationSet.empty;
|
|
69199
|
+
if (!query.valid) return DecorationSet.empty;
|
|
69141
69200
|
let deco = [];
|
|
69142
69201
|
let sel = state2.selection;
|
|
69143
69202
|
for (let pos = range2 ? range2.from : 0, end2 = range2 ? range2.to : state2.doc.content.size; ; ) {
|
|
69144
69203
|
let next = query.findNext(state2, pos, end2);
|
|
69145
|
-
if (!next)
|
|
69146
|
-
break;
|
|
69204
|
+
if (!next) break;
|
|
69147
69205
|
let cls = next.from == sel.from && next.to == sel.to ? "ProseMirror-active-search-match" : "ProseMirror-search-match";
|
|
69148
69206
|
deco.push(Decoration.inline(next.from, next.to, { class: cls }));
|
|
69149
69207
|
pos = next.to;
|
|
@@ -69162,8 +69220,7 @@ function search(options = {}) {
|
|
|
69162
69220
|
},
|
|
69163
69221
|
apply(tr, search2, _oldState, state2) {
|
|
69164
69222
|
let set = tr.getMeta(searchKey);
|
|
69165
|
-
if (set)
|
|
69166
|
-
return new SearchState(set.query, set.range, buildMatchDeco(state2, set.query, set.range));
|
|
69223
|
+
if (set) return new SearchState(set.query, set.range, buildMatchDeco(state2, set.query, set.range));
|
|
69167
69224
|
if (tr.docChanged || tr.selectionSet) {
|
|
69168
69225
|
let range2 = search2.range;
|
|
69169
69226
|
if (range2) {
|
|
@@ -69188,6 +69245,7 @@ function getMatchHighlights(state2) {
|
|
|
69188
69245
|
function setSearchState(tr, query, range2 = null) {
|
|
69189
69246
|
return tr.setMeta(searchKey, { query, range: range2 });
|
|
69190
69247
|
}
|
|
69248
|
+
const isRegExp = (value) => Object.prototype.toString.call(value) === "[object RegExp]";
|
|
69191
69249
|
const Search = Extension.create({
|
|
69192
69250
|
addStorage() {
|
|
69193
69251
|
return {
|
|
@@ -69257,10 +69315,14 @@ const Search = Extension.create({
|
|
|
69257
69315
|
let caseSensitive = false;
|
|
69258
69316
|
let regexp = false;
|
|
69259
69317
|
const wholeWord = false;
|
|
69260
|
-
if (patternInput
|
|
69318
|
+
if (isRegExp(patternInput)) {
|
|
69319
|
+
const regexPattern = (
|
|
69320
|
+
/** @type {RegExp} */
|
|
69321
|
+
patternInput
|
|
69322
|
+
);
|
|
69261
69323
|
regexp = true;
|
|
69262
|
-
pattern =
|
|
69263
|
-
caseSensitive = !
|
|
69324
|
+
pattern = regexPattern.source;
|
|
69325
|
+
caseSensitive = !regexPattern.flags.includes("i");
|
|
69264
69326
|
} else if (typeof patternInput === "string" && /^\/(.+)\/([gimsuy]*)$/.test(patternInput)) {
|
|
69265
69327
|
const [, body, flags] = patternInput.match(/^\/(.+)\/([gimsuy]*)$/);
|
|
69266
69328
|
regexp = true;
|