@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
package/dist/superdoc.umd.js
CHANGED
|
@@ -27402,7 +27402,11 @@
|
|
|
27402
27402
|
}
|
|
27403
27403
|
const styleIdIndex = pPr?.elements?.findIndex((el) => el.name === "w:pStyle");
|
|
27404
27404
|
if (styleIdIndex >= 0) pPr?.elements?.splice(styleIdIndex, 1);
|
|
27405
|
-
const fallBack = nodeListHandler2.handler({
|
|
27405
|
+
const fallBack = nodeListHandler2.handler({
|
|
27406
|
+
...params2,
|
|
27407
|
+
nodes: [node2],
|
|
27408
|
+
path: [...params2.path || [], node2]
|
|
27409
|
+
})?.filter((n) => n);
|
|
27406
27410
|
return fallBack[0];
|
|
27407
27411
|
}
|
|
27408
27412
|
if (!lists[currentListNumId]) lists[currentListNumId] = { levels: {} };
|
|
@@ -27430,7 +27434,11 @@
|
|
|
27430
27434
|
const nodePpr = node2.attrs?.paragraphProperties?.elements?.find((el) => el.name === "w:pPr");
|
|
27431
27435
|
const numPrIndex = node2.attrs?.paragraphProperties?.elements?.findIndex((el) => el.name === "w:numPr");
|
|
27432
27436
|
nodePpr?.elements?.splice(numPrIndex, 1);
|
|
27433
|
-
const listContents = nodeListHandler2.handler({
|
|
27437
|
+
const listContents = nodeListHandler2.handler({
|
|
27438
|
+
...params2,
|
|
27439
|
+
nodes: [node2],
|
|
27440
|
+
path: [...params2.path || [], node2]
|
|
27441
|
+
});
|
|
27434
27442
|
const innerParagraph = listContents.find((el) => el.type === "paragraph");
|
|
27435
27443
|
const firstElement = innerParagraph.content[0];
|
|
27436
27444
|
firstElement?.marks?.find((mark) => mark.type === "textStyle");
|
|
@@ -33275,13 +33283,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33275
33283
|
const { clear } = attrs;
|
|
33276
33284
|
return clear;
|
|
33277
33285
|
};
|
|
33278
|
-
const XML_NODE_NAME$
|
|
33279
|
-
const SD_NODE_NAME$
|
|
33280
|
-
const validXmlAttributes$
|
|
33286
|
+
const XML_NODE_NAME$2 = "w:br";
|
|
33287
|
+
const SD_NODE_NAME$2 = "lineBreak";
|
|
33288
|
+
const validXmlAttributes$2 = [
|
|
33281
33289
|
{ xmlName: "w:type", sdName: "lineBreakType", encode: lineBreakTypeEncoder, decode: lineBreakTypeDecoder },
|
|
33282
33290
|
{ xmlName: "w:clear", sdName: "clear", encode: wClearEncoder, decode: wClearDecoder }
|
|
33283
33291
|
];
|
|
33284
|
-
const encode$
|
|
33292
|
+
const encode$2 = (_2, encodedAttrs) => {
|
|
33285
33293
|
const isPageBreak = encodedAttrs?.lineBreakType === "page";
|
|
33286
33294
|
const translated = {
|
|
33287
33295
|
type: isPageBreak ? "hardBreak" : "lineBreak"
|
|
@@ -33291,7 +33299,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33291
33299
|
}
|
|
33292
33300
|
return translated;
|
|
33293
33301
|
};
|
|
33294
|
-
const decode$
|
|
33302
|
+
const decode$2 = (params2, decodedAttrs) => {
|
|
33295
33303
|
const { node: node2 } = params2;
|
|
33296
33304
|
if (!node2) return;
|
|
33297
33305
|
const wBreak = { name: "w:br" };
|
|
@@ -33308,15 +33316,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33308
33316
|
};
|
|
33309
33317
|
return translated;
|
|
33310
33318
|
};
|
|
33311
|
-
const config$
|
|
33312
|
-
xmlName: XML_NODE_NAME$
|
|
33313
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
33319
|
+
const config$2 = {
|
|
33320
|
+
xmlName: XML_NODE_NAME$2,
|
|
33321
|
+
sdNodeOrKeyName: SD_NODE_NAME$2,
|
|
33314
33322
|
type: NodeTranslator.translatorTypes.NODE,
|
|
33315
|
-
encode: encode$
|
|
33316
|
-
decode: decode$
|
|
33317
|
-
attributes: validXmlAttributes$
|
|
33323
|
+
encode: encode$2,
|
|
33324
|
+
decode: decode$2,
|
|
33325
|
+
attributes: validXmlAttributes$2
|
|
33318
33326
|
};
|
|
33319
|
-
const translator$
|
|
33327
|
+
const translator$2 = NodeTranslator.from(config$2);
|
|
33320
33328
|
const tabSizeEncoder = (attributes) => {
|
|
33321
33329
|
return attributes["w:val"];
|
|
33322
33330
|
};
|
|
@@ -33338,19 +33346,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33338
33346
|
const { pos } = attrs;
|
|
33339
33347
|
return pos;
|
|
33340
33348
|
};
|
|
33341
|
-
const XML_NODE_NAME = "w:tab";
|
|
33342
|
-
const SD_NODE_NAME = "tab";
|
|
33343
|
-
const validXmlAttributes = [
|
|
33349
|
+
const XML_NODE_NAME$1 = "w:tab";
|
|
33350
|
+
const SD_NODE_NAME$1 = "tab";
|
|
33351
|
+
const validXmlAttributes$1 = [
|
|
33344
33352
|
{ xmlName: "w:val", sdName: "tabSize", encode: tabSizeEncoder, decode: tabSizeDecoder },
|
|
33345
33353
|
{ xmlName: "w:pos", sdName: "pos", encode: tabPositionEncoder, decode: tabPositionDecoder },
|
|
33346
33354
|
{ xmlName: "w:leader", sdName: "leader", encode: tabLeaderEncoder, decode: tabLeaderDecoder }
|
|
33347
33355
|
];
|
|
33348
|
-
const encode$
|
|
33356
|
+
const encode$1 = (_2, encodedAttrs = {}) => {
|
|
33349
33357
|
const translated = { type: "tab" };
|
|
33350
33358
|
if (encodedAttrs) translated.attrs = { ...encodedAttrs };
|
|
33351
33359
|
return translated;
|
|
33352
33360
|
};
|
|
33353
|
-
const decode = (params2, decodedAttrs = {}) => {
|
|
33361
|
+
const decode$1 = (params2, decodedAttrs = {}) => {
|
|
33354
33362
|
const { node: node2 } = params2 || {};
|
|
33355
33363
|
if (!node2) return;
|
|
33356
33364
|
const wTab = { name: "w:tab" };
|
|
@@ -33366,11 +33374,543 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33366
33374
|
}
|
|
33367
33375
|
return translated;
|
|
33368
33376
|
};
|
|
33377
|
+
const config$1 = {
|
|
33378
|
+
xmlName: XML_NODE_NAME$1,
|
|
33379
|
+
sdNodeOrKeyName: SD_NODE_NAME$1,
|
|
33380
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
33381
|
+
encode: encode$1,
|
|
33382
|
+
decode: decode$1,
|
|
33383
|
+
attributes: validXmlAttributes$1
|
|
33384
|
+
};
|
|
33385
|
+
const translator$1 = NodeTranslator.from(config$1);
|
|
33386
|
+
const handleAllTableNodes = (params2) => {
|
|
33387
|
+
const { nodes } = params2;
|
|
33388
|
+
if (nodes.length === 0) {
|
|
33389
|
+
return { nodes: [], consumed: 0 };
|
|
33390
|
+
}
|
|
33391
|
+
const node2 = nodes[0];
|
|
33392
|
+
switch (node2.name) {
|
|
33393
|
+
case "w:tbl":
|
|
33394
|
+
return { nodes: [handleTableNode(node2, params2)], consumed: 1 };
|
|
33395
|
+
}
|
|
33396
|
+
return { nodes: [], consumed: 0 };
|
|
33397
|
+
};
|
|
33398
|
+
const tableNodeHandlerEntity = {
|
|
33399
|
+
handlerName: "tableNodeHandler",
|
|
33400
|
+
handler: handleAllTableNodes
|
|
33401
|
+
};
|
|
33402
|
+
function handleTableNode(node2, params2) {
|
|
33403
|
+
const { docx, nodeListHandler: nodeListHandler2 } = params2;
|
|
33404
|
+
const tblPr = node2.elements.find((el) => el.name === "w:tblPr");
|
|
33405
|
+
const tableBordersElement = tblPr.elements.find((el) => el.name === "w:tblBorders");
|
|
33406
|
+
const tableBorders = tableBordersElement?.elements || [];
|
|
33407
|
+
const { borders, rowBorders } = processTableBorders(tableBorders);
|
|
33408
|
+
const tblStyleTag = tblPr.elements.find((el) => el.name === "w:tblStyle");
|
|
33409
|
+
const tableStyleId = tblStyleTag?.attributes["w:val"];
|
|
33410
|
+
const attrs = { tableStyleId };
|
|
33411
|
+
const tableIndent = tblPr?.elements.find((el) => el.name === "w:tblInd");
|
|
33412
|
+
if (tableIndent) {
|
|
33413
|
+
const { "w:w": width, "w:type": type2 } = tableIndent.attributes;
|
|
33414
|
+
attrs["tableIndent"] = { width: twipsToPixels(width), type: type2 };
|
|
33415
|
+
}
|
|
33416
|
+
const tableLayout = tblPr?.elements.find((el) => el.name === "w:tblLayout");
|
|
33417
|
+
if (tableLayout) {
|
|
33418
|
+
const { "w:type": type2 } = tableLayout.attributes;
|
|
33419
|
+
attrs["tableLayout"] = type2;
|
|
33420
|
+
}
|
|
33421
|
+
const referencedStyles = getReferencedTableStyles(tblStyleTag, docx);
|
|
33422
|
+
const tblW = tblPr.elements.find((el) => el.name === "w:tblW");
|
|
33423
|
+
if (tblW) {
|
|
33424
|
+
attrs["tableWidth"] = {
|
|
33425
|
+
width: twipsToPixels(tblW.attributes["w:w"]),
|
|
33426
|
+
type: tblW.attributes["w:type"]
|
|
33427
|
+
};
|
|
33428
|
+
}
|
|
33429
|
+
const tblCellSpacing = tblPr.elements.find((el) => el.name === "w:tblCellSpacing");
|
|
33430
|
+
if (tblCellSpacing) {
|
|
33431
|
+
attrs["tableCellSpacing"] = {
|
|
33432
|
+
w: tblCellSpacing.attributes["w:w"],
|
|
33433
|
+
type: tblCellSpacing.attributes["w:type"]
|
|
33434
|
+
};
|
|
33435
|
+
attrs["borderCollapse"] = "separate";
|
|
33436
|
+
}
|
|
33437
|
+
const tblJustification = tblPr.elements.find((el) => el.name === "w:jc");
|
|
33438
|
+
if (tblJustification?.attributes) {
|
|
33439
|
+
attrs["justification"] = tblJustification.attributes["w:val"];
|
|
33440
|
+
}
|
|
33441
|
+
const rows = node2.elements.filter((el) => el.name === "w:tr");
|
|
33442
|
+
const refStylesBorders = referencedStyles?.borders || {};
|
|
33443
|
+
const refStylesRowBorders = referencedStyles?.rowBorders || {};
|
|
33444
|
+
const borderData = Object.keys(borders)?.length ? Object.assign(refStylesBorders, borders) : refStylesBorders;
|
|
33445
|
+
const borderRowData = Object.keys(rowBorders)?.length ? Object.assign(refStylesRowBorders, rowBorders) : refStylesRowBorders;
|
|
33446
|
+
attrs["borders"] = borderData;
|
|
33447
|
+
const content = [];
|
|
33448
|
+
rows.forEach((row) => {
|
|
33449
|
+
const result = handleTableRowNode(row, node2, borderRowData, tblStyleTag, params2);
|
|
33450
|
+
if (result.content?.length) content.push(result);
|
|
33451
|
+
});
|
|
33452
|
+
return {
|
|
33453
|
+
type: "table",
|
|
33454
|
+
content,
|
|
33455
|
+
attrs
|
|
33456
|
+
};
|
|
33457
|
+
}
|
|
33458
|
+
function handleTableCellNode$1({
|
|
33459
|
+
params: params2,
|
|
33460
|
+
node: node2,
|
|
33461
|
+
table,
|
|
33462
|
+
row,
|
|
33463
|
+
rowBorders,
|
|
33464
|
+
styleTag,
|
|
33465
|
+
columnIndex,
|
|
33466
|
+
columnWidth = null
|
|
33467
|
+
}) {
|
|
33468
|
+
const translatorParams = {
|
|
33469
|
+
...params2,
|
|
33470
|
+
extraParams: {
|
|
33471
|
+
node: node2,
|
|
33472
|
+
table,
|
|
33473
|
+
row,
|
|
33474
|
+
rowBorders,
|
|
33475
|
+
styleTag,
|
|
33476
|
+
columnIndex,
|
|
33477
|
+
columnWidth
|
|
33478
|
+
}
|
|
33479
|
+
};
|
|
33480
|
+
const schemaNode = translator.encode(translatorParams);
|
|
33481
|
+
return schemaNode;
|
|
33482
|
+
}
|
|
33483
|
+
function getReferencedTableStyles(tblStyleTag, docx) {
|
|
33484
|
+
if (!tblStyleTag) return null;
|
|
33485
|
+
const stylesToReturn = {};
|
|
33486
|
+
const { attributes = {} } = tblStyleTag;
|
|
33487
|
+
const tableStyleReference = attributes["w:val"];
|
|
33488
|
+
if (!tableStyleReference) return null;
|
|
33489
|
+
const styles = docx["word/styles.xml"];
|
|
33490
|
+
const { elements } = styles.elements[0];
|
|
33491
|
+
const styleElements = elements.filter((el) => el.name === "w:style");
|
|
33492
|
+
const styleTag = styleElements.find((el) => el.attributes["w:styleId"] === tableStyleReference);
|
|
33493
|
+
if (!styleTag) return null;
|
|
33494
|
+
stylesToReturn.name = styleTag.elements.find((el) => el.name === "w:name");
|
|
33495
|
+
const basedOn = styleTag.elements.find((el) => el.name === "w:basedOn");
|
|
33496
|
+
let baseTblPr;
|
|
33497
|
+
if (basedOn?.attributes) {
|
|
33498
|
+
const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
|
|
33499
|
+
baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
|
|
33500
|
+
}
|
|
33501
|
+
const pPr = styleTag.elements.find((el) => el.name === "w:pPr");
|
|
33502
|
+
if (pPr) {
|
|
33503
|
+
const justification = pPr.elements.find((el) => el.name === "w:jc");
|
|
33504
|
+
if (justification?.attributes) stylesToReturn.justification = justification.attributes["w:val"];
|
|
33505
|
+
}
|
|
33506
|
+
const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
|
|
33507
|
+
if (rPr) {
|
|
33508
|
+
const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
|
|
33509
|
+
if (fonts) {
|
|
33510
|
+
const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
|
|
33511
|
+
stylesToReturn.fonts = { ascii, hAnsi, cs };
|
|
33512
|
+
}
|
|
33513
|
+
const fontSize2 = rPr.elements.find((el) => el.name === "w:sz");
|
|
33514
|
+
if (fontSize2?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize2.attributes["w:val"]) + "pt";
|
|
33515
|
+
}
|
|
33516
|
+
const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
|
|
33517
|
+
if (tblPr && tblPr.elements) {
|
|
33518
|
+
if (baseTblPr && baseTblPr.elements) {
|
|
33519
|
+
tblPr.elements.push(...baseTblPr.elements);
|
|
33520
|
+
}
|
|
33521
|
+
const tableBorders = tblPr?.elements?.find((el) => el.name === "w:tblBorders");
|
|
33522
|
+
const { elements: borderElements = [] } = tableBorders || {};
|
|
33523
|
+
const { borders, rowBorders } = processTableBorders(borderElements);
|
|
33524
|
+
if (borders) stylesToReturn.borders = borders;
|
|
33525
|
+
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
33526
|
+
const tableCellMargin = tblPr?.elements.find((el) => el.name === "w:tblCellMar");
|
|
33527
|
+
if (tableCellMargin) {
|
|
33528
|
+
const marginLeft = tableCellMargin.elements.find((el) => el.name === "w:left");
|
|
33529
|
+
const marginRight = tableCellMargin.elements.find((el) => el.name === "w:right");
|
|
33530
|
+
const marginTop = tableCellMargin.elements.find((el) => el.name === "w:top");
|
|
33531
|
+
const marginBottom = tableCellMargin.elements.find((el) => el.name === "w:bottom");
|
|
33532
|
+
stylesToReturn.cellMargins = {
|
|
33533
|
+
marginLeft: marginLeft?.attributes["w:w"],
|
|
33534
|
+
marginRight: marginRight?.attributes["w:w"],
|
|
33535
|
+
marginTop: marginTop?.attributes["w:w"],
|
|
33536
|
+
marginBottom: marginBottom?.attributes["w:w"]
|
|
33537
|
+
};
|
|
33538
|
+
}
|
|
33539
|
+
}
|
|
33540
|
+
return stylesToReturn;
|
|
33541
|
+
}
|
|
33542
|
+
function processTableBorders(borderElements) {
|
|
33543
|
+
const borders = {};
|
|
33544
|
+
const rowBorders = {};
|
|
33545
|
+
borderElements.forEach((borderElement) => {
|
|
33546
|
+
const { name } = borderElement;
|
|
33547
|
+
const borderName = name.split("w:")[1];
|
|
33548
|
+
const { attributes } = borderElement;
|
|
33549
|
+
const attrs = {};
|
|
33550
|
+
const color = attributes["w:color"];
|
|
33551
|
+
const size2 = attributes["w:sz"];
|
|
33552
|
+
if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
|
|
33553
|
+
if (size2 && size2 !== "auto") attrs["size"] = eigthPointsToPixels(size2);
|
|
33554
|
+
const rowBorderNames = ["insideH", "insideV"];
|
|
33555
|
+
if (rowBorderNames.includes(borderName)) rowBorders[borderName] = attrs;
|
|
33556
|
+
borders[borderName] = attrs;
|
|
33557
|
+
});
|
|
33558
|
+
return {
|
|
33559
|
+
borders,
|
|
33560
|
+
rowBorders
|
|
33561
|
+
};
|
|
33562
|
+
}
|
|
33563
|
+
function handleTableRowNode(node2, table, rowBorders, styleTag, params2) {
|
|
33564
|
+
const attrs = {};
|
|
33565
|
+
const tPr = node2.elements.find((el) => el.name === "w:trPr");
|
|
33566
|
+
const rowHeightTag = tPr?.elements?.find((el) => el.name === "w:trHeight");
|
|
33567
|
+
const rowHeight = rowHeightTag?.attributes["w:val"];
|
|
33568
|
+
const cantSplitTag = tPr?.elements?.find((el) => el.name === "w:cantSplit");
|
|
33569
|
+
if (cantSplitTag) {
|
|
33570
|
+
attrs["cantSplit"] = true;
|
|
33571
|
+
}
|
|
33572
|
+
const borders = {};
|
|
33573
|
+
if (rowBorders?.insideH) borders["bottom"] = rowBorders.insideH;
|
|
33574
|
+
if (rowBorders?.insideV) borders["right"] = rowBorders.insideV;
|
|
33575
|
+
attrs["borders"] = borders;
|
|
33576
|
+
if (rowHeight) {
|
|
33577
|
+
attrs["rowHeight"] = twipsToPixels(rowHeight);
|
|
33578
|
+
}
|
|
33579
|
+
const gridColumnWidths = getGridColumnWidths(table);
|
|
33580
|
+
const cellNodes = node2.elements.filter((el) => el.name === "w:tc");
|
|
33581
|
+
let currentColumnIndex = 0;
|
|
33582
|
+
const content = cellNodes?.map((n) => {
|
|
33583
|
+
let colWidth = gridColumnWidths?.[currentColumnIndex] || null;
|
|
33584
|
+
const result = handleTableCellNode$1({
|
|
33585
|
+
params: params2,
|
|
33586
|
+
node: n,
|
|
33587
|
+
table,
|
|
33588
|
+
row: node2,
|
|
33589
|
+
rowBorders: borders,
|
|
33590
|
+
styleTag,
|
|
33591
|
+
columnIndex: currentColumnIndex,
|
|
33592
|
+
columnWidth: colWidth
|
|
33593
|
+
});
|
|
33594
|
+
const tcPr = n.elements?.find((el) => el.name === "w:tcPr");
|
|
33595
|
+
const colspanTag = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
33596
|
+
const colspan = parseInt(colspanTag?.attributes["w:val"] || 1, 10);
|
|
33597
|
+
currentColumnIndex += colspan;
|
|
33598
|
+
return result;
|
|
33599
|
+
}) || [];
|
|
33600
|
+
const newNode = {
|
|
33601
|
+
type: "tableRow",
|
|
33602
|
+
content,
|
|
33603
|
+
attrs
|
|
33604
|
+
};
|
|
33605
|
+
return newNode;
|
|
33606
|
+
}
|
|
33607
|
+
const getGridColumnWidths = (tableNode) => {
|
|
33608
|
+
const tblGrid = tableNode.elements.find((el) => el.name === "w:tblGrid");
|
|
33609
|
+
if (!tblGrid) return [];
|
|
33610
|
+
const columnWidths = tblGrid?.elements?.flatMap((el) => {
|
|
33611
|
+
if (el.name !== "w:gridCol") return [];
|
|
33612
|
+
return twipsToPixels(el.attributes["w:w"]);
|
|
33613
|
+
}) || [];
|
|
33614
|
+
return columnWidths;
|
|
33615
|
+
};
|
|
33616
|
+
function handleTableCellNode({
|
|
33617
|
+
params: params2,
|
|
33618
|
+
node: node2,
|
|
33619
|
+
table,
|
|
33620
|
+
row,
|
|
33621
|
+
rowBorders,
|
|
33622
|
+
styleTag,
|
|
33623
|
+
columnIndex,
|
|
33624
|
+
columnWidth = null
|
|
33625
|
+
}) {
|
|
33626
|
+
const { docx, nodeListHandler: nodeListHandler2 } = params2;
|
|
33627
|
+
const tcPr = node2.elements.find((el) => el.name === "w:tcPr");
|
|
33628
|
+
const borders = tcPr?.elements?.find((el) => el.name === "w:tcBorders");
|
|
33629
|
+
const inlineBorders = processInlineCellBorders(borders, rowBorders);
|
|
33630
|
+
const gridColumnWidths = getGridColumnWidths(table);
|
|
33631
|
+
const tcWidth = tcPr?.elements?.find((el) => el.name === "w:tcW");
|
|
33632
|
+
let width = tcWidth ? twipsToPixels(tcWidth.attributes["w:w"]) : null;
|
|
33633
|
+
const widthType = tcWidth?.attributes["w:type"];
|
|
33634
|
+
if (!width && columnWidth) width = columnWidth;
|
|
33635
|
+
const vMerge = getTableCellMergeTag(node2);
|
|
33636
|
+
const { attributes: vMergeAttrs } = vMerge || {};
|
|
33637
|
+
const backgroundColor = tcPr?.elements?.find((el) => el.name === "w:shd");
|
|
33638
|
+
const background = {
|
|
33639
|
+
color: backgroundColor?.attributes["w:fill"]
|
|
33640
|
+
};
|
|
33641
|
+
const colspanTag = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
33642
|
+
const colspan = colspanTag?.attributes["w:val"];
|
|
33643
|
+
const marginTag = tcPr?.elements?.find((el) => el.name === "w:tcMar");
|
|
33644
|
+
const verticalAlignTag = tcPr?.elements?.find((el) => el.name === "w:vAlign");
|
|
33645
|
+
const verticalAlign = verticalAlignTag?.attributes["w:val"] || "top";
|
|
33646
|
+
const attributes = {};
|
|
33647
|
+
const referencedStyles = getReferencedTableStyles(styleTag, docx) || {};
|
|
33648
|
+
attributes.cellMargins = getTableCellMargins(marginTag, referencedStyles);
|
|
33649
|
+
const { fontSize: fontSize2, fonts = {} } = referencedStyles;
|
|
33650
|
+
const fontFamily2 = fonts["ascii"];
|
|
33651
|
+
if (width) {
|
|
33652
|
+
attributes["colwidth"] = [width];
|
|
33653
|
+
attributes["widthUnit"] = "px";
|
|
33654
|
+
const defaultColWidths = gridColumnWidths;
|
|
33655
|
+
const hasDefaultColWidths = gridColumnWidths && gridColumnWidths.length > 0;
|
|
33656
|
+
const colspanNum = parseInt(colspan || 1, 10);
|
|
33657
|
+
if (colspanNum && colspanNum > 1 && hasDefaultColWidths) {
|
|
33658
|
+
let colwidth = [];
|
|
33659
|
+
for (let i2 = 0; i2 < colspanNum; i2++) {
|
|
33660
|
+
let colwidthValue = defaultColWidths[columnIndex + i2];
|
|
33661
|
+
let defaultColwidth = 100;
|
|
33662
|
+
if (typeof colwidthValue !== "undefined") {
|
|
33663
|
+
colwidth.push(colwidthValue);
|
|
33664
|
+
} else {
|
|
33665
|
+
colwidth.push(defaultColwidth);
|
|
33666
|
+
}
|
|
33667
|
+
}
|
|
33668
|
+
if (colwidth.length) {
|
|
33669
|
+
attributes["colwidth"] = [...colwidth];
|
|
33670
|
+
}
|
|
33671
|
+
}
|
|
33672
|
+
}
|
|
33673
|
+
if (widthType) attributes["widthType"] = widthType;
|
|
33674
|
+
if (colspan) attributes["colspan"] = parseInt(colspan, 10);
|
|
33675
|
+
if (background) attributes["background"] = background;
|
|
33676
|
+
attributes["verticalAlign"] = verticalAlign;
|
|
33677
|
+
if (fontSize2) attributes["fontSize"] = fontSize2;
|
|
33678
|
+
if (fontFamily2) attributes["fontFamily"] = fontFamily2["ascii"];
|
|
33679
|
+
if (rowBorders) attributes["borders"] = { ...rowBorders };
|
|
33680
|
+
if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"] || {}, inlineBorders);
|
|
33681
|
+
if (vMergeAttrs && vMergeAttrs["w:val"] === "restart") {
|
|
33682
|
+
const rows = table.elements.filter((el) => el.name === "w:tr");
|
|
33683
|
+
const currentRowIndex = rows.findIndex((r2) => r2 === row);
|
|
33684
|
+
const remainingRows = rows.slice(currentRowIndex + 1);
|
|
33685
|
+
const cellsInRow = row.elements.filter((el) => el.name === "w:tc");
|
|
33686
|
+
let cellIndex = cellsInRow.findIndex((el) => el === node2);
|
|
33687
|
+
let rowspan = 1;
|
|
33688
|
+
for (let remainingRow of remainingRows) {
|
|
33689
|
+
const firstCell = remainingRow.elements.findIndex((el) => el.name === "w:tc");
|
|
33690
|
+
const cellAtIndex = remainingRow.elements[firstCell + cellIndex];
|
|
33691
|
+
if (!cellAtIndex) break;
|
|
33692
|
+
const vMerge2 = getTableCellMergeTag(cellAtIndex);
|
|
33693
|
+
const { attributes: currentCellMergeAttrs } = vMerge2 || {};
|
|
33694
|
+
if (!vMerge2 && !currentCellMergeAttrs || currentCellMergeAttrs && currentCellMergeAttrs["w:val"] === "restart") {
|
|
33695
|
+
break;
|
|
33696
|
+
}
|
|
33697
|
+
rowspan++;
|
|
33698
|
+
remainingRow.elements.splice(firstCell + cellIndex, 1);
|
|
33699
|
+
}
|
|
33700
|
+
attributes["rowspan"] = rowspan;
|
|
33701
|
+
}
|
|
33702
|
+
return {
|
|
33703
|
+
type: "tableCell",
|
|
33704
|
+
content: nodeListHandler2.handler({
|
|
33705
|
+
...params2,
|
|
33706
|
+
nodes: node2.elements,
|
|
33707
|
+
path: [...params2.path || [], node2]
|
|
33708
|
+
}),
|
|
33709
|
+
attrs: attributes
|
|
33710
|
+
};
|
|
33711
|
+
}
|
|
33712
|
+
const processInlineCellBorders = (borders, rowBorders) => {
|
|
33713
|
+
if (!borders) return null;
|
|
33714
|
+
const processedBorders = {};
|
|
33715
|
+
const inlineBorderBottom = processBorder(borders, "bottom", rowBorders);
|
|
33716
|
+
if (inlineBorderBottom) processedBorders["bottom"] = inlineBorderBottom;
|
|
33717
|
+
const inlineBorderTop = processBorder(borders, "top", rowBorders);
|
|
33718
|
+
if (inlineBorderTop) processedBorders["top"] = inlineBorderTop;
|
|
33719
|
+
const inlineBorderLeft = processBorder(borders, "left", rowBorders);
|
|
33720
|
+
if (inlineBorderLeft) processedBorders["left"] = inlineBorderLeft;
|
|
33721
|
+
const inlineBorderRight = processBorder(borders, "right", rowBorders);
|
|
33722
|
+
if (inlineBorderRight) processedBorders["right"] = inlineBorderRight;
|
|
33723
|
+
return processedBorders;
|
|
33724
|
+
};
|
|
33725
|
+
const processBorder = (borders, direction, rowBorders = {}) => {
|
|
33726
|
+
const borderAttrs = borders?.elements?.find((el) => el.name === `w:${direction}`)?.attributes;
|
|
33727
|
+
if (borderAttrs && borderAttrs["w:val"] !== "nil") {
|
|
33728
|
+
const border = {};
|
|
33729
|
+
const color = borderAttrs["w:color"];
|
|
33730
|
+
if (color) border["color"] = color === "auto" ? "#000000" : `#${color}`;
|
|
33731
|
+
const size2 = borderAttrs["w:sz"];
|
|
33732
|
+
if (size2) border["size"] = eigthPointsToPixels(size2);
|
|
33733
|
+
return border;
|
|
33734
|
+
}
|
|
33735
|
+
if (borderAttrs && borderAttrs["w:val"] === "nil") {
|
|
33736
|
+
const border = Object.assign({}, rowBorders[direction] || {});
|
|
33737
|
+
if (!Object.keys(border)) return null;
|
|
33738
|
+
border["val"] = "none";
|
|
33739
|
+
return border;
|
|
33740
|
+
}
|
|
33741
|
+
return null;
|
|
33742
|
+
};
|
|
33743
|
+
const getTableCellMergeTag = (node2) => {
|
|
33744
|
+
const tcPr = node2.elements.find((el) => el.name === "w:tcPr");
|
|
33745
|
+
const vMerge = tcPr?.elements?.find((el) => el.name === "w:vMerge");
|
|
33746
|
+
return vMerge;
|
|
33747
|
+
};
|
|
33748
|
+
const getTableCellMargins = (marginTag, referencedStyles) => {
|
|
33749
|
+
const inlineMarginLeftTag = marginTag?.elements?.find((el) => el.name === "w:left");
|
|
33750
|
+
const inlineMarginRightTag = marginTag?.elements?.find((el) => el.name === "w:right");
|
|
33751
|
+
const inlineMarginTopTag = marginTag?.elements?.find((el) => el.name === "w:top");
|
|
33752
|
+
const inlineMarginBottomTag = marginTag?.elements?.find((el) => el.name === "w:bottom");
|
|
33753
|
+
const inlineMarginLeftValue = inlineMarginLeftTag?.attributes["w:w"];
|
|
33754
|
+
const inlineMarginRightValue = inlineMarginRightTag?.attributes["w:w"];
|
|
33755
|
+
const inlineMarginTopValue = inlineMarginTopTag?.attributes["w:w"];
|
|
33756
|
+
const inlineMarginBottomValue = inlineMarginBottomTag?.attributes["w:w"];
|
|
33757
|
+
const { cellMargins = {} } = referencedStyles;
|
|
33758
|
+
const {
|
|
33759
|
+
marginLeft: marginLeftStyle,
|
|
33760
|
+
marginRight: marginRightStyle,
|
|
33761
|
+
marginTop: marginTopStyle,
|
|
33762
|
+
marginBottom: marginBottomStyle
|
|
33763
|
+
} = cellMargins;
|
|
33764
|
+
const margins = {
|
|
33765
|
+
left: twipsToPixels(inlineMarginLeftValue ?? marginLeftStyle),
|
|
33766
|
+
right: twipsToPixels(inlineMarginRightValue ?? marginRightStyle),
|
|
33767
|
+
top: twipsToPixels(inlineMarginTopValue ?? marginTopStyle),
|
|
33768
|
+
bottom: twipsToPixels(inlineMarginBottomValue ?? marginBottomStyle)
|
|
33769
|
+
};
|
|
33770
|
+
return margins;
|
|
33771
|
+
};
|
|
33772
|
+
function translateTableCell(params2) {
|
|
33773
|
+
const elements = translateChildNodes({
|
|
33774
|
+
...params2,
|
|
33775
|
+
tableCell: params2.node
|
|
33776
|
+
});
|
|
33777
|
+
const cellProps = generateTableCellProperties(params2.node);
|
|
33778
|
+
elements.unshift(cellProps);
|
|
33779
|
+
return {
|
|
33780
|
+
name: "w:tc",
|
|
33781
|
+
elements
|
|
33782
|
+
};
|
|
33783
|
+
}
|
|
33784
|
+
function generateTableCellProperties(node2) {
|
|
33785
|
+
const elements = [];
|
|
33786
|
+
const { attrs } = node2;
|
|
33787
|
+
const { colwidth = [], cellWidthType = "dxa", background = {}, colspan, rowspan, widthUnit } = attrs;
|
|
33788
|
+
const colwidthSum = colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
33789
|
+
const cellWidthElement = {
|
|
33790
|
+
name: "w:tcW",
|
|
33791
|
+
attributes: {
|
|
33792
|
+
"w:w": widthUnit === "px" ? pixelsToTwips(colwidthSum) : inchesToTwips(colwidthSum),
|
|
33793
|
+
"w:type": cellWidthType
|
|
33794
|
+
}
|
|
33795
|
+
};
|
|
33796
|
+
elements.push(cellWidthElement);
|
|
33797
|
+
if (colspan) {
|
|
33798
|
+
const gridSpanElement = {
|
|
33799
|
+
name: "w:gridSpan",
|
|
33800
|
+
attributes: { "w:val": `${colspan}` }
|
|
33801
|
+
};
|
|
33802
|
+
elements.push(gridSpanElement);
|
|
33803
|
+
}
|
|
33804
|
+
const { color } = background || {};
|
|
33805
|
+
if (color) {
|
|
33806
|
+
const cellBgElement = {
|
|
33807
|
+
name: "w:shd",
|
|
33808
|
+
attributes: { "w:fill": color }
|
|
33809
|
+
};
|
|
33810
|
+
elements.push(cellBgElement);
|
|
33811
|
+
}
|
|
33812
|
+
const { cellMargins } = attrs;
|
|
33813
|
+
if (cellMargins) {
|
|
33814
|
+
const cellMarginsElement = {
|
|
33815
|
+
name: "w:tcMar",
|
|
33816
|
+
elements: generateCellMargins(cellMargins)
|
|
33817
|
+
};
|
|
33818
|
+
elements.push(cellMarginsElement);
|
|
33819
|
+
}
|
|
33820
|
+
const { verticalAlign } = attrs;
|
|
33821
|
+
if (verticalAlign) {
|
|
33822
|
+
const vertAlignElement = {
|
|
33823
|
+
name: "w:vAlign",
|
|
33824
|
+
attributes: { "w:val": verticalAlign }
|
|
33825
|
+
};
|
|
33826
|
+
elements.push(vertAlignElement);
|
|
33827
|
+
}
|
|
33828
|
+
if (rowspan && rowspan > 1) {
|
|
33829
|
+
const vMergeElement = {
|
|
33830
|
+
name: "w:vMerge",
|
|
33831
|
+
type: "element",
|
|
33832
|
+
attributes: { "w:val": "restart" }
|
|
33833
|
+
};
|
|
33834
|
+
elements.push(vMergeElement);
|
|
33835
|
+
} else if (attrs.continueMerge) {
|
|
33836
|
+
const vMergeElement = {
|
|
33837
|
+
name: "w:vMerge",
|
|
33838
|
+
type: "element"
|
|
33839
|
+
};
|
|
33840
|
+
elements.push(vMergeElement);
|
|
33841
|
+
}
|
|
33842
|
+
const { borders = {} } = attrs;
|
|
33843
|
+
if (!!borders && Object.keys(borders).length) {
|
|
33844
|
+
const cellBordersElement = {
|
|
33845
|
+
name: "w:tcBorders",
|
|
33846
|
+
elements: Object.entries(borders).map(([key, value]) => {
|
|
33847
|
+
if (!value.size || value.val === "none") {
|
|
33848
|
+
return {
|
|
33849
|
+
name: `w:${key}`,
|
|
33850
|
+
attributes: {
|
|
33851
|
+
"w:val": "nil"
|
|
33852
|
+
}
|
|
33853
|
+
};
|
|
33854
|
+
}
|
|
33855
|
+
return {
|
|
33856
|
+
name: `w:${key}`,
|
|
33857
|
+
attributes: {
|
|
33858
|
+
"w:val": "single",
|
|
33859
|
+
"w:color": value.color ? value.color.substring(1) : "auto",
|
|
33860
|
+
"w:sz": pixelsToEightPoints(value.size),
|
|
33861
|
+
"w:space": value.space || 0
|
|
33862
|
+
}
|
|
33863
|
+
};
|
|
33864
|
+
})
|
|
33865
|
+
};
|
|
33866
|
+
elements.push(cellBordersElement);
|
|
33867
|
+
}
|
|
33868
|
+
return {
|
|
33869
|
+
name: "w:tcPr",
|
|
33870
|
+
elements
|
|
33871
|
+
};
|
|
33872
|
+
}
|
|
33873
|
+
function generateCellMargins(cellMargins) {
|
|
33874
|
+
const elements = [];
|
|
33875
|
+
const { top: top2, right: right2, bottom: bottom2, left: left2 } = cellMargins;
|
|
33876
|
+
if (top2 != null) elements.push({ name: "w:top", attributes: { "w:w": pixelsToTwips(top2) } });
|
|
33877
|
+
if (right2 != null) elements.push({ name: "w:right", attributes: { "w:w": pixelsToTwips(right2) } });
|
|
33878
|
+
if (bottom2 != null) elements.push({ name: "w:bottom", attributes: { "w:w": pixelsToTwips(bottom2) } });
|
|
33879
|
+
if (left2 != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left2) } });
|
|
33880
|
+
return elements;
|
|
33881
|
+
}
|
|
33882
|
+
const XML_NODE_NAME = "w:tc";
|
|
33883
|
+
const SD_NODE_NAME = "tableCell";
|
|
33884
|
+
const validXmlAttributes = [];
|
|
33885
|
+
function encode$3(params2, encodedAttrs) {
|
|
33886
|
+
const { node: node2, table, row, rowBorders, styleTag, columnIndex, columnWidth } = params2.extraParams;
|
|
33887
|
+
const schemaNode = handleTableCellNode({
|
|
33888
|
+
params: params2,
|
|
33889
|
+
node: node2,
|
|
33890
|
+
table,
|
|
33891
|
+
row,
|
|
33892
|
+
rowBorders,
|
|
33893
|
+
styleTag,
|
|
33894
|
+
columnIndex,
|
|
33895
|
+
columnWidth
|
|
33896
|
+
});
|
|
33897
|
+
if (encodedAttrs && Object.keys(encodedAttrs).length) {
|
|
33898
|
+
schemaNode.attrs = { ...schemaNode.attrs, ...encodedAttrs };
|
|
33899
|
+
}
|
|
33900
|
+
return schemaNode;
|
|
33901
|
+
}
|
|
33902
|
+
function decode(params2, decodedAttrs) {
|
|
33903
|
+
const translated = translateTableCell(params2);
|
|
33904
|
+
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
33905
|
+
translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
|
|
33906
|
+
}
|
|
33907
|
+
return translated;
|
|
33908
|
+
}
|
|
33369
33909
|
const config = {
|
|
33370
33910
|
xmlName: XML_NODE_NAME,
|
|
33371
33911
|
sdNodeOrKeyName: SD_NODE_NAME,
|
|
33372
33912
|
type: NodeTranslator.translatorTypes.NODE,
|
|
33373
|
-
encode: encode$
|
|
33913
|
+
encode: encode$3,
|
|
33374
33914
|
decode,
|
|
33375
33915
|
attributes: validXmlAttributes
|
|
33376
33916
|
};
|
|
@@ -33385,15 +33925,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33385
33925
|
text: translateTextNode,
|
|
33386
33926
|
bulletList: translateList,
|
|
33387
33927
|
orderedList: translateList,
|
|
33388
|
-
lineBreak: translator$
|
|
33928
|
+
lineBreak: translator$2,
|
|
33389
33929
|
table: translateTable,
|
|
33390
33930
|
tableRow: translateTableRow,
|
|
33391
|
-
tableCell:
|
|
33931
|
+
tableCell: translator,
|
|
33392
33932
|
bookmarkStart: translateBookmarkStart,
|
|
33393
33933
|
fieldAnnotation: translateFieldAnnotation,
|
|
33394
|
-
tab: translator,
|
|
33934
|
+
tab: translator$1,
|
|
33395
33935
|
image: translateImageNode,
|
|
33396
|
-
hardBreak: translator$
|
|
33936
|
+
hardBreak: translator$2,
|
|
33397
33937
|
commentRangeStart: () => translateCommentNode(params2, "Start"),
|
|
33398
33938
|
commentRangeEnd: () => translateCommentNode(params2, "End"),
|
|
33399
33939
|
commentReference: () => null,
|
|
@@ -34224,116 +34764,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34224
34764
|
elements
|
|
34225
34765
|
};
|
|
34226
34766
|
}
|
|
34227
|
-
function translateTableCell(params2) {
|
|
34228
|
-
const elements = translateChildNodes({
|
|
34229
|
-
...params2,
|
|
34230
|
-
tableCell: params2.node
|
|
34231
|
-
});
|
|
34232
|
-
const cellProps = generateTableCellProperties(params2.node);
|
|
34233
|
-
elements.unshift(cellProps);
|
|
34234
|
-
return {
|
|
34235
|
-
name: "w:tc",
|
|
34236
|
-
elements
|
|
34237
|
-
};
|
|
34238
|
-
}
|
|
34239
|
-
function generateTableCellProperties(node2) {
|
|
34240
|
-
const elements = [];
|
|
34241
|
-
const { attrs } = node2;
|
|
34242
|
-
const { colwidth = [], cellWidthType = "dxa", background = {}, colspan, rowspan, widthUnit } = attrs;
|
|
34243
|
-
const colwidthSum = colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
34244
|
-
const cellWidthElement = {
|
|
34245
|
-
name: "w:tcW",
|
|
34246
|
-
attributes: {
|
|
34247
|
-
"w:w": widthUnit === "px" ? pixelsToTwips(colwidthSum) : inchesToTwips(colwidthSum),
|
|
34248
|
-
"w:type": cellWidthType
|
|
34249
|
-
}
|
|
34250
|
-
};
|
|
34251
|
-
elements.push(cellWidthElement);
|
|
34252
|
-
if (colspan) {
|
|
34253
|
-
const gridSpanElement = {
|
|
34254
|
-
name: "w:gridSpan",
|
|
34255
|
-
attributes: { "w:val": `${colspan}` }
|
|
34256
|
-
};
|
|
34257
|
-
elements.push(gridSpanElement);
|
|
34258
|
-
}
|
|
34259
|
-
const { color } = background || {};
|
|
34260
|
-
if (color) {
|
|
34261
|
-
const cellBgElement = {
|
|
34262
|
-
name: "w:shd",
|
|
34263
|
-
attributes: { "w:fill": color }
|
|
34264
|
-
};
|
|
34265
|
-
elements.push(cellBgElement);
|
|
34266
|
-
}
|
|
34267
|
-
const { cellMargins } = attrs;
|
|
34268
|
-
if (cellMargins) {
|
|
34269
|
-
const cellMarginsElement = {
|
|
34270
|
-
name: "w:tcMar",
|
|
34271
|
-
elements: generateCellMargins(cellMargins)
|
|
34272
|
-
};
|
|
34273
|
-
elements.push(cellMarginsElement);
|
|
34274
|
-
}
|
|
34275
|
-
const { verticalAlign } = attrs;
|
|
34276
|
-
if (verticalAlign) {
|
|
34277
|
-
const vertAlignElement = {
|
|
34278
|
-
name: "w:vAlign",
|
|
34279
|
-
attributes: { "w:val": verticalAlign }
|
|
34280
|
-
};
|
|
34281
|
-
elements.push(vertAlignElement);
|
|
34282
|
-
}
|
|
34283
|
-
if (rowspan && rowspan > 1) {
|
|
34284
|
-
const vMergeElement = {
|
|
34285
|
-
name: "w:vMerge",
|
|
34286
|
-
type: "element",
|
|
34287
|
-
attributes: { "w:val": "restart" }
|
|
34288
|
-
};
|
|
34289
|
-
elements.push(vMergeElement);
|
|
34290
|
-
} else if (attrs.continueMerge) {
|
|
34291
|
-
const vMergeElement = {
|
|
34292
|
-
name: "w:vMerge",
|
|
34293
|
-
type: "element"
|
|
34294
|
-
};
|
|
34295
|
-
elements.push(vMergeElement);
|
|
34296
|
-
}
|
|
34297
|
-
const { borders = {} } = attrs;
|
|
34298
|
-
if (!!borders && Object.keys(borders).length) {
|
|
34299
|
-
const cellBordersElement = {
|
|
34300
|
-
name: "w:tcBorders",
|
|
34301
|
-
elements: Object.entries(borders).map(([key, value]) => {
|
|
34302
|
-
if (!value.size || value.val === "none") {
|
|
34303
|
-
return {
|
|
34304
|
-
name: `w:${key}`,
|
|
34305
|
-
attributes: {
|
|
34306
|
-
"w:val": "nil"
|
|
34307
|
-
}
|
|
34308
|
-
};
|
|
34309
|
-
}
|
|
34310
|
-
return {
|
|
34311
|
-
name: `w:${key}`,
|
|
34312
|
-
attributes: {
|
|
34313
|
-
"w:val": "single",
|
|
34314
|
-
"w:color": value.color ? value.color.substring(1) : "auto",
|
|
34315
|
-
"w:sz": pixelsToEightPoints(value.size),
|
|
34316
|
-
"w:space": value.space || 0
|
|
34317
|
-
}
|
|
34318
|
-
};
|
|
34319
|
-
})
|
|
34320
|
-
};
|
|
34321
|
-
elements.push(cellBordersElement);
|
|
34322
|
-
}
|
|
34323
|
-
return {
|
|
34324
|
-
name: "w:tcPr",
|
|
34325
|
-
elements
|
|
34326
|
-
};
|
|
34327
|
-
}
|
|
34328
|
-
function generateCellMargins(cellMargins) {
|
|
34329
|
-
const elements = [];
|
|
34330
|
-
const { top: top2, right: right2, bottom: bottom2, left: left2 } = cellMargins;
|
|
34331
|
-
if (top2 != null) elements.push({ name: "w:top", attributes: { "w:w": pixelsToTwips(top2) } });
|
|
34332
|
-
if (right2 != null) elements.push({ name: "w:right", attributes: { "w:w": pixelsToTwips(right2) } });
|
|
34333
|
-
if (bottom2 != null) elements.push({ name: "w:bottom", attributes: { "w:w": pixelsToTwips(bottom2) } });
|
|
34334
|
-
if (left2 != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left2) } });
|
|
34335
|
-
return elements;
|
|
34336
|
-
}
|
|
34337
34767
|
function translateBookmarkStart(params2) {
|
|
34338
34768
|
const bookmarkStartNode = {
|
|
34339
34769
|
name: "w:bookmarkStart",
|
|
@@ -35282,345 +35712,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35282
35712
|
const getInitialJSON = (parsedDocx, fallbackXml = defaultInitialXml) => {
|
|
35283
35713
|
return parsedDocx["word/document.xml"] || parseXmlToJson(fallbackXml);
|
|
35284
35714
|
};
|
|
35285
|
-
const handleAllTableNodes = (params2) => {
|
|
35286
|
-
const { nodes } = params2;
|
|
35287
|
-
if (nodes.length === 0) {
|
|
35288
|
-
return { nodes: [], consumed: 0 };
|
|
35289
|
-
}
|
|
35290
|
-
const node2 = nodes[0];
|
|
35291
|
-
switch (node2.name) {
|
|
35292
|
-
case "w:tbl":
|
|
35293
|
-
return { nodes: [handleTableNode(node2, params2)], consumed: 1 };
|
|
35294
|
-
}
|
|
35295
|
-
return { nodes: [], consumed: 0 };
|
|
35296
|
-
};
|
|
35297
|
-
const tableNodeHandlerEntity = {
|
|
35298
|
-
handlerName: "tableNodeHandler",
|
|
35299
|
-
handler: handleAllTableNodes
|
|
35300
|
-
};
|
|
35301
|
-
function handleTableNode(node2, params2) {
|
|
35302
|
-
const { docx, nodeListHandler: nodeListHandler2 } = params2;
|
|
35303
|
-
const tblPr = node2.elements.find((el) => el.name === "w:tblPr");
|
|
35304
|
-
const tableBordersElement = tblPr.elements.find((el) => el.name === "w:tblBorders");
|
|
35305
|
-
const tableBorders = tableBordersElement?.elements || [];
|
|
35306
|
-
const { borders, rowBorders } = processTableBorders(tableBorders);
|
|
35307
|
-
const tblStyleTag = tblPr.elements.find((el) => el.name === "w:tblStyle");
|
|
35308
|
-
const tableStyleId = tblStyleTag?.attributes["w:val"];
|
|
35309
|
-
const attrs = { tableStyleId };
|
|
35310
|
-
const tableIndent = tblPr?.elements.find((el) => el.name === "w:tblInd");
|
|
35311
|
-
if (tableIndent) {
|
|
35312
|
-
const { "w:w": width, "w:type": type2 } = tableIndent.attributes;
|
|
35313
|
-
attrs["tableIndent"] = { width: twipsToPixels(width), type: type2 };
|
|
35314
|
-
}
|
|
35315
|
-
const tableLayout = tblPr?.elements.find((el) => el.name === "w:tblLayout");
|
|
35316
|
-
if (tableLayout) {
|
|
35317
|
-
const { "w:type": type2 } = tableLayout.attributes;
|
|
35318
|
-
attrs["tableLayout"] = type2;
|
|
35319
|
-
}
|
|
35320
|
-
const referencedStyles = getReferencedTableStyles(tblStyleTag, docx);
|
|
35321
|
-
const tblW = tblPr.elements.find((el) => el.name === "w:tblW");
|
|
35322
|
-
if (tblW) {
|
|
35323
|
-
attrs["tableWidth"] = {
|
|
35324
|
-
width: twipsToPixels(tblW.attributes["w:w"]),
|
|
35325
|
-
type: tblW.attributes["w:type"]
|
|
35326
|
-
};
|
|
35327
|
-
}
|
|
35328
|
-
const tblCellSpacing = tblPr.elements.find((el) => el.name === "w:tblCellSpacing");
|
|
35329
|
-
if (tblCellSpacing) {
|
|
35330
|
-
attrs["tableCellSpacing"] = {
|
|
35331
|
-
w: tblCellSpacing.attributes["w:w"],
|
|
35332
|
-
type: tblCellSpacing.attributes["w:type"]
|
|
35333
|
-
};
|
|
35334
|
-
attrs["borderCollapse"] = "separate";
|
|
35335
|
-
}
|
|
35336
|
-
const tblJustification = tblPr.elements.find((el) => el.name === "w:jc");
|
|
35337
|
-
if (tblJustification?.attributes) {
|
|
35338
|
-
attrs["justification"] = tblJustification.attributes["w:val"];
|
|
35339
|
-
}
|
|
35340
|
-
const rows = node2.elements.filter((el) => el.name === "w:tr");
|
|
35341
|
-
const refStylesBorders = referencedStyles?.borders || {};
|
|
35342
|
-
const refStylesRowBorders = referencedStyles?.rowBorders || {};
|
|
35343
|
-
const borderData = Object.keys(borders)?.length ? Object.assign(refStylesBorders, borders) : refStylesBorders;
|
|
35344
|
-
const borderRowData = Object.keys(rowBorders)?.length ? Object.assign(refStylesRowBorders, rowBorders) : refStylesRowBorders;
|
|
35345
|
-
attrs["borders"] = borderData;
|
|
35346
|
-
const content = [];
|
|
35347
|
-
rows.forEach((row) => {
|
|
35348
|
-
const result = handleTableRowNode(row, node2, borderRowData, tblStyleTag, params2);
|
|
35349
|
-
if (result.content?.length) content.push(result);
|
|
35350
|
-
});
|
|
35351
|
-
return {
|
|
35352
|
-
type: "table",
|
|
35353
|
-
content,
|
|
35354
|
-
attrs
|
|
35355
|
-
};
|
|
35356
|
-
}
|
|
35357
|
-
function handleTableCellNode(node2, row, table, rowBorders, columnWidth = null, styleTag, params2, columnIndex) {
|
|
35358
|
-
const { docx, nodeListHandler: nodeListHandler2 } = params2;
|
|
35359
|
-
const tcPr = node2.elements.find((el) => el.name === "w:tcPr");
|
|
35360
|
-
const borders = tcPr?.elements?.find((el) => el.name === "w:tcBorders");
|
|
35361
|
-
const inlineBorders = processInlineCellBorders(borders, rowBorders);
|
|
35362
|
-
const gridColumnWidths = getGridColumnWidths(table);
|
|
35363
|
-
const tcWidth = tcPr?.elements?.find((el) => el.name === "w:tcW");
|
|
35364
|
-
let width = tcWidth ? twipsToPixels(tcWidth.attributes["w:w"]) : null;
|
|
35365
|
-
const widthType = tcWidth?.attributes["w:type"];
|
|
35366
|
-
if (!width && columnWidth) width = columnWidth;
|
|
35367
|
-
const vMerge = getTableCellMergeTag(node2);
|
|
35368
|
-
const { attributes: vMergeAttrs } = vMerge || {};
|
|
35369
|
-
const backgroundColor = tcPr?.elements?.find((el) => el.name === "w:shd");
|
|
35370
|
-
const background = {
|
|
35371
|
-
color: backgroundColor?.attributes["w:fill"]
|
|
35372
|
-
};
|
|
35373
|
-
const colspanTag = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
35374
|
-
const colspan = colspanTag?.attributes["w:val"];
|
|
35375
|
-
const marginTag = tcPr?.elements?.find((el) => el.name === "w:tcMar");
|
|
35376
|
-
const verticalAlignTag = tcPr?.elements?.find((el) => el.name === "w:vAlign");
|
|
35377
|
-
const verticalAlign = verticalAlignTag?.attributes["w:val"] || "top";
|
|
35378
|
-
const attributes = {};
|
|
35379
|
-
const referencedStyles = getReferencedTableStyles(styleTag, docx) || {};
|
|
35380
|
-
attributes.cellMargins = getTableCellMargins(marginTag, referencedStyles);
|
|
35381
|
-
const { fontSize: fontSize2, fonts = {} } = referencedStyles;
|
|
35382
|
-
const fontFamily2 = fonts["ascii"];
|
|
35383
|
-
if (width) {
|
|
35384
|
-
attributes["colwidth"] = [width];
|
|
35385
|
-
attributes["widthUnit"] = "px";
|
|
35386
|
-
const defaultColWidths = gridColumnWidths;
|
|
35387
|
-
const hasDefaultColWidths = gridColumnWidths && gridColumnWidths.length > 0;
|
|
35388
|
-
const colspanNum = parseInt(colspan || 1, 10);
|
|
35389
|
-
if (colspanNum && colspanNum > 1 && hasDefaultColWidths) {
|
|
35390
|
-
let colwidth = [];
|
|
35391
|
-
for (let i2 = 0; i2 < colspanNum; i2++) {
|
|
35392
|
-
let colwidthValue = defaultColWidths[columnIndex + i2];
|
|
35393
|
-
let defaultColwidth = 100;
|
|
35394
|
-
if (typeof colwidthValue !== "undefined") {
|
|
35395
|
-
colwidth.push(colwidthValue);
|
|
35396
|
-
} else {
|
|
35397
|
-
colwidth.push(defaultColwidth);
|
|
35398
|
-
}
|
|
35399
|
-
}
|
|
35400
|
-
if (colwidth.length) {
|
|
35401
|
-
attributes["colwidth"] = [...colwidth];
|
|
35402
|
-
}
|
|
35403
|
-
}
|
|
35404
|
-
}
|
|
35405
|
-
if (widthType) attributes["widthType"] = widthType;
|
|
35406
|
-
if (colspan) attributes["colspan"] = parseInt(colspan, 10);
|
|
35407
|
-
if (background) attributes["background"] = background;
|
|
35408
|
-
attributes["verticalAlign"] = verticalAlign;
|
|
35409
|
-
if (fontSize2) attributes["fontSize"] = fontSize2;
|
|
35410
|
-
if (fontFamily2) attributes["fontFamily"] = fontFamily2["ascii"];
|
|
35411
|
-
if (rowBorders) attributes["borders"] = { ...rowBorders };
|
|
35412
|
-
if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"] || {}, inlineBorders);
|
|
35413
|
-
if (vMergeAttrs && vMergeAttrs["w:val"] === "restart") {
|
|
35414
|
-
const rows = table.elements.filter((el) => el.name === "w:tr");
|
|
35415
|
-
const currentRowIndex = rows.findIndex((r2) => r2 === row);
|
|
35416
|
-
const remainingRows = rows.slice(currentRowIndex + 1);
|
|
35417
|
-
const cellsInRow = row.elements.filter((el) => el.name === "w:tc");
|
|
35418
|
-
let cellIndex = cellsInRow.findIndex((el) => el === node2);
|
|
35419
|
-
let rowspan = 1;
|
|
35420
|
-
for (let remainingRow of remainingRows) {
|
|
35421
|
-
const firstCell = remainingRow.elements.findIndex((el) => el.name === "w:tc");
|
|
35422
|
-
const cellAtIndex = remainingRow.elements[firstCell + cellIndex];
|
|
35423
|
-
if (!cellAtIndex) break;
|
|
35424
|
-
const vMerge2 = getTableCellMergeTag(cellAtIndex);
|
|
35425
|
-
const { attributes: currentCellMergeAttrs } = vMerge2 || {};
|
|
35426
|
-
if (!vMerge2 && !currentCellMergeAttrs || currentCellMergeAttrs && currentCellMergeAttrs["w:val"] === "restart") {
|
|
35427
|
-
break;
|
|
35428
|
-
}
|
|
35429
|
-
rowspan++;
|
|
35430
|
-
remainingRow.elements.splice(firstCell + cellIndex, 1);
|
|
35431
|
-
}
|
|
35432
|
-
attributes["rowspan"] = rowspan;
|
|
35433
|
-
}
|
|
35434
|
-
return {
|
|
35435
|
-
type: "tableCell",
|
|
35436
|
-
content: nodeListHandler2.handler({ ...params2, nodes: node2.elements }),
|
|
35437
|
-
attrs: attributes
|
|
35438
|
-
};
|
|
35439
|
-
}
|
|
35440
|
-
const getTableCellMergeTag = (node2) => {
|
|
35441
|
-
const tcPr = node2.elements.find((el) => el.name === "w:tcPr");
|
|
35442
|
-
const vMerge = tcPr?.elements?.find((el) => el.name === "w:vMerge");
|
|
35443
|
-
return vMerge;
|
|
35444
|
-
};
|
|
35445
|
-
const processBorder = (borders, direction, rowBorders = {}) => {
|
|
35446
|
-
const borderAttrs = borders?.elements?.find((el) => el.name === `w:${direction}`)?.attributes;
|
|
35447
|
-
if (borderAttrs && borderAttrs["w:val"] !== "nil") {
|
|
35448
|
-
const border = {};
|
|
35449
|
-
const color = borderAttrs["w:color"];
|
|
35450
|
-
if (color) border["color"] = color === "auto" ? "#000000" : `#${color}`;
|
|
35451
|
-
const size2 = borderAttrs["w:sz"];
|
|
35452
|
-
if (size2) border["size"] = eigthPointsToPixels(size2);
|
|
35453
|
-
return border;
|
|
35454
|
-
}
|
|
35455
|
-
if (borderAttrs && borderAttrs["w:val"] === "nil") {
|
|
35456
|
-
const border = Object.assign({}, rowBorders[direction] || {});
|
|
35457
|
-
if (!Object.keys(border)) return null;
|
|
35458
|
-
border["val"] = "none";
|
|
35459
|
-
return border;
|
|
35460
|
-
}
|
|
35461
|
-
return null;
|
|
35462
|
-
};
|
|
35463
|
-
const processInlineCellBorders = (borders, rowBorders) => {
|
|
35464
|
-
if (!borders) return null;
|
|
35465
|
-
const processedBorders = {};
|
|
35466
|
-
const inlineBorderBottom = processBorder(borders, "bottom", rowBorders);
|
|
35467
|
-
if (inlineBorderBottom) processedBorders["bottom"] = inlineBorderBottom;
|
|
35468
|
-
const inlineBorderTop = processBorder(borders, "top", rowBorders);
|
|
35469
|
-
if (inlineBorderTop) processedBorders["top"] = inlineBorderTop;
|
|
35470
|
-
const inlineBorderLeft = processBorder(borders, "left", rowBorders);
|
|
35471
|
-
if (inlineBorderLeft) processedBorders["left"] = inlineBorderLeft;
|
|
35472
|
-
const inlineBorderRight = processBorder(borders, "right", rowBorders);
|
|
35473
|
-
if (inlineBorderRight) processedBorders["right"] = inlineBorderRight;
|
|
35474
|
-
return processedBorders;
|
|
35475
|
-
};
|
|
35476
|
-
function getReferencedTableStyles(tblStyleTag, docx) {
|
|
35477
|
-
if (!tblStyleTag) return null;
|
|
35478
|
-
const stylesToReturn = {};
|
|
35479
|
-
const { attributes = {} } = tblStyleTag;
|
|
35480
|
-
const tableStyleReference = attributes["w:val"];
|
|
35481
|
-
if (!tableStyleReference) return null;
|
|
35482
|
-
const styles = docx["word/styles.xml"];
|
|
35483
|
-
const { elements } = styles.elements[0];
|
|
35484
|
-
const styleElements = elements.filter((el) => el.name === "w:style");
|
|
35485
|
-
const styleTag = styleElements.find((el) => el.attributes["w:styleId"] === tableStyleReference);
|
|
35486
|
-
if (!styleTag) return null;
|
|
35487
|
-
stylesToReturn.name = styleTag.elements.find((el) => el.name === "w:name");
|
|
35488
|
-
const basedOn = styleTag.elements.find((el) => el.name === "w:basedOn");
|
|
35489
|
-
let baseTblPr;
|
|
35490
|
-
if (basedOn?.attributes) {
|
|
35491
|
-
const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
|
|
35492
|
-
baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
|
|
35493
|
-
}
|
|
35494
|
-
const pPr = styleTag.elements.find((el) => el.name === "w:pPr");
|
|
35495
|
-
if (pPr) {
|
|
35496
|
-
const justification = pPr.elements.find((el) => el.name === "w:jc");
|
|
35497
|
-
if (justification?.attributes) stylesToReturn.justification = justification.attributes["w:val"];
|
|
35498
|
-
}
|
|
35499
|
-
const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
|
|
35500
|
-
if (rPr) {
|
|
35501
|
-
const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
|
|
35502
|
-
if (fonts) {
|
|
35503
|
-
const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
|
|
35504
|
-
stylesToReturn.fonts = { ascii, hAnsi, cs };
|
|
35505
|
-
}
|
|
35506
|
-
const fontSize2 = rPr.elements.find((el) => el.name === "w:sz");
|
|
35507
|
-
if (fontSize2?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize2.attributes["w:val"]) + "pt";
|
|
35508
|
-
}
|
|
35509
|
-
const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
|
|
35510
|
-
if (tblPr && tblPr.elements) {
|
|
35511
|
-
if (baseTblPr && baseTblPr.elements) {
|
|
35512
|
-
tblPr.elements.push(...baseTblPr.elements);
|
|
35513
|
-
}
|
|
35514
|
-
const tableBorders = tblPr?.elements?.find((el) => el.name === "w:tblBorders");
|
|
35515
|
-
const { elements: borderElements = [] } = tableBorders || {};
|
|
35516
|
-
const { borders, rowBorders } = processTableBorders(borderElements);
|
|
35517
|
-
if (borders) stylesToReturn.borders = borders;
|
|
35518
|
-
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
35519
|
-
const tableCellMargin = tblPr?.elements.find((el) => el.name === "w:tblCellMar");
|
|
35520
|
-
if (tableCellMargin) {
|
|
35521
|
-
const marginLeft = tableCellMargin.elements.find((el) => el.name === "w:left");
|
|
35522
|
-
const marginRight = tableCellMargin.elements.find((el) => el.name === "w:right");
|
|
35523
|
-
const marginTop = tableCellMargin.elements.find((el) => el.name === "w:top");
|
|
35524
|
-
const marginBottom = tableCellMargin.elements.find((el) => el.name === "w:bottom");
|
|
35525
|
-
stylesToReturn.cellMargins = {
|
|
35526
|
-
marginLeft: marginLeft?.attributes["w:w"],
|
|
35527
|
-
marginRight: marginRight?.attributes["w:w"],
|
|
35528
|
-
marginTop: marginTop?.attributes["w:w"],
|
|
35529
|
-
marginBottom: marginBottom?.attributes["w:w"]
|
|
35530
|
-
};
|
|
35531
|
-
}
|
|
35532
|
-
}
|
|
35533
|
-
return stylesToReturn;
|
|
35534
|
-
}
|
|
35535
|
-
function processTableBorders(borderElements) {
|
|
35536
|
-
const borders = {};
|
|
35537
|
-
const rowBorders = {};
|
|
35538
|
-
borderElements.forEach((borderElement) => {
|
|
35539
|
-
const { name } = borderElement;
|
|
35540
|
-
const borderName = name.split("w:")[1];
|
|
35541
|
-
const { attributes } = borderElement;
|
|
35542
|
-
const attrs = {};
|
|
35543
|
-
const color = attributes["w:color"];
|
|
35544
|
-
const size2 = attributes["w:sz"];
|
|
35545
|
-
if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
|
|
35546
|
-
if (size2 && size2 !== "auto") attrs["size"] = eigthPointsToPixels(size2);
|
|
35547
|
-
const rowBorderNames = ["insideH", "insideV"];
|
|
35548
|
-
if (rowBorderNames.includes(borderName)) rowBorders[borderName] = attrs;
|
|
35549
|
-
borders[borderName] = attrs;
|
|
35550
|
-
});
|
|
35551
|
-
return {
|
|
35552
|
-
borders,
|
|
35553
|
-
rowBorders
|
|
35554
|
-
};
|
|
35555
|
-
}
|
|
35556
|
-
function handleTableRowNode(node2, table, rowBorders, styleTag, params2) {
|
|
35557
|
-
const attrs = {};
|
|
35558
|
-
const tPr = node2.elements.find((el) => el.name === "w:trPr");
|
|
35559
|
-
const rowHeightTag = tPr?.elements?.find((el) => el.name === "w:trHeight");
|
|
35560
|
-
const rowHeight = rowHeightTag?.attributes["w:val"];
|
|
35561
|
-
const cantSplitTag = tPr?.elements?.find((el) => el.name === "w:cantSplit");
|
|
35562
|
-
if (cantSplitTag) {
|
|
35563
|
-
attrs["cantSplit"] = true;
|
|
35564
|
-
}
|
|
35565
|
-
const borders = {};
|
|
35566
|
-
if (rowBorders?.insideH) borders["bottom"] = rowBorders.insideH;
|
|
35567
|
-
if (rowBorders?.insideV) borders["right"] = rowBorders.insideV;
|
|
35568
|
-
attrs["borders"] = borders;
|
|
35569
|
-
if (rowHeight) {
|
|
35570
|
-
attrs["rowHeight"] = twipsToPixels(rowHeight);
|
|
35571
|
-
}
|
|
35572
|
-
const gridColumnWidths = getGridColumnWidths(table);
|
|
35573
|
-
const cellNodes = node2.elements.filter((el) => el.name === "w:tc");
|
|
35574
|
-
let currentColumnIndex = 0;
|
|
35575
|
-
const content = cellNodes?.map((n) => {
|
|
35576
|
-
let colWidth = gridColumnWidths?.[currentColumnIndex] || null;
|
|
35577
|
-
const result = handleTableCellNode(n, node2, table, borders, colWidth, styleTag, params2, currentColumnIndex);
|
|
35578
|
-
const tcPr = n.elements?.find((el) => el.name === "w:tcPr");
|
|
35579
|
-
const colspanTag = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
35580
|
-
const colspan = parseInt(colspanTag?.attributes["w:val"] || 1, 10);
|
|
35581
|
-
currentColumnIndex += colspan;
|
|
35582
|
-
return result;
|
|
35583
|
-
}) || [];
|
|
35584
|
-
const newNode = {
|
|
35585
|
-
type: "tableRow",
|
|
35586
|
-
content,
|
|
35587
|
-
attrs
|
|
35588
|
-
};
|
|
35589
|
-
return newNode;
|
|
35590
|
-
}
|
|
35591
|
-
const getTableCellMargins = (marginTag, referencedStyles) => {
|
|
35592
|
-
const inlineMarginLeftTag = marginTag?.elements?.find((el) => el.name === "w:left");
|
|
35593
|
-
const inlineMarginRightTag = marginTag?.elements?.find((el) => el.name === "w:right");
|
|
35594
|
-
const inlineMarginTopTag = marginTag?.elements?.find((el) => el.name === "w:top");
|
|
35595
|
-
const inlineMarginBottomTag = marginTag?.elements?.find((el) => el.name === "w:bottom");
|
|
35596
|
-
const inlineMarginLeftValue = inlineMarginLeftTag?.attributes["w:w"];
|
|
35597
|
-
const inlineMarginRightValue = inlineMarginRightTag?.attributes["w:w"];
|
|
35598
|
-
const inlineMarginTopValue = inlineMarginTopTag?.attributes["w:w"];
|
|
35599
|
-
const inlineMarginBottomValue = inlineMarginBottomTag?.attributes["w:w"];
|
|
35600
|
-
const { cellMargins = {} } = referencedStyles;
|
|
35601
|
-
const {
|
|
35602
|
-
marginLeft: marginLeftStyle,
|
|
35603
|
-
marginRight: marginRightStyle,
|
|
35604
|
-
marginTop: marginTopStyle,
|
|
35605
|
-
marginBottom: marginBottomStyle
|
|
35606
|
-
} = cellMargins;
|
|
35607
|
-
const margins = {
|
|
35608
|
-
left: twipsToPixels(inlineMarginLeftValue ?? marginLeftStyle),
|
|
35609
|
-
right: twipsToPixels(inlineMarginRightValue ?? marginRightStyle),
|
|
35610
|
-
top: twipsToPixels(inlineMarginTopValue ?? marginTopStyle),
|
|
35611
|
-
bottom: twipsToPixels(inlineMarginBottomValue ?? marginBottomStyle)
|
|
35612
|
-
};
|
|
35613
|
-
return margins;
|
|
35614
|
-
};
|
|
35615
|
-
const getGridColumnWidths = (tableNode) => {
|
|
35616
|
-
const tblGrid = tableNode.elements.find((el) => el.name === "w:tblGrid");
|
|
35617
|
-
if (!tblGrid) return [];
|
|
35618
|
-
const columnWidths = tblGrid?.elements?.flatMap((el) => {
|
|
35619
|
-
if (el.name !== "w:gridCol") return [];
|
|
35620
|
-
return twipsToPixels(el.attributes["w:w"]);
|
|
35621
|
-
}) || [];
|
|
35622
|
-
return columnWidths;
|
|
35623
|
-
};
|
|
35624
35715
|
const handleDrawingNode = (params2) => {
|
|
35625
35716
|
const { nodes, filename } = params2;
|
|
35626
35717
|
const validNodes = ["w:drawing", "w:p"];
|
|
@@ -35762,7 +35853,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35762
35853
|
const translatedElement = nodeListHandler2.handler({
|
|
35763
35854
|
...params2,
|
|
35764
35855
|
node: textBoxContent.elements[0],
|
|
35765
|
-
nodes: textBoxContent.elements
|
|
35856
|
+
nodes: textBoxContent.elements,
|
|
35857
|
+
path: [...params2.path || [], textBoxContent]
|
|
35766
35858
|
});
|
|
35767
35859
|
return translatedElement[0];
|
|
35768
35860
|
};
|
|
@@ -36025,7 +36117,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36025
36117
|
}
|
|
36026
36118
|
const { name } = node2;
|
|
36027
36119
|
const { attributes, elements } = parseProperties(node2);
|
|
36028
|
-
const subs = nodeListHandler2.handler({
|
|
36120
|
+
const subs = nodeListHandler2.handler({
|
|
36121
|
+
...params2,
|
|
36122
|
+
insideTrackChange: true,
|
|
36123
|
+
nodes: elements,
|
|
36124
|
+
path: [...params2.path || [], node2]
|
|
36125
|
+
});
|
|
36029
36126
|
const changeType = name === "w:del" ? TrackDeleteMarkName : TrackInsertMarkName;
|
|
36030
36127
|
const mappedAttributes = {
|
|
36031
36128
|
id: attributes["w:id"],
|
|
@@ -36084,7 +36181,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36084
36181
|
}
|
|
36085
36182
|
}
|
|
36086
36183
|
}
|
|
36087
|
-
const updatedNode = nodeListHandler2.handler({
|
|
36184
|
+
const updatedNode = nodeListHandler2.handler({
|
|
36185
|
+
...params2,
|
|
36186
|
+
nodes: runNodes,
|
|
36187
|
+
path: [...params2.path || [], node2]
|
|
36188
|
+
});
|
|
36088
36189
|
return { nodes: updatedNode, consumed: 1 };
|
|
36089
36190
|
};
|
|
36090
36191
|
const hyperlinkNodeHandlerEntity = {
|
|
@@ -36097,7 +36198,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36097
36198
|
return { nodes: [], consumed: 0 };
|
|
36098
36199
|
}
|
|
36099
36200
|
const node2 = nodes[0];
|
|
36100
|
-
const childParams = { ...params2, nodes: node2.elements };
|
|
36201
|
+
const childParams = { ...params2, nodes: node2.elements, path: [...params2.path || [], node2] };
|
|
36101
36202
|
let processedRun = nodeListHandler2.handler(childParams)?.filter((n) => n) || [];
|
|
36102
36203
|
const hasRunProperties = node2.elements?.some((el) => el.name === "w:rPr");
|
|
36103
36204
|
const defaultNodeStyles = getMarksFromStyles(docx, parentStyleId);
|
|
@@ -36907,7 +37008,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36907
37008
|
const sdtContent = node2.elements.find((el) => el.name === "w:sdtContent");
|
|
36908
37009
|
const par = sdtContent?.elements?.find((el) => el.name === "w:p");
|
|
36909
37010
|
const { marks } = parseAnnotationMarks(sdtContent);
|
|
36910
|
-
const translatedContent = nodeListHandler2.handler({
|
|
37011
|
+
const translatedContent = nodeListHandler2.handler({
|
|
37012
|
+
...params2,
|
|
37013
|
+
nodes: sdtContent?.elements,
|
|
37014
|
+
path: [...params2.path || [], node2]
|
|
37015
|
+
});
|
|
36911
37016
|
let structuredContentType = "structuredContent";
|
|
36912
37017
|
if (par) {
|
|
36913
37018
|
structuredContentType = "structuredContentBlock";
|
|
@@ -36935,7 +37040,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36935
37040
|
const title = titleTag?.attributes?.["w:val"] || tagValue.title || null;
|
|
36936
37041
|
const { description } = tagValue;
|
|
36937
37042
|
const sdtContent = node2.elements.find((el) => el.name === "w:sdtContent");
|
|
36938
|
-
const translatedContent = nodeListHandler2.handler({
|
|
37043
|
+
const translatedContent = nodeListHandler2.handler({
|
|
37044
|
+
...params2,
|
|
37045
|
+
nodes: sdtContent?.elements,
|
|
37046
|
+
path: [...params2.path || [], node2]
|
|
37047
|
+
});
|
|
36939
37048
|
const result = {
|
|
36940
37049
|
type: "documentSection",
|
|
36941
37050
|
content: translatedContent,
|
|
@@ -36999,7 +37108,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36999
37108
|
el.marks.push(...marks);
|
|
37000
37109
|
return el;
|
|
37001
37110
|
});
|
|
37002
|
-
const childParams = {
|
|
37111
|
+
const childParams = {
|
|
37112
|
+
...params2,
|
|
37113
|
+
nodes: updatedElements,
|
|
37114
|
+
parentStyleId,
|
|
37115
|
+
path: [...params2.path || [], node2]
|
|
37116
|
+
};
|
|
37003
37117
|
const childContent = nodeListHandler2.handler(childParams);
|
|
37004
37118
|
content.push(...childContent);
|
|
37005
37119
|
}
|
|
@@ -37025,7 +37139,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37025
37139
|
if (nodes.length === 0 || nodes[0].name !== "w:br") {
|
|
37026
37140
|
return { nodes: [], consumed: 0 };
|
|
37027
37141
|
}
|
|
37028
|
-
const result = translator$
|
|
37142
|
+
const result = translator$2.encode(params2);
|
|
37029
37143
|
if (!result) return { nodes: [], consumed: 0 };
|
|
37030
37144
|
return {
|
|
37031
37145
|
nodes: [result],
|
|
@@ -37065,7 +37179,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37065
37179
|
attrs[key] = value;
|
|
37066
37180
|
}
|
|
37067
37181
|
});
|
|
37068
|
-
const translatedText = nodeListHandler3.handler({
|
|
37182
|
+
const translatedText = nodeListHandler3.handler({
|
|
37183
|
+
...params2,
|
|
37184
|
+
nodes: textNodes,
|
|
37185
|
+
path: [...params2.path || [], node2]
|
|
37186
|
+
});
|
|
37069
37187
|
translatedText.forEach((n) => {
|
|
37070
37188
|
n.marks.push({
|
|
37071
37189
|
type: customMark.name,
|
|
@@ -37113,7 +37231,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37113
37231
|
const contents = wpsNode.elements;
|
|
37114
37232
|
const result = nodeListHandler2.handler({
|
|
37115
37233
|
...params2,
|
|
37116
|
-
nodes: contents
|
|
37234
|
+
nodes: contents,
|
|
37235
|
+
path: [...params2.path || [], wpsNode]
|
|
37117
37236
|
});
|
|
37118
37237
|
return { nodes: result, consumed: 1 };
|
|
37119
37238
|
};
|
|
@@ -37407,7 +37526,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37407
37526
|
nodeListHandler: nodeListHandler2,
|
|
37408
37527
|
docx,
|
|
37409
37528
|
editor,
|
|
37410
|
-
converter
|
|
37529
|
+
converter,
|
|
37530
|
+
path: [el]
|
|
37411
37531
|
});
|
|
37412
37532
|
const { attrs } = parsedComment[0];
|
|
37413
37533
|
const paraId = attrs["w14:paraId"];
|
|
@@ -37463,7 +37583,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37463
37583
|
if (!nodes.length || nodes[0].name !== "w:tab") {
|
|
37464
37584
|
return { nodes: [], consumed: 0 };
|
|
37465
37585
|
}
|
|
37466
|
-
const node2 = translator.encode(params2);
|
|
37586
|
+
const node2 = translator$1.encode(params2);
|
|
37467
37587
|
return { nodes: [node2], consumed: 1 };
|
|
37468
37588
|
};
|
|
37469
37589
|
const tabNodeEntityHandler = {
|
|
@@ -37508,7 +37628,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37508
37628
|
docx,
|
|
37509
37629
|
converter,
|
|
37510
37630
|
editor,
|
|
37511
|
-
lists
|
|
37631
|
+
lists,
|
|
37632
|
+
path: []
|
|
37512
37633
|
});
|
|
37513
37634
|
const result = {
|
|
37514
37635
|
type: "doc",
|
|
@@ -37588,7 +37709,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37588
37709
|
editor,
|
|
37589
37710
|
filename,
|
|
37590
37711
|
parentStyleId,
|
|
37591
|
-
lists
|
|
37712
|
+
lists,
|
|
37713
|
+
path = []
|
|
37592
37714
|
}) => {
|
|
37593
37715
|
if (!elements || !elements.length) return [];
|
|
37594
37716
|
const filteredElements = pruneIgnoredNodes(elements);
|
|
@@ -37613,7 +37735,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37613
37735
|
editor,
|
|
37614
37736
|
filename,
|
|
37615
37737
|
parentStyleId,
|
|
37616
|
-
lists
|
|
37738
|
+
lists,
|
|
37739
|
+
path
|
|
37617
37740
|
});
|
|
37618
37741
|
},
|
|
37619
37742
|
{ nodes: [], consumed: 0 }
|
|
@@ -37790,7 +37913,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37790
37913
|
docx,
|
|
37791
37914
|
converter,
|
|
37792
37915
|
editor,
|
|
37793
|
-
filename: currentFileName
|
|
37916
|
+
filename: currentFileName,
|
|
37917
|
+
path: []
|
|
37794
37918
|
});
|
|
37795
37919
|
if (!converter.headerIds.ids) converter.headerIds.ids = [];
|
|
37796
37920
|
converter.headerIds.ids.push(rId);
|
|
@@ -37812,7 +37936,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37812
37936
|
docx,
|
|
37813
37937
|
converter,
|
|
37814
37938
|
editor,
|
|
37815
|
-
filename: currentFileName
|
|
37939
|
+
filename: currentFileName,
|
|
37940
|
+
path: []
|
|
37816
37941
|
});
|
|
37817
37942
|
if (!converter.footerIds.ids) converter.footerIds.ids = [];
|
|
37818
37943
|
converter.footerIds.ids.push(rId);
|
|
@@ -38067,7 +38192,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
38067
38192
|
return;
|
|
38068
38193
|
}
|
|
38069
38194
|
}
|
|
38070
|
-
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.17.
|
|
38195
|
+
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.17.1") {
|
|
38071
38196
|
const customLocation = "docProps/custom.xml";
|
|
38072
38197
|
if (!docx[customLocation]) {
|
|
38073
38198
|
docx[customLocation] = generateCustomXml();
|
|
@@ -38549,7 +38674,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
38549
38674
|
function generateCustomXml() {
|
|
38550
38675
|
return DEFAULT_CUSTOM_XML;
|
|
38551
38676
|
}
|
|
38552
|
-
function generateSuperdocVersion(pid = 2, version2 = "0.17.
|
|
38677
|
+
function generateSuperdocVersion(pid = 2, version2 = "0.17.1") {
|
|
38553
38678
|
return {
|
|
38554
38679
|
type: "element",
|
|
38555
38680
|
name: "property",
|
|
@@ -55409,7 +55534,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
55409
55534
|
* @returns {Object | void} Migration results
|
|
55410
55535
|
*/
|
|
55411
55536
|
processCollaborationMigrations() {
|
|
55412
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.17.
|
|
55537
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.17.1");
|
|
55413
55538
|
if (!this.options.ydoc) return;
|
|
55414
55539
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
55415
55540
|
let docVersion = metaMap.get("version");
|
|
@@ -88291,8 +88416,8 @@ ${style2}
|
|
|
88291
88416
|
};
|
|
88292
88417
|
const SuperInput = /* @__PURE__ */ _export_sfc$1(_sfc_main$i, [["__scopeId", "data-v-4d5cff52"]]);
|
|
88293
88418
|
const registeredHandlers = Object.freeze({
|
|
88294
|
-
"w:br": translator$
|
|
88295
|
-
"w:tab": translator
|
|
88419
|
+
"w:br": translator$2,
|
|
88420
|
+
"w:tab": translator$1
|
|
88296
88421
|
});
|
|
88297
88422
|
const Extensions = {
|
|
88298
88423
|
Node: Node$1,
|
|
@@ -105450,7 +105575,7 @@ ${style2}
|
|
|
105450
105575
|
this.config.colors = shuffleArray(this.config.colors);
|
|
105451
105576
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
105452
105577
|
this.colorIndex = 0;
|
|
105453
|
-
this.version = "0.17.
|
|
105578
|
+
this.version = "0.17.1";
|
|
105454
105579
|
this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
105455
105580
|
this.superdocId = config2.superdocId || v4();
|
|
105456
105581
|
this.colors = this.config.colors;
|