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
package/dist/superdoc.umd.js
CHANGED
|
@@ -19785,7 +19785,7 @@
|
|
|
19785
19785
|
return runProperties;
|
|
19786
19786
|
}
|
|
19787
19787
|
marks.forEach((mark2) => {
|
|
19788
|
-
switch (mark2.type) {
|
|
19788
|
+
switch (mark2.type.name ?? mark2.type) {
|
|
19789
19789
|
case "strike":
|
|
19790
19790
|
case "italic":
|
|
19791
19791
|
case "bold":
|
|
@@ -20851,6 +20851,11 @@
|
|
|
20851
20851
|
runs2.push(trackedClone);
|
|
20852
20852
|
return;
|
|
20853
20853
|
}
|
|
20854
|
+
if (child.name === "w:commentRangeStart" || child.name === "w:commentRangeEnd") {
|
|
20855
|
+
const commentRangeClone = cloneXmlNode(child);
|
|
20856
|
+
runs2.push(commentRangeClone);
|
|
20857
|
+
return;
|
|
20858
|
+
}
|
|
20854
20859
|
const runWrapper = { name: XML_NODE_NAME$i, elements: [] };
|
|
20855
20860
|
applyBaseRunProps(runWrapper);
|
|
20856
20861
|
if (!Array.isArray(runWrapper.elements)) runWrapper.elements = [];
|
|
@@ -27976,9 +27981,11 @@
|
|
|
27976
27981
|
const newAttrs = {
|
|
27977
27982
|
...paragraphNode.attrs,
|
|
27978
27983
|
paragraphProperties: newProperties,
|
|
27979
|
-
numberingProperties: newProperties.numberingProperties
|
|
27980
|
-
listRendering: null
|
|
27984
|
+
numberingProperties: newProperties.numberingProperties
|
|
27981
27985
|
};
|
|
27986
|
+
if (!newNumberingProperties) {
|
|
27987
|
+
newAttrs.listRendering = null;
|
|
27988
|
+
}
|
|
27982
27989
|
tr.setNodeMarkup(pos, null, newAttrs);
|
|
27983
27990
|
}
|
|
27984
27991
|
const generateNewListDefinition = ({ numId, listType, level, start: start2, text: text2, fmt, editor }) => {
|
|
@@ -28510,13 +28517,36 @@
|
|
|
28510
28517
|
extractAndRemoveConditionalPrefix(item);
|
|
28511
28518
|
});
|
|
28512
28519
|
transformWordLists(tempDiv, editor);
|
|
28513
|
-
|
|
28520
|
+
let doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
28521
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
28514
28522
|
tempDiv.remove();
|
|
28515
28523
|
const { dispatch } = editor.view;
|
|
28516
28524
|
if (!dispatch) return false;
|
|
28517
28525
|
dispatch(view.state.tr.replaceSelectionWith(doc2, true));
|
|
28518
28526
|
return true;
|
|
28519
28527
|
};
|
|
28528
|
+
const wrapTextsInRuns = (doc2) => {
|
|
28529
|
+
const runType = doc2.type?.schema?.nodes?.run;
|
|
28530
|
+
if (!runType) return doc2;
|
|
28531
|
+
const wrapNode = (node2, parent) => {
|
|
28532
|
+
if (node2.isText) {
|
|
28533
|
+
if (parent?.type?.name === "run") return node2;
|
|
28534
|
+
const runProperties = decodeRPrFromMarks(node2.marks);
|
|
28535
|
+
return runType.create({ runProperties }, [node2]);
|
|
28536
|
+
}
|
|
28537
|
+
if (!node2.childCount) return node2;
|
|
28538
|
+
let changed = false;
|
|
28539
|
+
const wrappedChildren = [];
|
|
28540
|
+
node2.forEach((child) => {
|
|
28541
|
+
const wrappedChild = wrapNode(child, node2);
|
|
28542
|
+
if (wrappedChild !== child) changed = true;
|
|
28543
|
+
wrappedChildren.push(wrappedChild);
|
|
28544
|
+
});
|
|
28545
|
+
if (!changed) return node2;
|
|
28546
|
+
return node2.copy(Fragment$1.fromArray(wrappedChildren));
|
|
28547
|
+
};
|
|
28548
|
+
return wrapNode(doc2, null);
|
|
28549
|
+
};
|
|
28520
28550
|
const transformWordLists = (container, editor) => {
|
|
28521
28551
|
const listItems = Array.from(container.querySelectorAll("[data-num-id]"));
|
|
28522
28552
|
const lists = {};
|
|
@@ -28946,7 +28976,8 @@
|
|
|
28946
28976
|
tempDiv.innerHTML = cleanedHtml;
|
|
28947
28977
|
const htmlWithMergedLists = mergeSeparateLists(tempDiv);
|
|
28948
28978
|
const flattenHtml = flattenListsInHtml(htmlWithMergedLists, editor);
|
|
28949
|
-
|
|
28979
|
+
let doc2 = DOMParser$1.fromSchema(editor.schema).parse(flattenHtml);
|
|
28980
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
28950
28981
|
tempDiv.remove();
|
|
28951
28982
|
const { dispatch } = editor.view;
|
|
28952
28983
|
if (!dispatch) return false;
|
|
@@ -29279,7 +29310,8 @@
|
|
|
29279
29310
|
function handleHtmlPaste(html2, editor, source) {
|
|
29280
29311
|
let cleanedHtml;
|
|
29281
29312
|
cleanedHtml = htmlHandler(html2, editor);
|
|
29282
|
-
|
|
29313
|
+
let doc2 = DOMParser$1.fromSchema(editor.schema).parse(cleanedHtml);
|
|
29314
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
29283
29315
|
const { dispatch, state: state2 } = editor.view;
|
|
29284
29316
|
if (!dispatch) return false;
|
|
29285
29317
|
const { $from } = state2.selection;
|
|
@@ -29384,7 +29416,9 @@
|
|
|
29384
29416
|
} else {
|
|
29385
29417
|
parsedContent = content2;
|
|
29386
29418
|
}
|
|
29387
|
-
|
|
29419
|
+
let doc2 = DOMParser$1.fromSchema(editor.schema).parse(parsedContent);
|
|
29420
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
29421
|
+
return doc2;
|
|
29388
29422
|
}
|
|
29389
29423
|
function L() {
|
|
29390
29424
|
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
@@ -30508,9 +30542,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
30508
30542
|
para.textContent = content2;
|
|
30509
30543
|
wrapper.appendChild(para);
|
|
30510
30544
|
doc2 = DOMParser$1.fromSchema(editor.schema).parse(wrapper);
|
|
30545
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
30511
30546
|
break;
|
|
30512
30547
|
case "schema":
|
|
30513
30548
|
doc2 = editor.schema.nodeFromJSON(content2);
|
|
30549
|
+
doc2 = wrapTextsInRuns(doc2);
|
|
30514
30550
|
break;
|
|
30515
30551
|
default:
|
|
30516
30552
|
throw new Error(`Unknown content type: ${type2}`);
|
|
@@ -36267,7 +36303,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36267
36303
|
static getStoredSuperdocVersion(docx) {
|
|
36268
36304
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
36269
36305
|
}
|
|
36270
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.
|
|
36306
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.17") {
|
|
36271
36307
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
36272
36308
|
}
|
|
36273
36309
|
/**
|
|
@@ -55535,6 +55571,83 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
55535
55571
|
tr.insertText(" ", tr.selection.from, tr.selection.to);
|
|
55536
55572
|
return true;
|
|
55537
55573
|
};
|
|
55574
|
+
const splitRunToParagraph = () => (props) => {
|
|
55575
|
+
const { state: state2, view, tr } = props;
|
|
55576
|
+
const { $from, empty: empty2 } = state2.selection;
|
|
55577
|
+
if (!empty2) return false;
|
|
55578
|
+
if ($from.parent.type.name !== "run") return false;
|
|
55579
|
+
const handled = splitBlockPatch(state2, (transaction) => {
|
|
55580
|
+
view.dispatch(transaction);
|
|
55581
|
+
});
|
|
55582
|
+
if (handled) {
|
|
55583
|
+
tr.setMeta("preventDispatch", true);
|
|
55584
|
+
}
|
|
55585
|
+
return handled;
|
|
55586
|
+
};
|
|
55587
|
+
function splitBlockPatch(state2, dispatch) {
|
|
55588
|
+
let { $from } = state2.selection;
|
|
55589
|
+
if (state2.selection instanceof NodeSelection && state2.selection.node.isBlock) {
|
|
55590
|
+
if (!$from.parentOffset || !canSplit(state2.doc, $from.pos)) return false;
|
|
55591
|
+
if (dispatch) dispatch(state2.tr.split($from.pos).scrollIntoView());
|
|
55592
|
+
return true;
|
|
55593
|
+
}
|
|
55594
|
+
if (!$from.depth) return false;
|
|
55595
|
+
let types2 = [];
|
|
55596
|
+
let splitDepth, deflt, atEnd = false, atStart = false;
|
|
55597
|
+
for (let d2 = $from.depth; ; d2--) {
|
|
55598
|
+
let node2 = $from.node(d2);
|
|
55599
|
+
if (node2.isBlock) {
|
|
55600
|
+
atEnd = $from.end(d2) == $from.pos + ($from.depth - d2);
|
|
55601
|
+
atStart = $from.start(d2) == $from.pos - ($from.depth - d2);
|
|
55602
|
+
deflt = defaultBlockAt$1($from.node(d2 - 1).contentMatchAt($from.indexAfter(d2 - 1)));
|
|
55603
|
+
types2.unshift(null);
|
|
55604
|
+
splitDepth = d2;
|
|
55605
|
+
break;
|
|
55606
|
+
} else {
|
|
55607
|
+
if (d2 == 1) return false;
|
|
55608
|
+
types2.unshift(null);
|
|
55609
|
+
}
|
|
55610
|
+
}
|
|
55611
|
+
let tr = state2.tr;
|
|
55612
|
+
if (state2.selection instanceof TextSelection$1 || state2.selection instanceof AllSelection) tr.deleteSelection();
|
|
55613
|
+
let splitPos = tr.mapping.map($from.pos);
|
|
55614
|
+
let can = canSplit(tr.doc, splitPos, types2.length, types2);
|
|
55615
|
+
if (!can) {
|
|
55616
|
+
types2[0] = deflt ? { type: deflt } : null;
|
|
55617
|
+
can = canSplit(tr.doc, splitPos, types2.length, types2);
|
|
55618
|
+
}
|
|
55619
|
+
if (!can) return false;
|
|
55620
|
+
tr.split(splitPos, types2.length, types2);
|
|
55621
|
+
if (!atEnd && atStart && $from.node(splitDepth).type != deflt) {
|
|
55622
|
+
let first2 = tr.mapping.map($from.before(splitDepth)), $first = tr.doc.resolve(first2);
|
|
55623
|
+
if (deflt && $from.node(splitDepth - 1).canReplaceWith($first.index(), $first.index() + 1, deflt))
|
|
55624
|
+
tr.setNodeMarkup(tr.mapping.map($from.before(splitDepth)), deflt);
|
|
55625
|
+
}
|
|
55626
|
+
if (dispatch) dispatch(tr.scrollIntoView());
|
|
55627
|
+
return true;
|
|
55628
|
+
}
|
|
55629
|
+
const splitRunAtCursor = () => (props) => {
|
|
55630
|
+
let { state: state2, dispatch, tr } = props;
|
|
55631
|
+
const sel = state2.selection;
|
|
55632
|
+
if (!sel.empty) return false;
|
|
55633
|
+
const $pos = sel.$from;
|
|
55634
|
+
const runType = state2.schema.nodes.run;
|
|
55635
|
+
if ($pos.parent.type !== runType) return false;
|
|
55636
|
+
const run2 = $pos.parent;
|
|
55637
|
+
const offset2 = $pos.parentOffset;
|
|
55638
|
+
const runStart = $pos.before();
|
|
55639
|
+
const runEnd = runStart + run2.nodeSize;
|
|
55640
|
+
const leftFrag = run2.content.cut(0, offset2);
|
|
55641
|
+
const rightFrag = run2.content.cut(offset2);
|
|
55642
|
+
const leftRun = runType.create(run2.attrs, leftFrag, run2.marks);
|
|
55643
|
+
const rightRun = runType.create(run2.attrs, rightFrag, run2.marks);
|
|
55644
|
+
const gapPos = runStart + leftRun.nodeSize;
|
|
55645
|
+
tr.replaceWith(runStart, runEnd, [leftRun, rightRun]).setSelection(TextSelection$1.create(tr.doc, gapPos));
|
|
55646
|
+
if (dispatch) {
|
|
55647
|
+
dispatch(tr);
|
|
55648
|
+
}
|
|
55649
|
+
return true;
|
|
55650
|
+
};
|
|
55538
55651
|
const insertTabCharacter = ({ tr, state: state2, dispatch }) => {
|
|
55539
55652
|
const { from: from2 } = tr.selection;
|
|
55540
55653
|
const tabText = state2.schema.text(" ");
|
|
@@ -55544,10 +55657,23 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
55544
55657
|
return true;
|
|
55545
55658
|
};
|
|
55546
55659
|
const insertTabNode = () => ({ tr, state: state2, dispatch }) => {
|
|
55547
|
-
|
|
55660
|
+
let newPos = tr.selection.from;
|
|
55548
55661
|
const tabNode = state2.schema?.nodes?.tab?.create();
|
|
55549
55662
|
if (!tabNode) return insertTabCharacter({ tr, state: state2, dispatch });
|
|
55663
|
+
const { from: from2 } = tr.selection;
|
|
55664
|
+
const $pos = tr.doc.resolve(from2);
|
|
55665
|
+
if ($pos.parent.type === state2.schema.nodes.run) {
|
|
55666
|
+
if (from2 === $pos.end()) {
|
|
55667
|
+
newPos = $pos.end() + 1;
|
|
55668
|
+
} else if (from2 === $pos.start()) {
|
|
55669
|
+
newPos = $pos.start() - 1;
|
|
55670
|
+
} else {
|
|
55671
|
+
splitRunAtCursor()({ tr, state: state2 });
|
|
55672
|
+
newPos = tr.selection.from;
|
|
55673
|
+
}
|
|
55674
|
+
}
|
|
55550
55675
|
tr.insert(newPos, tabNode);
|
|
55676
|
+
tr = tr.setSelection(TextSelection$1.create(tr.doc, newPos + tabNode.nodeSize));
|
|
55551
55677
|
if (dispatch) dispatch(tr);
|
|
55552
55678
|
return true;
|
|
55553
55679
|
};
|
|
@@ -57003,6 +57129,139 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
57003
57129
|
"paragraphProperties.spacing.lineRule"
|
|
57004
57130
|
);
|
|
57005
57131
|
};
|
|
57132
|
+
const backspaceEmptyRunParagraph = () => ({ state: state2, dispatch }) => {
|
|
57133
|
+
const { $from } = state2.selection;
|
|
57134
|
+
if (!state2.selection.empty) return false;
|
|
57135
|
+
const paraType = state2.schema.nodes.paragraph;
|
|
57136
|
+
const runType = state2.schema.nodes.run;
|
|
57137
|
+
const para = $from.parent;
|
|
57138
|
+
if (para.type !== paraType || para.childCount !== 1 || para.firstChild.type !== runType || para.firstChild.content.size)
|
|
57139
|
+
return false;
|
|
57140
|
+
if (state2.doc.childCount === 1 && $from.depth === 1) return false;
|
|
57141
|
+
if (dispatch) {
|
|
57142
|
+
const paraPos = $from.before();
|
|
57143
|
+
let tr = state2.tr.deleteRange(paraPos, paraPos + para.nodeSize).scrollIntoView();
|
|
57144
|
+
const targetPos = Math.max(1, Math.min(paraPos - 1, tr.doc.content.size));
|
|
57145
|
+
tr = tr.setSelection(TextSelection$1.create(tr.doc, targetPos));
|
|
57146
|
+
dispatch(tr);
|
|
57147
|
+
}
|
|
57148
|
+
return true;
|
|
57149
|
+
};
|
|
57150
|
+
const backspaceSkipEmptyRun = () => ({ state: state2, dispatch }) => {
|
|
57151
|
+
const sel = state2.selection;
|
|
57152
|
+
if (!sel.empty) return false;
|
|
57153
|
+
const runType = state2.schema.nodes.run;
|
|
57154
|
+
const $pos = sel.$from;
|
|
57155
|
+
const emptyRun = (n) => n && n.type === runType && n.content.size === 0;
|
|
57156
|
+
if ($pos.parent.type !== runType || $pos.pos !== $pos.end() || !emptyRun(state2.doc.nodeAt($pos.pos + 1))) {
|
|
57157
|
+
return false;
|
|
57158
|
+
}
|
|
57159
|
+
const leftTextSel = Selection.findFrom($pos, -1, true);
|
|
57160
|
+
if (!leftTextSel) return false;
|
|
57161
|
+
const pos = leftTextSel.$from.pos;
|
|
57162
|
+
if (dispatch) {
|
|
57163
|
+
dispatch(state2.tr.delete(pos - 1, pos).scrollIntoView());
|
|
57164
|
+
}
|
|
57165
|
+
return true;
|
|
57166
|
+
};
|
|
57167
|
+
const backspaceNextToRun = () => ({ state: state2, tr, dispatch }) => {
|
|
57168
|
+
const sel = state2.selection;
|
|
57169
|
+
if (!sel.empty) return false;
|
|
57170
|
+
const runType = state2.schema.nodes.run;
|
|
57171
|
+
const $pos = sel.$from;
|
|
57172
|
+
if ($pos.nodeBefore?.type !== runType && $pos.pos !== $pos.start()) return false;
|
|
57173
|
+
if ($pos.nodeBefore) {
|
|
57174
|
+
if ($pos.nodeBefore.content.size === 0) return false;
|
|
57175
|
+
tr.delete($pos.pos - 2, $pos.pos - 1).setSelection(Selection.near(tr.doc.resolve($pos.pos - 2)));
|
|
57176
|
+
if (dispatch) {
|
|
57177
|
+
dispatch(tr.scrollIntoView());
|
|
57178
|
+
}
|
|
57179
|
+
} else {
|
|
57180
|
+
const prevNode = state2.doc.resolve($pos.start() - 1).nodeBefore;
|
|
57181
|
+
if (prevNode?.type !== runType || prevNode.content.size === 0) return false;
|
|
57182
|
+
tr.delete($pos.pos - 3, $pos.pos - 2).setSelection(Selection.near(tr.doc.resolve($pos.pos - 3)));
|
|
57183
|
+
if (dispatch) {
|
|
57184
|
+
dispatch(tr.scrollIntoView());
|
|
57185
|
+
}
|
|
57186
|
+
}
|
|
57187
|
+
return true;
|
|
57188
|
+
};
|
|
57189
|
+
const deleteSkipEmptyRun = () => ({ state: state2, dispatch }) => {
|
|
57190
|
+
const sel = state2.selection;
|
|
57191
|
+
if (!sel.empty) return false;
|
|
57192
|
+
const runType = state2.schema.nodes.run;
|
|
57193
|
+
const $pos = sel.$from;
|
|
57194
|
+
const emptyRun = (n) => n && n.type === runType && n.content.size === 0;
|
|
57195
|
+
if ($pos.parent.type === runType && emptyRun(state2.doc.nodeAt($pos.end() + 1))) {
|
|
57196
|
+
if ($pos.pos === $pos.end()) {
|
|
57197
|
+
return deleteFromEndOfRun(state2, dispatch, $pos);
|
|
57198
|
+
} else if ($pos.pos === $pos.end() - 1) {
|
|
57199
|
+
return deleteFromLastCharacter(state2, dispatch, $pos);
|
|
57200
|
+
}
|
|
57201
|
+
return false;
|
|
57202
|
+
}
|
|
57203
|
+
return false;
|
|
57204
|
+
};
|
|
57205
|
+
function deleteFromEndOfRun(state2, dispatch, $pos) {
|
|
57206
|
+
const rightRun = state2.doc.nodeAt($pos.pos + 1);
|
|
57207
|
+
const $afterRightRunPos = state2.doc.resolve($pos.pos + 2 + rightRun.nodeSize);
|
|
57208
|
+
const rightTextSel = Selection.findFrom($afterRightRunPos, 1, true);
|
|
57209
|
+
if (!rightTextSel) return false;
|
|
57210
|
+
const pos = rightTextSel.$from.pos;
|
|
57211
|
+
if (dispatch) {
|
|
57212
|
+
dispatch(state2.tr.delete(pos, pos + 1).scrollIntoView());
|
|
57213
|
+
}
|
|
57214
|
+
return true;
|
|
57215
|
+
}
|
|
57216
|
+
function deleteFromLastCharacter(state2, dispatch, $pos) {
|
|
57217
|
+
if (dispatch) {
|
|
57218
|
+
dispatch(state2.tr.delete($pos.pos, $pos.pos + 1).scrollIntoView());
|
|
57219
|
+
}
|
|
57220
|
+
return true;
|
|
57221
|
+
}
|
|
57222
|
+
const deleteNextToRun = () => ({ state: state2, tr, dispatch }) => {
|
|
57223
|
+
const sel = state2.selection;
|
|
57224
|
+
if (!sel.empty) return false;
|
|
57225
|
+
const runType = state2.schema.nodes.run;
|
|
57226
|
+
const $pos = sel.$from;
|
|
57227
|
+
if ($pos.nodeAfter?.type !== runType && $pos.pos !== $pos.end()) return false;
|
|
57228
|
+
if ($pos.nodeAfter) {
|
|
57229
|
+
if ($pos.nodeAfter.content.size === 0) return false;
|
|
57230
|
+
tr.delete($pos.pos + 1, $pos.pos + 2).setSelection(Selection.near(tr.doc.resolve($pos.pos + 1)));
|
|
57231
|
+
if (dispatch) {
|
|
57232
|
+
dispatch(tr.scrollIntoView());
|
|
57233
|
+
}
|
|
57234
|
+
} else {
|
|
57235
|
+
const nextNode = state2.doc.resolve($pos.end() + 1).nodeAfter;
|
|
57236
|
+
if (nextNode?.type !== runType || nextNode.content.size === 0) return false;
|
|
57237
|
+
tr.delete($pos.pos + 2, $pos.pos + 3).setSelection(Selection.near(tr.doc.resolve($pos.pos + 2)));
|
|
57238
|
+
if (dispatch) {
|
|
57239
|
+
dispatch(tr.scrollIntoView());
|
|
57240
|
+
}
|
|
57241
|
+
}
|
|
57242
|
+
return true;
|
|
57243
|
+
};
|
|
57244
|
+
function skipTab(dir) {
|
|
57245
|
+
return ({ state: state2, dispatch }) => {
|
|
57246
|
+
const tab = state2.schema.nodes.tab;
|
|
57247
|
+
const run2 = state2.schema.nodes.run;
|
|
57248
|
+
const sel = state2.selection;
|
|
57249
|
+
if (!tab || !sel.empty) return false;
|
|
57250
|
+
const $pos = sel.$from;
|
|
57251
|
+
if ($pos.parent.type !== run2) return false;
|
|
57252
|
+
if (dir > 0 && $pos.pos < $pos.end()) return false;
|
|
57253
|
+
if (dir < 0 && $pos.pos > $pos.start()) return false;
|
|
57254
|
+
const step = dir > 0 ? 1 : -1;
|
|
57255
|
+
let $nextPos = state2.doc.resolve($pos.pos + step);
|
|
57256
|
+
const nextNode = dir > 0 ? $nextPos.nodeAfter : $nextPos.nodeBefore;
|
|
57257
|
+
if (!nextNode || nextNode.type !== tab) return false;
|
|
57258
|
+
const nextPos = dir > 0 ? Math.min($nextPos.pos + nextNode.nodeSize + 1, state2.doc.nodeSize) : Math.max(0, $nextPos.pos - nextNode.nodeSize - 1);
|
|
57259
|
+
if (dispatch) {
|
|
57260
|
+
dispatch(state2.tr.setSelection(TextSelection$1.create(state2.doc, nextPos)));
|
|
57261
|
+
}
|
|
57262
|
+
return true;
|
|
57263
|
+
};
|
|
57264
|
+
}
|
|
57006
57265
|
const toggleList = (listType) => ({ editor, state: state2, tr, dispatch }) => {
|
|
57007
57266
|
let predicate;
|
|
57008
57267
|
if (listType === "orderedList") {
|
|
@@ -57078,6 +57337,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
57078
57337
|
}
|
|
57079
57338
|
updateNumberingProperties(sharedNumberingProperties, node2, pos, editor, tr);
|
|
57080
57339
|
}
|
|
57340
|
+
const newTo = tr.mapping.map(to);
|
|
57341
|
+
if (newTo >= 0 && newTo <= tr.doc.content.size) {
|
|
57342
|
+
try {
|
|
57343
|
+
tr.setSelection(state2.selection.constructor.near(tr.doc.resolve(newTo)));
|
|
57344
|
+
} catch {
|
|
57345
|
+
}
|
|
57346
|
+
}
|
|
57081
57347
|
if (dispatch) dispatch(tr);
|
|
57082
57348
|
return true;
|
|
57083
57349
|
};
|
|
@@ -57196,6 +57462,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
57196
57462
|
};
|
|
57197
57463
|
const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
57198
57464
|
__proto__: null,
|
|
57465
|
+
backspaceEmptyRunParagraph,
|
|
57466
|
+
backspaceNextToRun,
|
|
57467
|
+
backspaceSkipEmptyRun,
|
|
57199
57468
|
changeListLevel,
|
|
57200
57469
|
clearNodes,
|
|
57201
57470
|
command,
|
|
@@ -57203,7 +57472,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
57203
57472
|
decreaseListIndent,
|
|
57204
57473
|
decreaseTextIndent,
|
|
57205
57474
|
defaultStyleDetector,
|
|
57475
|
+
deleteNextToRun,
|
|
57206
57476
|
deleteSelection,
|
|
57477
|
+
deleteSkipEmptyRun,
|
|
57207
57478
|
exitCode,
|
|
57208
57479
|
first,
|
|
57209
57480
|
getEffectiveStyleId,
|
|
@@ -57241,6 +57512,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
57241
57512
|
setSectionHeaderFooterAtSelection,
|
|
57242
57513
|
setTextIndentation,
|
|
57243
57514
|
setTextSelection,
|
|
57515
|
+
skipTab,
|
|
57244
57516
|
splitBlock: splitBlock$1,
|
|
57245
57517
|
toggleList,
|
|
57246
57518
|
toggleMark,
|
|
@@ -57262,7 +57534,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
57262
57534
|
});
|
|
57263
57535
|
const handleEnter = (editor) => {
|
|
57264
57536
|
return editor.commands.first(({ commands: commands2 }) => [
|
|
57265
|
-
() => commands2.
|
|
57537
|
+
() => commands2.splitRunToParagraph(),
|
|
57266
57538
|
() => commands2.newlineInCode(),
|
|
57267
57539
|
() => commands2.createParagraphNear(),
|
|
57268
57540
|
() => commands2.liftEmptyBlock(),
|
|
@@ -57276,6 +57548,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
57276
57548
|
tr.setMeta("inputType", "deleteContentBackward");
|
|
57277
57549
|
return false;
|
|
57278
57550
|
},
|
|
57551
|
+
() => commands2.backspaceEmptyRunParagraph(),
|
|
57552
|
+
() => commands2.backspaceSkipEmptyRun(),
|
|
57553
|
+
() => commands2.backspaceNextToRun(),
|
|
57279
57554
|
() => commands2.deleteSelection(),
|
|
57280
57555
|
() => commands2.removeNumberingProperties(),
|
|
57281
57556
|
() => commands2.joinBackward(),
|
|
@@ -57284,6 +57559,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
57284
57559
|
};
|
|
57285
57560
|
const handleDelete$1 = (editor) => {
|
|
57286
57561
|
return editor.commands.first(({ commands: commands2 }) => [
|
|
57562
|
+
() => commands2.deleteSkipEmptyRun(),
|
|
57563
|
+
() => commands2.deleteNextToRun(),
|
|
57287
57564
|
() => commands2.deleteSelection(),
|
|
57288
57565
|
() => commands2.joinForward(),
|
|
57289
57566
|
() => commands2.selectNodeForward()
|
|
@@ -57302,7 +57579,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
57302
57579
|
Delete: () => handleDelete$1(this.editor),
|
|
57303
57580
|
"Mod-Delete": () => handleDelete$1(this.editor),
|
|
57304
57581
|
"Mod-a": () => this.editor.commands.selectAll(),
|
|
57305
|
-
Tab: () => this.editor.commands.insertTabNode()
|
|
57582
|
+
Tab: () => this.editor.commands.insertTabNode(),
|
|
57583
|
+
ArrowLeft: () => this.editor.commands.skipTab(-1),
|
|
57584
|
+
ArrowRight: () => this.editor.commands.skipTab(1)
|
|
57306
57585
|
};
|
|
57307
57586
|
const pcBaseKeymap = {
|
|
57308
57587
|
...baseKeymap
|
|
@@ -60852,7 +61131,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
60852
61131
|
const shouldSkipNodeView = (editor) => {
|
|
60853
61132
|
return isHeadless(editor);
|
|
60854
61133
|
};
|
|
60855
|
-
const summaryVersion = "1.0.0-beta.
|
|
61134
|
+
const summaryVersion = "1.0.0-beta.17";
|
|
60856
61135
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
60857
61136
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
60858
61137
|
function mapAttributes(attrs) {
|
|
@@ -61362,12 +61641,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61362
61641
|
if (!this.schema) {
|
|
61363
61642
|
throw new Error("Schema is not initialized.");
|
|
61364
61643
|
}
|
|
61365
|
-
const topNodeName = this.schema.topNodeType?.name || "doc";
|
|
61366
|
-
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] } : (() => {
|
|
61367
|
-
throw new Error("Invalid document shape: expected a node object or an array of node objects.");
|
|
61368
|
-
})();
|
|
61369
61644
|
try {
|
|
61370
|
-
return this.schema.nodeFromJSON(
|
|
61645
|
+
if (Array.isArray(doc2)) return doc2.map((d2) => this.schema.nodeFromJSON(d2));
|
|
61646
|
+
return this.schema.nodeFromJSON(doc2);
|
|
61371
61647
|
} catch (error) {
|
|
61372
61648
|
const detail = error instanceof Error ? error.message : String(error);
|
|
61373
61649
|
const validationError = new Error(`Invalid document for current schema: ${detail}`);
|
|
@@ -61631,7 +61907,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61631
61907
|
{ default: remarkStringify2 },
|
|
61632
61908
|
{ default: remarkGfm2 }
|
|
61633
61909
|
] = await Promise.all([
|
|
61634
|
-
Promise.resolve().then(() =>
|
|
61910
|
+
Promise.resolve().then(() => indexVCeRjVPO),
|
|
61635
61911
|
Promise.resolve().then(() => indexDRCvimau),
|
|
61636
61912
|
Promise.resolve().then(() => indexC_x_N6Uh),
|
|
61637
61913
|
Promise.resolve().then(() => indexD_sWOSiG),
|
|
@@ -61836,7 +62112,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61836
62112
|
* Process collaboration migrations
|
|
61837
62113
|
*/
|
|
61838
62114
|
processCollaborationMigrations() {
|
|
61839
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
62115
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.17");
|
|
61840
62116
|
if (!this.options.ydoc) return;
|
|
61841
62117
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
61842
62118
|
let docVersion = metaMap.get("version");
|
|
@@ -62911,7 +63187,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
62911
63187
|
const normalized = value.trim().toLowerCase();
|
|
62912
63188
|
return normalized || void 0;
|
|
62913
63189
|
};
|
|
62914
|
-
const normalizeColor = (value) => {
|
|
63190
|
+
const normalizeColor$1 = (value) => {
|
|
62915
63191
|
if (typeof value !== "string") return void 0;
|
|
62916
63192
|
const trimmed = value.trim();
|
|
62917
63193
|
if (!trimmed || trimmed === "auto" || trimmed === "none") return void 0;
|
|
@@ -63551,14 +63827,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
63551
63827
|
const resolveColorFromAttributes = (attrs, themeColors) => {
|
|
63552
63828
|
if (!attrs) return void 0;
|
|
63553
63829
|
if (typeof attrs.color === "string") {
|
|
63554
|
-
const normalized = normalizeColor(attrs.color);
|
|
63830
|
+
const normalized = normalizeColor$1(attrs.color);
|
|
63555
63831
|
if (normalized) {
|
|
63556
63832
|
return normalized;
|
|
63557
63833
|
}
|
|
63558
63834
|
}
|
|
63559
63835
|
const theme = resolveThemeColor(attrs, themeColors);
|
|
63560
63836
|
if (theme) {
|
|
63561
|
-
return normalizeColor(theme);
|
|
63837
|
+
return normalizeColor$1(theme);
|
|
63562
63838
|
}
|
|
63563
63839
|
return void 0;
|
|
63564
63840
|
};
|
|
@@ -63993,13 +64269,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
63993
64269
|
const borderSizeToPx = (size2) => {
|
|
63994
64270
|
if (!isFiniteNumber(size2)) return void 0;
|
|
63995
64271
|
if (size2 <= 0) return 0;
|
|
63996
|
-
|
|
63997
|
-
|
|
63998
|
-
pixelValue = size2;
|
|
63999
|
-
} else {
|
|
64000
|
-
const points = size2 / EIGHTHS_PER_POINT;
|
|
64001
|
-
pixelValue = points * PX_PER_PT;
|
|
64002
|
-
}
|
|
64272
|
+
const points = size2 / EIGHTHS_PER_POINT;
|
|
64273
|
+
const pixelValue = points * PX_PER_PT;
|
|
64003
64274
|
return Math.min(MAX_BORDER_SIZE_PX, Math.max(MIN_BORDER_SIZE_PX, pixelValue));
|
|
64004
64275
|
};
|
|
64005
64276
|
const normalizeColorWithDefault = (color2) => {
|
|
@@ -64138,7 +64409,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
64138
64409
|
if (style2 === "none") return void 0;
|
|
64139
64410
|
const width = pickNumber(raw.size);
|
|
64140
64411
|
const widthPx = borderSizeToPx(width);
|
|
64141
|
-
const color2 = normalizeColor(raw.color);
|
|
64412
|
+
const color2 = normalizeColor$1(raw.color);
|
|
64142
64413
|
const space = pickNumber(raw.space);
|
|
64143
64414
|
if (!style2 && widthPx == null && space == null && !color2) {
|
|
64144
64415
|
return void 0;
|
|
@@ -64194,7 +64465,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
64194
64465
|
return Object.keys(shading).length > 0 ? shading : void 0;
|
|
64195
64466
|
};
|
|
64196
64467
|
const normalizeShadingColor = (value) => {
|
|
64197
|
-
const normalized = normalizeColor(value);
|
|
64468
|
+
const normalized = normalizeColor$1(value);
|
|
64198
64469
|
if (!normalized) return void 0;
|
|
64199
64470
|
if (normalized.toLowerCase() === "#auto") {
|
|
64200
64471
|
return void 0;
|
|
@@ -65357,11 +65628,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
65357
65628
|
baselineOffsetPx: markerRun.baselineShift ?? 0,
|
|
65358
65629
|
gutterWidthPx: markerBoxWidthPx,
|
|
65359
65630
|
justification: numbering.lvlJc ?? "left",
|
|
65360
|
-
suffix: normalizeSuffix(numbering.suffix) ?? "tab",
|
|
65631
|
+
suffix: normalizeSuffix$1(numbering.suffix) ?? "tab",
|
|
65361
65632
|
run: markerRun,
|
|
65362
65633
|
path: numbering.path
|
|
65363
65634
|
});
|
|
65364
|
-
const normalizeSuffix = (suffix2) => {
|
|
65635
|
+
const normalizeSuffix$1 = (suffix2) => {
|
|
65365
65636
|
if (suffix2 === "tab" || suffix2 === "space" || suffix2 === "nothing") {
|
|
65366
65637
|
return suffix2;
|
|
65367
65638
|
}
|
|
@@ -65815,6 +66086,154 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
65815
66086
|
};
|
|
65816
66087
|
const { resolveSpacingIndent } = Engines;
|
|
65817
66088
|
const DEFAULT_DECIMAL_SEPARATOR$2 = ".";
|
|
66089
|
+
const asOoxmlElement = (value) => {
|
|
66090
|
+
if (!value || typeof value !== "object") return void 0;
|
|
66091
|
+
const element2 = value;
|
|
66092
|
+
if (element2.name == null && element2.attributes == null && element2.elements == null) return void 0;
|
|
66093
|
+
return element2;
|
|
66094
|
+
};
|
|
66095
|
+
const findChild = (parent, name) => {
|
|
66096
|
+
return parent?.elements?.find((child) => child?.name === name);
|
|
66097
|
+
};
|
|
66098
|
+
const getAttribute = (element2, key2) => {
|
|
66099
|
+
if (!element2?.attributes) return void 0;
|
|
66100
|
+
const attrs = element2.attributes;
|
|
66101
|
+
return attrs[key2] ?? attrs[key2.startsWith("w:") ? key2.slice(2) : `w:${key2}`];
|
|
66102
|
+
};
|
|
66103
|
+
const parseNumberAttr = (value) => {
|
|
66104
|
+
if (value == null) return void 0;
|
|
66105
|
+
const num = typeof value === "number" ? value : Number.parseInt(String(value), 10);
|
|
66106
|
+
return Number.isFinite(num) ? num : void 0;
|
|
66107
|
+
};
|
|
66108
|
+
const normalizeNumFmt = (value) => {
|
|
66109
|
+
if (typeof value !== "string") return void 0;
|
|
66110
|
+
switch (value) {
|
|
66111
|
+
case "decimal":
|
|
66112
|
+
return "decimal";
|
|
66113
|
+
case "lowerLetter":
|
|
66114
|
+
return "lowerLetter";
|
|
66115
|
+
case "upperLetter":
|
|
66116
|
+
return "upperLetter";
|
|
66117
|
+
case "lowerRoman":
|
|
66118
|
+
return "lowerRoman";
|
|
66119
|
+
case "upperRoman":
|
|
66120
|
+
return "upperRoman";
|
|
66121
|
+
case "bullet":
|
|
66122
|
+
return "bullet";
|
|
66123
|
+
default:
|
|
66124
|
+
return void 0;
|
|
66125
|
+
}
|
|
66126
|
+
};
|
|
66127
|
+
const normalizeSuffix = (value) => {
|
|
66128
|
+
if (typeof value !== "string") return void 0;
|
|
66129
|
+
if (value === "tab" || value === "space" || value === "nothing") {
|
|
66130
|
+
return value;
|
|
66131
|
+
}
|
|
66132
|
+
return void 0;
|
|
66133
|
+
};
|
|
66134
|
+
const normalizeJustification = (value) => {
|
|
66135
|
+
if (typeof value !== "string") return void 0;
|
|
66136
|
+
if (value === "start") return "left";
|
|
66137
|
+
if (value === "end") return "right";
|
|
66138
|
+
if (value === "left" || value === "center" || value === "right") return value;
|
|
66139
|
+
return void 0;
|
|
66140
|
+
};
|
|
66141
|
+
const extractIndentFromLevel = (lvl) => {
|
|
66142
|
+
const pPr = findChild(lvl, "w:pPr");
|
|
66143
|
+
const ind = findChild(pPr, "w:ind");
|
|
66144
|
+
if (!ind) return void 0;
|
|
66145
|
+
const left2 = parseNumberAttr(getAttribute(ind, "w:left"));
|
|
66146
|
+
const right2 = parseNumberAttr(getAttribute(ind, "w:right"));
|
|
66147
|
+
const firstLine = parseNumberAttr(getAttribute(ind, "w:firstLine"));
|
|
66148
|
+
const hanging = parseNumberAttr(getAttribute(ind, "w:hanging"));
|
|
66149
|
+
const indent2 = {};
|
|
66150
|
+
if (left2 != null) indent2.left = left2;
|
|
66151
|
+
if (right2 != null) indent2.right = right2;
|
|
66152
|
+
if (firstLine != null) indent2.firstLine = firstLine;
|
|
66153
|
+
if (hanging != null) indent2.hanging = hanging;
|
|
66154
|
+
return Object.keys(indent2).length ? indent2 : void 0;
|
|
66155
|
+
};
|
|
66156
|
+
const normalizeColor = (value) => {
|
|
66157
|
+
if (typeof value !== "string") return void 0;
|
|
66158
|
+
const trimmed = value.trim();
|
|
66159
|
+
if (!trimmed || trimmed.toLowerCase() === "auto") return void 0;
|
|
66160
|
+
const upper = trimmed.startsWith("#") ? trimmed.slice(1) : trimmed;
|
|
66161
|
+
return `#${upper.toUpperCase()}`;
|
|
66162
|
+
};
|
|
66163
|
+
const extractMarkerRun = (lvl) => {
|
|
66164
|
+
const rPr = findChild(lvl, "w:rPr");
|
|
66165
|
+
if (!rPr) return void 0;
|
|
66166
|
+
const run2 = {};
|
|
66167
|
+
const rFonts = findChild(rPr, "w:rFonts");
|
|
66168
|
+
const font = getAttribute(rFonts, "w:ascii") ?? getAttribute(rFonts, "w:hAnsi") ?? getAttribute(rFonts, "w:eastAsia");
|
|
66169
|
+
if (typeof font === "string" && font.trim()) {
|
|
66170
|
+
run2.fontFamily = font;
|
|
66171
|
+
}
|
|
66172
|
+
const sz = parseNumberAttr(getAttribute(findChild(rPr, "w:sz"), "w:val")) ?? parseNumberAttr(getAttribute(findChild(rPr, "w:szCs"), "w:val"));
|
|
66173
|
+
if (sz != null) {
|
|
66174
|
+
run2.fontSize = sz / 2;
|
|
66175
|
+
}
|
|
66176
|
+
const color2 = normalizeColor(getAttribute(findChild(rPr, "w:color"), "w:val"));
|
|
66177
|
+
if (color2) run2.color = color2;
|
|
66178
|
+
if (findChild(rPr, "w:b")) run2.bold = true;
|
|
66179
|
+
if (findChild(rPr, "w:i")) run2.italic = true;
|
|
66180
|
+
const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
|
|
66181
|
+
if (spacingTwips != null && Number.isFinite(spacingTwips)) {
|
|
66182
|
+
run2.letterSpacing = twipsToPx$1(spacingTwips);
|
|
66183
|
+
}
|
|
66184
|
+
return Object.keys(run2).length ? run2 : void 0;
|
|
66185
|
+
};
|
|
66186
|
+
const findNumFmtElement = (lvl) => {
|
|
66187
|
+
if (!lvl) return void 0;
|
|
66188
|
+
const direct = findChild(lvl, "w:numFmt");
|
|
66189
|
+
if (direct) return direct;
|
|
66190
|
+
const alternate = findChild(lvl, "mc:AlternateContent");
|
|
66191
|
+
const choice = findChild(alternate, "mc:Choice");
|
|
66192
|
+
if (choice) {
|
|
66193
|
+
return findChild(choice, "w:numFmt");
|
|
66194
|
+
}
|
|
66195
|
+
return void 0;
|
|
66196
|
+
};
|
|
66197
|
+
const resolveNumberingFromContext = (numId, ilvl, numbering) => {
|
|
66198
|
+
const definitions = numbering?.definitions;
|
|
66199
|
+
const abstracts = numbering?.abstracts;
|
|
66200
|
+
if (!definitions || !abstracts) return void 0;
|
|
66201
|
+
const numDef = asOoxmlElement(definitions[String(numId)]);
|
|
66202
|
+
if (!numDef) return void 0;
|
|
66203
|
+
const abstractId = getAttribute(findChild(numDef, "w:abstractNumId"), "w:val");
|
|
66204
|
+
if (abstractId == null) return void 0;
|
|
66205
|
+
const abstract = asOoxmlElement(abstracts[String(abstractId)]);
|
|
66206
|
+
if (!abstract) return void 0;
|
|
66207
|
+
let levelDef = abstract.elements?.find(
|
|
66208
|
+
(el) => el?.name === "w:lvl" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
|
|
66209
|
+
);
|
|
66210
|
+
const override = numDef.elements?.find(
|
|
66211
|
+
(el) => el?.name === "w:lvlOverride" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
|
|
66212
|
+
);
|
|
66213
|
+
const overrideLvl = findChild(override, "w:lvl");
|
|
66214
|
+
if (overrideLvl) {
|
|
66215
|
+
levelDef = overrideLvl;
|
|
66216
|
+
}
|
|
66217
|
+
const startOverride = parseNumberAttr(getAttribute(findChild(override, "w:startOverride"), "w:val"));
|
|
66218
|
+
if (!levelDef) return void 0;
|
|
66219
|
+
const numFmtEl = findNumFmtElement(levelDef);
|
|
66220
|
+
const lvlText = getAttribute(findChild(levelDef, "w:lvlText"), "w:val");
|
|
66221
|
+
const start2 = startOverride ?? parseNumberAttr(getAttribute(findChild(levelDef, "w:start"), "w:val"));
|
|
66222
|
+
const suffix2 = normalizeSuffix(getAttribute(findChild(levelDef, "w:suff"), "w:val"));
|
|
66223
|
+
const lvlJc = normalizeJustification(getAttribute(findChild(levelDef, "w:lvlJc"), "w:val"));
|
|
66224
|
+
const indent2 = extractIndentFromLevel(levelDef);
|
|
66225
|
+
const markerRun = extractMarkerRun(levelDef);
|
|
66226
|
+
const numFmt = normalizeNumFmt(getAttribute(numFmtEl, "w:val"));
|
|
66227
|
+
return {
|
|
66228
|
+
format: numFmt,
|
|
66229
|
+
lvlText,
|
|
66230
|
+
start: start2,
|
|
66231
|
+
suffix: suffix2,
|
|
66232
|
+
lvlJc,
|
|
66233
|
+
resolvedLevelIndent: indent2,
|
|
66234
|
+
resolvedMarkerRpr: markerRun
|
|
66235
|
+
};
|
|
66236
|
+
};
|
|
65818
66237
|
const isTruthy = (value) => {
|
|
65819
66238
|
if (value === true || value === 1) return true;
|
|
65820
66239
|
if (typeof value === "string") {
|
|
@@ -66447,6 +66866,30 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66447
66866
|
const ilvl = Number.isFinite(numberingProps.ilvl) ? Math.max(0, Math.floor(Number(numberingProps.ilvl))) : 0;
|
|
66448
66867
|
const listRendering = normalizeListRenderingAttrs(attrs.listRendering);
|
|
66449
66868
|
const numericNumId = typeof numId === "number" ? numId : void 0;
|
|
66869
|
+
const resolvedLevel = resolveNumberingFromContext(numId, ilvl, converterContext?.numbering);
|
|
66870
|
+
if (resolvedLevel) {
|
|
66871
|
+
if (resolvedLevel.format && numberingProps.format == null) {
|
|
66872
|
+
numberingProps.format = resolvedLevel.format;
|
|
66873
|
+
}
|
|
66874
|
+
if (resolvedLevel.lvlText && numberingProps.lvlText == null) {
|
|
66875
|
+
numberingProps.lvlText = resolvedLevel.lvlText;
|
|
66876
|
+
}
|
|
66877
|
+
if (resolvedLevel.start != null && numberingProps.start == null) {
|
|
66878
|
+
numberingProps.start = resolvedLevel.start;
|
|
66879
|
+
}
|
|
66880
|
+
if (resolvedLevel.suffix && numberingProps.suffix == null) {
|
|
66881
|
+
numberingProps.suffix = resolvedLevel.suffix;
|
|
66882
|
+
}
|
|
66883
|
+
if (resolvedLevel.lvlJc && numberingProps.lvlJc == null) {
|
|
66884
|
+
numberingProps.lvlJc = resolvedLevel.lvlJc;
|
|
66885
|
+
}
|
|
66886
|
+
if (resolvedLevel.resolvedLevelIndent && !numberingProps.resolvedLevelIndent) {
|
|
66887
|
+
numberingProps.resolvedLevelIndent = resolvedLevel.resolvedLevelIndent;
|
|
66888
|
+
}
|
|
66889
|
+
if (resolvedLevel.resolvedMarkerRpr && !numberingProps.resolvedMarkerRpr) {
|
|
66890
|
+
numberingProps.resolvedMarkerRpr = resolvedLevel.resolvedMarkerRpr;
|
|
66891
|
+
}
|
|
66892
|
+
}
|
|
66450
66893
|
let counterValue = 1;
|
|
66451
66894
|
if (listCounterContext && typeof numericNumId === "number") {
|
|
66452
66895
|
counterValue = listCounterContext.incrementListCounter(numericNumId, ilvl);
|
|
@@ -67672,41 +68115,45 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
67672
68115
|
}
|
|
67673
68116
|
return;
|
|
67674
68117
|
}
|
|
67675
|
-
if (node2.type === "hardBreak") {
|
|
67676
|
-
flushParagraph();
|
|
67677
|
-
blocks2.push({
|
|
67678
|
-
kind: "pageBreak",
|
|
67679
|
-
id: nextId(),
|
|
67680
|
-
attrs: node2.attrs || {}
|
|
67681
|
-
});
|
|
67682
|
-
return;
|
|
67683
|
-
}
|
|
67684
|
-
if (node2.type === "lineBreak") {
|
|
68118
|
+
if (node2.type === "hardBreak" || node2.type === "lineBreak") {
|
|
67685
68119
|
const attrs = node2.attrs ?? {};
|
|
67686
|
-
|
|
68120
|
+
const breakType = attrs.pageBreakType ?? attrs.lineBreakType ?? "line";
|
|
68121
|
+
if (breakType === "page") {
|
|
68122
|
+
flushParagraph();
|
|
68123
|
+
blocks2.push({
|
|
68124
|
+
kind: "pageBreak",
|
|
68125
|
+
id: nextId(),
|
|
68126
|
+
attrs: node2.attrs || {}
|
|
68127
|
+
});
|
|
68128
|
+
return;
|
|
68129
|
+
}
|
|
68130
|
+
if (breakType === "column") {
|
|
67687
68131
|
flushParagraph();
|
|
67688
68132
|
blocks2.push({
|
|
67689
68133
|
kind: "columnBreak",
|
|
67690
68134
|
id: nextId(),
|
|
67691
68135
|
attrs: node2.attrs || {}
|
|
67692
68136
|
});
|
|
68137
|
+
return;
|
|
68138
|
+
}
|
|
68139
|
+
const lineBreakRun = { kind: "lineBreak", attrs: {} };
|
|
68140
|
+
const lbAttrs = {};
|
|
68141
|
+
if (attrs.lineBreakType) lbAttrs.lineBreakType = String(attrs.lineBreakType);
|
|
68142
|
+
if (attrs.clear) lbAttrs.clear = String(attrs.clear);
|
|
68143
|
+
if (Object.keys(lbAttrs).length > 0) {
|
|
68144
|
+
lineBreakRun.attrs = lbAttrs;
|
|
67693
68145
|
} else {
|
|
67694
|
-
|
|
67695
|
-
|
|
67696
|
-
|
|
67697
|
-
|
|
67698
|
-
|
|
67699
|
-
|
|
67700
|
-
|
|
67701
|
-
|
|
67702
|
-
|
|
67703
|
-
const pos = positions.get(node2);
|
|
67704
|
-
if (pos) {
|
|
67705
|
-
lineBreakRun.pmStart = pos.start;
|
|
67706
|
-
lineBreakRun.pmEnd = pos.end;
|
|
67707
|
-
}
|
|
67708
|
-
currentRuns.push(lineBreakRun);
|
|
68146
|
+
delete lineBreakRun.attrs;
|
|
68147
|
+
}
|
|
68148
|
+
const pos = positions.get(node2);
|
|
68149
|
+
if (pos) {
|
|
68150
|
+
lineBreakRun.pmStart = pos.start;
|
|
68151
|
+
lineBreakRun.pmEnd = pos.end;
|
|
68152
|
+
}
|
|
68153
|
+
if (activeSdt) {
|
|
68154
|
+
lineBreakRun.sdt = activeSdt;
|
|
67709
68155
|
}
|
|
68156
|
+
currentRuns.push(lineBreakRun);
|
|
67710
68157
|
return;
|
|
67711
68158
|
}
|
|
67712
68159
|
};
|
|
@@ -68299,6 +68746,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68299
68746
|
};
|
|
68300
68747
|
const isTableRowNode = (node2) => node2.type === "tableRow" || node2.type === "table_row";
|
|
68301
68748
|
const isTableCellNode = (node2) => node2.type === "tableCell" || node2.type === "table_cell" || node2.type === "tableHeader" || node2.type === "table_header";
|
|
68749
|
+
const normalizeRowHeight = (rowProps) => {
|
|
68750
|
+
if (!rowProps || typeof rowProps !== "object") return void 0;
|
|
68751
|
+
const rawRowHeight = rowProps.rowHeight;
|
|
68752
|
+
if (!rawRowHeight || typeof rawRowHeight !== "object") return void 0;
|
|
68753
|
+
const heightObj = rawRowHeight;
|
|
68754
|
+
const rawValue = pickNumber(heightObj.value ?? heightObj.val);
|
|
68755
|
+
if (rawValue == null) return void 0;
|
|
68756
|
+
const rawRule = heightObj.rule ?? heightObj.hRule;
|
|
68757
|
+
const rule = rawRule === "exact" || rawRule === "atLeast" || rawRule === "auto" ? rawRule : "atLeast";
|
|
68758
|
+
const isLikelyTwips = rawValue >= 300 || Math.abs(rawValue % 15) < 1e-6;
|
|
68759
|
+
const valuePx = isLikelyTwips ? twipsToPx$1(rawValue) : rawValue;
|
|
68760
|
+
return {
|
|
68761
|
+
value: valuePx,
|
|
68762
|
+
rule
|
|
68763
|
+
};
|
|
68764
|
+
};
|
|
68302
68765
|
const parseTableCell = (args) => {
|
|
68303
68766
|
const { cellNode, rowIndex, cellIndex, context, defaultCellPadding } = args;
|
|
68304
68767
|
if (!isTableCellNode(cellNode) || !Array.isArray(cellNode.content)) {
|
|
@@ -68336,8 +68799,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68336
68799
|
const padding = extractCellPadding(cellNode.attrs ?? {}) ?? (defaultCellPadding ? { ...defaultCellPadding } : void 0);
|
|
68337
68800
|
if (padding) cellAttrs.padding = padding;
|
|
68338
68801
|
const verticalAlign = cellNode.attrs?.verticalAlign;
|
|
68339
|
-
|
|
68340
|
-
|
|
68802
|
+
const normalizedVerticalAlign = verticalAlign === "middle" ? "center" : verticalAlign === "center" ? "center" : verticalAlign;
|
|
68803
|
+
if (normalizedVerticalAlign === "top" || normalizedVerticalAlign === "center" || normalizedVerticalAlign === "bottom") {
|
|
68804
|
+
cellAttrs.verticalAlign = normalizedVerticalAlign;
|
|
68341
68805
|
}
|
|
68342
68806
|
const background = cellNode.attrs?.background;
|
|
68343
68807
|
if (background && typeof background.color === "string") {
|
|
@@ -68380,15 +68844,89 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68380
68844
|
});
|
|
68381
68845
|
if (cells.length === 0) return null;
|
|
68382
68846
|
const rowProps = rowNode.attrs?.tableRowProperties;
|
|
68847
|
+
const rowHeight = normalizeRowHeight(rowProps);
|
|
68383
68848
|
const attrs = rowProps && typeof rowProps === "object" ? {
|
|
68384
|
-
tableRowProperties: rowProps
|
|
68385
|
-
|
|
68849
|
+
tableRowProperties: rowProps,
|
|
68850
|
+
...rowHeight ? { rowHeight } : {}
|
|
68851
|
+
} : rowHeight ? { rowHeight } : void 0;
|
|
68386
68852
|
return {
|
|
68387
68853
|
id: context.nextBlockId(`row-${rowIndex}`),
|
|
68388
68854
|
cells,
|
|
68389
68855
|
attrs
|
|
68390
68856
|
};
|
|
68391
68857
|
};
|
|
68858
|
+
function extractFloatingTableAnchorWrap(node2) {
|
|
68859
|
+
const tableProperties = node2.attrs?.tableProperties;
|
|
68860
|
+
const floatingProps = tableProperties?.floatingTableProperties;
|
|
68861
|
+
if (!floatingProps) {
|
|
68862
|
+
return {};
|
|
68863
|
+
}
|
|
68864
|
+
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;
|
|
68865
|
+
if (!hasPositioning) {
|
|
68866
|
+
return {};
|
|
68867
|
+
}
|
|
68868
|
+
const mapHorzAnchor = (val) => {
|
|
68869
|
+
switch (val) {
|
|
68870
|
+
case "page":
|
|
68871
|
+
return "page";
|
|
68872
|
+
case "margin":
|
|
68873
|
+
return "margin";
|
|
68874
|
+
case "text":
|
|
68875
|
+
default:
|
|
68876
|
+
return "column";
|
|
68877
|
+
}
|
|
68878
|
+
};
|
|
68879
|
+
const mapVertAnchor = (val) => {
|
|
68880
|
+
switch (val) {
|
|
68881
|
+
case "page":
|
|
68882
|
+
return "page";
|
|
68883
|
+
case "margin":
|
|
68884
|
+
return "margin";
|
|
68885
|
+
case "text":
|
|
68886
|
+
default:
|
|
68887
|
+
return "paragraph";
|
|
68888
|
+
}
|
|
68889
|
+
};
|
|
68890
|
+
const anchor = {
|
|
68891
|
+
isAnchored: true,
|
|
68892
|
+
hRelativeFrom: mapHorzAnchor(floatingProps.horzAnchor),
|
|
68893
|
+
vRelativeFrom: mapVertAnchor(floatingProps.vertAnchor)
|
|
68894
|
+
};
|
|
68895
|
+
if (floatingProps.tblpXSpec) {
|
|
68896
|
+
anchor.alignH = floatingProps.tblpXSpec;
|
|
68897
|
+
}
|
|
68898
|
+
if (floatingProps.tblpYSpec) {
|
|
68899
|
+
anchor.alignV = floatingProps.tblpYSpec;
|
|
68900
|
+
}
|
|
68901
|
+
if (floatingProps.tblpX !== void 0) {
|
|
68902
|
+
anchor.offsetH = twipsToPx$1(floatingProps.tblpX);
|
|
68903
|
+
}
|
|
68904
|
+
if (floatingProps.tblpY !== void 0) {
|
|
68905
|
+
anchor.offsetV = twipsToPx$1(floatingProps.tblpY);
|
|
68906
|
+
}
|
|
68907
|
+
const hasDistances = floatingProps.leftFromText !== void 0 || floatingProps.rightFromText !== void 0 || floatingProps.topFromText !== void 0 || floatingProps.bottomFromText !== void 0;
|
|
68908
|
+
const wrap2 = {
|
|
68909
|
+
type: "Square",
|
|
68910
|
+
// Floating tables with text distances use square wrapping
|
|
68911
|
+
wrapText: "bothSides"
|
|
68912
|
+
// Default to text on both sides
|
|
68913
|
+
};
|
|
68914
|
+
if (hasDistances) {
|
|
68915
|
+
if (floatingProps.topFromText !== void 0) {
|
|
68916
|
+
wrap2.distTop = twipsToPx$1(floatingProps.topFromText);
|
|
68917
|
+
}
|
|
68918
|
+
if (floatingProps.bottomFromText !== void 0) {
|
|
68919
|
+
wrap2.distBottom = twipsToPx$1(floatingProps.bottomFromText);
|
|
68920
|
+
}
|
|
68921
|
+
if (floatingProps.leftFromText !== void 0) {
|
|
68922
|
+
wrap2.distLeft = twipsToPx$1(floatingProps.leftFromText);
|
|
68923
|
+
}
|
|
68924
|
+
if (floatingProps.rightFromText !== void 0) {
|
|
68925
|
+
wrap2.distRight = twipsToPx$1(floatingProps.rightFromText);
|
|
68926
|
+
}
|
|
68927
|
+
}
|
|
68928
|
+
return { anchor, wrap: wrap2 };
|
|
68929
|
+
}
|
|
68392
68930
|
function tableNodeToBlock$1(node2, nextBlockId, positions, defaultFont, defaultSize, _styleContext, trackedChanges, bookmarks, hyperlinkConfig, themeColors, paragraphToFlowBlocks2, converterContext) {
|
|
68393
68931
|
if (!Array.isArray(node2.content) || node2.content.length === 0) return null;
|
|
68394
68932
|
if (!paragraphToFlowBlocks2) return null;
|
|
@@ -68453,6 +68991,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68453
68991
|
if (tableLayout) {
|
|
68454
68992
|
tableAttrs.tableLayout = tableLayout;
|
|
68455
68993
|
}
|
|
68994
|
+
const tableProperties = node2.attrs?.tableProperties;
|
|
68995
|
+
if (tableProperties && typeof tableProperties === "object") {
|
|
68996
|
+
tableAttrs.tableProperties = tableProperties;
|
|
68997
|
+
}
|
|
68456
68998
|
let columnWidths = void 0;
|
|
68457
68999
|
const twipsToPixels2 = (twips) => {
|
|
68458
69000
|
const PIXELS_PER_INCH2 = 96;
|
|
@@ -68496,12 +69038,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68496
69038
|
columnWidths = void 0;
|
|
68497
69039
|
}
|
|
68498
69040
|
}
|
|
69041
|
+
const { anchor, wrap: wrap2 } = extractFloatingTableAnchorWrap(node2);
|
|
68499
69042
|
const tableBlock = {
|
|
68500
69043
|
kind: "table",
|
|
68501
69044
|
id: nextBlockId("table"),
|
|
68502
69045
|
rows,
|
|
68503
69046
|
attrs: Object.keys(tableAttrs).length > 0 ? tableAttrs : void 0,
|
|
68504
|
-
columnWidths
|
|
69047
|
+
columnWidths,
|
|
69048
|
+
...anchor ? { anchor } : {},
|
|
69049
|
+
...wrap2 ? { wrap: wrap2 } : {}
|
|
68505
69050
|
};
|
|
68506
69051
|
return tableBlock;
|
|
68507
69052
|
}
|
|
@@ -68837,7 +69382,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68837
69382
|
return measurementCtx;
|
|
68838
69383
|
}
|
|
68839
69384
|
function getRunFontString(run2) {
|
|
68840
|
-
if (run2.kind === "tab" || run2.kind === "lineBreak" || "src" in run2) {
|
|
69385
|
+
if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || "src" in run2) {
|
|
68841
69386
|
return "normal normal 16px Arial";
|
|
68842
69387
|
}
|
|
68843
69388
|
const style2 = run2.italic ? "italic" : "normal";
|
|
@@ -68864,6 +69409,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68864
69409
|
result.push(run2);
|
|
68865
69410
|
continue;
|
|
68866
69411
|
}
|
|
69412
|
+
if (run2.kind === "break") {
|
|
69413
|
+
result.push(run2);
|
|
69414
|
+
continue;
|
|
69415
|
+
}
|
|
68867
69416
|
const text2 = run2.text ?? "";
|
|
68868
69417
|
const isFirstRun = runIndex === line.fromRun;
|
|
68869
69418
|
const isLastRun = runIndex === line.toRun;
|
|
@@ -68897,7 +69446,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68897
69446
|
1,
|
|
68898
69447
|
runs22.reduce((sum, run2) => {
|
|
68899
69448
|
if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
|
|
68900
|
-
if ("src" in run2 || run2.kind === "lineBreak") return sum;
|
|
69449
|
+
if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") return sum;
|
|
68901
69450
|
return sum + (run2.text ?? "").length;
|
|
68902
69451
|
}, 0)
|
|
68903
69452
|
);
|
|
@@ -68918,7 +69467,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68918
69467
|
currentCharOffset += runLength2;
|
|
68919
69468
|
continue;
|
|
68920
69469
|
}
|
|
68921
|
-
const text2 = "src" in run2 || run2.kind === "lineBreak" ? "" : run2.text ?? "";
|
|
69470
|
+
const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
|
|
68922
69471
|
const runLength = text2.length;
|
|
68923
69472
|
if (currentCharOffset + runLength >= charOffset) {
|
|
68924
69473
|
const offsetInRun = charOffset - currentCharOffset;
|
|
@@ -68961,7 +69510,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68961
69510
|
if (isTabRun$1(run2)) {
|
|
68962
69511
|
return segmentBaseX + (offsetInSegment > 0 ? segment.width ?? 0 : 0);
|
|
68963
69512
|
}
|
|
68964
|
-
if ("src" in run2 || run2.kind === "lineBreak") {
|
|
69513
|
+
if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") {
|
|
68965
69514
|
return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
|
|
68966
69515
|
}
|
|
68967
69516
|
const text2 = run2.text ?? "";
|
|
@@ -68984,7 +69533,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68984
69533
|
1,
|
|
68985
69534
|
runs22.reduce((sum, run2) => {
|
|
68986
69535
|
if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
|
|
68987
|
-
if ("src" in run2 || run2.kind === "lineBreak") return sum;
|
|
69536
|
+
if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") return sum;
|
|
68988
69537
|
return sum + (run2.text ?? "").length;
|
|
68989
69538
|
}, 0)
|
|
68990
69539
|
);
|
|
@@ -69019,7 +69568,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
69019
69568
|
currentCharOffset += TAB_CHAR_LENGTH;
|
|
69020
69569
|
continue;
|
|
69021
69570
|
}
|
|
69022
|
-
const text2 = "src" in run2 || run2.kind === "lineBreak" ? "" : run2.text ?? "";
|
|
69571
|
+
const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
|
|
69023
69572
|
const runLength = text2.length;
|
|
69024
69573
|
if (runLength === 0) continue;
|
|
69025
69574
|
ctx2.font = getRunFontString(run2);
|
|
@@ -69452,6 +70001,40 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
69452
70001
|
};
|
|
69453
70002
|
zones.push(zone);
|
|
69454
70003
|
},
|
|
70004
|
+
registerTable(tableBlock, measure, anchorY, columnIndex, pageNumber) {
|
|
70005
|
+
if (!tableBlock.anchor?.isAnchored) {
|
|
70006
|
+
return;
|
|
70007
|
+
}
|
|
70008
|
+
const { wrap: wrap2, anchor } = tableBlock;
|
|
70009
|
+
const wrapType = wrap2?.type ?? "None";
|
|
70010
|
+
if (wrapType === "None") {
|
|
70011
|
+
return;
|
|
70012
|
+
}
|
|
70013
|
+
const tableWidth = measure.totalWidth ?? 0;
|
|
70014
|
+
const tableHeight = measure.totalHeight ?? 0;
|
|
70015
|
+
const x2 = computeTableAnchorX(anchor, columnIndex, columns, tableWidth, margins, pageWidth);
|
|
70016
|
+
const y2 = anchorY + (anchor.offsetV ?? 0);
|
|
70017
|
+
const zone = {
|
|
70018
|
+
imageBlockId: tableBlock.id,
|
|
70019
|
+
// Reusing imageBlockId field for table id
|
|
70020
|
+
pageNumber,
|
|
70021
|
+
columnIndex,
|
|
70022
|
+
bounds: {
|
|
70023
|
+
x: x2,
|
|
70024
|
+
y: y2,
|
|
70025
|
+
width: tableWidth,
|
|
70026
|
+
height: tableHeight
|
|
70027
|
+
},
|
|
70028
|
+
distances: {
|
|
70029
|
+
top: wrap2?.distTop ?? 0,
|
|
70030
|
+
bottom: wrap2?.distBottom ?? 0,
|
|
70031
|
+
left: wrap2?.distLeft ?? 0,
|
|
70032
|
+
right: wrap2?.distRight ?? 0
|
|
70033
|
+
},
|
|
70034
|
+
wrapMode: computeTableWrapMode(wrap2)
|
|
70035
|
+
};
|
|
70036
|
+
zones.push(zone);
|
|
70037
|
+
},
|
|
69455
70038
|
getExclusionsForLine(lineY, lineHeight2, columnIndex, pageNumber) {
|
|
69456
70039
|
const result = zones.filter((zone) => {
|
|
69457
70040
|
if (zone.pageNumber !== pageNumber || zone.columnIndex !== columnIndex) {
|
|
@@ -69559,6 +70142,49 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
69559
70142
|
if (wrapText === "largest") return "largest";
|
|
69560
70143
|
return "both";
|
|
69561
70144
|
}
|
|
70145
|
+
function computeTableAnchorX(anchor, columnIndex, columns, tableWidth, margins, pageWidth) {
|
|
70146
|
+
const alignH = anchor.alignH ?? "left";
|
|
70147
|
+
const offsetH = anchor.offsetH ?? 0;
|
|
70148
|
+
const marginLeft = Math.max(0, margins?.left ?? 0);
|
|
70149
|
+
const marginRight = Math.max(0, margins?.right ?? 0);
|
|
70150
|
+
const contentWidth = pageWidth != null ? Math.max(1, pageWidth - (marginLeft + marginRight)) : columns.width;
|
|
70151
|
+
const contentLeft = marginLeft;
|
|
70152
|
+
const columnLeft = contentLeft + columnIndex * (columns.width + columns.gap);
|
|
70153
|
+
const relativeFrom = anchor.hRelativeFrom ?? "column";
|
|
70154
|
+
let baseX;
|
|
70155
|
+
let availableWidth;
|
|
70156
|
+
if (relativeFrom === "page") {
|
|
70157
|
+
if (columns.count === 1) {
|
|
70158
|
+
baseX = contentLeft;
|
|
70159
|
+
availableWidth = contentWidth;
|
|
70160
|
+
} else {
|
|
70161
|
+
baseX = 0;
|
|
70162
|
+
availableWidth = pageWidth != null ? pageWidth : contentWidth;
|
|
70163
|
+
}
|
|
70164
|
+
} else if (relativeFrom === "margin") {
|
|
70165
|
+
baseX = contentLeft;
|
|
70166
|
+
availableWidth = contentWidth;
|
|
70167
|
+
} else {
|
|
70168
|
+
baseX = columnLeft;
|
|
70169
|
+
availableWidth = columns.width;
|
|
70170
|
+
}
|
|
70171
|
+
let effectiveAlignH = alignH;
|
|
70172
|
+
if (alignH === "inside") effectiveAlignH = "left";
|
|
70173
|
+
if (alignH === "outside") effectiveAlignH = "right";
|
|
70174
|
+
const result = effectiveAlignH === "left" ? baseX + offsetH : effectiveAlignH === "right" ? baseX + availableWidth - tableWidth - offsetH : effectiveAlignH === "center" ? baseX + (availableWidth - tableWidth) / 2 + offsetH : baseX;
|
|
70175
|
+
return result;
|
|
70176
|
+
}
|
|
70177
|
+
function computeTableWrapMode(wrap2) {
|
|
70178
|
+
if (!wrap2) return "none";
|
|
70179
|
+
if (wrap2.type === "None") {
|
|
70180
|
+
return "none";
|
|
70181
|
+
}
|
|
70182
|
+
const wrapText = wrap2.wrapText ?? "bothSides";
|
|
70183
|
+
if (wrapText === "left") return "right";
|
|
70184
|
+
if (wrapText === "right") return "left";
|
|
70185
|
+
if (wrapText === "largest") return "largest";
|
|
70186
|
+
return "both";
|
|
70187
|
+
}
|
|
69562
70188
|
function computeNextSectionPropsAtBreak(blocks2) {
|
|
69563
70189
|
const nextSectionPropsAtBreak = /* @__PURE__ */ new Map();
|
|
69564
70190
|
const docxBreakIndexes = [];
|
|
@@ -69977,6 +70603,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
69977
70603
|
};
|
|
69978
70604
|
if (measure.marker) {
|
|
69979
70605
|
fragment.markerWidth = measure.marker.markerWidth;
|
|
70606
|
+
if (measure.marker.markerTextWidth != null) {
|
|
70607
|
+
fragment.markerTextWidth = measure.marker.markerTextWidth;
|
|
70608
|
+
}
|
|
69980
70609
|
}
|
|
69981
70610
|
state2.page.fragments.push(fragment);
|
|
69982
70611
|
state2.trailingSpacing = 0;
|
|
@@ -70078,6 +70707,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
70078
70707
|
};
|
|
70079
70708
|
if (measure.marker && fromLine === 0) {
|
|
70080
70709
|
fragment.markerWidth = measure.marker.markerWidth;
|
|
70710
|
+
if (measure.marker.markerTextWidth != null) {
|
|
70711
|
+
fragment.markerTextWidth = measure.marker.markerTextWidth;
|
|
70712
|
+
}
|
|
70713
|
+
if (measure.kind === "paragraph" && measure.marker?.gutterWidth != null) {
|
|
70714
|
+
fragment.markerGutter = measure.marker.gutterWidth;
|
|
70715
|
+
}
|
|
70081
70716
|
}
|
|
70082
70717
|
if (fromLine > 0) fragment.continuesFromPrev = true;
|
|
70083
70718
|
if (slice2.toLine < lines.length) fragment.continuesOnNext = true;
|
|
@@ -70255,6 +70890,206 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
70255
70890
|
}
|
|
70256
70891
|
return boundaries;
|
|
70257
70892
|
}
|
|
70893
|
+
function countHeaderRows(block) {
|
|
70894
|
+
let count = 0;
|
|
70895
|
+
for (let i2 = 0; i2 < block.rows.length; i2++) {
|
|
70896
|
+
const row2 = block.rows[i2];
|
|
70897
|
+
const repeatHeader = row2.attrs?.tableRowProperties?.repeatHeader;
|
|
70898
|
+
if (repeatHeader === true) {
|
|
70899
|
+
count++;
|
|
70900
|
+
} else {
|
|
70901
|
+
break;
|
|
70902
|
+
}
|
|
70903
|
+
}
|
|
70904
|
+
return count;
|
|
70905
|
+
}
|
|
70906
|
+
function sumRowHeights(rows, fromRow, toRow) {
|
|
70907
|
+
let total = 0;
|
|
70908
|
+
for (let i2 = fromRow; i2 < toRow && i2 < rows.length; i2++) {
|
|
70909
|
+
total += rows[i2].height;
|
|
70910
|
+
}
|
|
70911
|
+
return total;
|
|
70912
|
+
}
|
|
70913
|
+
function calculateFragmentHeight(fragment, measure, _headerCount) {
|
|
70914
|
+
let height = 0;
|
|
70915
|
+
if (fragment.repeatHeaderCount && fragment.repeatHeaderCount > 0) {
|
|
70916
|
+
height += sumRowHeights(measure.rows, 0, fragment.repeatHeaderCount);
|
|
70917
|
+
}
|
|
70918
|
+
height += sumRowHeights(measure.rows, fragment.fromRow, fragment.toRow);
|
|
70919
|
+
return height;
|
|
70920
|
+
}
|
|
70921
|
+
const MIN_PARTIAL_ROW_HEIGHT = 20;
|
|
70922
|
+
function getCellLines(cell2) {
|
|
70923
|
+
if (cell2.blocks && cell2.blocks.length > 0) {
|
|
70924
|
+
const allLines = [];
|
|
70925
|
+
for (const block of cell2.blocks) {
|
|
70926
|
+
if (block.kind === "paragraph") {
|
|
70927
|
+
if (block.kind === "paragraph" && "lines" in block) {
|
|
70928
|
+
const paraBlock = block;
|
|
70929
|
+
if (paraBlock.lines) {
|
|
70930
|
+
allLines.push(...paraBlock.lines);
|
|
70931
|
+
}
|
|
70932
|
+
}
|
|
70933
|
+
}
|
|
70934
|
+
}
|
|
70935
|
+
return allLines;
|
|
70936
|
+
}
|
|
70937
|
+
if (cell2.paragraph?.lines) {
|
|
70938
|
+
return cell2.paragraph.lines;
|
|
70939
|
+
}
|
|
70940
|
+
return [];
|
|
70941
|
+
}
|
|
70942
|
+
function getCellPadding(cellIdx, blockRow) {
|
|
70943
|
+
const padding = blockRow?.cells?.[cellIdx]?.attrs?.padding ?? {};
|
|
70944
|
+
return {
|
|
70945
|
+
top: padding.top ?? 2,
|
|
70946
|
+
bottom: padding.bottom ?? 2,
|
|
70947
|
+
left: padding.left ?? 4,
|
|
70948
|
+
right: padding.right ?? 4
|
|
70949
|
+
};
|
|
70950
|
+
}
|
|
70951
|
+
function getCellTotalLines(cell2) {
|
|
70952
|
+
return getCellLines(cell2).length;
|
|
70953
|
+
}
|
|
70954
|
+
function computePartialRow(rowIndex, blockRow, measure, availableHeight, fromLineByCell) {
|
|
70955
|
+
const row2 = measure.rows[rowIndex];
|
|
70956
|
+
if (!row2) {
|
|
70957
|
+
throw new Error(`Invalid rowIndex ${rowIndex}: measure.rows has ${measure.rows.length} rows`);
|
|
70958
|
+
}
|
|
70959
|
+
const cellCount = row2.cells.length;
|
|
70960
|
+
const startLines = fromLineByCell || new Array(cellCount).fill(0);
|
|
70961
|
+
const toLineByCell = [];
|
|
70962
|
+
const heightByCell = [];
|
|
70963
|
+
const cellPaddings = row2.cells.map((_2, idx) => getCellPadding(idx, blockRow));
|
|
70964
|
+
for (let cellIdx = 0; cellIdx < cellCount; cellIdx++) {
|
|
70965
|
+
const cell2 = row2.cells[cellIdx];
|
|
70966
|
+
const startLine = startLines[cellIdx] || 0;
|
|
70967
|
+
const cellPadding = cellPaddings[cellIdx];
|
|
70968
|
+
const availableForLines = Math.max(0, availableHeight - (cellPadding.top + cellPadding.bottom));
|
|
70969
|
+
const lines = getCellLines(cell2);
|
|
70970
|
+
let cumulativeHeight = 0;
|
|
70971
|
+
let cutLine = startLine;
|
|
70972
|
+
for (let i2 = startLine; i2 < lines.length; i2++) {
|
|
70973
|
+
const lineHeight2 = lines[i2].lineHeight || 0;
|
|
70974
|
+
if (cumulativeHeight + lineHeight2 > availableForLines) {
|
|
70975
|
+
break;
|
|
70976
|
+
}
|
|
70977
|
+
cumulativeHeight += lineHeight2;
|
|
70978
|
+
cutLine = i2 + 1;
|
|
70979
|
+
}
|
|
70980
|
+
toLineByCell.push(cutLine);
|
|
70981
|
+
heightByCell.push(cumulativeHeight);
|
|
70982
|
+
}
|
|
70983
|
+
const positiveHeights = heightByCell.filter((h2) => h2 > 0);
|
|
70984
|
+
const minHeight = positiveHeights.length > 0 ? Math.min(...positiveHeights) : 0;
|
|
70985
|
+
let actualPartialHeight = 0;
|
|
70986
|
+
let maxPaddingTotal = 0;
|
|
70987
|
+
for (let cellIdx = 0; cellIdx < cellCount; cellIdx++) {
|
|
70988
|
+
const cell2 = row2.cells[cellIdx];
|
|
70989
|
+
const startLine = startLines[cellIdx] || 0;
|
|
70990
|
+
const lines = getCellLines(cell2);
|
|
70991
|
+
const cellPadding = cellPaddings[cellIdx];
|
|
70992
|
+
const paddingTotal = cellPadding.top + cellPadding.bottom;
|
|
70993
|
+
maxPaddingTotal = Math.max(maxPaddingTotal, paddingTotal);
|
|
70994
|
+
let cumulativeHeight = 0;
|
|
70995
|
+
let cutLine = startLine;
|
|
70996
|
+
for (let i2 = startLine; i2 < lines.length; i2++) {
|
|
70997
|
+
const lineHeight2 = lines[i2].lineHeight || 0;
|
|
70998
|
+
if (cumulativeHeight + lineHeight2 > minHeight) {
|
|
70999
|
+
break;
|
|
71000
|
+
}
|
|
71001
|
+
cumulativeHeight += lineHeight2;
|
|
71002
|
+
cutLine = i2 + 1;
|
|
71003
|
+
}
|
|
71004
|
+
toLineByCell[cellIdx] = cutLine;
|
|
71005
|
+
actualPartialHeight = Math.max(actualPartialHeight, cumulativeHeight + paddingTotal);
|
|
71006
|
+
}
|
|
71007
|
+
const madeProgress = toLineByCell.some((cutLine, idx) => cutLine > (startLines[idx] || 0));
|
|
71008
|
+
const isFirstPart = startLines.every((l) => l === 0);
|
|
71009
|
+
const allCellsExhausted = toLineByCell.every((cutLine, idx) => {
|
|
71010
|
+
const totalLines = getCellTotalLines(row2.cells[idx]);
|
|
71011
|
+
return cutLine >= totalLines;
|
|
71012
|
+
});
|
|
71013
|
+
const isLastPart = allCellsExhausted || !madeProgress;
|
|
71014
|
+
if (actualPartialHeight === 0 && isFirstPart) {
|
|
71015
|
+
actualPartialHeight = maxPaddingTotal;
|
|
71016
|
+
}
|
|
71017
|
+
return {
|
|
71018
|
+
rowIndex,
|
|
71019
|
+
fromLineByCell: startLines,
|
|
71020
|
+
toLineByCell,
|
|
71021
|
+
isFirstPart,
|
|
71022
|
+
isLastPart,
|
|
71023
|
+
partialHeight: actualPartialHeight
|
|
71024
|
+
};
|
|
71025
|
+
}
|
|
71026
|
+
function findSplitPoint(block, measure, startRow, availableHeight, fullPageHeight, _pendingPartialRow) {
|
|
71027
|
+
let accumulatedHeight = 0;
|
|
71028
|
+
let lastFitRow = startRow;
|
|
71029
|
+
for (let i2 = startRow; i2 < block.rows.length; i2++) {
|
|
71030
|
+
const row2 = block.rows[i2];
|
|
71031
|
+
const rowHeight = measure.rows[i2]?.height || 0;
|
|
71032
|
+
const cantSplit = row2.attrs?.tableRowProperties?.cantSplit === true;
|
|
71033
|
+
if (accumulatedHeight + rowHeight <= availableHeight) {
|
|
71034
|
+
accumulatedHeight += rowHeight;
|
|
71035
|
+
lastFitRow = i2 + 1;
|
|
71036
|
+
} else {
|
|
71037
|
+
const remainingHeight = availableHeight - accumulatedHeight;
|
|
71038
|
+
if (fullPageHeight && rowHeight > fullPageHeight) {
|
|
71039
|
+
const partialRow = computePartialRow(i2, block.rows[i2], measure, remainingHeight);
|
|
71040
|
+
return { endRow: i2 + 1, partialRow };
|
|
71041
|
+
}
|
|
71042
|
+
if (cantSplit) {
|
|
71043
|
+
if (lastFitRow === startRow) {
|
|
71044
|
+
return { endRow: startRow, partialRow: null };
|
|
71045
|
+
}
|
|
71046
|
+
return { endRow: lastFitRow, partialRow: null };
|
|
71047
|
+
}
|
|
71048
|
+
if (remainingHeight >= MIN_PARTIAL_ROW_HEIGHT) {
|
|
71049
|
+
const partialRow = computePartialRow(i2, block.rows[i2], measure, remainingHeight);
|
|
71050
|
+
const hasContent = partialRow.toLineByCell.some(
|
|
71051
|
+
(cutLine, idx) => cutLine > (partialRow.fromLineByCell[idx] || 0)
|
|
71052
|
+
);
|
|
71053
|
+
if (hasContent) {
|
|
71054
|
+
return { endRow: i2 + 1, partialRow };
|
|
71055
|
+
}
|
|
71056
|
+
}
|
|
71057
|
+
return { endRow: lastFitRow, partialRow: null };
|
|
71058
|
+
}
|
|
71059
|
+
}
|
|
71060
|
+
return { endRow: block.rows.length, partialRow: null };
|
|
71061
|
+
}
|
|
71062
|
+
function generateFragmentMetadata(measure, _fromRow, _toRow, _repeatHeaderCount) {
|
|
71063
|
+
return {
|
|
71064
|
+
columnBoundaries: generateColumnBoundaries(measure),
|
|
71065
|
+
coordinateSystem: "fragment"
|
|
71066
|
+
};
|
|
71067
|
+
}
|
|
71068
|
+
function layoutMonolithicTable(context) {
|
|
71069
|
+
let state2 = context.ensurePage();
|
|
71070
|
+
if (state2.cursorY + context.measure.totalHeight > state2.contentBottom && state2.page.fragments.length > 0) {
|
|
71071
|
+
state2 = context.advanceColumn(state2);
|
|
71072
|
+
}
|
|
71073
|
+
state2 = context.ensurePage();
|
|
71074
|
+
const height = Math.min(context.measure.totalHeight, state2.contentBottom - state2.cursorY);
|
|
71075
|
+
const metadata = {
|
|
71076
|
+
columnBoundaries: generateColumnBoundaries(context.measure),
|
|
71077
|
+
coordinateSystem: "fragment"
|
|
71078
|
+
};
|
|
71079
|
+
const fragment = {
|
|
71080
|
+
kind: "table",
|
|
71081
|
+
blockId: context.block.id,
|
|
71082
|
+
fromRow: 0,
|
|
71083
|
+
toRow: context.block.rows.length,
|
|
71084
|
+
x: context.columnX(state2.columnIndex),
|
|
71085
|
+
y: state2.cursorY,
|
|
71086
|
+
width: Math.min(context.columnWidth, context.measure.totalWidth || context.columnWidth),
|
|
71087
|
+
height,
|
|
71088
|
+
metadata
|
|
71089
|
+
};
|
|
71090
|
+
state2.page.fragments.push(fragment);
|
|
71091
|
+
state2.cursorY += height;
|
|
71092
|
+
}
|
|
70258
71093
|
function layoutTableBlock({
|
|
70259
71094
|
block,
|
|
70260
71095
|
measure,
|
|
@@ -70263,30 +71098,176 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
70263
71098
|
advanceColumn,
|
|
70264
71099
|
columnX
|
|
70265
71100
|
}) {
|
|
71101
|
+
if (block.anchor?.isAnchored) {
|
|
71102
|
+
return;
|
|
71103
|
+
}
|
|
71104
|
+
const tableProps = block.attrs?.tableProperties;
|
|
71105
|
+
const floatingProps = tableProps?.floatingTableProperties;
|
|
71106
|
+
if (floatingProps && Object.keys(floatingProps).length > 0) {
|
|
71107
|
+
layoutMonolithicTable({ block, measure, columnWidth, ensurePage, advanceColumn, columnX });
|
|
71108
|
+
return;
|
|
71109
|
+
}
|
|
71110
|
+
const headerCount = countHeaderRows(block);
|
|
71111
|
+
const headerHeight = headerCount > 0 ? sumRowHeights(measure.rows, 0, headerCount) : 0;
|
|
70266
71112
|
let state2 = ensurePage();
|
|
70267
|
-
|
|
70268
|
-
|
|
71113
|
+
let currentRow = 0;
|
|
71114
|
+
let isTableContinuation = false;
|
|
71115
|
+
let pendingPartialRow = null;
|
|
71116
|
+
while (currentRow < block.rows.length || pendingPartialRow !== null) {
|
|
71117
|
+
state2 = ensurePage();
|
|
71118
|
+
const availableHeight = state2.contentBottom - state2.cursorY;
|
|
71119
|
+
let repeatHeaderCount = 0;
|
|
71120
|
+
if (currentRow === 0 && !pendingPartialRow) {
|
|
71121
|
+
repeatHeaderCount = 0;
|
|
71122
|
+
} else {
|
|
71123
|
+
if (headerCount > 0 && headerHeight <= availableHeight) {
|
|
71124
|
+
repeatHeaderCount = headerCount;
|
|
71125
|
+
} else if (headerCount > 0 && headerHeight > availableHeight) {
|
|
71126
|
+
repeatHeaderCount = 0;
|
|
71127
|
+
}
|
|
71128
|
+
}
|
|
71129
|
+
const availableForBody = repeatHeaderCount > 0 ? availableHeight - headerHeight : availableHeight;
|
|
71130
|
+
const fullPageHeight = state2.contentBottom;
|
|
71131
|
+
if (pendingPartialRow !== null) {
|
|
71132
|
+
const rowIndex = pendingPartialRow.rowIndex;
|
|
71133
|
+
const fromLineByCell = pendingPartialRow.toLineByCell;
|
|
71134
|
+
const continuationPartialRow = computePartialRow(
|
|
71135
|
+
rowIndex,
|
|
71136
|
+
block.rows[rowIndex],
|
|
71137
|
+
measure,
|
|
71138
|
+
availableForBody,
|
|
71139
|
+
fromLineByCell
|
|
71140
|
+
);
|
|
71141
|
+
const madeProgress = continuationPartialRow.toLineByCell.some(
|
|
71142
|
+
(toLine, idx) => toLine > (fromLineByCell[idx] || 0)
|
|
71143
|
+
);
|
|
71144
|
+
const hasRemainingLinesAfterContinuation = continuationPartialRow.toLineByCell.some(
|
|
71145
|
+
(toLine, idx) => {
|
|
71146
|
+
const totalLines = getCellTotalLines(measure.rows[rowIndex].cells[idx]);
|
|
71147
|
+
return toLine < totalLines;
|
|
71148
|
+
}
|
|
71149
|
+
);
|
|
71150
|
+
const hadRemainingLinesBefore = fromLineByCell.some((fromLine, idx) => {
|
|
71151
|
+
const totalLines = getCellTotalLines(measure.rows[rowIndex].cells[idx]);
|
|
71152
|
+
return fromLine < totalLines;
|
|
71153
|
+
});
|
|
71154
|
+
const fragmentHeight2 = continuationPartialRow.partialHeight + (repeatHeaderCount > 0 ? headerHeight : 0);
|
|
71155
|
+
if (fragmentHeight2 > 0) {
|
|
71156
|
+
const fragment2 = {
|
|
71157
|
+
kind: "table",
|
|
71158
|
+
blockId: block.id,
|
|
71159
|
+
fromRow: rowIndex,
|
|
71160
|
+
toRow: rowIndex + 1,
|
|
71161
|
+
x: columnX(state2.columnIndex),
|
|
71162
|
+
y: state2.cursorY,
|
|
71163
|
+
width: Math.min(columnWidth, measure.totalWidth || columnWidth),
|
|
71164
|
+
height: fragmentHeight2,
|
|
71165
|
+
continuesFromPrev: true,
|
|
71166
|
+
continuesOnNext: hasRemainingLinesAfterContinuation || rowIndex + 1 < block.rows.length,
|
|
71167
|
+
repeatHeaderCount,
|
|
71168
|
+
partialRow: continuationPartialRow,
|
|
71169
|
+
metadata: generateFragmentMetadata(measure)
|
|
71170
|
+
};
|
|
71171
|
+
state2.page.fragments.push(fragment2);
|
|
71172
|
+
state2.cursorY += fragmentHeight2;
|
|
71173
|
+
}
|
|
71174
|
+
const rowComplete = !hasRemainingLinesAfterContinuation;
|
|
71175
|
+
if (rowComplete) {
|
|
71176
|
+
currentRow = rowIndex + 1;
|
|
71177
|
+
pendingPartialRow = null;
|
|
71178
|
+
} else if (!madeProgress && hadRemainingLinesBefore) {
|
|
71179
|
+
state2 = advanceColumn(state2);
|
|
71180
|
+
} else {
|
|
71181
|
+
state2 = advanceColumn(state2);
|
|
71182
|
+
pendingPartialRow = continuationPartialRow;
|
|
71183
|
+
}
|
|
71184
|
+
isTableContinuation = true;
|
|
71185
|
+
continue;
|
|
71186
|
+
}
|
|
71187
|
+
const bodyStartRow = currentRow;
|
|
71188
|
+
const { endRow, partialRow } = findSplitPoint(block, measure, bodyStartRow, availableForBody, fullPageHeight);
|
|
71189
|
+
if (endRow === bodyStartRow && partialRow === null && state2.page.fragments.length > 0) {
|
|
71190
|
+
state2 = advanceColumn(state2);
|
|
71191
|
+
continue;
|
|
71192
|
+
}
|
|
71193
|
+
if (endRow === bodyStartRow && partialRow === null) {
|
|
71194
|
+
const forcedPartialRow = computePartialRow(bodyStartRow, block.rows[bodyStartRow], measure, availableForBody);
|
|
71195
|
+
const forcedEndRow = bodyStartRow + 1;
|
|
71196
|
+
const fragmentHeight2 = forcedPartialRow.partialHeight + (repeatHeaderCount > 0 ? headerHeight : 0);
|
|
71197
|
+
const fragment2 = {
|
|
71198
|
+
kind: "table",
|
|
71199
|
+
blockId: block.id,
|
|
71200
|
+
fromRow: bodyStartRow,
|
|
71201
|
+
toRow: forcedEndRow,
|
|
71202
|
+
x: columnX(state2.columnIndex),
|
|
71203
|
+
y: state2.cursorY,
|
|
71204
|
+
width: Math.min(columnWidth, measure.totalWidth || columnWidth),
|
|
71205
|
+
height: fragmentHeight2,
|
|
71206
|
+
continuesFromPrev: isTableContinuation,
|
|
71207
|
+
continuesOnNext: !forcedPartialRow.isLastPart || forcedEndRow < block.rows.length,
|
|
71208
|
+
repeatHeaderCount,
|
|
71209
|
+
partialRow: forcedPartialRow,
|
|
71210
|
+
metadata: generateFragmentMetadata(measure)
|
|
71211
|
+
};
|
|
71212
|
+
state2.page.fragments.push(fragment2);
|
|
71213
|
+
state2.cursorY += fragmentHeight2;
|
|
71214
|
+
pendingPartialRow = forcedPartialRow;
|
|
71215
|
+
isTableContinuation = true;
|
|
71216
|
+
continue;
|
|
71217
|
+
}
|
|
71218
|
+
let fragmentHeight;
|
|
71219
|
+
if (partialRow) {
|
|
71220
|
+
const fullRowsHeight = sumRowHeights(measure.rows, bodyStartRow, endRow - 1);
|
|
71221
|
+
fragmentHeight = fullRowsHeight + partialRow.partialHeight + (repeatHeaderCount > 0 ? headerHeight : 0);
|
|
71222
|
+
} else {
|
|
71223
|
+
fragmentHeight = calculateFragmentHeight(
|
|
71224
|
+
{ fromRow: bodyStartRow, toRow: endRow, repeatHeaderCount },
|
|
71225
|
+
measure
|
|
71226
|
+
);
|
|
71227
|
+
}
|
|
71228
|
+
const fragment = {
|
|
71229
|
+
kind: "table",
|
|
71230
|
+
blockId: block.id,
|
|
71231
|
+
fromRow: bodyStartRow,
|
|
71232
|
+
toRow: endRow,
|
|
71233
|
+
x: columnX(state2.columnIndex),
|
|
71234
|
+
y: state2.cursorY,
|
|
71235
|
+
width: Math.min(columnWidth, measure.totalWidth || columnWidth),
|
|
71236
|
+
height: fragmentHeight,
|
|
71237
|
+
continuesFromPrev: isTableContinuation,
|
|
71238
|
+
continuesOnNext: endRow < block.rows.length || (partialRow ? !partialRow.isLastPart : false),
|
|
71239
|
+
repeatHeaderCount,
|
|
71240
|
+
partialRow: partialRow || void 0,
|
|
71241
|
+
metadata: generateFragmentMetadata(measure)
|
|
71242
|
+
};
|
|
71243
|
+
state2.page.fragments.push(fragment);
|
|
71244
|
+
state2.cursorY += fragmentHeight;
|
|
71245
|
+
if (partialRow && !partialRow.isLastPart) {
|
|
71246
|
+
pendingPartialRow = partialRow;
|
|
71247
|
+
currentRow = partialRow.rowIndex;
|
|
71248
|
+
} else {
|
|
71249
|
+
currentRow = endRow;
|
|
71250
|
+
pendingPartialRow = null;
|
|
71251
|
+
}
|
|
71252
|
+
isTableContinuation = true;
|
|
70269
71253
|
}
|
|
70270
|
-
|
|
70271
|
-
|
|
71254
|
+
}
|
|
71255
|
+
function createAnchoredTableFragment(block, measure, x2, y2) {
|
|
70272
71256
|
const metadata = {
|
|
70273
71257
|
columnBoundaries: generateColumnBoundaries(measure),
|
|
70274
71258
|
coordinateSystem: "fragment"
|
|
70275
|
-
// rowBoundaries omitted - not needed for column resize, reduces DOM overhead
|
|
70276
71259
|
};
|
|
70277
|
-
|
|
71260
|
+
return {
|
|
70278
71261
|
kind: "table",
|
|
70279
71262
|
blockId: block.id,
|
|
70280
71263
|
fromRow: 0,
|
|
70281
71264
|
toRow: block.rows.length,
|
|
70282
|
-
x:
|
|
70283
|
-
y:
|
|
70284
|
-
width:
|
|
70285
|
-
height,
|
|
71265
|
+
x: x2,
|
|
71266
|
+
y: y2,
|
|
71267
|
+
width: measure.totalWidth ?? 0,
|
|
71268
|
+
height: measure.totalHeight ?? 0,
|
|
70286
71269
|
metadata
|
|
70287
71270
|
};
|
|
70288
|
-
state2.page.fragments.push(fragment);
|
|
70289
|
-
state2.cursorY += height;
|
|
70290
71271
|
}
|
|
70291
71272
|
function isPageRelativeAnchor(block) {
|
|
70292
71273
|
const vRelativeFrom = block.anchor?.vRelativeFrom;
|
|
@@ -70313,9 +71294,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
70313
71294
|
function collectAnchoredDrawings(blocks2, measures) {
|
|
70314
71295
|
const map2 = /* @__PURE__ */ new Map();
|
|
70315
71296
|
const len2 = Math.min(blocks2.length, measures.length);
|
|
70316
|
-
for (let i2 = 0; i2 < len2; i2 += 1) {
|
|
70317
|
-
if (blocks2[i2].kind === "paragraph") ;
|
|
70318
|
-
}
|
|
70319
71297
|
const nearestPrevParagraph = (fromIndex) => {
|
|
70320
71298
|
for (let i2 = fromIndex - 1; i2 >= 0; i2 -= 1) {
|
|
70321
71299
|
if (blocks2[i2].kind === "paragraph") return i2;
|
|
@@ -70351,6 +71329,36 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
70351
71329
|
}
|
|
70352
71330
|
return map2;
|
|
70353
71331
|
}
|
|
71332
|
+
function collectAnchoredTables(blocks2, measures) {
|
|
71333
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
71334
|
+
const nearestPrevParagraph = (fromIndex) => {
|
|
71335
|
+
for (let i2 = fromIndex - 1; i2 >= 0; i2 -= 1) {
|
|
71336
|
+
if (blocks2[i2].kind === "paragraph") return i2;
|
|
71337
|
+
}
|
|
71338
|
+
return null;
|
|
71339
|
+
};
|
|
71340
|
+
const nearestNextParagraph = (fromIndex) => {
|
|
71341
|
+
for (let i2 = fromIndex + 1; i2 < blocks2.length; i2 += 1) {
|
|
71342
|
+
if (blocks2[i2].kind === "paragraph") return i2;
|
|
71343
|
+
}
|
|
71344
|
+
return null;
|
|
71345
|
+
};
|
|
71346
|
+
for (let i2 = 0; i2 < blocks2.length; i2 += 1) {
|
|
71347
|
+
const block = blocks2[i2];
|
|
71348
|
+
const measure = measures[i2];
|
|
71349
|
+
if (block.kind !== "table" || measure?.kind !== "table") continue;
|
|
71350
|
+
const tableBlock = block;
|
|
71351
|
+
const tableMeasure = measure;
|
|
71352
|
+
if (!tableBlock.anchor?.isAnchored) continue;
|
|
71353
|
+
let anchorParaIndex = nearestPrevParagraph(i2);
|
|
71354
|
+
if (anchorParaIndex == null) anchorParaIndex = nearestNextParagraph(i2);
|
|
71355
|
+
if (anchorParaIndex == null) continue;
|
|
71356
|
+
const list2 = map2.get(anchorParaIndex) ?? [];
|
|
71357
|
+
list2.push({ block: tableBlock, measure: tableMeasure });
|
|
71358
|
+
map2.set(anchorParaIndex, list2);
|
|
71359
|
+
}
|
|
71360
|
+
return map2;
|
|
71361
|
+
}
|
|
70354
71362
|
function createPaginator(opts) {
|
|
70355
71363
|
const states = [];
|
|
70356
71364
|
const pages = [];
|
|
@@ -70936,7 +71944,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
70936
71944
|
cachedColumnsState.state = null;
|
|
70937
71945
|
};
|
|
70938
71946
|
const anchoredByParagraph = collectAnchoredDrawings(blocks2, measures);
|
|
71947
|
+
const anchoredTablesByParagraph = collectAnchoredTables(blocks2, measures);
|
|
70939
71948
|
const placedAnchoredIds = /* @__PURE__ */ new Set();
|
|
71949
|
+
const placedAnchoredTableIds = /* @__PURE__ */ new Set();
|
|
70940
71950
|
const preRegisteredAnchors = collectPreRegisteredAnchors(blocks2, measures);
|
|
70941
71951
|
const preRegisteredPositions = /* @__PURE__ */ new Map();
|
|
70942
71952
|
for (const entry of preRegisteredAnchors) {
|
|
@@ -71114,6 +72124,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
71114
72124
|
}
|
|
71115
72125
|
}
|
|
71116
72126
|
const anchorsForPara = anchoredByParagraph.get(index2);
|
|
72127
|
+
const tablesForPara = anchoredTablesByParagraph.get(index2);
|
|
72128
|
+
if (tablesForPara) {
|
|
72129
|
+
const state2 = paginator.ensurePage();
|
|
72130
|
+
for (const { block: tableBlock, measure: tableMeasure } of tablesForPara) {
|
|
72131
|
+
if (placedAnchoredTableIds.has(tableBlock.id)) continue;
|
|
72132
|
+
floatManager.registerTable(tableBlock, tableMeasure, state2.cursorY, state2.columnIndex, state2.page.number);
|
|
72133
|
+
const anchorX = tableBlock.anchor?.offsetH ?? columnX(state2.columnIndex);
|
|
72134
|
+
const anchorY = state2.cursorY + (tableBlock.anchor?.offsetV ?? 0);
|
|
72135
|
+
const tableFragment = createAnchoredTableFragment(tableBlock, tableMeasure, anchorX, anchorY);
|
|
72136
|
+
state2.page.fragments.push(tableFragment);
|
|
72137
|
+
placedAnchoredTableIds.add(tableBlock.id);
|
|
72138
|
+
}
|
|
72139
|
+
}
|
|
71117
72140
|
layoutParagraphBlock(
|
|
71118
72141
|
{
|
|
71119
72142
|
block,
|
|
@@ -71385,7 +72408,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
71385
72408
|
const trackedMode = block.attrs && "trackedChangesMode" in block.attrs && block.attrs.trackedChangesMode || "review";
|
|
71386
72409
|
const trackedEnabled = resolveTrackedChangesEnabled(block.attrs, true);
|
|
71387
72410
|
const runsHash = block.runs.map((run2) => {
|
|
71388
|
-
const text2 = normalizeText(
|
|
72411
|
+
const text2 = normalizeText(
|
|
72412
|
+
"src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? ""
|
|
72413
|
+
);
|
|
71389
72414
|
const bold = "bold" in run2 ? run2.bold : false;
|
|
71390
72415
|
const italic = "italic" in run2 ? run2.italic : false;
|
|
71391
72416
|
const color2 = "color" in run2 ? run2.color : void 0;
|
|
@@ -71399,7 +72424,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
71399
72424
|
}
|
|
71400
72425
|
return `${text2}:${marks}${trackedKey}`;
|
|
71401
72426
|
}).join("|");
|
|
71402
|
-
|
|
72427
|
+
let numberingKey = "";
|
|
72428
|
+
if (block.attrs) {
|
|
72429
|
+
const attrs = block.attrs;
|
|
72430
|
+
if (attrs.numberingProperties) {
|
|
72431
|
+
const np = attrs.numberingProperties;
|
|
72432
|
+
let markerTextKey;
|
|
72433
|
+
if (!attrs.wordLayout?.marker) {
|
|
72434
|
+
markerTextKey = "<NULL>";
|
|
72435
|
+
} else {
|
|
72436
|
+
const markerText = attrs.wordLayout.marker.markerText;
|
|
72437
|
+
markerTextKey = markerText === "" ? "<EMPTY>" : markerText ?? "<NULL>";
|
|
72438
|
+
}
|
|
72439
|
+
numberingKey = `|num:${np.numId ?? ""}:${np.ilvl ?? 0}:${markerTextKey}`;
|
|
72440
|
+
}
|
|
72441
|
+
}
|
|
72442
|
+
return `${trackedMode}:${trackedEnabled ? "on" : "off"}|${runsHash}${numberingKey}`;
|
|
71403
72443
|
};
|
|
71404
72444
|
const createStats = () => ({
|
|
71405
72445
|
hits: 0,
|
|
@@ -72045,7 +73085,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
72045
73085
|
return `${italic}${bold}${size2}px ${family}`.trim();
|
|
72046
73086
|
}
|
|
72047
73087
|
function runText(run2) {
|
|
72048
|
-
return "src" in run2 || run2.kind === "lineBreak" ? "" : run2.text ?? "";
|
|
73088
|
+
return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
|
|
72049
73089
|
}
|
|
72050
73090
|
function measureRunSliceWidth(run2, fromChar, toChar) {
|
|
72051
73091
|
const context = getCtx();
|
|
@@ -72207,7 +73247,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
72207
73247
|
for (let i2 = 0; i2 < a2.runs.length; i2 += 1) {
|
|
72208
73248
|
const runA = a2.runs[i2];
|
|
72209
73249
|
const runB = b2.runs[i2];
|
|
72210
|
-
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)) {
|
|
73250
|
+
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)) {
|
|
72211
73251
|
return false;
|
|
72212
73252
|
}
|
|
72213
73253
|
}
|
|
@@ -72327,7 +73367,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
72327
73367
|
parts.push(block.id);
|
|
72328
73368
|
if (block.kind === "paragraph") {
|
|
72329
73369
|
for (const run2 of block.runs) {
|
|
72330
|
-
if (!("src" in run2) && run2.kind !== "lineBreak") {
|
|
73370
|
+
if (!("src" in run2) && run2.kind !== "lineBreak" && run2.kind !== "break") {
|
|
72331
73371
|
parts.push(run2.text ?? "");
|
|
72332
73372
|
}
|
|
72333
73373
|
if ("bold" in run2 && run2.bold) parts.push("b");
|
|
@@ -73298,7 +74338,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
73298
74338
|
for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
|
|
73299
74339
|
const run2 = block.runs[runIndex];
|
|
73300
74340
|
if (!run2) continue;
|
|
73301
|
-
const text2 = "src" in run2 || run2.kind === "lineBreak" ? "" : run2.text ?? "";
|
|
74341
|
+
const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
|
|
73302
74342
|
const runLength = text2.length;
|
|
73303
74343
|
const runPmStart = run2.pmStart ?? null;
|
|
73304
74344
|
const runPmEnd = run2.pmEnd ?? (runPmStart != null ? runPmStart + runLength : null);
|
|
@@ -75906,7 +76946,20 @@ ${l}
|
|
|
75906
76946
|
};
|
|
75907
76947
|
};
|
|
75908
76948
|
const renderTableCell = (deps) => {
|
|
75909
|
-
const {
|
|
76949
|
+
const {
|
|
76950
|
+
doc: doc2,
|
|
76951
|
+
x: x2,
|
|
76952
|
+
y: y2,
|
|
76953
|
+
rowHeight,
|
|
76954
|
+
cellMeasure,
|
|
76955
|
+
cell: cell2,
|
|
76956
|
+
borders,
|
|
76957
|
+
renderLine,
|
|
76958
|
+
context,
|
|
76959
|
+
applySdtDataset,
|
|
76960
|
+
fromLine,
|
|
76961
|
+
toLine
|
|
76962
|
+
} = deps;
|
|
75910
76963
|
const cellEl = doc2.createElement("div");
|
|
75911
76964
|
cellEl.style.position = "absolute";
|
|
75912
76965
|
cellEl.style.left = `${x2}px`;
|
|
@@ -75914,6 +76967,7 @@ ${l}
|
|
|
75914
76967
|
cellEl.style.width = `${cellMeasure.width}px`;
|
|
75915
76968
|
cellEl.style.height = `${rowHeight}px`;
|
|
75916
76969
|
cellEl.style.boxSizing = "border-box";
|
|
76970
|
+
cellEl.style.overflow = "hidden";
|
|
75917
76971
|
if (borders) {
|
|
75918
76972
|
applyCellBorders(cellEl, borders);
|
|
75919
76973
|
}
|
|
@@ -75927,36 +76981,87 @@ ${l}
|
|
|
75927
76981
|
}
|
|
75928
76982
|
let contentElement;
|
|
75929
76983
|
const attrs = cell2?.attrs;
|
|
75930
|
-
const padding = attrs?.padding || { top: 2, left: 4, right: 4 };
|
|
76984
|
+
const padding = attrs?.padding || { top: 2, left: 4, right: 4, bottom: 2 };
|
|
75931
76985
|
const paddingLeft = padding.left ?? 4;
|
|
75932
76986
|
const paddingTop = padding.top ?? 2;
|
|
75933
76987
|
const paddingRight = padding.right ?? 4;
|
|
76988
|
+
const paddingBottom = padding.bottom ?? 2;
|
|
75934
76989
|
const cellBlocks = cell2?.blocks ?? (cell2?.paragraph ? [cell2.paragraph] : []);
|
|
75935
|
-
const blockMeasures = cellMeasure
|
|
76990
|
+
const blockMeasures = cellMeasure?.blocks ?? (cellMeasure?.paragraph ? [cellMeasure.paragraph] : []);
|
|
75936
76991
|
if (cellBlocks.length > 0 && blockMeasures.length > 0) {
|
|
75937
76992
|
const content2 = doc2.createElement("div");
|
|
75938
76993
|
content2.style.position = "absolute";
|
|
75939
76994
|
content2.style.left = `${x2 + paddingLeft}px`;
|
|
75940
76995
|
content2.style.top = `${y2 + paddingTop}px`;
|
|
75941
|
-
|
|
75942
|
-
|
|
76996
|
+
const contentWidth = Math.max(0, cellMeasure.width - paddingLeft - paddingRight);
|
|
76997
|
+
const contentHeight = Math.max(0, rowHeight - paddingTop - paddingBottom);
|
|
76998
|
+
content2.style.width = `${contentWidth + 1}px`;
|
|
76999
|
+
content2.style.height = `${contentHeight}px`;
|
|
77000
|
+
content2.style.display = "flex";
|
|
77001
|
+
content2.style.flexDirection = "column";
|
|
77002
|
+
content2.style.overflowX = "visible";
|
|
77003
|
+
content2.style.overflowY = "hidden";
|
|
77004
|
+
if (cell2?.attrs?.verticalAlign === "center") {
|
|
77005
|
+
content2.style.justifyContent = "center";
|
|
77006
|
+
} else if (cell2?.attrs?.verticalAlign === "bottom") {
|
|
77007
|
+
content2.style.justifyContent = "flex-end";
|
|
77008
|
+
} else {
|
|
77009
|
+
content2.style.justifyContent = "flex-start";
|
|
77010
|
+
}
|
|
77011
|
+
const blockLineCounts = [];
|
|
77012
|
+
for (let i2 = 0; i2 < Math.min(blockMeasures.length, cellBlocks.length); i2++) {
|
|
77013
|
+
const bm = blockMeasures[i2];
|
|
77014
|
+
if (bm.kind === "paragraph") {
|
|
77015
|
+
blockLineCounts.push(bm.lines?.length || 0);
|
|
77016
|
+
} else {
|
|
77017
|
+
blockLineCounts.push(0);
|
|
77018
|
+
}
|
|
77019
|
+
}
|
|
77020
|
+
const totalLines = blockLineCounts.reduce((a2, b2) => a2 + b2, 0);
|
|
77021
|
+
const globalFromLine = fromLine ?? 0;
|
|
77022
|
+
const globalToLine = toLine === -1 || toLine === void 0 ? totalLines : toLine;
|
|
77023
|
+
let cumulativeLineCount = 0;
|
|
75943
77024
|
for (let i2 = 0; i2 < Math.min(blockMeasures.length, cellBlocks.length); i2++) {
|
|
75944
77025
|
const blockMeasure = blockMeasures[i2];
|
|
75945
77026
|
const block = cellBlocks[i2];
|
|
75946
77027
|
if (blockMeasure.kind === "paragraph" && block?.kind === "paragraph") {
|
|
77028
|
+
const lines = blockMeasure.lines;
|
|
77029
|
+
const blockLineCount = lines?.length || 0;
|
|
77030
|
+
const blockStartGlobal = cumulativeLineCount;
|
|
77031
|
+
const blockEndGlobal = cumulativeLineCount + blockLineCount;
|
|
77032
|
+
if (blockEndGlobal <= globalFromLine) {
|
|
77033
|
+
cumulativeLineCount += blockLineCount;
|
|
77034
|
+
continue;
|
|
77035
|
+
}
|
|
77036
|
+
if (blockStartGlobal >= globalToLine) {
|
|
77037
|
+
cumulativeLineCount += blockLineCount;
|
|
77038
|
+
continue;
|
|
77039
|
+
}
|
|
77040
|
+
const localStartLine = Math.max(0, globalFromLine - blockStartGlobal);
|
|
77041
|
+
const localEndLine = Math.min(blockLineCount, globalToLine - blockStartGlobal);
|
|
75947
77042
|
const paraWrapper = doc2.createElement("div");
|
|
75948
|
-
paraWrapper.style.position = "
|
|
75949
|
-
paraWrapper.style.top = `${blockY}px`;
|
|
77043
|
+
paraWrapper.style.position = "relative";
|
|
75950
77044
|
paraWrapper.style.left = "0";
|
|
75951
77045
|
paraWrapper.style.width = "100%";
|
|
75952
77046
|
applySdtDataset(paraWrapper, block.attrs?.sdt);
|
|
75953
|
-
|
|
75954
|
-
lines.
|
|
77047
|
+
let renderedHeight = 0;
|
|
77048
|
+
for (let lineIdx = localStartLine; lineIdx < localEndLine && lineIdx < lines.length; lineIdx++) {
|
|
77049
|
+
const line = lines[lineIdx];
|
|
75955
77050
|
const lineEl = renderLine(block, line, { ...context, section: "body" });
|
|
75956
77051
|
paraWrapper.appendChild(lineEl);
|
|
75957
|
-
|
|
77052
|
+
renderedHeight += line.lineHeight;
|
|
77053
|
+
}
|
|
77054
|
+
const renderedEntireBlock = localStartLine === 0 && localEndLine >= blockLineCount;
|
|
77055
|
+
if (renderedEntireBlock && blockMeasure.totalHeight && blockMeasure.totalHeight > renderedHeight) {
|
|
77056
|
+
renderedHeight = blockMeasure.totalHeight;
|
|
77057
|
+
}
|
|
75958
77058
|
content2.appendChild(paraWrapper);
|
|
75959
|
-
|
|
77059
|
+
if (renderedHeight > 0) {
|
|
77060
|
+
paraWrapper.style.height = `${renderedHeight}px`;
|
|
77061
|
+
}
|
|
77062
|
+
cumulativeLineCount += blockLineCount;
|
|
77063
|
+
} else {
|
|
77064
|
+
cumulativeLineCount += 0;
|
|
75960
77065
|
}
|
|
75961
77066
|
}
|
|
75962
77067
|
contentElement = content2;
|
|
@@ -75977,7 +77082,10 @@ ${l}
|
|
|
75977
77082
|
allRowHeights,
|
|
75978
77083
|
context,
|
|
75979
77084
|
renderLine,
|
|
75980
|
-
applySdtDataset
|
|
77085
|
+
applySdtDataset,
|
|
77086
|
+
continuesFromPrev,
|
|
77087
|
+
continuesOnNext,
|
|
77088
|
+
partialRow
|
|
75981
77089
|
} = deps;
|
|
75982
77090
|
const calculateXPosition = (gridColumnStart) => {
|
|
75983
77091
|
let x2 = 0;
|
|
@@ -76010,25 +77118,57 @@ ${l}
|
|
|
76010
77118
|
const isLastRow = rowIndex === totalRows - 1;
|
|
76011
77119
|
const isFirstCol = gridColIndex === 0;
|
|
76012
77120
|
const isLastCol = gridColIndex === totalCols - 1;
|
|
77121
|
+
const treatAsFirstRow = isFirstRow || continuesFromPrev;
|
|
77122
|
+
const treatAsLastRow = isLastRow || continuesOnNext;
|
|
76013
77123
|
resolvedBorders = {
|
|
76014
|
-
// For top: use cell's if defined, otherwise use table's top for first row
|
|
76015
|
-
top: cellBordersAttr.top ?? borderValueToSpec(
|
|
76016
|
-
// For bottom: use cell's if defined, otherwise use table's bottom for last row
|
|
76017
|
-
bottom: cellBordersAttr.bottom ?? borderValueToSpec(
|
|
77124
|
+
// For top: use cell's if defined, otherwise use table's top border for first row OR continuation
|
|
77125
|
+
top: cellBordersAttr.top ?? borderValueToSpec(treatAsFirstRow ? tableBorders.top : tableBorders.insideH),
|
|
77126
|
+
// For bottom: use cell's if defined, otherwise use table's bottom border for last row OR before continuation
|
|
77127
|
+
bottom: cellBordersAttr.bottom ?? borderValueToSpec(treatAsLastRow ? tableBorders.bottom : void 0),
|
|
76018
77128
|
// For left: use cell's if defined, otherwise use table's left for first col
|
|
76019
77129
|
left: cellBordersAttr.left ?? borderValueToSpec(isFirstCol ? tableBorders.left : tableBorders.insideV),
|
|
76020
77130
|
// For right: use cell's if defined, otherwise use table's right for last col only
|
|
76021
77131
|
right: cellBordersAttr.right ?? borderValueToSpec(isLastCol ? tableBorders.right : void 0)
|
|
76022
77132
|
};
|
|
76023
77133
|
} else if (hasExplicitBorders) {
|
|
76024
|
-
resolvedBorders =
|
|
77134
|
+
resolvedBorders = {
|
|
77135
|
+
top: cellBordersAttr.top,
|
|
77136
|
+
bottom: cellBordersAttr.bottom,
|
|
77137
|
+
left: cellBordersAttr.left,
|
|
77138
|
+
right: cellBordersAttr.right
|
|
77139
|
+
};
|
|
76025
77140
|
} else if (tableBorders) {
|
|
76026
|
-
|
|
77141
|
+
const isFirstRow = rowIndex === 0;
|
|
77142
|
+
const isLastRow = rowIndex === totalRows - 1;
|
|
77143
|
+
const treatAsFirstRow = isFirstRow || continuesFromPrev;
|
|
77144
|
+
const treatAsLastRow = isLastRow || continuesOnNext;
|
|
77145
|
+
const baseBorders = resolveTableCellBorders(tableBorders, rowIndex, gridColIndex, totalRows, totalCols);
|
|
77146
|
+
if (baseBorders) {
|
|
77147
|
+
resolvedBorders = {
|
|
77148
|
+
// If this is a continuation (continuesFromPrev), use table's top border
|
|
77149
|
+
top: treatAsFirstRow ? borderValueToSpec(tableBorders.top) : baseBorders.top,
|
|
77150
|
+
// If this continues on next (continuesOnNext), use table's bottom border
|
|
77151
|
+
bottom: treatAsLastRow ? borderValueToSpec(tableBorders.bottom) : baseBorders.bottom,
|
|
77152
|
+
left: baseBorders.left,
|
|
77153
|
+
right: baseBorders.right
|
|
77154
|
+
};
|
|
77155
|
+
} else {
|
|
77156
|
+
resolvedBorders = void 0;
|
|
77157
|
+
}
|
|
76027
77158
|
} else {
|
|
76028
77159
|
resolvedBorders = void 0;
|
|
76029
77160
|
}
|
|
76030
77161
|
const rowSpan = cellMeasure.rowSpan ?? 1;
|
|
76031
|
-
|
|
77162
|
+
let cellHeight;
|
|
77163
|
+
if (partialRow) {
|
|
77164
|
+
cellHeight = partialRow.partialHeight;
|
|
77165
|
+
} else if (rowSpan > 1) {
|
|
77166
|
+
cellHeight = calculateRowspanHeight(rowIndex, rowSpan);
|
|
77167
|
+
} else {
|
|
77168
|
+
cellHeight = rowMeasure.height;
|
|
77169
|
+
}
|
|
77170
|
+
const fromLine = partialRow?.fromLineByCell?.[cellIndex];
|
|
77171
|
+
const toLine = partialRow?.toLineByCell?.[cellIndex];
|
|
76032
77172
|
const { cellElement, contentElement } = renderTableCell({
|
|
76033
77173
|
doc: doc2,
|
|
76034
77174
|
x: x2,
|
|
@@ -76039,7 +77179,9 @@ ${l}
|
|
|
76039
77179
|
borders: resolvedBorders,
|
|
76040
77180
|
renderLine,
|
|
76041
77181
|
context,
|
|
76042
|
-
applySdtDataset
|
|
77182
|
+
applySdtDataset,
|
|
77183
|
+
fromLine,
|
|
77184
|
+
toLine
|
|
76043
77185
|
});
|
|
76044
77186
|
container.appendChild(cellElement);
|
|
76045
77187
|
if (contentElement) {
|
|
@@ -76153,11 +77295,46 @@ ${l}
|
|
|
76153
77295
|
if (borderCollapse === "separate" && block.attrs?.cellSpacing) {
|
|
76154
77296
|
container.style.borderSpacing = `${block.attrs.cellSpacing}px`;
|
|
76155
77297
|
}
|
|
76156
|
-
const allRowHeights = measure.rows.map((r2) =>
|
|
77298
|
+
const allRowHeights = measure.rows.map((r2, idx) => {
|
|
77299
|
+
if (fragment.partialRow && fragment.partialRow.rowIndex === idx) {
|
|
77300
|
+
return fragment.partialRow.partialHeight;
|
|
77301
|
+
}
|
|
77302
|
+
return r2?.height ?? 0;
|
|
77303
|
+
});
|
|
76157
77304
|
let y2 = 0;
|
|
77305
|
+
if (fragment.repeatHeaderCount && fragment.repeatHeaderCount > 0) {
|
|
77306
|
+
for (let r2 = 0; r2 < fragment.repeatHeaderCount; r2 += 1) {
|
|
77307
|
+
const rowMeasure = measure.rows[r2];
|
|
77308
|
+
if (!rowMeasure) break;
|
|
77309
|
+
renderTableRow({
|
|
77310
|
+
doc: doc2,
|
|
77311
|
+
container,
|
|
77312
|
+
rowIndex: r2,
|
|
77313
|
+
y: y2,
|
|
77314
|
+
rowMeasure,
|
|
77315
|
+
row: block.rows[r2],
|
|
77316
|
+
totalRows: block.rows.length,
|
|
77317
|
+
tableBorders,
|
|
77318
|
+
columnWidths: measure.columnWidths,
|
|
77319
|
+
allRowHeights,
|
|
77320
|
+
context,
|
|
77321
|
+
renderLine,
|
|
77322
|
+
applySdtDataset,
|
|
77323
|
+
// Headers are always rendered as-is (no border suppression)
|
|
77324
|
+
continuesFromPrev: false,
|
|
77325
|
+
continuesOnNext: false
|
|
77326
|
+
});
|
|
77327
|
+
y2 += rowMeasure.height;
|
|
77328
|
+
}
|
|
77329
|
+
}
|
|
76158
77330
|
for (let r2 = fragment.fromRow; r2 < fragment.toRow; r2 += 1) {
|
|
76159
77331
|
const rowMeasure = measure.rows[r2];
|
|
76160
77332
|
if (!rowMeasure) break;
|
|
77333
|
+
const isFirstRenderedBodyRow = r2 === fragment.fromRow;
|
|
77334
|
+
const isLastRenderedBodyRow = r2 === fragment.toRow - 1;
|
|
77335
|
+
const isPartialRow = fragment.partialRow && fragment.partialRow.rowIndex === r2;
|
|
77336
|
+
const partialRowData = isPartialRow ? fragment.partialRow : void 0;
|
|
77337
|
+
const actualRowHeight = partialRowData ? partialRowData.partialHeight : rowMeasure.height;
|
|
76161
77338
|
renderTableRow({
|
|
76162
77339
|
doc: doc2,
|
|
76163
77340
|
container,
|
|
@@ -76171,9 +77348,15 @@ ${l}
|
|
|
76171
77348
|
allRowHeights,
|
|
76172
77349
|
context,
|
|
76173
77350
|
renderLine,
|
|
76174
|
-
applySdtDataset
|
|
77351
|
+
applySdtDataset,
|
|
77352
|
+
// Draw top border if table continues from previous fragment (MS Word behavior)
|
|
77353
|
+
continuesFromPrev: isFirstRenderedBodyRow && fragment.continuesFromPrev === true,
|
|
77354
|
+
// Draw bottom border if table continues on next fragment (MS Word behavior)
|
|
77355
|
+
continuesOnNext: isLastRenderedBodyRow && fragment.continuesOnNext === true,
|
|
77356
|
+
// Pass partial row data for mid-row splits
|
|
77357
|
+
partialRow: partialRowData
|
|
76175
77358
|
});
|
|
76176
|
-
y2 +=
|
|
77359
|
+
y2 += actualRowHeight;
|
|
76177
77360
|
}
|
|
76178
77361
|
return container;
|
|
76179
77362
|
};
|
|
@@ -76268,6 +77451,7 @@ ${l}
|
|
|
76268
77451
|
}
|
|
76269
77452
|
}
|
|
76270
77453
|
const LIST_MARKER_GAP$1 = 8;
|
|
77454
|
+
const DEFAULT_TAB_INTERVAL_PX$1 = 48;
|
|
76271
77455
|
const COMMENT_EXTERNAL_COLOR = "#B1124B";
|
|
76272
77456
|
const COMMENT_INTERNAL_COLOR = "#078383";
|
|
76273
77457
|
const COMMENT_INACTIVE_ALPHA = "22";
|
|
@@ -77064,33 +78248,41 @@ ${l}
|
|
|
77064
78248
|
const firstLineOffset = (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
|
|
77065
78249
|
lines.forEach((line, index2) => {
|
|
77066
78250
|
const lineEl = this.renderLine(block, line, context);
|
|
77067
|
-
|
|
78251
|
+
const isListFirstLine = index2 === 0 && !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
|
|
78252
|
+
if (paraIndentLeft && !isListFirstLine) {
|
|
77068
78253
|
lineEl.style.paddingLeft = `${paraIndentLeft}px`;
|
|
77069
78254
|
}
|
|
77070
78255
|
if (paraIndentRight) {
|
|
77071
78256
|
lineEl.style.paddingRight = `${paraIndentRight}px`;
|
|
77072
78257
|
}
|
|
77073
|
-
if (!fragment.continuesFromPrev && index2 === 0 && firstLineOffset) {
|
|
78258
|
+
if (!fragment.continuesFromPrev && index2 === 0 && firstLineOffset && !isListFirstLine) {
|
|
77074
78259
|
lineEl.style.textIndent = `${firstLineOffset}px`;
|
|
77075
|
-
} else if (firstLineOffset) {
|
|
78260
|
+
} else if (firstLineOffset && !isListFirstLine) {
|
|
77076
78261
|
lineEl.style.textIndent = "0px";
|
|
77077
78262
|
}
|
|
77078
|
-
if (
|
|
78263
|
+
if (isListFirstLine && wordLayout?.marker && fragment.markerWidth) {
|
|
78264
|
+
const markerStartPos = paraIndentLeft - (paraIndent?.hanging ?? 0);
|
|
78265
|
+
lineEl.style.paddingLeft = `${markerStartPos}px`;
|
|
77079
78266
|
const markerContainer = this.doc.createElement("span");
|
|
77080
78267
|
markerContainer.style.display = "inline-block";
|
|
77081
78268
|
const markerEl = this.doc.createElement("span");
|
|
77082
78269
|
markerEl.classList.add("superdoc-paragraph-marker");
|
|
77083
78270
|
markerEl.textContent = wordLayout.marker.markerText ?? "";
|
|
77084
|
-
markerEl.style.width = `${fragment.markerWidth}px`;
|
|
77085
|
-
markerEl.style.textAlign = wordLayout.marker.justification ?? "right";
|
|
77086
|
-
markerEl.style.paddingRight = `${LIST_MARKER_GAP$1}px`;
|
|
77087
78271
|
markerEl.style.pointerEvents = "none";
|
|
77088
|
-
const
|
|
77089
|
-
|
|
77090
|
-
|
|
77091
|
-
|
|
77092
|
-
|
|
77093
|
-
|
|
78272
|
+
const markerJustification = wordLayout.marker.justification ?? "left";
|
|
78273
|
+
if (markerJustification !== "left") {
|
|
78274
|
+
markerEl.style.width = `${fragment.markerWidth}px`;
|
|
78275
|
+
markerEl.style.textAlign = wordLayout.marker.justification ?? "right";
|
|
78276
|
+
markerEl.style.paddingRight = `${LIST_MARKER_GAP$1}px`;
|
|
78277
|
+
}
|
|
78278
|
+
if (markerJustification === "left") {
|
|
78279
|
+
markerContainer.style.position = "relative";
|
|
78280
|
+
} else {
|
|
78281
|
+
const markerLeftX = markerStartPos - fragment.markerWidth;
|
|
78282
|
+
markerContainer.style.position = "absolute";
|
|
78283
|
+
markerContainer.style.left = `${markerLeftX}px`;
|
|
78284
|
+
markerContainer.style.top = "0";
|
|
78285
|
+
}
|
|
77094
78286
|
markerEl.style.fontFamily = wordLayout.marker.run.fontFamily;
|
|
77095
78287
|
markerEl.style.fontSize = `${wordLayout.marker.run.fontSize}px`;
|
|
77096
78288
|
markerEl.style.fontWeight = wordLayout.marker.run.bold ? "bold" : "";
|
|
@@ -77107,12 +78299,25 @@ ${l}
|
|
|
77107
78299
|
const tabEl = this.doc.createElement("span");
|
|
77108
78300
|
tabEl.className = "superdoc-tab";
|
|
77109
78301
|
tabEl.innerHTML = " ";
|
|
77110
|
-
|
|
78302
|
+
let tabWidth;
|
|
78303
|
+
const markerBoxWidth = fragment.markerWidth;
|
|
78304
|
+
const markerTextWidth = fragment.markerTextWidth != null && isFinite(fragment.markerTextWidth) && fragment.markerTextWidth >= 0 ? fragment.markerTextWidth : markerBoxWidth;
|
|
78305
|
+
if ((wordLayout.marker.justification ?? "left") === "left") {
|
|
78306
|
+
const currentPos = markerStartPos + markerTextWidth;
|
|
78307
|
+
const implicitTabStop = paraIndentLeft;
|
|
78308
|
+
tabWidth = implicitTabStop - currentPos;
|
|
78309
|
+
if (tabWidth < 1) {
|
|
78310
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$1 - currentPos % DEFAULT_TAB_INTERVAL_PX$1;
|
|
78311
|
+
if (tabWidth === 0) tabWidth = DEFAULT_TAB_INTERVAL_PX$1;
|
|
78312
|
+
}
|
|
78313
|
+
} else {
|
|
78314
|
+
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;
|
|
78315
|
+
}
|
|
77111
78316
|
tabEl.style.display = "inline-block";
|
|
77112
|
-
tabEl.style.width = `${
|
|
77113
|
-
|
|
78317
|
+
tabEl.style.width = `${tabWidth}px`;
|
|
78318
|
+
lineEl.prepend(tabEl);
|
|
77114
78319
|
} else if (suffix2 === "space") {
|
|
77115
|
-
|
|
78320
|
+
lineEl.prepend(this.doc.createTextNode(" "));
|
|
77116
78321
|
}
|
|
77117
78322
|
lineEl.prepend(markerContainer);
|
|
77118
78323
|
}
|
|
@@ -77961,6 +79166,12 @@ ${l}
|
|
|
77961
79166
|
isLineBreakRun(run2) {
|
|
77962
79167
|
return run2.kind === "lineBreak";
|
|
77963
79168
|
}
|
|
79169
|
+
/**
|
|
79170
|
+
* Type guard to check if a run is a break run.
|
|
79171
|
+
*/
|
|
79172
|
+
isBreakRun(run2) {
|
|
79173
|
+
return run2.kind === "break";
|
|
79174
|
+
}
|
|
77964
79175
|
renderRun(run2, context, trackedConfig) {
|
|
77965
79176
|
if (this.isImageRun(run2)) {
|
|
77966
79177
|
return this.renderImageRun(run2);
|
|
@@ -77968,7 +79179,10 @@ ${l}
|
|
|
77968
79179
|
if (this.isLineBreakRun(run2)) {
|
|
77969
79180
|
return null;
|
|
77970
79181
|
}
|
|
77971
|
-
if (
|
|
79182
|
+
if (this.isBreakRun(run2)) {
|
|
79183
|
+
return null;
|
|
79184
|
+
}
|
|
79185
|
+
if (!("text" in run2) || !run2.text || !this.doc) {
|
|
77972
79186
|
return null;
|
|
77973
79187
|
}
|
|
77974
79188
|
const linkData = this.extractLinkData(run2);
|
|
@@ -78109,6 +79323,12 @@ ${l}
|
|
|
78109
79323
|
if (styleId) {
|
|
78110
79324
|
el.setAttribute("styleid", styleId);
|
|
78111
79325
|
}
|
|
79326
|
+
const alignment2 = block.attrs?.alignment;
|
|
79327
|
+
if (alignment2 === "center" || alignment2 === "right" || alignment2 === "justify") {
|
|
79328
|
+
el.style.textAlign = alignment2 === "justify" ? "justify" : alignment2;
|
|
79329
|
+
} else {
|
|
79330
|
+
el.style.textAlign = "left";
|
|
79331
|
+
}
|
|
78112
79332
|
const lineRange = computeLinePmRange(block, line);
|
|
78113
79333
|
if (lineRange.pmStart != null) {
|
|
78114
79334
|
el.dataset.pmStart = String(lineRange.pmStart);
|
|
@@ -78226,10 +79446,16 @@ ${l}
|
|
|
78226
79446
|
if (this.isLineBreakRun(baseRun)) {
|
|
78227
79447
|
continue;
|
|
78228
79448
|
}
|
|
79449
|
+
if (this.isBreakRun(baseRun)) {
|
|
79450
|
+
continue;
|
|
79451
|
+
}
|
|
78229
79452
|
const runSegments = segmentsByRun.get(runIndex);
|
|
78230
79453
|
if (!runSegments || runSegments.length === 0) {
|
|
78231
79454
|
continue;
|
|
78232
79455
|
}
|
|
79456
|
+
if (!("text" in baseRun)) {
|
|
79457
|
+
continue;
|
|
79458
|
+
}
|
|
78233
79459
|
const baseText = baseRun.text ?? "";
|
|
78234
79460
|
const runPmStart = baseRun.pmStart ?? null;
|
|
78235
79461
|
const fallbackPmEnd = runPmStart != null && baseRun.pmEnd == null ? runPmStart + baseText.length : baseRun.pmEnd ?? null;
|
|
@@ -78548,7 +79774,12 @@ ${l}
|
|
|
78548
79774
|
if (fragment.kind === "drawing") {
|
|
78549
79775
|
return `drawing:${fragment.blockId}:${fragment.x}:${fragment.y}`;
|
|
78550
79776
|
}
|
|
78551
|
-
|
|
79777
|
+
if (fragment.kind === "table") {
|
|
79778
|
+
const partialKey = fragment.partialRow ? `:${fragment.partialRow.fromLineByCell.join(",")}-${fragment.partialRow.toLineByCell.join(",")}` : "";
|
|
79779
|
+
return `table:${fragment.blockId}:${fragment.fromRow}:${fragment.toRow}${partialKey}`;
|
|
79780
|
+
}
|
|
79781
|
+
const _exhaustiveCheck = fragment;
|
|
79782
|
+
return _exhaustiveCheck;
|
|
78552
79783
|
};
|
|
78553
79784
|
const fragmentSignature = (fragment, lookup2) => {
|
|
78554
79785
|
const base2 = lookup2.get(fragment.blockId)?.version ?? "missing";
|
|
@@ -78560,7 +79791,9 @@ ${l}
|
|
|
78560
79791
|
fragment.pmStart ?? "",
|
|
78561
79792
|
fragment.pmEnd ?? "",
|
|
78562
79793
|
fragment.continuesFromPrev ? 1 : 0,
|
|
78563
|
-
fragment.continuesOnNext ? 1 : 0
|
|
79794
|
+
fragment.continuesOnNext ? 1 : 0,
|
|
79795
|
+
fragment.markerWidth ?? ""
|
|
79796
|
+
// Include markerWidth to trigger re-render when list status changes
|
|
78564
79797
|
].join("|");
|
|
78565
79798
|
}
|
|
78566
79799
|
if (fragment.kind === "list-item") {
|
|
@@ -78590,6 +79823,20 @@ ${l}
|
|
|
78590
79823
|
fragment.zIndex ?? ""
|
|
78591
79824
|
].join("|");
|
|
78592
79825
|
}
|
|
79826
|
+
if (fragment.kind === "table") {
|
|
79827
|
+
const partialSig = fragment.partialRow ? `${fragment.partialRow.fromLineByCell.join(",")}-${fragment.partialRow.toLineByCell.join(",")}-${fragment.partialRow.partialHeight}` : "";
|
|
79828
|
+
return [
|
|
79829
|
+
base2,
|
|
79830
|
+
fragment.fromRow,
|
|
79831
|
+
fragment.toRow,
|
|
79832
|
+
fragment.width,
|
|
79833
|
+
fragment.height,
|
|
79834
|
+
fragment.continuesFromPrev ? 1 : 0,
|
|
79835
|
+
fragment.continuesOnNext ? 1 : 0,
|
|
79836
|
+
fragment.repeatHeaderCount ?? 0,
|
|
79837
|
+
partialSig
|
|
79838
|
+
].join("|");
|
|
79839
|
+
}
|
|
78593
79840
|
return base2;
|
|
78594
79841
|
};
|
|
78595
79842
|
const deriveBlockVersion = (block) => {
|
|
@@ -78735,7 +79982,7 @@ ${l}
|
|
|
78735
79982
|
return block.id;
|
|
78736
79983
|
};
|
|
78737
79984
|
const applyRunStyles = (element2, run2, isLink = false) => {
|
|
78738
|
-
if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak") {
|
|
79985
|
+
if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break") {
|
|
78739
79986
|
return;
|
|
78740
79987
|
}
|
|
78741
79988
|
element2.style.fontFamily = run2.fontFamily;
|
|
@@ -78869,6 +80116,17 @@ ${l}
|
|
|
78869
80116
|
result.push(run2);
|
|
78870
80117
|
continue;
|
|
78871
80118
|
}
|
|
80119
|
+
if (run2.kind === "break") {
|
|
80120
|
+
result.push(run2);
|
|
80121
|
+
continue;
|
|
80122
|
+
}
|
|
80123
|
+
if (run2.kind === "tab") {
|
|
80124
|
+
result.push(run2);
|
|
80125
|
+
continue;
|
|
80126
|
+
}
|
|
80127
|
+
if (!("text" in run2)) {
|
|
80128
|
+
continue;
|
|
80129
|
+
}
|
|
78872
80130
|
const text2 = run2.text ?? "";
|
|
78873
80131
|
const isFirstRun = runIndex === line.fromRun;
|
|
78874
80132
|
const isLastRun = runIndex === line.toRun;
|
|
@@ -78882,20 +80140,14 @@ ${l}
|
|
|
78882
80140
|
if (!slice2) continue;
|
|
78883
80141
|
const pmSliceStart = runPmStart != null ? runPmStart + start2 : void 0;
|
|
78884
80142
|
const pmSliceEnd = runPmStart != null ? runPmStart + end2 : fallbackPmEnd ?? void 0;
|
|
78885
|
-
|
|
78886
|
-
|
|
78887
|
-
|
|
78888
|
-
|
|
78889
|
-
|
|
78890
|
-
|
|
78891
|
-
|
|
78892
|
-
|
|
78893
|
-
pmStart: pmSliceStart,
|
|
78894
|
-
pmEnd: pmSliceEnd,
|
|
78895
|
-
comments: run2.comments ? [...run2.comments] : void 0
|
|
78896
|
-
};
|
|
78897
|
-
result.push(sliced);
|
|
78898
|
-
}
|
|
80143
|
+
const sliced = {
|
|
80144
|
+
...run2,
|
|
80145
|
+
text: slice2,
|
|
80146
|
+
pmStart: pmSliceStart,
|
|
80147
|
+
pmEnd: pmSliceEnd,
|
|
80148
|
+
comments: run2.comments ? [...run2.comments] : void 0
|
|
80149
|
+
};
|
|
80150
|
+
result.push(sliced);
|
|
78899
80151
|
} else {
|
|
78900
80152
|
result.push(run2);
|
|
78901
80153
|
}
|
|
@@ -78938,6 +80190,39 @@ ${l}
|
|
|
78938
80190
|
}
|
|
78939
80191
|
continue;
|
|
78940
80192
|
}
|
|
80193
|
+
if (run2.kind === "break") {
|
|
80194
|
+
const runPmStart2 = run2.pmStart ?? null;
|
|
80195
|
+
const runPmEnd = run2.pmEnd ?? null;
|
|
80196
|
+
if (runPmStart2 == null || runPmEnd == null) {
|
|
80197
|
+
continue;
|
|
80198
|
+
}
|
|
80199
|
+
if (pmStart == null) {
|
|
80200
|
+
pmStart = runPmStart2;
|
|
80201
|
+
}
|
|
80202
|
+
pmEnd = runPmEnd;
|
|
80203
|
+
if (runIndex === line.toRun) {
|
|
80204
|
+
break;
|
|
80205
|
+
}
|
|
80206
|
+
continue;
|
|
80207
|
+
}
|
|
80208
|
+
if (run2.kind === "tab") {
|
|
80209
|
+
const runPmStart2 = run2.pmStart ?? null;
|
|
80210
|
+
const runPmEnd = run2.pmEnd ?? null;
|
|
80211
|
+
if (runPmStart2 == null || runPmEnd == null) {
|
|
80212
|
+
continue;
|
|
80213
|
+
}
|
|
80214
|
+
if (pmStart == null) {
|
|
80215
|
+
pmStart = runPmStart2;
|
|
80216
|
+
}
|
|
80217
|
+
pmEnd = runPmEnd;
|
|
80218
|
+
if (runIndex === line.toRun) {
|
|
80219
|
+
break;
|
|
80220
|
+
}
|
|
80221
|
+
continue;
|
|
80222
|
+
}
|
|
80223
|
+
if (!("text" in run2)) {
|
|
80224
|
+
continue;
|
|
80225
|
+
}
|
|
78941
80226
|
const text2 = run2.text ?? "";
|
|
78942
80227
|
const runLength = text2.length;
|
|
78943
80228
|
const runPmStart = run2.pmStart ?? null;
|
|
@@ -78979,6 +80264,12 @@ ${l}
|
|
|
78979
80264
|
if (run2.kind === "lineBreak") {
|
|
78980
80265
|
return "";
|
|
78981
80266
|
}
|
|
80267
|
+
if (run2.kind === "break") {
|
|
80268
|
+
return "";
|
|
80269
|
+
}
|
|
80270
|
+
if (!("text" in run2)) {
|
|
80271
|
+
return "";
|
|
80272
|
+
}
|
|
78982
80273
|
if (!runToken) {
|
|
78983
80274
|
return run2.text ?? "";
|
|
78984
80275
|
}
|
|
@@ -79176,6 +80467,7 @@ ${l}
|
|
|
79176
80467
|
async function measureParagraphBlock(block, maxWidth) {
|
|
79177
80468
|
const ctx2 = getCanvasContext();
|
|
79178
80469
|
const wordLayout = block.attrs?.wordLayout;
|
|
80470
|
+
const WIDTH_FUDGE_PX = 0.5;
|
|
79179
80471
|
const lines = [];
|
|
79180
80472
|
const indent2 = block.attrs?.indent;
|
|
79181
80473
|
const spacing = block.attrs?.spacing;
|
|
@@ -79270,8 +80562,67 @@ ${l}
|
|
|
79270
80562
|
lastAppliedTabAlign = { target, val };
|
|
79271
80563
|
pendingTabAlignment = null;
|
|
79272
80564
|
};
|
|
79273
|
-
|
|
79274
|
-
|
|
80565
|
+
const runsToProcess = [];
|
|
80566
|
+
for (const run2 of block.runs) {
|
|
80567
|
+
if (run2.text && typeof run2.text === "string" && run2.text.includes("\n")) {
|
|
80568
|
+
const textRun = run2;
|
|
80569
|
+
const segments = textRun.text.split("\n");
|
|
80570
|
+
let cursor = textRun.pmStart ?? 0;
|
|
80571
|
+
segments.forEach((seg, idx) => {
|
|
80572
|
+
runsToProcess.push({
|
|
80573
|
+
...textRun,
|
|
80574
|
+
text: seg,
|
|
80575
|
+
pmStart: cursor,
|
|
80576
|
+
pmEnd: cursor + seg.length
|
|
80577
|
+
});
|
|
80578
|
+
cursor += seg.length;
|
|
80579
|
+
if (idx !== segments.length - 1) {
|
|
80580
|
+
runsToProcess.push({
|
|
80581
|
+
kind: "break",
|
|
80582
|
+
breakType: "line",
|
|
80583
|
+
pmStart: cursor,
|
|
80584
|
+
pmEnd: cursor + 1,
|
|
80585
|
+
sdt: run2.sdt
|
|
80586
|
+
});
|
|
80587
|
+
cursor += 1;
|
|
80588
|
+
}
|
|
80589
|
+
});
|
|
80590
|
+
} else {
|
|
80591
|
+
runsToProcess.push(run2);
|
|
80592
|
+
}
|
|
80593
|
+
}
|
|
80594
|
+
for (let runIndex = 0; runIndex < runsToProcess.length; runIndex++) {
|
|
80595
|
+
const run2 = runsToProcess[runIndex];
|
|
80596
|
+
if (run2.kind === "break") {
|
|
80597
|
+
if (currentLine) {
|
|
80598
|
+
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
|
|
80599
|
+
const completedLine = { ...currentLine, ...metrics };
|
|
80600
|
+
addBarTabsToLine(completedLine);
|
|
80601
|
+
lines.push(completedLine);
|
|
80602
|
+
currentLine = null;
|
|
80603
|
+
} else {
|
|
80604
|
+
const textRunWithSize = block.runs.find(
|
|
80605
|
+
(r2) => r2.kind !== "tab" && r2.kind !== "lineBreak" && r2.kind !== "break" && !("src" in r2) && "fontSize" in r2
|
|
80606
|
+
);
|
|
80607
|
+
const fallbackSize = textRunWithSize?.fontSize ?? 12;
|
|
80608
|
+
const metrics = calculateTypographyMetrics(fallbackSize, spacing);
|
|
80609
|
+
const emptyLine = {
|
|
80610
|
+
fromRun: runIndex,
|
|
80611
|
+
fromChar: 0,
|
|
80612
|
+
toRun: runIndex,
|
|
80613
|
+
toChar: 0,
|
|
80614
|
+
width: 0,
|
|
80615
|
+
segments: [],
|
|
80616
|
+
...metrics
|
|
80617
|
+
};
|
|
80618
|
+
addBarTabsToLine(emptyLine);
|
|
80619
|
+
lines.push(emptyLine);
|
|
80620
|
+
}
|
|
80621
|
+
tabStopCursor = 0;
|
|
80622
|
+
pendingTabAlignment = null;
|
|
80623
|
+
lastAppliedTabAlign = null;
|
|
80624
|
+
continue;
|
|
80625
|
+
}
|
|
79275
80626
|
if (isLineBreakRun(run2)) {
|
|
79276
80627
|
if (currentLine) {
|
|
79277
80628
|
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
|
|
@@ -79422,6 +80773,9 @@ ${l}
|
|
|
79422
80773
|
}
|
|
79423
80774
|
continue;
|
|
79424
80775
|
}
|
|
80776
|
+
if (!("text" in run2) || !("fontSize" in run2)) {
|
|
80777
|
+
continue;
|
|
80778
|
+
}
|
|
79425
80779
|
lastFontSize = run2.fontSize;
|
|
79426
80780
|
const { font } = buildFontString(run2);
|
|
79427
80781
|
const tabSegments = run2.text.split(" ");
|
|
@@ -79461,18 +80815,18 @@ ${l}
|
|
|
79461
80815
|
segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }]
|
|
79462
80816
|
};
|
|
79463
80817
|
const ls = run2.letterSpacing ?? 0;
|
|
79464
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth) {
|
|
80818
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
|
|
79465
80819
|
currentLine.toChar = wordEndWithSpace;
|
|
79466
80820
|
currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
|
|
79467
80821
|
charPosInRun = wordEndWithSpace;
|
|
79468
80822
|
} else {
|
|
79469
|
-
charPosInRun =
|
|
80823
|
+
charPosInRun = wordEndWithSpace;
|
|
79470
80824
|
}
|
|
79471
80825
|
continue;
|
|
79472
80826
|
}
|
|
79473
80827
|
const isTocEntry = block.attrs?.isTocEntry;
|
|
79474
80828
|
const boundarySpacing = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
|
|
79475
|
-
if (currentLine.width + boundarySpacing + wordOnlyWidth > currentLine.maxWidth && currentLine.width > 0 && !isTocEntry) {
|
|
80829
|
+
if (currentLine.width + boundarySpacing + wordOnlyWidth > currentLine.maxWidth - WIDTH_FUDGE_PX && currentLine.width > 0 && !isTocEntry) {
|
|
79476
80830
|
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
|
|
79477
80831
|
const completedLine = {
|
|
79478
80832
|
...currentLine,
|
|
@@ -79492,16 +80846,16 @@ ${l}
|
|
|
79492
80846
|
maxWidth: getEffectiveWidth(contentWidth),
|
|
79493
80847
|
segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }]
|
|
79494
80848
|
};
|
|
79495
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth) {
|
|
80849
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
|
|
79496
80850
|
currentLine.toChar = wordEndWithSpace;
|
|
79497
80851
|
currentLine.width = roundValue(currentLine.width + spaceWidth + (run2.letterSpacing ?? 0));
|
|
79498
80852
|
charPosInRun = wordEndWithSpace;
|
|
79499
80853
|
} else {
|
|
79500
|
-
charPosInRun =
|
|
80854
|
+
charPosInRun = wordEndWithSpace;
|
|
79501
80855
|
}
|
|
79502
80856
|
} else {
|
|
79503
80857
|
currentLine.toRun = runIndex;
|
|
79504
|
-
if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth) {
|
|
80858
|
+
if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX) {
|
|
79505
80859
|
currentLine.toChar = wordEndNoSpace;
|
|
79506
80860
|
currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
|
|
79507
80861
|
currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
|
|
@@ -79610,10 +80964,14 @@ ${l}
|
|
|
79610
80964
|
const { font: markerFont } = buildFontString(markerRun);
|
|
79611
80965
|
const markerText = wordLayout.marker.markerText ?? "";
|
|
79612
80966
|
const glyphWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
|
|
80967
|
+
const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP;
|
|
80968
|
+
const markerBoxWidth = Math.max(wordLayout.marker.markerBoxWidthPx ?? 0, glyphWidth + LIST_MARKER_GAP);
|
|
79613
80969
|
markerInfo = {
|
|
79614
|
-
markerWidth:
|
|
80970
|
+
markerWidth: markerBoxWidth,
|
|
79615
80971
|
markerTextWidth: glyphWidth,
|
|
79616
|
-
indentLeft: wordLayout.indentLeftPx ?? 0
|
|
80972
|
+
indentLeft: wordLayout.indentLeftPx ?? 0,
|
|
80973
|
+
// For tab sizing in the renderer: expose gutter for word-layout lists
|
|
80974
|
+
gutterWidth: gutter
|
|
79617
80975
|
};
|
|
79618
80976
|
}
|
|
79619
80977
|
return {
|
|
@@ -79627,6 +80985,34 @@ ${l}
|
|
|
79627
80985
|
async function measureTableBlock(block, constraints) {
|
|
79628
80986
|
const maxWidth = typeof constraints === "number" ? constraints : constraints.maxWidth;
|
|
79629
80987
|
let columnWidths;
|
|
80988
|
+
const scaleColumnWidths = (widths, targetWidth) => {
|
|
80989
|
+
const totalWidth2 = widths.reduce((a2, b2) => a2 + b2, 0);
|
|
80990
|
+
if (totalWidth2 <= targetWidth || widths.length === 0) return widths;
|
|
80991
|
+
const scale = targetWidth / totalWidth2;
|
|
80992
|
+
const scaled = widths.map((w2) => Math.max(1, Math.round(w2 * scale)));
|
|
80993
|
+
const sum = scaled.reduce((a2, b2) => a2 + b2, 0);
|
|
80994
|
+
if (sum !== targetWidth) {
|
|
80995
|
+
const adjust = (delta) => {
|
|
80996
|
+
let idx = 0;
|
|
80997
|
+
const direction = delta > 0 ? 1 : -1;
|
|
80998
|
+
delta = Math.abs(delta);
|
|
80999
|
+
while (delta > 0 && scaled.length > 0) {
|
|
81000
|
+
const i2 = idx % scaled.length;
|
|
81001
|
+
if (direction > 0) {
|
|
81002
|
+
scaled[i2] += 1;
|
|
81003
|
+
delta -= 1;
|
|
81004
|
+
} else if (scaled[i2] > 1) {
|
|
81005
|
+
scaled[i2] -= 1;
|
|
81006
|
+
delta -= 1;
|
|
81007
|
+
}
|
|
81008
|
+
idx += 1;
|
|
81009
|
+
if (idx > scaled.length * 2 && delta > 0) break;
|
|
81010
|
+
}
|
|
81011
|
+
};
|
|
81012
|
+
adjust(targetWidth - sum);
|
|
81013
|
+
}
|
|
81014
|
+
return scaled;
|
|
81015
|
+
};
|
|
79630
81016
|
const maxCellCount = Math.max(1, Math.max(...block.rows.map((r2) => r2.cells.length)));
|
|
79631
81017
|
if (block.columnWidths && block.columnWidths.length > 0) {
|
|
79632
81018
|
columnWidths = [...block.columnWidths];
|
|
@@ -79635,8 +81021,7 @@ ${l}
|
|
|
79635
81021
|
if (hasExplicitWidth || hasFixedLayout) {
|
|
79636
81022
|
const totalWidth2 = columnWidths.reduce((a2, b2) => a2 + b2, 0);
|
|
79637
81023
|
if (totalWidth2 > maxWidth) {
|
|
79638
|
-
|
|
79639
|
-
columnWidths = columnWidths.map((w2) => Math.max(1, Math.floor(w2 * scale)));
|
|
81024
|
+
columnWidths = scaleColumnWidths(columnWidths, maxWidth);
|
|
79640
81025
|
}
|
|
79641
81026
|
} else {
|
|
79642
81027
|
if (columnWidths.length < maxCellCount) {
|
|
@@ -79650,8 +81035,7 @@ ${l}
|
|
|
79650
81035
|
}
|
|
79651
81036
|
const totalWidth2 = columnWidths.reduce((a2, b2) => a2 + b2, 0);
|
|
79652
81037
|
if (totalWidth2 > maxWidth) {
|
|
79653
|
-
|
|
79654
|
-
columnWidths = columnWidths.map((w2) => Math.max(1, Math.floor(w2 * scale)));
|
|
81038
|
+
columnWidths = scaleColumnWidths(columnWidths, maxWidth);
|
|
79655
81039
|
}
|
|
79656
81040
|
}
|
|
79657
81041
|
} else {
|
|
@@ -79668,6 +81052,8 @@ ${l}
|
|
|
79668
81052
|
};
|
|
79669
81053
|
const rowspanTracker = new Array(gridColumnCount).fill(0);
|
|
79670
81054
|
const rows = [];
|
|
81055
|
+
const rowBaseHeights = new Array(block.rows.length).fill(0);
|
|
81056
|
+
const spanConstraints = [];
|
|
79671
81057
|
for (let rowIndex = 0; rowIndex < block.rows.length; rowIndex++) {
|
|
79672
81058
|
const row2 = block.rows[rowIndex];
|
|
79673
81059
|
const cellMeasures = [];
|
|
@@ -79714,6 +81100,11 @@ ${l}
|
|
|
79714
81100
|
colSpan: colspan,
|
|
79715
81101
|
rowSpan: rowspan
|
|
79716
81102
|
});
|
|
81103
|
+
if (rowspan === 1) {
|
|
81104
|
+
rowBaseHeights[rowIndex] = Math.max(rowBaseHeights[rowIndex], totalCellHeight);
|
|
81105
|
+
} else {
|
|
81106
|
+
spanConstraints.push({ startRow: rowIndex, rowSpan: rowspan, requiredHeight: totalCellHeight });
|
|
81107
|
+
}
|
|
79717
81108
|
gridColIndex += colspan;
|
|
79718
81109
|
}
|
|
79719
81110
|
for (let col = gridColIndex; col < gridColumnCount; col++) {
|
|
@@ -79721,10 +81112,39 @@ ${l}
|
|
|
79721
81112
|
rowspanTracker[col]--;
|
|
79722
81113
|
}
|
|
79723
81114
|
}
|
|
79724
|
-
|
|
79725
|
-
|
|
81115
|
+
rows.push({ cells: cellMeasures, height: 0 });
|
|
81116
|
+
}
|
|
81117
|
+
const rowHeights = [...rowBaseHeights];
|
|
81118
|
+
for (const constraint of spanConstraints) {
|
|
81119
|
+
const { startRow, rowSpan, requiredHeight } = constraint;
|
|
81120
|
+
if (rowSpan <= 0) continue;
|
|
81121
|
+
let currentHeight = 0;
|
|
81122
|
+
for (let i2 = 0; i2 < rowSpan && startRow + i2 < rowHeights.length; i2++) {
|
|
81123
|
+
currentHeight += rowHeights[startRow + i2];
|
|
81124
|
+
}
|
|
81125
|
+
if (currentHeight < requiredHeight) {
|
|
81126
|
+
const spanLength = Math.min(rowSpan, rowHeights.length - startRow);
|
|
81127
|
+
const increment2 = spanLength > 0 ? (requiredHeight - currentHeight) / spanLength : 0;
|
|
81128
|
+
for (let i2 = 0; i2 < spanLength; i2++) {
|
|
81129
|
+
rowHeights[startRow + i2] += increment2;
|
|
81130
|
+
}
|
|
81131
|
+
}
|
|
81132
|
+
}
|
|
81133
|
+
block.rows.forEach((row2, index2) => {
|
|
81134
|
+
const spec = row2.attrs?.rowHeight;
|
|
81135
|
+
if (spec?.value != null && Number.isFinite(spec.value)) {
|
|
81136
|
+
const rule = spec.rule ?? "atLeast";
|
|
81137
|
+
if (rule === "exact") {
|
|
81138
|
+
rowHeights[index2] = spec.value;
|
|
81139
|
+
} else {
|
|
81140
|
+
rowHeights[index2] = Math.max(rowHeights[index2], spec.value);
|
|
81141
|
+
}
|
|
81142
|
+
}
|
|
81143
|
+
});
|
|
81144
|
+
for (let i2 = 0; i2 < rows.length; i2++) {
|
|
81145
|
+
rows[i2].height = Math.max(0, rowHeights[i2]);
|
|
79726
81146
|
}
|
|
79727
|
-
const totalHeight =
|
|
81147
|
+
const totalHeight = rowHeights.reduce((sum, h2) => sum + h2, 0);
|
|
79728
81148
|
const totalWidth = columnWidths.reduce((a2, b2) => a2 + b2, 0);
|
|
79729
81149
|
return {
|
|
79730
81150
|
kind: "table",
|
|
@@ -79930,7 +81350,7 @@ ${l}
|
|
|
79930
81350
|
if (spacing.lineRule === "atLeast") {
|
|
79931
81351
|
return Math.max(baseLineHeight, raw);
|
|
79932
81352
|
}
|
|
79933
|
-
return raw;
|
|
81353
|
+
return Math.max(baseLineHeight, raw);
|
|
79934
81354
|
};
|
|
79935
81355
|
const sanitizePositive = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0;
|
|
79936
81356
|
const sanitizeDecimalSeparator = (value) => {
|
|
@@ -85820,6 +87240,17 @@ ${l}
|
|
|
85820
87240
|
parseTagObject
|
|
85821
87241
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
85822
87242
|
const STRUCTURED_CONTENT_NAMES = ["structuredContent", "structuredContentBlock"];
|
|
87243
|
+
const findFirstTextNode = (node2) => {
|
|
87244
|
+
let firstTextNode = null;
|
|
87245
|
+
node2.descendants((child) => {
|
|
87246
|
+
if (child.isText) {
|
|
87247
|
+
firstTextNode = child;
|
|
87248
|
+
return false;
|
|
87249
|
+
}
|
|
87250
|
+
return true;
|
|
87251
|
+
});
|
|
87252
|
+
return firstTextNode;
|
|
87253
|
+
};
|
|
85823
87254
|
const StructuredContentCommands = Extension.create({
|
|
85824
87255
|
name: "structuredContentCommands",
|
|
85825
87256
|
addCommands() {
|
|
@@ -85960,7 +87391,7 @@ ${l}
|
|
|
85960
87391
|
* @param {string} id - Unique identifier of the field
|
|
85961
87392
|
* @param {StructuredContentUpdate} options
|
|
85962
87393
|
* @example
|
|
85963
|
-
* editor.commands.updateStructuredContentById('123', { text: 'Jane Doe' });
|
|
87394
|
+
* editor.commands.updateStructuredContentById('123', { text: 'Jane Doe', keepTextNodeStyles: true });
|
|
85964
87395
|
* editor.commands.updateStructuredContentById('123', {
|
|
85965
87396
|
* json: { type: 'text', text: 'Jane Doe' },
|
|
85966
87397
|
* });
|
|
@@ -85981,7 +87412,9 @@ ${l}
|
|
|
85981
87412
|
const posTo = pos + node2.nodeSize;
|
|
85982
87413
|
let content2 = null;
|
|
85983
87414
|
if (options.text) {
|
|
85984
|
-
|
|
87415
|
+
const firstTextNode = options.keepTextNodeStyles === true ? findFirstTextNode(node2) : null;
|
|
87416
|
+
const textMarks = firstTextNode ? firstTextNode.marks : [];
|
|
87417
|
+
content2 = schema.text(options.text, textMarks);
|
|
85985
87418
|
}
|
|
85986
87419
|
if (options.html) {
|
|
85987
87420
|
const html2 = htmlHandler(options.html, editor);
|
|
@@ -85995,6 +87428,13 @@ ${l}
|
|
|
85995
87428
|
content2 = node2.content;
|
|
85996
87429
|
}
|
|
85997
87430
|
const updatedNode = node2.type.create({ ...node2.attrs, ...options.attrs }, content2, node2.marks);
|
|
87431
|
+
try {
|
|
87432
|
+
const nodeForValidation = editor.validateJSON(updatedNode.toJSON());
|
|
87433
|
+
nodeForValidation.check();
|
|
87434
|
+
} catch (error) {
|
|
87435
|
+
console.error("Invalid content.", "Passed value:", content2, "Error:", error);
|
|
87436
|
+
return false;
|
|
87437
|
+
}
|
|
85998
87438
|
tr.replaceWith(posFrom, posTo, updatedNode);
|
|
85999
87439
|
}
|
|
86000
87440
|
return true;
|
|
@@ -86079,7 +87519,7 @@ ${l}
|
|
|
86079
87519
|
* @param {StructuredContentUpdate} options
|
|
86080
87520
|
* @example
|
|
86081
87521
|
* // Update all fields in the customer-info group
|
|
86082
|
-
* editor.commands.updateStructuredContentByGroup('customer-info', { text: 'Jane Doe' });
|
|
87522
|
+
* editor.commands.updateStructuredContentByGroup('customer-info', { text: 'Jane Doe', keepTextNodeStyles: true });
|
|
86083
87523
|
*
|
|
86084
87524
|
* // Update block content in a group
|
|
86085
87525
|
* editor.commands.updateStructuredContentByGroup('terms-section', {
|
|
@@ -86093,13 +87533,14 @@ ${l}
|
|
|
86093
87533
|
}
|
|
86094
87534
|
const { schema } = editor;
|
|
86095
87535
|
if (dispatch) {
|
|
86096
|
-
|
|
87536
|
+
const updates = [];
|
|
87537
|
+
for (const structuredContent of structuredContentTags) {
|
|
86097
87538
|
const { pos, node: node2 } = structuredContent;
|
|
86098
|
-
const posFrom = tr.mapping.map(pos);
|
|
86099
|
-
const posTo = tr.mapping.map(pos + node2.nodeSize);
|
|
86100
87539
|
let content2 = null;
|
|
86101
87540
|
if (options.text) {
|
|
86102
|
-
|
|
87541
|
+
const firstTextNode = options.keepTextNodeStyles === true ? findFirstTextNode(node2) : null;
|
|
87542
|
+
const textMarks = firstTextNode ? firstTextNode.marks : [];
|
|
87543
|
+
content2 = schema.text(options.text, textMarks);
|
|
86103
87544
|
}
|
|
86104
87545
|
if (options.html) {
|
|
86105
87546
|
const html2 = htmlHandler(options.html, editor);
|
|
@@ -86113,11 +87554,23 @@ ${l}
|
|
|
86113
87554
|
content2 = node2.content;
|
|
86114
87555
|
}
|
|
86115
87556
|
const updatedNode = node2.type.create({ ...node2.attrs, ...options.attrs }, content2, node2.marks);
|
|
87557
|
+
try {
|
|
87558
|
+
const nodeForValidation = editor.validateJSON(updatedNode.toJSON());
|
|
87559
|
+
nodeForValidation.check();
|
|
87560
|
+
} catch (error) {
|
|
87561
|
+
console.error("Invalid content.", "Passed value:", content2, "Error:", error);
|
|
87562
|
+
return false;
|
|
87563
|
+
}
|
|
87564
|
+
updates.push({ pos, node: node2, updatedNode });
|
|
87565
|
+
}
|
|
87566
|
+
for (const { pos, node: node2, updatedNode } of updates) {
|
|
87567
|
+
const posFrom = tr.mapping.map(pos);
|
|
87568
|
+
const posTo = tr.mapping.map(pos + node2.nodeSize);
|
|
86116
87569
|
const currentNode = tr.doc.nodeAt(posFrom);
|
|
86117
87570
|
if (currentNode && node2.eq(currentNode)) {
|
|
86118
87571
|
tr.replaceWith(posFrom, posTo, updatedNode);
|
|
86119
87572
|
}
|
|
86120
|
-
}
|
|
87573
|
+
}
|
|
86121
87574
|
}
|
|
86122
87575
|
return true;
|
|
86123
87576
|
},
|
|
@@ -86693,61 +88146,153 @@ ${l}
|
|
|
86693
88146
|
return {};
|
|
86694
88147
|
}
|
|
86695
88148
|
});
|
|
86696
|
-
const
|
|
86697
|
-
|
|
86698
|
-
|
|
86699
|
-
|
|
86700
|
-
|
|
86701
|
-
|
|
86702
|
-
|
|
86703
|
-
|
|
86704
|
-
|
|
86705
|
-
|
|
86706
|
-
|
|
86707
|
-
|
|
86708
|
-
|
|
86709
|
-
|
|
86710
|
-
|
|
86711
|
-
|
|
86712
|
-
|
|
86713
|
-
|
|
86714
|
-
|
|
88149
|
+
const cleanupEmptyRunsPlugin = new Plugin({
|
|
88150
|
+
appendTransaction(trs, oldState, newState) {
|
|
88151
|
+
if (!trs.some((tr2) => tr2.docChanged)) return null;
|
|
88152
|
+
const { run: run2, paragraph: paragraph2 } = newState.schema.nodes;
|
|
88153
|
+
if (!run2) return null;
|
|
88154
|
+
const ranges = [];
|
|
88155
|
+
trs.forEach((tr2) => {
|
|
88156
|
+
tr2.mapping.maps.forEach((map2) => {
|
|
88157
|
+
map2.forEach((oldStart, oldEnd, newStart, newEnd) => {
|
|
88158
|
+
if (newStart !== oldStart || oldEnd !== newEnd) ranges.push({ from: newStart, to: newEnd });
|
|
88159
|
+
});
|
|
88160
|
+
});
|
|
88161
|
+
});
|
|
88162
|
+
if (!ranges.length) return null;
|
|
88163
|
+
ranges.sort((a2, b2) => a2.from - b2.from);
|
|
88164
|
+
const merged = [];
|
|
88165
|
+
for (const r2 of ranges) {
|
|
88166
|
+
const from2 = Math.max(0, r2.from - 1);
|
|
88167
|
+
const to = Math.min(newState.doc.content.size, r2.to + 1);
|
|
88168
|
+
const last = merged[merged.length - 1];
|
|
88169
|
+
if (last && from2 <= last.to) last.to = Math.max(last.to, to);
|
|
88170
|
+
else merged.push({ from: from2, to });
|
|
88171
|
+
}
|
|
88172
|
+
const toDelete = [];
|
|
88173
|
+
merged.forEach(({ from: from2, to }) => {
|
|
88174
|
+
newState.doc.nodesBetween(from2, to, (node2, pos, parent) => {
|
|
88175
|
+
if (node2.type === run2 && node2.content.size === 0 && parent?.type === paragraph2) {
|
|
88176
|
+
toDelete.push({ from: pos, to: pos + node2.nodeSize });
|
|
88177
|
+
}
|
|
88178
|
+
});
|
|
88179
|
+
});
|
|
88180
|
+
if (!toDelete.length) return null;
|
|
88181
|
+
const tr = newState.tr;
|
|
88182
|
+
toDelete.sort((a2, b2) => b2.from - a2.from).forEach(({ from: from2, to }) => tr.deleteRange(from2, to));
|
|
88183
|
+
return tr.docChanged ? tr : null;
|
|
86715
88184
|
}
|
|
86716
|
-
|
|
86717
|
-
|
|
86718
|
-
|
|
86719
|
-
|
|
86720
|
-
|
|
86721
|
-
|
|
86722
|
-
|
|
86723
|
-
|
|
86724
|
-
|
|
86725
|
-
|
|
86726
|
-
|
|
86727
|
-
|
|
88185
|
+
});
|
|
88186
|
+
const mergeRanges$1 = (ranges, docSize) => {
|
|
88187
|
+
if (!ranges.length) return [];
|
|
88188
|
+
const sorted = ranges.map(({ from: from2, to }) => ({
|
|
88189
|
+
from: Math.max(0, from2),
|
|
88190
|
+
to: Math.min(docSize, to)
|
|
88191
|
+
})).filter(({ from: from2, to }) => from2 < to).sort((a2, b2) => a2.from - b2.from);
|
|
88192
|
+
const merged = [];
|
|
88193
|
+
for (const range2 of sorted) {
|
|
88194
|
+
const last = merged[merged.length - 1];
|
|
88195
|
+
if (last && range2.from <= last.to) {
|
|
88196
|
+
last.to = Math.max(last.to, range2.to);
|
|
86728
88197
|
} else {
|
|
86729
|
-
|
|
86730
|
-
types2.unshift(null);
|
|
88198
|
+
merged.push({ ...range2 });
|
|
86731
88199
|
}
|
|
86732
88200
|
}
|
|
86733
|
-
|
|
86734
|
-
|
|
86735
|
-
|
|
86736
|
-
|
|
86737
|
-
|
|
86738
|
-
|
|
86739
|
-
|
|
86740
|
-
|
|
86741
|
-
|
|
86742
|
-
|
|
86743
|
-
|
|
86744
|
-
|
|
86745
|
-
|
|
86746
|
-
|
|
86747
|
-
|
|
86748
|
-
|
|
86749
|
-
|
|
86750
|
-
|
|
88201
|
+
return merged;
|
|
88202
|
+
};
|
|
88203
|
+
const collectChangedRanges = (trs, docSize) => {
|
|
88204
|
+
const ranges = [];
|
|
88205
|
+
trs.forEach((tr) => {
|
|
88206
|
+
if (!tr.docChanged) return;
|
|
88207
|
+
tr.mapping.maps.forEach((map2) => {
|
|
88208
|
+
map2.forEach((oldStart, oldEnd, newStart, newEnd) => {
|
|
88209
|
+
if (newStart !== oldStart || oldEnd !== newEnd) {
|
|
88210
|
+
ranges.push({ from: newStart, to: newEnd });
|
|
88211
|
+
}
|
|
88212
|
+
});
|
|
88213
|
+
});
|
|
88214
|
+
});
|
|
88215
|
+
return mergeRanges$1(ranges, docSize);
|
|
88216
|
+
};
|
|
88217
|
+
const mapRangesThroughTransactions = (ranges, transactions, docSize) => {
|
|
88218
|
+
let mapped = ranges;
|
|
88219
|
+
transactions.forEach((tr) => {
|
|
88220
|
+
mapped = mapped.map(({ from: from2, to }) => {
|
|
88221
|
+
const mappedFrom = tr.mapping.map(from2, -1);
|
|
88222
|
+
const mappedTo = tr.mapping.map(to, 1);
|
|
88223
|
+
if (mappedFrom >= mappedTo) return null;
|
|
88224
|
+
return { from: mappedFrom, to: mappedTo };
|
|
88225
|
+
}).filter(Boolean);
|
|
88226
|
+
});
|
|
88227
|
+
return mergeRanges$1(mapped, docSize);
|
|
88228
|
+
};
|
|
88229
|
+
const buildWrapTransaction = (state2, ranges, runType) => {
|
|
88230
|
+
if (!ranges.length) return null;
|
|
88231
|
+
const replacements = [];
|
|
88232
|
+
ranges.forEach(({ from: from2, to }) => {
|
|
88233
|
+
state2.doc.nodesBetween(from2, to, (node2, pos, parent, index2) => {
|
|
88234
|
+
if (!node2.isText || !parent || parent.type === runType) return;
|
|
88235
|
+
const match = parent.contentMatchAt ? parent.contentMatchAt(index2) : null;
|
|
88236
|
+
if (match && !match.matchType(runType)) return;
|
|
88237
|
+
if (!match && !parent.type.contentMatch.matchType(runType)) return;
|
|
88238
|
+
const runProperties = decodeRPrFromMarks(node2.marks);
|
|
88239
|
+
const runNode = runType.create({ runProperties }, node2);
|
|
88240
|
+
replacements.push({ from: pos, to: pos + node2.nodeSize, runNode });
|
|
88241
|
+
});
|
|
88242
|
+
});
|
|
88243
|
+
if (!replacements.length) return null;
|
|
88244
|
+
const tr = state2.tr;
|
|
88245
|
+
replacements.sort((a2, b2) => b2.from - a2.from).forEach(({ from: from2, to, runNode }) => tr.replaceWith(from2, to, runNode));
|
|
88246
|
+
return tr.docChanged ? tr : null;
|
|
88247
|
+
};
|
|
88248
|
+
const wrapTextInRunsPlugin = () => {
|
|
88249
|
+
let view = null;
|
|
88250
|
+
let pendingRanges = [];
|
|
88251
|
+
const flush = () => {
|
|
88252
|
+
if (!view) return;
|
|
88253
|
+
const runType = view.state.schema.nodes.run;
|
|
88254
|
+
if (!runType) {
|
|
88255
|
+
pendingRanges = [];
|
|
88256
|
+
return;
|
|
88257
|
+
}
|
|
88258
|
+
const tr = buildWrapTransaction(view.state, pendingRanges, runType);
|
|
88259
|
+
pendingRanges = [];
|
|
88260
|
+
if (tr) {
|
|
88261
|
+
view.dispatch(tr);
|
|
88262
|
+
}
|
|
88263
|
+
};
|
|
88264
|
+
const onCompositionEnd2 = () => {
|
|
88265
|
+
if (typeof globalThis === "undefined") return;
|
|
88266
|
+
globalThis.queueMicrotask(flush);
|
|
88267
|
+
};
|
|
88268
|
+
return new Plugin({
|
|
88269
|
+
view(editorView) {
|
|
88270
|
+
view = editorView;
|
|
88271
|
+
editorView.dom.addEventListener("compositionend", onCompositionEnd2);
|
|
88272
|
+
return {
|
|
88273
|
+
destroy() {
|
|
88274
|
+
editorView.dom.removeEventListener("compositionend", onCompositionEnd2);
|
|
88275
|
+
view = null;
|
|
88276
|
+
pendingRanges = [];
|
|
88277
|
+
}
|
|
88278
|
+
};
|
|
88279
|
+
},
|
|
88280
|
+
appendTransaction(transactions, _oldState, newState) {
|
|
88281
|
+
const docSize = newState.doc.content.size;
|
|
88282
|
+
const runType = newState.schema.nodes.run;
|
|
88283
|
+
if (!runType) return null;
|
|
88284
|
+
pendingRanges = mapRangesThroughTransactions(pendingRanges, transactions, docSize);
|
|
88285
|
+
const changedRanges = collectChangedRanges(transactions, docSize);
|
|
88286
|
+
pendingRanges = mergeRanges$1([...pendingRanges, ...changedRanges], docSize);
|
|
88287
|
+
if (view?.composing) {
|
|
88288
|
+
return null;
|
|
88289
|
+
}
|
|
88290
|
+
const tr = buildWrapTransaction(newState, pendingRanges, runType);
|
|
88291
|
+
pendingRanges = [];
|
|
88292
|
+
return tr;
|
|
88293
|
+
}
|
|
88294
|
+
});
|
|
88295
|
+
};
|
|
86751
88296
|
const Run = OxmlNode.create({
|
|
86752
88297
|
name: "run",
|
|
86753
88298
|
oXmlName: "w:r",
|
|
@@ -86790,7 +88335,8 @@ ${l}
|
|
|
86790
88335
|
// @ts-expect-error - Command signatures will be fixed in TS migration
|
|
86791
88336
|
addCommands() {
|
|
86792
88337
|
return {
|
|
86793
|
-
|
|
88338
|
+
splitRunToParagraph,
|
|
88339
|
+
splitRunAtCursor
|
|
86794
88340
|
};
|
|
86795
88341
|
},
|
|
86796
88342
|
parseDOM() {
|
|
@@ -86799,6 +88345,9 @@ ${l}
|
|
|
86799
88345
|
renderDOM({ htmlAttributes }) {
|
|
86800
88346
|
const base2 = Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
|
|
86801
88347
|
return ["span", base2, 0];
|
|
88348
|
+
},
|
|
88349
|
+
addPmPlugins() {
|
|
88350
|
+
return [wrapTextInRunsPlugin(), cleanupEmptyRunsPlugin];
|
|
86802
88351
|
}
|
|
86803
88352
|
});
|
|
86804
88353
|
const restartNumbering = ({ editor, tr, state: state2, dispatch }) => {
|
|
@@ -87541,20 +89090,15 @@ ${l}
|
|
|
87541
89090
|
} else {
|
|
87542
89091
|
markerText = docxNumberingHelpers.normalizeLvlTextChar(lvlText);
|
|
87543
89092
|
}
|
|
87544
|
-
|
|
89093
|
+
const newListRendering = {
|
|
87545
89094
|
markerText,
|
|
87546
89095
|
suffix: suffix2,
|
|
87547
89096
|
justification,
|
|
87548
89097
|
path: path2,
|
|
87549
89098
|
numberingType: listNumberingType
|
|
87550
|
-
}
|
|
87551
|
-
|
|
87552
|
-
|
|
87553
|
-
suffix: suffix2,
|
|
87554
|
-
justification,
|
|
87555
|
-
path: path2,
|
|
87556
|
-
numberingType: listNumberingType
|
|
87557
|
-
});
|
|
89099
|
+
};
|
|
89100
|
+
if (JSON.stringify(node2.attrs.listRendering) !== JSON.stringify(newListRendering)) {
|
|
89101
|
+
tr.setNodeAttribute(pos, "listRendering", newListRendering);
|
|
87558
89102
|
}
|
|
87559
89103
|
return false;
|
|
87560
89104
|
});
|
|
@@ -87855,7 +89399,7 @@ ${l}
|
|
|
87855
89399
|
return null;
|
|
87856
89400
|
}
|
|
87857
89401
|
const { tr } = state2;
|
|
87858
|
-
tr.delete(range2.from, range2.to);
|
|
89402
|
+
tr.delete(range2.from, range2.to).setSelection(TextSelection$1.create(tr.doc, range2.from));
|
|
87859
89403
|
ListHelpers.createNewList({
|
|
87860
89404
|
listType: type2,
|
|
87861
89405
|
tr,
|
|
@@ -91285,7 +92829,10 @@ ${l}
|
|
|
91285
92829
|
insertTable: ({ rows = 3, cols = 3, withHeaderRow = false } = {}) => ({ tr, dispatch, editor }) => {
|
|
91286
92830
|
const node2 = createTable(editor.schema, rows, cols, withHeaderRow);
|
|
91287
92831
|
if (dispatch) {
|
|
91288
|
-
|
|
92832
|
+
let offset2 = tr.selection.$from.end() + 1;
|
|
92833
|
+
if (tr.selection.$from.parent?.type?.name === "run") {
|
|
92834
|
+
offset2 = tr.selection.$from.after(tr.selection.$from.depth - 1);
|
|
92835
|
+
}
|
|
91289
92836
|
tr.replaceSelectionWith(node2).scrollIntoView().setSelection(TextSelection$1.near(tr.doc.resolve(offset2)));
|
|
91290
92837
|
}
|
|
91291
92838
|
return true;
|
|
@@ -118596,6 +120143,12 @@ ${style2}
|
|
|
118596
120143
|
};
|
|
118597
120144
|
const GenericPopover = /* @__PURE__ */ _export_sfc$1(_sfc_main$4$1, [["__scopeId", "data-v-cbddcc0f"]]);
|
|
118598
120145
|
const _hoisted_1$3$1 = ["data-boundary-index", "data-boundary-type", "onMousedown"];
|
|
120146
|
+
const RESIZE_HANDLE_WIDTH_PX = 9;
|
|
120147
|
+
const RESIZE_HANDLE_OFFSET_PX = 4;
|
|
120148
|
+
const DRAG_OVERLAY_EXTENSION_PX = 1e3;
|
|
120149
|
+
const MIN_DRAG_OVERLAY_WIDTH_PX = 2e3;
|
|
120150
|
+
const THROTTLE_INTERVAL_MS = 16;
|
|
120151
|
+
const MIN_RESIZE_DELTA_PX = 1;
|
|
118599
120152
|
const _sfc_main$3$1 = {
|
|
118600
120153
|
__name: "TableResizeOverlay",
|
|
118601
120154
|
props: {
|
|
@@ -118619,26 +120172,73 @@ ${style2}
|
|
|
118619
120172
|
setup(__props, { emit: __emit }) {
|
|
118620
120173
|
const props = __props;
|
|
118621
120174
|
const emit2 = __emit;
|
|
120175
|
+
const overlayRect = ref(null);
|
|
118622
120176
|
const tableMetadata = ref(null);
|
|
118623
120177
|
const dragState = ref(null);
|
|
118624
120178
|
const forcedCleanup = ref(false);
|
|
120179
|
+
let rafId = null;
|
|
120180
|
+
let isUnmounted = false;
|
|
120181
|
+
function startOverlayTracking() {
|
|
120182
|
+
if (rafId !== null) return;
|
|
120183
|
+
const step = () => {
|
|
120184
|
+
updateOverlayRect();
|
|
120185
|
+
rafId = requestAnimationFrame(step);
|
|
120186
|
+
};
|
|
120187
|
+
rafId = requestAnimationFrame(step);
|
|
120188
|
+
}
|
|
120189
|
+
function stopOverlayTracking() {
|
|
120190
|
+
if (rafId !== null) {
|
|
120191
|
+
cancelAnimationFrame(rafId);
|
|
120192
|
+
rafId = null;
|
|
120193
|
+
}
|
|
120194
|
+
}
|
|
118625
120195
|
const overlayStyle = computed(() => {
|
|
118626
|
-
if (!props.tableElement) return {};
|
|
118627
|
-
const rect =
|
|
120196
|
+
if (!overlayRect.value || !props.tableElement) return {};
|
|
120197
|
+
const rect = overlayRect.value;
|
|
118628
120198
|
let overlayWidth = rect.width;
|
|
118629
120199
|
if (dragState.value) {
|
|
118630
|
-
overlayWidth = Math.max(rect.width +
|
|
120200
|
+
overlayWidth = Math.max(rect.width + DRAG_OVERLAY_EXTENSION_PX, MIN_DRAG_OVERLAY_WIDTH_PX);
|
|
118631
120201
|
}
|
|
118632
120202
|
return {
|
|
118633
120203
|
position: "absolute",
|
|
118634
|
-
left: `${
|
|
118635
|
-
top: `${
|
|
120204
|
+
left: `${rect.left}px`,
|
|
120205
|
+
top: `${rect.top}px`,
|
|
118636
120206
|
width: `${overlayWidth}px`,
|
|
118637
120207
|
height: `${rect.height}px`,
|
|
118638
120208
|
pointerEvents: dragState.value ? "auto" : "none",
|
|
118639
120209
|
zIndex: 10
|
|
118640
120210
|
};
|
|
118641
120211
|
});
|
|
120212
|
+
function updateOverlayRect() {
|
|
120213
|
+
if (!props.tableElement) {
|
|
120214
|
+
overlayRect.value = null;
|
|
120215
|
+
return;
|
|
120216
|
+
}
|
|
120217
|
+
const parent = props.tableElement.offsetParent;
|
|
120218
|
+
const tableRect = props.tableElement.getBoundingClientRect();
|
|
120219
|
+
if (tableRect.width === 0 || tableRect.height === 0) {
|
|
120220
|
+
overlayRect.value = null;
|
|
120221
|
+
return;
|
|
120222
|
+
}
|
|
120223
|
+
if (parent) {
|
|
120224
|
+
const parentRect = parent.getBoundingClientRect();
|
|
120225
|
+
const left2 = tableRect.left - parentRect.left + (parent.scrollLeft || 0);
|
|
120226
|
+
const top2 = tableRect.top - parentRect.top + (parent.scrollTop || 0);
|
|
120227
|
+
overlayRect.value = {
|
|
120228
|
+
left: left2,
|
|
120229
|
+
top: top2,
|
|
120230
|
+
width: tableRect.width,
|
|
120231
|
+
height: tableRect.height
|
|
120232
|
+
};
|
|
120233
|
+
} else {
|
|
120234
|
+
overlayRect.value = {
|
|
120235
|
+
left: props.tableElement.offsetLeft,
|
|
120236
|
+
top: props.tableElement.offsetTop,
|
|
120237
|
+
width: tableRect.width,
|
|
120238
|
+
height: tableRect.height
|
|
120239
|
+
};
|
|
120240
|
+
}
|
|
120241
|
+
}
|
|
118642
120242
|
const resizableBoundaries = computed(() => {
|
|
118643
120243
|
if (!tableMetadata.value?.columns) {
|
|
118644
120244
|
return [];
|
|
@@ -118677,9 +120277,9 @@ ${style2}
|
|
|
118677
120277
|
if (!colSegments || colSegments.length === 0) {
|
|
118678
120278
|
return [];
|
|
118679
120279
|
}
|
|
118680
|
-
return colSegments.map((seg) => ({
|
|
118681
|
-
y: seg.y,
|
|
118682
|
-
h: seg.h
|
|
120280
|
+
return colSegments.filter((seg) => seg && typeof seg === "object").map((seg) => ({
|
|
120281
|
+
y: typeof seg.y === "number" ? seg.y : 0,
|
|
120282
|
+
h: seg.h !== null && typeof seg.h === "number" ? seg.h : null
|
|
118683
120283
|
}));
|
|
118684
120284
|
}
|
|
118685
120285
|
function getSegmentHandleStyle(boundary, segment) {
|
|
@@ -118687,16 +120287,16 @@ ${style2}
|
|
|
118687
120287
|
position: "absolute",
|
|
118688
120288
|
left: `${boundary.x}px`,
|
|
118689
120289
|
top: segment.y != null ? `${segment.y}px` : "0",
|
|
118690
|
-
width:
|
|
120290
|
+
width: `${RESIZE_HANDLE_WIDTH_PX}px`,
|
|
118691
120291
|
height: segment.h != null ? `${segment.h}px` : "100%",
|
|
118692
|
-
transform:
|
|
120292
|
+
transform: `translateX(-${RESIZE_HANDLE_OFFSET_PX}px)`,
|
|
118693
120293
|
cursor: "col-resize",
|
|
118694
120294
|
pointerEvents: "auto"
|
|
118695
120295
|
};
|
|
118696
120296
|
}
|
|
118697
120297
|
const guidelineStyle = computed(() => {
|
|
118698
120298
|
if (!dragState.value || !tableMetadata.value) return { display: "none" };
|
|
118699
|
-
const initialBoundary = resizableBoundaries.value[dragState.value.
|
|
120299
|
+
const initialBoundary = resizableBoundaries.value[dragState.value.resizableBoundaryIndex];
|
|
118700
120300
|
if (!initialBoundary) return { display: "none" };
|
|
118701
120301
|
const newX = initialBoundary.x + dragState.value.constrainedDelta;
|
|
118702
120302
|
return {
|
|
@@ -118753,11 +120353,11 @@ ${style2}
|
|
|
118753
120353
|
});
|
|
118754
120354
|
}
|
|
118755
120355
|
}
|
|
118756
|
-
function onHandleMouseDown(event,
|
|
120356
|
+
function onHandleMouseDown(event, resizableBoundaryIndex) {
|
|
118757
120357
|
event.preventDefault();
|
|
118758
120358
|
event.stopPropagation();
|
|
118759
120359
|
if (!tableMetadata.value?.columns) return;
|
|
118760
|
-
const boundary = resizableBoundaries.value[
|
|
120360
|
+
const boundary = resizableBoundaries.value[resizableBoundaryIndex];
|
|
118761
120361
|
if (!boundary) return;
|
|
118762
120362
|
const columns = tableMetadata.value.columns;
|
|
118763
120363
|
const isRightEdge = boundary.type === "right-edge";
|
|
@@ -118765,7 +120365,7 @@ ${style2}
|
|
|
118765
120365
|
const rightColumn = isRightEdge ? null : columns[boundary.index + 1];
|
|
118766
120366
|
dragState.value = {
|
|
118767
120367
|
columnIndex: boundary.index,
|
|
118768
|
-
|
|
120368
|
+
resizableBoundaryIndex,
|
|
118769
120369
|
isRightEdge,
|
|
118770
120370
|
initialX: event.clientX,
|
|
118771
120371
|
initialWidths: columns.map((col) => col.w),
|
|
@@ -118779,15 +120379,28 @@ ${style2}
|
|
|
118779
120379
|
} : null,
|
|
118780
120380
|
constrainedDelta: 0
|
|
118781
120381
|
};
|
|
120382
|
+
if (!props.editor?.view?.dom) {
|
|
120383
|
+
emit2("resize-error", { error: "Editor view not available" });
|
|
120384
|
+
dragState.value = null;
|
|
120385
|
+
return;
|
|
120386
|
+
}
|
|
118782
120387
|
const pmView = props.editor.view.dom;
|
|
118783
120388
|
pmView.style.pointerEvents = "none";
|
|
118784
|
-
|
|
118785
|
-
|
|
118786
|
-
|
|
118787
|
-
|
|
118788
|
-
|
|
118789
|
-
|
|
118790
|
-
|
|
120389
|
+
try {
|
|
120390
|
+
document.addEventListener("mousemove", onDocumentMouseMove2);
|
|
120391
|
+
document.addEventListener("mouseup", onDocumentMouseUp);
|
|
120392
|
+
emit2("resize-start", {
|
|
120393
|
+
columnIndex: boundary.index,
|
|
120394
|
+
isRightEdge,
|
|
120395
|
+
initialWidths: dragState.value.initialWidths
|
|
120396
|
+
});
|
|
120397
|
+
} catch (error) {
|
|
120398
|
+
document.removeEventListener("mousemove", onDocumentMouseMove2);
|
|
120399
|
+
document.removeEventListener("mouseup", onDocumentMouseUp);
|
|
120400
|
+
pmView.style.pointerEvents = "auto";
|
|
120401
|
+
dragState.value = null;
|
|
120402
|
+
emit2("resize-error", { error: error instanceof Error ? error.message : String(error) });
|
|
120403
|
+
}
|
|
118791
120404
|
}
|
|
118792
120405
|
function throttle2(func, limit) {
|
|
118793
120406
|
let inThrottle;
|
|
@@ -118812,7 +120425,7 @@ ${style2}
|
|
|
118812
120425
|
return { throttled, cancel };
|
|
118813
120426
|
}
|
|
118814
120427
|
const mouseMoveThrottle = throttle2((event) => {
|
|
118815
|
-
if (!dragState.value) return;
|
|
120428
|
+
if (isUnmounted || !dragState.value) return;
|
|
118816
120429
|
const delta = event.clientX - dragState.value.initialX;
|
|
118817
120430
|
const minDelta = -(dragState.value.leftColumn.width - dragState.value.leftColumn.minWidth);
|
|
118818
120431
|
let maxDelta;
|
|
@@ -118838,7 +120451,7 @@ ${style2}
|
|
|
118838
120451
|
columnIndex: dragState.value.columnIndex,
|
|
118839
120452
|
delta: constrainedDelta
|
|
118840
120453
|
});
|
|
118841
|
-
},
|
|
120454
|
+
}, THROTTLE_INTERVAL_MS);
|
|
118842
120455
|
const onDocumentMouseMove2 = mouseMoveThrottle.throttled;
|
|
118843
120456
|
function onDocumentMouseUp(event) {
|
|
118844
120457
|
if (!dragState.value) return;
|
|
@@ -118853,13 +120466,11 @@ ${style2}
|
|
|
118853
120466
|
}
|
|
118854
120467
|
document.removeEventListener("mousemove", onDocumentMouseMove2);
|
|
118855
120468
|
document.removeEventListener("mouseup", onDocumentMouseUp);
|
|
118856
|
-
if (props.editor?.view) {
|
|
120469
|
+
if (props.editor?.view?.dom) {
|
|
118857
120470
|
const pmView = props.editor.view.dom;
|
|
118858
|
-
|
|
118859
|
-
pmView.style.pointerEvents = "auto";
|
|
118860
|
-
}
|
|
120471
|
+
pmView.style.pointerEvents = "auto";
|
|
118861
120472
|
}
|
|
118862
|
-
if (!forcedCleanup.value && Math.abs(finalDelta) >
|
|
120473
|
+
if (!forcedCleanup.value && Math.abs(finalDelta) > MIN_RESIZE_DELTA_PX) {
|
|
118863
120474
|
dispatchResizeTransaction(columnIndex, newWidths);
|
|
118864
120475
|
emit2("resize-end", {
|
|
118865
120476
|
columnIndex,
|
|
@@ -118922,7 +120533,14 @@ ${style2}
|
|
|
118922
120533
|
if (!pmElement) {
|
|
118923
120534
|
return null;
|
|
118924
120535
|
}
|
|
118925
|
-
const
|
|
120536
|
+
const pmStartAttr = pmElement.getAttribute("data-pm-start");
|
|
120537
|
+
if (!pmStartAttr) {
|
|
120538
|
+
return null;
|
|
120539
|
+
}
|
|
120540
|
+
const pmStart = parseInt(pmStartAttr, 10);
|
|
120541
|
+
if (!Number.isFinite(pmStart)) {
|
|
120542
|
+
return null;
|
|
120543
|
+
}
|
|
118926
120544
|
let tablePos = null;
|
|
118927
120545
|
state2.doc.descendants((node2, pos) => {
|
|
118928
120546
|
if (node2.type.name === "table") {
|
|
@@ -118974,6 +120592,12 @@ ${style2}
|
|
|
118974
120592
|
() => props.tableElement,
|
|
118975
120593
|
() => {
|
|
118976
120594
|
parseTableMetadata();
|
|
120595
|
+
updateOverlayRect();
|
|
120596
|
+
if (props.visible && props.tableElement) {
|
|
120597
|
+
startOverlayTracking();
|
|
120598
|
+
} else if (!props.tableElement) {
|
|
120599
|
+
stopOverlayTracking();
|
|
120600
|
+
}
|
|
118977
120601
|
},
|
|
118978
120602
|
{ immediate: true }
|
|
118979
120603
|
);
|
|
@@ -118982,7 +120606,10 @@ ${style2}
|
|
|
118982
120606
|
(visible) => {
|
|
118983
120607
|
if (visible) {
|
|
118984
120608
|
parseTableMetadata();
|
|
120609
|
+
updateOverlayRect();
|
|
120610
|
+
startOverlayTracking();
|
|
118985
120611
|
} else {
|
|
120612
|
+
stopOverlayTracking();
|
|
118986
120613
|
if (dragState.value) {
|
|
118987
120614
|
forcedCleanup.value = true;
|
|
118988
120615
|
onDocumentMouseUp(new MouseEvent("mouseup"));
|
|
@@ -118991,8 +120618,15 @@ ${style2}
|
|
|
118991
120618
|
}
|
|
118992
120619
|
}
|
|
118993
120620
|
);
|
|
120621
|
+
onMounted(() => {
|
|
120622
|
+
window.addEventListener("scroll", updateOverlayRect, true);
|
|
120623
|
+
window.addEventListener("resize", updateOverlayRect);
|
|
120624
|
+
updateOverlayRect();
|
|
120625
|
+
});
|
|
118994
120626
|
onBeforeUnmount(() => {
|
|
120627
|
+
isUnmounted = true;
|
|
118995
120628
|
mouseMoveThrottle.cancel();
|
|
120629
|
+
stopOverlayTracking();
|
|
118996
120630
|
if (dragState.value) {
|
|
118997
120631
|
document.removeEventListener("mousemove", onDocumentMouseMove2);
|
|
118998
120632
|
document.removeEventListener("mouseup", onDocumentMouseUp);
|
|
@@ -119000,6 +120634,8 @@ ${style2}
|
|
|
119000
120634
|
props.editor.view.dom.style.pointerEvents = "auto";
|
|
119001
120635
|
}
|
|
119002
120636
|
}
|
|
120637
|
+
window.removeEventListener("scroll", updateOverlayRect, true);
|
|
120638
|
+
window.removeEventListener("resize", updateOverlayRect);
|
|
119003
120639
|
});
|
|
119004
120640
|
return (_ctx, _cache) => {
|
|
119005
120641
|
return __props.visible && tableMetadata.value ? (openBlock(), createElementBlock("div", {
|
|
@@ -119009,21 +120645,21 @@ ${style2}
|
|
|
119009
120645
|
onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
119010
120646
|
}, ["stop"]))
|
|
119011
120647
|
}, [
|
|
119012
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(resizableBoundaries.value, (boundary,
|
|
120648
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(resizableBoundaries.value, (boundary, resizableBoundaryIndex) => {
|
|
119013
120649
|
return openBlock(), createElementBlock(Fragment, {
|
|
119014
|
-
key: `boundary-${
|
|
120650
|
+
key: `boundary-${resizableBoundaryIndex}`
|
|
119015
120651
|
}, [
|
|
119016
120652
|
(openBlock(true), createElementBlock(Fragment, null, renderList(getBoundarySegments(boundary), (segment, segmentIndex) => {
|
|
119017
120653
|
return openBlock(), createElementBlock("div", {
|
|
119018
120654
|
key: `handle-${boundary.type}-${boundary.index}-${segmentIndex}`,
|
|
119019
120655
|
class: normalizeClass(["resize-handle", {
|
|
119020
|
-
"resize-handle--active": dragState.value && dragState.value.
|
|
120656
|
+
"resize-handle--active": dragState.value && dragState.value.resizableBoundaryIndex === resizableBoundaryIndex,
|
|
119021
120657
|
"resize-handle--edge": boundary.type === "right-edge"
|
|
119022
120658
|
}]),
|
|
119023
|
-
"data-boundary-index":
|
|
120659
|
+
"data-boundary-index": resizableBoundaryIndex,
|
|
119024
120660
|
"data-boundary-type": boundary.type,
|
|
119025
120661
|
style: normalizeStyle(getSegmentHandleStyle(boundary, segment)),
|
|
119026
|
-
onMousedown: ($event) => onHandleMouseDown($event,
|
|
120662
|
+
onMousedown: ($event) => onHandleMouseDown($event, resizableBoundaryIndex)
|
|
119027
120663
|
}, null, 46, _hoisted_1$3$1);
|
|
119028
120664
|
}), 128))
|
|
119029
120665
|
], 64);
|
|
@@ -119037,7 +120673,7 @@ ${style2}
|
|
|
119037
120673
|
};
|
|
119038
120674
|
}
|
|
119039
120675
|
};
|
|
119040
|
-
const TableResizeOverlay = /* @__PURE__ */ _export_sfc$1(_sfc_main$3$1, [["__scopeId", "data-v-
|
|
120676
|
+
const TableResizeOverlay = /* @__PURE__ */ _export_sfc$1(_sfc_main$3$1, [["__scopeId", "data-v-2fdf7836"]]);
|
|
119041
120677
|
const _hoisted_1$2$1 = ["data-handle-position", "onMousedown"];
|
|
119042
120678
|
const OVERLAY_EXPANSION_PX = 2e3;
|
|
119043
120679
|
const RESIZE_HANDLE_SIZE_PX = 12;
|
|
@@ -137036,7 +138672,7 @@ ${style2}
|
|
|
137036
138672
|
this.config.colors = shuffleArray(this.config.colors);
|
|
137037
138673
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
137038
138674
|
this.colorIndex = 0;
|
|
137039
|
-
this.version = "1.0.0-beta.
|
|
138675
|
+
this.version = "1.0.0-beta.17";
|
|
137040
138676
|
this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
137041
138677
|
this.superdocId = config2.superdocId || v4();
|
|
137042
138678
|
this.colors = this.config.colors;
|
|
@@ -139479,7 +141115,7 @@ ${style2}
|
|
|
139479
141115
|
value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
|
|
139480
141116
|
);
|
|
139481
141117
|
}
|
|
139482
|
-
const
|
|
141118
|
+
const indexVCeRjVPO = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
139483
141119
|
__proto__: null,
|
|
139484
141120
|
unified
|
|
139485
141121
|
}, Symbol.toStringTag, { value: "Module" }));
|