@harbour-enterprises/superdoc 0.20.0-next.1 → 0.20.0-next.10
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-BLwxuMWh.cjs → PdfViewer-DOggjrQG.cjs} +1 -1
- package/dist/chunks/{PdfViewer-t_JS3Mbo.es.js → PdfViewer-Dqmc7nRW.es.js} +1 -1
- package/dist/chunks/{index-Vp2WxlNm.es.js → index-BWLk-GjX.es.js} +2 -2
- package/dist/chunks/{index-CBTSdULo.cjs → index-BbzkKu8K.cjs} +2 -2
- package/dist/chunks/{super-editor.es-Cten5oWF.cjs → super-editor.es--aCMUiMA.cjs} +3533 -2531
- package/dist/chunks/{super-editor.es-DGV2_J23.es.js → super-editor.es-Czm6AhQx.es.js} +3533 -2531
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/style.css +38 -0
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-Dq0PLazx.js → converter-CJg7BSkp.js} +1781 -1155
- package/dist/super-editor/chunks/{docx-zipper-jT0gaoep.js → docx-zipper-D56KgEUM.js} +2 -2
- package/dist/super-editor/chunks/{editor-BEtv1kuN.js → editor-CZE0QdnY.js} +1409 -1044
- package/dist/super-editor/chunks/{toolbar-CJfSHfLU.js → toolbar-YvqMpKof.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 +1 -0
- package/dist/super-editor/src/core/helpers/updateDOMAttributes.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/export-helpers/pre-process-vertical-merge-cells.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/exporter.d.ts +7 -1
- package/dist/super-editor/src/core/super-converter/helpers/mediaHelpers.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/helpers.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v2/importer/bookmarkEndImporter.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v2/importer/bookmarkNodeImporter.d.ts +5 -0
- package/dist/super-editor/src/core/super-converter/v2/importer/bookmarkStartImporter.d.ts +6 -0
- 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 +0 -22
- package/dist/super-editor/src/core/super-converter/v3/handlers/index.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/utils.d.ts +10 -3
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bidiVisual/bidiVisual-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bidiVisual/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-end/attributes/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-end/attributes/w-displaced-by-custom-xml.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-end/attributes/w-id.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-end/bookmark-end-translator.d.ts +7 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-end/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/w-col-first.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/w-col-last.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/w-displaced-by-custom-xml.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/w-id.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/w-name.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/bookmark-start-translator.d.ts +7 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/bottom-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/marginBottom-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/drawing/drawing-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/drawing/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/end-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/marginEnd-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/gridCol/gridCol-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/gridCol/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideH/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideH/insideH-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideV/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideV/insideV-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/left-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/marginLeft-translator.d.ts +6 -0
- 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/right/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/marginRight-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/right-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/shd/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/shd/shd-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/marginStart-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/start-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tbl/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tbl/tbl-translator.d.ts +28 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblBorders/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblBorders/tblBorders-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCaption/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCaption/tblCaption-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCellMar/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCellMar/tblCellMar-translator.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblDescription/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblDescription/tblDescription-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-helpers.d.ts +5 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-translator.d.ts +5 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblInd/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblInd/tblInd-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLayout/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLayout/tblLayout-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLook/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLook/tblLook-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblOverlap/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblOverlap/tblOverlap-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblPr/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblPr/tblPr-translator.d.ts +5 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyle/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyle/tblStyle-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleColBandSize/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleColBandSize/tblStyleColBandSize-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleRowBandSize/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleRowBandSize/tblStyleRowBandSize-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblW/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblW/tblW-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblpPr/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblpPr/tblpPr-translator.d.ts +6 -0
- 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/handlers/w/top/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/marginTop-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/top-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/anchor-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/handle-anchor-node.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/translate-anchor-node.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/decode-image-node-helpers.d.ts +18 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/encode-image-node-helpers.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/helpers/handle-inline-node.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/helpers/translate-inline-node.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/inline-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +11 -1
- package/dist/super-editor/src/extensions/block-node/block-node.d.ts +30 -5
- package/dist/super-editor/src/extensions/bold/bold.d.ts +20 -0
- package/dist/super-editor/src/extensions/bookmarks/bookmark-end.d.ts +6 -0
- package/dist/super-editor/src/extensions/bookmarks/index.d.ts +2 -1
- package/dist/super-editor/src/extensions/bullet-list/bullet-list.d.ts +12 -0
- package/dist/super-editor/src/extensions/color/color.d.ts +26 -0
- package/dist/super-editor/src/extensions/content-block/content-block.d.ts +30 -0
- package/dist/super-editor/src/extensions/custom-selection/custom-selection.d.ts +16 -0
- package/dist/super-editor/src/extensions/document/document.d.ts +26 -0
- package/dist/super-editor/src/extensions/dropcursor/dropcursor.d.ts +26 -0
- package/dist/super-editor/src/extensions/font-family/font-family.d.ts +29 -0
- package/dist/super-editor/src/extensions/font-size/font-size.d.ts +21 -0
- package/dist/super-editor/src/extensions/format-commands/format-commands.d.ts +9 -0
- package/dist/super-editor/src/extensions/gapcursor/gapcursor.d.ts +9 -0
- package/dist/super-editor/src/extensions/heading/heading.d.ts +12 -6
- package/dist/super-editor/src/extensions/highlight/highlight.d.ts +20 -0
- package/dist/super-editor/src/extensions/history/history.d.ts +7 -15
- package/dist/super-editor/src/extensions/image/image.d.ts +78 -0
- package/dist/super-editor/src/extensions/image/imageHelpers/fileNameUtils.d.ts +3 -0
- package/dist/super-editor/src/extensions/image/imageHelpers/handleBase64.d.ts +1 -0
- package/dist/super-editor/src/extensions/image/imageHelpers/handleUrl.d.ts +2 -0
- package/dist/super-editor/src/extensions/image/imageHelpers/imageRegistrationPlugin.d.ts +11 -0
- package/dist/super-editor/src/extensions/image/imageHelpers/index.d.ts +3 -1
- package/dist/super-editor/src/extensions/image/imageHelpers/processUploadedImage.d.ts +2 -2
- package/dist/super-editor/src/extensions/image/imageHelpers/rotation.d.ts +4 -0
- package/dist/super-editor/src/extensions/image/imageHelpers/startImageUpload.d.ts +18 -23
- package/dist/super-editor/src/extensions/index.d.ts +2 -1
- package/dist/super-editor/src/extensions/italic/italic.d.ts +10 -0
- package/dist/super-editor/src/extensions/line-break/line-break.d.ts +43 -0
- package/dist/super-editor/src/extensions/line-height/line-height.d.ts +22 -0
- package/dist/super-editor/src/extensions/link/link.d.ts +53 -25
- package/dist/super-editor/src/extensions/linked-styles/linked-styles.d.ts +9 -0
- package/dist/super-editor/src/extensions/list-item/list-item.d.ts +48 -0
- package/dist/super-editor/src/extensions/mention/mention.d.ts +26 -0
- package/dist/super-editor/src/extensions/noderesizer/noderesizer.d.ts +14 -0
- package/dist/super-editor/src/extensions/ordered-list/ordered-list.d.ts +35 -0
- package/dist/super-editor/src/extensions/page-number/page-number.d.ts +52 -0
- package/dist/super-editor/src/extensions/paragraph/paragraph.d.ts +49 -0
- package/dist/super-editor/src/extensions/placeholder/placeholder.d.ts +15 -0
- package/dist/super-editor/src/extensions/popover-plugin/popover-plugin.d.ts +9 -0
- package/dist/super-editor/src/extensions/run-item/run-item.d.ts +24 -0
- package/dist/super-editor/src/extensions/search/search.d.ts +11 -2
- package/dist/super-editor/src/extensions/shape-container/shape-container.d.ts +29 -0
- package/dist/super-editor/src/extensions/shape-textbox/shape-textbox.d.ts +26 -0
- package/dist/super-editor/src/extensions/slash-menu/slash-menu.d.ts +9 -0
- package/dist/super-editor/src/extensions/strike/strike.d.ts +10 -0
- package/dist/super-editor/src/extensions/structured-content/StructuredContentBlockView.d.ts +9 -0
- package/dist/super-editor/src/extensions/structured-content/StructuredContentInlineView.d.ts +9 -0
- package/dist/super-editor/src/extensions/structured-content/StructuredContentViewBase.d.ts +24 -0
- package/dist/super-editor/src/extensions/structured-content/document-section.d.ts +46 -27
- package/dist/super-editor/src/extensions/structured-content/structured-content-block.d.ts +29 -1
- package/dist/super-editor/src/extensions/structured-content/structured-content.d.ts +29 -1
- package/dist/super-editor/src/extensions/tab/tab.d.ts +25 -0
- package/dist/super-editor/src/extensions/table/table.d.ts +376 -55
- package/dist/super-editor/src/extensions/table-cell/table-cell.d.ts +41 -0
- package/dist/super-editor/src/extensions/table-header/table-header.d.ts +22 -0
- package/dist/super-editor/src/extensions/table-row/table-row.d.ts +28 -0
- package/dist/super-editor/src/extensions/text/text.d.ts +14 -0
- package/dist/super-editor/src/extensions/text-align/text-align.d.ts +22 -0
- package/dist/super-editor/src/extensions/text-indent/text-indent.d.ts +19 -10
- package/dist/super-editor/src/extensions/text-style/text-style.d.ts +20 -0
- package/dist/super-editor/src/extensions/text-transform/text-transform.d.ts +20 -0
- package/dist/super-editor/src/extensions/underline/underline.d.ts +25 -0
- package/dist/super-editor/src/tests/helpers/editor-test-utils.d.ts +14 -0
- package/dist/super-editor/style.css +38 -0
- package/dist/super-editor/super-editor.es.js +65 -55
- 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 +4161 -3159
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/super-editor/src/extensions/image/imageHelpers/imagePlaceholderPlugin.d.ts +0 -5
- /package/dist/super-editor/src/extensions/bookmarks/{bookmarks.d.ts → bookmark-start.d.ts} +0 -0
|
@@ -14779,22 +14779,25 @@ 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(inches * 1440);
|
|
14782
|
+
return Math.round(Number(inches) * 1440);
|
|
14783
14783
|
}
|
|
14784
14784
|
function twipsToInches(twips) {
|
|
14785
14785
|
if (twips == null) return;
|
|
14786
|
-
|
|
14787
|
-
|
|
14786
|
+
const value = Number(twips);
|
|
14787
|
+
if (Number.isNaN(value)) return;
|
|
14788
|
+
return value / 1440;
|
|
14788
14789
|
}
|
|
14789
14790
|
function twipsToPixels(twips) {
|
|
14790
14791
|
if (twips == null) return;
|
|
14791
|
-
|
|
14792
|
-
|
|
14792
|
+
const inches = twipsToInches(twips);
|
|
14793
|
+
if (inches == null) return;
|
|
14794
|
+
const pixels = inches * 96;
|
|
14795
|
+
return Math.round(pixels * 1e3) / 1e3;
|
|
14793
14796
|
}
|
|
14794
14797
|
function pixelsToTwips(pixels) {
|
|
14795
14798
|
if (pixels == null) return;
|
|
14796
|
-
|
|
14797
|
-
return inchesToTwips(
|
|
14799
|
+
const inches = Number(pixels) / 96;
|
|
14800
|
+
return inchesToTwips(inches);
|
|
14798
14801
|
}
|
|
14799
14802
|
function twipsToLines(twips) {
|
|
14800
14803
|
if (twips == null) return;
|
|
@@ -14837,6 +14840,14 @@ function ptToTwips(pt) {
|
|
|
14837
14840
|
if (pt == null) return;
|
|
14838
14841
|
return pt * 20;
|
|
14839
14842
|
}
|
|
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
|
+
}
|
|
14840
14851
|
const getTextIndentExportValue = (indent) => {
|
|
14841
14852
|
const [value, unit] = parseSizeUnit(indent);
|
|
14842
14853
|
const functionsMap = {
|
|
@@ -16392,41 +16403,6 @@ const prepareCommentsXmlFilesForExport = ({ convertedXml, defs, commentsWithPara
|
|
|
16392
16403
|
documentXml: updatedXml
|
|
16393
16404
|
};
|
|
16394
16405
|
};
|
|
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
|
-
};
|
|
16430
16406
|
const lower16 = 65535;
|
|
16431
16407
|
const factor16 = Math.pow(2, 16);
|
|
16432
16408
|
function makeRecover(index, offset) {
|
|
@@ -21371,7 +21347,7 @@ const isInTable = (state2) => {
|
|
|
21371
21347
|
};
|
|
21372
21348
|
function stripHtmlStyles(html) {
|
|
21373
21349
|
if (!html) return "";
|
|
21374
|
-
const parser = new DOMParser();
|
|
21350
|
+
const parser = new window.DOMParser();
|
|
21375
21351
|
const doc2 = parser.parseFromString(html, "text/html");
|
|
21376
21352
|
const SUPPORTED_ATTRS = [
|
|
21377
21353
|
"href",
|
|
@@ -21390,7 +21366,7 @@ function stripHtmlStyles(html) {
|
|
|
21390
21366
|
"styleid"
|
|
21391
21367
|
];
|
|
21392
21368
|
const cleanNode = (node) => {
|
|
21393
|
-
if (node.nodeType !== Node.ELEMENT_NODE) return;
|
|
21369
|
+
if (node.nodeType !== window.Node.ELEMENT_NODE) return;
|
|
21394
21370
|
[...node.attributes].forEach((attr) => {
|
|
21395
21371
|
const name = attr.name.toLowerCase();
|
|
21396
21372
|
const shouldKeep = SUPPORTED_ATTRS.includes(name) || name.startsWith("data-");
|
|
@@ -22529,6 +22505,23 @@ function processContent({ content, type: type2, schema }) {
|
|
|
22529
22505
|
}
|
|
22530
22506
|
return doc2;
|
|
22531
22507
|
}
|
|
22508
|
+
const defaultBooleans = ["required", "readonly", "disabled", "checked", "multiple", "autofocus"];
|
|
22509
|
+
function updateDOMAttributes(dom, attrs = {}, options = {}) {
|
|
22510
|
+
const customBooleans = options.customBooleans || [];
|
|
22511
|
+
const booleans = [...defaultBooleans, ...customBooleans];
|
|
22512
|
+
Object.entries(attrs).forEach(([key, value]) => {
|
|
22513
|
+
if (booleans.includes(key)) {
|
|
22514
|
+
if (!value) dom.removeAttribute(key);
|
|
22515
|
+
else dom.setAttribute(key, "");
|
|
22516
|
+
return;
|
|
22517
|
+
}
|
|
22518
|
+
if (value != null) {
|
|
22519
|
+
dom.setAttribute(key, value);
|
|
22520
|
+
} else {
|
|
22521
|
+
dom.removeAttribute(key);
|
|
22522
|
+
}
|
|
22523
|
+
});
|
|
22524
|
+
}
|
|
22532
22525
|
const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
22533
22526
|
__proto__: null,
|
|
22534
22527
|
chainableEditorState,
|
|
@@ -22561,7 +22554,8 @@ const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
22561
22554
|
isNodeActive,
|
|
22562
22555
|
isTextSelection,
|
|
22563
22556
|
posToDOMRect,
|
|
22564
|
-
processContent
|
|
22557
|
+
processContent,
|
|
22558
|
+
updateDOMAttributes
|
|
22565
22559
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
22566
22560
|
const generateNewListDefinition = ({ numId, listType, level, start, text, fmt, editor }) => {
|
|
22567
22561
|
if (typeof listType === "string") listType = editor.schema.nodes[listType];
|
|
@@ -24303,37 +24297,37 @@ const _NodeTranslator = class _NodeTranslator {
|
|
|
24303
24297
|
/** @type {typeof TranslatorTypes} */
|
|
24304
24298
|
__publicField(_NodeTranslator, "translatorTypes", TranslatorTypes);
|
|
24305
24299
|
let NodeTranslator = _NodeTranslator;
|
|
24306
|
-
const encode$
|
|
24300
|
+
const encode$A = (attributes) => {
|
|
24307
24301
|
return attributes["w:type"];
|
|
24308
24302
|
};
|
|
24309
|
-
const decode$
|
|
24303
|
+
const decode$A = (attrs) => {
|
|
24310
24304
|
const { lineBreakType } = attrs;
|
|
24311
24305
|
return lineBreakType;
|
|
24312
24306
|
};
|
|
24313
|
-
const attrConfig$
|
|
24307
|
+
const attrConfig$i = Object.freeze({
|
|
24314
24308
|
xmlName: "w:type",
|
|
24315
24309
|
sdName: "lineBreakType",
|
|
24316
|
-
encode: encode$
|
|
24317
|
-
decode: decode$
|
|
24310
|
+
encode: encode$A,
|
|
24311
|
+
decode: decode$A
|
|
24318
24312
|
});
|
|
24319
|
-
const encode$
|
|
24313
|
+
const encode$z = (attributes) => {
|
|
24320
24314
|
const xmlAttrValue = attributes["w:clear"];
|
|
24321
24315
|
return xmlAttrValue;
|
|
24322
24316
|
};
|
|
24323
|
-
const decode$
|
|
24317
|
+
const decode$z = (attrs) => {
|
|
24324
24318
|
const { clear } = attrs;
|
|
24325
24319
|
return clear;
|
|
24326
24320
|
};
|
|
24327
|
-
const attrConfig$
|
|
24321
|
+
const attrConfig$h = Object.freeze({
|
|
24328
24322
|
xmlName: "w:clear",
|
|
24329
24323
|
sdName: "clear",
|
|
24330
|
-
encode: encode$
|
|
24331
|
-
decode: decode$
|
|
24324
|
+
encode: encode$z,
|
|
24325
|
+
decode: decode$z
|
|
24332
24326
|
});
|
|
24333
|
-
const validXmlAttributes$
|
|
24334
|
-
const XML_NODE_NAME$
|
|
24335
|
-
const SD_NODE_NAME$
|
|
24336
|
-
const encode$
|
|
24327
|
+
const validXmlAttributes$b = [attrConfig$i, attrConfig$h];
|
|
24328
|
+
const XML_NODE_NAME$h = "w:br";
|
|
24329
|
+
const SD_NODE_NAME$c = "lineBreak";
|
|
24330
|
+
const encode$y = (_2, encodedAttrs) => {
|
|
24337
24331
|
const isPageBreak = encodedAttrs?.lineBreakType === "page";
|
|
24338
24332
|
const translated = {
|
|
24339
24333
|
type: isPageBreak ? "hardBreak" : "lineBreak"
|
|
@@ -24343,7 +24337,7 @@ const encode$h = (_2, encodedAttrs) => {
|
|
|
24343
24337
|
}
|
|
24344
24338
|
return translated;
|
|
24345
24339
|
};
|
|
24346
|
-
const decode$
|
|
24340
|
+
const decode$y = (params, decodedAttrs) => {
|
|
24347
24341
|
const { node } = params;
|
|
24348
24342
|
if (!node) return;
|
|
24349
24343
|
const wBreak = { name: "w:br" };
|
|
@@ -24360,63 +24354,63 @@ const decode$h = (params, decodedAttrs) => {
|
|
|
24360
24354
|
};
|
|
24361
24355
|
return translated;
|
|
24362
24356
|
};
|
|
24363
|
-
const config$
|
|
24364
|
-
xmlName: XML_NODE_NAME$
|
|
24365
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
24357
|
+
const config$f = {
|
|
24358
|
+
xmlName: XML_NODE_NAME$h,
|
|
24359
|
+
sdNodeOrKeyName: SD_NODE_NAME$c,
|
|
24366
24360
|
type: NodeTranslator.translatorTypes.NODE,
|
|
24367
|
-
encode: encode$
|
|
24368
|
-
decode: decode$
|
|
24369
|
-
attributes: validXmlAttributes$
|
|
24361
|
+
encode: encode$y,
|
|
24362
|
+
decode: decode$y,
|
|
24363
|
+
attributes: validXmlAttributes$b
|
|
24370
24364
|
};
|
|
24371
|
-
const translator$
|
|
24372
|
-
const encode$
|
|
24365
|
+
const translator$V = NodeTranslator.from(config$f);
|
|
24366
|
+
const encode$x = (attributes) => {
|
|
24373
24367
|
return attributes["w:val"];
|
|
24374
24368
|
};
|
|
24375
|
-
const decode$
|
|
24369
|
+
const decode$x = (attrs) => {
|
|
24376
24370
|
const { tabSize } = attrs || {};
|
|
24377
24371
|
return tabSize;
|
|
24378
24372
|
};
|
|
24379
|
-
const attrConfig$
|
|
24373
|
+
const attrConfig$g = Object.freeze({
|
|
24380
24374
|
xmlName: "w:val",
|
|
24381
24375
|
sdName: "tabSize",
|
|
24382
|
-
encode: encode$
|
|
24383
|
-
decode: decode$
|
|
24376
|
+
encode: encode$x,
|
|
24377
|
+
decode: decode$x
|
|
24384
24378
|
});
|
|
24385
|
-
const encode$
|
|
24379
|
+
const encode$w = (attributes) => {
|
|
24386
24380
|
return attributes["w:leader"];
|
|
24387
24381
|
};
|
|
24388
|
-
const decode$
|
|
24382
|
+
const decode$w = (attrs) => {
|
|
24389
24383
|
const { leader } = attrs || {};
|
|
24390
24384
|
return leader;
|
|
24391
24385
|
};
|
|
24392
|
-
const attrConfig$
|
|
24386
|
+
const attrConfig$f = Object.freeze({
|
|
24393
24387
|
xmlName: "w:leader",
|
|
24394
24388
|
sdName: "leader",
|
|
24395
|
-
encode: encode$
|
|
24396
|
-
decode: decode$
|
|
24389
|
+
encode: encode$w,
|
|
24390
|
+
decode: decode$w
|
|
24397
24391
|
});
|
|
24398
|
-
const encode$
|
|
24392
|
+
const encode$v = (attributes) => {
|
|
24399
24393
|
return attributes["w:pos"];
|
|
24400
24394
|
};
|
|
24401
|
-
const decode$
|
|
24395
|
+
const decode$v = (attrs) => {
|
|
24402
24396
|
const { pos } = attrs || {};
|
|
24403
24397
|
return pos;
|
|
24404
24398
|
};
|
|
24405
|
-
const attrConfig$
|
|
24399
|
+
const attrConfig$e = Object.freeze({
|
|
24406
24400
|
xmlName: "w:pos",
|
|
24407
24401
|
sdName: "pos",
|
|
24408
|
-
encode: encode$
|
|
24409
|
-
decode: decode$
|
|
24402
|
+
encode: encode$v,
|
|
24403
|
+
decode: decode$v
|
|
24410
24404
|
});
|
|
24411
|
-
const validXmlAttributes$
|
|
24412
|
-
const XML_NODE_NAME$
|
|
24413
|
-
const SD_NODE_NAME$
|
|
24414
|
-
const encode$
|
|
24405
|
+
const validXmlAttributes$a = [attrConfig$g, attrConfig$e, attrConfig$f];
|
|
24406
|
+
const XML_NODE_NAME$g = "w:tab";
|
|
24407
|
+
const SD_NODE_NAME$b = "tab";
|
|
24408
|
+
const encode$u = (_2, encodedAttrs = {}) => {
|
|
24415
24409
|
const translated = { type: "tab" };
|
|
24416
24410
|
if (encodedAttrs) translated.attrs = { ...encodedAttrs };
|
|
24417
24411
|
return translated;
|
|
24418
24412
|
};
|
|
24419
|
-
const decode$
|
|
24413
|
+
const decode$u = (params, decodedAttrs = {}) => {
|
|
24420
24414
|
const { node } = params || {};
|
|
24421
24415
|
if (!node) return;
|
|
24422
24416
|
const wTab = { name: "w:tab" };
|
|
@@ -24432,15 +24426,15 @@ const decode$d = (params, decodedAttrs = {}) => {
|
|
|
24432
24426
|
}
|
|
24433
24427
|
return translated;
|
|
24434
24428
|
};
|
|
24435
|
-
const config$
|
|
24436
|
-
xmlName: XML_NODE_NAME$
|
|
24437
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
24429
|
+
const config$e = {
|
|
24430
|
+
xmlName: XML_NODE_NAME$g,
|
|
24431
|
+
sdNodeOrKeyName: SD_NODE_NAME$b,
|
|
24438
24432
|
type: NodeTranslator.translatorTypes.NODE,
|
|
24439
|
-
encode: encode$
|
|
24440
|
-
decode: decode$
|
|
24441
|
-
attributes: validXmlAttributes$
|
|
24433
|
+
encode: encode$u,
|
|
24434
|
+
decode: decode$u,
|
|
24435
|
+
attributes: validXmlAttributes$a
|
|
24442
24436
|
};
|
|
24443
|
-
const translator$
|
|
24437
|
+
const translator$U = NodeTranslator.from(config$e);
|
|
24444
24438
|
const mergeTextNodes = (nodes) => {
|
|
24445
24439
|
if (!nodes || !Array.isArray(nodes)) {
|
|
24446
24440
|
return nodes;
|
|
@@ -24704,13 +24698,15 @@ const getParagraphIndent = (node, docx, styleId = "") => {
|
|
|
24704
24698
|
}
|
|
24705
24699
|
return indent;
|
|
24706
24700
|
};
|
|
24707
|
-
const getParagraphSpacing = (node, docx, styleId = "", marks = []) => {
|
|
24701
|
+
const getParagraphSpacing = (node, docx, styleId = "", marks = [], options = {}) => {
|
|
24702
|
+
const { insideTable = false } = options;
|
|
24708
24703
|
const spacing = {};
|
|
24709
|
-
const { spacing: pDefaultSpacing = {} } = getDefaultParagraphStyle(docx, styleId);
|
|
24704
|
+
const { spacing: pDefaultSpacing = {}, spacingSource } = getDefaultParagraphStyle(docx, styleId);
|
|
24710
24705
|
let lineSpaceAfter, lineSpaceBefore, line, lineRuleStyle;
|
|
24711
24706
|
const pPr = node.elements?.find((el) => el.name === "w:pPr");
|
|
24712
24707
|
const inLineSpacingTag = pPr?.elements?.find((el) => el.name === "w:spacing");
|
|
24713
24708
|
const inLineSpacing = inLineSpacingTag?.attributes || {};
|
|
24709
|
+
const hasInlineSpacing = !!Object.keys(inLineSpacing).length;
|
|
24714
24710
|
const textStyleMark = marks.find((el) => el.type === "textStyle");
|
|
24715
24711
|
const fontSize = textStyleMark?.attrs?.fontSize;
|
|
24716
24712
|
const lineSpacing = inLineSpacing?.["w:line"] || line || pDefaultSpacing?.["w:line"];
|
|
@@ -24732,6 +24728,12 @@ const getParagraphSpacing = (node, docx, styleId = "", marks = []) => {
|
|
|
24732
24728
|
if (afterAutospacing === "1" && fontSize) {
|
|
24733
24729
|
spacing.lineSpaceAfter += Math.round(parseInt(fontSize) * 0.5 * 96 / 72);
|
|
24734
24730
|
}
|
|
24731
|
+
if (insideTable && !hasInlineSpacing && spacingSource === "docDefault") {
|
|
24732
|
+
const hasExplicitSpacing = Object.keys(inLineSpacing).length > 0;
|
|
24733
|
+
if (!hasExplicitSpacing) {
|
|
24734
|
+
return void 0;
|
|
24735
|
+
}
|
|
24736
|
+
}
|
|
24735
24737
|
return spacing;
|
|
24736
24738
|
};
|
|
24737
24739
|
const getDefaultParagraphStyle = (docx, styleId = "") => {
|
|
@@ -24772,9 +24774,20 @@ const getDefaultParagraphStyle = (docx, styleId = "") => {
|
|
|
24772
24774
|
const { attributes: pPrByIdIndentAttr } = pPrStyleIdIndentTag;
|
|
24773
24775
|
const spacingRest = isNormalAsDefault ? pPrNormalSpacingAttr || pPrDefaultSpacingAttr : pPrDefaultSpacingAttr || pPrNormalSpacingAttr;
|
|
24774
24776
|
const indentRest = isNormalAsDefault ? pPrNormalIndentAttr || pPrDefaultIndentAttr : pPrDefaultIndentAttr || pPrNormalIndentAttr;
|
|
24777
|
+
let spacingToUse = pPrByIdSpacingAttr || spacingRest;
|
|
24778
|
+
let spacingSource = "docDefault";
|
|
24779
|
+
if (pPrByIdSpacingAttr) {
|
|
24780
|
+
spacingSource = "style";
|
|
24781
|
+
} else if (spacingRest === pPrNormalSpacingAttr && pPrNormalSpacingAttr) {
|
|
24782
|
+
spacingSource = isNormalAsDefault ? "docDefault" : "normal";
|
|
24783
|
+
} else if (spacingRest === pPrDefaultSpacingAttr && pPrDefaultSpacingAttr) {
|
|
24784
|
+
spacingSource = "docDefault";
|
|
24785
|
+
}
|
|
24786
|
+
let indentToUse = pPrByIdIndentAttr || indentRest;
|
|
24775
24787
|
return {
|
|
24776
|
-
spacing:
|
|
24777
|
-
|
|
24788
|
+
spacing: spacingToUse,
|
|
24789
|
+
spacingSource,
|
|
24790
|
+
indent: indentToUse,
|
|
24778
24791
|
justify: pPrByIdJcAttr
|
|
24779
24792
|
};
|
|
24780
24793
|
};
|
|
@@ -24949,7 +24962,13 @@ const handleParagraphNode$1 = (params) => {
|
|
|
24949
24962
|
}
|
|
24950
24963
|
if (docx) {
|
|
24951
24964
|
const defaultStyleId = node.attributes?.["w:rsidRDefault"];
|
|
24952
|
-
|
|
24965
|
+
const insideTable = (params.path || []).some((ancestor) => ancestor.name === "w:tc");
|
|
24966
|
+
const spacing = getParagraphSpacing(node, docx, styleId, schemaNode.attrs.marksAttrs, {
|
|
24967
|
+
insideTable
|
|
24968
|
+
});
|
|
24969
|
+
if (spacing) {
|
|
24970
|
+
schemaNode.attrs["spacing"] = spacing;
|
|
24971
|
+
}
|
|
24953
24972
|
schemaNode.attrs["rsidRDefault"] = defaultStyleId;
|
|
24954
24973
|
}
|
|
24955
24974
|
if (docx) {
|
|
@@ -25010,102 +25029,102 @@ const handleParagraphNode$1 = (params) => {
|
|
|
25010
25029
|
}
|
|
25011
25030
|
return schemaNode;
|
|
25012
25031
|
};
|
|
25013
|
-
const encode$
|
|
25032
|
+
const encode$t = (attributes) => {
|
|
25014
25033
|
return attributes["w:rsidDel"];
|
|
25015
25034
|
};
|
|
25016
|
-
const decode$
|
|
25035
|
+
const decode$t = (attrs) => {
|
|
25017
25036
|
return attrs.rsidDel;
|
|
25018
25037
|
};
|
|
25019
|
-
const attrConfig$
|
|
25038
|
+
const attrConfig$d = Object.freeze({
|
|
25020
25039
|
xmlName: "w:rsidDel",
|
|
25021
25040
|
sdName: "rsidDel",
|
|
25022
|
-
encode: encode$
|
|
25023
|
-
decode: decode$
|
|
25041
|
+
encode: encode$t,
|
|
25042
|
+
decode: decode$t
|
|
25024
25043
|
});
|
|
25025
|
-
const encode$
|
|
25044
|
+
const encode$s = (attributes) => {
|
|
25026
25045
|
return attributes["w:rsidP"];
|
|
25027
25046
|
};
|
|
25028
|
-
const decode$
|
|
25047
|
+
const decode$s = (attrs) => {
|
|
25029
25048
|
return attrs.rsidP;
|
|
25030
25049
|
};
|
|
25031
|
-
const attrConfig$
|
|
25050
|
+
const attrConfig$c = Object.freeze({
|
|
25032
25051
|
xmlName: "w:rsidP",
|
|
25033
25052
|
sdName: "rsidP",
|
|
25034
|
-
encode: encode$
|
|
25035
|
-
decode: decode$
|
|
25053
|
+
encode: encode$s,
|
|
25054
|
+
decode: decode$s
|
|
25036
25055
|
});
|
|
25037
|
-
const encode$
|
|
25056
|
+
const encode$r = (attributes) => {
|
|
25038
25057
|
return attributes["w:rsidR"];
|
|
25039
25058
|
};
|
|
25040
|
-
const decode$
|
|
25059
|
+
const decode$r = (attrs) => {
|
|
25041
25060
|
return attrs.rsidR;
|
|
25042
25061
|
};
|
|
25043
|
-
const attrConfig$
|
|
25062
|
+
const attrConfig$b = Object.freeze({
|
|
25044
25063
|
xmlName: "w:rsidR",
|
|
25045
25064
|
sdName: "rsidR",
|
|
25046
|
-
encode: encode$
|
|
25047
|
-
decode: decode$
|
|
25065
|
+
encode: encode$r,
|
|
25066
|
+
decode: decode$r
|
|
25048
25067
|
});
|
|
25049
|
-
const encode$
|
|
25068
|
+
const encode$q = (attributes) => {
|
|
25050
25069
|
return attributes["w:rsidRPr"];
|
|
25051
25070
|
};
|
|
25052
|
-
const decode$
|
|
25071
|
+
const decode$q = (attrs) => {
|
|
25053
25072
|
return attrs.rsidRPr;
|
|
25054
25073
|
};
|
|
25055
|
-
const attrConfig$
|
|
25074
|
+
const attrConfig$a = Object.freeze({
|
|
25056
25075
|
xmlName: "w:rsidRPr",
|
|
25057
25076
|
sdName: "rsidRPr",
|
|
25058
|
-
encode: encode$
|
|
25059
|
-
decode: decode$
|
|
25077
|
+
encode: encode$q,
|
|
25078
|
+
decode: decode$q
|
|
25060
25079
|
});
|
|
25061
|
-
const encode$
|
|
25080
|
+
const encode$p = (attributes) => {
|
|
25062
25081
|
return attributes["w:rsidRDefault"];
|
|
25063
25082
|
};
|
|
25064
|
-
const decode$
|
|
25083
|
+
const decode$p = (attrs) => {
|
|
25065
25084
|
return attrs.rsidRDefault;
|
|
25066
25085
|
};
|
|
25067
|
-
const attrConfig$
|
|
25086
|
+
const attrConfig$9 = Object.freeze({
|
|
25068
25087
|
xmlName: "w:rsidRDefault",
|
|
25069
25088
|
sdName: "rsidRDefault",
|
|
25070
|
-
encode: encode$
|
|
25071
|
-
decode: decode$
|
|
25089
|
+
encode: encode$p,
|
|
25090
|
+
decode: decode$p
|
|
25072
25091
|
});
|
|
25073
|
-
const encode$
|
|
25092
|
+
const encode$o = (attributes) => {
|
|
25074
25093
|
return attributes["w14:paraId"];
|
|
25075
25094
|
};
|
|
25076
|
-
const decode$
|
|
25095
|
+
const decode$o = (attrs) => {
|
|
25077
25096
|
return attrs.paraId;
|
|
25078
25097
|
};
|
|
25079
|
-
const attrConfig$
|
|
25098
|
+
const attrConfig$8 = Object.freeze({
|
|
25080
25099
|
xmlName: "w14:paraId",
|
|
25081
25100
|
sdName: "paraId",
|
|
25082
|
-
encode: encode$
|
|
25083
|
-
decode: decode$
|
|
25101
|
+
encode: encode$o,
|
|
25102
|
+
decode: decode$o
|
|
25084
25103
|
});
|
|
25085
|
-
const encode$
|
|
25104
|
+
const encode$n = (attributes) => {
|
|
25086
25105
|
return attributes["w14:textId"];
|
|
25087
25106
|
};
|
|
25088
|
-
const decode$
|
|
25107
|
+
const decode$n = (attrs) => {
|
|
25089
25108
|
return attrs.textId;
|
|
25090
25109
|
};
|
|
25091
|
-
const attrConfig = Object.freeze({
|
|
25110
|
+
const attrConfig$7 = Object.freeze({
|
|
25092
25111
|
xmlName: "w14:textId",
|
|
25093
25112
|
sdName: "textId",
|
|
25094
|
-
encode: encode$
|
|
25095
|
-
decode: decode$
|
|
25113
|
+
encode: encode$n,
|
|
25114
|
+
decode: decode$n
|
|
25096
25115
|
});
|
|
25097
|
-
const validXmlAttributes$
|
|
25098
|
-
attrConfig$
|
|
25099
|
-
attrConfig,
|
|
25100
|
-
attrConfig$
|
|
25101
|
-
attrConfig$
|
|
25102
|
-
attrConfig$
|
|
25103
|
-
attrConfig$
|
|
25104
|
-
attrConfig$
|
|
25116
|
+
const validXmlAttributes$9 = [
|
|
25117
|
+
attrConfig$8,
|
|
25118
|
+
attrConfig$7,
|
|
25119
|
+
attrConfig$b,
|
|
25120
|
+
attrConfig$9,
|
|
25121
|
+
attrConfig$c,
|
|
25122
|
+
attrConfig$a,
|
|
25123
|
+
attrConfig$d
|
|
25105
25124
|
];
|
|
25106
|
-
const XML_NODE_NAME$
|
|
25107
|
-
const SD_NODE_NAME$
|
|
25108
|
-
const encode$
|
|
25125
|
+
const XML_NODE_NAME$f = "w:p";
|
|
25126
|
+
const SD_NODE_NAME$a = "paragraph";
|
|
25127
|
+
const encode$m = (params, encodedAttrs = {}) => {
|
|
25109
25128
|
const node = handleParagraphNode$1(params);
|
|
25110
25129
|
if (!node) return void 0;
|
|
25111
25130
|
if (encodedAttrs && Object.keys(encodedAttrs).length) {
|
|
@@ -25113,7 +25132,7 @@ const encode$5 = (params, encodedAttrs = {}) => {
|
|
|
25113
25132
|
}
|
|
25114
25133
|
return node;
|
|
25115
25134
|
};
|
|
25116
|
-
const decode$
|
|
25135
|
+
const decode$m = (params, decodedAttrs = {}) => {
|
|
25117
25136
|
const translated = translateParagraphNode(params);
|
|
25118
25137
|
if (!translated) return void 0;
|
|
25119
25138
|
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
@@ -25121,15 +25140,15 @@ const decode$5 = (params, decodedAttrs = {}) => {
|
|
|
25121
25140
|
}
|
|
25122
25141
|
return translated;
|
|
25123
25142
|
};
|
|
25124
|
-
const config$
|
|
25125
|
-
xmlName: XML_NODE_NAME$
|
|
25126
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
25143
|
+
const config$d = {
|
|
25144
|
+
xmlName: XML_NODE_NAME$f,
|
|
25145
|
+
sdNodeOrKeyName: SD_NODE_NAME$a,
|
|
25127
25146
|
type: NodeTranslator.translatorTypes.NODE,
|
|
25128
|
-
encode: encode$
|
|
25129
|
-
decode: decode$
|
|
25130
|
-
attributes: validXmlAttributes$
|
|
25147
|
+
encode: encode$m,
|
|
25148
|
+
decode: decode$m,
|
|
25149
|
+
attributes: validXmlAttributes$9
|
|
25131
25150
|
};
|
|
25132
|
-
const translator$
|
|
25151
|
+
const translator$T = NodeTranslator.from(config$d);
|
|
25133
25152
|
const generateV2HandlerEntity = (handlerName, translator2) => ({
|
|
25134
25153
|
handlerName,
|
|
25135
25154
|
handler: (params) => {
|
|
@@ -25157,7 +25176,7 @@ function createSingleAttrPropertyHandler(xmlName, sdName = null, attrName = "w:v
|
|
|
25157
25176
|
},
|
|
25158
25177
|
decode: ({ node }) => {
|
|
25159
25178
|
const value = node.attrs?.[sdName] != null ? transformDecode(node.attrs[sdName]) : void 0;
|
|
25160
|
-
return value != null ? { [attrName]: value } : void 0;
|
|
25179
|
+
return value != null ? { name: xmlName, attributes: { [attrName]: value } } : void 0;
|
|
25161
25180
|
}
|
|
25162
25181
|
};
|
|
25163
25182
|
}
|
|
@@ -25175,7 +25194,32 @@ function createMeasurementPropertyHandler(xmlName, sdName = null) {
|
|
|
25175
25194
|
},
|
|
25176
25195
|
decode: function({ node }) {
|
|
25177
25196
|
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
|
|
25178
|
-
return decodedAttrs["w:w"] != null ? decodedAttrs : void 0;
|
|
25197
|
+
return decodedAttrs["w:w"] != null ? { attributes: decodedAttrs } : void 0;
|
|
25198
|
+
}
|
|
25199
|
+
};
|
|
25200
|
+
}
|
|
25201
|
+
function createBorderPropertyHandler(xmlName, sdName = null) {
|
|
25202
|
+
if (!sdName) sdName = xmlName.split(":")[1];
|
|
25203
|
+
return {
|
|
25204
|
+
xmlName,
|
|
25205
|
+
sdNodeOrKeyName: sdName,
|
|
25206
|
+
attributes: [
|
|
25207
|
+
createAttributeHandler("w:val"),
|
|
25208
|
+
createAttributeHandler("w:color"),
|
|
25209
|
+
createAttributeHandler("w:themeColor"),
|
|
25210
|
+
createAttributeHandler("w:themeTint"),
|
|
25211
|
+
createAttributeHandler("w:themeShade"),
|
|
25212
|
+
createAttributeHandler("w:sz", "size", parseInteger, integerToString),
|
|
25213
|
+
createAttributeHandler("w:space", null, parseInteger, integerToString),
|
|
25214
|
+
createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
|
|
25215
|
+
createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
|
|
25216
|
+
],
|
|
25217
|
+
encode: (params, encodedAttrs) => {
|
|
25218
|
+
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25219
|
+
},
|
|
25220
|
+
decode: function({ node }, context) {
|
|
25221
|
+
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
|
|
25222
|
+
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25179
25223
|
}
|
|
25180
25224
|
};
|
|
25181
25225
|
}
|
|
@@ -25218,15 +25262,17 @@ function decodeProperties(translatorsBySdName, properties) {
|
|
|
25218
25262
|
Object.keys(properties).forEach((key) => {
|
|
25219
25263
|
const translator2 = translatorsBySdName[key];
|
|
25220
25264
|
if (translator2) {
|
|
25221
|
-
const
|
|
25222
|
-
if (
|
|
25223
|
-
|
|
25265
|
+
const result = translator2.decode({ node: { attrs: { [key]: properties[key] } } });
|
|
25266
|
+
if (result != null) {
|
|
25267
|
+
result.name = translator2.xmlName;
|
|
25268
|
+
elements.push(result);
|
|
25224
25269
|
}
|
|
25225
25270
|
}
|
|
25226
25271
|
});
|
|
25227
25272
|
return elements;
|
|
25228
25273
|
}
|
|
25229
|
-
const parseBoolean = (value) => ["1", "true"].includes(value);
|
|
25274
|
+
const parseBoolean = (value) => value != null ? ["1", "true"].includes(value) : void 0;
|
|
25275
|
+
const booleanToString = (value) => value != null ? value ? "1" : "0" : void 0;
|
|
25230
25276
|
const parseInteger = (value) => {
|
|
25231
25277
|
if (value == null) return void 0;
|
|
25232
25278
|
const intValue = parseInt(value, 10);
|
|
@@ -25236,13 +25282,53 @@ const integerToString = (value) => {
|
|
|
25236
25282
|
const intValue = parseInteger(value);
|
|
25237
25283
|
return intValue != void 0 ? String(intValue) : void 0;
|
|
25238
25284
|
};
|
|
25239
|
-
|
|
25285
|
+
function preProcessVerticalMergeCells(table, { editorSchema }) {
|
|
25286
|
+
if (!table || !Array.isArray(table.content)) {
|
|
25287
|
+
return table;
|
|
25288
|
+
}
|
|
25289
|
+
const rows = table.content;
|
|
25290
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
25291
|
+
const row = rows[rowIndex];
|
|
25292
|
+
if (!row) continue;
|
|
25293
|
+
if (!Array.isArray(row.content)) {
|
|
25294
|
+
row.content = [];
|
|
25295
|
+
}
|
|
25296
|
+
for (let cellIndex = 0; cellIndex < row.content.length; cellIndex++) {
|
|
25297
|
+
const cell = row.content[cellIndex];
|
|
25298
|
+
if (!cell) continue;
|
|
25299
|
+
const attrs = cell.attrs || {};
|
|
25300
|
+
if (!attrs.rowspan || attrs.rowspan <= 1) continue;
|
|
25301
|
+
const maxRowspan = Math.min(attrs.rowspan, rows.length - rowIndex);
|
|
25302
|
+
for (let offset = 1; offset < maxRowspan; offset++) {
|
|
25303
|
+
const rowToChange = rows[rowIndex + offset];
|
|
25304
|
+
if (!rowToChange) continue;
|
|
25305
|
+
if (!Array.isArray(rowToChange.content)) {
|
|
25306
|
+
rowToChange.content = [];
|
|
25307
|
+
}
|
|
25308
|
+
const existingCell = rowToChange.content[cellIndex];
|
|
25309
|
+
if (existingCell?.attrs?.continueMerge) continue;
|
|
25310
|
+
const mergedCell = {
|
|
25311
|
+
type: cell.type,
|
|
25312
|
+
content: [editorSchema.nodes.paragraph.createAndFill().toJSON()],
|
|
25313
|
+
attrs: {
|
|
25314
|
+
...cell.attrs,
|
|
25315
|
+
rowspan: null,
|
|
25316
|
+
continueMerge: true
|
|
25317
|
+
}
|
|
25318
|
+
};
|
|
25319
|
+
rowToChange.content.splice(cellIndex, 0, mergedCell);
|
|
25320
|
+
}
|
|
25321
|
+
}
|
|
25322
|
+
}
|
|
25323
|
+
return table;
|
|
25324
|
+
}
|
|
25325
|
+
const translator$S = NodeTranslator.from({
|
|
25240
25326
|
xmlName: "w:cantSplit",
|
|
25241
25327
|
sdNodeOrKeyName: "cantSplit",
|
|
25242
25328
|
encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25243
|
-
decode: ({ node }) => node.attrs?.cantSplit ? {} : void 0
|
|
25329
|
+
decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
|
|
25244
25330
|
});
|
|
25245
|
-
const translator$
|
|
25331
|
+
const translator$R = NodeTranslator.from({
|
|
25246
25332
|
xmlName: "w:cnfStyle",
|
|
25247
25333
|
sdNodeOrKeyName: "cnfStyle",
|
|
25248
25334
|
attributes: [
|
|
@@ -25257,26 +25343,19 @@ const translator$f = NodeTranslator.from({
|
|
|
25257
25343
|
"w:lastRowFirstColumn",
|
|
25258
25344
|
"w:lastRowLastColumn",
|
|
25259
25345
|
"w:oddHBand",
|
|
25260
|
-
"w:oddVBand"
|
|
25261
|
-
|
|
25262
|
-
].map((attr) => createAttributeHandler(attr)),
|
|
25346
|
+
"w:oddVBand"
|
|
25347
|
+
].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
|
|
25263
25348
|
encode: (_2, encodedAttrs) => {
|
|
25264
|
-
Object.keys(encodedAttrs).forEach((key) => {
|
|
25265
|
-
encodedAttrs[key] = ["1", "true"].includes(encodedAttrs[key]);
|
|
25266
|
-
});
|
|
25267
25349
|
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25268
25350
|
},
|
|
25269
|
-
decode: ({ node })
|
|
25351
|
+
decode: function({ node }) {
|
|
25270
25352
|
if (!node.attrs?.cnfStyle) return;
|
|
25271
|
-
const
|
|
25272
|
-
Object.
|
|
25273
|
-
cnfStyleAttrs[`w:${key}`] = value ? "1" : "0";
|
|
25274
|
-
});
|
|
25275
|
-
return Object.keys(cnfStyleAttrs).length > 0 ? cnfStyleAttrs : void 0;
|
|
25353
|
+
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.cnfStyle || {} } });
|
|
25354
|
+
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25276
25355
|
}
|
|
25277
25356
|
});
|
|
25278
|
-
const translator$
|
|
25279
|
-
const translator$
|
|
25357
|
+
const translator$Q = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
|
|
25358
|
+
const translator$P = NodeTranslator.from(
|
|
25280
25359
|
createSingleAttrPropertyHandler(
|
|
25281
25360
|
"w:gridAfter",
|
|
25282
25361
|
null,
|
|
@@ -25285,7 +25364,7 @@ const translator$d = NodeTranslator.from(
|
|
|
25285
25364
|
(v2) => integerToString(v2)
|
|
25286
25365
|
)
|
|
25287
25366
|
);
|
|
25288
|
-
const translator$
|
|
25367
|
+
const translator$O = NodeTranslator.from(
|
|
25289
25368
|
createSingleAttrPropertyHandler(
|
|
25290
25369
|
"w:gridBefore",
|
|
25291
25370
|
null,
|
|
@@ -25294,21 +25373,21 @@ const translator$c = NodeTranslator.from(
|
|
|
25294
25373
|
(v2) => integerToString(v2)
|
|
25295
25374
|
)
|
|
25296
25375
|
);
|
|
25297
|
-
const translator$
|
|
25376
|
+
const translator$N = NodeTranslator.from({
|
|
25298
25377
|
xmlName: "w:hidden",
|
|
25299
25378
|
sdNodeOrKeyName: "hidden",
|
|
25300
25379
|
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25301
|
-
decode: ({ node }) => node.attrs.hidden ? {} : void 0
|
|
25380
|
+
decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
|
|
25302
25381
|
});
|
|
25303
|
-
const translator$
|
|
25304
|
-
const translator$
|
|
25305
|
-
const translator$
|
|
25382
|
+
const translator$M = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
|
|
25383
|
+
const translator$L = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
|
|
25384
|
+
const translator$K = NodeTranslator.from({
|
|
25306
25385
|
xmlName: "w:tblHeader",
|
|
25307
25386
|
sdNodeOrKeyName: "repeatHeader",
|
|
25308
25387
|
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25309
|
-
decode: ({ node }) => node.attrs.repeatHeader ? {} : void 0
|
|
25388
|
+
decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
|
|
25310
25389
|
});
|
|
25311
|
-
const translator$
|
|
25390
|
+
const translator$J = NodeTranslator.from({
|
|
25312
25391
|
xmlName: "w:trHeight",
|
|
25313
25392
|
sdNodeOrKeyName: "rowHeight",
|
|
25314
25393
|
encode: ({ nodes }) => {
|
|
@@ -25332,14 +25411,14 @@ const translator$7 = NodeTranslator.from({
|
|
|
25332
25411
|
if (node.attrs.rowHeight.rule) {
|
|
25333
25412
|
heightAttrs["w:hRule"] = node.attrs.rowHeight.rule;
|
|
25334
25413
|
}
|
|
25335
|
-
return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
|
|
25414
|
+
return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
|
|
25336
25415
|
}
|
|
25337
25416
|
});
|
|
25338
|
-
const translator$
|
|
25339
|
-
const translator$
|
|
25340
|
-
const XML_NODE_NAME$
|
|
25341
|
-
const SD_ATTR_KEY = "tableRowProperties";
|
|
25342
|
-
const encode$
|
|
25417
|
+
const translator$I = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
|
|
25418
|
+
const translator$H = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
|
|
25419
|
+
const XML_NODE_NAME$e = "w:trPr";
|
|
25420
|
+
const SD_ATTR_KEY$4 = "tableRowProperties";
|
|
25421
|
+
const encode$l = (params) => {
|
|
25343
25422
|
const { nodes } = params;
|
|
25344
25423
|
const node = nodes[0];
|
|
25345
25424
|
let attributes = {
|
|
@@ -25349,18 +25428,18 @@ const encode$4 = (params) => {
|
|
|
25349
25428
|
};
|
|
25350
25429
|
attributes = {
|
|
25351
25430
|
...attributes,
|
|
25352
|
-
...encodeProperties(node, propertyTranslatorsByXmlName)
|
|
25431
|
+
...encodeProperties(node, propertyTranslatorsByXmlName$2)
|
|
25353
25432
|
};
|
|
25354
25433
|
return {
|
|
25355
25434
|
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
25356
|
-
xmlName: XML_NODE_NAME$
|
|
25357
|
-
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
25435
|
+
xmlName: XML_NODE_NAME$e,
|
|
25436
|
+
sdNodeOrKeyName: SD_ATTR_KEY$4,
|
|
25358
25437
|
attributes
|
|
25359
25438
|
};
|
|
25360
25439
|
};
|
|
25361
|
-
const decode$
|
|
25440
|
+
const decode$l = (params) => {
|
|
25362
25441
|
const { tableRowProperties = {} } = params.node.attrs || {};
|
|
25363
|
-
const elements = decodeProperties(propertyTranslatorsBySdName, tableRowProperties);
|
|
25442
|
+
const elements = decodeProperties(propertyTranslatorsBySdName$2, tableRowProperties);
|
|
25364
25443
|
const newNode = {
|
|
25365
25444
|
name: "w:trPr",
|
|
25366
25445
|
type: "element",
|
|
@@ -25369,47 +25448,47 @@ const decode$4 = (params) => {
|
|
|
25369
25448
|
};
|
|
25370
25449
|
return newNode;
|
|
25371
25450
|
};
|
|
25372
|
-
const propertyTranslators = [
|
|
25373
|
-
translator$
|
|
25374
|
-
translator$
|
|
25375
|
-
translator$
|
|
25376
|
-
translator$
|
|
25377
|
-
translator$
|
|
25378
|
-
translator$
|
|
25379
|
-
translator$
|
|
25380
|
-
translator$
|
|
25381
|
-
translator$
|
|
25382
|
-
translator$
|
|
25383
|
-
translator$
|
|
25384
|
-
translator$
|
|
25451
|
+
const propertyTranslators$3 = [
|
|
25452
|
+
translator$S,
|
|
25453
|
+
translator$R,
|
|
25454
|
+
translator$Q,
|
|
25455
|
+
translator$P,
|
|
25456
|
+
translator$O,
|
|
25457
|
+
translator$N,
|
|
25458
|
+
translator$M,
|
|
25459
|
+
translator$L,
|
|
25460
|
+
translator$K,
|
|
25461
|
+
translator$J,
|
|
25462
|
+
translator$I,
|
|
25463
|
+
translator$H
|
|
25385
25464
|
];
|
|
25386
|
-
const propertyTranslatorsByXmlName = {};
|
|
25387
|
-
propertyTranslators.forEach((translator2) => {
|
|
25388
|
-
propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
|
|
25465
|
+
const propertyTranslatorsByXmlName$2 = {};
|
|
25466
|
+
propertyTranslators$3.forEach((translator2) => {
|
|
25467
|
+
propertyTranslatorsByXmlName$2[translator2.xmlName] = translator2;
|
|
25389
25468
|
});
|
|
25390
|
-
const propertyTranslatorsBySdName = {};
|
|
25391
|
-
propertyTranslators.forEach((translator2) => {
|
|
25392
|
-
propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
|
|
25469
|
+
const propertyTranslatorsBySdName$2 = {};
|
|
25470
|
+
propertyTranslators$3.forEach((translator2) => {
|
|
25471
|
+
propertyTranslatorsBySdName$2[translator2.sdNodeOrKeyName] = translator2;
|
|
25393
25472
|
});
|
|
25394
|
-
const config$
|
|
25395
|
-
xmlName: XML_NODE_NAME$
|
|
25396
|
-
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
25473
|
+
const config$c = {
|
|
25474
|
+
xmlName: XML_NODE_NAME$e,
|
|
25475
|
+
sdNodeOrKeyName: SD_ATTR_KEY$4,
|
|
25397
25476
|
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
25398
|
-
encode: encode$
|
|
25399
|
-
decode: decode$
|
|
25477
|
+
encode: encode$l,
|
|
25478
|
+
decode: decode$l
|
|
25400
25479
|
};
|
|
25401
|
-
const translator$
|
|
25402
|
-
const XML_NODE_NAME$
|
|
25403
|
-
const SD_NODE_NAME$
|
|
25404
|
-
const validXmlAttributes$
|
|
25480
|
+
const translator$G = NodeTranslator.from(config$c);
|
|
25481
|
+
const XML_NODE_NAME$d = "w:tr";
|
|
25482
|
+
const SD_NODE_NAME$9 = "tableRow";
|
|
25483
|
+
const validXmlAttributes$8 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
|
|
25405
25484
|
(xmlName) => createAttributeHandler(xmlName)
|
|
25406
25485
|
);
|
|
25407
|
-
const encode$
|
|
25408
|
-
const { row
|
|
25486
|
+
const encode$k = (params, encodedAttrs) => {
|
|
25487
|
+
const { row } = params.extraParams;
|
|
25409
25488
|
let tableRowProperties = {};
|
|
25410
25489
|
const tPr = row.elements.find((el) => el.name === "w:trPr");
|
|
25411
25490
|
if (tPr) {
|
|
25412
|
-
({ attributes: tableRowProperties } = translator$
|
|
25491
|
+
({ attributes: tableRowProperties } = translator$G.encode({
|
|
25413
25492
|
...params,
|
|
25414
25493
|
nodes: [tPr]
|
|
25415
25494
|
}));
|
|
@@ -25417,12 +25496,12 @@ const encode$3 = (params, encodedAttrs) => {
|
|
|
25417
25496
|
encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
|
|
25418
25497
|
encodedAttrs["rowHeight"] = twipsToPixels(tableRowProperties["rowHeight"]?.value);
|
|
25419
25498
|
encodedAttrs["cantSplit"] = tableRowProperties["cantSplit"];
|
|
25420
|
-
const gridColumnWidths =
|
|
25499
|
+
const { columnWidths: gridColumnWidths } = params.extraParams;
|
|
25421
25500
|
const cellNodes = row.elements.filter((el) => el.name === "w:tc");
|
|
25422
25501
|
let currentColumnIndex = 0;
|
|
25423
25502
|
const content = cellNodes?.map((n) => {
|
|
25424
25503
|
let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
|
|
25425
|
-
const result = translator$
|
|
25504
|
+
const result = translator$7.encode({
|
|
25426
25505
|
...params,
|
|
25427
25506
|
extraParams: {
|
|
25428
25507
|
...params.extraParams,
|
|
@@ -25444,16 +25523,7 @@ const encode$3 = (params, encodedAttrs) => {
|
|
|
25444
25523
|
};
|
|
25445
25524
|
return newNode;
|
|
25446
25525
|
};
|
|
25447
|
-
const
|
|
25448
|
-
const tblGrid = tableNode.elements.find((el) => el.name === "w:tblGrid");
|
|
25449
|
-
if (!tblGrid) return [];
|
|
25450
|
-
const columnWidths = tblGrid?.elements?.flatMap((el) => {
|
|
25451
|
-
if (el.name !== "w:gridCol") return [];
|
|
25452
|
-
return twipsToPixels(el.attributes["w:w"]);
|
|
25453
|
-
}) || [];
|
|
25454
|
-
return columnWidths;
|
|
25455
|
-
};
|
|
25456
|
-
const decode$3 = (params, decodedAttrs) => {
|
|
25526
|
+
const decode$k = (params, decodedAttrs) => {
|
|
25457
25527
|
const { node } = params;
|
|
25458
25528
|
const elements = translateChildNodes(params);
|
|
25459
25529
|
if (node.attrs?.tableRowProperties) {
|
|
@@ -25465,7 +25535,7 @@ const decode$3 = (params, decodedAttrs) => {
|
|
|
25465
25535
|
}
|
|
25466
25536
|
}
|
|
25467
25537
|
tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
|
|
25468
|
-
const trPr = translator$
|
|
25538
|
+
const trPr = translator$G.decode({
|
|
25469
25539
|
...params,
|
|
25470
25540
|
node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
|
|
25471
25541
|
});
|
|
@@ -25477,98 +25547,549 @@ const decode$3 = (params, decodedAttrs) => {
|
|
|
25477
25547
|
elements
|
|
25478
25548
|
};
|
|
25479
25549
|
};
|
|
25480
|
-
const config$
|
|
25481
|
-
xmlName: XML_NODE_NAME$
|
|
25482
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
25550
|
+
const config$b = {
|
|
25551
|
+
xmlName: XML_NODE_NAME$d,
|
|
25552
|
+
sdNodeOrKeyName: SD_NODE_NAME$9,
|
|
25483
25553
|
type: NodeTranslator.translatorTypes.NODE,
|
|
25484
|
-
encode: encode$
|
|
25485
|
-
decode: decode$
|
|
25486
|
-
attributes: validXmlAttributes$
|
|
25554
|
+
encode: encode$k,
|
|
25555
|
+
decode: decode$k,
|
|
25556
|
+
attributes: validXmlAttributes$8
|
|
25557
|
+
};
|
|
25558
|
+
const translator$F = NodeTranslator.from(config$b);
|
|
25559
|
+
const translator$E = NodeTranslator.from({
|
|
25560
|
+
xmlName: "w:bidiVisual",
|
|
25561
|
+
sdNodeOrKeyName: "rightToLeft",
|
|
25562
|
+
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25563
|
+
decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
|
|
25564
|
+
});
|
|
25565
|
+
const translator$D = NodeTranslator.from({
|
|
25566
|
+
xmlName: "w:shd",
|
|
25567
|
+
sdNodeOrKeyName: "shading",
|
|
25568
|
+
attributes: [
|
|
25569
|
+
"w:color",
|
|
25570
|
+
"w:fill",
|
|
25571
|
+
"w:themeColor",
|
|
25572
|
+
"w:themeFill",
|
|
25573
|
+
"w:themeFillShade",
|
|
25574
|
+
"w:themeFillTint",
|
|
25575
|
+
"w:themeShade",
|
|
25576
|
+
"w:themeTint",
|
|
25577
|
+
"w:val"
|
|
25578
|
+
].map((attr) => createAttributeHandler(attr)),
|
|
25579
|
+
encode: (params, encodedAttrs) => {
|
|
25580
|
+
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25581
|
+
},
|
|
25582
|
+
decode: function({ node }, context) {
|
|
25583
|
+
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.shading || {} } });
|
|
25584
|
+
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25585
|
+
}
|
|
25586
|
+
});
|
|
25587
|
+
const translator$C = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
|
|
25588
|
+
const translator$B = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
|
|
25589
|
+
const translator$A = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
|
|
25590
|
+
const translator$z = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
|
|
25591
|
+
const translator$y = NodeTranslator.from({
|
|
25592
|
+
xmlName: "w:tblLook",
|
|
25593
|
+
sdNodeOrKeyName: "tblLook",
|
|
25594
|
+
attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
|
|
25595
|
+
encode: (params, encodedAttrs) => {
|
|
25596
|
+
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25597
|
+
},
|
|
25598
|
+
decode: function({ node }, context) {
|
|
25599
|
+
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.tblLook || {} } });
|
|
25600
|
+
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25601
|
+
}
|
|
25602
|
+
});
|
|
25603
|
+
const translator$x = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
|
|
25604
|
+
const translator$w = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
|
|
25605
|
+
const translator$v = NodeTranslator.from(
|
|
25606
|
+
createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
|
|
25607
|
+
);
|
|
25608
|
+
const translator$u = NodeTranslator.from(
|
|
25609
|
+
createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
|
|
25610
|
+
);
|
|
25611
|
+
const translator$t = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
|
|
25612
|
+
const translator$s = NodeTranslator.from({
|
|
25613
|
+
xmlName: "w:tblpPr",
|
|
25614
|
+
sdNodeOrKeyName: "floatingTableProperties",
|
|
25615
|
+
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))),
|
|
25616
|
+
encode: (params, encodedAttrs) => {
|
|
25617
|
+
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25618
|
+
},
|
|
25619
|
+
decode: function({ node }, context) {
|
|
25620
|
+
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.floatingTableProperties || {} } });
|
|
25621
|
+
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25622
|
+
}
|
|
25623
|
+
});
|
|
25624
|
+
const translator$r = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
|
|
25625
|
+
const translator$q = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
|
|
25626
|
+
const translator$p = NodeTranslator.from(createBorderPropertyHandler("w:end"));
|
|
25627
|
+
const translator$o = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
|
|
25628
|
+
const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
|
|
25629
|
+
const translator$m = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
|
|
25630
|
+
const translator$l = NodeTranslator.from(createBorderPropertyHandler("w:left"));
|
|
25631
|
+
const translator$k = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
|
|
25632
|
+
const translator$j = NodeTranslator.from(createBorderPropertyHandler("w:right"));
|
|
25633
|
+
const translator$i = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
|
|
25634
|
+
const translator$h = NodeTranslator.from(createBorderPropertyHandler("w:start"));
|
|
25635
|
+
const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
|
|
25636
|
+
const translator$f = NodeTranslator.from(createBorderPropertyHandler("w:top"));
|
|
25637
|
+
const translator$e = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
|
|
25638
|
+
const XML_NODE_NAME$c = "w:tblBorders";
|
|
25639
|
+
const SD_ATTR_KEY$3 = "borders";
|
|
25640
|
+
const encode$j = (params) => {
|
|
25641
|
+
const { nodes } = params;
|
|
25642
|
+
const node = nodes[0];
|
|
25643
|
+
const attributes = encodeProperties(node, tblBordersTranslatorsByXmlName);
|
|
25644
|
+
return Object.keys(attributes).length > 0 ? attributes : void 0;
|
|
25487
25645
|
};
|
|
25488
|
-
const
|
|
25489
|
-
const
|
|
25646
|
+
const decode$j = (params) => {
|
|
25647
|
+
const { borders = {} } = params.node.attrs || {};
|
|
25648
|
+
const elements = decodeProperties(tblBordersTranslatorsBySdName, borders);
|
|
25649
|
+
const newNode = {
|
|
25650
|
+
name: "w:tblBorders",
|
|
25651
|
+
type: "element",
|
|
25652
|
+
attributes: {},
|
|
25653
|
+
elements
|
|
25654
|
+
};
|
|
25655
|
+
return newNode;
|
|
25656
|
+
};
|
|
25657
|
+
const propertyTranslators$2 = [
|
|
25658
|
+
translator$r,
|
|
25659
|
+
translator$p,
|
|
25660
|
+
translator$n,
|
|
25661
|
+
translator$m,
|
|
25662
|
+
translator$l,
|
|
25663
|
+
translator$j,
|
|
25664
|
+
translator$h,
|
|
25665
|
+
translator$f
|
|
25666
|
+
];
|
|
25667
|
+
const tblBordersTranslatorsByXmlName = {};
|
|
25668
|
+
const tblBordersTranslatorsBySdName = {};
|
|
25669
|
+
propertyTranslators$2.forEach((translator2) => {
|
|
25670
|
+
tblBordersTranslatorsByXmlName[translator2.xmlName] = translator2;
|
|
25671
|
+
tblBordersTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
|
|
25672
|
+
});
|
|
25673
|
+
const translator$d = NodeTranslator.from({
|
|
25674
|
+
xmlName: XML_NODE_NAME$c,
|
|
25675
|
+
sdNodeOrKeyName: SD_ATTR_KEY$3,
|
|
25676
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
25677
|
+
attributes: [],
|
|
25678
|
+
encode: encode$j,
|
|
25679
|
+
decode: decode$j
|
|
25680
|
+
});
|
|
25681
|
+
const XML_NODE_NAME$b = "w:tblCellMar";
|
|
25682
|
+
const SD_ATTR_KEY$2 = "cellMargins";
|
|
25683
|
+
const encode$i = (params) => {
|
|
25490
25684
|
const { nodes } = params;
|
|
25491
|
-
if (nodes.length === 0) {
|
|
25492
|
-
return { nodes: [], consumed: 0 };
|
|
25493
|
-
}
|
|
25494
25685
|
const node = nodes[0];
|
|
25495
|
-
|
|
25496
|
-
|
|
25497
|
-
return { nodes: [handleTableNode(node, params)], consumed: 1 };
|
|
25498
|
-
}
|
|
25499
|
-
return { nodes: [], consumed: 0 };
|
|
25686
|
+
const attributes = encodeProperties(node, propertyTranslatorsByXmlName$1);
|
|
25687
|
+
return Object.keys(attributes).length > 0 ? attributes : void 0;
|
|
25500
25688
|
};
|
|
25501
|
-
const
|
|
25502
|
-
|
|
25503
|
-
|
|
25689
|
+
const decode$i = (params) => {
|
|
25690
|
+
const { cellMargins = {} } = params.node.attrs || {};
|
|
25691
|
+
const elements = decodeProperties(propertyTranslatorsBySdName$1, cellMargins);
|
|
25692
|
+
const newNode = {
|
|
25693
|
+
name: XML_NODE_NAME$b,
|
|
25694
|
+
type: "element",
|
|
25695
|
+
attributes: {},
|
|
25696
|
+
elements
|
|
25697
|
+
};
|
|
25698
|
+
return newNode;
|
|
25504
25699
|
};
|
|
25505
|
-
|
|
25506
|
-
|
|
25507
|
-
|
|
25508
|
-
|
|
25509
|
-
|
|
25510
|
-
|
|
25511
|
-
|
|
25512
|
-
|
|
25513
|
-
|
|
25514
|
-
|
|
25515
|
-
|
|
25516
|
-
|
|
25517
|
-
|
|
25518
|
-
|
|
25519
|
-
|
|
25520
|
-
|
|
25521
|
-
|
|
25522
|
-
|
|
25523
|
-
|
|
25524
|
-
|
|
25525
|
-
|
|
25526
|
-
|
|
25527
|
-
|
|
25528
|
-
|
|
25529
|
-
|
|
25530
|
-
|
|
25700
|
+
const propertyTranslators$1 = [
|
|
25701
|
+
translator$q,
|
|
25702
|
+
translator$o,
|
|
25703
|
+
translator$k,
|
|
25704
|
+
translator$i,
|
|
25705
|
+
translator$g,
|
|
25706
|
+
translator$e
|
|
25707
|
+
];
|
|
25708
|
+
const propertyTranslatorsByXmlName$1 = {};
|
|
25709
|
+
const propertyTranslatorsBySdName$1 = {};
|
|
25710
|
+
propertyTranslators$1.forEach((translator2) => {
|
|
25711
|
+
propertyTranslatorsByXmlName$1[translator2.xmlName] = translator2;
|
|
25712
|
+
propertyTranslatorsBySdName$1[translator2.sdNodeOrKeyName] = translator2;
|
|
25713
|
+
});
|
|
25714
|
+
const translator$c = NodeTranslator.from({
|
|
25715
|
+
xmlName: XML_NODE_NAME$b,
|
|
25716
|
+
sdNodeOrKeyName: SD_ATTR_KEY$2,
|
|
25717
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
25718
|
+
attributes: [],
|
|
25719
|
+
encode: encode$i,
|
|
25720
|
+
decode: decode$i
|
|
25721
|
+
});
|
|
25722
|
+
const XML_NODE_NAME$a = "w:tblPr";
|
|
25723
|
+
const SD_ATTR_KEY$1 = "tableProperties";
|
|
25724
|
+
const encode$h = (params) => {
|
|
25725
|
+
const { nodes } = params;
|
|
25726
|
+
const node = nodes[0];
|
|
25727
|
+
const attributes = encodeProperties(node, propertyTranslatorsByXmlName);
|
|
25728
|
+
return {
|
|
25729
|
+
xmlName: XML_NODE_NAME$a,
|
|
25730
|
+
sdNodeOrKeyName: SD_ATTR_KEY$1,
|
|
25731
|
+
attributes
|
|
25732
|
+
};
|
|
25733
|
+
};
|
|
25734
|
+
const decode$h = (params) => {
|
|
25735
|
+
const { tableProperties = {} } = params.node.attrs || {};
|
|
25736
|
+
const elements = decodeProperties(propertyTranslatorsBySdName, tableProperties);
|
|
25737
|
+
const newNode = {
|
|
25738
|
+
name: "w:tblPr",
|
|
25739
|
+
type: "element",
|
|
25740
|
+
attributes: {},
|
|
25741
|
+
elements
|
|
25742
|
+
};
|
|
25743
|
+
return newNode;
|
|
25744
|
+
};
|
|
25745
|
+
const propertyTranslators = [
|
|
25746
|
+
translator$E,
|
|
25747
|
+
translator$M,
|
|
25748
|
+
translator$D,
|
|
25749
|
+
translator$C,
|
|
25750
|
+
translator$L,
|
|
25751
|
+
translator$B,
|
|
25752
|
+
translator$A,
|
|
25753
|
+
translator$z,
|
|
25754
|
+
translator$y,
|
|
25755
|
+
translator$x,
|
|
25756
|
+
translator$w,
|
|
25757
|
+
translator$v,
|
|
25758
|
+
translator$u,
|
|
25759
|
+
translator$t,
|
|
25760
|
+
translator$s,
|
|
25761
|
+
translator$d,
|
|
25762
|
+
translator$c
|
|
25763
|
+
];
|
|
25764
|
+
const propertyTranslatorsByXmlName = {};
|
|
25765
|
+
const propertyTranslatorsBySdName = {};
|
|
25766
|
+
propertyTranslators.forEach((translator2) => {
|
|
25767
|
+
propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
|
|
25768
|
+
propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
|
|
25769
|
+
});
|
|
25770
|
+
const config$a = {
|
|
25771
|
+
xmlName: XML_NODE_NAME$a,
|
|
25772
|
+
sdNodeOrKeyName: SD_ATTR_KEY$1,
|
|
25773
|
+
encode: encode$h,
|
|
25774
|
+
decode: decode$h
|
|
25775
|
+
};
|
|
25776
|
+
const translator$b = NodeTranslator.from(config$a);
|
|
25777
|
+
const translator$a = NodeTranslator.from(
|
|
25778
|
+
createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
|
|
25779
|
+
);
|
|
25780
|
+
const DEFAULT_COLUMN_WIDTH_PX = 100;
|
|
25781
|
+
const normalizeTwipWidth = (value) => {
|
|
25782
|
+
if (value == null) return null;
|
|
25783
|
+
const numericValue = typeof value === "string" ? parseInt(value, 10) : value;
|
|
25784
|
+
if (!Number.isFinite(numericValue) || Number.isNaN(numericValue) || numericValue <= 0) {
|
|
25785
|
+
return null;
|
|
25531
25786
|
}
|
|
25532
|
-
|
|
25533
|
-
|
|
25534
|
-
|
|
25535
|
-
|
|
25536
|
-
|
|
25537
|
-
|
|
25538
|
-
|
|
25787
|
+
return numericValue;
|
|
25788
|
+
};
|
|
25789
|
+
const getSchemaDefaultColumnWidthPx = (params) => {
|
|
25790
|
+
const defaultValue = params?.editor?.schema?.nodes?.tableCell?.spec?.attrs?.colwidth?.default;
|
|
25791
|
+
if (Array.isArray(defaultValue)) {
|
|
25792
|
+
const numericWidth = defaultValue.find((width) => typeof width === "number" && Number.isFinite(width) && width > 0);
|
|
25793
|
+
if (numericWidth != null) return numericWidth;
|
|
25794
|
+
} else if (typeof defaultValue === "number" && Number.isFinite(defaultValue) && defaultValue > 0) {
|
|
25795
|
+
return defaultValue;
|
|
25539
25796
|
}
|
|
25540
|
-
|
|
25541
|
-
|
|
25542
|
-
|
|
25797
|
+
return DEFAULT_COLUMN_WIDTH_PX;
|
|
25798
|
+
};
|
|
25799
|
+
const getTableWidthPx = (params) => {
|
|
25800
|
+
const explicitWidth = params?.node?.attrs?.tableWidth?.width;
|
|
25801
|
+
if (typeof explicitWidth === "number" && explicitWidth > 0) return explicitWidth;
|
|
25802
|
+
const tableWidth = params?.node?.attrs?.tableProperties?.tableWidth;
|
|
25803
|
+
if (tableWidth?.value != null && typeof tableWidth.value === "number" && tableWidth.value > 0) {
|
|
25804
|
+
const { value, type: type2 } = tableWidth;
|
|
25805
|
+
if (!type2 || type2 === "auto" || type2 === "dxa") {
|
|
25806
|
+
return twipsToPixels(value);
|
|
25807
|
+
}
|
|
25543
25808
|
}
|
|
25544
|
-
|
|
25545
|
-
|
|
25546
|
-
|
|
25547
|
-
const
|
|
25548
|
-
const
|
|
25549
|
-
|
|
25550
|
-
const
|
|
25551
|
-
|
|
25552
|
-
|
|
25553
|
-
|
|
25554
|
-
|
|
25555
|
-
|
|
25556
|
-
|
|
25557
|
-
|
|
25558
|
-
|
|
25559
|
-
|
|
25560
|
-
|
|
25561
|
-
|
|
25562
|
-
|
|
25563
|
-
|
|
25809
|
+
return null;
|
|
25810
|
+
};
|
|
25811
|
+
const resolveFallbackColumnWidthTwips = (params, totalColumns, cellMinWidthTwips) => {
|
|
25812
|
+
const columnCount = Math.max(totalColumns, 1);
|
|
25813
|
+
const defaultColumnWidthPx = getSchemaDefaultColumnWidthPx(params);
|
|
25814
|
+
const tableWidthPx = getTableWidthPx(params);
|
|
25815
|
+
const safeDefaultPx = Number.isFinite(defaultColumnWidthPx) && defaultColumnWidthPx > 0 ? defaultColumnWidthPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
25816
|
+
let fallbackWidthPx = safeDefaultPx;
|
|
25817
|
+
if (typeof tableWidthPx === "number" && tableWidthPx > 0) {
|
|
25818
|
+
fallbackWidthPx = tableWidthPx / columnCount;
|
|
25819
|
+
}
|
|
25820
|
+
const fallbackWidthTwips = pixelsToTwips(fallbackWidthPx);
|
|
25821
|
+
if (!Number.isFinite(fallbackWidthTwips) || Number.isNaN(fallbackWidthTwips) || fallbackWidthTwips <= 0) {
|
|
25822
|
+
const safeDefault = Math.max(pixelsToTwips(safeDefaultPx), cellMinWidthTwips);
|
|
25823
|
+
return safeDefault;
|
|
25824
|
+
}
|
|
25825
|
+
return Math.max(fallbackWidthTwips, cellMinWidthTwips);
|
|
25826
|
+
};
|
|
25827
|
+
const XML_NODE_NAME$9 = "w:tblGrid";
|
|
25828
|
+
const SD_ATTR_KEY = "grid";
|
|
25829
|
+
const cellMinWidth = pixelsToTwips(10);
|
|
25830
|
+
const encode$g = (params) => {
|
|
25831
|
+
const { nodes } = params;
|
|
25832
|
+
const node = nodes[0];
|
|
25833
|
+
const attributes = encodeProperties(node, { [translator$a.xmlName]: translator$a }, true);
|
|
25564
25834
|
return {
|
|
25565
|
-
|
|
25566
|
-
|
|
25567
|
-
|
|
25835
|
+
xmlName: XML_NODE_NAME$9,
|
|
25836
|
+
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
25837
|
+
attributes
|
|
25568
25838
|
};
|
|
25569
|
-
}
|
|
25570
|
-
|
|
25571
|
-
|
|
25839
|
+
};
|
|
25840
|
+
const decode$g = (params) => {
|
|
25841
|
+
const { grid: rawGrid } = params.node.attrs || {};
|
|
25842
|
+
const grid = Array.isArray(rawGrid) ? rawGrid : [];
|
|
25843
|
+
const { firstRow = {} } = params.extraParams || {};
|
|
25844
|
+
const cellNodes = firstRow.content?.filter((n) => n.type === "tableCell") ?? [];
|
|
25845
|
+
const columnCountFromCells = cellNodes.reduce((count, cell) => {
|
|
25846
|
+
const spanCount = Math.max(1, cell?.attrs?.colspan ?? 1);
|
|
25847
|
+
return count + spanCount;
|
|
25848
|
+
}, 0);
|
|
25849
|
+
const totalColumns = Math.max(columnCountFromCells, grid.length);
|
|
25850
|
+
const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params, totalColumns, cellMinWidth);
|
|
25851
|
+
const elements = [];
|
|
25852
|
+
let columnIndex = 0;
|
|
25853
|
+
const pushColumn = (widthTwips) => {
|
|
25854
|
+
let numericWidth = typeof widthTwips === "string" ? parseInt(widthTwips, 10) : widthTwips;
|
|
25855
|
+
if (numericWidth == null || Number.isNaN(numericWidth) || numericWidth <= 0) {
|
|
25856
|
+
numericWidth = fallbackColumnWidthTwips;
|
|
25857
|
+
}
|
|
25858
|
+
numericWidth = Math.max(numericWidth, cellMinWidth);
|
|
25859
|
+
const decoded = translator$a.decode({
|
|
25860
|
+
node: { type: (
|
|
25861
|
+
/** @type {string} */
|
|
25862
|
+
translator$a.sdNodeOrKeyName
|
|
25863
|
+
), attrs: { col: numericWidth } }
|
|
25864
|
+
});
|
|
25865
|
+
if (decoded) elements.push(decoded);
|
|
25866
|
+
};
|
|
25867
|
+
cellNodes.forEach((cell) => {
|
|
25868
|
+
const { colspan = 1, colwidth } = cell?.attrs || {};
|
|
25869
|
+
const spanCount = Math.max(1, colspan);
|
|
25870
|
+
for (let span = 0; span < spanCount; span++) {
|
|
25871
|
+
const cellWidthPixels = Array.isArray(colwidth) ? colwidth[span] : void 0;
|
|
25872
|
+
const colGridAttrs = grid?.[columnIndex] || {};
|
|
25873
|
+
const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
|
|
25874
|
+
const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
|
|
25875
|
+
let cellWidthTwips;
|
|
25876
|
+
if (cellWidthPixels != null) {
|
|
25877
|
+
if (gridWidthTwips != null && gridWidthPixels === cellWidthPixels) {
|
|
25878
|
+
cellWidthTwips = gridWidthTwips;
|
|
25879
|
+
} else {
|
|
25880
|
+
cellWidthTwips = pixelsToTwips(cellWidthPixels);
|
|
25881
|
+
}
|
|
25882
|
+
} else if (gridWidthTwips != null) {
|
|
25883
|
+
cellWidthTwips = gridWidthTwips;
|
|
25884
|
+
} else {
|
|
25885
|
+
cellWidthTwips = fallbackColumnWidthTwips;
|
|
25886
|
+
}
|
|
25887
|
+
pushColumn(cellWidthTwips);
|
|
25888
|
+
columnIndex++;
|
|
25889
|
+
}
|
|
25890
|
+
});
|
|
25891
|
+
while (columnIndex < grid.length) {
|
|
25892
|
+
const gridWidthTwips = normalizeTwipWidth(grid[columnIndex]?.col);
|
|
25893
|
+
pushColumn(gridWidthTwips);
|
|
25894
|
+
columnIndex++;
|
|
25895
|
+
}
|
|
25896
|
+
const newNode = {
|
|
25897
|
+
name: XML_NODE_NAME$9,
|
|
25898
|
+
attributes: {},
|
|
25899
|
+
elements
|
|
25900
|
+
};
|
|
25901
|
+
return newNode;
|
|
25902
|
+
};
|
|
25903
|
+
const config$9 = {
|
|
25904
|
+
xmlName: XML_NODE_NAME$9,
|
|
25905
|
+
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
25906
|
+
encode: encode$g,
|
|
25907
|
+
decode: decode$g
|
|
25908
|
+
};
|
|
25909
|
+
const translator$9 = NodeTranslator.from(config$9);
|
|
25910
|
+
const XML_NODE_NAME$8 = "w:tbl";
|
|
25911
|
+
const SD_NODE_NAME$8 = "table";
|
|
25912
|
+
const encode$f = (params, encodedAttrs) => {
|
|
25913
|
+
const { nodes } = params;
|
|
25914
|
+
const node = nodes[0];
|
|
25915
|
+
const tblPr = node.elements.find((el) => el.name === "w:tblPr");
|
|
25916
|
+
if (tblPr) {
|
|
25917
|
+
const encodedProperties = translator$b.encode({ ...params, nodes: [tblPr] });
|
|
25918
|
+
encodedAttrs["tableProperties"] = encodedProperties?.attributes || {};
|
|
25919
|
+
}
|
|
25920
|
+
const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
|
|
25921
|
+
if (tblGrid) {
|
|
25922
|
+
encodedAttrs["grid"] = translator$9.encode({ ...params, nodes: [tblGrid] }).attributes;
|
|
25923
|
+
}
|
|
25924
|
+
[
|
|
25925
|
+
"tableStyleId",
|
|
25926
|
+
"justification",
|
|
25927
|
+
"tableLayout",
|
|
25928
|
+
["tableIndent", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
25929
|
+
["tableWidth", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
25930
|
+
["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
|
|
25931
|
+
].forEach((prop) => {
|
|
25932
|
+
let key;
|
|
25933
|
+
let transform;
|
|
25934
|
+
if (Array.isArray(prop)) {
|
|
25935
|
+
[key, transform] = prop;
|
|
25936
|
+
} else {
|
|
25937
|
+
key = prop;
|
|
25938
|
+
transform = (v2) => v2;
|
|
25939
|
+
}
|
|
25940
|
+
if (encodedAttrs.tableProperties && encodedAttrs.tableProperties[key]) {
|
|
25941
|
+
encodedAttrs[key] = transform(encodedAttrs.tableProperties[key]);
|
|
25942
|
+
}
|
|
25943
|
+
});
|
|
25944
|
+
if (encodedAttrs.tableCellSpacing) {
|
|
25945
|
+
encodedAttrs["borderCollapse"] = "separate";
|
|
25946
|
+
}
|
|
25947
|
+
const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
|
|
25948
|
+
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params);
|
|
25949
|
+
if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
|
|
25950
|
+
encodedAttrs.tableProperties = {
|
|
25951
|
+
...encodedAttrs.tableProperties || {},
|
|
25952
|
+
cellMargins: referencedStyles.cellMargins
|
|
25953
|
+
};
|
|
25954
|
+
}
|
|
25955
|
+
const rows = node.elements.filter((el) => el.name === "w:tr");
|
|
25956
|
+
const borderData = Object.assign({}, referencedStyles?.borders || {}, borders || {});
|
|
25957
|
+
const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
|
|
25958
|
+
encodedAttrs["borders"] = borderData;
|
|
25959
|
+
const tblStyleTag = tblPr?.elements?.find((el) => el.name === "w:tblStyle");
|
|
25960
|
+
const columnWidths = (encodedAttrs["grid"] ?? []).map((item) => twipsToPixels(item.col));
|
|
25961
|
+
const content = [];
|
|
25962
|
+
rows.forEach((row) => {
|
|
25963
|
+
const result = translator$F.encode({
|
|
25964
|
+
...params,
|
|
25965
|
+
nodes: [row],
|
|
25966
|
+
extraParams: {
|
|
25967
|
+
row,
|
|
25968
|
+
table: node,
|
|
25969
|
+
rowBorders: borderRowData,
|
|
25970
|
+
styleTag: tblStyleTag,
|
|
25971
|
+
columnWidths
|
|
25972
|
+
}
|
|
25973
|
+
});
|
|
25974
|
+
if (result.content?.length) content.push(result);
|
|
25975
|
+
});
|
|
25976
|
+
return {
|
|
25977
|
+
type: "table",
|
|
25978
|
+
content,
|
|
25979
|
+
attrs: encodedAttrs
|
|
25980
|
+
};
|
|
25981
|
+
};
|
|
25982
|
+
const decode$f = (params, decodedAttrs) => {
|
|
25983
|
+
params.node = preProcessVerticalMergeCells(params.node, params);
|
|
25984
|
+
const { node } = params;
|
|
25985
|
+
const elements = translateChildNodes(params);
|
|
25986
|
+
const firstRow = node.content?.find((n) => n.type === "tableRow");
|
|
25987
|
+
const properties = node.attrs.grid;
|
|
25988
|
+
const element = translator$9.decode({
|
|
25989
|
+
...params,
|
|
25990
|
+
node: { ...node, attrs: { ...node.attrs, grid: properties } },
|
|
25991
|
+
extraParams: {
|
|
25992
|
+
firstRow
|
|
25993
|
+
}
|
|
25994
|
+
});
|
|
25995
|
+
if (element) elements.unshift(element);
|
|
25996
|
+
if (node.attrs?.tableProperties) {
|
|
25997
|
+
const properties2 = { ...node.attrs.tableProperties };
|
|
25998
|
+
const element2 = translator$b.decode({
|
|
25999
|
+
...params,
|
|
26000
|
+
node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
|
|
26001
|
+
});
|
|
26002
|
+
if (element2) elements.unshift(element2);
|
|
26003
|
+
}
|
|
26004
|
+
return {
|
|
26005
|
+
name: "w:tbl",
|
|
26006
|
+
attributes: decodedAttrs || {},
|
|
26007
|
+
elements
|
|
26008
|
+
};
|
|
26009
|
+
};
|
|
26010
|
+
function _processTableBorders(rawBorders) {
|
|
26011
|
+
const borders = {};
|
|
26012
|
+
const rowBorders = {};
|
|
26013
|
+
Object.entries(rawBorders).forEach(([name, attributes]) => {
|
|
26014
|
+
const attrs = {};
|
|
26015
|
+
const color = attributes.color;
|
|
26016
|
+
const size = attributes.size;
|
|
26017
|
+
if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
|
|
26018
|
+
if (size && size !== "auto") attrs["size"] = eigthPointsToPixels(size);
|
|
26019
|
+
const rowBorderNames = ["insideH", "insideV"];
|
|
26020
|
+
if (rowBorderNames.includes(name)) rowBorders[name] = attrs;
|
|
26021
|
+
borders[name] = attrs;
|
|
26022
|
+
});
|
|
26023
|
+
return {
|
|
26024
|
+
borders,
|
|
26025
|
+
rowBorders
|
|
26026
|
+
};
|
|
26027
|
+
}
|
|
26028
|
+
function _getReferencedTableStyles(tableStyleReference, params) {
|
|
26029
|
+
if (!tableStyleReference) return null;
|
|
26030
|
+
const stylesToReturn = {};
|
|
26031
|
+
const { docx } = params;
|
|
26032
|
+
const styles = docx["word/styles.xml"];
|
|
26033
|
+
const { elements } = styles.elements[0];
|
|
26034
|
+
const styleElements = elements.filter((el) => el.name === "w:style");
|
|
26035
|
+
const styleTag = styleElements.find((el) => el.attributes["w:styleId"] === tableStyleReference);
|
|
26036
|
+
if (!styleTag) return null;
|
|
26037
|
+
stylesToReturn.name = styleTag.elements.find((el) => el.name === "w:name");
|
|
26038
|
+
const basedOn = styleTag.elements.find((el) => el.name === "w:basedOn");
|
|
26039
|
+
let baseTblPr;
|
|
26040
|
+
if (basedOn?.attributes) {
|
|
26041
|
+
const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
|
|
26042
|
+
baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
|
|
26043
|
+
}
|
|
26044
|
+
const pPr = styleTag.elements.find((el) => el.name === "w:pPr");
|
|
26045
|
+
if (pPr) {
|
|
26046
|
+
const justification = pPr.elements.find((el) => el.name === "w:jc");
|
|
26047
|
+
if (justification?.attributes) stylesToReturn.justification = justification.attributes["w:val"];
|
|
26048
|
+
}
|
|
26049
|
+
const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
|
|
26050
|
+
if (rPr) {
|
|
26051
|
+
const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
|
|
26052
|
+
if (fonts) {
|
|
26053
|
+
const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
|
|
26054
|
+
stylesToReturn.fonts = { ascii, hAnsi, cs };
|
|
26055
|
+
}
|
|
26056
|
+
const fontSize = rPr.elements.find((el) => el.name === "w:sz");
|
|
26057
|
+
if (fontSize?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize.attributes["w:val"]) + "pt";
|
|
26058
|
+
}
|
|
26059
|
+
const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
|
|
26060
|
+
if (tblPr && tblPr.elements) {
|
|
26061
|
+
if (baseTblPr && baseTblPr.elements) {
|
|
26062
|
+
tblPr.elements.push(...baseTblPr.elements);
|
|
26063
|
+
}
|
|
26064
|
+
const tableProperties = translator$b.encode({ ...params, nodes: [tblPr] }).attributes;
|
|
26065
|
+
const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
|
|
26066
|
+
if (borders) stylesToReturn.borders = borders;
|
|
26067
|
+
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
26068
|
+
const cellMargins = {};
|
|
26069
|
+
Object.entries(tableProperties.cellMargins || {}).forEach(([key, attrs]) => {
|
|
26070
|
+
if (attrs?.value != null) {
|
|
26071
|
+
cellMargins[key] = {
|
|
26072
|
+
value: attrs.value,
|
|
26073
|
+
type: attrs.type || "dxa"
|
|
26074
|
+
};
|
|
26075
|
+
}
|
|
26076
|
+
});
|
|
26077
|
+
if (Object.keys(cellMargins).length) stylesToReturn.cellMargins = cellMargins;
|
|
26078
|
+
}
|
|
26079
|
+
return stylesToReturn;
|
|
26080
|
+
}
|
|
26081
|
+
const config$8 = {
|
|
26082
|
+
xmlName: XML_NODE_NAME$8,
|
|
26083
|
+
sdNodeOrKeyName: SD_NODE_NAME$8,
|
|
26084
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
26085
|
+
encode: encode$f,
|
|
26086
|
+
decode: decode$f,
|
|
26087
|
+
attributes: []
|
|
26088
|
+
};
|
|
26089
|
+
const translator$8 = NodeTranslator.from(config$8);
|
|
26090
|
+
const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$8);
|
|
26091
|
+
function getReferencedTableStyles(tblStyleTag, docx) {
|
|
26092
|
+
if (!tblStyleTag) return null;
|
|
25572
26093
|
const stylesToReturn = {};
|
|
25573
26094
|
const { attributes = {} } = tblStyleTag;
|
|
25574
26095
|
const tableStyleReference = attributes["w:val"];
|
|
@@ -25647,15 +26168,6 @@ function processTableBorders(borderElements) {
|
|
|
25647
26168
|
rowBorders
|
|
25648
26169
|
};
|
|
25649
26170
|
}
|
|
25650
|
-
const getGridColumnWidths = (tableNode) => {
|
|
25651
|
-
const tblGrid = tableNode.elements.find((el) => el.name === "w:tblGrid");
|
|
25652
|
-
if (!tblGrid) return [];
|
|
25653
|
-
const columnWidths = tblGrid?.elements?.flatMap((el) => {
|
|
25654
|
-
if (el.name !== "w:gridCol") return [];
|
|
25655
|
-
return twipsToPixels(el.attributes["w:w"]);
|
|
25656
|
-
}) || [];
|
|
25657
|
-
return columnWidths;
|
|
25658
|
-
};
|
|
25659
26171
|
function handleTableCellNode({
|
|
25660
26172
|
params,
|
|
25661
26173
|
node,
|
|
@@ -25664,7 +26176,8 @@ function handleTableCellNode({
|
|
|
25664
26176
|
rowBorders,
|
|
25665
26177
|
styleTag,
|
|
25666
26178
|
columnIndex,
|
|
25667
|
-
columnWidth = null
|
|
26179
|
+
columnWidth = null,
|
|
26180
|
+
allColumnWidths = []
|
|
25668
26181
|
}) {
|
|
25669
26182
|
const { docx, nodeListHandler } = params;
|
|
25670
26183
|
const tcPr = node.elements.find((el) => el.name === "w:tcPr");
|
|
@@ -25678,7 +26191,7 @@ function handleTableCellNode({
|
|
|
25678
26191
|
delete rowBorders?.insideV;
|
|
25679
26192
|
}
|
|
25680
26193
|
const inlineBorders = processInlineCellBorders(borders, rowBorders);
|
|
25681
|
-
const gridColumnWidths =
|
|
26194
|
+
const gridColumnWidths = allColumnWidths;
|
|
25682
26195
|
const tcWidth = tcPr?.elements?.find((el) => el.name === "w:tcW");
|
|
25683
26196
|
let width = tcWidth ? twipsToPixels(tcWidth.attributes["w:w"]) : null;
|
|
25684
26197
|
const widthType = tcWidth?.attributes["w:type"];
|
|
@@ -25812,11 +26325,17 @@ const getTableCellMargins = (marginTag, referencedStyles) => {
|
|
|
25812
26325
|
marginTop: marginTopStyle,
|
|
25813
26326
|
marginBottom: marginBottomStyle
|
|
25814
26327
|
} = cellMargins;
|
|
26328
|
+
const resolveMargin = (inlineValue, styleValue) => {
|
|
26329
|
+
if (inlineValue != null) return inlineValue;
|
|
26330
|
+
if (styleValue == null) return void 0;
|
|
26331
|
+
if (typeof styleValue === "object") return styleValue.value;
|
|
26332
|
+
return styleValue;
|
|
26333
|
+
};
|
|
25815
26334
|
const margins = {
|
|
25816
|
-
left: twipsToPixels(inlineMarginLeftValue
|
|
25817
|
-
right: twipsToPixels(inlineMarginRightValue
|
|
25818
|
-
top: twipsToPixels(inlineMarginTopValue
|
|
25819
|
-
bottom: twipsToPixels(inlineMarginBottomValue
|
|
26335
|
+
left: twipsToPixels(resolveMargin(inlineMarginLeftValue, marginLeftStyle)),
|
|
26336
|
+
right: twipsToPixels(resolveMargin(inlineMarginRightValue, marginRightStyle)),
|
|
26337
|
+
top: twipsToPixels(resolveMargin(inlineMarginTopValue, marginTopStyle)),
|
|
26338
|
+
bottom: twipsToPixels(resolveMargin(inlineMarginBottomValue, marginBottomStyle))
|
|
25820
26339
|
};
|
|
25821
26340
|
return margins;
|
|
25822
26341
|
};
|
|
@@ -25930,11 +26449,20 @@ function generateCellMargins(cellMargins) {
|
|
|
25930
26449
|
if (left != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left) } });
|
|
25931
26450
|
return elements;
|
|
25932
26451
|
}
|
|
25933
|
-
const XML_NODE_NAME$
|
|
25934
|
-
const SD_NODE_NAME$
|
|
25935
|
-
const validXmlAttributes$
|
|
25936
|
-
function encode$
|
|
25937
|
-
const {
|
|
26452
|
+
const XML_NODE_NAME$7 = "w:tc";
|
|
26453
|
+
const SD_NODE_NAME$7 = "tableCell";
|
|
26454
|
+
const validXmlAttributes$7 = [];
|
|
26455
|
+
function encode$e(params, encodedAttrs) {
|
|
26456
|
+
const {
|
|
26457
|
+
node,
|
|
26458
|
+
table,
|
|
26459
|
+
row,
|
|
26460
|
+
rowBorders,
|
|
26461
|
+
styleTag,
|
|
26462
|
+
columnIndex,
|
|
26463
|
+
columnWidth,
|
|
26464
|
+
columnWidths: allColumnWidths
|
|
26465
|
+
} = params.extraParams;
|
|
25938
26466
|
const schemaNode = handleTableCellNode({
|
|
25939
26467
|
params,
|
|
25940
26468
|
node,
|
|
@@ -25943,38 +26471,39 @@ function encode$2(params, encodedAttrs) {
|
|
|
25943
26471
|
rowBorders,
|
|
25944
26472
|
styleTag,
|
|
25945
26473
|
columnIndex,
|
|
25946
|
-
columnWidth
|
|
26474
|
+
columnWidth,
|
|
26475
|
+
allColumnWidths
|
|
25947
26476
|
});
|
|
25948
26477
|
if (encodedAttrs && Object.keys(encodedAttrs).length) {
|
|
25949
26478
|
schemaNode.attrs = { ...schemaNode.attrs, ...encodedAttrs };
|
|
25950
26479
|
}
|
|
25951
26480
|
return schemaNode;
|
|
25952
26481
|
}
|
|
25953
|
-
function decode$
|
|
26482
|
+
function decode$e(params, decodedAttrs) {
|
|
25954
26483
|
const translated = translateTableCell(params);
|
|
25955
26484
|
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
25956
26485
|
translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
|
|
25957
26486
|
}
|
|
25958
26487
|
return translated;
|
|
25959
26488
|
}
|
|
25960
|
-
const config$
|
|
25961
|
-
xmlName: XML_NODE_NAME$
|
|
25962
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
26489
|
+
const config$7 = {
|
|
26490
|
+
xmlName: XML_NODE_NAME$7,
|
|
26491
|
+
sdNodeOrKeyName: SD_NODE_NAME$7,
|
|
25963
26492
|
type: NodeTranslator.translatorTypes.NODE,
|
|
25964
|
-
encode: encode$
|
|
25965
|
-
decode: decode$
|
|
25966
|
-
attributes: validXmlAttributes$
|
|
26493
|
+
encode: encode$e,
|
|
26494
|
+
decode: decode$e,
|
|
26495
|
+
attributes: validXmlAttributes$7
|
|
25967
26496
|
};
|
|
25968
|
-
const translator$
|
|
25969
|
-
const XML_NODE_NAME$
|
|
25970
|
-
const SD_NODE_NAME$
|
|
26497
|
+
const translator$7 = NodeTranslator.from(config$7);
|
|
26498
|
+
const XML_NODE_NAME$6 = "w:hyperlink";
|
|
26499
|
+
const SD_NODE_NAME$6 = "link";
|
|
25971
26500
|
const _createAttributeHandler = (xmlName, sdName) => ({
|
|
25972
26501
|
xmlName,
|
|
25973
26502
|
sdName,
|
|
25974
26503
|
encode: (attributes) => attributes[xmlName],
|
|
25975
26504
|
decode: (attributes) => attributes[sdName]
|
|
25976
26505
|
});
|
|
25977
|
-
const validXmlAttributes$
|
|
26506
|
+
const validXmlAttributes$6 = [
|
|
25978
26507
|
_createAttributeHandler("w:anchor", "anchor"),
|
|
25979
26508
|
_createAttributeHandler("w:docLocation", "docLocation"),
|
|
25980
26509
|
{
|
|
@@ -25987,7 +26516,7 @@ const validXmlAttributes$1 = [
|
|
|
25987
26516
|
_createAttributeHandler("r:id", "rId"),
|
|
25988
26517
|
_createAttributeHandler("w:tgtFrame", "target")
|
|
25989
26518
|
];
|
|
25990
|
-
const encode$
|
|
26519
|
+
const encode$d = (params, encodedAttrs) => {
|
|
25991
26520
|
const { nodes, docx, nodeListHandler } = params;
|
|
25992
26521
|
const node = nodes[0];
|
|
25993
26522
|
let href = _resolveHref(docx, encodedAttrs);
|
|
@@ -26018,7 +26547,7 @@ const _resolveHref = (docx, encodedAttrs) => {
|
|
|
26018
26547
|
}
|
|
26019
26548
|
return href;
|
|
26020
26549
|
};
|
|
26021
|
-
function decode$
|
|
26550
|
+
function decode$d(params) {
|
|
26022
26551
|
const { node } = params;
|
|
26023
26552
|
const linkMark = node.marks.find((m2) => m2.type === "link");
|
|
26024
26553
|
const linkAttrs = this.decodeAttributes({ ...params, node: linkMark });
|
|
@@ -26062,15 +26591,15 @@ function _addNewLinkRelationship(params, link, rId) {
|
|
|
26062
26591
|
});
|
|
26063
26592
|
return rId;
|
|
26064
26593
|
}
|
|
26065
|
-
const config$
|
|
26066
|
-
xmlName: XML_NODE_NAME$
|
|
26067
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
26594
|
+
const config$6 = {
|
|
26595
|
+
xmlName: XML_NODE_NAME$6,
|
|
26596
|
+
sdNodeOrKeyName: SD_NODE_NAME$6,
|
|
26068
26597
|
type: NodeTranslator.translatorTypes.NODE,
|
|
26069
|
-
encode: encode$
|
|
26070
|
-
decode: decode$
|
|
26071
|
-
attributes: validXmlAttributes$
|
|
26598
|
+
encode: encode$d,
|
|
26599
|
+
decode: decode$d,
|
|
26600
|
+
attributes: validXmlAttributes$6
|
|
26072
26601
|
};
|
|
26073
|
-
const translator$
|
|
26602
|
+
const translator$6 = NodeTranslator.from(config$6);
|
|
26074
26603
|
function parseTagValueJSON(json) {
|
|
26075
26604
|
if (typeof json !== "string") {
|
|
26076
26605
|
return {};
|
|
@@ -26081,7 +26610,7 @@ function parseTagValueJSON(json) {
|
|
|
26081
26610
|
}
|
|
26082
26611
|
try {
|
|
26083
26612
|
return JSON.parse(trimmed);
|
|
26084
|
-
} catch
|
|
26613
|
+
} catch {
|
|
26085
26614
|
return {};
|
|
26086
26615
|
}
|
|
26087
26616
|
}
|
|
@@ -26310,8 +26839,815 @@ function sdtNodeTypeStrategy(node) {
|
|
|
26310
26839
|
if (sdtContent) {
|
|
26311
26840
|
return { type: "structuredContent", handler: handleStructuredContentNode };
|
|
26312
26841
|
}
|
|
26313
|
-
return { type: "unknown", handler: null };
|
|
26842
|
+
return { type: "unknown", handler: null };
|
|
26843
|
+
}
|
|
26844
|
+
function handleImageNode(node, params, isAnchor) {
|
|
26845
|
+
const { docx, filename } = params;
|
|
26846
|
+
const { attributes } = node;
|
|
26847
|
+
const padding = {
|
|
26848
|
+
top: emuToPixels(attributes["distT"]),
|
|
26849
|
+
bottom: emuToPixels(attributes["distB"]),
|
|
26850
|
+
left: emuToPixels(attributes["distL"]),
|
|
26851
|
+
right: emuToPixels(attributes["distR"])
|
|
26852
|
+
};
|
|
26853
|
+
const extent = node.elements.find((el) => el.name === "wp:extent");
|
|
26854
|
+
const size = {
|
|
26855
|
+
width: emuToPixels(extent.attributes?.cx),
|
|
26856
|
+
height: emuToPixels(extent.attributes?.cy)
|
|
26857
|
+
};
|
|
26858
|
+
const graphic = node.elements.find((el) => el.name === "a:graphic");
|
|
26859
|
+
const graphicData = graphic.elements.find((el) => el.name === "a:graphicData");
|
|
26860
|
+
const { uri: uri2 } = graphicData?.attributes || {};
|
|
26861
|
+
const shapeURI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
26862
|
+
if (!!uri2 && uri2 === shapeURI) {
|
|
26863
|
+
return handleShapeDrawing(params, node, graphicData);
|
|
26864
|
+
}
|
|
26865
|
+
const picture = graphicData.elements.find((el) => el.name === "pic:pic");
|
|
26866
|
+
if (!picture || !picture.elements) return null;
|
|
26867
|
+
const blipFill = picture.elements.find((el) => el.name === "pic:blipFill");
|
|
26868
|
+
const blip = blipFill.elements.find((el) => el.name === "a:blip");
|
|
26869
|
+
const spPr = picture.elements.find((el) => el.name === "pic:spPr");
|
|
26870
|
+
let transformData = {};
|
|
26871
|
+
if (spPr) {
|
|
26872
|
+
const xfrm = spPr.elements.find((el) => el.name === "a:xfrm");
|
|
26873
|
+
if (xfrm?.attributes) {
|
|
26874
|
+
transformData = {
|
|
26875
|
+
rotation: rotToDegrees(xfrm.attributes["rot"]),
|
|
26876
|
+
verticalFlip: xfrm.attributes["flipV"] === "1",
|
|
26877
|
+
horizontalFlip: xfrm.attributes["flipH"] === "1"
|
|
26878
|
+
};
|
|
26879
|
+
}
|
|
26880
|
+
}
|
|
26881
|
+
const effectExtent = node.elements.find((el) => el.name === "wp:effectExtent");
|
|
26882
|
+
if (effectExtent) {
|
|
26883
|
+
const sanitizeEmuValue = (value) => {
|
|
26884
|
+
if (value === null || value === void 0) return 0;
|
|
26885
|
+
const numeric = Number(value);
|
|
26886
|
+
return Number.isFinite(numeric) ? numeric : 0;
|
|
26887
|
+
};
|
|
26888
|
+
transformData.sizeExtension = {
|
|
26889
|
+
left: emuToPixels(sanitizeEmuValue(effectExtent.attributes["l"])),
|
|
26890
|
+
top: emuToPixels(sanitizeEmuValue(effectExtent.attributes["t"])),
|
|
26891
|
+
right: emuToPixels(sanitizeEmuValue(effectExtent.attributes["r"])),
|
|
26892
|
+
bottom: emuToPixels(sanitizeEmuValue(effectExtent.attributes["b"]))
|
|
26893
|
+
};
|
|
26894
|
+
}
|
|
26895
|
+
const positionHTag = node.elements.find((el) => el.name === "wp:positionH");
|
|
26896
|
+
const positionH = positionHTag?.elements.find((el) => el.name === "wp:posOffset");
|
|
26897
|
+
const positionHValue = emuToPixels(positionH?.elements[0]?.text);
|
|
26898
|
+
const hRelativeFrom = positionHTag?.attributes.relativeFrom;
|
|
26899
|
+
const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
26900
|
+
const positionVTag = node.elements.find((el) => el.name === "wp:positionV");
|
|
26901
|
+
const positionV = positionVTag?.elements?.find((el) => el.name === "wp:posOffset");
|
|
26902
|
+
const positionVValue = emuToPixels(positionV?.elements[0]?.text);
|
|
26903
|
+
const vRelativeFrom = positionVTag?.attributes.relativeFrom;
|
|
26904
|
+
const alignV = positionVTag?.elements?.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
26905
|
+
const simplePos = node.elements.find((el) => el.name === "wp:simplePos");
|
|
26906
|
+
const wrapSquare = node.elements.find((el) => el.name === "wp:wrapSquare");
|
|
26907
|
+
const wrapTopAndBottom = node.elements.find((el) => el.name === "wp:wrapTopAndBottom");
|
|
26908
|
+
const docPr = node.elements.find((el) => el.name === "wp:docPr");
|
|
26909
|
+
let anchorData = null;
|
|
26910
|
+
if (hRelativeFrom || alignH || vRelativeFrom || alignV) {
|
|
26911
|
+
anchorData = {
|
|
26912
|
+
hRelativeFrom,
|
|
26913
|
+
vRelativeFrom,
|
|
26914
|
+
alignH,
|
|
26915
|
+
alignV
|
|
26916
|
+
};
|
|
26917
|
+
}
|
|
26918
|
+
const marginOffset = {
|
|
26919
|
+
left: positionHValue,
|
|
26920
|
+
top: positionVValue
|
|
26921
|
+
};
|
|
26922
|
+
const { attributes: blipAttributes = {} } = blip;
|
|
26923
|
+
const rEmbed = blipAttributes["r:embed"];
|
|
26924
|
+
if (!rEmbed) return null;
|
|
26925
|
+
const currentFile = filename || "document.xml";
|
|
26926
|
+
let rels = docx[`word/_rels/${currentFile}.rels`];
|
|
26927
|
+
if (!rels) rels = docx[`word/_rels/document.xml.rels`];
|
|
26928
|
+
const relationships = rels.elements.find((el) => el.name === "Relationships");
|
|
26929
|
+
const { elements } = relationships || [];
|
|
26930
|
+
const rel = elements?.find((el) => el.attributes["Id"] === rEmbed);
|
|
26931
|
+
if (!rel) return null;
|
|
26932
|
+
const { attributes: relAttributes } = rel;
|
|
26933
|
+
const targetPath = relAttributes["Target"];
|
|
26934
|
+
let path = `word/${targetPath}`;
|
|
26935
|
+
if (targetPath.startsWith("/word") || targetPath.startsWith("/media")) path = targetPath.substring(1);
|
|
26936
|
+
const extension = targetPath.substring(targetPath.lastIndexOf(".") + 1);
|
|
26937
|
+
return {
|
|
26938
|
+
type: "image",
|
|
26939
|
+
attrs: {
|
|
26940
|
+
src: path,
|
|
26941
|
+
alt: ["emf", "wmf"].includes(extension) ? "Unable to render EMF/WMF image" : docPr?.attributes.name || "Image",
|
|
26942
|
+
extension,
|
|
26943
|
+
id: docPr?.attributes.id || "",
|
|
26944
|
+
title: docPr?.attributes.descr || "Image",
|
|
26945
|
+
inline: true,
|
|
26946
|
+
padding,
|
|
26947
|
+
marginOffset,
|
|
26948
|
+
size,
|
|
26949
|
+
anchorData,
|
|
26950
|
+
isAnchor,
|
|
26951
|
+
transformData,
|
|
26952
|
+
...simplePos && {
|
|
26953
|
+
simplePos: {
|
|
26954
|
+
x: simplePos.attributes.x,
|
|
26955
|
+
y: simplePos.attributes.y
|
|
26956
|
+
}
|
|
26957
|
+
},
|
|
26958
|
+
...wrapSquare && {
|
|
26959
|
+
wrapText: wrapSquare.attributes.wrapText
|
|
26960
|
+
},
|
|
26961
|
+
wrapTopAndBottom: !!wrapTopAndBottom,
|
|
26962
|
+
originalPadding: {
|
|
26963
|
+
distT: attributes["distT"],
|
|
26964
|
+
distB: attributes["distB"],
|
|
26965
|
+
distL: attributes["distL"],
|
|
26966
|
+
distR: attributes["distR"]
|
|
26967
|
+
},
|
|
26968
|
+
originalAttributes: node.attributes,
|
|
26969
|
+
rId: relAttributes["Id"]
|
|
26970
|
+
}
|
|
26971
|
+
};
|
|
26972
|
+
}
|
|
26973
|
+
const handleShapeDrawing = (params, node, graphicData) => {
|
|
26974
|
+
const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
|
|
26975
|
+
const textBox = wsp.elements.find((el) => el.name === "wps:txbx");
|
|
26976
|
+
const textBoxContent = textBox?.elements?.find((el) => el.name === "w:txbxContent");
|
|
26977
|
+
node.elements.find((el) => el.name === "wp:docPr");
|
|
26978
|
+
const spPr = wsp.elements.find((el) => el.name === "wps:spPr");
|
|
26979
|
+
const prstGeom = spPr?.elements.find((el) => el.name === "a:prstGeom");
|
|
26980
|
+
if (!!prstGeom && prstGeom.attributes["prst"] === "rect" && !textBoxContent) {
|
|
26981
|
+
return getRectangleShape(params, spPr);
|
|
26982
|
+
}
|
|
26983
|
+
if (!textBoxContent) {
|
|
26984
|
+
return null;
|
|
26985
|
+
}
|
|
26986
|
+
const { nodeListHandler } = params;
|
|
26987
|
+
const translatedElement = nodeListHandler.handler({
|
|
26988
|
+
...params,
|
|
26989
|
+
node: textBoxContent.elements[0],
|
|
26990
|
+
nodes: textBoxContent.elements,
|
|
26991
|
+
path: [...params.path || [], textBoxContent]
|
|
26992
|
+
});
|
|
26993
|
+
return translatedElement[0];
|
|
26994
|
+
};
|
|
26995
|
+
const getRectangleShape = (params, node) => {
|
|
26996
|
+
const schemaAttrs = {};
|
|
26997
|
+
const [drawingNode] = params.nodes;
|
|
26998
|
+
if (drawingNode?.name === "w:drawing") {
|
|
26999
|
+
schemaAttrs.drawingContent = drawingNode;
|
|
27000
|
+
}
|
|
27001
|
+
const xfrm = node.elements.find((el) => el.name === "a:xfrm");
|
|
27002
|
+
const start = xfrm.elements.find((el) => el.name === "a:off");
|
|
27003
|
+
const size = xfrm.elements.find((el) => el.name === "a:ext");
|
|
27004
|
+
const solidFill = node.elements.find((el) => el.name === "a:solidFill");
|
|
27005
|
+
node.elements.find((el) => el.name === "a:ln");
|
|
27006
|
+
const rectangleSize = {
|
|
27007
|
+
top: emuToPixels(start.attributes["y"]),
|
|
27008
|
+
left: emuToPixels(start.attributes["x"]),
|
|
27009
|
+
width: emuToPixels(size.attributes["cx"]),
|
|
27010
|
+
height: emuToPixels(size.attributes["cy"])
|
|
27011
|
+
};
|
|
27012
|
+
schemaAttrs.size = rectangleSize;
|
|
27013
|
+
const background = solidFill?.elements[0]?.attributes["val"];
|
|
27014
|
+
if (background) {
|
|
27015
|
+
schemaAttrs.background = "#" + background;
|
|
27016
|
+
}
|
|
27017
|
+
return {
|
|
27018
|
+
type: "contentBlock",
|
|
27019
|
+
attrs: schemaAttrs
|
|
27020
|
+
};
|
|
27021
|
+
};
|
|
27022
|
+
function handleAnchorNode(params) {
|
|
27023
|
+
const { node } = params.extraParams;
|
|
27024
|
+
if (node.name !== "wp:anchor") {
|
|
27025
|
+
return null;
|
|
27026
|
+
}
|
|
27027
|
+
return handleImageNode(node, params, true);
|
|
27028
|
+
}
|
|
27029
|
+
const sanitizeDocxMediaName = (value, fallback = "image") => {
|
|
27030
|
+
if (!value) return fallback;
|
|
27031
|
+
const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
27032
|
+
return sanitized || fallback;
|
|
27033
|
+
};
|
|
27034
|
+
const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
|
|
27035
|
+
if (!src || typeof src !== "string") return fallback;
|
|
27036
|
+
const [prefix] = src.split(";");
|
|
27037
|
+
const [, maybeType] = prefix.split("/");
|
|
27038
|
+
const extension = maybeType?.toLowerCase();
|
|
27039
|
+
return extension ? `${fallback}.${extension}` : fallback;
|
|
27040
|
+
};
|
|
27041
|
+
const translateImageNode = (params) => {
|
|
27042
|
+
const {
|
|
27043
|
+
node: { attrs = {} },
|
|
27044
|
+
tableCell,
|
|
27045
|
+
imageSize
|
|
27046
|
+
} = params;
|
|
27047
|
+
let imageId = attrs.rId;
|
|
27048
|
+
const src = attrs.src || attrs.imageSrc;
|
|
27049
|
+
const { originalWidth, originalHeight } = getPngDimensions(src);
|
|
27050
|
+
let imageName;
|
|
27051
|
+
if (params.node.type === "image") {
|
|
27052
|
+
if (src?.startsWith("data:")) {
|
|
27053
|
+
imageName = getFallbackImageNameFromDataUri(src);
|
|
27054
|
+
} else {
|
|
27055
|
+
imageName = src?.split("/").pop();
|
|
27056
|
+
}
|
|
27057
|
+
} else {
|
|
27058
|
+
imageName = attrs.fieldId;
|
|
27059
|
+
}
|
|
27060
|
+
imageName = sanitizeDocxMediaName(imageName);
|
|
27061
|
+
let size = attrs.size ? {
|
|
27062
|
+
w: pixelsToEmu(attrs.size.width),
|
|
27063
|
+
h: pixelsToEmu(attrs.size.height)
|
|
27064
|
+
} : imageSize;
|
|
27065
|
+
if (originalWidth && originalHeight) {
|
|
27066
|
+
const boxWidthPx = emuToPixels(size.w);
|
|
27067
|
+
const boxHeightPx = emuToPixels(size.h);
|
|
27068
|
+
const { scaledWidth, scaledHeight } = getScaledSize(originalWidth, originalHeight, boxWidthPx, boxHeightPx);
|
|
27069
|
+
size = {
|
|
27070
|
+
w: pixelsToEmu(scaledWidth),
|
|
27071
|
+
h: pixelsToEmu(scaledHeight)
|
|
27072
|
+
};
|
|
27073
|
+
}
|
|
27074
|
+
if (tableCell) {
|
|
27075
|
+
const colwidthSum = tableCell.attrs.colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
27076
|
+
const leftMargin = tableCell.attrs.cellMargins?.left || 8;
|
|
27077
|
+
const rightMargin = tableCell.attrs.cellMargins?.right || 8;
|
|
27078
|
+
const maxWidthEmu = pixelsToEmu(colwidthSum - (leftMargin + rightMargin));
|
|
27079
|
+
const { width: w2, height: h2 } = resizeKeepAspectRatio(size.w, size.h, maxWidthEmu);
|
|
27080
|
+
if (w2 && h2) size = { w: w2, h: h2 };
|
|
27081
|
+
}
|
|
27082
|
+
if (params.node.type === "image" && !imageId) {
|
|
27083
|
+
const path = src?.split("word/")[1];
|
|
27084
|
+
imageId = addNewImageRelationship(params, path);
|
|
27085
|
+
} else if (params.node.type === "fieldAnnotation" && !imageId) {
|
|
27086
|
+
const type2 = src?.split(";")[0].split("/")[1];
|
|
27087
|
+
if (!type2) {
|
|
27088
|
+
return prepareTextAnnotation(params);
|
|
27089
|
+
}
|
|
27090
|
+
const sanitizedHash = sanitizeDocxMediaName(attrs.hash, generateDocxRandomId(4));
|
|
27091
|
+
const fileName = `${imageName}_${sanitizedHash}.${type2}`;
|
|
27092
|
+
const relationshipTarget = `media/${fileName}`;
|
|
27093
|
+
const packagePath = `word/${relationshipTarget}`;
|
|
27094
|
+
imageId = addNewImageRelationship(params, relationshipTarget);
|
|
27095
|
+
params.media[packagePath] = src;
|
|
27096
|
+
}
|
|
27097
|
+
const inlineAttrs = attrs.originalPadding || {
|
|
27098
|
+
distT: 0,
|
|
27099
|
+
distB: 0,
|
|
27100
|
+
distL: 0,
|
|
27101
|
+
distR: 0
|
|
27102
|
+
};
|
|
27103
|
+
const xfrmAttrs = {};
|
|
27104
|
+
const effectExtentAttrs = {
|
|
27105
|
+
l: 0,
|
|
27106
|
+
t: 0,
|
|
27107
|
+
r: 0,
|
|
27108
|
+
b: 0
|
|
27109
|
+
};
|
|
27110
|
+
const transformData = attrs.transformData;
|
|
27111
|
+
if (transformData) {
|
|
27112
|
+
if (transformData.rotation) {
|
|
27113
|
+
xfrmAttrs.rot = degreesToRot(transformData.rotation);
|
|
27114
|
+
}
|
|
27115
|
+
if (transformData.verticalFlip) {
|
|
27116
|
+
xfrmAttrs.flipV = "1";
|
|
27117
|
+
}
|
|
27118
|
+
if (transformData.horizontalFlip) {
|
|
27119
|
+
xfrmAttrs.flipH = "1";
|
|
27120
|
+
}
|
|
27121
|
+
if (transformData.sizeExtension) {
|
|
27122
|
+
effectExtentAttrs.l = pixelsToEmu(transformData.sizeExtension.left);
|
|
27123
|
+
effectExtentAttrs.t = pixelsToEmu(transformData.sizeExtension.top);
|
|
27124
|
+
effectExtentAttrs.r = pixelsToEmu(transformData.sizeExtension.right);
|
|
27125
|
+
effectExtentAttrs.b = pixelsToEmu(transformData.sizeExtension.bottom);
|
|
27126
|
+
}
|
|
27127
|
+
}
|
|
27128
|
+
const drawingXmlns = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
27129
|
+
const pictureXmlns = "http://schemas.openxmlformats.org/drawingml/2006/picture";
|
|
27130
|
+
return {
|
|
27131
|
+
attributes: inlineAttrs,
|
|
27132
|
+
elements: [
|
|
27133
|
+
{
|
|
27134
|
+
name: "wp:extent",
|
|
27135
|
+
attributes: {
|
|
27136
|
+
cx: size.w,
|
|
27137
|
+
cy: size.h
|
|
27138
|
+
}
|
|
27139
|
+
},
|
|
27140
|
+
{
|
|
27141
|
+
name: "wp:effectExtent",
|
|
27142
|
+
attributes: effectExtentAttrs
|
|
27143
|
+
},
|
|
27144
|
+
{
|
|
27145
|
+
name: "wp:docPr",
|
|
27146
|
+
attributes: {
|
|
27147
|
+
id: attrs.id || 0,
|
|
27148
|
+
name: attrs.alt || `Picture ${imageName}`
|
|
27149
|
+
}
|
|
27150
|
+
},
|
|
27151
|
+
{
|
|
27152
|
+
name: "wp:cNvGraphicFramePr",
|
|
27153
|
+
elements: [
|
|
27154
|
+
{
|
|
27155
|
+
name: "a:graphicFrameLocks",
|
|
27156
|
+
attributes: {
|
|
27157
|
+
"xmlns:a": drawingXmlns,
|
|
27158
|
+
noChangeAspect: 1
|
|
27159
|
+
}
|
|
27160
|
+
}
|
|
27161
|
+
]
|
|
27162
|
+
},
|
|
27163
|
+
{
|
|
27164
|
+
name: "a:graphic",
|
|
27165
|
+
attributes: { "xmlns:a": drawingXmlns },
|
|
27166
|
+
elements: [
|
|
27167
|
+
{
|
|
27168
|
+
name: "a:graphicData",
|
|
27169
|
+
attributes: { uri: pictureXmlns },
|
|
27170
|
+
elements: [
|
|
27171
|
+
{
|
|
27172
|
+
name: "pic:pic",
|
|
27173
|
+
attributes: { "xmlns:pic": pictureXmlns },
|
|
27174
|
+
elements: [
|
|
27175
|
+
{
|
|
27176
|
+
name: "pic:nvPicPr",
|
|
27177
|
+
elements: [
|
|
27178
|
+
{
|
|
27179
|
+
name: "pic:cNvPr",
|
|
27180
|
+
attributes: {
|
|
27181
|
+
id: attrs.id || 0,
|
|
27182
|
+
name: attrs.title || `Picture ${imageName}`
|
|
27183
|
+
}
|
|
27184
|
+
},
|
|
27185
|
+
{
|
|
27186
|
+
name: "pic:cNvPicPr",
|
|
27187
|
+
elements: [
|
|
27188
|
+
{
|
|
27189
|
+
name: "a:picLocks",
|
|
27190
|
+
attributes: {
|
|
27191
|
+
noChangeAspect: 1,
|
|
27192
|
+
noChangeArrowheads: 1
|
|
27193
|
+
}
|
|
27194
|
+
}
|
|
27195
|
+
]
|
|
27196
|
+
}
|
|
27197
|
+
]
|
|
27198
|
+
},
|
|
27199
|
+
{
|
|
27200
|
+
name: "pic:blipFill",
|
|
27201
|
+
elements: [
|
|
27202
|
+
{
|
|
27203
|
+
name: "a:blip",
|
|
27204
|
+
attributes: {
|
|
27205
|
+
"r:embed": imageId
|
|
27206
|
+
}
|
|
27207
|
+
},
|
|
27208
|
+
{
|
|
27209
|
+
name: "a:stretch",
|
|
27210
|
+
elements: [{ name: "a:fillRect" }]
|
|
27211
|
+
}
|
|
27212
|
+
]
|
|
27213
|
+
},
|
|
27214
|
+
{
|
|
27215
|
+
name: "pic:spPr",
|
|
27216
|
+
attributes: {
|
|
27217
|
+
bwMode: "auto"
|
|
27218
|
+
},
|
|
27219
|
+
elements: [
|
|
27220
|
+
{
|
|
27221
|
+
name: "a:xfrm",
|
|
27222
|
+
attributes: xfrmAttrs,
|
|
27223
|
+
elements: [
|
|
27224
|
+
{
|
|
27225
|
+
name: "a:ext",
|
|
27226
|
+
attributes: {
|
|
27227
|
+
cx: size.w,
|
|
27228
|
+
cy: size.h
|
|
27229
|
+
}
|
|
27230
|
+
},
|
|
27231
|
+
{
|
|
27232
|
+
name: "a:off",
|
|
27233
|
+
attributes: {
|
|
27234
|
+
x: 0,
|
|
27235
|
+
y: 0
|
|
27236
|
+
}
|
|
27237
|
+
}
|
|
27238
|
+
]
|
|
27239
|
+
},
|
|
27240
|
+
{
|
|
27241
|
+
name: "a:prstGeom",
|
|
27242
|
+
attributes: { prst: "rect" },
|
|
27243
|
+
elements: [{ name: "a:avLst" }]
|
|
27244
|
+
},
|
|
27245
|
+
{
|
|
27246
|
+
name: "a:noFill"
|
|
27247
|
+
}
|
|
27248
|
+
]
|
|
27249
|
+
}
|
|
27250
|
+
]
|
|
27251
|
+
}
|
|
27252
|
+
]
|
|
27253
|
+
}
|
|
27254
|
+
]
|
|
27255
|
+
}
|
|
27256
|
+
]
|
|
27257
|
+
};
|
|
27258
|
+
};
|
|
27259
|
+
function getPngDimensions(base64) {
|
|
27260
|
+
if (!base64) return {};
|
|
27261
|
+
const type2 = base64.split(";")[0].split("/")[1];
|
|
27262
|
+
if (!base64 || type2 !== "png") {
|
|
27263
|
+
return {
|
|
27264
|
+
originalWidth: void 0,
|
|
27265
|
+
originalHeight: void 0
|
|
27266
|
+
};
|
|
27267
|
+
}
|
|
27268
|
+
let header = base64.split(",")[1].slice(0, 50);
|
|
27269
|
+
let uint8 = Uint8Array.from(atob(header), (c) => c.charCodeAt(0));
|
|
27270
|
+
let dataView = new DataView(uint8.buffer, 0, 28);
|
|
27271
|
+
return {
|
|
27272
|
+
originalWidth: dataView.getInt32(16),
|
|
27273
|
+
originalHeight: dataView.getInt32(20)
|
|
27274
|
+
};
|
|
27275
|
+
}
|
|
27276
|
+
function getScaledSize(originalWidth, originalHeight, maxWidth, maxHeight) {
|
|
27277
|
+
let scaledWidth = originalWidth;
|
|
27278
|
+
let scaledHeight = originalHeight;
|
|
27279
|
+
let ratio = Math.min(maxWidth / originalWidth, maxHeight / originalHeight);
|
|
27280
|
+
scaledWidth = Math.round(scaledWidth * ratio);
|
|
27281
|
+
scaledHeight = Math.round(scaledHeight * ratio);
|
|
27282
|
+
return { scaledWidth, scaledHeight };
|
|
27283
|
+
}
|
|
27284
|
+
function resizeKeepAspectRatio(width, height, maxWidth) {
|
|
27285
|
+
if (width > maxWidth) {
|
|
27286
|
+
let scale = maxWidth / width;
|
|
27287
|
+
let newHeight = Math.round(height * scale);
|
|
27288
|
+
return { width: maxWidth, height: newHeight };
|
|
27289
|
+
}
|
|
27290
|
+
return { width, height };
|
|
27291
|
+
}
|
|
27292
|
+
function addNewImageRelationship(params, imagePath) {
|
|
27293
|
+
const newId = "rId" + generateDocxRandomId();
|
|
27294
|
+
const newRel = {
|
|
27295
|
+
type: "element",
|
|
27296
|
+
name: "Relationship",
|
|
27297
|
+
attributes: {
|
|
27298
|
+
Id: newId,
|
|
27299
|
+
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
27300
|
+
Target: imagePath
|
|
27301
|
+
}
|
|
27302
|
+
};
|
|
27303
|
+
params.relationships.push(newRel);
|
|
27304
|
+
return newId;
|
|
27305
|
+
}
|
|
27306
|
+
function translateAnchorNode(params) {
|
|
27307
|
+
const { attrs } = params.node;
|
|
27308
|
+
const anchorElements = [];
|
|
27309
|
+
const wrapElements = [];
|
|
27310
|
+
if (attrs.simplePos) {
|
|
27311
|
+
anchorElements.push({
|
|
27312
|
+
name: "wp:simplePos",
|
|
27313
|
+
attributes: {
|
|
27314
|
+
x: 0,
|
|
27315
|
+
y: 0
|
|
27316
|
+
}
|
|
27317
|
+
});
|
|
27318
|
+
}
|
|
27319
|
+
if (attrs.anchorData) {
|
|
27320
|
+
const hElements = [];
|
|
27321
|
+
if (attrs.marginOffset.left !== void 0) {
|
|
27322
|
+
hElements.push({
|
|
27323
|
+
name: "wp:posOffset",
|
|
27324
|
+
elements: [{ type: "text", text: pixelsToEmu(attrs.marginOffset.left).toString() }]
|
|
27325
|
+
});
|
|
27326
|
+
}
|
|
27327
|
+
if (attrs.anchorData.alignH) {
|
|
27328
|
+
hElements.push({
|
|
27329
|
+
name: "wp:align",
|
|
27330
|
+
elements: [{ type: "text", text: attrs.anchorData.alignH }]
|
|
27331
|
+
});
|
|
27332
|
+
}
|
|
27333
|
+
anchorElements.push({
|
|
27334
|
+
name: "wp:positionH",
|
|
27335
|
+
attributes: { relativeFrom: attrs.anchorData.hRelativeFrom },
|
|
27336
|
+
...hElements.length && { elements: hElements }
|
|
27337
|
+
});
|
|
27338
|
+
const vElements = [];
|
|
27339
|
+
if (attrs.marginOffset.top !== void 0) {
|
|
27340
|
+
vElements.push({
|
|
27341
|
+
name: "wp:posOffset",
|
|
27342
|
+
elements: [{ type: "text", text: pixelsToEmu(attrs.marginOffset.top).toString() }]
|
|
27343
|
+
});
|
|
27344
|
+
}
|
|
27345
|
+
if (attrs.anchorData.alignV) {
|
|
27346
|
+
vElements.push({
|
|
27347
|
+
name: "wp:align",
|
|
27348
|
+
elements: [{ type: "text", text: attrs.anchorData.alignV }]
|
|
27349
|
+
});
|
|
27350
|
+
}
|
|
27351
|
+
anchorElements.push({
|
|
27352
|
+
name: "wp:positionV",
|
|
27353
|
+
attributes: { relativeFrom: attrs.anchorData.vRelativeFrom },
|
|
27354
|
+
...vElements.length && { elements: vElements }
|
|
27355
|
+
});
|
|
27356
|
+
}
|
|
27357
|
+
if (attrs.wrapText) {
|
|
27358
|
+
wrapElements.push({
|
|
27359
|
+
name: "wp:wrapSquare",
|
|
27360
|
+
attributes: {
|
|
27361
|
+
wrapText: attrs.wrapText
|
|
27362
|
+
}
|
|
27363
|
+
});
|
|
27364
|
+
}
|
|
27365
|
+
if (attrs.wrapTopAndBottom) {
|
|
27366
|
+
wrapElements.push({
|
|
27367
|
+
name: "wp:wrapTopAndBottom"
|
|
27368
|
+
});
|
|
27369
|
+
}
|
|
27370
|
+
if (!wrapElements.length) {
|
|
27371
|
+
wrapElements.push({
|
|
27372
|
+
name: "wp:wrapNone"
|
|
27373
|
+
});
|
|
27374
|
+
}
|
|
27375
|
+
const nodeElements = translateImageNode(params);
|
|
27376
|
+
const inlineAttrs = {
|
|
27377
|
+
...nodeElements.attributes,
|
|
27378
|
+
simplePos: attrs.originalAttributes?.simplePos,
|
|
27379
|
+
relativeHeight: 1,
|
|
27380
|
+
behindDoc: attrs.originalAttributes?.behindDoc,
|
|
27381
|
+
locked: attrs.originalAttributes?.locked,
|
|
27382
|
+
layoutInCell: attrs.originalAttributes?.layoutInCell,
|
|
27383
|
+
allowOverlap: attrs.originalAttributes?.allowOverlap
|
|
27384
|
+
};
|
|
27385
|
+
const effectIndex = nodeElements.elements.findIndex((el) => el.name === "wp:effectExtent");
|
|
27386
|
+
const elementsWithWrap = [
|
|
27387
|
+
...nodeElements.elements.slice(0, effectIndex + 1),
|
|
27388
|
+
...wrapElements,
|
|
27389
|
+
...nodeElements.elements.slice(effectIndex + 1)
|
|
27390
|
+
];
|
|
27391
|
+
return {
|
|
27392
|
+
name: "wp:anchor",
|
|
27393
|
+
attributes: inlineAttrs,
|
|
27394
|
+
elements: [...anchorElements, ...elementsWithWrap]
|
|
27395
|
+
};
|
|
27396
|
+
}
|
|
27397
|
+
const XML_NODE_NAME$5 = "wp:anchor";
|
|
27398
|
+
const SD_NODE_NAME$5 = ["image"];
|
|
27399
|
+
const validXmlAttributes$5 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
27400
|
+
function encode$c(params) {
|
|
27401
|
+
const { node } = params.extraParams;
|
|
27402
|
+
if (!node || !node.type) {
|
|
27403
|
+
return null;
|
|
27404
|
+
}
|
|
27405
|
+
return handleAnchorNode(params);
|
|
27406
|
+
}
|
|
27407
|
+
function decode$c(params) {
|
|
27408
|
+
const { node } = params;
|
|
27409
|
+
if (!node || !node.type) {
|
|
27410
|
+
return null;
|
|
27411
|
+
}
|
|
27412
|
+
return translateAnchorNode(params);
|
|
27413
|
+
}
|
|
27414
|
+
const config$5 = {
|
|
27415
|
+
xmlName: XML_NODE_NAME$5,
|
|
27416
|
+
sdNodeOrKeyName: SD_NODE_NAME$5,
|
|
27417
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
27418
|
+
encode: encode$c,
|
|
27419
|
+
decode: decode$c,
|
|
27420
|
+
attributes: validXmlAttributes$5
|
|
27421
|
+
};
|
|
27422
|
+
const translator$5 = NodeTranslator.from(config$5);
|
|
27423
|
+
function handleInlineNode(params) {
|
|
27424
|
+
const { node } = params.extraParams;
|
|
27425
|
+
if (node.name !== "wp:inline") {
|
|
27426
|
+
return null;
|
|
27427
|
+
}
|
|
27428
|
+
return handleImageNode(node, params, false);
|
|
27429
|
+
}
|
|
27430
|
+
function translateInlineNode(params) {
|
|
27431
|
+
const nodeElements = translateImageNode(params);
|
|
27432
|
+
return {
|
|
27433
|
+
name: "wp:inline",
|
|
27434
|
+
attributes: nodeElements.attributes,
|
|
27435
|
+
elements: nodeElements.elements
|
|
27436
|
+
};
|
|
27437
|
+
}
|
|
27438
|
+
const XML_NODE_NAME$4 = "wp:inline";
|
|
27439
|
+
const SD_NODE_NAME$4 = ["image"];
|
|
27440
|
+
const validXmlAttributes$4 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
27441
|
+
function encode$b(params) {
|
|
27442
|
+
const { node } = params.extraParams;
|
|
27443
|
+
if (!node || !node.type) {
|
|
27444
|
+
return null;
|
|
27445
|
+
}
|
|
27446
|
+
return handleInlineNode(params);
|
|
27447
|
+
}
|
|
27448
|
+
function decode$b(params) {
|
|
27449
|
+
const { node } = params;
|
|
27450
|
+
if (!node || !node.type) {
|
|
27451
|
+
return null;
|
|
27452
|
+
}
|
|
27453
|
+
return translateInlineNode(params);
|
|
27454
|
+
}
|
|
27455
|
+
const config$4 = {
|
|
27456
|
+
xmlName: XML_NODE_NAME$4,
|
|
27457
|
+
sdNodeOrKeyName: SD_NODE_NAME$4,
|
|
27458
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
27459
|
+
encode: encode$b,
|
|
27460
|
+
decode: decode$b,
|
|
27461
|
+
attributes: validXmlAttributes$4
|
|
27462
|
+
};
|
|
27463
|
+
const translator$4 = NodeTranslator.from(config$4);
|
|
27464
|
+
const encode$a = (attributes) => {
|
|
27465
|
+
return attributes["w:id"];
|
|
27466
|
+
};
|
|
27467
|
+
const decode$a = (attrs) => {
|
|
27468
|
+
return attrs.id;
|
|
27469
|
+
};
|
|
27470
|
+
const attrConfig$6 = Object.freeze({
|
|
27471
|
+
xmlName: "w:id",
|
|
27472
|
+
sdName: "id",
|
|
27473
|
+
encode: encode$a,
|
|
27474
|
+
decode: decode$a
|
|
27475
|
+
});
|
|
27476
|
+
const encode$9 = (attributes) => {
|
|
27477
|
+
return attributes["w:name"];
|
|
27478
|
+
};
|
|
27479
|
+
const decode$9 = (attrs) => {
|
|
27480
|
+
return attrs.name;
|
|
27481
|
+
};
|
|
27482
|
+
const attrConfig$5 = Object.freeze({
|
|
27483
|
+
xmlName: "w:name",
|
|
27484
|
+
sdName: "name",
|
|
27485
|
+
encode: encode$9,
|
|
27486
|
+
decode: decode$9
|
|
27487
|
+
});
|
|
27488
|
+
const encode$8 = (attributes) => {
|
|
27489
|
+
return attributes["w:colFirst"];
|
|
27490
|
+
};
|
|
27491
|
+
const decode$8 = (attrs) => {
|
|
27492
|
+
return attrs.colFirst;
|
|
27493
|
+
};
|
|
27494
|
+
const attrConfig$4 = Object.freeze({
|
|
27495
|
+
xmlName: "w:colFirst",
|
|
27496
|
+
sdName: "colFirst",
|
|
27497
|
+
encode: encode$8,
|
|
27498
|
+
decode: decode$8
|
|
27499
|
+
});
|
|
27500
|
+
const encode$7 = (attributes) => {
|
|
27501
|
+
return attributes["w:colLast"];
|
|
27502
|
+
};
|
|
27503
|
+
const decode$7 = (attrs) => {
|
|
27504
|
+
return attrs.colLast;
|
|
27505
|
+
};
|
|
27506
|
+
const attrConfig$3 = Object.freeze({
|
|
27507
|
+
xmlName: "w:colLast",
|
|
27508
|
+
sdName: "colLast",
|
|
27509
|
+
encode: encode$7,
|
|
27510
|
+
decode: decode$7
|
|
27511
|
+
});
|
|
27512
|
+
const encode$6 = (attributes) => {
|
|
27513
|
+
return attributes["w:displacedByCustomXml"];
|
|
27514
|
+
};
|
|
27515
|
+
const decode$6 = (attrs) => {
|
|
27516
|
+
return attrs.displacedByCustomXml;
|
|
27517
|
+
};
|
|
27518
|
+
const attrConfig$2 = Object.freeze({
|
|
27519
|
+
xmlName: "w:displacedByCustomXml",
|
|
27520
|
+
sdName: "displacedByCustomXml",
|
|
27521
|
+
encode: encode$6,
|
|
27522
|
+
decode: decode$6
|
|
27523
|
+
});
|
|
27524
|
+
const validXmlAttributes$3 = [attrConfig$6, attrConfig$5, attrConfig$4, attrConfig$3, attrConfig$2];
|
|
27525
|
+
const XML_NODE_NAME$3 = "w:bookmarkStart";
|
|
27526
|
+
const SD_NODE_NAME$3 = "bookmarkStart";
|
|
27527
|
+
const encode$5 = (params, encodedAttrs = {}) => {
|
|
27528
|
+
return {
|
|
27529
|
+
type: "bookmarkStart",
|
|
27530
|
+
attrs: encodedAttrs
|
|
27531
|
+
};
|
|
27532
|
+
};
|
|
27533
|
+
const decode$5 = (params, decodedAttrs = {}) => {
|
|
27534
|
+
const result = {
|
|
27535
|
+
name: "w:bookmarkStart",
|
|
27536
|
+
elements: []
|
|
27537
|
+
};
|
|
27538
|
+
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
27539
|
+
result.attributes = decodedAttrs;
|
|
27540
|
+
}
|
|
27541
|
+
return result;
|
|
27542
|
+
};
|
|
27543
|
+
const config$3 = {
|
|
27544
|
+
xmlName: XML_NODE_NAME$3,
|
|
27545
|
+
sdNodeOrKeyName: SD_NODE_NAME$3,
|
|
27546
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
27547
|
+
encode: encode$5,
|
|
27548
|
+
decode: decode$5,
|
|
27549
|
+
attributes: validXmlAttributes$3
|
|
27550
|
+
};
|
|
27551
|
+
const translator$3 = NodeTranslator.from(config$3);
|
|
27552
|
+
const encode$4 = (attributes) => {
|
|
27553
|
+
return attributes["w:id"];
|
|
27554
|
+
};
|
|
27555
|
+
const decode$4 = (attrs) => {
|
|
27556
|
+
return attrs.id;
|
|
27557
|
+
};
|
|
27558
|
+
const attrConfig$1 = Object.freeze({
|
|
27559
|
+
xmlName: "w:id",
|
|
27560
|
+
sdName: "id",
|
|
27561
|
+
encode: encode$4,
|
|
27562
|
+
decode: decode$4
|
|
27563
|
+
});
|
|
27564
|
+
const encode$3 = (attributes) => {
|
|
27565
|
+
return attributes["w:displacedByCustomXml"];
|
|
27566
|
+
};
|
|
27567
|
+
const decode$3 = (attrs) => {
|
|
27568
|
+
return attrs.displacedByCustomXml;
|
|
27569
|
+
};
|
|
27570
|
+
const attrConfig = Object.freeze({
|
|
27571
|
+
xmlName: "w:displacedByCustomXml",
|
|
27572
|
+
sdName: "displacedByCustomXml",
|
|
27573
|
+
encode: encode$3,
|
|
27574
|
+
decode: decode$3
|
|
27575
|
+
});
|
|
27576
|
+
const validXmlAttributes$2 = [attrConfig$1, attrConfig];
|
|
27577
|
+
const XML_NODE_NAME$2 = "w:bookmarkEnd";
|
|
27578
|
+
const SD_NODE_NAME$2 = "bookmarkEnd";
|
|
27579
|
+
const encode$2 = (params, encodedAttrs = {}) => {
|
|
27580
|
+
return {
|
|
27581
|
+
type: "bookmarkEnd",
|
|
27582
|
+
attrs: encodedAttrs
|
|
27583
|
+
};
|
|
27584
|
+
};
|
|
27585
|
+
const decode$2 = (params, decodedAttrs = {}) => {
|
|
27586
|
+
const result = {
|
|
27587
|
+
name: "w:bookmarkEnd",
|
|
27588
|
+
elements: []
|
|
27589
|
+
};
|
|
27590
|
+
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
27591
|
+
result.attributes = decodedAttrs;
|
|
27592
|
+
}
|
|
27593
|
+
return result;
|
|
27594
|
+
};
|
|
27595
|
+
const config$2 = {
|
|
27596
|
+
xmlName: XML_NODE_NAME$2,
|
|
27597
|
+
sdNodeOrKeyName: SD_NODE_NAME$2,
|
|
27598
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
27599
|
+
encode: encode$2,
|
|
27600
|
+
decode: decode$2,
|
|
27601
|
+
attributes: validXmlAttributes$2
|
|
27602
|
+
};
|
|
27603
|
+
const translator$2 = NodeTranslator.from(config$2);
|
|
27604
|
+
const registeredHandlers = Object.freeze({
|
|
27605
|
+
"w:br": translator$V,
|
|
27606
|
+
"w:tab": translator$U,
|
|
27607
|
+
"w:p": translator$T,
|
|
27608
|
+
"wp:anchor": translator$5,
|
|
27609
|
+
"wp:inline": translator$4,
|
|
27610
|
+
"w:bookmarkStart": translator$3,
|
|
27611
|
+
"w:bookmarkEnd": translator$2
|
|
27612
|
+
});
|
|
27613
|
+
const XML_NODE_NAME$1 = "w:drawing";
|
|
27614
|
+
const SD_NODE_NAME$1 = [];
|
|
27615
|
+
const validXmlAttributes$1 = [];
|
|
27616
|
+
function encode$1(params) {
|
|
27617
|
+
const nodes = params.nodes;
|
|
27618
|
+
const node = nodes[0];
|
|
27619
|
+
const validChildTranslators = ["wp:anchor", "wp:inline"];
|
|
27620
|
+
return node.elements.reduce((acc, child) => {
|
|
27621
|
+
if (acc) return acc;
|
|
27622
|
+
if (!validChildTranslators.includes(child.name)) return acc;
|
|
27623
|
+
const translator2 = registeredHandlers[child.name];
|
|
27624
|
+
return translator2.encode({ ...params, extraParams: { node: child } }) || acc;
|
|
27625
|
+
}, null);
|
|
27626
|
+
}
|
|
27627
|
+
function decode$1(params) {
|
|
27628
|
+
const { node } = params;
|
|
27629
|
+
if (!node || !node.type) {
|
|
27630
|
+
return null;
|
|
27631
|
+
}
|
|
27632
|
+
const handlerName = node.attrs.isAnchor ? "wp:anchor" : "wp:inline";
|
|
27633
|
+
const resultNode = registeredHandlers[handlerName].decode(params);
|
|
27634
|
+
return wrapTextInRun(
|
|
27635
|
+
{
|
|
27636
|
+
name: "w:drawing",
|
|
27637
|
+
elements: [resultNode]
|
|
27638
|
+
},
|
|
27639
|
+
[]
|
|
27640
|
+
);
|
|
26314
27641
|
}
|
|
27642
|
+
const config$1 = {
|
|
27643
|
+
xmlName: XML_NODE_NAME$1,
|
|
27644
|
+
sdNodeOrKeyName: SD_NODE_NAME$1,
|
|
27645
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
27646
|
+
encode: encode$1,
|
|
27647
|
+
decode: decode$1,
|
|
27648
|
+
attributes: validXmlAttributes$1
|
|
27649
|
+
};
|
|
27650
|
+
const translator$1 = NodeTranslator.from(config$1);
|
|
26315
27651
|
class CommandService {
|
|
26316
27652
|
/**
|
|
26317
27653
|
* @param {import('./commands/types/index.js').CommandServiceOptions} props
|
|
@@ -27649,7 +28985,10 @@ function prepareTextAnnotation(params) {
|
|
|
27649
28985
|
return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params);
|
|
27650
28986
|
}
|
|
27651
28987
|
function prepareImageAnnotation(params, imageSize) {
|
|
27652
|
-
return
|
|
28988
|
+
return translator$1.decode({
|
|
28989
|
+
...params,
|
|
28990
|
+
imageSize
|
|
28991
|
+
});
|
|
27653
28992
|
}
|
|
27654
28993
|
function prepareCheckboxAnnotation(params) {
|
|
27655
28994
|
const {
|
|
@@ -27886,7 +29225,7 @@ function translateStructuredContent(params) {
|
|
|
27886
29225
|
const XML_NODE_NAME = "w:sdt";
|
|
27887
29226
|
const SD_NODE_NAME = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
|
|
27888
29227
|
const validXmlAttributes = [];
|
|
27889
|
-
function encode(params
|
|
29228
|
+
function encode(params) {
|
|
27890
29229
|
const nodes = params.nodes;
|
|
27891
29230
|
const node = nodes[0];
|
|
27892
29231
|
const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
|
|
@@ -27896,7 +29235,7 @@ function encode(params, encodedAttrs) {
|
|
|
27896
29235
|
const result = handler2(params);
|
|
27897
29236
|
return result;
|
|
27898
29237
|
}
|
|
27899
|
-
function decode(params
|
|
29238
|
+
function decode(params) {
|
|
27900
29239
|
const { node } = params;
|
|
27901
29240
|
if (!node || !node.type) {
|
|
27902
29241
|
return null;
|
|
@@ -27927,19 +29266,20 @@ function exportSchemaToJson(params) {
|
|
|
27927
29266
|
doc: translateDocumentNode,
|
|
27928
29267
|
body: translateBodyNode,
|
|
27929
29268
|
heading: translateHeadingNode,
|
|
27930
|
-
paragraph: translator$
|
|
29269
|
+
paragraph: translator$T,
|
|
27931
29270
|
text: translateTextNode,
|
|
27932
29271
|
bulletList: translateList,
|
|
27933
29272
|
orderedList: translateList,
|
|
27934
|
-
lineBreak: translator$
|
|
27935
|
-
table:
|
|
27936
|
-
tableRow: translator$
|
|
27937
|
-
tableCell: translator$
|
|
27938
|
-
bookmarkStart:
|
|
29273
|
+
lineBreak: translator$V,
|
|
29274
|
+
table: translator$8,
|
|
29275
|
+
tableRow: translator$F,
|
|
29276
|
+
tableCell: translator$7,
|
|
29277
|
+
bookmarkStart: translator$3,
|
|
29278
|
+
bookmarkEnd: translator$2,
|
|
27939
29279
|
fieldAnnotation: translator,
|
|
27940
|
-
tab: translator$
|
|
27941
|
-
image:
|
|
27942
|
-
hardBreak: translator$
|
|
29280
|
+
tab: translator$U,
|
|
29281
|
+
image: translator$1,
|
|
29282
|
+
hardBreak: translator$V,
|
|
27943
29283
|
commentRangeStart: () => translateCommentNode(params, "Start"),
|
|
27944
29284
|
commentRangeEnd: () => translateCommentNode(params, "End"),
|
|
27945
29285
|
commentReference: () => null,
|
|
@@ -28271,7 +29611,7 @@ function translateTextNode(params) {
|
|
|
28271
29611
|
const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
|
|
28272
29612
|
if (isTrackedNode) return translateTrackedNode(params);
|
|
28273
29613
|
const isLinkNode = node.marks?.some((m2) => m2.type === "link");
|
|
28274
|
-
if (isLinkNode) return translator$
|
|
29614
|
+
if (isLinkNode) return translator$6.decode(params);
|
|
28275
29615
|
const { text, marks = [] } = node;
|
|
28276
29616
|
return getTextNodeForExport(text, marks, params);
|
|
28277
29617
|
}
|
|
@@ -28404,20 +29744,6 @@ function addNewLinkRelationship(params, link) {
|
|
|
28404
29744
|
});
|
|
28405
29745
|
return newId;
|
|
28406
29746
|
}
|
|
28407
|
-
function addNewImageRelationship(params, imagePath) {
|
|
28408
|
-
const newId = "rId" + generateDocxRandomId();
|
|
28409
|
-
const newRel = {
|
|
28410
|
-
type: "element",
|
|
28411
|
-
name: "Relationship",
|
|
28412
|
-
attributes: {
|
|
28413
|
-
Id: newId,
|
|
28414
|
-
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
28415
|
-
Target: imagePath
|
|
28416
|
-
}
|
|
28417
|
-
};
|
|
28418
|
-
params.relationships.push(newRel);
|
|
28419
|
-
return newId;
|
|
28420
|
-
}
|
|
28421
29747
|
function translateList(params) {
|
|
28422
29748
|
const { node, editor } = params;
|
|
28423
29749
|
const listItem = node.content[0];
|
|
@@ -28560,181 +29886,6 @@ const generateNumPrTag = (numId, level) => {
|
|
|
28560
29886
|
]
|
|
28561
29887
|
};
|
|
28562
29888
|
};
|
|
28563
|
-
function translateTable(params) {
|
|
28564
|
-
params.node = preProcessVerticalMergeCells(params.node, params);
|
|
28565
|
-
const elements = translateChildNodes(params);
|
|
28566
|
-
const tableProperties = generateTableProperties(params.node);
|
|
28567
|
-
const gridProperties = generateTableGrid(params.node, params);
|
|
28568
|
-
elements.unshift(tableProperties);
|
|
28569
|
-
elements.unshift(gridProperties);
|
|
28570
|
-
return {
|
|
28571
|
-
name: "w:tbl",
|
|
28572
|
-
elements
|
|
28573
|
-
};
|
|
28574
|
-
}
|
|
28575
|
-
function preProcessVerticalMergeCells(table, { editorSchema }) {
|
|
28576
|
-
const { content } = table;
|
|
28577
|
-
for (let rowIndex = 0; rowIndex < content.length; rowIndex++) {
|
|
28578
|
-
const row = content[rowIndex];
|
|
28579
|
-
if (!row.content) continue;
|
|
28580
|
-
for (let cellIndex = 0; cellIndex < row.content?.length; cellIndex++) {
|
|
28581
|
-
const cell = row.content[cellIndex];
|
|
28582
|
-
if (!cell) continue;
|
|
28583
|
-
const { attrs } = cell;
|
|
28584
|
-
if (attrs.rowspan > 1) {
|
|
28585
|
-
const rowsToChange = content.slice(rowIndex + 1, rowIndex + attrs.rowspan);
|
|
28586
|
-
const mergedCell = {
|
|
28587
|
-
type: cell.type,
|
|
28588
|
-
content: [
|
|
28589
|
-
// cells must end with a paragraph
|
|
28590
|
-
editorSchema.nodes.paragraph.createAndFill().toJSON()
|
|
28591
|
-
],
|
|
28592
|
-
attrs: {
|
|
28593
|
-
...cell.attrs,
|
|
28594
|
-
// reset colspan and rowspan
|
|
28595
|
-
colspan: null,
|
|
28596
|
-
rowspan: null,
|
|
28597
|
-
// to add vMerge
|
|
28598
|
-
continueMerge: true
|
|
28599
|
-
}
|
|
28600
|
-
};
|
|
28601
|
-
rowsToChange.forEach((rowToChange) => {
|
|
28602
|
-
rowToChange.content.splice(cellIndex, 0, mergedCell);
|
|
28603
|
-
});
|
|
28604
|
-
}
|
|
28605
|
-
}
|
|
28606
|
-
}
|
|
28607
|
-
return table;
|
|
28608
|
-
}
|
|
28609
|
-
function generateTableProperties(node) {
|
|
28610
|
-
const elements = [];
|
|
28611
|
-
const { attrs } = node;
|
|
28612
|
-
const { tableWidth, tableStyleId, borders, tableIndent, tableLayout, tableCellSpacing, justification } = attrs;
|
|
28613
|
-
if (tableStyleId) {
|
|
28614
|
-
const tableStyleElement = {
|
|
28615
|
-
name: "w:tblStyle",
|
|
28616
|
-
attributes: { "w:val": tableStyleId }
|
|
28617
|
-
};
|
|
28618
|
-
elements.push(tableStyleElement);
|
|
28619
|
-
}
|
|
28620
|
-
if (borders) {
|
|
28621
|
-
const borderElement = generateTableBorders(node);
|
|
28622
|
-
elements.push(borderElement);
|
|
28623
|
-
}
|
|
28624
|
-
if (tableIndent) {
|
|
28625
|
-
const { width, type: type2 } = tableIndent;
|
|
28626
|
-
const tableIndentElement = {
|
|
28627
|
-
name: "w:tblInd",
|
|
28628
|
-
attributes: { "w:w": pixelsToTwips(width), "w:type": type2 }
|
|
28629
|
-
};
|
|
28630
|
-
elements.push(tableIndentElement);
|
|
28631
|
-
}
|
|
28632
|
-
if (tableLayout) {
|
|
28633
|
-
const tableLayoutElement = {
|
|
28634
|
-
name: "w:tblLayout",
|
|
28635
|
-
attributes: { "w:type": tableLayout }
|
|
28636
|
-
};
|
|
28637
|
-
elements.push(tableLayoutElement);
|
|
28638
|
-
}
|
|
28639
|
-
if (tableWidth && tableWidth.width) {
|
|
28640
|
-
const tableWidthElement = {
|
|
28641
|
-
name: "w:tblW",
|
|
28642
|
-
attributes: { "w:w": pixelsToTwips(tableWidth.width), "w:type": tableWidth.type }
|
|
28643
|
-
};
|
|
28644
|
-
elements.push(tableWidthElement);
|
|
28645
|
-
}
|
|
28646
|
-
if (tableCellSpacing) {
|
|
28647
|
-
elements.push({
|
|
28648
|
-
name: "w:tblCellSpacing",
|
|
28649
|
-
attributes: {
|
|
28650
|
-
"w:w": tableCellSpacing.w,
|
|
28651
|
-
"w:type": tableCellSpacing.type
|
|
28652
|
-
}
|
|
28653
|
-
});
|
|
28654
|
-
}
|
|
28655
|
-
if (justification) {
|
|
28656
|
-
const justificationElement = {
|
|
28657
|
-
name: "w:jc",
|
|
28658
|
-
attributes: { "w:val": justification }
|
|
28659
|
-
};
|
|
28660
|
-
elements.push(justificationElement);
|
|
28661
|
-
}
|
|
28662
|
-
return {
|
|
28663
|
-
name: "w:tblPr",
|
|
28664
|
-
elements
|
|
28665
|
-
};
|
|
28666
|
-
}
|
|
28667
|
-
function generateTableBorders(node) {
|
|
28668
|
-
const { borders } = node.attrs;
|
|
28669
|
-
const elements = [];
|
|
28670
|
-
if (!borders) return;
|
|
28671
|
-
const borderTypes = ["top", "bottom", "left", "right", "insideH", "insideV"];
|
|
28672
|
-
borderTypes.forEach((type2) => {
|
|
28673
|
-
const border = borders[type2];
|
|
28674
|
-
if (!border) return;
|
|
28675
|
-
let attributes = {};
|
|
28676
|
-
if (!Object.keys(border).length || !border.size) {
|
|
28677
|
-
attributes = {
|
|
28678
|
-
"w:val": "nil"
|
|
28679
|
-
};
|
|
28680
|
-
} else {
|
|
28681
|
-
attributes = {
|
|
28682
|
-
"w:val": "single",
|
|
28683
|
-
"w:sz": pixelsToEightPoints(border.size),
|
|
28684
|
-
"w:space": border.space || 0,
|
|
28685
|
-
"w:color": border?.color?.substring(1) || "000000"
|
|
28686
|
-
};
|
|
28687
|
-
}
|
|
28688
|
-
const borderElement = {
|
|
28689
|
-
name: `w:${type2}`,
|
|
28690
|
-
attributes
|
|
28691
|
-
};
|
|
28692
|
-
elements.push(borderElement);
|
|
28693
|
-
});
|
|
28694
|
-
return {
|
|
28695
|
-
name: "w:tblBorders",
|
|
28696
|
-
elements
|
|
28697
|
-
};
|
|
28698
|
-
}
|
|
28699
|
-
function generateTableGrid(node, params) {
|
|
28700
|
-
const { editorSchema } = params;
|
|
28701
|
-
let colgroup = [];
|
|
28702
|
-
try {
|
|
28703
|
-
const pmNode = editorSchema.nodeFromJSON(node);
|
|
28704
|
-
const cellMinWidth = 10;
|
|
28705
|
-
const { colgroupValues } = createColGroup(pmNode, cellMinWidth);
|
|
28706
|
-
colgroup = colgroupValues;
|
|
28707
|
-
} catch {
|
|
28708
|
-
colgroup = [];
|
|
28709
|
-
}
|
|
28710
|
-
const elements = [];
|
|
28711
|
-
colgroup?.forEach((width) => {
|
|
28712
|
-
elements.push({
|
|
28713
|
-
name: "w:gridCol",
|
|
28714
|
-
attributes: { "w:w": pixelsToTwips(width) }
|
|
28715
|
-
});
|
|
28716
|
-
});
|
|
28717
|
-
return {
|
|
28718
|
-
name: "w:tblGrid",
|
|
28719
|
-
elements
|
|
28720
|
-
};
|
|
28721
|
-
}
|
|
28722
|
-
function translateBookmarkStart(params) {
|
|
28723
|
-
const bookmarkStartNode = {
|
|
28724
|
-
name: "w:bookmarkStart",
|
|
28725
|
-
attributes: {
|
|
28726
|
-
"w:id": params.node.attrs.id,
|
|
28727
|
-
"w:name": params.node.attrs.name
|
|
28728
|
-
}
|
|
28729
|
-
};
|
|
28730
|
-
const bookmarkEndNode = {
|
|
28731
|
-
name: "w:bookmarkEnd",
|
|
28732
|
-
attributes: {
|
|
28733
|
-
"w:id": params.node.attrs.id
|
|
28734
|
-
}
|
|
28735
|
-
};
|
|
28736
|
-
return [bookmarkStartNode, bookmarkEndNode];
|
|
28737
|
-
}
|
|
28738
29889
|
function translateMark(mark) {
|
|
28739
29890
|
const xmlMark = SuperConverter.markTypes.find((m2) => m2.type === mark.type);
|
|
28740
29891
|
if (!xmlMark) {
|
|
@@ -28793,348 +29944,22 @@ function translateMark(mark) {
|
|
|
28793
29944
|
case "textTransform":
|
|
28794
29945
|
if (attrs?.textTransform === "none") {
|
|
28795
29946
|
markElement.attributes["w:val"] = "0";
|
|
28796
|
-
} else {
|
|
28797
|
-
delete markElement.attributes;
|
|
28798
|
-
}
|
|
28799
|
-
markElement.type = "element";
|
|
28800
|
-
break;
|
|
28801
|
-
case "lineHeight":
|
|
28802
|
-
markElement.attributes["w:line"] = linesToTwips(attrs.lineHeight);
|
|
28803
|
-
break;
|
|
28804
|
-
case "highlight":
|
|
28805
|
-
markElement.attributes["w:fill"] = attrs.color?.substring(1);
|
|
28806
|
-
markElement.attributes["w:color"] = "auto";
|
|
28807
|
-
markElement.attributes["w:val"] = "clear";
|
|
28808
|
-
markElement.name = "w:shd";
|
|
28809
|
-
break;
|
|
28810
|
-
}
|
|
28811
|
-
return markElement;
|
|
28812
|
-
}
|
|
28813
|
-
function getPngDimensions(base64) {
|
|
28814
|
-
if (!base64) return {};
|
|
28815
|
-
const type2 = base64.split(";")[0].split("/")[1];
|
|
28816
|
-
if (!base64 || type2 !== "png") {
|
|
28817
|
-
return {
|
|
28818
|
-
originalWidth: void 0,
|
|
28819
|
-
originalHeight: void 0
|
|
28820
|
-
};
|
|
28821
|
-
}
|
|
28822
|
-
let header = base64.split(",")[1].slice(0, 50);
|
|
28823
|
-
let uint8 = Uint8Array.from(atob(header), (c) => c.charCodeAt(0));
|
|
28824
|
-
let dataView = new DataView(uint8.buffer, 0, 28);
|
|
28825
|
-
return {
|
|
28826
|
-
originalWidth: dataView.getInt32(16),
|
|
28827
|
-
originalHeight: dataView.getInt32(20)
|
|
28828
|
-
};
|
|
28829
|
-
}
|
|
28830
|
-
function getScaledSize(originalWidth, originalHeight, maxWidth, maxHeight) {
|
|
28831
|
-
let scaledWidth = originalWidth;
|
|
28832
|
-
let scaledHeight = originalHeight;
|
|
28833
|
-
let ratio = Math.min(maxWidth / originalWidth, maxHeight / originalHeight);
|
|
28834
|
-
scaledWidth = Math.round(scaledWidth * ratio);
|
|
28835
|
-
scaledHeight = Math.round(scaledHeight * ratio);
|
|
28836
|
-
return { scaledWidth, scaledHeight };
|
|
28837
|
-
}
|
|
28838
|
-
function translateImageNode(params, imageSize) {
|
|
28839
|
-
const {
|
|
28840
|
-
node: { attrs = {} },
|
|
28841
|
-
tableCell
|
|
28842
|
-
} = params;
|
|
28843
|
-
let imageId = attrs.rId;
|
|
28844
|
-
const src = attrs.src || attrs.imageSrc;
|
|
28845
|
-
const { originalWidth, originalHeight } = getPngDimensions(src);
|
|
28846
|
-
const imageName = params.node.type === "image" ? src.split("/").pop() : attrs.fieldId?.replace("-", "_");
|
|
28847
|
-
let size = attrs.size ? {
|
|
28848
|
-
w: pixelsToEmu(attrs.size.width),
|
|
28849
|
-
h: pixelsToEmu(attrs.size.height)
|
|
28850
|
-
} : imageSize;
|
|
28851
|
-
if (originalWidth && originalHeight) {
|
|
28852
|
-
const boxWidthPx = emuToPixels(size.w);
|
|
28853
|
-
const boxHeightPx = emuToPixels(size.h);
|
|
28854
|
-
const { scaledWidth, scaledHeight } = getScaledSize(originalWidth, originalHeight, boxWidthPx, boxHeightPx);
|
|
28855
|
-
size = {
|
|
28856
|
-
w: pixelsToEmu(scaledWidth),
|
|
28857
|
-
h: pixelsToEmu(scaledHeight)
|
|
28858
|
-
};
|
|
28859
|
-
}
|
|
28860
|
-
if (tableCell) {
|
|
28861
|
-
const colwidthSum = tableCell.attrs.colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
28862
|
-
const leftMargin = tableCell.attrs.cellMargins?.left || 8;
|
|
28863
|
-
const rightMargin = tableCell.attrs.cellMargins?.right || 8;
|
|
28864
|
-
const maxWidthEmu = pixelsToEmu(colwidthSum - (leftMargin + rightMargin));
|
|
28865
|
-
const { width: w2, height: h2 } = resizeKeepAspectRatio(size.w, size.h, maxWidthEmu);
|
|
28866
|
-
if (w2 && h2) size = { w: w2, h: h2 };
|
|
28867
|
-
}
|
|
28868
|
-
if (params.node.type === "image" && !imageId) {
|
|
28869
|
-
const path = src?.split("word/")[1];
|
|
28870
|
-
imageId = addNewImageRelationship(params, path);
|
|
28871
|
-
} else if (params.node.type === "fieldAnnotation" && !imageId) {
|
|
28872
|
-
const type2 = src?.split(";")[0].split("/")[1];
|
|
28873
|
-
if (!type2) {
|
|
28874
|
-
return prepareTextAnnotation(params);
|
|
28875
|
-
}
|
|
28876
|
-
const imageUrl = `media/${imageName}_${attrs.hash}.${type2}`;
|
|
28877
|
-
imageId = addNewImageRelationship(params, imageUrl);
|
|
28878
|
-
params.media[`${imageName}_${attrs.hash}.${type2}`] = src;
|
|
28879
|
-
}
|
|
28880
|
-
let inlineAttrs = attrs.originalPadding || {
|
|
28881
|
-
distT: 0,
|
|
28882
|
-
distB: 0,
|
|
28883
|
-
distL: 0,
|
|
28884
|
-
distR: 0
|
|
28885
|
-
};
|
|
28886
|
-
const anchorElements = [];
|
|
28887
|
-
let wrapProp = [];
|
|
28888
|
-
if (attrs.isAnchor) {
|
|
28889
|
-
inlineAttrs = {
|
|
28890
|
-
...inlineAttrs,
|
|
28891
|
-
simplePos: attrs.originalAttributes?.simplePos,
|
|
28892
|
-
relativeHeight: 1,
|
|
28893
|
-
behindDoc: attrs.originalAttributes?.behindDoc,
|
|
28894
|
-
locked: attrs.originalAttributes?.locked,
|
|
28895
|
-
layoutInCell: attrs.originalAttributes?.layoutInCell,
|
|
28896
|
-
allowOverlap: attrs.originalAttributes?.allowOverlap
|
|
28897
|
-
};
|
|
28898
|
-
if (attrs.simplePos) {
|
|
28899
|
-
anchorElements.push({
|
|
28900
|
-
name: "wp:simplePos",
|
|
28901
|
-
attributes: {
|
|
28902
|
-
x: 0,
|
|
28903
|
-
y: 0
|
|
28904
|
-
}
|
|
28905
|
-
});
|
|
28906
|
-
}
|
|
28907
|
-
if (attrs.anchorData) {
|
|
28908
|
-
anchorElements.push({
|
|
28909
|
-
name: "wp:positionH",
|
|
28910
|
-
attributes: {
|
|
28911
|
-
relativeFrom: attrs.anchorData.hRelativeFrom
|
|
28912
|
-
},
|
|
28913
|
-
...attrs.marginOffset.left !== void 0 && {
|
|
28914
|
-
elements: [
|
|
28915
|
-
{
|
|
28916
|
-
name: "wp:posOffset",
|
|
28917
|
-
elements: [
|
|
28918
|
-
{
|
|
28919
|
-
type: "text",
|
|
28920
|
-
text: pixelsToEmu(attrs.marginOffset.left).toString()
|
|
28921
|
-
}
|
|
28922
|
-
]
|
|
28923
|
-
}
|
|
28924
|
-
]
|
|
28925
|
-
},
|
|
28926
|
-
...attrs.anchorData.alignH && {
|
|
28927
|
-
elements: [
|
|
28928
|
-
{
|
|
28929
|
-
name: "wp:align",
|
|
28930
|
-
elements: [
|
|
28931
|
-
{
|
|
28932
|
-
type: "text",
|
|
28933
|
-
text: attrs.anchorData.alignH
|
|
28934
|
-
}
|
|
28935
|
-
]
|
|
28936
|
-
}
|
|
28937
|
-
]
|
|
28938
|
-
}
|
|
28939
|
-
});
|
|
28940
|
-
anchorElements.push({
|
|
28941
|
-
name: "wp:positionV",
|
|
28942
|
-
attributes: {
|
|
28943
|
-
relativeFrom: attrs.anchorData.vRelativeFrom
|
|
28944
|
-
},
|
|
28945
|
-
...attrs.marginOffset.top !== void 0 && {
|
|
28946
|
-
elements: [
|
|
28947
|
-
{
|
|
28948
|
-
name: "wp:posOffset",
|
|
28949
|
-
elements: [
|
|
28950
|
-
{
|
|
28951
|
-
type: "text",
|
|
28952
|
-
text: pixelsToEmu(attrs.marginOffset.top).toString()
|
|
28953
|
-
}
|
|
28954
|
-
]
|
|
28955
|
-
}
|
|
28956
|
-
]
|
|
28957
|
-
},
|
|
28958
|
-
...attrs.anchorData.alignV && {
|
|
28959
|
-
elements: [
|
|
28960
|
-
{
|
|
28961
|
-
name: "wp:align",
|
|
28962
|
-
elements: [
|
|
28963
|
-
{
|
|
28964
|
-
type: "text",
|
|
28965
|
-
text: attrs.anchorData.alignV
|
|
28966
|
-
}
|
|
28967
|
-
]
|
|
28968
|
-
}
|
|
28969
|
-
]
|
|
28970
|
-
}
|
|
28971
|
-
});
|
|
28972
|
-
}
|
|
28973
|
-
if (attrs.wrapText) {
|
|
28974
|
-
wrapProp.push({
|
|
28975
|
-
name: "wp:wrapSquare",
|
|
28976
|
-
attributes: {
|
|
28977
|
-
wrapText: attrs.wrapText
|
|
28978
|
-
}
|
|
28979
|
-
});
|
|
28980
|
-
}
|
|
28981
|
-
if (attrs.wrapTopAndBottom) {
|
|
28982
|
-
wrapProp.push({
|
|
28983
|
-
name: "wp:wrapTopAndBottom"
|
|
28984
|
-
});
|
|
28985
|
-
}
|
|
28986
|
-
if (attrs.isAnchor && !wrapProp.length) {
|
|
28987
|
-
wrapProp.push({
|
|
28988
|
-
name: "wp:wrapNone"
|
|
28989
|
-
});
|
|
28990
|
-
}
|
|
29947
|
+
} else {
|
|
29948
|
+
delete markElement.attributes;
|
|
29949
|
+
}
|
|
29950
|
+
markElement.type = "element";
|
|
29951
|
+
break;
|
|
29952
|
+
case "lineHeight":
|
|
29953
|
+
markElement.attributes["w:line"] = linesToTwips(attrs.lineHeight);
|
|
29954
|
+
break;
|
|
29955
|
+
case "highlight":
|
|
29956
|
+
markElement.attributes["w:fill"] = attrs.color?.substring(1);
|
|
29957
|
+
markElement.attributes["w:color"] = "auto";
|
|
29958
|
+
markElement.attributes["w:val"] = "clear";
|
|
29959
|
+
markElement.name = "w:shd";
|
|
29960
|
+
break;
|
|
28991
29961
|
}
|
|
28992
|
-
|
|
28993
|
-
const pictureXmlns = "http://schemas.openxmlformats.org/drawingml/2006/picture";
|
|
28994
|
-
const textNode = wrapTextInRun(
|
|
28995
|
-
{
|
|
28996
|
-
name: "w:drawing",
|
|
28997
|
-
elements: [
|
|
28998
|
-
{
|
|
28999
|
-
name: attrs.isAnchor ? "wp:anchor" : "wp:inline",
|
|
29000
|
-
attributes: inlineAttrs,
|
|
29001
|
-
elements: [
|
|
29002
|
-
...anchorElements,
|
|
29003
|
-
{
|
|
29004
|
-
name: "wp:extent",
|
|
29005
|
-
attributes: {
|
|
29006
|
-
cx: size.w,
|
|
29007
|
-
cy: size.h
|
|
29008
|
-
}
|
|
29009
|
-
},
|
|
29010
|
-
{
|
|
29011
|
-
name: "wp:effectExtent",
|
|
29012
|
-
attributes: {
|
|
29013
|
-
l: 0,
|
|
29014
|
-
t: 0,
|
|
29015
|
-
r: 0,
|
|
29016
|
-
b: 0
|
|
29017
|
-
}
|
|
29018
|
-
},
|
|
29019
|
-
...wrapProp,
|
|
29020
|
-
{
|
|
29021
|
-
name: "wp:docPr",
|
|
29022
|
-
attributes: {
|
|
29023
|
-
id: attrs.id || 0,
|
|
29024
|
-
name: attrs.alt || `Picture ${imageName}`
|
|
29025
|
-
}
|
|
29026
|
-
},
|
|
29027
|
-
{
|
|
29028
|
-
name: "wp:cNvGraphicFramePr",
|
|
29029
|
-
elements: [
|
|
29030
|
-
{
|
|
29031
|
-
name: "a:graphicFrameLocks",
|
|
29032
|
-
attributes: {
|
|
29033
|
-
"xmlns:a": drawingXmlns,
|
|
29034
|
-
noChangeAspect: 1
|
|
29035
|
-
}
|
|
29036
|
-
}
|
|
29037
|
-
]
|
|
29038
|
-
},
|
|
29039
|
-
{
|
|
29040
|
-
name: "a:graphic",
|
|
29041
|
-
attributes: { "xmlns:a": drawingXmlns },
|
|
29042
|
-
elements: [
|
|
29043
|
-
{
|
|
29044
|
-
name: "a:graphicData",
|
|
29045
|
-
attributes: { uri: pictureXmlns },
|
|
29046
|
-
elements: [
|
|
29047
|
-
{
|
|
29048
|
-
name: "pic:pic",
|
|
29049
|
-
attributes: { "xmlns:pic": pictureXmlns },
|
|
29050
|
-
elements: [
|
|
29051
|
-
{
|
|
29052
|
-
name: "pic:nvPicPr",
|
|
29053
|
-
elements: [
|
|
29054
|
-
{
|
|
29055
|
-
name: "pic:cNvPr",
|
|
29056
|
-
attributes: {
|
|
29057
|
-
id: attrs.id || 0,
|
|
29058
|
-
name: attrs.title || `Picture ${imageName}`
|
|
29059
|
-
}
|
|
29060
|
-
},
|
|
29061
|
-
{
|
|
29062
|
-
name: "pic:cNvPicPr",
|
|
29063
|
-
elements: [
|
|
29064
|
-
{
|
|
29065
|
-
name: "a:picLocks",
|
|
29066
|
-
attributes: {
|
|
29067
|
-
noChangeAspect: 1,
|
|
29068
|
-
noChangeArrowheads: 1
|
|
29069
|
-
}
|
|
29070
|
-
}
|
|
29071
|
-
]
|
|
29072
|
-
}
|
|
29073
|
-
]
|
|
29074
|
-
},
|
|
29075
|
-
{
|
|
29076
|
-
name: "pic:blipFill",
|
|
29077
|
-
elements: [
|
|
29078
|
-
{
|
|
29079
|
-
name: "a:blip",
|
|
29080
|
-
attributes: {
|
|
29081
|
-
"r:embed": imageId
|
|
29082
|
-
}
|
|
29083
|
-
},
|
|
29084
|
-
{
|
|
29085
|
-
name: "a:stretch",
|
|
29086
|
-
elements: [{ name: "a:fillRect" }]
|
|
29087
|
-
}
|
|
29088
|
-
]
|
|
29089
|
-
},
|
|
29090
|
-
{
|
|
29091
|
-
name: "pic:spPr",
|
|
29092
|
-
attributes: {
|
|
29093
|
-
bwMode: "auto"
|
|
29094
|
-
},
|
|
29095
|
-
elements: [
|
|
29096
|
-
{
|
|
29097
|
-
name: "a:xfrm",
|
|
29098
|
-
elements: [
|
|
29099
|
-
{
|
|
29100
|
-
name: "a:ext",
|
|
29101
|
-
attributes: {
|
|
29102
|
-
cx: size.w,
|
|
29103
|
-
cy: size.h
|
|
29104
|
-
}
|
|
29105
|
-
},
|
|
29106
|
-
{
|
|
29107
|
-
name: "a:off",
|
|
29108
|
-
attributes: {
|
|
29109
|
-
x: 0,
|
|
29110
|
-
y: 0
|
|
29111
|
-
}
|
|
29112
|
-
}
|
|
29113
|
-
]
|
|
29114
|
-
},
|
|
29115
|
-
{
|
|
29116
|
-
name: "a:prstGeom",
|
|
29117
|
-
attributes: { prst: "rect" },
|
|
29118
|
-
elements: [{ name: "a:avLst" }]
|
|
29119
|
-
},
|
|
29120
|
-
{
|
|
29121
|
-
name: "a:noFill"
|
|
29122
|
-
}
|
|
29123
|
-
]
|
|
29124
|
-
}
|
|
29125
|
-
]
|
|
29126
|
-
}
|
|
29127
|
-
]
|
|
29128
|
-
}
|
|
29129
|
-
]
|
|
29130
|
-
}
|
|
29131
|
-
]
|
|
29132
|
-
}
|
|
29133
|
-
]
|
|
29134
|
-
},
|
|
29135
|
-
[]
|
|
29136
|
-
);
|
|
29137
|
-
return textNode;
|
|
29962
|
+
return markElement;
|
|
29138
29963
|
}
|
|
29139
29964
|
function translateShapeContainer(params) {
|
|
29140
29965
|
const { node } = params;
|
|
@@ -29313,14 +30138,6 @@ generateXml_fn = function(node) {
|
|
|
29313
30138
|
if (!selfClosing) tags.push(`</${name}>`);
|
|
29314
30139
|
return tags;
|
|
29315
30140
|
};
|
|
29316
|
-
function resizeKeepAspectRatio(width, height, maxWidth) {
|
|
29317
|
-
if (width > maxWidth) {
|
|
29318
|
-
let scale = maxWidth / width;
|
|
29319
|
-
let newHeight = Math.round(height * scale);
|
|
29320
|
-
return { width: maxWidth, height: newHeight };
|
|
29321
|
-
}
|
|
29322
|
-
return { width, height };
|
|
29323
|
-
}
|
|
29324
30141
|
const translatePageNumberNode = (params) => {
|
|
29325
30142
|
const outputMarks = processOutputMarks(params.node.attrs?.marksAsAttrs || []);
|
|
29326
30143
|
return getAutoPageJson("PAGE", outputMarks);
|
|
@@ -29404,7 +30221,7 @@ const getInitialJSON = (parsedDocx, fallbackXml = defaultInitialXml) => {
|
|
|
29404
30221
|
return parsedDocx["word/document.xml"] || parseXmlToJson(fallbackXml);
|
|
29405
30222
|
};
|
|
29406
30223
|
const handleDrawingNode = (params) => {
|
|
29407
|
-
const { nodes
|
|
30224
|
+
const { nodes } = params;
|
|
29408
30225
|
const validNodes = ["w:drawing", "w:p"];
|
|
29409
30226
|
if (nodes.length === 0 || !validNodes.includes(nodes[0].name)) {
|
|
29410
30227
|
return { nodes: [], consumed: 0 };
|
|
@@ -29414,167 +30231,9 @@ const handleDrawingNode = (params) => {
|
|
|
29414
30231
|
if (mainNode.name === "w:drawing") node = mainNode;
|
|
29415
30232
|
else node = mainNode.elements.find((el) => el.name === "w:drawing");
|
|
29416
30233
|
if (!node) return { nodes: [], consumed: 0 };
|
|
29417
|
-
|
|
29418
|
-
const
|
|
29419
|
-
|
|
29420
|
-
const isAnchor = elements.find((el) => el.name === "wp:anchor");
|
|
29421
|
-
if (isAnchor) {
|
|
29422
|
-
result = handleImageImport(elements[0], currentFileName, params);
|
|
29423
|
-
if (result && result.attrs) result.attrs.isAnchor = isAnchor;
|
|
29424
|
-
}
|
|
29425
|
-
const inlineImage = elements.find((el) => el.name === "wp:inline");
|
|
29426
|
-
if (inlineImage) result = handleImageImport(inlineImage, currentFileName, params);
|
|
29427
|
-
return { nodes: result ? [result] : [], consumed: 1 };
|
|
29428
|
-
};
|
|
29429
|
-
function handleImageImport(node, currentFileName, params) {
|
|
29430
|
-
const { docx } = params;
|
|
29431
|
-
const { attributes } = node;
|
|
29432
|
-
const padding = {
|
|
29433
|
-
top: emuToPixels(attributes["distT"]),
|
|
29434
|
-
bottom: emuToPixels(attributes["distB"]),
|
|
29435
|
-
left: emuToPixels(attributes["distL"]),
|
|
29436
|
-
right: emuToPixels(attributes["distR"])
|
|
29437
|
-
};
|
|
29438
|
-
const extent = node.elements.find((el) => el.name === "wp:extent");
|
|
29439
|
-
const size = {
|
|
29440
|
-
width: emuToPixels(extent.attributes?.cx),
|
|
29441
|
-
height: emuToPixels(extent.attributes?.cy)
|
|
29442
|
-
};
|
|
29443
|
-
const graphic = node.elements.find((el) => el.name === "a:graphic");
|
|
29444
|
-
const graphicData = graphic.elements.find((el) => el.name === "a:graphicData");
|
|
29445
|
-
const { uri: uri2 } = graphicData?.attributes || {};
|
|
29446
|
-
const shapeURI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
29447
|
-
if (!!uri2 && uri2 === shapeURI) {
|
|
29448
|
-
return handleShapeDrawing(params, node, graphicData);
|
|
29449
|
-
}
|
|
29450
|
-
const picture = graphicData.elements.find((el) => el.name === "pic:pic");
|
|
29451
|
-
if (!picture || !picture.elements) return null;
|
|
29452
|
-
const blipFill = picture.elements.find((el) => el.name === "pic:blipFill");
|
|
29453
|
-
const blip = blipFill.elements.find((el) => el.name === "a:blip");
|
|
29454
|
-
const positionHTag = node.elements.find((el) => el.name === "wp:positionH");
|
|
29455
|
-
const positionH = positionHTag?.elements.find((el) => el.name === "wp:posOffset");
|
|
29456
|
-
const positionHValue = emuToPixels(positionH?.elements[0]?.text);
|
|
29457
|
-
const hRelativeFrom = positionHTag?.attributes.relativeFrom;
|
|
29458
|
-
const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
29459
|
-
const positionVTag = node.elements.find((el) => el.name === "wp:positionV");
|
|
29460
|
-
const positionV = positionVTag?.elements?.find((el) => el.name === "wp:posOffset");
|
|
29461
|
-
const positionVValue = emuToPixels(positionV?.elements[0]?.text);
|
|
29462
|
-
const vRelativeFrom = positionVTag?.attributes.relativeFrom;
|
|
29463
|
-
const alignV = positionVTag?.elements?.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
29464
|
-
const simplePos = node.elements.find((el) => el.name === "wp:simplePos");
|
|
29465
|
-
const wrapSquare = node.elements.find((el) => el.name === "wp:wrapSquare");
|
|
29466
|
-
const wrapTopAndBottom = node.elements.find((el) => el.name === "wp:wrapTopAndBottom");
|
|
29467
|
-
const docPr = node.elements.find((el) => el.name === "wp:docPr");
|
|
29468
|
-
let anchorData = null;
|
|
29469
|
-
if (hRelativeFrom || alignH || vRelativeFrom || alignV) {
|
|
29470
|
-
anchorData = {
|
|
29471
|
-
hRelativeFrom,
|
|
29472
|
-
vRelativeFrom,
|
|
29473
|
-
alignH,
|
|
29474
|
-
alignV
|
|
29475
|
-
};
|
|
29476
|
-
}
|
|
29477
|
-
const marginOffset = {
|
|
29478
|
-
left: positionHValue,
|
|
29479
|
-
top: positionVValue
|
|
29480
|
-
};
|
|
29481
|
-
const { attributes: blipAttributes = {} } = blip;
|
|
29482
|
-
const rEmbed = blipAttributes["r:embed"];
|
|
29483
|
-
if (!rEmbed) return null;
|
|
29484
|
-
const currentFile = currentFileName || "document.xml";
|
|
29485
|
-
let rels = docx[`word/_rels/${currentFile}.rels`];
|
|
29486
|
-
if (!rels) rels = docx[`word/_rels/document.xml.rels`];
|
|
29487
|
-
const relationships = rels.elements.find((el) => el.name === "Relationships");
|
|
29488
|
-
const { elements } = relationships;
|
|
29489
|
-
const rel = elements.find((el) => el.attributes["Id"] === rEmbed);
|
|
29490
|
-
if (!rel) return null;
|
|
29491
|
-
const { attributes: relAttributes } = rel;
|
|
29492
|
-
const targetPath = relAttributes["Target"];
|
|
29493
|
-
let path = `word/${targetPath}`;
|
|
29494
|
-
if (targetPath.startsWith("/word") || targetPath.startsWith("/media")) path = targetPath.substring(1);
|
|
29495
|
-
const extension = targetPath.substring(targetPath.lastIndexOf(".") + 1);
|
|
29496
|
-
return {
|
|
29497
|
-
type: "image",
|
|
29498
|
-
attrs: {
|
|
29499
|
-
src: path,
|
|
29500
|
-
alt: ["emf", "wmf"].includes(extension) ? "Unable to render EMF/WMF image" : docPr?.attributes.name || "Image",
|
|
29501
|
-
extension,
|
|
29502
|
-
id: docPr?.attributes.id || "",
|
|
29503
|
-
title: docPr?.attributes.descr || "Image",
|
|
29504
|
-
inline: true,
|
|
29505
|
-
padding,
|
|
29506
|
-
marginOffset,
|
|
29507
|
-
size,
|
|
29508
|
-
anchorData,
|
|
29509
|
-
...simplePos && {
|
|
29510
|
-
simplePos: {
|
|
29511
|
-
x: simplePos.attributes.x,
|
|
29512
|
-
y: simplePos.attributes.y
|
|
29513
|
-
}
|
|
29514
|
-
},
|
|
29515
|
-
...wrapSquare && {
|
|
29516
|
-
wrapText: wrapSquare.attributes.wrapText
|
|
29517
|
-
},
|
|
29518
|
-
wrapTopAndBottom: !!wrapTopAndBottom,
|
|
29519
|
-
originalPadding: {
|
|
29520
|
-
distT: attributes["distT"],
|
|
29521
|
-
distB: attributes["distB"],
|
|
29522
|
-
distL: attributes["distL"],
|
|
29523
|
-
distR: attributes["distR"]
|
|
29524
|
-
},
|
|
29525
|
-
originalAttributes: node.attributes,
|
|
29526
|
-
rId: relAttributes["Id"]
|
|
29527
|
-
}
|
|
29528
|
-
};
|
|
29529
|
-
}
|
|
29530
|
-
const handleShapeDrawing = (params, node, graphicData) => {
|
|
29531
|
-
const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
|
|
29532
|
-
const textBox = wsp.elements.find((el) => el.name === "wps:txbx");
|
|
29533
|
-
const textBoxContent = textBox?.elements?.find((el) => el.name === "w:txbxContent");
|
|
29534
|
-
node.elements.find((el) => el.name === "wp:docPr");
|
|
29535
|
-
const spPr = wsp.elements.find((el) => el.name === "wps:spPr");
|
|
29536
|
-
const prstGeom = spPr?.elements.find((el) => el.name === "a:prstGeom");
|
|
29537
|
-
if (!!prstGeom && prstGeom.attributes["prst"] === "rect" && !textBoxContent) {
|
|
29538
|
-
return getRectangleShape(params, spPr);
|
|
29539
|
-
}
|
|
29540
|
-
if (!textBoxContent) {
|
|
29541
|
-
return null;
|
|
29542
|
-
}
|
|
29543
|
-
const { nodeListHandler } = params;
|
|
29544
|
-
const translatedElement = nodeListHandler.handler({
|
|
29545
|
-
...params,
|
|
29546
|
-
node: textBoxContent.elements[0],
|
|
29547
|
-
nodes: textBoxContent.elements,
|
|
29548
|
-
path: [...params.path || [], textBoxContent]
|
|
29549
|
-
});
|
|
29550
|
-
return translatedElement[0];
|
|
29551
|
-
};
|
|
29552
|
-
const getRectangleShape = (params, node) => {
|
|
29553
|
-
const schemaAttrs = {};
|
|
29554
|
-
const [drawingNode] = params.nodes;
|
|
29555
|
-
if (drawingNode?.name === "w:drawing") {
|
|
29556
|
-
schemaAttrs.drawingContent = drawingNode;
|
|
29557
|
-
}
|
|
29558
|
-
const xfrm = node.elements.find((el) => el.name === "a:xfrm");
|
|
29559
|
-
const start = xfrm.elements.find((el) => el.name === "a:off");
|
|
29560
|
-
const size = xfrm.elements.find((el) => el.name === "a:ext");
|
|
29561
|
-
const solidFill = node.elements.find((el) => el.name === "a:solidFill");
|
|
29562
|
-
node.elements.find((el) => el.name === "a:ln");
|
|
29563
|
-
const rectangleSize = {
|
|
29564
|
-
top: emuToPixels(start.attributes["y"]),
|
|
29565
|
-
left: emuToPixels(start.attributes["x"]),
|
|
29566
|
-
width: emuToPixels(size.attributes["cx"]),
|
|
29567
|
-
height: emuToPixels(size.attributes["cy"])
|
|
29568
|
-
};
|
|
29569
|
-
schemaAttrs.size = rectangleSize;
|
|
29570
|
-
const background = solidFill?.elements[0]?.attributes["val"];
|
|
29571
|
-
if (background) {
|
|
29572
|
-
schemaAttrs.background = "#" + background;
|
|
29573
|
-
}
|
|
29574
|
-
return {
|
|
29575
|
-
type: "contentBlock",
|
|
29576
|
-
attrs: schemaAttrs
|
|
29577
|
-
};
|
|
30234
|
+
const schemaNode = translator$1.encode(params);
|
|
30235
|
+
const newNodes = schemaNode ? [schemaNode] : [];
|
|
30236
|
+
return { nodes: newNodes, consumed: 1 };
|
|
29578
30237
|
};
|
|
29579
30238
|
const drawingNodeHandlerEntity = {
|
|
29580
30239
|
handlerName: "drawingNodeHandler",
|
|
@@ -29674,7 +30333,7 @@ const trackChangeNodeHandlerEntity = {
|
|
|
29674
30333
|
handlerName: "trackChangeNodeHandler",
|
|
29675
30334
|
handler: handleTrackChangeNode
|
|
29676
30335
|
};
|
|
29677
|
-
const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$
|
|
30336
|
+
const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$6);
|
|
29678
30337
|
const handleRunNode = (params) => {
|
|
29679
30338
|
const { nodes, nodeListHandler, parentStyleId, docx } = params;
|
|
29680
30339
|
if (nodes.length === 0 || nodes[0].name !== "w:r") {
|
|
@@ -29786,7 +30445,7 @@ const handleParagraphNode = (params) => {
|
|
|
29786
30445
|
if (nodes.length === 0 || nodes[0].name !== "w:p") {
|
|
29787
30446
|
return { nodes: [], consumed: 0 };
|
|
29788
30447
|
}
|
|
29789
|
-
const schemaNode = translator$
|
|
30448
|
+
const schemaNode = translator$T.encode(params);
|
|
29790
30449
|
const newNodes = schemaNode ? [schemaNode] : [];
|
|
29791
30450
|
return { nodes: newNodes, consumed: 1 };
|
|
29792
30451
|
};
|
|
@@ -29889,7 +30548,7 @@ const handler = (params) => {
|
|
|
29889
30548
|
if (nodes.length === 0 || nodes[0].name !== "w:br") {
|
|
29890
30549
|
return { nodes: [], consumed: 0 };
|
|
29891
30550
|
}
|
|
29892
|
-
const result = translator$
|
|
30551
|
+
const result = translator$V.encode(params);
|
|
29893
30552
|
if (!result) return { nodes: [], consumed: 0 };
|
|
29894
30553
|
return {
|
|
29895
30554
|
nodes: [result],
|
|
@@ -29900,62 +30559,31 @@ const lineBreakNodeHandlerEntity = {
|
|
|
29900
30559
|
handlerName: "lineBreakNodeHandler",
|
|
29901
30560
|
handler
|
|
29902
30561
|
};
|
|
29903
|
-
const
|
|
29904
|
-
const { nodes
|
|
29905
|
-
if (nodes.length
|
|
30562
|
+
const handleBookmarkStartNode = (params) => {
|
|
30563
|
+
const { nodes } = params;
|
|
30564
|
+
if (!nodes.length || nodes[0].name !== "w:bookmarkStart") {
|
|
29906
30565
|
return { nodes: [], consumed: 0 };
|
|
29907
30566
|
}
|
|
29908
|
-
const node =
|
|
29909
|
-
|
|
29910
|
-
|
|
29911
|
-
|
|
29912
|
-
|
|
29913
|
-
|
|
30567
|
+
const node = translator$3.encode(params);
|
|
30568
|
+
if (!node) return { nodes: [], consumed: 0 };
|
|
30569
|
+
return { nodes: [node], consumed: 1 };
|
|
30570
|
+
};
|
|
30571
|
+
const bookmarkStartNodeHandlerEntity = {
|
|
30572
|
+
handlerName: "w:bookmarkStartTranslator",
|
|
30573
|
+
handler: handleBookmarkStartNode
|
|
30574
|
+
};
|
|
30575
|
+
const handleBookmarkEndNode = (params) => {
|
|
30576
|
+
const { nodes } = params;
|
|
30577
|
+
if (!nodes.length || nodes[0].name !== "w:bookmarkEnd") {
|
|
29914
30578
|
return { nodes: [], consumed: 0 };
|
|
29915
30579
|
}
|
|
29916
|
-
const
|
|
29917
|
-
|
|
29918
|
-
|
|
29919
|
-
if (customMark) {
|
|
29920
|
-
const bookmarkEndIndex = nodes.findIndex(
|
|
29921
|
-
(n) => n.name === "w:bookmarkEnd" && n.attributes["w:id"] === node.attributes["w:id"]
|
|
29922
|
-
);
|
|
29923
|
-
const textNodes = nodes.slice(1, bookmarkEndIndex);
|
|
29924
|
-
const nodeListHandler2 = params.nodeListHandler;
|
|
29925
|
-
const attrs = {};
|
|
29926
|
-
node.attributes["w:name"].split(";").forEach((name) => {
|
|
29927
|
-
const [key, value] = name.split("=");
|
|
29928
|
-
if (key && value) {
|
|
29929
|
-
attrs[key] = value;
|
|
29930
|
-
}
|
|
29931
|
-
});
|
|
29932
|
-
const translatedText = nodeListHandler2.handler({
|
|
29933
|
-
...params,
|
|
29934
|
-
nodes: textNodes,
|
|
29935
|
-
path: [...params.path || [], node]
|
|
29936
|
-
});
|
|
29937
|
-
translatedText.forEach((n) => {
|
|
29938
|
-
n.marks.push({
|
|
29939
|
-
type: customMark.name,
|
|
29940
|
-
attrs
|
|
29941
|
-
});
|
|
29942
|
-
});
|
|
29943
|
-
return {
|
|
29944
|
-
nodes: translatedText,
|
|
29945
|
-
consumed: translatedText.length + 2
|
|
29946
|
-
};
|
|
29947
|
-
}
|
|
29948
|
-
const updatedParams = { ...params, nodes: [node] };
|
|
29949
|
-
const result = handleStandardNode2(updatedParams);
|
|
29950
|
-
if (result.nodes.length === 1) {
|
|
29951
|
-
result.nodes[0].attrs.name = node.attributes["w:name"];
|
|
29952
|
-
result.nodes[0].attrs.id = node.attributes["w:id"];
|
|
29953
|
-
}
|
|
29954
|
-
return result;
|
|
30580
|
+
const node = translator$2.encode(params);
|
|
30581
|
+
if (!node) return { nodes: [], consumed: 0 };
|
|
30582
|
+
return { nodes: [node], consumed: 1 };
|
|
29955
30583
|
};
|
|
29956
|
-
const
|
|
29957
|
-
handlerName: "
|
|
29958
|
-
handler:
|
|
30584
|
+
const bookmarkEndNodeHandlerEntity = {
|
|
30585
|
+
handlerName: "w:bookmarkEndTranslator",
|
|
30586
|
+
handler: handleBookmarkEndNode
|
|
29959
30587
|
};
|
|
29960
30588
|
const handleAlternateChoice = (params) => {
|
|
29961
30589
|
const skipHandlerResponse = { nodes: [], consumed: 0 };
|
|
@@ -30585,7 +31213,7 @@ const handleTabNode = (params) => {
|
|
|
30585
31213
|
if (!nodes.length || nodes[0].name !== "w:tab") {
|
|
30586
31214
|
return { nodes: [], consumed: 0 };
|
|
30587
31215
|
}
|
|
30588
|
-
const node = translator$
|
|
31216
|
+
const node = translator$U.encode(params);
|
|
30589
31217
|
return { nodes: [node], consumed: 1 };
|
|
30590
31218
|
};
|
|
30591
31219
|
const tabNodeEntityHandler = {
|
|
@@ -30668,7 +31296,8 @@ const defaultNodeListHandler = () => {
|
|
|
30668
31296
|
textNodeHandlerEntity,
|
|
30669
31297
|
lineBreakNodeHandlerEntity,
|
|
30670
31298
|
sdtNodeHandlerEntity,
|
|
30671
|
-
|
|
31299
|
+
bookmarkStartNodeHandlerEntity,
|
|
31300
|
+
bookmarkEndNodeHandlerEntity,
|
|
30672
31301
|
hyperlinkNodeHandlerEntity,
|
|
30673
31302
|
drawingNodeHandlerEntity,
|
|
30674
31303
|
trackChangeNodeHandlerEntity,
|
|
@@ -30890,8 +31519,8 @@ function addDefaultStylesIfMissing(styles) {
|
|
|
30890
31519
|
}
|
|
30891
31520
|
const importHeadersFooters = (docx, converter, mainEditor) => {
|
|
30892
31521
|
const rels = docx["word/_rels/document.xml.rels"];
|
|
30893
|
-
const relationships = rels
|
|
30894
|
-
const { elements } = relationships;
|
|
31522
|
+
const relationships = rels?.elements.find((el) => el.name === "Relationships");
|
|
31523
|
+
const { elements } = relationships || { elements: [] };
|
|
30895
31524
|
const headerType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header";
|
|
30896
31525
|
const footerType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";
|
|
30897
31526
|
const headers = elements.filter((el) => el.attributes["Type"] === headerType);
|
|
@@ -31665,15 +32294,12 @@ export {
|
|
|
31665
32294
|
createDocFromMarkdown as a7,
|
|
31666
32295
|
createDocFromHTML as a8,
|
|
31667
32296
|
EditorState as a9,
|
|
31668
|
-
|
|
31669
|
-
|
|
31670
|
-
|
|
31671
|
-
|
|
31672
|
-
|
|
31673
|
-
|
|
31674
|
-
translator$i as aG,
|
|
31675
|
-
translator$j as aH,
|
|
31676
|
-
_sfc_main as aI,
|
|
32297
|
+
getActiveFormatting as aA,
|
|
32298
|
+
readFromClipboard as aB,
|
|
32299
|
+
handleClipboardPaste as aC,
|
|
32300
|
+
getFileObject as aD,
|
|
32301
|
+
_sfc_main as aE,
|
|
32302
|
+
registeredHandlers as aF,
|
|
31677
32303
|
hasSomeParentWithClass as aa,
|
|
31678
32304
|
isActive as ab,
|
|
31679
32305
|
unflattenListsInHtml as ac,
|
|
@@ -31688,18 +32314,18 @@ export {
|
|
|
31688
32314
|
parseIndentElement as al,
|
|
31689
32315
|
combineIndents as am,
|
|
31690
32316
|
StepMap as an,
|
|
31691
|
-
|
|
31692
|
-
|
|
31693
|
-
|
|
31694
|
-
|
|
31695
|
-
|
|
31696
|
-
|
|
31697
|
-
|
|
31698
|
-
|
|
31699
|
-
|
|
31700
|
-
|
|
31701
|
-
|
|
31702
|
-
|
|
32317
|
+
SelectionRange as ao,
|
|
32318
|
+
Transform as ap,
|
|
32319
|
+
isInTable as aq,
|
|
32320
|
+
generateDocxRandomId as ar,
|
|
32321
|
+
insertNewRelationship as as,
|
|
32322
|
+
updateDOMAttributes as at,
|
|
32323
|
+
htmlHandler as au,
|
|
32324
|
+
commonjsGlobal as av,
|
|
32325
|
+
getDefaultExportFromCjs$1 as aw,
|
|
32326
|
+
getContentTypesFromXml as ax,
|
|
32327
|
+
xmljs as ay,
|
|
32328
|
+
vClickOutside as az,
|
|
31703
32329
|
Slice as b,
|
|
31704
32330
|
DOMParser$1 as c,
|
|
31705
32331
|
Mark as d,
|