@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
package/dist/super-editor.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const superEditor_es = require("./chunks/super-editor.es-
|
|
3
|
+
const superEditor_es = require("./chunks/super-editor.es-U-GVCd_F.cjs");
|
|
4
4
|
require("./chunks/vue-DWle4Cai.cjs");
|
|
5
5
|
exports.AIWriter = superEditor_es.AIWriter;
|
|
6
6
|
exports.AnnotatorHelpers = superEditor_es.AnnotatorHelpers;
|
package/dist/super-editor.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A, a, _, C, D, E, b, S, c, d, e, f, g, T, h, i, j, k, l, m, n, o, p, r, q } from "./chunks/super-editor.es-
|
|
1
|
+
import { A, a, _, C, D, E, b, S, c, d, e, f, g, T, h, i, j, k, l, m, n, o, p, r, q } from "./chunks/super-editor.es-Bntob7Wd.es.js";
|
|
2
2
|
import "./chunks/vue-CXxsqYcP.es.js";
|
|
3
3
|
export {
|
|
4
4
|
A as AIWriter,
|
package/dist/superdoc.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const superEditor_es = require("./chunks/super-editor.es-
|
|
4
|
-
const superdoc = require("./chunks/index-
|
|
3
|
+
const superEditor_es = require("./chunks/super-editor.es-U-GVCd_F.cjs");
|
|
4
|
+
const superdoc = require("./chunks/index-CfYf4T_z.cjs");
|
|
5
5
|
require("./chunks/vue-DWle4Cai.cjs");
|
|
6
6
|
require("./chunks/jszip-b7l8QkfH.cjs");
|
|
7
7
|
const blankDocx = require("./chunks/blank-docx-CPqX9RF5.cjs");
|
package/dist/superdoc.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a, E, b, S, d, i, j, n, r, p, q } from "./chunks/super-editor.es-
|
|
2
|
-
import { D, H, P, S as S2, m, l } from "./chunks/index-
|
|
1
|
+
import { a, E, b, S, d, i, j, n, r, p, q } from "./chunks/super-editor.es-Bntob7Wd.es.js";
|
|
2
|
+
import { D, H, P, S as S2, m, l } from "./chunks/index-MzW5BVNd.es.js";
|
|
3
3
|
import "./chunks/vue-CXxsqYcP.es.js";
|
|
4
4
|
import "./chunks/jszip-B8KIZSNe.es.js";
|
|
5
5
|
import { B } from "./chunks/blank-docx-iwdyG9RH.es.js";
|
package/dist/superdoc.umd.js
CHANGED
|
@@ -19126,7 +19126,7 @@
|
|
|
19126
19126
|
navigator.platform
|
|
19127
19127
|
);
|
|
19128
19128
|
};
|
|
19129
|
-
const isRegExp = (value) => {
|
|
19129
|
+
const isRegExp$1 = (value) => {
|
|
19130
19130
|
return Object.prototype.toString.call(value) === "[object RegExp]";
|
|
19131
19131
|
};
|
|
19132
19132
|
function objectIncludes(obj1, obj2, options = { strict: true }) {
|
|
@@ -19134,7 +19134,7 @@
|
|
|
19134
19134
|
if (!keys2.length) return true;
|
|
19135
19135
|
return keys2.every((key2) => {
|
|
19136
19136
|
if (options.strict) return obj2[key2] === obj1[key2];
|
|
19137
|
-
if (isRegExp(obj2[key2])) return obj2[key2].test(obj1[key2]);
|
|
19137
|
+
if (isRegExp$1(obj2[key2])) return obj2[key2].test(obj1[key2]);
|
|
19138
19138
|
return obj2[key2] === obj1[key2];
|
|
19139
19139
|
});
|
|
19140
19140
|
}
|
|
@@ -31938,18 +31938,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
31938
31938
|
}
|
|
31939
31939
|
]
|
|
31940
31940
|
};
|
|
31941
|
-
const sanitizeDocxMediaName = (value, fallback = "image") => {
|
|
31942
|
-
if (!value) return fallback;
|
|
31943
|
-
const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
31944
|
-
return sanitized || fallback;
|
|
31945
|
-
};
|
|
31946
|
-
const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
|
|
31947
|
-
if (!src || typeof src !== "string") return fallback;
|
|
31948
|
-
const [prefix2] = src.split(";");
|
|
31949
|
-
const [, maybeType] = prefix2.split("/");
|
|
31950
|
-
const extension = maybeType?.toLowerCase();
|
|
31951
|
-
return extension ? `${fallback}.${extension}` : fallback;
|
|
31952
|
-
};
|
|
31953
31941
|
const TranslatorTypes = Object.freeze({
|
|
31954
31942
|
NODE: "node",
|
|
31955
31943
|
ATTRIBUTE: "attribute"
|
|
@@ -35561,7 +35549,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35561
35549
|
if (filteredMarks.length !== existingMarks2.length) {
|
|
35562
35550
|
if (filteredMarks.length) child = { ...child, marks: filteredMarks };
|
|
35563
35551
|
else {
|
|
35564
|
-
const { marks, ...rest } = child;
|
|
35552
|
+
const { marks: _removedMarks, ...rest } = child;
|
|
35565
35553
|
child = rest;
|
|
35566
35554
|
}
|
|
35567
35555
|
}
|
|
@@ -36071,6 +36059,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36071
36059
|
}
|
|
36072
36060
|
return handleImageNode(node, params2, true);
|
|
36073
36061
|
}
|
|
36062
|
+
const sanitizeDocxMediaName = (value, fallback = "image") => {
|
|
36063
|
+
if (!value) return fallback;
|
|
36064
|
+
const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
36065
|
+
return sanitized || fallback;
|
|
36066
|
+
};
|
|
36067
|
+
const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
|
|
36068
|
+
if (!src || typeof src !== "string") return fallback;
|
|
36069
|
+
const [prefix2] = src.split(";");
|
|
36070
|
+
const [, maybeType] = prefix2.split("/");
|
|
36071
|
+
const extension = maybeType?.toLowerCase();
|
|
36072
|
+
return extension ? `${fallback}.${extension}` : fallback;
|
|
36073
|
+
};
|
|
36074
36074
|
const translateImageNode = (params2) => {
|
|
36075
36075
|
const {
|
|
36076
36076
|
node: { attrs = {} },
|
|
@@ -37278,7 +37278,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37278
37278
|
}
|
|
37279
37279
|
}
|
|
37280
37280
|
const inputRuleMatcherHandler = (text, match) => {
|
|
37281
|
-
if (isRegExp(match)) {
|
|
37281
|
+
if (isRegExp$1(match)) {
|
|
37282
37282
|
return match.exec(text);
|
|
37283
37283
|
}
|
|
37284
37284
|
const inputRuleMatch = match(text);
|
|
@@ -55166,6 +55166,33 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
55166
55166
|
return DecorationSet.create(state2.doc, decorations);
|
|
55167
55167
|
};
|
|
55168
55168
|
const CommentMarkName = "commentMark";
|
|
55169
|
+
const resolveCommentMeta = ({ converter, importedId }) => {
|
|
55170
|
+
const comments = converter?.comments || [];
|
|
55171
|
+
const matchingImportedComment = comments.find((c2) => c2.importedId == importedId);
|
|
55172
|
+
const resolvedCommentId = matchingImportedComment?.commentId ?? (importedId ? String(importedId) : v4$1());
|
|
55173
|
+
const internal = matchingImportedComment?.internal ?? matchingImportedComment?.isInternal ?? false;
|
|
55174
|
+
return {
|
|
55175
|
+
resolvedCommentId,
|
|
55176
|
+
importedId,
|
|
55177
|
+
internal,
|
|
55178
|
+
matchingImportedComment
|
|
55179
|
+
};
|
|
55180
|
+
};
|
|
55181
|
+
const ensureFallbackComment = ({ converter, matchingImportedComment, commentId, importedId }) => {
|
|
55182
|
+
if (matchingImportedComment || !converter) return;
|
|
55183
|
+
converter.comments = converter.comments || [];
|
|
55184
|
+
const alreadyExists = converter.comments.some((comment) => comment.commentId === commentId);
|
|
55185
|
+
if (alreadyExists) return;
|
|
55186
|
+
converter.comments.push({
|
|
55187
|
+
commentId,
|
|
55188
|
+
importedId,
|
|
55189
|
+
textJson: null,
|
|
55190
|
+
creatorName: null,
|
|
55191
|
+
creatorEmail: null,
|
|
55192
|
+
createdTime: null,
|
|
55193
|
+
isDone: false
|
|
55194
|
+
});
|
|
55195
|
+
};
|
|
55169
55196
|
const removeCommentsById = ({ commentId, state: state2, tr, dispatch }) => {
|
|
55170
55197
|
const positions = getCommentPositionsById(commentId, state2.doc);
|
|
55171
55198
|
positions.forEach(({ from: from2, to }) => {
|
|
@@ -55259,24 +55286,31 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
55259
55286
|
const { type: type2 } = node;
|
|
55260
55287
|
const commentNodes = ["commentRangeStart", "commentRangeEnd", "commentReference"];
|
|
55261
55288
|
if (!commentNodes.includes(type2.name)) return;
|
|
55262
|
-
const
|
|
55263
|
-
|
|
55264
|
-
|
|
55289
|
+
const { resolvedCommentId, importedId, internal, matchingImportedComment } = resolveCommentMeta({
|
|
55290
|
+
converter,
|
|
55291
|
+
importedId: node.attrs["w:id"]
|
|
55292
|
+
});
|
|
55265
55293
|
if (type2.name === "commentRangeStart") {
|
|
55266
55294
|
toMark.push({
|
|
55267
|
-
|
|
55268
|
-
importedId
|
|
55269
|
-
internal
|
|
55295
|
+
commentId: resolvedCommentId,
|
|
55296
|
+
importedId,
|
|
55297
|
+
internal,
|
|
55270
55298
|
start: pos
|
|
55271
55299
|
});
|
|
55300
|
+
ensureFallbackComment({
|
|
55301
|
+
converter,
|
|
55302
|
+
matchingImportedComment,
|
|
55303
|
+
commentId: resolvedCommentId,
|
|
55304
|
+
importedId
|
|
55305
|
+
});
|
|
55272
55306
|
toDelete.push({ start: pos, end: pos + 1 });
|
|
55273
55307
|
} else if (type2.name === "commentRangeEnd") {
|
|
55274
|
-
const itemToMark = toMark.find((p2) => p2.importedId ===
|
|
55308
|
+
const itemToMark = toMark.find((p2) => p2.importedId === importedId);
|
|
55275
55309
|
if (!itemToMark) return;
|
|
55276
55310
|
const { start: start2 } = itemToMark;
|
|
55277
55311
|
const markAttrs = {
|
|
55278
|
-
commentId,
|
|
55279
|
-
importedId
|
|
55312
|
+
commentId: itemToMark.commentId,
|
|
55313
|
+
importedId,
|
|
55280
55314
|
internal: itemToMark.internal
|
|
55281
55315
|
};
|
|
55282
55316
|
tr.addMark(start2, pos + 1, schema.marks[CommentMarkName].create(markAttrs));
|
|
@@ -76563,8 +76597,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
76563
76597
|
}
|
|
76564
76598
|
class SearchQuery {
|
|
76565
76599
|
/**
|
|
76566
|
-
|
|
76567
|
-
|
|
76600
|
+
Create a query object.
|
|
76601
|
+
*/
|
|
76568
76602
|
constructor(config2) {
|
|
76569
76603
|
this.search = config2.search;
|
|
76570
76604
|
this.caseSensitive = !!config2.caseSensitive;
|
|
@@ -76577,72 +76611,70 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
76577
76611
|
this.impl = !this.valid ? nullQuery : this.regexp ? new RegExpQuery(this) : new StringQuery(this);
|
|
76578
76612
|
}
|
|
76579
76613
|
/**
|
|
76580
|
-
|
|
76581
|
-
|
|
76614
|
+
Compare this query to another query.
|
|
76615
|
+
*/
|
|
76582
76616
|
eq(other) {
|
|
76583
76617
|
return this.search == other.search && this.replace == other.replace && this.caseSensitive == other.caseSensitive && this.regexp == other.regexp && this.wholeWord == other.wholeWord;
|
|
76584
76618
|
}
|
|
76585
76619
|
/**
|
|
76586
|
-
|
|
76587
|
-
|
|
76620
|
+
Find the next occurrence of this query in the given range.
|
|
76621
|
+
*/
|
|
76588
76622
|
findNext(state2, from2 = 0, to = state2.doc.content.size) {
|
|
76589
76623
|
for (; ; ) {
|
|
76590
|
-
if (from2 >= to)
|
|
76591
|
-
return null;
|
|
76624
|
+
if (from2 >= to) return null;
|
|
76592
76625
|
let result = this.impl.findNext(state2, from2, to);
|
|
76593
|
-
if (!result || this.checkResult(state2, result))
|
|
76594
|
-
return result;
|
|
76626
|
+
if (!result || this.checkResult(state2, result)) return result;
|
|
76595
76627
|
from2 = result.from + 1;
|
|
76596
76628
|
}
|
|
76597
76629
|
}
|
|
76598
76630
|
/**
|
|
76599
|
-
|
|
76600
|
-
|
|
76601
|
-
|
|
76631
|
+
Find the previous occurrence of this query in the given range.
|
|
76632
|
+
Note that, if `to` is given, it should be _less_ than `from`.
|
|
76633
|
+
*/
|
|
76602
76634
|
findPrev(state2, from2 = state2.doc.content.size, to = 0) {
|
|
76603
76635
|
for (; ; ) {
|
|
76604
|
-
if (from2 <= to)
|
|
76605
|
-
return null;
|
|
76636
|
+
if (from2 <= to) return null;
|
|
76606
76637
|
let result = this.impl.findPrev(state2, from2, to);
|
|
76607
|
-
if (!result || this.checkResult(state2, result))
|
|
76608
|
-
return result;
|
|
76638
|
+
if (!result || this.checkResult(state2, result)) return result;
|
|
76609
76639
|
from2 = result.to - 1;
|
|
76610
76640
|
}
|
|
76611
76641
|
}
|
|
76612
76642
|
/**
|
|
76613
|
-
|
|
76614
|
-
|
|
76643
|
+
@internal
|
|
76644
|
+
*/
|
|
76615
76645
|
checkResult(state2, result) {
|
|
76616
76646
|
return (!this.wholeWord || checkWordBoundary(state2, result.from) && checkWordBoundary(state2, result.to)) && (!this.filter || this.filter(state2, result));
|
|
76617
76647
|
}
|
|
76618
76648
|
/**
|
|
76619
|
-
|
|
76620
|
-
|
|
76649
|
+
@internal
|
|
76650
|
+
*/
|
|
76621
76651
|
unquote(string) {
|
|
76622
76652
|
return this.literal ? string : string.replace(/\\([nrt\\])/g, (_2, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? " " : "\\");
|
|
76623
76653
|
}
|
|
76624
76654
|
/**
|
|
76625
|
-
|
|
76626
|
-
|
|
76627
|
-
|
|
76628
|
-
|
|
76629
|
-
|
|
76630
|
-
|
|
76631
|
-
|
|
76632
|
-
|
|
76633
|
-
|
|
76634
|
-
|
|
76655
|
+
Get the ranges that should be replaced for this result. This can
|
|
76656
|
+
return multiple ranges when `this.replace` contains
|
|
76657
|
+
`$1`/`$&`-style placeholders, in which case the preserved
|
|
76658
|
+
content is skipped by the replacements.
|
|
76659
|
+
|
|
76660
|
+
Ranges are sorted by position, and `from`/`to` positions all
|
|
76661
|
+
refer to positions in `state.doc`. When applying these, you'll
|
|
76662
|
+
want to either apply them from back to front, or map these
|
|
76663
|
+
positions through your transaction's current mapping.
|
|
76664
|
+
*/
|
|
76635
76665
|
getReplacements(state2, result) {
|
|
76636
76666
|
let $from = state2.doc.resolve(result.from);
|
|
76637
76667
|
let marks = $from.marksAcross(state2.doc.resolve(result.to));
|
|
76638
76668
|
let ranges = [];
|
|
76639
76669
|
let frag = Fragment.empty, pos = result.from, { match } = result;
|
|
76640
76670
|
let groups = match ? getGroupIndices(match) : [[0, result.to - result.from]];
|
|
76641
|
-
let replParts = parseReplacement(this.unquote(this.replace))
|
|
76671
|
+
let replParts = parseReplacement(this.unquote(this.replace));
|
|
76642
76672
|
for (let part of replParts) {
|
|
76643
76673
|
if (typeof part == "string") {
|
|
76644
76674
|
frag = frag.addToEnd(state2.schema.text(part, marks));
|
|
76645
|
-
} else
|
|
76675
|
+
} else {
|
|
76676
|
+
const groupSpan = groups[part.group];
|
|
76677
|
+
if (!groupSpan) continue;
|
|
76646
76678
|
let from2 = result.matchStart + groupSpan[0], to = result.matchStart + groupSpan[1];
|
|
76647
76679
|
if (part.copy) {
|
|
76648
76680
|
frag = frag.append(state2.doc.slice(from2, to).content);
|
|
@@ -76672,8 +76704,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
76672
76704
|
constructor(query) {
|
|
76673
76705
|
this.query = query;
|
|
76674
76706
|
let string = query.unquote(query.search);
|
|
76675
|
-
if (!query.caseSensitive)
|
|
76676
|
-
string = string.toLowerCase();
|
|
76707
|
+
if (!query.caseSensitive) string = string.toLowerCase();
|
|
76677
76708
|
this.string = string;
|
|
76678
76709
|
}
|
|
76679
76710
|
findNext(state2, from2, to) {
|
|
@@ -76681,17 +76712,26 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
76681
76712
|
let off2 = Math.max(from2, start2);
|
|
76682
76713
|
let content = textContent(node).slice(off2 - start2, Math.min(node.content.size, to - start2));
|
|
76683
76714
|
let index2 = (this.query.caseSensitive ? content : content.toLowerCase()).indexOf(this.string);
|
|
76684
|
-
|
|
76715
|
+
if (index2 < 0) return null;
|
|
76716
|
+
const startOffset = off2 - start2;
|
|
76717
|
+
const absoluteIndex = startOffset + index2;
|
|
76718
|
+
const fromPos = mapIndexToDocPos(node, start2, absoluteIndex);
|
|
76719
|
+
const toPos = mapIndexToDocPos(node, start2, absoluteIndex + this.string.length);
|
|
76720
|
+
return { from: fromPos, to: toPos, match: null, matchStart: start2 };
|
|
76685
76721
|
});
|
|
76686
76722
|
}
|
|
76687
76723
|
findPrev(state2, from2, to) {
|
|
76688
76724
|
return scanTextblocks(state2.doc, from2, to, (node, start2) => {
|
|
76689
76725
|
let off2 = Math.max(start2, to);
|
|
76690
76726
|
let content = textContent(node).slice(off2 - start2, Math.min(node.content.size, from2 - start2));
|
|
76691
|
-
if (!this.query.caseSensitive)
|
|
76692
|
-
content = content.toLowerCase();
|
|
76727
|
+
if (!this.query.caseSensitive) content = content.toLowerCase();
|
|
76693
76728
|
let index2 = content.lastIndexOf(this.string);
|
|
76694
|
-
|
|
76729
|
+
if (index2 < 0) return null;
|
|
76730
|
+
const startOffset = off2 - start2;
|
|
76731
|
+
const absoluteIndex = startOffset + index2;
|
|
76732
|
+
const fromPos = mapIndexToDocPos(node, start2, absoluteIndex);
|
|
76733
|
+
const toPos = mapIndexToDocPos(node, start2, absoluteIndex + this.string.length);
|
|
76734
|
+
return { from: fromPos, to: toPos, match: null, matchStart: start2 };
|
|
76695
76735
|
});
|
|
76696
76736
|
}
|
|
76697
76737
|
}
|
|
@@ -76706,7 +76746,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
76706
76746
|
let content = textContent(node).slice(0, Math.min(node.content.size, to - start2));
|
|
76707
76747
|
this.regexp.lastIndex = from2 - start2;
|
|
76708
76748
|
let match = this.regexp.exec(content);
|
|
76709
|
-
|
|
76749
|
+
if (!match) return null;
|
|
76750
|
+
const absoluteIndex = match.index;
|
|
76751
|
+
const fromPos = mapIndexToDocPos(node, start2, absoluteIndex);
|
|
76752
|
+
const toPos = mapIndexToDocPos(node, start2, absoluteIndex + match[0].length);
|
|
76753
|
+
return { from: fromPos, to: toPos, match, matchStart: start2 };
|
|
76710
76754
|
});
|
|
76711
76755
|
}
|
|
76712
76756
|
findPrev(state2, from2, to) {
|
|
@@ -76716,18 +76760,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
76716
76760
|
for (let off2 = 0; ; ) {
|
|
76717
76761
|
this.regexp.lastIndex = off2;
|
|
76718
76762
|
let next = this.regexp.exec(content);
|
|
76719
|
-
if (!next)
|
|
76720
|
-
break;
|
|
76763
|
+
if (!next) break;
|
|
76721
76764
|
match = next;
|
|
76722
76765
|
off2 = next.index + 1;
|
|
76723
76766
|
}
|
|
76724
|
-
|
|
76767
|
+
if (!match) return null;
|
|
76768
|
+
const absoluteIndex = match.index;
|
|
76769
|
+
const fromPos = mapIndexToDocPos(node, start2, absoluteIndex);
|
|
76770
|
+
const toPos = mapIndexToDocPos(node, start2, absoluteIndex + match[0].length);
|
|
76771
|
+
return { from: fromPos, to: toPos, match, matchStart: start2 };
|
|
76725
76772
|
});
|
|
76726
76773
|
}
|
|
76727
76774
|
}
|
|
76728
76775
|
function getGroupIndices(match) {
|
|
76729
|
-
if (match.indices)
|
|
76730
|
-
return match.indices;
|
|
76776
|
+
if (match.indices) return match.indices;
|
|
76731
76777
|
let result = [[0, match[0].length]];
|
|
76732
76778
|
for (let i2 = 1, pos = 0; i2 < match.length; i2++) {
|
|
76733
76779
|
let found2 = match[i2] ? match[0].indexOf(match[i2], pos) : -1;
|
|
@@ -76739,10 +76785,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
76739
76785
|
let result = [], highestSeen = -1;
|
|
76740
76786
|
function add(text2) {
|
|
76741
76787
|
let last = result.length - 1;
|
|
76742
|
-
if (last > -1 && typeof result[last] == "string")
|
|
76743
|
-
|
|
76744
|
-
else
|
|
76745
|
-
result.push(text2);
|
|
76788
|
+
if (last > -1 && typeof result[last] == "string") result[last] += text2;
|
|
76789
|
+
else result.push(text2);
|
|
76746
76790
|
}
|
|
76747
76791
|
while (text.length) {
|
|
76748
76792
|
let m2 = /\$([$&\d+])/.exec(text);
|
|
@@ -76750,8 +76794,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
76750
76794
|
add(text);
|
|
76751
76795
|
return result;
|
|
76752
76796
|
}
|
|
76753
|
-
if (m2.index > 0)
|
|
76754
|
-
add(text.slice(0, m2.index + (m2[1] == "$" ? 1 : 0)));
|
|
76797
|
+
if (m2.index > 0) add(text.slice(0, m2.index + (m2[1] == "$" ? 1 : 0)));
|
|
76755
76798
|
if (m2[1] != "$") {
|
|
76756
76799
|
let n = m2[1] == "&" ? 0 : +m2[1];
|
|
76757
76800
|
if (highestSeen >= n) {
|
|
@@ -76769,30 +76812,50 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
76769
76812
|
try {
|
|
76770
76813
|
new RegExp(source, baseFlags);
|
|
76771
76814
|
return true;
|
|
76772
|
-
} catch
|
|
76815
|
+
} catch {
|
|
76773
76816
|
return false;
|
|
76774
76817
|
}
|
|
76775
76818
|
}
|
|
76776
76819
|
const TextContentCache = /* @__PURE__ */ new WeakMap();
|
|
76777
76820
|
function textContent(node) {
|
|
76778
76821
|
let cached = TextContentCache.get(node);
|
|
76779
|
-
if (cached)
|
|
76780
|
-
return cached;
|
|
76822
|
+
if (cached) return cached;
|
|
76781
76823
|
let content = "";
|
|
76782
76824
|
for (let i2 = 0; i2 < node.childCount; i2++) {
|
|
76783
76825
|
let child = node.child(i2);
|
|
76784
|
-
if (child.isText)
|
|
76785
|
-
|
|
76786
|
-
else if (child.
|
|
76787
|
-
|
|
76788
|
-
else
|
|
76789
|
-
content += " " + textContent(child) + " ";
|
|
76826
|
+
if (child.isText) content += child.text;
|
|
76827
|
+
else if (child.isLeaf) content += "";
|
|
76828
|
+
else if (child.type && child.type.name === "run") content += textContent(child);
|
|
76829
|
+
else content += " " + textContent(child) + " ";
|
|
76790
76830
|
}
|
|
76791
76831
|
TextContentCache.set(node, content);
|
|
76792
76832
|
return content;
|
|
76793
76833
|
}
|
|
76834
|
+
function mapIndexToDocPos(node, start2, index2) {
|
|
76835
|
+
if (index2 <= 0) return start2;
|
|
76836
|
+
const fullText = textContent(node);
|
|
76837
|
+
if (index2 >= fullText.length) return start2 + node.content.size;
|
|
76838
|
+
let target = start2;
|
|
76839
|
+
let remaining = index2;
|
|
76840
|
+
let found2 = false;
|
|
76841
|
+
node.descendants((child, pos) => {
|
|
76842
|
+
if (found2) return false;
|
|
76843
|
+
if (!child.isText) return true;
|
|
76844
|
+
const len2 = child.text.length;
|
|
76845
|
+
if (remaining <= len2) {
|
|
76846
|
+
target = start2 + pos + remaining;
|
|
76847
|
+
found2 = true;
|
|
76848
|
+
return false;
|
|
76849
|
+
}
|
|
76850
|
+
remaining -= len2;
|
|
76851
|
+
return true;
|
|
76852
|
+
});
|
|
76853
|
+
return found2 ? target : start2 + node.content.size;
|
|
76854
|
+
}
|
|
76855
|
+
const transparentInlineNodes = /* @__PURE__ */ new Set(["run"]);
|
|
76794
76856
|
function scanTextblocks(node, from2, to, f, nodeStart = 0) {
|
|
76795
|
-
|
|
76857
|
+
const isTransparentInline = node.inlineContent && node.type && transparentInlineNodes.has(node.type.name);
|
|
76858
|
+
if (node.inlineContent && !isTransparentInline) {
|
|
76796
76859
|
return f(node, nodeStart);
|
|
76797
76860
|
} else if (!node.isLeaf) {
|
|
76798
76861
|
if (from2 > to) {
|
|
@@ -76801,8 +76864,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
76801
76864
|
pos -= child.nodeSize;
|
|
76802
76865
|
if (pos < from2) {
|
|
76803
76866
|
let result = scanTextblocks(child, from2, to, f, pos + 1);
|
|
76804
|
-
if (result != null)
|
|
76805
|
-
return result;
|
|
76867
|
+
if (result != null) return result;
|
|
76806
76868
|
}
|
|
76807
76869
|
}
|
|
76808
76870
|
} else {
|
|
@@ -76811,8 +76873,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
76811
76873
|
pos += child.nodeSize;
|
|
76812
76874
|
if (pos > from2) {
|
|
76813
76875
|
let result = scanTextblocks(child, from2, to, f, start2 + 1);
|
|
76814
|
-
if (result != null)
|
|
76815
|
-
return result;
|
|
76876
|
+
if (result != null) return result;
|
|
76816
76877
|
}
|
|
76817
76878
|
}
|
|
76818
76879
|
}
|
|
@@ -76822,8 +76883,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
76822
76883
|
function checkWordBoundary(state2, pos) {
|
|
76823
76884
|
let $pos = state2.doc.resolve(pos);
|
|
76824
76885
|
let before = $pos.nodeBefore, after = $pos.nodeAfter;
|
|
76825
|
-
if (!before || !after || !before.isText || !after.isText)
|
|
76826
|
-
return true;
|
|
76886
|
+
if (!before || !after || !before.isText || !after.isText) return true;
|
|
76827
76887
|
return !/\p{L}$/u.test(before.text) || !/^\p{L}/u.test(after.text);
|
|
76828
76888
|
}
|
|
76829
76889
|
class SearchState {
|
|
@@ -76834,14 +76894,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
76834
76894
|
}
|
|
76835
76895
|
}
|
|
76836
76896
|
function buildMatchDeco(state2, query, range2) {
|
|
76837
|
-
if (!query.valid)
|
|
76838
|
-
return DecorationSet.empty;
|
|
76897
|
+
if (!query.valid) return DecorationSet.empty;
|
|
76839
76898
|
let deco = [];
|
|
76840
76899
|
let sel = state2.selection;
|
|
76841
76900
|
for (let pos = range2 ? range2.from : 0, end2 = range2 ? range2.to : state2.doc.content.size; ; ) {
|
|
76842
76901
|
let next = query.findNext(state2, pos, end2);
|
|
76843
|
-
if (!next)
|
|
76844
|
-
break;
|
|
76902
|
+
if (!next) break;
|
|
76845
76903
|
let cls = next.from == sel.from && next.to == sel.to ? "ProseMirror-active-search-match" : "ProseMirror-search-match";
|
|
76846
76904
|
deco.push(Decoration.inline(next.from, next.to, { class: cls }));
|
|
76847
76905
|
pos = next.to;
|
|
@@ -76860,8 +76918,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
76860
76918
|
},
|
|
76861
76919
|
apply(tr, search2, _oldState, state2) {
|
|
76862
76920
|
let set = tr.getMeta(searchKey);
|
|
76863
|
-
if (set)
|
|
76864
|
-
return new SearchState(set.query, set.range, buildMatchDeco(state2, set.query, set.range));
|
|
76921
|
+
if (set) return new SearchState(set.query, set.range, buildMatchDeco(state2, set.query, set.range));
|
|
76865
76922
|
if (tr.docChanged || tr.selectionSet) {
|
|
76866
76923
|
let range2 = search2.range;
|
|
76867
76924
|
if (range2) {
|
|
@@ -76886,6 +76943,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
76886
76943
|
function setSearchState(tr, query, range2 = null) {
|
|
76887
76944
|
return tr.setMeta(searchKey, { query, range: range2 });
|
|
76888
76945
|
}
|
|
76946
|
+
const isRegExp = (value) => Object.prototype.toString.call(value) === "[object RegExp]";
|
|
76889
76947
|
const Search = Extension.create({
|
|
76890
76948
|
addStorage() {
|
|
76891
76949
|
return {
|
|
@@ -76955,10 +77013,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
76955
77013
|
let caseSensitive = false;
|
|
76956
77014
|
let regexp = false;
|
|
76957
77015
|
const wholeWord = false;
|
|
76958
|
-
if (patternInput
|
|
77016
|
+
if (isRegExp(patternInput)) {
|
|
77017
|
+
const regexPattern = (
|
|
77018
|
+
/** @type {RegExp} */
|
|
77019
|
+
patternInput
|
|
77020
|
+
);
|
|
76959
77021
|
regexp = true;
|
|
76960
|
-
pattern =
|
|
76961
|
-
caseSensitive = !
|
|
77022
|
+
pattern = regexPattern.source;
|
|
77023
|
+
caseSensitive = !regexPattern.flags.includes("i");
|
|
76962
77024
|
} else if (typeof patternInput === "string" && /^\/(.+)\/([gimsuy]*)$/.test(patternInput)) {
|
|
76963
77025
|
const [, body, flags] = patternInput.match(/^\/(.+)\/([gimsuy]*)$/);
|
|
76964
77026
|
regexp = true;
|