@harbour-enterprises/superdoc 0.20.0-next.9 → 0.20.0
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-BqGjx7hC.cjs → PdfViewer--8KwZWwP.cjs} +1 -1
- package/dist/chunks/{PdfViewer-BZlsmhsJ.es.js → PdfViewer-SpPk10jl.es.js} +1 -1
- package/dist/chunks/{index-4GToG3C3.es.js → index-BjLjS5O9.es.js} +3 -3
- package/dist/chunks/{index-DPzgGSfg.cjs → index-yRUOdLmp.cjs} +3 -3
- package/dist/chunks/{super-editor.es-BkxUKZfn.cjs → super-editor.es-CuNhawtn.cjs} +2505 -3347
- package/dist/chunks/{super-editor.es-DqX3Ipsk.es.js → super-editor.es-D24_Ox1u.es.js} +2505 -3347
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/style.css +0 -38
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-C6YOTAXG.js → converter-Cg4SgA5y.js} +1119 -1659
- package/dist/super-editor/chunks/{docx-zipper-CSiwWpmr.js → docx-zipper-CDX2fnxb.js} +2 -2
- package/dist/super-editor/chunks/{editor-chVid4VD.js → editor-MKuu81v8.js} +1048 -1339
- package/dist/super-editor/chunks/{toolbar-ancqgN0p.js → toolbar-CpQ7L2K-.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/helpers/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/exporter.d.ts +1 -7
- package/dist/super-editor/src/core/super-converter/helpers.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v2/importer/imageImporter.d.ts +1 -1
- package/dist/super-editor/src/core/super-converter/v2/importer/tableImporter.d.ts +22 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/utils.d.ts +3 -10
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/w-p-helpers.d.ts +1 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/legacy-handle-table-cell-node.d.ts +1 -1
- package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +1 -11
- package/dist/super-editor/src/extensions/block-node/block-node.d.ts +5 -30
- package/dist/super-editor/src/extensions/bold/bold.d.ts +0 -20
- package/dist/super-editor/src/extensions/bullet-list/bullet-list.d.ts +0 -12
- package/dist/super-editor/src/extensions/color/color.d.ts +0 -26
- package/dist/super-editor/src/extensions/content-block/content-block.d.ts +0 -30
- package/dist/super-editor/src/extensions/custom-selection/custom-selection.d.ts +0 -16
- package/dist/super-editor/src/extensions/document/document.d.ts +0 -26
- package/dist/super-editor/src/extensions/dropcursor/dropcursor.d.ts +0 -26
- package/dist/super-editor/src/extensions/font-family/font-family.d.ts +0 -29
- package/dist/super-editor/src/extensions/font-size/font-size.d.ts +0 -21
- package/dist/super-editor/src/extensions/format-commands/format-commands.d.ts +0 -9
- package/dist/super-editor/src/extensions/gapcursor/gapcursor.d.ts +0 -9
- package/dist/super-editor/src/extensions/heading/heading.d.ts +6 -12
- package/dist/super-editor/src/extensions/highlight/highlight.d.ts +0 -20
- package/dist/super-editor/src/extensions/history/history.d.ts +15 -7
- package/dist/super-editor/src/extensions/image/image.d.ts +0 -78
- package/dist/super-editor/src/extensions/image/imageHelpers/imagePlaceholderPlugin.d.ts +5 -0
- package/dist/super-editor/src/extensions/image/imageHelpers/index.d.ts +1 -3
- package/dist/super-editor/src/extensions/image/imageHelpers/processUploadedImage.d.ts +2 -2
- package/dist/super-editor/src/extensions/image/imageHelpers/startImageUpload.d.ts +23 -18
- package/dist/super-editor/src/extensions/italic/italic.d.ts +0 -10
- package/dist/super-editor/src/extensions/line-break/line-break.d.ts +0 -43
- package/dist/super-editor/src/extensions/line-height/line-height.d.ts +0 -22
- package/dist/super-editor/src/extensions/link/link.d.ts +25 -53
- package/dist/super-editor/src/extensions/linked-styles/linked-styles.d.ts +0 -9
- package/dist/super-editor/src/extensions/list-item/list-item.d.ts +0 -48
- package/dist/super-editor/src/extensions/mention/mention.d.ts +0 -26
- package/dist/super-editor/src/extensions/noderesizer/noderesizer.d.ts +0 -14
- package/dist/super-editor/src/extensions/ordered-list/ordered-list.d.ts +0 -35
- package/dist/super-editor/src/extensions/page-number/page-number.d.ts +0 -52
- package/dist/super-editor/src/extensions/paragraph/paragraph.d.ts +0 -49
- package/dist/super-editor/src/extensions/placeholder/placeholder.d.ts +0 -15
- package/dist/super-editor/src/extensions/popover-plugin/popover-plugin.d.ts +0 -9
- package/dist/super-editor/src/extensions/run-item/run-item.d.ts +0 -24
- package/dist/super-editor/src/extensions/search/search.d.ts +2 -11
- package/dist/super-editor/src/extensions/shape-container/shape-container.d.ts +0 -29
- package/dist/super-editor/src/extensions/shape-textbox/shape-textbox.d.ts +0 -26
- package/dist/super-editor/src/extensions/slash-menu/slash-menu.d.ts +0 -9
- package/dist/super-editor/src/extensions/strike/strike.d.ts +0 -10
- package/dist/super-editor/src/extensions/structured-content/document-section.d.ts +27 -46
- package/dist/super-editor/src/extensions/structured-content/structured-content-block.d.ts +1 -29
- package/dist/super-editor/src/extensions/structured-content/structured-content.d.ts +1 -29
- package/dist/super-editor/src/extensions/tab/tab.d.ts +0 -25
- package/dist/super-editor/src/extensions/table/table.d.ts +55 -376
- package/dist/super-editor/src/extensions/table-cell/table-cell.d.ts +0 -41
- package/dist/super-editor/src/extensions/table-header/table-header.d.ts +0 -22
- package/dist/super-editor/src/extensions/table-row/table-row.d.ts +0 -28
- package/dist/super-editor/src/extensions/text/text.d.ts +0 -14
- package/dist/super-editor/src/extensions/text-align/text-align.d.ts +0 -22
- package/dist/super-editor/src/extensions/text-indent/text-indent.d.ts +10 -19
- package/dist/super-editor/src/extensions/text-style/text-style.d.ts +0 -20
- package/dist/super-editor/src/extensions/text-transform/text-transform.d.ts +0 -20
- package/dist/super-editor/src/extensions/underline/underline.d.ts +0 -25
- package/dist/super-editor/style.css +0 -38
- package/dist/super-editor/super-editor.es.js +55 -65
- 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 +3134 -3976
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/super-editor/src/core/helpers/updateDOMAttributes.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/export-helpers/pre-process-vertical-merge-cells.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/helpers/mediaHelpers.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bidiVisual/bidiVisual-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bidiVisual/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/bottom-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/marginBottom-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/drawing/drawing-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/drawing/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/end-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/marginEnd-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/gridCol/gridCol-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/gridCol/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideH/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideH/insideH-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideV/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideV/insideV-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/left-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/marginLeft-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/marginRight-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/right-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/shd/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/shd/shd-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/marginStart-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/start-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tbl/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tbl/tbl-translator.d.ts +0 -28
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblBorders/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblBorders/tblBorders-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCaption/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCaption/tblCaption-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCellMar/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCellMar/tblCellMar-translator.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblDescription/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblDescription/tblDescription-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-helpers.d.ts +0 -5
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-translator.d.ts +0 -5
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblInd/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblInd/tblInd-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLayout/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLayout/tblLayout-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLook/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLook/tblLook-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblOverlap/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblOverlap/tblOverlap-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblPr/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblPr/tblPr-translator.d.ts +0 -5
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyle/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyle/tblStyle-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleColBandSize/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleColBandSize/tblStyleColBandSize-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleRowBandSize/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleRowBandSize/tblStyleRowBandSize-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblW/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblW/tblW-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblpPr/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblpPr/tblpPr-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/marginTop-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/top-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/anchor-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/handle-anchor-node.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/translate-anchor-node.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/decode-image-node-helpers.d.ts +0 -18
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/encode-image-node-helpers.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/helpers/handle-inline-node.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/helpers/translate-inline-node.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/inline-translator.d.ts +0 -6
- package/dist/super-editor/src/extensions/image/imageHelpers/fileNameUtils.d.ts +0 -3
- package/dist/super-editor/src/extensions/image/imageHelpers/handleBase64.d.ts +0 -1
- package/dist/super-editor/src/extensions/image/imageHelpers/handleUrl.d.ts +0 -2
- package/dist/super-editor/src/extensions/image/imageHelpers/imageRegistrationPlugin.d.ts +0 -11
- package/dist/super-editor/src/extensions/image/imageHelpers/rotation.d.ts +0 -4
- package/dist/super-editor/src/extensions/structured-content/StructuredContentBlockView.d.ts +0 -9
- package/dist/super-editor/src/extensions/structured-content/StructuredContentInlineView.d.ts +0 -9
- package/dist/super-editor/src/extensions/structured-content/StructuredContentViewBase.d.ts +0 -24
- package/dist/super-editor/src/tests/helpers/editor-test-utils.d.ts +0 -14
|
@@ -14779,25 +14779,22 @@ async function readFromClipboard(state2) {
|
|
|
14779
14779
|
function inchesToTwips(inches) {
|
|
14780
14780
|
if (inches == null) return;
|
|
14781
14781
|
if (typeof inches === "string") inches = parseFloat(inches);
|
|
14782
|
-
return Math.round(
|
|
14782
|
+
return Math.round(inches * 1440);
|
|
14783
14783
|
}
|
|
14784
14784
|
function twipsToInches(twips) {
|
|
14785
14785
|
if (twips == null) return;
|
|
14786
|
-
|
|
14787
|
-
|
|
14788
|
-
return value / 1440;
|
|
14786
|
+
if (typeof twips === "string") twips = parseInt(twips, 10);
|
|
14787
|
+
return Math.round(twips / 1440 * 100) / 100;
|
|
14789
14788
|
}
|
|
14790
14789
|
function twipsToPixels(twips) {
|
|
14791
14790
|
if (twips == null) return;
|
|
14792
|
-
|
|
14793
|
-
|
|
14794
|
-
const pixels = inches * 96;
|
|
14795
|
-
return Math.round(pixels * 1e3) / 1e3;
|
|
14791
|
+
twips = twipsToInches(twips);
|
|
14792
|
+
return Math.round(twips * 96);
|
|
14796
14793
|
}
|
|
14797
14794
|
function pixelsToTwips(pixels) {
|
|
14798
14795
|
if (pixels == null) return;
|
|
14799
|
-
|
|
14800
|
-
return inchesToTwips(
|
|
14796
|
+
pixels = pixels / 96;
|
|
14797
|
+
return inchesToTwips(pixels);
|
|
14801
14798
|
}
|
|
14802
14799
|
function twipsToLines(twips) {
|
|
14803
14800
|
if (twips == null) return;
|
|
@@ -14840,14 +14837,6 @@ function ptToTwips(pt) {
|
|
|
14840
14837
|
if (pt == null) return;
|
|
14841
14838
|
return pt * 20;
|
|
14842
14839
|
}
|
|
14843
|
-
function rotToDegrees(rot) {
|
|
14844
|
-
if (rot == null) return;
|
|
14845
|
-
return rot / 6e4;
|
|
14846
|
-
}
|
|
14847
|
-
function degreesToRot(degrees) {
|
|
14848
|
-
if (degrees == null) return;
|
|
14849
|
-
return degrees * 6e4;
|
|
14850
|
-
}
|
|
14851
14840
|
const getTextIndentExportValue = (indent) => {
|
|
14852
14841
|
const [value, unit] = parseSizeUnit(indent);
|
|
14853
14842
|
const functionsMap = {
|
|
@@ -16403,6 +16392,41 @@ const prepareCommentsXmlFilesForExport = ({ convertedXml, defs, commentsWithPara
|
|
|
16403
16392
|
documentXml: updatedXml
|
|
16404
16393
|
};
|
|
16405
16394
|
};
|
|
16395
|
+
const getColStyleDeclaration = (minWidth, width) => {
|
|
16396
|
+
if (width) {
|
|
16397
|
+
return ["width", `${Math.max(width, minWidth)}px`];
|
|
16398
|
+
}
|
|
16399
|
+
return ["min-width", `${minWidth}px`];
|
|
16400
|
+
};
|
|
16401
|
+
const createColGroup = (node, cellMinWidth, overrideCol, overrideValue) => {
|
|
16402
|
+
let totalWidth = 0;
|
|
16403
|
+
let fixedWidth = true;
|
|
16404
|
+
const cols = [];
|
|
16405
|
+
const colsValues = [];
|
|
16406
|
+
const row = node.firstChild;
|
|
16407
|
+
if (!row) return {};
|
|
16408
|
+
for (let i = 0, col = 0; i < row.childCount; i++) {
|
|
16409
|
+
const { colspan, colwidth } = row.child(i).attrs;
|
|
16410
|
+
for (let j2 = 0; j2 < colspan; j2++, col++) {
|
|
16411
|
+
const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j2];
|
|
16412
|
+
totalWidth += hasWidth || cellMinWidth;
|
|
16413
|
+
if (!hasWidth) fixedWidth = false;
|
|
16414
|
+
const [prop, value] = getColStyleDeclaration(cellMinWidth, hasWidth);
|
|
16415
|
+
cols.push(["col", { style: `${prop}: ${value}` }]);
|
|
16416
|
+
colsValues.push(parseInt(value, 10));
|
|
16417
|
+
}
|
|
16418
|
+
}
|
|
16419
|
+
const tableWidth = fixedWidth ? `${totalWidth}px` : "";
|
|
16420
|
+
const tableMinWidth = fixedWidth ? "" : `${totalWidth}px`;
|
|
16421
|
+
const colgroup = ["colgroup", {}, ...cols];
|
|
16422
|
+
const colgroupValues = [...colsValues];
|
|
16423
|
+
return {
|
|
16424
|
+
colgroup,
|
|
16425
|
+
tableWidth,
|
|
16426
|
+
tableMinWidth,
|
|
16427
|
+
colgroupValues
|
|
16428
|
+
};
|
|
16429
|
+
};
|
|
16406
16430
|
const lower16 = 65535;
|
|
16407
16431
|
const factor16 = Math.pow(2, 16);
|
|
16408
16432
|
function makeRecover(index, offset) {
|
|
@@ -21347,7 +21371,7 @@ const isInTable = (state2) => {
|
|
|
21347
21371
|
};
|
|
21348
21372
|
function stripHtmlStyles(html) {
|
|
21349
21373
|
if (!html) return "";
|
|
21350
|
-
const parser = new
|
|
21374
|
+
const parser = new DOMParser();
|
|
21351
21375
|
const doc2 = parser.parseFromString(html, "text/html");
|
|
21352
21376
|
const SUPPORTED_ATTRS = [
|
|
21353
21377
|
"href",
|
|
@@ -21366,11 +21390,9 @@ function stripHtmlStyles(html) {
|
|
|
21366
21390
|
"styleid"
|
|
21367
21391
|
];
|
|
21368
21392
|
const cleanNode = (node) => {
|
|
21369
|
-
if (node.nodeType !==
|
|
21393
|
+
if (node.nodeType !== Node.ELEMENT_NODE) return;
|
|
21370
21394
|
[...node.attributes].forEach((attr) => {
|
|
21371
|
-
|
|
21372
|
-
const shouldKeep = SUPPORTED_ATTRS.includes(name) || name.startsWith("data-");
|
|
21373
|
-
if (!shouldKeep) {
|
|
21395
|
+
if (!SUPPORTED_ATTRS.includes(attr.name.toLowerCase())) {
|
|
21374
21396
|
node.removeAttribute(attr.name);
|
|
21375
21397
|
}
|
|
21376
21398
|
});
|
|
@@ -21399,7 +21421,7 @@ function L() {
|
|
|
21399
21421
|
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
21400
21422
|
}
|
|
21401
21423
|
var O = L();
|
|
21402
|
-
function
|
|
21424
|
+
function H(l3) {
|
|
21403
21425
|
O = l3;
|
|
21404
21426
|
}
|
|
21405
21427
|
var E = { exec: () => null };
|
|
@@ -21411,7 +21433,7 @@ function h(l3, e = "") {
|
|
|
21411
21433
|
return n;
|
|
21412
21434
|
}
|
|
21413
21435
|
var m = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceTabs: /^\t+/, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] /, listReplaceTask: /^\[[ xX]\] +/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (l3) => new RegExp(`^( {0,3}${l3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}#`), htmlBeginRegex: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}<(?:[a-z].*>|!--)`, "i") }, xe = /^(?:[ \t]*(?:\n|$))+/, be = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, Re = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, C = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Oe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, j = /(?:[*+-]|\d{1,9}[.)])/, se = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, ie = h(se).replace(/bull/g, j).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(), Te = h(se).replace(/bull/g, j).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), F = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, we = /^[^\n]+/, Q = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, ye = h(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Q).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Pe = h(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, j).getRegex(), v = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", U = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Se = h("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", U).replace("tag", v).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), oe = h(F).replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex(), $e = h(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", oe).getRegex(), K = { blockquote: $e, code: be, def: ye, fences: Re, heading: Oe, hr: C, html: Se, lheading: ie, list: Pe, newline: xe, paragraph: oe, table: E, text: we }, re = h("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex(), _e = { ...K, lheading: Te, table: re, paragraph: h(F).replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", re).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex() }, Le = { ...K, html: h(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", U).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: E, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: h(F).replace("hr", C).replace("heading", ` *#{1,6} *[^
|
|
21414
|
-
]`).replace("lheading", ie).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() }, Me = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, ze = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, ae = /^( {2,}|\\)\n(?!\s*$)/, Ae = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, D = /[\p{P}\p{S}]/u, W = /[\s\p{P}\p{S}]/u, le = /[^\s\p{P}\p{S}]/u, Ee = h(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, W).getRegex(), ue = /(?!~)[\p{P}\p{S}]/u, Ce = /(?!~)[\s\p{P}\p{S}]/u, Ie = /(?:[^\s\p{P}\p{S}]|~)/u, Be = /\[[^\[\]]*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g, pe = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, qe = h(pe, "u").replace(/punct/g, D).getRegex(), ve = h(pe, "u").replace(/punct/g, ue).getRegex(), ce = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", De = h(ce, "gu").replace(/notPunctSpace/g, le).replace(/punctSpace/g, W).replace(/punct/g, D).getRegex(),
|
|
21436
|
+
]`).replace("lheading", ie).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() }, Me = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, ze = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, ae = /^( {2,}|\\)\n(?!\s*$)/, Ae = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, D = /[\p{P}\p{S}]/u, W = /[\s\p{P}\p{S}]/u, le = /[^\s\p{P}\p{S}]/u, Ee = h(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, W).getRegex(), ue = /(?!~)[\p{P}\p{S}]/u, Ce = /(?!~)[\s\p{P}\p{S}]/u, Ie = /(?:[^\s\p{P}\p{S}]|~)/u, Be = /\[[^\[\]]*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g, pe = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, qe = h(pe, "u").replace(/punct/g, D).getRegex(), ve = h(pe, "u").replace(/punct/g, ue).getRegex(), ce = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", De = h(ce, "gu").replace(/notPunctSpace/g, le).replace(/punctSpace/g, W).replace(/punct/g, D).getRegex(), Ze = h(ce, "gu").replace(/notPunctSpace/g, Ie).replace(/punctSpace/g, Ce).replace(/punct/g, ue).getRegex(), Ge = h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, le).replace(/punctSpace/g, W).replace(/punct/g, D).getRegex(), He = h(/\\(punct)/, "gu").replace(/punct/g, D).getRegex(), Ne = h(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), je = h(U).replace("(?:-->|$)", "-->").getRegex(), Fe = h("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", je).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), q = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`[^`]*`|[^\[\]\\`])*?/, Qe = h(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), he$3 = h(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", Q).getRegex(), de = h(/^!?\[(ref)\](?:\[\])?/).replace("ref", Q).getRegex(), Ue = h("reflink|nolink(?!\\()", "g").replace("reflink", he$3).replace("nolink", de).getRegex(), X = { _backpedal: E, anyPunctuation: He, autolink: Ne, blockSkip: Be, br: ae, code: ze, del: E, emStrongLDelim: qe, emStrongRDelimAst: De, emStrongRDelimUnd: Ge, escape: Me, link: Qe, nolink: de, punctuation: Ee, reflink: he$3, reflinkSearch: Ue, tag: Fe, text: Ae, url: E }, Ke = { ...X, link: h(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(), reflink: h(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex() }, N = { ...X, emStrongRDelimAst: Ze, emStrongLDelim: ve, url: h(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/ }, We = { ...N, br: h(ae).replace("{2,}", "*").getRegex(), text: h(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() }, I = { normal: K, gfm: _e, pedantic: Le }, M = { normal: X, gfm: N, breaks: We, pedantic: Ke };
|
|
21415
21437
|
var Xe = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }, ke = (l3) => Xe[l3];
|
|
21416
21438
|
function w(l3, e) {
|
|
21417
21439
|
if (e) {
|
|
@@ -21569,15 +21591,15 @@ ${c}` : c;
|
|
|
21569
21591
|
if (!(t = s.exec(e)) || this.rules.block.hr.test(e)) break;
|
|
21570
21592
|
p = t[0], e = e.substring(p.length);
|
|
21571
21593
|
let f = t[2].split(`
|
|
21572
|
-
`, 1)[0].replace(this.rules.other.listReplaceTabs, (
|
|
21594
|
+
`, 1)[0].replace(this.rules.other.listReplaceTabs, (Z) => " ".repeat(3 * Z.length)), k = e.split(`
|
|
21573
21595
|
`, 1)[0], x = !f.trim(), g = 0;
|
|
21574
21596
|
if (this.options.pedantic ? (g = 2, c = f.trimStart()) : x ? g = t[1].length + 1 : (g = t[2].search(this.rules.other.nonSpaceChar), g = g > 4 ? 1 : g, c = f.slice(g), g += t[1].length), x && this.rules.other.blankLine.test(k) && (p += k + `
|
|
21575
21597
|
`, e = e.substring(k.length + 1), u = true), !u) {
|
|
21576
|
-
let
|
|
21598
|
+
let Z = this.rules.other.nextBulletRegex(g), ee = this.rules.other.hrRegex(g), te = this.rules.other.fencesBeginRegex(g), ne = this.rules.other.headingBeginRegex(g), me = this.rules.other.htmlBeginRegex(g);
|
|
21577
21599
|
for (; e; ) {
|
|
21578
|
-
let
|
|
21600
|
+
let G = e.split(`
|
|
21579
21601
|
`, 1)[0], A;
|
|
21580
|
-
if (k =
|
|
21602
|
+
if (k = G, this.options.pedantic ? (k = k.replace(this.rules.other.listReplaceNesting, " "), A = k) : A = k.replace(this.rules.other.tabCharGlobal, " "), te.test(k) || ne.test(k) || me.test(k) || Z.test(k) || ee.test(k)) break;
|
|
21581
21603
|
if (A.search(this.rules.other.nonSpaceChar) >= g || !k.trim()) c += `
|
|
21582
21604
|
` + A.slice(g);
|
|
21583
21605
|
else {
|
|
@@ -21585,8 +21607,8 @@ ${c}` : c;
|
|
|
21585
21607
|
c += `
|
|
21586
21608
|
` + k;
|
|
21587
21609
|
}
|
|
21588
|
-
!x && !k.trim() && (x = true), p +=
|
|
21589
|
-
`, e = e.substring(
|
|
21610
|
+
!x && !k.trim() && (x = true), p += G + `
|
|
21611
|
+
`, e = e.substring(G.length + 1), f = A.slice(g);
|
|
21590
21612
|
}
|
|
21591
21613
|
}
|
|
21592
21614
|
i.loose || (o ? i.loose = true : this.rules.other.doubleBlankLine.test(p) && (o = true));
|
|
@@ -21893,7 +21915,6 @@ var b = class l {
|
|
|
21893
21915
|
}
|
|
21894
21916
|
for (; (r = this.tokenizer.rules.inline.anyPunctuation.exec(n)) != null; ) n = n.slice(0, r.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
21895
21917
|
for (; (r = this.tokenizer.rules.inline.blockSkip.exec(n)) != null; ) n = n.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
21896
|
-
n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
|
|
21897
21918
|
let i = false, s = "";
|
|
21898
21919
|
for (; e; ) {
|
|
21899
21920
|
i || (s = ""), i = false;
|
|
@@ -22088,7 +22109,7 @@ ${e}</tr>
|
|
|
22088
22109
|
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : w(e.text);
|
|
22089
22110
|
}
|
|
22090
22111
|
};
|
|
22091
|
-
var
|
|
22112
|
+
var S = class {
|
|
22092
22113
|
strong({ text: e }) {
|
|
22093
22114
|
return e;
|
|
22094
22115
|
}
|
|
@@ -22122,7 +22143,7 @@ var R = class l2 {
|
|
|
22122
22143
|
__publicField(this, "options");
|
|
22123
22144
|
__publicField(this, "renderer");
|
|
22124
22145
|
__publicField(this, "textRenderer");
|
|
22125
|
-
this.options = e || O, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new
|
|
22146
|
+
this.options = e || O, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new S();
|
|
22126
22147
|
}
|
|
22127
22148
|
static parse(e, t) {
|
|
22128
22149
|
return new l2(t).parse(e);
|
|
@@ -22262,7 +22283,7 @@ var R = class l2 {
|
|
|
22262
22283
|
return n;
|
|
22263
22284
|
}
|
|
22264
22285
|
};
|
|
22265
|
-
var
|
|
22286
|
+
var $ = (_a = class {
|
|
22266
22287
|
constructor(e) {
|
|
22267
22288
|
__publicField(this, "options");
|
|
22268
22289
|
__publicField(this, "block");
|
|
@@ -22277,16 +22298,13 @@ var S = (_a = class {
|
|
|
22277
22298
|
processAllTokens(e) {
|
|
22278
22299
|
return e;
|
|
22279
22300
|
}
|
|
22280
|
-
emStrongMask(e) {
|
|
22281
|
-
return e;
|
|
22282
|
-
}
|
|
22283
22301
|
provideLexer() {
|
|
22284
22302
|
return this.block ? b.lex : b.lexInline;
|
|
22285
22303
|
}
|
|
22286
22304
|
provideParser() {
|
|
22287
22305
|
return this.block ? R.parse : R.parseInline;
|
|
22288
22306
|
}
|
|
22289
|
-
}, __publicField(_a, "passThroughHooks", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"
|
|
22307
|
+
}, __publicField(_a, "passThroughHooks", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"])), _a);
|
|
22290
22308
|
var B = class {
|
|
22291
22309
|
constructor(...e) {
|
|
22292
22310
|
__publicField(this, "defaults", L());
|
|
@@ -22295,10 +22313,10 @@ var B = class {
|
|
|
22295
22313
|
__publicField(this, "parseInline", this.parseMarkdown(false));
|
|
22296
22314
|
__publicField(this, "Parser", R);
|
|
22297
22315
|
__publicField(this, "Renderer", P);
|
|
22298
|
-
__publicField(this, "TextRenderer",
|
|
22316
|
+
__publicField(this, "TextRenderer", S);
|
|
22299
22317
|
__publicField(this, "Lexer", b);
|
|
22300
22318
|
__publicField(this, "Tokenizer", y);
|
|
22301
|
-
__publicField(this, "Hooks",
|
|
22319
|
+
__publicField(this, "Hooks", $);
|
|
22302
22320
|
this.use(...e);
|
|
22303
22321
|
}
|
|
22304
22322
|
walkTokens(e, t) {
|
|
@@ -22371,13 +22389,13 @@ var B = class {
|
|
|
22371
22389
|
r.tokenizer = i;
|
|
22372
22390
|
}
|
|
22373
22391
|
if (n.hooks) {
|
|
22374
|
-
let i = this.defaults.hooks || new
|
|
22392
|
+
let i = this.defaults.hooks || new $();
|
|
22375
22393
|
for (let s in n.hooks) {
|
|
22376
22394
|
if (!(s in i)) throw new Error(`hook '${s}' does not exist`);
|
|
22377
22395
|
if (["options", "block"].includes(s)) continue;
|
|
22378
22396
|
let o = s, a = n.hooks[o], u = i[o];
|
|
22379
|
-
|
|
22380
|
-
if (this.defaults.async
|
|
22397
|
+
$.passThroughHooks.has(s) ? i[o] = (p) => {
|
|
22398
|
+
if (this.defaults.async) return Promise.resolve(a.call(i, p)).then((f) => u.call(i, f));
|
|
22381
22399
|
let c = a.call(i, p);
|
|
22382
22400
|
return u.call(i, c);
|
|
22383
22401
|
} : i[o] = (...p) => {
|
|
@@ -22443,12 +22461,12 @@ function d(l3, e) {
|
|
|
22443
22461
|
return _.parse(l3, e);
|
|
22444
22462
|
}
|
|
22445
22463
|
d.options = d.setOptions = function(l3) {
|
|
22446
|
-
return _.setOptions(l3), d.defaults = _.defaults,
|
|
22464
|
+
return _.setOptions(l3), d.defaults = _.defaults, H(d.defaults), d;
|
|
22447
22465
|
};
|
|
22448
22466
|
d.getDefaults = L;
|
|
22449
22467
|
d.defaults = O;
|
|
22450
22468
|
d.use = function(...l3) {
|
|
22451
|
-
return _.use(...l3), d.defaults = _.defaults,
|
|
22469
|
+
return _.use(...l3), d.defaults = _.defaults, H(d.defaults), d;
|
|
22452
22470
|
};
|
|
22453
22471
|
d.walkTokens = function(l3, e) {
|
|
22454
22472
|
return _.walkTokens(l3, e);
|
|
@@ -22457,11 +22475,11 @@ d.parseInline = _.parseInline;
|
|
|
22457
22475
|
d.Parser = R;
|
|
22458
22476
|
d.parser = R.parse;
|
|
22459
22477
|
d.Renderer = P;
|
|
22460
|
-
d.TextRenderer =
|
|
22478
|
+
d.TextRenderer = S;
|
|
22461
22479
|
d.Lexer = b;
|
|
22462
22480
|
d.lexer = b.lex;
|
|
22463
22481
|
d.Tokenizer = y;
|
|
22464
|
-
d.Hooks =
|
|
22482
|
+
d.Hooks = $;
|
|
22465
22483
|
d.parse = d;
|
|
22466
22484
|
d.options;
|
|
22467
22485
|
d.setOptions;
|
|
@@ -22509,23 +22527,6 @@ function processContent({ content, type: type2, schema }) {
|
|
|
22509
22527
|
}
|
|
22510
22528
|
return doc2;
|
|
22511
22529
|
}
|
|
22512
|
-
const defaultBooleans = ["required", "readonly", "disabled", "checked", "multiple", "autofocus"];
|
|
22513
|
-
function updateDOMAttributes(dom, attrs = {}, options = {}) {
|
|
22514
|
-
const customBooleans = options.customBooleans || [];
|
|
22515
|
-
const booleans = [...defaultBooleans, ...customBooleans];
|
|
22516
|
-
Object.entries(attrs).forEach(([key, value]) => {
|
|
22517
|
-
if (booleans.includes(key)) {
|
|
22518
|
-
if (!value) dom.removeAttribute(key);
|
|
22519
|
-
else dom.setAttribute(key, "");
|
|
22520
|
-
return;
|
|
22521
|
-
}
|
|
22522
|
-
if (value != null) {
|
|
22523
|
-
dom.setAttribute(key, value);
|
|
22524
|
-
} else {
|
|
22525
|
-
dom.removeAttribute(key);
|
|
22526
|
-
}
|
|
22527
|
-
});
|
|
22528
|
-
}
|
|
22529
22530
|
const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
22530
22531
|
__proto__: null,
|
|
22531
22532
|
chainableEditorState,
|
|
@@ -22558,8 +22559,7 @@ const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
22558
22559
|
isNodeActive,
|
|
22559
22560
|
isTextSelection,
|
|
22560
22561
|
posToDOMRect,
|
|
22561
|
-
processContent
|
|
22562
|
-
updateDOMAttributes
|
|
22562
|
+
processContent
|
|
22563
22563
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
22564
22564
|
const generateNewListDefinition = ({ numId, listType, level, start, text, fmt, editor }) => {
|
|
22565
22565
|
if (typeof listType === "string") listType = editor.schema.nodes[listType];
|
|
@@ -22771,18 +22771,13 @@ const createSchemaOrderedListNode = ({ level, numId, listType, editor, listLevel
|
|
|
22771
22771
|
numId = Number(numId);
|
|
22772
22772
|
const { lvlText, numFmt } = ListHelpers.getListDefinitionDetails({ numId, level, listType, editor });
|
|
22773
22773
|
const listNodeJSON = createListItemNodeJSON({ level, lvlText, numFmt, numId, listLevel, contentNode });
|
|
22774
|
-
const nodeTypeName = typeof listType === "string" ? listType : listType?.name;
|
|
22775
|
-
const type2 = nodeTypeName || "orderedList";
|
|
22776
|
-
const attrs = {
|
|
22777
|
-
"list-style-type": numFmt,
|
|
22778
|
-
listId: numId
|
|
22779
|
-
};
|
|
22780
|
-
if (type2 === "orderedList") {
|
|
22781
|
-
attrs.order = level;
|
|
22782
|
-
}
|
|
22783
22774
|
const node = {
|
|
22784
|
-
type:
|
|
22785
|
-
attrs
|
|
22775
|
+
type: "orderedList",
|
|
22776
|
+
attrs: {
|
|
22777
|
+
"list-style-type": numFmt,
|
|
22778
|
+
listId: numId,
|
|
22779
|
+
order: level
|
|
22780
|
+
},
|
|
22786
22781
|
content: [listNodeJSON]
|
|
22787
22782
|
};
|
|
22788
22783
|
return editor.schema.nodeFromJSON(node);
|
|
@@ -24301,37 +24296,37 @@ const _NodeTranslator = class _NodeTranslator {
|
|
|
24301
24296
|
/** @type {typeof TranslatorTypes} */
|
|
24302
24297
|
__publicField(_NodeTranslator, "translatorTypes", TranslatorTypes);
|
|
24303
24298
|
let NodeTranslator = _NodeTranslator;
|
|
24304
|
-
const encode$
|
|
24299
|
+
const encode$j = (attributes) => {
|
|
24305
24300
|
return attributes["w:type"];
|
|
24306
24301
|
};
|
|
24307
|
-
const decode$
|
|
24302
|
+
const decode$j = (attrs) => {
|
|
24308
24303
|
const { lineBreakType } = attrs;
|
|
24309
24304
|
return lineBreakType;
|
|
24310
24305
|
};
|
|
24311
24306
|
const attrConfig$b = Object.freeze({
|
|
24312
24307
|
xmlName: "w:type",
|
|
24313
24308
|
sdName: "lineBreakType",
|
|
24314
|
-
encode: encode$
|
|
24315
|
-
decode: decode$
|
|
24309
|
+
encode: encode$j,
|
|
24310
|
+
decode: decode$j
|
|
24316
24311
|
});
|
|
24317
|
-
const encode$
|
|
24312
|
+
const encode$i = (attributes) => {
|
|
24318
24313
|
const xmlAttrValue = attributes["w:clear"];
|
|
24319
24314
|
return xmlAttrValue;
|
|
24320
24315
|
};
|
|
24321
|
-
const decode$
|
|
24316
|
+
const decode$i = (attrs) => {
|
|
24322
24317
|
const { clear } = attrs;
|
|
24323
24318
|
return clear;
|
|
24324
24319
|
};
|
|
24325
24320
|
const attrConfig$a = Object.freeze({
|
|
24326
24321
|
xmlName: "w:clear",
|
|
24327
24322
|
sdName: "clear",
|
|
24328
|
-
encode: encode$
|
|
24329
|
-
decode: decode$
|
|
24323
|
+
encode: encode$i,
|
|
24324
|
+
decode: decode$i
|
|
24330
24325
|
});
|
|
24331
|
-
const validXmlAttributes$
|
|
24332
|
-
const XML_NODE_NAME$
|
|
24333
|
-
const SD_NODE_NAME$
|
|
24334
|
-
const encode$
|
|
24326
|
+
const validXmlAttributes$6 = [attrConfig$b, attrConfig$a];
|
|
24327
|
+
const XML_NODE_NAME$7 = "w:br";
|
|
24328
|
+
const SD_NODE_NAME$6 = "lineBreak";
|
|
24329
|
+
const encode$h = (_2, encodedAttrs) => {
|
|
24335
24330
|
const isPageBreak = encodedAttrs?.lineBreakType === "page";
|
|
24336
24331
|
const translated = {
|
|
24337
24332
|
type: isPageBreak ? "hardBreak" : "lineBreak"
|
|
@@ -24341,7 +24336,7 @@ const encode$p = (_2, encodedAttrs) => {
|
|
|
24341
24336
|
}
|
|
24342
24337
|
return translated;
|
|
24343
24338
|
};
|
|
24344
|
-
const decode$
|
|
24339
|
+
const decode$h = (params, decodedAttrs) => {
|
|
24345
24340
|
const { node } = params;
|
|
24346
24341
|
if (!node) return;
|
|
24347
24342
|
const wBreak = { name: "w:br" };
|
|
@@ -24358,63 +24353,63 @@ const decode$p = (params, decodedAttrs) => {
|
|
|
24358
24353
|
};
|
|
24359
24354
|
return translated;
|
|
24360
24355
|
};
|
|
24361
|
-
const config$
|
|
24362
|
-
xmlName: XML_NODE_NAME$
|
|
24363
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
24356
|
+
const config$7 = {
|
|
24357
|
+
xmlName: XML_NODE_NAME$7,
|
|
24358
|
+
sdNodeOrKeyName: SD_NODE_NAME$6,
|
|
24364
24359
|
type: NodeTranslator.translatorTypes.NODE,
|
|
24365
|
-
encode: encode$
|
|
24366
|
-
decode: decode$
|
|
24367
|
-
attributes: validXmlAttributes$
|
|
24360
|
+
encode: encode$h,
|
|
24361
|
+
decode: decode$h,
|
|
24362
|
+
attributes: validXmlAttributes$6
|
|
24368
24363
|
};
|
|
24369
|
-
const translator$
|
|
24370
|
-
const encode$
|
|
24364
|
+
const translator$j = NodeTranslator.from(config$7);
|
|
24365
|
+
const encode$g = (attributes) => {
|
|
24371
24366
|
return attributes["w:val"];
|
|
24372
24367
|
};
|
|
24373
|
-
const decode$
|
|
24368
|
+
const decode$g = (attrs) => {
|
|
24374
24369
|
const { tabSize } = attrs || {};
|
|
24375
24370
|
return tabSize;
|
|
24376
24371
|
};
|
|
24377
24372
|
const attrConfig$9 = Object.freeze({
|
|
24378
24373
|
xmlName: "w:val",
|
|
24379
24374
|
sdName: "tabSize",
|
|
24380
|
-
encode: encode$
|
|
24381
|
-
decode: decode$
|
|
24375
|
+
encode: encode$g,
|
|
24376
|
+
decode: decode$g
|
|
24382
24377
|
});
|
|
24383
|
-
const encode$
|
|
24378
|
+
const encode$f = (attributes) => {
|
|
24384
24379
|
return attributes["w:leader"];
|
|
24385
24380
|
};
|
|
24386
|
-
const decode$
|
|
24381
|
+
const decode$f = (attrs) => {
|
|
24387
24382
|
const { leader } = attrs || {};
|
|
24388
24383
|
return leader;
|
|
24389
24384
|
};
|
|
24390
24385
|
const attrConfig$8 = Object.freeze({
|
|
24391
24386
|
xmlName: "w:leader",
|
|
24392
24387
|
sdName: "leader",
|
|
24393
|
-
encode: encode$
|
|
24394
|
-
decode: decode$
|
|
24388
|
+
encode: encode$f,
|
|
24389
|
+
decode: decode$f
|
|
24395
24390
|
});
|
|
24396
|
-
const encode$
|
|
24391
|
+
const encode$e = (attributes) => {
|
|
24397
24392
|
return attributes["w:pos"];
|
|
24398
24393
|
};
|
|
24399
|
-
const decode$
|
|
24394
|
+
const decode$e = (attrs) => {
|
|
24400
24395
|
const { pos } = attrs || {};
|
|
24401
24396
|
return pos;
|
|
24402
24397
|
};
|
|
24403
24398
|
const attrConfig$7 = Object.freeze({
|
|
24404
24399
|
xmlName: "w:pos",
|
|
24405
24400
|
sdName: "pos",
|
|
24406
|
-
encode: encode$
|
|
24407
|
-
decode: decode$
|
|
24401
|
+
encode: encode$e,
|
|
24402
|
+
decode: decode$e
|
|
24408
24403
|
});
|
|
24409
|
-
const validXmlAttributes$
|
|
24410
|
-
const XML_NODE_NAME$
|
|
24411
|
-
const SD_NODE_NAME$
|
|
24412
|
-
const encode$
|
|
24404
|
+
const validXmlAttributes$5 = [attrConfig$9, attrConfig$7, attrConfig$8];
|
|
24405
|
+
const XML_NODE_NAME$6 = "w:tab";
|
|
24406
|
+
const SD_NODE_NAME$5 = "tab";
|
|
24407
|
+
const encode$d = (_2, encodedAttrs = {}) => {
|
|
24413
24408
|
const translated = { type: "tab" };
|
|
24414
24409
|
if (encodedAttrs) translated.attrs = { ...encodedAttrs };
|
|
24415
24410
|
return translated;
|
|
24416
24411
|
};
|
|
24417
|
-
const decode$
|
|
24412
|
+
const decode$d = (params, decodedAttrs = {}) => {
|
|
24418
24413
|
const { node } = params || {};
|
|
24419
24414
|
if (!node) return;
|
|
24420
24415
|
const wTab = { name: "w:tab" };
|
|
@@ -24430,15 +24425,15 @@ const decode$l = (params, decodedAttrs = {}) => {
|
|
|
24430
24425
|
}
|
|
24431
24426
|
return translated;
|
|
24432
24427
|
};
|
|
24433
|
-
const config$
|
|
24434
|
-
xmlName: XML_NODE_NAME$
|
|
24435
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
24428
|
+
const config$6 = {
|
|
24429
|
+
xmlName: XML_NODE_NAME$6,
|
|
24430
|
+
sdNodeOrKeyName: SD_NODE_NAME$5,
|
|
24436
24431
|
type: NodeTranslator.translatorTypes.NODE,
|
|
24437
|
-
encode: encode$
|
|
24438
|
-
decode: decode$
|
|
24439
|
-
attributes: validXmlAttributes$
|
|
24432
|
+
encode: encode$d,
|
|
24433
|
+
decode: decode$d,
|
|
24434
|
+
attributes: validXmlAttributes$5
|
|
24440
24435
|
};
|
|
24441
|
-
const translator$
|
|
24436
|
+
const translator$i = NodeTranslator.from(config$6);
|
|
24442
24437
|
const mergeTextNodes = (nodes) => {
|
|
24443
24438
|
if (!nodes || !Array.isArray(nodes)) {
|
|
24444
24439
|
return nodes;
|
|
@@ -24702,15 +24697,13 @@ const getParagraphIndent = (node, docx, styleId = "") => {
|
|
|
24702
24697
|
}
|
|
24703
24698
|
return indent;
|
|
24704
24699
|
};
|
|
24705
|
-
const getParagraphSpacing = (node, docx, styleId = "", marks = []
|
|
24706
|
-
const { insideTable = false } = options;
|
|
24700
|
+
const getParagraphSpacing = (node, docx, styleId = "", marks = []) => {
|
|
24707
24701
|
const spacing = {};
|
|
24708
|
-
const { spacing: pDefaultSpacing = {}
|
|
24702
|
+
const { spacing: pDefaultSpacing = {} } = getDefaultParagraphStyle(docx, styleId);
|
|
24709
24703
|
let lineSpaceAfter, lineSpaceBefore, line, lineRuleStyle;
|
|
24710
24704
|
const pPr = node.elements?.find((el) => el.name === "w:pPr");
|
|
24711
24705
|
const inLineSpacingTag = pPr?.elements?.find((el) => el.name === "w:spacing");
|
|
24712
24706
|
const inLineSpacing = inLineSpacingTag?.attributes || {};
|
|
24713
|
-
const hasInlineSpacing = !!Object.keys(inLineSpacing).length;
|
|
24714
24707
|
const textStyleMark = marks.find((el) => el.type === "textStyle");
|
|
24715
24708
|
const fontSize = textStyleMark?.attrs?.fontSize;
|
|
24716
24709
|
const lineSpacing = inLineSpacing?.["w:line"] || line || pDefaultSpacing?.["w:line"];
|
|
@@ -24732,12 +24725,6 @@ const getParagraphSpacing = (node, docx, styleId = "", marks = [], options = {})
|
|
|
24732
24725
|
if (afterAutospacing === "1" && fontSize) {
|
|
24733
24726
|
spacing.lineSpaceAfter += Math.round(parseInt(fontSize) * 0.5 * 96 / 72);
|
|
24734
24727
|
}
|
|
24735
|
-
if (insideTable && !hasInlineSpacing && spacingSource === "docDefault") {
|
|
24736
|
-
const hasExplicitSpacing = Object.keys(inLineSpacing).length > 0;
|
|
24737
|
-
if (!hasExplicitSpacing) {
|
|
24738
|
-
return void 0;
|
|
24739
|
-
}
|
|
24740
|
-
}
|
|
24741
24728
|
return spacing;
|
|
24742
24729
|
};
|
|
24743
24730
|
const getDefaultParagraphStyle = (docx, styleId = "") => {
|
|
@@ -24778,20 +24765,9 @@ const getDefaultParagraphStyle = (docx, styleId = "") => {
|
|
|
24778
24765
|
const { attributes: pPrByIdIndentAttr } = pPrStyleIdIndentTag;
|
|
24779
24766
|
const spacingRest = isNormalAsDefault ? pPrNormalSpacingAttr || pPrDefaultSpacingAttr : pPrDefaultSpacingAttr || pPrNormalSpacingAttr;
|
|
24780
24767
|
const indentRest = isNormalAsDefault ? pPrNormalIndentAttr || pPrDefaultIndentAttr : pPrDefaultIndentAttr || pPrNormalIndentAttr;
|
|
24781
|
-
let spacingToUse = pPrByIdSpacingAttr || spacingRest;
|
|
24782
|
-
let spacingSource = "docDefault";
|
|
24783
|
-
if (pPrByIdSpacingAttr) {
|
|
24784
|
-
spacingSource = "style";
|
|
24785
|
-
} else if (spacingRest === pPrNormalSpacingAttr && pPrNormalSpacingAttr) {
|
|
24786
|
-
spacingSource = isNormalAsDefault ? "docDefault" : "normal";
|
|
24787
|
-
} else if (spacingRest === pPrDefaultSpacingAttr && pPrDefaultSpacingAttr) {
|
|
24788
|
-
spacingSource = "docDefault";
|
|
24789
|
-
}
|
|
24790
|
-
let indentToUse = pPrByIdIndentAttr || indentRest;
|
|
24791
24768
|
return {
|
|
24792
|
-
spacing:
|
|
24793
|
-
|
|
24794
|
-
indent: indentToUse,
|
|
24769
|
+
spacing: pPrByIdSpacingAttr || spacingRest,
|
|
24770
|
+
indent: pPrByIdIndentAttr || indentRest,
|
|
24795
24771
|
justify: pPrByIdJcAttr
|
|
24796
24772
|
};
|
|
24797
24773
|
};
|
|
@@ -24966,13 +24942,7 @@ const handleParagraphNode$1 = (params) => {
|
|
|
24966
24942
|
}
|
|
24967
24943
|
if (docx) {
|
|
24968
24944
|
const defaultStyleId = node.attributes?.["w:rsidRDefault"];
|
|
24969
|
-
|
|
24970
|
-
const spacing = getParagraphSpacing(node, docx, styleId, schemaNode.attrs.marksAttrs, {
|
|
24971
|
-
insideTable
|
|
24972
|
-
});
|
|
24973
|
-
if (spacing) {
|
|
24974
|
-
schemaNode.attrs["spacing"] = spacing;
|
|
24975
|
-
}
|
|
24945
|
+
schemaNode.attrs["spacing"] = getParagraphSpacing(node, docx, styleId, schemaNode.attrs.marksAttrs);
|
|
24976
24946
|
schemaNode.attrs["rsidRDefault"] = defaultStyleId;
|
|
24977
24947
|
}
|
|
24978
24948
|
if (docx) {
|
|
@@ -25033,91 +25003,91 @@ const handleParagraphNode$1 = (params) => {
|
|
|
25033
25003
|
}
|
|
25034
25004
|
return schemaNode;
|
|
25035
25005
|
};
|
|
25036
|
-
const encode$
|
|
25006
|
+
const encode$c = (attributes) => {
|
|
25037
25007
|
return attributes["w:rsidDel"];
|
|
25038
25008
|
};
|
|
25039
|
-
const decode$
|
|
25009
|
+
const decode$c = (attrs) => {
|
|
25040
25010
|
return attrs.rsidDel;
|
|
25041
25011
|
};
|
|
25042
25012
|
const attrConfig$6 = Object.freeze({
|
|
25043
25013
|
xmlName: "w:rsidDel",
|
|
25044
25014
|
sdName: "rsidDel",
|
|
25045
|
-
encode: encode$
|
|
25046
|
-
decode: decode$
|
|
25015
|
+
encode: encode$c,
|
|
25016
|
+
decode: decode$c
|
|
25047
25017
|
});
|
|
25048
|
-
const encode$
|
|
25018
|
+
const encode$b = (attributes) => {
|
|
25049
25019
|
return attributes["w:rsidP"];
|
|
25050
25020
|
};
|
|
25051
|
-
const decode$
|
|
25021
|
+
const decode$b = (attrs) => {
|
|
25052
25022
|
return attrs.rsidP;
|
|
25053
25023
|
};
|
|
25054
25024
|
const attrConfig$5 = Object.freeze({
|
|
25055
25025
|
xmlName: "w:rsidP",
|
|
25056
25026
|
sdName: "rsidP",
|
|
25057
|
-
encode: encode$
|
|
25058
|
-
decode: decode$
|
|
25027
|
+
encode: encode$b,
|
|
25028
|
+
decode: decode$b
|
|
25059
25029
|
});
|
|
25060
|
-
const encode$
|
|
25030
|
+
const encode$a = (attributes) => {
|
|
25061
25031
|
return attributes["w:rsidR"];
|
|
25062
25032
|
};
|
|
25063
|
-
const decode$
|
|
25033
|
+
const decode$a = (attrs) => {
|
|
25064
25034
|
return attrs.rsidR;
|
|
25065
25035
|
};
|
|
25066
25036
|
const attrConfig$4 = Object.freeze({
|
|
25067
25037
|
xmlName: "w:rsidR",
|
|
25068
25038
|
sdName: "rsidR",
|
|
25069
|
-
encode: encode$
|
|
25070
|
-
decode: decode$
|
|
25039
|
+
encode: encode$a,
|
|
25040
|
+
decode: decode$a
|
|
25071
25041
|
});
|
|
25072
|
-
const encode$
|
|
25042
|
+
const encode$9 = (attributes) => {
|
|
25073
25043
|
return attributes["w:rsidRPr"];
|
|
25074
25044
|
};
|
|
25075
|
-
const decode$
|
|
25045
|
+
const decode$9 = (attrs) => {
|
|
25076
25046
|
return attrs.rsidRPr;
|
|
25077
25047
|
};
|
|
25078
25048
|
const attrConfig$3 = Object.freeze({
|
|
25079
25049
|
xmlName: "w:rsidRPr",
|
|
25080
25050
|
sdName: "rsidRPr",
|
|
25081
|
-
encode: encode$
|
|
25082
|
-
decode: decode$
|
|
25051
|
+
encode: encode$9,
|
|
25052
|
+
decode: decode$9
|
|
25083
25053
|
});
|
|
25084
|
-
const encode$
|
|
25054
|
+
const encode$8 = (attributes) => {
|
|
25085
25055
|
return attributes["w:rsidRDefault"];
|
|
25086
25056
|
};
|
|
25087
|
-
const decode$
|
|
25057
|
+
const decode$8 = (attrs) => {
|
|
25088
25058
|
return attrs.rsidRDefault;
|
|
25089
25059
|
};
|
|
25090
25060
|
const attrConfig$2 = Object.freeze({
|
|
25091
25061
|
xmlName: "w:rsidRDefault",
|
|
25092
25062
|
sdName: "rsidRDefault",
|
|
25093
|
-
encode: encode$
|
|
25094
|
-
decode: decode$
|
|
25063
|
+
encode: encode$8,
|
|
25064
|
+
decode: decode$8
|
|
25095
25065
|
});
|
|
25096
|
-
const encode$
|
|
25066
|
+
const encode$7 = (attributes) => {
|
|
25097
25067
|
return attributes["w14:paraId"];
|
|
25098
25068
|
};
|
|
25099
|
-
const decode$
|
|
25069
|
+
const decode$7 = (attrs) => {
|
|
25100
25070
|
return attrs.paraId;
|
|
25101
25071
|
};
|
|
25102
25072
|
const attrConfig$1 = Object.freeze({
|
|
25103
25073
|
xmlName: "w14:paraId",
|
|
25104
25074
|
sdName: "paraId",
|
|
25105
|
-
encode: encode$
|
|
25106
|
-
decode: decode$
|
|
25075
|
+
encode: encode$7,
|
|
25076
|
+
decode: decode$7
|
|
25107
25077
|
});
|
|
25108
|
-
const encode$
|
|
25078
|
+
const encode$6 = (attributes) => {
|
|
25109
25079
|
return attributes["w14:textId"];
|
|
25110
25080
|
};
|
|
25111
|
-
const decode$
|
|
25081
|
+
const decode$6 = (attrs) => {
|
|
25112
25082
|
return attrs.textId;
|
|
25113
25083
|
};
|
|
25114
25084
|
const attrConfig = Object.freeze({
|
|
25115
25085
|
xmlName: "w14:textId",
|
|
25116
25086
|
sdName: "textId",
|
|
25117
|
-
encode: encode$
|
|
25118
|
-
decode: decode$
|
|
25087
|
+
encode: encode$6,
|
|
25088
|
+
decode: decode$6
|
|
25119
25089
|
});
|
|
25120
|
-
const validXmlAttributes$
|
|
25090
|
+
const validXmlAttributes$4 = [
|
|
25121
25091
|
attrConfig$1,
|
|
25122
25092
|
attrConfig,
|
|
25123
25093
|
attrConfig$4,
|
|
@@ -25126,9 +25096,9 @@ const validXmlAttributes$7 = [
|
|
|
25126
25096
|
attrConfig$3,
|
|
25127
25097
|
attrConfig$6
|
|
25128
25098
|
];
|
|
25129
|
-
const XML_NODE_NAME$
|
|
25130
|
-
const SD_NODE_NAME$
|
|
25131
|
-
const encode$
|
|
25099
|
+
const XML_NODE_NAME$5 = "w:p";
|
|
25100
|
+
const SD_NODE_NAME$4 = "paragraph";
|
|
25101
|
+
const encode$5 = (params, encodedAttrs = {}) => {
|
|
25132
25102
|
const node = handleParagraphNode$1(params);
|
|
25133
25103
|
if (!node) return void 0;
|
|
25134
25104
|
if (encodedAttrs && Object.keys(encodedAttrs).length) {
|
|
@@ -25136,7 +25106,7 @@ const encode$d = (params, encodedAttrs = {}) => {
|
|
|
25136
25106
|
}
|
|
25137
25107
|
return node;
|
|
25138
25108
|
};
|
|
25139
|
-
const decode$
|
|
25109
|
+
const decode$5 = (params, decodedAttrs = {}) => {
|
|
25140
25110
|
const translated = translateParagraphNode(params);
|
|
25141
25111
|
if (!translated) return void 0;
|
|
25142
25112
|
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
@@ -25144,15 +25114,15 @@ const decode$d = (params, decodedAttrs = {}) => {
|
|
|
25144
25114
|
}
|
|
25145
25115
|
return translated;
|
|
25146
25116
|
};
|
|
25147
|
-
const config$
|
|
25148
|
-
xmlName: XML_NODE_NAME$
|
|
25149
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
25117
|
+
const config$5 = {
|
|
25118
|
+
xmlName: XML_NODE_NAME$5,
|
|
25119
|
+
sdNodeOrKeyName: SD_NODE_NAME$4,
|
|
25150
25120
|
type: NodeTranslator.translatorTypes.NODE,
|
|
25151
|
-
encode: encode$
|
|
25152
|
-
decode: decode$
|
|
25153
|
-
attributes: validXmlAttributes$
|
|
25121
|
+
encode: encode$5,
|
|
25122
|
+
decode: decode$5,
|
|
25123
|
+
attributes: validXmlAttributes$4
|
|
25154
25124
|
};
|
|
25155
|
-
const translator$
|
|
25125
|
+
const translator$h = NodeTranslator.from(config$5);
|
|
25156
25126
|
const generateV2HandlerEntity = (handlerName, translator2) => ({
|
|
25157
25127
|
handlerName,
|
|
25158
25128
|
handler: (params) => {
|
|
@@ -25180,7 +25150,7 @@ function createSingleAttrPropertyHandler(xmlName, sdName = null, attrName = "w:v
|
|
|
25180
25150
|
},
|
|
25181
25151
|
decode: ({ node }) => {
|
|
25182
25152
|
const value = node.attrs?.[sdName] != null ? transformDecode(node.attrs[sdName]) : void 0;
|
|
25183
|
-
return value != null ? {
|
|
25153
|
+
return value != null ? { [attrName]: value } : void 0;
|
|
25184
25154
|
}
|
|
25185
25155
|
};
|
|
25186
25156
|
}
|
|
@@ -25198,32 +25168,7 @@ function createMeasurementPropertyHandler(xmlName, sdName = null) {
|
|
|
25198
25168
|
},
|
|
25199
25169
|
decode: function({ node }) {
|
|
25200
25170
|
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
|
|
25201
|
-
return decodedAttrs["w:w"] != null ?
|
|
25202
|
-
}
|
|
25203
|
-
};
|
|
25204
|
-
}
|
|
25205
|
-
function createBorderPropertyHandler(xmlName, sdName = null) {
|
|
25206
|
-
if (!sdName) sdName = xmlName.split(":")[1];
|
|
25207
|
-
return {
|
|
25208
|
-
xmlName,
|
|
25209
|
-
sdNodeOrKeyName: sdName,
|
|
25210
|
-
attributes: [
|
|
25211
|
-
createAttributeHandler("w:val"),
|
|
25212
|
-
createAttributeHandler("w:color"),
|
|
25213
|
-
createAttributeHandler("w:themeColor"),
|
|
25214
|
-
createAttributeHandler("w:themeTint"),
|
|
25215
|
-
createAttributeHandler("w:themeShade"),
|
|
25216
|
-
createAttributeHandler("w:sz", "size", parseInteger, integerToString),
|
|
25217
|
-
createAttributeHandler("w:space", null, parseInteger, integerToString),
|
|
25218
|
-
createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
|
|
25219
|
-
createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
|
|
25220
|
-
],
|
|
25221
|
-
encode: (params, encodedAttrs) => {
|
|
25222
|
-
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25223
|
-
},
|
|
25224
|
-
decode: function({ node }, context) {
|
|
25225
|
-
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
|
|
25226
|
-
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25171
|
+
return decodedAttrs["w:w"] != null ? decodedAttrs : void 0;
|
|
25227
25172
|
}
|
|
25228
25173
|
};
|
|
25229
25174
|
}
|
|
@@ -25266,17 +25211,15 @@ function decodeProperties(translatorsBySdName, properties) {
|
|
|
25266
25211
|
Object.keys(properties).forEach((key) => {
|
|
25267
25212
|
const translator2 = translatorsBySdName[key];
|
|
25268
25213
|
if (translator2) {
|
|
25269
|
-
const
|
|
25270
|
-
if (
|
|
25271
|
-
|
|
25272
|
-
elements.push(result);
|
|
25214
|
+
const attributes = translator2.decode({ node: { attrs: { [key]: properties[key] } } });
|
|
25215
|
+
if (attributes != null) {
|
|
25216
|
+
elements.push({ name: translator2.xmlName, attributes });
|
|
25273
25217
|
}
|
|
25274
25218
|
}
|
|
25275
25219
|
});
|
|
25276
25220
|
return elements;
|
|
25277
25221
|
}
|
|
25278
|
-
const parseBoolean = (value) =>
|
|
25279
|
-
const booleanToString = (value) => value != null ? value ? "1" : "0" : void 0;
|
|
25222
|
+
const parseBoolean = (value) => ["1", "true"].includes(value);
|
|
25280
25223
|
const parseInteger = (value) => {
|
|
25281
25224
|
if (value == null) return void 0;
|
|
25282
25225
|
const intValue = parseInt(value, 10);
|
|
@@ -25286,53 +25229,13 @@ const integerToString = (value) => {
|
|
|
25286
25229
|
const intValue = parseInteger(value);
|
|
25287
25230
|
return intValue != void 0 ? String(intValue) : void 0;
|
|
25288
25231
|
};
|
|
25289
|
-
|
|
25290
|
-
if (!table || !Array.isArray(table.content)) {
|
|
25291
|
-
return table;
|
|
25292
|
-
}
|
|
25293
|
-
const rows = table.content;
|
|
25294
|
-
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
25295
|
-
const row = rows[rowIndex];
|
|
25296
|
-
if (!row) continue;
|
|
25297
|
-
if (!Array.isArray(row.content)) {
|
|
25298
|
-
row.content = [];
|
|
25299
|
-
}
|
|
25300
|
-
for (let cellIndex = 0; cellIndex < row.content.length; cellIndex++) {
|
|
25301
|
-
const cell = row.content[cellIndex];
|
|
25302
|
-
if (!cell) continue;
|
|
25303
|
-
const attrs = cell.attrs || {};
|
|
25304
|
-
if (!attrs.rowspan || attrs.rowspan <= 1) continue;
|
|
25305
|
-
const maxRowspan = Math.min(attrs.rowspan, rows.length - rowIndex);
|
|
25306
|
-
for (let offset = 1; offset < maxRowspan; offset++) {
|
|
25307
|
-
const rowToChange = rows[rowIndex + offset];
|
|
25308
|
-
if (!rowToChange) continue;
|
|
25309
|
-
if (!Array.isArray(rowToChange.content)) {
|
|
25310
|
-
rowToChange.content = [];
|
|
25311
|
-
}
|
|
25312
|
-
const existingCell = rowToChange.content[cellIndex];
|
|
25313
|
-
if (existingCell?.attrs?.continueMerge) continue;
|
|
25314
|
-
const mergedCell = {
|
|
25315
|
-
type: cell.type,
|
|
25316
|
-
content: [editorSchema.nodes.paragraph.createAndFill().toJSON()],
|
|
25317
|
-
attrs: {
|
|
25318
|
-
...cell.attrs,
|
|
25319
|
-
rowspan: null,
|
|
25320
|
-
continueMerge: true
|
|
25321
|
-
}
|
|
25322
|
-
};
|
|
25323
|
-
rowToChange.content.splice(cellIndex, 0, mergedCell);
|
|
25324
|
-
}
|
|
25325
|
-
}
|
|
25326
|
-
}
|
|
25327
|
-
return table;
|
|
25328
|
-
}
|
|
25329
|
-
const translator$Q = NodeTranslator.from({
|
|
25232
|
+
const translator$g = NodeTranslator.from({
|
|
25330
25233
|
xmlName: "w:cantSplit",
|
|
25331
25234
|
sdNodeOrKeyName: "cantSplit",
|
|
25332
25235
|
encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25333
|
-
decode: ({ node }) => node.attrs?.cantSplit ? {
|
|
25236
|
+
decode: ({ node }) => node.attrs?.cantSplit ? {} : void 0
|
|
25334
25237
|
});
|
|
25335
|
-
const translator$
|
|
25238
|
+
const translator$f = NodeTranslator.from({
|
|
25336
25239
|
xmlName: "w:cnfStyle",
|
|
25337
25240
|
sdNodeOrKeyName: "cnfStyle",
|
|
25338
25241
|
attributes: [
|
|
@@ -25347,19 +25250,26 @@ const translator$P = NodeTranslator.from({
|
|
|
25347
25250
|
"w:lastRowFirstColumn",
|
|
25348
25251
|
"w:lastRowLastColumn",
|
|
25349
25252
|
"w:oddHBand",
|
|
25350
|
-
"w:oddVBand"
|
|
25351
|
-
|
|
25253
|
+
"w:oddVBand",
|
|
25254
|
+
"w:val"
|
|
25255
|
+
].map((attr) => createAttributeHandler(attr)),
|
|
25352
25256
|
encode: (_2, encodedAttrs) => {
|
|
25257
|
+
Object.keys(encodedAttrs).forEach((key) => {
|
|
25258
|
+
encodedAttrs[key] = ["1", "true"].includes(encodedAttrs[key]);
|
|
25259
|
+
});
|
|
25353
25260
|
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25354
25261
|
},
|
|
25355
|
-
decode:
|
|
25262
|
+
decode: ({ node }) => {
|
|
25356
25263
|
if (!node.attrs?.cnfStyle) return;
|
|
25357
|
-
const
|
|
25358
|
-
|
|
25264
|
+
const cnfStyleAttrs = {};
|
|
25265
|
+
Object.entries(node.attrs.cnfStyle).forEach(([key, value]) => {
|
|
25266
|
+
cnfStyleAttrs[`w:${key}`] = value ? "1" : "0";
|
|
25267
|
+
});
|
|
25268
|
+
return Object.keys(cnfStyleAttrs).length > 0 ? cnfStyleAttrs : void 0;
|
|
25359
25269
|
}
|
|
25360
25270
|
});
|
|
25361
|
-
const translator$
|
|
25362
|
-
const translator$
|
|
25271
|
+
const translator$e = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
|
|
25272
|
+
const translator$d = NodeTranslator.from(
|
|
25363
25273
|
createSingleAttrPropertyHandler(
|
|
25364
25274
|
"w:gridAfter",
|
|
25365
25275
|
null,
|
|
@@ -25368,7 +25278,7 @@ const translator$N = NodeTranslator.from(
|
|
|
25368
25278
|
(v2) => integerToString(v2)
|
|
25369
25279
|
)
|
|
25370
25280
|
);
|
|
25371
|
-
const translator$
|
|
25281
|
+
const translator$c = NodeTranslator.from(
|
|
25372
25282
|
createSingleAttrPropertyHandler(
|
|
25373
25283
|
"w:gridBefore",
|
|
25374
25284
|
null,
|
|
@@ -25377,21 +25287,21 @@ const translator$M = NodeTranslator.from(
|
|
|
25377
25287
|
(v2) => integerToString(v2)
|
|
25378
25288
|
)
|
|
25379
25289
|
);
|
|
25380
|
-
const translator$
|
|
25290
|
+
const translator$b = NodeTranslator.from({
|
|
25381
25291
|
xmlName: "w:hidden",
|
|
25382
25292
|
sdNodeOrKeyName: "hidden",
|
|
25383
25293
|
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25384
|
-
decode: ({ node }) => node.attrs.hidden ? {
|
|
25294
|
+
decode: ({ node }) => node.attrs.hidden ? {} : void 0
|
|
25385
25295
|
});
|
|
25386
|
-
const translator$
|
|
25387
|
-
const translator$
|
|
25388
|
-
const translator$
|
|
25296
|
+
const translator$a = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc"));
|
|
25297
|
+
const translator$9 = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "cellSpacing"));
|
|
25298
|
+
const translator$8 = NodeTranslator.from({
|
|
25389
25299
|
xmlName: "w:tblHeader",
|
|
25390
25300
|
sdNodeOrKeyName: "repeatHeader",
|
|
25391
25301
|
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25392
|
-
decode: ({ node }) => node.attrs.repeatHeader ? {
|
|
25302
|
+
decode: ({ node }) => node.attrs.repeatHeader ? {} : void 0
|
|
25393
25303
|
});
|
|
25394
|
-
const translator$
|
|
25304
|
+
const translator$7 = NodeTranslator.from({
|
|
25395
25305
|
xmlName: "w:trHeight",
|
|
25396
25306
|
sdNodeOrKeyName: "rowHeight",
|
|
25397
25307
|
encode: ({ nodes }) => {
|
|
@@ -25415,14 +25325,14 @@ const translator$H = NodeTranslator.from({
|
|
|
25415
25325
|
if (node.attrs.rowHeight.rule) {
|
|
25416
25326
|
heightAttrs["w:hRule"] = node.attrs.rowHeight.rule;
|
|
25417
25327
|
}
|
|
25418
|
-
return Object.keys(heightAttrs).length > 0 ?
|
|
25328
|
+
return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
|
|
25419
25329
|
}
|
|
25420
25330
|
});
|
|
25421
|
-
const translator$
|
|
25422
|
-
const translator$
|
|
25423
|
-
const XML_NODE_NAME$
|
|
25424
|
-
const SD_ATTR_KEY
|
|
25425
|
-
const encode$
|
|
25331
|
+
const translator$6 = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
|
|
25332
|
+
const translator$5 = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
|
|
25333
|
+
const XML_NODE_NAME$4 = "w:trPr";
|
|
25334
|
+
const SD_ATTR_KEY = "tableRowProperties";
|
|
25335
|
+
const encode$4 = (params) => {
|
|
25426
25336
|
const { nodes } = params;
|
|
25427
25337
|
const node = nodes[0];
|
|
25428
25338
|
let attributes = {
|
|
@@ -25432,18 +25342,18 @@ const encode$c = (params) => {
|
|
|
25432
25342
|
};
|
|
25433
25343
|
attributes = {
|
|
25434
25344
|
...attributes,
|
|
25435
|
-
...encodeProperties(node, propertyTranslatorsByXmlName
|
|
25345
|
+
...encodeProperties(node, propertyTranslatorsByXmlName)
|
|
25436
25346
|
};
|
|
25437
25347
|
return {
|
|
25438
25348
|
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
25439
|
-
xmlName: XML_NODE_NAME$
|
|
25440
|
-
sdNodeOrKeyName: SD_ATTR_KEY
|
|
25349
|
+
xmlName: XML_NODE_NAME$4,
|
|
25350
|
+
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
25441
25351
|
attributes
|
|
25442
25352
|
};
|
|
25443
25353
|
};
|
|
25444
|
-
const decode$
|
|
25354
|
+
const decode$4 = (params) => {
|
|
25445
25355
|
const { tableRowProperties = {} } = params.node.attrs || {};
|
|
25446
|
-
const elements = decodeProperties(propertyTranslatorsBySdName
|
|
25356
|
+
const elements = decodeProperties(propertyTranslatorsBySdName, tableRowProperties);
|
|
25447
25357
|
const newNode = {
|
|
25448
25358
|
name: "w:trPr",
|
|
25449
25359
|
type: "element",
|
|
@@ -25452,47 +25362,47 @@ const decode$c = (params) => {
|
|
|
25452
25362
|
};
|
|
25453
25363
|
return newNode;
|
|
25454
25364
|
};
|
|
25455
|
-
const propertyTranslators
|
|
25456
|
-
translator$
|
|
25457
|
-
translator$
|
|
25458
|
-
translator$
|
|
25459
|
-
translator$
|
|
25460
|
-
translator$
|
|
25461
|
-
translator$
|
|
25462
|
-
translator$
|
|
25463
|
-
translator$
|
|
25464
|
-
translator$
|
|
25465
|
-
translator$
|
|
25466
|
-
translator$
|
|
25467
|
-
translator$
|
|
25365
|
+
const propertyTranslators = [
|
|
25366
|
+
translator$g,
|
|
25367
|
+
translator$f,
|
|
25368
|
+
translator$e,
|
|
25369
|
+
translator$d,
|
|
25370
|
+
translator$c,
|
|
25371
|
+
translator$b,
|
|
25372
|
+
translator$a,
|
|
25373
|
+
translator$9,
|
|
25374
|
+
translator$8,
|
|
25375
|
+
translator$7,
|
|
25376
|
+
translator$6,
|
|
25377
|
+
translator$5
|
|
25468
25378
|
];
|
|
25469
|
-
const propertyTranslatorsByXmlName
|
|
25470
|
-
propertyTranslators
|
|
25471
|
-
propertyTranslatorsByXmlName
|
|
25379
|
+
const propertyTranslatorsByXmlName = {};
|
|
25380
|
+
propertyTranslators.forEach((translator2) => {
|
|
25381
|
+
propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
|
|
25472
25382
|
});
|
|
25473
|
-
const propertyTranslatorsBySdName
|
|
25474
|
-
propertyTranslators
|
|
25475
|
-
propertyTranslatorsBySdName
|
|
25383
|
+
const propertyTranslatorsBySdName = {};
|
|
25384
|
+
propertyTranslators.forEach((translator2) => {
|
|
25385
|
+
propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
|
|
25476
25386
|
});
|
|
25477
|
-
const config$
|
|
25478
|
-
xmlName: XML_NODE_NAME$
|
|
25479
|
-
sdNodeOrKeyName: SD_ATTR_KEY
|
|
25387
|
+
const config$4 = {
|
|
25388
|
+
xmlName: XML_NODE_NAME$4,
|
|
25389
|
+
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
25480
25390
|
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
25481
|
-
encode: encode$
|
|
25482
|
-
decode: decode$
|
|
25391
|
+
encode: encode$4,
|
|
25392
|
+
decode: decode$4
|
|
25483
25393
|
};
|
|
25484
|
-
const translator$
|
|
25485
|
-
const XML_NODE_NAME$
|
|
25486
|
-
const SD_NODE_NAME$
|
|
25487
|
-
const validXmlAttributes$
|
|
25394
|
+
const translator$4 = NodeTranslator.from(config$4);
|
|
25395
|
+
const XML_NODE_NAME$3 = "w:tr";
|
|
25396
|
+
const SD_NODE_NAME$3 = "tableRow";
|
|
25397
|
+
const validXmlAttributes$3 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
|
|
25488
25398
|
(xmlName) => createAttributeHandler(xmlName)
|
|
25489
25399
|
);
|
|
25490
|
-
const encode$
|
|
25491
|
-
const { row } = params.extraParams;
|
|
25400
|
+
const encode$3 = (params, encodedAttrs) => {
|
|
25401
|
+
const { row, table } = params.extraParams;
|
|
25492
25402
|
let tableRowProperties = {};
|
|
25493
25403
|
const tPr = row.elements.find((el) => el.name === "w:trPr");
|
|
25494
25404
|
if (tPr) {
|
|
25495
|
-
({ attributes: tableRowProperties } = translator$
|
|
25405
|
+
({ attributes: tableRowProperties } = translator$4.encode({
|
|
25496
25406
|
...params,
|
|
25497
25407
|
nodes: [tPr]
|
|
25498
25408
|
}));
|
|
@@ -25500,12 +25410,12 @@ const encode$b = (params, encodedAttrs) => {
|
|
|
25500
25410
|
encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
|
|
25501
25411
|
encodedAttrs["rowHeight"] = twipsToPixels(tableRowProperties["rowHeight"]?.value);
|
|
25502
25412
|
encodedAttrs["cantSplit"] = tableRowProperties["cantSplit"];
|
|
25503
|
-
const
|
|
25413
|
+
const gridColumnWidths = _getGridColumnWidths(table);
|
|
25504
25414
|
const cellNodes = row.elements.filter((el) => el.name === "w:tc");
|
|
25505
25415
|
let currentColumnIndex = 0;
|
|
25506
25416
|
const content = cellNodes?.map((n) => {
|
|
25507
25417
|
let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
|
|
25508
|
-
const result = translator$
|
|
25418
|
+
const result = translator$2.encode({
|
|
25509
25419
|
...params,
|
|
25510
25420
|
extraParams: {
|
|
25511
25421
|
...params.extraParams,
|
|
@@ -25527,7 +25437,16 @@ const encode$b = (params, encodedAttrs) => {
|
|
|
25527
25437
|
};
|
|
25528
25438
|
return newNode;
|
|
25529
25439
|
};
|
|
25530
|
-
const
|
|
25440
|
+
const _getGridColumnWidths = (tableNode) => {
|
|
25441
|
+
const tblGrid = tableNode.elements.find((el) => el.name === "w:tblGrid");
|
|
25442
|
+
if (!tblGrid) return [];
|
|
25443
|
+
const columnWidths = tblGrid?.elements?.flatMap((el) => {
|
|
25444
|
+
if (el.name !== "w:gridCol") return [];
|
|
25445
|
+
return twipsToPixels(el.attributes["w:w"]);
|
|
25446
|
+
}) || [];
|
|
25447
|
+
return columnWidths;
|
|
25448
|
+
};
|
|
25449
|
+
const decode$3 = (params, decodedAttrs) => {
|
|
25531
25450
|
const { node } = params;
|
|
25532
25451
|
const elements = translateChildNodes(params);
|
|
25533
25452
|
if (node.attrs?.tableRowProperties) {
|
|
@@ -25539,7 +25458,7 @@ const decode$b = (params, decodedAttrs) => {
|
|
|
25539
25458
|
}
|
|
25540
25459
|
}
|
|
25541
25460
|
tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
|
|
25542
|
-
const trPr = translator$
|
|
25461
|
+
const trPr = translator$4.decode({
|
|
25543
25462
|
...params,
|
|
25544
25463
|
node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
|
|
25545
25464
|
});
|
|
@@ -25551,547 +25470,96 @@ const decode$b = (params, decodedAttrs) => {
|
|
|
25551
25470
|
elements
|
|
25552
25471
|
};
|
|
25553
25472
|
};
|
|
25554
|
-
const config$
|
|
25555
|
-
xmlName: XML_NODE_NAME$
|
|
25556
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
25473
|
+
const config$3 = {
|
|
25474
|
+
xmlName: XML_NODE_NAME$3,
|
|
25475
|
+
sdNodeOrKeyName: SD_NODE_NAME$3,
|
|
25557
25476
|
type: NodeTranslator.translatorTypes.NODE,
|
|
25558
|
-
encode: encode$
|
|
25559
|
-
decode: decode$
|
|
25560
|
-
attributes: validXmlAttributes$
|
|
25561
|
-
};
|
|
25562
|
-
const translator$D = NodeTranslator.from(config$9);
|
|
25563
|
-
const translator$C = NodeTranslator.from({
|
|
25564
|
-
xmlName: "w:bidiVisual",
|
|
25565
|
-
sdNodeOrKeyName: "rightToLeft",
|
|
25566
|
-
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25567
|
-
decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
|
|
25568
|
-
});
|
|
25569
|
-
const translator$B = NodeTranslator.from({
|
|
25570
|
-
xmlName: "w:shd",
|
|
25571
|
-
sdNodeOrKeyName: "shading",
|
|
25572
|
-
attributes: [
|
|
25573
|
-
"w:color",
|
|
25574
|
-
"w:fill",
|
|
25575
|
-
"w:themeColor",
|
|
25576
|
-
"w:themeFill",
|
|
25577
|
-
"w:themeFillShade",
|
|
25578
|
-
"w:themeFillTint",
|
|
25579
|
-
"w:themeShade",
|
|
25580
|
-
"w:themeTint",
|
|
25581
|
-
"w:val"
|
|
25582
|
-
].map((attr) => createAttributeHandler(attr)),
|
|
25583
|
-
encode: (params, encodedAttrs) => {
|
|
25584
|
-
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25585
|
-
},
|
|
25586
|
-
decode: function({ node }, context) {
|
|
25587
|
-
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.shading || {} } });
|
|
25588
|
-
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25589
|
-
}
|
|
25590
|
-
});
|
|
25591
|
-
const translator$A = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
|
|
25592
|
-
const translator$z = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
|
|
25593
|
-
const translator$y = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
|
|
25594
|
-
const translator$x = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
|
|
25595
|
-
const translator$w = NodeTranslator.from({
|
|
25596
|
-
xmlName: "w:tblLook",
|
|
25597
|
-
sdNodeOrKeyName: "tblLook",
|
|
25598
|
-
attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
|
|
25599
|
-
encode: (params, encodedAttrs) => {
|
|
25600
|
-
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25601
|
-
},
|
|
25602
|
-
decode: function({ node }, context) {
|
|
25603
|
-
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.tblLook || {} } });
|
|
25604
|
-
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25605
|
-
}
|
|
25606
|
-
});
|
|
25607
|
-
const translator$v = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
|
|
25608
|
-
const translator$u = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
|
|
25609
|
-
const translator$t = NodeTranslator.from(
|
|
25610
|
-
createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
|
|
25611
|
-
);
|
|
25612
|
-
const translator$s = NodeTranslator.from(
|
|
25613
|
-
createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
|
|
25614
|
-
);
|
|
25615
|
-
const translator$r = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
|
|
25616
|
-
const translator$q = NodeTranslator.from({
|
|
25617
|
-
xmlName: "w:tblpPr",
|
|
25618
|
-
sdNodeOrKeyName: "floatingTableProperties",
|
|
25619
|
-
attributes: ["w:leftFromText", "w:rightFromText", "w:topFromText", "w:bottomFromText", "w:tblpX", "w:tblpY"].map((attr) => createAttributeHandler(attr, null, parseInteger, integerToString)).concat(["w:horzAnchor", "w:vertAnchor", "w:tblpXSpec", "w:tblpYSpec"].map((attr) => createAttributeHandler(attr))),
|
|
25620
|
-
encode: (params, encodedAttrs) => {
|
|
25621
|
-
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25622
|
-
},
|
|
25623
|
-
decode: function({ node }, context) {
|
|
25624
|
-
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.floatingTableProperties || {} } });
|
|
25625
|
-
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25626
|
-
}
|
|
25627
|
-
});
|
|
25628
|
-
const translator$p = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
|
|
25629
|
-
const translator$o = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
|
|
25630
|
-
const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:end"));
|
|
25631
|
-
const translator$m = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
|
|
25632
|
-
const translator$l = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
|
|
25633
|
-
const translator$k = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
|
|
25634
|
-
const translator$j = NodeTranslator.from(createBorderPropertyHandler("w:left"));
|
|
25635
|
-
const translator$i = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
|
|
25636
|
-
const translator$h = NodeTranslator.from(createBorderPropertyHandler("w:right"));
|
|
25637
|
-
const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
|
|
25638
|
-
const translator$f = NodeTranslator.from(createBorderPropertyHandler("w:start"));
|
|
25639
|
-
const translator$e = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
|
|
25640
|
-
const translator$d = NodeTranslator.from(createBorderPropertyHandler("w:top"));
|
|
25641
|
-
const translator$c = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
|
|
25642
|
-
const XML_NODE_NAME$a = "w:tblBorders";
|
|
25643
|
-
const SD_ATTR_KEY$3 = "borders";
|
|
25644
|
-
const encode$a = (params) => {
|
|
25645
|
-
const { nodes } = params;
|
|
25646
|
-
const node = nodes[0];
|
|
25647
|
-
const attributes = encodeProperties(node, tblBordersTranslatorsByXmlName);
|
|
25648
|
-
return Object.keys(attributes).length > 0 ? attributes : void 0;
|
|
25649
|
-
};
|
|
25650
|
-
const decode$a = (params) => {
|
|
25651
|
-
const { borders = {} } = params.node.attrs || {};
|
|
25652
|
-
const elements = decodeProperties(tblBordersTranslatorsBySdName, borders);
|
|
25653
|
-
const newNode = {
|
|
25654
|
-
name: "w:tblBorders",
|
|
25655
|
-
type: "element",
|
|
25656
|
-
attributes: {},
|
|
25657
|
-
elements
|
|
25658
|
-
};
|
|
25659
|
-
return newNode;
|
|
25477
|
+
encode: encode$3,
|
|
25478
|
+
decode: decode$3,
|
|
25479
|
+
attributes: validXmlAttributes$3
|
|
25660
25480
|
};
|
|
25661
|
-
const
|
|
25662
|
-
|
|
25663
|
-
translator$n,
|
|
25664
|
-
translator$l,
|
|
25665
|
-
translator$k,
|
|
25666
|
-
translator$j,
|
|
25667
|
-
translator$h,
|
|
25668
|
-
translator$f,
|
|
25669
|
-
translator$d
|
|
25670
|
-
];
|
|
25671
|
-
const tblBordersTranslatorsByXmlName = {};
|
|
25672
|
-
const tblBordersTranslatorsBySdName = {};
|
|
25673
|
-
propertyTranslators$2.forEach((translator2) => {
|
|
25674
|
-
tblBordersTranslatorsByXmlName[translator2.xmlName] = translator2;
|
|
25675
|
-
tblBordersTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
|
|
25676
|
-
});
|
|
25677
|
-
const translator$b = NodeTranslator.from({
|
|
25678
|
-
xmlName: XML_NODE_NAME$a,
|
|
25679
|
-
sdNodeOrKeyName: SD_ATTR_KEY$3,
|
|
25680
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
25681
|
-
attributes: [],
|
|
25682
|
-
encode: encode$a,
|
|
25683
|
-
decode: decode$a
|
|
25684
|
-
});
|
|
25685
|
-
const XML_NODE_NAME$9 = "w:tblCellMar";
|
|
25686
|
-
const SD_ATTR_KEY$2 = "cellMargins";
|
|
25687
|
-
const encode$9 = (params) => {
|
|
25481
|
+
const translator$3 = NodeTranslator.from(config$3);
|
|
25482
|
+
const handleAllTableNodes = (params) => {
|
|
25688
25483
|
const { nodes } = params;
|
|
25484
|
+
if (nodes.length === 0) {
|
|
25485
|
+
return { nodes: [], consumed: 0 };
|
|
25486
|
+
}
|
|
25689
25487
|
const node = nodes[0];
|
|
25690
|
-
|
|
25691
|
-
|
|
25488
|
+
switch (node.name) {
|
|
25489
|
+
case "w:tbl":
|
|
25490
|
+
return { nodes: [handleTableNode(node, params)], consumed: 1 };
|
|
25491
|
+
}
|
|
25492
|
+
return { nodes: [], consumed: 0 };
|
|
25692
25493
|
};
|
|
25693
|
-
const
|
|
25694
|
-
|
|
25695
|
-
|
|
25696
|
-
const newNode = {
|
|
25697
|
-
name: XML_NODE_NAME$9,
|
|
25698
|
-
type: "element",
|
|
25699
|
-
attributes: {},
|
|
25700
|
-
elements
|
|
25701
|
-
};
|
|
25702
|
-
return newNode;
|
|
25494
|
+
const tableNodeHandlerEntity = {
|
|
25495
|
+
handlerName: "tableNodeHandler",
|
|
25496
|
+
handler: handleAllTableNodes
|
|
25703
25497
|
};
|
|
25704
|
-
|
|
25705
|
-
|
|
25706
|
-
|
|
25707
|
-
|
|
25708
|
-
|
|
25709
|
-
|
|
25710
|
-
|
|
25711
|
-
];
|
|
25712
|
-
const
|
|
25713
|
-
const
|
|
25714
|
-
|
|
25715
|
-
|
|
25716
|
-
|
|
25717
|
-
}
|
|
25718
|
-
const
|
|
25719
|
-
|
|
25720
|
-
|
|
25721
|
-
|
|
25722
|
-
|
|
25723
|
-
|
|
25724
|
-
|
|
25725
|
-
|
|
25726
|
-
|
|
25727
|
-
|
|
25728
|
-
|
|
25729
|
-
|
|
25730
|
-
|
|
25731
|
-
const
|
|
25498
|
+
function handleTableNode(node, params) {
|
|
25499
|
+
const { docx, nodeListHandler } = params;
|
|
25500
|
+
const tblPr = node.elements.find((el) => el.name === "w:tblPr");
|
|
25501
|
+
const tableBordersElement = tblPr.elements.find((el) => el.name === "w:tblBorders");
|
|
25502
|
+
const tableBorders = tableBordersElement?.elements || [];
|
|
25503
|
+
const { borders, rowBorders } = processTableBorders(tableBorders);
|
|
25504
|
+
const tblStyleTag = tblPr.elements.find((el) => el.name === "w:tblStyle");
|
|
25505
|
+
const tableStyleId = tblStyleTag?.attributes["w:val"];
|
|
25506
|
+
const attrs = { tableStyleId };
|
|
25507
|
+
const tableIndent = tblPr?.elements.find((el) => el.name === "w:tblInd");
|
|
25508
|
+
if (tableIndent) {
|
|
25509
|
+
const { "w:w": width, "w:type": type2 } = tableIndent.attributes;
|
|
25510
|
+
attrs["tableIndent"] = { width: twipsToPixels(width), type: type2 };
|
|
25511
|
+
}
|
|
25512
|
+
const tableLayout = tblPr?.elements.find((el) => el.name === "w:tblLayout");
|
|
25513
|
+
if (tableLayout) {
|
|
25514
|
+
const { "w:type": type2 } = tableLayout.attributes;
|
|
25515
|
+
attrs["tableLayout"] = type2;
|
|
25516
|
+
}
|
|
25517
|
+
const referencedStyles = getReferencedTableStyles(tblStyleTag, docx);
|
|
25518
|
+
const tblW = tblPr.elements.find((el) => el.name === "w:tblW");
|
|
25519
|
+
if (tblW) {
|
|
25520
|
+
attrs["tableWidth"] = {
|
|
25521
|
+
width: twipsToPixels(tblW.attributes["w:w"]),
|
|
25522
|
+
type: tblW.attributes["w:type"]
|
|
25523
|
+
};
|
|
25524
|
+
}
|
|
25525
|
+
const tblCellSpacing = tblPr.elements.find((el) => el.name === "w:tblCellSpacing");
|
|
25526
|
+
if (tblCellSpacing) {
|
|
25527
|
+
attrs["tableCellSpacing"] = {
|
|
25528
|
+
w: tblCellSpacing.attributes["w:w"],
|
|
25529
|
+
type: tblCellSpacing.attributes["w:type"]
|
|
25530
|
+
};
|
|
25531
|
+
attrs["borderCollapse"] = "separate";
|
|
25532
|
+
}
|
|
25533
|
+
const tblJustification = tblPr.elements.find((el) => el.name === "w:jc");
|
|
25534
|
+
if (tblJustification?.attributes) {
|
|
25535
|
+
attrs["justification"] = tblJustification.attributes["w:val"];
|
|
25536
|
+
}
|
|
25537
|
+
const rows = node.elements.filter((el) => el.name === "w:tr");
|
|
25538
|
+
const refStylesBorders = referencedStyles?.borders || {};
|
|
25539
|
+
const refStylesRowBorders = referencedStyles?.rowBorders || {};
|
|
25540
|
+
const borderData = Object.keys(borders)?.length ? Object.assign(refStylesBorders, borders) : refStylesBorders;
|
|
25541
|
+
const borderRowData = Object.keys(rowBorders)?.length ? Object.assign(refStylesRowBorders, rowBorders) : refStylesRowBorders;
|
|
25542
|
+
attrs["borders"] = borderData;
|
|
25543
|
+
const content = [];
|
|
25544
|
+
rows.forEach((row) => {
|
|
25545
|
+
const result = translator$3.encode({
|
|
25546
|
+
...params,
|
|
25547
|
+
nodes: [row],
|
|
25548
|
+
extraParams: {
|
|
25549
|
+
row,
|
|
25550
|
+
table: node,
|
|
25551
|
+
rowBorders: borderRowData,
|
|
25552
|
+
styleTag: tblStyleTag
|
|
25553
|
+
}
|
|
25554
|
+
});
|
|
25555
|
+
if (result.content?.length) content.push(result);
|
|
25556
|
+
});
|
|
25732
25557
|
return {
|
|
25733
|
-
|
|
25734
|
-
|
|
25735
|
-
|
|
25558
|
+
type: "table",
|
|
25559
|
+
content,
|
|
25560
|
+
attrs
|
|
25736
25561
|
};
|
|
25737
|
-
};
|
|
25738
|
-
const decode$8 = (params) => {
|
|
25739
|
-
const { tableProperties = {} } = params.node.attrs || {};
|
|
25740
|
-
const elements = decodeProperties(propertyTranslatorsBySdName, tableProperties);
|
|
25741
|
-
const newNode = {
|
|
25742
|
-
name: "w:tblPr",
|
|
25743
|
-
type: "element",
|
|
25744
|
-
attributes: {},
|
|
25745
|
-
elements
|
|
25746
|
-
};
|
|
25747
|
-
return newNode;
|
|
25748
|
-
};
|
|
25749
|
-
const propertyTranslators = [
|
|
25750
|
-
translator$C,
|
|
25751
|
-
translator$K,
|
|
25752
|
-
translator$B,
|
|
25753
|
-
translator$A,
|
|
25754
|
-
translator$J,
|
|
25755
|
-
translator$z,
|
|
25756
|
-
translator$y,
|
|
25757
|
-
translator$x,
|
|
25758
|
-
translator$w,
|
|
25759
|
-
translator$v,
|
|
25760
|
-
translator$u,
|
|
25761
|
-
translator$t,
|
|
25762
|
-
translator$s,
|
|
25763
|
-
translator$r,
|
|
25764
|
-
translator$q,
|
|
25765
|
-
translator$b,
|
|
25766
|
-
translator$a
|
|
25767
|
-
];
|
|
25768
|
-
const propertyTranslatorsByXmlName = {};
|
|
25769
|
-
const propertyTranslatorsBySdName = {};
|
|
25770
|
-
propertyTranslators.forEach((translator2) => {
|
|
25771
|
-
propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
|
|
25772
|
-
propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
|
|
25773
|
-
});
|
|
25774
|
-
const config$8 = {
|
|
25775
|
-
xmlName: XML_NODE_NAME$8,
|
|
25776
|
-
sdNodeOrKeyName: SD_ATTR_KEY$1,
|
|
25777
|
-
encode: encode$8,
|
|
25778
|
-
decode: decode$8
|
|
25779
|
-
};
|
|
25780
|
-
const translator$9 = NodeTranslator.from(config$8);
|
|
25781
|
-
const translator$8 = NodeTranslator.from(
|
|
25782
|
-
createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
|
|
25783
|
-
);
|
|
25784
|
-
const DEFAULT_COLUMN_WIDTH_PX = 100;
|
|
25785
|
-
const normalizeTwipWidth = (value) => {
|
|
25786
|
-
if (value == null) return null;
|
|
25787
|
-
const numericValue = typeof value === "string" ? parseInt(value, 10) : value;
|
|
25788
|
-
if (!Number.isFinite(numericValue) || Number.isNaN(numericValue) || numericValue <= 0) {
|
|
25789
|
-
return null;
|
|
25790
|
-
}
|
|
25791
|
-
return numericValue;
|
|
25792
|
-
};
|
|
25793
|
-
const getSchemaDefaultColumnWidthPx = (params) => {
|
|
25794
|
-
const defaultValue = params?.editor?.schema?.nodes?.tableCell?.spec?.attrs?.colwidth?.default;
|
|
25795
|
-
if (Array.isArray(defaultValue)) {
|
|
25796
|
-
const numericWidth = defaultValue.find((width) => typeof width === "number" && Number.isFinite(width) && width > 0);
|
|
25797
|
-
if (numericWidth != null) return numericWidth;
|
|
25798
|
-
} else if (typeof defaultValue === "number" && Number.isFinite(defaultValue) && defaultValue > 0) {
|
|
25799
|
-
return defaultValue;
|
|
25800
|
-
}
|
|
25801
|
-
return DEFAULT_COLUMN_WIDTH_PX;
|
|
25802
|
-
};
|
|
25803
|
-
const getTableWidthPx = (params) => {
|
|
25804
|
-
const explicitWidth = params?.node?.attrs?.tableWidth?.width;
|
|
25805
|
-
if (typeof explicitWidth === "number" && explicitWidth > 0) return explicitWidth;
|
|
25806
|
-
const tableWidth = params?.node?.attrs?.tableProperties?.tableWidth;
|
|
25807
|
-
if (tableWidth?.value != null && typeof tableWidth.value === "number" && tableWidth.value > 0) {
|
|
25808
|
-
const { value, type: type2 } = tableWidth;
|
|
25809
|
-
if (!type2 || type2 === "auto" || type2 === "dxa") {
|
|
25810
|
-
return twipsToPixels(value);
|
|
25811
|
-
}
|
|
25812
|
-
}
|
|
25813
|
-
return null;
|
|
25814
|
-
};
|
|
25815
|
-
const resolveFallbackColumnWidthTwips = (params, totalColumns, cellMinWidthTwips) => {
|
|
25816
|
-
const columnCount = Math.max(totalColumns, 1);
|
|
25817
|
-
const defaultColumnWidthPx = getSchemaDefaultColumnWidthPx(params);
|
|
25818
|
-
const tableWidthPx = getTableWidthPx(params);
|
|
25819
|
-
const safeDefaultPx = Number.isFinite(defaultColumnWidthPx) && defaultColumnWidthPx > 0 ? defaultColumnWidthPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
25820
|
-
let fallbackWidthPx = safeDefaultPx;
|
|
25821
|
-
if (typeof tableWidthPx === "number" && tableWidthPx > 0) {
|
|
25822
|
-
fallbackWidthPx = tableWidthPx / columnCount;
|
|
25823
|
-
}
|
|
25824
|
-
const fallbackWidthTwips = pixelsToTwips(fallbackWidthPx);
|
|
25825
|
-
if (!Number.isFinite(fallbackWidthTwips) || Number.isNaN(fallbackWidthTwips) || fallbackWidthTwips <= 0) {
|
|
25826
|
-
const safeDefault = Math.max(pixelsToTwips(safeDefaultPx), cellMinWidthTwips);
|
|
25827
|
-
return safeDefault;
|
|
25828
|
-
}
|
|
25829
|
-
return Math.max(fallbackWidthTwips, cellMinWidthTwips);
|
|
25830
|
-
};
|
|
25831
|
-
const XML_NODE_NAME$7 = "w:tblGrid";
|
|
25832
|
-
const SD_ATTR_KEY = "grid";
|
|
25833
|
-
const cellMinWidth = pixelsToTwips(10);
|
|
25834
|
-
const encode$7 = (params) => {
|
|
25835
|
-
const { nodes } = params;
|
|
25836
|
-
const node = nodes[0];
|
|
25837
|
-
const attributes = encodeProperties(node, { [translator$8.xmlName]: translator$8 }, true);
|
|
25838
|
-
return {
|
|
25839
|
-
xmlName: XML_NODE_NAME$7,
|
|
25840
|
-
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
25841
|
-
attributes
|
|
25842
|
-
};
|
|
25843
|
-
};
|
|
25844
|
-
const decode$7 = (params) => {
|
|
25845
|
-
const { grid: rawGrid } = params.node.attrs || {};
|
|
25846
|
-
const grid = Array.isArray(rawGrid) ? rawGrid : [];
|
|
25847
|
-
const { firstRow = {} } = params.extraParams || {};
|
|
25848
|
-
const cellNodes = firstRow.content?.filter((n) => n.type === "tableCell") ?? [];
|
|
25849
|
-
const columnCountFromCells = cellNodes.reduce((count, cell) => {
|
|
25850
|
-
const spanCount = Math.max(1, cell?.attrs?.colspan ?? 1);
|
|
25851
|
-
return count + spanCount;
|
|
25852
|
-
}, 0);
|
|
25853
|
-
const totalColumns = Math.max(columnCountFromCells, grid.length);
|
|
25854
|
-
const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params, totalColumns, cellMinWidth);
|
|
25855
|
-
const elements = [];
|
|
25856
|
-
let columnIndex = 0;
|
|
25857
|
-
const pushColumn = (widthTwips) => {
|
|
25858
|
-
let numericWidth = typeof widthTwips === "string" ? parseInt(widthTwips, 10) : widthTwips;
|
|
25859
|
-
if (numericWidth == null || Number.isNaN(numericWidth) || numericWidth <= 0) {
|
|
25860
|
-
numericWidth = fallbackColumnWidthTwips;
|
|
25861
|
-
}
|
|
25862
|
-
numericWidth = Math.max(numericWidth, cellMinWidth);
|
|
25863
|
-
const decoded = translator$8.decode({
|
|
25864
|
-
node: { type: (
|
|
25865
|
-
/** @type {string} */
|
|
25866
|
-
translator$8.sdNodeOrKeyName
|
|
25867
|
-
), attrs: { col: numericWidth } }
|
|
25868
|
-
});
|
|
25869
|
-
if (decoded) elements.push(decoded);
|
|
25870
|
-
};
|
|
25871
|
-
cellNodes.forEach((cell) => {
|
|
25872
|
-
const { colspan = 1, colwidth } = cell?.attrs || {};
|
|
25873
|
-
const spanCount = Math.max(1, colspan);
|
|
25874
|
-
for (let span = 0; span < spanCount; span++) {
|
|
25875
|
-
const cellWidthPixels = Array.isArray(colwidth) ? colwidth[span] : void 0;
|
|
25876
|
-
const colGridAttrs = grid?.[columnIndex] || {};
|
|
25877
|
-
const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
|
|
25878
|
-
const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
|
|
25879
|
-
let cellWidthTwips;
|
|
25880
|
-
if (cellWidthPixels != null) {
|
|
25881
|
-
if (gridWidthTwips != null && gridWidthPixels === cellWidthPixels) {
|
|
25882
|
-
cellWidthTwips = gridWidthTwips;
|
|
25883
|
-
} else {
|
|
25884
|
-
cellWidthTwips = pixelsToTwips(cellWidthPixels);
|
|
25885
|
-
}
|
|
25886
|
-
} else if (gridWidthTwips != null) {
|
|
25887
|
-
cellWidthTwips = gridWidthTwips;
|
|
25888
|
-
} else {
|
|
25889
|
-
cellWidthTwips = fallbackColumnWidthTwips;
|
|
25890
|
-
}
|
|
25891
|
-
pushColumn(cellWidthTwips);
|
|
25892
|
-
columnIndex++;
|
|
25893
|
-
}
|
|
25894
|
-
});
|
|
25895
|
-
while (columnIndex < grid.length) {
|
|
25896
|
-
const gridWidthTwips = normalizeTwipWidth(grid[columnIndex]?.col);
|
|
25897
|
-
pushColumn(gridWidthTwips);
|
|
25898
|
-
columnIndex++;
|
|
25899
|
-
}
|
|
25900
|
-
const newNode = {
|
|
25901
|
-
name: XML_NODE_NAME$7,
|
|
25902
|
-
attributes: {},
|
|
25903
|
-
elements
|
|
25904
|
-
};
|
|
25905
|
-
return newNode;
|
|
25906
|
-
};
|
|
25907
|
-
const config$7 = {
|
|
25908
|
-
xmlName: XML_NODE_NAME$7,
|
|
25909
|
-
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
25910
|
-
encode: encode$7,
|
|
25911
|
-
decode: decode$7
|
|
25912
|
-
};
|
|
25913
|
-
const translator$7 = NodeTranslator.from(config$7);
|
|
25914
|
-
const XML_NODE_NAME$6 = "w:tbl";
|
|
25915
|
-
const SD_NODE_NAME$6 = "table";
|
|
25916
|
-
const encode$6 = (params, encodedAttrs) => {
|
|
25917
|
-
const { nodes } = params;
|
|
25918
|
-
const node = nodes[0];
|
|
25919
|
-
const tblPr = node.elements.find((el) => el.name === "w:tblPr");
|
|
25920
|
-
if (tblPr) {
|
|
25921
|
-
const encodedProperties = translator$9.encode({ ...params, nodes: [tblPr] });
|
|
25922
|
-
encodedAttrs["tableProperties"] = encodedProperties?.attributes || {};
|
|
25923
|
-
}
|
|
25924
|
-
const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
|
|
25925
|
-
if (tblGrid) {
|
|
25926
|
-
encodedAttrs["grid"] = translator$7.encode({ ...params, nodes: [tblGrid] }).attributes;
|
|
25927
|
-
}
|
|
25928
|
-
[
|
|
25929
|
-
"tableStyleId",
|
|
25930
|
-
"justification",
|
|
25931
|
-
"tableLayout",
|
|
25932
|
-
["tableIndent", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
25933
|
-
["tableWidth", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
25934
|
-
["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
|
|
25935
|
-
].forEach((prop) => {
|
|
25936
|
-
let key;
|
|
25937
|
-
let transform;
|
|
25938
|
-
if (Array.isArray(prop)) {
|
|
25939
|
-
[key, transform] = prop;
|
|
25940
|
-
} else {
|
|
25941
|
-
key = prop;
|
|
25942
|
-
transform = (v2) => v2;
|
|
25943
|
-
}
|
|
25944
|
-
if (encodedAttrs.tableProperties && encodedAttrs.tableProperties[key]) {
|
|
25945
|
-
encodedAttrs[key] = transform(encodedAttrs.tableProperties[key]);
|
|
25946
|
-
}
|
|
25947
|
-
});
|
|
25948
|
-
if (encodedAttrs.tableCellSpacing) {
|
|
25949
|
-
encodedAttrs["borderCollapse"] = "separate";
|
|
25950
|
-
}
|
|
25951
|
-
const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
|
|
25952
|
-
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params);
|
|
25953
|
-
if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
|
|
25954
|
-
encodedAttrs.tableProperties = {
|
|
25955
|
-
...encodedAttrs.tableProperties || {},
|
|
25956
|
-
cellMargins: referencedStyles.cellMargins
|
|
25957
|
-
};
|
|
25958
|
-
}
|
|
25959
|
-
const rows = node.elements.filter((el) => el.name === "w:tr");
|
|
25960
|
-
const borderData = Object.assign({}, referencedStyles?.borders || {}, borders || {});
|
|
25961
|
-
const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
|
|
25962
|
-
encodedAttrs["borders"] = borderData;
|
|
25963
|
-
const tblStyleTag = tblPr?.elements?.find((el) => el.name === "w:tblStyle");
|
|
25964
|
-
const columnWidths = (encodedAttrs["grid"] ?? []).map((item) => twipsToPixels(item.col));
|
|
25965
|
-
const content = [];
|
|
25966
|
-
rows.forEach((row) => {
|
|
25967
|
-
const result = translator$D.encode({
|
|
25968
|
-
...params,
|
|
25969
|
-
nodes: [row],
|
|
25970
|
-
extraParams: {
|
|
25971
|
-
row,
|
|
25972
|
-
table: node,
|
|
25973
|
-
rowBorders: borderRowData,
|
|
25974
|
-
styleTag: tblStyleTag,
|
|
25975
|
-
columnWidths
|
|
25976
|
-
}
|
|
25977
|
-
});
|
|
25978
|
-
if (result.content?.length) content.push(result);
|
|
25979
|
-
});
|
|
25980
|
-
return {
|
|
25981
|
-
type: "table",
|
|
25982
|
-
content,
|
|
25983
|
-
attrs: encodedAttrs
|
|
25984
|
-
};
|
|
25985
|
-
};
|
|
25986
|
-
const decode$6 = (params, decodedAttrs) => {
|
|
25987
|
-
params.node = preProcessVerticalMergeCells(params.node, params);
|
|
25988
|
-
const { node } = params;
|
|
25989
|
-
const elements = translateChildNodes(params);
|
|
25990
|
-
const firstRow = node.content?.find((n) => n.type === "tableRow");
|
|
25991
|
-
const properties = node.attrs.grid;
|
|
25992
|
-
const element = translator$7.decode({
|
|
25993
|
-
...params,
|
|
25994
|
-
node: { ...node, attrs: { ...node.attrs, grid: properties } },
|
|
25995
|
-
extraParams: {
|
|
25996
|
-
firstRow
|
|
25997
|
-
}
|
|
25998
|
-
});
|
|
25999
|
-
if (element) elements.unshift(element);
|
|
26000
|
-
if (node.attrs?.tableProperties) {
|
|
26001
|
-
const properties2 = { ...node.attrs.tableProperties };
|
|
26002
|
-
const element2 = translator$9.decode({
|
|
26003
|
-
...params,
|
|
26004
|
-
node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
|
|
26005
|
-
});
|
|
26006
|
-
if (element2) elements.unshift(element2);
|
|
26007
|
-
}
|
|
26008
|
-
return {
|
|
26009
|
-
name: "w:tbl",
|
|
26010
|
-
attributes: decodedAttrs || {},
|
|
26011
|
-
elements
|
|
26012
|
-
};
|
|
26013
|
-
};
|
|
26014
|
-
function _processTableBorders(rawBorders) {
|
|
26015
|
-
const borders = {};
|
|
26016
|
-
const rowBorders = {};
|
|
26017
|
-
Object.entries(rawBorders).forEach(([name, attributes]) => {
|
|
26018
|
-
const attrs = {};
|
|
26019
|
-
const color = attributes.color;
|
|
26020
|
-
const size = attributes.size;
|
|
26021
|
-
if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
|
|
26022
|
-
if (size && size !== "auto") attrs["size"] = eigthPointsToPixels(size);
|
|
26023
|
-
const rowBorderNames = ["insideH", "insideV"];
|
|
26024
|
-
if (rowBorderNames.includes(name)) rowBorders[name] = attrs;
|
|
26025
|
-
borders[name] = attrs;
|
|
26026
|
-
});
|
|
26027
|
-
return {
|
|
26028
|
-
borders,
|
|
26029
|
-
rowBorders
|
|
26030
|
-
};
|
|
26031
|
-
}
|
|
26032
|
-
function _getReferencedTableStyles(tableStyleReference, params) {
|
|
26033
|
-
if (!tableStyleReference) return null;
|
|
26034
|
-
const stylesToReturn = {};
|
|
26035
|
-
const { docx } = params;
|
|
26036
|
-
const styles = docx["word/styles.xml"];
|
|
26037
|
-
const { elements } = styles.elements[0];
|
|
26038
|
-
const styleElements = elements.filter((el) => el.name === "w:style");
|
|
26039
|
-
const styleTag = styleElements.find((el) => el.attributes["w:styleId"] === tableStyleReference);
|
|
26040
|
-
if (!styleTag) return null;
|
|
26041
|
-
stylesToReturn.name = styleTag.elements.find((el) => el.name === "w:name");
|
|
26042
|
-
const basedOn = styleTag.elements.find((el) => el.name === "w:basedOn");
|
|
26043
|
-
let baseTblPr;
|
|
26044
|
-
if (basedOn?.attributes) {
|
|
26045
|
-
const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
|
|
26046
|
-
baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
|
|
26047
|
-
}
|
|
26048
|
-
const pPr = styleTag.elements.find((el) => el.name === "w:pPr");
|
|
26049
|
-
if (pPr) {
|
|
26050
|
-
const justification = pPr.elements.find((el) => el.name === "w:jc");
|
|
26051
|
-
if (justification?.attributes) stylesToReturn.justification = justification.attributes["w:val"];
|
|
26052
|
-
}
|
|
26053
|
-
const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
|
|
26054
|
-
if (rPr) {
|
|
26055
|
-
const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
|
|
26056
|
-
if (fonts) {
|
|
26057
|
-
const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
|
|
26058
|
-
stylesToReturn.fonts = { ascii, hAnsi, cs };
|
|
26059
|
-
}
|
|
26060
|
-
const fontSize = rPr.elements.find((el) => el.name === "w:sz");
|
|
26061
|
-
if (fontSize?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize.attributes["w:val"]) + "pt";
|
|
26062
|
-
}
|
|
26063
|
-
const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
|
|
26064
|
-
if (tblPr && tblPr.elements) {
|
|
26065
|
-
if (baseTblPr && baseTblPr.elements) {
|
|
26066
|
-
tblPr.elements.push(...baseTblPr.elements);
|
|
26067
|
-
}
|
|
26068
|
-
const tableProperties = translator$9.encode({ ...params, nodes: [tblPr] }).attributes;
|
|
26069
|
-
const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
|
|
26070
|
-
if (borders) stylesToReturn.borders = borders;
|
|
26071
|
-
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
26072
|
-
const cellMargins = {};
|
|
26073
|
-
Object.entries(tableProperties.cellMargins || {}).forEach(([key, attrs]) => {
|
|
26074
|
-
if (attrs?.value != null) {
|
|
26075
|
-
cellMargins[key] = {
|
|
26076
|
-
value: attrs.value,
|
|
26077
|
-
type: attrs.type || "dxa"
|
|
26078
|
-
};
|
|
26079
|
-
}
|
|
26080
|
-
});
|
|
26081
|
-
if (Object.keys(cellMargins).length) stylesToReturn.cellMargins = cellMargins;
|
|
26082
|
-
}
|
|
26083
|
-
return stylesToReturn;
|
|
26084
25562
|
}
|
|
26085
|
-
const config$6 = {
|
|
26086
|
-
xmlName: XML_NODE_NAME$6,
|
|
26087
|
-
sdNodeOrKeyName: SD_NODE_NAME$6,
|
|
26088
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
26089
|
-
encode: encode$6,
|
|
26090
|
-
decode: decode$6,
|
|
26091
|
-
attributes: []
|
|
26092
|
-
};
|
|
26093
|
-
const translator$6 = NodeTranslator.from(config$6);
|
|
26094
|
-
const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$6);
|
|
26095
25563
|
function getReferencedTableStyles(tblStyleTag, docx) {
|
|
26096
25564
|
if (!tblStyleTag) return null;
|
|
26097
25565
|
const stylesToReturn = {};
|
|
@@ -26172,6 +25640,15 @@ function processTableBorders(borderElements) {
|
|
|
26172
25640
|
rowBorders
|
|
26173
25641
|
};
|
|
26174
25642
|
}
|
|
25643
|
+
const getGridColumnWidths = (tableNode) => {
|
|
25644
|
+
const tblGrid = tableNode.elements.find((el) => el.name === "w:tblGrid");
|
|
25645
|
+
if (!tblGrid) return [];
|
|
25646
|
+
const columnWidths = tblGrid?.elements?.flatMap((el) => {
|
|
25647
|
+
if (el.name !== "w:gridCol") return [];
|
|
25648
|
+
return twipsToPixels(el.attributes["w:w"]);
|
|
25649
|
+
}) || [];
|
|
25650
|
+
return columnWidths;
|
|
25651
|
+
};
|
|
26175
25652
|
function handleTableCellNode({
|
|
26176
25653
|
params,
|
|
26177
25654
|
node,
|
|
@@ -26180,8 +25657,7 @@ function handleTableCellNode({
|
|
|
26180
25657
|
rowBorders,
|
|
26181
25658
|
styleTag,
|
|
26182
25659
|
columnIndex,
|
|
26183
|
-
columnWidth = null
|
|
26184
|
-
allColumnWidths = []
|
|
25660
|
+
columnWidth = null
|
|
26185
25661
|
}) {
|
|
26186
25662
|
const { docx, nodeListHandler } = params;
|
|
26187
25663
|
const tcPr = node.elements.find((el) => el.name === "w:tcPr");
|
|
@@ -26195,7 +25671,7 @@ function handleTableCellNode({
|
|
|
26195
25671
|
delete rowBorders?.insideV;
|
|
26196
25672
|
}
|
|
26197
25673
|
const inlineBorders = processInlineCellBorders(borders, rowBorders);
|
|
26198
|
-
const gridColumnWidths =
|
|
25674
|
+
const gridColumnWidths = getGridColumnWidths(table);
|
|
26199
25675
|
const tcWidth = tcPr?.elements?.find((el) => el.name === "w:tcW");
|
|
26200
25676
|
let width = tcWidth ? twipsToPixels(tcWidth.attributes["w:w"]) : null;
|
|
26201
25677
|
const widthType = tcWidth?.attributes["w:type"];
|
|
@@ -26329,17 +25805,11 @@ const getTableCellMargins = (marginTag, referencedStyles) => {
|
|
|
26329
25805
|
marginTop: marginTopStyle,
|
|
26330
25806
|
marginBottom: marginBottomStyle
|
|
26331
25807
|
} = cellMargins;
|
|
26332
|
-
const resolveMargin = (inlineValue, styleValue) => {
|
|
26333
|
-
if (inlineValue != null) return inlineValue;
|
|
26334
|
-
if (styleValue == null) return void 0;
|
|
26335
|
-
if (typeof styleValue === "object") return styleValue.value;
|
|
26336
|
-
return styleValue;
|
|
26337
|
-
};
|
|
26338
25808
|
const margins = {
|
|
26339
|
-
left: twipsToPixels(
|
|
26340
|
-
right: twipsToPixels(
|
|
26341
|
-
top: twipsToPixels(
|
|
26342
|
-
bottom: twipsToPixels(
|
|
25809
|
+
left: twipsToPixels(inlineMarginLeftValue ?? marginLeftStyle),
|
|
25810
|
+
right: twipsToPixels(inlineMarginRightValue ?? marginRightStyle),
|
|
25811
|
+
top: twipsToPixels(inlineMarginTopValue ?? marginTopStyle),
|
|
25812
|
+
bottom: twipsToPixels(inlineMarginBottomValue ?? marginBottomStyle)
|
|
26343
25813
|
};
|
|
26344
25814
|
return margins;
|
|
26345
25815
|
};
|
|
@@ -26453,20 +25923,11 @@ function generateCellMargins(cellMargins) {
|
|
|
26453
25923
|
if (left != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left) } });
|
|
26454
25924
|
return elements;
|
|
26455
25925
|
}
|
|
26456
|
-
const XML_NODE_NAME$
|
|
26457
|
-
const SD_NODE_NAME$
|
|
26458
|
-
const validXmlAttributes$
|
|
26459
|
-
function encode$
|
|
26460
|
-
const {
|
|
26461
|
-
node,
|
|
26462
|
-
table,
|
|
26463
|
-
row,
|
|
26464
|
-
rowBorders,
|
|
26465
|
-
styleTag,
|
|
26466
|
-
columnIndex,
|
|
26467
|
-
columnWidth,
|
|
26468
|
-
columnWidths: allColumnWidths
|
|
26469
|
-
} = params.extraParams;
|
|
25926
|
+
const XML_NODE_NAME$2 = "w:tc";
|
|
25927
|
+
const SD_NODE_NAME$2 = "tableCell";
|
|
25928
|
+
const validXmlAttributes$2 = [];
|
|
25929
|
+
function encode$2(params, encodedAttrs) {
|
|
25930
|
+
const { node, table, row, rowBorders, styleTag, columnIndex, columnWidth } = params.extraParams;
|
|
26470
25931
|
const schemaNode = handleTableCellNode({
|
|
26471
25932
|
params,
|
|
26472
25933
|
node,
|
|
@@ -26475,39 +25936,38 @@ function encode$5(params, encodedAttrs) {
|
|
|
26475
25936
|
rowBorders,
|
|
26476
25937
|
styleTag,
|
|
26477
25938
|
columnIndex,
|
|
26478
|
-
columnWidth
|
|
26479
|
-
allColumnWidths
|
|
25939
|
+
columnWidth
|
|
26480
25940
|
});
|
|
26481
25941
|
if (encodedAttrs && Object.keys(encodedAttrs).length) {
|
|
26482
25942
|
schemaNode.attrs = { ...schemaNode.attrs, ...encodedAttrs };
|
|
26483
25943
|
}
|
|
26484
25944
|
return schemaNode;
|
|
26485
25945
|
}
|
|
26486
|
-
function decode$
|
|
25946
|
+
function decode$2(params, decodedAttrs) {
|
|
26487
25947
|
const translated = translateTableCell(params);
|
|
26488
25948
|
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
26489
25949
|
translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
|
|
26490
25950
|
}
|
|
26491
25951
|
return translated;
|
|
26492
25952
|
}
|
|
26493
|
-
const config$
|
|
26494
|
-
xmlName: XML_NODE_NAME$
|
|
26495
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
25953
|
+
const config$2 = {
|
|
25954
|
+
xmlName: XML_NODE_NAME$2,
|
|
25955
|
+
sdNodeOrKeyName: SD_NODE_NAME$2,
|
|
26496
25956
|
type: NodeTranslator.translatorTypes.NODE,
|
|
26497
|
-
encode: encode$
|
|
26498
|
-
decode: decode$
|
|
26499
|
-
attributes: validXmlAttributes$
|
|
25957
|
+
encode: encode$2,
|
|
25958
|
+
decode: decode$2,
|
|
25959
|
+
attributes: validXmlAttributes$2
|
|
26500
25960
|
};
|
|
26501
|
-
const translator$
|
|
26502
|
-
const XML_NODE_NAME$
|
|
26503
|
-
const SD_NODE_NAME$
|
|
25961
|
+
const translator$2 = NodeTranslator.from(config$2);
|
|
25962
|
+
const XML_NODE_NAME$1 = "w:hyperlink";
|
|
25963
|
+
const SD_NODE_NAME$1 = "link";
|
|
26504
25964
|
const _createAttributeHandler = (xmlName, sdName) => ({
|
|
26505
25965
|
xmlName,
|
|
26506
25966
|
sdName,
|
|
26507
25967
|
encode: (attributes) => attributes[xmlName],
|
|
26508
25968
|
decode: (attributes) => attributes[sdName]
|
|
26509
25969
|
});
|
|
26510
|
-
const validXmlAttributes$
|
|
25970
|
+
const validXmlAttributes$1 = [
|
|
26511
25971
|
_createAttributeHandler("w:anchor", "anchor"),
|
|
26512
25972
|
_createAttributeHandler("w:docLocation", "docLocation"),
|
|
26513
25973
|
{
|
|
@@ -26520,7 +25980,7 @@ const validXmlAttributes$4 = [
|
|
|
26520
25980
|
_createAttributeHandler("r:id", "rId"),
|
|
26521
25981
|
_createAttributeHandler("w:tgtFrame", "target")
|
|
26522
25982
|
];
|
|
26523
|
-
const encode$
|
|
25983
|
+
const encode$1 = (params, encodedAttrs) => {
|
|
26524
25984
|
const { nodes, docx, nodeListHandler } = params;
|
|
26525
25985
|
const node = nodes[0];
|
|
26526
25986
|
let href = _resolveHref(docx, encodedAttrs);
|
|
@@ -26551,7 +26011,7 @@ const _resolveHref = (docx, encodedAttrs) => {
|
|
|
26551
26011
|
}
|
|
26552
26012
|
return href;
|
|
26553
26013
|
};
|
|
26554
|
-
function decode$
|
|
26014
|
+
function decode$1(params) {
|
|
26555
26015
|
const { node } = params;
|
|
26556
26016
|
const linkMark = node.marks.find((m2) => m2.type === "link");
|
|
26557
26017
|
const linkAttrs = this.decodeAttributes({ ...params, node: linkMark });
|
|
@@ -26595,15 +26055,15 @@ function _addNewLinkRelationship(params, link, rId) {
|
|
|
26595
26055
|
});
|
|
26596
26056
|
return rId;
|
|
26597
26057
|
}
|
|
26598
|
-
const config$
|
|
26599
|
-
xmlName: XML_NODE_NAME$
|
|
26600
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
26058
|
+
const config$1 = {
|
|
26059
|
+
xmlName: XML_NODE_NAME$1,
|
|
26060
|
+
sdNodeOrKeyName: SD_NODE_NAME$1,
|
|
26601
26061
|
type: NodeTranslator.translatorTypes.NODE,
|
|
26602
|
-
encode: encode$
|
|
26603
|
-
decode: decode$
|
|
26604
|
-
attributes: validXmlAttributes$
|
|
26062
|
+
encode: encode$1,
|
|
26063
|
+
decode: decode$1,
|
|
26064
|
+
attributes: validXmlAttributes$1
|
|
26605
26065
|
};
|
|
26606
|
-
const translator$
|
|
26066
|
+
const translator$1 = NodeTranslator.from(config$1);
|
|
26607
26067
|
function parseTagValueJSON(json) {
|
|
26608
26068
|
if (typeof json !== "string") {
|
|
26609
26069
|
return {};
|
|
@@ -26614,7 +26074,7 @@ function parseTagValueJSON(json) {
|
|
|
26614
26074
|
}
|
|
26615
26075
|
try {
|
|
26616
26076
|
return JSON.parse(trimmed);
|
|
26617
|
-
} catch {
|
|
26077
|
+
} catch (err) {
|
|
26618
26078
|
return {};
|
|
26619
26079
|
}
|
|
26620
26080
|
}
|
|
@@ -26843,673 +26303,8 @@ function sdtNodeTypeStrategy(node) {
|
|
|
26843
26303
|
if (sdtContent) {
|
|
26844
26304
|
return { type: "structuredContent", handler: handleStructuredContentNode };
|
|
26845
26305
|
}
|
|
26846
|
-
return { type: "unknown", handler: null };
|
|
26847
|
-
}
|
|
26848
|
-
function handleImageNode(node, params, isAnchor) {
|
|
26849
|
-
const { docx, filename } = params;
|
|
26850
|
-
const { attributes } = node;
|
|
26851
|
-
const padding = {
|
|
26852
|
-
top: emuToPixels(attributes["distT"]),
|
|
26853
|
-
bottom: emuToPixels(attributes["distB"]),
|
|
26854
|
-
left: emuToPixels(attributes["distL"]),
|
|
26855
|
-
right: emuToPixels(attributes["distR"])
|
|
26856
|
-
};
|
|
26857
|
-
const extent = node.elements.find((el) => el.name === "wp:extent");
|
|
26858
|
-
const size = {
|
|
26859
|
-
width: emuToPixels(extent.attributes?.cx),
|
|
26860
|
-
height: emuToPixels(extent.attributes?.cy)
|
|
26861
|
-
};
|
|
26862
|
-
const graphic = node.elements.find((el) => el.name === "a:graphic");
|
|
26863
|
-
const graphicData = graphic.elements.find((el) => el.name === "a:graphicData");
|
|
26864
|
-
const { uri: uri2 } = graphicData?.attributes || {};
|
|
26865
|
-
const shapeURI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
26866
|
-
if (!!uri2 && uri2 === shapeURI) {
|
|
26867
|
-
return handleShapeDrawing(params, node, graphicData);
|
|
26868
|
-
}
|
|
26869
|
-
const picture = graphicData.elements.find((el) => el.name === "pic:pic");
|
|
26870
|
-
if (!picture || !picture.elements) return null;
|
|
26871
|
-
const blipFill = picture.elements.find((el) => el.name === "pic:blipFill");
|
|
26872
|
-
const blip = blipFill.elements.find((el) => el.name === "a:blip");
|
|
26873
|
-
const spPr = picture.elements.find((el) => el.name === "pic:spPr");
|
|
26874
|
-
let transformData = {};
|
|
26875
|
-
if (spPr) {
|
|
26876
|
-
const xfrm = spPr.elements.find((el) => el.name === "a:xfrm");
|
|
26877
|
-
if (xfrm?.attributes) {
|
|
26878
|
-
transformData = {
|
|
26879
|
-
rotation: rotToDegrees(xfrm.attributes["rot"]),
|
|
26880
|
-
verticalFlip: xfrm.attributes["flipV"] === "1",
|
|
26881
|
-
horizontalFlip: xfrm.attributes["flipH"] === "1"
|
|
26882
|
-
};
|
|
26883
|
-
}
|
|
26884
|
-
}
|
|
26885
|
-
const effectExtent = node.elements.find((el) => el.name === "wp:effectExtent");
|
|
26886
|
-
if (effectExtent) {
|
|
26887
|
-
const sanitizeEmuValue = (value) => {
|
|
26888
|
-
if (value === null || value === void 0) return 0;
|
|
26889
|
-
const numeric = Number(value);
|
|
26890
|
-
return Number.isFinite(numeric) ? numeric : 0;
|
|
26891
|
-
};
|
|
26892
|
-
transformData.sizeExtension = {
|
|
26893
|
-
left: emuToPixels(sanitizeEmuValue(effectExtent.attributes["l"])),
|
|
26894
|
-
top: emuToPixels(sanitizeEmuValue(effectExtent.attributes["t"])),
|
|
26895
|
-
right: emuToPixels(sanitizeEmuValue(effectExtent.attributes["r"])),
|
|
26896
|
-
bottom: emuToPixels(sanitizeEmuValue(effectExtent.attributes["b"]))
|
|
26897
|
-
};
|
|
26898
|
-
}
|
|
26899
|
-
const positionHTag = node.elements.find((el) => el.name === "wp:positionH");
|
|
26900
|
-
const positionH = positionHTag?.elements.find((el) => el.name === "wp:posOffset");
|
|
26901
|
-
const positionHValue = emuToPixels(positionH?.elements[0]?.text);
|
|
26902
|
-
const hRelativeFrom = positionHTag?.attributes.relativeFrom;
|
|
26903
|
-
const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
26904
|
-
const positionVTag = node.elements.find((el) => el.name === "wp:positionV");
|
|
26905
|
-
const positionV = positionVTag?.elements?.find((el) => el.name === "wp:posOffset");
|
|
26906
|
-
const positionVValue = emuToPixels(positionV?.elements[0]?.text);
|
|
26907
|
-
const vRelativeFrom = positionVTag?.attributes.relativeFrom;
|
|
26908
|
-
const alignV = positionVTag?.elements?.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
26909
|
-
const simplePos = node.elements.find((el) => el.name === "wp:simplePos");
|
|
26910
|
-
const wrapSquare = node.elements.find((el) => el.name === "wp:wrapSquare");
|
|
26911
|
-
const wrapTopAndBottom = node.elements.find((el) => el.name === "wp:wrapTopAndBottom");
|
|
26912
|
-
const docPr = node.elements.find((el) => el.name === "wp:docPr");
|
|
26913
|
-
let anchorData = null;
|
|
26914
|
-
if (hRelativeFrom || alignH || vRelativeFrom || alignV) {
|
|
26915
|
-
anchorData = {
|
|
26916
|
-
hRelativeFrom,
|
|
26917
|
-
vRelativeFrom,
|
|
26918
|
-
alignH,
|
|
26919
|
-
alignV
|
|
26920
|
-
};
|
|
26921
|
-
}
|
|
26922
|
-
const marginOffset = {
|
|
26923
|
-
left: positionHValue,
|
|
26924
|
-
top: positionVValue
|
|
26925
|
-
};
|
|
26926
|
-
const { attributes: blipAttributes = {} } = blip;
|
|
26927
|
-
const rEmbed = blipAttributes["r:embed"];
|
|
26928
|
-
if (!rEmbed) return null;
|
|
26929
|
-
const currentFile = filename || "document.xml";
|
|
26930
|
-
let rels = docx[`word/_rels/${currentFile}.rels`];
|
|
26931
|
-
if (!rels) rels = docx[`word/_rels/document.xml.rels`];
|
|
26932
|
-
const relationships = rels.elements.find((el) => el.name === "Relationships");
|
|
26933
|
-
const { elements } = relationships || [];
|
|
26934
|
-
const rel = elements?.find((el) => el.attributes["Id"] === rEmbed);
|
|
26935
|
-
if (!rel) return null;
|
|
26936
|
-
const { attributes: relAttributes } = rel;
|
|
26937
|
-
const targetPath = relAttributes["Target"];
|
|
26938
|
-
let path = `word/${targetPath}`;
|
|
26939
|
-
if (targetPath.startsWith("/word") || targetPath.startsWith("/media")) path = targetPath.substring(1);
|
|
26940
|
-
const extension = targetPath.substring(targetPath.lastIndexOf(".") + 1);
|
|
26941
|
-
return {
|
|
26942
|
-
type: "image",
|
|
26943
|
-
attrs: {
|
|
26944
|
-
src: path,
|
|
26945
|
-
alt: ["emf", "wmf"].includes(extension) ? "Unable to render EMF/WMF image" : docPr?.attributes.name || "Image",
|
|
26946
|
-
extension,
|
|
26947
|
-
id: docPr?.attributes.id || "",
|
|
26948
|
-
title: docPr?.attributes.descr || "Image",
|
|
26949
|
-
inline: true,
|
|
26950
|
-
padding,
|
|
26951
|
-
marginOffset,
|
|
26952
|
-
size,
|
|
26953
|
-
anchorData,
|
|
26954
|
-
isAnchor,
|
|
26955
|
-
transformData,
|
|
26956
|
-
...simplePos && {
|
|
26957
|
-
simplePos: {
|
|
26958
|
-
x: simplePos.attributes.x,
|
|
26959
|
-
y: simplePos.attributes.y
|
|
26960
|
-
}
|
|
26961
|
-
},
|
|
26962
|
-
...wrapSquare && {
|
|
26963
|
-
wrapText: wrapSquare.attributes.wrapText
|
|
26964
|
-
},
|
|
26965
|
-
wrapTopAndBottom: !!wrapTopAndBottom,
|
|
26966
|
-
originalPadding: {
|
|
26967
|
-
distT: attributes["distT"],
|
|
26968
|
-
distB: attributes["distB"],
|
|
26969
|
-
distL: attributes["distL"],
|
|
26970
|
-
distR: attributes["distR"]
|
|
26971
|
-
},
|
|
26972
|
-
originalAttributes: node.attributes,
|
|
26973
|
-
rId: relAttributes["Id"]
|
|
26974
|
-
}
|
|
26975
|
-
};
|
|
26976
|
-
}
|
|
26977
|
-
const handleShapeDrawing = (params, node, graphicData) => {
|
|
26978
|
-
const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
|
|
26979
|
-
const textBox = wsp.elements.find((el) => el.name === "wps:txbx");
|
|
26980
|
-
const textBoxContent = textBox?.elements?.find((el) => el.name === "w:txbxContent");
|
|
26981
|
-
node.elements.find((el) => el.name === "wp:docPr");
|
|
26982
|
-
const spPr = wsp.elements.find((el) => el.name === "wps:spPr");
|
|
26983
|
-
const prstGeom = spPr?.elements.find((el) => el.name === "a:prstGeom");
|
|
26984
|
-
if (!!prstGeom && prstGeom.attributes["prst"] === "rect" && !textBoxContent) {
|
|
26985
|
-
return getRectangleShape(params, spPr);
|
|
26986
|
-
}
|
|
26987
|
-
if (!textBoxContent) {
|
|
26988
|
-
return null;
|
|
26989
|
-
}
|
|
26990
|
-
const { nodeListHandler } = params;
|
|
26991
|
-
const translatedElement = nodeListHandler.handler({
|
|
26992
|
-
...params,
|
|
26993
|
-
node: textBoxContent.elements[0],
|
|
26994
|
-
nodes: textBoxContent.elements,
|
|
26995
|
-
path: [...params.path || [], textBoxContent]
|
|
26996
|
-
});
|
|
26997
|
-
return translatedElement[0];
|
|
26998
|
-
};
|
|
26999
|
-
const getRectangleShape = (params, node) => {
|
|
27000
|
-
const schemaAttrs = {};
|
|
27001
|
-
const [drawingNode] = params.nodes;
|
|
27002
|
-
if (drawingNode?.name === "w:drawing") {
|
|
27003
|
-
schemaAttrs.drawingContent = drawingNode;
|
|
27004
|
-
}
|
|
27005
|
-
const xfrm = node.elements.find((el) => el.name === "a:xfrm");
|
|
27006
|
-
const start = xfrm.elements.find((el) => el.name === "a:off");
|
|
27007
|
-
const size = xfrm.elements.find((el) => el.name === "a:ext");
|
|
27008
|
-
const solidFill = node.elements.find((el) => el.name === "a:solidFill");
|
|
27009
|
-
node.elements.find((el) => el.name === "a:ln");
|
|
27010
|
-
const rectangleSize = {
|
|
27011
|
-
top: emuToPixels(start.attributes["y"]),
|
|
27012
|
-
left: emuToPixels(start.attributes["x"]),
|
|
27013
|
-
width: emuToPixels(size.attributes["cx"]),
|
|
27014
|
-
height: emuToPixels(size.attributes["cy"])
|
|
27015
|
-
};
|
|
27016
|
-
schemaAttrs.size = rectangleSize;
|
|
27017
|
-
const background = solidFill?.elements[0]?.attributes["val"];
|
|
27018
|
-
if (background) {
|
|
27019
|
-
schemaAttrs.background = "#" + background;
|
|
27020
|
-
}
|
|
27021
|
-
return {
|
|
27022
|
-
type: "contentBlock",
|
|
27023
|
-
attrs: schemaAttrs
|
|
27024
|
-
};
|
|
27025
|
-
};
|
|
27026
|
-
function handleAnchorNode(params) {
|
|
27027
|
-
const { node } = params.extraParams;
|
|
27028
|
-
if (node.name !== "wp:anchor") {
|
|
27029
|
-
return null;
|
|
27030
|
-
}
|
|
27031
|
-
return handleImageNode(node, params, true);
|
|
27032
|
-
}
|
|
27033
|
-
const sanitizeDocxMediaName = (value, fallback = "image") => {
|
|
27034
|
-
if (!value) return fallback;
|
|
27035
|
-
const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
27036
|
-
return sanitized || fallback;
|
|
27037
|
-
};
|
|
27038
|
-
const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
|
|
27039
|
-
if (!src || typeof src !== "string") return fallback;
|
|
27040
|
-
const [prefix] = src.split(";");
|
|
27041
|
-
const [, maybeType] = prefix.split("/");
|
|
27042
|
-
const extension = maybeType?.toLowerCase();
|
|
27043
|
-
return extension ? `${fallback}.${extension}` : fallback;
|
|
27044
|
-
};
|
|
27045
|
-
const translateImageNode = (params) => {
|
|
27046
|
-
const {
|
|
27047
|
-
node: { attrs = {} },
|
|
27048
|
-
tableCell,
|
|
27049
|
-
imageSize
|
|
27050
|
-
} = params;
|
|
27051
|
-
let imageId = attrs.rId;
|
|
27052
|
-
const src = attrs.src || attrs.imageSrc;
|
|
27053
|
-
const { originalWidth, originalHeight } = getPngDimensions(src);
|
|
27054
|
-
let imageName;
|
|
27055
|
-
if (params.node.type === "image") {
|
|
27056
|
-
if (src?.startsWith("data:")) {
|
|
27057
|
-
imageName = getFallbackImageNameFromDataUri(src);
|
|
27058
|
-
} else {
|
|
27059
|
-
imageName = src?.split("/").pop();
|
|
27060
|
-
}
|
|
27061
|
-
} else {
|
|
27062
|
-
imageName = attrs.fieldId;
|
|
27063
|
-
}
|
|
27064
|
-
imageName = sanitizeDocxMediaName(imageName);
|
|
27065
|
-
let size = attrs.size ? {
|
|
27066
|
-
w: pixelsToEmu(attrs.size.width),
|
|
27067
|
-
h: pixelsToEmu(attrs.size.height)
|
|
27068
|
-
} : imageSize;
|
|
27069
|
-
if (originalWidth && originalHeight) {
|
|
27070
|
-
const boxWidthPx = emuToPixels(size.w);
|
|
27071
|
-
const boxHeightPx = emuToPixels(size.h);
|
|
27072
|
-
const { scaledWidth, scaledHeight } = getScaledSize(originalWidth, originalHeight, boxWidthPx, boxHeightPx);
|
|
27073
|
-
size = {
|
|
27074
|
-
w: pixelsToEmu(scaledWidth),
|
|
27075
|
-
h: pixelsToEmu(scaledHeight)
|
|
27076
|
-
};
|
|
27077
|
-
}
|
|
27078
|
-
if (tableCell) {
|
|
27079
|
-
const colwidthSum = tableCell.attrs.colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
27080
|
-
const leftMargin = tableCell.attrs.cellMargins?.left || 8;
|
|
27081
|
-
const rightMargin = tableCell.attrs.cellMargins?.right || 8;
|
|
27082
|
-
const maxWidthEmu = pixelsToEmu(colwidthSum - (leftMargin + rightMargin));
|
|
27083
|
-
const { width: w2, height: h2 } = resizeKeepAspectRatio(size.w, size.h, maxWidthEmu);
|
|
27084
|
-
if (w2 && h2) size = { w: w2, h: h2 };
|
|
27085
|
-
}
|
|
27086
|
-
if (params.node.type === "image" && !imageId) {
|
|
27087
|
-
const path = src?.split("word/")[1];
|
|
27088
|
-
imageId = addNewImageRelationship(params, path);
|
|
27089
|
-
} else if (params.node.type === "fieldAnnotation" && !imageId) {
|
|
27090
|
-
const type2 = src?.split(";")[0].split("/")[1];
|
|
27091
|
-
if (!type2) {
|
|
27092
|
-
return prepareTextAnnotation(params);
|
|
27093
|
-
}
|
|
27094
|
-
const sanitizedHash = sanitizeDocxMediaName(attrs.hash, generateDocxRandomId(4));
|
|
27095
|
-
const fileName = `${imageName}_${sanitizedHash}.${type2}`;
|
|
27096
|
-
const relationshipTarget = `media/${fileName}`;
|
|
27097
|
-
const packagePath = `word/${relationshipTarget}`;
|
|
27098
|
-
imageId = addNewImageRelationship(params, relationshipTarget);
|
|
27099
|
-
params.media[packagePath] = src;
|
|
27100
|
-
}
|
|
27101
|
-
const inlineAttrs = attrs.originalPadding || {
|
|
27102
|
-
distT: 0,
|
|
27103
|
-
distB: 0,
|
|
27104
|
-
distL: 0,
|
|
27105
|
-
distR: 0
|
|
27106
|
-
};
|
|
27107
|
-
const xfrmAttrs = {};
|
|
27108
|
-
const effectExtentAttrs = {
|
|
27109
|
-
l: 0,
|
|
27110
|
-
t: 0,
|
|
27111
|
-
r: 0,
|
|
27112
|
-
b: 0
|
|
27113
|
-
};
|
|
27114
|
-
const transformData = attrs.transformData;
|
|
27115
|
-
if (transformData) {
|
|
27116
|
-
if (transformData.rotation) {
|
|
27117
|
-
xfrmAttrs.rot = degreesToRot(transformData.rotation);
|
|
27118
|
-
}
|
|
27119
|
-
if (transformData.verticalFlip) {
|
|
27120
|
-
xfrmAttrs.flipV = "1";
|
|
27121
|
-
}
|
|
27122
|
-
if (transformData.horizontalFlip) {
|
|
27123
|
-
xfrmAttrs.flipH = "1";
|
|
27124
|
-
}
|
|
27125
|
-
if (transformData.sizeExtension) {
|
|
27126
|
-
effectExtentAttrs.l = pixelsToEmu(transformData.sizeExtension.left);
|
|
27127
|
-
effectExtentAttrs.t = pixelsToEmu(transformData.sizeExtension.top);
|
|
27128
|
-
effectExtentAttrs.r = pixelsToEmu(transformData.sizeExtension.right);
|
|
27129
|
-
effectExtentAttrs.b = pixelsToEmu(transformData.sizeExtension.bottom);
|
|
27130
|
-
}
|
|
27131
|
-
}
|
|
27132
|
-
const drawingXmlns = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
27133
|
-
const pictureXmlns = "http://schemas.openxmlformats.org/drawingml/2006/picture";
|
|
27134
|
-
return {
|
|
27135
|
-
attributes: inlineAttrs,
|
|
27136
|
-
elements: [
|
|
27137
|
-
{
|
|
27138
|
-
name: "wp:extent",
|
|
27139
|
-
attributes: {
|
|
27140
|
-
cx: size.w,
|
|
27141
|
-
cy: size.h
|
|
27142
|
-
}
|
|
27143
|
-
},
|
|
27144
|
-
{
|
|
27145
|
-
name: "wp:effectExtent",
|
|
27146
|
-
attributes: effectExtentAttrs
|
|
27147
|
-
},
|
|
27148
|
-
{
|
|
27149
|
-
name: "wp:docPr",
|
|
27150
|
-
attributes: {
|
|
27151
|
-
id: attrs.id || 0,
|
|
27152
|
-
name: attrs.alt || `Picture ${imageName}`
|
|
27153
|
-
}
|
|
27154
|
-
},
|
|
27155
|
-
{
|
|
27156
|
-
name: "wp:cNvGraphicFramePr",
|
|
27157
|
-
elements: [
|
|
27158
|
-
{
|
|
27159
|
-
name: "a:graphicFrameLocks",
|
|
27160
|
-
attributes: {
|
|
27161
|
-
"xmlns:a": drawingXmlns,
|
|
27162
|
-
noChangeAspect: 1
|
|
27163
|
-
}
|
|
27164
|
-
}
|
|
27165
|
-
]
|
|
27166
|
-
},
|
|
27167
|
-
{
|
|
27168
|
-
name: "a:graphic",
|
|
27169
|
-
attributes: { "xmlns:a": drawingXmlns },
|
|
27170
|
-
elements: [
|
|
27171
|
-
{
|
|
27172
|
-
name: "a:graphicData",
|
|
27173
|
-
attributes: { uri: pictureXmlns },
|
|
27174
|
-
elements: [
|
|
27175
|
-
{
|
|
27176
|
-
name: "pic:pic",
|
|
27177
|
-
attributes: { "xmlns:pic": pictureXmlns },
|
|
27178
|
-
elements: [
|
|
27179
|
-
{
|
|
27180
|
-
name: "pic:nvPicPr",
|
|
27181
|
-
elements: [
|
|
27182
|
-
{
|
|
27183
|
-
name: "pic:cNvPr",
|
|
27184
|
-
attributes: {
|
|
27185
|
-
id: attrs.id || 0,
|
|
27186
|
-
name: attrs.title || `Picture ${imageName}`
|
|
27187
|
-
}
|
|
27188
|
-
},
|
|
27189
|
-
{
|
|
27190
|
-
name: "pic:cNvPicPr",
|
|
27191
|
-
elements: [
|
|
27192
|
-
{
|
|
27193
|
-
name: "a:picLocks",
|
|
27194
|
-
attributes: {
|
|
27195
|
-
noChangeAspect: 1,
|
|
27196
|
-
noChangeArrowheads: 1
|
|
27197
|
-
}
|
|
27198
|
-
}
|
|
27199
|
-
]
|
|
27200
|
-
}
|
|
27201
|
-
]
|
|
27202
|
-
},
|
|
27203
|
-
{
|
|
27204
|
-
name: "pic:blipFill",
|
|
27205
|
-
elements: [
|
|
27206
|
-
{
|
|
27207
|
-
name: "a:blip",
|
|
27208
|
-
attributes: {
|
|
27209
|
-
"r:embed": imageId
|
|
27210
|
-
}
|
|
27211
|
-
},
|
|
27212
|
-
{
|
|
27213
|
-
name: "a:stretch",
|
|
27214
|
-
elements: [{ name: "a:fillRect" }]
|
|
27215
|
-
}
|
|
27216
|
-
]
|
|
27217
|
-
},
|
|
27218
|
-
{
|
|
27219
|
-
name: "pic:spPr",
|
|
27220
|
-
attributes: {
|
|
27221
|
-
bwMode: "auto"
|
|
27222
|
-
},
|
|
27223
|
-
elements: [
|
|
27224
|
-
{
|
|
27225
|
-
name: "a:xfrm",
|
|
27226
|
-
attributes: xfrmAttrs,
|
|
27227
|
-
elements: [
|
|
27228
|
-
{
|
|
27229
|
-
name: "a:ext",
|
|
27230
|
-
attributes: {
|
|
27231
|
-
cx: size.w,
|
|
27232
|
-
cy: size.h
|
|
27233
|
-
}
|
|
27234
|
-
},
|
|
27235
|
-
{
|
|
27236
|
-
name: "a:off",
|
|
27237
|
-
attributes: {
|
|
27238
|
-
x: 0,
|
|
27239
|
-
y: 0
|
|
27240
|
-
}
|
|
27241
|
-
}
|
|
27242
|
-
]
|
|
27243
|
-
},
|
|
27244
|
-
{
|
|
27245
|
-
name: "a:prstGeom",
|
|
27246
|
-
attributes: { prst: "rect" },
|
|
27247
|
-
elements: [{ name: "a:avLst" }]
|
|
27248
|
-
},
|
|
27249
|
-
{
|
|
27250
|
-
name: "a:noFill"
|
|
27251
|
-
}
|
|
27252
|
-
]
|
|
27253
|
-
}
|
|
27254
|
-
]
|
|
27255
|
-
}
|
|
27256
|
-
]
|
|
27257
|
-
}
|
|
27258
|
-
]
|
|
27259
|
-
}
|
|
27260
|
-
]
|
|
27261
|
-
};
|
|
27262
|
-
};
|
|
27263
|
-
function getPngDimensions(base64) {
|
|
27264
|
-
if (!base64) return {};
|
|
27265
|
-
const type2 = base64.split(";")[0].split("/")[1];
|
|
27266
|
-
if (!base64 || type2 !== "png") {
|
|
27267
|
-
return {
|
|
27268
|
-
originalWidth: void 0,
|
|
27269
|
-
originalHeight: void 0
|
|
27270
|
-
};
|
|
27271
|
-
}
|
|
27272
|
-
let header = base64.split(",")[1].slice(0, 50);
|
|
27273
|
-
let uint8 = Uint8Array.from(atob(header), (c) => c.charCodeAt(0));
|
|
27274
|
-
let dataView = new DataView(uint8.buffer, 0, 28);
|
|
27275
|
-
return {
|
|
27276
|
-
originalWidth: dataView.getInt32(16),
|
|
27277
|
-
originalHeight: dataView.getInt32(20)
|
|
27278
|
-
};
|
|
27279
|
-
}
|
|
27280
|
-
function getScaledSize(originalWidth, originalHeight, maxWidth, maxHeight) {
|
|
27281
|
-
let scaledWidth = originalWidth;
|
|
27282
|
-
let scaledHeight = originalHeight;
|
|
27283
|
-
let ratio = Math.min(maxWidth / originalWidth, maxHeight / originalHeight);
|
|
27284
|
-
scaledWidth = Math.round(scaledWidth * ratio);
|
|
27285
|
-
scaledHeight = Math.round(scaledHeight * ratio);
|
|
27286
|
-
return { scaledWidth, scaledHeight };
|
|
27287
|
-
}
|
|
27288
|
-
function resizeKeepAspectRatio(width, height, maxWidth) {
|
|
27289
|
-
if (width > maxWidth) {
|
|
27290
|
-
let scale = maxWidth / width;
|
|
27291
|
-
let newHeight = Math.round(height * scale);
|
|
27292
|
-
return { width: maxWidth, height: newHeight };
|
|
27293
|
-
}
|
|
27294
|
-
return { width, height };
|
|
27295
|
-
}
|
|
27296
|
-
function addNewImageRelationship(params, imagePath) {
|
|
27297
|
-
const newId = "rId" + generateDocxRandomId();
|
|
27298
|
-
const newRel = {
|
|
27299
|
-
type: "element",
|
|
27300
|
-
name: "Relationship",
|
|
27301
|
-
attributes: {
|
|
27302
|
-
Id: newId,
|
|
27303
|
-
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
27304
|
-
Target: imagePath
|
|
27305
|
-
}
|
|
27306
|
-
};
|
|
27307
|
-
params.relationships.push(newRel);
|
|
27308
|
-
return newId;
|
|
27309
|
-
}
|
|
27310
|
-
function translateAnchorNode(params) {
|
|
27311
|
-
const { attrs } = params.node;
|
|
27312
|
-
const anchorElements = [];
|
|
27313
|
-
const wrapElements = [];
|
|
27314
|
-
if (attrs.simplePos) {
|
|
27315
|
-
anchorElements.push({
|
|
27316
|
-
name: "wp:simplePos",
|
|
27317
|
-
attributes: {
|
|
27318
|
-
x: 0,
|
|
27319
|
-
y: 0
|
|
27320
|
-
}
|
|
27321
|
-
});
|
|
27322
|
-
}
|
|
27323
|
-
if (attrs.anchorData) {
|
|
27324
|
-
const hElements = [];
|
|
27325
|
-
if (attrs.marginOffset.left !== void 0) {
|
|
27326
|
-
hElements.push({
|
|
27327
|
-
name: "wp:posOffset",
|
|
27328
|
-
elements: [{ type: "text", text: pixelsToEmu(attrs.marginOffset.left).toString() }]
|
|
27329
|
-
});
|
|
27330
|
-
}
|
|
27331
|
-
if (attrs.anchorData.alignH) {
|
|
27332
|
-
hElements.push({
|
|
27333
|
-
name: "wp:align",
|
|
27334
|
-
elements: [{ type: "text", text: attrs.anchorData.alignH }]
|
|
27335
|
-
});
|
|
27336
|
-
}
|
|
27337
|
-
anchorElements.push({
|
|
27338
|
-
name: "wp:positionH",
|
|
27339
|
-
attributes: { relativeFrom: attrs.anchorData.hRelativeFrom },
|
|
27340
|
-
...hElements.length && { elements: hElements }
|
|
27341
|
-
});
|
|
27342
|
-
const vElements = [];
|
|
27343
|
-
if (attrs.marginOffset.top !== void 0) {
|
|
27344
|
-
vElements.push({
|
|
27345
|
-
name: "wp:posOffset",
|
|
27346
|
-
elements: [{ type: "text", text: pixelsToEmu(attrs.marginOffset.top).toString() }]
|
|
27347
|
-
});
|
|
27348
|
-
}
|
|
27349
|
-
if (attrs.anchorData.alignV) {
|
|
27350
|
-
vElements.push({
|
|
27351
|
-
name: "wp:align",
|
|
27352
|
-
elements: [{ type: "text", text: attrs.anchorData.alignV }]
|
|
27353
|
-
});
|
|
27354
|
-
}
|
|
27355
|
-
anchorElements.push({
|
|
27356
|
-
name: "wp:positionV",
|
|
27357
|
-
attributes: { relativeFrom: attrs.anchorData.vRelativeFrom },
|
|
27358
|
-
...vElements.length && { elements: vElements }
|
|
27359
|
-
});
|
|
27360
|
-
}
|
|
27361
|
-
if (attrs.wrapText) {
|
|
27362
|
-
wrapElements.push({
|
|
27363
|
-
name: "wp:wrapSquare",
|
|
27364
|
-
attributes: {
|
|
27365
|
-
wrapText: attrs.wrapText
|
|
27366
|
-
}
|
|
27367
|
-
});
|
|
27368
|
-
}
|
|
27369
|
-
if (attrs.wrapTopAndBottom) {
|
|
27370
|
-
wrapElements.push({
|
|
27371
|
-
name: "wp:wrapTopAndBottom"
|
|
27372
|
-
});
|
|
27373
|
-
}
|
|
27374
|
-
if (!wrapElements.length) {
|
|
27375
|
-
wrapElements.push({
|
|
27376
|
-
name: "wp:wrapNone"
|
|
27377
|
-
});
|
|
27378
|
-
}
|
|
27379
|
-
const nodeElements = translateImageNode(params);
|
|
27380
|
-
const inlineAttrs = {
|
|
27381
|
-
...nodeElements.attributes,
|
|
27382
|
-
simplePos: attrs.originalAttributes?.simplePos,
|
|
27383
|
-
relativeHeight: 1,
|
|
27384
|
-
behindDoc: attrs.originalAttributes?.behindDoc,
|
|
27385
|
-
locked: attrs.originalAttributes?.locked,
|
|
27386
|
-
layoutInCell: attrs.originalAttributes?.layoutInCell,
|
|
27387
|
-
allowOverlap: attrs.originalAttributes?.allowOverlap
|
|
27388
|
-
};
|
|
27389
|
-
const effectIndex = nodeElements.elements.findIndex((el) => el.name === "wp:effectExtent");
|
|
27390
|
-
const elementsWithWrap = [
|
|
27391
|
-
...nodeElements.elements.slice(0, effectIndex + 1),
|
|
27392
|
-
...wrapElements,
|
|
27393
|
-
...nodeElements.elements.slice(effectIndex + 1)
|
|
27394
|
-
];
|
|
27395
|
-
return {
|
|
27396
|
-
name: "wp:anchor",
|
|
27397
|
-
attributes: inlineAttrs,
|
|
27398
|
-
elements: [...anchorElements, ...elementsWithWrap]
|
|
27399
|
-
};
|
|
27400
|
-
}
|
|
27401
|
-
const XML_NODE_NAME$3 = "wp:anchor";
|
|
27402
|
-
const SD_NODE_NAME$3 = ["image"];
|
|
27403
|
-
const validXmlAttributes$3 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
27404
|
-
function encode$3(params) {
|
|
27405
|
-
const { node } = params.extraParams;
|
|
27406
|
-
if (!node || !node.type) {
|
|
27407
|
-
return null;
|
|
27408
|
-
}
|
|
27409
|
-
return handleAnchorNode(params);
|
|
27410
|
-
}
|
|
27411
|
-
function decode$3(params) {
|
|
27412
|
-
const { node } = params;
|
|
27413
|
-
if (!node || !node.type) {
|
|
27414
|
-
return null;
|
|
27415
|
-
}
|
|
27416
|
-
return translateAnchorNode(params);
|
|
27417
|
-
}
|
|
27418
|
-
const config$3 = {
|
|
27419
|
-
xmlName: XML_NODE_NAME$3,
|
|
27420
|
-
sdNodeOrKeyName: SD_NODE_NAME$3,
|
|
27421
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
27422
|
-
encode: encode$3,
|
|
27423
|
-
decode: decode$3,
|
|
27424
|
-
attributes: validXmlAttributes$3
|
|
27425
|
-
};
|
|
27426
|
-
const translator$3 = NodeTranslator.from(config$3);
|
|
27427
|
-
function handleInlineNode(params) {
|
|
27428
|
-
const { node } = params.extraParams;
|
|
27429
|
-
if (node.name !== "wp:inline") {
|
|
27430
|
-
return null;
|
|
27431
|
-
}
|
|
27432
|
-
return handleImageNode(node, params, false);
|
|
27433
|
-
}
|
|
27434
|
-
function translateInlineNode(params) {
|
|
27435
|
-
const nodeElements = translateImageNode(params);
|
|
27436
|
-
return {
|
|
27437
|
-
name: "wp:inline",
|
|
27438
|
-
attributes: nodeElements.attributes,
|
|
27439
|
-
elements: nodeElements.elements
|
|
27440
|
-
};
|
|
27441
|
-
}
|
|
27442
|
-
const XML_NODE_NAME$2 = "wp:inline";
|
|
27443
|
-
const SD_NODE_NAME$2 = ["image"];
|
|
27444
|
-
const validXmlAttributes$2 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
27445
|
-
function encode$2(params) {
|
|
27446
|
-
const { node } = params.extraParams;
|
|
27447
|
-
if (!node || !node.type) {
|
|
27448
|
-
return null;
|
|
27449
|
-
}
|
|
27450
|
-
return handleInlineNode(params);
|
|
27451
|
-
}
|
|
27452
|
-
function decode$2(params) {
|
|
27453
|
-
const { node } = params;
|
|
27454
|
-
if (!node || !node.type) {
|
|
27455
|
-
return null;
|
|
27456
|
-
}
|
|
27457
|
-
return translateInlineNode(params);
|
|
27458
|
-
}
|
|
27459
|
-
const config$2 = {
|
|
27460
|
-
xmlName: XML_NODE_NAME$2,
|
|
27461
|
-
sdNodeOrKeyName: SD_NODE_NAME$2,
|
|
27462
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
27463
|
-
encode: encode$2,
|
|
27464
|
-
decode: decode$2,
|
|
27465
|
-
attributes: validXmlAttributes$2
|
|
27466
|
-
};
|
|
27467
|
-
const translator$2 = NodeTranslator.from(config$2);
|
|
27468
|
-
const registeredHandlers = Object.freeze({
|
|
27469
|
-
"w:br": translator$T,
|
|
27470
|
-
"w:tab": translator$S,
|
|
27471
|
-
"w:p": translator$R,
|
|
27472
|
-
"wp:anchor": translator$3,
|
|
27473
|
-
"wp:inline": translator$2
|
|
27474
|
-
});
|
|
27475
|
-
const XML_NODE_NAME$1 = "w:drawing";
|
|
27476
|
-
const SD_NODE_NAME$1 = [];
|
|
27477
|
-
const validXmlAttributes$1 = [];
|
|
27478
|
-
function encode$1(params) {
|
|
27479
|
-
const nodes = params.nodes;
|
|
27480
|
-
const node = nodes[0];
|
|
27481
|
-
const validChildTranslators = ["wp:anchor", "wp:inline"];
|
|
27482
|
-
return node.elements.reduce((acc, child) => {
|
|
27483
|
-
if (acc) return acc;
|
|
27484
|
-
if (!validChildTranslators.includes(child.name)) return acc;
|
|
27485
|
-
const translator2 = registeredHandlers[child.name];
|
|
27486
|
-
return translator2.encode({ ...params, extraParams: { node: child } }) || acc;
|
|
27487
|
-
}, null);
|
|
27488
|
-
}
|
|
27489
|
-
function decode$1(params) {
|
|
27490
|
-
const { node } = params;
|
|
27491
|
-
if (!node || !node.type) {
|
|
27492
|
-
return null;
|
|
27493
|
-
}
|
|
27494
|
-
const handlerName = node.attrs.isAnchor ? "wp:anchor" : "wp:inline";
|
|
27495
|
-
const resultNode = registeredHandlers[handlerName].decode(params);
|
|
27496
|
-
return wrapTextInRun(
|
|
27497
|
-
{
|
|
27498
|
-
name: "w:drawing",
|
|
27499
|
-
elements: [resultNode]
|
|
27500
|
-
},
|
|
27501
|
-
[]
|
|
27502
|
-
);
|
|
26306
|
+
return { type: "unknown", handler: null };
|
|
27503
26307
|
}
|
|
27504
|
-
const config$1 = {
|
|
27505
|
-
xmlName: XML_NODE_NAME$1,
|
|
27506
|
-
sdNodeOrKeyName: SD_NODE_NAME$1,
|
|
27507
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
27508
|
-
encode: encode$1,
|
|
27509
|
-
decode: decode$1,
|
|
27510
|
-
attributes: validXmlAttributes$1
|
|
27511
|
-
};
|
|
27512
|
-
const translator$1 = NodeTranslator.from(config$1);
|
|
27513
26308
|
class CommandService {
|
|
27514
26309
|
/**
|
|
27515
26310
|
* @param {import('./commands/types/index.js').CommandServiceOptions} props
|
|
@@ -28847,10 +27642,7 @@ function prepareTextAnnotation(params) {
|
|
|
28847
27642
|
return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params);
|
|
28848
27643
|
}
|
|
28849
27644
|
function prepareImageAnnotation(params, imageSize) {
|
|
28850
|
-
return
|
|
28851
|
-
...params,
|
|
28852
|
-
imageSize
|
|
28853
|
-
});
|
|
27645
|
+
return translateImageNode(params, imageSize);
|
|
28854
27646
|
}
|
|
28855
27647
|
function prepareCheckboxAnnotation(params) {
|
|
28856
27648
|
const {
|
|
@@ -29087,7 +27879,7 @@ function translateStructuredContent(params) {
|
|
|
29087
27879
|
const XML_NODE_NAME = "w:sdt";
|
|
29088
27880
|
const SD_NODE_NAME = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
|
|
29089
27881
|
const validXmlAttributes = [];
|
|
29090
|
-
function encode(params) {
|
|
27882
|
+
function encode(params, encodedAttrs) {
|
|
29091
27883
|
const nodes = params.nodes;
|
|
29092
27884
|
const node = nodes[0];
|
|
29093
27885
|
const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
|
|
@@ -29097,7 +27889,7 @@ function encode(params) {
|
|
|
29097
27889
|
const result = handler2(params);
|
|
29098
27890
|
return result;
|
|
29099
27891
|
}
|
|
29100
|
-
function decode(params) {
|
|
27892
|
+
function decode(params, decodedAttrs) {
|
|
29101
27893
|
const { node } = params;
|
|
29102
27894
|
if (!node || !node.type) {
|
|
29103
27895
|
return null;
|
|
@@ -29128,19 +27920,19 @@ function exportSchemaToJson(params) {
|
|
|
29128
27920
|
doc: translateDocumentNode,
|
|
29129
27921
|
body: translateBodyNode,
|
|
29130
27922
|
heading: translateHeadingNode,
|
|
29131
|
-
paragraph: translator$
|
|
27923
|
+
paragraph: translator$h,
|
|
29132
27924
|
text: translateTextNode,
|
|
29133
27925
|
bulletList: translateList,
|
|
29134
27926
|
orderedList: translateList,
|
|
29135
|
-
lineBreak: translator$
|
|
29136
|
-
table:
|
|
29137
|
-
tableRow: translator$
|
|
29138
|
-
tableCell: translator$
|
|
27927
|
+
lineBreak: translator$j,
|
|
27928
|
+
table: translateTable,
|
|
27929
|
+
tableRow: translator$3,
|
|
27930
|
+
tableCell: translator$2,
|
|
29139
27931
|
bookmarkStart: translateBookmarkStart,
|
|
29140
27932
|
fieldAnnotation: translator,
|
|
29141
|
-
tab: translator$
|
|
29142
|
-
image:
|
|
29143
|
-
hardBreak: translator$
|
|
27933
|
+
tab: translator$i,
|
|
27934
|
+
image: translateImageNode,
|
|
27935
|
+
hardBreak: translator$j,
|
|
29144
27936
|
commentRangeStart: () => translateCommentNode(params, "Start"),
|
|
29145
27937
|
commentRangeEnd: () => translateCommentNode(params, "End"),
|
|
29146
27938
|
commentReference: () => null,
|
|
@@ -29472,7 +28264,7 @@ function translateTextNode(params) {
|
|
|
29472
28264
|
const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
|
|
29473
28265
|
if (isTrackedNode) return translateTrackedNode(params);
|
|
29474
28266
|
const isLinkNode = node.marks?.some((m2) => m2.type === "link");
|
|
29475
|
-
if (isLinkNode) return translator$
|
|
28267
|
+
if (isLinkNode) return translator$1.decode(params);
|
|
29476
28268
|
const { text, marks = [] } = node;
|
|
29477
28269
|
return getTextNodeForExport(text, marks, params);
|
|
29478
28270
|
}
|
|
@@ -29605,6 +28397,20 @@ function addNewLinkRelationship(params, link) {
|
|
|
29605
28397
|
});
|
|
29606
28398
|
return newId;
|
|
29607
28399
|
}
|
|
28400
|
+
function addNewImageRelationship(params, imagePath) {
|
|
28401
|
+
const newId = "rId" + generateDocxRandomId();
|
|
28402
|
+
const newRel = {
|
|
28403
|
+
type: "element",
|
|
28404
|
+
name: "Relationship",
|
|
28405
|
+
attributes: {
|
|
28406
|
+
Id: newId,
|
|
28407
|
+
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
28408
|
+
Target: imagePath
|
|
28409
|
+
}
|
|
28410
|
+
};
|
|
28411
|
+
params.relationships.push(newRel);
|
|
28412
|
+
return newId;
|
|
28413
|
+
}
|
|
29608
28414
|
function translateList(params) {
|
|
29609
28415
|
const { node, editor } = params;
|
|
29610
28416
|
const listItem = node.content[0];
|
|
@@ -29747,6 +28553,165 @@ const generateNumPrTag = (numId, level) => {
|
|
|
29747
28553
|
]
|
|
29748
28554
|
};
|
|
29749
28555
|
};
|
|
28556
|
+
function translateTable(params) {
|
|
28557
|
+
params.node = preProcessVerticalMergeCells(params.node, params);
|
|
28558
|
+
const elements = translateChildNodes(params);
|
|
28559
|
+
const tableProperties = generateTableProperties(params.node);
|
|
28560
|
+
const gridProperties = generateTableGrid(params.node, params);
|
|
28561
|
+
elements.unshift(tableProperties);
|
|
28562
|
+
elements.unshift(gridProperties);
|
|
28563
|
+
return {
|
|
28564
|
+
name: "w:tbl",
|
|
28565
|
+
elements
|
|
28566
|
+
};
|
|
28567
|
+
}
|
|
28568
|
+
function preProcessVerticalMergeCells(table, { editorSchema }) {
|
|
28569
|
+
const { content } = table;
|
|
28570
|
+
for (let rowIndex = 0; rowIndex < content.length; rowIndex++) {
|
|
28571
|
+
const row = content[rowIndex];
|
|
28572
|
+
if (!row.content) continue;
|
|
28573
|
+
for (let cellIndex = 0; cellIndex < row.content?.length; cellIndex++) {
|
|
28574
|
+
const cell = row.content[cellIndex];
|
|
28575
|
+
if (!cell) continue;
|
|
28576
|
+
const { attrs } = cell;
|
|
28577
|
+
if (attrs.rowspan > 1) {
|
|
28578
|
+
const rowsToChange = content.slice(rowIndex + 1, rowIndex + attrs.rowspan);
|
|
28579
|
+
const mergedCell = {
|
|
28580
|
+
type: cell.type,
|
|
28581
|
+
content: [
|
|
28582
|
+
// cells must end with a paragraph
|
|
28583
|
+
editorSchema.nodes.paragraph.createAndFill().toJSON()
|
|
28584
|
+
],
|
|
28585
|
+
attrs: {
|
|
28586
|
+
...cell.attrs,
|
|
28587
|
+
// reset colspan and rowspan
|
|
28588
|
+
colspan: null,
|
|
28589
|
+
rowspan: null,
|
|
28590
|
+
// to add vMerge
|
|
28591
|
+
continueMerge: true
|
|
28592
|
+
}
|
|
28593
|
+
};
|
|
28594
|
+
rowsToChange.forEach((rowToChange) => {
|
|
28595
|
+
rowToChange.content.splice(cellIndex, 0, mergedCell);
|
|
28596
|
+
});
|
|
28597
|
+
}
|
|
28598
|
+
}
|
|
28599
|
+
}
|
|
28600
|
+
return table;
|
|
28601
|
+
}
|
|
28602
|
+
function generateTableProperties(node) {
|
|
28603
|
+
const elements = [];
|
|
28604
|
+
const { attrs } = node;
|
|
28605
|
+
const { tableWidth, tableStyleId, borders, tableIndent, tableLayout, tableCellSpacing, justification } = attrs;
|
|
28606
|
+
if (tableStyleId) {
|
|
28607
|
+
const tableStyleElement = {
|
|
28608
|
+
name: "w:tblStyle",
|
|
28609
|
+
attributes: { "w:val": tableStyleId }
|
|
28610
|
+
};
|
|
28611
|
+
elements.push(tableStyleElement);
|
|
28612
|
+
}
|
|
28613
|
+
if (borders) {
|
|
28614
|
+
const borderElement = generateTableBorders(node);
|
|
28615
|
+
elements.push(borderElement);
|
|
28616
|
+
}
|
|
28617
|
+
if (tableIndent) {
|
|
28618
|
+
const { width, type: type2 } = tableIndent;
|
|
28619
|
+
const tableIndentElement = {
|
|
28620
|
+
name: "w:tblInd",
|
|
28621
|
+
attributes: { "w:w": pixelsToTwips(width), "w:type": type2 }
|
|
28622
|
+
};
|
|
28623
|
+
elements.push(tableIndentElement);
|
|
28624
|
+
}
|
|
28625
|
+
if (tableLayout) {
|
|
28626
|
+
const tableLayoutElement = {
|
|
28627
|
+
name: "w:tblLayout",
|
|
28628
|
+
attributes: { "w:type": tableLayout }
|
|
28629
|
+
};
|
|
28630
|
+
elements.push(tableLayoutElement);
|
|
28631
|
+
}
|
|
28632
|
+
if (tableWidth && tableWidth.width) {
|
|
28633
|
+
const tableWidthElement = {
|
|
28634
|
+
name: "w:tblW",
|
|
28635
|
+
attributes: { "w:w": pixelsToTwips(tableWidth.width), "w:type": tableWidth.type }
|
|
28636
|
+
};
|
|
28637
|
+
elements.push(tableWidthElement);
|
|
28638
|
+
}
|
|
28639
|
+
if (tableCellSpacing) {
|
|
28640
|
+
elements.push({
|
|
28641
|
+
name: "w:tblCellSpacing",
|
|
28642
|
+
attributes: {
|
|
28643
|
+
"w:w": tableCellSpacing.w,
|
|
28644
|
+
"w:type": tableCellSpacing.type
|
|
28645
|
+
}
|
|
28646
|
+
});
|
|
28647
|
+
}
|
|
28648
|
+
if (justification) {
|
|
28649
|
+
const justificationElement = {
|
|
28650
|
+
name: "w:jc",
|
|
28651
|
+
attributes: { "w:val": justification }
|
|
28652
|
+
};
|
|
28653
|
+
elements.push(justificationElement);
|
|
28654
|
+
}
|
|
28655
|
+
return {
|
|
28656
|
+
name: "w:tblPr",
|
|
28657
|
+
elements
|
|
28658
|
+
};
|
|
28659
|
+
}
|
|
28660
|
+
function generateTableBorders(node) {
|
|
28661
|
+
const { borders } = node.attrs;
|
|
28662
|
+
const elements = [];
|
|
28663
|
+
if (!borders) return;
|
|
28664
|
+
const borderTypes = ["top", "bottom", "left", "right", "insideH", "insideV"];
|
|
28665
|
+
borderTypes.forEach((type2) => {
|
|
28666
|
+
const border = borders[type2];
|
|
28667
|
+
if (!border) return;
|
|
28668
|
+
let attributes = {};
|
|
28669
|
+
if (!Object.keys(border).length || !border.size) {
|
|
28670
|
+
attributes = {
|
|
28671
|
+
"w:val": "nil"
|
|
28672
|
+
};
|
|
28673
|
+
} else {
|
|
28674
|
+
attributes = {
|
|
28675
|
+
"w:val": "single",
|
|
28676
|
+
"w:sz": pixelsToEightPoints(border.size),
|
|
28677
|
+
"w:space": border.space || 0,
|
|
28678
|
+
"w:color": border?.color?.substring(1) || "000000"
|
|
28679
|
+
};
|
|
28680
|
+
}
|
|
28681
|
+
const borderElement = {
|
|
28682
|
+
name: `w:${type2}`,
|
|
28683
|
+
attributes
|
|
28684
|
+
};
|
|
28685
|
+
elements.push(borderElement);
|
|
28686
|
+
});
|
|
28687
|
+
return {
|
|
28688
|
+
name: "w:tblBorders",
|
|
28689
|
+
elements
|
|
28690
|
+
};
|
|
28691
|
+
}
|
|
28692
|
+
function generateTableGrid(node, params) {
|
|
28693
|
+
const { editorSchema } = params;
|
|
28694
|
+
let colgroup = [];
|
|
28695
|
+
try {
|
|
28696
|
+
const pmNode = editorSchema.nodeFromJSON(node);
|
|
28697
|
+
const cellMinWidth = 10;
|
|
28698
|
+
const { colgroupValues } = createColGroup(pmNode, cellMinWidth);
|
|
28699
|
+
colgroup = colgroupValues;
|
|
28700
|
+
} catch {
|
|
28701
|
+
colgroup = [];
|
|
28702
|
+
}
|
|
28703
|
+
const elements = [];
|
|
28704
|
+
colgroup?.forEach((width) => {
|
|
28705
|
+
elements.push({
|
|
28706
|
+
name: "w:gridCol",
|
|
28707
|
+
attributes: { "w:w": pixelsToTwips(width) }
|
|
28708
|
+
});
|
|
28709
|
+
});
|
|
28710
|
+
return {
|
|
28711
|
+
name: "w:tblGrid",
|
|
28712
|
+
elements
|
|
28713
|
+
};
|
|
28714
|
+
}
|
|
29750
28715
|
function translateBookmarkStart(params) {
|
|
29751
28716
|
const bookmarkStartNode = {
|
|
29752
28717
|
name: "w:bookmarkStart",
|
|
@@ -29799,44 +28764,370 @@ function translateMark(mark) {
|
|
|
29799
28764
|
const parsedValue = value.split(", ");
|
|
29800
28765
|
markElement.attributes[attr] = parsedValue[0] ? parsedValue[0] : value;
|
|
29801
28766
|
});
|
|
29802
|
-
break;
|
|
29803
|
-
// Add ability to get run styleIds from textStyle marks and inject to run properties in word
|
|
29804
|
-
case "styleId":
|
|
29805
|
-
markElement.name = "w:rStyle";
|
|
29806
|
-
markElement.attributes["w:val"] = attrs.styleId;
|
|
29807
|
-
break;
|
|
29808
|
-
case "color":
|
|
29809
|
-
let processedColor = attrs.color.replace(/^#/, "").replace(/;$/, "");
|
|
29810
|
-
if (processedColor.startsWith("rgb")) {
|
|
29811
|
-
processedColor = rgbToHex(processedColor);
|
|
29812
|
-
}
|
|
29813
|
-
markElement.attributes["w:val"] = processedColor;
|
|
29814
|
-
break;
|
|
29815
|
-
case "textAlign":
|
|
29816
|
-
markElement.attributes["w:val"] = attrs.textAlign;
|
|
29817
|
-
break;
|
|
29818
|
-
case "textIndent":
|
|
29819
|
-
markElement.attributes["w:firstline"] = inchesToTwips(attrs.textIndent);
|
|
29820
|
-
break;
|
|
29821
|
-
case "textTransform":
|
|
29822
|
-
if (attrs?.textTransform === "none") {
|
|
29823
|
-
markElement.attributes["w:val"] = "0";
|
|
29824
|
-
} else {
|
|
29825
|
-
delete markElement.attributes;
|
|
29826
|
-
}
|
|
29827
|
-
markElement.type = "element";
|
|
29828
|
-
break;
|
|
29829
|
-
case "lineHeight":
|
|
29830
|
-
markElement.attributes["w:line"] = linesToTwips(attrs.lineHeight);
|
|
29831
|
-
break;
|
|
29832
|
-
case "highlight":
|
|
29833
|
-
markElement.attributes["w:fill"] = attrs.color?.substring(1);
|
|
29834
|
-
markElement.attributes["w:color"] = "auto";
|
|
29835
|
-
markElement.attributes["w:val"] = "clear";
|
|
29836
|
-
markElement.name = "w:shd";
|
|
29837
|
-
break;
|
|
28767
|
+
break;
|
|
28768
|
+
// Add ability to get run styleIds from textStyle marks and inject to run properties in word
|
|
28769
|
+
case "styleId":
|
|
28770
|
+
markElement.name = "w:rStyle";
|
|
28771
|
+
markElement.attributes["w:val"] = attrs.styleId;
|
|
28772
|
+
break;
|
|
28773
|
+
case "color":
|
|
28774
|
+
let processedColor = attrs.color.replace(/^#/, "").replace(/;$/, "");
|
|
28775
|
+
if (processedColor.startsWith("rgb")) {
|
|
28776
|
+
processedColor = rgbToHex(processedColor);
|
|
28777
|
+
}
|
|
28778
|
+
markElement.attributes["w:val"] = processedColor;
|
|
28779
|
+
break;
|
|
28780
|
+
case "textAlign":
|
|
28781
|
+
markElement.attributes["w:val"] = attrs.textAlign;
|
|
28782
|
+
break;
|
|
28783
|
+
case "textIndent":
|
|
28784
|
+
markElement.attributes["w:firstline"] = inchesToTwips(attrs.textIndent);
|
|
28785
|
+
break;
|
|
28786
|
+
case "textTransform":
|
|
28787
|
+
if (attrs?.textTransform === "none") {
|
|
28788
|
+
markElement.attributes["w:val"] = "0";
|
|
28789
|
+
} else {
|
|
28790
|
+
delete markElement.attributes;
|
|
28791
|
+
}
|
|
28792
|
+
markElement.type = "element";
|
|
28793
|
+
break;
|
|
28794
|
+
case "lineHeight":
|
|
28795
|
+
markElement.attributes["w:line"] = linesToTwips(attrs.lineHeight);
|
|
28796
|
+
break;
|
|
28797
|
+
case "highlight":
|
|
28798
|
+
markElement.attributes["w:fill"] = attrs.color?.substring(1);
|
|
28799
|
+
markElement.attributes["w:color"] = "auto";
|
|
28800
|
+
markElement.attributes["w:val"] = "clear";
|
|
28801
|
+
markElement.name = "w:shd";
|
|
28802
|
+
break;
|
|
28803
|
+
}
|
|
28804
|
+
return markElement;
|
|
28805
|
+
}
|
|
28806
|
+
function getPngDimensions(base64) {
|
|
28807
|
+
if (!base64) return {};
|
|
28808
|
+
const type2 = base64.split(";")[0].split("/")[1];
|
|
28809
|
+
if (!base64 || type2 !== "png") {
|
|
28810
|
+
return {
|
|
28811
|
+
originalWidth: void 0,
|
|
28812
|
+
originalHeight: void 0
|
|
28813
|
+
};
|
|
28814
|
+
}
|
|
28815
|
+
let header = base64.split(",")[1].slice(0, 50);
|
|
28816
|
+
let uint8 = Uint8Array.from(atob(header), (c) => c.charCodeAt(0));
|
|
28817
|
+
let dataView = new DataView(uint8.buffer, 0, 28);
|
|
28818
|
+
return {
|
|
28819
|
+
originalWidth: dataView.getInt32(16),
|
|
28820
|
+
originalHeight: dataView.getInt32(20)
|
|
28821
|
+
};
|
|
28822
|
+
}
|
|
28823
|
+
function getScaledSize(originalWidth, originalHeight, maxWidth, maxHeight) {
|
|
28824
|
+
let scaledWidth = originalWidth;
|
|
28825
|
+
let scaledHeight = originalHeight;
|
|
28826
|
+
let ratio = Math.min(maxWidth / originalWidth, maxHeight / originalHeight);
|
|
28827
|
+
scaledWidth = Math.round(scaledWidth * ratio);
|
|
28828
|
+
scaledHeight = Math.round(scaledHeight * ratio);
|
|
28829
|
+
return { scaledWidth, scaledHeight };
|
|
28830
|
+
}
|
|
28831
|
+
function translateImageNode(params, imageSize) {
|
|
28832
|
+
const {
|
|
28833
|
+
node: { attrs = {} },
|
|
28834
|
+
tableCell
|
|
28835
|
+
} = params;
|
|
28836
|
+
let imageId = attrs.rId;
|
|
28837
|
+
const src = attrs.src || attrs.imageSrc;
|
|
28838
|
+
const { originalWidth, originalHeight } = getPngDimensions(src);
|
|
28839
|
+
const imageName = params.node.type === "image" ? src.split("/").pop() : attrs.fieldId?.replace("-", "_");
|
|
28840
|
+
let size = attrs.size ? {
|
|
28841
|
+
w: pixelsToEmu(attrs.size.width),
|
|
28842
|
+
h: pixelsToEmu(attrs.size.height)
|
|
28843
|
+
} : imageSize;
|
|
28844
|
+
if (originalWidth && originalHeight) {
|
|
28845
|
+
const boxWidthPx = emuToPixels(size.w);
|
|
28846
|
+
const boxHeightPx = emuToPixels(size.h);
|
|
28847
|
+
const { scaledWidth, scaledHeight } = getScaledSize(originalWidth, originalHeight, boxWidthPx, boxHeightPx);
|
|
28848
|
+
size = {
|
|
28849
|
+
w: pixelsToEmu(scaledWidth),
|
|
28850
|
+
h: pixelsToEmu(scaledHeight)
|
|
28851
|
+
};
|
|
28852
|
+
}
|
|
28853
|
+
if (tableCell) {
|
|
28854
|
+
const colwidthSum = tableCell.attrs.colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
28855
|
+
const leftMargin = tableCell.attrs.cellMargins?.left || 8;
|
|
28856
|
+
const rightMargin = tableCell.attrs.cellMargins?.right || 8;
|
|
28857
|
+
const maxWidthEmu = pixelsToEmu(colwidthSum - (leftMargin + rightMargin));
|
|
28858
|
+
const { width: w2, height: h2 } = resizeKeepAspectRatio(size.w, size.h, maxWidthEmu);
|
|
28859
|
+
if (w2 && h2) size = { w: w2, h: h2 };
|
|
28860
|
+
}
|
|
28861
|
+
if (params.node.type === "image" && !imageId) {
|
|
28862
|
+
const path = src?.split("word/")[1];
|
|
28863
|
+
imageId = addNewImageRelationship(params, path);
|
|
28864
|
+
} else if (params.node.type === "fieldAnnotation" && !imageId) {
|
|
28865
|
+
const type2 = src?.split(";")[0].split("/")[1];
|
|
28866
|
+
if (!type2) {
|
|
28867
|
+
return prepareTextAnnotation(params);
|
|
28868
|
+
}
|
|
28869
|
+
const imageUrl = `media/${imageName}_${attrs.hash}.${type2}`;
|
|
28870
|
+
imageId = addNewImageRelationship(params, imageUrl);
|
|
28871
|
+
params.media[`${imageName}_${attrs.hash}.${type2}`] = src;
|
|
28872
|
+
}
|
|
28873
|
+
let inlineAttrs = attrs.originalPadding || {
|
|
28874
|
+
distT: 0,
|
|
28875
|
+
distB: 0,
|
|
28876
|
+
distL: 0,
|
|
28877
|
+
distR: 0
|
|
28878
|
+
};
|
|
28879
|
+
const anchorElements = [];
|
|
28880
|
+
let wrapProp = [];
|
|
28881
|
+
if (attrs.isAnchor) {
|
|
28882
|
+
inlineAttrs = {
|
|
28883
|
+
...inlineAttrs,
|
|
28884
|
+
simplePos: attrs.originalAttributes?.simplePos,
|
|
28885
|
+
relativeHeight: 1,
|
|
28886
|
+
behindDoc: attrs.originalAttributes?.behindDoc,
|
|
28887
|
+
locked: attrs.originalAttributes?.locked,
|
|
28888
|
+
layoutInCell: attrs.originalAttributes?.layoutInCell,
|
|
28889
|
+
allowOverlap: attrs.originalAttributes?.allowOverlap
|
|
28890
|
+
};
|
|
28891
|
+
if (attrs.simplePos) {
|
|
28892
|
+
anchorElements.push({
|
|
28893
|
+
name: "wp:simplePos",
|
|
28894
|
+
attributes: {
|
|
28895
|
+
x: 0,
|
|
28896
|
+
y: 0
|
|
28897
|
+
}
|
|
28898
|
+
});
|
|
28899
|
+
}
|
|
28900
|
+
if (attrs.anchorData) {
|
|
28901
|
+
anchorElements.push({
|
|
28902
|
+
name: "wp:positionH",
|
|
28903
|
+
attributes: {
|
|
28904
|
+
relativeFrom: attrs.anchorData.hRelativeFrom
|
|
28905
|
+
},
|
|
28906
|
+
...attrs.marginOffset.left !== void 0 && {
|
|
28907
|
+
elements: [
|
|
28908
|
+
{
|
|
28909
|
+
name: "wp:posOffset",
|
|
28910
|
+
elements: [
|
|
28911
|
+
{
|
|
28912
|
+
type: "text",
|
|
28913
|
+
text: pixelsToEmu(attrs.marginOffset.left).toString()
|
|
28914
|
+
}
|
|
28915
|
+
]
|
|
28916
|
+
}
|
|
28917
|
+
]
|
|
28918
|
+
},
|
|
28919
|
+
...attrs.anchorData.alignH && {
|
|
28920
|
+
elements: [
|
|
28921
|
+
{
|
|
28922
|
+
name: "wp:align",
|
|
28923
|
+
elements: [
|
|
28924
|
+
{
|
|
28925
|
+
type: "text",
|
|
28926
|
+
text: attrs.anchorData.alignH
|
|
28927
|
+
}
|
|
28928
|
+
]
|
|
28929
|
+
}
|
|
28930
|
+
]
|
|
28931
|
+
}
|
|
28932
|
+
});
|
|
28933
|
+
anchorElements.push({
|
|
28934
|
+
name: "wp:positionV",
|
|
28935
|
+
attributes: {
|
|
28936
|
+
relativeFrom: attrs.anchorData.vRelativeFrom
|
|
28937
|
+
},
|
|
28938
|
+
...attrs.marginOffset.top !== void 0 && {
|
|
28939
|
+
elements: [
|
|
28940
|
+
{
|
|
28941
|
+
name: "wp:posOffset",
|
|
28942
|
+
elements: [
|
|
28943
|
+
{
|
|
28944
|
+
type: "text",
|
|
28945
|
+
text: pixelsToEmu(attrs.marginOffset.top).toString()
|
|
28946
|
+
}
|
|
28947
|
+
]
|
|
28948
|
+
}
|
|
28949
|
+
]
|
|
28950
|
+
},
|
|
28951
|
+
...attrs.anchorData.alignV && {
|
|
28952
|
+
elements: [
|
|
28953
|
+
{
|
|
28954
|
+
name: "wp:align",
|
|
28955
|
+
elements: [
|
|
28956
|
+
{
|
|
28957
|
+
type: "text",
|
|
28958
|
+
text: attrs.anchorData.alignV
|
|
28959
|
+
}
|
|
28960
|
+
]
|
|
28961
|
+
}
|
|
28962
|
+
]
|
|
28963
|
+
}
|
|
28964
|
+
});
|
|
28965
|
+
}
|
|
28966
|
+
if (attrs.wrapText) {
|
|
28967
|
+
wrapProp.push({
|
|
28968
|
+
name: "wp:wrapSquare",
|
|
28969
|
+
attributes: {
|
|
28970
|
+
wrapText: attrs.wrapText
|
|
28971
|
+
}
|
|
28972
|
+
});
|
|
28973
|
+
}
|
|
28974
|
+
if (attrs.wrapTopAndBottom) {
|
|
28975
|
+
wrapProp.push({
|
|
28976
|
+
name: "wp:wrapTopAndBottom"
|
|
28977
|
+
});
|
|
28978
|
+
}
|
|
28979
|
+
if (attrs.isAnchor && !wrapProp.length) {
|
|
28980
|
+
wrapProp.push({
|
|
28981
|
+
name: "wp:wrapNone"
|
|
28982
|
+
});
|
|
28983
|
+
}
|
|
29838
28984
|
}
|
|
29839
|
-
|
|
28985
|
+
const drawingXmlns = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
28986
|
+
const pictureXmlns = "http://schemas.openxmlformats.org/drawingml/2006/picture";
|
|
28987
|
+
const textNode = wrapTextInRun(
|
|
28988
|
+
{
|
|
28989
|
+
name: "w:drawing",
|
|
28990
|
+
elements: [
|
|
28991
|
+
{
|
|
28992
|
+
name: attrs.isAnchor ? "wp:anchor" : "wp:inline",
|
|
28993
|
+
attributes: inlineAttrs,
|
|
28994
|
+
elements: [
|
|
28995
|
+
...anchorElements,
|
|
28996
|
+
{
|
|
28997
|
+
name: "wp:extent",
|
|
28998
|
+
attributes: {
|
|
28999
|
+
cx: size.w,
|
|
29000
|
+
cy: size.h
|
|
29001
|
+
}
|
|
29002
|
+
},
|
|
29003
|
+
{
|
|
29004
|
+
name: "wp:effectExtent",
|
|
29005
|
+
attributes: {
|
|
29006
|
+
l: 0,
|
|
29007
|
+
t: 0,
|
|
29008
|
+
r: 0,
|
|
29009
|
+
b: 0
|
|
29010
|
+
}
|
|
29011
|
+
},
|
|
29012
|
+
...wrapProp,
|
|
29013
|
+
{
|
|
29014
|
+
name: "wp:docPr",
|
|
29015
|
+
attributes: {
|
|
29016
|
+
id: attrs.id || 0,
|
|
29017
|
+
name: attrs.alt || `Picture ${imageName}`
|
|
29018
|
+
}
|
|
29019
|
+
},
|
|
29020
|
+
{
|
|
29021
|
+
name: "wp:cNvGraphicFramePr",
|
|
29022
|
+
elements: [
|
|
29023
|
+
{
|
|
29024
|
+
name: "a:graphicFrameLocks",
|
|
29025
|
+
attributes: {
|
|
29026
|
+
"xmlns:a": drawingXmlns,
|
|
29027
|
+
noChangeAspect: 1
|
|
29028
|
+
}
|
|
29029
|
+
}
|
|
29030
|
+
]
|
|
29031
|
+
},
|
|
29032
|
+
{
|
|
29033
|
+
name: "a:graphic",
|
|
29034
|
+
attributes: { "xmlns:a": drawingXmlns },
|
|
29035
|
+
elements: [
|
|
29036
|
+
{
|
|
29037
|
+
name: "a:graphicData",
|
|
29038
|
+
attributes: { uri: pictureXmlns },
|
|
29039
|
+
elements: [
|
|
29040
|
+
{
|
|
29041
|
+
name: "pic:pic",
|
|
29042
|
+
attributes: { "xmlns:pic": pictureXmlns },
|
|
29043
|
+
elements: [
|
|
29044
|
+
{
|
|
29045
|
+
name: "pic:nvPicPr",
|
|
29046
|
+
elements: [
|
|
29047
|
+
{
|
|
29048
|
+
name: "pic:cNvPr",
|
|
29049
|
+
attributes: {
|
|
29050
|
+
id: attrs.id || 0,
|
|
29051
|
+
name: attrs.title || `Picture ${imageName}`
|
|
29052
|
+
}
|
|
29053
|
+
},
|
|
29054
|
+
{
|
|
29055
|
+
name: "pic:cNvPicPr",
|
|
29056
|
+
elements: [
|
|
29057
|
+
{
|
|
29058
|
+
name: "a:picLocks",
|
|
29059
|
+
attributes: {
|
|
29060
|
+
noChangeAspect: 1,
|
|
29061
|
+
noChangeArrowheads: 1
|
|
29062
|
+
}
|
|
29063
|
+
}
|
|
29064
|
+
]
|
|
29065
|
+
}
|
|
29066
|
+
]
|
|
29067
|
+
},
|
|
29068
|
+
{
|
|
29069
|
+
name: "pic:blipFill",
|
|
29070
|
+
elements: [
|
|
29071
|
+
{
|
|
29072
|
+
name: "a:blip",
|
|
29073
|
+
attributes: {
|
|
29074
|
+
"r:embed": imageId
|
|
29075
|
+
}
|
|
29076
|
+
},
|
|
29077
|
+
{
|
|
29078
|
+
name: "a:stretch",
|
|
29079
|
+
elements: [{ name: "a:fillRect" }]
|
|
29080
|
+
}
|
|
29081
|
+
]
|
|
29082
|
+
},
|
|
29083
|
+
{
|
|
29084
|
+
name: "pic:spPr",
|
|
29085
|
+
attributes: {
|
|
29086
|
+
bwMode: "auto"
|
|
29087
|
+
},
|
|
29088
|
+
elements: [
|
|
29089
|
+
{
|
|
29090
|
+
name: "a:xfrm",
|
|
29091
|
+
elements: [
|
|
29092
|
+
{
|
|
29093
|
+
name: "a:ext",
|
|
29094
|
+
attributes: {
|
|
29095
|
+
cx: size.w,
|
|
29096
|
+
cy: size.h
|
|
29097
|
+
}
|
|
29098
|
+
},
|
|
29099
|
+
{
|
|
29100
|
+
name: "a:off",
|
|
29101
|
+
attributes: {
|
|
29102
|
+
x: 0,
|
|
29103
|
+
y: 0
|
|
29104
|
+
}
|
|
29105
|
+
}
|
|
29106
|
+
]
|
|
29107
|
+
},
|
|
29108
|
+
{
|
|
29109
|
+
name: "a:prstGeom",
|
|
29110
|
+
attributes: { prst: "rect" },
|
|
29111
|
+
elements: [{ name: "a:avLst" }]
|
|
29112
|
+
},
|
|
29113
|
+
{
|
|
29114
|
+
name: "a:noFill"
|
|
29115
|
+
}
|
|
29116
|
+
]
|
|
29117
|
+
}
|
|
29118
|
+
]
|
|
29119
|
+
}
|
|
29120
|
+
]
|
|
29121
|
+
}
|
|
29122
|
+
]
|
|
29123
|
+
}
|
|
29124
|
+
]
|
|
29125
|
+
}
|
|
29126
|
+
]
|
|
29127
|
+
},
|
|
29128
|
+
[]
|
|
29129
|
+
);
|
|
29130
|
+
return textNode;
|
|
29840
29131
|
}
|
|
29841
29132
|
function translateShapeContainer(params) {
|
|
29842
29133
|
const { node } = params;
|
|
@@ -30015,6 +29306,14 @@ generateXml_fn = function(node) {
|
|
|
30015
29306
|
if (!selfClosing) tags.push(`</${name}>`);
|
|
30016
29307
|
return tags;
|
|
30017
29308
|
};
|
|
29309
|
+
function resizeKeepAspectRatio(width, height, maxWidth) {
|
|
29310
|
+
if (width > maxWidth) {
|
|
29311
|
+
let scale = maxWidth / width;
|
|
29312
|
+
let newHeight = Math.round(height * scale);
|
|
29313
|
+
return { width: maxWidth, height: newHeight };
|
|
29314
|
+
}
|
|
29315
|
+
return { width, height };
|
|
29316
|
+
}
|
|
30018
29317
|
const translatePageNumberNode = (params) => {
|
|
30019
29318
|
const outputMarks = processOutputMarks(params.node.attrs?.marksAsAttrs || []);
|
|
30020
29319
|
return getAutoPageJson("PAGE", outputMarks);
|
|
@@ -30098,7 +29397,7 @@ const getInitialJSON = (parsedDocx, fallbackXml = defaultInitialXml) => {
|
|
|
30098
29397
|
return parsedDocx["word/document.xml"] || parseXmlToJson(fallbackXml);
|
|
30099
29398
|
};
|
|
30100
29399
|
const handleDrawingNode = (params) => {
|
|
30101
|
-
const { nodes } = params;
|
|
29400
|
+
const { nodes, filename } = params;
|
|
30102
29401
|
const validNodes = ["w:drawing", "w:p"];
|
|
30103
29402
|
if (nodes.length === 0 || !validNodes.includes(nodes[0].name)) {
|
|
30104
29403
|
return { nodes: [], consumed: 0 };
|
|
@@ -30108,9 +29407,167 @@ const handleDrawingNode = (params) => {
|
|
|
30108
29407
|
if (mainNode.name === "w:drawing") node = mainNode;
|
|
30109
29408
|
else node = mainNode.elements.find((el) => el.name === "w:drawing");
|
|
30110
29409
|
if (!node) return { nodes: [], consumed: 0 };
|
|
30111
|
-
|
|
30112
|
-
const
|
|
30113
|
-
|
|
29410
|
+
let result;
|
|
29411
|
+
const { elements } = node;
|
|
29412
|
+
const currentFileName = filename || null;
|
|
29413
|
+
const isAnchor = elements.find((el) => el.name === "wp:anchor");
|
|
29414
|
+
if (isAnchor) {
|
|
29415
|
+
result = handleImageImport(elements[0], currentFileName, params);
|
|
29416
|
+
if (result && result.attrs) result.attrs.isAnchor = isAnchor;
|
|
29417
|
+
}
|
|
29418
|
+
const inlineImage = elements.find((el) => el.name === "wp:inline");
|
|
29419
|
+
if (inlineImage) result = handleImageImport(inlineImage, currentFileName, params);
|
|
29420
|
+
return { nodes: result ? [result] : [], consumed: 1 };
|
|
29421
|
+
};
|
|
29422
|
+
function handleImageImport(node, currentFileName, params) {
|
|
29423
|
+
const { docx } = params;
|
|
29424
|
+
const { attributes } = node;
|
|
29425
|
+
const padding = {
|
|
29426
|
+
top: emuToPixels(attributes["distT"]),
|
|
29427
|
+
bottom: emuToPixels(attributes["distB"]),
|
|
29428
|
+
left: emuToPixels(attributes["distL"]),
|
|
29429
|
+
right: emuToPixels(attributes["distR"])
|
|
29430
|
+
};
|
|
29431
|
+
const extent = node.elements.find((el) => el.name === "wp:extent");
|
|
29432
|
+
const size = {
|
|
29433
|
+
width: emuToPixels(extent.attributes?.cx),
|
|
29434
|
+
height: emuToPixels(extent.attributes?.cy)
|
|
29435
|
+
};
|
|
29436
|
+
const graphic = node.elements.find((el) => el.name === "a:graphic");
|
|
29437
|
+
const graphicData = graphic.elements.find((el) => el.name === "a:graphicData");
|
|
29438
|
+
const { uri: uri2 } = graphicData?.attributes || {};
|
|
29439
|
+
const shapeURI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
29440
|
+
if (!!uri2 && uri2 === shapeURI) {
|
|
29441
|
+
return handleShapeDrawing(params, node, graphicData);
|
|
29442
|
+
}
|
|
29443
|
+
const picture = graphicData.elements.find((el) => el.name === "pic:pic");
|
|
29444
|
+
if (!picture || !picture.elements) return null;
|
|
29445
|
+
const blipFill = picture.elements.find((el) => el.name === "pic:blipFill");
|
|
29446
|
+
const blip = blipFill.elements.find((el) => el.name === "a:blip");
|
|
29447
|
+
const positionHTag = node.elements.find((el) => el.name === "wp:positionH");
|
|
29448
|
+
const positionH = positionHTag?.elements.find((el) => el.name === "wp:posOffset");
|
|
29449
|
+
const positionHValue = emuToPixels(positionH?.elements[0]?.text);
|
|
29450
|
+
const hRelativeFrom = positionHTag?.attributes.relativeFrom;
|
|
29451
|
+
const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
29452
|
+
const positionVTag = node.elements.find((el) => el.name === "wp:positionV");
|
|
29453
|
+
const positionV = positionVTag?.elements?.find((el) => el.name === "wp:posOffset");
|
|
29454
|
+
const positionVValue = emuToPixels(positionV?.elements[0]?.text);
|
|
29455
|
+
const vRelativeFrom = positionVTag?.attributes.relativeFrom;
|
|
29456
|
+
const alignV = positionVTag?.elements?.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
29457
|
+
const simplePos = node.elements.find((el) => el.name === "wp:simplePos");
|
|
29458
|
+
const wrapSquare = node.elements.find((el) => el.name === "wp:wrapSquare");
|
|
29459
|
+
const wrapTopAndBottom = node.elements.find((el) => el.name === "wp:wrapTopAndBottom");
|
|
29460
|
+
const docPr = node.elements.find((el) => el.name === "wp:docPr");
|
|
29461
|
+
let anchorData = null;
|
|
29462
|
+
if (hRelativeFrom || alignH || vRelativeFrom || alignV) {
|
|
29463
|
+
anchorData = {
|
|
29464
|
+
hRelativeFrom,
|
|
29465
|
+
vRelativeFrom,
|
|
29466
|
+
alignH,
|
|
29467
|
+
alignV
|
|
29468
|
+
};
|
|
29469
|
+
}
|
|
29470
|
+
const marginOffset = {
|
|
29471
|
+
left: positionHValue,
|
|
29472
|
+
top: positionVValue
|
|
29473
|
+
};
|
|
29474
|
+
const { attributes: blipAttributes = {} } = blip;
|
|
29475
|
+
const rEmbed = blipAttributes["r:embed"];
|
|
29476
|
+
if (!rEmbed) return null;
|
|
29477
|
+
const currentFile = currentFileName || "document.xml";
|
|
29478
|
+
let rels = docx[`word/_rels/${currentFile}.rels`];
|
|
29479
|
+
if (!rels) rels = docx[`word/_rels/document.xml.rels`];
|
|
29480
|
+
const relationships = rels.elements.find((el) => el.name === "Relationships");
|
|
29481
|
+
const { elements } = relationships;
|
|
29482
|
+
const rel = elements.find((el) => el.attributes["Id"] === rEmbed);
|
|
29483
|
+
if (!rel) return null;
|
|
29484
|
+
const { attributes: relAttributes } = rel;
|
|
29485
|
+
const targetPath = relAttributes["Target"];
|
|
29486
|
+
let path = `word/${targetPath}`;
|
|
29487
|
+
if (targetPath.startsWith("/word") || targetPath.startsWith("/media")) path = targetPath.substring(1);
|
|
29488
|
+
const extension = targetPath.substring(targetPath.lastIndexOf(".") + 1);
|
|
29489
|
+
return {
|
|
29490
|
+
type: "image",
|
|
29491
|
+
attrs: {
|
|
29492
|
+
src: path,
|
|
29493
|
+
alt: ["emf", "wmf"].includes(extension) ? "Unable to render EMF/WMF image" : docPr?.attributes.name || "Image",
|
|
29494
|
+
extension,
|
|
29495
|
+
id: docPr?.attributes.id || "",
|
|
29496
|
+
title: docPr?.attributes.descr || "Image",
|
|
29497
|
+
inline: true,
|
|
29498
|
+
padding,
|
|
29499
|
+
marginOffset,
|
|
29500
|
+
size,
|
|
29501
|
+
anchorData,
|
|
29502
|
+
...simplePos && {
|
|
29503
|
+
simplePos: {
|
|
29504
|
+
x: simplePos.attributes.x,
|
|
29505
|
+
y: simplePos.attributes.y
|
|
29506
|
+
}
|
|
29507
|
+
},
|
|
29508
|
+
...wrapSquare && {
|
|
29509
|
+
wrapText: wrapSquare.attributes.wrapText
|
|
29510
|
+
},
|
|
29511
|
+
wrapTopAndBottom: !!wrapTopAndBottom,
|
|
29512
|
+
originalPadding: {
|
|
29513
|
+
distT: attributes["distT"],
|
|
29514
|
+
distB: attributes["distB"],
|
|
29515
|
+
distL: attributes["distL"],
|
|
29516
|
+
distR: attributes["distR"]
|
|
29517
|
+
},
|
|
29518
|
+
originalAttributes: node.attributes,
|
|
29519
|
+
rId: relAttributes["Id"]
|
|
29520
|
+
}
|
|
29521
|
+
};
|
|
29522
|
+
}
|
|
29523
|
+
const handleShapeDrawing = (params, node, graphicData) => {
|
|
29524
|
+
const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
|
|
29525
|
+
const textBox = wsp.elements.find((el) => el.name === "wps:txbx");
|
|
29526
|
+
const textBoxContent = textBox?.elements?.find((el) => el.name === "w:txbxContent");
|
|
29527
|
+
node.elements.find((el) => el.name === "wp:docPr");
|
|
29528
|
+
const spPr = wsp.elements.find((el) => el.name === "wps:spPr");
|
|
29529
|
+
const prstGeom = spPr?.elements.find((el) => el.name === "a:prstGeom");
|
|
29530
|
+
if (!!prstGeom && prstGeom.attributes["prst"] === "rect" && !textBoxContent) {
|
|
29531
|
+
return getRectangleShape(params, spPr);
|
|
29532
|
+
}
|
|
29533
|
+
if (!textBoxContent) {
|
|
29534
|
+
return null;
|
|
29535
|
+
}
|
|
29536
|
+
const { nodeListHandler } = params;
|
|
29537
|
+
const translatedElement = nodeListHandler.handler({
|
|
29538
|
+
...params,
|
|
29539
|
+
node: textBoxContent.elements[0],
|
|
29540
|
+
nodes: textBoxContent.elements,
|
|
29541
|
+
path: [...params.path || [], textBoxContent]
|
|
29542
|
+
});
|
|
29543
|
+
return translatedElement[0];
|
|
29544
|
+
};
|
|
29545
|
+
const getRectangleShape = (params, node) => {
|
|
29546
|
+
const schemaAttrs = {};
|
|
29547
|
+
const [drawingNode] = params.nodes;
|
|
29548
|
+
if (drawingNode?.name === "w:drawing") {
|
|
29549
|
+
schemaAttrs.drawingContent = drawingNode;
|
|
29550
|
+
}
|
|
29551
|
+
const xfrm = node.elements.find((el) => el.name === "a:xfrm");
|
|
29552
|
+
const start = xfrm.elements.find((el) => el.name === "a:off");
|
|
29553
|
+
const size = xfrm.elements.find((el) => el.name === "a:ext");
|
|
29554
|
+
const solidFill = node.elements.find((el) => el.name === "a:solidFill");
|
|
29555
|
+
node.elements.find((el) => el.name === "a:ln");
|
|
29556
|
+
const rectangleSize = {
|
|
29557
|
+
top: emuToPixels(start.attributes["y"]),
|
|
29558
|
+
left: emuToPixels(start.attributes["x"]),
|
|
29559
|
+
width: emuToPixels(size.attributes["cx"]),
|
|
29560
|
+
height: emuToPixels(size.attributes["cy"])
|
|
29561
|
+
};
|
|
29562
|
+
schemaAttrs.size = rectangleSize;
|
|
29563
|
+
const background = solidFill?.elements[0]?.attributes["val"];
|
|
29564
|
+
if (background) {
|
|
29565
|
+
schemaAttrs.background = "#" + background;
|
|
29566
|
+
}
|
|
29567
|
+
return {
|
|
29568
|
+
type: "contentBlock",
|
|
29569
|
+
attrs: schemaAttrs
|
|
29570
|
+
};
|
|
30114
29571
|
};
|
|
30115
29572
|
const drawingNodeHandlerEntity = {
|
|
30116
29573
|
handlerName: "drawingNodeHandler",
|
|
@@ -30210,7 +29667,7 @@ const trackChangeNodeHandlerEntity = {
|
|
|
30210
29667
|
handlerName: "trackChangeNodeHandler",
|
|
30211
29668
|
handler: handleTrackChangeNode
|
|
30212
29669
|
};
|
|
30213
|
-
const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$
|
|
29670
|
+
const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$1);
|
|
30214
29671
|
const handleRunNode = (params) => {
|
|
30215
29672
|
const { nodes, nodeListHandler, parentStyleId, docx } = params;
|
|
30216
29673
|
if (nodes.length === 0 || nodes[0].name !== "w:r") {
|
|
@@ -30322,7 +29779,7 @@ const handleParagraphNode = (params) => {
|
|
|
30322
29779
|
if (nodes.length === 0 || nodes[0].name !== "w:p") {
|
|
30323
29780
|
return { nodes: [], consumed: 0 };
|
|
30324
29781
|
}
|
|
30325
|
-
const schemaNode = translator$
|
|
29782
|
+
const schemaNode = translator$h.encode(params);
|
|
30326
29783
|
const newNodes = schemaNode ? [schemaNode] : [];
|
|
30327
29784
|
return { nodes: newNodes, consumed: 1 };
|
|
30328
29785
|
};
|
|
@@ -30425,7 +29882,7 @@ const handler = (params) => {
|
|
|
30425
29882
|
if (nodes.length === 0 || nodes[0].name !== "w:br") {
|
|
30426
29883
|
return { nodes: [], consumed: 0 };
|
|
30427
29884
|
}
|
|
30428
|
-
const result = translator$
|
|
29885
|
+
const result = translator$j.encode(params);
|
|
30429
29886
|
if (!result) return { nodes: [], consumed: 0 };
|
|
30430
29887
|
return {
|
|
30431
29888
|
nodes: [result],
|
|
@@ -31121,7 +30578,7 @@ const handleTabNode = (params) => {
|
|
|
31121
30578
|
if (!nodes.length || nodes[0].name !== "w:tab") {
|
|
31122
30579
|
return { nodes: [], consumed: 0 };
|
|
31123
30580
|
}
|
|
31124
|
-
const node = translator$
|
|
30581
|
+
const node = translator$i.encode(params);
|
|
31125
30582
|
return { nodes: [node], consumed: 1 };
|
|
31126
30583
|
};
|
|
31127
30584
|
const tabNodeEntityHandler = {
|
|
@@ -31426,8 +30883,8 @@ function addDefaultStylesIfMissing(styles) {
|
|
|
31426
30883
|
}
|
|
31427
30884
|
const importHeadersFooters = (docx, converter, mainEditor) => {
|
|
31428
30885
|
const rels = docx["word/_rels/document.xml.rels"];
|
|
31429
|
-
const relationships = rels
|
|
31430
|
-
const { elements } = relationships
|
|
30886
|
+
const relationships = rels.elements.find((el) => el.name === "Relationships");
|
|
30887
|
+
const { elements } = relationships;
|
|
31431
30888
|
const headerType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header";
|
|
31432
30889
|
const footerType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";
|
|
31433
30890
|
const headers = elements.filter((el) => el.attributes["Type"] === headerType);
|
|
@@ -31648,7 +31105,7 @@ const _SuperConverter = class _SuperConverter {
|
|
|
31648
31105
|
return;
|
|
31649
31106
|
}
|
|
31650
31107
|
}
|
|
31651
|
-
static updateDocumentVersion(docx = this.convertedXml, version = "0.
|
|
31108
|
+
static updateDocumentVersion(docx = this.convertedXml, version = "0.19.0") {
|
|
31652
31109
|
const customLocation = "docProps/custom.xml";
|
|
31653
31110
|
if (!docx[customLocation]) {
|
|
31654
31111
|
docx[customLocation] = generateCustomXml();
|
|
@@ -32138,7 +31595,7 @@ function storeSuperdocVersion(docx) {
|
|
|
32138
31595
|
function generateCustomXml() {
|
|
32139
31596
|
return DEFAULT_CUSTOM_XML;
|
|
32140
31597
|
}
|
|
32141
|
-
function generateSuperdocVersion(pid = 2, version = "0.
|
|
31598
|
+
function generateSuperdocVersion(pid = 2, version = "0.19.0") {
|
|
32142
31599
|
return {
|
|
32143
31600
|
type: "element",
|
|
32144
31601
|
name: "property",
|
|
@@ -32201,12 +31658,15 @@ export {
|
|
|
32201
31658
|
createDocFromMarkdown as a7,
|
|
32202
31659
|
createDocFromHTML as a8,
|
|
32203
31660
|
EditorState as a9,
|
|
32204
|
-
|
|
32205
|
-
|
|
32206
|
-
|
|
32207
|
-
|
|
32208
|
-
|
|
32209
|
-
|
|
31661
|
+
vClickOutside as aA,
|
|
31662
|
+
getActiveFormatting as aB,
|
|
31663
|
+
readFromClipboard as aC,
|
|
31664
|
+
handleClipboardPaste as aD,
|
|
31665
|
+
getFileObject as aE,
|
|
31666
|
+
translator$h as aF,
|
|
31667
|
+
translator$i as aG,
|
|
31668
|
+
translator$j as aH,
|
|
31669
|
+
_sfc_main as aI,
|
|
32210
31670
|
hasSomeParentWithClass as aa,
|
|
32211
31671
|
isActive as ab,
|
|
32212
31672
|
unflattenListsInHtml as ac,
|
|
@@ -32221,18 +31681,18 @@ export {
|
|
|
32221
31681
|
parseIndentElement as al,
|
|
32222
31682
|
combineIndents as am,
|
|
32223
31683
|
StepMap as an,
|
|
32224
|
-
|
|
32225
|
-
|
|
32226
|
-
|
|
32227
|
-
|
|
32228
|
-
|
|
32229
|
-
|
|
32230
|
-
|
|
32231
|
-
|
|
32232
|
-
|
|
32233
|
-
|
|
32234
|
-
|
|
32235
|
-
|
|
31684
|
+
getColStyleDeclaration as ao,
|
|
31685
|
+
SelectionRange as ap,
|
|
31686
|
+
Transform as aq,
|
|
31687
|
+
isInTable as ar,
|
|
31688
|
+
createColGroup as as,
|
|
31689
|
+
generateDocxRandomId as at,
|
|
31690
|
+
insertNewRelationship as au,
|
|
31691
|
+
htmlHandler as av,
|
|
31692
|
+
commonjsGlobal as aw,
|
|
31693
|
+
getDefaultExportFromCjs$1 as ax,
|
|
31694
|
+
getContentTypesFromXml as ay,
|
|
31695
|
+
xmljs as az,
|
|
32236
31696
|
Slice as b,
|
|
32237
31697
|
DOMParser$1 as c,
|
|
32238
31698
|
Mark as d,
|