@harbour-enterprises/superdoc 0.14.5-next.1 → 0.14.5-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.
Files changed (30) hide show
  1. package/dist/chunks/{super-editor.es-CbdU9k19.cjs → super-editor.es-CFpGpOoc.cjs} +492 -351
  2. package/dist/chunks/{super-editor.es-C6n5_0Ab.es.js → super-editor.es-CiA4uq6O.es.js} +492 -351
  3. package/dist/style.css +169 -169
  4. package/dist/super-editor/ai-writer.es.js +2 -2
  5. package/dist/super-editor/chunks/{converter-B7H3Sf5_.js → converter-CqN1dLza.js} +31 -25
  6. package/dist/super-editor/chunks/{docx-zipper-CRnln7Lc.js → docx-zipper-BFOjwdTS.js} +1 -1
  7. package/dist/super-editor/chunks/{editor-qdpgLEYR.js → editor-BgFDYm6H.js} +17 -16
  8. package/dist/super-editor/chunks/{toolbar-D_-x5OZN.js → toolbar-DVtiKzYb.js} +2 -2
  9. package/dist/super-editor/components/slash-menu/menuItems.d.ts.map +1 -1
  10. package/dist/super-editor/components/toolbar/defaultItems.d.ts.map +1 -1
  11. package/dist/super-editor/components/toolbar/super-toolbar.d.ts.map +1 -1
  12. package/dist/super-editor/converter.es.js +1 -1
  13. package/dist/super-editor/core/InputRule.d.ts +26 -0
  14. package/dist/super-editor/core/InputRule.d.ts.map +1 -1
  15. package/dist/super-editor/core/inputRules/docx-paste/docx-paste.d.ts +1 -1
  16. package/dist/super-editor/core/inputRules/docx-paste/docx-paste.d.ts.map +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/extensions/link/link.d.ts.map +1 -1
  20. package/dist/super-editor/file-zipper.es.js +1 -1
  21. package/dist/super-editor/style.css +169 -169
  22. package/dist/super-editor/super-editor.es.js +411 -275
  23. package/dist/super-editor/toolbar.es.js +2 -2
  24. package/dist/super-editor.cjs +1 -1
  25. package/dist/super-editor.es.js +1 -1
  26. package/dist/superdoc.cjs +2 -2
  27. package/dist/superdoc.es.js +3 -3
  28. package/dist/superdoc.umd.js +493 -352
  29. package/dist/superdoc.umd.js.map +1 -1
  30. package/package.json +1 -1
@@ -22417,7 +22417,7 @@
22417
22417
  found.
22418
22418
  */
22419
22419
  static findFrom($pos, dir, textOnly = false) {
22420
- let inner = $pos.parent.inlineContent ? new TextSelection($pos) : findSelectionIn($pos.node(0), $pos.parent, $pos.pos, $pos.index(), dir, textOnly);
22420
+ let inner = $pos.parent.inlineContent ? new TextSelection$1($pos) : findSelectionIn($pos.node(0), $pos.parent, $pos.pos, $pos.index(), dir, textOnly);
22421
22421
  if (inner)
22422
22422
  return inner;
22423
22423
  for (let depth = $pos.depth - 1; depth >= 0; depth--) {
@@ -22486,7 +22486,7 @@
22486
22486
  returns the bookmark for that.
22487
22487
  */
22488
22488
  getBookmark() {
22489
- return TextSelection.between(this.$anchor, this.$head).getBookmark();
22489
+ return TextSelection$1.between(this.$anchor, this.$head).getBookmark();
22490
22490
  }
22491
22491
  }
22492
22492
  Selection.prototype.visible = true;
@@ -22506,7 +22506,7 @@
22506
22506
  console["warn"]("TextSelection endpoint not pointing into a node with inline content (" + $pos.parent.type.name + ")");
22507
22507
  }
22508
22508
  }
22509
- class TextSelection extends Selection {
22509
+ let TextSelection$1 = class TextSelection2 extends Selection {
22510
22510
  /**
22511
22511
  Construct a text selection between the given points.
22512
22512
  */
@@ -22527,7 +22527,7 @@
22527
22527
  if (!$head.parent.inlineContent)
22528
22528
  return Selection.near($head);
22529
22529
  let $anchor = doc2.resolve(mapping.map(this.anchor));
22530
- return new TextSelection($anchor.parent.inlineContent ? $anchor : $head, $head);
22530
+ return new TextSelection2($anchor.parent.inlineContent ? $anchor : $head, $head);
22531
22531
  }
22532
22532
  replace(tr, content = Slice.empty) {
22533
22533
  super.replace(tr, content);
@@ -22538,7 +22538,7 @@
22538
22538
  }
22539
22539
  }
22540
22540
  eq(other) {
22541
- return other instanceof TextSelection && other.anchor == this.anchor && other.head == this.head;
22541
+ return other instanceof TextSelection2 && other.anchor == this.anchor && other.head == this.head;
22542
22542
  }
22543
22543
  getBookmark() {
22544
22544
  return new TextBookmark(this.anchor, this.head);
@@ -22552,7 +22552,7 @@
22552
22552
  static fromJSON(doc2, json) {
22553
22553
  if (typeof json.anchor != "number" || typeof json.head != "number")
22554
22554
  throw new RangeError("Invalid input for TextSelection.fromJSON");
22555
- return new TextSelection(doc2.resolve(json.anchor), doc2.resolve(json.head));
22555
+ return new TextSelection2(doc2.resolve(json.anchor), doc2.resolve(json.head));
22556
22556
  }
22557
22557
  /**
22558
22558
  Create a text selection from non-resolved positions.
@@ -22589,10 +22589,10 @@
22589
22589
  $anchor = $head;
22590
22590
  }
22591
22591
  }
22592
- return new TextSelection($anchor, $head);
22592
+ return new TextSelection2($anchor, $head);
22593
22593
  }
22594
- }
22595
- Selection.jsonID("text", TextSelection);
22594
+ };
22595
+ Selection.jsonID("text", TextSelection$1);
22596
22596
  class TextBookmark {
22597
22597
  constructor(anchor, head) {
22598
22598
  this.anchor = anchor;
@@ -22602,7 +22602,7 @@
22602
22602
  return new TextBookmark(mapping.map(this.anchor), mapping.map(this.head));
22603
22603
  }
22604
22604
  resolve(doc2) {
22605
- return TextSelection.between(doc2.resolve(this.anchor), doc2.resolve(this.head));
22605
+ return TextSelection$1.between(doc2.resolve(this.anchor), doc2.resolve(this.head));
22606
22606
  }
22607
22607
  }
22608
22608
  class NodeSelection extends Selection {
@@ -22721,7 +22721,7 @@
22721
22721
  };
22722
22722
  function findSelectionIn(doc2, node2, pos, index2, dir, text = false) {
22723
22723
  if (node2.inlineContent)
22724
- return TextSelection.create(doc2, pos);
22724
+ return TextSelection$1.create(doc2, pos);
22725
22725
  for (let i2 = index2 - (dir > 0 ? 0 : 1); dir > 0 ? i2 < node2.childCount : i2 >= 0; i2 += dir) {
22726
22726
  let child = node2.child(i2);
22727
22727
  if (!child.isAtom) {
@@ -26439,7 +26439,7 @@
26439
26439
  };
26440
26440
  const handleDocxPaste = (html, editor, view, plugin2) => {
26441
26441
  const { converter } = editor;
26442
- if (!converter || !converter.convertedXml) return handleHtmlPaste(html, editor, view, plugin2);
26442
+ if (!converter || !converter.convertedXml) return handleHtmlPaste(html, editor);
26443
26443
  let cleanedHtml = convertEmToPt(html);
26444
26444
  cleanedHtml = cleanHtmlUnnecessaryTags(cleanedHtml);
26445
26445
  const tempDiv = document.createElement("div");
@@ -26759,29 +26759,13 @@
26759
26759
  const clipboard = event.clipboardData;
26760
26760
  const html = clipboard.getData("text/html");
26761
26761
  clipboard.getData("text/plain");
26762
- const fieldAnnotationContent = slice.content.content.filter((item) => item.type.name === "fieldAnnotation");
26762
+ const fieldAnnotationContent = slice.content.content.filter(
26763
+ (item) => item.type.name === "fieldAnnotation"
26764
+ );
26763
26765
  if (fieldAnnotationContent.length) {
26764
26766
  return false;
26765
26767
  }
26766
- let source;
26767
- if (!html) {
26768
- source = "plain-text";
26769
- } else if (isWordHtml(html)) {
26770
- source = "word-html";
26771
- } else {
26772
- source = "browser-html";
26773
- }
26774
- switch (source) {
26775
- case "plain-text":
26776
- break;
26777
- case "word-html":
26778
- if (editor.options.mode === "docx") {
26779
- return handleDocxPaste(html, editor, view, plugin2);
26780
- }
26781
- case "browser-html":
26782
- return handleHtmlPaste$1(html, editor);
26783
- }
26784
- return false;
26768
+ return handleClipboardPaste({ editor, view }, html);
26785
26769
  }
26786
26770
  },
26787
26771
  isInputRules: true
@@ -26791,7 +26775,7 @@
26791
26775
  function isWordHtml(html) {
26792
26776
  return /class=["']?Mso|xmlns:o=["']?urn:schemas-microsoft-com|<!--\[if gte mso|<meta[^>]+name=["']?Generator["']?[^>]+Word/i.test(html);
26793
26777
  }
26794
- const handleHtmlPaste$1 = (html, editor) => {
26778
+ function handleHtmlPaste(html, editor) {
26795
26779
  const htmlWithPtSizing = convertEmToPt(html);
26796
26780
  const cleanedHtml = sanitizeHtml(htmlWithPtSizing);
26797
26781
  const doc2 = DOMParser$1.fromSchema(editor.schema).parse(cleanedHtml);
@@ -26808,7 +26792,7 @@
26808
26792
  dispatch(state2.tr.replaceSelectionWith(doc2, true));
26809
26793
  }
26810
26794
  return true;
26811
- };
26795
+ }
26812
26796
  const convertEmToPt = (html) => {
26813
26797
  return html.replace(
26814
26798
  /font-size\s*:\s*([\d.]+)em/gi,
@@ -26840,6 +26824,27 @@
26840
26824
  walkAndClean(container);
26841
26825
  return container;
26842
26826
  }
26827
+ function handleClipboardPaste({ editor, view }, html, text) {
26828
+ let source;
26829
+ if (!html) {
26830
+ source = "plain-text";
26831
+ } else if (isWordHtml(html)) {
26832
+ source = "word-html";
26833
+ } else {
26834
+ source = "browser-html";
26835
+ }
26836
+ switch (source) {
26837
+ case "plain-text":
26838
+ return false;
26839
+ case "word-html":
26840
+ if (editor.options.mode === "docx") {
26841
+ return handleDocxPaste(html, editor, view);
26842
+ }
26843
+ case "browser-html":
26844
+ return handleHtmlPaste(html, editor);
26845
+ }
26846
+ return false;
26847
+ }
26843
26848
  function exportSchemaToJson(params2) {
26844
26849
  const { type: type2 } = params2.node || {};
26845
26850
  const router = {
@@ -31721,7 +31726,7 @@
31721
31726
  return;
31722
31727
  }
31723
31728
  }
31724
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.14.5-next.1") {
31729
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.14.5-next.3") {
31725
31730
  const customLocation = "docProps/custom.xml";
31726
31731
  if (!docx[customLocation]) {
31727
31732
  docx[customLocation] = generateCustomXml();
@@ -32197,7 +32202,7 @@
32197
32202
  function generateCustomXml() {
32198
32203
  return DEFAULT_CUSTOM_XML;
32199
32204
  }
32200
- function generateSuperdocVersion(pid = 2, version2 = "0.14.5-next.1") {
32205
+ function generateSuperdocVersion(pid = 2, version2 = "0.14.5-next.3") {
32201
32206
  return {
32202
32207
  type: "element",
32203
32208
  name: "property",
@@ -35935,7 +35940,7 @@
35935
35940
  const { from: from2 } = tr.selection;
35936
35941
  const tabText = state2.schema.text(" ");
35937
35942
  tr = tr.replaceSelectionWith(tabText);
35938
- tr = tr.setSelection(TextSelection.create(tr.doc, from2 + 1));
35943
+ tr = tr.setSelection(TextSelection$1.create(tr.doc, from2 + 1));
35939
35944
  if (dispatch) dispatch(tr);
35940
35945
  return true;
35941
35946
  };
@@ -36172,7 +36177,7 @@
36172
36177
  if (dispatch) {
36173
36178
  let side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to).pos;
36174
36179
  let tr = state2.tr.insert(side, type2.createAndFill());
36175
- tr.setSelection(TextSelection.create(tr.doc, side + 1));
36180
+ tr.setSelection(TextSelection$1.create(tr.doc, side + 1));
36176
36181
  dispatch(tr.scrollIntoView());
36177
36182
  }
36178
36183
  return true;
@@ -36226,7 +36231,7 @@
36226
36231
  }
36227
36232
  }
36228
36233
  let tr = state2.tr;
36229
- if (state2.selection instanceof TextSelection || state2.selection instanceof AllSelection)
36234
+ if (state2.selection instanceof TextSelection$1 || state2.selection instanceof AllSelection)
36230
36235
  tr.deleteSelection();
36231
36236
  let splitPos = tr.mapping.map($from.pos);
36232
36237
  let can = canSplit(tr.doc, splitPos, types2.length, types2);
@@ -36331,7 +36336,7 @@
36331
36336
  if (!$pos.node(depth).isTextblock)
36332
36337
  return false;
36333
36338
  if (dispatch)
36334
- dispatch(state2.tr.setSelection(TextSelection.create(state2.doc, side < 0 ? $pos.start(depth) : $pos.end(depth))));
36339
+ dispatch(state2.tr.setSelection(TextSelection$1.create(state2.doc, side < 0 ? $pos.start(depth) : $pos.end(depth))));
36335
36340
  return true;
36336
36341
  };
36337
36342
  }
@@ -36413,7 +36418,7 @@
36413
36418
  if (!$from.parent.isBlock) return false;
36414
36419
  if (dispatch) {
36415
36420
  const atEnd = $to.parentOffset === $to.parent.content.size;
36416
- if (selection instanceof TextSelection) tr.deleteSelection();
36421
+ if (selection instanceof TextSelection$1) tr.deleteSelection();
36417
36422
  const deflt = $from.depth === 0 ? null : defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1)));
36418
36423
  let types2 = atEnd && deflt ? [{ type: deflt, attrs: newAttrs }] : void 0;
36419
36424
  let can = canSplit(tr.doc, tr.mapping.map($from.pos), 1, types2);
@@ -36764,7 +36769,7 @@
36764
36769
  tr.delete(oldParaPos, oldParaPos + $from.parent.nodeSize);
36765
36770
  const insertPos = paraStartPos + 1 + targetPara.content.size;
36766
36771
  tr.insert(insertPos, inlineContent);
36767
- tr.setSelection(TextSelection.near(tr.doc.resolve(insertPos), 1));
36772
+ tr.setSelection(TextSelection$1.near(tr.doc.resolve(insertPos), 1));
36768
36773
  dispatch(tr);
36769
36774
  return true;
36770
36775
  };
@@ -36808,7 +36813,7 @@
36808
36813
  tr.delete(nextListStartPos, nextListStartPos + nextNode.nodeSize);
36809
36814
  const insertPos = tr.mapping.map($from.pos);
36810
36815
  tr.insert(insertPos, targetInlineContent);
36811
- tr.setSelection(TextSelection.near(tr.doc.resolve(insertPos), 1));
36816
+ tr.setSelection(TextSelection$1.near(tr.doc.resolve(insertPos), 1));
36812
36817
  dispatch(tr);
36813
36818
  return true;
36814
36819
  } else {
@@ -36831,7 +36836,7 @@
36831
36836
  tr.delete(listStartPos, listStartPos + afterNode.nodeSize);
36832
36837
  const insertPos = tr.mapping.map($from.pos);
36833
36838
  tr.insert(insertPos, targetInlineContent);
36834
- tr.setSelection(TextSelection.near(tr.doc.resolve(insertPos), 1));
36839
+ tr.setSelection(TextSelection$1.near(tr.doc.resolve(insertPos), 1));
36835
36840
  dispatch(tr);
36836
36841
  return true;
36837
36842
  }
@@ -38774,10 +38779,10 @@
38774
38779
  const setSelectionInsideNewList = (tr, basePos) => {
38775
38780
  try {
38776
38781
  const $pos = tr.doc.resolve(basePos + 3);
38777
- tr.setSelection(TextSelection.near($pos));
38782
+ tr.setSelection(TextSelection$1.near($pos));
38778
38783
  } catch {
38779
38784
  const $fallback = tr.doc.resolve(basePos + 1);
38780
- tr.setSelection(TextSelection.near($fallback));
38785
+ tr.setSelection(TextSelection$1.near($fallback));
38781
38786
  }
38782
38787
  };
38783
38788
  const replaceListWithNode = ({ tr, from: from2, to, newNode }) => {
@@ -38794,7 +38799,7 @@
38794
38799
  replaceListWithNode({ tr, from: replaceFrom, to: replaceTo, newNode: paragraphNode });
38795
38800
  const newPos = replaceFrom + 1;
38796
38801
  const $pos = tr.doc.resolve(newPos);
38797
- tr.setSelection(TextSelection.near($pos));
38802
+ tr.setSelection(TextSelection$1.near($pos));
38798
38803
  return true;
38799
38804
  };
38800
38805
  const insertNewList = (tr, replaceFrom, replaceTo, listNode, marks = []) => {
@@ -38805,7 +38810,7 @@
38805
38810
  const paragraphNode = $paragraphStart.parent;
38806
38811
  const endPos = $paragraphStart.pos + paragraphNode.content.size;
38807
38812
  const $endPos = tr.doc.resolve(endPos);
38808
- tr.setSelection(TextSelection.near($endPos));
38813
+ tr.setSelection(TextSelection$1.near($endPos));
38809
38814
  return true;
38810
38815
  };
38811
38816
  const getListItemStyleDefinitions = ({ styleId, node: node2, numId, level, editor, tries }) => {
@@ -39003,7 +39008,7 @@
39003
39008
  const insertPosition = listStart + firstList.nodeSize;
39004
39009
  tr.insert(insertPosition, secondList);
39005
39010
  const secondListStart = insertPosition + 2;
39006
- tr.setSelection(TextSelection.near(tr.doc.resolve(secondListStart)));
39011
+ tr.setSelection(TextSelection$1.near(tr.doc.resolve(secondListStart)));
39007
39012
  tr.scrollIntoView();
39008
39013
  const marks = state2.storedMarks || $from.marks() || [];
39009
39014
  if (marks?.length) {
@@ -39038,7 +39043,7 @@
39038
39043
  const insertPos = parentList.pos + parentList.node.nodeSize;
39039
39044
  tr.insert(insertPos, newList);
39040
39045
  const newPos = insertPos + 2;
39041
- tr.setSelection(TextSelection.near(tr.doc.resolve(newPos)));
39046
+ tr.setSelection(TextSelection$1.near(tr.doc.resolve(newPos)));
39042
39047
  tr.scrollIntoView();
39043
39048
  return true;
39044
39049
  } catch (error) {
@@ -39087,7 +39092,7 @@
39087
39092
  const listEnd = parentList.pos + parentList.node.nodeSize;
39088
39093
  tr.replaceWith(listStart, listEnd, newParagraph);
39089
39094
  const newPos = listStart + 1;
39090
- tr.setSelection(TextSelection.near(tr.doc.resolve(newPos)));
39095
+ tr.setSelection(TextSelection$1.near(tr.doc.resolve(newPos)));
39091
39096
  tr.scrollIntoView();
39092
39097
  return true;
39093
39098
  } catch (error) {
@@ -39122,7 +39127,7 @@
39122
39127
  tr.delete(pos, pos + size2);
39123
39128
  });
39124
39129
  const $new = tr.doc.resolve(from2);
39125
- tr.setSelection(TextSelection.near($new));
39130
+ tr.setSelection(TextSelection$1.near($new));
39126
39131
  return true;
39127
39132
  }
39128
39133
  return false;
@@ -39150,7 +39155,7 @@
39150
39155
  });
39151
39156
  tr.replaceWith(listFrom, listTo, nodes);
39152
39157
  const $pos = tr.doc.resolve(listFrom + 1);
39153
- tr.setSelection(TextSelection.near($pos));
39158
+ tr.setSelection(TextSelection$1.near($pos));
39154
39159
  return true;
39155
39160
  };
39156
39161
  const increaseListIndent = () => ({ editor, tr }) => {
@@ -40587,7 +40592,7 @@
40587
40592
  }
40588
40593
  localCompositionInfo(view, pos) {
40589
40594
  let { from: from2, to } = view.state.selection;
40590
- if (!(view.state.selection instanceof TextSelection) || from2 < pos || to > pos + this.node.content.size)
40595
+ if (!(view.state.selection instanceof TextSelection$1) || from2 < pos || to > pos + this.node.content.size)
40591
40596
  return null;
40592
40597
  let textNode = view.input.compositionNode;
40593
40598
  if (!textNode || !this.dom.contains(textNode.parentNode))
@@ -41353,7 +41358,7 @@
41353
41358
  selectCursorWrapper(view);
41354
41359
  } else {
41355
41360
  let { anchor, head } = sel, resetEditableFrom, resetEditableTo;
41356
- if (brokenSelectBetweenUneditable && !(sel instanceof TextSelection)) {
41361
+ if (brokenSelectBetweenUneditable && !(sel instanceof TextSelection$1)) {
41357
41362
  if (!sel.$from.parent.inlineContent)
41358
41363
  resetEditableFrom = temporarilyEditableNear(view, sel.from);
41359
41364
  if (!sel.empty && !sel.$from.parent.inlineContent)
@@ -41459,7 +41464,7 @@
41459
41464
  }
41460
41465
  }
41461
41466
  function selectionBetween(view, $anchor, $head, bias) {
41462
- return view.someProp("createSelectionBetween", (f) => f(view, $anchor, $head)) || TextSelection.between($anchor, $head, bias);
41467
+ return view.someProp("createSelectionBetween", (f) => f(view, $anchor, $head)) || TextSelection$1.between($anchor, $head, bias);
41463
41468
  }
41464
41469
  function hasFocusAndSelection(view) {
41465
41470
  if (view.editable && !view.hasFocus())
@@ -41493,13 +41498,13 @@
41493
41498
  }
41494
41499
  function selectHorizontally(view, dir, mods) {
41495
41500
  let sel = view.state.selection;
41496
- if (sel instanceof TextSelection) {
41501
+ if (sel instanceof TextSelection$1) {
41497
41502
  if (mods.indexOf("s") > -1) {
41498
41503
  let { $head } = sel, node2 = $head.textOffset ? null : dir < 0 ? $head.nodeBefore : $head.nodeAfter;
41499
41504
  if (!node2 || node2.isText || !node2.isLeaf)
41500
41505
  return false;
41501
41506
  let $newHead = view.state.doc.resolve($head.pos + node2.nodeSize * (dir < 0 ? -1 : 1));
41502
- return apply$2(view, new TextSelection(sel.$anchor, $newHead));
41507
+ return apply$2(view, new TextSelection$1(sel.$anchor, $newHead));
41503
41508
  } else if (!sel.empty) {
41504
41509
  return false;
41505
41510
  } else if (view.endOfTextblock(dir > 0 ? "forward" : "backward")) {
@@ -41517,13 +41522,13 @@
41517
41522
  if (NodeSelection.isSelectable(node2)) {
41518
41523
  return apply$2(view, new NodeSelection(dir < 0 ? view.state.doc.resolve($head.pos - node2.nodeSize) : $head));
41519
41524
  } else if (webkit) {
41520
- return apply$2(view, new TextSelection(view.state.doc.resolve(dir < 0 ? nodePos : nodePos + node2.nodeSize)));
41525
+ return apply$2(view, new TextSelection$1(view.state.doc.resolve(dir < 0 ? nodePos : nodePos + node2.nodeSize)));
41521
41526
  } else {
41522
41527
  return false;
41523
41528
  }
41524
41529
  }
41525
41530
  } else if (sel instanceof NodeSelection && sel.node.isInline) {
41526
- return apply$2(view, new TextSelection(dir > 0 ? sel.$to : sel.$from));
41531
+ return apply$2(view, new TextSelection$1(dir > 0 ? sel.$to : sel.$from));
41527
41532
  } else {
41528
41533
  let next = moveSelectionBlock(view.state, dir);
41529
41534
  if (next)
@@ -41716,7 +41721,7 @@
41716
41721
  }
41717
41722
  function selectVertically(view, dir, mods) {
41718
41723
  let sel = view.state.selection;
41719
- if (sel instanceof TextSelection && !sel.empty || mods.indexOf("s") > -1)
41724
+ if (sel instanceof TextSelection$1 && !sel.empty || mods.indexOf("s") > -1)
41720
41725
  return false;
41721
41726
  if (mac$2 && mods.indexOf("m") > -1)
41722
41727
  return false;
@@ -41734,7 +41739,7 @@
41734
41739
  return false;
41735
41740
  }
41736
41741
  function stopNativeHorizontalDelete(view, dir) {
41737
- if (!(view.state.selection instanceof TextSelection))
41742
+ if (!(view.state.selection instanceof TextSelection$1))
41738
41743
  return true;
41739
41744
  let { $head, $anchor, empty: empty2 } = view.state.selection;
41740
41745
  if (!$head.sameParent($anchor))
@@ -42164,7 +42169,7 @@
42164
42169
  return;
42165
42170
  }
42166
42171
  let sel = view.state.selection;
42167
- if (!(sel instanceof TextSelection) || !sel.$from.sameParent(sel.$to)) {
42172
+ if (!(sel instanceof TextSelection$1) || !sel.$from.sameParent(sel.$to)) {
42168
42173
  let text = String.fromCharCode(event.charCode);
42169
42174
  let deflt = () => view.state.tr.insertText(text).scrollIntoView();
42170
42175
  if (!/[\r\n]/.test(text) && !view.someProp("handleTextInput", (f) => f(view, sel.$from.pos, sel.$to.pos, text, deflt)))
@@ -42247,7 +42252,7 @@
42247
42252
  let doc2 = view.state.doc;
42248
42253
  if (inside == -1) {
42249
42254
  if (doc2.inlineContent) {
42250
- updateSelection(view, TextSelection.create(doc2, 0, doc2.content.size));
42255
+ updateSelection(view, TextSelection$1.create(doc2, 0, doc2.content.size));
42251
42256
  return true;
42252
42257
  }
42253
42258
  return false;
@@ -42257,7 +42262,7 @@
42257
42262
  let node2 = i2 > $pos.depth ? $pos.nodeAfter : $pos.node(i2);
42258
42263
  let nodePos = $pos.before(i2);
42259
42264
  if (node2.inlineContent)
42260
- updateSelection(view, TextSelection.create(doc2, nodePos + 1, nodePos + 1 + node2.content.size));
42265
+ updateSelection(view, TextSelection$1.create(doc2, nodePos + 1, nodePos + 1 + node2.content.size));
42261
42266
  else if (NodeSelection.isSelectable(node2))
42262
42267
  updateSelection(view, NodeSelection.create(doc2, nodePos));
42263
42268
  else
@@ -42417,7 +42422,7 @@
42417
42422
  if (!view.composing) {
42418
42423
  view.domObserver.flush();
42419
42424
  let { state: state2 } = view, $pos = state2.selection.$to;
42420
- if (state2.selection instanceof TextSelection && (state2.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some((m) => m.type.spec.inclusive === false))) {
42425
+ if (state2.selection instanceof TextSelection$1 && (state2.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some((m) => m.type.spec.inclusive === false))) {
42421
42426
  view.markCursor = view.state.storedMarks || $pos.marks();
42422
42427
  endComposition(view, true);
42423
42428
  view.markCursor = null;
@@ -43775,7 +43780,7 @@
43775
43780
  return;
43776
43781
  }
43777
43782
  if (!change) {
43778
- if (typeOver && sel instanceof TextSelection && !sel.empty && sel.$head.sameParent(sel.$anchor) && !view.composing && !(parse.sel && parse.sel.anchor != parse.sel.head)) {
43783
+ if (typeOver && sel instanceof TextSelection$1 && !sel.empty && sel.$head.sameParent(sel.$anchor) && !view.composing && !(parse.sel && parse.sel.anchor != parse.sel.head)) {
43779
43784
  change = { start: sel.from, endA: sel.to, endB: sel.to };
43780
43785
  } else {
43781
43786
  if (parse.sel) {
@@ -43790,7 +43795,7 @@
43790
43795
  return;
43791
43796
  }
43792
43797
  }
43793
- if (view.state.selection.from < view.state.selection.to && change.start == change.endB && view.state.selection instanceof TextSelection) {
43798
+ if (view.state.selection.from < view.state.selection.to && change.start == change.endB && view.state.selection instanceof TextSelection$1) {
43794
43799
  if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2 && view.state.selection.from >= parse.from) {
43795
43800
  change.start = view.state.selection.from;
43796
43801
  } else if (change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2 && view.state.selection.to <= parse.to) {
@@ -45218,7 +45223,7 @@
45218
45223
  binding.mapping
45219
45224
  );
45220
45225
  if (anchor !== null && head !== null) {
45221
- const sel = TextSelection.between(tr.doc.resolve(anchor), tr.doc.resolve(head));
45226
+ const sel = TextSelection$1.between(tr.doc.resolve(anchor), tr.doc.resolve(head));
45222
45227
  tr.setSelection(sel);
45223
45228
  }
45224
45229
  }
@@ -45353,7 +45358,7 @@
45353
45358
  if (sel) {
45354
45359
  const clampedAnchor = min$2(max$2(sel.anchor, 0), tr.doc.content.size);
45355
45360
  const clampedHead = min$2(max$2(sel.head, 0), tr.doc.content.size);
45356
- tr.setSelection(TextSelection.create(tr.doc, clampedAnchor, clampedHead));
45361
+ tr.setSelection(TextSelection$1.create(tr.doc, clampedAnchor, clampedHead));
45357
45362
  }
45358
45363
  this.prosemirrorView.dispatch(
45359
45364
  tr.setMeta(ySyncPluginKey, { isChangeOrigin: true, binding: this })
@@ -48314,18 +48319,18 @@
48314
48319
  if (tr.selectionSet) {
48315
48320
  const deletionMarkSchema = state2.schema.marks[TrackDeleteMarkName];
48316
48321
  const deletionMark = findMark(state2, deletionMarkSchema, false);
48317
- if (tr.selection instanceof TextSelection && (tr.selection.from < state2.selection.from || tr.getMeta("inputType") === "deleteContentBackward")) {
48322
+ if (tr.selection instanceof TextSelection$1 && (tr.selection.from < state2.selection.from || tr.getMeta("inputType") === "deleteContentBackward")) {
48318
48323
  const caretPos = map2.map(tr.selection.from, -1);
48319
- newTr.setSelection(new TextSelection(newTr.doc.resolve(caretPos)));
48324
+ newTr.setSelection(new TextSelection$1(newTr.doc.resolve(caretPos)));
48320
48325
  } else if (tr.selection.from > state2.selection.from && deletionMark) {
48321
48326
  const caretPos = map2.map(deletionMark.to + 1, 1);
48322
- newTr.setSelection(new TextSelection(newTr.doc.resolve(caretPos)));
48327
+ newTr.setSelection(new TextSelection$1(newTr.doc.resolve(caretPos)));
48323
48328
  } else {
48324
48329
  newTr.setSelection(tr.selection.map(newTr.doc, map2));
48325
48330
  }
48326
48331
  } else if (state2.selection.from - tr.selection.from > 1 && tr.selection.$head.depth > 1) {
48327
48332
  const caretPos = map2.map(tr.selection.from - 2, -1);
48328
- newTr.setSelection(new TextSelection(newTr.doc.resolve(caretPos)));
48333
+ newTr.setSelection(new TextSelection$1(newTr.doc.resolve(caretPos)));
48329
48334
  } else ;
48330
48335
  if (tr.storedMarksSet) {
48331
48336
  newTr.setStoredMarks(tr.storedMarks);
@@ -48902,7 +48907,7 @@
48902
48907
  const setWordSelection = (view, pos) => {
48903
48908
  const { state: state2, dispatch } = view;
48904
48909
  const word = findWordBounds(state2.doc, pos);
48905
- const tr = state2.tr.setSelection(TextSelection.create(state2.doc, word.from, word.to));
48910
+ const tr = state2.tr.setSelection(TextSelection$1.create(state2.doc, word.from, word.to));
48906
48911
  dispatch(tr);
48907
48912
  };
48908
48913
  const setImageNodeSelection = (view, pos) => {
@@ -49791,7 +49796,7 @@
49791
49796
  * @returns {Object | void} Migration results
49792
49797
  */
49793
49798
  processCollaborationMigrations() {
49794
- console.debug("[checkVersionMigrations] Current editor version", "0.14.5-next.1");
49799
+ console.debug("[checkVersionMigrations] Current editor version", "0.14.5-next.3");
49795
49800
  if (!this.options.ydoc) return;
49796
49801
  const metaMap = this.options.ydoc.getMap("meta");
49797
49802
  let docVersion = metaMap.get("version");
@@ -50989,7 +50994,7 @@
50989
50994
  return function(state2, dispatch, view) {
50990
50995
  let sel = state2.selection;
50991
50996
  let $start = dir > 0 ? sel.$to : sel.$from, mustMove = sel.empty;
50992
- if (sel instanceof TextSelection) {
50997
+ if (sel instanceof TextSelection$1) {
50993
50998
  if (!view.endOfTextblock(dirStr) || $start.depth == 0)
50994
50999
  return false;
50995
51000
  mustMove = false;
@@ -51026,7 +51031,7 @@
51026
51031
  for (let i2 = insert.length - 1; i2 >= 0; i2--)
51027
51032
  frag = Fragment.from(insert[i2].createAndFill(null, frag));
51028
51033
  let tr = view.state.tr.replace($from.pos, $from.pos, new Slice(frag, 0, 0));
51029
- tr.setSelection(TextSelection.near(tr.doc.resolve($from.pos + 1)));
51034
+ tr.setSelection(TextSelection$1.near(tr.doc.resolve($from.pos + 1)));
51030
51035
  view.dispatch(tr);
51031
51036
  return false;
51032
51037
  }
@@ -53503,7 +53508,7 @@
53503
53508
  return _CellSelection.colSelection($anchorCell, $headCell);
53504
53509
  else return new _CellSelection($anchorCell, $headCell);
53505
53510
  }
53506
- return TextSelection.between($anchorCell, $headCell);
53511
+ return TextSelection$1.between($anchorCell, $headCell);
53507
53512
  }
53508
53513
  // Returns a rectangular slice of table rows containing the selected
53509
53514
  // cells.
@@ -53775,10 +53780,10 @@
53775
53780
  const lastCell = start2 + map2.map[map2.width * map2.height - 1];
53776
53781
  normalize2 = CellSelection.create(doc2, start2 + 1, lastCell);
53777
53782
  }
53778
- } else if (sel instanceof TextSelection && isCellBoundarySelection(sel)) {
53779
- normalize2 = TextSelection.create(doc2, sel.from);
53780
- } else if (sel instanceof TextSelection && isTextSelectionAcrossCells(sel)) {
53781
- normalize2 = TextSelection.create(doc2, sel.$from.start(), sel.$from.end());
53783
+ } else if (sel instanceof TextSelection$1 && isCellBoundarySelection(sel)) {
53784
+ normalize2 = TextSelection$1.create(doc2, sel.from);
53785
+ } else if (sel instanceof TextSelection$1 && isTextSelectionAcrossCells(sel)) {
53786
+ normalize2 = TextSelection$1.create(doc2, sel.$from.start(), sel.$from.end());
53782
53787
  }
53783
53788
  if (normalize2) (tr || (tr = state2.tr)).setSelection(normalize2);
53784
53789
  return tr;
@@ -54374,7 +54379,7 @@
54374
54379
  if (dispatch) {
54375
54380
  const $cell = state2.doc.resolve(cell);
54376
54381
  dispatch(
54377
- state2.tr.setSelection(TextSelection.between($cell, moveCellForward($cell))).scrollIntoView()
54382
+ state2.tr.setSelection(TextSelection$1.between($cell, moveCellForward($cell))).scrollIntoView()
54378
54383
  );
54379
54384
  }
54380
54385
  return true;
@@ -54827,7 +54832,7 @@
54827
54832
  view.root.addEventListener("mousemove", move2);
54828
54833
  }
54829
54834
  function atEndOfCell(view, axis, dir) {
54830
- if (!(view.state.selection instanceof TextSelection)) return null;
54835
+ if (!(view.state.selection instanceof TextSelection$1)) return null;
54831
54836
  const { $head } = view.state.selection;
54832
54837
  for (let d = $head.depth - 1; d >= 0; d--) {
54833
54838
  const parent = $head.node(d), index2 = dir < 0 ? $head.index(d) : $head.indexAfter(d);
@@ -55394,7 +55399,7 @@
55394
55399
  const node2 = createTable(editor.schema, rows, cols, withHeaderRow);
55395
55400
  if (dispatch) {
55396
55401
  const offset2 = tr.selection.from + 1;
55397
- tr.replaceSelectionWith(node2).scrollIntoView().setSelection(TextSelection.near(tr.doc.resolve(offset2)));
55402
+ tr.replaceSelectionWith(node2).scrollIntoView().setSelection(TextSelection$1.near(tr.doc.resolve(offset2)));
55398
55403
  }
55399
55404
  return true;
55400
55405
  },
@@ -58720,7 +58725,7 @@
58720
58725
  return chain().setMark("underline").setMark(this.name, { href }).run();
58721
58726
  },
58722
58727
  unsetLink: () => ({ chain }) => {
58723
- return chain().unsetMark("underline").unsetColor().unsetMark(this.name, { extendEmptyMarkRange: true }).run();
58728
+ return chain().unsetMark("underline", { extendEmptyMarkRange: true }).unsetColor().unsetMark("link", { extendEmptyMarkRange: true }).run();
58724
58729
  },
58725
58730
  toggleLink: ({ href }) => ({ commands: commands2 }) => {
58726
58731
  if (!href) return commands2.unsetLink();
@@ -64186,7 +64191,7 @@
64186
64191
  goToSearchResult: (match) => ({ state: state2, dispatch, editor }) => {
64187
64192
  const { from: from2, to } = match;
64188
64193
  editor.view.focus();
64189
- const tr = state2.tr.setSelection(TextSelection.create(state2.doc, from2, to)).scrollIntoView();
64194
+ const tr = state2.tr.setSelection(TextSelection$1.create(state2.doc, from2, to)).scrollIntoView();
64190
64195
  dispatch(tr);
64191
64196
  const { node: node2 } = editor.view.domAtPos(from2);
64192
64197
  if (node2?.scrollIntoView) {
@@ -75007,7 +75012,7 @@ ${style2}
75007
75012
  const { state: state2 } = props.editor;
75008
75013
  const { from: from2, to } = selectionState.value;
75009
75014
  const tr = state2.tr.setSelection(
75010
- TextSelection.create(state2.doc, from2, to)
75015
+ TextSelection$1.create(state2.doc, from2, to)
75011
75016
  );
75012
75017
  props.editor.view.dispatch(tr);
75013
75018
  } else {
@@ -75239,7 +75244,7 @@ ${style2}
75239
75244
  var evt = prefix2 ? prefix2 + event : event, handlers2 = this._events[evt];
75240
75245
  if (!handlers2) return [];
75241
75246
  if (handlers2.fn) return [handlers2.fn];
75242
- for (var i2 = 0, l2 = handlers2.length, ee = new Array(l2); i2 < l2; i2++) {
75247
+ for (var i2 = 0, l = handlers2.length, ee = new Array(l); i2 < l; i2++) {
75243
75248
  ee[i2] = handlers2[i2].fn;
75244
75249
  }
75245
75250
  return ee;
@@ -75740,11 +75745,238 @@ ${style2}
75740
75745
  }
75741
75746
  };
75742
75747
  const LinkedStyle = /* @__PURE__ */ _export_sfc$1(_sfc_main$c$1, [["__scopeId", "data-v-2cf079a2"]]);
75743
- const _hoisted_1$9$1 = ["aria-label", "onClick", "onKeydown"];
75744
- const _hoisted_2$7$1 = ["innerHTML"];
75745
- const _hoisted_3$6$1 = ["innerHTML"];
75746
- const ROW_SIZE$1 = 7;
75748
+ const _hoisted_1$9$1 = {
75749
+ key: 0,
75750
+ class: "link-title"
75751
+ };
75752
+ const _hoisted_2$7$1 = {
75753
+ key: 1,
75754
+ class: "link-title"
75755
+ };
75756
+ const _hoisted_3$6$1 = {
75757
+ key: 2,
75758
+ class: "link-title"
75759
+ };
75760
+ const _hoisted_4$2$1 = { key: 3 };
75761
+ const _hoisted_5$1$1 = { class: "input-row" };
75762
+ const _hoisted_6$2 = ["innerHTML"];
75763
+ const _hoisted_7$2 = ["onKeydown"];
75764
+ const _hoisted_8$2 = ["innerHTML"];
75765
+ const _hoisted_9$2 = { class: "input-row link-buttons" };
75766
+ const _hoisted_10$1 = ["innerHTML"];
75767
+ const _hoisted_11$1 = {
75768
+ key: 4,
75769
+ class: "input-row go-to-anchor clickable"
75770
+ };
75747
75771
  const _sfc_main$b$1 = {
75772
+ __name: "LinkInput",
75773
+ props: {
75774
+ showInput: {
75775
+ type: Boolean,
75776
+ default: true
75777
+ },
75778
+ showLink: {
75779
+ type: Boolean,
75780
+ default: true
75781
+ },
75782
+ goToAnchor: {
75783
+ type: Function,
75784
+ default: () => {
75785
+ }
75786
+ },
75787
+ editor: {
75788
+ type: Object,
75789
+ required: true
75790
+ },
75791
+ closePopover: {
75792
+ type: Function,
75793
+ default: () => {
75794
+ }
75795
+ }
75796
+ },
75797
+ setup(__props) {
75798
+ const props = __props;
75799
+ const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode$1();
75800
+ const urlError = ref$1(false);
75801
+ const getSelectedText = () => {
75802
+ if (!props.editor || !props.editor.state) return "";
75803
+ const { state: state2 } = props.editor;
75804
+ const { from: from2, to } = state2.selection;
75805
+ return state2.doc.textBetween(from2, to, " ");
75806
+ };
75807
+ const getLinkHrefAtSelection = () => {
75808
+ if (!props.editor || !props.editor.state) return "";
75809
+ const { state: state2 } = props.editor;
75810
+ const { schema, selection } = state2;
75811
+ const linkMark = schema.marks.link;
75812
+ if (!linkMark) return "";
75813
+ let href = "";
75814
+ const { $from, empty: empty2 } = selection;
75815
+ if (empty2) {
75816
+ const marks = state2.storedMarks || $from.marks();
75817
+ const link = marks.find((mark) => mark.type === linkMark);
75818
+ if (link) href = link.attrs.href;
75819
+ } else {
75820
+ state2.doc.nodesBetween(selection.from, selection.to, (node2) => {
75821
+ if (node2.marks) {
75822
+ const link = node2.marks.find((mark) => mark.type === linkMark);
75823
+ if (link) href = link.attrs.href;
75824
+ }
75825
+ });
75826
+ }
75827
+ return href || "";
75828
+ };
75829
+ const text = ref$1("");
75830
+ const rawUrl = ref$1("");
75831
+ const isAnchor = ref$1(false);
75832
+ const url = computed(() => {
75833
+ if (!rawUrl.value?.startsWith("http")) return "http://" + rawUrl.value;
75834
+ return rawUrl.value;
75835
+ });
75836
+ const validUrl = computed(() => {
75837
+ const urlSplit = url.value.split(".").filter(Boolean);
75838
+ return url.value.includes(".") && urlSplit.length > 1;
75839
+ });
75840
+ const isEditing = computed(() => !isAnchor.value && !!getLinkHrefAtSelection());
75841
+ const getApplyText = computed(() => showApply.value ? "Apply" : "Remove");
75842
+ const isDisabled2 = computed(() => !validUrl.value);
75843
+ const showApply = computed(() => !showRemove.value);
75844
+ const showRemove = computed(() => rawUrl.value === "" && getLinkHrefAtSelection());
75845
+ const openLink = () => {
75846
+ window.open(url.value, "_blank");
75847
+ };
75848
+ const updateFromEditor = () => {
75849
+ text.value = getSelectedText();
75850
+ rawUrl.value = getLinkHrefAtSelection();
75851
+ };
75852
+ watch(
75853
+ () => props.editor?.state?.selection,
75854
+ () => {
75855
+ updateFromEditor();
75856
+ },
75857
+ { immediate: true }
75858
+ );
75859
+ const focusInput = () => {
75860
+ const input = document.querySelector(".link-input-ctn input");
75861
+ if (!input) return;
75862
+ input.focus();
75863
+ };
75864
+ onMounted(() => {
75865
+ updateFromEditor();
75866
+ isAnchor.value = rawUrl.value.startsWith("#");
75867
+ if (props.showInput) focusInput();
75868
+ });
75869
+ const handleSubmit = () => {
75870
+ if (rawUrl.value && validUrl.value) {
75871
+ if (props.editor && props.editor.commands) {
75872
+ if (isEditing.value) {
75873
+ const { state: state2, view: view2 } = props.editor;
75874
+ const linkMark = state2.schema.marks.link;
75875
+ let { from: from2, to } = state2.selection;
75876
+ if (state2.selection.empty) {
75877
+ const range2 = getMarkRange(state2.selection.$from, linkMark);
75878
+ if (range2) {
75879
+ from2 = range2.from;
75880
+ to = range2.to;
75881
+ }
75882
+ }
75883
+ const tr2 = state2.tr.removeMark(from2, to, linkMark).addMark(from2, to, linkMark.create({ href: url.value }));
75884
+ view2.dispatch(tr2);
75885
+ } else if (props.editor.commands.toggleLink) {
75886
+ props.editor.commands.toggleLink({ href: url.value, text: text.value });
75887
+ }
75888
+ const { view } = props.editor;
75889
+ let { selection } = view.state;
75890
+ const endPos = selection.$to.pos;
75891
+ const tr = view.state.tr.setSelection(new TextSelection$1(view.state.doc.resolve(endPos)));
75892
+ view.dispatch(tr);
75893
+ setTimeout(() => {
75894
+ view.focus();
75895
+ }, 100);
75896
+ }
75897
+ props.closePopover();
75898
+ return;
75899
+ } else if (!rawUrl.value) {
75900
+ if (props.editor && props.editor.commands && props.editor.commands.unsetLink) {
75901
+ props.editor.commands.unsetLink();
75902
+ }
75903
+ props.closePopover();
75904
+ return;
75905
+ }
75906
+ urlError.value = true;
75907
+ };
75908
+ const handleRemove = () => {
75909
+ if (props.editor && props.editor.commands && props.editor.commands.unsetLink) {
75910
+ props.editor.commands.unsetLink();
75911
+ props.closePopover();
75912
+ }
75913
+ };
75914
+ return (_ctx, _cache) => {
75915
+ return openBlock(), createElementBlock("div", {
75916
+ class: normalizeClass(["link-input-ctn", { "high-contrast": unref(isHighContrastMode2) }])
75917
+ }, [
75918
+ isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_1$9$1, "Page anchor")) : isEditing.value ? (openBlock(), createElementBlock("div", _hoisted_2$7$1, "Edit link")) : (openBlock(), createElementBlock("div", _hoisted_3$6$1, "Add link")),
75919
+ __props.showInput && !isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_4$2$1, [
75920
+ createBaseVNode("div", _hoisted_5$1$1, [
75921
+ createBaseVNode("div", {
75922
+ class: "input-icon",
75923
+ innerHTML: unref(toolbarIcons).linkInput
75924
+ }, null, 8, _hoisted_6$2),
75925
+ withDirectives(createBaseVNode("input", {
75926
+ type: "text",
75927
+ name: "link",
75928
+ placeholder: "Type or paste a link",
75929
+ class: normalizeClass({ error: urlError.value }),
75930
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => rawUrl.value = $event),
75931
+ onKeydown: [
75932
+ withKeys(withModifiers(handleSubmit, ["stop", "prevent"]), ["enter"]),
75933
+ _cache[1] || (_cache[1] = ($event) => urlError.value = false)
75934
+ ]
75935
+ }, null, 42, _hoisted_7$2), [
75936
+ [vModelText, rawUrl.value]
75937
+ ]),
75938
+ createBaseVNode("div", {
75939
+ class: normalizeClass(["open-link-icon", { disabled: !validUrl.value }]),
75940
+ innerHTML: unref(toolbarIcons).openLink,
75941
+ onClick: openLink,
75942
+ "data-item": "btn-link-open"
75943
+ }, null, 10, _hoisted_8$2)
75944
+ ]),
75945
+ createBaseVNode("div", _hoisted_9$2, [
75946
+ rawUrl.value ? (openBlock(), createElementBlock("button", {
75947
+ key: 0,
75948
+ class: "remove-btn",
75949
+ onClick: handleRemove,
75950
+ "data-item": "btn-link-remove"
75951
+ }, [
75952
+ createBaseVNode("div", {
75953
+ class: "remove-btn__icon",
75954
+ innerHTML: unref(toolbarIcons).removeLink
75955
+ }, null, 8, _hoisted_10$1),
75956
+ _cache[3] || (_cache[3] = createTextVNode(" Remove "))
75957
+ ])) : createCommentVNode("", true),
75958
+ showApply.value ? (openBlock(), createElementBlock("button", {
75959
+ key: 1,
75960
+ class: normalizeClass(["submit-btn", { "disable-btn": isDisabled2.value }]),
75961
+ onClick: handleSubmit,
75962
+ "data-item": "btn-link-apply"
75963
+ }, toDisplayString(getApplyText.value), 3)) : createCommentVNode("", true)
75964
+ ])
75965
+ ])) : isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_11$1, [
75966
+ createBaseVNode("a", {
75967
+ onClick: _cache[2] || (_cache[2] = withModifiers((...args) => __props.goToAnchor && __props.goToAnchor(...args), ["stop", "prevent"]))
75968
+ }, "Go to " + toDisplayString(rawUrl.value.startsWith("#_") ? rawUrl.value.substring(2) : rawUrl.value), 1)
75969
+ ])) : createCommentVNode("", true)
75970
+ ], 2);
75971
+ };
75972
+ }
75973
+ };
75974
+ const LinkInput = /* @__PURE__ */ _export_sfc$1(_sfc_main$b$1, [["__scopeId", "data-v-0c411ee5"]]);
75975
+ const _hoisted_1$8$1 = ["aria-label", "onClick", "onKeydown"];
75976
+ const _hoisted_2$6$1 = ["innerHTML"];
75977
+ const _hoisted_3$5$1 = ["innerHTML"];
75978
+ const ROW_SIZE$1 = 7;
75979
+ const _sfc_main$a$1 = {
75748
75980
  __name: "IconGridRow",
75749
75981
  props: {
75750
75982
  icons: {
@@ -75863,26 +76095,26 @@ ${style2}
75863
76095
  class: "option__icon",
75864
76096
  innerHTML: option.icon,
75865
76097
  style: normalizeStyle(option.style)
75866
- }, null, 12, _hoisted_2$7$1),
76098
+ }, null, 12, _hoisted_2$6$1),
75867
76099
  isActive2.value(option) ? (openBlock(), createElementBlock("div", {
75868
76100
  key: 0,
75869
76101
  class: "option__check",
75870
76102
  innerHTML: unref(toolbarIcons).colorOptionCheck,
75871
76103
  style: normalizeStyle(getCheckStyle(option.value, optionIndex))
75872
- }, null, 12, _hoisted_3$6$1)) : createCommentVNode("", true)
75873
- ], 40, _hoisted_1$9$1);
76104
+ }, null, 12, _hoisted_3$5$1)) : createCommentVNode("", true)
76105
+ ], 40, _hoisted_1$8$1);
75874
76106
  }), 128))
75875
76107
  ]);
75876
76108
  }), 128);
75877
76109
  };
75878
76110
  }
75879
76111
  };
75880
- const IconGridRow = /* @__PURE__ */ _export_sfc$1(_sfc_main$b$1, [["__scopeId", "data-v-e89b7f5f"]]);
76112
+ const IconGridRow = /* @__PURE__ */ _export_sfc$1(_sfc_main$a$1, [["__scopeId", "data-v-e89b7f5f"]]);
75881
76113
  const DropIcon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M320 512c53.2 0 101.4-21.6 136.1-56.6l-298.3-235C140 257.1 128 292.3 128 320c0 106 86 192 192 192zM505.2 370.7c4.4-16.2 6.8-33.1 6.8-50.7c0-91.2-130.2-262.3-166.6-308.3C339.4 4.2 330.5 0 320.9 0l-1.8 0c-9.6 0-18.5 4.2-24.5 11.7C277.8 33 240.7 81.3 205.8 136L38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L505.2 370.7zM224 336c0 44.2 35.8 80 80 80c8.8 0 16 7.2 16 16s-7.2 16-16 16c-61.9 0-112-50.1-112-112c0-8.8 7.2-16 16-16s16 7.2 16 16z"/></svg>\n';
75882
- const _hoisted_1$8$1 = { class: "options-grid-wrap" };
75883
- const _hoisted_2$6$1 = ["innerHTML"];
75884
- const _hoisted_3$5$1 = { class: "option-grid-ctn" };
75885
- const _sfc_main$a$1 = {
76114
+ const _hoisted_1$7$1 = { class: "options-grid-wrap" };
76115
+ const _hoisted_2$5$1 = ["innerHTML"];
76116
+ const _hoisted_3$4$1 = { class: "option-grid-ctn" };
76117
+ const _sfc_main$9$1 = {
75886
76118
  __name: "IconGrid",
75887
76119
  props: {
75888
76120
  icons: {
@@ -75909,7 +76141,7 @@ ${style2}
75909
76141
  emit2("select", option);
75910
76142
  };
75911
76143
  return (_ctx, _cache) => {
75912
- return openBlock(), createElementBlock("div", _hoisted_1$8$1, [
76144
+ return openBlock(), createElementBlock("div", _hoisted_1$7$1, [
75913
76145
  __props.hasNoneIcon ? (openBlock(), createElementBlock("div", {
75914
76146
  key: 0,
75915
76147
  class: "none-option",
@@ -75920,10 +76152,10 @@ ${style2}
75920
76152
  createBaseVNode("span", {
75921
76153
  innerHTML: unref(DropIcon),
75922
76154
  class: "none-icon"
75923
- }, null, 8, _hoisted_2$6$1),
76155
+ }, null, 8, _hoisted_2$5$1),
75924
76156
  _cache[1] || (_cache[1] = createTextVNode(" None "))
75925
76157
  ])) : createCommentVNode("", true),
75926
- createBaseVNode("div", _hoisted_3$5$1, [
76158
+ createBaseVNode("div", _hoisted_3$4$1, [
75927
76159
  createVNode(IconGridRow, {
75928
76160
  icons: __props.icons,
75929
76161
  "active-color": __props.activeColor,
@@ -75942,7 +76174,7 @@ ${style2}
75942
76174
  };
75943
76175
  }
75944
76176
  };
75945
- const IconGrid = /* @__PURE__ */ _export_sfc$1(_sfc_main$a$1, [["__scopeId", "data-v-a00a9a3e"]]);
76177
+ const IconGrid = /* @__PURE__ */ _export_sfc$1(_sfc_main$9$1, [["__scopeId", "data-v-a00a9a3e"]]);
75946
76178
  const closeDropdown$1 = (dropdown) => {
75947
76179
  dropdown.expand.value = false;
75948
76180
  };
@@ -76051,10 +76283,10 @@ ${style2}
76051
76283
  const getAvailableColorOptions = () => {
76052
76284
  return icons.flat().map((item) => item.value);
76053
76285
  };
76054
- const _hoisted_1$7$1 = ["data-cols", "data-rows", "onKeydown", "onClick"];
76055
- const _hoisted_2$5$1 = ["aria-valuetext"];
76286
+ const _hoisted_1$6$1 = ["data-cols", "data-rows", "onKeydown", "onClick"];
76287
+ const _hoisted_2$4$1 = ["aria-valuetext"];
76056
76288
  const ROW_SIZE = 5;
76057
- const _sfc_main$9$1 = {
76289
+ const _sfc_main$8$1 = {
76058
76290
  __name: "TableGrid",
76059
76291
  emits: ["select", "clickoutside"],
76060
76292
  setup(__props, { emit: __emit }) {
@@ -76170,7 +76402,7 @@ ${style2}
76170
76402
  ref: tableGridItems,
76171
76403
  onKeydown: withModifiers((event) => handleKeyDown2(event, n2, i2), ["prevent"]),
76172
76404
  onClick: withModifiers(($event) => handleClick2({ cols: n2, rows: i2 }), ["stop", "prevent"])
76173
- }, null, 40, _hoisted_1$7$1);
76405
+ }, null, 40, _hoisted_1$6$1);
76174
76406
  }), 64))
76175
76407
  ], 64);
76176
76408
  }), 64))
@@ -76178,17 +76410,39 @@ ${style2}
76178
76410
  createBaseVNode("div", {
76179
76411
  class: "toolbar-table-grid-value",
76180
76412
  "aria-valuetext": `${selectedRows.value} x ${selectedCols.value}`
76181
- }, toDisplayString(selectedRows.value) + " x " + toDisplayString(selectedCols.value), 9, _hoisted_2$5$1)
76413
+ }, toDisplayString(selectedRows.value) + " x " + toDisplayString(selectedCols.value), 9, _hoisted_2$4$1)
76182
76414
  ], 2);
76183
76415
  };
76184
76416
  }
76185
76417
  };
76186
- const TableGrid = /* @__PURE__ */ _export_sfc$1(_sfc_main$9$1, [["__scopeId", "data-v-3e1154b8"]]);
76418
+ const TableGrid = /* @__PURE__ */ _export_sfc$1(_sfc_main$8$1, [["__scopeId", "data-v-3e1154b8"]]);
76419
+ function getScrollableParent(element) {
76420
+ let currentElement2 = element;
76421
+ while (currentElement2) {
76422
+ const overflowY = window.getComputedStyle(currentElement2).overflowY;
76423
+ if (/(auto|scroll)/.test(overflowY) && currentElement2.scrollHeight > currentElement2.clientHeight) {
76424
+ return currentElement2;
76425
+ }
76426
+ currentElement2 = currentElement2.parentElement;
76427
+ }
76428
+ return document.scrollingElement || document.documentElement;
76429
+ }
76430
+ function scrollToElement(targetElement, options2 = { behavior: "smooth", block: "start" }) {
76431
+ if (!targetElement) return;
76432
+ const container = getScrollableParent(targetElement);
76433
+ const containerRect = container.getBoundingClientRect();
76434
+ const targetRect = targetElement.getBoundingClientRect();
76435
+ const offsetTop = targetRect.top - containerRect.top + container.scrollTop;
76436
+ container.scrollTo({
76437
+ top: options2.block === "start" ? offsetTop : offsetTop - container.clientHeight + targetElement.offsetHeight,
76438
+ behavior: options2.behavior
76439
+ });
76440
+ }
76187
76441
  const checkIconSvg$1 = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>\n';
76188
- const _hoisted_1$6$1 = { class: "search-input-ctn" };
76189
- const _hoisted_2$4$1 = { class: "row" };
76190
- const _hoisted_3$4$1 = ["onKeydown"];
76191
- const _sfc_main$8$1 = {
76442
+ const _hoisted_1$5$1 = { class: "search-input-ctn" };
76443
+ const _hoisted_2$3$1 = { class: "row" };
76444
+ const _hoisted_3$3$1 = ["onKeydown"];
76445
+ const _sfc_main$7$1 = {
76192
76446
  __name: "SearchInput",
76193
76447
  props: {
76194
76448
  searchRef: {
@@ -76203,8 +76457,8 @@ ${style2}
76203
76457
  emit2("submit", { value: searchValue.value });
76204
76458
  };
76205
76459
  return (_ctx, _cache) => {
76206
- return openBlock(), createElementBlock("div", _hoisted_1$6$1, [
76207
- createBaseVNode("div", _hoisted_2$4$1, [
76460
+ return openBlock(), createElementBlock("div", _hoisted_1$5$1, [
76461
+ createBaseVNode("div", _hoisted_2$3$1, [
76208
76462
  withDirectives(createBaseVNode("input", {
76209
76463
  ref: __props.searchRef,
76210
76464
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchValue.value = $event),
@@ -76213,7 +76467,7 @@ ${style2}
76213
76467
  name: "search",
76214
76468
  placeholder: "Type search string",
76215
76469
  onKeydown: withKeys(withModifiers(handleSubmit, ["stop", "prevent"]), ["enter"])
76216
- }, null, 40, _hoisted_3$4$1), [
76470
+ }, null, 40, _hoisted_3$3$1), [
76217
76471
  [vModelText, searchValue.value]
76218
76472
  ])
76219
76473
  ]),
@@ -76227,7 +76481,7 @@ ${style2}
76227
76481
  };
76228
76482
  }
76229
76483
  };
76230
- const SearchInput = /* @__PURE__ */ _export_sfc$1(_sfc_main$8$1, [["__scopeId", "data-v-af870fbd"]]);
76484
+ const SearchInput = /* @__PURE__ */ _export_sfc$1(_sfc_main$7$1, [["__scopeId", "data-v-af870fbd"]]);
76231
76485
  const TOOLBAR_FONTS = [
76232
76486
  {
76233
76487
  label: "Georgia",
@@ -76509,6 +76763,54 @@ ${style2}
76509
76763
  })
76510
76764
  ]);
76511
76765
  };
76766
+ const link = useToolbarItem({
76767
+ type: "dropdown",
76768
+ name: "link",
76769
+ markName: "link",
76770
+ icon: toolbarIcons2.link,
76771
+ tooltip: toolbarTexts2.link,
76772
+ attributes: {
76773
+ ariaLabel: "Link dropdown"
76774
+ },
76775
+ options: [
76776
+ {
76777
+ type: "render",
76778
+ key: "linkDropdown",
76779
+ render: () => renderLinkDropdown(link)
76780
+ }
76781
+ ],
76782
+ onActivate: ({ href }) => {
76783
+ if (href) link.attributes.value = { href };
76784
+ else link.attributes.value = {};
76785
+ },
76786
+ onDeactivate: () => {
76787
+ link.attributes.value = {};
76788
+ link.expand.value = false;
76789
+ }
76790
+ });
76791
+ function renderLinkDropdown(link2) {
76792
+ return h("div", {}, [
76793
+ h(LinkInput, {
76794
+ editor: superToolbar.activeEditor,
76795
+ closePopover: () => closeDropdown(link2),
76796
+ goToAnchor: () => {
76797
+ closeDropdown(link2);
76798
+ if (!superToolbar.activeEditor || !link2.attributes.value?.href) return;
76799
+ const anchorName = link2.attributes.value?.href?.slice(1);
76800
+ const container = superToolbar.activeEditor.element;
76801
+ const anchor = container.querySelector(`a[name='${anchorName}']`);
76802
+ if (anchor) scrollToElement(anchor);
76803
+ }
76804
+ })
76805
+ ]);
76806
+ }
76807
+ const linkInput = useToolbarItem({
76808
+ type: "options",
76809
+ name: "linkInput",
76810
+ command: "toggleLink"
76811
+ });
76812
+ link.childItem = linkInput;
76813
+ linkInput.parentItem = link;
76512
76814
  const image = useToolbarItem({
76513
76815
  type: "button",
76514
76816
  name: "image",
@@ -77006,6 +77308,7 @@ ${style2}
77006
77308
  colorButton,
77007
77309
  highlight,
77008
77310
  separator,
77311
+ link,
77009
77312
  image,
77010
77313
  tableItem,
77011
77314
  separator,
@@ -77342,6 +77645,35 @@ ${style2}
77342
77645
  }
77343
77646
  this.updateToolbarState();
77344
77647
  },
77648
+ /**
77649
+ * Toggles link formatting and updates cursor position
77650
+ * @param {Object} params - Command parameters
77651
+ * @param {CommandItem} params.item - The command item
77652
+ * @param {*} params.argument - Command arguments
77653
+ * @returns {void}
77654
+ */
77655
+ toggleLink: ({ item, argument }) => {
77656
+ let command2 = item.command;
77657
+ if (command2 in this.activeEditor.commands) {
77658
+ this.activeEditor.commands[command2](argument);
77659
+ const { view } = this.activeEditor;
77660
+ let { selection } = view.state;
77661
+ if (this.activeEditor.options.isHeaderOrFooter) {
77662
+ selection = this.activeEditor.options.lastSelection;
77663
+ }
77664
+ const endPos = selection.$to.pos;
77665
+ const newSelection = new TextSelection(view.state.doc.resolve(endPos));
77666
+ const tr = view.state.tr.setSelection(newSelection);
77667
+ const state2 = view.state.apply(tr);
77668
+ view.updateState(state2);
77669
+ if (!this.activeEditor.options.isHeaderOrFooter) {
77670
+ setTimeout(() => {
77671
+ view.focus();
77672
+ }, 100);
77673
+ }
77674
+ }
77675
+ this.updateToolbarState();
77676
+ },
77345
77677
  /**
77346
77678
  * Inserts a table into the document
77347
77679
  * @param {Object} params - Command parameters
@@ -77908,219 +78240,6 @@ ${style2}
77908
78240
  clipboardContent
77909
78241
  };
77910
78242
  }
77911
- const _hoisted_1$5$1 = {
77912
- key: 0,
77913
- class: "link-title"
77914
- };
77915
- const _hoisted_2$3$1 = {
77916
- key: 1,
77917
- class: "link-title"
77918
- };
77919
- const _hoisted_3$3$1 = {
77920
- key: 2,
77921
- class: "link-title"
77922
- };
77923
- const _hoisted_4$2$1 = { key: 3 };
77924
- const _hoisted_5$1$1 = { class: "input-row" };
77925
- const _hoisted_6$2 = ["innerHTML"];
77926
- const _hoisted_7$2 = ["onKeydown"];
77927
- const _hoisted_8$2 = ["innerHTML"];
77928
- const _hoisted_9$2 = { class: "input-row link-buttons" };
77929
- const _hoisted_10$1 = ["innerHTML"];
77930
- const _hoisted_11$1 = {
77931
- key: 4,
77932
- class: "input-row go-to-anchor clickable"
77933
- };
77934
- const _sfc_main$7$1 = {
77935
- __name: "LinkInput",
77936
- props: {
77937
- showInput: {
77938
- type: Boolean,
77939
- default: true
77940
- },
77941
- showLink: {
77942
- type: Boolean,
77943
- default: true
77944
- },
77945
- goToAnchor: {
77946
- type: Function,
77947
- default: () => {
77948
- }
77949
- },
77950
- editor: {
77951
- type: Object,
77952
- required: true
77953
- },
77954
- closePopover: {
77955
- type: Function,
77956
- default: () => {
77957
- }
77958
- }
77959
- },
77960
- setup(__props) {
77961
- const props = __props;
77962
- const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode$1();
77963
- const urlError = ref$1(false);
77964
- const getSelectedText = () => {
77965
- if (!props.editor || !props.editor.state) return "";
77966
- const { state: state2 } = props.editor;
77967
- const { from: from2, to } = state2.selection;
77968
- return state2.doc.textBetween(from2, to, " ");
77969
- };
77970
- const getLinkHrefAtSelection = () => {
77971
- if (!props.editor || !props.editor.state) return "";
77972
- const { state: state2 } = props.editor;
77973
- const { schema, selection } = state2;
77974
- const linkMark = schema.marks.link;
77975
- if (!linkMark) return "";
77976
- let href = "";
77977
- const { $from, empty: empty2 } = selection;
77978
- if (empty2) {
77979
- const marks = state2.storedMarks || $from.marks();
77980
- const link = marks.find((mark) => mark.type === linkMark);
77981
- if (link) href = link.attrs.href;
77982
- } else {
77983
- state2.doc.nodesBetween(selection.from, selection.to, (node2) => {
77984
- if (node2.marks) {
77985
- const link = node2.marks.find((mark) => mark.type === linkMark);
77986
- if (link) href = link.attrs.href;
77987
- }
77988
- });
77989
- }
77990
- return href || "";
77991
- };
77992
- const text = ref$1("");
77993
- const rawUrl = ref$1("");
77994
- const isAnchor = ref$1(false);
77995
- const url = computed(() => {
77996
- if (!rawUrl.value?.startsWith("http")) return "http://" + rawUrl.value;
77997
- return rawUrl.value;
77998
- });
77999
- const validUrl = computed(() => {
78000
- const urlSplit = url.value.split(".").filter(Boolean);
78001
- return url.value.includes(".") && urlSplit.length > 1;
78002
- });
78003
- const isEditing = computed(() => !isAnchor.value && !!getLinkHrefAtSelection());
78004
- const getApplyText = computed(() => showApply.value ? "Apply" : "Remove");
78005
- const isDisabled2 = computed(() => !validUrl.value);
78006
- const showApply = computed(() => !showRemove.value);
78007
- const showRemove = computed(() => rawUrl.value === "" && getLinkHrefAtSelection());
78008
- const openLink = () => {
78009
- window.open(url.value, "_blank");
78010
- };
78011
- const updateFromEditor = () => {
78012
- text.value = getSelectedText();
78013
- rawUrl.value = getLinkHrefAtSelection();
78014
- };
78015
- watch(
78016
- () => props.editor?.state?.selection,
78017
- () => {
78018
- updateFromEditor();
78019
- },
78020
- { immediate: true }
78021
- );
78022
- const focusInput = () => {
78023
- const input = document.querySelector(".link-input-ctn input");
78024
- if (!input) return;
78025
- input.focus();
78026
- };
78027
- onMounted(() => {
78028
- updateFromEditor();
78029
- isAnchor.value = rawUrl.value.startsWith("#");
78030
- if (props.showInput) focusInput();
78031
- });
78032
- const handleSubmit = () => {
78033
- if (rawUrl.value && validUrl.value) {
78034
- if (props.editor && props.editor.commands && props.editor.commands.toggleLink) {
78035
- props.editor.commands.toggleLink({ href: url.value, text: text.value });
78036
- const { view } = props.editor;
78037
- let { selection } = view.state;
78038
- const endPos = selection.$to.pos;
78039
- const tr = view.state.tr.setSelection(new TextSelection(view.state.doc.resolve(endPos)));
78040
- const state2 = view.state.apply(tr);
78041
- view.updateState(state2);
78042
- setTimeout(() => {
78043
- view.focus();
78044
- }, 100);
78045
- }
78046
- props.closePopover();
78047
- return;
78048
- } else if (!rawUrl.value) {
78049
- if (props.editor && props.editor.commands && props.editor.commands.unsetLink) {
78050
- props.editor.commands.unsetLink();
78051
- }
78052
- props.closePopover();
78053
- return;
78054
- }
78055
- urlError.value = true;
78056
- };
78057
- const handleRemove = () => {
78058
- if (props.editor && props.editor.commands && props.editor.commands.unsetLink) {
78059
- props.editor.commands.unsetLink();
78060
- props.closePopover();
78061
- }
78062
- };
78063
- return (_ctx, _cache) => {
78064
- return openBlock(), createElementBlock("div", {
78065
- class: normalizeClass(["link-input-ctn", { "high-contrast": unref(isHighContrastMode2) }])
78066
- }, [
78067
- isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_1$5$1, "Page anchor")) : isEditing.value ? (openBlock(), createElementBlock("div", _hoisted_2$3$1, "Edit link")) : (openBlock(), createElementBlock("div", _hoisted_3$3$1, "Add link")),
78068
- __props.showInput && !isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_4$2$1, [
78069
- createBaseVNode("div", _hoisted_5$1$1, [
78070
- createBaseVNode("div", {
78071
- class: "input-icon",
78072
- innerHTML: unref(toolbarIcons).linkInput
78073
- }, null, 8, _hoisted_6$2),
78074
- withDirectives(createBaseVNode("input", {
78075
- type: "text",
78076
- name: "link",
78077
- placeholder: "Type or paste a link",
78078
- class: normalizeClass({ error: urlError.value }),
78079
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => rawUrl.value = $event),
78080
- onKeydown: [
78081
- withKeys(withModifiers(handleSubmit, ["stop", "prevent"]), ["enter"]),
78082
- _cache[1] || (_cache[1] = ($event) => urlError.value = false)
78083
- ]
78084
- }, null, 42, _hoisted_7$2), [
78085
- [vModelText, rawUrl.value]
78086
- ]),
78087
- createBaseVNode("div", {
78088
- class: normalizeClass(["open-link-icon", { disabled: !validUrl.value }]),
78089
- innerHTML: unref(toolbarIcons).openLink,
78090
- onClick: openLink,
78091
- "data-item": "btn-link-open"
78092
- }, null, 10, _hoisted_8$2)
78093
- ]),
78094
- createBaseVNode("div", _hoisted_9$2, [
78095
- rawUrl.value ? (openBlock(), createElementBlock("button", {
78096
- key: 0,
78097
- class: "remove-btn",
78098
- onClick: handleRemove,
78099
- "data-item": "btn-link-remove"
78100
- }, [
78101
- createBaseVNode("div", {
78102
- class: "remove-btn__icon",
78103
- innerHTML: unref(toolbarIcons).removeLink
78104
- }, null, 8, _hoisted_10$1),
78105
- _cache[3] || (_cache[3] = createTextVNode(" Remove "))
78106
- ])) : createCommentVNode("", true),
78107
- showApply.value ? (openBlock(), createElementBlock("button", {
78108
- key: 1,
78109
- class: normalizeClass(["submit-btn", { "disable-btn": isDisabled2.value }]),
78110
- onClick: handleSubmit,
78111
- "data-item": "btn-link-apply"
78112
- }, toDisplayString(getApplyText.value), 3)) : createCommentVNode("", true)
78113
- ])
78114
- ])) : isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_11$1, [
78115
- createBaseVNode("a", {
78116
- onClick: _cache[2] || (_cache[2] = withModifiers((...args) => __props.goToAnchor && __props.goToAnchor(...args), ["stop", "prevent"]))
78117
- }, "Go to " + toDisplayString(rawUrl.value.startsWith("#_") ? rawUrl.value.substring(2) : rawUrl.value), 1)
78118
- ])) : createCommentVNode("", true)
78119
- ], 2);
78120
- };
78121
- }
78122
- };
78123
- const LinkInput = /* @__PURE__ */ _export_sfc$1(_sfc_main$7$1, [["__scopeId", "data-v-2632571a"]]);
78124
78243
  const onMarginClickCursorChange = (event, editor) => {
78125
78244
  const y = event.clientY;
78126
78245
  const x = event.clientX;
@@ -78149,7 +78268,7 @@ ${style2}
78149
78268
  cursorPos = node2?.isText && charAtPos !== " " ? pos - 1 : pos;
78150
78269
  }
78151
78270
  const transaction = view.state.tr.setSelection(
78152
- TextSelection.create(view.state.doc, cursorPos)
78271
+ TextSelection$1.create(view.state.doc, cursorPos)
78153
78272
  );
78154
78273
  view.dispatch(transaction);
78155
78274
  view.focus();
@@ -78228,7 +78347,7 @@ ${style2}
78228
78347
  const pos = view.posAtCoords(coords)?.pos;
78229
78348
  if (typeof pos === "number") {
78230
78349
  const tr = view.state.tr.setSelection(
78231
- TextSelection.create(view.state.doc, pos)
78350
+ TextSelection$1.create(view.state.doc, pos)
78232
78351
  );
78233
78352
  view.dispatch(tr);
78234
78353
  view.focus();
@@ -78368,19 +78487,29 @@ ${style2}
78368
78487
  icon: ICONS.paste,
78369
78488
  action: async (editor2) => {
78370
78489
  try {
78371
- const clipboardData = await navigator.clipboard.read();
78372
- const event = new ClipboardEvent("paste", {
78373
- clipboardData: new DataTransfer(),
78374
- bubbles: true,
78375
- cancelable: true
78376
- });
78377
- for (const item of clipboardData) {
78378
- for (const type2 of item.types) {
78379
- const blob = await item.getType(type2);
78380
- event.clipboardData.setData(type2, await blob.text());
78490
+ const clipboardItems = await navigator.clipboard.read();
78491
+ let html = "";
78492
+ let text = "";
78493
+ for (const item of clipboardItems) {
78494
+ if (!html && item.types.includes("text/html")) {
78495
+ html = await (await item.getType("text/html")).text();
78381
78496
  }
78497
+ if (!text && item.types.includes("text/plain")) {
78498
+ text = await (await item.getType("text/plain")).text();
78499
+ }
78500
+ }
78501
+ const handled = handleClipboardPaste({ editor: editor2, view: editor2.view }, html, text);
78502
+ if (!handled) {
78503
+ const dataTransfer = new DataTransfer();
78504
+ if (html) dataTransfer.setData("text/html", html);
78505
+ if (text) dataTransfer.setData("text/plain", text);
78506
+ const event = new ClipboardEvent("paste", {
78507
+ clipboardData: dataTransfer,
78508
+ bubbles: true,
78509
+ cancelable: true
78510
+ });
78511
+ editor2.view.dom.dispatchEvent(event);
78382
78512
  }
78383
- editor2.view.dom.dispatchEvent(event);
78384
78513
  } catch (error) {
78385
78514
  console.warn("Failed to paste:", error);
78386
78515
  }
@@ -78440,6 +78569,11 @@ ${style2}
78440
78569
  const menuRef = ref$1(null);
78441
78570
  const sections = ref$1([]);
78442
78571
  const selectedId = ref$1(null);
78572
+ const handleEditorUpdate = () => {
78573
+ if (!props.editor?.isEditable && isOpen.value) {
78574
+ closeMenu({ restoreCursor: false });
78575
+ }
78576
+ };
78443
78577
  const flattenedItems = computed(() => {
78444
78578
  const items = [];
78445
78579
  sections.value.forEach((section) => {
@@ -78524,7 +78658,9 @@ ${style2}
78524
78658
  }
78525
78659
  };
78526
78660
  const handleRightClick = async (event) => {
78527
- if (event.ctrlKey) {
78661
+ const readOnly = !props.editor?.isEditable;
78662
+ const isHoldingCtrl = event.ctrlKey;
78663
+ if (readOnly || isHoldingCtrl) {
78528
78664
  return;
78529
78665
  }
78530
78666
  event.preventDefault();
@@ -78582,7 +78718,10 @@ ${style2}
78582
78718
  if (!props.editor) return;
78583
78719
  document.addEventListener("keydown", handleGlobalKeyDown);
78584
78720
  document.addEventListener("mousedown", handleGlobalOutsideClick);
78721
+ props.editor.on("update", handleEditorUpdate);
78585
78722
  props.editor.on("slashMenu:open", async (event) => {
78723
+ const readOnly = !props.editor?.isEditable;
78724
+ if (readOnly) return;
78586
78725
  isOpen.value = true;
78587
78726
  menuPosition.value = event.menuPosition;
78588
78727
  searchQuery.value = "";
@@ -78603,6 +78742,7 @@ ${style2}
78603
78742
  try {
78604
78743
  props.editor.off("slashMenu:open");
78605
78744
  props.editor.off("slashMenu:close");
78745
+ props.editor.off("update", handleEditorUpdate);
78606
78746
  props.editor.view.dom.removeEventListener("contextmenu", handleRightClick);
78607
78747
  } catch (error) {
78608
78748
  }
@@ -79205,8 +79345,9 @@ ${style2}
79205
79345
  style: { "width": "70%" }
79206
79346
  })
79207
79347
  ])) : createCommentVNode("", true),
79208
- createVNode(GenericPopover, {
79209
- editor: editor.value ?? {},
79348
+ editor.value ? (openBlock(), createBlock(GenericPopover, {
79349
+ key: 2,
79350
+ editor: editor.value,
79210
79351
  visible: popoverControls.visible,
79211
79352
  position: popoverControls.position,
79212
79353
  onClose: closePopover
@@ -79215,12 +79356,12 @@ ${style2}
79215
79356
  (openBlock(), createBlock(resolveDynamicComponent(popoverControls.component), normalizeProps(guardReactiveProps({ ...popoverControls.props, editor: editor.value, closePopover })), null, 16))
79216
79357
  ]),
79217
79358
  _: 1
79218
- }, 8, ["editor", "visible", "position"])
79359
+ }, 8, ["editor", "visible", "position"])) : createCommentVNode("", true)
79219
79360
  ]);
79220
79361
  };
79221
79362
  }
79222
79363
  };
79223
- const SuperEditor = /* @__PURE__ */ _export_sfc$1(_sfc_main$2$1, [["__scopeId", "data-v-b71313e5"]]);
79364
+ const SuperEditor = /* @__PURE__ */ _export_sfc$1(_sfc_main$2$1, [["__scopeId", "data-v-d4ce5f62"]]);
79224
79365
  const _hoisted_1$h = ["innerHTML"];
79225
79366
  const _sfc_main$i = {
79226
79367
  __name: "SuperInput",
@@ -95535,7 +95676,7 @@ ${style2}
95535
95676
  this.config.colors = shuffleArray(this.config.colors);
95536
95677
  this.userColorMap = /* @__PURE__ */ new Map();
95537
95678
  this.colorIndex = 0;
95538
- this.version = "0.14.5-next.1";
95679
+ this.version = "0.14.5-next.3";
95539
95680
  console.debug("🦋 [superdoc] Using SuperDoc version:", this.version);
95540
95681
  this.superdocId = config.superdocId || v4();
95541
95682
  this.colors = this.config.colors;