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
|
@@ -19784,7 +19784,7 @@ function decodeRPrFromMarks(marks) {
|
|
|
19784
19784
|
return runProperties;
|
|
19785
19785
|
}
|
|
19786
19786
|
marks.forEach((mark) => {
|
|
19787
|
-
switch (mark.type) {
|
|
19787
|
+
switch (mark.type.name ?? mark.type) {
|
|
19788
19788
|
case "strike":
|
|
19789
19789
|
case "italic":
|
|
19790
19790
|
case "bold":
|
|
@@ -20850,6 +20850,11 @@ const decode$q = (params2, decodedAttrs = {}) => {
|
|
|
20850
20850
|
runs.push(trackedClone);
|
|
20851
20851
|
return;
|
|
20852
20852
|
}
|
|
20853
|
+
if (child.name === "w:commentRangeStart" || child.name === "w:commentRangeEnd") {
|
|
20854
|
+
const commentRangeClone = cloneXmlNode(child);
|
|
20855
|
+
runs.push(commentRangeClone);
|
|
20856
|
+
return;
|
|
20857
|
+
}
|
|
20853
20858
|
const runWrapper = { name: XML_NODE_NAME$i, elements: [] };
|
|
20854
20859
|
applyBaseRunProps(runWrapper);
|
|
20855
20860
|
if (!Array.isArray(runWrapper.elements)) runWrapper.elements = [];
|
|
@@ -27975,9 +27980,11 @@ function updateNumberingProperties(newNumberingProperties, paragraphNode, pos, e
|
|
|
27975
27980
|
const newAttrs = {
|
|
27976
27981
|
...paragraphNode.attrs,
|
|
27977
27982
|
paragraphProperties: newProperties,
|
|
27978
|
-
numberingProperties: newProperties.numberingProperties
|
|
27979
|
-
listRendering: null
|
|
27983
|
+
numberingProperties: newProperties.numberingProperties
|
|
27980
27984
|
};
|
|
27985
|
+
if (!newNumberingProperties) {
|
|
27986
|
+
newAttrs.listRendering = null;
|
|
27987
|
+
}
|
|
27981
27988
|
tr.setNodeMarkup(pos, null, newAttrs);
|
|
27982
27989
|
}
|
|
27983
27990
|
const generateNewListDefinition = ({ numId, listType, level, start: start2, text, fmt, editor }) => {
|
|
@@ -28509,13 +28516,36 @@ const handleDocxPaste = (html, editor, view) => {
|
|
|
28509
28516
|
extractAndRemoveConditionalPrefix(item);
|
|
28510
28517
|
});
|
|
28511
28518
|
transformWordLists(tempDiv, editor);
|
|
28512
|
-
|
|
28519
|
+
let doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
28520
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
28513
28521
|
tempDiv.remove();
|
|
28514
28522
|
const { dispatch } = editor.view;
|
|
28515
28523
|
if (!dispatch) return false;
|
|
28516
28524
|
dispatch(view.state.tr.replaceSelectionWith(doc2, true));
|
|
28517
28525
|
return true;
|
|
28518
28526
|
};
|
|
28527
|
+
const wrapTextsInRuns = (doc2) => {
|
|
28528
|
+
const runType = doc2.type?.schema?.nodes?.run;
|
|
28529
|
+
if (!runType) return doc2;
|
|
28530
|
+
const wrapNode = (node, parent) => {
|
|
28531
|
+
if (node.isText) {
|
|
28532
|
+
if (parent?.type?.name === "run") return node;
|
|
28533
|
+
const runProperties = decodeRPrFromMarks(node.marks);
|
|
28534
|
+
return runType.create({ runProperties }, [node]);
|
|
28535
|
+
}
|
|
28536
|
+
if (!node.childCount) return node;
|
|
28537
|
+
let changed = false;
|
|
28538
|
+
const wrappedChildren = [];
|
|
28539
|
+
node.forEach((child) => {
|
|
28540
|
+
const wrappedChild = wrapNode(child, node);
|
|
28541
|
+
if (wrappedChild !== child) changed = true;
|
|
28542
|
+
wrappedChildren.push(wrappedChild);
|
|
28543
|
+
});
|
|
28544
|
+
if (!changed) return node;
|
|
28545
|
+
return node.copy(Fragment.fromArray(wrappedChildren));
|
|
28546
|
+
};
|
|
28547
|
+
return wrapNode(doc2, null);
|
|
28548
|
+
};
|
|
28519
28549
|
const transformWordLists = (container, editor) => {
|
|
28520
28550
|
const listItems = Array.from(container.querySelectorAll("[data-num-id]"));
|
|
28521
28551
|
const lists = {};
|
|
@@ -28945,7 +28975,8 @@ const handleGoogleDocsHtml = (html, editor, view) => {
|
|
|
28945
28975
|
tempDiv.innerHTML = cleanedHtml;
|
|
28946
28976
|
const htmlWithMergedLists = mergeSeparateLists(tempDiv);
|
|
28947
28977
|
const flattenHtml = flattenListsInHtml(htmlWithMergedLists, editor);
|
|
28948
|
-
|
|
28978
|
+
let doc2 = DOMParser$1.fromSchema(editor.schema).parse(flattenHtml);
|
|
28979
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
28949
28980
|
tempDiv.remove();
|
|
28950
28981
|
const { dispatch } = editor.view;
|
|
28951
28982
|
if (!dispatch) return false;
|
|
@@ -29278,7 +29309,8 @@ function isGoogleDocsHtml(html) {
|
|
|
29278
29309
|
function handleHtmlPaste(html, editor, source) {
|
|
29279
29310
|
let cleanedHtml;
|
|
29280
29311
|
cleanedHtml = htmlHandler(html, editor);
|
|
29281
|
-
|
|
29312
|
+
let doc2 = DOMParser$1.fromSchema(editor.schema).parse(cleanedHtml);
|
|
29313
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
29282
29314
|
const { dispatch, state: state2 } = editor.view;
|
|
29283
29315
|
if (!dispatch) return false;
|
|
29284
29316
|
const { $from } = state2.selection;
|
|
@@ -29383,7 +29415,9 @@ function createDocFromHTML(content, editor, options = {}) {
|
|
|
29383
29415
|
} else {
|
|
29384
29416
|
parsedContent = content;
|
|
29385
29417
|
}
|
|
29386
|
-
|
|
29418
|
+
let doc2 = DOMParser$1.fromSchema(editor.schema).parse(parsedContent);
|
|
29419
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
29420
|
+
return doc2;
|
|
29387
29421
|
}
|
|
29388
29422
|
function L() {
|
|
29389
29423
|
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
@@ -30507,9 +30541,11 @@ function processContent({ content, type: type2, editor }) {
|
|
|
30507
30541
|
para.textContent = content;
|
|
30508
30542
|
wrapper.appendChild(para);
|
|
30509
30543
|
doc2 = DOMParser$1.fromSchema(editor.schema).parse(wrapper);
|
|
30544
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
30510
30545
|
break;
|
|
30511
30546
|
case "schema":
|
|
30512
30547
|
doc2 = editor.schema.nodeFromJSON(content);
|
|
30548
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
30513
30549
|
break;
|
|
30514
30550
|
default:
|
|
30515
30551
|
throw new Error(`Unknown content type: ${type2}`);
|
|
@@ -36266,7 +36302,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
36266
36302
|
static getStoredSuperdocVersion(docx) {
|
|
36267
36303
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
36268
36304
|
}
|
|
36269
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.
|
|
36305
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.17") {
|
|
36270
36306
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
36271
36307
|
}
|
|
36272
36308
|
/**
|
|
@@ -47677,6 +47713,83 @@ const insertTabChar = () => ({ tr }) => {
|
|
|
47677
47713
|
tr.insertText(" ", tr.selection.from, tr.selection.to);
|
|
47678
47714
|
return true;
|
|
47679
47715
|
};
|
|
47716
|
+
const splitRunToParagraph = () => (props) => {
|
|
47717
|
+
const { state: state2, view, tr } = props;
|
|
47718
|
+
const { $from, empty: empty2 } = state2.selection;
|
|
47719
|
+
if (!empty2) return false;
|
|
47720
|
+
if ($from.parent.type.name !== "run") return false;
|
|
47721
|
+
const handled = splitBlockPatch(state2, (transaction) => {
|
|
47722
|
+
view.dispatch(transaction);
|
|
47723
|
+
});
|
|
47724
|
+
if (handled) {
|
|
47725
|
+
tr.setMeta("preventDispatch", true);
|
|
47726
|
+
}
|
|
47727
|
+
return handled;
|
|
47728
|
+
};
|
|
47729
|
+
function splitBlockPatch(state2, dispatch) {
|
|
47730
|
+
let { $from } = state2.selection;
|
|
47731
|
+
if (state2.selection instanceof NodeSelection && state2.selection.node.isBlock) {
|
|
47732
|
+
if (!$from.parentOffset || !canSplit(state2.doc, $from.pos)) return false;
|
|
47733
|
+
if (dispatch) dispatch(state2.tr.split($from.pos).scrollIntoView());
|
|
47734
|
+
return true;
|
|
47735
|
+
}
|
|
47736
|
+
if (!$from.depth) return false;
|
|
47737
|
+
let types2 = [];
|
|
47738
|
+
let splitDepth, deflt, atEnd = false, atStart = false;
|
|
47739
|
+
for (let d2 = $from.depth; ; d2--) {
|
|
47740
|
+
let node = $from.node(d2);
|
|
47741
|
+
if (node.isBlock) {
|
|
47742
|
+
atEnd = $from.end(d2) == $from.pos + ($from.depth - d2);
|
|
47743
|
+
atStart = $from.start(d2) == $from.pos - ($from.depth - d2);
|
|
47744
|
+
deflt = defaultBlockAt$1($from.node(d2 - 1).contentMatchAt($from.indexAfter(d2 - 1)));
|
|
47745
|
+
types2.unshift(null);
|
|
47746
|
+
splitDepth = d2;
|
|
47747
|
+
break;
|
|
47748
|
+
} else {
|
|
47749
|
+
if (d2 == 1) return false;
|
|
47750
|
+
types2.unshift(null);
|
|
47751
|
+
}
|
|
47752
|
+
}
|
|
47753
|
+
let tr = state2.tr;
|
|
47754
|
+
if (state2.selection instanceof TextSelection$1 || state2.selection instanceof AllSelection) tr.deleteSelection();
|
|
47755
|
+
let splitPos = tr.mapping.map($from.pos);
|
|
47756
|
+
let can = canSplit(tr.doc, splitPos, types2.length, types2);
|
|
47757
|
+
if (!can) {
|
|
47758
|
+
types2[0] = deflt ? { type: deflt } : null;
|
|
47759
|
+
can = canSplit(tr.doc, splitPos, types2.length, types2);
|
|
47760
|
+
}
|
|
47761
|
+
if (!can) return false;
|
|
47762
|
+
tr.split(splitPos, types2.length, types2);
|
|
47763
|
+
if (!atEnd && atStart && $from.node(splitDepth).type != deflt) {
|
|
47764
|
+
let first2 = tr.mapping.map($from.before(splitDepth)), $first = tr.doc.resolve(first2);
|
|
47765
|
+
if (deflt && $from.node(splitDepth - 1).canReplaceWith($first.index(), $first.index() + 1, deflt))
|
|
47766
|
+
tr.setNodeMarkup(tr.mapping.map($from.before(splitDepth)), deflt);
|
|
47767
|
+
}
|
|
47768
|
+
if (dispatch) dispatch(tr.scrollIntoView());
|
|
47769
|
+
return true;
|
|
47770
|
+
}
|
|
47771
|
+
const splitRunAtCursor = () => (props) => {
|
|
47772
|
+
let { state: state2, dispatch, tr } = props;
|
|
47773
|
+
const sel = state2.selection;
|
|
47774
|
+
if (!sel.empty) return false;
|
|
47775
|
+
const $pos = sel.$from;
|
|
47776
|
+
const runType = state2.schema.nodes.run;
|
|
47777
|
+
if ($pos.parent.type !== runType) return false;
|
|
47778
|
+
const run2 = $pos.parent;
|
|
47779
|
+
const offset2 = $pos.parentOffset;
|
|
47780
|
+
const runStart = $pos.before();
|
|
47781
|
+
const runEnd = runStart + run2.nodeSize;
|
|
47782
|
+
const leftFrag = run2.content.cut(0, offset2);
|
|
47783
|
+
const rightFrag = run2.content.cut(offset2);
|
|
47784
|
+
const leftRun = runType.create(run2.attrs, leftFrag, run2.marks);
|
|
47785
|
+
const rightRun = runType.create(run2.attrs, rightFrag, run2.marks);
|
|
47786
|
+
const gapPos = runStart + leftRun.nodeSize;
|
|
47787
|
+
tr.replaceWith(runStart, runEnd, [leftRun, rightRun]).setSelection(TextSelection$1.create(tr.doc, gapPos));
|
|
47788
|
+
if (dispatch) {
|
|
47789
|
+
dispatch(tr);
|
|
47790
|
+
}
|
|
47791
|
+
return true;
|
|
47792
|
+
};
|
|
47680
47793
|
const insertTabCharacter = ({ tr, state: state2, dispatch }) => {
|
|
47681
47794
|
const { from: from2 } = tr.selection;
|
|
47682
47795
|
const tabText = state2.schema.text(" ");
|
|
@@ -47686,10 +47799,23 @@ const insertTabCharacter = ({ tr, state: state2, dispatch }) => {
|
|
|
47686
47799
|
return true;
|
|
47687
47800
|
};
|
|
47688
47801
|
const insertTabNode = () => ({ tr, state: state2, dispatch }) => {
|
|
47689
|
-
|
|
47802
|
+
let newPos = tr.selection.from;
|
|
47690
47803
|
const tabNode = state2.schema?.nodes?.tab?.create();
|
|
47691
47804
|
if (!tabNode) return insertTabCharacter({ tr, state: state2, dispatch });
|
|
47805
|
+
const { from: from2 } = tr.selection;
|
|
47806
|
+
const $pos = tr.doc.resolve(from2);
|
|
47807
|
+
if ($pos.parent.type === state2.schema.nodes.run) {
|
|
47808
|
+
if (from2 === $pos.end()) {
|
|
47809
|
+
newPos = $pos.end() + 1;
|
|
47810
|
+
} else if (from2 === $pos.start()) {
|
|
47811
|
+
newPos = $pos.start() - 1;
|
|
47812
|
+
} else {
|
|
47813
|
+
splitRunAtCursor()({ tr, state: state2 });
|
|
47814
|
+
newPos = tr.selection.from;
|
|
47815
|
+
}
|
|
47816
|
+
}
|
|
47692
47817
|
tr.insert(newPos, tabNode);
|
|
47818
|
+
tr = tr.setSelection(TextSelection$1.create(tr.doc, newPos + tabNode.nodeSize));
|
|
47693
47819
|
if (dispatch) dispatch(tr);
|
|
47694
47820
|
return true;
|
|
47695
47821
|
};
|
|
@@ -49145,6 +49271,139 @@ const unsetLineHeight = () => ({ commands: commands2 }) => {
|
|
|
49145
49271
|
"paragraphProperties.spacing.lineRule"
|
|
49146
49272
|
);
|
|
49147
49273
|
};
|
|
49274
|
+
const backspaceEmptyRunParagraph = () => ({ state: state2, dispatch }) => {
|
|
49275
|
+
const { $from } = state2.selection;
|
|
49276
|
+
if (!state2.selection.empty) return false;
|
|
49277
|
+
const paraType = state2.schema.nodes.paragraph;
|
|
49278
|
+
const runType = state2.schema.nodes.run;
|
|
49279
|
+
const para = $from.parent;
|
|
49280
|
+
if (para.type !== paraType || para.childCount !== 1 || para.firstChild.type !== runType || para.firstChild.content.size)
|
|
49281
|
+
return false;
|
|
49282
|
+
if (state2.doc.childCount === 1 && $from.depth === 1) return false;
|
|
49283
|
+
if (dispatch) {
|
|
49284
|
+
const paraPos = $from.before();
|
|
49285
|
+
let tr = state2.tr.deleteRange(paraPos, paraPos + para.nodeSize).scrollIntoView();
|
|
49286
|
+
const targetPos = Math.max(1, Math.min(paraPos - 1, tr.doc.content.size));
|
|
49287
|
+
tr = tr.setSelection(TextSelection$1.create(tr.doc, targetPos));
|
|
49288
|
+
dispatch(tr);
|
|
49289
|
+
}
|
|
49290
|
+
return true;
|
|
49291
|
+
};
|
|
49292
|
+
const backspaceSkipEmptyRun = () => ({ state: state2, 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
|
+
const emptyRun = (n) => n && n.type === runType && n.content.size === 0;
|
|
49298
|
+
if ($pos.parent.type !== runType || $pos.pos !== $pos.end() || !emptyRun(state2.doc.nodeAt($pos.pos + 1))) {
|
|
49299
|
+
return false;
|
|
49300
|
+
}
|
|
49301
|
+
const leftTextSel = Selection.findFrom($pos, -1, true);
|
|
49302
|
+
if (!leftTextSel) return false;
|
|
49303
|
+
const pos = leftTextSel.$from.pos;
|
|
49304
|
+
if (dispatch) {
|
|
49305
|
+
dispatch(state2.tr.delete(pos - 1, pos).scrollIntoView());
|
|
49306
|
+
}
|
|
49307
|
+
return true;
|
|
49308
|
+
};
|
|
49309
|
+
const backspaceNextToRun = () => ({ state: state2, tr, dispatch }) => {
|
|
49310
|
+
const sel = state2.selection;
|
|
49311
|
+
if (!sel.empty) return false;
|
|
49312
|
+
const runType = state2.schema.nodes.run;
|
|
49313
|
+
const $pos = sel.$from;
|
|
49314
|
+
if ($pos.nodeBefore?.type !== runType && $pos.pos !== $pos.start()) return false;
|
|
49315
|
+
if ($pos.nodeBefore) {
|
|
49316
|
+
if ($pos.nodeBefore.content.size === 0) return false;
|
|
49317
|
+
tr.delete($pos.pos - 2, $pos.pos - 1).setSelection(Selection.near(tr.doc.resolve($pos.pos - 2)));
|
|
49318
|
+
if (dispatch) {
|
|
49319
|
+
dispatch(tr.scrollIntoView());
|
|
49320
|
+
}
|
|
49321
|
+
} else {
|
|
49322
|
+
const prevNode = state2.doc.resolve($pos.start() - 1).nodeBefore;
|
|
49323
|
+
if (prevNode?.type !== runType || prevNode.content.size === 0) return false;
|
|
49324
|
+
tr.delete($pos.pos - 3, $pos.pos - 2).setSelection(Selection.near(tr.doc.resolve($pos.pos - 3)));
|
|
49325
|
+
if (dispatch) {
|
|
49326
|
+
dispatch(tr.scrollIntoView());
|
|
49327
|
+
}
|
|
49328
|
+
}
|
|
49329
|
+
return true;
|
|
49330
|
+
};
|
|
49331
|
+
const deleteSkipEmptyRun = () => ({ state: state2, dispatch }) => {
|
|
49332
|
+
const sel = state2.selection;
|
|
49333
|
+
if (!sel.empty) return false;
|
|
49334
|
+
const runType = state2.schema.nodes.run;
|
|
49335
|
+
const $pos = sel.$from;
|
|
49336
|
+
const emptyRun = (n) => n && n.type === runType && n.content.size === 0;
|
|
49337
|
+
if ($pos.parent.type === runType && emptyRun(state2.doc.nodeAt($pos.end() + 1))) {
|
|
49338
|
+
if ($pos.pos === $pos.end()) {
|
|
49339
|
+
return deleteFromEndOfRun(state2, dispatch, $pos);
|
|
49340
|
+
} else if ($pos.pos === $pos.end() - 1) {
|
|
49341
|
+
return deleteFromLastCharacter(state2, dispatch, $pos);
|
|
49342
|
+
}
|
|
49343
|
+
return false;
|
|
49344
|
+
}
|
|
49345
|
+
return false;
|
|
49346
|
+
};
|
|
49347
|
+
function deleteFromEndOfRun(state2, dispatch, $pos) {
|
|
49348
|
+
const rightRun = state2.doc.nodeAt($pos.pos + 1);
|
|
49349
|
+
const $afterRightRunPos = state2.doc.resolve($pos.pos + 2 + rightRun.nodeSize);
|
|
49350
|
+
const rightTextSel = Selection.findFrom($afterRightRunPos, 1, true);
|
|
49351
|
+
if (!rightTextSel) return false;
|
|
49352
|
+
const pos = rightTextSel.$from.pos;
|
|
49353
|
+
if (dispatch) {
|
|
49354
|
+
dispatch(state2.tr.delete(pos, pos + 1).scrollIntoView());
|
|
49355
|
+
}
|
|
49356
|
+
return true;
|
|
49357
|
+
}
|
|
49358
|
+
function deleteFromLastCharacter(state2, dispatch, $pos) {
|
|
49359
|
+
if (dispatch) {
|
|
49360
|
+
dispatch(state2.tr.delete($pos.pos, $pos.pos + 1).scrollIntoView());
|
|
49361
|
+
}
|
|
49362
|
+
return true;
|
|
49363
|
+
}
|
|
49364
|
+
const deleteNextToRun = () => ({ state: state2, tr, dispatch }) => {
|
|
49365
|
+
const sel = state2.selection;
|
|
49366
|
+
if (!sel.empty) return false;
|
|
49367
|
+
const runType = state2.schema.nodes.run;
|
|
49368
|
+
const $pos = sel.$from;
|
|
49369
|
+
if ($pos.nodeAfter?.type !== runType && $pos.pos !== $pos.end()) return false;
|
|
49370
|
+
if ($pos.nodeAfter) {
|
|
49371
|
+
if ($pos.nodeAfter.content.size === 0) return false;
|
|
49372
|
+
tr.delete($pos.pos + 1, $pos.pos + 2).setSelection(Selection.near(tr.doc.resolve($pos.pos + 1)));
|
|
49373
|
+
if (dispatch) {
|
|
49374
|
+
dispatch(tr.scrollIntoView());
|
|
49375
|
+
}
|
|
49376
|
+
} else {
|
|
49377
|
+
const nextNode = state2.doc.resolve($pos.end() + 1).nodeAfter;
|
|
49378
|
+
if (nextNode?.type !== runType || nextNode.content.size === 0) return false;
|
|
49379
|
+
tr.delete($pos.pos + 2, $pos.pos + 3).setSelection(Selection.near(tr.doc.resolve($pos.pos + 2)));
|
|
49380
|
+
if (dispatch) {
|
|
49381
|
+
dispatch(tr.scrollIntoView());
|
|
49382
|
+
}
|
|
49383
|
+
}
|
|
49384
|
+
return true;
|
|
49385
|
+
};
|
|
49386
|
+
function skipTab(dir) {
|
|
49387
|
+
return ({ state: state2, dispatch }) => {
|
|
49388
|
+
const tab = state2.schema.nodes.tab;
|
|
49389
|
+
const run2 = state2.schema.nodes.run;
|
|
49390
|
+
const sel = state2.selection;
|
|
49391
|
+
if (!tab || !sel.empty) return false;
|
|
49392
|
+
const $pos = sel.$from;
|
|
49393
|
+
if ($pos.parent.type !== run2) return false;
|
|
49394
|
+
if (dir > 0 && $pos.pos < $pos.end()) return false;
|
|
49395
|
+
if (dir < 0 && $pos.pos > $pos.start()) return false;
|
|
49396
|
+
const step = dir > 0 ? 1 : -1;
|
|
49397
|
+
let $nextPos = state2.doc.resolve($pos.pos + step);
|
|
49398
|
+
const nextNode = dir > 0 ? $nextPos.nodeAfter : $nextPos.nodeBefore;
|
|
49399
|
+
if (!nextNode || nextNode.type !== tab) return false;
|
|
49400
|
+
const nextPos = dir > 0 ? Math.min($nextPos.pos + nextNode.nodeSize + 1, state2.doc.nodeSize) : Math.max(0, $nextPos.pos - nextNode.nodeSize - 1);
|
|
49401
|
+
if (dispatch) {
|
|
49402
|
+
dispatch(state2.tr.setSelection(TextSelection$1.create(state2.doc, nextPos)));
|
|
49403
|
+
}
|
|
49404
|
+
return true;
|
|
49405
|
+
};
|
|
49406
|
+
}
|
|
49148
49407
|
const toggleList = (listType) => ({ editor, state: state2, tr, dispatch }) => {
|
|
49149
49408
|
let predicate;
|
|
49150
49409
|
if (listType === "orderedList") {
|
|
@@ -49220,6 +49479,13 @@ const toggleList = (listType) => ({ editor, state: state2, tr, dispatch }) => {
|
|
|
49220
49479
|
}
|
|
49221
49480
|
updateNumberingProperties(sharedNumberingProperties, node, pos, editor, tr);
|
|
49222
49481
|
}
|
|
49482
|
+
const newTo = tr.mapping.map(to);
|
|
49483
|
+
if (newTo >= 0 && newTo <= tr.doc.content.size) {
|
|
49484
|
+
try {
|
|
49485
|
+
tr.setSelection(state2.selection.constructor.near(tr.doc.resolve(newTo)));
|
|
49486
|
+
} catch {
|
|
49487
|
+
}
|
|
49488
|
+
}
|
|
49223
49489
|
if (dispatch) dispatch(tr);
|
|
49224
49490
|
return true;
|
|
49225
49491
|
};
|
|
@@ -49338,6 +49604,9 @@ const getSelectionMarks = () => ({ state: state2, tr }) => {
|
|
|
49338
49604
|
};
|
|
49339
49605
|
const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
49340
49606
|
__proto__: null,
|
|
49607
|
+
backspaceEmptyRunParagraph,
|
|
49608
|
+
backspaceNextToRun,
|
|
49609
|
+
backspaceSkipEmptyRun,
|
|
49341
49610
|
changeListLevel,
|
|
49342
49611
|
clearNodes,
|
|
49343
49612
|
command,
|
|
@@ -49345,7 +49614,9 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
49345
49614
|
decreaseListIndent,
|
|
49346
49615
|
decreaseTextIndent,
|
|
49347
49616
|
defaultStyleDetector,
|
|
49617
|
+
deleteNextToRun,
|
|
49348
49618
|
deleteSelection,
|
|
49619
|
+
deleteSkipEmptyRun,
|
|
49349
49620
|
exitCode,
|
|
49350
49621
|
first,
|
|
49351
49622
|
getEffectiveStyleId,
|
|
@@ -49383,6 +49654,7 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
49383
49654
|
setSectionHeaderFooterAtSelection,
|
|
49384
49655
|
setTextIndentation,
|
|
49385
49656
|
setTextSelection,
|
|
49657
|
+
skipTab,
|
|
49386
49658
|
splitBlock: splitBlock$1,
|
|
49387
49659
|
toggleList,
|
|
49388
49660
|
toggleMark,
|
|
@@ -49404,7 +49676,7 @@ const Commands = Extension.create({
|
|
|
49404
49676
|
});
|
|
49405
49677
|
const handleEnter = (editor) => {
|
|
49406
49678
|
return editor.commands.first(({ commands: commands2 }) => [
|
|
49407
|
-
() => commands2.
|
|
49679
|
+
() => commands2.splitRunToParagraph(),
|
|
49408
49680
|
() => commands2.newlineInCode(),
|
|
49409
49681
|
() => commands2.createParagraphNear(),
|
|
49410
49682
|
() => commands2.liftEmptyBlock(),
|
|
@@ -49418,6 +49690,9 @@ const handleBackspace = (editor) => {
|
|
|
49418
49690
|
tr.setMeta("inputType", "deleteContentBackward");
|
|
49419
49691
|
return false;
|
|
49420
49692
|
},
|
|
49693
|
+
() => commands2.backspaceEmptyRunParagraph(),
|
|
49694
|
+
() => commands2.backspaceSkipEmptyRun(),
|
|
49695
|
+
() => commands2.backspaceNextToRun(),
|
|
49421
49696
|
() => commands2.deleteSelection(),
|
|
49422
49697
|
() => commands2.removeNumberingProperties(),
|
|
49423
49698
|
() => commands2.joinBackward(),
|
|
@@ -49426,6 +49701,8 @@ const handleBackspace = (editor) => {
|
|
|
49426
49701
|
};
|
|
49427
49702
|
const handleDelete = (editor) => {
|
|
49428
49703
|
return editor.commands.first(({ commands: commands2 }) => [
|
|
49704
|
+
() => commands2.deleteSkipEmptyRun(),
|
|
49705
|
+
() => commands2.deleteNextToRun(),
|
|
49429
49706
|
() => commands2.deleteSelection(),
|
|
49430
49707
|
() => commands2.joinForward(),
|
|
49431
49708
|
() => commands2.selectNodeForward()
|
|
@@ -49444,7 +49721,9 @@ const Keymap = Extension.create({
|
|
|
49444
49721
|
Delete: () => handleDelete(this.editor),
|
|
49445
49722
|
"Mod-Delete": () => handleDelete(this.editor),
|
|
49446
49723
|
"Mod-a": () => this.editor.commands.selectAll(),
|
|
49447
|
-
Tab: () => this.editor.commands.insertTabNode()
|
|
49724
|
+
Tab: () => this.editor.commands.insertTabNode(),
|
|
49725
|
+
ArrowLeft: () => this.editor.commands.skipTab(-1),
|
|
49726
|
+
ArrowRight: () => this.editor.commands.skipTab(1)
|
|
49448
49727
|
};
|
|
49449
49728
|
const pcBaseKeymap = {
|
|
49450
49729
|
...baseKeymap
|
|
@@ -52994,7 +53273,7 @@ const isHeadless = (editor) => {
|
|
|
52994
53273
|
const shouldSkipNodeView = (editor) => {
|
|
52995
53274
|
return isHeadless(editor);
|
|
52996
53275
|
};
|
|
52997
|
-
const summaryVersion = "1.0.0-beta.
|
|
53276
|
+
const summaryVersion = "1.0.0-beta.17";
|
|
52998
53277
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
52999
53278
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
53000
53279
|
function mapAttributes(attrs) {
|
|
@@ -53504,12 +53783,9 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
53504
53783
|
if (!this.schema) {
|
|
53505
53784
|
throw new Error("Schema is not initialized.");
|
|
53506
53785
|
}
|
|
53507
|
-
const topNodeName = this.schema.topNodeType?.name || "doc";
|
|
53508
|
-
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] } : (() => {
|
|
53509
|
-
throw new Error("Invalid document shape: expected a node object or an array of node objects.");
|
|
53510
|
-
})();
|
|
53511
53786
|
try {
|
|
53512
|
-
return this.schema.nodeFromJSON(
|
|
53787
|
+
if (Array.isArray(doc2)) return doc2.map((d2) => this.schema.nodeFromJSON(d2));
|
|
53788
|
+
return this.schema.nodeFromJSON(doc2);
|
|
53513
53789
|
} catch (error) {
|
|
53514
53790
|
const detail = error instanceof Error ? error.message : String(error);
|
|
53515
53791
|
const validationError = new Error(`Invalid document for current schema: ${detail}`);
|
|
@@ -53773,7 +54049,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
53773
54049
|
{ default: remarkStringify },
|
|
53774
54050
|
{ default: remarkGfm }
|
|
53775
54051
|
] = await Promise.all([
|
|
53776
|
-
Promise.resolve().then(() => require("./index-
|
|
54052
|
+
Promise.resolve().then(() => require("./index-VCeRjVPO-DjkejB6t.cjs")),
|
|
53777
54053
|
Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
|
|
53778
54054
|
Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
|
|
53779
54055
|
Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
|
|
@@ -53978,7 +54254,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
53978
54254
|
* Process collaboration migrations
|
|
53979
54255
|
*/
|
|
53980
54256
|
processCollaborationMigrations() {
|
|
53981
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
54257
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.17");
|
|
53982
54258
|
if (!this.options.ydoc) return;
|
|
53983
54259
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
53984
54260
|
let docVersion = metaMap.get("version");
|
|
@@ -62469,6 +62745,9 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
62469
62745
|
};
|
|
62470
62746
|
if (measure.marker) {
|
|
62471
62747
|
fragment.markerWidth = measure.marker.markerWidth;
|
|
62748
|
+
if (measure.marker.markerTextWidth != null) {
|
|
62749
|
+
fragment.markerTextWidth = measure.marker.markerTextWidth;
|
|
62750
|
+
}
|
|
62472
62751
|
}
|
|
62473
62752
|
state2.page.fragments.push(fragment);
|
|
62474
62753
|
state2.trailingSpacing = 0;
|
|
@@ -62570,6 +62849,12 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
62570
62849
|
};
|
|
62571
62850
|
if (measure.marker && fromLine === 0) {
|
|
62572
62851
|
fragment.markerWidth = measure.marker.markerWidth;
|
|
62852
|
+
if (measure.marker.markerTextWidth != null) {
|
|
62853
|
+
fragment.markerTextWidth = measure.marker.markerTextWidth;
|
|
62854
|
+
}
|
|
62855
|
+
if (measure.kind === "paragraph" && measure.marker?.gutterWidth != null) {
|
|
62856
|
+
fragment.markerGutter = measure.marker.gutterWidth;
|
|
62857
|
+
}
|
|
62573
62858
|
}
|
|
62574
62859
|
if (fromLine > 0) fragment.continuesFromPrev = true;
|
|
62575
62860
|
if (slice2.toLine < lines.length) fragment.continuesOnNext = true;
|
|
@@ -64281,7 +64566,22 @@ const hashRuns = (block) => {
|
|
|
64281
64566
|
}
|
|
64282
64567
|
return `${text}:${marks}${trackedKey}`;
|
|
64283
64568
|
}).join("|");
|
|
64284
|
-
|
|
64569
|
+
let numberingKey = "";
|
|
64570
|
+
if (block.attrs) {
|
|
64571
|
+
const attrs = block.attrs;
|
|
64572
|
+
if (attrs.numberingProperties) {
|
|
64573
|
+
const np = attrs.numberingProperties;
|
|
64574
|
+
let markerTextKey;
|
|
64575
|
+
if (!attrs.wordLayout?.marker) {
|
|
64576
|
+
markerTextKey = "<NULL>";
|
|
64577
|
+
} else {
|
|
64578
|
+
const markerText = attrs.wordLayout.marker.markerText;
|
|
64579
|
+
markerTextKey = markerText === "" ? "<EMPTY>" : markerText ?? "<NULL>";
|
|
64580
|
+
}
|
|
64581
|
+
numberingKey = `|num:${np.numId ?? ""}:${np.ilvl ?? 0}:${markerTextKey}`;
|
|
64582
|
+
}
|
|
64583
|
+
}
|
|
64584
|
+
return `${trackedMode}:${trackedEnabled ? "on" : "off"}|${runsHash}${numberingKey}`;
|
|
64285
64585
|
};
|
|
64286
64586
|
const createStats = () => ({
|
|
64287
64587
|
hits: 0,
|
|
@@ -69293,6 +69593,7 @@ function assertFragmentPmPositions(fragment, context) {
|
|
|
69293
69593
|
}
|
|
69294
69594
|
}
|
|
69295
69595
|
const LIST_MARKER_GAP$1 = 8;
|
|
69596
|
+
const DEFAULT_TAB_INTERVAL_PX$1 = 48;
|
|
69296
69597
|
const COMMENT_EXTERNAL_COLOR = "#B1124B";
|
|
69297
69598
|
const COMMENT_INTERNAL_COLOR = "#078383";
|
|
69298
69599
|
const COMMENT_INACTIVE_ALPHA = "22";
|
|
@@ -70089,33 +70390,41 @@ const _DomPainter = class _DomPainter2 {
|
|
|
70089
70390
|
const firstLineOffset = (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
|
|
70090
70391
|
lines.forEach((line, index2) => {
|
|
70091
70392
|
const lineEl = this.renderLine(block, line, context);
|
|
70092
|
-
|
|
70393
|
+
const isListFirstLine = index2 === 0 && !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
|
|
70394
|
+
if (paraIndentLeft && !isListFirstLine) {
|
|
70093
70395
|
lineEl.style.paddingLeft = `${paraIndentLeft}px`;
|
|
70094
70396
|
}
|
|
70095
70397
|
if (paraIndentRight) {
|
|
70096
70398
|
lineEl.style.paddingRight = `${paraIndentRight}px`;
|
|
70097
70399
|
}
|
|
70098
|
-
if (!fragment.continuesFromPrev && index2 === 0 && firstLineOffset) {
|
|
70400
|
+
if (!fragment.continuesFromPrev && index2 === 0 && firstLineOffset && !isListFirstLine) {
|
|
70099
70401
|
lineEl.style.textIndent = `${firstLineOffset}px`;
|
|
70100
|
-
} else if (firstLineOffset) {
|
|
70402
|
+
} else if (firstLineOffset && !isListFirstLine) {
|
|
70101
70403
|
lineEl.style.textIndent = "0px";
|
|
70102
70404
|
}
|
|
70103
|
-
if (
|
|
70405
|
+
if (isListFirstLine && wordLayout?.marker && fragment.markerWidth) {
|
|
70406
|
+
const markerStartPos = paraIndentLeft - (paraIndent?.hanging ?? 0);
|
|
70407
|
+
lineEl.style.paddingLeft = `${markerStartPos}px`;
|
|
70104
70408
|
const markerContainer = this.doc.createElement("span");
|
|
70105
70409
|
markerContainer.style.display = "inline-block";
|
|
70106
70410
|
const markerEl = this.doc.createElement("span");
|
|
70107
70411
|
markerEl.classList.add("superdoc-paragraph-marker");
|
|
70108
70412
|
markerEl.textContent = wordLayout.marker.markerText ?? "";
|
|
70109
|
-
markerEl.style.width = `${fragment.markerWidth}px`;
|
|
70110
|
-
markerEl.style.textAlign = wordLayout.marker.justification ?? "right";
|
|
70111
|
-
markerEl.style.paddingRight = `${LIST_MARKER_GAP$1}px`;
|
|
70112
70413
|
markerEl.style.pointerEvents = "none";
|
|
70113
|
-
const
|
|
70114
|
-
|
|
70115
|
-
|
|
70116
|
-
|
|
70117
|
-
|
|
70118
|
-
|
|
70414
|
+
const markerJustification = wordLayout.marker.justification ?? "left";
|
|
70415
|
+
if (markerJustification !== "left") {
|
|
70416
|
+
markerEl.style.width = `${fragment.markerWidth}px`;
|
|
70417
|
+
markerEl.style.textAlign = wordLayout.marker.justification ?? "right";
|
|
70418
|
+
markerEl.style.paddingRight = `${LIST_MARKER_GAP$1}px`;
|
|
70419
|
+
}
|
|
70420
|
+
if (markerJustification === "left") {
|
|
70421
|
+
markerContainer.style.position = "relative";
|
|
70422
|
+
} else {
|
|
70423
|
+
const markerLeftX = markerStartPos - fragment.markerWidth;
|
|
70424
|
+
markerContainer.style.position = "absolute";
|
|
70425
|
+
markerContainer.style.left = `${markerLeftX}px`;
|
|
70426
|
+
markerContainer.style.top = "0";
|
|
70427
|
+
}
|
|
70119
70428
|
markerEl.style.fontFamily = wordLayout.marker.run.fontFamily;
|
|
70120
70429
|
markerEl.style.fontSize = `${wordLayout.marker.run.fontSize}px`;
|
|
70121
70430
|
markerEl.style.fontWeight = wordLayout.marker.run.bold ? "bold" : "";
|
|
@@ -70132,12 +70441,25 @@ const _DomPainter = class _DomPainter2 {
|
|
|
70132
70441
|
const tabEl = this.doc.createElement("span");
|
|
70133
70442
|
tabEl.className = "superdoc-tab";
|
|
70134
70443
|
tabEl.innerHTML = " ";
|
|
70135
|
-
|
|
70444
|
+
let tabWidth;
|
|
70445
|
+
const markerBoxWidth = fragment.markerWidth;
|
|
70446
|
+
const markerTextWidth = fragment.markerTextWidth != null && isFinite(fragment.markerTextWidth) && fragment.markerTextWidth >= 0 ? fragment.markerTextWidth : markerBoxWidth;
|
|
70447
|
+
if ((wordLayout.marker.justification ?? "left") === "left") {
|
|
70448
|
+
const currentPos = markerStartPos + markerTextWidth;
|
|
70449
|
+
const implicitTabStop = paraIndentLeft;
|
|
70450
|
+
tabWidth = implicitTabStop - currentPos;
|
|
70451
|
+
if (tabWidth < 1) {
|
|
70452
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$1 - currentPos % DEFAULT_TAB_INTERVAL_PX$1;
|
|
70453
|
+
if (tabWidth === 0) tabWidth = DEFAULT_TAB_INTERVAL_PX$1;
|
|
70454
|
+
}
|
|
70455
|
+
} else {
|
|
70456
|
+
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;
|
|
70457
|
+
}
|
|
70136
70458
|
tabEl.style.display = "inline-block";
|
|
70137
|
-
tabEl.style.width = `${
|
|
70138
|
-
|
|
70459
|
+
tabEl.style.width = `${tabWidth}px`;
|
|
70460
|
+
lineEl.prepend(tabEl);
|
|
70139
70461
|
} else if (suffix2 === "space") {
|
|
70140
|
-
|
|
70462
|
+
lineEl.prepend(this.doc.createTextNode(" "));
|
|
70141
70463
|
}
|
|
70142
70464
|
lineEl.prepend(markerContainer);
|
|
70143
70465
|
}
|
|
@@ -71611,7 +71933,9 @@ const fragmentSignature = (fragment, lookup2) => {
|
|
|
71611
71933
|
fragment.pmStart ?? "",
|
|
71612
71934
|
fragment.pmEnd ?? "",
|
|
71613
71935
|
fragment.continuesFromPrev ? 1 : 0,
|
|
71614
|
-
fragment.continuesOnNext ? 1 : 0
|
|
71936
|
+
fragment.continuesOnNext ? 1 : 0,
|
|
71937
|
+
fragment.markerWidth ?? ""
|
|
71938
|
+
// Include markerWidth to trigger re-render when list status changes
|
|
71615
71939
|
].join("|");
|
|
71616
71940
|
}
|
|
71617
71941
|
if (fragment.kind === "list-item") {
|
|
@@ -72782,10 +73106,14 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
72782
73106
|
const { font: markerFont } = buildFontString(markerRun);
|
|
72783
73107
|
const markerText = wordLayout.marker.markerText ?? "";
|
|
72784
73108
|
const glyphWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
|
|
73109
|
+
const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP;
|
|
73110
|
+
const markerBoxWidth = Math.max(wordLayout.marker.markerBoxWidthPx ?? 0, glyphWidth + LIST_MARKER_GAP);
|
|
72785
73111
|
markerInfo = {
|
|
72786
|
-
markerWidth:
|
|
73112
|
+
markerWidth: markerBoxWidth,
|
|
72787
73113
|
markerTextWidth: glyphWidth,
|
|
72788
|
-
indentLeft: wordLayout.indentLeftPx ?? 0
|
|
73114
|
+
indentLeft: wordLayout.indentLeftPx ?? 0,
|
|
73115
|
+
// For tab sizing in the renderer: expose gutter for word-layout lists
|
|
73116
|
+
gutterWidth: gutter
|
|
72789
73117
|
};
|
|
72790
73118
|
}
|
|
72791
73119
|
return {
|
|
@@ -79054,6 +79382,17 @@ const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ O
|
|
|
79054
79382
|
parseTagObject
|
|
79055
79383
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
79056
79384
|
const STRUCTURED_CONTENT_NAMES = ["structuredContent", "structuredContentBlock"];
|
|
79385
|
+
const findFirstTextNode = (node) => {
|
|
79386
|
+
let firstTextNode = null;
|
|
79387
|
+
node.descendants((child) => {
|
|
79388
|
+
if (child.isText) {
|
|
79389
|
+
firstTextNode = child;
|
|
79390
|
+
return false;
|
|
79391
|
+
}
|
|
79392
|
+
return true;
|
|
79393
|
+
});
|
|
79394
|
+
return firstTextNode;
|
|
79395
|
+
};
|
|
79057
79396
|
const StructuredContentCommands = Extension.create({
|
|
79058
79397
|
name: "structuredContentCommands",
|
|
79059
79398
|
addCommands() {
|
|
@@ -79194,7 +79533,7 @@ const StructuredContentCommands = Extension.create({
|
|
|
79194
79533
|
* @param {string} id - Unique identifier of the field
|
|
79195
79534
|
* @param {StructuredContentUpdate} options
|
|
79196
79535
|
* @example
|
|
79197
|
-
* editor.commands.updateStructuredContentById('123', { text: 'Jane Doe' });
|
|
79536
|
+
* editor.commands.updateStructuredContentById('123', { text: 'Jane Doe', keepTextNodeStyles: true });
|
|
79198
79537
|
* editor.commands.updateStructuredContentById('123', {
|
|
79199
79538
|
* json: { type: 'text', text: 'Jane Doe' },
|
|
79200
79539
|
* });
|
|
@@ -79215,7 +79554,9 @@ const StructuredContentCommands = Extension.create({
|
|
|
79215
79554
|
const posTo = pos + node.nodeSize;
|
|
79216
79555
|
let content = null;
|
|
79217
79556
|
if (options.text) {
|
|
79218
|
-
|
|
79557
|
+
const firstTextNode = options.keepTextNodeStyles === true ? findFirstTextNode(node) : null;
|
|
79558
|
+
const textMarks = firstTextNode ? firstTextNode.marks : [];
|
|
79559
|
+
content = schema.text(options.text, textMarks);
|
|
79219
79560
|
}
|
|
79220
79561
|
if (options.html) {
|
|
79221
79562
|
const html = htmlHandler(options.html, editor);
|
|
@@ -79229,6 +79570,13 @@ const StructuredContentCommands = Extension.create({
|
|
|
79229
79570
|
content = node.content;
|
|
79230
79571
|
}
|
|
79231
79572
|
const updatedNode = node.type.create({ ...node.attrs, ...options.attrs }, content, node.marks);
|
|
79573
|
+
try {
|
|
79574
|
+
const nodeForValidation = editor.validateJSON(updatedNode.toJSON());
|
|
79575
|
+
nodeForValidation.check();
|
|
79576
|
+
} catch (error) {
|
|
79577
|
+
console.error("Invalid content.", "Passed value:", content, "Error:", error);
|
|
79578
|
+
return false;
|
|
79579
|
+
}
|
|
79232
79580
|
tr.replaceWith(posFrom, posTo, updatedNode);
|
|
79233
79581
|
}
|
|
79234
79582
|
return true;
|
|
@@ -79313,7 +79661,7 @@ const StructuredContentCommands = Extension.create({
|
|
|
79313
79661
|
* @param {StructuredContentUpdate} options
|
|
79314
79662
|
* @example
|
|
79315
79663
|
* // Update all fields in the customer-info group
|
|
79316
|
-
* editor.commands.updateStructuredContentByGroup('customer-info', { text: 'Jane Doe' });
|
|
79664
|
+
* editor.commands.updateStructuredContentByGroup('customer-info', { text: 'Jane Doe', keepTextNodeStyles: true });
|
|
79317
79665
|
*
|
|
79318
79666
|
* // Update block content in a group
|
|
79319
79667
|
* editor.commands.updateStructuredContentByGroup('terms-section', {
|
|
@@ -79327,13 +79675,14 @@ const StructuredContentCommands = Extension.create({
|
|
|
79327
79675
|
}
|
|
79328
79676
|
const { schema } = editor;
|
|
79329
79677
|
if (dispatch) {
|
|
79330
|
-
|
|
79678
|
+
const updates = [];
|
|
79679
|
+
for (const structuredContent of structuredContentTags) {
|
|
79331
79680
|
const { pos, node } = structuredContent;
|
|
79332
|
-
const posFrom = tr.mapping.map(pos);
|
|
79333
|
-
const posTo = tr.mapping.map(pos + node.nodeSize);
|
|
79334
79681
|
let content = null;
|
|
79335
79682
|
if (options.text) {
|
|
79336
|
-
|
|
79683
|
+
const firstTextNode = options.keepTextNodeStyles === true ? findFirstTextNode(node) : null;
|
|
79684
|
+
const textMarks = firstTextNode ? firstTextNode.marks : [];
|
|
79685
|
+
content = schema.text(options.text, textMarks);
|
|
79337
79686
|
}
|
|
79338
79687
|
if (options.html) {
|
|
79339
79688
|
const html = htmlHandler(options.html, editor);
|
|
@@ -79347,11 +79696,23 @@ const StructuredContentCommands = Extension.create({
|
|
|
79347
79696
|
content = node.content;
|
|
79348
79697
|
}
|
|
79349
79698
|
const updatedNode = node.type.create({ ...node.attrs, ...options.attrs }, content, node.marks);
|
|
79699
|
+
try {
|
|
79700
|
+
const nodeForValidation = editor.validateJSON(updatedNode.toJSON());
|
|
79701
|
+
nodeForValidation.check();
|
|
79702
|
+
} catch (error) {
|
|
79703
|
+
console.error("Invalid content.", "Passed value:", content, "Error:", error);
|
|
79704
|
+
return false;
|
|
79705
|
+
}
|
|
79706
|
+
updates.push({ pos, node, updatedNode });
|
|
79707
|
+
}
|
|
79708
|
+
for (const { pos, node, updatedNode } of updates) {
|
|
79709
|
+
const posFrom = tr.mapping.map(pos);
|
|
79710
|
+
const posTo = tr.mapping.map(pos + node.nodeSize);
|
|
79350
79711
|
const currentNode = tr.doc.nodeAt(posFrom);
|
|
79351
79712
|
if (currentNode && node.eq(currentNode)) {
|
|
79352
79713
|
tr.replaceWith(posFrom, posTo, updatedNode);
|
|
79353
79714
|
}
|
|
79354
|
-
}
|
|
79715
|
+
}
|
|
79355
79716
|
}
|
|
79356
79717
|
return true;
|
|
79357
79718
|
},
|
|
@@ -79927,61 +80288,153 @@ const Text = Node$1.create({
|
|
|
79927
80288
|
return {};
|
|
79928
80289
|
}
|
|
79929
80290
|
});
|
|
79930
|
-
const
|
|
79931
|
-
|
|
79932
|
-
|
|
79933
|
-
|
|
79934
|
-
|
|
79935
|
-
|
|
79936
|
-
|
|
79937
|
-
|
|
79938
|
-
|
|
79939
|
-
|
|
79940
|
-
|
|
79941
|
-
|
|
79942
|
-
};
|
|
79943
|
-
|
|
79944
|
-
|
|
79945
|
-
|
|
79946
|
-
|
|
79947
|
-
|
|
79948
|
-
|
|
80291
|
+
const cleanupEmptyRunsPlugin = new Plugin({
|
|
80292
|
+
appendTransaction(trs, oldState, newState) {
|
|
80293
|
+
if (!trs.some((tr2) => tr2.docChanged)) return null;
|
|
80294
|
+
const { run: run2, paragraph } = newState.schema.nodes;
|
|
80295
|
+
if (!run2) return null;
|
|
80296
|
+
const ranges = [];
|
|
80297
|
+
trs.forEach((tr2) => {
|
|
80298
|
+
tr2.mapping.maps.forEach((map22) => {
|
|
80299
|
+
map22.forEach((oldStart, oldEnd, newStart, newEnd) => {
|
|
80300
|
+
if (newStart !== oldStart || oldEnd !== newEnd) ranges.push({ from: newStart, to: newEnd });
|
|
80301
|
+
});
|
|
80302
|
+
});
|
|
80303
|
+
});
|
|
80304
|
+
if (!ranges.length) return null;
|
|
80305
|
+
ranges.sort((a, b2) => a.from - b2.from);
|
|
80306
|
+
const merged = [];
|
|
80307
|
+
for (const r2 of ranges) {
|
|
80308
|
+
const from2 = Math.max(0, r2.from - 1);
|
|
80309
|
+
const to = Math.min(newState.doc.content.size, r2.to + 1);
|
|
80310
|
+
const last = merged[merged.length - 1];
|
|
80311
|
+
if (last && from2 <= last.to) last.to = Math.max(last.to, to);
|
|
80312
|
+
else merged.push({ from: from2, to });
|
|
80313
|
+
}
|
|
80314
|
+
const toDelete = [];
|
|
80315
|
+
merged.forEach(({ from: from2, to }) => {
|
|
80316
|
+
newState.doc.nodesBetween(from2, to, (node, pos, parent) => {
|
|
80317
|
+
if (node.type === run2 && node.content.size === 0 && parent?.type === paragraph) {
|
|
80318
|
+
toDelete.push({ from: pos, to: pos + node.nodeSize });
|
|
80319
|
+
}
|
|
80320
|
+
});
|
|
80321
|
+
});
|
|
80322
|
+
if (!toDelete.length) return null;
|
|
80323
|
+
const tr = newState.tr;
|
|
80324
|
+
toDelete.sort((a, b2) => b2.from - a.from).forEach(({ from: from2, to }) => tr.deleteRange(from2, to));
|
|
80325
|
+
return tr.docChanged ? tr : null;
|
|
79949
80326
|
}
|
|
79950
|
-
|
|
79951
|
-
|
|
79952
|
-
|
|
79953
|
-
|
|
79954
|
-
|
|
79955
|
-
|
|
79956
|
-
|
|
79957
|
-
|
|
79958
|
-
|
|
79959
|
-
|
|
79960
|
-
|
|
79961
|
-
|
|
80327
|
+
});
|
|
80328
|
+
const mergeRanges$1 = (ranges, docSize) => {
|
|
80329
|
+
if (!ranges.length) return [];
|
|
80330
|
+
const sorted = ranges.map(({ from: from2, to }) => ({
|
|
80331
|
+
from: Math.max(0, from2),
|
|
80332
|
+
to: Math.min(docSize, to)
|
|
80333
|
+
})).filter(({ from: from2, to }) => from2 < to).sort((a, b2) => a.from - b2.from);
|
|
80334
|
+
const merged = [];
|
|
80335
|
+
for (const range2 of sorted) {
|
|
80336
|
+
const last = merged[merged.length - 1];
|
|
80337
|
+
if (last && range2.from <= last.to) {
|
|
80338
|
+
last.to = Math.max(last.to, range2.to);
|
|
79962
80339
|
} else {
|
|
79963
|
-
|
|
79964
|
-
types2.unshift(null);
|
|
80340
|
+
merged.push({ ...range2 });
|
|
79965
80341
|
}
|
|
79966
80342
|
}
|
|
79967
|
-
|
|
79968
|
-
|
|
79969
|
-
|
|
79970
|
-
|
|
79971
|
-
|
|
79972
|
-
|
|
79973
|
-
|
|
79974
|
-
|
|
79975
|
-
|
|
79976
|
-
|
|
79977
|
-
|
|
79978
|
-
|
|
79979
|
-
|
|
79980
|
-
|
|
79981
|
-
|
|
79982
|
-
|
|
79983
|
-
|
|
79984
|
-
|
|
80343
|
+
return merged;
|
|
80344
|
+
};
|
|
80345
|
+
const collectChangedRanges = (trs, docSize) => {
|
|
80346
|
+
const ranges = [];
|
|
80347
|
+
trs.forEach((tr) => {
|
|
80348
|
+
if (!tr.docChanged) return;
|
|
80349
|
+
tr.mapping.maps.forEach((map22) => {
|
|
80350
|
+
map22.forEach((oldStart, oldEnd, newStart, newEnd) => {
|
|
80351
|
+
if (newStart !== oldStart || oldEnd !== newEnd) {
|
|
80352
|
+
ranges.push({ from: newStart, to: newEnd });
|
|
80353
|
+
}
|
|
80354
|
+
});
|
|
80355
|
+
});
|
|
80356
|
+
});
|
|
80357
|
+
return mergeRanges$1(ranges, docSize);
|
|
80358
|
+
};
|
|
80359
|
+
const mapRangesThroughTransactions = (ranges, transactions, docSize) => {
|
|
80360
|
+
let mapped = ranges;
|
|
80361
|
+
transactions.forEach((tr) => {
|
|
80362
|
+
mapped = mapped.map(({ from: from2, to }) => {
|
|
80363
|
+
const mappedFrom = tr.mapping.map(from2, -1);
|
|
80364
|
+
const mappedTo = tr.mapping.map(to, 1);
|
|
80365
|
+
if (mappedFrom >= mappedTo) return null;
|
|
80366
|
+
return { from: mappedFrom, to: mappedTo };
|
|
80367
|
+
}).filter(Boolean);
|
|
80368
|
+
});
|
|
80369
|
+
return mergeRanges$1(mapped, docSize);
|
|
80370
|
+
};
|
|
80371
|
+
const buildWrapTransaction = (state2, ranges, runType) => {
|
|
80372
|
+
if (!ranges.length) return null;
|
|
80373
|
+
const replacements = [];
|
|
80374
|
+
ranges.forEach(({ from: from2, to }) => {
|
|
80375
|
+
state2.doc.nodesBetween(from2, to, (node, pos, parent, index2) => {
|
|
80376
|
+
if (!node.isText || !parent || parent.type === runType) return;
|
|
80377
|
+
const match = parent.contentMatchAt ? parent.contentMatchAt(index2) : null;
|
|
80378
|
+
if (match && !match.matchType(runType)) return;
|
|
80379
|
+
if (!match && !parent.type.contentMatch.matchType(runType)) return;
|
|
80380
|
+
const runProperties = decodeRPrFromMarks(node.marks);
|
|
80381
|
+
const runNode = runType.create({ runProperties }, node);
|
|
80382
|
+
replacements.push({ from: pos, to: pos + node.nodeSize, runNode });
|
|
80383
|
+
});
|
|
80384
|
+
});
|
|
80385
|
+
if (!replacements.length) return null;
|
|
80386
|
+
const tr = state2.tr;
|
|
80387
|
+
replacements.sort((a, b2) => b2.from - a.from).forEach(({ from: from2, to, runNode }) => tr.replaceWith(from2, to, runNode));
|
|
80388
|
+
return tr.docChanged ? tr : null;
|
|
80389
|
+
};
|
|
80390
|
+
const wrapTextInRunsPlugin = () => {
|
|
80391
|
+
let view = null;
|
|
80392
|
+
let pendingRanges = [];
|
|
80393
|
+
const flush = () => {
|
|
80394
|
+
if (!view) return;
|
|
80395
|
+
const runType = view.state.schema.nodes.run;
|
|
80396
|
+
if (!runType) {
|
|
80397
|
+
pendingRanges = [];
|
|
80398
|
+
return;
|
|
80399
|
+
}
|
|
80400
|
+
const tr = buildWrapTransaction(view.state, pendingRanges, runType);
|
|
80401
|
+
pendingRanges = [];
|
|
80402
|
+
if (tr) {
|
|
80403
|
+
view.dispatch(tr);
|
|
80404
|
+
}
|
|
80405
|
+
};
|
|
80406
|
+
const onCompositionEnd = () => {
|
|
80407
|
+
if (typeof globalThis === "undefined") return;
|
|
80408
|
+
globalThis.queueMicrotask(flush);
|
|
80409
|
+
};
|
|
80410
|
+
return new Plugin({
|
|
80411
|
+
view(editorView) {
|
|
80412
|
+
view = editorView;
|
|
80413
|
+
editorView.dom.addEventListener("compositionend", onCompositionEnd);
|
|
80414
|
+
return {
|
|
80415
|
+
destroy() {
|
|
80416
|
+
editorView.dom.removeEventListener("compositionend", onCompositionEnd);
|
|
80417
|
+
view = null;
|
|
80418
|
+
pendingRanges = [];
|
|
80419
|
+
}
|
|
80420
|
+
};
|
|
80421
|
+
},
|
|
80422
|
+
appendTransaction(transactions, _oldState, newState) {
|
|
80423
|
+
const docSize = newState.doc.content.size;
|
|
80424
|
+
const runType = newState.schema.nodes.run;
|
|
80425
|
+
if (!runType) return null;
|
|
80426
|
+
pendingRanges = mapRangesThroughTransactions(pendingRanges, transactions, docSize);
|
|
80427
|
+
const changedRanges = collectChangedRanges(transactions, docSize);
|
|
80428
|
+
pendingRanges = mergeRanges$1([...pendingRanges, ...changedRanges], docSize);
|
|
80429
|
+
if (view?.composing) {
|
|
80430
|
+
return null;
|
|
80431
|
+
}
|
|
80432
|
+
const tr = buildWrapTransaction(newState, pendingRanges, runType);
|
|
80433
|
+
pendingRanges = [];
|
|
80434
|
+
return tr;
|
|
80435
|
+
}
|
|
80436
|
+
});
|
|
80437
|
+
};
|
|
79985
80438
|
const Run = OxmlNode.create({
|
|
79986
80439
|
name: "run",
|
|
79987
80440
|
oXmlName: "w:r",
|
|
@@ -80024,7 +80477,8 @@ const Run = OxmlNode.create({
|
|
|
80024
80477
|
// @ts-expect-error - Command signatures will be fixed in TS migration
|
|
80025
80478
|
addCommands() {
|
|
80026
80479
|
return {
|
|
80027
|
-
|
|
80480
|
+
splitRunToParagraph,
|
|
80481
|
+
splitRunAtCursor
|
|
80028
80482
|
};
|
|
80029
80483
|
},
|
|
80030
80484
|
parseDOM() {
|
|
@@ -80033,6 +80487,9 @@ const Run = OxmlNode.create({
|
|
|
80033
80487
|
renderDOM({ htmlAttributes }) {
|
|
80034
80488
|
const base2 = Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
|
|
80035
80489
|
return ["span", base2, 0];
|
|
80490
|
+
},
|
|
80491
|
+
addPmPlugins() {
|
|
80492
|
+
return [wrapTextInRunsPlugin(), cleanupEmptyRunsPlugin];
|
|
80036
80493
|
}
|
|
80037
80494
|
});
|
|
80038
80495
|
const restartNumbering = ({ editor, tr, state: state2, dispatch }) => {
|
|
@@ -80775,20 +81232,15 @@ function createNumberingPlugin(editor) {
|
|
|
80775
81232
|
} else {
|
|
80776
81233
|
markerText = docxNumberingHelpers.normalizeLvlTextChar(lvlText);
|
|
80777
81234
|
}
|
|
80778
|
-
|
|
81235
|
+
const newListRendering = {
|
|
80779
81236
|
markerText,
|
|
80780
81237
|
suffix: suffix2,
|
|
80781
81238
|
justification,
|
|
80782
81239
|
path,
|
|
80783
81240
|
numberingType: listNumberingType
|
|
80784
|
-
}
|
|
80785
|
-
|
|
80786
|
-
|
|
80787
|
-
suffix: suffix2,
|
|
80788
|
-
justification,
|
|
80789
|
-
path,
|
|
80790
|
-
numberingType: listNumberingType
|
|
80791
|
-
});
|
|
81241
|
+
};
|
|
81242
|
+
if (JSON.stringify(node.attrs.listRendering) !== JSON.stringify(newListRendering)) {
|
|
81243
|
+
tr.setNodeAttribute(pos, "listRendering", newListRendering);
|
|
80792
81244
|
}
|
|
80793
81245
|
return false;
|
|
80794
81246
|
});
|
|
@@ -81089,7 +81541,7 @@ const Paragraph = OxmlNode.create({
|
|
|
81089
81541
|
return null;
|
|
81090
81542
|
}
|
|
81091
81543
|
const { tr } = state2;
|
|
81092
|
-
tr.delete(range2.from, range2.to);
|
|
81544
|
+
tr.delete(range2.from, range2.to).setSelection(TextSelection$1.create(tr.doc, range2.from));
|
|
81093
81545
|
ListHelpers.createNewList({
|
|
81094
81546
|
listType: type2,
|
|
81095
81547
|
tr,
|
|
@@ -84519,7 +84971,10 @@ const Table = Node$1.create({
|
|
|
84519
84971
|
insertTable: ({ rows = 3, cols = 3, withHeaderRow = false } = {}) => ({ tr, dispatch, editor }) => {
|
|
84520
84972
|
const node = createTable(editor.schema, rows, cols, withHeaderRow);
|
|
84521
84973
|
if (dispatch) {
|
|
84522
|
-
|
|
84974
|
+
let offset2 = tr.selection.$from.end() + 1;
|
|
84975
|
+
if (tr.selection.$from.parent?.type?.name === "run") {
|
|
84976
|
+
offset2 = tr.selection.$from.after(tr.selection.$from.depth - 1);
|
|
84977
|
+
}
|
|
84523
84978
|
tr.replaceSelectionWith(node).scrollIntoView().setSelection(TextSelection$1.near(tr.doc.resolve(offset2)));
|
|
84524
84979
|
}
|
|
84525
84980
|
return true;
|
|
@@ -111857,6 +112312,12 @@ const _sfc_main$4 = {
|
|
|
111857
112312
|
};
|
|
111858
112313
|
const GenericPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-cbddcc0f"]]);
|
|
111859
112314
|
const _hoisted_1$3 = ["data-boundary-index", "data-boundary-type", "onMousedown"];
|
|
112315
|
+
const RESIZE_HANDLE_WIDTH_PX = 9;
|
|
112316
|
+
const RESIZE_HANDLE_OFFSET_PX = 4;
|
|
112317
|
+
const DRAG_OVERLAY_EXTENSION_PX = 1e3;
|
|
112318
|
+
const MIN_DRAG_OVERLAY_WIDTH_PX = 2e3;
|
|
112319
|
+
const THROTTLE_INTERVAL_MS = 16;
|
|
112320
|
+
const MIN_RESIZE_DELTA_PX = 1;
|
|
111860
112321
|
const _sfc_main$3 = {
|
|
111861
112322
|
__name: "TableResizeOverlay",
|
|
111862
112323
|
props: {
|
|
@@ -111880,26 +112341,73 @@ const _sfc_main$3 = {
|
|
|
111880
112341
|
setup(__props, { emit: __emit }) {
|
|
111881
112342
|
const props = __props;
|
|
111882
112343
|
const emit = __emit;
|
|
112344
|
+
const overlayRect = vue.ref(null);
|
|
111883
112345
|
const tableMetadata = vue.ref(null);
|
|
111884
112346
|
const dragState = vue.ref(null);
|
|
111885
112347
|
const forcedCleanup = vue.ref(false);
|
|
112348
|
+
let rafId = null;
|
|
112349
|
+
let isUnmounted = false;
|
|
112350
|
+
function startOverlayTracking() {
|
|
112351
|
+
if (rafId !== null) return;
|
|
112352
|
+
const step = () => {
|
|
112353
|
+
updateOverlayRect();
|
|
112354
|
+
rafId = requestAnimationFrame(step);
|
|
112355
|
+
};
|
|
112356
|
+
rafId = requestAnimationFrame(step);
|
|
112357
|
+
}
|
|
112358
|
+
function stopOverlayTracking() {
|
|
112359
|
+
if (rafId !== null) {
|
|
112360
|
+
cancelAnimationFrame(rafId);
|
|
112361
|
+
rafId = null;
|
|
112362
|
+
}
|
|
112363
|
+
}
|
|
111886
112364
|
const overlayStyle = vue.computed(() => {
|
|
111887
|
-
if (!props.tableElement) return {};
|
|
111888
|
-
const rect =
|
|
112365
|
+
if (!overlayRect.value || !props.tableElement) return {};
|
|
112366
|
+
const rect = overlayRect.value;
|
|
111889
112367
|
let overlayWidth = rect.width;
|
|
111890
112368
|
if (dragState.value) {
|
|
111891
|
-
overlayWidth = Math.max(rect.width +
|
|
112369
|
+
overlayWidth = Math.max(rect.width + DRAG_OVERLAY_EXTENSION_PX, MIN_DRAG_OVERLAY_WIDTH_PX);
|
|
111892
112370
|
}
|
|
111893
112371
|
return {
|
|
111894
112372
|
position: "absolute",
|
|
111895
|
-
left: `${
|
|
111896
|
-
top: `${
|
|
112373
|
+
left: `${rect.left}px`,
|
|
112374
|
+
top: `${rect.top}px`,
|
|
111897
112375
|
width: `${overlayWidth}px`,
|
|
111898
112376
|
height: `${rect.height}px`,
|
|
111899
112377
|
pointerEvents: dragState.value ? "auto" : "none",
|
|
111900
112378
|
zIndex: 10
|
|
111901
112379
|
};
|
|
111902
112380
|
});
|
|
112381
|
+
function updateOverlayRect() {
|
|
112382
|
+
if (!props.tableElement) {
|
|
112383
|
+
overlayRect.value = null;
|
|
112384
|
+
return;
|
|
112385
|
+
}
|
|
112386
|
+
const parent = props.tableElement.offsetParent;
|
|
112387
|
+
const tableRect = props.tableElement.getBoundingClientRect();
|
|
112388
|
+
if (tableRect.width === 0 || tableRect.height === 0) {
|
|
112389
|
+
overlayRect.value = null;
|
|
112390
|
+
return;
|
|
112391
|
+
}
|
|
112392
|
+
if (parent) {
|
|
112393
|
+
const parentRect = parent.getBoundingClientRect();
|
|
112394
|
+
const left2 = tableRect.left - parentRect.left + (parent.scrollLeft || 0);
|
|
112395
|
+
const top2 = tableRect.top - parentRect.top + (parent.scrollTop || 0);
|
|
112396
|
+
overlayRect.value = {
|
|
112397
|
+
left: left2,
|
|
112398
|
+
top: top2,
|
|
112399
|
+
width: tableRect.width,
|
|
112400
|
+
height: tableRect.height
|
|
112401
|
+
};
|
|
112402
|
+
} else {
|
|
112403
|
+
overlayRect.value = {
|
|
112404
|
+
left: props.tableElement.offsetLeft,
|
|
112405
|
+
top: props.tableElement.offsetTop,
|
|
112406
|
+
width: tableRect.width,
|
|
112407
|
+
height: tableRect.height
|
|
112408
|
+
};
|
|
112409
|
+
}
|
|
112410
|
+
}
|
|
111903
112411
|
const resizableBoundaries = vue.computed(() => {
|
|
111904
112412
|
if (!tableMetadata.value?.columns) {
|
|
111905
112413
|
return [];
|
|
@@ -111938,9 +112446,9 @@ const _sfc_main$3 = {
|
|
|
111938
112446
|
if (!colSegments || colSegments.length === 0) {
|
|
111939
112447
|
return [];
|
|
111940
112448
|
}
|
|
111941
|
-
return colSegments.map((seg) => ({
|
|
111942
|
-
y: seg.y,
|
|
111943
|
-
h: seg.h
|
|
112449
|
+
return colSegments.filter((seg) => seg && typeof seg === "object").map((seg) => ({
|
|
112450
|
+
y: typeof seg.y === "number" ? seg.y : 0,
|
|
112451
|
+
h: seg.h !== null && typeof seg.h === "number" ? seg.h : null
|
|
111944
112452
|
}));
|
|
111945
112453
|
}
|
|
111946
112454
|
function getSegmentHandleStyle(boundary, segment) {
|
|
@@ -111948,16 +112456,16 @@ const _sfc_main$3 = {
|
|
|
111948
112456
|
position: "absolute",
|
|
111949
112457
|
left: `${boundary.x}px`,
|
|
111950
112458
|
top: segment.y != null ? `${segment.y}px` : "0",
|
|
111951
|
-
width:
|
|
112459
|
+
width: `${RESIZE_HANDLE_WIDTH_PX}px`,
|
|
111952
112460
|
height: segment.h != null ? `${segment.h}px` : "100%",
|
|
111953
|
-
transform:
|
|
112461
|
+
transform: `translateX(-${RESIZE_HANDLE_OFFSET_PX}px)`,
|
|
111954
112462
|
cursor: "col-resize",
|
|
111955
112463
|
pointerEvents: "auto"
|
|
111956
112464
|
};
|
|
111957
112465
|
}
|
|
111958
112466
|
const guidelineStyle = vue.computed(() => {
|
|
111959
112467
|
if (!dragState.value || !tableMetadata.value) return { display: "none" };
|
|
111960
|
-
const initialBoundary = resizableBoundaries.value[dragState.value.
|
|
112468
|
+
const initialBoundary = resizableBoundaries.value[dragState.value.resizableBoundaryIndex];
|
|
111961
112469
|
if (!initialBoundary) return { display: "none" };
|
|
111962
112470
|
const newX = initialBoundary.x + dragState.value.constrainedDelta;
|
|
111963
112471
|
return {
|
|
@@ -112014,11 +112522,11 @@ const _sfc_main$3 = {
|
|
|
112014
112522
|
});
|
|
112015
112523
|
}
|
|
112016
112524
|
}
|
|
112017
|
-
function onHandleMouseDown(event,
|
|
112525
|
+
function onHandleMouseDown(event, resizableBoundaryIndex) {
|
|
112018
112526
|
event.preventDefault();
|
|
112019
112527
|
event.stopPropagation();
|
|
112020
112528
|
if (!tableMetadata.value?.columns) return;
|
|
112021
|
-
const boundary = resizableBoundaries.value[
|
|
112529
|
+
const boundary = resizableBoundaries.value[resizableBoundaryIndex];
|
|
112022
112530
|
if (!boundary) return;
|
|
112023
112531
|
const columns = tableMetadata.value.columns;
|
|
112024
112532
|
const isRightEdge = boundary.type === "right-edge";
|
|
@@ -112026,7 +112534,7 @@ const _sfc_main$3 = {
|
|
|
112026
112534
|
const rightColumn = isRightEdge ? null : columns[boundary.index + 1];
|
|
112027
112535
|
dragState.value = {
|
|
112028
112536
|
columnIndex: boundary.index,
|
|
112029
|
-
|
|
112537
|
+
resizableBoundaryIndex,
|
|
112030
112538
|
isRightEdge,
|
|
112031
112539
|
initialX: event.clientX,
|
|
112032
112540
|
initialWidths: columns.map((col) => col.w),
|
|
@@ -112040,15 +112548,28 @@ const _sfc_main$3 = {
|
|
|
112040
112548
|
} : null,
|
|
112041
112549
|
constrainedDelta: 0
|
|
112042
112550
|
};
|
|
112551
|
+
if (!props.editor?.view?.dom) {
|
|
112552
|
+
emit("resize-error", { error: "Editor view not available" });
|
|
112553
|
+
dragState.value = null;
|
|
112554
|
+
return;
|
|
112555
|
+
}
|
|
112043
112556
|
const pmView = props.editor.view.dom;
|
|
112044
112557
|
pmView.style.pointerEvents = "none";
|
|
112045
|
-
|
|
112046
|
-
|
|
112047
|
-
|
|
112048
|
-
|
|
112049
|
-
|
|
112050
|
-
|
|
112051
|
-
|
|
112558
|
+
try {
|
|
112559
|
+
document.addEventListener("mousemove", onDocumentMouseMove2);
|
|
112560
|
+
document.addEventListener("mouseup", onDocumentMouseUp);
|
|
112561
|
+
emit("resize-start", {
|
|
112562
|
+
columnIndex: boundary.index,
|
|
112563
|
+
isRightEdge,
|
|
112564
|
+
initialWidths: dragState.value.initialWidths
|
|
112565
|
+
});
|
|
112566
|
+
} catch (error) {
|
|
112567
|
+
document.removeEventListener("mousemove", onDocumentMouseMove2);
|
|
112568
|
+
document.removeEventListener("mouseup", onDocumentMouseUp);
|
|
112569
|
+
pmView.style.pointerEvents = "auto";
|
|
112570
|
+
dragState.value = null;
|
|
112571
|
+
emit("resize-error", { error: error instanceof Error ? error.message : String(error) });
|
|
112572
|
+
}
|
|
112052
112573
|
}
|
|
112053
112574
|
function throttle2(func, limit) {
|
|
112054
112575
|
let inThrottle;
|
|
@@ -112073,7 +112594,7 @@ const _sfc_main$3 = {
|
|
|
112073
112594
|
return { throttled, cancel };
|
|
112074
112595
|
}
|
|
112075
112596
|
const mouseMoveThrottle = throttle2((event) => {
|
|
112076
|
-
if (!dragState.value) return;
|
|
112597
|
+
if (isUnmounted || !dragState.value) return;
|
|
112077
112598
|
const delta = event.clientX - dragState.value.initialX;
|
|
112078
112599
|
const minDelta = -(dragState.value.leftColumn.width - dragState.value.leftColumn.minWidth);
|
|
112079
112600
|
let maxDelta;
|
|
@@ -112099,7 +112620,7 @@ const _sfc_main$3 = {
|
|
|
112099
112620
|
columnIndex: dragState.value.columnIndex,
|
|
112100
112621
|
delta: constrainedDelta
|
|
112101
112622
|
});
|
|
112102
|
-
},
|
|
112623
|
+
}, THROTTLE_INTERVAL_MS);
|
|
112103
112624
|
const onDocumentMouseMove2 = mouseMoveThrottle.throttled;
|
|
112104
112625
|
function onDocumentMouseUp(event) {
|
|
112105
112626
|
if (!dragState.value) return;
|
|
@@ -112114,13 +112635,11 @@ const _sfc_main$3 = {
|
|
|
112114
112635
|
}
|
|
112115
112636
|
document.removeEventListener("mousemove", onDocumentMouseMove2);
|
|
112116
112637
|
document.removeEventListener("mouseup", onDocumentMouseUp);
|
|
112117
|
-
if (props.editor?.view) {
|
|
112638
|
+
if (props.editor?.view?.dom) {
|
|
112118
112639
|
const pmView = props.editor.view.dom;
|
|
112119
|
-
|
|
112120
|
-
pmView.style.pointerEvents = "auto";
|
|
112121
|
-
}
|
|
112640
|
+
pmView.style.pointerEvents = "auto";
|
|
112122
112641
|
}
|
|
112123
|
-
if (!forcedCleanup.value && Math.abs(finalDelta) >
|
|
112642
|
+
if (!forcedCleanup.value && Math.abs(finalDelta) > MIN_RESIZE_DELTA_PX) {
|
|
112124
112643
|
dispatchResizeTransaction(columnIndex, newWidths);
|
|
112125
112644
|
emit("resize-end", {
|
|
112126
112645
|
columnIndex,
|
|
@@ -112183,7 +112702,14 @@ const _sfc_main$3 = {
|
|
|
112183
112702
|
if (!pmElement) {
|
|
112184
112703
|
return null;
|
|
112185
112704
|
}
|
|
112186
|
-
const
|
|
112705
|
+
const pmStartAttr = pmElement.getAttribute("data-pm-start");
|
|
112706
|
+
if (!pmStartAttr) {
|
|
112707
|
+
return null;
|
|
112708
|
+
}
|
|
112709
|
+
const pmStart = parseInt(pmStartAttr, 10);
|
|
112710
|
+
if (!Number.isFinite(pmStart)) {
|
|
112711
|
+
return null;
|
|
112712
|
+
}
|
|
112187
112713
|
let tablePos = null;
|
|
112188
112714
|
state2.doc.descendants((node, pos) => {
|
|
112189
112715
|
if (node.type.name === "table") {
|
|
@@ -112235,6 +112761,12 @@ const _sfc_main$3 = {
|
|
|
112235
112761
|
() => props.tableElement,
|
|
112236
112762
|
() => {
|
|
112237
112763
|
parseTableMetadata();
|
|
112764
|
+
updateOverlayRect();
|
|
112765
|
+
if (props.visible && props.tableElement) {
|
|
112766
|
+
startOverlayTracking();
|
|
112767
|
+
} else if (!props.tableElement) {
|
|
112768
|
+
stopOverlayTracking();
|
|
112769
|
+
}
|
|
112238
112770
|
},
|
|
112239
112771
|
{ immediate: true }
|
|
112240
112772
|
);
|
|
@@ -112243,7 +112775,10 @@ const _sfc_main$3 = {
|
|
|
112243
112775
|
(visible) => {
|
|
112244
112776
|
if (visible) {
|
|
112245
112777
|
parseTableMetadata();
|
|
112778
|
+
updateOverlayRect();
|
|
112779
|
+
startOverlayTracking();
|
|
112246
112780
|
} else {
|
|
112781
|
+
stopOverlayTracking();
|
|
112247
112782
|
if (dragState.value) {
|
|
112248
112783
|
forcedCleanup.value = true;
|
|
112249
112784
|
onDocumentMouseUp(new MouseEvent("mouseup"));
|
|
@@ -112252,8 +112787,15 @@ const _sfc_main$3 = {
|
|
|
112252
112787
|
}
|
|
112253
112788
|
}
|
|
112254
112789
|
);
|
|
112790
|
+
vue.onMounted(() => {
|
|
112791
|
+
window.addEventListener("scroll", updateOverlayRect, true);
|
|
112792
|
+
window.addEventListener("resize", updateOverlayRect);
|
|
112793
|
+
updateOverlayRect();
|
|
112794
|
+
});
|
|
112255
112795
|
vue.onBeforeUnmount(() => {
|
|
112796
|
+
isUnmounted = true;
|
|
112256
112797
|
mouseMoveThrottle.cancel();
|
|
112798
|
+
stopOverlayTracking();
|
|
112257
112799
|
if (dragState.value) {
|
|
112258
112800
|
document.removeEventListener("mousemove", onDocumentMouseMove2);
|
|
112259
112801
|
document.removeEventListener("mouseup", onDocumentMouseUp);
|
|
@@ -112261,6 +112803,8 @@ const _sfc_main$3 = {
|
|
|
112261
112803
|
props.editor.view.dom.style.pointerEvents = "auto";
|
|
112262
112804
|
}
|
|
112263
112805
|
}
|
|
112806
|
+
window.removeEventListener("scroll", updateOverlayRect, true);
|
|
112807
|
+
window.removeEventListener("resize", updateOverlayRect);
|
|
112264
112808
|
});
|
|
112265
112809
|
return (_ctx, _cache) => {
|
|
112266
112810
|
return __props.visible && tableMetadata.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
@@ -112270,21 +112814,21 @@ const _sfc_main$3 = {
|
|
|
112270
112814
|
onMousedown: _cache[0] || (_cache[0] = vue.withModifiers(() => {
|
|
112271
112815
|
}, ["stop"]))
|
|
112272
112816
|
}, [
|
|
112273
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(resizableBoundaries.value, (boundary,
|
|
112817
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(resizableBoundaries.value, (boundary, resizableBoundaryIndex) => {
|
|
112274
112818
|
return vue.openBlock(), vue.createElementBlock(vue.Fragment, {
|
|
112275
|
-
key: `boundary-${
|
|
112819
|
+
key: `boundary-${resizableBoundaryIndex}`
|
|
112276
112820
|
}, [
|
|
112277
112821
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(getBoundarySegments(boundary), (segment, segmentIndex) => {
|
|
112278
112822
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
112279
112823
|
key: `handle-${boundary.type}-${boundary.index}-${segmentIndex}`,
|
|
112280
112824
|
class: vue.normalizeClass(["resize-handle", {
|
|
112281
|
-
"resize-handle--active": dragState.value && dragState.value.
|
|
112825
|
+
"resize-handle--active": dragState.value && dragState.value.resizableBoundaryIndex === resizableBoundaryIndex,
|
|
112282
112826
|
"resize-handle--edge": boundary.type === "right-edge"
|
|
112283
112827
|
}]),
|
|
112284
|
-
"data-boundary-index":
|
|
112828
|
+
"data-boundary-index": resizableBoundaryIndex,
|
|
112285
112829
|
"data-boundary-type": boundary.type,
|
|
112286
112830
|
style: vue.normalizeStyle(getSegmentHandleStyle(boundary, segment)),
|
|
112287
|
-
onMousedown: ($event) => onHandleMouseDown($event,
|
|
112831
|
+
onMousedown: ($event) => onHandleMouseDown($event, resizableBoundaryIndex)
|
|
112288
112832
|
}, null, 46, _hoisted_1$3);
|
|
112289
112833
|
}), 128))
|
|
112290
112834
|
], 64);
|
|
@@ -112298,7 +112842,7 @@ const _sfc_main$3 = {
|
|
|
112298
112842
|
};
|
|
112299
112843
|
}
|
|
112300
112844
|
};
|
|
112301
|
-
const TableResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-
|
|
112845
|
+
const TableResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-2fdf7836"]]);
|
|
112302
112846
|
const _hoisted_1$2 = ["data-handle-position", "onMousedown"];
|
|
112303
112847
|
const OVERLAY_EXPANSION_PX = 2e3;
|
|
112304
112848
|
const RESIZE_HANDLE_SIZE_PX = 12;
|