@harbour-enterprises/superdoc 0.14.6-next.4 → 0.14.6-next.6

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/dist/chunks/{index-BMwK7kM5.es.js → index-BvK-G6B1.es.js} +2 -2
  2. package/dist/chunks/{index-CZuIe8A3.cjs → index-CCRVYhTn.cjs} +1 -1
  3. package/dist/chunks/{index-Oz4X1zyg.cjs → index-CgJ5KVh6.cjs} +2 -2
  4. package/dist/chunks/{index-MJ-5Yknb.es.js → index-oHslWah4.es.js} +1 -1
  5. package/dist/chunks/{super-editor.es-BSwiXGrJ.es.js → super-editor.es-B6ZmwTgT.es.js} +245 -97
  6. package/dist/chunks/{super-editor.es-Bmml9Uk7.cjs → super-editor.es-uOpJ3x2l.cjs} +245 -97
  7. package/dist/chunks/{url-CRVat8D5.cjs → url-BG1Z_Z2_.cjs} +1 -1
  8. package/dist/chunks/{url-Cqg2Hljl.es.js → url-Dvx6wrNT.es.js} +1 -1
  9. package/dist/chunks/{xml-js-t28wMlyv.cjs → xml-js-BHJlXtfU.cjs} +11 -4
  10. package/dist/chunks/{xml-js-D78KIQHL.es.js → xml-js-DNISVjNF.es.js} +11 -4
  11. package/dist/style.css +42 -35
  12. package/dist/super-editor/ai-writer.es.js +2 -2
  13. package/dist/super-editor/chunks/{converter-B6n6gLBy.js → converter-B3UaFCGR.js} +2 -2
  14. package/dist/super-editor/chunks/{docx-zipper-CSMGmfdk.js → docx-zipper-Bms_xFD2.js} +1 -1
  15. package/dist/super-editor/chunks/{editor-BBuhT-Hl.js → editor-CH2nYY6O.js} +158 -43
  16. package/dist/super-editor/chunks/{toolbar-DQKVvAMM.js → toolbar-DAaxBzFU.js} +2 -2
  17. package/dist/super-editor/converter.es.js +1 -1
  18. package/dist/super-editor/core/helpers/annotator.d.ts.map +1 -1
  19. package/dist/super-editor/docx-zipper.es.js +2 -2
  20. package/dist/super-editor/editor.es.js +3 -3
  21. package/dist/super-editor/extensions/link/link.d.ts.map +1 -1
  22. package/dist/super-editor/file-zipper.es.js +1 -1
  23. package/dist/super-editor/style.css +42 -35
  24. package/dist/super-editor/super-editor.es.js +93 -60
  25. package/dist/super-editor/toolbar.es.js +2 -2
  26. package/dist/super-editor.cjs +1 -1
  27. package/dist/super-editor.es.js +1 -1
  28. package/dist/superdoc.cjs +5 -5
  29. package/dist/superdoc.es.js +6 -6
  30. package/dist/superdoc.umd.js +246 -98
  31. package/dist/superdoc.umd.js.map +1 -1
  32. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { c as commonjsGlobal, B as Buffer, a as getAugmentedNamespace, g as getDefaultExportFromCjs } from "./jszip-CYDYUNnI.es.js";
2
2
  import { p as process$1 } from "./vue-lU0o_RlU.es.js";
3
- import { e as eventsExports, r as require$$2, u as util, i as inherits_browserExports, b as browser$1, a as requireString_decoder } from "./xml-js-D78KIQHL.es.js";
4
- import { u as url } from "./url-Cqg2Hljl.es.js";
3
+ import { e as eventsExports, r as require$$2, u as util, i as inherits_browserExports, b as browser$1, a as requireString_decoder } from "./xml-js-DNISVjNF.es.js";
4
+ import { u as url } from "./url-Dvx6wrNT.es.js";
5
5
  function _mergeNamespaces(n, m) {
6
6
  for (var i = 0; i < m.length; i++) {
7
7
  const e = m[i];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const jszip = require("./jszip-D5XoMX4C.cjs");
3
- const index$2 = require("./index-Oz4X1zyg.cjs");
3
+ const index$2 = require("./index-CgJ5KVh6.cjs");
4
4
  function _mergeNamespaces(n, m) {
5
5
  for (var i = 0; i < m.length; i++) {
6
6
  const e = m[i];
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  const jszip = require("./jszip-D5XoMX4C.cjs");
3
3
  const vue = require("./vue-tQYF719J.cjs");
4
- const xmlJs = require("./xml-js-t28wMlyv.cjs");
5
- const url = require("./url-CRVat8D5.cjs");
4
+ const xmlJs = require("./xml-js-BHJlXtfU.cjs");
5
+ const url = require("./url-BG1Z_Z2_.cjs");
6
6
  function _mergeNamespaces(n, m) {
7
7
  for (var i = 0; i < m.length; i++) {
8
8
  const e = m[i];
@@ -1,5 +1,5 @@
1
1
  import { g as getDefaultExportFromCjs } from "./jszip-CYDYUNnI.es.js";
2
- import { s as streamHttp, r as require$$1 } from "./index-BMwK7kM5.es.js";
2
+ import { s as streamHttp, r as require$$1 } from "./index-BvK-G6B1.es.js";
3
3
  function _mergeNamespaces(n, m) {
4
4
  for (var i = 0; i < m.length; i++) {
5
5
  const e = m[i];
@@ -24305,7 +24305,7 @@ const _SuperConverter = class _SuperConverter2 {
24305
24305
  return;
24306
24306
  }
24307
24307
  }
24308
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.14.6-next.4") {
24308
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.14.6-next.6") {
24309
24309
  const customLocation = "docProps/custom.xml";
24310
24310
  if (!docx[customLocation]) {
24311
24311
  docx[customLocation] = generateCustomXml();
@@ -24781,7 +24781,7 @@ function storeSuperdocVersion(docx) {
24781
24781
  function generateCustomXml() {
24782
24782
  return DEFAULT_CUSTOM_XML;
24783
24783
  }
24784
- function generateSuperdocVersion(pid = 2, version2 = "0.14.6-next.4") {
24784
+ function generateSuperdocVersion(pid = 2, version2 = "0.14.6-next.6") {
24785
24785
  return {
24786
24786
  type: "element",
24787
24787
  name: "property",
@@ -40997,33 +40997,46 @@ const processTables = ({ state: state2, tr, annotationValues }) => {
40997
40997
  tables.reverse().forEach(({ pos }) => {
40998
40998
  const currentTableNode = tr.doc.nodeAt(pos);
40999
40999
  if (!currentTableNode || currentTableNode.type.name !== "table") return;
41000
- generateTableIfNecessary({ tableNode: { node: currentTableNode, pos }, annotationValues, tr, state: state2 });
41000
+ try {
41001
+ generateTableIfNecessary({ tableNode: { node: currentTableNode, pos }, annotationValues, tr, state: state2 });
41002
+ } catch (error) {
41003
+ console.error("Error generating table at pos", pos, ":", error);
41004
+ }
41001
41005
  });
41002
41006
  return tr;
41003
41007
  };
41004
41008
  const generateTableIfNecessary = ({ tableNode, annotationValues, tr, state: state2 }) => {
41005
- let rowNodeToGenerate = null;
41006
- let currentRow = null;
41007
41009
  const {
41008
41010
  tableRow: RowType,
41009
41011
  tableCell: CellType,
41010
41012
  fieldAnnotation: FieldType,
41011
41013
  paragraph: ParaType
41012
41014
  } = state2.schema.nodes;
41015
+ const rows = [];
41013
41016
  tableNode.node.descendants((node2, pos) => {
41014
- if (rowNodeToGenerate) return true;
41015
- if (node2.type === RowType) currentRow = { node: node2, pos };
41016
- if (node2.type === FieldType) {
41017
- const annotationValue = getAnnotationValue(node2.attrs.fieldId, annotationValues);
41018
- if (Array.isArray(annotationValue) && node2.attrs.generatorIndex === null) {
41019
- rowNodeToGenerate = currentRow;
41020
- }
41017
+ if (node2.type === RowType) {
41018
+ rows.push({ node: node2, pos });
41021
41019
  }
41022
41020
  });
41021
+ let rowNodeToGenerate = null;
41022
+ for (const row of rows) {
41023
+ let hasArrayAnnotation = false;
41024
+ row.node.descendants((node2, pos) => {
41025
+ if (node2.type === FieldType) {
41026
+ const annotationValue = getAnnotationValue(node2.attrs.fieldId, annotationValues);
41027
+ if (Array.isArray(annotationValue) && node2.attrs.generatorIndex === null) {
41028
+ hasArrayAnnotation = true;
41029
+ }
41030
+ }
41031
+ });
41032
+ if (hasArrayAnnotation) {
41033
+ rowNodeToGenerate = row;
41034
+ break;
41035
+ }
41036
+ }
41023
41037
  if (!rowNodeToGenerate) return;
41024
41038
  const { node: rowNode, pos: rowStartPos } = rowNodeToGenerate;
41025
- const absoluteRowStart = tr.mapping.map(tableNode.pos + rowStartPos);
41026
- const absoluteRowEnd = absoluteRowStart + rowNode.nodeSize;
41039
+ const absoluteRowStart = tableNode.pos + 1 + rowStartPos;
41027
41040
  let rowsToGenerate = 0;
41028
41041
  rowNode.descendants((childNode, childPos) => {
41029
41042
  if (childNode.type === FieldType) {
@@ -41034,34 +41047,112 @@ const generateTableIfNecessary = ({ tableNode, annotationValues, tr, state: stat
41034
41047
  }
41035
41048
  });
41036
41049
  if (rowsToGenerate <= 1) return;
41050
+ const validateAttributes = (attrs) => {
41051
+ const cleaned = {};
41052
+ for (const [key, value] of Object.entries(attrs)) {
41053
+ if (value !== void 0 && value !== null) {
41054
+ if (key === "displayLabel") {
41055
+ cleaned[key] = String(value);
41056
+ } else if (key === "rawHtml" || key === "linkUrl" || key === "imageSrc") {
41057
+ cleaned[key] = String(value);
41058
+ } else if (typeof value === "string" && value.length > 0) {
41059
+ cleaned[key] = value;
41060
+ } else if (typeof value !== "string") {
41061
+ cleaned[key] = value;
41062
+ }
41063
+ }
41064
+ }
41065
+ return cleaned;
41066
+ };
41037
41067
  const rebuildCell = (cellNode, rowIndex) => {
41038
- const updatedBlocks = cellNode.content.content.map((blockNode) => {
41039
- if (blockNode.type !== ParaType) return blockNode;
41040
- const updatedInlines = blockNode.content.content.map((inlineNode) => {
41041
- if (inlineNode.type !== FieldType) return inlineNode;
41042
- let matchedAnnotationValues = getAnnotationValue(inlineNode.attrs.fieldId, annotationValues);
41043
- if (!Array.isArray(matchedAnnotationValues)) matchedAnnotationValues = [matchedAnnotationValues];
41044
- const value = matchedAnnotationValues?.[rowIndex];
41045
- const extraAttrs = getFieldAttrs(inlineNode, value);
41046
- return FieldType.create(
41047
- { ...inlineNode.attrs, ...extraAttrs, generatorIndex: rowIndex },
41048
- inlineNode.content,
41049
- inlineNode.marks
41050
- );
41068
+ try {
41069
+ const updatedBlocks = cellNode.content.content.map((blockNode) => {
41070
+ if (blockNode.type !== ParaType) return blockNode;
41071
+ const updatedInlines = blockNode.content.content.map((inlineNode) => {
41072
+ if (inlineNode.type !== FieldType) return inlineNode;
41073
+ let matchedAnnotationValues = getAnnotationValue(inlineNode.attrs.fieldId, annotationValues);
41074
+ if (!Array.isArray(matchedAnnotationValues)) {
41075
+ matchedAnnotationValues = [matchedAnnotationValues];
41076
+ }
41077
+ const value = matchedAnnotationValues[rowIndex];
41078
+ let extraAttrs = {};
41079
+ try {
41080
+ const rawExtraAttrs = getFieldAttrs(inlineNode, value, null);
41081
+ extraAttrs = validateAttributes(rawExtraAttrs || {});
41082
+ } catch (error) {
41083
+ console.error("Error getting field attrs:", error);
41084
+ extraAttrs = {};
41085
+ }
41086
+ const baseAttrs = validateAttributes(inlineNode.attrs || {});
41087
+ const newAttrs = {
41088
+ ...baseAttrs,
41089
+ ...extraAttrs,
41090
+ generatorIndex: rowIndex
41091
+ };
41092
+ try {
41093
+ return FieldType.create(
41094
+ newAttrs,
41095
+ inlineNode.content || Fragment.empty,
41096
+ inlineNode.marks || []
41097
+ );
41098
+ } catch (error) {
41099
+ console.error("Error creating field node:", error);
41100
+ try {
41101
+ const fallbackAttrs = {
41102
+ ...baseAttrs,
41103
+ generatorIndex: rowIndex,
41104
+ displayLabel: String(value || "")
41105
+ };
41106
+ return FieldType.create(
41107
+ validateAttributes(fallbackAttrs),
41108
+ inlineNode.content || Fragment.empty,
41109
+ inlineNode.marks || []
41110
+ );
41111
+ } catch (fallbackError) {
41112
+ console.error("Fallback also failed:", fallbackError);
41113
+ return inlineNode;
41114
+ }
41115
+ }
41116
+ });
41117
+ try {
41118
+ return ParaType.create(
41119
+ validateAttributes(blockNode.attrs || {}),
41120
+ Fragment.from(updatedInlines),
41121
+ blockNode.marks || []
41122
+ );
41123
+ } catch (error) {
41124
+ console.error("Error creating paragraph node:", error);
41125
+ return blockNode;
41126
+ }
41051
41127
  });
41052
- return ParaType.create(blockNode.attrs, Fragment.from(updatedInlines), blockNode.marks);
41053
- });
41054
- return CellType.create(cellNode.attrs, Fragment.from(updatedBlocks), cellNode.marks);
41128
+ return CellType.create(
41129
+ validateAttributes(cellNode.attrs || {}),
41130
+ Fragment.from(updatedBlocks),
41131
+ cellNode.marks || []
41132
+ );
41133
+ } catch (error) {
41134
+ console.error(`Failed to rebuild cell for row ${rowIndex}:`, error);
41135
+ throw error;
41136
+ }
41055
41137
  };
41056
- for (let rowIndex = rowsToGenerate - 1; rowIndex >= 0; rowIndex--) {
41057
- const mappedInsertPos = tr.mapping.map(absoluteRowEnd) + 1;
41058
- const newCells = rowNode.content.content.map((cellNode) => rebuildCell(cellNode, rowIndex));
41059
- const newRow = RowType.create(rowNode.attrs, Fragment.from(newCells), rowNode.marks);
41060
- tr.insert(mappedInsertPos, Fragment.from(newRow));
41138
+ try {
41139
+ const newRows = [];
41140
+ for (let rowIndex = 0; rowIndex < rowsToGenerate; rowIndex++) {
41141
+ const newCells = rowNode.content.content.map((cellNode) => rebuildCell(cellNode, rowIndex));
41142
+ const newRow = RowType.create(
41143
+ validateAttributes(rowNode.attrs || {}),
41144
+ Fragment.from(newCells),
41145
+ rowNode.marks || []
41146
+ );
41147
+ newRows.push(newRow);
41148
+ }
41149
+ const mappedRowStart = tr.mapping.map(absoluteRowStart);
41150
+ const rowEnd = mappedRowStart + rowNode.nodeSize;
41151
+ tr.replaceWith(mappedRowStart, rowEnd, Fragment.from(newRows));
41152
+ } catch (error) {
41153
+ console.error("Error during row generation:", error);
41154
+ throw error;
41061
41155
  }
41062
- const mappedDeleteStart = tr.mapping.map(absoluteRowStart);
41063
- const mappedDeleteEnd = mappedDeleteStart + rowNode.nodeSize;
41064
- tr.delete(mappedDeleteStart - 1, mappedDeleteEnd + 1);
41065
41156
  };
41066
41157
  const getAnnotationValue = (id, annotationValues) => {
41067
41158
  return annotationValues.find((value) => value.input_id === id)?.input_value || null;
@@ -42385,7 +42476,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
42385
42476
  * @returns {Object | void} Migration results
42386
42477
  */
42387
42478
  processCollaborationMigrations() {
42388
- console.debug("[checkVersionMigrations] Current editor version", "0.14.6-next.4");
42479
+ console.debug("[checkVersionMigrations] Current editor version", "0.14.6-next.6");
42389
42480
  if (!this.options.ydoc) return;
42390
42481
  const metaMap = this.options.ydoc.getMap("meta");
42391
42482
  let docVersion = metaMap.get("version");
@@ -51316,15 +51407,39 @@ const Link = Mark2.create({
51316
51407
  },
51317
51408
  addCommands() {
51318
51409
  return {
51319
- setLink: ({ href }) => ({ chain }) => {
51320
- return chain().setMark("underline").setMark(this.name, { href }).run();
51410
+ setLink: ({ href, text } = {}) => ({ state: state2, dispatch, editor }) => {
51411
+ const { selection } = state2;
51412
+ const linkMarkType = editor.schema.marks.link;
51413
+ const underlineMarkType = editor.schema.marks.underline;
51414
+ let from2 = selection.from;
51415
+ let to = selection.to;
51416
+ if (selection.empty) {
51417
+ const range2 = getMarkRange(selection.$from, linkMarkType);
51418
+ if (range2) {
51419
+ from2 = range2.from;
51420
+ to = range2.to;
51421
+ }
51422
+ }
51423
+ const currentText = state2.doc.textBetween(from2, to, " ");
51424
+ const finalText = (text ?? currentText) || href || "";
51425
+ let tr = state2.tr;
51426
+ if (finalText && currentText !== finalText) {
51427
+ tr = tr.insertText(finalText, from2, to);
51428
+ to = from2 + finalText.length;
51429
+ }
51430
+ if (linkMarkType) tr = tr.removeMark(from2, to, linkMarkType);
51431
+ if (underlineMarkType) tr = tr.removeMark(from2, to, underlineMarkType);
51432
+ if (underlineMarkType) tr = tr.addMark(from2, to, underlineMarkType.create());
51433
+ tr = tr.addMark(from2, to, linkMarkType.create({ href, text: finalText }));
51434
+ dispatch(tr.scrollIntoView());
51435
+ return true;
51321
51436
  },
51322
51437
  unsetLink: () => ({ chain }) => {
51323
51438
  return chain().unsetMark("underline", { extendEmptyMarkRange: true }).unsetColor().unsetMark("link", { extendEmptyMarkRange: true }).run();
51324
51439
  },
51325
- toggleLink: ({ href }) => ({ commands: commands2 }) => {
51440
+ toggleLink: ({ href, text } = {}) => ({ commands: commands2 }) => {
51326
51441
  if (!href) return commands2.unsetLink();
51327
- return commands2.setLink({ href });
51442
+ return commands2.setLink({ href, text });
51328
51443
  }
51329
51444
  };
51330
51445
  }
@@ -68352,14 +68467,19 @@ const _hoisted_3$6 = {
68352
68467
  key: 2,
68353
68468
  class: "link-title"
68354
68469
  };
68355
- const _hoisted_4$2 = { key: 3 };
68356
- const _hoisted_5$1 = { class: "input-row" };
68357
- const _hoisted_6 = ["innerHTML"];
68358
- const _hoisted_7 = ["onKeydown"];
68470
+ const _hoisted_4$2 = {
68471
+ key: 3,
68472
+ class: "link-input-wrapper"
68473
+ };
68474
+ const _hoisted_5$1 = { class: "input-row text-input-row" };
68475
+ const _hoisted_6 = ["onKeydown"];
68476
+ const _hoisted_7 = { class: "input-row url-input-row" };
68359
68477
  const _hoisted_8 = ["innerHTML"];
68360
- const _hoisted_9 = { class: "input-row link-buttons" };
68478
+ const _hoisted_9 = ["onKeydown"];
68361
68479
  const _hoisted_10 = ["innerHTML"];
68362
- const _hoisted_11 = {
68480
+ const _hoisted_11 = { class: "input-row link-buttons" };
68481
+ const _hoisted_12 = ["innerHTML"];
68482
+ const _hoisted_13 = {
68363
68483
  key: 4,
68364
68484
  class: "input-row go-to-anchor clickable"
68365
68485
  };
@@ -68396,8 +68516,19 @@ const _sfc_main$b = {
68396
68516
  const getSelectedText = () => {
68397
68517
  if (!props.editor || !props.editor.state) return "";
68398
68518
  const { state: state2 } = props.editor;
68399
- const { from: from2, to } = state2.selection;
68400
- return state2.doc.textBetween(from2, to, " ");
68519
+ const { selection } = state2;
68520
+ const linkMark = state2.schema.marks.link;
68521
+ if (selection.empty) {
68522
+ const range2 = getMarkRange(selection.$from, linkMark);
68523
+ return range2 ? state2.doc.textBetween(range2.from, range2.to, " ") : "";
68524
+ }
68525
+ const rangeFrom = getMarkRange(selection.$from, linkMark);
68526
+ const rangeTo = getMarkRange(selection.$to, linkMark);
68527
+ if (rangeFrom || rangeTo) {
68528
+ const linkRange = rangeFrom || rangeTo;
68529
+ return state2.doc.textBetween(linkRange.from, linkRange.to, " ");
68530
+ }
68531
+ return state2.doc.textBetween(selection.from, selection.to, " ");
68401
68532
  };
68402
68533
  const getLinkHrefAtSelection = () => {
68403
68534
  if (!props.editor || !props.editor.state) return "";
@@ -68425,10 +68556,12 @@ const _sfc_main$b = {
68425
68556
  const rawUrl = ref$1("");
68426
68557
  const isAnchor = ref$1(false);
68427
68558
  const url = computed(() => {
68428
- if (!rawUrl.value?.startsWith("http")) return "http://" + rawUrl.value;
68559
+ if (!rawUrl.value) return "";
68560
+ if (!rawUrl.value.startsWith("http") && !rawUrl.value.startsWith("#")) return "http://" + rawUrl.value;
68429
68561
  return rawUrl.value;
68430
68562
  });
68431
68563
  const validUrl = computed(() => {
68564
+ if (url.value.startsWith("#")) return true;
68432
68565
  const urlSplit = url.value.split(".").filter(Boolean);
68433
68566
  return url.value.includes(".") && urlSplit.length > 1;
68434
68567
  });
@@ -68462,43 +68595,29 @@ const _sfc_main$b = {
68462
68595
  if (props.showInput) focusInput();
68463
68596
  });
68464
68597
  const handleSubmit = () => {
68465
- if (rawUrl.value && validUrl.value) {
68466
- if (props.editor && props.editor.commands) {
68467
- if (isEditing.value) {
68468
- const { state: state2, view: view2 } = props.editor;
68469
- const linkMark = state2.schema.marks.link;
68470
- let { from: from2, to } = state2.selection;
68471
- if (state2.selection.empty) {
68472
- const range2 = getMarkRange(state2.selection.$from, linkMark);
68473
- if (range2) {
68474
- from2 = range2.from;
68475
- to = range2.to;
68476
- }
68477
- }
68478
- const tr2 = state2.tr.removeMark(from2, to, linkMark).addMark(from2, to, linkMark.create({ href: url.value }));
68479
- view2.dispatch(tr2);
68480
- } else if (props.editor.commands.toggleLink) {
68481
- props.editor.commands.toggleLink({ href: url.value, text: text.value });
68482
- }
68483
- const { view } = props.editor;
68484
- let { selection } = view.state;
68485
- const endPos = selection.$to.pos;
68486
- const tr = view.state.tr.setSelection(new TextSelection$1(view.state.doc.resolve(endPos)));
68487
- view.dispatch(tr);
68488
- setTimeout(() => {
68489
- view.focus();
68490
- }, 100);
68491
- }
68598
+ const editor = props.editor;
68599
+ if (!editor) return;
68600
+ if (!rawUrl.value) {
68601
+ if (editor.commands?.unsetLink) editor.commands.unsetLink();
68492
68602
  props.closePopover();
68493
68603
  return;
68494
- } else if (!rawUrl.value) {
68495
- if (props.editor && props.editor.commands && props.editor.commands.unsetLink) {
68496
- props.editor.commands.unsetLink();
68497
- }
68498
- props.closePopover();
68604
+ }
68605
+ if (!validUrl.value) {
68606
+ urlError.value = true;
68499
68607
  return;
68500
68608
  }
68501
- urlError.value = true;
68609
+ const finalText = text.value || url.value;
68610
+ if (editor.commands?.toggleLink) {
68611
+ editor.commands.toggleLink({ href: url.value, text: finalText });
68612
+ }
68613
+ const endPos = editor.view.state.selection.$to.pos;
68614
+ editor.view.dispatch(
68615
+ editor.view.state.tr.setSelection(
68616
+ new TextSelection$1(editor.view.state.doc.resolve(endPos))
68617
+ )
68618
+ );
68619
+ setTimeout(() => editor.view.focus(), 100);
68620
+ props.closePopover();
68502
68621
  };
68503
68622
  const handleRemove = () => {
68504
68623
  if (props.editor && props.editor.commands && props.editor.commands.unsetLink) {
@@ -68513,21 +68632,33 @@ const _sfc_main$b = {
68513
68632
  isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_1$9, "Page anchor")) : isEditing.value ? (openBlock(), createElementBlock("div", _hoisted_2$7, "Edit link")) : (openBlock(), createElementBlock("div", _hoisted_3$6, "Add link")),
68514
68633
  __props.showInput && !isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_4$2, [
68515
68634
  createBaseVNode("div", _hoisted_5$1, [
68635
+ _cache[4] || (_cache[4] = createBaseVNode("div", { class: "input-icon text-input-icon" }, "T", -1)),
68636
+ withDirectives(createBaseVNode("input", {
68637
+ type: "text",
68638
+ name: "text",
68639
+ placeholder: "Text",
68640
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => text.value = $event),
68641
+ onKeydown: withKeys(withModifiers(handleSubmit, ["stop", "prevent"]), ["enter"])
68642
+ }, null, 40, _hoisted_6), [
68643
+ [vModelText, text.value]
68644
+ ])
68645
+ ]),
68646
+ createBaseVNode("div", _hoisted_7, [
68516
68647
  createBaseVNode("div", {
68517
68648
  class: "input-icon",
68518
68649
  innerHTML: unref(toolbarIcons).linkInput
68519
- }, null, 8, _hoisted_6),
68650
+ }, null, 8, _hoisted_8),
68520
68651
  withDirectives(createBaseVNode("input", {
68521
68652
  type: "text",
68522
68653
  name: "link",
68523
68654
  placeholder: "Type or paste a link",
68524
68655
  class: normalizeClass({ error: urlError.value }),
68525
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => rawUrl.value = $event),
68656
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => rawUrl.value = $event),
68526
68657
  onKeydown: [
68527
68658
  withKeys(withModifiers(handleSubmit, ["stop", "prevent"]), ["enter"]),
68528
- _cache[1] || (_cache[1] = ($event) => urlError.value = false)
68659
+ _cache[2] || (_cache[2] = ($event) => urlError.value = false)
68529
68660
  ]
68530
- }, null, 42, _hoisted_7), [
68661
+ }, null, 42, _hoisted_9), [
68531
68662
  [vModelText, rawUrl.value]
68532
68663
  ]),
68533
68664
  createBaseVNode("div", {
@@ -68535,9 +68666,9 @@ const _sfc_main$b = {
68535
68666
  innerHTML: unref(toolbarIcons).openLink,
68536
68667
  onClick: openLink,
68537
68668
  "data-item": "btn-link-open"
68538
- }, null, 10, _hoisted_8)
68669
+ }, null, 10, _hoisted_10)
68539
68670
  ]),
68540
- createBaseVNode("div", _hoisted_9, [
68671
+ createBaseVNode("div", _hoisted_11, [
68541
68672
  rawUrl.value ? (openBlock(), createElementBlock("button", {
68542
68673
  key: 0,
68543
68674
  class: "remove-btn",
@@ -68547,8 +68678,8 @@ const _sfc_main$b = {
68547
68678
  createBaseVNode("div", {
68548
68679
  class: "remove-btn__icon",
68549
68680
  innerHTML: unref(toolbarIcons).removeLink
68550
- }, null, 8, _hoisted_10),
68551
- _cache[3] || (_cache[3] = createTextVNode(" Remove "))
68681
+ }, null, 8, _hoisted_12),
68682
+ _cache[5] || (_cache[5] = createTextVNode(" Remove "))
68552
68683
  ])) : createCommentVNode("", true),
68553
68684
  showApply.value ? (openBlock(), createElementBlock("button", {
68554
68685
  key: 1,
@@ -68557,16 +68688,16 @@ const _sfc_main$b = {
68557
68688
  "data-item": "btn-link-apply"
68558
68689
  }, toDisplayString(getApplyText.value), 3)) : createCommentVNode("", true)
68559
68690
  ])
68560
- ])) : isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_11, [
68691
+ ])) : isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_13, [
68561
68692
  createBaseVNode("a", {
68562
- onClick: _cache[2] || (_cache[2] = withModifiers((...args) => __props.goToAnchor && __props.goToAnchor(...args), ["stop", "prevent"]))
68693
+ onClick: _cache[3] || (_cache[3] = withModifiers((...args) => __props.goToAnchor && __props.goToAnchor(...args), ["stop", "prevent"]))
68563
68694
  }, "Go to " + toDisplayString(rawUrl.value.startsWith("#_") ? rawUrl.value.substring(2) : rawUrl.value), 1)
68564
68695
  ])) : createCommentVNode("", true)
68565
68696
  ], 2);
68566
68697
  };
68567
68698
  }
68568
68699
  };
68569
- const LinkInput = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-0c411ee5"]]);
68700
+ const LinkInput = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-aae04034"]]);
68570
68701
  const _hoisted_1$8 = ["aria-label", "onClick", "onKeydown"];
68571
68702
  const _hoisted_2$6 = ["innerHTML"];
68572
68703
  const _hoisted_3$5 = ["innerHTML"];
@@ -71831,6 +71962,23 @@ const _sfc_main$2 = {
71831
71962
  }
71832
71963
  }
71833
71964
  }
71965
+ if ((event.metaKey || event.ctrlKey) && !event.shiftKey && !event.altKey && (event.key === "k" || event.key === "K")) {
71966
+ event.preventDefault();
71967
+ if (!editor.value) return;
71968
+ const view = editor.value.view;
71969
+ const { state: state2 } = view;
71970
+ const container = editorWrapper.value;
71971
+ if (!container) return;
71972
+ const containerRect = container.getBoundingClientRect();
71973
+ const cursorCoords = view.coordsAtPos(state2.selection.head);
71974
+ const left2 = `${cursorCoords.left - containerRect.left}px`;
71975
+ const top2 = `${cursorCoords.bottom - containerRect.top + 6}px`;
71976
+ openPopover(
71977
+ markRaw(LinkInput),
71978
+ {},
71979
+ { left: left2, top: top2 }
71980
+ );
71981
+ }
71834
71982
  emit("editor-keydown", { editor: editor.value });
71835
71983
  };
71836
71984
  const handleSuperEditorClick = (event) => {
@@ -71958,7 +72106,7 @@ const _sfc_main$2 = {
71958
72106
  };
71959
72107
  }
71960
72108
  };
71961
- const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-14919226"]]);
72109
+ const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-161b524d"]]);
71962
72110
  const _sfc_main$1 = {
71963
72111
  __name: "BasicUpload",
71964
72112
  emits: ["file-change"],