superdoc 1.0.0-beta.15 → 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-DltPlBWC.cjs → PdfViewer-BIlJaTm7.cjs} +1 -1
- package/dist/chunks/{PdfViewer-CjlHzt9e.es.js → PdfViewer-cvzMUtBh.es.js} +1 -1
- package/dist/chunks/{index-qg0AxQJC.es.js → index-CrIfBvBN.es.js} +3 -3
- package/dist/chunks/{index-BZnlco_f.cjs → index-DDx90Dl3.cjs} +3 -3
- package/dist/chunks/{index-Bds7gW4r-JPDW6c39.cjs → index-VCeRjVPO-DjkejB6t.cjs} +1 -1
- package/dist/chunks/{index-Bds7gW4r-Pk_xAuWe.es.js → index-VCeRjVPO-FBgR9qxX.es.js} +1 -1
- package/dist/chunks/{super-editor.es-CQTkj_nb.es.js → super-editor.es-00SpI-wK.es.js} +1909 -273
- package/dist/chunks/{super-editor.es-CuAhqbzW.cjs → super-editor.es-Mlj7AGyt.cjs} +1909 -273
- package/dist/style.css +6 -6
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-qMoZOGGn.js → converter-B9zUZjYT.js} +71 -34
- package/dist/super-editor/chunks/{docx-zipper-QKiyORxV.js → docx-zipper-r5KdE_SA.js} +1 -1
- package/dist/super-editor/chunks/{editor-D8ZdjC2V.js → editor-D2k2BwSG.js} +1743 -232
- package/dist/super-editor/chunks/{index-Bds7gW4r.js → index-VCeRjVPO.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-Spi7vpev.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 +1911 -275
- 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");
|
|
@@ -55036,7 +55312,7 @@ const pickLang = (value) => {
|
|
|
55036
55312
|
const normalized = value.trim().toLowerCase();
|
|
55037
55313
|
return normalized || void 0;
|
|
55038
55314
|
};
|
|
55039
|
-
const normalizeColor = (value) => {
|
|
55315
|
+
const normalizeColor$1 = (value) => {
|
|
55040
55316
|
if (typeof value !== "string") return void 0;
|
|
55041
55317
|
const trimmed = value.trim();
|
|
55042
55318
|
if (!trimmed || trimmed === "auto" || trimmed === "none") return void 0;
|
|
@@ -55676,14 +55952,14 @@ const resolveThemeColor = (attrs, themeColors) => {
|
|
|
55676
55952
|
const resolveColorFromAttributes = (attrs, themeColors) => {
|
|
55677
55953
|
if (!attrs) return void 0;
|
|
55678
55954
|
if (typeof attrs.color === "string") {
|
|
55679
|
-
const normalized = normalizeColor(attrs.color);
|
|
55955
|
+
const normalized = normalizeColor$1(attrs.color);
|
|
55680
55956
|
if (normalized) {
|
|
55681
55957
|
return normalized;
|
|
55682
55958
|
}
|
|
55683
55959
|
}
|
|
55684
55960
|
const theme = resolveThemeColor(attrs, themeColors);
|
|
55685
55961
|
if (theme) {
|
|
55686
|
-
return normalizeColor(theme);
|
|
55962
|
+
return normalizeColor$1(theme);
|
|
55687
55963
|
}
|
|
55688
55964
|
return void 0;
|
|
55689
55965
|
};
|
|
@@ -56118,13 +56394,8 @@ const MAX_BORDER_SIZE_PX = 100;
|
|
|
56118
56394
|
const borderSizeToPx = (size2) => {
|
|
56119
56395
|
if (!isFiniteNumber(size2)) return void 0;
|
|
56120
56396
|
if (size2 <= 0) return 0;
|
|
56121
|
-
|
|
56122
|
-
|
|
56123
|
-
pixelValue = size2;
|
|
56124
|
-
} else {
|
|
56125
|
-
const points = size2 / EIGHTHS_PER_POINT;
|
|
56126
|
-
pixelValue = points * PX_PER_PT;
|
|
56127
|
-
}
|
|
56397
|
+
const points = size2 / EIGHTHS_PER_POINT;
|
|
56398
|
+
const pixelValue = points * PX_PER_PT;
|
|
56128
56399
|
return Math.min(MAX_BORDER_SIZE_PX, Math.max(MIN_BORDER_SIZE_PX, pixelValue));
|
|
56129
56400
|
};
|
|
56130
56401
|
const normalizeColorWithDefault = (color) => {
|
|
@@ -56263,7 +56534,7 @@ const normalizeBorderSide = (value) => {
|
|
|
56263
56534
|
if (style2 === "none") return void 0;
|
|
56264
56535
|
const width = pickNumber(raw.size);
|
|
56265
56536
|
const widthPx = borderSizeToPx(width);
|
|
56266
|
-
const color = normalizeColor(raw.color);
|
|
56537
|
+
const color = normalizeColor$1(raw.color);
|
|
56267
56538
|
const space = pickNumber(raw.space);
|
|
56268
56539
|
if (!style2 && widthPx == null && space == null && !color) {
|
|
56269
56540
|
return void 0;
|
|
@@ -56319,7 +56590,7 @@ const normalizeParagraphShading = (value) => {
|
|
|
56319
56590
|
return Object.keys(shading).length > 0 ? shading : void 0;
|
|
56320
56591
|
};
|
|
56321
56592
|
const normalizeShadingColor = (value) => {
|
|
56322
|
-
const normalized = normalizeColor(value);
|
|
56593
|
+
const normalized = normalizeColor$1(value);
|
|
56323
56594
|
if (!normalized) return void 0;
|
|
56324
56595
|
if (normalized.toLowerCase() === "#auto") {
|
|
56325
56596
|
return void 0;
|
|
@@ -57482,11 +57753,11 @@ const buildMarkerLayout = ({
|
|
|
57482
57753
|
baselineOffsetPx: markerRun.baselineShift ?? 0,
|
|
57483
57754
|
gutterWidthPx: markerBoxWidthPx,
|
|
57484
57755
|
justification: numbering.lvlJc ?? "left",
|
|
57485
|
-
suffix: normalizeSuffix(numbering.suffix) ?? "tab",
|
|
57756
|
+
suffix: normalizeSuffix$1(numbering.suffix) ?? "tab",
|
|
57486
57757
|
run: markerRun,
|
|
57487
57758
|
path: numbering.path
|
|
57488
57759
|
});
|
|
57489
|
-
const normalizeSuffix = (suffix2) => {
|
|
57760
|
+
const normalizeSuffix$1 = (suffix2) => {
|
|
57490
57761
|
if (suffix2 === "tab" || suffix2 === "space" || suffix2 === "nothing") {
|
|
57491
57762
|
return suffix2;
|
|
57492
57763
|
}
|
|
@@ -57940,6 +58211,154 @@ const cloneIfObject = (value) => {
|
|
|
57940
58211
|
};
|
|
57941
58212
|
const { resolveSpacingIndent } = Engines;
|
|
57942
58213
|
const DEFAULT_DECIMAL_SEPARATOR$2 = ".";
|
|
58214
|
+
const asOoxmlElement = (value) => {
|
|
58215
|
+
if (!value || typeof value !== "object") return void 0;
|
|
58216
|
+
const element = value;
|
|
58217
|
+
if (element.name == null && element.attributes == null && element.elements == null) return void 0;
|
|
58218
|
+
return element;
|
|
58219
|
+
};
|
|
58220
|
+
const findChild = (parent, name) => {
|
|
58221
|
+
return parent?.elements?.find((child) => child?.name === name);
|
|
58222
|
+
};
|
|
58223
|
+
const getAttribute = (element, key2) => {
|
|
58224
|
+
if (!element?.attributes) return void 0;
|
|
58225
|
+
const attrs = element.attributes;
|
|
58226
|
+
return attrs[key2] ?? attrs[key2.startsWith("w:") ? key2.slice(2) : `w:${key2}`];
|
|
58227
|
+
};
|
|
58228
|
+
const parseNumberAttr = (value) => {
|
|
58229
|
+
if (value == null) return void 0;
|
|
58230
|
+
const num = typeof value === "number" ? value : Number.parseInt(String(value), 10);
|
|
58231
|
+
return Number.isFinite(num) ? num : void 0;
|
|
58232
|
+
};
|
|
58233
|
+
const normalizeNumFmt = (value) => {
|
|
58234
|
+
if (typeof value !== "string") return void 0;
|
|
58235
|
+
switch (value) {
|
|
58236
|
+
case "decimal":
|
|
58237
|
+
return "decimal";
|
|
58238
|
+
case "lowerLetter":
|
|
58239
|
+
return "lowerLetter";
|
|
58240
|
+
case "upperLetter":
|
|
58241
|
+
return "upperLetter";
|
|
58242
|
+
case "lowerRoman":
|
|
58243
|
+
return "lowerRoman";
|
|
58244
|
+
case "upperRoman":
|
|
58245
|
+
return "upperRoman";
|
|
58246
|
+
case "bullet":
|
|
58247
|
+
return "bullet";
|
|
58248
|
+
default:
|
|
58249
|
+
return void 0;
|
|
58250
|
+
}
|
|
58251
|
+
};
|
|
58252
|
+
const normalizeSuffix = (value) => {
|
|
58253
|
+
if (typeof value !== "string") return void 0;
|
|
58254
|
+
if (value === "tab" || value === "space" || value === "nothing") {
|
|
58255
|
+
return value;
|
|
58256
|
+
}
|
|
58257
|
+
return void 0;
|
|
58258
|
+
};
|
|
58259
|
+
const normalizeJustification = (value) => {
|
|
58260
|
+
if (typeof value !== "string") return void 0;
|
|
58261
|
+
if (value === "start") return "left";
|
|
58262
|
+
if (value === "end") return "right";
|
|
58263
|
+
if (value === "left" || value === "center" || value === "right") return value;
|
|
58264
|
+
return void 0;
|
|
58265
|
+
};
|
|
58266
|
+
const extractIndentFromLevel = (lvl) => {
|
|
58267
|
+
const pPr = findChild(lvl, "w:pPr");
|
|
58268
|
+
const ind = findChild(pPr, "w:ind");
|
|
58269
|
+
if (!ind) return void 0;
|
|
58270
|
+
const left2 = parseNumberAttr(getAttribute(ind, "w:left"));
|
|
58271
|
+
const right2 = parseNumberAttr(getAttribute(ind, "w:right"));
|
|
58272
|
+
const firstLine = parseNumberAttr(getAttribute(ind, "w:firstLine"));
|
|
58273
|
+
const hanging = parseNumberAttr(getAttribute(ind, "w:hanging"));
|
|
58274
|
+
const indent = {};
|
|
58275
|
+
if (left2 != null) indent.left = left2;
|
|
58276
|
+
if (right2 != null) indent.right = right2;
|
|
58277
|
+
if (firstLine != null) indent.firstLine = firstLine;
|
|
58278
|
+
if (hanging != null) indent.hanging = hanging;
|
|
58279
|
+
return Object.keys(indent).length ? indent : void 0;
|
|
58280
|
+
};
|
|
58281
|
+
const normalizeColor = (value) => {
|
|
58282
|
+
if (typeof value !== "string") return void 0;
|
|
58283
|
+
const trimmed = value.trim();
|
|
58284
|
+
if (!trimmed || trimmed.toLowerCase() === "auto") return void 0;
|
|
58285
|
+
const upper = trimmed.startsWith("#") ? trimmed.slice(1) : trimmed;
|
|
58286
|
+
return `#${upper.toUpperCase()}`;
|
|
58287
|
+
};
|
|
58288
|
+
const extractMarkerRun = (lvl) => {
|
|
58289
|
+
const rPr = findChild(lvl, "w:rPr");
|
|
58290
|
+
if (!rPr) return void 0;
|
|
58291
|
+
const run2 = {};
|
|
58292
|
+
const rFonts = findChild(rPr, "w:rFonts");
|
|
58293
|
+
const font = getAttribute(rFonts, "w:ascii") ?? getAttribute(rFonts, "w:hAnsi") ?? getAttribute(rFonts, "w:eastAsia");
|
|
58294
|
+
if (typeof font === "string" && font.trim()) {
|
|
58295
|
+
run2.fontFamily = font;
|
|
58296
|
+
}
|
|
58297
|
+
const sz = parseNumberAttr(getAttribute(findChild(rPr, "w:sz"), "w:val")) ?? parseNumberAttr(getAttribute(findChild(rPr, "w:szCs"), "w:val"));
|
|
58298
|
+
if (sz != null) {
|
|
58299
|
+
run2.fontSize = sz / 2;
|
|
58300
|
+
}
|
|
58301
|
+
const color = normalizeColor(getAttribute(findChild(rPr, "w:color"), "w:val"));
|
|
58302
|
+
if (color) run2.color = color;
|
|
58303
|
+
if (findChild(rPr, "w:b")) run2.bold = true;
|
|
58304
|
+
if (findChild(rPr, "w:i")) run2.italic = true;
|
|
58305
|
+
const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
|
|
58306
|
+
if (spacingTwips != null && Number.isFinite(spacingTwips)) {
|
|
58307
|
+
run2.letterSpacing = twipsToPx$1(spacingTwips);
|
|
58308
|
+
}
|
|
58309
|
+
return Object.keys(run2).length ? run2 : void 0;
|
|
58310
|
+
};
|
|
58311
|
+
const findNumFmtElement = (lvl) => {
|
|
58312
|
+
if (!lvl) return void 0;
|
|
58313
|
+
const direct = findChild(lvl, "w:numFmt");
|
|
58314
|
+
if (direct) return direct;
|
|
58315
|
+
const alternate = findChild(lvl, "mc:AlternateContent");
|
|
58316
|
+
const choice = findChild(alternate, "mc:Choice");
|
|
58317
|
+
if (choice) {
|
|
58318
|
+
return findChild(choice, "w:numFmt");
|
|
58319
|
+
}
|
|
58320
|
+
return void 0;
|
|
58321
|
+
};
|
|
58322
|
+
const resolveNumberingFromContext = (numId, ilvl, numbering) => {
|
|
58323
|
+
const definitions = numbering?.definitions;
|
|
58324
|
+
const abstracts = numbering?.abstracts;
|
|
58325
|
+
if (!definitions || !abstracts) return void 0;
|
|
58326
|
+
const numDef = asOoxmlElement(definitions[String(numId)]);
|
|
58327
|
+
if (!numDef) return void 0;
|
|
58328
|
+
const abstractId = getAttribute(findChild(numDef, "w:abstractNumId"), "w:val");
|
|
58329
|
+
if (abstractId == null) return void 0;
|
|
58330
|
+
const abstract = asOoxmlElement(abstracts[String(abstractId)]);
|
|
58331
|
+
if (!abstract) return void 0;
|
|
58332
|
+
let levelDef = abstract.elements?.find(
|
|
58333
|
+
(el) => el?.name === "w:lvl" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
|
|
58334
|
+
);
|
|
58335
|
+
const override = numDef.elements?.find(
|
|
58336
|
+
(el) => el?.name === "w:lvlOverride" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
|
|
58337
|
+
);
|
|
58338
|
+
const overrideLvl = findChild(override, "w:lvl");
|
|
58339
|
+
if (overrideLvl) {
|
|
58340
|
+
levelDef = overrideLvl;
|
|
58341
|
+
}
|
|
58342
|
+
const startOverride = parseNumberAttr(getAttribute(findChild(override, "w:startOverride"), "w:val"));
|
|
58343
|
+
if (!levelDef) return void 0;
|
|
58344
|
+
const numFmtEl = findNumFmtElement(levelDef);
|
|
58345
|
+
const lvlText = getAttribute(findChild(levelDef, "w:lvlText"), "w:val");
|
|
58346
|
+
const start2 = startOverride ?? parseNumberAttr(getAttribute(findChild(levelDef, "w:start"), "w:val"));
|
|
58347
|
+
const suffix2 = normalizeSuffix(getAttribute(findChild(levelDef, "w:suff"), "w:val"));
|
|
58348
|
+
const lvlJc = normalizeJustification(getAttribute(findChild(levelDef, "w:lvlJc"), "w:val"));
|
|
58349
|
+
const indent = extractIndentFromLevel(levelDef);
|
|
58350
|
+
const markerRun = extractMarkerRun(levelDef);
|
|
58351
|
+
const numFmt = normalizeNumFmt(getAttribute(numFmtEl, "w:val"));
|
|
58352
|
+
return {
|
|
58353
|
+
format: numFmt,
|
|
58354
|
+
lvlText,
|
|
58355
|
+
start: start2,
|
|
58356
|
+
suffix: suffix2,
|
|
58357
|
+
lvlJc,
|
|
58358
|
+
resolvedLevelIndent: indent,
|
|
58359
|
+
resolvedMarkerRpr: markerRun
|
|
58360
|
+
};
|
|
58361
|
+
};
|
|
57943
58362
|
const isTruthy = (value) => {
|
|
57944
58363
|
if (value === true || value === 1) return true;
|
|
57945
58364
|
if (typeof value === "string") {
|
|
@@ -58572,6 +58991,30 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
58572
58991
|
const ilvl = Number.isFinite(numberingProps.ilvl) ? Math.max(0, Math.floor(Number(numberingProps.ilvl))) : 0;
|
|
58573
58992
|
const listRendering = normalizeListRenderingAttrs(attrs.listRendering);
|
|
58574
58993
|
const numericNumId = typeof numId === "number" ? numId : void 0;
|
|
58994
|
+
const resolvedLevel = resolveNumberingFromContext(numId, ilvl, converterContext?.numbering);
|
|
58995
|
+
if (resolvedLevel) {
|
|
58996
|
+
if (resolvedLevel.format && numberingProps.format == null) {
|
|
58997
|
+
numberingProps.format = resolvedLevel.format;
|
|
58998
|
+
}
|
|
58999
|
+
if (resolvedLevel.lvlText && numberingProps.lvlText == null) {
|
|
59000
|
+
numberingProps.lvlText = resolvedLevel.lvlText;
|
|
59001
|
+
}
|
|
59002
|
+
if (resolvedLevel.start != null && numberingProps.start == null) {
|
|
59003
|
+
numberingProps.start = resolvedLevel.start;
|
|
59004
|
+
}
|
|
59005
|
+
if (resolvedLevel.suffix && numberingProps.suffix == null) {
|
|
59006
|
+
numberingProps.suffix = resolvedLevel.suffix;
|
|
59007
|
+
}
|
|
59008
|
+
if (resolvedLevel.lvlJc && numberingProps.lvlJc == null) {
|
|
59009
|
+
numberingProps.lvlJc = resolvedLevel.lvlJc;
|
|
59010
|
+
}
|
|
59011
|
+
if (resolvedLevel.resolvedLevelIndent && !numberingProps.resolvedLevelIndent) {
|
|
59012
|
+
numberingProps.resolvedLevelIndent = resolvedLevel.resolvedLevelIndent;
|
|
59013
|
+
}
|
|
59014
|
+
if (resolvedLevel.resolvedMarkerRpr && !numberingProps.resolvedMarkerRpr) {
|
|
59015
|
+
numberingProps.resolvedMarkerRpr = resolvedLevel.resolvedMarkerRpr;
|
|
59016
|
+
}
|
|
59017
|
+
}
|
|
58575
59018
|
let counterValue = 1;
|
|
58576
59019
|
if (listCounterContext && typeof numericNumId === "number") {
|
|
58577
59020
|
counterValue = listCounterContext.incrementListCounter(numericNumId, ilvl);
|
|
@@ -59797,41 +60240,45 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
|
|
|
59797
60240
|
}
|
|
59798
60241
|
return;
|
|
59799
60242
|
}
|
|
59800
|
-
if (node.type === "hardBreak") {
|
|
59801
|
-
flushParagraph();
|
|
59802
|
-
blocks.push({
|
|
59803
|
-
kind: "pageBreak",
|
|
59804
|
-
id: nextId(),
|
|
59805
|
-
attrs: node.attrs || {}
|
|
59806
|
-
});
|
|
59807
|
-
return;
|
|
59808
|
-
}
|
|
59809
|
-
if (node.type === "lineBreak") {
|
|
60243
|
+
if (node.type === "hardBreak" || node.type === "lineBreak") {
|
|
59810
60244
|
const attrs = node.attrs ?? {};
|
|
59811
|
-
|
|
60245
|
+
const breakType = attrs.pageBreakType ?? attrs.lineBreakType ?? "line";
|
|
60246
|
+
if (breakType === "page") {
|
|
60247
|
+
flushParagraph();
|
|
60248
|
+
blocks.push({
|
|
60249
|
+
kind: "pageBreak",
|
|
60250
|
+
id: nextId(),
|
|
60251
|
+
attrs: node.attrs || {}
|
|
60252
|
+
});
|
|
60253
|
+
return;
|
|
60254
|
+
}
|
|
60255
|
+
if (breakType === "column") {
|
|
59812
60256
|
flushParagraph();
|
|
59813
60257
|
blocks.push({
|
|
59814
60258
|
kind: "columnBreak",
|
|
59815
60259
|
id: nextId(),
|
|
59816
60260
|
attrs: node.attrs || {}
|
|
59817
60261
|
});
|
|
60262
|
+
return;
|
|
60263
|
+
}
|
|
60264
|
+
const lineBreakRun = { kind: "lineBreak", attrs: {} };
|
|
60265
|
+
const lbAttrs = {};
|
|
60266
|
+
if (attrs.lineBreakType) lbAttrs.lineBreakType = String(attrs.lineBreakType);
|
|
60267
|
+
if (attrs.clear) lbAttrs.clear = String(attrs.clear);
|
|
60268
|
+
if (Object.keys(lbAttrs).length > 0) {
|
|
60269
|
+
lineBreakRun.attrs = lbAttrs;
|
|
59818
60270
|
} else {
|
|
59819
|
-
|
|
59820
|
-
|
|
59821
|
-
|
|
59822
|
-
|
|
59823
|
-
|
|
59824
|
-
|
|
59825
|
-
} else {
|
|
59826
|
-
delete lineBreakRun.attrs;
|
|
59827
|
-
}
|
|
59828
|
-
const pos = positions.get(node);
|
|
59829
|
-
if (pos) {
|
|
59830
|
-
lineBreakRun.pmStart = pos.start;
|
|
59831
|
-
lineBreakRun.pmEnd = pos.end;
|
|
59832
|
-
}
|
|
59833
|
-
currentRuns.push(lineBreakRun);
|
|
60271
|
+
delete lineBreakRun.attrs;
|
|
60272
|
+
}
|
|
60273
|
+
const pos = positions.get(node);
|
|
60274
|
+
if (pos) {
|
|
60275
|
+
lineBreakRun.pmStart = pos.start;
|
|
60276
|
+
lineBreakRun.pmEnd = pos.end;
|
|
59834
60277
|
}
|
|
60278
|
+
if (activeSdt) {
|
|
60279
|
+
lineBreakRun.sdt = activeSdt;
|
|
60280
|
+
}
|
|
60281
|
+
currentRuns.push(lineBreakRun);
|
|
59835
60282
|
return;
|
|
59836
60283
|
}
|
|
59837
60284
|
};
|
|
@@ -60424,6 +60871,22 @@ const normalizeTableWidth = (value) => {
|
|
|
60424
60871
|
};
|
|
60425
60872
|
const isTableRowNode = (node) => node.type === "tableRow" || node.type === "table_row";
|
|
60426
60873
|
const isTableCellNode = (node) => node.type === "tableCell" || node.type === "table_cell" || node.type === "tableHeader" || node.type === "table_header";
|
|
60874
|
+
const normalizeRowHeight = (rowProps) => {
|
|
60875
|
+
if (!rowProps || typeof rowProps !== "object") return void 0;
|
|
60876
|
+
const rawRowHeight = rowProps.rowHeight;
|
|
60877
|
+
if (!rawRowHeight || typeof rawRowHeight !== "object") return void 0;
|
|
60878
|
+
const heightObj = rawRowHeight;
|
|
60879
|
+
const rawValue = pickNumber(heightObj.value ?? heightObj.val);
|
|
60880
|
+
if (rawValue == null) return void 0;
|
|
60881
|
+
const rawRule = heightObj.rule ?? heightObj.hRule;
|
|
60882
|
+
const rule = rawRule === "exact" || rawRule === "atLeast" || rawRule === "auto" ? rawRule : "atLeast";
|
|
60883
|
+
const isLikelyTwips = rawValue >= 300 || Math.abs(rawValue % 15) < 1e-6;
|
|
60884
|
+
const valuePx = isLikelyTwips ? twipsToPx$1(rawValue) : rawValue;
|
|
60885
|
+
return {
|
|
60886
|
+
value: valuePx,
|
|
60887
|
+
rule
|
|
60888
|
+
};
|
|
60889
|
+
};
|
|
60427
60890
|
const parseTableCell = (args) => {
|
|
60428
60891
|
const { cellNode, rowIndex, cellIndex, context, defaultCellPadding } = args;
|
|
60429
60892
|
if (!isTableCellNode(cellNode) || !Array.isArray(cellNode.content)) {
|
|
@@ -60461,8 +60924,9 @@ const parseTableCell = (args) => {
|
|
|
60461
60924
|
const padding = extractCellPadding(cellNode.attrs ?? {}) ?? (defaultCellPadding ? { ...defaultCellPadding } : void 0);
|
|
60462
60925
|
if (padding) cellAttrs.padding = padding;
|
|
60463
60926
|
const verticalAlign = cellNode.attrs?.verticalAlign;
|
|
60464
|
-
|
|
60465
|
-
|
|
60927
|
+
const normalizedVerticalAlign = verticalAlign === "middle" ? "center" : verticalAlign === "center" ? "center" : verticalAlign;
|
|
60928
|
+
if (normalizedVerticalAlign === "top" || normalizedVerticalAlign === "center" || normalizedVerticalAlign === "bottom") {
|
|
60929
|
+
cellAttrs.verticalAlign = normalizedVerticalAlign;
|
|
60466
60930
|
}
|
|
60467
60931
|
const background = cellNode.attrs?.background;
|
|
60468
60932
|
if (background && typeof background.color === "string") {
|
|
@@ -60505,15 +60969,89 @@ const parseTableRow = (args) => {
|
|
|
60505
60969
|
});
|
|
60506
60970
|
if (cells.length === 0) return null;
|
|
60507
60971
|
const rowProps = rowNode.attrs?.tableRowProperties;
|
|
60972
|
+
const rowHeight = normalizeRowHeight(rowProps);
|
|
60508
60973
|
const attrs = rowProps && typeof rowProps === "object" ? {
|
|
60509
|
-
tableRowProperties: rowProps
|
|
60510
|
-
|
|
60974
|
+
tableRowProperties: rowProps,
|
|
60975
|
+
...rowHeight ? { rowHeight } : {}
|
|
60976
|
+
} : rowHeight ? { rowHeight } : void 0;
|
|
60511
60977
|
return {
|
|
60512
60978
|
id: context.nextBlockId(`row-${rowIndex}`),
|
|
60513
60979
|
cells,
|
|
60514
60980
|
attrs
|
|
60515
60981
|
};
|
|
60516
60982
|
};
|
|
60983
|
+
function extractFloatingTableAnchorWrap(node) {
|
|
60984
|
+
const tableProperties = node.attrs?.tableProperties;
|
|
60985
|
+
const floatingProps = tableProperties?.floatingTableProperties;
|
|
60986
|
+
if (!floatingProps) {
|
|
60987
|
+
return {};
|
|
60988
|
+
}
|
|
60989
|
+
const hasPositioning = floatingProps.tblpX !== void 0 || floatingProps.tblpY !== void 0 || floatingProps.tblpXSpec !== void 0 || floatingProps.tblpYSpec !== void 0 || floatingProps.horzAnchor !== void 0 || floatingProps.vertAnchor !== void 0;
|
|
60990
|
+
if (!hasPositioning) {
|
|
60991
|
+
return {};
|
|
60992
|
+
}
|
|
60993
|
+
const mapHorzAnchor = (val) => {
|
|
60994
|
+
switch (val) {
|
|
60995
|
+
case "page":
|
|
60996
|
+
return "page";
|
|
60997
|
+
case "margin":
|
|
60998
|
+
return "margin";
|
|
60999
|
+
case "text":
|
|
61000
|
+
default:
|
|
61001
|
+
return "column";
|
|
61002
|
+
}
|
|
61003
|
+
};
|
|
61004
|
+
const mapVertAnchor = (val) => {
|
|
61005
|
+
switch (val) {
|
|
61006
|
+
case "page":
|
|
61007
|
+
return "page";
|
|
61008
|
+
case "margin":
|
|
61009
|
+
return "margin";
|
|
61010
|
+
case "text":
|
|
61011
|
+
default:
|
|
61012
|
+
return "paragraph";
|
|
61013
|
+
}
|
|
61014
|
+
};
|
|
61015
|
+
const anchor = {
|
|
61016
|
+
isAnchored: true,
|
|
61017
|
+
hRelativeFrom: mapHorzAnchor(floatingProps.horzAnchor),
|
|
61018
|
+
vRelativeFrom: mapVertAnchor(floatingProps.vertAnchor)
|
|
61019
|
+
};
|
|
61020
|
+
if (floatingProps.tblpXSpec) {
|
|
61021
|
+
anchor.alignH = floatingProps.tblpXSpec;
|
|
61022
|
+
}
|
|
61023
|
+
if (floatingProps.tblpYSpec) {
|
|
61024
|
+
anchor.alignV = floatingProps.tblpYSpec;
|
|
61025
|
+
}
|
|
61026
|
+
if (floatingProps.tblpX !== void 0) {
|
|
61027
|
+
anchor.offsetH = twipsToPx$1(floatingProps.tblpX);
|
|
61028
|
+
}
|
|
61029
|
+
if (floatingProps.tblpY !== void 0) {
|
|
61030
|
+
anchor.offsetV = twipsToPx$1(floatingProps.tblpY);
|
|
61031
|
+
}
|
|
61032
|
+
const hasDistances = floatingProps.leftFromText !== void 0 || floatingProps.rightFromText !== void 0 || floatingProps.topFromText !== void 0 || floatingProps.bottomFromText !== void 0;
|
|
61033
|
+
const wrap2 = {
|
|
61034
|
+
type: "Square",
|
|
61035
|
+
// Floating tables with text distances use square wrapping
|
|
61036
|
+
wrapText: "bothSides"
|
|
61037
|
+
// Default to text on both sides
|
|
61038
|
+
};
|
|
61039
|
+
if (hasDistances) {
|
|
61040
|
+
if (floatingProps.topFromText !== void 0) {
|
|
61041
|
+
wrap2.distTop = twipsToPx$1(floatingProps.topFromText);
|
|
61042
|
+
}
|
|
61043
|
+
if (floatingProps.bottomFromText !== void 0) {
|
|
61044
|
+
wrap2.distBottom = twipsToPx$1(floatingProps.bottomFromText);
|
|
61045
|
+
}
|
|
61046
|
+
if (floatingProps.leftFromText !== void 0) {
|
|
61047
|
+
wrap2.distLeft = twipsToPx$1(floatingProps.leftFromText);
|
|
61048
|
+
}
|
|
61049
|
+
if (floatingProps.rightFromText !== void 0) {
|
|
61050
|
+
wrap2.distRight = twipsToPx$1(floatingProps.rightFromText);
|
|
61051
|
+
}
|
|
61052
|
+
}
|
|
61053
|
+
return { anchor, wrap: wrap2 };
|
|
61054
|
+
}
|
|
60517
61055
|
function tableNodeToBlock$1(node, nextBlockId, positions, defaultFont, defaultSize, _styleContext, trackedChanges, bookmarks, hyperlinkConfig, themeColors, paragraphToFlowBlocks2, converterContext) {
|
|
60518
61056
|
if (!Array.isArray(node.content) || node.content.length === 0) return null;
|
|
60519
61057
|
if (!paragraphToFlowBlocks2) return null;
|
|
@@ -60578,6 +61116,10 @@ function tableNodeToBlock$1(node, nextBlockId, positions, defaultFont, defaultSi
|
|
|
60578
61116
|
if (tableLayout) {
|
|
60579
61117
|
tableAttrs.tableLayout = tableLayout;
|
|
60580
61118
|
}
|
|
61119
|
+
const tableProperties = node.attrs?.tableProperties;
|
|
61120
|
+
if (tableProperties && typeof tableProperties === "object") {
|
|
61121
|
+
tableAttrs.tableProperties = tableProperties;
|
|
61122
|
+
}
|
|
60581
61123
|
let columnWidths = void 0;
|
|
60582
61124
|
const twipsToPixels2 = (twips) => {
|
|
60583
61125
|
const PIXELS_PER_INCH2 = 96;
|
|
@@ -60621,12 +61163,15 @@ function tableNodeToBlock$1(node, nextBlockId, positions, defaultFont, defaultSi
|
|
|
60621
61163
|
columnWidths = void 0;
|
|
60622
61164
|
}
|
|
60623
61165
|
}
|
|
61166
|
+
const { anchor, wrap: wrap2 } = extractFloatingTableAnchorWrap(node);
|
|
60624
61167
|
const tableBlock = {
|
|
60625
61168
|
kind: "table",
|
|
60626
61169
|
id: nextBlockId("table"),
|
|
60627
61170
|
rows,
|
|
60628
61171
|
attrs: Object.keys(tableAttrs).length > 0 ? tableAttrs : void 0,
|
|
60629
|
-
columnWidths
|
|
61172
|
+
columnWidths,
|
|
61173
|
+
...anchor ? { anchor } : {},
|
|
61174
|
+
...wrap2 ? { wrap: wrap2 } : {}
|
|
60630
61175
|
};
|
|
60631
61176
|
return tableBlock;
|
|
60632
61177
|
}
|
|
@@ -60962,7 +61507,7 @@ function getMeasurementContext() {
|
|
|
60962
61507
|
return measurementCtx;
|
|
60963
61508
|
}
|
|
60964
61509
|
function getRunFontString(run2) {
|
|
60965
|
-
if (run2.kind === "tab" || run2.kind === "lineBreak" || "src" in run2) {
|
|
61510
|
+
if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || "src" in run2) {
|
|
60966
61511
|
return "normal normal 16px Arial";
|
|
60967
61512
|
}
|
|
60968
61513
|
const style2 = run2.italic ? "italic" : "normal";
|
|
@@ -60989,6 +61534,10 @@ function sliceRunsForLine$1(block, line) {
|
|
|
60989
61534
|
result.push(run2);
|
|
60990
61535
|
continue;
|
|
60991
61536
|
}
|
|
61537
|
+
if (run2.kind === "break") {
|
|
61538
|
+
result.push(run2);
|
|
61539
|
+
continue;
|
|
61540
|
+
}
|
|
60992
61541
|
const text = run2.text ?? "";
|
|
60993
61542
|
const isFirstRun = runIndex === line.fromRun;
|
|
60994
61543
|
const isLastRun = runIndex === line.toRun;
|
|
@@ -61022,7 +61571,7 @@ function measureCharacterX(block, line, charOffset) {
|
|
|
61022
61571
|
1,
|
|
61023
61572
|
runs2.reduce((sum, run2) => {
|
|
61024
61573
|
if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
|
|
61025
|
-
if ("src" in run2 || run2.kind === "lineBreak") return sum;
|
|
61574
|
+
if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") return sum;
|
|
61026
61575
|
return sum + (run2.text ?? "").length;
|
|
61027
61576
|
}, 0)
|
|
61028
61577
|
);
|
|
@@ -61043,7 +61592,7 @@ function measureCharacterX(block, line, charOffset) {
|
|
|
61043
61592
|
currentCharOffset += runLength2;
|
|
61044
61593
|
continue;
|
|
61045
61594
|
}
|
|
61046
|
-
const text = "src" in run2 || run2.kind === "lineBreak" ? "" : run2.text ?? "";
|
|
61595
|
+
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
|
|
61047
61596
|
const runLength = text.length;
|
|
61048
61597
|
if (currentCharOffset + runLength >= charOffset) {
|
|
61049
61598
|
const offsetInRun = charOffset - currentCharOffset;
|
|
@@ -61086,7 +61635,7 @@ function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
|
|
|
61086
61635
|
if (isTabRun$1(run2)) {
|
|
61087
61636
|
return segmentBaseX + (offsetInSegment > 0 ? segment.width ?? 0 : 0);
|
|
61088
61637
|
}
|
|
61089
|
-
if ("src" in run2 || run2.kind === "lineBreak") {
|
|
61638
|
+
if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") {
|
|
61090
61639
|
return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
|
|
61091
61640
|
}
|
|
61092
61641
|
const text = run2.text ?? "";
|
|
@@ -61109,7 +61658,7 @@ function findCharacterAtX(block, line, x2, pmStart) {
|
|
|
61109
61658
|
1,
|
|
61110
61659
|
runs2.reduce((sum, run2) => {
|
|
61111
61660
|
if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
|
|
61112
|
-
if ("src" in run2 || run2.kind === "lineBreak") return sum;
|
|
61661
|
+
if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") return sum;
|
|
61113
61662
|
return sum + (run2.text ?? "").length;
|
|
61114
61663
|
}, 0)
|
|
61115
61664
|
);
|
|
@@ -61144,7 +61693,7 @@ function findCharacterAtX(block, line, x2, pmStart) {
|
|
|
61144
61693
|
currentCharOffset += TAB_CHAR_LENGTH;
|
|
61145
61694
|
continue;
|
|
61146
61695
|
}
|
|
61147
|
-
const text = "src" in run2 || run2.kind === "lineBreak" ? "" : run2.text ?? "";
|
|
61696
|
+
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
|
|
61148
61697
|
const runLength = text.length;
|
|
61149
61698
|
if (runLength === 0) continue;
|
|
61150
61699
|
ctx2.font = getRunFontString(run2);
|
|
@@ -61577,6 +62126,40 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
61577
62126
|
};
|
|
61578
62127
|
zones.push(zone);
|
|
61579
62128
|
},
|
|
62129
|
+
registerTable(tableBlock, measure, anchorY, columnIndex, pageNumber) {
|
|
62130
|
+
if (!tableBlock.anchor?.isAnchored) {
|
|
62131
|
+
return;
|
|
62132
|
+
}
|
|
62133
|
+
const { wrap: wrap2, anchor } = tableBlock;
|
|
62134
|
+
const wrapType = wrap2?.type ?? "None";
|
|
62135
|
+
if (wrapType === "None") {
|
|
62136
|
+
return;
|
|
62137
|
+
}
|
|
62138
|
+
const tableWidth = measure.totalWidth ?? 0;
|
|
62139
|
+
const tableHeight = measure.totalHeight ?? 0;
|
|
62140
|
+
const x2 = computeTableAnchorX(anchor, columnIndex, columns, tableWidth, margins, pageWidth);
|
|
62141
|
+
const y2 = anchorY + (anchor.offsetV ?? 0);
|
|
62142
|
+
const zone = {
|
|
62143
|
+
imageBlockId: tableBlock.id,
|
|
62144
|
+
// Reusing imageBlockId field for table id
|
|
62145
|
+
pageNumber,
|
|
62146
|
+
columnIndex,
|
|
62147
|
+
bounds: {
|
|
62148
|
+
x: x2,
|
|
62149
|
+
y: y2,
|
|
62150
|
+
width: tableWidth,
|
|
62151
|
+
height: tableHeight
|
|
62152
|
+
},
|
|
62153
|
+
distances: {
|
|
62154
|
+
top: wrap2?.distTop ?? 0,
|
|
62155
|
+
bottom: wrap2?.distBottom ?? 0,
|
|
62156
|
+
left: wrap2?.distLeft ?? 0,
|
|
62157
|
+
right: wrap2?.distRight ?? 0
|
|
62158
|
+
},
|
|
62159
|
+
wrapMode: computeTableWrapMode(wrap2)
|
|
62160
|
+
};
|
|
62161
|
+
zones.push(zone);
|
|
62162
|
+
},
|
|
61580
62163
|
getExclusionsForLine(lineY, lineHeight2, columnIndex, pageNumber) {
|
|
61581
62164
|
const result = zones.filter((zone) => {
|
|
61582
62165
|
if (zone.pageNumber !== pageNumber || zone.columnIndex !== columnIndex) {
|
|
@@ -61684,6 +62267,49 @@ function computeWrapMode(wrap2, _anchor) {
|
|
|
61684
62267
|
if (wrapText === "largest") return "largest";
|
|
61685
62268
|
return "both";
|
|
61686
62269
|
}
|
|
62270
|
+
function computeTableAnchorX(anchor, columnIndex, columns, tableWidth, margins, pageWidth) {
|
|
62271
|
+
const alignH = anchor.alignH ?? "left";
|
|
62272
|
+
const offsetH = anchor.offsetH ?? 0;
|
|
62273
|
+
const marginLeft = Math.max(0, margins?.left ?? 0);
|
|
62274
|
+
const marginRight = Math.max(0, margins?.right ?? 0);
|
|
62275
|
+
const contentWidth = pageWidth != null ? Math.max(1, pageWidth - (marginLeft + marginRight)) : columns.width;
|
|
62276
|
+
const contentLeft = marginLeft;
|
|
62277
|
+
const columnLeft = contentLeft + columnIndex * (columns.width + columns.gap);
|
|
62278
|
+
const relativeFrom = anchor.hRelativeFrom ?? "column";
|
|
62279
|
+
let baseX;
|
|
62280
|
+
let availableWidth;
|
|
62281
|
+
if (relativeFrom === "page") {
|
|
62282
|
+
if (columns.count === 1) {
|
|
62283
|
+
baseX = contentLeft;
|
|
62284
|
+
availableWidth = contentWidth;
|
|
62285
|
+
} else {
|
|
62286
|
+
baseX = 0;
|
|
62287
|
+
availableWidth = pageWidth != null ? pageWidth : contentWidth;
|
|
62288
|
+
}
|
|
62289
|
+
} else if (relativeFrom === "margin") {
|
|
62290
|
+
baseX = contentLeft;
|
|
62291
|
+
availableWidth = contentWidth;
|
|
62292
|
+
} else {
|
|
62293
|
+
baseX = columnLeft;
|
|
62294
|
+
availableWidth = columns.width;
|
|
62295
|
+
}
|
|
62296
|
+
let effectiveAlignH = alignH;
|
|
62297
|
+
if (alignH === "inside") effectiveAlignH = "left";
|
|
62298
|
+
if (alignH === "outside") effectiveAlignH = "right";
|
|
62299
|
+
const result = effectiveAlignH === "left" ? baseX + offsetH : effectiveAlignH === "right" ? baseX + availableWidth - tableWidth - offsetH : effectiveAlignH === "center" ? baseX + (availableWidth - tableWidth) / 2 + offsetH : baseX;
|
|
62300
|
+
return result;
|
|
62301
|
+
}
|
|
62302
|
+
function computeTableWrapMode(wrap2) {
|
|
62303
|
+
if (!wrap2) return "none";
|
|
62304
|
+
if (wrap2.type === "None") {
|
|
62305
|
+
return "none";
|
|
62306
|
+
}
|
|
62307
|
+
const wrapText = wrap2.wrapText ?? "bothSides";
|
|
62308
|
+
if (wrapText === "left") return "right";
|
|
62309
|
+
if (wrapText === "right") return "left";
|
|
62310
|
+
if (wrapText === "largest") return "largest";
|
|
62311
|
+
return "both";
|
|
62312
|
+
}
|
|
61687
62313
|
function computeNextSectionPropsAtBreak(blocks) {
|
|
61688
62314
|
const nextSectionPropsAtBreak = /* @__PURE__ */ new Map();
|
|
61689
62315
|
const docxBreakIndexes = [];
|
|
@@ -62102,6 +62728,9 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
62102
62728
|
};
|
|
62103
62729
|
if (measure.marker) {
|
|
62104
62730
|
fragment.markerWidth = measure.marker.markerWidth;
|
|
62731
|
+
if (measure.marker.markerTextWidth != null) {
|
|
62732
|
+
fragment.markerTextWidth = measure.marker.markerTextWidth;
|
|
62733
|
+
}
|
|
62105
62734
|
}
|
|
62106
62735
|
state2.page.fragments.push(fragment);
|
|
62107
62736
|
state2.trailingSpacing = 0;
|
|
@@ -62203,6 +62832,12 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
62203
62832
|
};
|
|
62204
62833
|
if (measure.marker && fromLine === 0) {
|
|
62205
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
|
+
}
|
|
62206
62841
|
}
|
|
62207
62842
|
if (fromLine > 0) fragment.continuesFromPrev = true;
|
|
62208
62843
|
if (slice2.toLine < lines.length) fragment.continuesOnNext = true;
|
|
@@ -62380,6 +63015,206 @@ function generateColumnBoundaries(measure) {
|
|
|
62380
63015
|
}
|
|
62381
63016
|
return boundaries;
|
|
62382
63017
|
}
|
|
63018
|
+
function countHeaderRows(block) {
|
|
63019
|
+
let count = 0;
|
|
63020
|
+
for (let i = 0; i < block.rows.length; i++) {
|
|
63021
|
+
const row = block.rows[i];
|
|
63022
|
+
const repeatHeader = row.attrs?.tableRowProperties?.repeatHeader;
|
|
63023
|
+
if (repeatHeader === true) {
|
|
63024
|
+
count++;
|
|
63025
|
+
} else {
|
|
63026
|
+
break;
|
|
63027
|
+
}
|
|
63028
|
+
}
|
|
63029
|
+
return count;
|
|
63030
|
+
}
|
|
63031
|
+
function sumRowHeights(rows, fromRow, toRow) {
|
|
63032
|
+
let total = 0;
|
|
63033
|
+
for (let i = fromRow; i < toRow && i < rows.length; i++) {
|
|
63034
|
+
total += rows[i].height;
|
|
63035
|
+
}
|
|
63036
|
+
return total;
|
|
63037
|
+
}
|
|
63038
|
+
function calculateFragmentHeight(fragment, measure, _headerCount) {
|
|
63039
|
+
let height = 0;
|
|
63040
|
+
if (fragment.repeatHeaderCount && fragment.repeatHeaderCount > 0) {
|
|
63041
|
+
height += sumRowHeights(measure.rows, 0, fragment.repeatHeaderCount);
|
|
63042
|
+
}
|
|
63043
|
+
height += sumRowHeights(measure.rows, fragment.fromRow, fragment.toRow);
|
|
63044
|
+
return height;
|
|
63045
|
+
}
|
|
63046
|
+
const MIN_PARTIAL_ROW_HEIGHT = 20;
|
|
63047
|
+
function getCellLines(cell) {
|
|
63048
|
+
if (cell.blocks && cell.blocks.length > 0) {
|
|
63049
|
+
const allLines = [];
|
|
63050
|
+
for (const block of cell.blocks) {
|
|
63051
|
+
if (block.kind === "paragraph") {
|
|
63052
|
+
if (block.kind === "paragraph" && "lines" in block) {
|
|
63053
|
+
const paraBlock = block;
|
|
63054
|
+
if (paraBlock.lines) {
|
|
63055
|
+
allLines.push(...paraBlock.lines);
|
|
63056
|
+
}
|
|
63057
|
+
}
|
|
63058
|
+
}
|
|
63059
|
+
}
|
|
63060
|
+
return allLines;
|
|
63061
|
+
}
|
|
63062
|
+
if (cell.paragraph?.lines) {
|
|
63063
|
+
return cell.paragraph.lines;
|
|
63064
|
+
}
|
|
63065
|
+
return [];
|
|
63066
|
+
}
|
|
63067
|
+
function getCellPadding(cellIdx, blockRow) {
|
|
63068
|
+
const padding = blockRow?.cells?.[cellIdx]?.attrs?.padding ?? {};
|
|
63069
|
+
return {
|
|
63070
|
+
top: padding.top ?? 2,
|
|
63071
|
+
bottom: padding.bottom ?? 2,
|
|
63072
|
+
left: padding.left ?? 4,
|
|
63073
|
+
right: padding.right ?? 4
|
|
63074
|
+
};
|
|
63075
|
+
}
|
|
63076
|
+
function getCellTotalLines(cell) {
|
|
63077
|
+
return getCellLines(cell).length;
|
|
63078
|
+
}
|
|
63079
|
+
function computePartialRow(rowIndex, blockRow, measure, availableHeight, fromLineByCell) {
|
|
63080
|
+
const row = measure.rows[rowIndex];
|
|
63081
|
+
if (!row) {
|
|
63082
|
+
throw new Error(`Invalid rowIndex ${rowIndex}: measure.rows has ${measure.rows.length} rows`);
|
|
63083
|
+
}
|
|
63084
|
+
const cellCount = row.cells.length;
|
|
63085
|
+
const startLines = fromLineByCell || new Array(cellCount).fill(0);
|
|
63086
|
+
const toLineByCell = [];
|
|
63087
|
+
const heightByCell = [];
|
|
63088
|
+
const cellPaddings = row.cells.map((_2, idx) => getCellPadding(idx, blockRow));
|
|
63089
|
+
for (let cellIdx = 0; cellIdx < cellCount; cellIdx++) {
|
|
63090
|
+
const cell = row.cells[cellIdx];
|
|
63091
|
+
const startLine = startLines[cellIdx] || 0;
|
|
63092
|
+
const cellPadding = cellPaddings[cellIdx];
|
|
63093
|
+
const availableForLines = Math.max(0, availableHeight - (cellPadding.top + cellPadding.bottom));
|
|
63094
|
+
const lines = getCellLines(cell);
|
|
63095
|
+
let cumulativeHeight = 0;
|
|
63096
|
+
let cutLine = startLine;
|
|
63097
|
+
for (let i = startLine; i < lines.length; i++) {
|
|
63098
|
+
const lineHeight2 = lines[i].lineHeight || 0;
|
|
63099
|
+
if (cumulativeHeight + lineHeight2 > availableForLines) {
|
|
63100
|
+
break;
|
|
63101
|
+
}
|
|
63102
|
+
cumulativeHeight += lineHeight2;
|
|
63103
|
+
cutLine = i + 1;
|
|
63104
|
+
}
|
|
63105
|
+
toLineByCell.push(cutLine);
|
|
63106
|
+
heightByCell.push(cumulativeHeight);
|
|
63107
|
+
}
|
|
63108
|
+
const positiveHeights = heightByCell.filter((h2) => h2 > 0);
|
|
63109
|
+
const minHeight = positiveHeights.length > 0 ? Math.min(...positiveHeights) : 0;
|
|
63110
|
+
let actualPartialHeight = 0;
|
|
63111
|
+
let maxPaddingTotal = 0;
|
|
63112
|
+
for (let cellIdx = 0; cellIdx < cellCount; cellIdx++) {
|
|
63113
|
+
const cell = row.cells[cellIdx];
|
|
63114
|
+
const startLine = startLines[cellIdx] || 0;
|
|
63115
|
+
const lines = getCellLines(cell);
|
|
63116
|
+
const cellPadding = cellPaddings[cellIdx];
|
|
63117
|
+
const paddingTotal = cellPadding.top + cellPadding.bottom;
|
|
63118
|
+
maxPaddingTotal = Math.max(maxPaddingTotal, paddingTotal);
|
|
63119
|
+
let cumulativeHeight = 0;
|
|
63120
|
+
let cutLine = startLine;
|
|
63121
|
+
for (let i = startLine; i < lines.length; i++) {
|
|
63122
|
+
const lineHeight2 = lines[i].lineHeight || 0;
|
|
63123
|
+
if (cumulativeHeight + lineHeight2 > minHeight) {
|
|
63124
|
+
break;
|
|
63125
|
+
}
|
|
63126
|
+
cumulativeHeight += lineHeight2;
|
|
63127
|
+
cutLine = i + 1;
|
|
63128
|
+
}
|
|
63129
|
+
toLineByCell[cellIdx] = cutLine;
|
|
63130
|
+
actualPartialHeight = Math.max(actualPartialHeight, cumulativeHeight + paddingTotal);
|
|
63131
|
+
}
|
|
63132
|
+
const madeProgress = toLineByCell.some((cutLine, idx) => cutLine > (startLines[idx] || 0));
|
|
63133
|
+
const isFirstPart = startLines.every((l3) => l3 === 0);
|
|
63134
|
+
const allCellsExhausted = toLineByCell.every((cutLine, idx) => {
|
|
63135
|
+
const totalLines = getCellTotalLines(row.cells[idx]);
|
|
63136
|
+
return cutLine >= totalLines;
|
|
63137
|
+
});
|
|
63138
|
+
const isLastPart = allCellsExhausted || !madeProgress;
|
|
63139
|
+
if (actualPartialHeight === 0 && isFirstPart) {
|
|
63140
|
+
actualPartialHeight = maxPaddingTotal;
|
|
63141
|
+
}
|
|
63142
|
+
return {
|
|
63143
|
+
rowIndex,
|
|
63144
|
+
fromLineByCell: startLines,
|
|
63145
|
+
toLineByCell,
|
|
63146
|
+
isFirstPart,
|
|
63147
|
+
isLastPart,
|
|
63148
|
+
partialHeight: actualPartialHeight
|
|
63149
|
+
};
|
|
63150
|
+
}
|
|
63151
|
+
function findSplitPoint(block, measure, startRow, availableHeight, fullPageHeight, _pendingPartialRow) {
|
|
63152
|
+
let accumulatedHeight = 0;
|
|
63153
|
+
let lastFitRow = startRow;
|
|
63154
|
+
for (let i = startRow; i < block.rows.length; i++) {
|
|
63155
|
+
const row = block.rows[i];
|
|
63156
|
+
const rowHeight = measure.rows[i]?.height || 0;
|
|
63157
|
+
const cantSplit = row.attrs?.tableRowProperties?.cantSplit === true;
|
|
63158
|
+
if (accumulatedHeight + rowHeight <= availableHeight) {
|
|
63159
|
+
accumulatedHeight += rowHeight;
|
|
63160
|
+
lastFitRow = i + 1;
|
|
63161
|
+
} else {
|
|
63162
|
+
const remainingHeight = availableHeight - accumulatedHeight;
|
|
63163
|
+
if (fullPageHeight && rowHeight > fullPageHeight) {
|
|
63164
|
+
const partialRow = computePartialRow(i, block.rows[i], measure, remainingHeight);
|
|
63165
|
+
return { endRow: i + 1, partialRow };
|
|
63166
|
+
}
|
|
63167
|
+
if (cantSplit) {
|
|
63168
|
+
if (lastFitRow === startRow) {
|
|
63169
|
+
return { endRow: startRow, partialRow: null };
|
|
63170
|
+
}
|
|
63171
|
+
return { endRow: lastFitRow, partialRow: null };
|
|
63172
|
+
}
|
|
63173
|
+
if (remainingHeight >= MIN_PARTIAL_ROW_HEIGHT) {
|
|
63174
|
+
const partialRow = computePartialRow(i, block.rows[i], measure, remainingHeight);
|
|
63175
|
+
const hasContent = partialRow.toLineByCell.some(
|
|
63176
|
+
(cutLine, idx) => cutLine > (partialRow.fromLineByCell[idx] || 0)
|
|
63177
|
+
);
|
|
63178
|
+
if (hasContent) {
|
|
63179
|
+
return { endRow: i + 1, partialRow };
|
|
63180
|
+
}
|
|
63181
|
+
}
|
|
63182
|
+
return { endRow: lastFitRow, partialRow: null };
|
|
63183
|
+
}
|
|
63184
|
+
}
|
|
63185
|
+
return { endRow: block.rows.length, partialRow: null };
|
|
63186
|
+
}
|
|
63187
|
+
function generateFragmentMetadata(measure, _fromRow, _toRow, _repeatHeaderCount) {
|
|
63188
|
+
return {
|
|
63189
|
+
columnBoundaries: generateColumnBoundaries(measure),
|
|
63190
|
+
coordinateSystem: "fragment"
|
|
63191
|
+
};
|
|
63192
|
+
}
|
|
63193
|
+
function layoutMonolithicTable(context) {
|
|
63194
|
+
let state2 = context.ensurePage();
|
|
63195
|
+
if (state2.cursorY + context.measure.totalHeight > state2.contentBottom && state2.page.fragments.length > 0) {
|
|
63196
|
+
state2 = context.advanceColumn(state2);
|
|
63197
|
+
}
|
|
63198
|
+
state2 = context.ensurePage();
|
|
63199
|
+
const height = Math.min(context.measure.totalHeight, state2.contentBottom - state2.cursorY);
|
|
63200
|
+
const metadata = {
|
|
63201
|
+
columnBoundaries: generateColumnBoundaries(context.measure),
|
|
63202
|
+
coordinateSystem: "fragment"
|
|
63203
|
+
};
|
|
63204
|
+
const fragment = {
|
|
63205
|
+
kind: "table",
|
|
63206
|
+
blockId: context.block.id,
|
|
63207
|
+
fromRow: 0,
|
|
63208
|
+
toRow: context.block.rows.length,
|
|
63209
|
+
x: context.columnX(state2.columnIndex),
|
|
63210
|
+
y: state2.cursorY,
|
|
63211
|
+
width: Math.min(context.columnWidth, context.measure.totalWidth || context.columnWidth),
|
|
63212
|
+
height,
|
|
63213
|
+
metadata
|
|
63214
|
+
};
|
|
63215
|
+
state2.page.fragments.push(fragment);
|
|
63216
|
+
state2.cursorY += height;
|
|
63217
|
+
}
|
|
62383
63218
|
function layoutTableBlock({
|
|
62384
63219
|
block,
|
|
62385
63220
|
measure,
|
|
@@ -62388,30 +63223,176 @@ function layoutTableBlock({
|
|
|
62388
63223
|
advanceColumn,
|
|
62389
63224
|
columnX
|
|
62390
63225
|
}) {
|
|
63226
|
+
if (block.anchor?.isAnchored) {
|
|
63227
|
+
return;
|
|
63228
|
+
}
|
|
63229
|
+
const tableProps = block.attrs?.tableProperties;
|
|
63230
|
+
const floatingProps = tableProps?.floatingTableProperties;
|
|
63231
|
+
if (floatingProps && Object.keys(floatingProps).length > 0) {
|
|
63232
|
+
layoutMonolithicTable({ block, measure, columnWidth, ensurePage, advanceColumn, columnX });
|
|
63233
|
+
return;
|
|
63234
|
+
}
|
|
63235
|
+
const headerCount = countHeaderRows(block);
|
|
63236
|
+
const headerHeight = headerCount > 0 ? sumRowHeights(measure.rows, 0, headerCount) : 0;
|
|
62391
63237
|
let state2 = ensurePage();
|
|
62392
|
-
|
|
62393
|
-
|
|
63238
|
+
let currentRow = 0;
|
|
63239
|
+
let isTableContinuation = false;
|
|
63240
|
+
let pendingPartialRow = null;
|
|
63241
|
+
while (currentRow < block.rows.length || pendingPartialRow !== null) {
|
|
63242
|
+
state2 = ensurePage();
|
|
63243
|
+
const availableHeight = state2.contentBottom - state2.cursorY;
|
|
63244
|
+
let repeatHeaderCount = 0;
|
|
63245
|
+
if (currentRow === 0 && !pendingPartialRow) {
|
|
63246
|
+
repeatHeaderCount = 0;
|
|
63247
|
+
} else {
|
|
63248
|
+
if (headerCount > 0 && headerHeight <= availableHeight) {
|
|
63249
|
+
repeatHeaderCount = headerCount;
|
|
63250
|
+
} else if (headerCount > 0 && headerHeight > availableHeight) {
|
|
63251
|
+
repeatHeaderCount = 0;
|
|
63252
|
+
}
|
|
63253
|
+
}
|
|
63254
|
+
const availableForBody = repeatHeaderCount > 0 ? availableHeight - headerHeight : availableHeight;
|
|
63255
|
+
const fullPageHeight = state2.contentBottom;
|
|
63256
|
+
if (pendingPartialRow !== null) {
|
|
63257
|
+
const rowIndex = pendingPartialRow.rowIndex;
|
|
63258
|
+
const fromLineByCell = pendingPartialRow.toLineByCell;
|
|
63259
|
+
const continuationPartialRow = computePartialRow(
|
|
63260
|
+
rowIndex,
|
|
63261
|
+
block.rows[rowIndex],
|
|
63262
|
+
measure,
|
|
63263
|
+
availableForBody,
|
|
63264
|
+
fromLineByCell
|
|
63265
|
+
);
|
|
63266
|
+
const madeProgress = continuationPartialRow.toLineByCell.some(
|
|
63267
|
+
(toLine, idx) => toLine > (fromLineByCell[idx] || 0)
|
|
63268
|
+
);
|
|
63269
|
+
const hasRemainingLinesAfterContinuation = continuationPartialRow.toLineByCell.some(
|
|
63270
|
+
(toLine, idx) => {
|
|
63271
|
+
const totalLines = getCellTotalLines(measure.rows[rowIndex].cells[idx]);
|
|
63272
|
+
return toLine < totalLines;
|
|
63273
|
+
}
|
|
63274
|
+
);
|
|
63275
|
+
const hadRemainingLinesBefore = fromLineByCell.some((fromLine, idx) => {
|
|
63276
|
+
const totalLines = getCellTotalLines(measure.rows[rowIndex].cells[idx]);
|
|
63277
|
+
return fromLine < totalLines;
|
|
63278
|
+
});
|
|
63279
|
+
const fragmentHeight2 = continuationPartialRow.partialHeight + (repeatHeaderCount > 0 ? headerHeight : 0);
|
|
63280
|
+
if (fragmentHeight2 > 0) {
|
|
63281
|
+
const fragment2 = {
|
|
63282
|
+
kind: "table",
|
|
63283
|
+
blockId: block.id,
|
|
63284
|
+
fromRow: rowIndex,
|
|
63285
|
+
toRow: rowIndex + 1,
|
|
63286
|
+
x: columnX(state2.columnIndex),
|
|
63287
|
+
y: state2.cursorY,
|
|
63288
|
+
width: Math.min(columnWidth, measure.totalWidth || columnWidth),
|
|
63289
|
+
height: fragmentHeight2,
|
|
63290
|
+
continuesFromPrev: true,
|
|
63291
|
+
continuesOnNext: hasRemainingLinesAfterContinuation || rowIndex + 1 < block.rows.length,
|
|
63292
|
+
repeatHeaderCount,
|
|
63293
|
+
partialRow: continuationPartialRow,
|
|
63294
|
+
metadata: generateFragmentMetadata(measure)
|
|
63295
|
+
};
|
|
63296
|
+
state2.page.fragments.push(fragment2);
|
|
63297
|
+
state2.cursorY += fragmentHeight2;
|
|
63298
|
+
}
|
|
63299
|
+
const rowComplete = !hasRemainingLinesAfterContinuation;
|
|
63300
|
+
if (rowComplete) {
|
|
63301
|
+
currentRow = rowIndex + 1;
|
|
63302
|
+
pendingPartialRow = null;
|
|
63303
|
+
} else if (!madeProgress && hadRemainingLinesBefore) {
|
|
63304
|
+
state2 = advanceColumn(state2);
|
|
63305
|
+
} else {
|
|
63306
|
+
state2 = advanceColumn(state2);
|
|
63307
|
+
pendingPartialRow = continuationPartialRow;
|
|
63308
|
+
}
|
|
63309
|
+
isTableContinuation = true;
|
|
63310
|
+
continue;
|
|
63311
|
+
}
|
|
63312
|
+
const bodyStartRow = currentRow;
|
|
63313
|
+
const { endRow, partialRow } = findSplitPoint(block, measure, bodyStartRow, availableForBody, fullPageHeight);
|
|
63314
|
+
if (endRow === bodyStartRow && partialRow === null && state2.page.fragments.length > 0) {
|
|
63315
|
+
state2 = advanceColumn(state2);
|
|
63316
|
+
continue;
|
|
63317
|
+
}
|
|
63318
|
+
if (endRow === bodyStartRow && partialRow === null) {
|
|
63319
|
+
const forcedPartialRow = computePartialRow(bodyStartRow, block.rows[bodyStartRow], measure, availableForBody);
|
|
63320
|
+
const forcedEndRow = bodyStartRow + 1;
|
|
63321
|
+
const fragmentHeight2 = forcedPartialRow.partialHeight + (repeatHeaderCount > 0 ? headerHeight : 0);
|
|
63322
|
+
const fragment2 = {
|
|
63323
|
+
kind: "table",
|
|
63324
|
+
blockId: block.id,
|
|
63325
|
+
fromRow: bodyStartRow,
|
|
63326
|
+
toRow: forcedEndRow,
|
|
63327
|
+
x: columnX(state2.columnIndex),
|
|
63328
|
+
y: state2.cursorY,
|
|
63329
|
+
width: Math.min(columnWidth, measure.totalWidth || columnWidth),
|
|
63330
|
+
height: fragmentHeight2,
|
|
63331
|
+
continuesFromPrev: isTableContinuation,
|
|
63332
|
+
continuesOnNext: !forcedPartialRow.isLastPart || forcedEndRow < block.rows.length,
|
|
63333
|
+
repeatHeaderCount,
|
|
63334
|
+
partialRow: forcedPartialRow,
|
|
63335
|
+
metadata: generateFragmentMetadata(measure)
|
|
63336
|
+
};
|
|
63337
|
+
state2.page.fragments.push(fragment2);
|
|
63338
|
+
state2.cursorY += fragmentHeight2;
|
|
63339
|
+
pendingPartialRow = forcedPartialRow;
|
|
63340
|
+
isTableContinuation = true;
|
|
63341
|
+
continue;
|
|
63342
|
+
}
|
|
63343
|
+
let fragmentHeight;
|
|
63344
|
+
if (partialRow) {
|
|
63345
|
+
const fullRowsHeight = sumRowHeights(measure.rows, bodyStartRow, endRow - 1);
|
|
63346
|
+
fragmentHeight = fullRowsHeight + partialRow.partialHeight + (repeatHeaderCount > 0 ? headerHeight : 0);
|
|
63347
|
+
} else {
|
|
63348
|
+
fragmentHeight = calculateFragmentHeight(
|
|
63349
|
+
{ fromRow: bodyStartRow, toRow: endRow, repeatHeaderCount },
|
|
63350
|
+
measure
|
|
63351
|
+
);
|
|
63352
|
+
}
|
|
63353
|
+
const fragment = {
|
|
63354
|
+
kind: "table",
|
|
63355
|
+
blockId: block.id,
|
|
63356
|
+
fromRow: bodyStartRow,
|
|
63357
|
+
toRow: endRow,
|
|
63358
|
+
x: columnX(state2.columnIndex),
|
|
63359
|
+
y: state2.cursorY,
|
|
63360
|
+
width: Math.min(columnWidth, measure.totalWidth || columnWidth),
|
|
63361
|
+
height: fragmentHeight,
|
|
63362
|
+
continuesFromPrev: isTableContinuation,
|
|
63363
|
+
continuesOnNext: endRow < block.rows.length || (partialRow ? !partialRow.isLastPart : false),
|
|
63364
|
+
repeatHeaderCount,
|
|
63365
|
+
partialRow: partialRow || void 0,
|
|
63366
|
+
metadata: generateFragmentMetadata(measure)
|
|
63367
|
+
};
|
|
63368
|
+
state2.page.fragments.push(fragment);
|
|
63369
|
+
state2.cursorY += fragmentHeight;
|
|
63370
|
+
if (partialRow && !partialRow.isLastPart) {
|
|
63371
|
+
pendingPartialRow = partialRow;
|
|
63372
|
+
currentRow = partialRow.rowIndex;
|
|
63373
|
+
} else {
|
|
63374
|
+
currentRow = endRow;
|
|
63375
|
+
pendingPartialRow = null;
|
|
63376
|
+
}
|
|
63377
|
+
isTableContinuation = true;
|
|
62394
63378
|
}
|
|
62395
|
-
|
|
62396
|
-
|
|
63379
|
+
}
|
|
63380
|
+
function createAnchoredTableFragment(block, measure, x2, y2) {
|
|
62397
63381
|
const metadata = {
|
|
62398
63382
|
columnBoundaries: generateColumnBoundaries(measure),
|
|
62399
63383
|
coordinateSystem: "fragment"
|
|
62400
|
-
// rowBoundaries omitted - not needed for column resize, reduces DOM overhead
|
|
62401
63384
|
};
|
|
62402
|
-
|
|
63385
|
+
return {
|
|
62403
63386
|
kind: "table",
|
|
62404
63387
|
blockId: block.id,
|
|
62405
63388
|
fromRow: 0,
|
|
62406
63389
|
toRow: block.rows.length,
|
|
62407
|
-
x:
|
|
62408
|
-
y:
|
|
62409
|
-
width:
|
|
62410
|
-
height,
|
|
63390
|
+
x: x2,
|
|
63391
|
+
y: y2,
|
|
63392
|
+
width: measure.totalWidth ?? 0,
|
|
63393
|
+
height: measure.totalHeight ?? 0,
|
|
62411
63394
|
metadata
|
|
62412
63395
|
};
|
|
62413
|
-
state2.page.fragments.push(fragment);
|
|
62414
|
-
state2.cursorY += height;
|
|
62415
63396
|
}
|
|
62416
63397
|
function isPageRelativeAnchor(block) {
|
|
62417
63398
|
const vRelativeFrom = block.anchor?.vRelativeFrom;
|
|
@@ -62438,9 +63419,6 @@ function collectPreRegisteredAnchors(blocks, measures) {
|
|
|
62438
63419
|
function collectAnchoredDrawings(blocks, measures) {
|
|
62439
63420
|
const map22 = /* @__PURE__ */ new Map();
|
|
62440
63421
|
const len = Math.min(blocks.length, measures.length);
|
|
62441
|
-
for (let i = 0; i < len; i += 1) {
|
|
62442
|
-
if (blocks[i].kind === "paragraph") ;
|
|
62443
|
-
}
|
|
62444
63422
|
const nearestPrevParagraph = (fromIndex) => {
|
|
62445
63423
|
for (let i = fromIndex - 1; i >= 0; i -= 1) {
|
|
62446
63424
|
if (blocks[i].kind === "paragraph") return i;
|
|
@@ -62476,6 +63454,36 @@ function collectAnchoredDrawings(blocks, measures) {
|
|
|
62476
63454
|
}
|
|
62477
63455
|
return map22;
|
|
62478
63456
|
}
|
|
63457
|
+
function collectAnchoredTables(blocks, measures) {
|
|
63458
|
+
const map22 = /* @__PURE__ */ new Map();
|
|
63459
|
+
const nearestPrevParagraph = (fromIndex) => {
|
|
63460
|
+
for (let i = fromIndex - 1; i >= 0; i -= 1) {
|
|
63461
|
+
if (blocks[i].kind === "paragraph") return i;
|
|
63462
|
+
}
|
|
63463
|
+
return null;
|
|
63464
|
+
};
|
|
63465
|
+
const nearestNextParagraph = (fromIndex) => {
|
|
63466
|
+
for (let i = fromIndex + 1; i < blocks.length; i += 1) {
|
|
63467
|
+
if (blocks[i].kind === "paragraph") return i;
|
|
63468
|
+
}
|
|
63469
|
+
return null;
|
|
63470
|
+
};
|
|
63471
|
+
for (let i = 0; i < blocks.length; i += 1) {
|
|
63472
|
+
const block = blocks[i];
|
|
63473
|
+
const measure = measures[i];
|
|
63474
|
+
if (block.kind !== "table" || measure?.kind !== "table") continue;
|
|
63475
|
+
const tableBlock = block;
|
|
63476
|
+
const tableMeasure = measure;
|
|
63477
|
+
if (!tableBlock.anchor?.isAnchored) continue;
|
|
63478
|
+
let anchorParaIndex = nearestPrevParagraph(i);
|
|
63479
|
+
if (anchorParaIndex == null) anchorParaIndex = nearestNextParagraph(i);
|
|
63480
|
+
if (anchorParaIndex == null) continue;
|
|
63481
|
+
const list = map22.get(anchorParaIndex) ?? [];
|
|
63482
|
+
list.push({ block: tableBlock, measure: tableMeasure });
|
|
63483
|
+
map22.set(anchorParaIndex, list);
|
|
63484
|
+
}
|
|
63485
|
+
return map22;
|
|
63486
|
+
}
|
|
62479
63487
|
function createPaginator(opts) {
|
|
62480
63488
|
const states = [];
|
|
62481
63489
|
const pages = [];
|
|
@@ -63061,7 +64069,9 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
63061
64069
|
cachedColumnsState.state = null;
|
|
63062
64070
|
};
|
|
63063
64071
|
const anchoredByParagraph = collectAnchoredDrawings(blocks, measures);
|
|
64072
|
+
const anchoredTablesByParagraph = collectAnchoredTables(blocks, measures);
|
|
63064
64073
|
const placedAnchoredIds = /* @__PURE__ */ new Set();
|
|
64074
|
+
const placedAnchoredTableIds = /* @__PURE__ */ new Set();
|
|
63065
64075
|
const preRegisteredAnchors = collectPreRegisteredAnchors(blocks, measures);
|
|
63066
64076
|
const preRegisteredPositions = /* @__PURE__ */ new Map();
|
|
63067
64077
|
for (const entry of preRegisteredAnchors) {
|
|
@@ -63239,6 +64249,19 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
63239
64249
|
}
|
|
63240
64250
|
}
|
|
63241
64251
|
const anchorsForPara = anchoredByParagraph.get(index2);
|
|
64252
|
+
const tablesForPara = anchoredTablesByParagraph.get(index2);
|
|
64253
|
+
if (tablesForPara) {
|
|
64254
|
+
const state2 = paginator.ensurePage();
|
|
64255
|
+
for (const { block: tableBlock, measure: tableMeasure } of tablesForPara) {
|
|
64256
|
+
if (placedAnchoredTableIds.has(tableBlock.id)) continue;
|
|
64257
|
+
floatManager.registerTable(tableBlock, tableMeasure, state2.cursorY, state2.columnIndex, state2.page.number);
|
|
64258
|
+
const anchorX = tableBlock.anchor?.offsetH ?? columnX(state2.columnIndex);
|
|
64259
|
+
const anchorY = state2.cursorY + (tableBlock.anchor?.offsetV ?? 0);
|
|
64260
|
+
const tableFragment = createAnchoredTableFragment(tableBlock, tableMeasure, anchorX, anchorY);
|
|
64261
|
+
state2.page.fragments.push(tableFragment);
|
|
64262
|
+
placedAnchoredTableIds.add(tableBlock.id);
|
|
64263
|
+
}
|
|
64264
|
+
}
|
|
63242
64265
|
layoutParagraphBlock(
|
|
63243
64266
|
{
|
|
63244
64267
|
block,
|
|
@@ -63510,7 +64533,9 @@ const hashRuns = (block) => {
|
|
|
63510
64533
|
const trackedMode = block.attrs && "trackedChangesMode" in block.attrs && block.attrs.trackedChangesMode || "review";
|
|
63511
64534
|
const trackedEnabled = resolveTrackedChangesEnabled(block.attrs, true);
|
|
63512
64535
|
const runsHash = block.runs.map((run2) => {
|
|
63513
|
-
const text = normalizeText(
|
|
64536
|
+
const text = normalizeText(
|
|
64537
|
+
"src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? ""
|
|
64538
|
+
);
|
|
63514
64539
|
const bold = "bold" in run2 ? run2.bold : false;
|
|
63515
64540
|
const italic = "italic" in run2 ? run2.italic : false;
|
|
63516
64541
|
const color = "color" in run2 ? run2.color : void 0;
|
|
@@ -63524,7 +64549,22 @@ const hashRuns = (block) => {
|
|
|
63524
64549
|
}
|
|
63525
64550
|
return `${text}:${marks}${trackedKey}`;
|
|
63526
64551
|
}).join("|");
|
|
63527
|
-
|
|
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}`;
|
|
63528
64568
|
};
|
|
63529
64569
|
const createStats = () => ({
|
|
63530
64570
|
hits: 0,
|
|
@@ -64170,7 +65210,7 @@ function fontString(run2) {
|
|
|
64170
65210
|
return `${italic}${bold}${size2}px ${family}`.trim();
|
|
64171
65211
|
}
|
|
64172
65212
|
function runText(run2) {
|
|
64173
|
-
return "src" in run2 || run2.kind === "lineBreak" ? "" : run2.text ?? "";
|
|
65213
|
+
return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
|
|
64174
65214
|
}
|
|
64175
65215
|
function measureRunSliceWidth(run2, fromChar, toChar) {
|
|
64176
65216
|
const context = getCtx();
|
|
@@ -64332,7 +65372,7 @@ const paragraphBlocksEqual = (a, b2) => {
|
|
|
64332
65372
|
for (let i = 0; i < a.runs.length; i += 1) {
|
|
64333
65373
|
const runA = a.runs[i];
|
|
64334
65374
|
const runB = b2.runs[i];
|
|
64335
|
-
if (("src" in runA || runA.kind === "lineBreak" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
|
|
65375
|
+
if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
|
|
64336
65376
|
return false;
|
|
64337
65377
|
}
|
|
64338
65378
|
}
|
|
@@ -64452,7 +65492,7 @@ function computeHeaderFooterContentHash(blocks) {
|
|
|
64452
65492
|
parts.push(block.id);
|
|
64453
65493
|
if (block.kind === "paragraph") {
|
|
64454
65494
|
for (const run2 of block.runs) {
|
|
64455
|
-
if (!("src" in run2) && run2.kind !== "lineBreak") {
|
|
65495
|
+
if (!("src" in run2) && run2.kind !== "lineBreak" && run2.kind !== "break") {
|
|
64456
65496
|
parts.push(run2.text ?? "");
|
|
64457
65497
|
}
|
|
64458
65498
|
if ("bold" in run2 && run2.bold) parts.push("b");
|
|
@@ -65423,7 +66463,7 @@ function computeLinePmRange$1(block, line) {
|
|
|
65423
66463
|
for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
|
|
65424
66464
|
const run2 = block.runs[runIndex];
|
|
65425
66465
|
if (!run2) continue;
|
|
65426
|
-
const text = "src" in run2 || run2.kind === "lineBreak" ? "" : run2.text ?? "";
|
|
66466
|
+
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
|
|
65427
66467
|
const runLength = text.length;
|
|
65428
66468
|
const runPmStart = run2.pmStart ?? null;
|
|
65429
66469
|
const runPmEnd = run2.pmEnd ?? (runPmStart != null ? runPmStart + runLength : null);
|
|
@@ -68031,7 +69071,20 @@ const resolveTableCellBorders = (tableBorders, rowIndex, colIndex, totalRows, to
|
|
|
68031
69071
|
};
|
|
68032
69072
|
};
|
|
68033
69073
|
const renderTableCell = (deps) => {
|
|
68034
|
-
const {
|
|
69074
|
+
const {
|
|
69075
|
+
doc: doc2,
|
|
69076
|
+
x: x2,
|
|
69077
|
+
y: y2,
|
|
69078
|
+
rowHeight,
|
|
69079
|
+
cellMeasure,
|
|
69080
|
+
cell,
|
|
69081
|
+
borders,
|
|
69082
|
+
renderLine,
|
|
69083
|
+
context,
|
|
69084
|
+
applySdtDataset,
|
|
69085
|
+
fromLine,
|
|
69086
|
+
toLine
|
|
69087
|
+
} = deps;
|
|
68035
69088
|
const cellEl = doc2.createElement("div");
|
|
68036
69089
|
cellEl.style.position = "absolute";
|
|
68037
69090
|
cellEl.style.left = `${x2}px`;
|
|
@@ -68039,6 +69092,7 @@ const renderTableCell = (deps) => {
|
|
|
68039
69092
|
cellEl.style.width = `${cellMeasure.width}px`;
|
|
68040
69093
|
cellEl.style.height = `${rowHeight}px`;
|
|
68041
69094
|
cellEl.style.boxSizing = "border-box";
|
|
69095
|
+
cellEl.style.overflow = "hidden";
|
|
68042
69096
|
if (borders) {
|
|
68043
69097
|
applyCellBorders(cellEl, borders);
|
|
68044
69098
|
}
|
|
@@ -68052,36 +69106,87 @@ const renderTableCell = (deps) => {
|
|
|
68052
69106
|
}
|
|
68053
69107
|
let contentElement;
|
|
68054
69108
|
const attrs = cell?.attrs;
|
|
68055
|
-
const padding = attrs?.padding || { top: 2, left: 4, right: 4 };
|
|
69109
|
+
const padding = attrs?.padding || { top: 2, left: 4, right: 4, bottom: 2 };
|
|
68056
69110
|
const paddingLeft = padding.left ?? 4;
|
|
68057
69111
|
const paddingTop = padding.top ?? 2;
|
|
68058
69112
|
const paddingRight = padding.right ?? 4;
|
|
69113
|
+
const paddingBottom = padding.bottom ?? 2;
|
|
68059
69114
|
const cellBlocks = cell?.blocks ?? (cell?.paragraph ? [cell.paragraph] : []);
|
|
68060
|
-
const blockMeasures = cellMeasure
|
|
69115
|
+
const blockMeasures = cellMeasure?.blocks ?? (cellMeasure?.paragraph ? [cellMeasure.paragraph] : []);
|
|
68061
69116
|
if (cellBlocks.length > 0 && blockMeasures.length > 0) {
|
|
68062
69117
|
const content = doc2.createElement("div");
|
|
68063
69118
|
content.style.position = "absolute";
|
|
68064
69119
|
content.style.left = `${x2 + paddingLeft}px`;
|
|
68065
69120
|
content.style.top = `${y2 + paddingTop}px`;
|
|
68066
|
-
|
|
68067
|
-
|
|
69121
|
+
const contentWidth = Math.max(0, cellMeasure.width - paddingLeft - paddingRight);
|
|
69122
|
+
const contentHeight = Math.max(0, rowHeight - paddingTop - paddingBottom);
|
|
69123
|
+
content.style.width = `${contentWidth + 1}px`;
|
|
69124
|
+
content.style.height = `${contentHeight}px`;
|
|
69125
|
+
content.style.display = "flex";
|
|
69126
|
+
content.style.flexDirection = "column";
|
|
69127
|
+
content.style.overflowX = "visible";
|
|
69128
|
+
content.style.overflowY = "hidden";
|
|
69129
|
+
if (cell?.attrs?.verticalAlign === "center") {
|
|
69130
|
+
content.style.justifyContent = "center";
|
|
69131
|
+
} else if (cell?.attrs?.verticalAlign === "bottom") {
|
|
69132
|
+
content.style.justifyContent = "flex-end";
|
|
69133
|
+
} else {
|
|
69134
|
+
content.style.justifyContent = "flex-start";
|
|
69135
|
+
}
|
|
69136
|
+
const blockLineCounts = [];
|
|
69137
|
+
for (let i = 0; i < Math.min(blockMeasures.length, cellBlocks.length); i++) {
|
|
69138
|
+
const bm = blockMeasures[i];
|
|
69139
|
+
if (bm.kind === "paragraph") {
|
|
69140
|
+
blockLineCounts.push(bm.lines?.length || 0);
|
|
69141
|
+
} else {
|
|
69142
|
+
blockLineCounts.push(0);
|
|
69143
|
+
}
|
|
69144
|
+
}
|
|
69145
|
+
const totalLines = blockLineCounts.reduce((a, b2) => a + b2, 0);
|
|
69146
|
+
const globalFromLine = fromLine ?? 0;
|
|
69147
|
+
const globalToLine = toLine === -1 || toLine === void 0 ? totalLines : toLine;
|
|
69148
|
+
let cumulativeLineCount = 0;
|
|
68068
69149
|
for (let i = 0; i < Math.min(blockMeasures.length, cellBlocks.length); i++) {
|
|
68069
69150
|
const blockMeasure = blockMeasures[i];
|
|
68070
69151
|
const block = cellBlocks[i];
|
|
68071
69152
|
if (blockMeasure.kind === "paragraph" && block?.kind === "paragraph") {
|
|
69153
|
+
const lines = blockMeasure.lines;
|
|
69154
|
+
const blockLineCount = lines?.length || 0;
|
|
69155
|
+
const blockStartGlobal = cumulativeLineCount;
|
|
69156
|
+
const blockEndGlobal = cumulativeLineCount + blockLineCount;
|
|
69157
|
+
if (blockEndGlobal <= globalFromLine) {
|
|
69158
|
+
cumulativeLineCount += blockLineCount;
|
|
69159
|
+
continue;
|
|
69160
|
+
}
|
|
69161
|
+
if (blockStartGlobal >= globalToLine) {
|
|
69162
|
+
cumulativeLineCount += blockLineCount;
|
|
69163
|
+
continue;
|
|
69164
|
+
}
|
|
69165
|
+
const localStartLine = Math.max(0, globalFromLine - blockStartGlobal);
|
|
69166
|
+
const localEndLine = Math.min(blockLineCount, globalToLine - blockStartGlobal);
|
|
68072
69167
|
const paraWrapper = doc2.createElement("div");
|
|
68073
|
-
paraWrapper.style.position = "
|
|
68074
|
-
paraWrapper.style.top = `${blockY}px`;
|
|
69168
|
+
paraWrapper.style.position = "relative";
|
|
68075
69169
|
paraWrapper.style.left = "0";
|
|
68076
69170
|
paraWrapper.style.width = "100%";
|
|
68077
69171
|
applySdtDataset(paraWrapper, block.attrs?.sdt);
|
|
68078
|
-
|
|
68079
|
-
lines.
|
|
69172
|
+
let renderedHeight = 0;
|
|
69173
|
+
for (let lineIdx = localStartLine; lineIdx < localEndLine && lineIdx < lines.length; lineIdx++) {
|
|
69174
|
+
const line = lines[lineIdx];
|
|
68080
69175
|
const lineEl = renderLine(block, line, { ...context, section: "body" });
|
|
68081
69176
|
paraWrapper.appendChild(lineEl);
|
|
68082
|
-
|
|
69177
|
+
renderedHeight += line.lineHeight;
|
|
69178
|
+
}
|
|
69179
|
+
const renderedEntireBlock = localStartLine === 0 && localEndLine >= blockLineCount;
|
|
69180
|
+
if (renderedEntireBlock && blockMeasure.totalHeight && blockMeasure.totalHeight > renderedHeight) {
|
|
69181
|
+
renderedHeight = blockMeasure.totalHeight;
|
|
69182
|
+
}
|
|
68083
69183
|
content.appendChild(paraWrapper);
|
|
68084
|
-
|
|
69184
|
+
if (renderedHeight > 0) {
|
|
69185
|
+
paraWrapper.style.height = `${renderedHeight}px`;
|
|
69186
|
+
}
|
|
69187
|
+
cumulativeLineCount += blockLineCount;
|
|
69188
|
+
} else {
|
|
69189
|
+
cumulativeLineCount += 0;
|
|
68085
69190
|
}
|
|
68086
69191
|
}
|
|
68087
69192
|
contentElement = content;
|
|
@@ -68102,7 +69207,10 @@ const renderTableRow = (deps) => {
|
|
|
68102
69207
|
allRowHeights,
|
|
68103
69208
|
context,
|
|
68104
69209
|
renderLine,
|
|
68105
|
-
applySdtDataset
|
|
69210
|
+
applySdtDataset,
|
|
69211
|
+
continuesFromPrev,
|
|
69212
|
+
continuesOnNext,
|
|
69213
|
+
partialRow
|
|
68106
69214
|
} = deps;
|
|
68107
69215
|
const calculateXPosition = (gridColumnStart) => {
|
|
68108
69216
|
let x2 = 0;
|
|
@@ -68135,25 +69243,57 @@ const renderTableRow = (deps) => {
|
|
|
68135
69243
|
const isLastRow = rowIndex === totalRows - 1;
|
|
68136
69244
|
const isFirstCol = gridColIndex === 0;
|
|
68137
69245
|
const isLastCol = gridColIndex === totalCols - 1;
|
|
69246
|
+
const treatAsFirstRow = isFirstRow || continuesFromPrev;
|
|
69247
|
+
const treatAsLastRow = isLastRow || continuesOnNext;
|
|
68138
69248
|
resolvedBorders = {
|
|
68139
|
-
// For top: use cell's if defined, otherwise use table's top for first row
|
|
68140
|
-
top: cellBordersAttr.top ?? borderValueToSpec(
|
|
68141
|
-
// For bottom: use cell's if defined, otherwise use table's bottom for last row
|
|
68142
|
-
bottom: cellBordersAttr.bottom ?? borderValueToSpec(
|
|
69249
|
+
// For top: use cell's if defined, otherwise use table's top border for first row OR continuation
|
|
69250
|
+
top: cellBordersAttr.top ?? borderValueToSpec(treatAsFirstRow ? tableBorders.top : tableBorders.insideH),
|
|
69251
|
+
// For bottom: use cell's if defined, otherwise use table's bottom border for last row OR before continuation
|
|
69252
|
+
bottom: cellBordersAttr.bottom ?? borderValueToSpec(treatAsLastRow ? tableBorders.bottom : void 0),
|
|
68143
69253
|
// For left: use cell's if defined, otherwise use table's left for first col
|
|
68144
69254
|
left: cellBordersAttr.left ?? borderValueToSpec(isFirstCol ? tableBorders.left : tableBorders.insideV),
|
|
68145
69255
|
// For right: use cell's if defined, otherwise use table's right for last col only
|
|
68146
69256
|
right: cellBordersAttr.right ?? borderValueToSpec(isLastCol ? tableBorders.right : void 0)
|
|
68147
69257
|
};
|
|
68148
69258
|
} else if (hasExplicitBorders) {
|
|
68149
|
-
resolvedBorders =
|
|
69259
|
+
resolvedBorders = {
|
|
69260
|
+
top: cellBordersAttr.top,
|
|
69261
|
+
bottom: cellBordersAttr.bottom,
|
|
69262
|
+
left: cellBordersAttr.left,
|
|
69263
|
+
right: cellBordersAttr.right
|
|
69264
|
+
};
|
|
68150
69265
|
} else if (tableBorders) {
|
|
68151
|
-
|
|
69266
|
+
const isFirstRow = rowIndex === 0;
|
|
69267
|
+
const isLastRow = rowIndex === totalRows - 1;
|
|
69268
|
+
const treatAsFirstRow = isFirstRow || continuesFromPrev;
|
|
69269
|
+
const treatAsLastRow = isLastRow || continuesOnNext;
|
|
69270
|
+
const baseBorders = resolveTableCellBorders(tableBorders, rowIndex, gridColIndex, totalRows, totalCols);
|
|
69271
|
+
if (baseBorders) {
|
|
69272
|
+
resolvedBorders = {
|
|
69273
|
+
// If this is a continuation (continuesFromPrev), use table's top border
|
|
69274
|
+
top: treatAsFirstRow ? borderValueToSpec(tableBorders.top) : baseBorders.top,
|
|
69275
|
+
// If this continues on next (continuesOnNext), use table's bottom border
|
|
69276
|
+
bottom: treatAsLastRow ? borderValueToSpec(tableBorders.bottom) : baseBorders.bottom,
|
|
69277
|
+
left: baseBorders.left,
|
|
69278
|
+
right: baseBorders.right
|
|
69279
|
+
};
|
|
69280
|
+
} else {
|
|
69281
|
+
resolvedBorders = void 0;
|
|
69282
|
+
}
|
|
68152
69283
|
} else {
|
|
68153
69284
|
resolvedBorders = void 0;
|
|
68154
69285
|
}
|
|
68155
69286
|
const rowSpan = cellMeasure.rowSpan ?? 1;
|
|
68156
|
-
|
|
69287
|
+
let cellHeight;
|
|
69288
|
+
if (partialRow) {
|
|
69289
|
+
cellHeight = partialRow.partialHeight;
|
|
69290
|
+
} else if (rowSpan > 1) {
|
|
69291
|
+
cellHeight = calculateRowspanHeight(rowIndex, rowSpan);
|
|
69292
|
+
} else {
|
|
69293
|
+
cellHeight = rowMeasure.height;
|
|
69294
|
+
}
|
|
69295
|
+
const fromLine = partialRow?.fromLineByCell?.[cellIndex];
|
|
69296
|
+
const toLine = partialRow?.toLineByCell?.[cellIndex];
|
|
68157
69297
|
const { cellElement, contentElement } = renderTableCell({
|
|
68158
69298
|
doc: doc2,
|
|
68159
69299
|
x: x2,
|
|
@@ -68164,7 +69304,9 @@ const renderTableRow = (deps) => {
|
|
|
68164
69304
|
borders: resolvedBorders,
|
|
68165
69305
|
renderLine,
|
|
68166
69306
|
context,
|
|
68167
|
-
applySdtDataset
|
|
69307
|
+
applySdtDataset,
|
|
69308
|
+
fromLine,
|
|
69309
|
+
toLine
|
|
68168
69310
|
});
|
|
68169
69311
|
container.appendChild(cellElement);
|
|
68170
69312
|
if (contentElement) {
|
|
@@ -68278,11 +69420,46 @@ const renderTableFragment = (deps) => {
|
|
|
68278
69420
|
if (borderCollapse === "separate" && block.attrs?.cellSpacing) {
|
|
68279
69421
|
container.style.borderSpacing = `${block.attrs.cellSpacing}px`;
|
|
68280
69422
|
}
|
|
68281
|
-
const allRowHeights = measure.rows.map((r2) =>
|
|
69423
|
+
const allRowHeights = measure.rows.map((r2, idx) => {
|
|
69424
|
+
if (fragment.partialRow && fragment.partialRow.rowIndex === idx) {
|
|
69425
|
+
return fragment.partialRow.partialHeight;
|
|
69426
|
+
}
|
|
69427
|
+
return r2?.height ?? 0;
|
|
69428
|
+
});
|
|
68282
69429
|
let y2 = 0;
|
|
69430
|
+
if (fragment.repeatHeaderCount && fragment.repeatHeaderCount > 0) {
|
|
69431
|
+
for (let r2 = 0; r2 < fragment.repeatHeaderCount; r2 += 1) {
|
|
69432
|
+
const rowMeasure = measure.rows[r2];
|
|
69433
|
+
if (!rowMeasure) break;
|
|
69434
|
+
renderTableRow({
|
|
69435
|
+
doc: doc2,
|
|
69436
|
+
container,
|
|
69437
|
+
rowIndex: r2,
|
|
69438
|
+
y: y2,
|
|
69439
|
+
rowMeasure,
|
|
69440
|
+
row: block.rows[r2],
|
|
69441
|
+
totalRows: block.rows.length,
|
|
69442
|
+
tableBorders,
|
|
69443
|
+
columnWidths: measure.columnWidths,
|
|
69444
|
+
allRowHeights,
|
|
69445
|
+
context,
|
|
69446
|
+
renderLine,
|
|
69447
|
+
applySdtDataset,
|
|
69448
|
+
// Headers are always rendered as-is (no border suppression)
|
|
69449
|
+
continuesFromPrev: false,
|
|
69450
|
+
continuesOnNext: false
|
|
69451
|
+
});
|
|
69452
|
+
y2 += rowMeasure.height;
|
|
69453
|
+
}
|
|
69454
|
+
}
|
|
68283
69455
|
for (let r2 = fragment.fromRow; r2 < fragment.toRow; r2 += 1) {
|
|
68284
69456
|
const rowMeasure = measure.rows[r2];
|
|
68285
69457
|
if (!rowMeasure) break;
|
|
69458
|
+
const isFirstRenderedBodyRow = r2 === fragment.fromRow;
|
|
69459
|
+
const isLastRenderedBodyRow = r2 === fragment.toRow - 1;
|
|
69460
|
+
const isPartialRow = fragment.partialRow && fragment.partialRow.rowIndex === r2;
|
|
69461
|
+
const partialRowData = isPartialRow ? fragment.partialRow : void 0;
|
|
69462
|
+
const actualRowHeight = partialRowData ? partialRowData.partialHeight : rowMeasure.height;
|
|
68286
69463
|
renderTableRow({
|
|
68287
69464
|
doc: doc2,
|
|
68288
69465
|
container,
|
|
@@ -68296,9 +69473,15 @@ const renderTableFragment = (deps) => {
|
|
|
68296
69473
|
allRowHeights,
|
|
68297
69474
|
context,
|
|
68298
69475
|
renderLine,
|
|
68299
|
-
applySdtDataset
|
|
69476
|
+
applySdtDataset,
|
|
69477
|
+
// Draw top border if table continues from previous fragment (MS Word behavior)
|
|
69478
|
+
continuesFromPrev: isFirstRenderedBodyRow && fragment.continuesFromPrev === true,
|
|
69479
|
+
// Draw bottom border if table continues on next fragment (MS Word behavior)
|
|
69480
|
+
continuesOnNext: isLastRenderedBodyRow && fragment.continuesOnNext === true,
|
|
69481
|
+
// Pass partial row data for mid-row splits
|
|
69482
|
+
partialRow: partialRowData
|
|
68300
69483
|
});
|
|
68301
|
-
y2 +=
|
|
69484
|
+
y2 += actualRowHeight;
|
|
68302
69485
|
}
|
|
68303
69486
|
return container;
|
|
68304
69487
|
};
|
|
@@ -68393,6 +69576,7 @@ function assertFragmentPmPositions(fragment, context) {
|
|
|
68393
69576
|
}
|
|
68394
69577
|
}
|
|
68395
69578
|
const LIST_MARKER_GAP$1 = 8;
|
|
69579
|
+
const DEFAULT_TAB_INTERVAL_PX$1 = 48;
|
|
68396
69580
|
const COMMENT_EXTERNAL_COLOR = "#B1124B";
|
|
68397
69581
|
const COMMENT_INTERNAL_COLOR = "#078383";
|
|
68398
69582
|
const COMMENT_INACTIVE_ALPHA = "22";
|
|
@@ -69189,33 +70373,41 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69189
70373
|
const firstLineOffset = (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
|
|
69190
70374
|
lines.forEach((line, index2) => {
|
|
69191
70375
|
const lineEl = this.renderLine(block, line, context);
|
|
69192
|
-
|
|
70376
|
+
const isListFirstLine = index2 === 0 && !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
|
|
70377
|
+
if (paraIndentLeft && !isListFirstLine) {
|
|
69193
70378
|
lineEl.style.paddingLeft = `${paraIndentLeft}px`;
|
|
69194
70379
|
}
|
|
69195
70380
|
if (paraIndentRight) {
|
|
69196
70381
|
lineEl.style.paddingRight = `${paraIndentRight}px`;
|
|
69197
70382
|
}
|
|
69198
|
-
if (!fragment.continuesFromPrev && index2 === 0 && firstLineOffset) {
|
|
70383
|
+
if (!fragment.continuesFromPrev && index2 === 0 && firstLineOffset && !isListFirstLine) {
|
|
69199
70384
|
lineEl.style.textIndent = `${firstLineOffset}px`;
|
|
69200
|
-
} else if (firstLineOffset) {
|
|
70385
|
+
} else if (firstLineOffset && !isListFirstLine) {
|
|
69201
70386
|
lineEl.style.textIndent = "0px";
|
|
69202
70387
|
}
|
|
69203
|
-
if (
|
|
70388
|
+
if (isListFirstLine && wordLayout?.marker && fragment.markerWidth) {
|
|
70389
|
+
const markerStartPos = paraIndentLeft - (paraIndent?.hanging ?? 0);
|
|
70390
|
+
lineEl.style.paddingLeft = `${markerStartPos}px`;
|
|
69204
70391
|
const markerContainer = this.doc.createElement("span");
|
|
69205
70392
|
markerContainer.style.display = "inline-block";
|
|
69206
70393
|
const markerEl = this.doc.createElement("span");
|
|
69207
70394
|
markerEl.classList.add("superdoc-paragraph-marker");
|
|
69208
70395
|
markerEl.textContent = wordLayout.marker.markerText ?? "";
|
|
69209
|
-
markerEl.style.width = `${fragment.markerWidth}px`;
|
|
69210
|
-
markerEl.style.textAlign = wordLayout.marker.justification ?? "right";
|
|
69211
|
-
markerEl.style.paddingRight = `${LIST_MARKER_GAP$1}px`;
|
|
69212
70396
|
markerEl.style.pointerEvents = "none";
|
|
69213
|
-
const
|
|
69214
|
-
|
|
69215
|
-
|
|
69216
|
-
|
|
69217
|
-
|
|
69218
|
-
|
|
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
|
+
}
|
|
69219
70411
|
markerEl.style.fontFamily = wordLayout.marker.run.fontFamily;
|
|
69220
70412
|
markerEl.style.fontSize = `${wordLayout.marker.run.fontSize}px`;
|
|
69221
70413
|
markerEl.style.fontWeight = wordLayout.marker.run.bold ? "bold" : "";
|
|
@@ -69232,12 +70424,25 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69232
70424
|
const tabEl = this.doc.createElement("span");
|
|
69233
70425
|
tabEl.className = "superdoc-tab";
|
|
69234
70426
|
tabEl.innerHTML = " ";
|
|
69235
|
-
|
|
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
|
+
}
|
|
69236
70441
|
tabEl.style.display = "inline-block";
|
|
69237
|
-
tabEl.style.width = `${
|
|
69238
|
-
|
|
70442
|
+
tabEl.style.width = `${tabWidth}px`;
|
|
70443
|
+
lineEl.prepend(tabEl);
|
|
69239
70444
|
} else if (suffix2 === "space") {
|
|
69240
|
-
|
|
70445
|
+
lineEl.prepend(this.doc.createTextNode(" "));
|
|
69241
70446
|
}
|
|
69242
70447
|
lineEl.prepend(markerContainer);
|
|
69243
70448
|
}
|
|
@@ -70086,6 +71291,12 @@ const _DomPainter = class _DomPainter2 {
|
|
|
70086
71291
|
isLineBreakRun(run2) {
|
|
70087
71292
|
return run2.kind === "lineBreak";
|
|
70088
71293
|
}
|
|
71294
|
+
/**
|
|
71295
|
+
* Type guard to check if a run is a break run.
|
|
71296
|
+
*/
|
|
71297
|
+
isBreakRun(run2) {
|
|
71298
|
+
return run2.kind === "break";
|
|
71299
|
+
}
|
|
70089
71300
|
renderRun(run2, context, trackedConfig) {
|
|
70090
71301
|
if (this.isImageRun(run2)) {
|
|
70091
71302
|
return this.renderImageRun(run2);
|
|
@@ -70093,7 +71304,10 @@ const _DomPainter = class _DomPainter2 {
|
|
|
70093
71304
|
if (this.isLineBreakRun(run2)) {
|
|
70094
71305
|
return null;
|
|
70095
71306
|
}
|
|
70096
|
-
if (
|
|
71307
|
+
if (this.isBreakRun(run2)) {
|
|
71308
|
+
return null;
|
|
71309
|
+
}
|
|
71310
|
+
if (!("text" in run2) || !run2.text || !this.doc) {
|
|
70097
71311
|
return null;
|
|
70098
71312
|
}
|
|
70099
71313
|
const linkData = this.extractLinkData(run2);
|
|
@@ -70234,6 +71448,12 @@ const _DomPainter = class _DomPainter2 {
|
|
|
70234
71448
|
if (styleId) {
|
|
70235
71449
|
el.setAttribute("styleid", styleId);
|
|
70236
71450
|
}
|
|
71451
|
+
const alignment2 = block.attrs?.alignment;
|
|
71452
|
+
if (alignment2 === "center" || alignment2 === "right" || alignment2 === "justify") {
|
|
71453
|
+
el.style.textAlign = alignment2 === "justify" ? "justify" : alignment2;
|
|
71454
|
+
} else {
|
|
71455
|
+
el.style.textAlign = "left";
|
|
71456
|
+
}
|
|
70237
71457
|
const lineRange = computeLinePmRange(block, line);
|
|
70238
71458
|
if (lineRange.pmStart != null) {
|
|
70239
71459
|
el.dataset.pmStart = String(lineRange.pmStart);
|
|
@@ -70351,10 +71571,16 @@ const _DomPainter = class _DomPainter2 {
|
|
|
70351
71571
|
if (this.isLineBreakRun(baseRun)) {
|
|
70352
71572
|
continue;
|
|
70353
71573
|
}
|
|
71574
|
+
if (this.isBreakRun(baseRun)) {
|
|
71575
|
+
continue;
|
|
71576
|
+
}
|
|
70354
71577
|
const runSegments = segmentsByRun.get(runIndex);
|
|
70355
71578
|
if (!runSegments || runSegments.length === 0) {
|
|
70356
71579
|
continue;
|
|
70357
71580
|
}
|
|
71581
|
+
if (!("text" in baseRun)) {
|
|
71582
|
+
continue;
|
|
71583
|
+
}
|
|
70358
71584
|
const baseText = baseRun.text ?? "";
|
|
70359
71585
|
const runPmStart = baseRun.pmStart ?? null;
|
|
70360
71586
|
const fallbackPmEnd = runPmStart != null && baseRun.pmEnd == null ? runPmStart + baseText.length : baseRun.pmEnd ?? null;
|
|
@@ -70673,7 +71899,12 @@ const fragmentKey = (fragment) => {
|
|
|
70673
71899
|
if (fragment.kind === "drawing") {
|
|
70674
71900
|
return `drawing:${fragment.blockId}:${fragment.x}:${fragment.y}`;
|
|
70675
71901
|
}
|
|
70676
|
-
|
|
71902
|
+
if (fragment.kind === "table") {
|
|
71903
|
+
const partialKey = fragment.partialRow ? `:${fragment.partialRow.fromLineByCell.join(",")}-${fragment.partialRow.toLineByCell.join(",")}` : "";
|
|
71904
|
+
return `table:${fragment.blockId}:${fragment.fromRow}:${fragment.toRow}${partialKey}`;
|
|
71905
|
+
}
|
|
71906
|
+
const _exhaustiveCheck = fragment;
|
|
71907
|
+
return _exhaustiveCheck;
|
|
70677
71908
|
};
|
|
70678
71909
|
const fragmentSignature = (fragment, lookup2) => {
|
|
70679
71910
|
const base2 = lookup2.get(fragment.blockId)?.version ?? "missing";
|
|
@@ -70685,7 +71916,9 @@ const fragmentSignature = (fragment, lookup2) => {
|
|
|
70685
71916
|
fragment.pmStart ?? "",
|
|
70686
71917
|
fragment.pmEnd ?? "",
|
|
70687
71918
|
fragment.continuesFromPrev ? 1 : 0,
|
|
70688
|
-
fragment.continuesOnNext ? 1 : 0
|
|
71919
|
+
fragment.continuesOnNext ? 1 : 0,
|
|
71920
|
+
fragment.markerWidth ?? ""
|
|
71921
|
+
// Include markerWidth to trigger re-render when list status changes
|
|
70689
71922
|
].join("|");
|
|
70690
71923
|
}
|
|
70691
71924
|
if (fragment.kind === "list-item") {
|
|
@@ -70715,6 +71948,20 @@ const fragmentSignature = (fragment, lookup2) => {
|
|
|
70715
71948
|
fragment.zIndex ?? ""
|
|
70716
71949
|
].join("|");
|
|
70717
71950
|
}
|
|
71951
|
+
if (fragment.kind === "table") {
|
|
71952
|
+
const partialSig = fragment.partialRow ? `${fragment.partialRow.fromLineByCell.join(",")}-${fragment.partialRow.toLineByCell.join(",")}-${fragment.partialRow.partialHeight}` : "";
|
|
71953
|
+
return [
|
|
71954
|
+
base2,
|
|
71955
|
+
fragment.fromRow,
|
|
71956
|
+
fragment.toRow,
|
|
71957
|
+
fragment.width,
|
|
71958
|
+
fragment.height,
|
|
71959
|
+
fragment.continuesFromPrev ? 1 : 0,
|
|
71960
|
+
fragment.continuesOnNext ? 1 : 0,
|
|
71961
|
+
fragment.repeatHeaderCount ?? 0,
|
|
71962
|
+
partialSig
|
|
71963
|
+
].join("|");
|
|
71964
|
+
}
|
|
70718
71965
|
return base2;
|
|
70719
71966
|
};
|
|
70720
71967
|
const deriveBlockVersion = (block) => {
|
|
@@ -70860,7 +72107,7 @@ const deriveBlockVersion = (block) => {
|
|
|
70860
72107
|
return block.id;
|
|
70861
72108
|
};
|
|
70862
72109
|
const applyRunStyles = (element, run2, isLink = false) => {
|
|
70863
|
-
if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak") {
|
|
72110
|
+
if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break") {
|
|
70864
72111
|
return;
|
|
70865
72112
|
}
|
|
70866
72113
|
element.style.fontFamily = run2.fontFamily;
|
|
@@ -70994,6 +72241,17 @@ const sliceRunsForLine = (block, line) => {
|
|
|
70994
72241
|
result.push(run2);
|
|
70995
72242
|
continue;
|
|
70996
72243
|
}
|
|
72244
|
+
if (run2.kind === "break") {
|
|
72245
|
+
result.push(run2);
|
|
72246
|
+
continue;
|
|
72247
|
+
}
|
|
72248
|
+
if (run2.kind === "tab") {
|
|
72249
|
+
result.push(run2);
|
|
72250
|
+
continue;
|
|
72251
|
+
}
|
|
72252
|
+
if (!("text" in run2)) {
|
|
72253
|
+
continue;
|
|
72254
|
+
}
|
|
70997
72255
|
const text = run2.text ?? "";
|
|
70998
72256
|
const isFirstRun = runIndex === line.fromRun;
|
|
70999
72257
|
const isLastRun = runIndex === line.toRun;
|
|
@@ -71007,20 +72265,14 @@ const sliceRunsForLine = (block, line) => {
|
|
|
71007
72265
|
if (!slice2) continue;
|
|
71008
72266
|
const pmSliceStart = runPmStart != null ? runPmStart + start2 : void 0;
|
|
71009
72267
|
const pmSliceEnd = runPmStart != null ? runPmStart + end2 : fallbackPmEnd ?? void 0;
|
|
71010
|
-
|
|
71011
|
-
|
|
71012
|
-
|
|
71013
|
-
|
|
71014
|
-
|
|
71015
|
-
|
|
71016
|
-
|
|
71017
|
-
|
|
71018
|
-
pmStart: pmSliceStart,
|
|
71019
|
-
pmEnd: pmSliceEnd,
|
|
71020
|
-
comments: run2.comments ? [...run2.comments] : void 0
|
|
71021
|
-
};
|
|
71022
|
-
result.push(sliced);
|
|
71023
|
-
}
|
|
72268
|
+
const sliced = {
|
|
72269
|
+
...run2,
|
|
72270
|
+
text: slice2,
|
|
72271
|
+
pmStart: pmSliceStart,
|
|
72272
|
+
pmEnd: pmSliceEnd,
|
|
72273
|
+
comments: run2.comments ? [...run2.comments] : void 0
|
|
72274
|
+
};
|
|
72275
|
+
result.push(sliced);
|
|
71024
72276
|
} else {
|
|
71025
72277
|
result.push(run2);
|
|
71026
72278
|
}
|
|
@@ -71063,6 +72315,39 @@ const computeLinePmRange = (block, line) => {
|
|
|
71063
72315
|
}
|
|
71064
72316
|
continue;
|
|
71065
72317
|
}
|
|
72318
|
+
if (run2.kind === "break") {
|
|
72319
|
+
const runPmStart2 = run2.pmStart ?? null;
|
|
72320
|
+
const runPmEnd = run2.pmEnd ?? null;
|
|
72321
|
+
if (runPmStart2 == null || runPmEnd == null) {
|
|
72322
|
+
continue;
|
|
72323
|
+
}
|
|
72324
|
+
if (pmStart == null) {
|
|
72325
|
+
pmStart = runPmStart2;
|
|
72326
|
+
}
|
|
72327
|
+
pmEnd = runPmEnd;
|
|
72328
|
+
if (runIndex === line.toRun) {
|
|
72329
|
+
break;
|
|
72330
|
+
}
|
|
72331
|
+
continue;
|
|
72332
|
+
}
|
|
72333
|
+
if (run2.kind === "tab") {
|
|
72334
|
+
const runPmStart2 = run2.pmStart ?? null;
|
|
72335
|
+
const runPmEnd = run2.pmEnd ?? null;
|
|
72336
|
+
if (runPmStart2 == null || runPmEnd == null) {
|
|
72337
|
+
continue;
|
|
72338
|
+
}
|
|
72339
|
+
if (pmStart == null) {
|
|
72340
|
+
pmStart = runPmStart2;
|
|
72341
|
+
}
|
|
72342
|
+
pmEnd = runPmEnd;
|
|
72343
|
+
if (runIndex === line.toRun) {
|
|
72344
|
+
break;
|
|
72345
|
+
}
|
|
72346
|
+
continue;
|
|
72347
|
+
}
|
|
72348
|
+
if (!("text" in run2)) {
|
|
72349
|
+
continue;
|
|
72350
|
+
}
|
|
71066
72351
|
const text = run2.text ?? "";
|
|
71067
72352
|
const runLength = text.length;
|
|
71068
72353
|
const runPmStart = run2.pmStart ?? null;
|
|
@@ -71104,6 +72389,12 @@ const resolveRunText = (run2, context) => {
|
|
|
71104
72389
|
if (run2.kind === "lineBreak") {
|
|
71105
72390
|
return "";
|
|
71106
72391
|
}
|
|
72392
|
+
if (run2.kind === "break") {
|
|
72393
|
+
return "";
|
|
72394
|
+
}
|
|
72395
|
+
if (!("text" in run2)) {
|
|
72396
|
+
return "";
|
|
72397
|
+
}
|
|
71107
72398
|
if (!runToken) {
|
|
71108
72399
|
return run2.text ?? "";
|
|
71109
72400
|
}
|
|
@@ -71301,6 +72592,7 @@ async function measureBlock(block, constraints) {
|
|
|
71301
72592
|
async function measureParagraphBlock(block, maxWidth) {
|
|
71302
72593
|
const ctx2 = getCanvasContext();
|
|
71303
72594
|
const wordLayout = block.attrs?.wordLayout;
|
|
72595
|
+
const WIDTH_FUDGE_PX = 0.5;
|
|
71304
72596
|
const lines = [];
|
|
71305
72597
|
const indent = block.attrs?.indent;
|
|
71306
72598
|
const spacing = block.attrs?.spacing;
|
|
@@ -71395,8 +72687,67 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
71395
72687
|
lastAppliedTabAlign = { target, val };
|
|
71396
72688
|
pendingTabAlignment = null;
|
|
71397
72689
|
};
|
|
71398
|
-
|
|
71399
|
-
|
|
72690
|
+
const runsToProcess = [];
|
|
72691
|
+
for (const run2 of block.runs) {
|
|
72692
|
+
if (run2.text && typeof run2.text === "string" && run2.text.includes("\n")) {
|
|
72693
|
+
const textRun = run2;
|
|
72694
|
+
const segments = textRun.text.split("\n");
|
|
72695
|
+
let cursor = textRun.pmStart ?? 0;
|
|
72696
|
+
segments.forEach((seg, idx) => {
|
|
72697
|
+
runsToProcess.push({
|
|
72698
|
+
...textRun,
|
|
72699
|
+
text: seg,
|
|
72700
|
+
pmStart: cursor,
|
|
72701
|
+
pmEnd: cursor + seg.length
|
|
72702
|
+
});
|
|
72703
|
+
cursor += seg.length;
|
|
72704
|
+
if (idx !== segments.length - 1) {
|
|
72705
|
+
runsToProcess.push({
|
|
72706
|
+
kind: "break",
|
|
72707
|
+
breakType: "line",
|
|
72708
|
+
pmStart: cursor,
|
|
72709
|
+
pmEnd: cursor + 1,
|
|
72710
|
+
sdt: run2.sdt
|
|
72711
|
+
});
|
|
72712
|
+
cursor += 1;
|
|
72713
|
+
}
|
|
72714
|
+
});
|
|
72715
|
+
} else {
|
|
72716
|
+
runsToProcess.push(run2);
|
|
72717
|
+
}
|
|
72718
|
+
}
|
|
72719
|
+
for (let runIndex = 0; runIndex < runsToProcess.length; runIndex++) {
|
|
72720
|
+
const run2 = runsToProcess[runIndex];
|
|
72721
|
+
if (run2.kind === "break") {
|
|
72722
|
+
if (currentLine) {
|
|
72723
|
+
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
|
|
72724
|
+
const completedLine = { ...currentLine, ...metrics };
|
|
72725
|
+
addBarTabsToLine(completedLine);
|
|
72726
|
+
lines.push(completedLine);
|
|
72727
|
+
currentLine = null;
|
|
72728
|
+
} else {
|
|
72729
|
+
const textRunWithSize = block.runs.find(
|
|
72730
|
+
(r2) => r2.kind !== "tab" && r2.kind !== "lineBreak" && r2.kind !== "break" && !("src" in r2) && "fontSize" in r2
|
|
72731
|
+
);
|
|
72732
|
+
const fallbackSize = textRunWithSize?.fontSize ?? 12;
|
|
72733
|
+
const metrics = calculateTypographyMetrics(fallbackSize, spacing);
|
|
72734
|
+
const emptyLine = {
|
|
72735
|
+
fromRun: runIndex,
|
|
72736
|
+
fromChar: 0,
|
|
72737
|
+
toRun: runIndex,
|
|
72738
|
+
toChar: 0,
|
|
72739
|
+
width: 0,
|
|
72740
|
+
segments: [],
|
|
72741
|
+
...metrics
|
|
72742
|
+
};
|
|
72743
|
+
addBarTabsToLine(emptyLine);
|
|
72744
|
+
lines.push(emptyLine);
|
|
72745
|
+
}
|
|
72746
|
+
tabStopCursor = 0;
|
|
72747
|
+
pendingTabAlignment = null;
|
|
72748
|
+
lastAppliedTabAlign = null;
|
|
72749
|
+
continue;
|
|
72750
|
+
}
|
|
71400
72751
|
if (isLineBreakRun(run2)) {
|
|
71401
72752
|
if (currentLine) {
|
|
71402
72753
|
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
|
|
@@ -71547,6 +72898,9 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
71547
72898
|
}
|
|
71548
72899
|
continue;
|
|
71549
72900
|
}
|
|
72901
|
+
if (!("text" in run2) || !("fontSize" in run2)) {
|
|
72902
|
+
continue;
|
|
72903
|
+
}
|
|
71550
72904
|
lastFontSize = run2.fontSize;
|
|
71551
72905
|
const { font } = buildFontString(run2);
|
|
71552
72906
|
const tabSegments = run2.text.split(" ");
|
|
@@ -71586,18 +72940,18 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
71586
72940
|
segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }]
|
|
71587
72941
|
};
|
|
71588
72942
|
const ls = run2.letterSpacing ?? 0;
|
|
71589
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth) {
|
|
72943
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
|
|
71590
72944
|
currentLine.toChar = wordEndWithSpace;
|
|
71591
72945
|
currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
|
|
71592
72946
|
charPosInRun = wordEndWithSpace;
|
|
71593
72947
|
} else {
|
|
71594
|
-
charPosInRun =
|
|
72948
|
+
charPosInRun = wordEndWithSpace;
|
|
71595
72949
|
}
|
|
71596
72950
|
continue;
|
|
71597
72951
|
}
|
|
71598
72952
|
const isTocEntry = block.attrs?.isTocEntry;
|
|
71599
72953
|
const boundarySpacing = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
|
|
71600
|
-
if (currentLine.width + boundarySpacing + wordOnlyWidth > currentLine.maxWidth && currentLine.width > 0 && !isTocEntry) {
|
|
72954
|
+
if (currentLine.width + boundarySpacing + wordOnlyWidth > currentLine.maxWidth - WIDTH_FUDGE_PX && currentLine.width > 0 && !isTocEntry) {
|
|
71601
72955
|
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
|
|
71602
72956
|
const completedLine = {
|
|
71603
72957
|
...currentLine,
|
|
@@ -71617,16 +72971,16 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
71617
72971
|
maxWidth: getEffectiveWidth(contentWidth),
|
|
71618
72972
|
segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }]
|
|
71619
72973
|
};
|
|
71620
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth) {
|
|
72974
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
|
|
71621
72975
|
currentLine.toChar = wordEndWithSpace;
|
|
71622
72976
|
currentLine.width = roundValue(currentLine.width + spaceWidth + (run2.letterSpacing ?? 0));
|
|
71623
72977
|
charPosInRun = wordEndWithSpace;
|
|
71624
72978
|
} else {
|
|
71625
|
-
charPosInRun =
|
|
72979
|
+
charPosInRun = wordEndWithSpace;
|
|
71626
72980
|
}
|
|
71627
72981
|
} else {
|
|
71628
72982
|
currentLine.toRun = runIndex;
|
|
71629
|
-
if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth) {
|
|
72983
|
+
if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX) {
|
|
71630
72984
|
currentLine.toChar = wordEndNoSpace;
|
|
71631
72985
|
currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
|
|
71632
72986
|
currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
|
|
@@ -71735,10 +73089,14 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
71735
73089
|
const { font: markerFont } = buildFontString(markerRun);
|
|
71736
73090
|
const markerText = wordLayout.marker.markerText ?? "";
|
|
71737
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);
|
|
71738
73094
|
markerInfo = {
|
|
71739
|
-
markerWidth:
|
|
73095
|
+
markerWidth: markerBoxWidth,
|
|
71740
73096
|
markerTextWidth: glyphWidth,
|
|
71741
|
-
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
|
|
71742
73100
|
};
|
|
71743
73101
|
}
|
|
71744
73102
|
return {
|
|
@@ -71752,6 +73110,34 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
71752
73110
|
async function measureTableBlock(block, constraints) {
|
|
71753
73111
|
const maxWidth = typeof constraints === "number" ? constraints : constraints.maxWidth;
|
|
71754
73112
|
let columnWidths;
|
|
73113
|
+
const scaleColumnWidths = (widths, targetWidth) => {
|
|
73114
|
+
const totalWidth2 = widths.reduce((a, b2) => a + b2, 0);
|
|
73115
|
+
if (totalWidth2 <= targetWidth || widths.length === 0) return widths;
|
|
73116
|
+
const scale = targetWidth / totalWidth2;
|
|
73117
|
+
const scaled = widths.map((w2) => Math.max(1, Math.round(w2 * scale)));
|
|
73118
|
+
const sum = scaled.reduce((a, b2) => a + b2, 0);
|
|
73119
|
+
if (sum !== targetWidth) {
|
|
73120
|
+
const adjust = (delta) => {
|
|
73121
|
+
let idx = 0;
|
|
73122
|
+
const direction = delta > 0 ? 1 : -1;
|
|
73123
|
+
delta = Math.abs(delta);
|
|
73124
|
+
while (delta > 0 && scaled.length > 0) {
|
|
73125
|
+
const i = idx % scaled.length;
|
|
73126
|
+
if (direction > 0) {
|
|
73127
|
+
scaled[i] += 1;
|
|
73128
|
+
delta -= 1;
|
|
73129
|
+
} else if (scaled[i] > 1) {
|
|
73130
|
+
scaled[i] -= 1;
|
|
73131
|
+
delta -= 1;
|
|
73132
|
+
}
|
|
73133
|
+
idx += 1;
|
|
73134
|
+
if (idx > scaled.length * 2 && delta > 0) break;
|
|
73135
|
+
}
|
|
73136
|
+
};
|
|
73137
|
+
adjust(targetWidth - sum);
|
|
73138
|
+
}
|
|
73139
|
+
return scaled;
|
|
73140
|
+
};
|
|
71755
73141
|
const maxCellCount = Math.max(1, Math.max(...block.rows.map((r2) => r2.cells.length)));
|
|
71756
73142
|
if (block.columnWidths && block.columnWidths.length > 0) {
|
|
71757
73143
|
columnWidths = [...block.columnWidths];
|
|
@@ -71760,8 +73146,7 @@ async function measureTableBlock(block, constraints) {
|
|
|
71760
73146
|
if (hasExplicitWidth || hasFixedLayout) {
|
|
71761
73147
|
const totalWidth2 = columnWidths.reduce((a, b2) => a + b2, 0);
|
|
71762
73148
|
if (totalWidth2 > maxWidth) {
|
|
71763
|
-
|
|
71764
|
-
columnWidths = columnWidths.map((w2) => Math.max(1, Math.floor(w2 * scale)));
|
|
73149
|
+
columnWidths = scaleColumnWidths(columnWidths, maxWidth);
|
|
71765
73150
|
}
|
|
71766
73151
|
} else {
|
|
71767
73152
|
if (columnWidths.length < maxCellCount) {
|
|
@@ -71775,8 +73160,7 @@ async function measureTableBlock(block, constraints) {
|
|
|
71775
73160
|
}
|
|
71776
73161
|
const totalWidth2 = columnWidths.reduce((a, b2) => a + b2, 0);
|
|
71777
73162
|
if (totalWidth2 > maxWidth) {
|
|
71778
|
-
|
|
71779
|
-
columnWidths = columnWidths.map((w2) => Math.max(1, Math.floor(w2 * scale)));
|
|
73163
|
+
columnWidths = scaleColumnWidths(columnWidths, maxWidth);
|
|
71780
73164
|
}
|
|
71781
73165
|
}
|
|
71782
73166
|
} else {
|
|
@@ -71793,6 +73177,8 @@ async function measureTableBlock(block, constraints) {
|
|
|
71793
73177
|
};
|
|
71794
73178
|
const rowspanTracker = new Array(gridColumnCount).fill(0);
|
|
71795
73179
|
const rows = [];
|
|
73180
|
+
const rowBaseHeights = new Array(block.rows.length).fill(0);
|
|
73181
|
+
const spanConstraints = [];
|
|
71796
73182
|
for (let rowIndex = 0; rowIndex < block.rows.length; rowIndex++) {
|
|
71797
73183
|
const row = block.rows[rowIndex];
|
|
71798
73184
|
const cellMeasures = [];
|
|
@@ -71839,6 +73225,11 @@ async function measureTableBlock(block, constraints) {
|
|
|
71839
73225
|
colSpan: colspan,
|
|
71840
73226
|
rowSpan: rowspan
|
|
71841
73227
|
});
|
|
73228
|
+
if (rowspan === 1) {
|
|
73229
|
+
rowBaseHeights[rowIndex] = Math.max(rowBaseHeights[rowIndex], totalCellHeight);
|
|
73230
|
+
} else {
|
|
73231
|
+
spanConstraints.push({ startRow: rowIndex, rowSpan: rowspan, requiredHeight: totalCellHeight });
|
|
73232
|
+
}
|
|
71842
73233
|
gridColIndex += colspan;
|
|
71843
73234
|
}
|
|
71844
73235
|
for (let col = gridColIndex; col < gridColumnCount; col++) {
|
|
@@ -71846,10 +73237,39 @@ async function measureTableBlock(block, constraints) {
|
|
|
71846
73237
|
rowspanTracker[col]--;
|
|
71847
73238
|
}
|
|
71848
73239
|
}
|
|
71849
|
-
|
|
71850
|
-
|
|
73240
|
+
rows.push({ cells: cellMeasures, height: 0 });
|
|
73241
|
+
}
|
|
73242
|
+
const rowHeights = [...rowBaseHeights];
|
|
73243
|
+
for (const constraint of spanConstraints) {
|
|
73244
|
+
const { startRow, rowSpan, requiredHeight } = constraint;
|
|
73245
|
+
if (rowSpan <= 0) continue;
|
|
73246
|
+
let currentHeight = 0;
|
|
73247
|
+
for (let i = 0; i < rowSpan && startRow + i < rowHeights.length; i++) {
|
|
73248
|
+
currentHeight += rowHeights[startRow + i];
|
|
73249
|
+
}
|
|
73250
|
+
if (currentHeight < requiredHeight) {
|
|
73251
|
+
const spanLength = Math.min(rowSpan, rowHeights.length - startRow);
|
|
73252
|
+
const increment = spanLength > 0 ? (requiredHeight - currentHeight) / spanLength : 0;
|
|
73253
|
+
for (let i = 0; i < spanLength; i++) {
|
|
73254
|
+
rowHeights[startRow + i] += increment;
|
|
73255
|
+
}
|
|
73256
|
+
}
|
|
73257
|
+
}
|
|
73258
|
+
block.rows.forEach((row, index2) => {
|
|
73259
|
+
const spec = row.attrs?.rowHeight;
|
|
73260
|
+
if (spec?.value != null && Number.isFinite(spec.value)) {
|
|
73261
|
+
const rule = spec.rule ?? "atLeast";
|
|
73262
|
+
if (rule === "exact") {
|
|
73263
|
+
rowHeights[index2] = spec.value;
|
|
73264
|
+
} else {
|
|
73265
|
+
rowHeights[index2] = Math.max(rowHeights[index2], spec.value);
|
|
73266
|
+
}
|
|
73267
|
+
}
|
|
73268
|
+
});
|
|
73269
|
+
for (let i = 0; i < rows.length; i++) {
|
|
73270
|
+
rows[i].height = Math.max(0, rowHeights[i]);
|
|
71851
73271
|
}
|
|
71852
|
-
const totalHeight =
|
|
73272
|
+
const totalHeight = rowHeights.reduce((sum, h2) => sum + h2, 0);
|
|
71853
73273
|
const totalWidth = columnWidths.reduce((a, b2) => a + b2, 0);
|
|
71854
73274
|
return {
|
|
71855
73275
|
kind: "table",
|
|
@@ -72055,7 +73475,7 @@ const resolveLineHeight = (spacing, baseLineHeight) => {
|
|
|
72055
73475
|
if (spacing.lineRule === "atLeast") {
|
|
72056
73476
|
return Math.max(baseLineHeight, raw);
|
|
72057
73477
|
}
|
|
72058
|
-
return raw;
|
|
73478
|
+
return Math.max(baseLineHeight, raw);
|
|
72059
73479
|
};
|
|
72060
73480
|
const sanitizePositive = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0;
|
|
72061
73481
|
const sanitizeDecimalSeparator = (value) => {
|
|
@@ -77945,6 +79365,17 @@ const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ O
|
|
|
77945
79365
|
parseTagObject
|
|
77946
79366
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
77947
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
|
+
};
|
|
77948
79379
|
const StructuredContentCommands = Extension.create({
|
|
77949
79380
|
name: "structuredContentCommands",
|
|
77950
79381
|
addCommands() {
|
|
@@ -78085,7 +79516,7 @@ const StructuredContentCommands = Extension.create({
|
|
|
78085
79516
|
* @param {string} id - Unique identifier of the field
|
|
78086
79517
|
* @param {StructuredContentUpdate} options
|
|
78087
79518
|
* @example
|
|
78088
|
-
* editor.commands.updateStructuredContentById('123', { text: 'Jane Doe' });
|
|
79519
|
+
* editor.commands.updateStructuredContentById('123', { text: 'Jane Doe', keepTextNodeStyles: true });
|
|
78089
79520
|
* editor.commands.updateStructuredContentById('123', {
|
|
78090
79521
|
* json: { type: 'text', text: 'Jane Doe' },
|
|
78091
79522
|
* });
|
|
@@ -78106,7 +79537,9 @@ const StructuredContentCommands = Extension.create({
|
|
|
78106
79537
|
const posTo = pos + node.nodeSize;
|
|
78107
79538
|
let content = null;
|
|
78108
79539
|
if (options.text) {
|
|
78109
|
-
|
|
79540
|
+
const firstTextNode = options.keepTextNodeStyles === true ? findFirstTextNode(node) : null;
|
|
79541
|
+
const textMarks = firstTextNode ? firstTextNode.marks : [];
|
|
79542
|
+
content = schema.text(options.text, textMarks);
|
|
78110
79543
|
}
|
|
78111
79544
|
if (options.html) {
|
|
78112
79545
|
const html = htmlHandler(options.html, editor);
|
|
@@ -78120,6 +79553,13 @@ const StructuredContentCommands = Extension.create({
|
|
|
78120
79553
|
content = node.content;
|
|
78121
79554
|
}
|
|
78122
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
|
+
}
|
|
78123
79563
|
tr.replaceWith(posFrom, posTo, updatedNode);
|
|
78124
79564
|
}
|
|
78125
79565
|
return true;
|
|
@@ -78204,7 +79644,7 @@ const StructuredContentCommands = Extension.create({
|
|
|
78204
79644
|
* @param {StructuredContentUpdate} options
|
|
78205
79645
|
* @example
|
|
78206
79646
|
* // Update all fields in the customer-info group
|
|
78207
|
-
* editor.commands.updateStructuredContentByGroup('customer-info', { text: 'Jane Doe' });
|
|
79647
|
+
* editor.commands.updateStructuredContentByGroup('customer-info', { text: 'Jane Doe', keepTextNodeStyles: true });
|
|
78208
79648
|
*
|
|
78209
79649
|
* // Update block content in a group
|
|
78210
79650
|
* editor.commands.updateStructuredContentByGroup('terms-section', {
|
|
@@ -78218,13 +79658,14 @@ const StructuredContentCommands = Extension.create({
|
|
|
78218
79658
|
}
|
|
78219
79659
|
const { schema } = editor;
|
|
78220
79660
|
if (dispatch) {
|
|
78221
|
-
|
|
79661
|
+
const updates = [];
|
|
79662
|
+
for (const structuredContent of structuredContentTags) {
|
|
78222
79663
|
const { pos, node } = structuredContent;
|
|
78223
|
-
const posFrom = tr.mapping.map(pos);
|
|
78224
|
-
const posTo = tr.mapping.map(pos + node.nodeSize);
|
|
78225
79664
|
let content = null;
|
|
78226
79665
|
if (options.text) {
|
|
78227
|
-
|
|
79666
|
+
const firstTextNode = options.keepTextNodeStyles === true ? findFirstTextNode(node) : null;
|
|
79667
|
+
const textMarks = firstTextNode ? firstTextNode.marks : [];
|
|
79668
|
+
content = schema.text(options.text, textMarks);
|
|
78228
79669
|
}
|
|
78229
79670
|
if (options.html) {
|
|
78230
79671
|
const html = htmlHandler(options.html, editor);
|
|
@@ -78238,11 +79679,23 @@ const StructuredContentCommands = Extension.create({
|
|
|
78238
79679
|
content = node.content;
|
|
78239
79680
|
}
|
|
78240
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);
|
|
78241
79694
|
const currentNode = tr.doc.nodeAt(posFrom);
|
|
78242
79695
|
if (currentNode && node.eq(currentNode)) {
|
|
78243
79696
|
tr.replaceWith(posFrom, posTo, updatedNode);
|
|
78244
79697
|
}
|
|
78245
|
-
}
|
|
79698
|
+
}
|
|
78246
79699
|
}
|
|
78247
79700
|
return true;
|
|
78248
79701
|
},
|
|
@@ -78818,61 +80271,153 @@ const Text = Node$1.create({
|
|
|
78818
80271
|
return {};
|
|
78819
80272
|
}
|
|
78820
80273
|
});
|
|
78821
|
-
const
|
|
78822
|
-
|
|
78823
|
-
|
|
78824
|
-
|
|
78825
|
-
|
|
78826
|
-
|
|
78827
|
-
|
|
78828
|
-
|
|
78829
|
-
|
|
78830
|
-
|
|
78831
|
-
|
|
78832
|
-
|
|
78833
|
-
};
|
|
78834
|
-
|
|
78835
|
-
|
|
78836
|
-
|
|
78837
|
-
|
|
78838
|
-
|
|
78839
|
-
|
|
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;
|
|
78840
80309
|
}
|
|
78841
|
-
|
|
78842
|
-
|
|
78843
|
-
|
|
78844
|
-
|
|
78845
|
-
|
|
78846
|
-
|
|
78847
|
-
|
|
78848
|
-
|
|
78849
|
-
|
|
78850
|
-
|
|
78851
|
-
|
|
78852
|
-
|
|
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);
|
|
78853
80322
|
} else {
|
|
78854
|
-
|
|
78855
|
-
types2.unshift(null);
|
|
80323
|
+
merged.push({ ...range2 });
|
|
78856
80324
|
}
|
|
78857
80325
|
}
|
|
78858
|
-
|
|
78859
|
-
|
|
78860
|
-
|
|
78861
|
-
|
|
78862
|
-
|
|
78863
|
-
|
|
78864
|
-
|
|
78865
|
-
|
|
78866
|
-
|
|
78867
|
-
|
|
78868
|
-
|
|
78869
|
-
|
|
78870
|
-
|
|
78871
|
-
|
|
78872
|
-
|
|
78873
|
-
|
|
78874
|
-
|
|
78875
|
-
|
|
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
|
+
};
|
|
78876
80421
|
const Run = OxmlNode.create({
|
|
78877
80422
|
name: "run",
|
|
78878
80423
|
oXmlName: "w:r",
|
|
@@ -78915,7 +80460,8 @@ const Run = OxmlNode.create({
|
|
|
78915
80460
|
// @ts-expect-error - Command signatures will be fixed in TS migration
|
|
78916
80461
|
addCommands() {
|
|
78917
80462
|
return {
|
|
78918
|
-
|
|
80463
|
+
splitRunToParagraph,
|
|
80464
|
+
splitRunAtCursor
|
|
78919
80465
|
};
|
|
78920
80466
|
},
|
|
78921
80467
|
parseDOM() {
|
|
@@ -78924,6 +80470,9 @@ const Run = OxmlNode.create({
|
|
|
78924
80470
|
renderDOM({ htmlAttributes }) {
|
|
78925
80471
|
const base2 = Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
|
|
78926
80472
|
return ["span", base2, 0];
|
|
80473
|
+
},
|
|
80474
|
+
addPmPlugins() {
|
|
80475
|
+
return [wrapTextInRunsPlugin(), cleanupEmptyRunsPlugin];
|
|
78927
80476
|
}
|
|
78928
80477
|
});
|
|
78929
80478
|
const restartNumbering = ({ editor, tr, state: state2, dispatch }) => {
|
|
@@ -79666,20 +81215,15 @@ function createNumberingPlugin(editor) {
|
|
|
79666
81215
|
} else {
|
|
79667
81216
|
markerText = docxNumberingHelpers.normalizeLvlTextChar(lvlText);
|
|
79668
81217
|
}
|
|
79669
|
-
|
|
81218
|
+
const newListRendering = {
|
|
79670
81219
|
markerText,
|
|
79671
81220
|
suffix: suffix2,
|
|
79672
81221
|
justification,
|
|
79673
81222
|
path,
|
|
79674
81223
|
numberingType: listNumberingType
|
|
79675
|
-
}
|
|
79676
|
-
|
|
79677
|
-
|
|
79678
|
-
suffix: suffix2,
|
|
79679
|
-
justification,
|
|
79680
|
-
path,
|
|
79681
|
-
numberingType: listNumberingType
|
|
79682
|
-
});
|
|
81224
|
+
};
|
|
81225
|
+
if (JSON.stringify(node.attrs.listRendering) !== JSON.stringify(newListRendering)) {
|
|
81226
|
+
tr.setNodeAttribute(pos, "listRendering", newListRendering);
|
|
79683
81227
|
}
|
|
79684
81228
|
return false;
|
|
79685
81229
|
});
|
|
@@ -79980,7 +81524,7 @@ const Paragraph = OxmlNode.create({
|
|
|
79980
81524
|
return null;
|
|
79981
81525
|
}
|
|
79982
81526
|
const { tr } = state2;
|
|
79983
|
-
tr.delete(range2.from, range2.to);
|
|
81527
|
+
tr.delete(range2.from, range2.to).setSelection(TextSelection$1.create(tr.doc, range2.from));
|
|
79984
81528
|
ListHelpers.createNewList({
|
|
79985
81529
|
listType: type2,
|
|
79986
81530
|
tr,
|
|
@@ -83410,7 +84954,10 @@ const Table = Node$1.create({
|
|
|
83410
84954
|
insertTable: ({ rows = 3, cols = 3, withHeaderRow = false } = {}) => ({ tr, dispatch, editor }) => {
|
|
83411
84955
|
const node = createTable(editor.schema, rows, cols, withHeaderRow);
|
|
83412
84956
|
if (dispatch) {
|
|
83413
|
-
|
|
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
|
+
}
|
|
83414
84961
|
tr.replaceSelectionWith(node).scrollIntoView().setSelection(TextSelection$1.near(tr.doc.resolve(offset2)));
|
|
83415
84962
|
}
|
|
83416
84963
|
return true;
|
|
@@ -110748,6 +112295,12 @@ const _sfc_main$4 = {
|
|
|
110748
112295
|
};
|
|
110749
112296
|
const GenericPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-cbddcc0f"]]);
|
|
110750
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;
|
|
110751
112304
|
const _sfc_main$3 = {
|
|
110752
112305
|
__name: "TableResizeOverlay",
|
|
110753
112306
|
props: {
|
|
@@ -110771,26 +112324,73 @@ const _sfc_main$3 = {
|
|
|
110771
112324
|
setup(__props, { emit: __emit }) {
|
|
110772
112325
|
const props = __props;
|
|
110773
112326
|
const emit = __emit;
|
|
112327
|
+
const overlayRect = ref$1(null);
|
|
110774
112328
|
const tableMetadata = ref$1(null);
|
|
110775
112329
|
const dragState = ref$1(null);
|
|
110776
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
|
+
}
|
|
110777
112347
|
const overlayStyle = computed(() => {
|
|
110778
|
-
if (!props.tableElement) return {};
|
|
110779
|
-
const rect =
|
|
112348
|
+
if (!overlayRect.value || !props.tableElement) return {};
|
|
112349
|
+
const rect = overlayRect.value;
|
|
110780
112350
|
let overlayWidth = rect.width;
|
|
110781
112351
|
if (dragState.value) {
|
|
110782
|
-
overlayWidth = Math.max(rect.width +
|
|
112352
|
+
overlayWidth = Math.max(rect.width + DRAG_OVERLAY_EXTENSION_PX, MIN_DRAG_OVERLAY_WIDTH_PX);
|
|
110783
112353
|
}
|
|
110784
112354
|
return {
|
|
110785
112355
|
position: "absolute",
|
|
110786
|
-
left: `${
|
|
110787
|
-
top: `${
|
|
112356
|
+
left: `${rect.left}px`,
|
|
112357
|
+
top: `${rect.top}px`,
|
|
110788
112358
|
width: `${overlayWidth}px`,
|
|
110789
112359
|
height: `${rect.height}px`,
|
|
110790
112360
|
pointerEvents: dragState.value ? "auto" : "none",
|
|
110791
112361
|
zIndex: 10
|
|
110792
112362
|
};
|
|
110793
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
|
+
}
|
|
110794
112394
|
const resizableBoundaries = computed(() => {
|
|
110795
112395
|
if (!tableMetadata.value?.columns) {
|
|
110796
112396
|
return [];
|
|
@@ -110829,9 +112429,9 @@ const _sfc_main$3 = {
|
|
|
110829
112429
|
if (!colSegments || colSegments.length === 0) {
|
|
110830
112430
|
return [];
|
|
110831
112431
|
}
|
|
110832
|
-
return colSegments.map((seg) => ({
|
|
110833
|
-
y: seg.y,
|
|
110834
|
-
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
|
|
110835
112435
|
}));
|
|
110836
112436
|
}
|
|
110837
112437
|
function getSegmentHandleStyle(boundary, segment) {
|
|
@@ -110839,16 +112439,16 @@ const _sfc_main$3 = {
|
|
|
110839
112439
|
position: "absolute",
|
|
110840
112440
|
left: `${boundary.x}px`,
|
|
110841
112441
|
top: segment.y != null ? `${segment.y}px` : "0",
|
|
110842
|
-
width:
|
|
112442
|
+
width: `${RESIZE_HANDLE_WIDTH_PX}px`,
|
|
110843
112443
|
height: segment.h != null ? `${segment.h}px` : "100%",
|
|
110844
|
-
transform:
|
|
112444
|
+
transform: `translateX(-${RESIZE_HANDLE_OFFSET_PX}px)`,
|
|
110845
112445
|
cursor: "col-resize",
|
|
110846
112446
|
pointerEvents: "auto"
|
|
110847
112447
|
};
|
|
110848
112448
|
}
|
|
110849
112449
|
const guidelineStyle = computed(() => {
|
|
110850
112450
|
if (!dragState.value || !tableMetadata.value) return { display: "none" };
|
|
110851
|
-
const initialBoundary = resizableBoundaries.value[dragState.value.
|
|
112451
|
+
const initialBoundary = resizableBoundaries.value[dragState.value.resizableBoundaryIndex];
|
|
110852
112452
|
if (!initialBoundary) return { display: "none" };
|
|
110853
112453
|
const newX = initialBoundary.x + dragState.value.constrainedDelta;
|
|
110854
112454
|
return {
|
|
@@ -110905,11 +112505,11 @@ const _sfc_main$3 = {
|
|
|
110905
112505
|
});
|
|
110906
112506
|
}
|
|
110907
112507
|
}
|
|
110908
|
-
function onHandleMouseDown(event,
|
|
112508
|
+
function onHandleMouseDown(event, resizableBoundaryIndex) {
|
|
110909
112509
|
event.preventDefault();
|
|
110910
112510
|
event.stopPropagation();
|
|
110911
112511
|
if (!tableMetadata.value?.columns) return;
|
|
110912
|
-
const boundary = resizableBoundaries.value[
|
|
112512
|
+
const boundary = resizableBoundaries.value[resizableBoundaryIndex];
|
|
110913
112513
|
if (!boundary) return;
|
|
110914
112514
|
const columns = tableMetadata.value.columns;
|
|
110915
112515
|
const isRightEdge = boundary.type === "right-edge";
|
|
@@ -110917,7 +112517,7 @@ const _sfc_main$3 = {
|
|
|
110917
112517
|
const rightColumn = isRightEdge ? null : columns[boundary.index + 1];
|
|
110918
112518
|
dragState.value = {
|
|
110919
112519
|
columnIndex: boundary.index,
|
|
110920
|
-
|
|
112520
|
+
resizableBoundaryIndex,
|
|
110921
112521
|
isRightEdge,
|
|
110922
112522
|
initialX: event.clientX,
|
|
110923
112523
|
initialWidths: columns.map((col) => col.w),
|
|
@@ -110931,15 +112531,28 @@ const _sfc_main$3 = {
|
|
|
110931
112531
|
} : null,
|
|
110932
112532
|
constrainedDelta: 0
|
|
110933
112533
|
};
|
|
112534
|
+
if (!props.editor?.view?.dom) {
|
|
112535
|
+
emit("resize-error", { error: "Editor view not available" });
|
|
112536
|
+
dragState.value = null;
|
|
112537
|
+
return;
|
|
112538
|
+
}
|
|
110934
112539
|
const pmView = props.editor.view.dom;
|
|
110935
112540
|
pmView.style.pointerEvents = "none";
|
|
110936
|
-
|
|
110937
|
-
|
|
110938
|
-
|
|
110939
|
-
|
|
110940
|
-
|
|
110941
|
-
|
|
110942
|
-
|
|
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
|
+
}
|
|
110943
112556
|
}
|
|
110944
112557
|
function throttle2(func, limit) {
|
|
110945
112558
|
let inThrottle;
|
|
@@ -110964,7 +112577,7 @@ const _sfc_main$3 = {
|
|
|
110964
112577
|
return { throttled, cancel };
|
|
110965
112578
|
}
|
|
110966
112579
|
const mouseMoveThrottle = throttle2((event) => {
|
|
110967
|
-
if (!dragState.value) return;
|
|
112580
|
+
if (isUnmounted || !dragState.value) return;
|
|
110968
112581
|
const delta = event.clientX - dragState.value.initialX;
|
|
110969
112582
|
const minDelta = -(dragState.value.leftColumn.width - dragState.value.leftColumn.minWidth);
|
|
110970
112583
|
let maxDelta;
|
|
@@ -110990,7 +112603,7 @@ const _sfc_main$3 = {
|
|
|
110990
112603
|
columnIndex: dragState.value.columnIndex,
|
|
110991
112604
|
delta: constrainedDelta
|
|
110992
112605
|
});
|
|
110993
|
-
},
|
|
112606
|
+
}, THROTTLE_INTERVAL_MS);
|
|
110994
112607
|
const onDocumentMouseMove2 = mouseMoveThrottle.throttled;
|
|
110995
112608
|
function onDocumentMouseUp(event) {
|
|
110996
112609
|
if (!dragState.value) return;
|
|
@@ -111005,13 +112618,11 @@ const _sfc_main$3 = {
|
|
|
111005
112618
|
}
|
|
111006
112619
|
document.removeEventListener("mousemove", onDocumentMouseMove2);
|
|
111007
112620
|
document.removeEventListener("mouseup", onDocumentMouseUp);
|
|
111008
|
-
if (props.editor?.view) {
|
|
112621
|
+
if (props.editor?.view?.dom) {
|
|
111009
112622
|
const pmView = props.editor.view.dom;
|
|
111010
|
-
|
|
111011
|
-
pmView.style.pointerEvents = "auto";
|
|
111012
|
-
}
|
|
112623
|
+
pmView.style.pointerEvents = "auto";
|
|
111013
112624
|
}
|
|
111014
|
-
if (!forcedCleanup.value && Math.abs(finalDelta) >
|
|
112625
|
+
if (!forcedCleanup.value && Math.abs(finalDelta) > MIN_RESIZE_DELTA_PX) {
|
|
111015
112626
|
dispatchResizeTransaction(columnIndex, newWidths);
|
|
111016
112627
|
emit("resize-end", {
|
|
111017
112628
|
columnIndex,
|
|
@@ -111074,7 +112685,14 @@ const _sfc_main$3 = {
|
|
|
111074
112685
|
if (!pmElement) {
|
|
111075
112686
|
return null;
|
|
111076
112687
|
}
|
|
111077
|
-
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
|
+
}
|
|
111078
112696
|
let tablePos = null;
|
|
111079
112697
|
state2.doc.descendants((node, pos) => {
|
|
111080
112698
|
if (node.type.name === "table") {
|
|
@@ -111126,6 +112744,12 @@ const _sfc_main$3 = {
|
|
|
111126
112744
|
() => props.tableElement,
|
|
111127
112745
|
() => {
|
|
111128
112746
|
parseTableMetadata();
|
|
112747
|
+
updateOverlayRect();
|
|
112748
|
+
if (props.visible && props.tableElement) {
|
|
112749
|
+
startOverlayTracking();
|
|
112750
|
+
} else if (!props.tableElement) {
|
|
112751
|
+
stopOverlayTracking();
|
|
112752
|
+
}
|
|
111129
112753
|
},
|
|
111130
112754
|
{ immediate: true }
|
|
111131
112755
|
);
|
|
@@ -111134,7 +112758,10 @@ const _sfc_main$3 = {
|
|
|
111134
112758
|
(visible) => {
|
|
111135
112759
|
if (visible) {
|
|
111136
112760
|
parseTableMetadata();
|
|
112761
|
+
updateOverlayRect();
|
|
112762
|
+
startOverlayTracking();
|
|
111137
112763
|
} else {
|
|
112764
|
+
stopOverlayTracking();
|
|
111138
112765
|
if (dragState.value) {
|
|
111139
112766
|
forcedCleanup.value = true;
|
|
111140
112767
|
onDocumentMouseUp(new MouseEvent("mouseup"));
|
|
@@ -111143,8 +112770,15 @@ const _sfc_main$3 = {
|
|
|
111143
112770
|
}
|
|
111144
112771
|
}
|
|
111145
112772
|
);
|
|
112773
|
+
onMounted(() => {
|
|
112774
|
+
window.addEventListener("scroll", updateOverlayRect, true);
|
|
112775
|
+
window.addEventListener("resize", updateOverlayRect);
|
|
112776
|
+
updateOverlayRect();
|
|
112777
|
+
});
|
|
111146
112778
|
onBeforeUnmount(() => {
|
|
112779
|
+
isUnmounted = true;
|
|
111147
112780
|
mouseMoveThrottle.cancel();
|
|
112781
|
+
stopOverlayTracking();
|
|
111148
112782
|
if (dragState.value) {
|
|
111149
112783
|
document.removeEventListener("mousemove", onDocumentMouseMove2);
|
|
111150
112784
|
document.removeEventListener("mouseup", onDocumentMouseUp);
|
|
@@ -111152,6 +112786,8 @@ const _sfc_main$3 = {
|
|
|
111152
112786
|
props.editor.view.dom.style.pointerEvents = "auto";
|
|
111153
112787
|
}
|
|
111154
112788
|
}
|
|
112789
|
+
window.removeEventListener("scroll", updateOverlayRect, true);
|
|
112790
|
+
window.removeEventListener("resize", updateOverlayRect);
|
|
111155
112791
|
});
|
|
111156
112792
|
return (_ctx, _cache) => {
|
|
111157
112793
|
return __props.visible && tableMetadata.value ? (openBlock(), createElementBlock("div", {
|
|
@@ -111161,21 +112797,21 @@ const _sfc_main$3 = {
|
|
|
111161
112797
|
onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
111162
112798
|
}, ["stop"]))
|
|
111163
112799
|
}, [
|
|
111164
|
-
(openBlock(true), createElementBlock(Fragment$1, null, renderList(resizableBoundaries.value, (boundary,
|
|
112800
|
+
(openBlock(true), createElementBlock(Fragment$1, null, renderList(resizableBoundaries.value, (boundary, resizableBoundaryIndex) => {
|
|
111165
112801
|
return openBlock(), createElementBlock(Fragment$1, {
|
|
111166
|
-
key: `boundary-${
|
|
112802
|
+
key: `boundary-${resizableBoundaryIndex}`
|
|
111167
112803
|
}, [
|
|
111168
112804
|
(openBlock(true), createElementBlock(Fragment$1, null, renderList(getBoundarySegments(boundary), (segment, segmentIndex) => {
|
|
111169
112805
|
return openBlock(), createElementBlock("div", {
|
|
111170
112806
|
key: `handle-${boundary.type}-${boundary.index}-${segmentIndex}`,
|
|
111171
112807
|
class: normalizeClass(["resize-handle", {
|
|
111172
|
-
"resize-handle--active": dragState.value && dragState.value.
|
|
112808
|
+
"resize-handle--active": dragState.value && dragState.value.resizableBoundaryIndex === resizableBoundaryIndex,
|
|
111173
112809
|
"resize-handle--edge": boundary.type === "right-edge"
|
|
111174
112810
|
}]),
|
|
111175
|
-
"data-boundary-index":
|
|
112811
|
+
"data-boundary-index": resizableBoundaryIndex,
|
|
111176
112812
|
"data-boundary-type": boundary.type,
|
|
111177
112813
|
style: normalizeStyle(getSegmentHandleStyle(boundary, segment)),
|
|
111178
|
-
onMousedown: ($event) => onHandleMouseDown($event,
|
|
112814
|
+
onMousedown: ($event) => onHandleMouseDown($event, resizableBoundaryIndex)
|
|
111179
112815
|
}, null, 46, _hoisted_1$3);
|
|
111180
112816
|
}), 128))
|
|
111181
112817
|
], 64);
|
|
@@ -111189,7 +112825,7 @@ const _sfc_main$3 = {
|
|
|
111189
112825
|
};
|
|
111190
112826
|
}
|
|
111191
112827
|
};
|
|
111192
|
-
const TableResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-
|
|
112828
|
+
const TableResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-2fdf7836"]]);
|
|
111193
112829
|
const _hoisted_1$2 = ["data-handle-position", "onMousedown"];
|
|
111194
112830
|
const OVERLAY_EXPANSION_PX = 2e3;
|
|
111195
112831
|
const RESIZE_HANDLE_SIZE_PX = 12;
|