@harbour-enterprises/superdoc 0.21.0-RC2 → 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.
Files changed (32) hide show
  1. package/README.md +4 -4
  2. package/dist/chunks/{PdfViewer-DGbJ8_qc.cjs → PdfViewer-1mNuyy3m.cjs} +1 -1
  3. package/dist/chunks/{PdfViewer-CbGuPQY8.es.js → PdfViewer-BkXBRXPs.es.js} +1 -1
  4. package/dist/chunks/{index-ecl0ZFNw.cjs → index-BB3Qn69u.cjs} +57 -15
  5. package/dist/chunks/{index-qjntJEk0.es.js → index-C-44kxYe.es.js} +57 -15
  6. package/dist/chunks/{super-editor.es-BF_Xaucb.es.js → super-editor.es-CKw7iZcz.es.js} +217 -128
  7. package/dist/chunks/{super-editor.es-CS5l-cVZ.cjs → super-editor.es-Dd0joLAR.cjs} +217 -128
  8. package/dist/core/SuperDoc.d.ts.map +1 -1
  9. package/dist/stores/comments-store.d.ts.map +1 -1
  10. package/dist/style.css +1 -1
  11. package/dist/super-editor/ai-writer.es.js +2 -2
  12. package/dist/super-editor/chunks/{converter-DUqGq6qj.js → converter-FESR2WO7.js} +41 -25
  13. package/dist/super-editor/chunks/{docx-zipper-CQsQR8Zs.js → docx-zipper-BWZ2o1H5.js} +1 -1
  14. package/dist/super-editor/chunks/{editor-gMF6aWiz.js → editor-XsrBXzy-.js} +156 -93
  15. package/dist/super-editor/chunks/{toolbar-BxsT1ZgG.js → toolbar-tBWlOBPh.js} +21 -11
  16. package/dist/super-editor/converter.es.js +1 -1
  17. package/dist/super-editor/docx-zipper.es.js +2 -2
  18. package/dist/super-editor/editor.es.js +3 -3
  19. package/dist/super-editor/file-zipper.es.js +1 -1
  20. package/dist/super-editor/src/extensions/comment/comment-import-helpers.d.ts +15 -0
  21. package/dist/super-editor/src/extensions/search/prosemirror-search-patched.d.ts +110 -0
  22. package/dist/super-editor/style.css +1 -1
  23. package/dist/super-editor/super-editor.es.js +6 -6
  24. package/dist/super-editor/toolbar.es.js +2 -2
  25. package/dist/super-editor.cjs +1 -1
  26. package/dist/super-editor.es.js +1 -1
  27. package/dist/superdoc.cjs +2 -2
  28. package/dist/superdoc.es.js +2 -2
  29. package/dist/superdoc.umd.js +272 -141
  30. package/dist/superdoc.umd.js.map +1 -1
  31. package/npm-deprecation-notice.cjs +10 -0
  32. package/package.json +11 -6
@@ -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,6 +24213,18 @@ 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
+ };
24216
24228
  const TranslatorTypes = Object.freeze({
24217
24229
  NODE: "node",
24218
24230
  ATTRIBUTE: "attribute"
@@ -24410,6 +24422,7 @@ const attrConfig$D = Object.freeze({
24410
24422
  const validXmlAttributes$k = [attrConfig$D];
24411
24423
  const XML_NODE_NAME$s = "w:highlight";
24412
24424
  const SD_ATTR_KEY$f = "highlight";
24425
+ const DISABLED_TOKENS = /* @__PURE__ */ new Set(["transparent", "none", "inherit"]);
24413
24426
  const encode$13 = (params2, encodedAttrs = {}) => {
24414
24427
  const { nodes } = params2;
24415
24428
  const node = nodes?.[0];
@@ -24426,8 +24439,12 @@ const decode$W = (params2) => {
24426
24439
  const highlightValue = attrs.highlight ?? attrs.color ?? null;
24427
24440
  if (!highlightValue) return void 0;
24428
24441
  const normalizedValue = String(highlightValue).trim().toLowerCase();
24429
- if (!normalizedValue || normalizedValue === "transparent" || normalizedValue === "none") {
24430
- return void 0;
24442
+ if (!normalizedValue) return void 0;
24443
+ if (DISABLED_TOKENS.has(normalizedValue)) {
24444
+ return {
24445
+ name: XML_NODE_NAME$s,
24446
+ attributes: { "w:val": "none" }
24447
+ };
24431
24448
  }
24432
24449
  const keyword = getDocxHighlightKeywordFromHex(highlightValue);
24433
24450
  if (keyword) {
@@ -27819,7 +27836,7 @@ const encode$d = (params2, encodedAttrs) => {
27819
27836
  if (filteredMarks.length !== existingMarks2.length) {
27820
27837
  if (filteredMarks.length) child = { ...child, marks: filteredMarks };
27821
27838
  else {
27822
- const { marks, ...rest } = child;
27839
+ const { marks: _removedMarks, ...rest } = child;
27823
27840
  child = rest;
27824
27841
  }
27825
27842
  }
@@ -28329,18 +28346,6 @@ function handleAnchorNode(params2) {
28329
28346
  }
28330
28347
  return handleImageNode(node, params2, true);
28331
28348
  }
28332
- const sanitizeDocxMediaName = (value, fallback = "image") => {
28333
- if (!value) return fallback;
28334
- const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
28335
- return sanitized || fallback;
28336
- };
28337
- const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
28338
- if (!src || typeof src !== "string") return fallback;
28339
- const [prefix2] = src.split(";");
28340
- const [, maybeType] = prefix2.split("/");
28341
- const extension = maybeType?.toLowerCase();
28342
- return extension ? `${fallback}.${extension}` : fallback;
28343
- };
28344
28349
  const translateImageNode = (params2) => {
28345
28350
  const {
28346
28351
  node: { attrs = {} },
@@ -29548,7 +29553,7 @@ class InputRule {
29548
29553
  }
29549
29554
  }
29550
29555
  const inputRuleMatcherHandler = (text, match) => {
29551
- if (isRegExp(match)) {
29556
+ if (isRegExp$1(match)) {
29552
29557
  return match.exec(text);
29553
29558
  }
29554
29559
  const inputRuleMatch = match(text);
@@ -31269,13 +31274,21 @@ function translateMark(mark) {
31269
31274
  markElement.name = "w:rStyle";
31270
31275
  markElement.attributes["w:val"] = attrs.styleId;
31271
31276
  break;
31272
- case "color":
31273
- let processedColor = attrs.color.replace(/^#/, "").replace(/;$/, "");
31277
+ case "color": {
31278
+ const rawColor = attrs.color;
31279
+ if (!rawColor) break;
31280
+ const normalized = String(rawColor).trim().toLowerCase();
31281
+ if (normalized === "inherit") {
31282
+ markElement.attributes["w:val"] = "auto";
31283
+ break;
31284
+ }
31285
+ let processedColor = String(rawColor).replace(/^#/, "").replace(/;$/, "");
31274
31286
  if (processedColor.startsWith("rgb")) {
31275
31287
  processedColor = rgbToHex(processedColor);
31276
31288
  }
31277
31289
  markElement.attributes["w:val"] = processedColor;
31278
31290
  break;
31291
+ }
31279
31292
  case "textAlign":
31280
31293
  markElement.attributes["w:val"] = attrs.textAlign;
31281
31294
  break;
@@ -32266,27 +32279,30 @@ function importCommentData({ docx, editor, converter }) {
32266
32279
  trackedChange,
32267
32280
  trackedChangeText,
32268
32281
  trackedChangeType,
32269
- trackedDeletedText
32282
+ trackedDeletedText,
32283
+ isDone: false
32270
32284
  };
32271
32285
  });
32272
32286
  const extendedComments = generateCommentsWithExtendedData({ docx, comments: extractedComments });
32273
32287
  return extendedComments;
32274
32288
  }
32275
32289
  const generateCommentsWithExtendedData = ({ docx, comments }) => {
32290
+ if (!comments?.length) return [];
32276
32291
  const commentsExtended = docx["word/commentsExtended.xml"];
32277
- if (!commentsExtended) return [];
32278
- const { elements: initialElements } = commentsExtended;
32279
- const { elements } = initialElements[0];
32292
+ if (!commentsExtended) return comments.map((comment) => ({ ...comment, isDone: comment.isDone ?? false }));
32293
+ const { elements: initialElements = [] } = commentsExtended;
32294
+ if (!initialElements?.length) return comments.map((comment) => ({ ...comment, isDone: comment.isDone ?? false }));
32295
+ const { elements = [] } = initialElements[0] ?? {};
32280
32296
  const commentEx = elements.filter((el) => el.name === "w15:commentEx");
32281
32297
  return comments.map((comment) => {
32282
32298
  const extendedDef = commentEx.find((ce2) => ce2.attributes["w15:paraId"] === comment.paraId);
32283
- if (!extendedDef) return { ...comment };
32299
+ if (!extendedDef) return { ...comment, isDone: comment.isDone ?? false };
32284
32300
  const { isDone, paraIdParent } = getExtendedDetails(extendedDef);
32285
32301
  let parentComment;
32286
32302
  if (paraIdParent) parentComment = comments.find((c2) => c2.paraId === paraIdParent);
32287
32303
  const newComment = {
32288
32304
  ...comment,
32289
- isDone,
32305
+ isDone: isDone ?? false,
32290
32306
  parentCommentId: parentComment?.commentId
32291
32307
  };
32292
32308
  return newComment;
@@ -33122,7 +33138,7 @@ const _SuperConverter = class _SuperConverter2 {
33122
33138
  return;
33123
33139
  }
33124
33140
  }
33125
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.21.0-RC2") {
33141
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.20.2") {
33126
33142
  const customLocation = "docProps/custom.xml";
33127
33143
  if (!docx[customLocation]) {
33128
33144
  docx[customLocation] = generateCustomXml();
@@ -33615,7 +33631,7 @@ function storeSuperdocVersion(docx) {
33615
33631
  function generateCustomXml() {
33616
33632
  return DEFAULT_CUSTOM_XML;
33617
33633
  }
33618
- function generateSuperdocVersion(pid = 2, version2 = "0.21.0-RC2") {
33634
+ function generateSuperdocVersion(pid = 2, version2 = "0.20.2") {
33619
33635
  return {
33620
33636
  type: "element",
33621
33637
  name: "property",
@@ -38054,17 +38070,18 @@ class NodeViewDesc extends ViewDesc {
38054
38070
  }
38055
38071
  // Mark this node as being the selected node.
38056
38072
  selectNode() {
38057
- if (this.nodeDOM.nodeType == 1)
38073
+ if (this.nodeDOM.nodeType == 1) {
38058
38074
  this.nodeDOM.classList.add("ProseMirror-selectednode");
38059
- if (this.contentDOM || !this.node.type.spec.draggable)
38060
- this.dom.draggable = true;
38075
+ if (this.contentDOM || !this.node.type.spec.draggable)
38076
+ this.nodeDOM.draggable = true;
38077
+ }
38061
38078
  }
38062
38079
  // Remove selected node marking from this node.
38063
38080
  deselectNode() {
38064
38081
  if (this.nodeDOM.nodeType == 1) {
38065
38082
  this.nodeDOM.classList.remove("ProseMirror-selectednode");
38066
38083
  if (this.contentDOM || !this.node.type.spec.draggable)
38067
- this.dom.removeAttribute("draggable");
38084
+ this.nodeDOM.removeAttribute("draggable");
38068
38085
  }
38069
38086
  }
38070
38087
  get domAtom() {
@@ -39724,7 +39741,7 @@ class MouseDown {
39724
39741
  }
39725
39742
  const target = flushed ? null : event.target;
39726
39743
  const targetDesc = target ? view.docView.nearestDesc(target, true) : null;
39727
- this.target = targetDesc && targetDesc.dom.nodeType == 1 ? targetDesc.dom : null;
39744
+ this.target = targetDesc && targetDesc.nodeDOM.nodeType == 1 ? targetDesc.nodeDOM : null;
39728
39745
  let { selection } = view.state;
39729
39746
  if (event.button == 0 && targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)
39730
39747
  this.mightDrag = {
@@ -47451,6 +47468,33 @@ const getTrackChangesDecorations = (state2, onlyOriginalShown, onlyModifiedShown
47451
47468
  return DecorationSet.create(state2.doc, decorations);
47452
47469
  };
47453
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
+ };
47454
47498
  const removeCommentsById = ({ commentId, state: state2, tr, dispatch }) => {
47455
47499
  const positions = getCommentPositionsById(commentId, state2.doc);
47456
47500
  positions.forEach(({ from: from2, to }) => {
@@ -47544,24 +47588,31 @@ const prepareCommentsForImport = (doc2, tr, schema, converter) => {
47544
47588
  const { type: type2 } = node;
47545
47589
  const commentNodes = ["commentRangeStart", "commentRangeEnd", "commentReference"];
47546
47590
  if (!commentNodes.includes(type2.name)) return;
47547
- const matchingImportedComment = converter.comments?.find((c2) => c2.importedId == node.attrs["w:id"]) || {};
47548
- const { commentId } = matchingImportedComment;
47549
- if (!commentId) return;
47591
+ const { resolvedCommentId, importedId, internal, matchingImportedComment } = resolveCommentMeta({
47592
+ converter,
47593
+ importedId: node.attrs["w:id"]
47594
+ });
47550
47595
  if (type2.name === "commentRangeStart") {
47551
47596
  toMark.push({
47552
- "w:id": commentId,
47553
- importedId: node.attrs["w:id"],
47554
- internal: false,
47597
+ commentId: resolvedCommentId,
47598
+ importedId,
47599
+ internal,
47555
47600
  start: pos
47556
47601
  });
47602
+ ensureFallbackComment({
47603
+ converter,
47604
+ matchingImportedComment,
47605
+ commentId: resolvedCommentId,
47606
+ importedId
47607
+ });
47557
47608
  toDelete.push({ start: pos, end: pos + 1 });
47558
47609
  } else if (type2.name === "commentRangeEnd") {
47559
- const itemToMark = toMark.find((p) => p.importedId === node.attrs["w:id"]);
47610
+ const itemToMark = toMark.find((p) => p.importedId === importedId);
47560
47611
  if (!itemToMark) return;
47561
47612
  const { start: start2 } = itemToMark;
47562
47613
  const markAttrs = {
47563
- commentId,
47564
- importedId: node.attrs["w:id"],
47614
+ commentId: itemToMark.commentId,
47615
+ importedId,
47565
47616
  internal: itemToMark.internal
47566
47617
  };
47567
47618
  tr.addMark(start2, pos + 1, schema.marks[CommentMarkName].create(markAttrs));
@@ -50970,7 +51021,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
50970
51021
  * @returns {Object | void} Migration results
50971
51022
  */
50972
51023
  processCollaborationMigrations() {
50973
- console.debug("[checkVersionMigrations] Current editor version", "0.21.0-RC2");
51024
+ console.debug("[checkVersionMigrations] Current editor version", "0.20.2");
50974
51025
  if (!this.options.ydoc) return;
50975
51026
  const metaMap = this.options.ydoc.getMap("meta");
50976
51027
  let docVersion = metaMap.get("version");
@@ -68848,8 +68899,8 @@ function getScaleFactor(element) {
68848
68899
  }
68849
68900
  class SearchQuery {
68850
68901
  /**
68851
- Create a query object.
68852
- */
68902
+ Create a query object.
68903
+ */
68853
68904
  constructor(config2) {
68854
68905
  this.search = config2.search;
68855
68906
  this.caseSensitive = !!config2.caseSensitive;
@@ -68862,72 +68913,70 @@ class SearchQuery {
68862
68913
  this.impl = !this.valid ? nullQuery : this.regexp ? new RegExpQuery(this) : new StringQuery(this);
68863
68914
  }
68864
68915
  /**
68865
- Compare this query to another query.
68866
- */
68916
+ Compare this query to another query.
68917
+ */
68867
68918
  eq(other) {
68868
68919
  return this.search == other.search && this.replace == other.replace && this.caseSensitive == other.caseSensitive && this.regexp == other.regexp && this.wholeWord == other.wholeWord;
68869
68920
  }
68870
68921
  /**
68871
- Find the next occurrence of this query in the given range.
68872
- */
68922
+ Find the next occurrence of this query in the given range.
68923
+ */
68873
68924
  findNext(state2, from2 = 0, to = state2.doc.content.size) {
68874
68925
  for (; ; ) {
68875
- if (from2 >= to)
68876
- return null;
68926
+ if (from2 >= to) return null;
68877
68927
  let result = this.impl.findNext(state2, from2, to);
68878
- if (!result || this.checkResult(state2, result))
68879
- return result;
68928
+ if (!result || this.checkResult(state2, result)) return result;
68880
68929
  from2 = result.from + 1;
68881
68930
  }
68882
68931
  }
68883
68932
  /**
68884
- Find the previous occurrence of this query in the given range.
68885
- Note that, if `to` is given, it should be _less_ than `from`.
68886
- */
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
+ */
68887
68936
  findPrev(state2, from2 = state2.doc.content.size, to = 0) {
68888
68937
  for (; ; ) {
68889
- if (from2 <= to)
68890
- return null;
68938
+ if (from2 <= to) return null;
68891
68939
  let result = this.impl.findPrev(state2, from2, to);
68892
- if (!result || this.checkResult(state2, result))
68893
- return result;
68940
+ if (!result || this.checkResult(state2, result)) return result;
68894
68941
  from2 = result.to - 1;
68895
68942
  }
68896
68943
  }
68897
68944
  /**
68898
- @internal
68899
- */
68945
+ @internal
68946
+ */
68900
68947
  checkResult(state2, result) {
68901
68948
  return (!this.wholeWord || checkWordBoundary(state2, result.from) && checkWordBoundary(state2, result.to)) && (!this.filter || this.filter(state2, result));
68902
68949
  }
68903
68950
  /**
68904
- @internal
68905
- */
68951
+ @internal
68952
+ */
68906
68953
  unquote(string) {
68907
68954
  return this.literal ? string : string.replace(/\\([nrt\\])/g, (_2, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? " " : "\\");
68908
68955
  }
68909
68956
  /**
68910
- Get the ranges that should be replaced for this result. This can
68911
- return multiple ranges when `this.replace` contains
68912
- `$1`/`$&`-style placeholders, in which case the preserved
68913
- content is skipped by the replacements.
68914
-
68915
- Ranges are sorted by position, and `from`/`to` positions all
68916
- refer to positions in `state.doc`. When applying these, you'll
68917
- want to either apply them from back to front, or map these
68918
- positions through your transaction's current mapping.
68919
- */
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
+ */
68920
68967
  getReplacements(state2, result) {
68921
68968
  let $from = state2.doc.resolve(result.from);
68922
68969
  let marks = $from.marksAcross(state2.doc.resolve(result.to));
68923
68970
  let ranges = [];
68924
68971
  let frag = Fragment.empty, pos = result.from, { match } = result;
68925
68972
  let groups = match ? getGroupIndices(match) : [[0, result.to - result.from]];
68926
- let replParts = parseReplacement(this.unquote(this.replace)), groupSpan;
68973
+ let replParts = parseReplacement(this.unquote(this.replace));
68927
68974
  for (let part of replParts) {
68928
68975
  if (typeof part == "string") {
68929
68976
  frag = frag.addToEnd(state2.schema.text(part, marks));
68930
- } else if (groupSpan = groups[part.group]) {
68977
+ } else {
68978
+ const groupSpan = groups[part.group];
68979
+ if (!groupSpan) continue;
68931
68980
  let from2 = result.matchStart + groupSpan[0], to = result.matchStart + groupSpan[1];
68932
68981
  if (part.copy) {
68933
68982
  frag = frag.append(state2.doc.slice(from2, to).content);
@@ -68957,8 +69006,7 @@ class StringQuery {
68957
69006
  constructor(query) {
68958
69007
  this.query = query;
68959
69008
  let string = query.unquote(query.search);
68960
- if (!query.caseSensitive)
68961
- string = string.toLowerCase();
69009
+ if (!query.caseSensitive) string = string.toLowerCase();
68962
69010
  this.string = string;
68963
69011
  }
68964
69012
  findNext(state2, from2, to) {
@@ -68966,17 +69014,26 @@ class StringQuery {
68966
69014
  let off2 = Math.max(from2, start2);
68967
69015
  let content = textContent(node).slice(off2 - start2, Math.min(node.content.size, to - start2));
68968
69016
  let index2 = (this.query.caseSensitive ? content : content.toLowerCase()).indexOf(this.string);
68969
- return index2 < 0 ? null : { from: off2 + index2, to: off2 + index2 + this.string.length, match: null, matchStart: start2 };
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 };
68970
69023
  });
68971
69024
  }
68972
69025
  findPrev(state2, from2, to) {
68973
69026
  return scanTextblocks(state2.doc, from2, to, (node, start2) => {
68974
69027
  let off2 = Math.max(start2, to);
68975
69028
  let content = textContent(node).slice(off2 - start2, Math.min(node.content.size, from2 - start2));
68976
- if (!this.query.caseSensitive)
68977
- content = content.toLowerCase();
69029
+ if (!this.query.caseSensitive) content = content.toLowerCase();
68978
69030
  let index2 = content.lastIndexOf(this.string);
68979
- return index2 < 0 ? null : { from: off2 + index2, to: off2 + index2 + this.string.length, match: null, matchStart: start2 };
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 };
68980
69037
  });
68981
69038
  }
68982
69039
  }
@@ -68991,7 +69048,11 @@ class RegExpQuery {
68991
69048
  let content = textContent(node).slice(0, Math.min(node.content.size, to - start2));
68992
69049
  this.regexp.lastIndex = from2 - start2;
68993
69050
  let match = this.regexp.exec(content);
68994
- return match ? { from: start2 + match.index, to: start2 + match.index + match[0].length, match, matchStart: start2 } : null;
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 };
68995
69056
  });
68996
69057
  }
68997
69058
  findPrev(state2, from2, to) {
@@ -69001,18 +69062,20 @@ class RegExpQuery {
69001
69062
  for (let off2 = 0; ; ) {
69002
69063
  this.regexp.lastIndex = off2;
69003
69064
  let next = this.regexp.exec(content);
69004
- if (!next)
69005
- break;
69065
+ if (!next) break;
69006
69066
  match = next;
69007
69067
  off2 = next.index + 1;
69008
69068
  }
69009
- return match ? { from: start2 + match.index, to: start2 + match.index + match[0].length, match, matchStart: start2 } : null;
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 };
69010
69074
  });
69011
69075
  }
69012
69076
  }
69013
69077
  function getGroupIndices(match) {
69014
- if (match.indices)
69015
- return match.indices;
69078
+ if (match.indices) return match.indices;
69016
69079
  let result = [[0, match[0].length]];
69017
69080
  for (let i = 1, pos = 0; i < match.length; i++) {
69018
69081
  let found2 = match[i] ? match[0].indexOf(match[i], pos) : -1;
@@ -69024,10 +69087,8 @@ function parseReplacement(text) {
69024
69087
  let result = [], highestSeen = -1;
69025
69088
  function add(text2) {
69026
69089
  let last = result.length - 1;
69027
- if (last > -1 && typeof result[last] == "string")
69028
- result[last] += text2;
69029
- else
69030
- result.push(text2);
69090
+ if (last > -1 && typeof result[last] == "string") result[last] += text2;
69091
+ else result.push(text2);
69031
69092
  }
69032
69093
  while (text.length) {
69033
69094
  let m2 = /\$([$&\d+])/.exec(text);
@@ -69035,8 +69096,7 @@ function parseReplacement(text) {
69035
69096
  add(text);
69036
69097
  return result;
69037
69098
  }
69038
- if (m2.index > 0)
69039
- 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)));
69040
69100
  if (m2[1] != "$") {
69041
69101
  let n = m2[1] == "&" ? 0 : +m2[1];
69042
69102
  if (highestSeen >= n) {
@@ -69054,30 +69114,50 @@ function validRegExp(source) {
69054
69114
  try {
69055
69115
  new RegExp(source, baseFlags);
69056
69116
  return true;
69057
- } catch (_a2) {
69117
+ } catch {
69058
69118
  return false;
69059
69119
  }
69060
69120
  }
69061
69121
  const TextContentCache = /* @__PURE__ */ new WeakMap();
69062
69122
  function textContent(node) {
69063
69123
  let cached = TextContentCache.get(node);
69064
- if (cached)
69065
- return cached;
69124
+ if (cached) return cached;
69066
69125
  let content = "";
69067
69126
  for (let i = 0; i < node.childCount; i++) {
69068
69127
  let child = node.child(i);
69069
- if (child.isText)
69070
- content += child.text;
69071
- else if (child.isLeaf)
69072
- content += "";
69073
- else
69074
- 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) + " ";
69075
69132
  }
69076
69133
  TextContentCache.set(node, content);
69077
69134
  return content;
69078
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"]);
69079
69158
  function scanTextblocks(node, from2, to, f, nodeStart = 0) {
69080
- if (node.inlineContent) {
69159
+ const isTransparentInline = node.inlineContent && node.type && transparentInlineNodes.has(node.type.name);
69160
+ if (node.inlineContent && !isTransparentInline) {
69081
69161
  return f(node, nodeStart);
69082
69162
  } else if (!node.isLeaf) {
69083
69163
  if (from2 > to) {
@@ -69086,8 +69166,7 @@ function scanTextblocks(node, from2, to, f, nodeStart = 0) {
69086
69166
  pos -= child.nodeSize;
69087
69167
  if (pos < from2) {
69088
69168
  let result = scanTextblocks(child, from2, to, f, pos + 1);
69089
- if (result != null)
69090
- return result;
69169
+ if (result != null) return result;
69091
69170
  }
69092
69171
  }
69093
69172
  } else {
@@ -69096,8 +69175,7 @@ function scanTextblocks(node, from2, to, f, nodeStart = 0) {
69096
69175
  pos += child.nodeSize;
69097
69176
  if (pos > from2) {
69098
69177
  let result = scanTextblocks(child, from2, to, f, start2 + 1);
69099
- if (result != null)
69100
- return result;
69178
+ if (result != null) return result;
69101
69179
  }
69102
69180
  }
69103
69181
  }
@@ -69107,8 +69185,7 @@ function scanTextblocks(node, from2, to, f, nodeStart = 0) {
69107
69185
  function checkWordBoundary(state2, pos) {
69108
69186
  let $pos = state2.doc.resolve(pos);
69109
69187
  let before = $pos.nodeBefore, after = $pos.nodeAfter;
69110
- if (!before || !after || !before.isText || !after.isText)
69111
- return true;
69188
+ if (!before || !after || !before.isText || !after.isText) return true;
69112
69189
  return !/\p{L}$/u.test(before.text) || !/^\p{L}/u.test(after.text);
69113
69190
  }
69114
69191
  class SearchState {
@@ -69119,14 +69196,12 @@ class SearchState {
69119
69196
  }
69120
69197
  }
69121
69198
  function buildMatchDeco(state2, query, range2) {
69122
- if (!query.valid)
69123
- return DecorationSet.empty;
69199
+ if (!query.valid) return DecorationSet.empty;
69124
69200
  let deco = [];
69125
69201
  let sel = state2.selection;
69126
69202
  for (let pos = range2 ? range2.from : 0, end2 = range2 ? range2.to : state2.doc.content.size; ; ) {
69127
69203
  let next = query.findNext(state2, pos, end2);
69128
- if (!next)
69129
- break;
69204
+ if (!next) break;
69130
69205
  let cls = next.from == sel.from && next.to == sel.to ? "ProseMirror-active-search-match" : "ProseMirror-search-match";
69131
69206
  deco.push(Decoration.inline(next.from, next.to, { class: cls }));
69132
69207
  pos = next.to;
@@ -69145,8 +69220,7 @@ function search(options = {}) {
69145
69220
  },
69146
69221
  apply(tr, search2, _oldState, state2) {
69147
69222
  let set = tr.getMeta(searchKey);
69148
- if (set)
69149
- 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));
69150
69224
  if (tr.docChanged || tr.selectionSet) {
69151
69225
  let range2 = search2.range;
69152
69226
  if (range2) {
@@ -69171,6 +69245,7 @@ function getMatchHighlights(state2) {
69171
69245
  function setSearchState(tr, query, range2 = null) {
69172
69246
  return tr.setMeta(searchKey, { query, range: range2 });
69173
69247
  }
69248
+ const isRegExp = (value) => Object.prototype.toString.call(value) === "[object RegExp]";
69174
69249
  const Search = Extension.create({
69175
69250
  addStorage() {
69176
69251
  return {
@@ -69240,10 +69315,14 @@ const Search = Extension.create({
69240
69315
  let caseSensitive = false;
69241
69316
  let regexp = false;
69242
69317
  const wholeWord = false;
69243
- if (patternInput instanceof RegExp) {
69318
+ if (isRegExp(patternInput)) {
69319
+ const regexPattern = (
69320
+ /** @type {RegExp} */
69321
+ patternInput
69322
+ );
69244
69323
  regexp = true;
69245
- pattern = patternInput.source;
69246
- caseSensitive = !patternInput.flags.includes("i");
69324
+ pattern = regexPattern.source;
69325
+ caseSensitive = !regexPattern.flags.includes("i");
69247
69326
  } else if (typeof patternInput === "string" && /^\/(.+)\/([gimsuy]*)$/.test(patternInput)) {
69248
69327
  const [, body, flags] = patternInput.match(/^\/(.+)\/([gimsuy]*)$/);
69249
69328
  regexp = true;
@@ -72148,7 +72227,7 @@ function resolveTo(selector) {
72148
72227
  if (typeof selector === "string") {
72149
72228
  return document.querySelector(selector);
72150
72229
  }
72151
- return selector();
72230
+ return selector() || null;
72152
72231
  }
72153
72232
  const LazyTeleport = vue.defineComponent({
72154
72233
  name: "LazyTeleport",
@@ -72236,8 +72315,11 @@ const oppositeAlignCssPositionProps = {
72236
72315
  };
72237
72316
  const keepOffsetDirection = {
72238
72317
  top: true,
72318
+ // top++
72239
72319
  bottom: false,
72320
+ // top--
72240
72321
  left: true,
72322
+ // left++
72241
72323
  right: false
72242
72324
  // left--
72243
72325
  };
@@ -73354,7 +73436,6 @@ function isFocusable(element) {
73354
73436
  return !!element.href && element.rel !== "ignore";
73355
73437
  case "INPUT":
73356
73438
  return element.type !== "hidden" && element.type !== "file";
73357
- case "BUTTON":
73358
73439
  case "SELECT":
73359
73440
  case "TEXTAREA":
73360
73441
  return true;
@@ -73373,8 +73454,8 @@ const FocusTrap = vue.defineComponent({
73373
73454
  default: true
73374
73455
  },
73375
73456
  onEsc: Function,
73376
- initialFocusTo: String,
73377
- finalFocusTo: String,
73457
+ initialFocusTo: [String, Function],
73458
+ finalFocusTo: [String, Function],
73378
73459
  returnFocusOnDeactivated: {
73379
73460
  type: Boolean,
73380
73461
  default: true
@@ -75472,6 +75553,7 @@ function self$6(vars) {
75472
75553
  });
75473
75554
  }
75474
75555
  const scrollbarLight = {
75556
+ name: "Scrollbar",
75475
75557
  common: derived,
75476
75558
  self: self$6
75477
75559
  };
@@ -76987,11 +77069,14 @@ function self$5(vars) {
76987
77069
  boxShadow: boxShadow2
76988
77070
  });
76989
77071
  }
76990
- const popoverLight = {
77072
+ const popoverLight = createTheme({
76991
77073
  name: "Popover",
76992
77074
  common: derived,
77075
+ peers: {
77076
+ Scrollbar: scrollbarLight
77077
+ },
76993
77078
  self: self$5
76994
- };
77079
+ });
76995
77080
  const oppositePlacement = {
76996
77081
  top: "bottom",
76997
77082
  bottom: "top",
@@ -77211,9 +77296,11 @@ const NPopoverBody = vue.defineComponent({
77211
77296
  const {
77212
77297
  namespaceRef,
77213
77298
  mergedClsPrefixRef,
77214
- inlineThemeDisabled
77299
+ inlineThemeDisabled,
77300
+ mergedRtlRef
77215
77301
  } = useConfig(props);
77216
77302
  const themeRef = useTheme("Popover", "-popover", style$3, popoverLight, props, mergedClsPrefixRef);
77303
+ const rtlEnabledRef = useRtl("Popover", mergedRtlRef, mergedClsPrefixRef);
77217
77304
  const followerRef = vue.ref(null);
77218
77305
  const NPopover2 = vue.inject("NPopover");
77219
77306
  const bodyRef = vue.ref(null);
@@ -77411,6 +77498,8 @@ const NPopoverBody = vue.defineComponent({
77411
77498
  style: props.contentStyle
77412
77499
  }, slots);
77413
77500
  const maybeScrollableBody = props.scrollable ? vue.h(XScrollbar, {
77501
+ themeOverrides: themeRef.value.peerOverrides.Scrollbar,
77502
+ theme: themeRef.value.peers.Scrollbar,
77414
77503
  contentClass: hasHeaderOrFooter ? void 0 : `${mergedClsPrefix}-popover__content ${(_b = props.contentClass) !== null && _b !== void 0 ? _b : ""}`,
77415
77504
  contentStyle: hasHeaderOrFooter ? void 0 : props.contentStyle
77416
77505
  }, {
@@ -77426,7 +77515,7 @@ const NPopoverBody = vue.defineComponent({
77426
77515
  return [maybeScrollableBody, arrow2];
77427
77516
  };
77428
77517
  contentNode = vue.h("div", vue.mergeProps({
77429
- class: [`${mergedClsPrefix}-popover`, `${mergedClsPrefix}-popover-shared`, themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass.value, extraClass.map((v2) => `${mergedClsPrefix}-${v2}`), {
77518
+ class: [`${mergedClsPrefix}-popover`, `${mergedClsPrefix}-popover-shared`, (rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) && `${mergedClsPrefix}-popover--rtl`, themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass.value, extraClass.map((v2) => `${mergedClsPrefix}-${v2}`), {
77430
77519
  [`${mergedClsPrefix}-popover--scrollable`]: props.scrollable,
77431
77520
  [`${mergedClsPrefix}-popover--show-header-or-footer`]: hasHeaderOrFooter,
77432
77521
  [`${mergedClsPrefix}-popover--raw`]: props.raw,
@@ -77450,7 +77539,7 @@ const NPopoverBody = vue.defineComponent({
77450
77539
  // The popover class and overlap class must exists, they will be used
77451
77540
  // to place the body & transition animation.
77452
77541
  // Shadow class exists for reuse box-shadow.
77453
- [`${mergedClsPrefix}-popover-shared`, themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass.value, props.overlap && `${mergedClsPrefix}-popover-shared--overlap`, props.showArrow && `${mergedClsPrefix}-popover-shared--show-arrow`, props.arrowPointToCenter && `${mergedClsPrefix}-popover-shared--center-arrow`],
77542
+ [`${mergedClsPrefix}-popover-shared`, (rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) && `${mergedClsPrefix}-popover--rtl`, themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass.value, props.overlap && `${mergedClsPrefix}-popover-shared--overlap`, props.showArrow && `${mergedClsPrefix}-popover-shared--show-arrow`, props.arrowPointToCenter && `${mergedClsPrefix}-popover-shared--center-arrow`],
77454
77543
  bodyRef,
77455
77544
  styleRef.value,
77456
77545
  handleMouseEnter,