@harbour-enterprises/superdoc 0.18.0-next.5 → 0.18.0-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{PdfViewer-DDwiCSwf.cjs → PdfViewer-D923RAYf.cjs} +1 -1
- package/dist/chunks/{PdfViewer-Md3OYLQ6.es.js → PdfViewer-oLMiGubp.es.js} +1 -1
- package/dist/chunks/{index-B8Gqq2Ls.cjs → index-BSBoH60z.cjs} +3 -3
- package/dist/chunks/{index-nnK3k8Eg.es.js → index-DfESC4_z.es.js} +3 -3
- package/dist/chunks/{super-editor.es-C2jrGo_q.es.js → super-editor.es--ZHZr2PU.es.js} +620 -495
- package/dist/chunks/{super-editor.es-DPPXteBi.cjs → super-editor.es-CWyHUECy.cjs} +620 -495
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-YnaMMkRN.js → converter-5vEzqeeM.js} +1201 -1076
- package/dist/super-editor/chunks/{docx-zipper-Bq9-qqP_.js → docx-zipper-CWFbV6tN.js} +1 -1
- package/dist/super-editor/chunks/{editor-CAEseNKq.js → editor-CRz0_fqK.js} +3 -3
- package/dist/super-editor/chunks/{toolbar-BxxxSTHJ.js → toolbar-DCZwgkzr.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/src/core/super-converter/exporter.d.ts +2 -2
- package/dist/super-editor/src/core/super-converter/v2/importer/docxImporter.d.ts +2 -1
- package/dist/super-editor/src/core/super-converter/v2/importer/tableImporter.d.ts +17 -6
- package/dist/super-editor/src/core/super-converter/v2/importer/types/index.d.ts +4 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/legacy-handle-table-cell-node.d.ts +9 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/translate-table-cell.d.ts +17 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tc/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tc/tc-translator.d.ts +6 -0
- package/dist/super-editor/super-editor.es.js +6 -6
- 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 +621 -496
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -19677,7 +19677,11 @@ function handleListNodes(params2, node2) {
|
|
|
19677
19677
|
}
|
|
19678
19678
|
const styleIdIndex = pPr?.elements?.findIndex((el) => el.name === "w:pStyle");
|
|
19679
19679
|
if (styleIdIndex >= 0) pPr?.elements?.splice(styleIdIndex, 1);
|
|
19680
|
-
const fallBack = nodeListHandler2.handler({
|
|
19680
|
+
const fallBack = nodeListHandler2.handler({
|
|
19681
|
+
...params2,
|
|
19682
|
+
nodes: [node2],
|
|
19683
|
+
path: [...params2.path || [], node2]
|
|
19684
|
+
})?.filter((n) => n);
|
|
19681
19685
|
return fallBack[0];
|
|
19682
19686
|
}
|
|
19683
19687
|
if (!lists[currentListNumId]) lists[currentListNumId] = { levels: {} };
|
|
@@ -19705,7 +19709,11 @@ function handleListNodes(params2, node2) {
|
|
|
19705
19709
|
const nodePpr = node2.attrs?.paragraphProperties?.elements?.find((el) => el.name === "w:pPr");
|
|
19706
19710
|
const numPrIndex = node2.attrs?.paragraphProperties?.elements?.findIndex((el) => el.name === "w:numPr");
|
|
19707
19711
|
nodePpr?.elements?.splice(numPrIndex, 1);
|
|
19708
|
-
const listContents = nodeListHandler2.handler({
|
|
19712
|
+
const listContents = nodeListHandler2.handler({
|
|
19713
|
+
...params2,
|
|
19714
|
+
nodes: [node2],
|
|
19715
|
+
path: [...params2.path || [], node2]
|
|
19716
|
+
});
|
|
19709
19717
|
const innerParagraph = listContents.find((el) => el.type === "paragraph");
|
|
19710
19718
|
const firstElement = innerParagraph.content[0];
|
|
19711
19719
|
firstElement?.marks?.find((mark) => mark.type === "textStyle");
|
|
@@ -25550,13 +25558,13 @@ const wClearDecoder = (attrs) => {
|
|
|
25550
25558
|
const { clear } = attrs;
|
|
25551
25559
|
return clear;
|
|
25552
25560
|
};
|
|
25553
|
-
const XML_NODE_NAME$
|
|
25554
|
-
const SD_NODE_NAME$
|
|
25555
|
-
const validXmlAttributes$
|
|
25561
|
+
const XML_NODE_NAME$2 = "w:br";
|
|
25562
|
+
const SD_NODE_NAME$2 = "lineBreak";
|
|
25563
|
+
const validXmlAttributes$2 = [
|
|
25556
25564
|
{ xmlName: "w:type", sdName: "lineBreakType", encode: lineBreakTypeEncoder, decode: lineBreakTypeDecoder },
|
|
25557
25565
|
{ xmlName: "w:clear", sdName: "clear", encode: wClearEncoder, decode: wClearDecoder }
|
|
25558
25566
|
];
|
|
25559
|
-
const encode$
|
|
25567
|
+
const encode$2 = (_2, encodedAttrs) => {
|
|
25560
25568
|
const isPageBreak = encodedAttrs?.lineBreakType === "page";
|
|
25561
25569
|
const translated = {
|
|
25562
25570
|
type: isPageBreak ? "hardBreak" : "lineBreak"
|
|
@@ -25566,7 +25574,7 @@ const encode$1 = (_2, encodedAttrs) => {
|
|
|
25566
25574
|
}
|
|
25567
25575
|
return translated;
|
|
25568
25576
|
};
|
|
25569
|
-
const decode$
|
|
25577
|
+
const decode$2 = (params2, decodedAttrs) => {
|
|
25570
25578
|
const { node: node2 } = params2;
|
|
25571
25579
|
if (!node2) return;
|
|
25572
25580
|
const wBreak = { name: "w:br" };
|
|
@@ -25583,15 +25591,15 @@ const decode$1 = (params2, decodedAttrs) => {
|
|
|
25583
25591
|
};
|
|
25584
25592
|
return translated;
|
|
25585
25593
|
};
|
|
25586
|
-
const config$
|
|
25587
|
-
xmlName: XML_NODE_NAME$
|
|
25588
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
25594
|
+
const config$2 = {
|
|
25595
|
+
xmlName: XML_NODE_NAME$2,
|
|
25596
|
+
sdNodeOrKeyName: SD_NODE_NAME$2,
|
|
25589
25597
|
type: NodeTranslator.translatorTypes.NODE,
|
|
25590
|
-
encode: encode$
|
|
25591
|
-
decode: decode$
|
|
25592
|
-
attributes: validXmlAttributes$
|
|
25598
|
+
encode: encode$2,
|
|
25599
|
+
decode: decode$2,
|
|
25600
|
+
attributes: validXmlAttributes$2
|
|
25593
25601
|
};
|
|
25594
|
-
const translator$
|
|
25602
|
+
const translator$2 = NodeTranslator.from(config$2);
|
|
25595
25603
|
const tabSizeEncoder = (attributes) => {
|
|
25596
25604
|
return attributes["w:val"];
|
|
25597
25605
|
};
|
|
@@ -25613,19 +25621,19 @@ const tabPositionDecoder = (attrs) => {
|
|
|
25613
25621
|
const { pos } = attrs;
|
|
25614
25622
|
return pos;
|
|
25615
25623
|
};
|
|
25616
|
-
const XML_NODE_NAME = "w:tab";
|
|
25617
|
-
const SD_NODE_NAME = "tab";
|
|
25618
|
-
const validXmlAttributes = [
|
|
25624
|
+
const XML_NODE_NAME$1 = "w:tab";
|
|
25625
|
+
const SD_NODE_NAME$1 = "tab";
|
|
25626
|
+
const validXmlAttributes$1 = [
|
|
25619
25627
|
{ xmlName: "w:val", sdName: "tabSize", encode: tabSizeEncoder, decode: tabSizeDecoder },
|
|
25620
25628
|
{ xmlName: "w:pos", sdName: "pos", encode: tabPositionEncoder, decode: tabPositionDecoder },
|
|
25621
25629
|
{ xmlName: "w:leader", sdName: "leader", encode: tabLeaderEncoder, decode: tabLeaderDecoder }
|
|
25622
25630
|
];
|
|
25623
|
-
const encode$
|
|
25631
|
+
const encode$1 = (_2, encodedAttrs = {}) => {
|
|
25624
25632
|
const translated = { type: "tab" };
|
|
25625
25633
|
if (encodedAttrs) translated.attrs = { ...encodedAttrs };
|
|
25626
25634
|
return translated;
|
|
25627
25635
|
};
|
|
25628
|
-
const decode = (params2, decodedAttrs = {}) => {
|
|
25636
|
+
const decode$1 = (params2, decodedAttrs = {}) => {
|
|
25629
25637
|
const { node: node2 } = params2 || {};
|
|
25630
25638
|
if (!node2) return;
|
|
25631
25639
|
const wTab = { name: "w:tab" };
|
|
@@ -25641,11 +25649,543 @@ const decode = (params2, decodedAttrs = {}) => {
|
|
|
25641
25649
|
}
|
|
25642
25650
|
return translated;
|
|
25643
25651
|
};
|
|
25652
|
+
const config$1 = {
|
|
25653
|
+
xmlName: XML_NODE_NAME$1,
|
|
25654
|
+
sdNodeOrKeyName: SD_NODE_NAME$1,
|
|
25655
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
25656
|
+
encode: encode$1,
|
|
25657
|
+
decode: decode$1,
|
|
25658
|
+
attributes: validXmlAttributes$1
|
|
25659
|
+
};
|
|
25660
|
+
const translator$1 = NodeTranslator.from(config$1);
|
|
25661
|
+
const handleAllTableNodes = (params2) => {
|
|
25662
|
+
const { nodes } = params2;
|
|
25663
|
+
if (nodes.length === 0) {
|
|
25664
|
+
return { nodes: [], consumed: 0 };
|
|
25665
|
+
}
|
|
25666
|
+
const node2 = nodes[0];
|
|
25667
|
+
switch (node2.name) {
|
|
25668
|
+
case "w:tbl":
|
|
25669
|
+
return { nodes: [handleTableNode(node2, params2)], consumed: 1 };
|
|
25670
|
+
}
|
|
25671
|
+
return { nodes: [], consumed: 0 };
|
|
25672
|
+
};
|
|
25673
|
+
const tableNodeHandlerEntity = {
|
|
25674
|
+
handlerName: "tableNodeHandler",
|
|
25675
|
+
handler: handleAllTableNodes
|
|
25676
|
+
};
|
|
25677
|
+
function handleTableNode(node2, params2) {
|
|
25678
|
+
const { docx, nodeListHandler: nodeListHandler2 } = params2;
|
|
25679
|
+
const tblPr = node2.elements.find((el) => el.name === "w:tblPr");
|
|
25680
|
+
const tableBordersElement = tblPr.elements.find((el) => el.name === "w:tblBorders");
|
|
25681
|
+
const tableBorders = tableBordersElement?.elements || [];
|
|
25682
|
+
const { borders, rowBorders } = processTableBorders(tableBorders);
|
|
25683
|
+
const tblStyleTag = tblPr.elements.find((el) => el.name === "w:tblStyle");
|
|
25684
|
+
const tableStyleId = tblStyleTag?.attributes["w:val"];
|
|
25685
|
+
const attrs = { tableStyleId };
|
|
25686
|
+
const tableIndent = tblPr?.elements.find((el) => el.name === "w:tblInd");
|
|
25687
|
+
if (tableIndent) {
|
|
25688
|
+
const { "w:w": width, "w:type": type2 } = tableIndent.attributes;
|
|
25689
|
+
attrs["tableIndent"] = { width: twipsToPixels(width), type: type2 };
|
|
25690
|
+
}
|
|
25691
|
+
const tableLayout = tblPr?.elements.find((el) => el.name === "w:tblLayout");
|
|
25692
|
+
if (tableLayout) {
|
|
25693
|
+
const { "w:type": type2 } = tableLayout.attributes;
|
|
25694
|
+
attrs["tableLayout"] = type2;
|
|
25695
|
+
}
|
|
25696
|
+
const referencedStyles = getReferencedTableStyles(tblStyleTag, docx);
|
|
25697
|
+
const tblW = tblPr.elements.find((el) => el.name === "w:tblW");
|
|
25698
|
+
if (tblW) {
|
|
25699
|
+
attrs["tableWidth"] = {
|
|
25700
|
+
width: twipsToPixels(tblW.attributes["w:w"]),
|
|
25701
|
+
type: tblW.attributes["w:type"]
|
|
25702
|
+
};
|
|
25703
|
+
}
|
|
25704
|
+
const tblCellSpacing = tblPr.elements.find((el) => el.name === "w:tblCellSpacing");
|
|
25705
|
+
if (tblCellSpacing) {
|
|
25706
|
+
attrs["tableCellSpacing"] = {
|
|
25707
|
+
w: tblCellSpacing.attributes["w:w"],
|
|
25708
|
+
type: tblCellSpacing.attributes["w:type"]
|
|
25709
|
+
};
|
|
25710
|
+
attrs["borderCollapse"] = "separate";
|
|
25711
|
+
}
|
|
25712
|
+
const tblJustification = tblPr.elements.find((el) => el.name === "w:jc");
|
|
25713
|
+
if (tblJustification?.attributes) {
|
|
25714
|
+
attrs["justification"] = tblJustification.attributes["w:val"];
|
|
25715
|
+
}
|
|
25716
|
+
const rows = node2.elements.filter((el) => el.name === "w:tr");
|
|
25717
|
+
const refStylesBorders = referencedStyles?.borders || {};
|
|
25718
|
+
const refStylesRowBorders = referencedStyles?.rowBorders || {};
|
|
25719
|
+
const borderData = Object.keys(borders)?.length ? Object.assign(refStylesBorders, borders) : refStylesBorders;
|
|
25720
|
+
const borderRowData = Object.keys(rowBorders)?.length ? Object.assign(refStylesRowBorders, rowBorders) : refStylesRowBorders;
|
|
25721
|
+
attrs["borders"] = borderData;
|
|
25722
|
+
const content = [];
|
|
25723
|
+
rows.forEach((row) => {
|
|
25724
|
+
const result = handleTableRowNode(row, node2, borderRowData, tblStyleTag, params2);
|
|
25725
|
+
if (result.content?.length) content.push(result);
|
|
25726
|
+
});
|
|
25727
|
+
return {
|
|
25728
|
+
type: "table",
|
|
25729
|
+
content,
|
|
25730
|
+
attrs
|
|
25731
|
+
};
|
|
25732
|
+
}
|
|
25733
|
+
function handleTableCellNode$1({
|
|
25734
|
+
params: params2,
|
|
25735
|
+
node: node2,
|
|
25736
|
+
table,
|
|
25737
|
+
row,
|
|
25738
|
+
rowBorders,
|
|
25739
|
+
styleTag,
|
|
25740
|
+
columnIndex,
|
|
25741
|
+
columnWidth = null
|
|
25742
|
+
}) {
|
|
25743
|
+
const translatorParams = {
|
|
25744
|
+
...params2,
|
|
25745
|
+
extraParams: {
|
|
25746
|
+
node: node2,
|
|
25747
|
+
table,
|
|
25748
|
+
row,
|
|
25749
|
+
rowBorders,
|
|
25750
|
+
styleTag,
|
|
25751
|
+
columnIndex,
|
|
25752
|
+
columnWidth
|
|
25753
|
+
}
|
|
25754
|
+
};
|
|
25755
|
+
const schemaNode = translator.encode(translatorParams);
|
|
25756
|
+
return schemaNode;
|
|
25757
|
+
}
|
|
25758
|
+
function getReferencedTableStyles(tblStyleTag, docx) {
|
|
25759
|
+
if (!tblStyleTag) return null;
|
|
25760
|
+
const stylesToReturn = {};
|
|
25761
|
+
const { attributes = {} } = tblStyleTag;
|
|
25762
|
+
const tableStyleReference = attributes["w:val"];
|
|
25763
|
+
if (!tableStyleReference) return null;
|
|
25764
|
+
const styles = docx["word/styles.xml"];
|
|
25765
|
+
const { elements } = styles.elements[0];
|
|
25766
|
+
const styleElements = elements.filter((el) => el.name === "w:style");
|
|
25767
|
+
const styleTag = styleElements.find((el) => el.attributes["w:styleId"] === tableStyleReference);
|
|
25768
|
+
if (!styleTag) return null;
|
|
25769
|
+
stylesToReturn.name = styleTag.elements.find((el) => el.name === "w:name");
|
|
25770
|
+
const basedOn = styleTag.elements.find((el) => el.name === "w:basedOn");
|
|
25771
|
+
let baseTblPr;
|
|
25772
|
+
if (basedOn?.attributes) {
|
|
25773
|
+
const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
|
|
25774
|
+
baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
|
|
25775
|
+
}
|
|
25776
|
+
const pPr = styleTag.elements.find((el) => el.name === "w:pPr");
|
|
25777
|
+
if (pPr) {
|
|
25778
|
+
const justification = pPr.elements.find((el) => el.name === "w:jc");
|
|
25779
|
+
if (justification?.attributes) stylesToReturn.justification = justification.attributes["w:val"];
|
|
25780
|
+
}
|
|
25781
|
+
const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
|
|
25782
|
+
if (rPr) {
|
|
25783
|
+
const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
|
|
25784
|
+
if (fonts) {
|
|
25785
|
+
const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
|
|
25786
|
+
stylesToReturn.fonts = { ascii, hAnsi, cs };
|
|
25787
|
+
}
|
|
25788
|
+
const fontSize2 = rPr.elements.find((el) => el.name === "w:sz");
|
|
25789
|
+
if (fontSize2?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize2.attributes["w:val"]) + "pt";
|
|
25790
|
+
}
|
|
25791
|
+
const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
|
|
25792
|
+
if (tblPr && tblPr.elements) {
|
|
25793
|
+
if (baseTblPr && baseTblPr.elements) {
|
|
25794
|
+
tblPr.elements.push(...baseTblPr.elements);
|
|
25795
|
+
}
|
|
25796
|
+
const tableBorders = tblPr?.elements?.find((el) => el.name === "w:tblBorders");
|
|
25797
|
+
const { elements: borderElements = [] } = tableBorders || {};
|
|
25798
|
+
const { borders, rowBorders } = processTableBorders(borderElements);
|
|
25799
|
+
if (borders) stylesToReturn.borders = borders;
|
|
25800
|
+
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
25801
|
+
const tableCellMargin = tblPr?.elements.find((el) => el.name === "w:tblCellMar");
|
|
25802
|
+
if (tableCellMargin) {
|
|
25803
|
+
const marginLeft = tableCellMargin.elements.find((el) => el.name === "w:left");
|
|
25804
|
+
const marginRight = tableCellMargin.elements.find((el) => el.name === "w:right");
|
|
25805
|
+
const marginTop = tableCellMargin.elements.find((el) => el.name === "w:top");
|
|
25806
|
+
const marginBottom = tableCellMargin.elements.find((el) => el.name === "w:bottom");
|
|
25807
|
+
stylesToReturn.cellMargins = {
|
|
25808
|
+
marginLeft: marginLeft?.attributes["w:w"],
|
|
25809
|
+
marginRight: marginRight?.attributes["w:w"],
|
|
25810
|
+
marginTop: marginTop?.attributes["w:w"],
|
|
25811
|
+
marginBottom: marginBottom?.attributes["w:w"]
|
|
25812
|
+
};
|
|
25813
|
+
}
|
|
25814
|
+
}
|
|
25815
|
+
return stylesToReturn;
|
|
25816
|
+
}
|
|
25817
|
+
function processTableBorders(borderElements) {
|
|
25818
|
+
const borders = {};
|
|
25819
|
+
const rowBorders = {};
|
|
25820
|
+
borderElements.forEach((borderElement) => {
|
|
25821
|
+
const { name } = borderElement;
|
|
25822
|
+
const borderName = name.split("w:")[1];
|
|
25823
|
+
const { attributes } = borderElement;
|
|
25824
|
+
const attrs = {};
|
|
25825
|
+
const color = attributes["w:color"];
|
|
25826
|
+
const size2 = attributes["w:sz"];
|
|
25827
|
+
if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
|
|
25828
|
+
if (size2 && size2 !== "auto") attrs["size"] = eigthPointsToPixels(size2);
|
|
25829
|
+
const rowBorderNames = ["insideH", "insideV"];
|
|
25830
|
+
if (rowBorderNames.includes(borderName)) rowBorders[borderName] = attrs;
|
|
25831
|
+
borders[borderName] = attrs;
|
|
25832
|
+
});
|
|
25833
|
+
return {
|
|
25834
|
+
borders,
|
|
25835
|
+
rowBorders
|
|
25836
|
+
};
|
|
25837
|
+
}
|
|
25838
|
+
function handleTableRowNode(node2, table, rowBorders, styleTag, params2) {
|
|
25839
|
+
const attrs = {};
|
|
25840
|
+
const tPr = node2.elements.find((el) => el.name === "w:trPr");
|
|
25841
|
+
const rowHeightTag = tPr?.elements?.find((el) => el.name === "w:trHeight");
|
|
25842
|
+
const rowHeight = rowHeightTag?.attributes["w:val"];
|
|
25843
|
+
const cantSplitTag = tPr?.elements?.find((el) => el.name === "w:cantSplit");
|
|
25844
|
+
if (cantSplitTag) {
|
|
25845
|
+
attrs["cantSplit"] = true;
|
|
25846
|
+
}
|
|
25847
|
+
const borders = {};
|
|
25848
|
+
if (rowBorders?.insideH) borders["bottom"] = rowBorders.insideH;
|
|
25849
|
+
if (rowBorders?.insideV) borders["right"] = rowBorders.insideV;
|
|
25850
|
+
attrs["borders"] = borders;
|
|
25851
|
+
if (rowHeight) {
|
|
25852
|
+
attrs["rowHeight"] = twipsToPixels(rowHeight);
|
|
25853
|
+
}
|
|
25854
|
+
const gridColumnWidths = getGridColumnWidths(table);
|
|
25855
|
+
const cellNodes = node2.elements.filter((el) => el.name === "w:tc");
|
|
25856
|
+
let currentColumnIndex = 0;
|
|
25857
|
+
const content = cellNodes?.map((n) => {
|
|
25858
|
+
let colWidth = gridColumnWidths?.[currentColumnIndex] || null;
|
|
25859
|
+
const result = handleTableCellNode$1({
|
|
25860
|
+
params: params2,
|
|
25861
|
+
node: n,
|
|
25862
|
+
table,
|
|
25863
|
+
row: node2,
|
|
25864
|
+
rowBorders: borders,
|
|
25865
|
+
styleTag,
|
|
25866
|
+
columnIndex: currentColumnIndex,
|
|
25867
|
+
columnWidth: colWidth
|
|
25868
|
+
});
|
|
25869
|
+
const tcPr = n.elements?.find((el) => el.name === "w:tcPr");
|
|
25870
|
+
const colspanTag = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
25871
|
+
const colspan = parseInt(colspanTag?.attributes["w:val"] || 1, 10);
|
|
25872
|
+
currentColumnIndex += colspan;
|
|
25873
|
+
return result;
|
|
25874
|
+
}) || [];
|
|
25875
|
+
const newNode = {
|
|
25876
|
+
type: "tableRow",
|
|
25877
|
+
content,
|
|
25878
|
+
attrs
|
|
25879
|
+
};
|
|
25880
|
+
return newNode;
|
|
25881
|
+
}
|
|
25882
|
+
const getGridColumnWidths = (tableNode) => {
|
|
25883
|
+
const tblGrid = tableNode.elements.find((el) => el.name === "w:tblGrid");
|
|
25884
|
+
if (!tblGrid) return [];
|
|
25885
|
+
const columnWidths = tblGrid?.elements?.flatMap((el) => {
|
|
25886
|
+
if (el.name !== "w:gridCol") return [];
|
|
25887
|
+
return twipsToPixels(el.attributes["w:w"]);
|
|
25888
|
+
}) || [];
|
|
25889
|
+
return columnWidths;
|
|
25890
|
+
};
|
|
25891
|
+
function handleTableCellNode({
|
|
25892
|
+
params: params2,
|
|
25893
|
+
node: node2,
|
|
25894
|
+
table,
|
|
25895
|
+
row,
|
|
25896
|
+
rowBorders,
|
|
25897
|
+
styleTag,
|
|
25898
|
+
columnIndex,
|
|
25899
|
+
columnWidth = null
|
|
25900
|
+
}) {
|
|
25901
|
+
const { docx, nodeListHandler: nodeListHandler2 } = params2;
|
|
25902
|
+
const tcPr = node2.elements.find((el) => el.name === "w:tcPr");
|
|
25903
|
+
const borders = tcPr?.elements?.find((el) => el.name === "w:tcBorders");
|
|
25904
|
+
const inlineBorders = processInlineCellBorders(borders, rowBorders);
|
|
25905
|
+
const gridColumnWidths = getGridColumnWidths(table);
|
|
25906
|
+
const tcWidth = tcPr?.elements?.find((el) => el.name === "w:tcW");
|
|
25907
|
+
let width = tcWidth ? twipsToPixels(tcWidth.attributes["w:w"]) : null;
|
|
25908
|
+
const widthType = tcWidth?.attributes["w:type"];
|
|
25909
|
+
if (!width && columnWidth) width = columnWidth;
|
|
25910
|
+
const vMerge = getTableCellMergeTag(node2);
|
|
25911
|
+
const { attributes: vMergeAttrs } = vMerge || {};
|
|
25912
|
+
const backgroundColor = tcPr?.elements?.find((el) => el.name === "w:shd");
|
|
25913
|
+
const background = {
|
|
25914
|
+
color: backgroundColor?.attributes["w:fill"]
|
|
25915
|
+
};
|
|
25916
|
+
const colspanTag = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
25917
|
+
const colspan = colspanTag?.attributes["w:val"];
|
|
25918
|
+
const marginTag = tcPr?.elements?.find((el) => el.name === "w:tcMar");
|
|
25919
|
+
const verticalAlignTag = tcPr?.elements?.find((el) => el.name === "w:vAlign");
|
|
25920
|
+
const verticalAlign = verticalAlignTag?.attributes["w:val"] || "top";
|
|
25921
|
+
const attributes = {};
|
|
25922
|
+
const referencedStyles = getReferencedTableStyles(styleTag, docx) || {};
|
|
25923
|
+
attributes.cellMargins = getTableCellMargins(marginTag, referencedStyles);
|
|
25924
|
+
const { fontSize: fontSize2, fonts = {} } = referencedStyles;
|
|
25925
|
+
const fontFamily2 = fonts["ascii"];
|
|
25926
|
+
if (width) {
|
|
25927
|
+
attributes["colwidth"] = [width];
|
|
25928
|
+
attributes["widthUnit"] = "px";
|
|
25929
|
+
const defaultColWidths = gridColumnWidths;
|
|
25930
|
+
const hasDefaultColWidths = gridColumnWidths && gridColumnWidths.length > 0;
|
|
25931
|
+
const colspanNum = parseInt(colspan || 1, 10);
|
|
25932
|
+
if (colspanNum && colspanNum > 1 && hasDefaultColWidths) {
|
|
25933
|
+
let colwidth = [];
|
|
25934
|
+
for (let i = 0; i < colspanNum; i++) {
|
|
25935
|
+
let colwidthValue = defaultColWidths[columnIndex + i];
|
|
25936
|
+
let defaultColwidth = 100;
|
|
25937
|
+
if (typeof colwidthValue !== "undefined") {
|
|
25938
|
+
colwidth.push(colwidthValue);
|
|
25939
|
+
} else {
|
|
25940
|
+
colwidth.push(defaultColwidth);
|
|
25941
|
+
}
|
|
25942
|
+
}
|
|
25943
|
+
if (colwidth.length) {
|
|
25944
|
+
attributes["colwidth"] = [...colwidth];
|
|
25945
|
+
}
|
|
25946
|
+
}
|
|
25947
|
+
}
|
|
25948
|
+
if (widthType) attributes["widthType"] = widthType;
|
|
25949
|
+
if (colspan) attributes["colspan"] = parseInt(colspan, 10);
|
|
25950
|
+
if (background) attributes["background"] = background;
|
|
25951
|
+
attributes["verticalAlign"] = verticalAlign;
|
|
25952
|
+
if (fontSize2) attributes["fontSize"] = fontSize2;
|
|
25953
|
+
if (fontFamily2) attributes["fontFamily"] = fontFamily2["ascii"];
|
|
25954
|
+
if (rowBorders) attributes["borders"] = { ...rowBorders };
|
|
25955
|
+
if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"] || {}, inlineBorders);
|
|
25956
|
+
if (vMergeAttrs && vMergeAttrs["w:val"] === "restart") {
|
|
25957
|
+
const rows = table.elements.filter((el) => el.name === "w:tr");
|
|
25958
|
+
const currentRowIndex = rows.findIndex((r2) => r2 === row);
|
|
25959
|
+
const remainingRows = rows.slice(currentRowIndex + 1);
|
|
25960
|
+
const cellsInRow = row.elements.filter((el) => el.name === "w:tc");
|
|
25961
|
+
let cellIndex = cellsInRow.findIndex((el) => el === node2);
|
|
25962
|
+
let rowspan = 1;
|
|
25963
|
+
for (let remainingRow of remainingRows) {
|
|
25964
|
+
const firstCell = remainingRow.elements.findIndex((el) => el.name === "w:tc");
|
|
25965
|
+
const cellAtIndex = remainingRow.elements[firstCell + cellIndex];
|
|
25966
|
+
if (!cellAtIndex) break;
|
|
25967
|
+
const vMerge2 = getTableCellMergeTag(cellAtIndex);
|
|
25968
|
+
const { attributes: currentCellMergeAttrs } = vMerge2 || {};
|
|
25969
|
+
if (!vMerge2 && !currentCellMergeAttrs || currentCellMergeAttrs && currentCellMergeAttrs["w:val"] === "restart") {
|
|
25970
|
+
break;
|
|
25971
|
+
}
|
|
25972
|
+
rowspan++;
|
|
25973
|
+
remainingRow.elements.splice(firstCell + cellIndex, 1);
|
|
25974
|
+
}
|
|
25975
|
+
attributes["rowspan"] = rowspan;
|
|
25976
|
+
}
|
|
25977
|
+
return {
|
|
25978
|
+
type: "tableCell",
|
|
25979
|
+
content: nodeListHandler2.handler({
|
|
25980
|
+
...params2,
|
|
25981
|
+
nodes: node2.elements,
|
|
25982
|
+
path: [...params2.path || [], node2]
|
|
25983
|
+
}),
|
|
25984
|
+
attrs: attributes
|
|
25985
|
+
};
|
|
25986
|
+
}
|
|
25987
|
+
const processInlineCellBorders = (borders, rowBorders) => {
|
|
25988
|
+
if (!borders) return null;
|
|
25989
|
+
const processedBorders = {};
|
|
25990
|
+
const inlineBorderBottom = processBorder(borders, "bottom", rowBorders);
|
|
25991
|
+
if (inlineBorderBottom) processedBorders["bottom"] = inlineBorderBottom;
|
|
25992
|
+
const inlineBorderTop = processBorder(borders, "top", rowBorders);
|
|
25993
|
+
if (inlineBorderTop) processedBorders["top"] = inlineBorderTop;
|
|
25994
|
+
const inlineBorderLeft = processBorder(borders, "left", rowBorders);
|
|
25995
|
+
if (inlineBorderLeft) processedBorders["left"] = inlineBorderLeft;
|
|
25996
|
+
const inlineBorderRight = processBorder(borders, "right", rowBorders);
|
|
25997
|
+
if (inlineBorderRight) processedBorders["right"] = inlineBorderRight;
|
|
25998
|
+
return processedBorders;
|
|
25999
|
+
};
|
|
26000
|
+
const processBorder = (borders, direction, rowBorders = {}) => {
|
|
26001
|
+
const borderAttrs = borders?.elements?.find((el) => el.name === `w:${direction}`)?.attributes;
|
|
26002
|
+
if (borderAttrs && borderAttrs["w:val"] !== "nil") {
|
|
26003
|
+
const border = {};
|
|
26004
|
+
const color = borderAttrs["w:color"];
|
|
26005
|
+
if (color) border["color"] = color === "auto" ? "#000000" : `#${color}`;
|
|
26006
|
+
const size2 = borderAttrs["w:sz"];
|
|
26007
|
+
if (size2) border["size"] = eigthPointsToPixels(size2);
|
|
26008
|
+
return border;
|
|
26009
|
+
}
|
|
26010
|
+
if (borderAttrs && borderAttrs["w:val"] === "nil") {
|
|
26011
|
+
const border = Object.assign({}, rowBorders[direction] || {});
|
|
26012
|
+
if (!Object.keys(border)) return null;
|
|
26013
|
+
border["val"] = "none";
|
|
26014
|
+
return border;
|
|
26015
|
+
}
|
|
26016
|
+
return null;
|
|
26017
|
+
};
|
|
26018
|
+
const getTableCellMergeTag = (node2) => {
|
|
26019
|
+
const tcPr = node2.elements.find((el) => el.name === "w:tcPr");
|
|
26020
|
+
const vMerge = tcPr?.elements?.find((el) => el.name === "w:vMerge");
|
|
26021
|
+
return vMerge;
|
|
26022
|
+
};
|
|
26023
|
+
const getTableCellMargins = (marginTag, referencedStyles) => {
|
|
26024
|
+
const inlineMarginLeftTag = marginTag?.elements?.find((el) => el.name === "w:left");
|
|
26025
|
+
const inlineMarginRightTag = marginTag?.elements?.find((el) => el.name === "w:right");
|
|
26026
|
+
const inlineMarginTopTag = marginTag?.elements?.find((el) => el.name === "w:top");
|
|
26027
|
+
const inlineMarginBottomTag = marginTag?.elements?.find((el) => el.name === "w:bottom");
|
|
26028
|
+
const inlineMarginLeftValue = inlineMarginLeftTag?.attributes["w:w"];
|
|
26029
|
+
const inlineMarginRightValue = inlineMarginRightTag?.attributes["w:w"];
|
|
26030
|
+
const inlineMarginTopValue = inlineMarginTopTag?.attributes["w:w"];
|
|
26031
|
+
const inlineMarginBottomValue = inlineMarginBottomTag?.attributes["w:w"];
|
|
26032
|
+
const { cellMargins = {} } = referencedStyles;
|
|
26033
|
+
const {
|
|
26034
|
+
marginLeft: marginLeftStyle,
|
|
26035
|
+
marginRight: marginRightStyle,
|
|
26036
|
+
marginTop: marginTopStyle,
|
|
26037
|
+
marginBottom: marginBottomStyle
|
|
26038
|
+
} = cellMargins;
|
|
26039
|
+
const margins = {
|
|
26040
|
+
left: twipsToPixels(inlineMarginLeftValue ?? marginLeftStyle),
|
|
26041
|
+
right: twipsToPixels(inlineMarginRightValue ?? marginRightStyle),
|
|
26042
|
+
top: twipsToPixels(inlineMarginTopValue ?? marginTopStyle),
|
|
26043
|
+
bottom: twipsToPixels(inlineMarginBottomValue ?? marginBottomStyle)
|
|
26044
|
+
};
|
|
26045
|
+
return margins;
|
|
26046
|
+
};
|
|
26047
|
+
function translateTableCell(params2) {
|
|
26048
|
+
const elements = translateChildNodes({
|
|
26049
|
+
...params2,
|
|
26050
|
+
tableCell: params2.node
|
|
26051
|
+
});
|
|
26052
|
+
const cellProps = generateTableCellProperties(params2.node);
|
|
26053
|
+
elements.unshift(cellProps);
|
|
26054
|
+
return {
|
|
26055
|
+
name: "w:tc",
|
|
26056
|
+
elements
|
|
26057
|
+
};
|
|
26058
|
+
}
|
|
26059
|
+
function generateTableCellProperties(node2) {
|
|
26060
|
+
const elements = [];
|
|
26061
|
+
const { attrs } = node2;
|
|
26062
|
+
const { colwidth = [], cellWidthType = "dxa", background = {}, colspan, rowspan, widthUnit } = attrs;
|
|
26063
|
+
const colwidthSum = colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
26064
|
+
const cellWidthElement = {
|
|
26065
|
+
name: "w:tcW",
|
|
26066
|
+
attributes: {
|
|
26067
|
+
"w:w": widthUnit === "px" ? pixelsToTwips(colwidthSum) : inchesToTwips(colwidthSum),
|
|
26068
|
+
"w:type": cellWidthType
|
|
26069
|
+
}
|
|
26070
|
+
};
|
|
26071
|
+
elements.push(cellWidthElement);
|
|
26072
|
+
if (colspan) {
|
|
26073
|
+
const gridSpanElement = {
|
|
26074
|
+
name: "w:gridSpan",
|
|
26075
|
+
attributes: { "w:val": `${colspan}` }
|
|
26076
|
+
};
|
|
26077
|
+
elements.push(gridSpanElement);
|
|
26078
|
+
}
|
|
26079
|
+
const { color } = background || {};
|
|
26080
|
+
if (color) {
|
|
26081
|
+
const cellBgElement = {
|
|
26082
|
+
name: "w:shd",
|
|
26083
|
+
attributes: { "w:fill": color }
|
|
26084
|
+
};
|
|
26085
|
+
elements.push(cellBgElement);
|
|
26086
|
+
}
|
|
26087
|
+
const { cellMargins } = attrs;
|
|
26088
|
+
if (cellMargins) {
|
|
26089
|
+
const cellMarginsElement = {
|
|
26090
|
+
name: "w:tcMar",
|
|
26091
|
+
elements: generateCellMargins(cellMargins)
|
|
26092
|
+
};
|
|
26093
|
+
elements.push(cellMarginsElement);
|
|
26094
|
+
}
|
|
26095
|
+
const { verticalAlign } = attrs;
|
|
26096
|
+
if (verticalAlign) {
|
|
26097
|
+
const vertAlignElement = {
|
|
26098
|
+
name: "w:vAlign",
|
|
26099
|
+
attributes: { "w:val": verticalAlign }
|
|
26100
|
+
};
|
|
26101
|
+
elements.push(vertAlignElement);
|
|
26102
|
+
}
|
|
26103
|
+
if (rowspan && rowspan > 1) {
|
|
26104
|
+
const vMergeElement = {
|
|
26105
|
+
name: "w:vMerge",
|
|
26106
|
+
type: "element",
|
|
26107
|
+
attributes: { "w:val": "restart" }
|
|
26108
|
+
};
|
|
26109
|
+
elements.push(vMergeElement);
|
|
26110
|
+
} else if (attrs.continueMerge) {
|
|
26111
|
+
const vMergeElement = {
|
|
26112
|
+
name: "w:vMerge",
|
|
26113
|
+
type: "element"
|
|
26114
|
+
};
|
|
26115
|
+
elements.push(vMergeElement);
|
|
26116
|
+
}
|
|
26117
|
+
const { borders = {} } = attrs;
|
|
26118
|
+
if (!!borders && Object.keys(borders).length) {
|
|
26119
|
+
const cellBordersElement = {
|
|
26120
|
+
name: "w:tcBorders",
|
|
26121
|
+
elements: Object.entries(borders).map(([key, value]) => {
|
|
26122
|
+
if (!value.size || value.val === "none") {
|
|
26123
|
+
return {
|
|
26124
|
+
name: `w:${key}`,
|
|
26125
|
+
attributes: {
|
|
26126
|
+
"w:val": "nil"
|
|
26127
|
+
}
|
|
26128
|
+
};
|
|
26129
|
+
}
|
|
26130
|
+
return {
|
|
26131
|
+
name: `w:${key}`,
|
|
26132
|
+
attributes: {
|
|
26133
|
+
"w:val": "single",
|
|
26134
|
+
"w:color": value.color ? value.color.substring(1) : "auto",
|
|
26135
|
+
"w:sz": pixelsToEightPoints(value.size),
|
|
26136
|
+
"w:space": value.space || 0
|
|
26137
|
+
}
|
|
26138
|
+
};
|
|
26139
|
+
})
|
|
26140
|
+
};
|
|
26141
|
+
elements.push(cellBordersElement);
|
|
26142
|
+
}
|
|
26143
|
+
return {
|
|
26144
|
+
name: "w:tcPr",
|
|
26145
|
+
elements
|
|
26146
|
+
};
|
|
26147
|
+
}
|
|
26148
|
+
function generateCellMargins(cellMargins) {
|
|
26149
|
+
const elements = [];
|
|
26150
|
+
const { top: top2, right: right2, bottom: bottom2, left: left2 } = cellMargins;
|
|
26151
|
+
if (top2 != null) elements.push({ name: "w:top", attributes: { "w:w": pixelsToTwips(top2) } });
|
|
26152
|
+
if (right2 != null) elements.push({ name: "w:right", attributes: { "w:w": pixelsToTwips(right2) } });
|
|
26153
|
+
if (bottom2 != null) elements.push({ name: "w:bottom", attributes: { "w:w": pixelsToTwips(bottom2) } });
|
|
26154
|
+
if (left2 != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left2) } });
|
|
26155
|
+
return elements;
|
|
26156
|
+
}
|
|
26157
|
+
const XML_NODE_NAME = "w:tc";
|
|
26158
|
+
const SD_NODE_NAME = "tableCell";
|
|
26159
|
+
const validXmlAttributes = [];
|
|
26160
|
+
function encode$3(params2, encodedAttrs) {
|
|
26161
|
+
const { node: node2, table, row, rowBorders, styleTag, columnIndex, columnWidth } = params2.extraParams;
|
|
26162
|
+
const schemaNode = handleTableCellNode({
|
|
26163
|
+
params: params2,
|
|
26164
|
+
node: node2,
|
|
26165
|
+
table,
|
|
26166
|
+
row,
|
|
26167
|
+
rowBorders,
|
|
26168
|
+
styleTag,
|
|
26169
|
+
columnIndex,
|
|
26170
|
+
columnWidth
|
|
26171
|
+
});
|
|
26172
|
+
if (encodedAttrs && Object.keys(encodedAttrs).length) {
|
|
26173
|
+
schemaNode.attrs = { ...schemaNode.attrs, ...encodedAttrs };
|
|
26174
|
+
}
|
|
26175
|
+
return schemaNode;
|
|
26176
|
+
}
|
|
26177
|
+
function decode(params2, decodedAttrs) {
|
|
26178
|
+
const translated = translateTableCell(params2);
|
|
26179
|
+
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
26180
|
+
translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
|
|
26181
|
+
}
|
|
26182
|
+
return translated;
|
|
26183
|
+
}
|
|
25644
26184
|
const config = {
|
|
25645
26185
|
xmlName: XML_NODE_NAME,
|
|
25646
26186
|
sdNodeOrKeyName: SD_NODE_NAME,
|
|
25647
26187
|
type: NodeTranslator.translatorTypes.NODE,
|
|
25648
|
-
encode: encode$
|
|
26188
|
+
encode: encode$3,
|
|
25649
26189
|
decode,
|
|
25650
26190
|
attributes: validXmlAttributes
|
|
25651
26191
|
};
|
|
@@ -25660,15 +26200,15 @@ function exportSchemaToJson(params2) {
|
|
|
25660
26200
|
text: translateTextNode,
|
|
25661
26201
|
bulletList: translateList,
|
|
25662
26202
|
orderedList: translateList,
|
|
25663
|
-
lineBreak: translator$
|
|
26203
|
+
lineBreak: translator$2,
|
|
25664
26204
|
table: translateTable,
|
|
25665
26205
|
tableRow: translateTableRow,
|
|
25666
|
-
tableCell:
|
|
26206
|
+
tableCell: translator,
|
|
25667
26207
|
bookmarkStart: translateBookmarkStart,
|
|
25668
26208
|
fieldAnnotation: translateFieldAnnotation,
|
|
25669
|
-
tab: translator,
|
|
26209
|
+
tab: translator$1,
|
|
25670
26210
|
image: translateImageNode,
|
|
25671
|
-
hardBreak: translator$
|
|
26211
|
+
hardBreak: translator$2,
|
|
25672
26212
|
commentRangeStart: () => translateCommentNode(params2, "Start"),
|
|
25673
26213
|
commentRangeEnd: () => translateCommentNode(params2, "End"),
|
|
25674
26214
|
commentReference: () => null,
|
|
@@ -26499,116 +27039,6 @@ function generateTableRowProperties(node2) {
|
|
|
26499
27039
|
elements
|
|
26500
27040
|
};
|
|
26501
27041
|
}
|
|
26502
|
-
function translateTableCell(params2) {
|
|
26503
|
-
const elements = translateChildNodes({
|
|
26504
|
-
...params2,
|
|
26505
|
-
tableCell: params2.node
|
|
26506
|
-
});
|
|
26507
|
-
const cellProps = generateTableCellProperties(params2.node);
|
|
26508
|
-
elements.unshift(cellProps);
|
|
26509
|
-
return {
|
|
26510
|
-
name: "w:tc",
|
|
26511
|
-
elements
|
|
26512
|
-
};
|
|
26513
|
-
}
|
|
26514
|
-
function generateTableCellProperties(node2) {
|
|
26515
|
-
const elements = [];
|
|
26516
|
-
const { attrs } = node2;
|
|
26517
|
-
const { colwidth = [], cellWidthType = "dxa", background = {}, colspan, rowspan, widthUnit } = attrs;
|
|
26518
|
-
const colwidthSum = colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
26519
|
-
const cellWidthElement = {
|
|
26520
|
-
name: "w:tcW",
|
|
26521
|
-
attributes: {
|
|
26522
|
-
"w:w": widthUnit === "px" ? pixelsToTwips(colwidthSum) : inchesToTwips(colwidthSum),
|
|
26523
|
-
"w:type": cellWidthType
|
|
26524
|
-
}
|
|
26525
|
-
};
|
|
26526
|
-
elements.push(cellWidthElement);
|
|
26527
|
-
if (colspan) {
|
|
26528
|
-
const gridSpanElement = {
|
|
26529
|
-
name: "w:gridSpan",
|
|
26530
|
-
attributes: { "w:val": `${colspan}` }
|
|
26531
|
-
};
|
|
26532
|
-
elements.push(gridSpanElement);
|
|
26533
|
-
}
|
|
26534
|
-
const { color } = background || {};
|
|
26535
|
-
if (color) {
|
|
26536
|
-
const cellBgElement = {
|
|
26537
|
-
name: "w:shd",
|
|
26538
|
-
attributes: { "w:fill": color }
|
|
26539
|
-
};
|
|
26540
|
-
elements.push(cellBgElement);
|
|
26541
|
-
}
|
|
26542
|
-
const { cellMargins } = attrs;
|
|
26543
|
-
if (cellMargins) {
|
|
26544
|
-
const cellMarginsElement = {
|
|
26545
|
-
name: "w:tcMar",
|
|
26546
|
-
elements: generateCellMargins(cellMargins)
|
|
26547
|
-
};
|
|
26548
|
-
elements.push(cellMarginsElement);
|
|
26549
|
-
}
|
|
26550
|
-
const { verticalAlign } = attrs;
|
|
26551
|
-
if (verticalAlign) {
|
|
26552
|
-
const vertAlignElement = {
|
|
26553
|
-
name: "w:vAlign",
|
|
26554
|
-
attributes: { "w:val": verticalAlign }
|
|
26555
|
-
};
|
|
26556
|
-
elements.push(vertAlignElement);
|
|
26557
|
-
}
|
|
26558
|
-
if (rowspan && rowspan > 1) {
|
|
26559
|
-
const vMergeElement = {
|
|
26560
|
-
name: "w:vMerge",
|
|
26561
|
-
type: "element",
|
|
26562
|
-
attributes: { "w:val": "restart" }
|
|
26563
|
-
};
|
|
26564
|
-
elements.push(vMergeElement);
|
|
26565
|
-
} else if (attrs.continueMerge) {
|
|
26566
|
-
const vMergeElement = {
|
|
26567
|
-
name: "w:vMerge",
|
|
26568
|
-
type: "element"
|
|
26569
|
-
};
|
|
26570
|
-
elements.push(vMergeElement);
|
|
26571
|
-
}
|
|
26572
|
-
const { borders = {} } = attrs;
|
|
26573
|
-
if (!!borders && Object.keys(borders).length) {
|
|
26574
|
-
const cellBordersElement = {
|
|
26575
|
-
name: "w:tcBorders",
|
|
26576
|
-
elements: Object.entries(borders).map(([key, value]) => {
|
|
26577
|
-
if (!value.size || value.val === "none") {
|
|
26578
|
-
return {
|
|
26579
|
-
name: `w:${key}`,
|
|
26580
|
-
attributes: {
|
|
26581
|
-
"w:val": "nil"
|
|
26582
|
-
}
|
|
26583
|
-
};
|
|
26584
|
-
}
|
|
26585
|
-
return {
|
|
26586
|
-
name: `w:${key}`,
|
|
26587
|
-
attributes: {
|
|
26588
|
-
"w:val": "single",
|
|
26589
|
-
"w:color": value.color ? value.color.substring(1) : "auto",
|
|
26590
|
-
"w:sz": pixelsToEightPoints(value.size),
|
|
26591
|
-
"w:space": value.space || 0
|
|
26592
|
-
}
|
|
26593
|
-
};
|
|
26594
|
-
})
|
|
26595
|
-
};
|
|
26596
|
-
elements.push(cellBordersElement);
|
|
26597
|
-
}
|
|
26598
|
-
return {
|
|
26599
|
-
name: "w:tcPr",
|
|
26600
|
-
elements
|
|
26601
|
-
};
|
|
26602
|
-
}
|
|
26603
|
-
function generateCellMargins(cellMargins) {
|
|
26604
|
-
const elements = [];
|
|
26605
|
-
const { top: top2, right: right2, bottom: bottom2, left: left2 } = cellMargins;
|
|
26606
|
-
if (top2 != null) elements.push({ name: "w:top", attributes: { "w:w": pixelsToTwips(top2) } });
|
|
26607
|
-
if (right2 != null) elements.push({ name: "w:right", attributes: { "w:w": pixelsToTwips(right2) } });
|
|
26608
|
-
if (bottom2 != null) elements.push({ name: "w:bottom", attributes: { "w:w": pixelsToTwips(bottom2) } });
|
|
26609
|
-
if (left2 != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left2) } });
|
|
26610
|
-
return elements;
|
|
26611
|
-
}
|
|
26612
27042
|
function translateBookmarkStart(params2) {
|
|
26613
27043
|
const bookmarkStartNode = {
|
|
26614
27044
|
name: "w:bookmarkStart",
|
|
@@ -27557,345 +27987,6 @@ const parseXmlToJson = (xml) => {
|
|
|
27557
27987
|
const getInitialJSON = (parsedDocx, fallbackXml = defaultInitialXml) => {
|
|
27558
27988
|
return parsedDocx["word/document.xml"] || parseXmlToJson(fallbackXml);
|
|
27559
27989
|
};
|
|
27560
|
-
const handleAllTableNodes = (params2) => {
|
|
27561
|
-
const { nodes } = params2;
|
|
27562
|
-
if (nodes.length === 0) {
|
|
27563
|
-
return { nodes: [], consumed: 0 };
|
|
27564
|
-
}
|
|
27565
|
-
const node2 = nodes[0];
|
|
27566
|
-
switch (node2.name) {
|
|
27567
|
-
case "w:tbl":
|
|
27568
|
-
return { nodes: [handleTableNode(node2, params2)], consumed: 1 };
|
|
27569
|
-
}
|
|
27570
|
-
return { nodes: [], consumed: 0 };
|
|
27571
|
-
};
|
|
27572
|
-
const tableNodeHandlerEntity = {
|
|
27573
|
-
handlerName: "tableNodeHandler",
|
|
27574
|
-
handler: handleAllTableNodes
|
|
27575
|
-
};
|
|
27576
|
-
function handleTableNode(node2, params2) {
|
|
27577
|
-
const { docx, nodeListHandler: nodeListHandler2 } = params2;
|
|
27578
|
-
const tblPr = node2.elements.find((el) => el.name === "w:tblPr");
|
|
27579
|
-
const tableBordersElement = tblPr.elements.find((el) => el.name === "w:tblBorders");
|
|
27580
|
-
const tableBorders = tableBordersElement?.elements || [];
|
|
27581
|
-
const { borders, rowBorders } = processTableBorders(tableBorders);
|
|
27582
|
-
const tblStyleTag = tblPr.elements.find((el) => el.name === "w:tblStyle");
|
|
27583
|
-
const tableStyleId = tblStyleTag?.attributes["w:val"];
|
|
27584
|
-
const attrs = { tableStyleId };
|
|
27585
|
-
const tableIndent = tblPr?.elements.find((el) => el.name === "w:tblInd");
|
|
27586
|
-
if (tableIndent) {
|
|
27587
|
-
const { "w:w": width, "w:type": type2 } = tableIndent.attributes;
|
|
27588
|
-
attrs["tableIndent"] = { width: twipsToPixels(width), type: type2 };
|
|
27589
|
-
}
|
|
27590
|
-
const tableLayout = tblPr?.elements.find((el) => el.name === "w:tblLayout");
|
|
27591
|
-
if (tableLayout) {
|
|
27592
|
-
const { "w:type": type2 } = tableLayout.attributes;
|
|
27593
|
-
attrs["tableLayout"] = type2;
|
|
27594
|
-
}
|
|
27595
|
-
const referencedStyles = getReferencedTableStyles(tblStyleTag, docx);
|
|
27596
|
-
const tblW = tblPr.elements.find((el) => el.name === "w:tblW");
|
|
27597
|
-
if (tblW) {
|
|
27598
|
-
attrs["tableWidth"] = {
|
|
27599
|
-
width: twipsToPixels(tblW.attributes["w:w"]),
|
|
27600
|
-
type: tblW.attributes["w:type"]
|
|
27601
|
-
};
|
|
27602
|
-
}
|
|
27603
|
-
const tblCellSpacing = tblPr.elements.find((el) => el.name === "w:tblCellSpacing");
|
|
27604
|
-
if (tblCellSpacing) {
|
|
27605
|
-
attrs["tableCellSpacing"] = {
|
|
27606
|
-
w: tblCellSpacing.attributes["w:w"],
|
|
27607
|
-
type: tblCellSpacing.attributes["w:type"]
|
|
27608
|
-
};
|
|
27609
|
-
attrs["borderCollapse"] = "separate";
|
|
27610
|
-
}
|
|
27611
|
-
const tblJustification = tblPr.elements.find((el) => el.name === "w:jc");
|
|
27612
|
-
if (tblJustification?.attributes) {
|
|
27613
|
-
attrs["justification"] = tblJustification.attributes["w:val"];
|
|
27614
|
-
}
|
|
27615
|
-
const rows = node2.elements.filter((el) => el.name === "w:tr");
|
|
27616
|
-
const refStylesBorders = referencedStyles?.borders || {};
|
|
27617
|
-
const refStylesRowBorders = referencedStyles?.rowBorders || {};
|
|
27618
|
-
const borderData = Object.keys(borders)?.length ? Object.assign(refStylesBorders, borders) : refStylesBorders;
|
|
27619
|
-
const borderRowData = Object.keys(rowBorders)?.length ? Object.assign(refStylesRowBorders, rowBorders) : refStylesRowBorders;
|
|
27620
|
-
attrs["borders"] = borderData;
|
|
27621
|
-
const content = [];
|
|
27622
|
-
rows.forEach((row) => {
|
|
27623
|
-
const result = handleTableRowNode(row, node2, borderRowData, tblStyleTag, params2);
|
|
27624
|
-
if (result.content?.length) content.push(result);
|
|
27625
|
-
});
|
|
27626
|
-
return {
|
|
27627
|
-
type: "table",
|
|
27628
|
-
content,
|
|
27629
|
-
attrs
|
|
27630
|
-
};
|
|
27631
|
-
}
|
|
27632
|
-
function handleTableCellNode(node2, row, table, rowBorders, columnWidth = null, styleTag, params2, columnIndex) {
|
|
27633
|
-
const { docx, nodeListHandler: nodeListHandler2 } = params2;
|
|
27634
|
-
const tcPr = node2.elements.find((el) => el.name === "w:tcPr");
|
|
27635
|
-
const borders = tcPr?.elements?.find((el) => el.name === "w:tcBorders");
|
|
27636
|
-
const inlineBorders = processInlineCellBorders(borders, rowBorders);
|
|
27637
|
-
const gridColumnWidths = getGridColumnWidths(table);
|
|
27638
|
-
const tcWidth = tcPr?.elements?.find((el) => el.name === "w:tcW");
|
|
27639
|
-
let width = tcWidth ? twipsToPixels(tcWidth.attributes["w:w"]) : null;
|
|
27640
|
-
const widthType = tcWidth?.attributes["w:type"];
|
|
27641
|
-
if (!width && columnWidth) width = columnWidth;
|
|
27642
|
-
const vMerge = getTableCellMergeTag(node2);
|
|
27643
|
-
const { attributes: vMergeAttrs } = vMerge || {};
|
|
27644
|
-
const backgroundColor = tcPr?.elements?.find((el) => el.name === "w:shd");
|
|
27645
|
-
const background = {
|
|
27646
|
-
color: backgroundColor?.attributes["w:fill"]
|
|
27647
|
-
};
|
|
27648
|
-
const colspanTag = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
27649
|
-
const colspan = colspanTag?.attributes["w:val"];
|
|
27650
|
-
const marginTag = tcPr?.elements?.find((el) => el.name === "w:tcMar");
|
|
27651
|
-
const verticalAlignTag = tcPr?.elements?.find((el) => el.name === "w:vAlign");
|
|
27652
|
-
const verticalAlign = verticalAlignTag?.attributes["w:val"] || "top";
|
|
27653
|
-
const attributes = {};
|
|
27654
|
-
const referencedStyles = getReferencedTableStyles(styleTag, docx) || {};
|
|
27655
|
-
attributes.cellMargins = getTableCellMargins(marginTag, referencedStyles);
|
|
27656
|
-
const { fontSize: fontSize2, fonts = {} } = referencedStyles;
|
|
27657
|
-
const fontFamily2 = fonts["ascii"];
|
|
27658
|
-
if (width) {
|
|
27659
|
-
attributes["colwidth"] = [width];
|
|
27660
|
-
attributes["widthUnit"] = "px";
|
|
27661
|
-
const defaultColWidths = gridColumnWidths;
|
|
27662
|
-
const hasDefaultColWidths = gridColumnWidths && gridColumnWidths.length > 0;
|
|
27663
|
-
const colspanNum = parseInt(colspan || 1, 10);
|
|
27664
|
-
if (colspanNum && colspanNum > 1 && hasDefaultColWidths) {
|
|
27665
|
-
let colwidth = [];
|
|
27666
|
-
for (let i = 0; i < colspanNum; i++) {
|
|
27667
|
-
let colwidthValue = defaultColWidths[columnIndex + i];
|
|
27668
|
-
let defaultColwidth = 100;
|
|
27669
|
-
if (typeof colwidthValue !== "undefined") {
|
|
27670
|
-
colwidth.push(colwidthValue);
|
|
27671
|
-
} else {
|
|
27672
|
-
colwidth.push(defaultColwidth);
|
|
27673
|
-
}
|
|
27674
|
-
}
|
|
27675
|
-
if (colwidth.length) {
|
|
27676
|
-
attributes["colwidth"] = [...colwidth];
|
|
27677
|
-
}
|
|
27678
|
-
}
|
|
27679
|
-
}
|
|
27680
|
-
if (widthType) attributes["widthType"] = widthType;
|
|
27681
|
-
if (colspan) attributes["colspan"] = parseInt(colspan, 10);
|
|
27682
|
-
if (background) attributes["background"] = background;
|
|
27683
|
-
attributes["verticalAlign"] = verticalAlign;
|
|
27684
|
-
if (fontSize2) attributes["fontSize"] = fontSize2;
|
|
27685
|
-
if (fontFamily2) attributes["fontFamily"] = fontFamily2["ascii"];
|
|
27686
|
-
if (rowBorders) attributes["borders"] = { ...rowBorders };
|
|
27687
|
-
if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"] || {}, inlineBorders);
|
|
27688
|
-
if (vMergeAttrs && vMergeAttrs["w:val"] === "restart") {
|
|
27689
|
-
const rows = table.elements.filter((el) => el.name === "w:tr");
|
|
27690
|
-
const currentRowIndex = rows.findIndex((r2) => r2 === row);
|
|
27691
|
-
const remainingRows = rows.slice(currentRowIndex + 1);
|
|
27692
|
-
const cellsInRow = row.elements.filter((el) => el.name === "w:tc");
|
|
27693
|
-
let cellIndex = cellsInRow.findIndex((el) => el === node2);
|
|
27694
|
-
let rowspan = 1;
|
|
27695
|
-
for (let remainingRow of remainingRows) {
|
|
27696
|
-
const firstCell = remainingRow.elements.findIndex((el) => el.name === "w:tc");
|
|
27697
|
-
const cellAtIndex = remainingRow.elements[firstCell + cellIndex];
|
|
27698
|
-
if (!cellAtIndex) break;
|
|
27699
|
-
const vMerge2 = getTableCellMergeTag(cellAtIndex);
|
|
27700
|
-
const { attributes: currentCellMergeAttrs } = vMerge2 || {};
|
|
27701
|
-
if (!vMerge2 && !currentCellMergeAttrs || currentCellMergeAttrs && currentCellMergeAttrs["w:val"] === "restart") {
|
|
27702
|
-
break;
|
|
27703
|
-
}
|
|
27704
|
-
rowspan++;
|
|
27705
|
-
remainingRow.elements.splice(firstCell + cellIndex, 1);
|
|
27706
|
-
}
|
|
27707
|
-
attributes["rowspan"] = rowspan;
|
|
27708
|
-
}
|
|
27709
|
-
return {
|
|
27710
|
-
type: "tableCell",
|
|
27711
|
-
content: nodeListHandler2.handler({ ...params2, nodes: node2.elements }),
|
|
27712
|
-
attrs: attributes
|
|
27713
|
-
};
|
|
27714
|
-
}
|
|
27715
|
-
const getTableCellMergeTag = (node2) => {
|
|
27716
|
-
const tcPr = node2.elements.find((el) => el.name === "w:tcPr");
|
|
27717
|
-
const vMerge = tcPr?.elements?.find((el) => el.name === "w:vMerge");
|
|
27718
|
-
return vMerge;
|
|
27719
|
-
};
|
|
27720
|
-
const processBorder = (borders, direction, rowBorders = {}) => {
|
|
27721
|
-
const borderAttrs = borders?.elements?.find((el) => el.name === `w:${direction}`)?.attributes;
|
|
27722
|
-
if (borderAttrs && borderAttrs["w:val"] !== "nil") {
|
|
27723
|
-
const border = {};
|
|
27724
|
-
const color = borderAttrs["w:color"];
|
|
27725
|
-
if (color) border["color"] = color === "auto" ? "#000000" : `#${color}`;
|
|
27726
|
-
const size2 = borderAttrs["w:sz"];
|
|
27727
|
-
if (size2) border["size"] = eigthPointsToPixels(size2);
|
|
27728
|
-
return border;
|
|
27729
|
-
}
|
|
27730
|
-
if (borderAttrs && borderAttrs["w:val"] === "nil") {
|
|
27731
|
-
const border = Object.assign({}, rowBorders[direction] || {});
|
|
27732
|
-
if (!Object.keys(border)) return null;
|
|
27733
|
-
border["val"] = "none";
|
|
27734
|
-
return border;
|
|
27735
|
-
}
|
|
27736
|
-
return null;
|
|
27737
|
-
};
|
|
27738
|
-
const processInlineCellBorders = (borders, rowBorders) => {
|
|
27739
|
-
if (!borders) return null;
|
|
27740
|
-
const processedBorders = {};
|
|
27741
|
-
const inlineBorderBottom = processBorder(borders, "bottom", rowBorders);
|
|
27742
|
-
if (inlineBorderBottom) processedBorders["bottom"] = inlineBorderBottom;
|
|
27743
|
-
const inlineBorderTop = processBorder(borders, "top", rowBorders);
|
|
27744
|
-
if (inlineBorderTop) processedBorders["top"] = inlineBorderTop;
|
|
27745
|
-
const inlineBorderLeft = processBorder(borders, "left", rowBorders);
|
|
27746
|
-
if (inlineBorderLeft) processedBorders["left"] = inlineBorderLeft;
|
|
27747
|
-
const inlineBorderRight = processBorder(borders, "right", rowBorders);
|
|
27748
|
-
if (inlineBorderRight) processedBorders["right"] = inlineBorderRight;
|
|
27749
|
-
return processedBorders;
|
|
27750
|
-
};
|
|
27751
|
-
function getReferencedTableStyles(tblStyleTag, docx) {
|
|
27752
|
-
if (!tblStyleTag) return null;
|
|
27753
|
-
const stylesToReturn = {};
|
|
27754
|
-
const { attributes = {} } = tblStyleTag;
|
|
27755
|
-
const tableStyleReference = attributes["w:val"];
|
|
27756
|
-
if (!tableStyleReference) return null;
|
|
27757
|
-
const styles = docx["word/styles.xml"];
|
|
27758
|
-
const { elements } = styles.elements[0];
|
|
27759
|
-
const styleElements = elements.filter((el) => el.name === "w:style");
|
|
27760
|
-
const styleTag = styleElements.find((el) => el.attributes["w:styleId"] === tableStyleReference);
|
|
27761
|
-
if (!styleTag) return null;
|
|
27762
|
-
stylesToReturn.name = styleTag.elements.find((el) => el.name === "w:name");
|
|
27763
|
-
const basedOn = styleTag.elements.find((el) => el.name === "w:basedOn");
|
|
27764
|
-
let baseTblPr;
|
|
27765
|
-
if (basedOn?.attributes) {
|
|
27766
|
-
const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
|
|
27767
|
-
baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
|
|
27768
|
-
}
|
|
27769
|
-
const pPr = styleTag.elements.find((el) => el.name === "w:pPr");
|
|
27770
|
-
if (pPr) {
|
|
27771
|
-
const justification = pPr.elements.find((el) => el.name === "w:jc");
|
|
27772
|
-
if (justification?.attributes) stylesToReturn.justification = justification.attributes["w:val"];
|
|
27773
|
-
}
|
|
27774
|
-
const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
|
|
27775
|
-
if (rPr) {
|
|
27776
|
-
const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
|
|
27777
|
-
if (fonts) {
|
|
27778
|
-
const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
|
|
27779
|
-
stylesToReturn.fonts = { ascii, hAnsi, cs };
|
|
27780
|
-
}
|
|
27781
|
-
const fontSize2 = rPr.elements.find((el) => el.name === "w:sz");
|
|
27782
|
-
if (fontSize2?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize2.attributes["w:val"]) + "pt";
|
|
27783
|
-
}
|
|
27784
|
-
const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
|
|
27785
|
-
if (tblPr && tblPr.elements) {
|
|
27786
|
-
if (baseTblPr && baseTblPr.elements) {
|
|
27787
|
-
tblPr.elements.push(...baseTblPr.elements);
|
|
27788
|
-
}
|
|
27789
|
-
const tableBorders = tblPr?.elements?.find((el) => el.name === "w:tblBorders");
|
|
27790
|
-
const { elements: borderElements = [] } = tableBorders || {};
|
|
27791
|
-
const { borders, rowBorders } = processTableBorders(borderElements);
|
|
27792
|
-
if (borders) stylesToReturn.borders = borders;
|
|
27793
|
-
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
27794
|
-
const tableCellMargin = tblPr?.elements.find((el) => el.name === "w:tblCellMar");
|
|
27795
|
-
if (tableCellMargin) {
|
|
27796
|
-
const marginLeft = tableCellMargin.elements.find((el) => el.name === "w:left");
|
|
27797
|
-
const marginRight = tableCellMargin.elements.find((el) => el.name === "w:right");
|
|
27798
|
-
const marginTop = tableCellMargin.elements.find((el) => el.name === "w:top");
|
|
27799
|
-
const marginBottom = tableCellMargin.elements.find((el) => el.name === "w:bottom");
|
|
27800
|
-
stylesToReturn.cellMargins = {
|
|
27801
|
-
marginLeft: marginLeft?.attributes["w:w"],
|
|
27802
|
-
marginRight: marginRight?.attributes["w:w"],
|
|
27803
|
-
marginTop: marginTop?.attributes["w:w"],
|
|
27804
|
-
marginBottom: marginBottom?.attributes["w:w"]
|
|
27805
|
-
};
|
|
27806
|
-
}
|
|
27807
|
-
}
|
|
27808
|
-
return stylesToReturn;
|
|
27809
|
-
}
|
|
27810
|
-
function processTableBorders(borderElements) {
|
|
27811
|
-
const borders = {};
|
|
27812
|
-
const rowBorders = {};
|
|
27813
|
-
borderElements.forEach((borderElement) => {
|
|
27814
|
-
const { name } = borderElement;
|
|
27815
|
-
const borderName = name.split("w:")[1];
|
|
27816
|
-
const { attributes } = borderElement;
|
|
27817
|
-
const attrs = {};
|
|
27818
|
-
const color = attributes["w:color"];
|
|
27819
|
-
const size2 = attributes["w:sz"];
|
|
27820
|
-
if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
|
|
27821
|
-
if (size2 && size2 !== "auto") attrs["size"] = eigthPointsToPixels(size2);
|
|
27822
|
-
const rowBorderNames = ["insideH", "insideV"];
|
|
27823
|
-
if (rowBorderNames.includes(borderName)) rowBorders[borderName] = attrs;
|
|
27824
|
-
borders[borderName] = attrs;
|
|
27825
|
-
});
|
|
27826
|
-
return {
|
|
27827
|
-
borders,
|
|
27828
|
-
rowBorders
|
|
27829
|
-
};
|
|
27830
|
-
}
|
|
27831
|
-
function handleTableRowNode(node2, table, rowBorders, styleTag, params2) {
|
|
27832
|
-
const attrs = {};
|
|
27833
|
-
const tPr = node2.elements.find((el) => el.name === "w:trPr");
|
|
27834
|
-
const rowHeightTag = tPr?.elements?.find((el) => el.name === "w:trHeight");
|
|
27835
|
-
const rowHeight = rowHeightTag?.attributes["w:val"];
|
|
27836
|
-
const cantSplitTag = tPr?.elements?.find((el) => el.name === "w:cantSplit");
|
|
27837
|
-
if (cantSplitTag) {
|
|
27838
|
-
attrs["cantSplit"] = true;
|
|
27839
|
-
}
|
|
27840
|
-
const borders = {};
|
|
27841
|
-
if (rowBorders?.insideH) borders["bottom"] = rowBorders.insideH;
|
|
27842
|
-
if (rowBorders?.insideV) borders["right"] = rowBorders.insideV;
|
|
27843
|
-
attrs["borders"] = borders;
|
|
27844
|
-
if (rowHeight) {
|
|
27845
|
-
attrs["rowHeight"] = twipsToPixels(rowHeight);
|
|
27846
|
-
}
|
|
27847
|
-
const gridColumnWidths = getGridColumnWidths(table);
|
|
27848
|
-
const cellNodes = node2.elements.filter((el) => el.name === "w:tc");
|
|
27849
|
-
let currentColumnIndex = 0;
|
|
27850
|
-
const content = cellNodes?.map((n) => {
|
|
27851
|
-
let colWidth = gridColumnWidths?.[currentColumnIndex] || null;
|
|
27852
|
-
const result = handleTableCellNode(n, node2, table, borders, colWidth, styleTag, params2, currentColumnIndex);
|
|
27853
|
-
const tcPr = n.elements?.find((el) => el.name === "w:tcPr");
|
|
27854
|
-
const colspanTag = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
27855
|
-
const colspan = parseInt(colspanTag?.attributes["w:val"] || 1, 10);
|
|
27856
|
-
currentColumnIndex += colspan;
|
|
27857
|
-
return result;
|
|
27858
|
-
}) || [];
|
|
27859
|
-
const newNode = {
|
|
27860
|
-
type: "tableRow",
|
|
27861
|
-
content,
|
|
27862
|
-
attrs
|
|
27863
|
-
};
|
|
27864
|
-
return newNode;
|
|
27865
|
-
}
|
|
27866
|
-
const getTableCellMargins = (marginTag, referencedStyles) => {
|
|
27867
|
-
const inlineMarginLeftTag = marginTag?.elements?.find((el) => el.name === "w:left");
|
|
27868
|
-
const inlineMarginRightTag = marginTag?.elements?.find((el) => el.name === "w:right");
|
|
27869
|
-
const inlineMarginTopTag = marginTag?.elements?.find((el) => el.name === "w:top");
|
|
27870
|
-
const inlineMarginBottomTag = marginTag?.elements?.find((el) => el.name === "w:bottom");
|
|
27871
|
-
const inlineMarginLeftValue = inlineMarginLeftTag?.attributes["w:w"];
|
|
27872
|
-
const inlineMarginRightValue = inlineMarginRightTag?.attributes["w:w"];
|
|
27873
|
-
const inlineMarginTopValue = inlineMarginTopTag?.attributes["w:w"];
|
|
27874
|
-
const inlineMarginBottomValue = inlineMarginBottomTag?.attributes["w:w"];
|
|
27875
|
-
const { cellMargins = {} } = referencedStyles;
|
|
27876
|
-
const {
|
|
27877
|
-
marginLeft: marginLeftStyle,
|
|
27878
|
-
marginRight: marginRightStyle,
|
|
27879
|
-
marginTop: marginTopStyle,
|
|
27880
|
-
marginBottom: marginBottomStyle
|
|
27881
|
-
} = cellMargins;
|
|
27882
|
-
const margins = {
|
|
27883
|
-
left: twipsToPixels(inlineMarginLeftValue ?? marginLeftStyle),
|
|
27884
|
-
right: twipsToPixels(inlineMarginRightValue ?? marginRightStyle),
|
|
27885
|
-
top: twipsToPixels(inlineMarginTopValue ?? marginTopStyle),
|
|
27886
|
-
bottom: twipsToPixels(inlineMarginBottomValue ?? marginBottomStyle)
|
|
27887
|
-
};
|
|
27888
|
-
return margins;
|
|
27889
|
-
};
|
|
27890
|
-
const getGridColumnWidths = (tableNode) => {
|
|
27891
|
-
const tblGrid = tableNode.elements.find((el) => el.name === "w:tblGrid");
|
|
27892
|
-
if (!tblGrid) return [];
|
|
27893
|
-
const columnWidths = tblGrid?.elements?.flatMap((el) => {
|
|
27894
|
-
if (el.name !== "w:gridCol") return [];
|
|
27895
|
-
return twipsToPixels(el.attributes["w:w"]);
|
|
27896
|
-
}) || [];
|
|
27897
|
-
return columnWidths;
|
|
27898
|
-
};
|
|
27899
27990
|
const handleDrawingNode = (params2) => {
|
|
27900
27991
|
const { nodes, filename } = params2;
|
|
27901
27992
|
const validNodes = ["w:drawing", "w:p"];
|
|
@@ -28037,7 +28128,8 @@ const handleShapeDrawing = (params2, node2, graphicData) => {
|
|
|
28037
28128
|
const translatedElement = nodeListHandler2.handler({
|
|
28038
28129
|
...params2,
|
|
28039
28130
|
node: textBoxContent.elements[0],
|
|
28040
|
-
nodes: textBoxContent.elements
|
|
28131
|
+
nodes: textBoxContent.elements,
|
|
28132
|
+
path: [...params2.path || [], textBoxContent]
|
|
28041
28133
|
});
|
|
28042
28134
|
return translatedElement[0];
|
|
28043
28135
|
};
|
|
@@ -28300,7 +28392,12 @@ const handleTrackChangeNode = (params2) => {
|
|
|
28300
28392
|
}
|
|
28301
28393
|
const { name } = node2;
|
|
28302
28394
|
const { attributes, elements } = parseProperties(node2);
|
|
28303
|
-
const subs = nodeListHandler2.handler({
|
|
28395
|
+
const subs = nodeListHandler2.handler({
|
|
28396
|
+
...params2,
|
|
28397
|
+
insideTrackChange: true,
|
|
28398
|
+
nodes: elements,
|
|
28399
|
+
path: [...params2.path || [], node2]
|
|
28400
|
+
});
|
|
28304
28401
|
const changeType = name === "w:del" ? TrackDeleteMarkName : TrackInsertMarkName;
|
|
28305
28402
|
const mappedAttributes = {
|
|
28306
28403
|
id: attributes["w:id"],
|
|
@@ -28359,7 +28456,11 @@ const handleHyperlinkNode = (params2) => {
|
|
|
28359
28456
|
}
|
|
28360
28457
|
}
|
|
28361
28458
|
}
|
|
28362
|
-
const updatedNode = nodeListHandler2.handler({
|
|
28459
|
+
const updatedNode = nodeListHandler2.handler({
|
|
28460
|
+
...params2,
|
|
28461
|
+
nodes: runNodes,
|
|
28462
|
+
path: [...params2.path || [], node2]
|
|
28463
|
+
});
|
|
28363
28464
|
return { nodes: updatedNode, consumed: 1 };
|
|
28364
28465
|
};
|
|
28365
28466
|
const hyperlinkNodeHandlerEntity = {
|
|
@@ -28372,7 +28473,7 @@ const handleRunNode = (params2) => {
|
|
|
28372
28473
|
return { nodes: [], consumed: 0 };
|
|
28373
28474
|
}
|
|
28374
28475
|
const node2 = nodes[0];
|
|
28375
|
-
const childParams = { ...params2, nodes: node2.elements };
|
|
28476
|
+
const childParams = { ...params2, nodes: node2.elements, path: [...params2.path || [], node2] };
|
|
28376
28477
|
let processedRun = nodeListHandler2.handler(childParams)?.filter((n) => n) || [];
|
|
28377
28478
|
const hasRunProperties = node2.elements?.some((el) => el.name === "w:rPr");
|
|
28378
28479
|
const defaultNodeStyles = getMarksFromStyles(docx, parentStyleId);
|
|
@@ -29209,7 +29310,11 @@ const handleSdtNode = (params2) => {
|
|
|
29209
29310
|
const sdtContent = node2.elements.find((el) => el.name === "w:sdtContent");
|
|
29210
29311
|
const par = sdtContent?.elements?.find((el) => el.name === "w:p");
|
|
29211
29312
|
const { marks } = parseAnnotationMarks(sdtContent);
|
|
29212
|
-
const translatedContent = nodeListHandler2.handler({
|
|
29313
|
+
const translatedContent = nodeListHandler2.handler({
|
|
29314
|
+
...params2,
|
|
29315
|
+
nodes: sdtContent?.elements,
|
|
29316
|
+
path: [...params2.path || [], node2]
|
|
29317
|
+
});
|
|
29213
29318
|
let structuredContentType = "structuredContent";
|
|
29214
29319
|
if (par) {
|
|
29215
29320
|
structuredContentType = "structuredContentBlock";
|
|
@@ -29237,7 +29342,11 @@ const handleDocumentSectionNode = (params2, tagValue) => {
|
|
|
29237
29342
|
const title = titleTag?.attributes?.["w:val"] || tagValue.title || null;
|
|
29238
29343
|
const { description } = tagValue;
|
|
29239
29344
|
const sdtContent = node2.elements.find((el) => el.name === "w:sdtContent");
|
|
29240
|
-
const translatedContent = nodeListHandler2.handler({
|
|
29345
|
+
const translatedContent = nodeListHandler2.handler({
|
|
29346
|
+
...params2,
|
|
29347
|
+
nodes: sdtContent?.elements,
|
|
29348
|
+
path: [...params2.path || [], node2]
|
|
29349
|
+
});
|
|
29241
29350
|
const result = {
|
|
29242
29351
|
type: "documentSection",
|
|
29243
29352
|
content: translatedContent,
|
|
@@ -29301,7 +29410,12 @@ const handleStandardNode = (params2) => {
|
|
|
29301
29410
|
el.marks.push(...marks);
|
|
29302
29411
|
return el;
|
|
29303
29412
|
});
|
|
29304
|
-
const childParams = {
|
|
29413
|
+
const childParams = {
|
|
29414
|
+
...params2,
|
|
29415
|
+
nodes: updatedElements,
|
|
29416
|
+
parentStyleId,
|
|
29417
|
+
path: [...params2.path || [], node2]
|
|
29418
|
+
};
|
|
29305
29419
|
const childContent = nodeListHandler2.handler(childParams);
|
|
29306
29420
|
content.push(...childContent);
|
|
29307
29421
|
}
|
|
@@ -29327,7 +29441,7 @@ const handler = (params2) => {
|
|
|
29327
29441
|
if (nodes.length === 0 || nodes[0].name !== "w:br") {
|
|
29328
29442
|
return { nodes: [], consumed: 0 };
|
|
29329
29443
|
}
|
|
29330
|
-
const result = translator$
|
|
29444
|
+
const result = translator$2.encode(params2);
|
|
29331
29445
|
if (!result) return { nodes: [], consumed: 0 };
|
|
29332
29446
|
return {
|
|
29333
29447
|
nodes: [result],
|
|
@@ -29367,7 +29481,11 @@ const handleBookmarkNode = (params2) => {
|
|
|
29367
29481
|
attrs[key] = value;
|
|
29368
29482
|
}
|
|
29369
29483
|
});
|
|
29370
|
-
const translatedText = nodeListHandler3.handler({
|
|
29484
|
+
const translatedText = nodeListHandler3.handler({
|
|
29485
|
+
...params2,
|
|
29486
|
+
nodes: textNodes,
|
|
29487
|
+
path: [...params2.path || [], node2]
|
|
29488
|
+
});
|
|
29371
29489
|
translatedText.forEach((n) => {
|
|
29372
29490
|
n.marks.push({
|
|
29373
29491
|
type: customMark.name,
|
|
@@ -29415,7 +29533,8 @@ const handleAlternateChoice = (params2) => {
|
|
|
29415
29533
|
const contents = wpsNode.elements;
|
|
29416
29534
|
const result = nodeListHandler2.handler({
|
|
29417
29535
|
...params2,
|
|
29418
|
-
nodes: contents
|
|
29536
|
+
nodes: contents,
|
|
29537
|
+
path: [...params2.path || [], wpsNode]
|
|
29419
29538
|
});
|
|
29420
29539
|
return { nodes: result, consumed: 1 };
|
|
29421
29540
|
};
|
|
@@ -29709,7 +29828,8 @@ function importCommentData({ docx, editor, converter }) {
|
|
|
29709
29828
|
nodeListHandler: nodeListHandler2,
|
|
29710
29829
|
docx,
|
|
29711
29830
|
editor,
|
|
29712
|
-
converter
|
|
29831
|
+
converter,
|
|
29832
|
+
path: [el]
|
|
29713
29833
|
});
|
|
29714
29834
|
const { attrs } = parsedComment[0];
|
|
29715
29835
|
const paraId = attrs["w14:paraId"];
|
|
@@ -29765,7 +29885,7 @@ const handleTabNode = (params2) => {
|
|
|
29765
29885
|
if (!nodes.length || nodes[0].name !== "w:tab") {
|
|
29766
29886
|
return { nodes: [], consumed: 0 };
|
|
29767
29887
|
}
|
|
29768
|
-
const node2 = translator.encode(params2);
|
|
29888
|
+
const node2 = translator$1.encode(params2);
|
|
29769
29889
|
return { nodes: [node2], consumed: 1 };
|
|
29770
29890
|
};
|
|
29771
29891
|
const tabNodeEntityHandler = {
|
|
@@ -29810,7 +29930,8 @@ const createDocumentJson = (docx, converter, editor) => {
|
|
|
29810
29930
|
docx,
|
|
29811
29931
|
converter,
|
|
29812
29932
|
editor,
|
|
29813
|
-
lists
|
|
29933
|
+
lists,
|
|
29934
|
+
path: []
|
|
29814
29935
|
});
|
|
29815
29936
|
const result = {
|
|
29816
29937
|
type: "doc",
|
|
@@ -29890,7 +30011,8 @@ const createNodeListHandler = (nodeHandlers) => {
|
|
|
29890
30011
|
editor,
|
|
29891
30012
|
filename,
|
|
29892
30013
|
parentStyleId,
|
|
29893
|
-
lists
|
|
30014
|
+
lists,
|
|
30015
|
+
path = []
|
|
29894
30016
|
}) => {
|
|
29895
30017
|
if (!elements || !elements.length) return [];
|
|
29896
30018
|
const filteredElements = pruneIgnoredNodes(elements);
|
|
@@ -29915,7 +30037,8 @@ const createNodeListHandler = (nodeHandlers) => {
|
|
|
29915
30037
|
editor,
|
|
29916
30038
|
filename,
|
|
29917
30039
|
parentStyleId,
|
|
29918
|
-
lists
|
|
30040
|
+
lists,
|
|
30041
|
+
path
|
|
29919
30042
|
});
|
|
29920
30043
|
},
|
|
29921
30044
|
{ nodes: [], consumed: 0 }
|
|
@@ -30092,7 +30215,8 @@ const importHeadersFooters = (docx, converter, mainEditor) => {
|
|
|
30092
30215
|
docx,
|
|
30093
30216
|
converter,
|
|
30094
30217
|
editor,
|
|
30095
|
-
filename: currentFileName
|
|
30218
|
+
filename: currentFileName,
|
|
30219
|
+
path: []
|
|
30096
30220
|
});
|
|
30097
30221
|
if (!converter.headerIds.ids) converter.headerIds.ids = [];
|
|
30098
30222
|
converter.headerIds.ids.push(rId);
|
|
@@ -30114,7 +30238,8 @@ const importHeadersFooters = (docx, converter, mainEditor) => {
|
|
|
30114
30238
|
docx,
|
|
30115
30239
|
converter,
|
|
30116
30240
|
editor,
|
|
30117
|
-
filename: currentFileName
|
|
30241
|
+
filename: currentFileName,
|
|
30242
|
+
path: []
|
|
30118
30243
|
});
|
|
30119
30244
|
if (!converter.footerIds.ids) converter.footerIds.ids = [];
|
|
30120
30245
|
converter.footerIds.ids.push(rId);
|
|
@@ -30369,7 +30494,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
30369
30494
|
return;
|
|
30370
30495
|
}
|
|
30371
30496
|
}
|
|
30372
|
-
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.17.
|
|
30497
|
+
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.17.1") {
|
|
30373
30498
|
const customLocation = "docProps/custom.xml";
|
|
30374
30499
|
if (!docx[customLocation]) {
|
|
30375
30500
|
docx[customLocation] = generateCustomXml();
|
|
@@ -30851,7 +30976,7 @@ function storeSuperdocVersion(docx) {
|
|
|
30851
30976
|
function generateCustomXml() {
|
|
30852
30977
|
return DEFAULT_CUSTOM_XML;
|
|
30853
30978
|
}
|
|
30854
|
-
function generateSuperdocVersion(pid = 2, version2 = "0.17.
|
|
30979
|
+
function generateSuperdocVersion(pid = 2, version2 = "0.17.1") {
|
|
30855
30980
|
return {
|
|
30856
30981
|
type: "element",
|
|
30857
30982
|
name: "property",
|
|
@@ -47711,7 +47836,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
47711
47836
|
* @returns {Object | void} Migration results
|
|
47712
47837
|
*/
|
|
47713
47838
|
processCollaborationMigrations() {
|
|
47714
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.17.
|
|
47839
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.17.1");
|
|
47715
47840
|
if (!this.options.ydoc) return;
|
|
47716
47841
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
47717
47842
|
let docVersion = metaMap.get("version");
|
|
@@ -80593,8 +80718,8 @@ const _sfc_main = {
|
|
|
80593
80718
|
};
|
|
80594
80719
|
const SuperInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4d5cff52"]]);
|
|
80595
80720
|
const registeredHandlers = Object.freeze({
|
|
80596
|
-
"w:br": translator$
|
|
80597
|
-
"w:tab": translator
|
|
80721
|
+
"w:br": translator$2,
|
|
80722
|
+
"w:tab": translator$1
|
|
80598
80723
|
});
|
|
80599
80724
|
const Extensions = {
|
|
80600
80725
|
Node: Node$1,
|