superdoc 1.0.0-beta.16 → 1.0.0-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{PdfViewer-93eWvs8z.cjs → PdfViewer-BIlJaTm7.cjs} +1 -1
- package/dist/chunks/{PdfViewer-ODeuH1gb.es.js → PdfViewer-cvzMUtBh.es.js} +1 -1
- package/dist/chunks/{index-DW5_UKLM.es.js → index-CrIfBvBN.es.js} +3 -3
- package/dist/chunks/{index-RquHXtgI.cjs → index-DDx90Dl3.cjs} +3 -3
- package/dist/chunks/{index-DexFffM7-XZD_g6eY.cjs → index-VCeRjVPO-DjkejB6t.cjs} +1 -1
- package/dist/chunks/{index-DexFffM7-Cbdy0Zy6.es.js → index-VCeRjVPO-FBgR9qxX.es.js} +1 -1
- package/dist/chunks/{super-editor.es-Dg5uoFkw.es.js → super-editor.es-00SpI-wK.es.js} +690 -146
- package/dist/chunks/{super-editor.es-BLKWkx5G.cjs → super-editor.es-Mlj7AGyt.cjs} +690 -146
- package/dist/style.css +6 -6
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-C_R_BK8X.js → converter-B9zUZjYT.js} +71 -34
- package/dist/super-editor/chunks/{docx-zipper-BvQAYmi1.js → docx-zipper-r5KdE_SA.js} +1 -1
- package/dist/super-editor/chunks/{editor-DFFvalb1.js → editor-D2k2BwSG.js} +524 -105
- package/dist/super-editor/chunks/{index-DexFffM7.js → index-VCeRjVPO.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-DLPfegtw.js → toolbar-8o_LgoiW.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/style.css +6 -6
- package/dist/super-editor/super-editor.es.js +131 -42
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +692 -148
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -19767,7 +19767,7 @@ function decodeRPrFromMarks(marks) {
|
|
|
19767
19767
|
return runProperties;
|
|
19768
19768
|
}
|
|
19769
19769
|
marks.forEach((mark) => {
|
|
19770
|
-
switch (mark.type) {
|
|
19770
|
+
switch (mark.type.name ?? mark.type) {
|
|
19771
19771
|
case "strike":
|
|
19772
19772
|
case "italic":
|
|
19773
19773
|
case "bold":
|
|
@@ -20833,6 +20833,11 @@ const decode$q = (params2, decodedAttrs = {}) => {
|
|
|
20833
20833
|
runs.push(trackedClone);
|
|
20834
20834
|
return;
|
|
20835
20835
|
}
|
|
20836
|
+
if (child.name === "w:commentRangeStart" || child.name === "w:commentRangeEnd") {
|
|
20837
|
+
const commentRangeClone = cloneXmlNode(child);
|
|
20838
|
+
runs.push(commentRangeClone);
|
|
20839
|
+
return;
|
|
20840
|
+
}
|
|
20836
20841
|
const runWrapper = { name: XML_NODE_NAME$i, elements: [] };
|
|
20837
20842
|
applyBaseRunProps(runWrapper);
|
|
20838
20843
|
if (!Array.isArray(runWrapper.elements)) runWrapper.elements = [];
|
|
@@ -27958,9 +27963,11 @@ function updateNumberingProperties(newNumberingProperties, paragraphNode, pos, e
|
|
|
27958
27963
|
const newAttrs = {
|
|
27959
27964
|
...paragraphNode.attrs,
|
|
27960
27965
|
paragraphProperties: newProperties,
|
|
27961
|
-
numberingProperties: newProperties.numberingProperties
|
|
27962
|
-
listRendering: null
|
|
27966
|
+
numberingProperties: newProperties.numberingProperties
|
|
27963
27967
|
};
|
|
27968
|
+
if (!newNumberingProperties) {
|
|
27969
|
+
newAttrs.listRendering = null;
|
|
27970
|
+
}
|
|
27964
27971
|
tr.setNodeMarkup(pos, null, newAttrs);
|
|
27965
27972
|
}
|
|
27966
27973
|
const generateNewListDefinition = ({ numId, listType, level, start: start2, text, fmt, editor }) => {
|
|
@@ -28492,13 +28499,36 @@ const handleDocxPaste = (html, editor, view) => {
|
|
|
28492
28499
|
extractAndRemoveConditionalPrefix(item);
|
|
28493
28500
|
});
|
|
28494
28501
|
transformWordLists(tempDiv, editor);
|
|
28495
|
-
|
|
28502
|
+
let doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
28503
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
28496
28504
|
tempDiv.remove();
|
|
28497
28505
|
const { dispatch } = editor.view;
|
|
28498
28506
|
if (!dispatch) return false;
|
|
28499
28507
|
dispatch(view.state.tr.replaceSelectionWith(doc2, true));
|
|
28500
28508
|
return true;
|
|
28501
28509
|
};
|
|
28510
|
+
const wrapTextsInRuns = (doc2) => {
|
|
28511
|
+
const runType = doc2.type?.schema?.nodes?.run;
|
|
28512
|
+
if (!runType) return doc2;
|
|
28513
|
+
const wrapNode = (node, parent) => {
|
|
28514
|
+
if (node.isText) {
|
|
28515
|
+
if (parent?.type?.name === "run") return node;
|
|
28516
|
+
const runProperties = decodeRPrFromMarks(node.marks);
|
|
28517
|
+
return runType.create({ runProperties }, [node]);
|
|
28518
|
+
}
|
|
28519
|
+
if (!node.childCount) return node;
|
|
28520
|
+
let changed = false;
|
|
28521
|
+
const wrappedChildren = [];
|
|
28522
|
+
node.forEach((child) => {
|
|
28523
|
+
const wrappedChild = wrapNode(child, node);
|
|
28524
|
+
if (wrappedChild !== child) changed = true;
|
|
28525
|
+
wrappedChildren.push(wrappedChild);
|
|
28526
|
+
});
|
|
28527
|
+
if (!changed) return node;
|
|
28528
|
+
return node.copy(Fragment.fromArray(wrappedChildren));
|
|
28529
|
+
};
|
|
28530
|
+
return wrapNode(doc2, null);
|
|
28531
|
+
};
|
|
28502
28532
|
const transformWordLists = (container, editor) => {
|
|
28503
28533
|
const listItems = Array.from(container.querySelectorAll("[data-num-id]"));
|
|
28504
28534
|
const lists = {};
|
|
@@ -28928,7 +28958,8 @@ const handleGoogleDocsHtml = (html, editor, view) => {
|
|
|
28928
28958
|
tempDiv.innerHTML = cleanedHtml;
|
|
28929
28959
|
const htmlWithMergedLists = mergeSeparateLists(tempDiv);
|
|
28930
28960
|
const flattenHtml = flattenListsInHtml(htmlWithMergedLists, editor);
|
|
28931
|
-
|
|
28961
|
+
let doc2 = DOMParser$1.fromSchema(editor.schema).parse(flattenHtml);
|
|
28962
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
28932
28963
|
tempDiv.remove();
|
|
28933
28964
|
const { dispatch } = editor.view;
|
|
28934
28965
|
if (!dispatch) return false;
|
|
@@ -29261,7 +29292,8 @@ function isGoogleDocsHtml(html) {
|
|
|
29261
29292
|
function handleHtmlPaste(html, editor, source) {
|
|
29262
29293
|
let cleanedHtml;
|
|
29263
29294
|
cleanedHtml = htmlHandler(html, editor);
|
|
29264
|
-
|
|
29295
|
+
let doc2 = DOMParser$1.fromSchema(editor.schema).parse(cleanedHtml);
|
|
29296
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
29265
29297
|
const { dispatch, state: state2 } = editor.view;
|
|
29266
29298
|
if (!dispatch) return false;
|
|
29267
29299
|
const { $from } = state2.selection;
|
|
@@ -29366,7 +29398,9 @@ function createDocFromHTML(content, editor, options = {}) {
|
|
|
29366
29398
|
} else {
|
|
29367
29399
|
parsedContent = content;
|
|
29368
29400
|
}
|
|
29369
|
-
|
|
29401
|
+
let doc2 = DOMParser$1.fromSchema(editor.schema).parse(parsedContent);
|
|
29402
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
29403
|
+
return doc2;
|
|
29370
29404
|
}
|
|
29371
29405
|
function L() {
|
|
29372
29406
|
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
@@ -30490,9 +30524,11 @@ function processContent({ content, type: type2, editor }) {
|
|
|
30490
30524
|
para.textContent = content;
|
|
30491
30525
|
wrapper.appendChild(para);
|
|
30492
30526
|
doc2 = DOMParser$1.fromSchema(editor.schema).parse(wrapper);
|
|
30527
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
30493
30528
|
break;
|
|
30494
30529
|
case "schema":
|
|
30495
30530
|
doc2 = editor.schema.nodeFromJSON(content);
|
|
30531
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
30496
30532
|
break;
|
|
30497
30533
|
default:
|
|
30498
30534
|
throw new Error(`Unknown content type: ${type2}`);
|
|
@@ -36249,7 +36285,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
36249
36285
|
static getStoredSuperdocVersion(docx) {
|
|
36250
36286
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
36251
36287
|
}
|
|
36252
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.
|
|
36288
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.17") {
|
|
36253
36289
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
36254
36290
|
}
|
|
36255
36291
|
/**
|
|
@@ -47660,6 +47696,83 @@ const insertTabChar = () => ({ tr }) => {
|
|
|
47660
47696
|
tr.insertText(" ", tr.selection.from, tr.selection.to);
|
|
47661
47697
|
return true;
|
|
47662
47698
|
};
|
|
47699
|
+
const splitRunToParagraph = () => (props) => {
|
|
47700
|
+
const { state: state2, view, tr } = props;
|
|
47701
|
+
const { $from, empty: empty2 } = state2.selection;
|
|
47702
|
+
if (!empty2) return false;
|
|
47703
|
+
if ($from.parent.type.name !== "run") return false;
|
|
47704
|
+
const handled = splitBlockPatch(state2, (transaction) => {
|
|
47705
|
+
view.dispatch(transaction);
|
|
47706
|
+
});
|
|
47707
|
+
if (handled) {
|
|
47708
|
+
tr.setMeta("preventDispatch", true);
|
|
47709
|
+
}
|
|
47710
|
+
return handled;
|
|
47711
|
+
};
|
|
47712
|
+
function splitBlockPatch(state2, dispatch) {
|
|
47713
|
+
let { $from } = state2.selection;
|
|
47714
|
+
if (state2.selection instanceof NodeSelection && state2.selection.node.isBlock) {
|
|
47715
|
+
if (!$from.parentOffset || !canSplit(state2.doc, $from.pos)) return false;
|
|
47716
|
+
if (dispatch) dispatch(state2.tr.split($from.pos).scrollIntoView());
|
|
47717
|
+
return true;
|
|
47718
|
+
}
|
|
47719
|
+
if (!$from.depth) return false;
|
|
47720
|
+
let types2 = [];
|
|
47721
|
+
let splitDepth, deflt, atEnd = false, atStart = false;
|
|
47722
|
+
for (let d2 = $from.depth; ; d2--) {
|
|
47723
|
+
let node = $from.node(d2);
|
|
47724
|
+
if (node.isBlock) {
|
|
47725
|
+
atEnd = $from.end(d2) == $from.pos + ($from.depth - d2);
|
|
47726
|
+
atStart = $from.start(d2) == $from.pos - ($from.depth - d2);
|
|
47727
|
+
deflt = defaultBlockAt$1($from.node(d2 - 1).contentMatchAt($from.indexAfter(d2 - 1)));
|
|
47728
|
+
types2.unshift(null);
|
|
47729
|
+
splitDepth = d2;
|
|
47730
|
+
break;
|
|
47731
|
+
} else {
|
|
47732
|
+
if (d2 == 1) return false;
|
|
47733
|
+
types2.unshift(null);
|
|
47734
|
+
}
|
|
47735
|
+
}
|
|
47736
|
+
let tr = state2.tr;
|
|
47737
|
+
if (state2.selection instanceof TextSelection$1 || state2.selection instanceof AllSelection) tr.deleteSelection();
|
|
47738
|
+
let splitPos = tr.mapping.map($from.pos);
|
|
47739
|
+
let can = canSplit(tr.doc, splitPos, types2.length, types2);
|
|
47740
|
+
if (!can) {
|
|
47741
|
+
types2[0] = deflt ? { type: deflt } : null;
|
|
47742
|
+
can = canSplit(tr.doc, splitPos, types2.length, types2);
|
|
47743
|
+
}
|
|
47744
|
+
if (!can) return false;
|
|
47745
|
+
tr.split(splitPos, types2.length, types2);
|
|
47746
|
+
if (!atEnd && atStart && $from.node(splitDepth).type != deflt) {
|
|
47747
|
+
let first2 = tr.mapping.map($from.before(splitDepth)), $first = tr.doc.resolve(first2);
|
|
47748
|
+
if (deflt && $from.node(splitDepth - 1).canReplaceWith($first.index(), $first.index() + 1, deflt))
|
|
47749
|
+
tr.setNodeMarkup(tr.mapping.map($from.before(splitDepth)), deflt);
|
|
47750
|
+
}
|
|
47751
|
+
if (dispatch) dispatch(tr.scrollIntoView());
|
|
47752
|
+
return true;
|
|
47753
|
+
}
|
|
47754
|
+
const splitRunAtCursor = () => (props) => {
|
|
47755
|
+
let { state: state2, dispatch, tr } = props;
|
|
47756
|
+
const sel = state2.selection;
|
|
47757
|
+
if (!sel.empty) return false;
|
|
47758
|
+
const $pos = sel.$from;
|
|
47759
|
+
const runType = state2.schema.nodes.run;
|
|
47760
|
+
if ($pos.parent.type !== runType) return false;
|
|
47761
|
+
const run2 = $pos.parent;
|
|
47762
|
+
const offset2 = $pos.parentOffset;
|
|
47763
|
+
const runStart = $pos.before();
|
|
47764
|
+
const runEnd = runStart + run2.nodeSize;
|
|
47765
|
+
const leftFrag = run2.content.cut(0, offset2);
|
|
47766
|
+
const rightFrag = run2.content.cut(offset2);
|
|
47767
|
+
const leftRun = runType.create(run2.attrs, leftFrag, run2.marks);
|
|
47768
|
+
const rightRun = runType.create(run2.attrs, rightFrag, run2.marks);
|
|
47769
|
+
const gapPos = runStart + leftRun.nodeSize;
|
|
47770
|
+
tr.replaceWith(runStart, runEnd, [leftRun, rightRun]).setSelection(TextSelection$1.create(tr.doc, gapPos));
|
|
47771
|
+
if (dispatch) {
|
|
47772
|
+
dispatch(tr);
|
|
47773
|
+
}
|
|
47774
|
+
return true;
|
|
47775
|
+
};
|
|
47663
47776
|
const insertTabCharacter = ({ tr, state: state2, dispatch }) => {
|
|
47664
47777
|
const { from: from2 } = tr.selection;
|
|
47665
47778
|
const tabText = state2.schema.text(" ");
|
|
@@ -47669,10 +47782,23 @@ const insertTabCharacter = ({ tr, state: state2, dispatch }) => {
|
|
|
47669
47782
|
return true;
|
|
47670
47783
|
};
|
|
47671
47784
|
const insertTabNode = () => ({ tr, state: state2, dispatch }) => {
|
|
47672
|
-
|
|
47785
|
+
let newPos = tr.selection.from;
|
|
47673
47786
|
const tabNode = state2.schema?.nodes?.tab?.create();
|
|
47674
47787
|
if (!tabNode) return insertTabCharacter({ tr, state: state2, dispatch });
|
|
47788
|
+
const { from: from2 } = tr.selection;
|
|
47789
|
+
const $pos = tr.doc.resolve(from2);
|
|
47790
|
+
if ($pos.parent.type === state2.schema.nodes.run) {
|
|
47791
|
+
if (from2 === $pos.end()) {
|
|
47792
|
+
newPos = $pos.end() + 1;
|
|
47793
|
+
} else if (from2 === $pos.start()) {
|
|
47794
|
+
newPos = $pos.start() - 1;
|
|
47795
|
+
} else {
|
|
47796
|
+
splitRunAtCursor()({ tr, state: state2 });
|
|
47797
|
+
newPos = tr.selection.from;
|
|
47798
|
+
}
|
|
47799
|
+
}
|
|
47675
47800
|
tr.insert(newPos, tabNode);
|
|
47801
|
+
tr = tr.setSelection(TextSelection$1.create(tr.doc, newPos + tabNode.nodeSize));
|
|
47676
47802
|
if (dispatch) dispatch(tr);
|
|
47677
47803
|
return true;
|
|
47678
47804
|
};
|
|
@@ -49128,6 +49254,139 @@ const unsetLineHeight = () => ({ commands: commands2 }) => {
|
|
|
49128
49254
|
"paragraphProperties.spacing.lineRule"
|
|
49129
49255
|
);
|
|
49130
49256
|
};
|
|
49257
|
+
const backspaceEmptyRunParagraph = () => ({ state: state2, dispatch }) => {
|
|
49258
|
+
const { $from } = state2.selection;
|
|
49259
|
+
if (!state2.selection.empty) return false;
|
|
49260
|
+
const paraType = state2.schema.nodes.paragraph;
|
|
49261
|
+
const runType = state2.schema.nodes.run;
|
|
49262
|
+
const para = $from.parent;
|
|
49263
|
+
if (para.type !== paraType || para.childCount !== 1 || para.firstChild.type !== runType || para.firstChild.content.size)
|
|
49264
|
+
return false;
|
|
49265
|
+
if (state2.doc.childCount === 1 && $from.depth === 1) return false;
|
|
49266
|
+
if (dispatch) {
|
|
49267
|
+
const paraPos = $from.before();
|
|
49268
|
+
let tr = state2.tr.deleteRange(paraPos, paraPos + para.nodeSize).scrollIntoView();
|
|
49269
|
+
const targetPos = Math.max(1, Math.min(paraPos - 1, tr.doc.content.size));
|
|
49270
|
+
tr = tr.setSelection(TextSelection$1.create(tr.doc, targetPos));
|
|
49271
|
+
dispatch(tr);
|
|
49272
|
+
}
|
|
49273
|
+
return true;
|
|
49274
|
+
};
|
|
49275
|
+
const backspaceSkipEmptyRun = () => ({ state: state2, dispatch }) => {
|
|
49276
|
+
const sel = state2.selection;
|
|
49277
|
+
if (!sel.empty) return false;
|
|
49278
|
+
const runType = state2.schema.nodes.run;
|
|
49279
|
+
const $pos = sel.$from;
|
|
49280
|
+
const emptyRun = (n) => n && n.type === runType && n.content.size === 0;
|
|
49281
|
+
if ($pos.parent.type !== runType || $pos.pos !== $pos.end() || !emptyRun(state2.doc.nodeAt($pos.pos + 1))) {
|
|
49282
|
+
return false;
|
|
49283
|
+
}
|
|
49284
|
+
const leftTextSel = Selection.findFrom($pos, -1, true);
|
|
49285
|
+
if (!leftTextSel) return false;
|
|
49286
|
+
const pos = leftTextSel.$from.pos;
|
|
49287
|
+
if (dispatch) {
|
|
49288
|
+
dispatch(state2.tr.delete(pos - 1, pos).scrollIntoView());
|
|
49289
|
+
}
|
|
49290
|
+
return true;
|
|
49291
|
+
};
|
|
49292
|
+
const backspaceNextToRun = () => ({ state: state2, tr, dispatch }) => {
|
|
49293
|
+
const sel = state2.selection;
|
|
49294
|
+
if (!sel.empty) return false;
|
|
49295
|
+
const runType = state2.schema.nodes.run;
|
|
49296
|
+
const $pos = sel.$from;
|
|
49297
|
+
if ($pos.nodeBefore?.type !== runType && $pos.pos !== $pos.start()) return false;
|
|
49298
|
+
if ($pos.nodeBefore) {
|
|
49299
|
+
if ($pos.nodeBefore.content.size === 0) return false;
|
|
49300
|
+
tr.delete($pos.pos - 2, $pos.pos - 1).setSelection(Selection.near(tr.doc.resolve($pos.pos - 2)));
|
|
49301
|
+
if (dispatch) {
|
|
49302
|
+
dispatch(tr.scrollIntoView());
|
|
49303
|
+
}
|
|
49304
|
+
} else {
|
|
49305
|
+
const prevNode = state2.doc.resolve($pos.start() - 1).nodeBefore;
|
|
49306
|
+
if (prevNode?.type !== runType || prevNode.content.size === 0) return false;
|
|
49307
|
+
tr.delete($pos.pos - 3, $pos.pos - 2).setSelection(Selection.near(tr.doc.resolve($pos.pos - 3)));
|
|
49308
|
+
if (dispatch) {
|
|
49309
|
+
dispatch(tr.scrollIntoView());
|
|
49310
|
+
}
|
|
49311
|
+
}
|
|
49312
|
+
return true;
|
|
49313
|
+
};
|
|
49314
|
+
const deleteSkipEmptyRun = () => ({ state: state2, dispatch }) => {
|
|
49315
|
+
const sel = state2.selection;
|
|
49316
|
+
if (!sel.empty) return false;
|
|
49317
|
+
const runType = state2.schema.nodes.run;
|
|
49318
|
+
const $pos = sel.$from;
|
|
49319
|
+
const emptyRun = (n) => n && n.type === runType && n.content.size === 0;
|
|
49320
|
+
if ($pos.parent.type === runType && emptyRun(state2.doc.nodeAt($pos.end() + 1))) {
|
|
49321
|
+
if ($pos.pos === $pos.end()) {
|
|
49322
|
+
return deleteFromEndOfRun(state2, dispatch, $pos);
|
|
49323
|
+
} else if ($pos.pos === $pos.end() - 1) {
|
|
49324
|
+
return deleteFromLastCharacter(state2, dispatch, $pos);
|
|
49325
|
+
}
|
|
49326
|
+
return false;
|
|
49327
|
+
}
|
|
49328
|
+
return false;
|
|
49329
|
+
};
|
|
49330
|
+
function deleteFromEndOfRun(state2, dispatch, $pos) {
|
|
49331
|
+
const rightRun = state2.doc.nodeAt($pos.pos + 1);
|
|
49332
|
+
const $afterRightRunPos = state2.doc.resolve($pos.pos + 2 + rightRun.nodeSize);
|
|
49333
|
+
const rightTextSel = Selection.findFrom($afterRightRunPos, 1, true);
|
|
49334
|
+
if (!rightTextSel) return false;
|
|
49335
|
+
const pos = rightTextSel.$from.pos;
|
|
49336
|
+
if (dispatch) {
|
|
49337
|
+
dispatch(state2.tr.delete(pos, pos + 1).scrollIntoView());
|
|
49338
|
+
}
|
|
49339
|
+
return true;
|
|
49340
|
+
}
|
|
49341
|
+
function deleteFromLastCharacter(state2, dispatch, $pos) {
|
|
49342
|
+
if (dispatch) {
|
|
49343
|
+
dispatch(state2.tr.delete($pos.pos, $pos.pos + 1).scrollIntoView());
|
|
49344
|
+
}
|
|
49345
|
+
return true;
|
|
49346
|
+
}
|
|
49347
|
+
const deleteNextToRun = () => ({ state: state2, tr, dispatch }) => {
|
|
49348
|
+
const sel = state2.selection;
|
|
49349
|
+
if (!sel.empty) return false;
|
|
49350
|
+
const runType = state2.schema.nodes.run;
|
|
49351
|
+
const $pos = sel.$from;
|
|
49352
|
+
if ($pos.nodeAfter?.type !== runType && $pos.pos !== $pos.end()) return false;
|
|
49353
|
+
if ($pos.nodeAfter) {
|
|
49354
|
+
if ($pos.nodeAfter.content.size === 0) return false;
|
|
49355
|
+
tr.delete($pos.pos + 1, $pos.pos + 2).setSelection(Selection.near(tr.doc.resolve($pos.pos + 1)));
|
|
49356
|
+
if (dispatch) {
|
|
49357
|
+
dispatch(tr.scrollIntoView());
|
|
49358
|
+
}
|
|
49359
|
+
} else {
|
|
49360
|
+
const nextNode = state2.doc.resolve($pos.end() + 1).nodeAfter;
|
|
49361
|
+
if (nextNode?.type !== runType || nextNode.content.size === 0) return false;
|
|
49362
|
+
tr.delete($pos.pos + 2, $pos.pos + 3).setSelection(Selection.near(tr.doc.resolve($pos.pos + 2)));
|
|
49363
|
+
if (dispatch) {
|
|
49364
|
+
dispatch(tr.scrollIntoView());
|
|
49365
|
+
}
|
|
49366
|
+
}
|
|
49367
|
+
return true;
|
|
49368
|
+
};
|
|
49369
|
+
function skipTab(dir) {
|
|
49370
|
+
return ({ state: state2, dispatch }) => {
|
|
49371
|
+
const tab = state2.schema.nodes.tab;
|
|
49372
|
+
const run2 = state2.schema.nodes.run;
|
|
49373
|
+
const sel = state2.selection;
|
|
49374
|
+
if (!tab || !sel.empty) return false;
|
|
49375
|
+
const $pos = sel.$from;
|
|
49376
|
+
if ($pos.parent.type !== run2) return false;
|
|
49377
|
+
if (dir > 0 && $pos.pos < $pos.end()) return false;
|
|
49378
|
+
if (dir < 0 && $pos.pos > $pos.start()) return false;
|
|
49379
|
+
const step = dir > 0 ? 1 : -1;
|
|
49380
|
+
let $nextPos = state2.doc.resolve($pos.pos + step);
|
|
49381
|
+
const nextNode = dir > 0 ? $nextPos.nodeAfter : $nextPos.nodeBefore;
|
|
49382
|
+
if (!nextNode || nextNode.type !== tab) return false;
|
|
49383
|
+
const nextPos = dir > 0 ? Math.min($nextPos.pos + nextNode.nodeSize + 1, state2.doc.nodeSize) : Math.max(0, $nextPos.pos - nextNode.nodeSize - 1);
|
|
49384
|
+
if (dispatch) {
|
|
49385
|
+
dispatch(state2.tr.setSelection(TextSelection$1.create(state2.doc, nextPos)));
|
|
49386
|
+
}
|
|
49387
|
+
return true;
|
|
49388
|
+
};
|
|
49389
|
+
}
|
|
49131
49390
|
const toggleList = (listType) => ({ editor, state: state2, tr, dispatch }) => {
|
|
49132
49391
|
let predicate;
|
|
49133
49392
|
if (listType === "orderedList") {
|
|
@@ -49203,6 +49462,13 @@ const toggleList = (listType) => ({ editor, state: state2, tr, dispatch }) => {
|
|
|
49203
49462
|
}
|
|
49204
49463
|
updateNumberingProperties(sharedNumberingProperties, node, pos, editor, tr);
|
|
49205
49464
|
}
|
|
49465
|
+
const newTo = tr.mapping.map(to);
|
|
49466
|
+
if (newTo >= 0 && newTo <= tr.doc.content.size) {
|
|
49467
|
+
try {
|
|
49468
|
+
tr.setSelection(state2.selection.constructor.near(tr.doc.resolve(newTo)));
|
|
49469
|
+
} catch {
|
|
49470
|
+
}
|
|
49471
|
+
}
|
|
49206
49472
|
if (dispatch) dispatch(tr);
|
|
49207
49473
|
return true;
|
|
49208
49474
|
};
|
|
@@ -49321,6 +49587,9 @@ const getSelectionMarks = () => ({ state: state2, tr }) => {
|
|
|
49321
49587
|
};
|
|
49322
49588
|
const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
49323
49589
|
__proto__: null,
|
|
49590
|
+
backspaceEmptyRunParagraph,
|
|
49591
|
+
backspaceNextToRun,
|
|
49592
|
+
backspaceSkipEmptyRun,
|
|
49324
49593
|
changeListLevel,
|
|
49325
49594
|
clearNodes,
|
|
49326
49595
|
command,
|
|
@@ -49328,7 +49597,9 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
49328
49597
|
decreaseListIndent,
|
|
49329
49598
|
decreaseTextIndent,
|
|
49330
49599
|
defaultStyleDetector,
|
|
49600
|
+
deleteNextToRun,
|
|
49331
49601
|
deleteSelection,
|
|
49602
|
+
deleteSkipEmptyRun,
|
|
49332
49603
|
exitCode,
|
|
49333
49604
|
first,
|
|
49334
49605
|
getEffectiveStyleId,
|
|
@@ -49366,6 +49637,7 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
49366
49637
|
setSectionHeaderFooterAtSelection,
|
|
49367
49638
|
setTextIndentation,
|
|
49368
49639
|
setTextSelection,
|
|
49640
|
+
skipTab,
|
|
49369
49641
|
splitBlock: splitBlock$1,
|
|
49370
49642
|
toggleList,
|
|
49371
49643
|
toggleMark,
|
|
@@ -49387,7 +49659,7 @@ const Commands = Extension.create({
|
|
|
49387
49659
|
});
|
|
49388
49660
|
const handleEnter = (editor) => {
|
|
49389
49661
|
return editor.commands.first(({ commands: commands2 }) => [
|
|
49390
|
-
() => commands2.
|
|
49662
|
+
() => commands2.splitRunToParagraph(),
|
|
49391
49663
|
() => commands2.newlineInCode(),
|
|
49392
49664
|
() => commands2.createParagraphNear(),
|
|
49393
49665
|
() => commands2.liftEmptyBlock(),
|
|
@@ -49401,6 +49673,9 @@ const handleBackspace = (editor) => {
|
|
|
49401
49673
|
tr.setMeta("inputType", "deleteContentBackward");
|
|
49402
49674
|
return false;
|
|
49403
49675
|
},
|
|
49676
|
+
() => commands2.backspaceEmptyRunParagraph(),
|
|
49677
|
+
() => commands2.backspaceSkipEmptyRun(),
|
|
49678
|
+
() => commands2.backspaceNextToRun(),
|
|
49404
49679
|
() => commands2.deleteSelection(),
|
|
49405
49680
|
() => commands2.removeNumberingProperties(),
|
|
49406
49681
|
() => commands2.joinBackward(),
|
|
@@ -49409,6 +49684,8 @@ const handleBackspace = (editor) => {
|
|
|
49409
49684
|
};
|
|
49410
49685
|
const handleDelete = (editor) => {
|
|
49411
49686
|
return editor.commands.first(({ commands: commands2 }) => [
|
|
49687
|
+
() => commands2.deleteSkipEmptyRun(),
|
|
49688
|
+
() => commands2.deleteNextToRun(),
|
|
49412
49689
|
() => commands2.deleteSelection(),
|
|
49413
49690
|
() => commands2.joinForward(),
|
|
49414
49691
|
() => commands2.selectNodeForward()
|
|
@@ -49427,7 +49704,9 @@ const Keymap = Extension.create({
|
|
|
49427
49704
|
Delete: () => handleDelete(this.editor),
|
|
49428
49705
|
"Mod-Delete": () => handleDelete(this.editor),
|
|
49429
49706
|
"Mod-a": () => this.editor.commands.selectAll(),
|
|
49430
|
-
Tab: () => this.editor.commands.insertTabNode()
|
|
49707
|
+
Tab: () => this.editor.commands.insertTabNode(),
|
|
49708
|
+
ArrowLeft: () => this.editor.commands.skipTab(-1),
|
|
49709
|
+
ArrowRight: () => this.editor.commands.skipTab(1)
|
|
49431
49710
|
};
|
|
49432
49711
|
const pcBaseKeymap = {
|
|
49433
49712
|
...baseKeymap
|
|
@@ -52977,7 +53256,7 @@ const isHeadless = (editor) => {
|
|
|
52977
53256
|
const shouldSkipNodeView = (editor) => {
|
|
52978
53257
|
return isHeadless(editor);
|
|
52979
53258
|
};
|
|
52980
|
-
const summaryVersion = "1.0.0-beta.
|
|
53259
|
+
const summaryVersion = "1.0.0-beta.17";
|
|
52981
53260
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
52982
53261
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
52983
53262
|
function mapAttributes(attrs) {
|
|
@@ -53487,12 +53766,9 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
53487
53766
|
if (!this.schema) {
|
|
53488
53767
|
throw new Error("Schema is not initialized.");
|
|
53489
53768
|
}
|
|
53490
|
-
const topNodeName = this.schema.topNodeType?.name || "doc";
|
|
53491
|
-
const normalizedDoc = Array.isArray(doc2) ? { type: topNodeName, content: doc2 } : doc2 && typeof doc2 === "object" && doc2.type ? doc2.type === topNodeName || doc2.type === "doc" ? doc2 : { type: topNodeName, content: [doc2] } : (() => {
|
|
53492
|
-
throw new Error("Invalid document shape: expected a node object or an array of node objects.");
|
|
53493
|
-
})();
|
|
53494
53769
|
try {
|
|
53495
|
-
return this.schema.nodeFromJSON(
|
|
53770
|
+
if (Array.isArray(doc2)) return doc2.map((d2) => this.schema.nodeFromJSON(d2));
|
|
53771
|
+
return this.schema.nodeFromJSON(doc2);
|
|
53496
53772
|
} catch (error) {
|
|
53497
53773
|
const detail = error instanceof Error ? error.message : String(error);
|
|
53498
53774
|
const validationError = new Error(`Invalid document for current schema: ${detail}`);
|
|
@@ -53756,7 +54032,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
53756
54032
|
{ default: remarkStringify },
|
|
53757
54033
|
{ default: remarkGfm }
|
|
53758
54034
|
] = await Promise.all([
|
|
53759
|
-
import("./index-
|
|
54035
|
+
import("./index-VCeRjVPO-FBgR9qxX.es.js"),
|
|
53760
54036
|
import("./index-DRCvimau-Cw339678.es.js"),
|
|
53761
54037
|
import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
|
|
53762
54038
|
import("./index-D_sWOSiG-DE96TaT5.es.js"),
|
|
@@ -53961,7 +54237,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
53961
54237
|
* Process collaboration migrations
|
|
53962
54238
|
*/
|
|
53963
54239
|
processCollaborationMigrations() {
|
|
53964
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
54240
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.17");
|
|
53965
54241
|
if (!this.options.ydoc) return;
|
|
53966
54242
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
53967
54243
|
let docVersion = metaMap.get("version");
|
|
@@ -62452,6 +62728,9 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
62452
62728
|
};
|
|
62453
62729
|
if (measure.marker) {
|
|
62454
62730
|
fragment.markerWidth = measure.marker.markerWidth;
|
|
62731
|
+
if (measure.marker.markerTextWidth != null) {
|
|
62732
|
+
fragment.markerTextWidth = measure.marker.markerTextWidth;
|
|
62733
|
+
}
|
|
62455
62734
|
}
|
|
62456
62735
|
state2.page.fragments.push(fragment);
|
|
62457
62736
|
state2.trailingSpacing = 0;
|
|
@@ -62553,6 +62832,12 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
62553
62832
|
};
|
|
62554
62833
|
if (measure.marker && fromLine === 0) {
|
|
62555
62834
|
fragment.markerWidth = measure.marker.markerWidth;
|
|
62835
|
+
if (measure.marker.markerTextWidth != null) {
|
|
62836
|
+
fragment.markerTextWidth = measure.marker.markerTextWidth;
|
|
62837
|
+
}
|
|
62838
|
+
if (measure.kind === "paragraph" && measure.marker?.gutterWidth != null) {
|
|
62839
|
+
fragment.markerGutter = measure.marker.gutterWidth;
|
|
62840
|
+
}
|
|
62556
62841
|
}
|
|
62557
62842
|
if (fromLine > 0) fragment.continuesFromPrev = true;
|
|
62558
62843
|
if (slice2.toLine < lines.length) fragment.continuesOnNext = true;
|
|
@@ -64264,7 +64549,22 @@ const hashRuns = (block) => {
|
|
|
64264
64549
|
}
|
|
64265
64550
|
return `${text}:${marks}${trackedKey}`;
|
|
64266
64551
|
}).join("|");
|
|
64267
|
-
|
|
64552
|
+
let numberingKey = "";
|
|
64553
|
+
if (block.attrs) {
|
|
64554
|
+
const attrs = block.attrs;
|
|
64555
|
+
if (attrs.numberingProperties) {
|
|
64556
|
+
const np = attrs.numberingProperties;
|
|
64557
|
+
let markerTextKey;
|
|
64558
|
+
if (!attrs.wordLayout?.marker) {
|
|
64559
|
+
markerTextKey = "<NULL>";
|
|
64560
|
+
} else {
|
|
64561
|
+
const markerText = attrs.wordLayout.marker.markerText;
|
|
64562
|
+
markerTextKey = markerText === "" ? "<EMPTY>" : markerText ?? "<NULL>";
|
|
64563
|
+
}
|
|
64564
|
+
numberingKey = `|num:${np.numId ?? ""}:${np.ilvl ?? 0}:${markerTextKey}`;
|
|
64565
|
+
}
|
|
64566
|
+
}
|
|
64567
|
+
return `${trackedMode}:${trackedEnabled ? "on" : "off"}|${runsHash}${numberingKey}`;
|
|
64268
64568
|
};
|
|
64269
64569
|
const createStats = () => ({
|
|
64270
64570
|
hits: 0,
|
|
@@ -69276,6 +69576,7 @@ function assertFragmentPmPositions(fragment, context) {
|
|
|
69276
69576
|
}
|
|
69277
69577
|
}
|
|
69278
69578
|
const LIST_MARKER_GAP$1 = 8;
|
|
69579
|
+
const DEFAULT_TAB_INTERVAL_PX$1 = 48;
|
|
69279
69580
|
const COMMENT_EXTERNAL_COLOR = "#B1124B";
|
|
69280
69581
|
const COMMENT_INTERNAL_COLOR = "#078383";
|
|
69281
69582
|
const COMMENT_INACTIVE_ALPHA = "22";
|
|
@@ -70072,33 +70373,41 @@ const _DomPainter = class _DomPainter2 {
|
|
|
70072
70373
|
const firstLineOffset = (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
|
|
70073
70374
|
lines.forEach((line, index2) => {
|
|
70074
70375
|
const lineEl = this.renderLine(block, line, context);
|
|
70075
|
-
|
|
70376
|
+
const isListFirstLine = index2 === 0 && !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
|
|
70377
|
+
if (paraIndentLeft && !isListFirstLine) {
|
|
70076
70378
|
lineEl.style.paddingLeft = `${paraIndentLeft}px`;
|
|
70077
70379
|
}
|
|
70078
70380
|
if (paraIndentRight) {
|
|
70079
70381
|
lineEl.style.paddingRight = `${paraIndentRight}px`;
|
|
70080
70382
|
}
|
|
70081
|
-
if (!fragment.continuesFromPrev && index2 === 0 && firstLineOffset) {
|
|
70383
|
+
if (!fragment.continuesFromPrev && index2 === 0 && firstLineOffset && !isListFirstLine) {
|
|
70082
70384
|
lineEl.style.textIndent = `${firstLineOffset}px`;
|
|
70083
|
-
} else if (firstLineOffset) {
|
|
70385
|
+
} else if (firstLineOffset && !isListFirstLine) {
|
|
70084
70386
|
lineEl.style.textIndent = "0px";
|
|
70085
70387
|
}
|
|
70086
|
-
if (
|
|
70388
|
+
if (isListFirstLine && wordLayout?.marker && fragment.markerWidth) {
|
|
70389
|
+
const markerStartPos = paraIndentLeft - (paraIndent?.hanging ?? 0);
|
|
70390
|
+
lineEl.style.paddingLeft = `${markerStartPos}px`;
|
|
70087
70391
|
const markerContainer = this.doc.createElement("span");
|
|
70088
70392
|
markerContainer.style.display = "inline-block";
|
|
70089
70393
|
const markerEl = this.doc.createElement("span");
|
|
70090
70394
|
markerEl.classList.add("superdoc-paragraph-marker");
|
|
70091
70395
|
markerEl.textContent = wordLayout.marker.markerText ?? "";
|
|
70092
|
-
markerEl.style.width = `${fragment.markerWidth}px`;
|
|
70093
|
-
markerEl.style.textAlign = wordLayout.marker.justification ?? "right";
|
|
70094
|
-
markerEl.style.paddingRight = `${LIST_MARKER_GAP$1}px`;
|
|
70095
70396
|
markerEl.style.pointerEvents = "none";
|
|
70096
|
-
const
|
|
70097
|
-
|
|
70098
|
-
|
|
70099
|
-
|
|
70100
|
-
|
|
70101
|
-
|
|
70397
|
+
const markerJustification = wordLayout.marker.justification ?? "left";
|
|
70398
|
+
if (markerJustification !== "left") {
|
|
70399
|
+
markerEl.style.width = `${fragment.markerWidth}px`;
|
|
70400
|
+
markerEl.style.textAlign = wordLayout.marker.justification ?? "right";
|
|
70401
|
+
markerEl.style.paddingRight = `${LIST_MARKER_GAP$1}px`;
|
|
70402
|
+
}
|
|
70403
|
+
if (markerJustification === "left") {
|
|
70404
|
+
markerContainer.style.position = "relative";
|
|
70405
|
+
} else {
|
|
70406
|
+
const markerLeftX = markerStartPos - fragment.markerWidth;
|
|
70407
|
+
markerContainer.style.position = "absolute";
|
|
70408
|
+
markerContainer.style.left = `${markerLeftX}px`;
|
|
70409
|
+
markerContainer.style.top = "0";
|
|
70410
|
+
}
|
|
70102
70411
|
markerEl.style.fontFamily = wordLayout.marker.run.fontFamily;
|
|
70103
70412
|
markerEl.style.fontSize = `${wordLayout.marker.run.fontSize}px`;
|
|
70104
70413
|
markerEl.style.fontWeight = wordLayout.marker.run.bold ? "bold" : "";
|
|
@@ -70115,12 +70424,25 @@ const _DomPainter = class _DomPainter2 {
|
|
|
70115
70424
|
const tabEl = this.doc.createElement("span");
|
|
70116
70425
|
tabEl.className = "superdoc-tab";
|
|
70117
70426
|
tabEl.innerHTML = " ";
|
|
70118
|
-
|
|
70427
|
+
let tabWidth;
|
|
70428
|
+
const markerBoxWidth = fragment.markerWidth;
|
|
70429
|
+
const markerTextWidth = fragment.markerTextWidth != null && isFinite(fragment.markerTextWidth) && fragment.markerTextWidth >= 0 ? fragment.markerTextWidth : markerBoxWidth;
|
|
70430
|
+
if ((wordLayout.marker.justification ?? "left") === "left") {
|
|
70431
|
+
const currentPos = markerStartPos + markerTextWidth;
|
|
70432
|
+
const implicitTabStop = paraIndentLeft;
|
|
70433
|
+
tabWidth = implicitTabStop - currentPos;
|
|
70434
|
+
if (tabWidth < 1) {
|
|
70435
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$1 - currentPos % DEFAULT_TAB_INTERVAL_PX$1;
|
|
70436
|
+
if (tabWidth === 0) tabWidth = DEFAULT_TAB_INTERVAL_PX$1;
|
|
70437
|
+
}
|
|
70438
|
+
} else {
|
|
70439
|
+
tabWidth = fragment.markerGutter != null && isFinite(fragment.markerGutter) ? fragment.markerGutter : typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx > 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP$1;
|
|
70440
|
+
}
|
|
70119
70441
|
tabEl.style.display = "inline-block";
|
|
70120
|
-
tabEl.style.width = `${
|
|
70121
|
-
|
|
70442
|
+
tabEl.style.width = `${tabWidth}px`;
|
|
70443
|
+
lineEl.prepend(tabEl);
|
|
70122
70444
|
} else if (suffix2 === "space") {
|
|
70123
|
-
|
|
70445
|
+
lineEl.prepend(this.doc.createTextNode(" "));
|
|
70124
70446
|
}
|
|
70125
70447
|
lineEl.prepend(markerContainer);
|
|
70126
70448
|
}
|
|
@@ -71594,7 +71916,9 @@ const fragmentSignature = (fragment, lookup2) => {
|
|
|
71594
71916
|
fragment.pmStart ?? "",
|
|
71595
71917
|
fragment.pmEnd ?? "",
|
|
71596
71918
|
fragment.continuesFromPrev ? 1 : 0,
|
|
71597
|
-
fragment.continuesOnNext ? 1 : 0
|
|
71919
|
+
fragment.continuesOnNext ? 1 : 0,
|
|
71920
|
+
fragment.markerWidth ?? ""
|
|
71921
|
+
// Include markerWidth to trigger re-render when list status changes
|
|
71598
71922
|
].join("|");
|
|
71599
71923
|
}
|
|
71600
71924
|
if (fragment.kind === "list-item") {
|
|
@@ -72765,10 +73089,14 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
72765
73089
|
const { font: markerFont } = buildFontString(markerRun);
|
|
72766
73090
|
const markerText = wordLayout.marker.markerText ?? "";
|
|
72767
73091
|
const glyphWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
|
|
73092
|
+
const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP;
|
|
73093
|
+
const markerBoxWidth = Math.max(wordLayout.marker.markerBoxWidthPx ?? 0, glyphWidth + LIST_MARKER_GAP);
|
|
72768
73094
|
markerInfo = {
|
|
72769
|
-
markerWidth:
|
|
73095
|
+
markerWidth: markerBoxWidth,
|
|
72770
73096
|
markerTextWidth: glyphWidth,
|
|
72771
|
-
indentLeft: wordLayout.indentLeftPx ?? 0
|
|
73097
|
+
indentLeft: wordLayout.indentLeftPx ?? 0,
|
|
73098
|
+
// For tab sizing in the renderer: expose gutter for word-layout lists
|
|
73099
|
+
gutterWidth: gutter
|
|
72772
73100
|
};
|
|
72773
73101
|
}
|
|
72774
73102
|
return {
|
|
@@ -79037,6 +79365,17 @@ const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ O
|
|
|
79037
79365
|
parseTagObject
|
|
79038
79366
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
79039
79367
|
const STRUCTURED_CONTENT_NAMES = ["structuredContent", "structuredContentBlock"];
|
|
79368
|
+
const findFirstTextNode = (node) => {
|
|
79369
|
+
let firstTextNode = null;
|
|
79370
|
+
node.descendants((child) => {
|
|
79371
|
+
if (child.isText) {
|
|
79372
|
+
firstTextNode = child;
|
|
79373
|
+
return false;
|
|
79374
|
+
}
|
|
79375
|
+
return true;
|
|
79376
|
+
});
|
|
79377
|
+
return firstTextNode;
|
|
79378
|
+
};
|
|
79040
79379
|
const StructuredContentCommands = Extension.create({
|
|
79041
79380
|
name: "structuredContentCommands",
|
|
79042
79381
|
addCommands() {
|
|
@@ -79177,7 +79516,7 @@ const StructuredContentCommands = Extension.create({
|
|
|
79177
79516
|
* @param {string} id - Unique identifier of the field
|
|
79178
79517
|
* @param {StructuredContentUpdate} options
|
|
79179
79518
|
* @example
|
|
79180
|
-
* editor.commands.updateStructuredContentById('123', { text: 'Jane Doe' });
|
|
79519
|
+
* editor.commands.updateStructuredContentById('123', { text: 'Jane Doe', keepTextNodeStyles: true });
|
|
79181
79520
|
* editor.commands.updateStructuredContentById('123', {
|
|
79182
79521
|
* json: { type: 'text', text: 'Jane Doe' },
|
|
79183
79522
|
* });
|
|
@@ -79198,7 +79537,9 @@ const StructuredContentCommands = Extension.create({
|
|
|
79198
79537
|
const posTo = pos + node.nodeSize;
|
|
79199
79538
|
let content = null;
|
|
79200
79539
|
if (options.text) {
|
|
79201
|
-
|
|
79540
|
+
const firstTextNode = options.keepTextNodeStyles === true ? findFirstTextNode(node) : null;
|
|
79541
|
+
const textMarks = firstTextNode ? firstTextNode.marks : [];
|
|
79542
|
+
content = schema.text(options.text, textMarks);
|
|
79202
79543
|
}
|
|
79203
79544
|
if (options.html) {
|
|
79204
79545
|
const html = htmlHandler(options.html, editor);
|
|
@@ -79212,6 +79553,13 @@ const StructuredContentCommands = Extension.create({
|
|
|
79212
79553
|
content = node.content;
|
|
79213
79554
|
}
|
|
79214
79555
|
const updatedNode = node.type.create({ ...node.attrs, ...options.attrs }, content, node.marks);
|
|
79556
|
+
try {
|
|
79557
|
+
const nodeForValidation = editor.validateJSON(updatedNode.toJSON());
|
|
79558
|
+
nodeForValidation.check();
|
|
79559
|
+
} catch (error) {
|
|
79560
|
+
console.error("Invalid content.", "Passed value:", content, "Error:", error);
|
|
79561
|
+
return false;
|
|
79562
|
+
}
|
|
79215
79563
|
tr.replaceWith(posFrom, posTo, updatedNode);
|
|
79216
79564
|
}
|
|
79217
79565
|
return true;
|
|
@@ -79296,7 +79644,7 @@ const StructuredContentCommands = Extension.create({
|
|
|
79296
79644
|
* @param {StructuredContentUpdate} options
|
|
79297
79645
|
* @example
|
|
79298
79646
|
* // Update all fields in the customer-info group
|
|
79299
|
-
* editor.commands.updateStructuredContentByGroup('customer-info', { text: 'Jane Doe' });
|
|
79647
|
+
* editor.commands.updateStructuredContentByGroup('customer-info', { text: 'Jane Doe', keepTextNodeStyles: true });
|
|
79300
79648
|
*
|
|
79301
79649
|
* // Update block content in a group
|
|
79302
79650
|
* editor.commands.updateStructuredContentByGroup('terms-section', {
|
|
@@ -79310,13 +79658,14 @@ const StructuredContentCommands = Extension.create({
|
|
|
79310
79658
|
}
|
|
79311
79659
|
const { schema } = editor;
|
|
79312
79660
|
if (dispatch) {
|
|
79313
|
-
|
|
79661
|
+
const updates = [];
|
|
79662
|
+
for (const structuredContent of structuredContentTags) {
|
|
79314
79663
|
const { pos, node } = structuredContent;
|
|
79315
|
-
const posFrom = tr.mapping.map(pos);
|
|
79316
|
-
const posTo = tr.mapping.map(pos + node.nodeSize);
|
|
79317
79664
|
let content = null;
|
|
79318
79665
|
if (options.text) {
|
|
79319
|
-
|
|
79666
|
+
const firstTextNode = options.keepTextNodeStyles === true ? findFirstTextNode(node) : null;
|
|
79667
|
+
const textMarks = firstTextNode ? firstTextNode.marks : [];
|
|
79668
|
+
content = schema.text(options.text, textMarks);
|
|
79320
79669
|
}
|
|
79321
79670
|
if (options.html) {
|
|
79322
79671
|
const html = htmlHandler(options.html, editor);
|
|
@@ -79330,11 +79679,23 @@ const StructuredContentCommands = Extension.create({
|
|
|
79330
79679
|
content = node.content;
|
|
79331
79680
|
}
|
|
79332
79681
|
const updatedNode = node.type.create({ ...node.attrs, ...options.attrs }, content, node.marks);
|
|
79682
|
+
try {
|
|
79683
|
+
const nodeForValidation = editor.validateJSON(updatedNode.toJSON());
|
|
79684
|
+
nodeForValidation.check();
|
|
79685
|
+
} catch (error) {
|
|
79686
|
+
console.error("Invalid content.", "Passed value:", content, "Error:", error);
|
|
79687
|
+
return false;
|
|
79688
|
+
}
|
|
79689
|
+
updates.push({ pos, node, updatedNode });
|
|
79690
|
+
}
|
|
79691
|
+
for (const { pos, node, updatedNode } of updates) {
|
|
79692
|
+
const posFrom = tr.mapping.map(pos);
|
|
79693
|
+
const posTo = tr.mapping.map(pos + node.nodeSize);
|
|
79333
79694
|
const currentNode = tr.doc.nodeAt(posFrom);
|
|
79334
79695
|
if (currentNode && node.eq(currentNode)) {
|
|
79335
79696
|
tr.replaceWith(posFrom, posTo, updatedNode);
|
|
79336
79697
|
}
|
|
79337
|
-
}
|
|
79698
|
+
}
|
|
79338
79699
|
}
|
|
79339
79700
|
return true;
|
|
79340
79701
|
},
|
|
@@ -79910,61 +80271,153 @@ const Text = Node$1.create({
|
|
|
79910
80271
|
return {};
|
|
79911
80272
|
}
|
|
79912
80273
|
});
|
|
79913
|
-
const
|
|
79914
|
-
|
|
79915
|
-
|
|
79916
|
-
|
|
79917
|
-
|
|
79918
|
-
|
|
79919
|
-
|
|
79920
|
-
|
|
79921
|
-
|
|
79922
|
-
|
|
79923
|
-
|
|
79924
|
-
|
|
79925
|
-
};
|
|
79926
|
-
|
|
79927
|
-
|
|
79928
|
-
|
|
79929
|
-
|
|
79930
|
-
|
|
79931
|
-
|
|
80274
|
+
const cleanupEmptyRunsPlugin = new Plugin({
|
|
80275
|
+
appendTransaction(trs, oldState, newState) {
|
|
80276
|
+
if (!trs.some((tr2) => tr2.docChanged)) return null;
|
|
80277
|
+
const { run: run2, paragraph } = newState.schema.nodes;
|
|
80278
|
+
if (!run2) return null;
|
|
80279
|
+
const ranges = [];
|
|
80280
|
+
trs.forEach((tr2) => {
|
|
80281
|
+
tr2.mapping.maps.forEach((map22) => {
|
|
80282
|
+
map22.forEach((oldStart, oldEnd, newStart, newEnd) => {
|
|
80283
|
+
if (newStart !== oldStart || oldEnd !== newEnd) ranges.push({ from: newStart, to: newEnd });
|
|
80284
|
+
});
|
|
80285
|
+
});
|
|
80286
|
+
});
|
|
80287
|
+
if (!ranges.length) return null;
|
|
80288
|
+
ranges.sort((a, b2) => a.from - b2.from);
|
|
80289
|
+
const merged = [];
|
|
80290
|
+
for (const r2 of ranges) {
|
|
80291
|
+
const from2 = Math.max(0, r2.from - 1);
|
|
80292
|
+
const to = Math.min(newState.doc.content.size, r2.to + 1);
|
|
80293
|
+
const last = merged[merged.length - 1];
|
|
80294
|
+
if (last && from2 <= last.to) last.to = Math.max(last.to, to);
|
|
80295
|
+
else merged.push({ from: from2, to });
|
|
80296
|
+
}
|
|
80297
|
+
const toDelete = [];
|
|
80298
|
+
merged.forEach(({ from: from2, to }) => {
|
|
80299
|
+
newState.doc.nodesBetween(from2, to, (node, pos, parent) => {
|
|
80300
|
+
if (node.type === run2 && node.content.size === 0 && parent?.type === paragraph) {
|
|
80301
|
+
toDelete.push({ from: pos, to: pos + node.nodeSize });
|
|
80302
|
+
}
|
|
80303
|
+
});
|
|
80304
|
+
});
|
|
80305
|
+
if (!toDelete.length) return null;
|
|
80306
|
+
const tr = newState.tr;
|
|
80307
|
+
toDelete.sort((a, b2) => b2.from - a.from).forEach(({ from: from2, to }) => tr.deleteRange(from2, to));
|
|
80308
|
+
return tr.docChanged ? tr : null;
|
|
79932
80309
|
}
|
|
79933
|
-
|
|
79934
|
-
|
|
79935
|
-
|
|
79936
|
-
|
|
79937
|
-
|
|
79938
|
-
|
|
79939
|
-
|
|
79940
|
-
|
|
79941
|
-
|
|
79942
|
-
|
|
79943
|
-
|
|
79944
|
-
|
|
80310
|
+
});
|
|
80311
|
+
const mergeRanges$1 = (ranges, docSize) => {
|
|
80312
|
+
if (!ranges.length) return [];
|
|
80313
|
+
const sorted = ranges.map(({ from: from2, to }) => ({
|
|
80314
|
+
from: Math.max(0, from2),
|
|
80315
|
+
to: Math.min(docSize, to)
|
|
80316
|
+
})).filter(({ from: from2, to }) => from2 < to).sort((a, b2) => a.from - b2.from);
|
|
80317
|
+
const merged = [];
|
|
80318
|
+
for (const range2 of sorted) {
|
|
80319
|
+
const last = merged[merged.length - 1];
|
|
80320
|
+
if (last && range2.from <= last.to) {
|
|
80321
|
+
last.to = Math.max(last.to, range2.to);
|
|
79945
80322
|
} else {
|
|
79946
|
-
|
|
79947
|
-
types2.unshift(null);
|
|
80323
|
+
merged.push({ ...range2 });
|
|
79948
80324
|
}
|
|
79949
80325
|
}
|
|
79950
|
-
|
|
79951
|
-
|
|
79952
|
-
|
|
79953
|
-
|
|
79954
|
-
|
|
79955
|
-
|
|
79956
|
-
|
|
79957
|
-
|
|
79958
|
-
|
|
79959
|
-
|
|
79960
|
-
|
|
79961
|
-
|
|
79962
|
-
|
|
79963
|
-
|
|
79964
|
-
|
|
79965
|
-
|
|
79966
|
-
|
|
79967
|
-
|
|
80326
|
+
return merged;
|
|
80327
|
+
};
|
|
80328
|
+
const collectChangedRanges = (trs, docSize) => {
|
|
80329
|
+
const ranges = [];
|
|
80330
|
+
trs.forEach((tr) => {
|
|
80331
|
+
if (!tr.docChanged) return;
|
|
80332
|
+
tr.mapping.maps.forEach((map22) => {
|
|
80333
|
+
map22.forEach((oldStart, oldEnd, newStart, newEnd) => {
|
|
80334
|
+
if (newStart !== oldStart || oldEnd !== newEnd) {
|
|
80335
|
+
ranges.push({ from: newStart, to: newEnd });
|
|
80336
|
+
}
|
|
80337
|
+
});
|
|
80338
|
+
});
|
|
80339
|
+
});
|
|
80340
|
+
return mergeRanges$1(ranges, docSize);
|
|
80341
|
+
};
|
|
80342
|
+
const mapRangesThroughTransactions = (ranges, transactions, docSize) => {
|
|
80343
|
+
let mapped = ranges;
|
|
80344
|
+
transactions.forEach((tr) => {
|
|
80345
|
+
mapped = mapped.map(({ from: from2, to }) => {
|
|
80346
|
+
const mappedFrom = tr.mapping.map(from2, -1);
|
|
80347
|
+
const mappedTo = tr.mapping.map(to, 1);
|
|
80348
|
+
if (mappedFrom >= mappedTo) return null;
|
|
80349
|
+
return { from: mappedFrom, to: mappedTo };
|
|
80350
|
+
}).filter(Boolean);
|
|
80351
|
+
});
|
|
80352
|
+
return mergeRanges$1(mapped, docSize);
|
|
80353
|
+
};
|
|
80354
|
+
const buildWrapTransaction = (state2, ranges, runType) => {
|
|
80355
|
+
if (!ranges.length) return null;
|
|
80356
|
+
const replacements = [];
|
|
80357
|
+
ranges.forEach(({ from: from2, to }) => {
|
|
80358
|
+
state2.doc.nodesBetween(from2, to, (node, pos, parent, index2) => {
|
|
80359
|
+
if (!node.isText || !parent || parent.type === runType) return;
|
|
80360
|
+
const match = parent.contentMatchAt ? parent.contentMatchAt(index2) : null;
|
|
80361
|
+
if (match && !match.matchType(runType)) return;
|
|
80362
|
+
if (!match && !parent.type.contentMatch.matchType(runType)) return;
|
|
80363
|
+
const runProperties = decodeRPrFromMarks(node.marks);
|
|
80364
|
+
const runNode = runType.create({ runProperties }, node);
|
|
80365
|
+
replacements.push({ from: pos, to: pos + node.nodeSize, runNode });
|
|
80366
|
+
});
|
|
80367
|
+
});
|
|
80368
|
+
if (!replacements.length) return null;
|
|
80369
|
+
const tr = state2.tr;
|
|
80370
|
+
replacements.sort((a, b2) => b2.from - a.from).forEach(({ from: from2, to, runNode }) => tr.replaceWith(from2, to, runNode));
|
|
80371
|
+
return tr.docChanged ? tr : null;
|
|
80372
|
+
};
|
|
80373
|
+
const wrapTextInRunsPlugin = () => {
|
|
80374
|
+
let view = null;
|
|
80375
|
+
let pendingRanges = [];
|
|
80376
|
+
const flush = () => {
|
|
80377
|
+
if (!view) return;
|
|
80378
|
+
const runType = view.state.schema.nodes.run;
|
|
80379
|
+
if (!runType) {
|
|
80380
|
+
pendingRanges = [];
|
|
80381
|
+
return;
|
|
80382
|
+
}
|
|
80383
|
+
const tr = buildWrapTransaction(view.state, pendingRanges, runType);
|
|
80384
|
+
pendingRanges = [];
|
|
80385
|
+
if (tr) {
|
|
80386
|
+
view.dispatch(tr);
|
|
80387
|
+
}
|
|
80388
|
+
};
|
|
80389
|
+
const onCompositionEnd = () => {
|
|
80390
|
+
if (typeof globalThis === "undefined") return;
|
|
80391
|
+
globalThis.queueMicrotask(flush);
|
|
80392
|
+
};
|
|
80393
|
+
return new Plugin({
|
|
80394
|
+
view(editorView) {
|
|
80395
|
+
view = editorView;
|
|
80396
|
+
editorView.dom.addEventListener("compositionend", onCompositionEnd);
|
|
80397
|
+
return {
|
|
80398
|
+
destroy() {
|
|
80399
|
+
editorView.dom.removeEventListener("compositionend", onCompositionEnd);
|
|
80400
|
+
view = null;
|
|
80401
|
+
pendingRanges = [];
|
|
80402
|
+
}
|
|
80403
|
+
};
|
|
80404
|
+
},
|
|
80405
|
+
appendTransaction(transactions, _oldState, newState) {
|
|
80406
|
+
const docSize = newState.doc.content.size;
|
|
80407
|
+
const runType = newState.schema.nodes.run;
|
|
80408
|
+
if (!runType) return null;
|
|
80409
|
+
pendingRanges = mapRangesThroughTransactions(pendingRanges, transactions, docSize);
|
|
80410
|
+
const changedRanges = collectChangedRanges(transactions, docSize);
|
|
80411
|
+
pendingRanges = mergeRanges$1([...pendingRanges, ...changedRanges], docSize);
|
|
80412
|
+
if (view?.composing) {
|
|
80413
|
+
return null;
|
|
80414
|
+
}
|
|
80415
|
+
const tr = buildWrapTransaction(newState, pendingRanges, runType);
|
|
80416
|
+
pendingRanges = [];
|
|
80417
|
+
return tr;
|
|
80418
|
+
}
|
|
80419
|
+
});
|
|
80420
|
+
};
|
|
79968
80421
|
const Run = OxmlNode.create({
|
|
79969
80422
|
name: "run",
|
|
79970
80423
|
oXmlName: "w:r",
|
|
@@ -80007,7 +80460,8 @@ const Run = OxmlNode.create({
|
|
|
80007
80460
|
// @ts-expect-error - Command signatures will be fixed in TS migration
|
|
80008
80461
|
addCommands() {
|
|
80009
80462
|
return {
|
|
80010
|
-
|
|
80463
|
+
splitRunToParagraph,
|
|
80464
|
+
splitRunAtCursor
|
|
80011
80465
|
};
|
|
80012
80466
|
},
|
|
80013
80467
|
parseDOM() {
|
|
@@ -80016,6 +80470,9 @@ const Run = OxmlNode.create({
|
|
|
80016
80470
|
renderDOM({ htmlAttributes }) {
|
|
80017
80471
|
const base2 = Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
|
|
80018
80472
|
return ["span", base2, 0];
|
|
80473
|
+
},
|
|
80474
|
+
addPmPlugins() {
|
|
80475
|
+
return [wrapTextInRunsPlugin(), cleanupEmptyRunsPlugin];
|
|
80019
80476
|
}
|
|
80020
80477
|
});
|
|
80021
80478
|
const restartNumbering = ({ editor, tr, state: state2, dispatch }) => {
|
|
@@ -80758,20 +81215,15 @@ function createNumberingPlugin(editor) {
|
|
|
80758
81215
|
} else {
|
|
80759
81216
|
markerText = docxNumberingHelpers.normalizeLvlTextChar(lvlText);
|
|
80760
81217
|
}
|
|
80761
|
-
|
|
81218
|
+
const newListRendering = {
|
|
80762
81219
|
markerText,
|
|
80763
81220
|
suffix: suffix2,
|
|
80764
81221
|
justification,
|
|
80765
81222
|
path,
|
|
80766
81223
|
numberingType: listNumberingType
|
|
80767
|
-
}
|
|
80768
|
-
|
|
80769
|
-
|
|
80770
|
-
suffix: suffix2,
|
|
80771
|
-
justification,
|
|
80772
|
-
path,
|
|
80773
|
-
numberingType: listNumberingType
|
|
80774
|
-
});
|
|
81224
|
+
};
|
|
81225
|
+
if (JSON.stringify(node.attrs.listRendering) !== JSON.stringify(newListRendering)) {
|
|
81226
|
+
tr.setNodeAttribute(pos, "listRendering", newListRendering);
|
|
80775
81227
|
}
|
|
80776
81228
|
return false;
|
|
80777
81229
|
});
|
|
@@ -81072,7 +81524,7 @@ const Paragraph = OxmlNode.create({
|
|
|
81072
81524
|
return null;
|
|
81073
81525
|
}
|
|
81074
81526
|
const { tr } = state2;
|
|
81075
|
-
tr.delete(range2.from, range2.to);
|
|
81527
|
+
tr.delete(range2.from, range2.to).setSelection(TextSelection$1.create(tr.doc, range2.from));
|
|
81076
81528
|
ListHelpers.createNewList({
|
|
81077
81529
|
listType: type2,
|
|
81078
81530
|
tr,
|
|
@@ -84502,7 +84954,10 @@ const Table = Node$1.create({
|
|
|
84502
84954
|
insertTable: ({ rows = 3, cols = 3, withHeaderRow = false } = {}) => ({ tr, dispatch, editor }) => {
|
|
84503
84955
|
const node = createTable(editor.schema, rows, cols, withHeaderRow);
|
|
84504
84956
|
if (dispatch) {
|
|
84505
|
-
|
|
84957
|
+
let offset2 = tr.selection.$from.end() + 1;
|
|
84958
|
+
if (tr.selection.$from.parent?.type?.name === "run") {
|
|
84959
|
+
offset2 = tr.selection.$from.after(tr.selection.$from.depth - 1);
|
|
84960
|
+
}
|
|
84506
84961
|
tr.replaceSelectionWith(node).scrollIntoView().setSelection(TextSelection$1.near(tr.doc.resolve(offset2)));
|
|
84507
84962
|
}
|
|
84508
84963
|
return true;
|
|
@@ -111840,6 +112295,12 @@ const _sfc_main$4 = {
|
|
|
111840
112295
|
};
|
|
111841
112296
|
const GenericPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-cbddcc0f"]]);
|
|
111842
112297
|
const _hoisted_1$3 = ["data-boundary-index", "data-boundary-type", "onMousedown"];
|
|
112298
|
+
const RESIZE_HANDLE_WIDTH_PX = 9;
|
|
112299
|
+
const RESIZE_HANDLE_OFFSET_PX = 4;
|
|
112300
|
+
const DRAG_OVERLAY_EXTENSION_PX = 1e3;
|
|
112301
|
+
const MIN_DRAG_OVERLAY_WIDTH_PX = 2e3;
|
|
112302
|
+
const THROTTLE_INTERVAL_MS = 16;
|
|
112303
|
+
const MIN_RESIZE_DELTA_PX = 1;
|
|
111843
112304
|
const _sfc_main$3 = {
|
|
111844
112305
|
__name: "TableResizeOverlay",
|
|
111845
112306
|
props: {
|
|
@@ -111863,26 +112324,73 @@ const _sfc_main$3 = {
|
|
|
111863
112324
|
setup(__props, { emit: __emit }) {
|
|
111864
112325
|
const props = __props;
|
|
111865
112326
|
const emit = __emit;
|
|
112327
|
+
const overlayRect = ref$1(null);
|
|
111866
112328
|
const tableMetadata = ref$1(null);
|
|
111867
112329
|
const dragState = ref$1(null);
|
|
111868
112330
|
const forcedCleanup = ref$1(false);
|
|
112331
|
+
let rafId = null;
|
|
112332
|
+
let isUnmounted = false;
|
|
112333
|
+
function startOverlayTracking() {
|
|
112334
|
+
if (rafId !== null) return;
|
|
112335
|
+
const step = () => {
|
|
112336
|
+
updateOverlayRect();
|
|
112337
|
+
rafId = requestAnimationFrame(step);
|
|
112338
|
+
};
|
|
112339
|
+
rafId = requestAnimationFrame(step);
|
|
112340
|
+
}
|
|
112341
|
+
function stopOverlayTracking() {
|
|
112342
|
+
if (rafId !== null) {
|
|
112343
|
+
cancelAnimationFrame(rafId);
|
|
112344
|
+
rafId = null;
|
|
112345
|
+
}
|
|
112346
|
+
}
|
|
111869
112347
|
const overlayStyle = computed(() => {
|
|
111870
|
-
if (!props.tableElement) return {};
|
|
111871
|
-
const rect =
|
|
112348
|
+
if (!overlayRect.value || !props.tableElement) return {};
|
|
112349
|
+
const rect = overlayRect.value;
|
|
111872
112350
|
let overlayWidth = rect.width;
|
|
111873
112351
|
if (dragState.value) {
|
|
111874
|
-
overlayWidth = Math.max(rect.width +
|
|
112352
|
+
overlayWidth = Math.max(rect.width + DRAG_OVERLAY_EXTENSION_PX, MIN_DRAG_OVERLAY_WIDTH_PX);
|
|
111875
112353
|
}
|
|
111876
112354
|
return {
|
|
111877
112355
|
position: "absolute",
|
|
111878
|
-
left: `${
|
|
111879
|
-
top: `${
|
|
112356
|
+
left: `${rect.left}px`,
|
|
112357
|
+
top: `${rect.top}px`,
|
|
111880
112358
|
width: `${overlayWidth}px`,
|
|
111881
112359
|
height: `${rect.height}px`,
|
|
111882
112360
|
pointerEvents: dragState.value ? "auto" : "none",
|
|
111883
112361
|
zIndex: 10
|
|
111884
112362
|
};
|
|
111885
112363
|
});
|
|
112364
|
+
function updateOverlayRect() {
|
|
112365
|
+
if (!props.tableElement) {
|
|
112366
|
+
overlayRect.value = null;
|
|
112367
|
+
return;
|
|
112368
|
+
}
|
|
112369
|
+
const parent = props.tableElement.offsetParent;
|
|
112370
|
+
const tableRect = props.tableElement.getBoundingClientRect();
|
|
112371
|
+
if (tableRect.width === 0 || tableRect.height === 0) {
|
|
112372
|
+
overlayRect.value = null;
|
|
112373
|
+
return;
|
|
112374
|
+
}
|
|
112375
|
+
if (parent) {
|
|
112376
|
+
const parentRect = parent.getBoundingClientRect();
|
|
112377
|
+
const left2 = tableRect.left - parentRect.left + (parent.scrollLeft || 0);
|
|
112378
|
+
const top2 = tableRect.top - parentRect.top + (parent.scrollTop || 0);
|
|
112379
|
+
overlayRect.value = {
|
|
112380
|
+
left: left2,
|
|
112381
|
+
top: top2,
|
|
112382
|
+
width: tableRect.width,
|
|
112383
|
+
height: tableRect.height
|
|
112384
|
+
};
|
|
112385
|
+
} else {
|
|
112386
|
+
overlayRect.value = {
|
|
112387
|
+
left: props.tableElement.offsetLeft,
|
|
112388
|
+
top: props.tableElement.offsetTop,
|
|
112389
|
+
width: tableRect.width,
|
|
112390
|
+
height: tableRect.height
|
|
112391
|
+
};
|
|
112392
|
+
}
|
|
112393
|
+
}
|
|
111886
112394
|
const resizableBoundaries = computed(() => {
|
|
111887
112395
|
if (!tableMetadata.value?.columns) {
|
|
111888
112396
|
return [];
|
|
@@ -111921,9 +112429,9 @@ const _sfc_main$3 = {
|
|
|
111921
112429
|
if (!colSegments || colSegments.length === 0) {
|
|
111922
112430
|
return [];
|
|
111923
112431
|
}
|
|
111924
|
-
return colSegments.map((seg) => ({
|
|
111925
|
-
y: seg.y,
|
|
111926
|
-
h: seg.h
|
|
112432
|
+
return colSegments.filter((seg) => seg && typeof seg === "object").map((seg) => ({
|
|
112433
|
+
y: typeof seg.y === "number" ? seg.y : 0,
|
|
112434
|
+
h: seg.h !== null && typeof seg.h === "number" ? seg.h : null
|
|
111927
112435
|
}));
|
|
111928
112436
|
}
|
|
111929
112437
|
function getSegmentHandleStyle(boundary, segment) {
|
|
@@ -111931,16 +112439,16 @@ const _sfc_main$3 = {
|
|
|
111931
112439
|
position: "absolute",
|
|
111932
112440
|
left: `${boundary.x}px`,
|
|
111933
112441
|
top: segment.y != null ? `${segment.y}px` : "0",
|
|
111934
|
-
width:
|
|
112442
|
+
width: `${RESIZE_HANDLE_WIDTH_PX}px`,
|
|
111935
112443
|
height: segment.h != null ? `${segment.h}px` : "100%",
|
|
111936
|
-
transform:
|
|
112444
|
+
transform: `translateX(-${RESIZE_HANDLE_OFFSET_PX}px)`,
|
|
111937
112445
|
cursor: "col-resize",
|
|
111938
112446
|
pointerEvents: "auto"
|
|
111939
112447
|
};
|
|
111940
112448
|
}
|
|
111941
112449
|
const guidelineStyle = computed(() => {
|
|
111942
112450
|
if (!dragState.value || !tableMetadata.value) return { display: "none" };
|
|
111943
|
-
const initialBoundary = resizableBoundaries.value[dragState.value.
|
|
112451
|
+
const initialBoundary = resizableBoundaries.value[dragState.value.resizableBoundaryIndex];
|
|
111944
112452
|
if (!initialBoundary) return { display: "none" };
|
|
111945
112453
|
const newX = initialBoundary.x + dragState.value.constrainedDelta;
|
|
111946
112454
|
return {
|
|
@@ -111997,11 +112505,11 @@ const _sfc_main$3 = {
|
|
|
111997
112505
|
});
|
|
111998
112506
|
}
|
|
111999
112507
|
}
|
|
112000
|
-
function onHandleMouseDown(event,
|
|
112508
|
+
function onHandleMouseDown(event, resizableBoundaryIndex) {
|
|
112001
112509
|
event.preventDefault();
|
|
112002
112510
|
event.stopPropagation();
|
|
112003
112511
|
if (!tableMetadata.value?.columns) return;
|
|
112004
|
-
const boundary = resizableBoundaries.value[
|
|
112512
|
+
const boundary = resizableBoundaries.value[resizableBoundaryIndex];
|
|
112005
112513
|
if (!boundary) return;
|
|
112006
112514
|
const columns = tableMetadata.value.columns;
|
|
112007
112515
|
const isRightEdge = boundary.type === "right-edge";
|
|
@@ -112009,7 +112517,7 @@ const _sfc_main$3 = {
|
|
|
112009
112517
|
const rightColumn = isRightEdge ? null : columns[boundary.index + 1];
|
|
112010
112518
|
dragState.value = {
|
|
112011
112519
|
columnIndex: boundary.index,
|
|
112012
|
-
|
|
112520
|
+
resizableBoundaryIndex,
|
|
112013
112521
|
isRightEdge,
|
|
112014
112522
|
initialX: event.clientX,
|
|
112015
112523
|
initialWidths: columns.map((col) => col.w),
|
|
@@ -112023,15 +112531,28 @@ const _sfc_main$3 = {
|
|
|
112023
112531
|
} : null,
|
|
112024
112532
|
constrainedDelta: 0
|
|
112025
112533
|
};
|
|
112534
|
+
if (!props.editor?.view?.dom) {
|
|
112535
|
+
emit("resize-error", { error: "Editor view not available" });
|
|
112536
|
+
dragState.value = null;
|
|
112537
|
+
return;
|
|
112538
|
+
}
|
|
112026
112539
|
const pmView = props.editor.view.dom;
|
|
112027
112540
|
pmView.style.pointerEvents = "none";
|
|
112028
|
-
|
|
112029
|
-
|
|
112030
|
-
|
|
112031
|
-
|
|
112032
|
-
|
|
112033
|
-
|
|
112034
|
-
|
|
112541
|
+
try {
|
|
112542
|
+
document.addEventListener("mousemove", onDocumentMouseMove2);
|
|
112543
|
+
document.addEventListener("mouseup", onDocumentMouseUp);
|
|
112544
|
+
emit("resize-start", {
|
|
112545
|
+
columnIndex: boundary.index,
|
|
112546
|
+
isRightEdge,
|
|
112547
|
+
initialWidths: dragState.value.initialWidths
|
|
112548
|
+
});
|
|
112549
|
+
} catch (error) {
|
|
112550
|
+
document.removeEventListener("mousemove", onDocumentMouseMove2);
|
|
112551
|
+
document.removeEventListener("mouseup", onDocumentMouseUp);
|
|
112552
|
+
pmView.style.pointerEvents = "auto";
|
|
112553
|
+
dragState.value = null;
|
|
112554
|
+
emit("resize-error", { error: error instanceof Error ? error.message : String(error) });
|
|
112555
|
+
}
|
|
112035
112556
|
}
|
|
112036
112557
|
function throttle2(func, limit) {
|
|
112037
112558
|
let inThrottle;
|
|
@@ -112056,7 +112577,7 @@ const _sfc_main$3 = {
|
|
|
112056
112577
|
return { throttled, cancel };
|
|
112057
112578
|
}
|
|
112058
112579
|
const mouseMoveThrottle = throttle2((event) => {
|
|
112059
|
-
if (!dragState.value) return;
|
|
112580
|
+
if (isUnmounted || !dragState.value) return;
|
|
112060
112581
|
const delta = event.clientX - dragState.value.initialX;
|
|
112061
112582
|
const minDelta = -(dragState.value.leftColumn.width - dragState.value.leftColumn.minWidth);
|
|
112062
112583
|
let maxDelta;
|
|
@@ -112082,7 +112603,7 @@ const _sfc_main$3 = {
|
|
|
112082
112603
|
columnIndex: dragState.value.columnIndex,
|
|
112083
112604
|
delta: constrainedDelta
|
|
112084
112605
|
});
|
|
112085
|
-
},
|
|
112606
|
+
}, THROTTLE_INTERVAL_MS);
|
|
112086
112607
|
const onDocumentMouseMove2 = mouseMoveThrottle.throttled;
|
|
112087
112608
|
function onDocumentMouseUp(event) {
|
|
112088
112609
|
if (!dragState.value) return;
|
|
@@ -112097,13 +112618,11 @@ const _sfc_main$3 = {
|
|
|
112097
112618
|
}
|
|
112098
112619
|
document.removeEventListener("mousemove", onDocumentMouseMove2);
|
|
112099
112620
|
document.removeEventListener("mouseup", onDocumentMouseUp);
|
|
112100
|
-
if (props.editor?.view) {
|
|
112621
|
+
if (props.editor?.view?.dom) {
|
|
112101
112622
|
const pmView = props.editor.view.dom;
|
|
112102
|
-
|
|
112103
|
-
pmView.style.pointerEvents = "auto";
|
|
112104
|
-
}
|
|
112623
|
+
pmView.style.pointerEvents = "auto";
|
|
112105
112624
|
}
|
|
112106
|
-
if (!forcedCleanup.value && Math.abs(finalDelta) >
|
|
112625
|
+
if (!forcedCleanup.value && Math.abs(finalDelta) > MIN_RESIZE_DELTA_PX) {
|
|
112107
112626
|
dispatchResizeTransaction(columnIndex, newWidths);
|
|
112108
112627
|
emit("resize-end", {
|
|
112109
112628
|
columnIndex,
|
|
@@ -112166,7 +112685,14 @@ const _sfc_main$3 = {
|
|
|
112166
112685
|
if (!pmElement) {
|
|
112167
112686
|
return null;
|
|
112168
112687
|
}
|
|
112169
|
-
const
|
|
112688
|
+
const pmStartAttr = pmElement.getAttribute("data-pm-start");
|
|
112689
|
+
if (!pmStartAttr) {
|
|
112690
|
+
return null;
|
|
112691
|
+
}
|
|
112692
|
+
const pmStart = parseInt(pmStartAttr, 10);
|
|
112693
|
+
if (!Number.isFinite(pmStart)) {
|
|
112694
|
+
return null;
|
|
112695
|
+
}
|
|
112170
112696
|
let tablePos = null;
|
|
112171
112697
|
state2.doc.descendants((node, pos) => {
|
|
112172
112698
|
if (node.type.name === "table") {
|
|
@@ -112218,6 +112744,12 @@ const _sfc_main$3 = {
|
|
|
112218
112744
|
() => props.tableElement,
|
|
112219
112745
|
() => {
|
|
112220
112746
|
parseTableMetadata();
|
|
112747
|
+
updateOverlayRect();
|
|
112748
|
+
if (props.visible && props.tableElement) {
|
|
112749
|
+
startOverlayTracking();
|
|
112750
|
+
} else if (!props.tableElement) {
|
|
112751
|
+
stopOverlayTracking();
|
|
112752
|
+
}
|
|
112221
112753
|
},
|
|
112222
112754
|
{ immediate: true }
|
|
112223
112755
|
);
|
|
@@ -112226,7 +112758,10 @@ const _sfc_main$3 = {
|
|
|
112226
112758
|
(visible) => {
|
|
112227
112759
|
if (visible) {
|
|
112228
112760
|
parseTableMetadata();
|
|
112761
|
+
updateOverlayRect();
|
|
112762
|
+
startOverlayTracking();
|
|
112229
112763
|
} else {
|
|
112764
|
+
stopOverlayTracking();
|
|
112230
112765
|
if (dragState.value) {
|
|
112231
112766
|
forcedCleanup.value = true;
|
|
112232
112767
|
onDocumentMouseUp(new MouseEvent("mouseup"));
|
|
@@ -112235,8 +112770,15 @@ const _sfc_main$3 = {
|
|
|
112235
112770
|
}
|
|
112236
112771
|
}
|
|
112237
112772
|
);
|
|
112773
|
+
onMounted(() => {
|
|
112774
|
+
window.addEventListener("scroll", updateOverlayRect, true);
|
|
112775
|
+
window.addEventListener("resize", updateOverlayRect);
|
|
112776
|
+
updateOverlayRect();
|
|
112777
|
+
});
|
|
112238
112778
|
onBeforeUnmount(() => {
|
|
112779
|
+
isUnmounted = true;
|
|
112239
112780
|
mouseMoveThrottle.cancel();
|
|
112781
|
+
stopOverlayTracking();
|
|
112240
112782
|
if (dragState.value) {
|
|
112241
112783
|
document.removeEventListener("mousemove", onDocumentMouseMove2);
|
|
112242
112784
|
document.removeEventListener("mouseup", onDocumentMouseUp);
|
|
@@ -112244,6 +112786,8 @@ const _sfc_main$3 = {
|
|
|
112244
112786
|
props.editor.view.dom.style.pointerEvents = "auto";
|
|
112245
112787
|
}
|
|
112246
112788
|
}
|
|
112789
|
+
window.removeEventListener("scroll", updateOverlayRect, true);
|
|
112790
|
+
window.removeEventListener("resize", updateOverlayRect);
|
|
112247
112791
|
});
|
|
112248
112792
|
return (_ctx, _cache) => {
|
|
112249
112793
|
return __props.visible && tableMetadata.value ? (openBlock(), createElementBlock("div", {
|
|
@@ -112253,21 +112797,21 @@ const _sfc_main$3 = {
|
|
|
112253
112797
|
onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
112254
112798
|
}, ["stop"]))
|
|
112255
112799
|
}, [
|
|
112256
|
-
(openBlock(true), createElementBlock(Fragment$1, null, renderList(resizableBoundaries.value, (boundary,
|
|
112800
|
+
(openBlock(true), createElementBlock(Fragment$1, null, renderList(resizableBoundaries.value, (boundary, resizableBoundaryIndex) => {
|
|
112257
112801
|
return openBlock(), createElementBlock(Fragment$1, {
|
|
112258
|
-
key: `boundary-${
|
|
112802
|
+
key: `boundary-${resizableBoundaryIndex}`
|
|
112259
112803
|
}, [
|
|
112260
112804
|
(openBlock(true), createElementBlock(Fragment$1, null, renderList(getBoundarySegments(boundary), (segment, segmentIndex) => {
|
|
112261
112805
|
return openBlock(), createElementBlock("div", {
|
|
112262
112806
|
key: `handle-${boundary.type}-${boundary.index}-${segmentIndex}`,
|
|
112263
112807
|
class: normalizeClass(["resize-handle", {
|
|
112264
|
-
"resize-handle--active": dragState.value && dragState.value.
|
|
112808
|
+
"resize-handle--active": dragState.value && dragState.value.resizableBoundaryIndex === resizableBoundaryIndex,
|
|
112265
112809
|
"resize-handle--edge": boundary.type === "right-edge"
|
|
112266
112810
|
}]),
|
|
112267
|
-
"data-boundary-index":
|
|
112811
|
+
"data-boundary-index": resizableBoundaryIndex,
|
|
112268
112812
|
"data-boundary-type": boundary.type,
|
|
112269
112813
|
style: normalizeStyle(getSegmentHandleStyle(boundary, segment)),
|
|
112270
|
-
onMousedown: ($event) => onHandleMouseDown($event,
|
|
112814
|
+
onMousedown: ($event) => onHandleMouseDown($event, resizableBoundaryIndex)
|
|
112271
112815
|
}, null, 46, _hoisted_1$3);
|
|
112272
112816
|
}), 128))
|
|
112273
112817
|
], 64);
|
|
@@ -112281,7 +112825,7 @@ const _sfc_main$3 = {
|
|
|
112281
112825
|
};
|
|
112282
112826
|
}
|
|
112283
112827
|
};
|
|
112284
|
-
const TableResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-
|
|
112828
|
+
const TableResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-2fdf7836"]]);
|
|
112285
112829
|
const _hoisted_1$2 = ["data-handle-position", "onMousedown"];
|
|
112286
112830
|
const OVERLAY_EXPANSION_PX = 2e3;
|
|
112287
112831
|
const RESIZE_HANDLE_SIZE_PX = 12;
|