@harbour-enterprises/superdoc 0.20.0-next.14 → 0.20.0-next.2
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/README.md +4 -4
- package/dist/chunks/{PdfViewer-D-erp24R.cjs → PdfViewer-B6adMXJl.cjs} +1 -1
- package/dist/chunks/{PdfViewer-_NPRPRHl.es.js → PdfViewer-_tL5RYr9.es.js} +1 -1
- package/dist/chunks/{index-dMbV_syB.es.js → index-DwXeHvLq.es.js} +3 -3
- package/dist/chunks/{index-duHcNiwD.cjs → index-mjjKSLDT.cjs} +3 -3
- package/dist/chunks/{super-editor.es-BKurmwFy.es.js → super-editor.es-CPrd1wq8.es.js} +2520 -3569
- package/dist/chunks/{super-editor.es-ly_a915J.cjs → super-editor.es-DJHyk0Zs.cjs} +2520 -3569
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/style.css +0 -38
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-Brf9NxwA.js → converter-KHB8spG5.js} +1151 -1825
- package/dist/super-editor/chunks/{docx-zipper-Dld3TtPb.js → docx-zipper-B-vl4ISA.js} +1 -1
- package/dist/super-editor/chunks/{editor-N0dhAC41.js → editor-Df2sUgT0.js} +1020 -1384
- package/dist/super-editor/chunks/{toolbar-CXinz1gO.js → toolbar-C6JoUIM_.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/src/core/helpers/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/exporter.d.ts +1 -7
- package/dist/super-editor/src/core/super-converter/helpers.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v2/importer/bookmarkNodeImporter.d.ts +0 -5
- package/dist/super-editor/src/core/super-converter/v2/importer/imageImporter.d.ts +1 -1
- package/dist/super-editor/src/core/super-converter/v2/importer/tableImporter.d.ts +22 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/index.d.ts +0 -4
- package/dist/super-editor/src/core/super-converter/v3/handlers/utils.d.ts +3 -10
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/w-p-helpers.d.ts +1 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/legacy-handle-table-cell-node.d.ts +1 -1
- package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +1 -11
- package/dist/super-editor/src/extensions/block-node/block-node.d.ts +5 -30
- package/dist/super-editor/src/extensions/bold/bold.d.ts +0 -20
- package/dist/super-editor/src/extensions/bookmarks/index.d.ts +1 -2
- package/dist/super-editor/src/extensions/bullet-list/bullet-list.d.ts +0 -12
- package/dist/super-editor/src/extensions/color/color.d.ts +0 -26
- package/dist/super-editor/src/extensions/content-block/content-block.d.ts +0 -30
- package/dist/super-editor/src/extensions/custom-selection/custom-selection.d.ts +0 -16
- package/dist/super-editor/src/extensions/document/document.d.ts +0 -26
- package/dist/super-editor/src/extensions/dropcursor/dropcursor.d.ts +0 -26
- package/dist/super-editor/src/extensions/font-family/font-family.d.ts +0 -29
- package/dist/super-editor/src/extensions/font-size/font-size.d.ts +0 -21
- package/dist/super-editor/src/extensions/format-commands/format-commands.d.ts +0 -9
- package/dist/super-editor/src/extensions/gapcursor/gapcursor.d.ts +0 -9
- package/dist/super-editor/src/extensions/heading/heading.d.ts +6 -12
- package/dist/super-editor/src/extensions/highlight/highlight.d.ts +0 -20
- package/dist/super-editor/src/extensions/history/history.d.ts +15 -7
- package/dist/super-editor/src/extensions/image/image.d.ts +0 -78
- package/dist/super-editor/src/extensions/image/imageHelpers/imagePlaceholderPlugin.d.ts +5 -0
- package/dist/super-editor/src/extensions/image/imageHelpers/index.d.ts +1 -3
- package/dist/super-editor/src/extensions/image/imageHelpers/processUploadedImage.d.ts +2 -2
- package/dist/super-editor/src/extensions/image/imageHelpers/startImageUpload.d.ts +23 -18
- package/dist/super-editor/src/extensions/index.d.ts +1 -2
- package/dist/super-editor/src/extensions/italic/italic.d.ts +0 -10
- package/dist/super-editor/src/extensions/line-break/line-break.d.ts +0 -43
- package/dist/super-editor/src/extensions/line-height/line-height.d.ts +0 -22
- package/dist/super-editor/src/extensions/link/link.d.ts +25 -53
- package/dist/super-editor/src/extensions/linked-styles/linked-styles.d.ts +0 -9
- package/dist/super-editor/src/extensions/list-item/list-item.d.ts +0 -48
- package/dist/super-editor/src/extensions/mention/mention.d.ts +0 -26
- package/dist/super-editor/src/extensions/noderesizer/noderesizer.d.ts +0 -14
- package/dist/super-editor/src/extensions/ordered-list/ordered-list.d.ts +0 -35
- package/dist/super-editor/src/extensions/page-number/page-number.d.ts +0 -52
- package/dist/super-editor/src/extensions/paragraph/paragraph.d.ts +0 -49
- package/dist/super-editor/src/extensions/placeholder/placeholder.d.ts +0 -15
- package/dist/super-editor/src/extensions/popover-plugin/popover-plugin.d.ts +0 -9
- package/dist/super-editor/src/extensions/run-item/run-item.d.ts +0 -24
- package/dist/super-editor/src/extensions/search/search.d.ts +2 -11
- package/dist/super-editor/src/extensions/shape-container/shape-container.d.ts +0 -29
- package/dist/super-editor/src/extensions/shape-textbox/shape-textbox.d.ts +0 -26
- package/dist/super-editor/src/extensions/slash-menu/slash-menu.d.ts +0 -9
- package/dist/super-editor/src/extensions/strike/strike.d.ts +0 -10
- package/dist/super-editor/src/extensions/structured-content/document-section.d.ts +27 -46
- package/dist/super-editor/src/extensions/structured-content/structured-content-block.d.ts +1 -29
- package/dist/super-editor/src/extensions/structured-content/structured-content.d.ts +1 -29
- package/dist/super-editor/src/extensions/tab/tab.d.ts +0 -25
- package/dist/super-editor/src/extensions/table/table.d.ts +55 -376
- package/dist/super-editor/src/extensions/table-cell/table-cell.d.ts +0 -41
- package/dist/super-editor/src/extensions/table-header/table-header.d.ts +0 -22
- package/dist/super-editor/src/extensions/table-row/table-row.d.ts +0 -28
- package/dist/super-editor/src/extensions/text/text.d.ts +0 -14
- package/dist/super-editor/src/extensions/text-align/text-align.d.ts +0 -22
- package/dist/super-editor/src/extensions/text-indent/text-indent.d.ts +10 -19
- package/dist/super-editor/src/extensions/text-style/text-style.d.ts +0 -20
- package/dist/super-editor/src/extensions/text-transform/text-transform.d.ts +0 -20
- package/dist/super-editor/src/extensions/underline/underline.d.ts +0 -25
- package/dist/super-editor/style.css +0 -38
- package/dist/super-editor/super-editor.es.js +55 -65
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +3149 -4198
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +4 -7
- package/dist/super-editor/src/core/helpers/updateDOMAttributes.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v2/importer/bookmarkEndImporter.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v2/importer/bookmarkStartImporter.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bidiVisual/bidiVisual-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bidiVisual/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-end/attributes/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-end/attributes/w-displaced-by-custom-xml.d.ts +0 -4
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-end/attributes/w-id.d.ts +0 -4
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-end/bookmark-end-translator.d.ts +0 -7
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-end/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/w-col-first.d.ts +0 -4
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/w-col-last.d.ts +0 -4
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/w-displaced-by-custom-xml.d.ts +0 -4
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/w-id.d.ts +0 -4
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/w-name.d.ts +0 -4
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/bookmark-start-translator.d.ts +0 -7
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/bottom-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/marginBottom-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/drawing/drawing-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/drawing/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/end-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/marginEnd-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/gridCol/gridCol-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/gridCol/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideH/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideH/insideH-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideV/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideV/insideV-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/left-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/marginLeft-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/marginRight-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/right-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/shd/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/shd/shd-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/marginStart-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/start-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tbl/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tbl/tbl-translator.d.ts +0 -28
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblBorders/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblBorders/tblBorders-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCaption/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCaption/tblCaption-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCellMar/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCellMar/tblCellMar-translator.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblDescription/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblDescription/tblDescription-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-helpers.d.ts +0 -5
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-translator.d.ts +0 -5
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblInd/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblInd/tblInd-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLayout/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLayout/tblLayout-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLook/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLook/tblLook-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblOverlap/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblOverlap/tblOverlap-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblPr/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblPr/tblPr-translator.d.ts +0 -5
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyle/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyle/tblStyle-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleColBandSize/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleColBandSize/tblStyleColBandSize-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleRowBandSize/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleRowBandSize/tblStyleRowBandSize-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblW/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblW/tblW-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblpPr/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblpPr/tblpPr-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/marginTop-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/top-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/anchor-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/handle-anchor-node.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/translate-anchor-node.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/decode-image-node-helpers.d.ts +0 -18
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/encode-image-node-helpers.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/helpers/handle-inline-node.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/helpers/translate-inline-node.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/inline-translator.d.ts +0 -6
- package/dist/super-editor/src/extensions/bookmarks/bookmark-end.d.ts +0 -6
- package/dist/super-editor/src/extensions/image/imageHelpers/fileNameUtils.d.ts +0 -3
- package/dist/super-editor/src/extensions/image/imageHelpers/handleBase64.d.ts +0 -1
- package/dist/super-editor/src/extensions/image/imageHelpers/handleUrl.d.ts +0 -2
- package/dist/super-editor/src/extensions/image/imageHelpers/imageRegistrationPlugin.d.ts +0 -11
- package/dist/super-editor/src/extensions/image/imageHelpers/rotation.d.ts +0 -4
- package/dist/super-editor/src/extensions/structured-content/StructuredContentBlockView.d.ts +0 -9
- package/dist/super-editor/src/extensions/structured-content/StructuredContentInlineView.d.ts +0 -9
- package/dist/super-editor/src/extensions/structured-content/StructuredContentViewBase.d.ts +0 -24
- package/dist/super-editor/src/tests/helpers/editor-test-utils.d.ts +0 -14
- /package/dist/super-editor/src/extensions/bookmarks/{bookmark-start.d.ts → bookmarks.d.ts} +0 -0
|
@@ -14779,25 +14779,22 @@ async function readFromClipboard(state2) {
|
|
|
14779
14779
|
function inchesToTwips(inches) {
|
|
14780
14780
|
if (inches == null) return;
|
|
14781
14781
|
if (typeof inches === "string") inches = parseFloat(inches);
|
|
14782
|
-
return Math.round(
|
|
14782
|
+
return Math.round(inches * 1440);
|
|
14783
14783
|
}
|
|
14784
14784
|
function twipsToInches(twips) {
|
|
14785
14785
|
if (twips == null) return;
|
|
14786
|
-
|
|
14787
|
-
|
|
14788
|
-
return value / 1440;
|
|
14786
|
+
if (typeof twips === "string") twips = parseInt(twips, 10);
|
|
14787
|
+
return Math.round(twips / 1440 * 100) / 100;
|
|
14789
14788
|
}
|
|
14790
14789
|
function twipsToPixels(twips) {
|
|
14791
14790
|
if (twips == null) return;
|
|
14792
|
-
|
|
14793
|
-
|
|
14794
|
-
const pixels = inches * 96;
|
|
14795
|
-
return Math.round(pixels * 1e3) / 1e3;
|
|
14791
|
+
twips = twipsToInches(twips);
|
|
14792
|
+
return Math.round(twips * 96);
|
|
14796
14793
|
}
|
|
14797
14794
|
function pixelsToTwips(pixels) {
|
|
14798
14795
|
if (pixels == null) return;
|
|
14799
|
-
|
|
14800
|
-
return inchesToTwips(
|
|
14796
|
+
pixels = pixels / 96;
|
|
14797
|
+
return inchesToTwips(pixels);
|
|
14801
14798
|
}
|
|
14802
14799
|
function twipsToLines(twips) {
|
|
14803
14800
|
if (twips == null) return;
|
|
@@ -14840,14 +14837,6 @@ function ptToTwips(pt) {
|
|
|
14840
14837
|
if (pt == null) return;
|
|
14841
14838
|
return pt * 20;
|
|
14842
14839
|
}
|
|
14843
|
-
function rotToDegrees(rot) {
|
|
14844
|
-
if (rot == null) return;
|
|
14845
|
-
return rot / 6e4;
|
|
14846
|
-
}
|
|
14847
|
-
function degreesToRot(degrees) {
|
|
14848
|
-
if (degrees == null) return;
|
|
14849
|
-
return degrees * 6e4;
|
|
14850
|
-
}
|
|
14851
14840
|
const getTextIndentExportValue = (indent) => {
|
|
14852
14841
|
const [value, unit] = parseSizeUnit(indent);
|
|
14853
14842
|
const functionsMap = {
|
|
@@ -16403,6 +16392,41 @@ const prepareCommentsXmlFilesForExport = ({ convertedXml, defs, commentsWithPara
|
|
|
16403
16392
|
documentXml: updatedXml
|
|
16404
16393
|
};
|
|
16405
16394
|
};
|
|
16395
|
+
const getColStyleDeclaration = (minWidth, width) => {
|
|
16396
|
+
if (width) {
|
|
16397
|
+
return ["width", `${Math.max(width, minWidth)}px`];
|
|
16398
|
+
}
|
|
16399
|
+
return ["min-width", `${minWidth}px`];
|
|
16400
|
+
};
|
|
16401
|
+
const createColGroup = (node, cellMinWidth, overrideCol, overrideValue) => {
|
|
16402
|
+
let totalWidth = 0;
|
|
16403
|
+
let fixedWidth = true;
|
|
16404
|
+
const cols = [];
|
|
16405
|
+
const colsValues = [];
|
|
16406
|
+
const row = node.firstChild;
|
|
16407
|
+
if (!row) return {};
|
|
16408
|
+
for (let i = 0, col = 0; i < row.childCount; i++) {
|
|
16409
|
+
const { colspan, colwidth } = row.child(i).attrs;
|
|
16410
|
+
for (let j2 = 0; j2 < colspan; j2++, col++) {
|
|
16411
|
+
const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j2];
|
|
16412
|
+
totalWidth += hasWidth || cellMinWidth;
|
|
16413
|
+
if (!hasWidth) fixedWidth = false;
|
|
16414
|
+
const [prop, value] = getColStyleDeclaration(cellMinWidth, hasWidth);
|
|
16415
|
+
cols.push(["col", { style: `${prop}: ${value}` }]);
|
|
16416
|
+
colsValues.push(parseInt(value, 10));
|
|
16417
|
+
}
|
|
16418
|
+
}
|
|
16419
|
+
const tableWidth = fixedWidth ? `${totalWidth}px` : "";
|
|
16420
|
+
const tableMinWidth = fixedWidth ? "" : `${totalWidth}px`;
|
|
16421
|
+
const colgroup = ["colgroup", {}, ...cols];
|
|
16422
|
+
const colgroupValues = [...colsValues];
|
|
16423
|
+
return {
|
|
16424
|
+
colgroup,
|
|
16425
|
+
tableWidth,
|
|
16426
|
+
tableMinWidth,
|
|
16427
|
+
colgroupValues
|
|
16428
|
+
};
|
|
16429
|
+
};
|
|
16406
16430
|
const lower16 = 65535;
|
|
16407
16431
|
const factor16 = Math.pow(2, 16);
|
|
16408
16432
|
function makeRecover(index, offset) {
|
|
@@ -21347,7 +21371,7 @@ const isInTable = (state2) => {
|
|
|
21347
21371
|
};
|
|
21348
21372
|
function stripHtmlStyles(html) {
|
|
21349
21373
|
if (!html) return "";
|
|
21350
|
-
const parser = new
|
|
21374
|
+
const parser = new DOMParser();
|
|
21351
21375
|
const doc2 = parser.parseFromString(html, "text/html");
|
|
21352
21376
|
const SUPPORTED_ATTRS = [
|
|
21353
21377
|
"href",
|
|
@@ -21366,7 +21390,7 @@ function stripHtmlStyles(html) {
|
|
|
21366
21390
|
"styleid"
|
|
21367
21391
|
];
|
|
21368
21392
|
const cleanNode = (node) => {
|
|
21369
|
-
if (node.nodeType !==
|
|
21393
|
+
if (node.nodeType !== Node.ELEMENT_NODE) return;
|
|
21370
21394
|
[...node.attributes].forEach((attr) => {
|
|
21371
21395
|
const name = attr.name.toLowerCase();
|
|
21372
21396
|
const shouldKeep = SUPPORTED_ATTRS.includes(name) || name.startsWith("data-");
|
|
@@ -22509,23 +22533,6 @@ function processContent({ content, type: type2, schema }) {
|
|
|
22509
22533
|
}
|
|
22510
22534
|
return doc2;
|
|
22511
22535
|
}
|
|
22512
|
-
const defaultBooleans = ["required", "readonly", "disabled", "checked", "multiple", "autofocus"];
|
|
22513
|
-
function updateDOMAttributes(dom, attrs = {}, options = {}) {
|
|
22514
|
-
const customBooleans = options.customBooleans || [];
|
|
22515
|
-
const booleans = [...defaultBooleans, ...customBooleans];
|
|
22516
|
-
Object.entries(attrs).forEach(([key, value]) => {
|
|
22517
|
-
if (booleans.includes(key)) {
|
|
22518
|
-
if (!value) dom.removeAttribute(key);
|
|
22519
|
-
else dom.setAttribute(key, "");
|
|
22520
|
-
return;
|
|
22521
|
-
}
|
|
22522
|
-
if (value != null) {
|
|
22523
|
-
dom.setAttribute(key, value);
|
|
22524
|
-
} else {
|
|
22525
|
-
dom.removeAttribute(key);
|
|
22526
|
-
}
|
|
22527
|
-
});
|
|
22528
|
-
}
|
|
22529
22536
|
const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
22530
22537
|
__proto__: null,
|
|
22531
22538
|
chainableEditorState,
|
|
@@ -22558,8 +22565,7 @@ const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
22558
22565
|
isNodeActive,
|
|
22559
22566
|
isTextSelection,
|
|
22560
22567
|
posToDOMRect,
|
|
22561
|
-
processContent
|
|
22562
|
-
updateDOMAttributes
|
|
22568
|
+
processContent
|
|
22563
22569
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
22564
22570
|
const generateNewListDefinition = ({ numId, listType, level, start, text, fmt, editor }) => {
|
|
22565
22571
|
if (typeof listType === "string") listType = editor.schema.nodes[listType];
|
|
@@ -24172,6 +24178,58 @@ const baseNumbering = {
|
|
|
24172
24178
|
}
|
|
24173
24179
|
]
|
|
24174
24180
|
};
|
|
24181
|
+
const sanitizeDocxMediaName = (value, fallback = "image") => {
|
|
24182
|
+
if (!value) return fallback;
|
|
24183
|
+
const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
24184
|
+
return sanitized || fallback;
|
|
24185
|
+
};
|
|
24186
|
+
const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
|
|
24187
|
+
if (!src || typeof src !== "string") return fallback;
|
|
24188
|
+
const [prefix] = src.split(";");
|
|
24189
|
+
const [, maybeType] = prefix.split("/");
|
|
24190
|
+
const extension = maybeType?.toLowerCase();
|
|
24191
|
+
return extension ? `${fallback}.${extension}` : fallback;
|
|
24192
|
+
};
|
|
24193
|
+
function preProcessVerticalMergeCells(table, { editorSchema }) {
|
|
24194
|
+
if (!table || !Array.isArray(table.content)) {
|
|
24195
|
+
return table;
|
|
24196
|
+
}
|
|
24197
|
+
const rows = table.content;
|
|
24198
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
24199
|
+
const row = rows[rowIndex];
|
|
24200
|
+
if (!row) continue;
|
|
24201
|
+
if (!Array.isArray(row.content)) {
|
|
24202
|
+
row.content = [];
|
|
24203
|
+
}
|
|
24204
|
+
for (let cellIndex = 0; cellIndex < row.content.length; cellIndex++) {
|
|
24205
|
+
const cell = row.content[cellIndex];
|
|
24206
|
+
if (!cell) continue;
|
|
24207
|
+
const attrs = cell.attrs || {};
|
|
24208
|
+
if (!attrs.rowspan || attrs.rowspan <= 1) continue;
|
|
24209
|
+
const maxRowspan = Math.min(attrs.rowspan, rows.length - rowIndex);
|
|
24210
|
+
for (let offset = 1; offset < maxRowspan; offset++) {
|
|
24211
|
+
const rowToChange = rows[rowIndex + offset];
|
|
24212
|
+
if (!rowToChange) continue;
|
|
24213
|
+
if (!Array.isArray(rowToChange.content)) {
|
|
24214
|
+
rowToChange.content = [];
|
|
24215
|
+
}
|
|
24216
|
+
const existingCell = rowToChange.content[cellIndex];
|
|
24217
|
+
if (existingCell?.attrs?.continueMerge) continue;
|
|
24218
|
+
const mergedCell = {
|
|
24219
|
+
type: cell.type,
|
|
24220
|
+
content: [editorSchema.nodes.paragraph.createAndFill().toJSON()],
|
|
24221
|
+
attrs: {
|
|
24222
|
+
...cell.attrs,
|
|
24223
|
+
rowspan: null,
|
|
24224
|
+
continueMerge: true
|
|
24225
|
+
}
|
|
24226
|
+
};
|
|
24227
|
+
rowToChange.content.splice(cellIndex, 0, mergedCell);
|
|
24228
|
+
}
|
|
24229
|
+
}
|
|
24230
|
+
}
|
|
24231
|
+
return table;
|
|
24232
|
+
}
|
|
24175
24233
|
const TranslatorTypes = Object.freeze({
|
|
24176
24234
|
NODE: "node",
|
|
24177
24235
|
ATTRIBUTE: "attribute"
|
|
@@ -24301,37 +24359,37 @@ const _NodeTranslator = class _NodeTranslator {
|
|
|
24301
24359
|
/** @type {typeof TranslatorTypes} */
|
|
24302
24360
|
__publicField(_NodeTranslator, "translatorTypes", TranslatorTypes);
|
|
24303
24361
|
let NodeTranslator = _NodeTranslator;
|
|
24304
|
-
const encode$
|
|
24362
|
+
const encode$j = (attributes) => {
|
|
24305
24363
|
return attributes["w:type"];
|
|
24306
24364
|
};
|
|
24307
|
-
const decode$
|
|
24365
|
+
const decode$j = (attrs) => {
|
|
24308
24366
|
const { lineBreakType } = attrs;
|
|
24309
24367
|
return lineBreakType;
|
|
24310
24368
|
};
|
|
24311
|
-
const attrConfig$
|
|
24369
|
+
const attrConfig$b = Object.freeze({
|
|
24312
24370
|
xmlName: "w:type",
|
|
24313
24371
|
sdName: "lineBreakType",
|
|
24314
|
-
encode: encode$
|
|
24315
|
-
decode: decode$
|
|
24372
|
+
encode: encode$j,
|
|
24373
|
+
decode: decode$j
|
|
24316
24374
|
});
|
|
24317
|
-
const encode$
|
|
24375
|
+
const encode$i = (attributes) => {
|
|
24318
24376
|
const xmlAttrValue = attributes["w:clear"];
|
|
24319
24377
|
return xmlAttrValue;
|
|
24320
24378
|
};
|
|
24321
|
-
const decode$
|
|
24379
|
+
const decode$i = (attrs) => {
|
|
24322
24380
|
const { clear } = attrs;
|
|
24323
24381
|
return clear;
|
|
24324
24382
|
};
|
|
24325
|
-
const attrConfig$
|
|
24383
|
+
const attrConfig$a = Object.freeze({
|
|
24326
24384
|
xmlName: "w:clear",
|
|
24327
24385
|
sdName: "clear",
|
|
24328
|
-
encode: encode$
|
|
24329
|
-
decode: decode$
|
|
24386
|
+
encode: encode$i,
|
|
24387
|
+
decode: decode$i
|
|
24330
24388
|
});
|
|
24331
|
-
const validXmlAttributes$
|
|
24332
|
-
const XML_NODE_NAME$
|
|
24333
|
-
const SD_NODE_NAME$
|
|
24334
|
-
const encode$
|
|
24389
|
+
const validXmlAttributes$6 = [attrConfig$b, attrConfig$a];
|
|
24390
|
+
const XML_NODE_NAME$7 = "w:br";
|
|
24391
|
+
const SD_NODE_NAME$6 = "lineBreak";
|
|
24392
|
+
const encode$h = (_2, encodedAttrs) => {
|
|
24335
24393
|
const isPageBreak = encodedAttrs?.lineBreakType === "page";
|
|
24336
24394
|
const translated = {
|
|
24337
24395
|
type: isPageBreak ? "hardBreak" : "lineBreak"
|
|
@@ -24341,7 +24399,7 @@ const encode$y = (_2, encodedAttrs) => {
|
|
|
24341
24399
|
}
|
|
24342
24400
|
return translated;
|
|
24343
24401
|
};
|
|
24344
|
-
const decode$
|
|
24402
|
+
const decode$h = (params, decodedAttrs) => {
|
|
24345
24403
|
const { node } = params;
|
|
24346
24404
|
if (!node) return;
|
|
24347
24405
|
const wBreak = { name: "w:br" };
|
|
@@ -24358,63 +24416,63 @@ const decode$y = (params, decodedAttrs) => {
|
|
|
24358
24416
|
};
|
|
24359
24417
|
return translated;
|
|
24360
24418
|
};
|
|
24361
|
-
const config$
|
|
24362
|
-
xmlName: XML_NODE_NAME$
|
|
24363
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
24419
|
+
const config$7 = {
|
|
24420
|
+
xmlName: XML_NODE_NAME$7,
|
|
24421
|
+
sdNodeOrKeyName: SD_NODE_NAME$6,
|
|
24364
24422
|
type: NodeTranslator.translatorTypes.NODE,
|
|
24365
|
-
encode: encode$
|
|
24366
|
-
decode: decode$
|
|
24367
|
-
attributes: validXmlAttributes$
|
|
24423
|
+
encode: encode$h,
|
|
24424
|
+
decode: decode$h,
|
|
24425
|
+
attributes: validXmlAttributes$6
|
|
24368
24426
|
};
|
|
24369
|
-
const translator$
|
|
24370
|
-
const encode$
|
|
24427
|
+
const translator$j = NodeTranslator.from(config$7);
|
|
24428
|
+
const encode$g = (attributes) => {
|
|
24371
24429
|
return attributes["w:val"];
|
|
24372
24430
|
};
|
|
24373
|
-
const decode$
|
|
24431
|
+
const decode$g = (attrs) => {
|
|
24374
24432
|
const { tabSize } = attrs || {};
|
|
24375
24433
|
return tabSize;
|
|
24376
24434
|
};
|
|
24377
|
-
const attrConfig$
|
|
24435
|
+
const attrConfig$9 = Object.freeze({
|
|
24378
24436
|
xmlName: "w:val",
|
|
24379
24437
|
sdName: "tabSize",
|
|
24380
|
-
encode: encode$
|
|
24381
|
-
decode: decode$
|
|
24438
|
+
encode: encode$g,
|
|
24439
|
+
decode: decode$g
|
|
24382
24440
|
});
|
|
24383
|
-
const encode$
|
|
24441
|
+
const encode$f = (attributes) => {
|
|
24384
24442
|
return attributes["w:leader"];
|
|
24385
24443
|
};
|
|
24386
|
-
const decode$
|
|
24444
|
+
const decode$f = (attrs) => {
|
|
24387
24445
|
const { leader } = attrs || {};
|
|
24388
24446
|
return leader;
|
|
24389
24447
|
};
|
|
24390
|
-
const attrConfig$
|
|
24448
|
+
const attrConfig$8 = Object.freeze({
|
|
24391
24449
|
xmlName: "w:leader",
|
|
24392
24450
|
sdName: "leader",
|
|
24393
|
-
encode: encode$
|
|
24394
|
-
decode: decode$
|
|
24451
|
+
encode: encode$f,
|
|
24452
|
+
decode: decode$f
|
|
24395
24453
|
});
|
|
24396
|
-
const encode$
|
|
24454
|
+
const encode$e = (attributes) => {
|
|
24397
24455
|
return attributes["w:pos"];
|
|
24398
24456
|
};
|
|
24399
|
-
const decode$
|
|
24457
|
+
const decode$e = (attrs) => {
|
|
24400
24458
|
const { pos } = attrs || {};
|
|
24401
24459
|
return pos;
|
|
24402
24460
|
};
|
|
24403
|
-
const attrConfig$
|
|
24461
|
+
const attrConfig$7 = Object.freeze({
|
|
24404
24462
|
xmlName: "w:pos",
|
|
24405
24463
|
sdName: "pos",
|
|
24406
|
-
encode: encode$
|
|
24407
|
-
decode: decode$
|
|
24464
|
+
encode: encode$e,
|
|
24465
|
+
decode: decode$e
|
|
24408
24466
|
});
|
|
24409
|
-
const validXmlAttributes$
|
|
24410
|
-
const XML_NODE_NAME$
|
|
24411
|
-
const SD_NODE_NAME$
|
|
24412
|
-
const encode$
|
|
24467
|
+
const validXmlAttributes$5 = [attrConfig$9, attrConfig$7, attrConfig$8];
|
|
24468
|
+
const XML_NODE_NAME$6 = "w:tab";
|
|
24469
|
+
const SD_NODE_NAME$5 = "tab";
|
|
24470
|
+
const encode$d = (_2, encodedAttrs = {}) => {
|
|
24413
24471
|
const translated = { type: "tab" };
|
|
24414
24472
|
if (encodedAttrs) translated.attrs = { ...encodedAttrs };
|
|
24415
24473
|
return translated;
|
|
24416
24474
|
};
|
|
24417
|
-
const decode$
|
|
24475
|
+
const decode$d = (params, decodedAttrs = {}) => {
|
|
24418
24476
|
const { node } = params || {};
|
|
24419
24477
|
if (!node) return;
|
|
24420
24478
|
const wTab = { name: "w:tab" };
|
|
@@ -24430,15 +24488,15 @@ const decode$u = (params, decodedAttrs = {}) => {
|
|
|
24430
24488
|
}
|
|
24431
24489
|
return translated;
|
|
24432
24490
|
};
|
|
24433
|
-
const config$
|
|
24434
|
-
xmlName: XML_NODE_NAME$
|
|
24435
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
24491
|
+
const config$6 = {
|
|
24492
|
+
xmlName: XML_NODE_NAME$6,
|
|
24493
|
+
sdNodeOrKeyName: SD_NODE_NAME$5,
|
|
24436
24494
|
type: NodeTranslator.translatorTypes.NODE,
|
|
24437
|
-
encode: encode$
|
|
24438
|
-
decode: decode$
|
|
24439
|
-
attributes: validXmlAttributes$
|
|
24495
|
+
encode: encode$d,
|
|
24496
|
+
decode: decode$d,
|
|
24497
|
+
attributes: validXmlAttributes$5
|
|
24440
24498
|
};
|
|
24441
|
-
const translator$
|
|
24499
|
+
const translator$i = NodeTranslator.from(config$6);
|
|
24442
24500
|
const mergeTextNodes = (nodes) => {
|
|
24443
24501
|
if (!nodes || !Array.isArray(nodes)) {
|
|
24444
24502
|
return nodes;
|
|
@@ -24702,15 +24760,13 @@ const getParagraphIndent = (node, docx, styleId = "") => {
|
|
|
24702
24760
|
}
|
|
24703
24761
|
return indent;
|
|
24704
24762
|
};
|
|
24705
|
-
const getParagraphSpacing = (node, docx, styleId = "", marks = []
|
|
24706
|
-
const { insideTable = false } = options;
|
|
24763
|
+
const getParagraphSpacing = (node, docx, styleId = "", marks = []) => {
|
|
24707
24764
|
const spacing = {};
|
|
24708
|
-
const { spacing: pDefaultSpacing = {}
|
|
24765
|
+
const { spacing: pDefaultSpacing = {} } = getDefaultParagraphStyle(docx, styleId);
|
|
24709
24766
|
let lineSpaceAfter, lineSpaceBefore, line, lineRuleStyle;
|
|
24710
24767
|
const pPr = node.elements?.find((el) => el.name === "w:pPr");
|
|
24711
24768
|
const inLineSpacingTag = pPr?.elements?.find((el) => el.name === "w:spacing");
|
|
24712
24769
|
const inLineSpacing = inLineSpacingTag?.attributes || {};
|
|
24713
|
-
const hasInlineSpacing = !!Object.keys(inLineSpacing).length;
|
|
24714
24770
|
const textStyleMark = marks.find((el) => el.type === "textStyle");
|
|
24715
24771
|
const fontSize = textStyleMark?.attrs?.fontSize;
|
|
24716
24772
|
const lineSpacing = inLineSpacing?.["w:line"] || line || pDefaultSpacing?.["w:line"];
|
|
@@ -24732,12 +24788,6 @@ const getParagraphSpacing = (node, docx, styleId = "", marks = [], options = {})
|
|
|
24732
24788
|
if (afterAutospacing === "1" && fontSize) {
|
|
24733
24789
|
spacing.lineSpaceAfter += Math.round(parseInt(fontSize) * 0.5 * 96 / 72);
|
|
24734
24790
|
}
|
|
24735
|
-
if (insideTable && !hasInlineSpacing && spacingSource === "docDefault") {
|
|
24736
|
-
const hasExplicitSpacing = Object.keys(inLineSpacing).length > 0;
|
|
24737
|
-
if (!hasExplicitSpacing) {
|
|
24738
|
-
return void 0;
|
|
24739
|
-
}
|
|
24740
|
-
}
|
|
24741
24791
|
return spacing;
|
|
24742
24792
|
};
|
|
24743
24793
|
const getDefaultParagraphStyle = (docx, styleId = "") => {
|
|
@@ -24778,20 +24828,9 @@ const getDefaultParagraphStyle = (docx, styleId = "") => {
|
|
|
24778
24828
|
const { attributes: pPrByIdIndentAttr } = pPrStyleIdIndentTag;
|
|
24779
24829
|
const spacingRest = isNormalAsDefault ? pPrNormalSpacingAttr || pPrDefaultSpacingAttr : pPrDefaultSpacingAttr || pPrNormalSpacingAttr;
|
|
24780
24830
|
const indentRest = isNormalAsDefault ? pPrNormalIndentAttr || pPrDefaultIndentAttr : pPrDefaultIndentAttr || pPrNormalIndentAttr;
|
|
24781
|
-
let spacingToUse = pPrByIdSpacingAttr || spacingRest;
|
|
24782
|
-
let spacingSource = "docDefault";
|
|
24783
|
-
if (pPrByIdSpacingAttr) {
|
|
24784
|
-
spacingSource = "style";
|
|
24785
|
-
} else if (spacingRest === pPrNormalSpacingAttr && pPrNormalSpacingAttr) {
|
|
24786
|
-
spacingSource = isNormalAsDefault ? "docDefault" : "normal";
|
|
24787
|
-
} else if (spacingRest === pPrDefaultSpacingAttr && pPrDefaultSpacingAttr) {
|
|
24788
|
-
spacingSource = "docDefault";
|
|
24789
|
-
}
|
|
24790
|
-
let indentToUse = pPrByIdIndentAttr || indentRest;
|
|
24791
24831
|
return {
|
|
24792
|
-
spacing:
|
|
24793
|
-
|
|
24794
|
-
indent: indentToUse,
|
|
24832
|
+
spacing: pPrByIdSpacingAttr || spacingRest,
|
|
24833
|
+
indent: pPrByIdIndentAttr || indentRest,
|
|
24795
24834
|
justify: pPrByIdJcAttr
|
|
24796
24835
|
};
|
|
24797
24836
|
};
|
|
@@ -24966,13 +25005,7 @@ const handleParagraphNode$1 = (params) => {
|
|
|
24966
25005
|
}
|
|
24967
25006
|
if (docx) {
|
|
24968
25007
|
const defaultStyleId = node.attributes?.["w:rsidRDefault"];
|
|
24969
|
-
|
|
24970
|
-
const spacing = getParagraphSpacing(node, docx, styleId, schemaNode.attrs.marksAttrs, {
|
|
24971
|
-
insideTable
|
|
24972
|
-
});
|
|
24973
|
-
if (spacing) {
|
|
24974
|
-
schemaNode.attrs["spacing"] = spacing;
|
|
24975
|
-
}
|
|
25008
|
+
schemaNode.attrs["spacing"] = getParagraphSpacing(node, docx, styleId, schemaNode.attrs.marksAttrs);
|
|
24976
25009
|
schemaNode.attrs["rsidRDefault"] = defaultStyleId;
|
|
24977
25010
|
}
|
|
24978
25011
|
if (docx) {
|
|
@@ -25033,102 +25066,102 @@ const handleParagraphNode$1 = (params) => {
|
|
|
25033
25066
|
}
|
|
25034
25067
|
return schemaNode;
|
|
25035
25068
|
};
|
|
25036
|
-
const encode$
|
|
25069
|
+
const encode$c = (attributes) => {
|
|
25037
25070
|
return attributes["w:rsidDel"];
|
|
25038
25071
|
};
|
|
25039
|
-
const decode$
|
|
25072
|
+
const decode$c = (attrs) => {
|
|
25040
25073
|
return attrs.rsidDel;
|
|
25041
25074
|
};
|
|
25042
|
-
const attrConfig$
|
|
25075
|
+
const attrConfig$6 = Object.freeze({
|
|
25043
25076
|
xmlName: "w:rsidDel",
|
|
25044
25077
|
sdName: "rsidDel",
|
|
25045
|
-
encode: encode$
|
|
25046
|
-
decode: decode$
|
|
25078
|
+
encode: encode$c,
|
|
25079
|
+
decode: decode$c
|
|
25047
25080
|
});
|
|
25048
|
-
const encode$
|
|
25081
|
+
const encode$b = (attributes) => {
|
|
25049
25082
|
return attributes["w:rsidP"];
|
|
25050
25083
|
};
|
|
25051
|
-
const decode$
|
|
25084
|
+
const decode$b = (attrs) => {
|
|
25052
25085
|
return attrs.rsidP;
|
|
25053
25086
|
};
|
|
25054
|
-
const attrConfig$
|
|
25087
|
+
const attrConfig$5 = Object.freeze({
|
|
25055
25088
|
xmlName: "w:rsidP",
|
|
25056
25089
|
sdName: "rsidP",
|
|
25057
|
-
encode: encode$
|
|
25058
|
-
decode: decode$
|
|
25090
|
+
encode: encode$b,
|
|
25091
|
+
decode: decode$b
|
|
25059
25092
|
});
|
|
25060
|
-
const encode$
|
|
25093
|
+
const encode$a = (attributes) => {
|
|
25061
25094
|
return attributes["w:rsidR"];
|
|
25062
25095
|
};
|
|
25063
|
-
const decode$
|
|
25096
|
+
const decode$a = (attrs) => {
|
|
25064
25097
|
return attrs.rsidR;
|
|
25065
25098
|
};
|
|
25066
|
-
const attrConfig$
|
|
25099
|
+
const attrConfig$4 = Object.freeze({
|
|
25067
25100
|
xmlName: "w:rsidR",
|
|
25068
25101
|
sdName: "rsidR",
|
|
25069
|
-
encode: encode$
|
|
25070
|
-
decode: decode$
|
|
25102
|
+
encode: encode$a,
|
|
25103
|
+
decode: decode$a
|
|
25071
25104
|
});
|
|
25072
|
-
const encode$
|
|
25105
|
+
const encode$9 = (attributes) => {
|
|
25073
25106
|
return attributes["w:rsidRPr"];
|
|
25074
25107
|
};
|
|
25075
|
-
const decode$
|
|
25108
|
+
const decode$9 = (attrs) => {
|
|
25076
25109
|
return attrs.rsidRPr;
|
|
25077
25110
|
};
|
|
25078
|
-
const attrConfig$
|
|
25111
|
+
const attrConfig$3 = Object.freeze({
|
|
25079
25112
|
xmlName: "w:rsidRPr",
|
|
25080
25113
|
sdName: "rsidRPr",
|
|
25081
|
-
encode: encode$
|
|
25082
|
-
decode: decode$
|
|
25114
|
+
encode: encode$9,
|
|
25115
|
+
decode: decode$9
|
|
25083
25116
|
});
|
|
25084
|
-
const encode$
|
|
25117
|
+
const encode$8 = (attributes) => {
|
|
25085
25118
|
return attributes["w:rsidRDefault"];
|
|
25086
25119
|
};
|
|
25087
|
-
const decode$
|
|
25120
|
+
const decode$8 = (attrs) => {
|
|
25088
25121
|
return attrs.rsidRDefault;
|
|
25089
25122
|
};
|
|
25090
|
-
const attrConfig$
|
|
25123
|
+
const attrConfig$2 = Object.freeze({
|
|
25091
25124
|
xmlName: "w:rsidRDefault",
|
|
25092
25125
|
sdName: "rsidRDefault",
|
|
25093
|
-
encode: encode$
|
|
25094
|
-
decode: decode$
|
|
25126
|
+
encode: encode$8,
|
|
25127
|
+
decode: decode$8
|
|
25095
25128
|
});
|
|
25096
|
-
const encode$
|
|
25129
|
+
const encode$7 = (attributes) => {
|
|
25097
25130
|
return attributes["w14:paraId"];
|
|
25098
25131
|
};
|
|
25099
|
-
const decode$
|
|
25132
|
+
const decode$7 = (attrs) => {
|
|
25100
25133
|
return attrs.paraId;
|
|
25101
25134
|
};
|
|
25102
|
-
const attrConfig$
|
|
25135
|
+
const attrConfig$1 = Object.freeze({
|
|
25103
25136
|
xmlName: "w14:paraId",
|
|
25104
25137
|
sdName: "paraId",
|
|
25105
|
-
encode: encode$
|
|
25106
|
-
decode: decode$
|
|
25138
|
+
encode: encode$7,
|
|
25139
|
+
decode: decode$7
|
|
25107
25140
|
});
|
|
25108
|
-
const encode$
|
|
25141
|
+
const encode$6 = (attributes) => {
|
|
25109
25142
|
return attributes["w14:textId"];
|
|
25110
25143
|
};
|
|
25111
|
-
const decode$
|
|
25144
|
+
const decode$6 = (attrs) => {
|
|
25112
25145
|
return attrs.textId;
|
|
25113
25146
|
};
|
|
25114
|
-
const attrConfig
|
|
25147
|
+
const attrConfig = Object.freeze({
|
|
25115
25148
|
xmlName: "w14:textId",
|
|
25116
25149
|
sdName: "textId",
|
|
25117
|
-
encode: encode$
|
|
25118
|
-
decode: decode$
|
|
25150
|
+
encode: encode$6,
|
|
25151
|
+
decode: decode$6
|
|
25119
25152
|
});
|
|
25120
|
-
const validXmlAttributes$
|
|
25121
|
-
attrConfig$
|
|
25122
|
-
attrConfig
|
|
25123
|
-
attrConfig$
|
|
25124
|
-
attrConfig$
|
|
25125
|
-
attrConfig$
|
|
25126
|
-
attrConfig$
|
|
25127
|
-
attrConfig$
|
|
25153
|
+
const validXmlAttributes$4 = [
|
|
25154
|
+
attrConfig$1,
|
|
25155
|
+
attrConfig,
|
|
25156
|
+
attrConfig$4,
|
|
25157
|
+
attrConfig$2,
|
|
25158
|
+
attrConfig$5,
|
|
25159
|
+
attrConfig$3,
|
|
25160
|
+
attrConfig$6
|
|
25128
25161
|
];
|
|
25129
|
-
const XML_NODE_NAME$
|
|
25130
|
-
const SD_NODE_NAME$
|
|
25131
|
-
const encode$
|
|
25162
|
+
const XML_NODE_NAME$5 = "w:p";
|
|
25163
|
+
const SD_NODE_NAME$4 = "paragraph";
|
|
25164
|
+
const encode$5 = (params, encodedAttrs = {}) => {
|
|
25132
25165
|
const node = handleParagraphNode$1(params);
|
|
25133
25166
|
if (!node) return void 0;
|
|
25134
25167
|
if (encodedAttrs && Object.keys(encodedAttrs).length) {
|
|
@@ -25136,7 +25169,7 @@ const encode$m = (params, encodedAttrs = {}) => {
|
|
|
25136
25169
|
}
|
|
25137
25170
|
return node;
|
|
25138
25171
|
};
|
|
25139
|
-
const decode$
|
|
25172
|
+
const decode$5 = (params, decodedAttrs = {}) => {
|
|
25140
25173
|
const translated = translateParagraphNode(params);
|
|
25141
25174
|
if (!translated) return void 0;
|
|
25142
25175
|
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
@@ -25144,15 +25177,15 @@ const decode$m = (params, decodedAttrs = {}) => {
|
|
|
25144
25177
|
}
|
|
25145
25178
|
return translated;
|
|
25146
25179
|
};
|
|
25147
|
-
const config$
|
|
25148
|
-
xmlName: XML_NODE_NAME$
|
|
25149
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
25180
|
+
const config$5 = {
|
|
25181
|
+
xmlName: XML_NODE_NAME$5,
|
|
25182
|
+
sdNodeOrKeyName: SD_NODE_NAME$4,
|
|
25150
25183
|
type: NodeTranslator.translatorTypes.NODE,
|
|
25151
|
-
encode: encode$
|
|
25152
|
-
decode: decode$
|
|
25153
|
-
attributes: validXmlAttributes$
|
|
25184
|
+
encode: encode$5,
|
|
25185
|
+
decode: decode$5,
|
|
25186
|
+
attributes: validXmlAttributes$4
|
|
25154
25187
|
};
|
|
25155
|
-
const translator$
|
|
25188
|
+
const translator$h = NodeTranslator.from(config$5);
|
|
25156
25189
|
const generateV2HandlerEntity = (handlerName, translator2) => ({
|
|
25157
25190
|
handlerName,
|
|
25158
25191
|
handler: (params) => {
|
|
@@ -25180,7 +25213,7 @@ function createSingleAttrPropertyHandler(xmlName, sdName = null, attrName = "w:v
|
|
|
25180
25213
|
},
|
|
25181
25214
|
decode: ({ node }) => {
|
|
25182
25215
|
const value = node.attrs?.[sdName] != null ? transformDecode(node.attrs[sdName]) : void 0;
|
|
25183
|
-
return value != null ? {
|
|
25216
|
+
return value != null ? { [attrName]: value } : void 0;
|
|
25184
25217
|
}
|
|
25185
25218
|
};
|
|
25186
25219
|
}
|
|
@@ -25198,32 +25231,7 @@ function createMeasurementPropertyHandler(xmlName, sdName = null) {
|
|
|
25198
25231
|
},
|
|
25199
25232
|
decode: function({ node }) {
|
|
25200
25233
|
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
|
|
25201
|
-
return decodedAttrs["w:w"] != null ?
|
|
25202
|
-
}
|
|
25203
|
-
};
|
|
25204
|
-
}
|
|
25205
|
-
function createBorderPropertyHandler(xmlName, sdName = null) {
|
|
25206
|
-
if (!sdName) sdName = xmlName.split(":")[1];
|
|
25207
|
-
return {
|
|
25208
|
-
xmlName,
|
|
25209
|
-
sdNodeOrKeyName: sdName,
|
|
25210
|
-
attributes: [
|
|
25211
|
-
createAttributeHandler("w:val"),
|
|
25212
|
-
createAttributeHandler("w:color"),
|
|
25213
|
-
createAttributeHandler("w:themeColor"),
|
|
25214
|
-
createAttributeHandler("w:themeTint"),
|
|
25215
|
-
createAttributeHandler("w:themeShade"),
|
|
25216
|
-
createAttributeHandler("w:sz", "size", parseInteger, integerToString),
|
|
25217
|
-
createAttributeHandler("w:space", null, parseInteger, integerToString),
|
|
25218
|
-
createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
|
|
25219
|
-
createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
|
|
25220
|
-
],
|
|
25221
|
-
encode: (params, encodedAttrs) => {
|
|
25222
|
-
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25223
|
-
},
|
|
25224
|
-
decode: function({ node }, context) {
|
|
25225
|
-
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
|
|
25226
|
-
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25234
|
+
return decodedAttrs["w:w"] != null ? decodedAttrs : void 0;
|
|
25227
25235
|
}
|
|
25228
25236
|
};
|
|
25229
25237
|
}
|
|
@@ -25266,17 +25274,15 @@ function decodeProperties(translatorsBySdName, properties) {
|
|
|
25266
25274
|
Object.keys(properties).forEach((key) => {
|
|
25267
25275
|
const translator2 = translatorsBySdName[key];
|
|
25268
25276
|
if (translator2) {
|
|
25269
|
-
const
|
|
25270
|
-
if (
|
|
25271
|
-
|
|
25272
|
-
elements.push(result);
|
|
25277
|
+
const attributes = translator2.decode({ node: { attrs: { [key]: properties[key] } } });
|
|
25278
|
+
if (attributes != null) {
|
|
25279
|
+
elements.push({ name: translator2.xmlName, attributes });
|
|
25273
25280
|
}
|
|
25274
25281
|
}
|
|
25275
25282
|
});
|
|
25276
25283
|
return elements;
|
|
25277
25284
|
}
|
|
25278
|
-
const parseBoolean = (value) =>
|
|
25279
|
-
const booleanToString = (value) => value != null ? value ? "1" : "0" : void 0;
|
|
25285
|
+
const parseBoolean = (value) => ["1", "true"].includes(value);
|
|
25280
25286
|
const parseInteger = (value) => {
|
|
25281
25287
|
if (value == null) return void 0;
|
|
25282
25288
|
const intValue = parseInt(value, 10);
|
|
@@ -25286,53 +25292,13 @@ const integerToString = (value) => {
|
|
|
25286
25292
|
const intValue = parseInteger(value);
|
|
25287
25293
|
return intValue != void 0 ? String(intValue) : void 0;
|
|
25288
25294
|
};
|
|
25289
|
-
|
|
25290
|
-
if (!table || !Array.isArray(table.content)) {
|
|
25291
|
-
return table;
|
|
25292
|
-
}
|
|
25293
|
-
const rows = table.content;
|
|
25294
|
-
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
25295
|
-
const row = rows[rowIndex];
|
|
25296
|
-
if (!row) continue;
|
|
25297
|
-
if (!Array.isArray(row.content)) {
|
|
25298
|
-
row.content = [];
|
|
25299
|
-
}
|
|
25300
|
-
for (let cellIndex = 0; cellIndex < row.content.length; cellIndex++) {
|
|
25301
|
-
const cell = row.content[cellIndex];
|
|
25302
|
-
if (!cell) continue;
|
|
25303
|
-
const attrs = cell.attrs || {};
|
|
25304
|
-
if (!attrs.rowspan || attrs.rowspan <= 1) continue;
|
|
25305
|
-
const maxRowspan = Math.min(attrs.rowspan, rows.length - rowIndex);
|
|
25306
|
-
for (let offset = 1; offset < maxRowspan; offset++) {
|
|
25307
|
-
const rowToChange = rows[rowIndex + offset];
|
|
25308
|
-
if (!rowToChange) continue;
|
|
25309
|
-
if (!Array.isArray(rowToChange.content)) {
|
|
25310
|
-
rowToChange.content = [];
|
|
25311
|
-
}
|
|
25312
|
-
const existingCell = rowToChange.content[cellIndex];
|
|
25313
|
-
if (existingCell?.attrs?.continueMerge) continue;
|
|
25314
|
-
const mergedCell = {
|
|
25315
|
-
type: cell.type,
|
|
25316
|
-
content: [editorSchema.nodes.paragraph.createAndFill().toJSON()],
|
|
25317
|
-
attrs: {
|
|
25318
|
-
...cell.attrs,
|
|
25319
|
-
rowspan: null,
|
|
25320
|
-
continueMerge: true
|
|
25321
|
-
}
|
|
25322
|
-
};
|
|
25323
|
-
rowToChange.content.splice(cellIndex, 0, mergedCell);
|
|
25324
|
-
}
|
|
25325
|
-
}
|
|
25326
|
-
}
|
|
25327
|
-
return table;
|
|
25328
|
-
}
|
|
25329
|
-
const translator$S = NodeTranslator.from({
|
|
25295
|
+
const translator$g = NodeTranslator.from({
|
|
25330
25296
|
xmlName: "w:cantSplit",
|
|
25331
25297
|
sdNodeOrKeyName: "cantSplit",
|
|
25332
25298
|
encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25333
|
-
decode: ({ node }) => node.attrs?.cantSplit ? {
|
|
25299
|
+
decode: ({ node }) => node.attrs?.cantSplit ? {} : void 0
|
|
25334
25300
|
});
|
|
25335
|
-
const translator$
|
|
25301
|
+
const translator$f = NodeTranslator.from({
|
|
25336
25302
|
xmlName: "w:cnfStyle",
|
|
25337
25303
|
sdNodeOrKeyName: "cnfStyle",
|
|
25338
25304
|
attributes: [
|
|
@@ -25347,19 +25313,26 @@ const translator$R = NodeTranslator.from({
|
|
|
25347
25313
|
"w:lastRowFirstColumn",
|
|
25348
25314
|
"w:lastRowLastColumn",
|
|
25349
25315
|
"w:oddHBand",
|
|
25350
|
-
"w:oddVBand"
|
|
25351
|
-
|
|
25316
|
+
"w:oddVBand",
|
|
25317
|
+
"w:val"
|
|
25318
|
+
].map((attr) => createAttributeHandler(attr)),
|
|
25352
25319
|
encode: (_2, encodedAttrs) => {
|
|
25320
|
+
Object.keys(encodedAttrs).forEach((key) => {
|
|
25321
|
+
encodedAttrs[key] = ["1", "true"].includes(encodedAttrs[key]);
|
|
25322
|
+
});
|
|
25353
25323
|
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25354
25324
|
},
|
|
25355
|
-
decode:
|
|
25325
|
+
decode: ({ node }) => {
|
|
25356
25326
|
if (!node.attrs?.cnfStyle) return;
|
|
25357
|
-
const
|
|
25358
|
-
|
|
25327
|
+
const cnfStyleAttrs = {};
|
|
25328
|
+
Object.entries(node.attrs.cnfStyle).forEach(([key, value]) => {
|
|
25329
|
+
cnfStyleAttrs[`w:${key}`] = value ? "1" : "0";
|
|
25330
|
+
});
|
|
25331
|
+
return Object.keys(cnfStyleAttrs).length > 0 ? cnfStyleAttrs : void 0;
|
|
25359
25332
|
}
|
|
25360
25333
|
});
|
|
25361
|
-
const translator$
|
|
25362
|
-
const translator$
|
|
25334
|
+
const translator$e = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
|
|
25335
|
+
const translator$d = NodeTranslator.from(
|
|
25363
25336
|
createSingleAttrPropertyHandler(
|
|
25364
25337
|
"w:gridAfter",
|
|
25365
25338
|
null,
|
|
@@ -25368,7 +25341,7 @@ const translator$P = NodeTranslator.from(
|
|
|
25368
25341
|
(v2) => integerToString(v2)
|
|
25369
25342
|
)
|
|
25370
25343
|
);
|
|
25371
|
-
const translator$
|
|
25344
|
+
const translator$c = NodeTranslator.from(
|
|
25372
25345
|
createSingleAttrPropertyHandler(
|
|
25373
25346
|
"w:gridBefore",
|
|
25374
25347
|
null,
|
|
@@ -25377,21 +25350,21 @@ const translator$O = NodeTranslator.from(
|
|
|
25377
25350
|
(v2) => integerToString(v2)
|
|
25378
25351
|
)
|
|
25379
25352
|
);
|
|
25380
|
-
const translator$
|
|
25353
|
+
const translator$b = NodeTranslator.from({
|
|
25381
25354
|
xmlName: "w:hidden",
|
|
25382
25355
|
sdNodeOrKeyName: "hidden",
|
|
25383
25356
|
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25384
|
-
decode: ({ node }) => node.attrs.hidden ? {
|
|
25357
|
+
decode: ({ node }) => node.attrs.hidden ? {} : void 0
|
|
25385
25358
|
});
|
|
25386
|
-
const translator$
|
|
25387
|
-
const translator$
|
|
25388
|
-
const translator$
|
|
25359
|
+
const translator$a = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc"));
|
|
25360
|
+
const translator$9 = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "cellSpacing"));
|
|
25361
|
+
const translator$8 = NodeTranslator.from({
|
|
25389
25362
|
xmlName: "w:tblHeader",
|
|
25390
25363
|
sdNodeOrKeyName: "repeatHeader",
|
|
25391
25364
|
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25392
|
-
decode: ({ node }) => node.attrs.repeatHeader ? {
|
|
25365
|
+
decode: ({ node }) => node.attrs.repeatHeader ? {} : void 0
|
|
25393
25366
|
});
|
|
25394
|
-
const translator$
|
|
25367
|
+
const translator$7 = NodeTranslator.from({
|
|
25395
25368
|
xmlName: "w:trHeight",
|
|
25396
25369
|
sdNodeOrKeyName: "rowHeight",
|
|
25397
25370
|
encode: ({ nodes }) => {
|
|
@@ -25415,14 +25388,14 @@ const translator$J = NodeTranslator.from({
|
|
|
25415
25388
|
if (node.attrs.rowHeight.rule) {
|
|
25416
25389
|
heightAttrs["w:hRule"] = node.attrs.rowHeight.rule;
|
|
25417
25390
|
}
|
|
25418
|
-
return Object.keys(heightAttrs).length > 0 ?
|
|
25391
|
+
return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
|
|
25419
25392
|
}
|
|
25420
25393
|
});
|
|
25421
|
-
const translator$
|
|
25422
|
-
const translator$
|
|
25423
|
-
const XML_NODE_NAME$
|
|
25424
|
-
const SD_ATTR_KEY
|
|
25425
|
-
const encode$
|
|
25394
|
+
const translator$6 = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
|
|
25395
|
+
const translator$5 = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
|
|
25396
|
+
const XML_NODE_NAME$4 = "w:trPr";
|
|
25397
|
+
const SD_ATTR_KEY = "tableRowProperties";
|
|
25398
|
+
const encode$4 = (params) => {
|
|
25426
25399
|
const { nodes } = params;
|
|
25427
25400
|
const node = nodes[0];
|
|
25428
25401
|
let attributes = {
|
|
@@ -25432,18 +25405,18 @@ const encode$l = (params) => {
|
|
|
25432
25405
|
};
|
|
25433
25406
|
attributes = {
|
|
25434
25407
|
...attributes,
|
|
25435
|
-
...encodeProperties(node, propertyTranslatorsByXmlName
|
|
25408
|
+
...encodeProperties(node, propertyTranslatorsByXmlName)
|
|
25436
25409
|
};
|
|
25437
25410
|
return {
|
|
25438
25411
|
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
25439
|
-
xmlName: XML_NODE_NAME$
|
|
25440
|
-
sdNodeOrKeyName: SD_ATTR_KEY
|
|
25412
|
+
xmlName: XML_NODE_NAME$4,
|
|
25413
|
+
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
25441
25414
|
attributes
|
|
25442
25415
|
};
|
|
25443
25416
|
};
|
|
25444
|
-
const decode$
|
|
25417
|
+
const decode$4 = (params) => {
|
|
25445
25418
|
const { tableRowProperties = {} } = params.node.attrs || {};
|
|
25446
|
-
const elements = decodeProperties(propertyTranslatorsBySdName
|
|
25419
|
+
const elements = decodeProperties(propertyTranslatorsBySdName, tableRowProperties);
|
|
25447
25420
|
const newNode = {
|
|
25448
25421
|
name: "w:trPr",
|
|
25449
25422
|
type: "element",
|
|
@@ -25452,47 +25425,47 @@ const decode$l = (params) => {
|
|
|
25452
25425
|
};
|
|
25453
25426
|
return newNode;
|
|
25454
25427
|
};
|
|
25455
|
-
const propertyTranslators
|
|
25456
|
-
translator$
|
|
25457
|
-
translator$
|
|
25458
|
-
translator$
|
|
25459
|
-
translator$
|
|
25460
|
-
translator$
|
|
25461
|
-
translator$
|
|
25462
|
-
translator$
|
|
25463
|
-
translator$
|
|
25464
|
-
translator$
|
|
25465
|
-
translator$
|
|
25466
|
-
translator$
|
|
25467
|
-
translator$
|
|
25428
|
+
const propertyTranslators = [
|
|
25429
|
+
translator$g,
|
|
25430
|
+
translator$f,
|
|
25431
|
+
translator$e,
|
|
25432
|
+
translator$d,
|
|
25433
|
+
translator$c,
|
|
25434
|
+
translator$b,
|
|
25435
|
+
translator$a,
|
|
25436
|
+
translator$9,
|
|
25437
|
+
translator$8,
|
|
25438
|
+
translator$7,
|
|
25439
|
+
translator$6,
|
|
25440
|
+
translator$5
|
|
25468
25441
|
];
|
|
25469
|
-
const propertyTranslatorsByXmlName
|
|
25470
|
-
propertyTranslators
|
|
25471
|
-
propertyTranslatorsByXmlName
|
|
25442
|
+
const propertyTranslatorsByXmlName = {};
|
|
25443
|
+
propertyTranslators.forEach((translator2) => {
|
|
25444
|
+
propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
|
|
25472
25445
|
});
|
|
25473
|
-
const propertyTranslatorsBySdName
|
|
25474
|
-
propertyTranslators
|
|
25475
|
-
propertyTranslatorsBySdName
|
|
25446
|
+
const propertyTranslatorsBySdName = {};
|
|
25447
|
+
propertyTranslators.forEach((translator2) => {
|
|
25448
|
+
propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
|
|
25476
25449
|
});
|
|
25477
|
-
const config$
|
|
25478
|
-
xmlName: XML_NODE_NAME$
|
|
25479
|
-
sdNodeOrKeyName: SD_ATTR_KEY
|
|
25450
|
+
const config$4 = {
|
|
25451
|
+
xmlName: XML_NODE_NAME$4,
|
|
25452
|
+
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
25480
25453
|
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
25481
|
-
encode: encode$
|
|
25482
|
-
decode: decode$
|
|
25454
|
+
encode: encode$4,
|
|
25455
|
+
decode: decode$4
|
|
25483
25456
|
};
|
|
25484
|
-
const translator$
|
|
25485
|
-
const XML_NODE_NAME$
|
|
25486
|
-
const SD_NODE_NAME$
|
|
25487
|
-
const validXmlAttributes$
|
|
25457
|
+
const translator$4 = NodeTranslator.from(config$4);
|
|
25458
|
+
const XML_NODE_NAME$3 = "w:tr";
|
|
25459
|
+
const SD_NODE_NAME$3 = "tableRow";
|
|
25460
|
+
const validXmlAttributes$3 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
|
|
25488
25461
|
(xmlName) => createAttributeHandler(xmlName)
|
|
25489
25462
|
);
|
|
25490
|
-
const encode$
|
|
25491
|
-
const { row } = params.extraParams;
|
|
25463
|
+
const encode$3 = (params, encodedAttrs) => {
|
|
25464
|
+
const { row, table } = params.extraParams;
|
|
25492
25465
|
let tableRowProperties = {};
|
|
25493
25466
|
const tPr = row.elements.find((el) => el.name === "w:trPr");
|
|
25494
25467
|
if (tPr) {
|
|
25495
|
-
({ attributes: tableRowProperties } = translator$
|
|
25468
|
+
({ attributes: tableRowProperties } = translator$4.encode({
|
|
25496
25469
|
...params,
|
|
25497
25470
|
nodes: [tPr]
|
|
25498
25471
|
}));
|
|
@@ -25500,12 +25473,12 @@ const encode$k = (params, encodedAttrs) => {
|
|
|
25500
25473
|
encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
|
|
25501
25474
|
encodedAttrs["rowHeight"] = twipsToPixels(tableRowProperties["rowHeight"]?.value);
|
|
25502
25475
|
encodedAttrs["cantSplit"] = tableRowProperties["cantSplit"];
|
|
25503
|
-
const
|
|
25476
|
+
const gridColumnWidths = _getGridColumnWidths(table);
|
|
25504
25477
|
const cellNodes = row.elements.filter((el) => el.name === "w:tc");
|
|
25505
25478
|
let currentColumnIndex = 0;
|
|
25506
25479
|
const content = cellNodes?.map((n) => {
|
|
25507
25480
|
let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
|
|
25508
|
-
const result = translator$
|
|
25481
|
+
const result = translator$2.encode({
|
|
25509
25482
|
...params,
|
|
25510
25483
|
extraParams: {
|
|
25511
25484
|
...params.extraParams,
|
|
@@ -25527,7 +25500,16 @@ const encode$k = (params, encodedAttrs) => {
|
|
|
25527
25500
|
};
|
|
25528
25501
|
return newNode;
|
|
25529
25502
|
};
|
|
25530
|
-
const
|
|
25503
|
+
const _getGridColumnWidths = (tableNode) => {
|
|
25504
|
+
const tblGrid = tableNode.elements.find((el) => el.name === "w:tblGrid");
|
|
25505
|
+
if (!tblGrid) return [];
|
|
25506
|
+
const columnWidths = tblGrid?.elements?.flatMap((el) => {
|
|
25507
|
+
if (el.name !== "w:gridCol") return [];
|
|
25508
|
+
return twipsToPixels(el.attributes["w:w"]);
|
|
25509
|
+
}) || [];
|
|
25510
|
+
return columnWidths;
|
|
25511
|
+
};
|
|
25512
|
+
const decode$3 = (params, decodedAttrs) => {
|
|
25531
25513
|
const { node } = params;
|
|
25532
25514
|
const elements = translateChildNodes(params);
|
|
25533
25515
|
if (node.attrs?.tableRowProperties) {
|
|
@@ -25539,7 +25521,7 @@ const decode$k = (params, decodedAttrs) => {
|
|
|
25539
25521
|
}
|
|
25540
25522
|
}
|
|
25541
25523
|
tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
|
|
25542
|
-
const trPr = translator$
|
|
25524
|
+
const trPr = translator$4.decode({
|
|
25543
25525
|
...params,
|
|
25544
25526
|
node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
|
|
25545
25527
|
});
|
|
@@ -25551,428 +25533,86 @@ const decode$k = (params, decodedAttrs) => {
|
|
|
25551
25533
|
elements
|
|
25552
25534
|
};
|
|
25553
25535
|
};
|
|
25554
|
-
const config$
|
|
25555
|
-
xmlName: XML_NODE_NAME$
|
|
25556
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
25536
|
+
const config$3 = {
|
|
25537
|
+
xmlName: XML_NODE_NAME$3,
|
|
25538
|
+
sdNodeOrKeyName: SD_NODE_NAME$3,
|
|
25557
25539
|
type: NodeTranslator.translatorTypes.NODE,
|
|
25558
|
-
encode: encode$
|
|
25559
|
-
decode: decode$
|
|
25560
|
-
attributes: validXmlAttributes$
|
|
25561
|
-
};
|
|
25562
|
-
const translator$
|
|
25563
|
-
const
|
|
25564
|
-
xmlName: "w:bidiVisual",
|
|
25565
|
-
sdNodeOrKeyName: "rightToLeft",
|
|
25566
|
-
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25567
|
-
decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
|
|
25568
|
-
});
|
|
25569
|
-
const translator$D = NodeTranslator.from({
|
|
25570
|
-
xmlName: "w:shd",
|
|
25571
|
-
sdNodeOrKeyName: "shading",
|
|
25572
|
-
attributes: [
|
|
25573
|
-
"w:color",
|
|
25574
|
-
"w:fill",
|
|
25575
|
-
"w:themeColor",
|
|
25576
|
-
"w:themeFill",
|
|
25577
|
-
"w:themeFillShade",
|
|
25578
|
-
"w:themeFillTint",
|
|
25579
|
-
"w:themeShade",
|
|
25580
|
-
"w:themeTint",
|
|
25581
|
-
"w:val"
|
|
25582
|
-
].map((attr) => createAttributeHandler(attr)),
|
|
25583
|
-
encode: (params, encodedAttrs) => {
|
|
25584
|
-
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25585
|
-
},
|
|
25586
|
-
decode: function({ node }, context) {
|
|
25587
|
-
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.shading || {} } });
|
|
25588
|
-
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25589
|
-
}
|
|
25590
|
-
});
|
|
25591
|
-
const translator$C = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
|
|
25592
|
-
const translator$B = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
|
|
25593
|
-
const translator$A = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
|
|
25594
|
-
const translator$z = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
|
|
25595
|
-
const translator$y = NodeTranslator.from({
|
|
25596
|
-
xmlName: "w:tblLook",
|
|
25597
|
-
sdNodeOrKeyName: "tblLook",
|
|
25598
|
-
attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
|
|
25599
|
-
encode: (params, encodedAttrs) => {
|
|
25600
|
-
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25601
|
-
},
|
|
25602
|
-
decode: function({ node }, context) {
|
|
25603
|
-
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.tblLook || {} } });
|
|
25604
|
-
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25605
|
-
}
|
|
25606
|
-
});
|
|
25607
|
-
const translator$x = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
|
|
25608
|
-
const translator$w = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
|
|
25609
|
-
const translator$v = NodeTranslator.from(
|
|
25610
|
-
createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
|
|
25611
|
-
);
|
|
25612
|
-
const translator$u = NodeTranslator.from(
|
|
25613
|
-
createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
|
|
25614
|
-
);
|
|
25615
|
-
const translator$t = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
|
|
25616
|
-
const translator$s = NodeTranslator.from({
|
|
25617
|
-
xmlName: "w:tblpPr",
|
|
25618
|
-
sdNodeOrKeyName: "floatingTableProperties",
|
|
25619
|
-
attributes: ["w:leftFromText", "w:rightFromText", "w:topFromText", "w:bottomFromText", "w:tblpX", "w:tblpY"].map((attr) => createAttributeHandler(attr, null, parseInteger, integerToString)).concat(["w:horzAnchor", "w:vertAnchor", "w:tblpXSpec", "w:tblpYSpec"].map((attr) => createAttributeHandler(attr))),
|
|
25620
|
-
encode: (params, encodedAttrs) => {
|
|
25621
|
-
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25622
|
-
},
|
|
25623
|
-
decode: function({ node }, context) {
|
|
25624
|
-
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.floatingTableProperties || {} } });
|
|
25625
|
-
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25626
|
-
}
|
|
25627
|
-
});
|
|
25628
|
-
const translator$r = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
|
|
25629
|
-
const translator$q = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
|
|
25630
|
-
const translator$p = NodeTranslator.from(createBorderPropertyHandler("w:end"));
|
|
25631
|
-
const translator$o = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
|
|
25632
|
-
const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
|
|
25633
|
-
const translator$m = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
|
|
25634
|
-
const translator$l = NodeTranslator.from(createBorderPropertyHandler("w:left"));
|
|
25635
|
-
const translator$k = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
|
|
25636
|
-
const translator$j = NodeTranslator.from(createBorderPropertyHandler("w:right"));
|
|
25637
|
-
const translator$i = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
|
|
25638
|
-
const translator$h = NodeTranslator.from(createBorderPropertyHandler("w:start"));
|
|
25639
|
-
const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
|
|
25640
|
-
const translator$f = NodeTranslator.from(createBorderPropertyHandler("w:top"));
|
|
25641
|
-
const translator$e = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
|
|
25642
|
-
const XML_NODE_NAME$c = "w:tblBorders";
|
|
25643
|
-
const SD_ATTR_KEY$3 = "borders";
|
|
25644
|
-
const encode$j = (params) => {
|
|
25540
|
+
encode: encode$3,
|
|
25541
|
+
decode: decode$3,
|
|
25542
|
+
attributes: validXmlAttributes$3
|
|
25543
|
+
};
|
|
25544
|
+
const translator$3 = NodeTranslator.from(config$3);
|
|
25545
|
+
const handleAllTableNodes = (params) => {
|
|
25645
25546
|
const { nodes } = params;
|
|
25547
|
+
if (nodes.length === 0) {
|
|
25548
|
+
return { nodes: [], consumed: 0 };
|
|
25549
|
+
}
|
|
25646
25550
|
const node = nodes[0];
|
|
25647
|
-
|
|
25648
|
-
|
|
25551
|
+
switch (node.name) {
|
|
25552
|
+
case "w:tbl":
|
|
25553
|
+
return { nodes: [handleTableNode(node, params)], consumed: 1 };
|
|
25554
|
+
}
|
|
25555
|
+
return { nodes: [], consumed: 0 };
|
|
25649
25556
|
};
|
|
25650
|
-
const
|
|
25651
|
-
|
|
25652
|
-
|
|
25653
|
-
const newNode = {
|
|
25654
|
-
name: "w:tblBorders",
|
|
25655
|
-
type: "element",
|
|
25656
|
-
attributes: {},
|
|
25657
|
-
elements
|
|
25658
|
-
};
|
|
25659
|
-
return newNode;
|
|
25557
|
+
const tableNodeHandlerEntity = {
|
|
25558
|
+
handlerName: "tableNodeHandler",
|
|
25559
|
+
handler: handleAllTableNodes
|
|
25660
25560
|
};
|
|
25661
|
-
|
|
25662
|
-
|
|
25663
|
-
translator$p,
|
|
25664
|
-
translator$n,
|
|
25665
|
-
translator$m,
|
|
25666
|
-
translator$l,
|
|
25667
|
-
translator$j,
|
|
25668
|
-
translator$h,
|
|
25669
|
-
translator$f
|
|
25670
|
-
];
|
|
25671
|
-
const tblBordersTranslatorsByXmlName = {};
|
|
25672
|
-
const tblBordersTranslatorsBySdName = {};
|
|
25673
|
-
propertyTranslators$2.forEach((translator2) => {
|
|
25674
|
-
tblBordersTranslatorsByXmlName[translator2.xmlName] = translator2;
|
|
25675
|
-
tblBordersTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
|
|
25676
|
-
});
|
|
25677
|
-
const translator$d = NodeTranslator.from({
|
|
25678
|
-
xmlName: XML_NODE_NAME$c,
|
|
25679
|
-
sdNodeOrKeyName: SD_ATTR_KEY$3,
|
|
25680
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
25681
|
-
attributes: [],
|
|
25682
|
-
encode: encode$j,
|
|
25683
|
-
decode: decode$j
|
|
25684
|
-
});
|
|
25685
|
-
const XML_NODE_NAME$b = "w:tblCellMar";
|
|
25686
|
-
const SD_ATTR_KEY$2 = "cellMargins";
|
|
25687
|
-
const encode$i = (params) => {
|
|
25688
|
-
const { nodes } = params;
|
|
25689
|
-
const node = nodes[0];
|
|
25690
|
-
const attributes = encodeProperties(node, propertyTranslatorsByXmlName$1);
|
|
25691
|
-
return Object.keys(attributes).length > 0 ? attributes : void 0;
|
|
25692
|
-
};
|
|
25693
|
-
const decode$i = (params) => {
|
|
25694
|
-
const { cellMargins = {} } = params.node.attrs || {};
|
|
25695
|
-
const elements = decodeProperties(propertyTranslatorsBySdName$1, cellMargins);
|
|
25696
|
-
const newNode = {
|
|
25697
|
-
name: XML_NODE_NAME$b,
|
|
25698
|
-
type: "element",
|
|
25699
|
-
attributes: {},
|
|
25700
|
-
elements
|
|
25701
|
-
};
|
|
25702
|
-
return newNode;
|
|
25703
|
-
};
|
|
25704
|
-
const propertyTranslators$1 = [
|
|
25705
|
-
translator$q,
|
|
25706
|
-
translator$o,
|
|
25707
|
-
translator$k,
|
|
25708
|
-
translator$i,
|
|
25709
|
-
translator$g,
|
|
25710
|
-
translator$e
|
|
25711
|
-
];
|
|
25712
|
-
const propertyTranslatorsByXmlName$1 = {};
|
|
25713
|
-
const propertyTranslatorsBySdName$1 = {};
|
|
25714
|
-
propertyTranslators$1.forEach((translator2) => {
|
|
25715
|
-
propertyTranslatorsByXmlName$1[translator2.xmlName] = translator2;
|
|
25716
|
-
propertyTranslatorsBySdName$1[translator2.sdNodeOrKeyName] = translator2;
|
|
25717
|
-
});
|
|
25718
|
-
const translator$c = NodeTranslator.from({
|
|
25719
|
-
xmlName: XML_NODE_NAME$b,
|
|
25720
|
-
sdNodeOrKeyName: SD_ATTR_KEY$2,
|
|
25721
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
25722
|
-
attributes: [],
|
|
25723
|
-
encode: encode$i,
|
|
25724
|
-
decode: decode$i
|
|
25725
|
-
});
|
|
25726
|
-
const XML_NODE_NAME$a = "w:tblPr";
|
|
25727
|
-
const SD_ATTR_KEY$1 = "tableProperties";
|
|
25728
|
-
const encode$h = (params) => {
|
|
25729
|
-
const { nodes } = params;
|
|
25730
|
-
const node = nodes[0];
|
|
25731
|
-
const attributes = encodeProperties(node, propertyTranslatorsByXmlName);
|
|
25732
|
-
return {
|
|
25733
|
-
xmlName: XML_NODE_NAME$a,
|
|
25734
|
-
sdNodeOrKeyName: SD_ATTR_KEY$1,
|
|
25735
|
-
attributes
|
|
25736
|
-
};
|
|
25737
|
-
};
|
|
25738
|
-
const decode$h = (params) => {
|
|
25739
|
-
const { tableProperties = {} } = params.node.attrs || {};
|
|
25740
|
-
const elements = decodeProperties(propertyTranslatorsBySdName, tableProperties);
|
|
25741
|
-
const newNode = {
|
|
25742
|
-
name: "w:tblPr",
|
|
25743
|
-
type: "element",
|
|
25744
|
-
attributes: {},
|
|
25745
|
-
elements
|
|
25746
|
-
};
|
|
25747
|
-
return newNode;
|
|
25748
|
-
};
|
|
25749
|
-
const propertyTranslators = [
|
|
25750
|
-
translator$E,
|
|
25751
|
-
translator$M,
|
|
25752
|
-
translator$D,
|
|
25753
|
-
translator$C,
|
|
25754
|
-
translator$L,
|
|
25755
|
-
translator$B,
|
|
25756
|
-
translator$A,
|
|
25757
|
-
translator$z,
|
|
25758
|
-
translator$y,
|
|
25759
|
-
translator$x,
|
|
25760
|
-
translator$w,
|
|
25761
|
-
translator$v,
|
|
25762
|
-
translator$u,
|
|
25763
|
-
translator$t,
|
|
25764
|
-
translator$s,
|
|
25765
|
-
translator$d,
|
|
25766
|
-
translator$c
|
|
25767
|
-
];
|
|
25768
|
-
const propertyTranslatorsByXmlName = {};
|
|
25769
|
-
const propertyTranslatorsBySdName = {};
|
|
25770
|
-
propertyTranslators.forEach((translator2) => {
|
|
25771
|
-
propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
|
|
25772
|
-
propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
|
|
25773
|
-
});
|
|
25774
|
-
const config$a = {
|
|
25775
|
-
xmlName: XML_NODE_NAME$a,
|
|
25776
|
-
sdNodeOrKeyName: SD_ATTR_KEY$1,
|
|
25777
|
-
encode: encode$h,
|
|
25778
|
-
decode: decode$h
|
|
25779
|
-
};
|
|
25780
|
-
const translator$b = NodeTranslator.from(config$a);
|
|
25781
|
-
const translator$a = NodeTranslator.from(
|
|
25782
|
-
createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
|
|
25783
|
-
);
|
|
25784
|
-
const DEFAULT_COLUMN_WIDTH_PX = 100;
|
|
25785
|
-
const normalizeTwipWidth = (value) => {
|
|
25786
|
-
if (value == null) return null;
|
|
25787
|
-
const numericValue = typeof value === "string" ? parseInt(value, 10) : value;
|
|
25788
|
-
if (!Number.isFinite(numericValue) || Number.isNaN(numericValue) || numericValue <= 0) {
|
|
25789
|
-
return null;
|
|
25790
|
-
}
|
|
25791
|
-
return numericValue;
|
|
25792
|
-
};
|
|
25793
|
-
const getSchemaDefaultColumnWidthPx = (params) => {
|
|
25794
|
-
const defaultValue = params?.editor?.schema?.nodes?.tableCell?.spec?.attrs?.colwidth?.default;
|
|
25795
|
-
if (Array.isArray(defaultValue)) {
|
|
25796
|
-
const numericWidth = defaultValue.find((width) => typeof width === "number" && Number.isFinite(width) && width > 0);
|
|
25797
|
-
if (numericWidth != null) return numericWidth;
|
|
25798
|
-
} else if (typeof defaultValue === "number" && Number.isFinite(defaultValue) && defaultValue > 0) {
|
|
25799
|
-
return defaultValue;
|
|
25800
|
-
}
|
|
25801
|
-
return DEFAULT_COLUMN_WIDTH_PX;
|
|
25802
|
-
};
|
|
25803
|
-
const getTableWidthPx = (params) => {
|
|
25804
|
-
const explicitWidth = params?.node?.attrs?.tableWidth?.width;
|
|
25805
|
-
if (typeof explicitWidth === "number" && explicitWidth > 0) return explicitWidth;
|
|
25806
|
-
const tableWidth = params?.node?.attrs?.tableProperties?.tableWidth;
|
|
25807
|
-
if (tableWidth?.value != null && typeof tableWidth.value === "number" && tableWidth.value > 0) {
|
|
25808
|
-
const { value, type: type2 } = tableWidth;
|
|
25809
|
-
if (!type2 || type2 === "auto" || type2 === "dxa") {
|
|
25810
|
-
return twipsToPixels(value);
|
|
25811
|
-
}
|
|
25812
|
-
}
|
|
25813
|
-
return null;
|
|
25814
|
-
};
|
|
25815
|
-
const resolveFallbackColumnWidthTwips = (params, totalColumns, cellMinWidthTwips) => {
|
|
25816
|
-
const columnCount = Math.max(totalColumns, 1);
|
|
25817
|
-
const defaultColumnWidthPx = getSchemaDefaultColumnWidthPx(params);
|
|
25818
|
-
const tableWidthPx = getTableWidthPx(params);
|
|
25819
|
-
const safeDefaultPx = Number.isFinite(defaultColumnWidthPx) && defaultColumnWidthPx > 0 ? defaultColumnWidthPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
25820
|
-
let fallbackWidthPx = safeDefaultPx;
|
|
25821
|
-
if (typeof tableWidthPx === "number" && tableWidthPx > 0) {
|
|
25822
|
-
fallbackWidthPx = tableWidthPx / columnCount;
|
|
25823
|
-
}
|
|
25824
|
-
const fallbackWidthTwips = pixelsToTwips(fallbackWidthPx);
|
|
25825
|
-
if (!Number.isFinite(fallbackWidthTwips) || Number.isNaN(fallbackWidthTwips) || fallbackWidthTwips <= 0) {
|
|
25826
|
-
const safeDefault = Math.max(pixelsToTwips(safeDefaultPx), cellMinWidthTwips);
|
|
25827
|
-
return safeDefault;
|
|
25828
|
-
}
|
|
25829
|
-
return Math.max(fallbackWidthTwips, cellMinWidthTwips);
|
|
25830
|
-
};
|
|
25831
|
-
const XML_NODE_NAME$9 = "w:tblGrid";
|
|
25832
|
-
const SD_ATTR_KEY = "grid";
|
|
25833
|
-
const cellMinWidth = pixelsToTwips(10);
|
|
25834
|
-
const encode$g = (params) => {
|
|
25835
|
-
const { nodes } = params;
|
|
25836
|
-
const node = nodes[0];
|
|
25837
|
-
const attributes = encodeProperties(node, { [translator$a.xmlName]: translator$a }, true);
|
|
25838
|
-
return {
|
|
25839
|
-
xmlName: XML_NODE_NAME$9,
|
|
25840
|
-
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
25841
|
-
attributes
|
|
25842
|
-
};
|
|
25843
|
-
};
|
|
25844
|
-
const decode$g = (params) => {
|
|
25845
|
-
const { grid: rawGrid } = params.node.attrs || {};
|
|
25846
|
-
const grid = Array.isArray(rawGrid) ? rawGrid : [];
|
|
25847
|
-
const { firstRow = {} } = params.extraParams || {};
|
|
25848
|
-
const cellNodes = firstRow.content?.filter((n) => n.type === "tableCell") ?? [];
|
|
25849
|
-
const columnCountFromCells = cellNodes.reduce((count, cell) => {
|
|
25850
|
-
const spanCount = Math.max(1, cell?.attrs?.colspan ?? 1);
|
|
25851
|
-
return count + spanCount;
|
|
25852
|
-
}, 0);
|
|
25853
|
-
const totalColumns = Math.max(columnCountFromCells, grid.length);
|
|
25854
|
-
const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params, totalColumns, cellMinWidth);
|
|
25855
|
-
const elements = [];
|
|
25856
|
-
let columnIndex = 0;
|
|
25857
|
-
const pushColumn = (widthTwips) => {
|
|
25858
|
-
let numericWidth = typeof widthTwips === "string" ? parseInt(widthTwips, 10) : widthTwips;
|
|
25859
|
-
if (numericWidth == null || Number.isNaN(numericWidth) || numericWidth <= 0) {
|
|
25860
|
-
numericWidth = fallbackColumnWidthTwips;
|
|
25861
|
-
}
|
|
25862
|
-
numericWidth = Math.max(numericWidth, cellMinWidth);
|
|
25863
|
-
const decoded = translator$a.decode({
|
|
25864
|
-
node: { type: (
|
|
25865
|
-
/** @type {string} */
|
|
25866
|
-
translator$a.sdNodeOrKeyName
|
|
25867
|
-
), attrs: { col: numericWidth } }
|
|
25868
|
-
});
|
|
25869
|
-
if (decoded) elements.push(decoded);
|
|
25870
|
-
};
|
|
25871
|
-
cellNodes.forEach((cell) => {
|
|
25872
|
-
const { colspan = 1, colwidth } = cell?.attrs || {};
|
|
25873
|
-
const spanCount = Math.max(1, colspan);
|
|
25874
|
-
for (let span = 0; span < spanCount; span++) {
|
|
25875
|
-
const cellWidthPixels = Array.isArray(colwidth) ? colwidth[span] : void 0;
|
|
25876
|
-
const colGridAttrs = grid?.[columnIndex] || {};
|
|
25877
|
-
const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
|
|
25878
|
-
const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
|
|
25879
|
-
let cellWidthTwips;
|
|
25880
|
-
if (cellWidthPixels != null) {
|
|
25881
|
-
if (gridWidthTwips != null && gridWidthPixels === cellWidthPixels) {
|
|
25882
|
-
cellWidthTwips = gridWidthTwips;
|
|
25883
|
-
} else {
|
|
25884
|
-
cellWidthTwips = pixelsToTwips(cellWidthPixels);
|
|
25885
|
-
}
|
|
25886
|
-
} else if (gridWidthTwips != null) {
|
|
25887
|
-
cellWidthTwips = gridWidthTwips;
|
|
25888
|
-
} else {
|
|
25889
|
-
cellWidthTwips = fallbackColumnWidthTwips;
|
|
25890
|
-
}
|
|
25891
|
-
pushColumn(cellWidthTwips);
|
|
25892
|
-
columnIndex++;
|
|
25893
|
-
}
|
|
25894
|
-
});
|
|
25895
|
-
while (columnIndex < grid.length) {
|
|
25896
|
-
const gridWidthTwips = normalizeTwipWidth(grid[columnIndex]?.col);
|
|
25897
|
-
pushColumn(gridWidthTwips);
|
|
25898
|
-
columnIndex++;
|
|
25899
|
-
}
|
|
25900
|
-
const newNode = {
|
|
25901
|
-
name: XML_NODE_NAME$9,
|
|
25902
|
-
attributes: {},
|
|
25903
|
-
elements
|
|
25904
|
-
};
|
|
25905
|
-
return newNode;
|
|
25906
|
-
};
|
|
25907
|
-
const config$9 = {
|
|
25908
|
-
xmlName: XML_NODE_NAME$9,
|
|
25909
|
-
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
25910
|
-
encode: encode$g,
|
|
25911
|
-
decode: decode$g
|
|
25912
|
-
};
|
|
25913
|
-
const translator$9 = NodeTranslator.from(config$9);
|
|
25914
|
-
const XML_NODE_NAME$8 = "w:tbl";
|
|
25915
|
-
const SD_NODE_NAME$8 = "table";
|
|
25916
|
-
const encode$f = (params, encodedAttrs) => {
|
|
25917
|
-
const { nodes } = params;
|
|
25918
|
-
const node = nodes[0];
|
|
25561
|
+
function handleTableNode(node, params) {
|
|
25562
|
+
const { docx, nodeListHandler } = params;
|
|
25919
25563
|
const tblPr = node.elements.find((el) => el.name === "w:tblPr");
|
|
25920
|
-
|
|
25921
|
-
|
|
25922
|
-
|
|
25923
|
-
|
|
25924
|
-
const
|
|
25925
|
-
|
|
25926
|
-
|
|
25927
|
-
|
|
25928
|
-
|
|
25929
|
-
"
|
|
25930
|
-
|
|
25931
|
-
|
|
25932
|
-
|
|
25933
|
-
|
|
25934
|
-
["
|
|
25935
|
-
|
|
25936
|
-
|
|
25937
|
-
|
|
25938
|
-
|
|
25939
|
-
|
|
25940
|
-
|
|
25941
|
-
|
|
25942
|
-
transform = (v2) => v2;
|
|
25943
|
-
}
|
|
25944
|
-
if (encodedAttrs.tableProperties && encodedAttrs.tableProperties[key]) {
|
|
25945
|
-
encodedAttrs[key] = transform(encodedAttrs.tableProperties[key]);
|
|
25946
|
-
}
|
|
25947
|
-
});
|
|
25948
|
-
if (encodedAttrs.tableCellSpacing) {
|
|
25949
|
-
encodedAttrs["borderCollapse"] = "separate";
|
|
25950
|
-
}
|
|
25951
|
-
const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
|
|
25952
|
-
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params);
|
|
25953
|
-
if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
|
|
25954
|
-
encodedAttrs.tableProperties = {
|
|
25955
|
-
...encodedAttrs.tableProperties || {},
|
|
25956
|
-
cellMargins: referencedStyles.cellMargins
|
|
25564
|
+
const tableBordersElement = tblPr.elements.find((el) => el.name === "w:tblBorders");
|
|
25565
|
+
const tableBorders = tableBordersElement?.elements || [];
|
|
25566
|
+
const { borders, rowBorders } = processTableBorders(tableBorders);
|
|
25567
|
+
const tblStyleTag = tblPr.elements.find((el) => el.name === "w:tblStyle");
|
|
25568
|
+
const tableStyleId = tblStyleTag?.attributes["w:val"];
|
|
25569
|
+
const attrs = { tableStyleId };
|
|
25570
|
+
const tableIndent = tblPr?.elements.find((el) => el.name === "w:tblInd");
|
|
25571
|
+
if (tableIndent) {
|
|
25572
|
+
const { "w:w": width, "w:type": type2 } = tableIndent.attributes;
|
|
25573
|
+
attrs["tableIndent"] = { width: twipsToPixels(width), type: type2 };
|
|
25574
|
+
}
|
|
25575
|
+
const tableLayout = tblPr?.elements.find((el) => el.name === "w:tblLayout");
|
|
25576
|
+
if (tableLayout) {
|
|
25577
|
+
const { "w:type": type2 } = tableLayout.attributes;
|
|
25578
|
+
attrs["tableLayout"] = type2;
|
|
25579
|
+
}
|
|
25580
|
+
const referencedStyles = getReferencedTableStyles(tblStyleTag, docx);
|
|
25581
|
+
const tblW = tblPr.elements.find((el) => el.name === "w:tblW");
|
|
25582
|
+
if (tblW) {
|
|
25583
|
+
attrs["tableWidth"] = {
|
|
25584
|
+
width: twipsToPixels(tblW.attributes["w:w"]),
|
|
25585
|
+
type: tblW.attributes["w:type"]
|
|
25957
25586
|
};
|
|
25958
25587
|
}
|
|
25588
|
+
const tblCellSpacing = tblPr.elements.find((el) => el.name === "w:tblCellSpacing");
|
|
25589
|
+
if (tblCellSpacing) {
|
|
25590
|
+
attrs["tableCellSpacing"] = {
|
|
25591
|
+
w: tblCellSpacing.attributes["w:w"],
|
|
25592
|
+
type: tblCellSpacing.attributes["w:type"]
|
|
25593
|
+
};
|
|
25594
|
+
attrs["borderCollapse"] = "separate";
|
|
25595
|
+
}
|
|
25596
|
+
const tblJustification = tblPr.elements.find((el) => el.name === "w:jc");
|
|
25597
|
+
if (tblJustification?.attributes) {
|
|
25598
|
+
attrs["justification"] = tblJustification.attributes["w:val"];
|
|
25599
|
+
}
|
|
25959
25600
|
const rows = node.elements.filter((el) => el.name === "w:tr");
|
|
25960
|
-
const
|
|
25961
|
-
const
|
|
25962
|
-
|
|
25963
|
-
const
|
|
25964
|
-
|
|
25601
|
+
const refStylesBorders = referencedStyles?.borders || {};
|
|
25602
|
+
const refStylesRowBorders = referencedStyles?.rowBorders || {};
|
|
25603
|
+
const borderData = Object.keys(borders)?.length ? Object.assign(refStylesBorders, borders) : refStylesBorders;
|
|
25604
|
+
const borderRowData = Object.keys(rowBorders)?.length ? Object.assign(refStylesRowBorders, rowBorders) : refStylesRowBorders;
|
|
25605
|
+
attrs["borders"] = borderData;
|
|
25965
25606
|
const content = [];
|
|
25966
25607
|
rows.forEach((row) => {
|
|
25967
|
-
const result = translator$
|
|
25608
|
+
const result = translator$3.encode({
|
|
25968
25609
|
...params,
|
|
25969
25610
|
nodes: [row],
|
|
25970
25611
|
extraParams: {
|
|
25971
25612
|
row,
|
|
25972
25613
|
table: node,
|
|
25973
25614
|
rowBorders: borderRowData,
|
|
25974
|
-
styleTag: tblStyleTag
|
|
25975
|
-
columnWidths
|
|
25615
|
+
styleTag: tblStyleTag
|
|
25976
25616
|
}
|
|
25977
25617
|
});
|
|
25978
25618
|
if (result.content?.length) content.push(result);
|
|
@@ -25980,118 +25620,9 @@ const encode$f = (params, encodedAttrs) => {
|
|
|
25980
25620
|
return {
|
|
25981
25621
|
type: "table",
|
|
25982
25622
|
content,
|
|
25983
|
-
attrs
|
|
25984
|
-
};
|
|
25985
|
-
};
|
|
25986
|
-
const decode$f = (params, decodedAttrs) => {
|
|
25987
|
-
params.node = preProcessVerticalMergeCells(params.node, params);
|
|
25988
|
-
const { node } = params;
|
|
25989
|
-
const elements = translateChildNodes(params);
|
|
25990
|
-
const firstRow = node.content?.find((n) => n.type === "tableRow");
|
|
25991
|
-
const properties = node.attrs.grid;
|
|
25992
|
-
const element = translator$9.decode({
|
|
25993
|
-
...params,
|
|
25994
|
-
node: { ...node, attrs: { ...node.attrs, grid: properties } },
|
|
25995
|
-
extraParams: {
|
|
25996
|
-
firstRow
|
|
25997
|
-
}
|
|
25998
|
-
});
|
|
25999
|
-
if (element) elements.unshift(element);
|
|
26000
|
-
if (node.attrs?.tableProperties) {
|
|
26001
|
-
const properties2 = { ...node.attrs.tableProperties };
|
|
26002
|
-
const element2 = translator$b.decode({
|
|
26003
|
-
...params,
|
|
26004
|
-
node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
|
|
26005
|
-
});
|
|
26006
|
-
if (element2) elements.unshift(element2);
|
|
26007
|
-
}
|
|
26008
|
-
return {
|
|
26009
|
-
name: "w:tbl",
|
|
26010
|
-
attributes: decodedAttrs || {},
|
|
26011
|
-
elements
|
|
26012
|
-
};
|
|
26013
|
-
};
|
|
26014
|
-
function _processTableBorders(rawBorders) {
|
|
26015
|
-
const borders = {};
|
|
26016
|
-
const rowBorders = {};
|
|
26017
|
-
Object.entries(rawBorders).forEach(([name, attributes]) => {
|
|
26018
|
-
const attrs = {};
|
|
26019
|
-
const color = attributes.color;
|
|
26020
|
-
const size = attributes.size;
|
|
26021
|
-
if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
|
|
26022
|
-
if (size && size !== "auto") attrs["size"] = eigthPointsToPixels(size);
|
|
26023
|
-
const rowBorderNames = ["insideH", "insideV"];
|
|
26024
|
-
if (rowBorderNames.includes(name)) rowBorders[name] = attrs;
|
|
26025
|
-
borders[name] = attrs;
|
|
26026
|
-
});
|
|
26027
|
-
return {
|
|
26028
|
-
borders,
|
|
26029
|
-
rowBorders
|
|
25623
|
+
attrs
|
|
26030
25624
|
};
|
|
26031
25625
|
}
|
|
26032
|
-
function _getReferencedTableStyles(tableStyleReference, params) {
|
|
26033
|
-
if (!tableStyleReference) return null;
|
|
26034
|
-
const stylesToReturn = {};
|
|
26035
|
-
const { docx } = params;
|
|
26036
|
-
const styles = docx["word/styles.xml"];
|
|
26037
|
-
const { elements } = styles.elements[0];
|
|
26038
|
-
const styleElements = elements.filter((el) => el.name === "w:style");
|
|
26039
|
-
const styleTag = styleElements.find((el) => el.attributes["w:styleId"] === tableStyleReference);
|
|
26040
|
-
if (!styleTag) return null;
|
|
26041
|
-
stylesToReturn.name = styleTag.elements.find((el) => el.name === "w:name");
|
|
26042
|
-
const basedOn = styleTag.elements.find((el) => el.name === "w:basedOn");
|
|
26043
|
-
let baseTblPr;
|
|
26044
|
-
if (basedOn?.attributes) {
|
|
26045
|
-
const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
|
|
26046
|
-
baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
|
|
26047
|
-
}
|
|
26048
|
-
const pPr = styleTag.elements.find((el) => el.name === "w:pPr");
|
|
26049
|
-
if (pPr) {
|
|
26050
|
-
const justification = pPr.elements.find((el) => el.name === "w:jc");
|
|
26051
|
-
if (justification?.attributes) stylesToReturn.justification = justification.attributes["w:val"];
|
|
26052
|
-
}
|
|
26053
|
-
const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
|
|
26054
|
-
if (rPr) {
|
|
26055
|
-
const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
|
|
26056
|
-
if (fonts) {
|
|
26057
|
-
const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
|
|
26058
|
-
stylesToReturn.fonts = { ascii, hAnsi, cs };
|
|
26059
|
-
}
|
|
26060
|
-
const fontSize = rPr.elements.find((el) => el.name === "w:sz");
|
|
26061
|
-
if (fontSize?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize.attributes["w:val"]) + "pt";
|
|
26062
|
-
}
|
|
26063
|
-
const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
|
|
26064
|
-
if (tblPr && tblPr.elements) {
|
|
26065
|
-
if (baseTblPr && baseTblPr.elements) {
|
|
26066
|
-
tblPr.elements.push(...baseTblPr.elements);
|
|
26067
|
-
}
|
|
26068
|
-
const tableProperties = translator$b.encode({ ...params, nodes: [tblPr] }).attributes;
|
|
26069
|
-
const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
|
|
26070
|
-
if (borders) stylesToReturn.borders = borders;
|
|
26071
|
-
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
26072
|
-
const cellMargins = {};
|
|
26073
|
-
Object.entries(tableProperties.cellMargins || {}).forEach(([key, attrs]) => {
|
|
26074
|
-
if (attrs?.value != null) {
|
|
26075
|
-
cellMargins[key] = {
|
|
26076
|
-
value: attrs.value,
|
|
26077
|
-
type: attrs.type || "dxa"
|
|
26078
|
-
};
|
|
26079
|
-
}
|
|
26080
|
-
});
|
|
26081
|
-
if (Object.keys(cellMargins).length) stylesToReturn.cellMargins = cellMargins;
|
|
26082
|
-
}
|
|
26083
|
-
return stylesToReturn;
|
|
26084
|
-
}
|
|
26085
|
-
const config$8 = {
|
|
26086
|
-
xmlName: XML_NODE_NAME$8,
|
|
26087
|
-
sdNodeOrKeyName: SD_NODE_NAME$8,
|
|
26088
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
26089
|
-
encode: encode$f,
|
|
26090
|
-
decode: decode$f,
|
|
26091
|
-
attributes: []
|
|
26092
|
-
};
|
|
26093
|
-
const translator$8 = NodeTranslator.from(config$8);
|
|
26094
|
-
const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$8);
|
|
26095
25626
|
function getReferencedTableStyles(tblStyleTag, docx) {
|
|
26096
25627
|
if (!tblStyleTag) return null;
|
|
26097
25628
|
const stylesToReturn = {};
|
|
@@ -26172,6 +25703,15 @@ function processTableBorders(borderElements) {
|
|
|
26172
25703
|
rowBorders
|
|
26173
25704
|
};
|
|
26174
25705
|
}
|
|
25706
|
+
const getGridColumnWidths = (tableNode) => {
|
|
25707
|
+
const tblGrid = tableNode.elements.find((el) => el.name === "w:tblGrid");
|
|
25708
|
+
if (!tblGrid) return [];
|
|
25709
|
+
const columnWidths = tblGrid?.elements?.flatMap((el) => {
|
|
25710
|
+
if (el.name !== "w:gridCol") return [];
|
|
25711
|
+
return twipsToPixels(el.attributes["w:w"]);
|
|
25712
|
+
}) || [];
|
|
25713
|
+
return columnWidths;
|
|
25714
|
+
};
|
|
26175
25715
|
function handleTableCellNode({
|
|
26176
25716
|
params,
|
|
26177
25717
|
node,
|
|
@@ -26180,8 +25720,7 @@ function handleTableCellNode({
|
|
|
26180
25720
|
rowBorders,
|
|
26181
25721
|
styleTag,
|
|
26182
25722
|
columnIndex,
|
|
26183
|
-
columnWidth = null
|
|
26184
|
-
allColumnWidths = []
|
|
25723
|
+
columnWidth = null
|
|
26185
25724
|
}) {
|
|
26186
25725
|
const { docx, nodeListHandler } = params;
|
|
26187
25726
|
const tcPr = node.elements.find((el) => el.name === "w:tcPr");
|
|
@@ -26195,7 +25734,7 @@ function handleTableCellNode({
|
|
|
26195
25734
|
delete rowBorders?.insideV;
|
|
26196
25735
|
}
|
|
26197
25736
|
const inlineBorders = processInlineCellBorders(borders, rowBorders);
|
|
26198
|
-
const gridColumnWidths =
|
|
25737
|
+
const gridColumnWidths = getGridColumnWidths(table);
|
|
26199
25738
|
const tcWidth = tcPr?.elements?.find((el) => el.name === "w:tcW");
|
|
26200
25739
|
let width = tcWidth ? twipsToPixels(tcWidth.attributes["w:w"]) : null;
|
|
26201
25740
|
const widthType = tcWidth?.attributes["w:type"];
|
|
@@ -26329,17 +25868,11 @@ const getTableCellMargins = (marginTag, referencedStyles) => {
|
|
|
26329
25868
|
marginTop: marginTopStyle,
|
|
26330
25869
|
marginBottom: marginBottomStyle
|
|
26331
25870
|
} = cellMargins;
|
|
26332
|
-
const resolveMargin = (inlineValue, styleValue) => {
|
|
26333
|
-
if (inlineValue != null) return inlineValue;
|
|
26334
|
-
if (styleValue == null) return void 0;
|
|
26335
|
-
if (typeof styleValue === "object") return styleValue.value;
|
|
26336
|
-
return styleValue;
|
|
26337
|
-
};
|
|
26338
25871
|
const margins = {
|
|
26339
|
-
left: twipsToPixels(
|
|
26340
|
-
right: twipsToPixels(
|
|
26341
|
-
top: twipsToPixels(
|
|
26342
|
-
bottom: twipsToPixels(
|
|
25872
|
+
left: twipsToPixels(inlineMarginLeftValue ?? marginLeftStyle),
|
|
25873
|
+
right: twipsToPixels(inlineMarginRightValue ?? marginRightStyle),
|
|
25874
|
+
top: twipsToPixels(inlineMarginTopValue ?? marginTopStyle),
|
|
25875
|
+
bottom: twipsToPixels(inlineMarginBottomValue ?? marginBottomStyle)
|
|
26343
25876
|
};
|
|
26344
25877
|
return margins;
|
|
26345
25878
|
};
|
|
@@ -26453,20 +25986,11 @@ function generateCellMargins(cellMargins) {
|
|
|
26453
25986
|
if (left != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left) } });
|
|
26454
25987
|
return elements;
|
|
26455
25988
|
}
|
|
26456
|
-
const XML_NODE_NAME$
|
|
26457
|
-
const SD_NODE_NAME$
|
|
26458
|
-
const validXmlAttributes$
|
|
26459
|
-
function encode$
|
|
26460
|
-
const {
|
|
26461
|
-
node,
|
|
26462
|
-
table,
|
|
26463
|
-
row,
|
|
26464
|
-
rowBorders,
|
|
26465
|
-
styleTag,
|
|
26466
|
-
columnIndex,
|
|
26467
|
-
columnWidth,
|
|
26468
|
-
columnWidths: allColumnWidths
|
|
26469
|
-
} = params.extraParams;
|
|
25989
|
+
const XML_NODE_NAME$2 = "w:tc";
|
|
25990
|
+
const SD_NODE_NAME$2 = "tableCell";
|
|
25991
|
+
const validXmlAttributes$2 = [];
|
|
25992
|
+
function encode$2(params, encodedAttrs) {
|
|
25993
|
+
const { node, table, row, rowBorders, styleTag, columnIndex, columnWidth } = params.extraParams;
|
|
26470
25994
|
const schemaNode = handleTableCellNode({
|
|
26471
25995
|
params,
|
|
26472
25996
|
node,
|
|
@@ -26475,39 +25999,38 @@ function encode$e(params, encodedAttrs) {
|
|
|
26475
25999
|
rowBorders,
|
|
26476
26000
|
styleTag,
|
|
26477
26001
|
columnIndex,
|
|
26478
|
-
columnWidth
|
|
26479
|
-
allColumnWidths
|
|
26002
|
+
columnWidth
|
|
26480
26003
|
});
|
|
26481
26004
|
if (encodedAttrs && Object.keys(encodedAttrs).length) {
|
|
26482
26005
|
schemaNode.attrs = { ...schemaNode.attrs, ...encodedAttrs };
|
|
26483
26006
|
}
|
|
26484
26007
|
return schemaNode;
|
|
26485
26008
|
}
|
|
26486
|
-
function decode$
|
|
26009
|
+
function decode$2(params, decodedAttrs) {
|
|
26487
26010
|
const translated = translateTableCell(params);
|
|
26488
26011
|
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
26489
26012
|
translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
|
|
26490
26013
|
}
|
|
26491
26014
|
return translated;
|
|
26492
26015
|
}
|
|
26493
|
-
const config$
|
|
26494
|
-
xmlName: XML_NODE_NAME$
|
|
26495
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
26016
|
+
const config$2 = {
|
|
26017
|
+
xmlName: XML_NODE_NAME$2,
|
|
26018
|
+
sdNodeOrKeyName: SD_NODE_NAME$2,
|
|
26496
26019
|
type: NodeTranslator.translatorTypes.NODE,
|
|
26497
|
-
encode: encode$
|
|
26498
|
-
decode: decode$
|
|
26499
|
-
attributes: validXmlAttributes$
|
|
26020
|
+
encode: encode$2,
|
|
26021
|
+
decode: decode$2,
|
|
26022
|
+
attributes: validXmlAttributes$2
|
|
26500
26023
|
};
|
|
26501
|
-
const translator$
|
|
26502
|
-
const XML_NODE_NAME$
|
|
26503
|
-
const SD_NODE_NAME$
|
|
26024
|
+
const translator$2 = NodeTranslator.from(config$2);
|
|
26025
|
+
const XML_NODE_NAME$1 = "w:hyperlink";
|
|
26026
|
+
const SD_NODE_NAME$1 = "link";
|
|
26504
26027
|
const _createAttributeHandler = (xmlName, sdName) => ({
|
|
26505
26028
|
xmlName,
|
|
26506
26029
|
sdName,
|
|
26507
26030
|
encode: (attributes) => attributes[xmlName],
|
|
26508
26031
|
decode: (attributes) => attributes[sdName]
|
|
26509
26032
|
});
|
|
26510
|
-
const validXmlAttributes$
|
|
26033
|
+
const validXmlAttributes$1 = [
|
|
26511
26034
|
_createAttributeHandler("w:anchor", "anchor"),
|
|
26512
26035
|
_createAttributeHandler("w:docLocation", "docLocation"),
|
|
26513
26036
|
{
|
|
@@ -26520,7 +26043,7 @@ const validXmlAttributes$6 = [
|
|
|
26520
26043
|
_createAttributeHandler("r:id", "rId"),
|
|
26521
26044
|
_createAttributeHandler("w:tgtFrame", "target")
|
|
26522
26045
|
];
|
|
26523
|
-
const encode$
|
|
26046
|
+
const encode$1 = (params, encodedAttrs) => {
|
|
26524
26047
|
const { nodes, docx, nodeListHandler } = params;
|
|
26525
26048
|
const node = nodes[0];
|
|
26526
26049
|
let href = _resolveHref(docx, encodedAttrs);
|
|
@@ -26551,7 +26074,7 @@ const _resolveHref = (docx, encodedAttrs) => {
|
|
|
26551
26074
|
}
|
|
26552
26075
|
return href;
|
|
26553
26076
|
};
|
|
26554
|
-
function decode$
|
|
26077
|
+
function decode$1(params) {
|
|
26555
26078
|
const { node } = params;
|
|
26556
26079
|
const linkMark = node.marks.find((m2) => m2.type === "link");
|
|
26557
26080
|
const linkAttrs = this.decodeAttributes({ ...params, node: linkMark });
|
|
@@ -26595,15 +26118,15 @@ function _addNewLinkRelationship(params, link, rId) {
|
|
|
26595
26118
|
});
|
|
26596
26119
|
return rId;
|
|
26597
26120
|
}
|
|
26598
|
-
const config$
|
|
26599
|
-
xmlName: XML_NODE_NAME$
|
|
26600
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
26121
|
+
const config$1 = {
|
|
26122
|
+
xmlName: XML_NODE_NAME$1,
|
|
26123
|
+
sdNodeOrKeyName: SD_NODE_NAME$1,
|
|
26601
26124
|
type: NodeTranslator.translatorTypes.NODE,
|
|
26602
|
-
encode: encode$
|
|
26603
|
-
decode: decode$
|
|
26604
|
-
attributes: validXmlAttributes$
|
|
26125
|
+
encode: encode$1,
|
|
26126
|
+
decode: decode$1,
|
|
26127
|
+
attributes: validXmlAttributes$1
|
|
26605
26128
|
};
|
|
26606
|
-
const translator$
|
|
26129
|
+
const translator$1 = NodeTranslator.from(config$1);
|
|
26607
26130
|
function parseTagValueJSON(json) {
|
|
26608
26131
|
if (typeof json !== "string") {
|
|
26609
26132
|
return {};
|
|
@@ -26614,7 +26137,7 @@ function parseTagValueJSON(json) {
|
|
|
26614
26137
|
}
|
|
26615
26138
|
try {
|
|
26616
26139
|
return JSON.parse(trimmed);
|
|
26617
|
-
} catch {
|
|
26140
|
+
} catch (err) {
|
|
26618
26141
|
return {};
|
|
26619
26142
|
}
|
|
26620
26143
|
}
|
|
@@ -26805,853 +26328,46 @@ function handleStructuredContentNode(params) {
|
|
|
26805
26328
|
}
|
|
26806
26329
|
let result = {
|
|
26807
26330
|
type: sdtContentType,
|
|
26808
|
-
content: translatedContent,
|
|
26809
|
-
marks,
|
|
26810
|
-
attrs: {
|
|
26811
|
-
sdtPr
|
|
26812
|
-
}
|
|
26813
|
-
};
|
|
26814
|
-
return result;
|
|
26815
|
-
}
|
|
26816
|
-
function sdtNodeTypeStrategy(node) {
|
|
26817
|
-
const sdtContent = node.elements.find((el) => el.name === "w:sdtContent");
|
|
26818
|
-
const sdtPr = node.elements.find((el) => el.name === "w:sdtPr");
|
|
26819
|
-
const tag = sdtPr?.elements.find((el) => el.name === "w:tag");
|
|
26820
|
-
const tagValue = tag?.attributes?.["w:val"];
|
|
26821
|
-
const docPartObj = sdtPr?.elements.find((el) => el.name === "w:docPartObj");
|
|
26822
|
-
if (docPartObj) {
|
|
26823
|
-
return { type: "docPartObj", handler: handleDocPartObj };
|
|
26824
|
-
}
|
|
26825
|
-
if (tagValue) {
|
|
26826
|
-
const shouldProcessAsJson = tagValue.startsWith("{") && tagValue.endsWith("}");
|
|
26827
|
-
if (shouldProcessAsJson) {
|
|
26828
|
-
const parsedTag = parseTagValueJSON(tagValue);
|
|
26829
|
-
if (parsedTag.type === "documentSection") {
|
|
26830
|
-
return { type: "documentSection", handler: handleDocumentSectionNode };
|
|
26831
|
-
}
|
|
26832
|
-
if (parsedTag.fieldId && parsedTag.fieldTypeShort) {
|
|
26833
|
-
return { type: "fieldAnnotation", handler: handleAnnotationNode };
|
|
26834
|
-
}
|
|
26835
|
-
} else {
|
|
26836
|
-
const fieldTypeShort = sdtPr.elements.find((el) => el.name === "w:fieldTypeShort");
|
|
26837
|
-
const fieldTypeShortValue = fieldTypeShort?.attributes["w:val"];
|
|
26838
|
-
if (tagValue && fieldTypeShortValue) {
|
|
26839
|
-
return { type: "fieldAnnotation", handler: handleAnnotationNode };
|
|
26840
|
-
}
|
|
26841
|
-
}
|
|
26842
|
-
}
|
|
26843
|
-
if (sdtContent) {
|
|
26844
|
-
return { type: "structuredContent", handler: handleStructuredContentNode };
|
|
26845
|
-
}
|
|
26846
|
-
return { type: "unknown", handler: null };
|
|
26847
|
-
}
|
|
26848
|
-
function handleImageNode(node, params, isAnchor) {
|
|
26849
|
-
const { docx, filename } = params;
|
|
26850
|
-
const { attributes } = node;
|
|
26851
|
-
const padding = {
|
|
26852
|
-
top: emuToPixels(attributes["distT"]),
|
|
26853
|
-
bottom: emuToPixels(attributes["distB"]),
|
|
26854
|
-
left: emuToPixels(attributes["distL"]),
|
|
26855
|
-
right: emuToPixels(attributes["distR"])
|
|
26856
|
-
};
|
|
26857
|
-
const extent = node.elements.find((el) => el.name === "wp:extent");
|
|
26858
|
-
const size = {
|
|
26859
|
-
width: emuToPixels(extent.attributes?.cx),
|
|
26860
|
-
height: emuToPixels(extent.attributes?.cy)
|
|
26861
|
-
};
|
|
26862
|
-
const graphic = node.elements.find((el) => el.name === "a:graphic");
|
|
26863
|
-
const graphicData = graphic.elements.find((el) => el.name === "a:graphicData");
|
|
26864
|
-
const { uri: uri2 } = graphicData?.attributes || {};
|
|
26865
|
-
const shapeURI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
26866
|
-
if (!!uri2 && uri2 === shapeURI) {
|
|
26867
|
-
return handleShapeDrawing(params, node, graphicData);
|
|
26868
|
-
}
|
|
26869
|
-
const picture = graphicData.elements.find((el) => el.name === "pic:pic");
|
|
26870
|
-
if (!picture || !picture.elements) return null;
|
|
26871
|
-
const blipFill = picture.elements.find((el) => el.name === "pic:blipFill");
|
|
26872
|
-
const blip = blipFill.elements.find((el) => el.name === "a:blip");
|
|
26873
|
-
const spPr = picture.elements.find((el) => el.name === "pic:spPr");
|
|
26874
|
-
let transformData = {};
|
|
26875
|
-
if (spPr) {
|
|
26876
|
-
const xfrm = spPr.elements.find((el) => el.name === "a:xfrm");
|
|
26877
|
-
if (xfrm?.attributes) {
|
|
26878
|
-
transformData = {
|
|
26879
|
-
rotation: rotToDegrees(xfrm.attributes["rot"]),
|
|
26880
|
-
verticalFlip: xfrm.attributes["flipV"] === "1",
|
|
26881
|
-
horizontalFlip: xfrm.attributes["flipH"] === "1"
|
|
26882
|
-
};
|
|
26883
|
-
}
|
|
26884
|
-
}
|
|
26885
|
-
const effectExtent = node.elements.find((el) => el.name === "wp:effectExtent");
|
|
26886
|
-
if (effectExtent) {
|
|
26887
|
-
const sanitizeEmuValue = (value) => {
|
|
26888
|
-
if (value === null || value === void 0) return 0;
|
|
26889
|
-
const numeric = Number(value);
|
|
26890
|
-
return Number.isFinite(numeric) ? numeric : 0;
|
|
26891
|
-
};
|
|
26892
|
-
transformData.sizeExtension = {
|
|
26893
|
-
left: emuToPixels(sanitizeEmuValue(effectExtent.attributes["l"])),
|
|
26894
|
-
top: emuToPixels(sanitizeEmuValue(effectExtent.attributes["t"])),
|
|
26895
|
-
right: emuToPixels(sanitizeEmuValue(effectExtent.attributes["r"])),
|
|
26896
|
-
bottom: emuToPixels(sanitizeEmuValue(effectExtent.attributes["b"]))
|
|
26897
|
-
};
|
|
26898
|
-
}
|
|
26899
|
-
const positionHTag = node.elements.find((el) => el.name === "wp:positionH");
|
|
26900
|
-
const positionH = positionHTag?.elements.find((el) => el.name === "wp:posOffset");
|
|
26901
|
-
const positionHValue = emuToPixels(positionH?.elements[0]?.text);
|
|
26902
|
-
const hRelativeFrom = positionHTag?.attributes.relativeFrom;
|
|
26903
|
-
const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
26904
|
-
const positionVTag = node.elements.find((el) => el.name === "wp:positionV");
|
|
26905
|
-
const positionV = positionVTag?.elements?.find((el) => el.name === "wp:posOffset");
|
|
26906
|
-
const positionVValue = emuToPixels(positionV?.elements[0]?.text);
|
|
26907
|
-
const vRelativeFrom = positionVTag?.attributes.relativeFrom;
|
|
26908
|
-
const alignV = positionVTag?.elements?.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
26909
|
-
const simplePos = node.elements.find((el) => el.name === "wp:simplePos");
|
|
26910
|
-
const wrapSquare = node.elements.find((el) => el.name === "wp:wrapSquare");
|
|
26911
|
-
const wrapTopAndBottom = node.elements.find((el) => el.name === "wp:wrapTopAndBottom");
|
|
26912
|
-
const docPr = node.elements.find((el) => el.name === "wp:docPr");
|
|
26913
|
-
let anchorData = null;
|
|
26914
|
-
if (hRelativeFrom || alignH || vRelativeFrom || alignV) {
|
|
26915
|
-
anchorData = {
|
|
26916
|
-
hRelativeFrom,
|
|
26917
|
-
vRelativeFrom,
|
|
26918
|
-
alignH,
|
|
26919
|
-
alignV
|
|
26920
|
-
};
|
|
26921
|
-
}
|
|
26922
|
-
const marginOffset = {
|
|
26923
|
-
left: positionHValue,
|
|
26924
|
-
top: positionVValue
|
|
26925
|
-
};
|
|
26926
|
-
const { attributes: blipAttributes = {} } = blip;
|
|
26927
|
-
const rEmbed = blipAttributes["r:embed"];
|
|
26928
|
-
if (!rEmbed) return null;
|
|
26929
|
-
const currentFile = filename || "document.xml";
|
|
26930
|
-
let rels = docx[`word/_rels/${currentFile}.rels`];
|
|
26931
|
-
if (!rels) rels = docx[`word/_rels/document.xml.rels`];
|
|
26932
|
-
const relationships = rels.elements.find((el) => el.name === "Relationships");
|
|
26933
|
-
const { elements } = relationships || [];
|
|
26934
|
-
const rel = elements?.find((el) => el.attributes["Id"] === rEmbed);
|
|
26935
|
-
if (!rel) return null;
|
|
26936
|
-
const { attributes: relAttributes } = rel;
|
|
26937
|
-
const targetPath = relAttributes["Target"];
|
|
26938
|
-
let path = `word/${targetPath}`;
|
|
26939
|
-
if (targetPath.startsWith("/word") || targetPath.startsWith("/media")) path = targetPath.substring(1);
|
|
26940
|
-
const extension = targetPath.substring(targetPath.lastIndexOf(".") + 1);
|
|
26941
|
-
return {
|
|
26942
|
-
type: "image",
|
|
26943
|
-
attrs: {
|
|
26944
|
-
src: path,
|
|
26945
|
-
alt: ["emf", "wmf"].includes(extension) ? "Unable to render EMF/WMF image" : docPr?.attributes.name || "Image",
|
|
26946
|
-
extension,
|
|
26947
|
-
id: docPr?.attributes.id || "",
|
|
26948
|
-
title: docPr?.attributes.descr || "Image",
|
|
26949
|
-
inline: true,
|
|
26950
|
-
padding,
|
|
26951
|
-
marginOffset,
|
|
26952
|
-
size,
|
|
26953
|
-
anchorData,
|
|
26954
|
-
isAnchor,
|
|
26955
|
-
transformData,
|
|
26956
|
-
...simplePos && {
|
|
26957
|
-
simplePos: {
|
|
26958
|
-
x: simplePos.attributes.x,
|
|
26959
|
-
y: simplePos.attributes.y
|
|
26960
|
-
}
|
|
26961
|
-
},
|
|
26962
|
-
...wrapSquare && {
|
|
26963
|
-
wrapText: wrapSquare.attributes.wrapText
|
|
26964
|
-
},
|
|
26965
|
-
wrapTopAndBottom: !!wrapTopAndBottom,
|
|
26966
|
-
originalPadding: {
|
|
26967
|
-
distT: attributes["distT"],
|
|
26968
|
-
distB: attributes["distB"],
|
|
26969
|
-
distL: attributes["distL"],
|
|
26970
|
-
distR: attributes["distR"]
|
|
26971
|
-
},
|
|
26972
|
-
originalAttributes: node.attributes,
|
|
26973
|
-
rId: relAttributes["Id"]
|
|
26974
|
-
}
|
|
26975
|
-
};
|
|
26976
|
-
}
|
|
26977
|
-
const handleShapeDrawing = (params, node, graphicData) => {
|
|
26978
|
-
const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
|
|
26979
|
-
const textBox = wsp.elements.find((el) => el.name === "wps:txbx");
|
|
26980
|
-
const textBoxContent = textBox?.elements?.find((el) => el.name === "w:txbxContent");
|
|
26981
|
-
node.elements.find((el) => el.name === "wp:docPr");
|
|
26982
|
-
const spPr = wsp.elements.find((el) => el.name === "wps:spPr");
|
|
26983
|
-
const prstGeom = spPr?.elements.find((el) => el.name === "a:prstGeom");
|
|
26984
|
-
if (!!prstGeom && prstGeom.attributes["prst"] === "rect" && !textBoxContent) {
|
|
26985
|
-
return getRectangleShape(params, spPr);
|
|
26986
|
-
}
|
|
26987
|
-
if (!textBoxContent) {
|
|
26988
|
-
return null;
|
|
26989
|
-
}
|
|
26990
|
-
const { nodeListHandler } = params;
|
|
26991
|
-
const translatedElement = nodeListHandler.handler({
|
|
26992
|
-
...params,
|
|
26993
|
-
node: textBoxContent.elements[0],
|
|
26994
|
-
nodes: textBoxContent.elements,
|
|
26995
|
-
path: [...params.path || [], textBoxContent]
|
|
26996
|
-
});
|
|
26997
|
-
return translatedElement[0];
|
|
26998
|
-
};
|
|
26999
|
-
const getRectangleShape = (params, node) => {
|
|
27000
|
-
const schemaAttrs = {};
|
|
27001
|
-
const [drawingNode] = params.nodes;
|
|
27002
|
-
if (drawingNode?.name === "w:drawing") {
|
|
27003
|
-
schemaAttrs.drawingContent = drawingNode;
|
|
27004
|
-
}
|
|
27005
|
-
const xfrm = node.elements.find((el) => el.name === "a:xfrm");
|
|
27006
|
-
const start = xfrm.elements.find((el) => el.name === "a:off");
|
|
27007
|
-
const size = xfrm.elements.find((el) => el.name === "a:ext");
|
|
27008
|
-
const solidFill = node.elements.find((el) => el.name === "a:solidFill");
|
|
27009
|
-
node.elements.find((el) => el.name === "a:ln");
|
|
27010
|
-
const rectangleSize = {
|
|
27011
|
-
top: emuToPixels(start.attributes["y"]),
|
|
27012
|
-
left: emuToPixels(start.attributes["x"]),
|
|
27013
|
-
width: emuToPixels(size.attributes["cx"]),
|
|
27014
|
-
height: emuToPixels(size.attributes["cy"])
|
|
27015
|
-
};
|
|
27016
|
-
schemaAttrs.size = rectangleSize;
|
|
27017
|
-
const background = solidFill?.elements[0]?.attributes["val"];
|
|
27018
|
-
if (background) {
|
|
27019
|
-
schemaAttrs.background = "#" + background;
|
|
27020
|
-
}
|
|
27021
|
-
return {
|
|
27022
|
-
type: "contentBlock",
|
|
27023
|
-
attrs: schemaAttrs
|
|
27024
|
-
};
|
|
27025
|
-
};
|
|
27026
|
-
function handleAnchorNode(params) {
|
|
27027
|
-
const { node } = params.extraParams;
|
|
27028
|
-
if (node.name !== "wp:anchor") {
|
|
27029
|
-
return null;
|
|
27030
|
-
}
|
|
27031
|
-
return handleImageNode(node, params, true);
|
|
27032
|
-
}
|
|
27033
|
-
const sanitizeDocxMediaName = (value, fallback = "image") => {
|
|
27034
|
-
if (!value) return fallback;
|
|
27035
|
-
const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
27036
|
-
return sanitized || fallback;
|
|
27037
|
-
};
|
|
27038
|
-
const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
|
|
27039
|
-
if (!src || typeof src !== "string") return fallback;
|
|
27040
|
-
const [prefix] = src.split(";");
|
|
27041
|
-
const [, maybeType] = prefix.split("/");
|
|
27042
|
-
const extension = maybeType?.toLowerCase();
|
|
27043
|
-
return extension ? `${fallback}.${extension}` : fallback;
|
|
27044
|
-
};
|
|
27045
|
-
const translateImageNode = (params) => {
|
|
27046
|
-
const {
|
|
27047
|
-
node: { attrs = {} },
|
|
27048
|
-
tableCell,
|
|
27049
|
-
imageSize
|
|
27050
|
-
} = params;
|
|
27051
|
-
let imageId = attrs.rId;
|
|
27052
|
-
const src = attrs.src || attrs.imageSrc;
|
|
27053
|
-
const { originalWidth, originalHeight } = getPngDimensions(src);
|
|
27054
|
-
let imageName;
|
|
27055
|
-
if (params.node.type === "image") {
|
|
27056
|
-
if (src?.startsWith("data:")) {
|
|
27057
|
-
imageName = getFallbackImageNameFromDataUri(src);
|
|
27058
|
-
} else {
|
|
27059
|
-
imageName = src?.split("/").pop();
|
|
27060
|
-
}
|
|
27061
|
-
} else {
|
|
27062
|
-
imageName = attrs.fieldId;
|
|
27063
|
-
}
|
|
27064
|
-
imageName = sanitizeDocxMediaName(imageName);
|
|
27065
|
-
let size = attrs.size ? {
|
|
27066
|
-
w: pixelsToEmu(attrs.size.width),
|
|
27067
|
-
h: pixelsToEmu(attrs.size.height)
|
|
27068
|
-
} : imageSize;
|
|
27069
|
-
if (originalWidth && originalHeight) {
|
|
27070
|
-
const boxWidthPx = emuToPixels(size.w);
|
|
27071
|
-
const boxHeightPx = emuToPixels(size.h);
|
|
27072
|
-
const { scaledWidth, scaledHeight } = getScaledSize(originalWidth, originalHeight, boxWidthPx, boxHeightPx);
|
|
27073
|
-
size = {
|
|
27074
|
-
w: pixelsToEmu(scaledWidth),
|
|
27075
|
-
h: pixelsToEmu(scaledHeight)
|
|
27076
|
-
};
|
|
27077
|
-
}
|
|
27078
|
-
if (tableCell) {
|
|
27079
|
-
const colwidthSum = tableCell.attrs.colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
27080
|
-
const leftMargin = tableCell.attrs.cellMargins?.left || 8;
|
|
27081
|
-
const rightMargin = tableCell.attrs.cellMargins?.right || 8;
|
|
27082
|
-
const maxWidthEmu = pixelsToEmu(colwidthSum - (leftMargin + rightMargin));
|
|
27083
|
-
const { width: w2, height: h2 } = resizeKeepAspectRatio(size.w, size.h, maxWidthEmu);
|
|
27084
|
-
if (w2 && h2) size = { w: w2, h: h2 };
|
|
27085
|
-
}
|
|
27086
|
-
if (params.node.type === "image" && !imageId) {
|
|
27087
|
-
const path = src?.split("word/")[1];
|
|
27088
|
-
imageId = addNewImageRelationship(params, path);
|
|
27089
|
-
} else if (params.node.type === "fieldAnnotation" && !imageId) {
|
|
27090
|
-
const type2 = src?.split(";")[0].split("/")[1];
|
|
27091
|
-
if (!type2) {
|
|
27092
|
-
return prepareTextAnnotation(params);
|
|
27093
|
-
}
|
|
27094
|
-
const sanitizedHash = sanitizeDocxMediaName(attrs.hash, generateDocxRandomId(4));
|
|
27095
|
-
const fileName = `${imageName}_${sanitizedHash}.${type2}`;
|
|
27096
|
-
const relationshipTarget = `media/${fileName}`;
|
|
27097
|
-
const packagePath = `word/${relationshipTarget}`;
|
|
27098
|
-
imageId = addNewImageRelationship(params, relationshipTarget);
|
|
27099
|
-
params.media[packagePath] = src;
|
|
27100
|
-
}
|
|
27101
|
-
const inlineAttrs = attrs.originalPadding || {
|
|
27102
|
-
distT: 0,
|
|
27103
|
-
distB: 0,
|
|
27104
|
-
distL: 0,
|
|
27105
|
-
distR: 0
|
|
27106
|
-
};
|
|
27107
|
-
const xfrmAttrs = {};
|
|
27108
|
-
const effectExtentAttrs = {
|
|
27109
|
-
l: 0,
|
|
27110
|
-
t: 0,
|
|
27111
|
-
r: 0,
|
|
27112
|
-
b: 0
|
|
27113
|
-
};
|
|
27114
|
-
const transformData = attrs.transformData;
|
|
27115
|
-
if (transformData) {
|
|
27116
|
-
if (transformData.rotation) {
|
|
27117
|
-
xfrmAttrs.rot = degreesToRot(transformData.rotation);
|
|
27118
|
-
}
|
|
27119
|
-
if (transformData.verticalFlip) {
|
|
27120
|
-
xfrmAttrs.flipV = "1";
|
|
27121
|
-
}
|
|
27122
|
-
if (transformData.horizontalFlip) {
|
|
27123
|
-
xfrmAttrs.flipH = "1";
|
|
27124
|
-
}
|
|
27125
|
-
if (transformData.sizeExtension) {
|
|
27126
|
-
effectExtentAttrs.l = pixelsToEmu(transformData.sizeExtension.left);
|
|
27127
|
-
effectExtentAttrs.t = pixelsToEmu(transformData.sizeExtension.top);
|
|
27128
|
-
effectExtentAttrs.r = pixelsToEmu(transformData.sizeExtension.right);
|
|
27129
|
-
effectExtentAttrs.b = pixelsToEmu(transformData.sizeExtension.bottom);
|
|
27130
|
-
}
|
|
27131
|
-
}
|
|
27132
|
-
const drawingXmlns = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
27133
|
-
const pictureXmlns = "http://schemas.openxmlformats.org/drawingml/2006/picture";
|
|
27134
|
-
return {
|
|
27135
|
-
attributes: inlineAttrs,
|
|
27136
|
-
elements: [
|
|
27137
|
-
{
|
|
27138
|
-
name: "wp:extent",
|
|
27139
|
-
attributes: {
|
|
27140
|
-
cx: size.w,
|
|
27141
|
-
cy: size.h
|
|
27142
|
-
}
|
|
27143
|
-
},
|
|
27144
|
-
{
|
|
27145
|
-
name: "wp:effectExtent",
|
|
27146
|
-
attributes: effectExtentAttrs
|
|
27147
|
-
},
|
|
27148
|
-
{
|
|
27149
|
-
name: "wp:docPr",
|
|
27150
|
-
attributes: {
|
|
27151
|
-
id: attrs.id || 0,
|
|
27152
|
-
name: attrs.alt || `Picture ${imageName}`
|
|
27153
|
-
}
|
|
27154
|
-
},
|
|
27155
|
-
{
|
|
27156
|
-
name: "wp:cNvGraphicFramePr",
|
|
27157
|
-
elements: [
|
|
27158
|
-
{
|
|
27159
|
-
name: "a:graphicFrameLocks",
|
|
27160
|
-
attributes: {
|
|
27161
|
-
"xmlns:a": drawingXmlns,
|
|
27162
|
-
noChangeAspect: 1
|
|
27163
|
-
}
|
|
27164
|
-
}
|
|
27165
|
-
]
|
|
27166
|
-
},
|
|
27167
|
-
{
|
|
27168
|
-
name: "a:graphic",
|
|
27169
|
-
attributes: { "xmlns:a": drawingXmlns },
|
|
27170
|
-
elements: [
|
|
27171
|
-
{
|
|
27172
|
-
name: "a:graphicData",
|
|
27173
|
-
attributes: { uri: pictureXmlns },
|
|
27174
|
-
elements: [
|
|
27175
|
-
{
|
|
27176
|
-
name: "pic:pic",
|
|
27177
|
-
attributes: { "xmlns:pic": pictureXmlns },
|
|
27178
|
-
elements: [
|
|
27179
|
-
{
|
|
27180
|
-
name: "pic:nvPicPr",
|
|
27181
|
-
elements: [
|
|
27182
|
-
{
|
|
27183
|
-
name: "pic:cNvPr",
|
|
27184
|
-
attributes: {
|
|
27185
|
-
id: attrs.id || 0,
|
|
27186
|
-
name: attrs.title || `Picture ${imageName}`
|
|
27187
|
-
}
|
|
27188
|
-
},
|
|
27189
|
-
{
|
|
27190
|
-
name: "pic:cNvPicPr",
|
|
27191
|
-
elements: [
|
|
27192
|
-
{
|
|
27193
|
-
name: "a:picLocks",
|
|
27194
|
-
attributes: {
|
|
27195
|
-
noChangeAspect: 1,
|
|
27196
|
-
noChangeArrowheads: 1
|
|
27197
|
-
}
|
|
27198
|
-
}
|
|
27199
|
-
]
|
|
27200
|
-
}
|
|
27201
|
-
]
|
|
27202
|
-
},
|
|
27203
|
-
{
|
|
27204
|
-
name: "pic:blipFill",
|
|
27205
|
-
elements: [
|
|
27206
|
-
{
|
|
27207
|
-
name: "a:blip",
|
|
27208
|
-
attributes: {
|
|
27209
|
-
"r:embed": imageId
|
|
27210
|
-
}
|
|
27211
|
-
},
|
|
27212
|
-
{
|
|
27213
|
-
name: "a:stretch",
|
|
27214
|
-
elements: [{ name: "a:fillRect" }]
|
|
27215
|
-
}
|
|
27216
|
-
]
|
|
27217
|
-
},
|
|
27218
|
-
{
|
|
27219
|
-
name: "pic:spPr",
|
|
27220
|
-
attributes: {
|
|
27221
|
-
bwMode: "auto"
|
|
27222
|
-
},
|
|
27223
|
-
elements: [
|
|
27224
|
-
{
|
|
27225
|
-
name: "a:xfrm",
|
|
27226
|
-
attributes: xfrmAttrs,
|
|
27227
|
-
elements: [
|
|
27228
|
-
{
|
|
27229
|
-
name: "a:ext",
|
|
27230
|
-
attributes: {
|
|
27231
|
-
cx: size.w,
|
|
27232
|
-
cy: size.h
|
|
27233
|
-
}
|
|
27234
|
-
},
|
|
27235
|
-
{
|
|
27236
|
-
name: "a:off",
|
|
27237
|
-
attributes: {
|
|
27238
|
-
x: 0,
|
|
27239
|
-
y: 0
|
|
27240
|
-
}
|
|
27241
|
-
}
|
|
27242
|
-
]
|
|
27243
|
-
},
|
|
27244
|
-
{
|
|
27245
|
-
name: "a:prstGeom",
|
|
27246
|
-
attributes: { prst: "rect" },
|
|
27247
|
-
elements: [{ name: "a:avLst" }]
|
|
27248
|
-
},
|
|
27249
|
-
{
|
|
27250
|
-
name: "a:noFill"
|
|
27251
|
-
}
|
|
27252
|
-
]
|
|
27253
|
-
}
|
|
27254
|
-
]
|
|
27255
|
-
}
|
|
27256
|
-
]
|
|
27257
|
-
}
|
|
27258
|
-
]
|
|
27259
|
-
}
|
|
27260
|
-
]
|
|
27261
|
-
};
|
|
27262
|
-
};
|
|
27263
|
-
function getPngDimensions(base64) {
|
|
27264
|
-
if (!base64) return {};
|
|
27265
|
-
const type2 = base64.split(";")[0].split("/")[1];
|
|
27266
|
-
if (!base64 || type2 !== "png") {
|
|
27267
|
-
return {
|
|
27268
|
-
originalWidth: void 0,
|
|
27269
|
-
originalHeight: void 0
|
|
27270
|
-
};
|
|
27271
|
-
}
|
|
27272
|
-
let header = base64.split(",")[1].slice(0, 50);
|
|
27273
|
-
let uint8 = Uint8Array.from(atob(header), (c) => c.charCodeAt(0));
|
|
27274
|
-
let dataView = new DataView(uint8.buffer, 0, 28);
|
|
27275
|
-
return {
|
|
27276
|
-
originalWidth: dataView.getInt32(16),
|
|
27277
|
-
originalHeight: dataView.getInt32(20)
|
|
27278
|
-
};
|
|
27279
|
-
}
|
|
27280
|
-
function getScaledSize(originalWidth, originalHeight, maxWidth, maxHeight) {
|
|
27281
|
-
let scaledWidth = originalWidth;
|
|
27282
|
-
let scaledHeight = originalHeight;
|
|
27283
|
-
let ratio = Math.min(maxWidth / originalWidth, maxHeight / originalHeight);
|
|
27284
|
-
scaledWidth = Math.round(scaledWidth * ratio);
|
|
27285
|
-
scaledHeight = Math.round(scaledHeight * ratio);
|
|
27286
|
-
return { scaledWidth, scaledHeight };
|
|
27287
|
-
}
|
|
27288
|
-
function resizeKeepAspectRatio(width, height, maxWidth) {
|
|
27289
|
-
if (width > maxWidth) {
|
|
27290
|
-
let scale = maxWidth / width;
|
|
27291
|
-
let newHeight = Math.round(height * scale);
|
|
27292
|
-
return { width: maxWidth, height: newHeight };
|
|
27293
|
-
}
|
|
27294
|
-
return { width, height };
|
|
27295
|
-
}
|
|
27296
|
-
function addNewImageRelationship(params, imagePath) {
|
|
27297
|
-
const newId = "rId" + generateDocxRandomId();
|
|
27298
|
-
const newRel = {
|
|
27299
|
-
type: "element",
|
|
27300
|
-
name: "Relationship",
|
|
27301
|
-
attributes: {
|
|
27302
|
-
Id: newId,
|
|
27303
|
-
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
27304
|
-
Target: imagePath
|
|
27305
|
-
}
|
|
27306
|
-
};
|
|
27307
|
-
params.relationships.push(newRel);
|
|
27308
|
-
return newId;
|
|
27309
|
-
}
|
|
27310
|
-
function translateAnchorNode(params) {
|
|
27311
|
-
const { attrs } = params.node;
|
|
27312
|
-
const anchorElements = [];
|
|
27313
|
-
const wrapElements = [];
|
|
27314
|
-
if (attrs.simplePos) {
|
|
27315
|
-
anchorElements.push({
|
|
27316
|
-
name: "wp:simplePos",
|
|
27317
|
-
attributes: {
|
|
27318
|
-
x: 0,
|
|
27319
|
-
y: 0
|
|
27320
|
-
}
|
|
27321
|
-
});
|
|
27322
|
-
}
|
|
27323
|
-
if (attrs.anchorData) {
|
|
27324
|
-
const hElements = [];
|
|
27325
|
-
if (attrs.marginOffset.left !== void 0) {
|
|
27326
|
-
hElements.push({
|
|
27327
|
-
name: "wp:posOffset",
|
|
27328
|
-
elements: [{ type: "text", text: pixelsToEmu(attrs.marginOffset.left).toString() }]
|
|
27329
|
-
});
|
|
27330
|
-
}
|
|
27331
|
-
if (attrs.anchorData.alignH) {
|
|
27332
|
-
hElements.push({
|
|
27333
|
-
name: "wp:align",
|
|
27334
|
-
elements: [{ type: "text", text: attrs.anchorData.alignH }]
|
|
27335
|
-
});
|
|
27336
|
-
}
|
|
27337
|
-
anchorElements.push({
|
|
27338
|
-
name: "wp:positionH",
|
|
27339
|
-
attributes: { relativeFrom: attrs.anchorData.hRelativeFrom },
|
|
27340
|
-
...hElements.length && { elements: hElements }
|
|
27341
|
-
});
|
|
27342
|
-
const vElements = [];
|
|
27343
|
-
if (attrs.marginOffset.top !== void 0) {
|
|
27344
|
-
vElements.push({
|
|
27345
|
-
name: "wp:posOffset",
|
|
27346
|
-
elements: [{ type: "text", text: pixelsToEmu(attrs.marginOffset.top).toString() }]
|
|
27347
|
-
});
|
|
27348
|
-
}
|
|
27349
|
-
if (attrs.anchorData.alignV) {
|
|
27350
|
-
vElements.push({
|
|
27351
|
-
name: "wp:align",
|
|
27352
|
-
elements: [{ type: "text", text: attrs.anchorData.alignV }]
|
|
27353
|
-
});
|
|
27354
|
-
}
|
|
27355
|
-
anchorElements.push({
|
|
27356
|
-
name: "wp:positionV",
|
|
27357
|
-
attributes: { relativeFrom: attrs.anchorData.vRelativeFrom },
|
|
27358
|
-
...vElements.length && { elements: vElements }
|
|
27359
|
-
});
|
|
27360
|
-
}
|
|
27361
|
-
if (attrs.wrapText) {
|
|
27362
|
-
wrapElements.push({
|
|
27363
|
-
name: "wp:wrapSquare",
|
|
27364
|
-
attributes: {
|
|
27365
|
-
wrapText: attrs.wrapText
|
|
27366
|
-
}
|
|
27367
|
-
});
|
|
27368
|
-
}
|
|
27369
|
-
if (attrs.wrapTopAndBottom) {
|
|
27370
|
-
wrapElements.push({
|
|
27371
|
-
name: "wp:wrapTopAndBottom"
|
|
27372
|
-
});
|
|
27373
|
-
}
|
|
27374
|
-
if (!wrapElements.length) {
|
|
27375
|
-
wrapElements.push({
|
|
27376
|
-
name: "wp:wrapNone"
|
|
27377
|
-
});
|
|
27378
|
-
}
|
|
27379
|
-
const nodeElements = translateImageNode(params);
|
|
27380
|
-
const inlineAttrs = {
|
|
27381
|
-
...nodeElements.attributes,
|
|
27382
|
-
simplePos: attrs.originalAttributes?.simplePos,
|
|
27383
|
-
relativeHeight: 1,
|
|
27384
|
-
behindDoc: attrs.originalAttributes?.behindDoc,
|
|
27385
|
-
locked: attrs.originalAttributes?.locked,
|
|
27386
|
-
layoutInCell: attrs.originalAttributes?.layoutInCell,
|
|
27387
|
-
allowOverlap: attrs.originalAttributes?.allowOverlap
|
|
27388
|
-
};
|
|
27389
|
-
const effectIndex = nodeElements.elements.findIndex((el) => el.name === "wp:effectExtent");
|
|
27390
|
-
const elementsWithWrap = [
|
|
27391
|
-
...nodeElements.elements.slice(0, effectIndex + 1),
|
|
27392
|
-
...wrapElements,
|
|
27393
|
-
...nodeElements.elements.slice(effectIndex + 1)
|
|
27394
|
-
];
|
|
27395
|
-
return {
|
|
27396
|
-
name: "wp:anchor",
|
|
27397
|
-
attributes: inlineAttrs,
|
|
27398
|
-
elements: [...anchorElements, ...elementsWithWrap]
|
|
27399
|
-
};
|
|
27400
|
-
}
|
|
27401
|
-
const XML_NODE_NAME$5 = "wp:anchor";
|
|
27402
|
-
const SD_NODE_NAME$5 = ["image"];
|
|
27403
|
-
const validXmlAttributes$5 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
27404
|
-
function encode$c(params) {
|
|
27405
|
-
const { node } = params.extraParams;
|
|
27406
|
-
if (!node || !node.type) {
|
|
27407
|
-
return null;
|
|
27408
|
-
}
|
|
27409
|
-
return handleAnchorNode(params);
|
|
27410
|
-
}
|
|
27411
|
-
function decode$c(params) {
|
|
27412
|
-
const { node } = params;
|
|
27413
|
-
if (!node || !node.type) {
|
|
27414
|
-
return null;
|
|
27415
|
-
}
|
|
27416
|
-
return translateAnchorNode(params);
|
|
27417
|
-
}
|
|
27418
|
-
const config$5 = {
|
|
27419
|
-
xmlName: XML_NODE_NAME$5,
|
|
27420
|
-
sdNodeOrKeyName: SD_NODE_NAME$5,
|
|
27421
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
27422
|
-
encode: encode$c,
|
|
27423
|
-
decode: decode$c,
|
|
27424
|
-
attributes: validXmlAttributes$5
|
|
27425
|
-
};
|
|
27426
|
-
const translator$5 = NodeTranslator.from(config$5);
|
|
27427
|
-
function handleInlineNode(params) {
|
|
27428
|
-
const { node } = params.extraParams;
|
|
27429
|
-
if (node.name !== "wp:inline") {
|
|
27430
|
-
return null;
|
|
27431
|
-
}
|
|
27432
|
-
return handleImageNode(node, params, false);
|
|
27433
|
-
}
|
|
27434
|
-
function translateInlineNode(params) {
|
|
27435
|
-
const nodeElements = translateImageNode(params);
|
|
27436
|
-
return {
|
|
27437
|
-
name: "wp:inline",
|
|
27438
|
-
attributes: nodeElements.attributes,
|
|
27439
|
-
elements: nodeElements.elements
|
|
27440
|
-
};
|
|
27441
|
-
}
|
|
27442
|
-
const XML_NODE_NAME$4 = "wp:inline";
|
|
27443
|
-
const SD_NODE_NAME$4 = ["image"];
|
|
27444
|
-
const validXmlAttributes$4 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
27445
|
-
function encode$b(params) {
|
|
27446
|
-
const { node } = params.extraParams;
|
|
27447
|
-
if (!node || !node.type) {
|
|
27448
|
-
return null;
|
|
27449
|
-
}
|
|
27450
|
-
return handleInlineNode(params);
|
|
27451
|
-
}
|
|
27452
|
-
function decode$b(params) {
|
|
27453
|
-
const { node } = params;
|
|
27454
|
-
if (!node || !node.type) {
|
|
27455
|
-
return null;
|
|
27456
|
-
}
|
|
27457
|
-
return translateInlineNode(params);
|
|
27458
|
-
}
|
|
27459
|
-
const config$4 = {
|
|
27460
|
-
xmlName: XML_NODE_NAME$4,
|
|
27461
|
-
sdNodeOrKeyName: SD_NODE_NAME$4,
|
|
27462
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
27463
|
-
encode: encode$b,
|
|
27464
|
-
decode: decode$b,
|
|
27465
|
-
attributes: validXmlAttributes$4
|
|
27466
|
-
};
|
|
27467
|
-
const translator$4 = NodeTranslator.from(config$4);
|
|
27468
|
-
const encode$a = (attributes) => {
|
|
27469
|
-
return attributes["w:id"];
|
|
27470
|
-
};
|
|
27471
|
-
const decode$a = (attrs) => {
|
|
27472
|
-
return attrs.id;
|
|
27473
|
-
};
|
|
27474
|
-
const attrConfig$6 = Object.freeze({
|
|
27475
|
-
xmlName: "w:id",
|
|
27476
|
-
sdName: "id",
|
|
27477
|
-
encode: encode$a,
|
|
27478
|
-
decode: decode$a
|
|
27479
|
-
});
|
|
27480
|
-
const encode$9 = (attributes) => {
|
|
27481
|
-
return attributes["w:name"];
|
|
27482
|
-
};
|
|
27483
|
-
const decode$9 = (attrs) => {
|
|
27484
|
-
return attrs.name;
|
|
27485
|
-
};
|
|
27486
|
-
const attrConfig$5 = Object.freeze({
|
|
27487
|
-
xmlName: "w:name",
|
|
27488
|
-
sdName: "name",
|
|
27489
|
-
encode: encode$9,
|
|
27490
|
-
decode: decode$9
|
|
27491
|
-
});
|
|
27492
|
-
const encode$8 = (attributes) => {
|
|
27493
|
-
return attributes["w:colFirst"];
|
|
27494
|
-
};
|
|
27495
|
-
const decode$8 = (attrs) => {
|
|
27496
|
-
return attrs.colFirst;
|
|
27497
|
-
};
|
|
27498
|
-
const attrConfig$4 = Object.freeze({
|
|
27499
|
-
xmlName: "w:colFirst",
|
|
27500
|
-
sdName: "colFirst",
|
|
27501
|
-
encode: encode$8,
|
|
27502
|
-
decode: decode$8
|
|
27503
|
-
});
|
|
27504
|
-
const encode$7 = (attributes) => {
|
|
27505
|
-
return attributes["w:colLast"];
|
|
27506
|
-
};
|
|
27507
|
-
const decode$7 = (attrs) => {
|
|
27508
|
-
return attrs.colLast;
|
|
27509
|
-
};
|
|
27510
|
-
const attrConfig$3 = Object.freeze({
|
|
27511
|
-
xmlName: "w:colLast",
|
|
27512
|
-
sdName: "colLast",
|
|
27513
|
-
encode: encode$7,
|
|
27514
|
-
decode: decode$7
|
|
27515
|
-
});
|
|
27516
|
-
const encode$6 = (attributes) => {
|
|
27517
|
-
return attributes["w:displacedByCustomXml"];
|
|
27518
|
-
};
|
|
27519
|
-
const decode$6 = (attrs) => {
|
|
27520
|
-
return attrs.displacedByCustomXml;
|
|
27521
|
-
};
|
|
27522
|
-
const attrConfig$2 = Object.freeze({
|
|
27523
|
-
xmlName: "w:displacedByCustomXml",
|
|
27524
|
-
sdName: "displacedByCustomXml",
|
|
27525
|
-
encode: encode$6,
|
|
27526
|
-
decode: decode$6
|
|
27527
|
-
});
|
|
27528
|
-
const validXmlAttributes$3 = [attrConfig$6, attrConfig$5, attrConfig$4, attrConfig$3, attrConfig$2];
|
|
27529
|
-
const XML_NODE_NAME$3 = "w:bookmarkStart";
|
|
27530
|
-
const SD_NODE_NAME$3 = "bookmarkStart";
|
|
27531
|
-
const encode$5 = (params, encodedAttrs = {}) => {
|
|
27532
|
-
return {
|
|
27533
|
-
type: "bookmarkStart",
|
|
27534
|
-
attrs: encodedAttrs
|
|
27535
|
-
};
|
|
27536
|
-
};
|
|
27537
|
-
const decode$5 = (params, decodedAttrs = {}) => {
|
|
27538
|
-
const result = {
|
|
27539
|
-
name: "w:bookmarkStart",
|
|
27540
|
-
elements: []
|
|
27541
|
-
};
|
|
27542
|
-
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
27543
|
-
result.attributes = decodedAttrs;
|
|
27544
|
-
}
|
|
27545
|
-
return result;
|
|
27546
|
-
};
|
|
27547
|
-
const config$3 = {
|
|
27548
|
-
xmlName: XML_NODE_NAME$3,
|
|
27549
|
-
sdNodeOrKeyName: SD_NODE_NAME$3,
|
|
27550
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
27551
|
-
encode: encode$5,
|
|
27552
|
-
decode: decode$5,
|
|
27553
|
-
attributes: validXmlAttributes$3
|
|
27554
|
-
};
|
|
27555
|
-
const translator$3 = NodeTranslator.from(config$3);
|
|
27556
|
-
const encode$4 = (attributes) => {
|
|
27557
|
-
return attributes["w:id"];
|
|
27558
|
-
};
|
|
27559
|
-
const decode$4 = (attrs) => {
|
|
27560
|
-
return attrs.id;
|
|
27561
|
-
};
|
|
27562
|
-
const attrConfig$1 = Object.freeze({
|
|
27563
|
-
xmlName: "w:id",
|
|
27564
|
-
sdName: "id",
|
|
27565
|
-
encode: encode$4,
|
|
27566
|
-
decode: decode$4
|
|
27567
|
-
});
|
|
27568
|
-
const encode$3 = (attributes) => {
|
|
27569
|
-
return attributes["w:displacedByCustomXml"];
|
|
27570
|
-
};
|
|
27571
|
-
const decode$3 = (attrs) => {
|
|
27572
|
-
return attrs.displacedByCustomXml;
|
|
27573
|
-
};
|
|
27574
|
-
const attrConfig = Object.freeze({
|
|
27575
|
-
xmlName: "w:displacedByCustomXml",
|
|
27576
|
-
sdName: "displacedByCustomXml",
|
|
27577
|
-
encode: encode$3,
|
|
27578
|
-
decode: decode$3
|
|
27579
|
-
});
|
|
27580
|
-
const validXmlAttributes$2 = [attrConfig$1, attrConfig];
|
|
27581
|
-
const XML_NODE_NAME$2 = "w:bookmarkEnd";
|
|
27582
|
-
const SD_NODE_NAME$2 = "bookmarkEnd";
|
|
27583
|
-
const encode$2 = (params, encodedAttrs = {}) => {
|
|
27584
|
-
return {
|
|
27585
|
-
type: "bookmarkEnd",
|
|
27586
|
-
attrs: encodedAttrs
|
|
27587
|
-
};
|
|
27588
|
-
};
|
|
27589
|
-
const decode$2 = (params, decodedAttrs = {}) => {
|
|
27590
|
-
const result = {
|
|
27591
|
-
name: "w:bookmarkEnd",
|
|
27592
|
-
elements: []
|
|
27593
|
-
};
|
|
27594
|
-
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
27595
|
-
result.attributes = decodedAttrs;
|
|
27596
|
-
}
|
|
27597
|
-
return result;
|
|
27598
|
-
};
|
|
27599
|
-
const config$2 = {
|
|
27600
|
-
xmlName: XML_NODE_NAME$2,
|
|
27601
|
-
sdNodeOrKeyName: SD_NODE_NAME$2,
|
|
27602
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
27603
|
-
encode: encode$2,
|
|
27604
|
-
decode: decode$2,
|
|
27605
|
-
attributes: validXmlAttributes$2
|
|
27606
|
-
};
|
|
27607
|
-
const translator$2 = NodeTranslator.from(config$2);
|
|
27608
|
-
const registeredHandlers = Object.freeze({
|
|
27609
|
-
"w:br": translator$V,
|
|
27610
|
-
"w:tab": translator$U,
|
|
27611
|
-
"w:p": translator$T,
|
|
27612
|
-
"wp:anchor": translator$5,
|
|
27613
|
-
"wp:inline": translator$4,
|
|
27614
|
-
"w:bookmarkStart": translator$3,
|
|
27615
|
-
"w:bookmarkEnd": translator$2
|
|
27616
|
-
});
|
|
27617
|
-
const XML_NODE_NAME$1 = "w:drawing";
|
|
27618
|
-
const SD_NODE_NAME$1 = [];
|
|
27619
|
-
const validXmlAttributes$1 = [];
|
|
27620
|
-
function encode$1(params) {
|
|
27621
|
-
const nodes = params.nodes;
|
|
27622
|
-
const node = nodes[0];
|
|
27623
|
-
const validChildTranslators = ["wp:anchor", "wp:inline"];
|
|
27624
|
-
return node.elements.reduce((acc, child) => {
|
|
27625
|
-
if (acc) return acc;
|
|
27626
|
-
if (!validChildTranslators.includes(child.name)) return acc;
|
|
27627
|
-
const translator2 = registeredHandlers[child.name];
|
|
27628
|
-
return translator2.encode({ ...params, extraParams: { node: child } }) || acc;
|
|
27629
|
-
}, null);
|
|
26331
|
+
content: translatedContent,
|
|
26332
|
+
marks,
|
|
26333
|
+
attrs: {
|
|
26334
|
+
sdtPr
|
|
26335
|
+
}
|
|
26336
|
+
};
|
|
26337
|
+
return result;
|
|
27630
26338
|
}
|
|
27631
|
-
function
|
|
27632
|
-
const
|
|
27633
|
-
|
|
27634
|
-
|
|
26339
|
+
function sdtNodeTypeStrategy(node) {
|
|
26340
|
+
const sdtContent = node.elements.find((el) => el.name === "w:sdtContent");
|
|
26341
|
+
const sdtPr = node.elements.find((el) => el.name === "w:sdtPr");
|
|
26342
|
+
const tag = sdtPr?.elements.find((el) => el.name === "w:tag");
|
|
26343
|
+
const tagValue = tag?.attributes?.["w:val"];
|
|
26344
|
+
const docPartObj = sdtPr?.elements.find((el) => el.name === "w:docPartObj");
|
|
26345
|
+
if (docPartObj) {
|
|
26346
|
+
return { type: "docPartObj", handler: handleDocPartObj };
|
|
27635
26347
|
}
|
|
27636
|
-
|
|
27637
|
-
|
|
27638
|
-
|
|
27639
|
-
|
|
27640
|
-
|
|
27641
|
-
|
|
27642
|
-
|
|
27643
|
-
|
|
27644
|
-
|
|
26348
|
+
if (tagValue) {
|
|
26349
|
+
const shouldProcessAsJson = tagValue.startsWith("{") && tagValue.endsWith("}");
|
|
26350
|
+
if (shouldProcessAsJson) {
|
|
26351
|
+
const parsedTag = parseTagValueJSON(tagValue);
|
|
26352
|
+
if (parsedTag.type === "documentSection") {
|
|
26353
|
+
return { type: "documentSection", handler: handleDocumentSectionNode };
|
|
26354
|
+
}
|
|
26355
|
+
if (parsedTag.fieldId && parsedTag.fieldTypeShort) {
|
|
26356
|
+
return { type: "fieldAnnotation", handler: handleAnnotationNode };
|
|
26357
|
+
}
|
|
26358
|
+
} else {
|
|
26359
|
+
const fieldTypeShort = sdtPr.elements.find((el) => el.name === "w:fieldTypeShort");
|
|
26360
|
+
const fieldTypeShortValue = fieldTypeShort?.attributes["w:val"];
|
|
26361
|
+
if (tagValue && fieldTypeShortValue) {
|
|
26362
|
+
return { type: "fieldAnnotation", handler: handleAnnotationNode };
|
|
26363
|
+
}
|
|
26364
|
+
}
|
|
26365
|
+
}
|
|
26366
|
+
if (sdtContent) {
|
|
26367
|
+
return { type: "structuredContent", handler: handleStructuredContentNode };
|
|
26368
|
+
}
|
|
26369
|
+
return { type: "unknown", handler: null };
|
|
27645
26370
|
}
|
|
27646
|
-
const config$1 = {
|
|
27647
|
-
xmlName: XML_NODE_NAME$1,
|
|
27648
|
-
sdNodeOrKeyName: SD_NODE_NAME$1,
|
|
27649
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
27650
|
-
encode: encode$1,
|
|
27651
|
-
decode: decode$1,
|
|
27652
|
-
attributes: validXmlAttributes$1
|
|
27653
|
-
};
|
|
27654
|
-
const translator$1 = NodeTranslator.from(config$1);
|
|
27655
26371
|
class CommandService {
|
|
27656
26372
|
/**
|
|
27657
26373
|
* @param {import('./commands/types/index.js').CommandServiceOptions} props
|
|
@@ -28989,10 +27705,7 @@ function prepareTextAnnotation(params) {
|
|
|
28989
27705
|
return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params);
|
|
28990
27706
|
}
|
|
28991
27707
|
function prepareImageAnnotation(params, imageSize) {
|
|
28992
|
-
return
|
|
28993
|
-
...params,
|
|
28994
|
-
imageSize
|
|
28995
|
-
});
|
|
27708
|
+
return translateImageNode(params, imageSize);
|
|
28996
27709
|
}
|
|
28997
27710
|
function prepareCheckboxAnnotation(params) {
|
|
28998
27711
|
const {
|
|
@@ -29229,7 +27942,7 @@ function translateStructuredContent(params) {
|
|
|
29229
27942
|
const XML_NODE_NAME = "w:sdt";
|
|
29230
27943
|
const SD_NODE_NAME = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
|
|
29231
27944
|
const validXmlAttributes = [];
|
|
29232
|
-
function encode(params) {
|
|
27945
|
+
function encode(params, encodedAttrs) {
|
|
29233
27946
|
const nodes = params.nodes;
|
|
29234
27947
|
const node = nodes[0];
|
|
29235
27948
|
const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
|
|
@@ -29239,7 +27952,7 @@ function encode(params) {
|
|
|
29239
27952
|
const result = handler2(params);
|
|
29240
27953
|
return result;
|
|
29241
27954
|
}
|
|
29242
|
-
function decode(params) {
|
|
27955
|
+
function decode(params, decodedAttrs) {
|
|
29243
27956
|
const { node } = params;
|
|
29244
27957
|
if (!node || !node.type) {
|
|
29245
27958
|
return null;
|
|
@@ -29270,20 +27983,19 @@ function exportSchemaToJson(params) {
|
|
|
29270
27983
|
doc: translateDocumentNode,
|
|
29271
27984
|
body: translateBodyNode,
|
|
29272
27985
|
heading: translateHeadingNode,
|
|
29273
|
-
paragraph: translator$
|
|
27986
|
+
paragraph: translator$h,
|
|
29274
27987
|
text: translateTextNode,
|
|
29275
27988
|
bulletList: translateList,
|
|
29276
27989
|
orderedList: translateList,
|
|
29277
|
-
lineBreak: translator$
|
|
29278
|
-
table:
|
|
29279
|
-
tableRow: translator$
|
|
29280
|
-
tableCell: translator$
|
|
29281
|
-
bookmarkStart:
|
|
29282
|
-
bookmarkEnd: translator$2,
|
|
27990
|
+
lineBreak: translator$j,
|
|
27991
|
+
table: translateTable,
|
|
27992
|
+
tableRow: translator$3,
|
|
27993
|
+
tableCell: translator$2,
|
|
27994
|
+
bookmarkStart: translateBookmarkStart,
|
|
29283
27995
|
fieldAnnotation: translator,
|
|
29284
|
-
tab: translator$
|
|
29285
|
-
image:
|
|
29286
|
-
hardBreak: translator$
|
|
27996
|
+
tab: translator$i,
|
|
27997
|
+
image: translateImageNode,
|
|
27998
|
+
hardBreak: translator$j,
|
|
29287
27999
|
commentRangeStart: () => translateCommentNode(params, "Start"),
|
|
29288
28000
|
commentRangeEnd: () => translateCommentNode(params, "End"),
|
|
29289
28001
|
commentReference: () => null,
|
|
@@ -29615,7 +28327,7 @@ function translateTextNode(params) {
|
|
|
29615
28327
|
const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
|
|
29616
28328
|
if (isTrackedNode) return translateTrackedNode(params);
|
|
29617
28329
|
const isLinkNode = node.marks?.some((m2) => m2.type === "link");
|
|
29618
|
-
if (isLinkNode) return translator$
|
|
28330
|
+
if (isLinkNode) return translator$1.decode(params);
|
|
29619
28331
|
const { text, marks = [] } = node;
|
|
29620
28332
|
return getTextNodeForExport(text, marks, params);
|
|
29621
28333
|
}
|
|
@@ -29748,6 +28460,20 @@ function addNewLinkRelationship(params, link) {
|
|
|
29748
28460
|
});
|
|
29749
28461
|
return newId;
|
|
29750
28462
|
}
|
|
28463
|
+
function addNewImageRelationship(params, imagePath) {
|
|
28464
|
+
const newId = "rId" + generateDocxRandomId();
|
|
28465
|
+
const newRel = {
|
|
28466
|
+
type: "element",
|
|
28467
|
+
name: "Relationship",
|
|
28468
|
+
attributes: {
|
|
28469
|
+
Id: newId,
|
|
28470
|
+
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
28471
|
+
Target: imagePath
|
|
28472
|
+
}
|
|
28473
|
+
};
|
|
28474
|
+
params.relationships.push(newRel);
|
|
28475
|
+
return newId;
|
|
28476
|
+
}
|
|
29751
28477
|
function translateList(params) {
|
|
29752
28478
|
const { node, editor } = params;
|
|
29753
28479
|
const listItem = node.content[0];
|
|
@@ -29890,6 +28616,147 @@ const generateNumPrTag = (numId, level) => {
|
|
|
29890
28616
|
]
|
|
29891
28617
|
};
|
|
29892
28618
|
};
|
|
28619
|
+
function translateTable(params) {
|
|
28620
|
+
params.node = preProcessVerticalMergeCells(params.node, params);
|
|
28621
|
+
const elements = translateChildNodes(params);
|
|
28622
|
+
const tableProperties = generateTableProperties(params.node);
|
|
28623
|
+
const gridProperties = generateTableGrid(params.node, params);
|
|
28624
|
+
elements.unshift(tableProperties);
|
|
28625
|
+
elements.unshift(gridProperties);
|
|
28626
|
+
return {
|
|
28627
|
+
name: "w:tbl",
|
|
28628
|
+
elements
|
|
28629
|
+
};
|
|
28630
|
+
}
|
|
28631
|
+
function generateTableProperties(node) {
|
|
28632
|
+
const elements = [];
|
|
28633
|
+
const { attrs } = node;
|
|
28634
|
+
const { tableWidth, tableStyleId, borders, tableIndent, tableLayout, tableCellSpacing, justification } = attrs;
|
|
28635
|
+
if (tableStyleId) {
|
|
28636
|
+
const tableStyleElement = {
|
|
28637
|
+
name: "w:tblStyle",
|
|
28638
|
+
attributes: { "w:val": tableStyleId }
|
|
28639
|
+
};
|
|
28640
|
+
elements.push(tableStyleElement);
|
|
28641
|
+
}
|
|
28642
|
+
if (borders) {
|
|
28643
|
+
const borderElement = generateTableBorders(node);
|
|
28644
|
+
elements.push(borderElement);
|
|
28645
|
+
}
|
|
28646
|
+
if (tableIndent) {
|
|
28647
|
+
const { width, type: type2 } = tableIndent;
|
|
28648
|
+
const tableIndentElement = {
|
|
28649
|
+
name: "w:tblInd",
|
|
28650
|
+
attributes: { "w:w": pixelsToTwips(width), "w:type": type2 }
|
|
28651
|
+
};
|
|
28652
|
+
elements.push(tableIndentElement);
|
|
28653
|
+
}
|
|
28654
|
+
if (tableLayout) {
|
|
28655
|
+
const tableLayoutElement = {
|
|
28656
|
+
name: "w:tblLayout",
|
|
28657
|
+
attributes: { "w:type": tableLayout }
|
|
28658
|
+
};
|
|
28659
|
+
elements.push(tableLayoutElement);
|
|
28660
|
+
}
|
|
28661
|
+
if (tableWidth && tableWidth.width) {
|
|
28662
|
+
const tableWidthElement = {
|
|
28663
|
+
name: "w:tblW",
|
|
28664
|
+
attributes: { "w:w": pixelsToTwips(tableWidth.width), "w:type": tableWidth.type }
|
|
28665
|
+
};
|
|
28666
|
+
elements.push(tableWidthElement);
|
|
28667
|
+
}
|
|
28668
|
+
if (tableCellSpacing) {
|
|
28669
|
+
elements.push({
|
|
28670
|
+
name: "w:tblCellSpacing",
|
|
28671
|
+
attributes: {
|
|
28672
|
+
"w:w": tableCellSpacing.w,
|
|
28673
|
+
"w:type": tableCellSpacing.type
|
|
28674
|
+
}
|
|
28675
|
+
});
|
|
28676
|
+
}
|
|
28677
|
+
if (justification) {
|
|
28678
|
+
const justificationElement = {
|
|
28679
|
+
name: "w:jc",
|
|
28680
|
+
attributes: { "w:val": justification }
|
|
28681
|
+
};
|
|
28682
|
+
elements.push(justificationElement);
|
|
28683
|
+
}
|
|
28684
|
+
return {
|
|
28685
|
+
name: "w:tblPr",
|
|
28686
|
+
elements
|
|
28687
|
+
};
|
|
28688
|
+
}
|
|
28689
|
+
function generateTableBorders(node) {
|
|
28690
|
+
const { borders } = node.attrs;
|
|
28691
|
+
const elements = [];
|
|
28692
|
+
if (!borders) return;
|
|
28693
|
+
const borderTypes = ["top", "bottom", "left", "right", "insideH", "insideV"];
|
|
28694
|
+
borderTypes.forEach((type2) => {
|
|
28695
|
+
const border = borders[type2];
|
|
28696
|
+
if (!border) return;
|
|
28697
|
+
let attributes = {};
|
|
28698
|
+
if (!Object.keys(border).length || !border.size) {
|
|
28699
|
+
attributes = {
|
|
28700
|
+
"w:val": "nil"
|
|
28701
|
+
};
|
|
28702
|
+
} else {
|
|
28703
|
+
attributes = {
|
|
28704
|
+
"w:val": "single",
|
|
28705
|
+
"w:sz": pixelsToEightPoints(border.size),
|
|
28706
|
+
"w:space": border.space || 0,
|
|
28707
|
+
"w:color": border?.color?.substring(1) || "000000"
|
|
28708
|
+
};
|
|
28709
|
+
}
|
|
28710
|
+
const borderElement = {
|
|
28711
|
+
name: `w:${type2}`,
|
|
28712
|
+
attributes
|
|
28713
|
+
};
|
|
28714
|
+
elements.push(borderElement);
|
|
28715
|
+
});
|
|
28716
|
+
return {
|
|
28717
|
+
name: "w:tblBorders",
|
|
28718
|
+
elements
|
|
28719
|
+
};
|
|
28720
|
+
}
|
|
28721
|
+
function generateTableGrid(node, params) {
|
|
28722
|
+
const { editorSchema } = params;
|
|
28723
|
+
let colgroup = [];
|
|
28724
|
+
try {
|
|
28725
|
+
const pmNode = editorSchema.nodeFromJSON(node);
|
|
28726
|
+
const cellMinWidth = 10;
|
|
28727
|
+
const { colgroupValues } = createColGroup(pmNode, cellMinWidth);
|
|
28728
|
+
colgroup = colgroupValues;
|
|
28729
|
+
} catch {
|
|
28730
|
+
colgroup = [];
|
|
28731
|
+
}
|
|
28732
|
+
const elements = [];
|
|
28733
|
+
colgroup?.forEach((width) => {
|
|
28734
|
+
elements.push({
|
|
28735
|
+
name: "w:gridCol",
|
|
28736
|
+
attributes: { "w:w": pixelsToTwips(width) }
|
|
28737
|
+
});
|
|
28738
|
+
});
|
|
28739
|
+
return {
|
|
28740
|
+
name: "w:tblGrid",
|
|
28741
|
+
elements
|
|
28742
|
+
};
|
|
28743
|
+
}
|
|
28744
|
+
function translateBookmarkStart(params) {
|
|
28745
|
+
const bookmarkStartNode = {
|
|
28746
|
+
name: "w:bookmarkStart",
|
|
28747
|
+
attributes: {
|
|
28748
|
+
"w:id": params.node.attrs.id,
|
|
28749
|
+
"w:name": params.node.attrs.name
|
|
28750
|
+
}
|
|
28751
|
+
};
|
|
28752
|
+
const bookmarkEndNode = {
|
|
28753
|
+
name: "w:bookmarkEnd",
|
|
28754
|
+
attributes: {
|
|
28755
|
+
"w:id": params.node.attrs.id
|
|
28756
|
+
}
|
|
28757
|
+
};
|
|
28758
|
+
return [bookmarkStartNode, bookmarkEndNode];
|
|
28759
|
+
}
|
|
29893
28760
|
function translateMark(mark) {
|
|
29894
28761
|
const xmlMark = SuperConverter.markTypes.find((m2) => m2.type === mark.type);
|
|
29895
28762
|
if (!xmlMark) {
|
|
@@ -29963,7 +28830,346 @@ function translateMark(mark) {
|
|
|
29963
28830
|
markElement.name = "w:shd";
|
|
29964
28831
|
break;
|
|
29965
28832
|
}
|
|
29966
|
-
return markElement;
|
|
28833
|
+
return markElement;
|
|
28834
|
+
}
|
|
28835
|
+
function getPngDimensions(base64) {
|
|
28836
|
+
if (!base64) return {};
|
|
28837
|
+
const type2 = base64.split(";")[0].split("/")[1];
|
|
28838
|
+
if (!base64 || type2 !== "png") {
|
|
28839
|
+
return {
|
|
28840
|
+
originalWidth: void 0,
|
|
28841
|
+
originalHeight: void 0
|
|
28842
|
+
};
|
|
28843
|
+
}
|
|
28844
|
+
let header = base64.split(",")[1].slice(0, 50);
|
|
28845
|
+
let uint8 = Uint8Array.from(atob(header), (c) => c.charCodeAt(0));
|
|
28846
|
+
let dataView = new DataView(uint8.buffer, 0, 28);
|
|
28847
|
+
return {
|
|
28848
|
+
originalWidth: dataView.getInt32(16),
|
|
28849
|
+
originalHeight: dataView.getInt32(20)
|
|
28850
|
+
};
|
|
28851
|
+
}
|
|
28852
|
+
function getScaledSize(originalWidth, originalHeight, maxWidth, maxHeight) {
|
|
28853
|
+
let scaledWidth = originalWidth;
|
|
28854
|
+
let scaledHeight = originalHeight;
|
|
28855
|
+
let ratio = Math.min(maxWidth / originalWidth, maxHeight / originalHeight);
|
|
28856
|
+
scaledWidth = Math.round(scaledWidth * ratio);
|
|
28857
|
+
scaledHeight = Math.round(scaledHeight * ratio);
|
|
28858
|
+
return { scaledWidth, scaledHeight };
|
|
28859
|
+
}
|
|
28860
|
+
function translateImageNode(params, imageSize) {
|
|
28861
|
+
const {
|
|
28862
|
+
node: { attrs = {} },
|
|
28863
|
+
tableCell
|
|
28864
|
+
} = params;
|
|
28865
|
+
let imageId = attrs.rId;
|
|
28866
|
+
const src = attrs.src || attrs.imageSrc;
|
|
28867
|
+
const { originalWidth, originalHeight } = getPngDimensions(src);
|
|
28868
|
+
let imageName;
|
|
28869
|
+
if (params.node.type === "image") {
|
|
28870
|
+
if (src?.startsWith("data:")) {
|
|
28871
|
+
imageName = getFallbackImageNameFromDataUri(src);
|
|
28872
|
+
} else {
|
|
28873
|
+
imageName = src?.split("/").pop();
|
|
28874
|
+
}
|
|
28875
|
+
} else {
|
|
28876
|
+
imageName = attrs.fieldId;
|
|
28877
|
+
}
|
|
28878
|
+
imageName = sanitizeDocxMediaName(imageName);
|
|
28879
|
+
let size = attrs.size ? {
|
|
28880
|
+
w: pixelsToEmu(attrs.size.width),
|
|
28881
|
+
h: pixelsToEmu(attrs.size.height)
|
|
28882
|
+
} : imageSize;
|
|
28883
|
+
if (originalWidth && originalHeight) {
|
|
28884
|
+
const boxWidthPx = emuToPixels(size.w);
|
|
28885
|
+
const boxHeightPx = emuToPixels(size.h);
|
|
28886
|
+
const { scaledWidth, scaledHeight } = getScaledSize(originalWidth, originalHeight, boxWidthPx, boxHeightPx);
|
|
28887
|
+
size = {
|
|
28888
|
+
w: pixelsToEmu(scaledWidth),
|
|
28889
|
+
h: pixelsToEmu(scaledHeight)
|
|
28890
|
+
};
|
|
28891
|
+
}
|
|
28892
|
+
if (tableCell) {
|
|
28893
|
+
const colwidthSum = tableCell.attrs.colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
28894
|
+
const leftMargin = tableCell.attrs.cellMargins?.left || 8;
|
|
28895
|
+
const rightMargin = tableCell.attrs.cellMargins?.right || 8;
|
|
28896
|
+
const maxWidthEmu = pixelsToEmu(colwidthSum - (leftMargin + rightMargin));
|
|
28897
|
+
const { width: w2, height: h2 } = resizeKeepAspectRatio(size.w, size.h, maxWidthEmu);
|
|
28898
|
+
if (w2 && h2) size = { w: w2, h: h2 };
|
|
28899
|
+
}
|
|
28900
|
+
if (params.node.type === "image" && !imageId) {
|
|
28901
|
+
const path = src?.split("word/")[1];
|
|
28902
|
+
imageId = addNewImageRelationship(params, path);
|
|
28903
|
+
} else if (params.node.type === "fieldAnnotation" && !imageId) {
|
|
28904
|
+
const type2 = src?.split(";")[0].split("/")[1];
|
|
28905
|
+
if (!type2) {
|
|
28906
|
+
return prepareTextAnnotation(params);
|
|
28907
|
+
}
|
|
28908
|
+
const sanitizedHash = sanitizeDocxMediaName(attrs.hash, generateDocxRandomId(4));
|
|
28909
|
+
const fileName = `${imageName}_${sanitizedHash}.${type2}`;
|
|
28910
|
+
const relationshipTarget = `media/${fileName}`;
|
|
28911
|
+
const packagePath = `word/${relationshipTarget}`;
|
|
28912
|
+
imageId = addNewImageRelationship(params, relationshipTarget);
|
|
28913
|
+
params.media[packagePath] = src;
|
|
28914
|
+
}
|
|
28915
|
+
let inlineAttrs = attrs.originalPadding || {
|
|
28916
|
+
distT: 0,
|
|
28917
|
+
distB: 0,
|
|
28918
|
+
distL: 0,
|
|
28919
|
+
distR: 0
|
|
28920
|
+
};
|
|
28921
|
+
const anchorElements = [];
|
|
28922
|
+
let wrapProp = [];
|
|
28923
|
+
if (attrs.isAnchor) {
|
|
28924
|
+
inlineAttrs = {
|
|
28925
|
+
...inlineAttrs,
|
|
28926
|
+
simplePos: attrs.originalAttributes?.simplePos,
|
|
28927
|
+
relativeHeight: 1,
|
|
28928
|
+
behindDoc: attrs.originalAttributes?.behindDoc,
|
|
28929
|
+
locked: attrs.originalAttributes?.locked,
|
|
28930
|
+
layoutInCell: attrs.originalAttributes?.layoutInCell,
|
|
28931
|
+
allowOverlap: attrs.originalAttributes?.allowOverlap
|
|
28932
|
+
};
|
|
28933
|
+
if (attrs.simplePos) {
|
|
28934
|
+
anchorElements.push({
|
|
28935
|
+
name: "wp:simplePos",
|
|
28936
|
+
attributes: {
|
|
28937
|
+
x: 0,
|
|
28938
|
+
y: 0
|
|
28939
|
+
}
|
|
28940
|
+
});
|
|
28941
|
+
}
|
|
28942
|
+
if (attrs.anchorData) {
|
|
28943
|
+
anchorElements.push({
|
|
28944
|
+
name: "wp:positionH",
|
|
28945
|
+
attributes: {
|
|
28946
|
+
relativeFrom: attrs.anchorData.hRelativeFrom
|
|
28947
|
+
},
|
|
28948
|
+
...attrs.marginOffset.left !== void 0 && {
|
|
28949
|
+
elements: [
|
|
28950
|
+
{
|
|
28951
|
+
name: "wp:posOffset",
|
|
28952
|
+
elements: [
|
|
28953
|
+
{
|
|
28954
|
+
type: "text",
|
|
28955
|
+
text: pixelsToEmu(attrs.marginOffset.left).toString()
|
|
28956
|
+
}
|
|
28957
|
+
]
|
|
28958
|
+
}
|
|
28959
|
+
]
|
|
28960
|
+
},
|
|
28961
|
+
...attrs.anchorData.alignH && {
|
|
28962
|
+
elements: [
|
|
28963
|
+
{
|
|
28964
|
+
name: "wp:align",
|
|
28965
|
+
elements: [
|
|
28966
|
+
{
|
|
28967
|
+
type: "text",
|
|
28968
|
+
text: attrs.anchorData.alignH
|
|
28969
|
+
}
|
|
28970
|
+
]
|
|
28971
|
+
}
|
|
28972
|
+
]
|
|
28973
|
+
}
|
|
28974
|
+
});
|
|
28975
|
+
anchorElements.push({
|
|
28976
|
+
name: "wp:positionV",
|
|
28977
|
+
attributes: {
|
|
28978
|
+
relativeFrom: attrs.anchorData.vRelativeFrom
|
|
28979
|
+
},
|
|
28980
|
+
...attrs.marginOffset.top !== void 0 && {
|
|
28981
|
+
elements: [
|
|
28982
|
+
{
|
|
28983
|
+
name: "wp:posOffset",
|
|
28984
|
+
elements: [
|
|
28985
|
+
{
|
|
28986
|
+
type: "text",
|
|
28987
|
+
text: pixelsToEmu(attrs.marginOffset.top).toString()
|
|
28988
|
+
}
|
|
28989
|
+
]
|
|
28990
|
+
}
|
|
28991
|
+
]
|
|
28992
|
+
},
|
|
28993
|
+
...attrs.anchorData.alignV && {
|
|
28994
|
+
elements: [
|
|
28995
|
+
{
|
|
28996
|
+
name: "wp:align",
|
|
28997
|
+
elements: [
|
|
28998
|
+
{
|
|
28999
|
+
type: "text",
|
|
29000
|
+
text: attrs.anchorData.alignV
|
|
29001
|
+
}
|
|
29002
|
+
]
|
|
29003
|
+
}
|
|
29004
|
+
]
|
|
29005
|
+
}
|
|
29006
|
+
});
|
|
29007
|
+
}
|
|
29008
|
+
if (attrs.wrapText) {
|
|
29009
|
+
wrapProp.push({
|
|
29010
|
+
name: "wp:wrapSquare",
|
|
29011
|
+
attributes: {
|
|
29012
|
+
wrapText: attrs.wrapText
|
|
29013
|
+
}
|
|
29014
|
+
});
|
|
29015
|
+
}
|
|
29016
|
+
if (attrs.wrapTopAndBottom) {
|
|
29017
|
+
wrapProp.push({
|
|
29018
|
+
name: "wp:wrapTopAndBottom"
|
|
29019
|
+
});
|
|
29020
|
+
}
|
|
29021
|
+
if (attrs.isAnchor && !wrapProp.length) {
|
|
29022
|
+
wrapProp.push({
|
|
29023
|
+
name: "wp:wrapNone"
|
|
29024
|
+
});
|
|
29025
|
+
}
|
|
29026
|
+
}
|
|
29027
|
+
const drawingXmlns = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
29028
|
+
const pictureXmlns = "http://schemas.openxmlformats.org/drawingml/2006/picture";
|
|
29029
|
+
const textNode = wrapTextInRun(
|
|
29030
|
+
{
|
|
29031
|
+
name: "w:drawing",
|
|
29032
|
+
elements: [
|
|
29033
|
+
{
|
|
29034
|
+
name: attrs.isAnchor ? "wp:anchor" : "wp:inline",
|
|
29035
|
+
attributes: inlineAttrs,
|
|
29036
|
+
elements: [
|
|
29037
|
+
...anchorElements,
|
|
29038
|
+
{
|
|
29039
|
+
name: "wp:extent",
|
|
29040
|
+
attributes: {
|
|
29041
|
+
cx: size.w,
|
|
29042
|
+
cy: size.h
|
|
29043
|
+
}
|
|
29044
|
+
},
|
|
29045
|
+
{
|
|
29046
|
+
name: "wp:effectExtent",
|
|
29047
|
+
attributes: {
|
|
29048
|
+
l: 0,
|
|
29049
|
+
t: 0,
|
|
29050
|
+
r: 0,
|
|
29051
|
+
b: 0
|
|
29052
|
+
}
|
|
29053
|
+
},
|
|
29054
|
+
...wrapProp,
|
|
29055
|
+
{
|
|
29056
|
+
name: "wp:docPr",
|
|
29057
|
+
attributes: {
|
|
29058
|
+
id: attrs.id || 0,
|
|
29059
|
+
name: attrs.alt || `Picture ${imageName}`
|
|
29060
|
+
}
|
|
29061
|
+
},
|
|
29062
|
+
{
|
|
29063
|
+
name: "wp:cNvGraphicFramePr",
|
|
29064
|
+
elements: [
|
|
29065
|
+
{
|
|
29066
|
+
name: "a:graphicFrameLocks",
|
|
29067
|
+
attributes: {
|
|
29068
|
+
"xmlns:a": drawingXmlns,
|
|
29069
|
+
noChangeAspect: 1
|
|
29070
|
+
}
|
|
29071
|
+
}
|
|
29072
|
+
]
|
|
29073
|
+
},
|
|
29074
|
+
{
|
|
29075
|
+
name: "a:graphic",
|
|
29076
|
+
attributes: { "xmlns:a": drawingXmlns },
|
|
29077
|
+
elements: [
|
|
29078
|
+
{
|
|
29079
|
+
name: "a:graphicData",
|
|
29080
|
+
attributes: { uri: pictureXmlns },
|
|
29081
|
+
elements: [
|
|
29082
|
+
{
|
|
29083
|
+
name: "pic:pic",
|
|
29084
|
+
attributes: { "xmlns:pic": pictureXmlns },
|
|
29085
|
+
elements: [
|
|
29086
|
+
{
|
|
29087
|
+
name: "pic:nvPicPr",
|
|
29088
|
+
elements: [
|
|
29089
|
+
{
|
|
29090
|
+
name: "pic:cNvPr",
|
|
29091
|
+
attributes: {
|
|
29092
|
+
id: attrs.id || 0,
|
|
29093
|
+
name: attrs.title || `Picture ${imageName}`
|
|
29094
|
+
}
|
|
29095
|
+
},
|
|
29096
|
+
{
|
|
29097
|
+
name: "pic:cNvPicPr",
|
|
29098
|
+
elements: [
|
|
29099
|
+
{
|
|
29100
|
+
name: "a:picLocks",
|
|
29101
|
+
attributes: {
|
|
29102
|
+
noChangeAspect: 1,
|
|
29103
|
+
noChangeArrowheads: 1
|
|
29104
|
+
}
|
|
29105
|
+
}
|
|
29106
|
+
]
|
|
29107
|
+
}
|
|
29108
|
+
]
|
|
29109
|
+
},
|
|
29110
|
+
{
|
|
29111
|
+
name: "pic:blipFill",
|
|
29112
|
+
elements: [
|
|
29113
|
+
{
|
|
29114
|
+
name: "a:blip",
|
|
29115
|
+
attributes: {
|
|
29116
|
+
"r:embed": imageId
|
|
29117
|
+
}
|
|
29118
|
+
},
|
|
29119
|
+
{
|
|
29120
|
+
name: "a:stretch",
|
|
29121
|
+
elements: [{ name: "a:fillRect" }]
|
|
29122
|
+
}
|
|
29123
|
+
]
|
|
29124
|
+
},
|
|
29125
|
+
{
|
|
29126
|
+
name: "pic:spPr",
|
|
29127
|
+
attributes: {
|
|
29128
|
+
bwMode: "auto"
|
|
29129
|
+
},
|
|
29130
|
+
elements: [
|
|
29131
|
+
{
|
|
29132
|
+
name: "a:xfrm",
|
|
29133
|
+
elements: [
|
|
29134
|
+
{
|
|
29135
|
+
name: "a:ext",
|
|
29136
|
+
attributes: {
|
|
29137
|
+
cx: size.w,
|
|
29138
|
+
cy: size.h
|
|
29139
|
+
}
|
|
29140
|
+
},
|
|
29141
|
+
{
|
|
29142
|
+
name: "a:off",
|
|
29143
|
+
attributes: {
|
|
29144
|
+
x: 0,
|
|
29145
|
+
y: 0
|
|
29146
|
+
}
|
|
29147
|
+
}
|
|
29148
|
+
]
|
|
29149
|
+
},
|
|
29150
|
+
{
|
|
29151
|
+
name: "a:prstGeom",
|
|
29152
|
+
attributes: { prst: "rect" },
|
|
29153
|
+
elements: [{ name: "a:avLst" }]
|
|
29154
|
+
},
|
|
29155
|
+
{
|
|
29156
|
+
name: "a:noFill"
|
|
29157
|
+
}
|
|
29158
|
+
]
|
|
29159
|
+
}
|
|
29160
|
+
]
|
|
29161
|
+
}
|
|
29162
|
+
]
|
|
29163
|
+
}
|
|
29164
|
+
]
|
|
29165
|
+
}
|
|
29166
|
+
]
|
|
29167
|
+
}
|
|
29168
|
+
]
|
|
29169
|
+
},
|
|
29170
|
+
[]
|
|
29171
|
+
);
|
|
29172
|
+
return textNode;
|
|
29967
29173
|
}
|
|
29968
29174
|
function translateShapeContainer(params) {
|
|
29969
29175
|
const { node } = params;
|
|
@@ -30142,6 +29348,14 @@ generateXml_fn = function(node) {
|
|
|
30142
29348
|
if (!selfClosing) tags.push(`</${name}>`);
|
|
30143
29349
|
return tags;
|
|
30144
29350
|
};
|
|
29351
|
+
function resizeKeepAspectRatio(width, height, maxWidth) {
|
|
29352
|
+
if (width > maxWidth) {
|
|
29353
|
+
let scale = maxWidth / width;
|
|
29354
|
+
let newHeight = Math.round(height * scale);
|
|
29355
|
+
return { width: maxWidth, height: newHeight };
|
|
29356
|
+
}
|
|
29357
|
+
return { width, height };
|
|
29358
|
+
}
|
|
30145
29359
|
const translatePageNumberNode = (params) => {
|
|
30146
29360
|
const outputMarks = processOutputMarks(params.node.attrs?.marksAsAttrs || []);
|
|
30147
29361
|
return getAutoPageJson("PAGE", outputMarks);
|
|
@@ -30225,7 +29439,7 @@ const getInitialJSON = (parsedDocx, fallbackXml = defaultInitialXml) => {
|
|
|
30225
29439
|
return parsedDocx["word/document.xml"] || parseXmlToJson(fallbackXml);
|
|
30226
29440
|
};
|
|
30227
29441
|
const handleDrawingNode = (params) => {
|
|
30228
|
-
const { nodes } = params;
|
|
29442
|
+
const { nodes, filename } = params;
|
|
30229
29443
|
const validNodes = ["w:drawing", "w:p"];
|
|
30230
29444
|
if (nodes.length === 0 || !validNodes.includes(nodes[0].name)) {
|
|
30231
29445
|
return { nodes: [], consumed: 0 };
|
|
@@ -30235,9 +29449,167 @@ const handleDrawingNode = (params) => {
|
|
|
30235
29449
|
if (mainNode.name === "w:drawing") node = mainNode;
|
|
30236
29450
|
else node = mainNode.elements.find((el) => el.name === "w:drawing");
|
|
30237
29451
|
if (!node) return { nodes: [], consumed: 0 };
|
|
30238
|
-
|
|
30239
|
-
const
|
|
30240
|
-
|
|
29452
|
+
let result;
|
|
29453
|
+
const { elements } = node;
|
|
29454
|
+
const currentFileName = filename || null;
|
|
29455
|
+
const isAnchor = elements.find((el) => el.name === "wp:anchor");
|
|
29456
|
+
if (isAnchor) {
|
|
29457
|
+
result = handleImageImport(elements[0], currentFileName, params);
|
|
29458
|
+
if (result && result.attrs) result.attrs.isAnchor = isAnchor;
|
|
29459
|
+
}
|
|
29460
|
+
const inlineImage = elements.find((el) => el.name === "wp:inline");
|
|
29461
|
+
if (inlineImage) result = handleImageImport(inlineImage, currentFileName, params);
|
|
29462
|
+
return { nodes: result ? [result] : [], consumed: 1 };
|
|
29463
|
+
};
|
|
29464
|
+
function handleImageImport(node, currentFileName, params) {
|
|
29465
|
+
const { docx } = params;
|
|
29466
|
+
const { attributes } = node;
|
|
29467
|
+
const padding = {
|
|
29468
|
+
top: emuToPixels(attributes["distT"]),
|
|
29469
|
+
bottom: emuToPixels(attributes["distB"]),
|
|
29470
|
+
left: emuToPixels(attributes["distL"]),
|
|
29471
|
+
right: emuToPixels(attributes["distR"])
|
|
29472
|
+
};
|
|
29473
|
+
const extent = node.elements.find((el) => el.name === "wp:extent");
|
|
29474
|
+
const size = {
|
|
29475
|
+
width: emuToPixels(extent.attributes?.cx),
|
|
29476
|
+
height: emuToPixels(extent.attributes?.cy)
|
|
29477
|
+
};
|
|
29478
|
+
const graphic = node.elements.find((el) => el.name === "a:graphic");
|
|
29479
|
+
const graphicData = graphic.elements.find((el) => el.name === "a:graphicData");
|
|
29480
|
+
const { uri: uri2 } = graphicData?.attributes || {};
|
|
29481
|
+
const shapeURI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
29482
|
+
if (!!uri2 && uri2 === shapeURI) {
|
|
29483
|
+
return handleShapeDrawing(params, node, graphicData);
|
|
29484
|
+
}
|
|
29485
|
+
const picture = graphicData.elements.find((el) => el.name === "pic:pic");
|
|
29486
|
+
if (!picture || !picture.elements) return null;
|
|
29487
|
+
const blipFill = picture.elements.find((el) => el.name === "pic:blipFill");
|
|
29488
|
+
const blip = blipFill.elements.find((el) => el.name === "a:blip");
|
|
29489
|
+
const positionHTag = node.elements.find((el) => el.name === "wp:positionH");
|
|
29490
|
+
const positionH = positionHTag?.elements.find((el) => el.name === "wp:posOffset");
|
|
29491
|
+
const positionHValue = emuToPixels(positionH?.elements[0]?.text);
|
|
29492
|
+
const hRelativeFrom = positionHTag?.attributes.relativeFrom;
|
|
29493
|
+
const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
29494
|
+
const positionVTag = node.elements.find((el) => el.name === "wp:positionV");
|
|
29495
|
+
const positionV = positionVTag?.elements?.find((el) => el.name === "wp:posOffset");
|
|
29496
|
+
const positionVValue = emuToPixels(positionV?.elements[0]?.text);
|
|
29497
|
+
const vRelativeFrom = positionVTag?.attributes.relativeFrom;
|
|
29498
|
+
const alignV = positionVTag?.elements?.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
29499
|
+
const simplePos = node.elements.find((el) => el.name === "wp:simplePos");
|
|
29500
|
+
const wrapSquare = node.elements.find((el) => el.name === "wp:wrapSquare");
|
|
29501
|
+
const wrapTopAndBottom = node.elements.find((el) => el.name === "wp:wrapTopAndBottom");
|
|
29502
|
+
const docPr = node.elements.find((el) => el.name === "wp:docPr");
|
|
29503
|
+
let anchorData = null;
|
|
29504
|
+
if (hRelativeFrom || alignH || vRelativeFrom || alignV) {
|
|
29505
|
+
anchorData = {
|
|
29506
|
+
hRelativeFrom,
|
|
29507
|
+
vRelativeFrom,
|
|
29508
|
+
alignH,
|
|
29509
|
+
alignV
|
|
29510
|
+
};
|
|
29511
|
+
}
|
|
29512
|
+
const marginOffset = {
|
|
29513
|
+
left: positionHValue,
|
|
29514
|
+
top: positionVValue
|
|
29515
|
+
};
|
|
29516
|
+
const { attributes: blipAttributes = {} } = blip;
|
|
29517
|
+
const rEmbed = blipAttributes["r:embed"];
|
|
29518
|
+
if (!rEmbed) return null;
|
|
29519
|
+
const currentFile = currentFileName || "document.xml";
|
|
29520
|
+
let rels = docx[`word/_rels/${currentFile}.rels`];
|
|
29521
|
+
if (!rels) rels = docx[`word/_rels/document.xml.rels`];
|
|
29522
|
+
const relationships = rels.elements.find((el) => el.name === "Relationships");
|
|
29523
|
+
const { elements } = relationships;
|
|
29524
|
+
const rel = elements.find((el) => el.attributes["Id"] === rEmbed);
|
|
29525
|
+
if (!rel) return null;
|
|
29526
|
+
const { attributes: relAttributes } = rel;
|
|
29527
|
+
const targetPath = relAttributes["Target"];
|
|
29528
|
+
let path = `word/${targetPath}`;
|
|
29529
|
+
if (targetPath.startsWith("/word") || targetPath.startsWith("/media")) path = targetPath.substring(1);
|
|
29530
|
+
const extension = targetPath.substring(targetPath.lastIndexOf(".") + 1);
|
|
29531
|
+
return {
|
|
29532
|
+
type: "image",
|
|
29533
|
+
attrs: {
|
|
29534
|
+
src: path,
|
|
29535
|
+
alt: ["emf", "wmf"].includes(extension) ? "Unable to render EMF/WMF image" : docPr?.attributes.name || "Image",
|
|
29536
|
+
extension,
|
|
29537
|
+
id: docPr?.attributes.id || "",
|
|
29538
|
+
title: docPr?.attributes.descr || "Image",
|
|
29539
|
+
inline: true,
|
|
29540
|
+
padding,
|
|
29541
|
+
marginOffset,
|
|
29542
|
+
size,
|
|
29543
|
+
anchorData,
|
|
29544
|
+
...simplePos && {
|
|
29545
|
+
simplePos: {
|
|
29546
|
+
x: simplePos.attributes.x,
|
|
29547
|
+
y: simplePos.attributes.y
|
|
29548
|
+
}
|
|
29549
|
+
},
|
|
29550
|
+
...wrapSquare && {
|
|
29551
|
+
wrapText: wrapSquare.attributes.wrapText
|
|
29552
|
+
},
|
|
29553
|
+
wrapTopAndBottom: !!wrapTopAndBottom,
|
|
29554
|
+
originalPadding: {
|
|
29555
|
+
distT: attributes["distT"],
|
|
29556
|
+
distB: attributes["distB"],
|
|
29557
|
+
distL: attributes["distL"],
|
|
29558
|
+
distR: attributes["distR"]
|
|
29559
|
+
},
|
|
29560
|
+
originalAttributes: node.attributes,
|
|
29561
|
+
rId: relAttributes["Id"]
|
|
29562
|
+
}
|
|
29563
|
+
};
|
|
29564
|
+
}
|
|
29565
|
+
const handleShapeDrawing = (params, node, graphicData) => {
|
|
29566
|
+
const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
|
|
29567
|
+
const textBox = wsp.elements.find((el) => el.name === "wps:txbx");
|
|
29568
|
+
const textBoxContent = textBox?.elements?.find((el) => el.name === "w:txbxContent");
|
|
29569
|
+
node.elements.find((el) => el.name === "wp:docPr");
|
|
29570
|
+
const spPr = wsp.elements.find((el) => el.name === "wps:spPr");
|
|
29571
|
+
const prstGeom = spPr?.elements.find((el) => el.name === "a:prstGeom");
|
|
29572
|
+
if (!!prstGeom && prstGeom.attributes["prst"] === "rect" && !textBoxContent) {
|
|
29573
|
+
return getRectangleShape(params, spPr);
|
|
29574
|
+
}
|
|
29575
|
+
if (!textBoxContent) {
|
|
29576
|
+
return null;
|
|
29577
|
+
}
|
|
29578
|
+
const { nodeListHandler } = params;
|
|
29579
|
+
const translatedElement = nodeListHandler.handler({
|
|
29580
|
+
...params,
|
|
29581
|
+
node: textBoxContent.elements[0],
|
|
29582
|
+
nodes: textBoxContent.elements,
|
|
29583
|
+
path: [...params.path || [], textBoxContent]
|
|
29584
|
+
});
|
|
29585
|
+
return translatedElement[0];
|
|
29586
|
+
};
|
|
29587
|
+
const getRectangleShape = (params, node) => {
|
|
29588
|
+
const schemaAttrs = {};
|
|
29589
|
+
const [drawingNode] = params.nodes;
|
|
29590
|
+
if (drawingNode?.name === "w:drawing") {
|
|
29591
|
+
schemaAttrs.drawingContent = drawingNode;
|
|
29592
|
+
}
|
|
29593
|
+
const xfrm = node.elements.find((el) => el.name === "a:xfrm");
|
|
29594
|
+
const start = xfrm.elements.find((el) => el.name === "a:off");
|
|
29595
|
+
const size = xfrm.elements.find((el) => el.name === "a:ext");
|
|
29596
|
+
const solidFill = node.elements.find((el) => el.name === "a:solidFill");
|
|
29597
|
+
node.elements.find((el) => el.name === "a:ln");
|
|
29598
|
+
const rectangleSize = {
|
|
29599
|
+
top: emuToPixels(start.attributes["y"]),
|
|
29600
|
+
left: emuToPixels(start.attributes["x"]),
|
|
29601
|
+
width: emuToPixels(size.attributes["cx"]),
|
|
29602
|
+
height: emuToPixels(size.attributes["cy"])
|
|
29603
|
+
};
|
|
29604
|
+
schemaAttrs.size = rectangleSize;
|
|
29605
|
+
const background = solidFill?.elements[0]?.attributes["val"];
|
|
29606
|
+
if (background) {
|
|
29607
|
+
schemaAttrs.background = "#" + background;
|
|
29608
|
+
}
|
|
29609
|
+
return {
|
|
29610
|
+
type: "contentBlock",
|
|
29611
|
+
attrs: schemaAttrs
|
|
29612
|
+
};
|
|
30241
29613
|
};
|
|
30242
29614
|
const drawingNodeHandlerEntity = {
|
|
30243
29615
|
handlerName: "drawingNodeHandler",
|
|
@@ -30337,7 +29709,7 @@ const trackChangeNodeHandlerEntity = {
|
|
|
30337
29709
|
handlerName: "trackChangeNodeHandler",
|
|
30338
29710
|
handler: handleTrackChangeNode
|
|
30339
29711
|
};
|
|
30340
|
-
const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$
|
|
29712
|
+
const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$1);
|
|
30341
29713
|
const handleRunNode = (params) => {
|
|
30342
29714
|
const { nodes, nodeListHandler, parentStyleId, docx } = params;
|
|
30343
29715
|
if (nodes.length === 0 || nodes[0].name !== "w:r") {
|
|
@@ -30449,7 +29821,7 @@ const handleParagraphNode = (params) => {
|
|
|
30449
29821
|
if (nodes.length === 0 || nodes[0].name !== "w:p") {
|
|
30450
29822
|
return { nodes: [], consumed: 0 };
|
|
30451
29823
|
}
|
|
30452
|
-
const schemaNode = translator$
|
|
29824
|
+
const schemaNode = translator$h.encode(params);
|
|
30453
29825
|
const newNodes = schemaNode ? [schemaNode] : [];
|
|
30454
29826
|
return { nodes: newNodes, consumed: 1 };
|
|
30455
29827
|
};
|
|
@@ -30552,7 +29924,7 @@ const handler = (params) => {
|
|
|
30552
29924
|
if (nodes.length === 0 || nodes[0].name !== "w:br") {
|
|
30553
29925
|
return { nodes: [], consumed: 0 };
|
|
30554
29926
|
}
|
|
30555
|
-
const result = translator$
|
|
29927
|
+
const result = translator$j.encode(params);
|
|
30556
29928
|
if (!result) return { nodes: [], consumed: 0 };
|
|
30557
29929
|
return {
|
|
30558
29930
|
nodes: [result],
|
|
@@ -30616,53 +29988,9 @@ const handleBookmarkNode = (params) => {
|
|
|
30616
29988
|
}
|
|
30617
29989
|
return result;
|
|
30618
29990
|
};
|
|
30619
|
-
const
|
|
30620
|
-
|
|
30621
|
-
|
|
30622
|
-
return { nodes: [], consumed: 0 };
|
|
30623
|
-
}
|
|
30624
|
-
if (isCustomMarkBookmark(nodes[0], params.editor)) {
|
|
30625
|
-
return handleBookmarkNode(params);
|
|
30626
|
-
}
|
|
30627
|
-
const node = translator$3.encode(params);
|
|
30628
|
-
if (!node) return { nodes: [], consumed: 0 };
|
|
30629
|
-
return { nodes: [node], consumed: 1 };
|
|
30630
|
-
};
|
|
30631
|
-
const isCustomMarkBookmark = (bookmarkStartNode, editor) => {
|
|
30632
|
-
if (!bookmarkStartNode?.attributes || !editor?.extensionService?.extensions) {
|
|
30633
|
-
return false;
|
|
30634
|
-
}
|
|
30635
|
-
const rawBookmarkName = bookmarkStartNode.attributes["w:name"];
|
|
30636
|
-
if (!rawBookmarkName || typeof rawBookmarkName !== "string") {
|
|
30637
|
-
return false;
|
|
30638
|
-
}
|
|
30639
|
-
const [bookmarkName, ...bookmarkPayloadParts] = rawBookmarkName.split(";");
|
|
30640
|
-
if (!bookmarkName) {
|
|
30641
|
-
return false;
|
|
30642
|
-
}
|
|
30643
|
-
const customMarks = editor.extensionService.extensions.filter((extension) => extension.isExternal === true);
|
|
30644
|
-
const matchesCustomMarkName = customMarks.some((mark) => mark.name === bookmarkName);
|
|
30645
|
-
if (!matchesCustomMarkName) {
|
|
30646
|
-
return false;
|
|
30647
|
-
}
|
|
30648
|
-
return bookmarkPayloadParts.some((part) => part && part.includes("="));
|
|
30649
|
-
};
|
|
30650
|
-
const bookmarkStartNodeHandlerEntity = {
|
|
30651
|
-
handlerName: "w:bookmarkStartTranslator",
|
|
30652
|
-
handler: handleBookmarkStartNode
|
|
30653
|
-
};
|
|
30654
|
-
const handleBookmarkEndNode = (params) => {
|
|
30655
|
-
const { nodes } = params;
|
|
30656
|
-
if (!nodes.length || nodes[0].name !== "w:bookmarkEnd") {
|
|
30657
|
-
return { nodes: [], consumed: 0 };
|
|
30658
|
-
}
|
|
30659
|
-
const node = translator$2.encode(params);
|
|
30660
|
-
if (!node) return { nodes: [], consumed: 0 };
|
|
30661
|
-
return { nodes: [node], consumed: 1 };
|
|
30662
|
-
};
|
|
30663
|
-
const bookmarkEndNodeHandlerEntity = {
|
|
30664
|
-
handlerName: "w:bookmarkEndTranslator",
|
|
30665
|
-
handler: handleBookmarkEndNode
|
|
29991
|
+
const bookmarkNodeHandlerEntity = {
|
|
29992
|
+
handlerName: "bookmarkNodeHandler",
|
|
29993
|
+
handler: handleBookmarkNode
|
|
30666
29994
|
};
|
|
30667
29995
|
const handleAlternateChoice = (params) => {
|
|
30668
29996
|
const skipHandlerResponse = { nodes: [], consumed: 0 };
|
|
@@ -31000,30 +30328,27 @@ function importCommentData({ docx, editor, converter }) {
|
|
|
31000
30328
|
trackedChange,
|
|
31001
30329
|
trackedChangeText,
|
|
31002
30330
|
trackedChangeType,
|
|
31003
|
-
trackedDeletedText
|
|
31004
|
-
isDone: false
|
|
30331
|
+
trackedDeletedText
|
|
31005
30332
|
};
|
|
31006
30333
|
});
|
|
31007
30334
|
const extendedComments = generateCommentsWithExtendedData({ docx, comments: extractedComments });
|
|
31008
30335
|
return extendedComments;
|
|
31009
30336
|
}
|
|
31010
30337
|
const generateCommentsWithExtendedData = ({ docx, comments }) => {
|
|
31011
|
-
if (!comments?.length) return [];
|
|
31012
30338
|
const commentsExtended = docx["word/commentsExtended.xml"];
|
|
31013
|
-
if (!commentsExtended) return
|
|
31014
|
-
const { elements: initialElements
|
|
31015
|
-
|
|
31016
|
-
const { elements = [] } = initialElements[0] ?? {};
|
|
30339
|
+
if (!commentsExtended) return [];
|
|
30340
|
+
const { elements: initialElements } = commentsExtended;
|
|
30341
|
+
const { elements } = initialElements[0];
|
|
31017
30342
|
const commentEx = elements.filter((el) => el.name === "w15:commentEx");
|
|
31018
30343
|
return comments.map((comment) => {
|
|
31019
30344
|
const extendedDef = commentEx.find((ce2) => ce2.attributes["w15:paraId"] === comment.paraId);
|
|
31020
|
-
if (!extendedDef) return { ...comment
|
|
30345
|
+
if (!extendedDef) return { ...comment };
|
|
31021
30346
|
const { isDone, paraIdParent } = getExtendedDetails(extendedDef);
|
|
31022
30347
|
let parentComment;
|
|
31023
30348
|
if (paraIdParent) parentComment = comments.find((c) => c.paraId === paraIdParent);
|
|
31024
30349
|
const newComment = {
|
|
31025
30350
|
...comment,
|
|
31026
|
-
isDone
|
|
30351
|
+
isDone,
|
|
31027
30352
|
parentCommentId: parentComment?.commentId
|
|
31028
30353
|
};
|
|
31029
30354
|
return newComment;
|
|
@@ -31295,7 +30620,7 @@ const handleTabNode = (params) => {
|
|
|
31295
30620
|
if (!nodes.length || nodes[0].name !== "w:tab") {
|
|
31296
30621
|
return { nodes: [], consumed: 0 };
|
|
31297
30622
|
}
|
|
31298
|
-
const node = translator$
|
|
30623
|
+
const node = translator$i.encode(params);
|
|
31299
30624
|
return { nodes: [node], consumed: 1 };
|
|
31300
30625
|
};
|
|
31301
30626
|
const tabNodeEntityHandler = {
|
|
@@ -31378,8 +30703,7 @@ const defaultNodeListHandler = () => {
|
|
|
31378
30703
|
textNodeHandlerEntity,
|
|
31379
30704
|
lineBreakNodeHandlerEntity,
|
|
31380
30705
|
sdtNodeHandlerEntity,
|
|
31381
|
-
|
|
31382
|
-
bookmarkEndNodeHandlerEntity,
|
|
30706
|
+
bookmarkNodeHandlerEntity,
|
|
31383
30707
|
hyperlinkNodeHandlerEntity,
|
|
31384
30708
|
drawingNodeHandlerEntity,
|
|
31385
30709
|
trackChangeNodeHandlerEntity,
|
|
@@ -31601,8 +30925,8 @@ function addDefaultStylesIfMissing(styles) {
|
|
|
31601
30925
|
}
|
|
31602
30926
|
const importHeadersFooters = (docx, converter, mainEditor) => {
|
|
31603
30927
|
const rels = docx["word/_rels/document.xml.rels"];
|
|
31604
|
-
const relationships = rels
|
|
31605
|
-
const { elements } = relationships
|
|
30928
|
+
const relationships = rels.elements.find((el) => el.name === "Relationships");
|
|
30929
|
+
const { elements } = relationships;
|
|
31606
30930
|
const headerType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header";
|
|
31607
30931
|
const footerType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";
|
|
31608
30932
|
const headers = elements.filter((el) => el.attributes["Type"] === headerType);
|
|
@@ -31686,7 +31010,6 @@ function filterOutRootInlineNodes(content = []) {
|
|
|
31686
31010
|
const INLINE_TYPES = /* @__PURE__ */ new Set([
|
|
31687
31011
|
"text",
|
|
31688
31012
|
"bookmarkStart",
|
|
31689
|
-
"bookmarkEnd",
|
|
31690
31013
|
"lineBreak",
|
|
31691
31014
|
"hardBreak",
|
|
31692
31015
|
"pageNumber",
|
|
@@ -31824,7 +31147,7 @@ const _SuperConverter = class _SuperConverter {
|
|
|
31824
31147
|
return;
|
|
31825
31148
|
}
|
|
31826
31149
|
}
|
|
31827
|
-
static updateDocumentVersion(docx = this.convertedXml, version = "0.20.0
|
|
31150
|
+
static updateDocumentVersion(docx = this.convertedXml, version = "0.20.0") {
|
|
31828
31151
|
const customLocation = "docProps/custom.xml";
|
|
31829
31152
|
if (!docx[customLocation]) {
|
|
31830
31153
|
docx[customLocation] = generateCustomXml();
|
|
@@ -32314,7 +31637,7 @@ function storeSuperdocVersion(docx) {
|
|
|
32314
31637
|
function generateCustomXml() {
|
|
32315
31638
|
return DEFAULT_CUSTOM_XML;
|
|
32316
31639
|
}
|
|
32317
|
-
function generateSuperdocVersion(pid = 2, version = "0.20.0
|
|
31640
|
+
function generateSuperdocVersion(pid = 2, version = "0.20.0") {
|
|
32318
31641
|
return {
|
|
32319
31642
|
type: "element",
|
|
32320
31643
|
name: "property",
|
|
@@ -32377,12 +31700,15 @@ export {
|
|
|
32377
31700
|
createDocFromMarkdown as a7,
|
|
32378
31701
|
createDocFromHTML as a8,
|
|
32379
31702
|
EditorState as a9,
|
|
32380
|
-
|
|
32381
|
-
|
|
32382
|
-
|
|
32383
|
-
|
|
32384
|
-
|
|
32385
|
-
|
|
31703
|
+
vClickOutside as aA,
|
|
31704
|
+
getActiveFormatting as aB,
|
|
31705
|
+
readFromClipboard as aC,
|
|
31706
|
+
handleClipboardPaste as aD,
|
|
31707
|
+
getFileObject as aE,
|
|
31708
|
+
translator$h as aF,
|
|
31709
|
+
translator$i as aG,
|
|
31710
|
+
translator$j as aH,
|
|
31711
|
+
_sfc_main as aI,
|
|
32386
31712
|
hasSomeParentWithClass as aa,
|
|
32387
31713
|
isActive as ab,
|
|
32388
31714
|
unflattenListsInHtml as ac,
|
|
@@ -32397,18 +31723,18 @@ export {
|
|
|
32397
31723
|
parseIndentElement as al,
|
|
32398
31724
|
combineIndents as am,
|
|
32399
31725
|
StepMap as an,
|
|
32400
|
-
|
|
32401
|
-
|
|
32402
|
-
|
|
32403
|
-
|
|
32404
|
-
|
|
32405
|
-
|
|
32406
|
-
|
|
32407
|
-
|
|
32408
|
-
|
|
32409
|
-
|
|
32410
|
-
|
|
32411
|
-
|
|
31726
|
+
getColStyleDeclaration as ao,
|
|
31727
|
+
SelectionRange as ap,
|
|
31728
|
+
Transform as aq,
|
|
31729
|
+
isInTable as ar,
|
|
31730
|
+
createColGroup as as,
|
|
31731
|
+
generateDocxRandomId as at,
|
|
31732
|
+
insertNewRelationship as au,
|
|
31733
|
+
htmlHandler as av,
|
|
31734
|
+
commonjsGlobal as aw,
|
|
31735
|
+
getDefaultExportFromCjs$1 as ax,
|
|
31736
|
+
getContentTypesFromXml as ay,
|
|
31737
|
+
xmljs as az,
|
|
32412
31738
|
Slice as b,
|
|
32413
31739
|
DOMParser$1 as c,
|
|
32414
31740
|
Mark as d,
|