@harbour-enterprises/superdoc 0.27.3-next.1 → 0.27.3-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/dist/chunks/{PdfViewer-BkJGiP2u.cjs → PdfViewer-B4iIjHV0.cjs} +1 -1
- package/dist/chunks/{PdfViewer-Bnj3c-92.es.js → PdfViewer-BjZ5mGJm.es.js} +1 -1
- package/dist/chunks/{index-CuLDIhMe.cjs → index-D6aLyyxJ.cjs} +2 -2
- package/dist/chunks/{index-lF5qA9nw.es.js → index-DkzQzDKS.es.js} +2 -2
- package/dist/chunks/{super-editor.es-RvLsj0rg.cjs → super-editor.es-BbpZtQLg.cjs} +1667 -1746
- package/dist/chunks/{super-editor.es-6ikSS3Qu.es.js → super-editor.es-DAZHU_K5.es.js} +1667 -1746
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-GcMLdei-.js → converter-qTrGAY0a.js} +1818 -1897
- package/dist/super-editor/chunks/{docx-zipper-Y0x9TJvc.js → docx-zipper-BRttLmZq.js} +1 -1
- package/dist/super-editor/chunks/{editor-B97ToSSc.js → editor-DqOCeU9J.js} +2 -2
- package/dist/super-editor/chunks/{toolbar-Cm21JZgi.js → toolbar-cZin2t1V.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/super-editor/src/core/super-converter/v2/importer/tableImporter.d.ts +0 -16
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/legacy-handle-table-cell-node.d.ts +1 -1
- package/dist/super-editor/super-editor.es.js +6 -6
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +1667 -1746
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -26997,53 +26997,7 @@ const config$h = {
|
|
|
26997
26997
|
attributes: validXmlAttributes$c
|
|
26998
26998
|
};
|
|
26999
26999
|
const translator$1b = NodeTranslator.from(config$h);
|
|
27000
|
-
function preProcessVerticalMergeCells(table, { editorSchema }) {
|
|
27001
|
-
if (!table || !Array.isArray(table.content)) {
|
|
27002
|
-
return table;
|
|
27003
|
-
}
|
|
27004
|
-
const rows = table.content;
|
|
27005
|
-
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
27006
|
-
const row = rows[rowIndex];
|
|
27007
|
-
if (!row) continue;
|
|
27008
|
-
if (!Array.isArray(row.content)) {
|
|
27009
|
-
row.content = [];
|
|
27010
|
-
}
|
|
27011
|
-
for (let cellIndex = 0; cellIndex < row.content.length; cellIndex++) {
|
|
27012
|
-
const cell = row.content[cellIndex];
|
|
27013
|
-
if (!cell) continue;
|
|
27014
|
-
const attrs = cell.attrs || {};
|
|
27015
|
-
if (!attrs.rowspan || attrs.rowspan <= 1) continue;
|
|
27016
|
-
const maxRowspan = Math.min(attrs.rowspan, rows.length - rowIndex);
|
|
27017
|
-
for (let offset = 1; offset < maxRowspan; offset++) {
|
|
27018
|
-
const rowToChange = rows[rowIndex + offset];
|
|
27019
|
-
if (!rowToChange) continue;
|
|
27020
|
-
if (!Array.isArray(rowToChange.content)) {
|
|
27021
|
-
rowToChange.content = [];
|
|
27022
|
-
}
|
|
27023
|
-
const existingCell = rowToChange.content[cellIndex];
|
|
27024
|
-
if (existingCell?.attrs?.continueMerge) continue;
|
|
27025
|
-
const mergedCell = {
|
|
27026
|
-
type: cell.type,
|
|
27027
|
-
content: [editorSchema.nodes.paragraph.createAndFill().toJSON()],
|
|
27028
|
-
attrs: {
|
|
27029
|
-
...cell.attrs,
|
|
27030
|
-
rowspan: null,
|
|
27031
|
-
continueMerge: true
|
|
27032
|
-
}
|
|
27033
|
-
};
|
|
27034
|
-
rowToChange.content.splice(cellIndex, 0, mergedCell);
|
|
27035
|
-
}
|
|
27036
|
-
}
|
|
27037
|
-
}
|
|
27038
|
-
return table;
|
|
27039
|
-
}
|
|
27040
27000
|
const translator$1a = NodeTranslator.from({
|
|
27041
|
-
xmlName: "w:cantSplit",
|
|
27042
|
-
sdNodeOrKeyName: "cantSplit",
|
|
27043
|
-
encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27044
|
-
decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
|
|
27045
|
-
});
|
|
27046
|
-
const translator$19 = NodeTranslator.from({
|
|
27047
27001
|
xmlName: "w:cnfStyle",
|
|
27048
27002
|
sdNodeOrKeyName: "cnfStyle",
|
|
27049
27003
|
attributes: [
|
|
@@ -27069,1458 +27023,847 @@ const translator$19 = NodeTranslator.from({
|
|
|
27069
27023
|
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
27070
27024
|
}
|
|
27071
27025
|
});
|
|
27072
|
-
const translator$
|
|
27026
|
+
const translator$19 = NodeTranslator.from({
|
|
27027
|
+
xmlName: "w:shd",
|
|
27028
|
+
sdNodeOrKeyName: "shading",
|
|
27029
|
+
attributes: [
|
|
27030
|
+
"w:color",
|
|
27031
|
+
"w:fill",
|
|
27032
|
+
"w:themeColor",
|
|
27033
|
+
"w:themeFill",
|
|
27034
|
+
"w:themeFillShade",
|
|
27035
|
+
"w:themeFillTint",
|
|
27036
|
+
"w:themeShade",
|
|
27037
|
+
"w:themeTint",
|
|
27038
|
+
"w:val"
|
|
27039
|
+
].map((attr) => createAttributeHandler(attr)),
|
|
27040
|
+
encode: (params, encodedAttrs) => {
|
|
27041
|
+
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
27042
|
+
},
|
|
27043
|
+
decode: function({ node }, context) {
|
|
27044
|
+
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.shading || {} } });
|
|
27045
|
+
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
27046
|
+
}
|
|
27047
|
+
});
|
|
27048
|
+
const translator$18 = NodeTranslator.from(createMeasurementPropertyHandler("w:tcW", "cellWidth"));
|
|
27073
27049
|
const translator$17 = NodeTranslator.from(
|
|
27074
27050
|
createSingleAttrPropertyHandler(
|
|
27075
|
-
"w:
|
|
27051
|
+
"w:gridSpan",
|
|
27076
27052
|
null,
|
|
27077
27053
|
"w:val",
|
|
27078
27054
|
(v2) => parseInteger(v2) ?? void 0,
|
|
27079
27055
|
(v2) => integerToString(v2)
|
|
27080
27056
|
)
|
|
27081
27057
|
);
|
|
27082
|
-
const translator$16 = NodeTranslator.from(
|
|
27058
|
+
const translator$16 = NodeTranslator.from(createSingleAttrPropertyHandler("w:vMerge"));
|
|
27059
|
+
const translator$15 = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
|
|
27060
|
+
const translator$14 = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
|
|
27061
|
+
const translator$13 = NodeTranslator.from(createBorderPropertyHandler("w:end"));
|
|
27062
|
+
const translator$12 = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
|
|
27063
|
+
const translator$11 = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
|
|
27064
|
+
const translator$10 = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
|
|
27065
|
+
const translator$$ = NodeTranslator.from(createBorderPropertyHandler("w:left"));
|
|
27066
|
+
const translator$_ = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
|
|
27067
|
+
const translator$Z = NodeTranslator.from(createBorderPropertyHandler("w:right"));
|
|
27068
|
+
const translator$Y = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
|
|
27069
|
+
const translator$X = NodeTranslator.from(createBorderPropertyHandler("w:start"));
|
|
27070
|
+
const translator$W = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
|
|
27071
|
+
const translator$V = NodeTranslator.from(createBorderPropertyHandler("w:top"));
|
|
27072
|
+
const translator$U = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
|
|
27073
|
+
const translator$T = NodeTranslator.from(createBorderPropertyHandler("w:tl2br"));
|
|
27074
|
+
const translator$S = NodeTranslator.from(createBorderPropertyHandler("w:tr2bl"));
|
|
27075
|
+
const propertyTranslators$6 = [
|
|
27076
|
+
translator$V,
|
|
27077
|
+
translator$X,
|
|
27078
|
+
translator$$,
|
|
27079
|
+
translator$15,
|
|
27080
|
+
translator$13,
|
|
27081
|
+
translator$Z,
|
|
27082
|
+
translator$11,
|
|
27083
|
+
translator$10,
|
|
27084
|
+
translator$T,
|
|
27085
|
+
translator$S
|
|
27086
|
+
];
|
|
27087
|
+
const translator$R = NodeTranslator.from(
|
|
27088
|
+
createNestedPropertiesTranslator("w:tcBorders", "borders", propertyTranslators$6)
|
|
27089
|
+
);
|
|
27090
|
+
const translator$Q = NodeTranslator.from(
|
|
27083
27091
|
createSingleAttrPropertyHandler(
|
|
27084
|
-
"w:
|
|
27092
|
+
"w:noWrap",
|
|
27085
27093
|
null,
|
|
27086
27094
|
"w:val",
|
|
27087
|
-
(v2) =>
|
|
27088
|
-
(v2) =>
|
|
27095
|
+
(v2) => parseBoolean(v2 ?? "true"),
|
|
27096
|
+
(v2) => booleanToString(v2)
|
|
27089
27097
|
)
|
|
27090
27098
|
);
|
|
27091
|
-
const
|
|
27092
|
-
xmlName: "w:hidden",
|
|
27093
|
-
sdNodeOrKeyName: "hidden",
|
|
27094
|
-
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27095
|
-
decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
|
|
27096
|
-
});
|
|
27097
|
-
const translator$14 = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
|
|
27098
|
-
const translator$13 = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
|
|
27099
|
-
const translator$12 = NodeTranslator.from({
|
|
27100
|
-
xmlName: "w:tblHeader",
|
|
27101
|
-
sdNodeOrKeyName: "repeatHeader",
|
|
27102
|
-
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27103
|
-
decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
|
|
27104
|
-
});
|
|
27105
|
-
const translator$11 = NodeTranslator.from({
|
|
27106
|
-
xmlName: "w:trHeight",
|
|
27107
|
-
sdNodeOrKeyName: "rowHeight",
|
|
27108
|
-
encode: ({ nodes }) => {
|
|
27109
|
-
const heightAttrs = {};
|
|
27110
|
-
const val = nodes[0].attributes["w:val"];
|
|
27111
|
-
if (val) {
|
|
27112
|
-
heightAttrs["value"] = parseInt(val, 10);
|
|
27113
|
-
}
|
|
27114
|
-
const rule = nodes[0].attributes["w:hRule"];
|
|
27115
|
-
if (rule) {
|
|
27116
|
-
heightAttrs["rule"] = rule;
|
|
27117
|
-
}
|
|
27118
|
-
return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
|
|
27119
|
-
},
|
|
27120
|
-
decode: ({ node }) => {
|
|
27121
|
-
if (!node.attrs?.rowHeight) return;
|
|
27122
|
-
const heightAttrs = {};
|
|
27123
|
-
if (typeof node.attrs.rowHeight.value === "number" && !isNaN(node.attrs.rowHeight.value)) {
|
|
27124
|
-
heightAttrs["w:val"] = String(node.attrs.rowHeight.value);
|
|
27125
|
-
}
|
|
27126
|
-
if (node.attrs.rowHeight.rule) {
|
|
27127
|
-
heightAttrs["w:hRule"] = node.attrs.rowHeight.rule;
|
|
27128
|
-
}
|
|
27129
|
-
return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
|
|
27130
|
-
}
|
|
27131
|
-
});
|
|
27132
|
-
const translator$10 = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
|
|
27133
|
-
const translator$$ = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
|
|
27134
|
-
const propertyTranslators$6 = [
|
|
27135
|
-
translator$1a,
|
|
27136
|
-
translator$19,
|
|
27137
|
-
translator$18,
|
|
27138
|
-
translator$17,
|
|
27139
|
-
translator$16,
|
|
27140
|
-
translator$15,
|
|
27099
|
+
const propertyTranslators$5 = [
|
|
27141
27100
|
translator$14,
|
|
27142
|
-
translator$13,
|
|
27143
27101
|
translator$12,
|
|
27144
|
-
translator$
|
|
27145
|
-
translator$
|
|
27146
|
-
translator
|
|
27102
|
+
translator$_,
|
|
27103
|
+
translator$Y,
|
|
27104
|
+
translator$W,
|
|
27105
|
+
translator$U
|
|
27147
27106
|
];
|
|
27148
|
-
const translator$
|
|
27149
|
-
createNestedPropertiesTranslator("w:
|
|
27150
|
-
cantSplit: false,
|
|
27151
|
-
hidden: false,
|
|
27152
|
-
repeatHeader: false
|
|
27153
|
-
})
|
|
27107
|
+
const translator$P = NodeTranslator.from(
|
|
27108
|
+
createNestedPropertiesTranslator("w:tcMar", "cellMargins", propertyTranslators$5)
|
|
27154
27109
|
);
|
|
27155
|
-
const
|
|
27156
|
-
|
|
27157
|
-
|
|
27110
|
+
const translator$O = NodeTranslator.from(createSingleAttrPropertyHandler("w:textDirection"));
|
|
27111
|
+
const translator$N = NodeTranslator.from(
|
|
27112
|
+
createSingleAttrPropertyHandler(
|
|
27113
|
+
"w:tcFitText",
|
|
27114
|
+
null,
|
|
27115
|
+
"w:val",
|
|
27116
|
+
(v2) => parseBoolean(v2 ?? "true"),
|
|
27117
|
+
(v2) => booleanToString(v2)
|
|
27118
|
+
)
|
|
27119
|
+
);
|
|
27120
|
+
const translator$M = NodeTranslator.from(createSingleAttrPropertyHandler("w:vAlign"));
|
|
27121
|
+
const translator$L = NodeTranslator.from(
|
|
27122
|
+
createSingleAttrPropertyHandler(
|
|
27123
|
+
"w:hideMark",
|
|
27124
|
+
null,
|
|
27125
|
+
"w:val",
|
|
27126
|
+
(v2) => parseBoolean(v2 ?? "true"),
|
|
27127
|
+
(v2) => booleanToString(v2)
|
|
27128
|
+
)
|
|
27129
|
+
);
|
|
27130
|
+
const translator$K = NodeTranslator.from(createSingleAttrPropertyHandler("w:header"));
|
|
27131
|
+
const XML_NODE_NAME$h = "w:headers";
|
|
27132
|
+
const SD_ATTR_KEY$3 = "headers";
|
|
27133
|
+
const encode$n = (params) => {
|
|
27134
|
+
const { nodes } = params;
|
|
27135
|
+
const node = nodes[0];
|
|
27136
|
+
const attributes = encodeProperties(node, { [translator$K.xmlName]: translator$K }, true);
|
|
27158
27137
|
return {
|
|
27159
|
-
|
|
27160
|
-
|
|
27161
|
-
|
|
27162
|
-
rowspan: 1,
|
|
27163
|
-
colwidth: [safeWidth],
|
|
27164
|
-
__placeholder: reason,
|
|
27165
|
-
borders: {
|
|
27166
|
-
top: { ...noBorder },
|
|
27167
|
-
right: { ...noBorder },
|
|
27168
|
-
bottom: { ...noBorder },
|
|
27169
|
-
left: { ...noBorder }
|
|
27170
|
-
}
|
|
27171
|
-
},
|
|
27172
|
-
content: [{ type: "paragraph", content: [] }]
|
|
27138
|
+
xmlName: XML_NODE_NAME$h,
|
|
27139
|
+
sdNodeOrKeyName: SD_ATTR_KEY$3,
|
|
27140
|
+
attributes
|
|
27173
27141
|
};
|
|
27174
27142
|
};
|
|
27175
|
-
const
|
|
27176
|
-
|
|
27177
|
-
|
|
27178
|
-
|
|
27179
|
-
|
|
27180
|
-
|
|
27181
|
-
|
|
27182
|
-
}
|
|
27183
|
-
|
|
27184
|
-
|
|
27185
|
-
|
|
27186
|
-
|
|
27187
|
-
targetIndex,
|
|
27188
|
-
totalColumns,
|
|
27189
|
-
gridColumnWidths,
|
|
27190
|
-
reason
|
|
27191
|
-
}) => {
|
|
27192
|
-
let index2 = currentIndex;
|
|
27193
|
-
while (index2 < targetIndex && index2 < totalColumns) {
|
|
27194
|
-
if (pendingRowSpans[index2] > 0) {
|
|
27195
|
-
pendingRowSpans[index2] -= 1;
|
|
27196
|
-
index2 += 1;
|
|
27197
|
-
continue;
|
|
27198
|
-
}
|
|
27199
|
-
const width = Array.isArray(gridColumnWidths) ? gridColumnWidths[index2] ?? 0 : 0;
|
|
27200
|
-
content.push(createPlaceholderCell(width, reason));
|
|
27201
|
-
index2 += 1;
|
|
27202
|
-
}
|
|
27203
|
-
return index2;
|
|
27143
|
+
const decode$p = (params) => {
|
|
27144
|
+
const { headers = [] } = params.node.attrs || {};
|
|
27145
|
+
const newNode = {
|
|
27146
|
+
name: XML_NODE_NAME$h,
|
|
27147
|
+
attributes: {},
|
|
27148
|
+
elements: headers.map(
|
|
27149
|
+
(header) => translator$K.decode({
|
|
27150
|
+
node: { type: "header", attrs: header }
|
|
27151
|
+
})
|
|
27152
|
+
)
|
|
27153
|
+
};
|
|
27154
|
+
return newNode;
|
|
27204
27155
|
};
|
|
27205
|
-
const
|
|
27206
|
-
|
|
27207
|
-
|
|
27208
|
-
|
|
27209
|
-
|
|
27210
|
-
const hasMeaningfulWidth = widths.some(
|
|
27211
|
-
(value) => typeof value === "number" && Number.isFinite(value) && Math.abs(value) > 1
|
|
27212
|
-
);
|
|
27213
|
-
if (!hasMeaningfulWidth) return true;
|
|
27214
|
-
}
|
|
27215
|
-
return false;
|
|
27156
|
+
const config$g = {
|
|
27157
|
+
xmlName: XML_NODE_NAME$h,
|
|
27158
|
+
sdNodeOrKeyName: SD_ATTR_KEY$3,
|
|
27159
|
+
encode: encode$n,
|
|
27160
|
+
decode: decode$p
|
|
27216
27161
|
};
|
|
27217
|
-
const
|
|
27218
|
-
const
|
|
27219
|
-
|
|
27220
|
-
|
|
27162
|
+
const translator$J = NodeTranslator.from(config$g);
|
|
27163
|
+
const propertyTranslators$4 = [
|
|
27164
|
+
translator$1a,
|
|
27165
|
+
translator$18,
|
|
27166
|
+
translator$17,
|
|
27167
|
+
translator$16,
|
|
27168
|
+
translator$R,
|
|
27169
|
+
translator$19,
|
|
27170
|
+
translator$Q,
|
|
27171
|
+
translator$P,
|
|
27172
|
+
translator$O,
|
|
27173
|
+
translator$N,
|
|
27174
|
+
translator$M,
|
|
27175
|
+
translator$L,
|
|
27176
|
+
translator$J
|
|
27177
|
+
];
|
|
27178
|
+
const translator$I = NodeTranslator.from(
|
|
27179
|
+
createNestedPropertiesTranslator("w:tcPr", "tableCellProperties", propertyTranslators$4)
|
|
27221
27180
|
);
|
|
27222
|
-
|
|
27223
|
-
|
|
27224
|
-
|
|
27225
|
-
|
|
27226
|
-
|
|
27227
|
-
|
|
27228
|
-
|
|
27229
|
-
|
|
27230
|
-
|
|
27231
|
-
|
|
27232
|
-
|
|
27233
|
-
const
|
|
27234
|
-
|
|
27235
|
-
|
|
27236
|
-
|
|
27237
|
-
const {
|
|
27238
|
-
|
|
27239
|
-
|
|
27240
|
-
|
|
27241
|
-
|
|
27242
|
-
|
|
27243
|
-
|
|
27244
|
-
|
|
27245
|
-
|
|
27246
|
-
|
|
27247
|
-
|
|
27248
|
-
|
|
27249
|
-
|
|
27250
|
-
|
|
27251
|
-
|
|
27252
|
-
|
|
27253
|
-
|
|
27254
|
-
|
|
27255
|
-
|
|
27256
|
-
|
|
27257
|
-
|
|
27258
|
-
|
|
27259
|
-
|
|
27260
|
-
|
|
27261
|
-
|
|
27262
|
-
|
|
27263
|
-
|
|
27264
|
-
|
|
27265
|
-
|
|
27266
|
-
|
|
27267
|
-
|
|
27268
|
-
|
|
27269
|
-
|
|
27270
|
-
|
|
27271
|
-
}
|
|
27272
|
-
});
|
|
27273
|
-
if (result) {
|
|
27274
|
-
content.push(result);
|
|
27275
|
-
const colspan = Math.max(1, result.attrs?.colspan || 1);
|
|
27276
|
-
const rowspan = Math.max(1, result.attrs?.rowspan || 1);
|
|
27277
|
-
if (rowspan > 1) {
|
|
27278
|
-
for (let offset = 0; offset < colspan; offset += 1) {
|
|
27279
|
-
const target = startColumn + offset;
|
|
27280
|
-
if (target < pendingRowSpans.length) {
|
|
27281
|
-
pendingRowSpans[target] = Math.max(pendingRowSpans[target], rowspan - 1);
|
|
27282
|
-
}
|
|
27181
|
+
function handleTableCellNode({
|
|
27182
|
+
params,
|
|
27183
|
+
node,
|
|
27184
|
+
table,
|
|
27185
|
+
row,
|
|
27186
|
+
rowBorders,
|
|
27187
|
+
columnIndex,
|
|
27188
|
+
columnWidth = null,
|
|
27189
|
+
allColumnWidths = [],
|
|
27190
|
+
_referencedStyles
|
|
27191
|
+
}) {
|
|
27192
|
+
const { nodeListHandler } = params;
|
|
27193
|
+
const attributes = {};
|
|
27194
|
+
const referencedStyles = _referencedStyles ?? { fontSize: null, fonts: {}, cellMargins: {} };
|
|
27195
|
+
const tcPr = node.elements.find((el) => el.name === "w:tcPr");
|
|
27196
|
+
const tableCellProperties = tcPr ? translator$I.encode({ ...params, nodes: [tcPr] }) ?? {} : {};
|
|
27197
|
+
attributes["tableCellProperties"] = tableCellProperties;
|
|
27198
|
+
if (rowBorders?.insideH) {
|
|
27199
|
+
rowBorders["bottom"] = rowBorders.insideH;
|
|
27200
|
+
delete rowBorders.insideH;
|
|
27201
|
+
}
|
|
27202
|
+
if (rowBorders?.insideV) {
|
|
27203
|
+
rowBorders["right"] = rowBorders.insideV;
|
|
27204
|
+
delete rowBorders?.insideV;
|
|
27205
|
+
}
|
|
27206
|
+
if (rowBorders) attributes["borders"] = { ...rowBorders };
|
|
27207
|
+
const inlineBorders = processInlineCellBorders(tableCellProperties.borders, rowBorders);
|
|
27208
|
+
if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"] || {}, inlineBorders);
|
|
27209
|
+
const colspan = tableCellProperties.gridSpan;
|
|
27210
|
+
if (colspan && !isNaN(parseInt(colspan, 10))) attributes["colspan"] = parseInt(colspan, 10);
|
|
27211
|
+
let width = tableCellProperties.cellWidth?.value ? twipsToPixels(tableCellProperties.cellWidth?.value) : null;
|
|
27212
|
+
const widthType = tableCellProperties.cellWidth?.type;
|
|
27213
|
+
if (widthType) attributes["widthType"] = widthType;
|
|
27214
|
+
if (!width && columnWidth) width = columnWidth;
|
|
27215
|
+
if (width) {
|
|
27216
|
+
attributes["colwidth"] = [width];
|
|
27217
|
+
attributes["widthUnit"] = "px";
|
|
27218
|
+
const defaultColWidths = allColumnWidths;
|
|
27219
|
+
const hasDefaultColWidths = allColumnWidths && allColumnWidths.length > 0;
|
|
27220
|
+
const colspanNum = parseInt(colspan || 1, 10);
|
|
27221
|
+
if (colspanNum && colspanNum > 1 && hasDefaultColWidths) {
|
|
27222
|
+
let colwidth = [];
|
|
27223
|
+
for (let i = 0; i < colspanNum; i++) {
|
|
27224
|
+
let colwidthValue = defaultColWidths[columnIndex + i];
|
|
27225
|
+
let defaultColwidth = 100;
|
|
27226
|
+
if (typeof colwidthValue !== "undefined") {
|
|
27227
|
+
colwidth.push(colwidthValue);
|
|
27228
|
+
} else {
|
|
27229
|
+
colwidth.push(defaultColwidth);
|
|
27283
27230
|
}
|
|
27284
27231
|
}
|
|
27285
|
-
|
|
27232
|
+
if (colwidth.length) {
|
|
27233
|
+
attributes["colwidth"] = [...colwidth];
|
|
27234
|
+
}
|
|
27286
27235
|
}
|
|
27287
|
-
});
|
|
27288
|
-
skipOccupiedColumns();
|
|
27289
|
-
fillUntil(totalColumns, "gridAfter");
|
|
27290
|
-
const newNode = {
|
|
27291
|
-
type: "tableRow",
|
|
27292
|
-
content,
|
|
27293
|
-
attrs: encodedAttrs
|
|
27294
|
-
};
|
|
27295
|
-
return newNode;
|
|
27296
|
-
};
|
|
27297
|
-
const decode$p = (params, decodedAttrs) => {
|
|
27298
|
-
const { node } = params;
|
|
27299
|
-
const cells = node.content || [];
|
|
27300
|
-
let leadingPlaceholders = 0;
|
|
27301
|
-
while (leadingPlaceholders < cells.length && isPlaceholderCell(cells[leadingPlaceholders])) {
|
|
27302
|
-
leadingPlaceholders += 1;
|
|
27303
27236
|
}
|
|
27304
|
-
|
|
27305
|
-
|
|
27306
|
-
|
|
27237
|
+
const background = {
|
|
27238
|
+
color: tableCellProperties.shading?.fill
|
|
27239
|
+
};
|
|
27240
|
+
if (background.color) attributes["background"] = background;
|
|
27241
|
+
const verticalAlign = tableCellProperties.vAlign;
|
|
27242
|
+
if (verticalAlign) attributes["verticalAlign"] = verticalAlign;
|
|
27243
|
+
attributes.cellMargins = getTableCellMargins(tableCellProperties.cellMargins, referencedStyles);
|
|
27244
|
+
const { fontSize, fonts = {} } = referencedStyles;
|
|
27245
|
+
const fontFamily = fonts["ascii"];
|
|
27246
|
+
if (fontSize) attributes["fontSize"] = fontSize;
|
|
27247
|
+
if (fontFamily) attributes["fontFamily"] = fontFamily;
|
|
27248
|
+
if (tableCellProperties.vMerge === "restart") {
|
|
27249
|
+
const rows = table.elements.filter((el) => el.name === "w:tr");
|
|
27250
|
+
const currentRowIndex = rows.findIndex((r) => r === row);
|
|
27251
|
+
const remainingRows = rows.slice(currentRowIndex + 1);
|
|
27252
|
+
const cellsInRow = row.elements.filter((el) => el.name === "w:tc");
|
|
27253
|
+
let cellIndex = cellsInRow.findIndex((el) => el === node);
|
|
27254
|
+
let rowspan = 1;
|
|
27255
|
+
for (let remainingRow of remainingRows) {
|
|
27256
|
+
const firstCell = remainingRow.elements.findIndex((el) => el.name === "w:tc");
|
|
27257
|
+
const cellAtIndex = remainingRow.elements[firstCell + cellIndex];
|
|
27258
|
+
if (!cellAtIndex) break;
|
|
27259
|
+
const vMerge = getTableCellVMerge(cellAtIndex);
|
|
27260
|
+
if (!vMerge || vMerge === "restart") {
|
|
27261
|
+
break;
|
|
27262
|
+
}
|
|
27263
|
+
rowspan++;
|
|
27264
|
+
remainingRow.elements.splice(firstCell + cellIndex, 1);
|
|
27265
|
+
}
|
|
27266
|
+
attributes["rowspan"] = rowspan;
|
|
27307
27267
|
}
|
|
27308
|
-
|
|
27309
|
-
|
|
27310
|
-
|
|
27311
|
-
|
|
27312
|
-
|
|
27268
|
+
return {
|
|
27269
|
+
type: "tableCell",
|
|
27270
|
+
content: normalizeTableCellContent(
|
|
27271
|
+
nodeListHandler.handler({
|
|
27272
|
+
...params,
|
|
27273
|
+
nodes: node.elements,
|
|
27274
|
+
path: [...params.path || [], node]
|
|
27275
|
+
}),
|
|
27276
|
+
params.editor
|
|
27277
|
+
),
|
|
27278
|
+
attrs: attributes
|
|
27279
|
+
};
|
|
27280
|
+
}
|
|
27281
|
+
function normalizeTableCellContent(content, editor) {
|
|
27282
|
+
if (!Array.isArray(content) || content.length === 0) return content;
|
|
27283
|
+
const normalized = [];
|
|
27284
|
+
const pendingForNextBlock = [];
|
|
27285
|
+
const schema = editor?.schema;
|
|
27286
|
+
const cloneBlock = (node) => {
|
|
27287
|
+
if (!node) return node;
|
|
27288
|
+
const cloned = { ...node };
|
|
27289
|
+
if (Array.isArray(node.content)) {
|
|
27290
|
+
cloned.content = [...node.content];
|
|
27313
27291
|
}
|
|
27314
|
-
return
|
|
27315
|
-
});
|
|
27316
|
-
const trimmedContent = sanitizedCells.filter((_2, index2) => !isPlaceholderCell(trimmedSlice[index2]));
|
|
27317
|
-
const translateParams = {
|
|
27318
|
-
...params,
|
|
27319
|
-
node: { ...node, content: trimmedContent }
|
|
27292
|
+
return cloned;
|
|
27320
27293
|
};
|
|
27321
|
-
const
|
|
27322
|
-
|
|
27323
|
-
|
|
27324
|
-
if (leadingPlaceholders > 0) {
|
|
27325
|
-
tableRowProperties.gridBefore = leadingPlaceholders;
|
|
27294
|
+
const ensureArray = (node) => {
|
|
27295
|
+
if (!Array.isArray(node.content)) {
|
|
27296
|
+
node.content = [];
|
|
27326
27297
|
}
|
|
27327
|
-
|
|
27328
|
-
|
|
27298
|
+
return node.content;
|
|
27299
|
+
};
|
|
27300
|
+
const isInlineNode = (node) => {
|
|
27301
|
+
if (!node || typeof node.type !== "string") return false;
|
|
27302
|
+
if (node.type === "text") return true;
|
|
27303
|
+
if (node.type === "bookmarkStart" || node.type === "bookmarkEnd") return true;
|
|
27304
|
+
const nodeType = schema?.nodes?.[node.type];
|
|
27305
|
+
if (nodeType) {
|
|
27306
|
+
if (typeof nodeType.isInline === "boolean") return nodeType.isInline;
|
|
27307
|
+
if (nodeType.spec?.group && typeof nodeType.spec.group === "string") {
|
|
27308
|
+
return nodeType.spec.group.split(" ").includes("inline");
|
|
27309
|
+
}
|
|
27329
27310
|
}
|
|
27330
|
-
|
|
27331
|
-
|
|
27332
|
-
|
|
27333
|
-
|
|
27311
|
+
return false;
|
|
27312
|
+
};
|
|
27313
|
+
for (const node of content) {
|
|
27314
|
+
if (!node || typeof node.type !== "string") {
|
|
27315
|
+
normalized.push(node);
|
|
27316
|
+
continue;
|
|
27317
|
+
}
|
|
27318
|
+
if (!isInlineNode(node)) {
|
|
27319
|
+
const blockNode = cloneBlock(node);
|
|
27320
|
+
if (pendingForNextBlock.length) {
|
|
27321
|
+
const blockContent = ensureArray(blockNode);
|
|
27322
|
+
const leadingInline = pendingForNextBlock.splice(0);
|
|
27323
|
+
blockNode.content = [...leadingInline, ...blockContent];
|
|
27324
|
+
} else if (Array.isArray(blockNode.content)) {
|
|
27325
|
+
blockNode.content = [...blockNode.content];
|
|
27334
27326
|
}
|
|
27327
|
+
normalized.push(blockNode);
|
|
27328
|
+
continue;
|
|
27329
|
+
}
|
|
27330
|
+
const targetIsNextBlock = node.type === "bookmarkStart" || normalized.length === 0;
|
|
27331
|
+
if (targetIsNextBlock) {
|
|
27332
|
+
pendingForNextBlock.push(node);
|
|
27333
|
+
} else {
|
|
27334
|
+
const lastIndex = normalized.length - 1;
|
|
27335
|
+
const lastNode = normalized[lastIndex];
|
|
27336
|
+
if (!lastNode || typeof lastNode.type !== "string" || isInlineNode(lastNode)) {
|
|
27337
|
+
pendingForNextBlock.push(node);
|
|
27338
|
+
continue;
|
|
27339
|
+
}
|
|
27340
|
+
const blockContent = ensureArray(lastNode);
|
|
27341
|
+
if (pendingForNextBlock.length) {
|
|
27342
|
+
blockContent.push(...pendingForNextBlock.splice(0));
|
|
27343
|
+
}
|
|
27344
|
+
blockContent.push(node);
|
|
27335
27345
|
}
|
|
27336
|
-
tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
|
|
27337
|
-
const trPr = translator$_.decode({
|
|
27338
|
-
...params,
|
|
27339
|
-
node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
|
|
27340
|
-
});
|
|
27341
|
-
if (trPr) elements.unshift(trPr);
|
|
27342
27346
|
}
|
|
27343
|
-
|
|
27344
|
-
|
|
27345
|
-
|
|
27346
|
-
|
|
27347
|
-
|
|
27348
|
-
|
|
27349
|
-
|
|
27350
|
-
|
|
27351
|
-
|
|
27352
|
-
|
|
27353
|
-
|
|
27354
|
-
|
|
27355
|
-
|
|
27356
|
-
}
|
|
27357
|
-
|
|
27358
|
-
|
|
27359
|
-
|
|
27360
|
-
sdNodeOrKeyName: "rightToLeft",
|
|
27361
|
-
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27362
|
-
decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
|
|
27363
|
-
});
|
|
27364
|
-
const translator$X = NodeTranslator.from({
|
|
27365
|
-
xmlName: "w:shd",
|
|
27366
|
-
sdNodeOrKeyName: "shading",
|
|
27367
|
-
attributes: [
|
|
27368
|
-
"w:color",
|
|
27369
|
-
"w:fill",
|
|
27370
|
-
"w:themeColor",
|
|
27371
|
-
"w:themeFill",
|
|
27372
|
-
"w:themeFillShade",
|
|
27373
|
-
"w:themeFillTint",
|
|
27374
|
-
"w:themeShade",
|
|
27375
|
-
"w:themeTint",
|
|
27376
|
-
"w:val"
|
|
27377
|
-
].map((attr) => createAttributeHandler(attr)),
|
|
27378
|
-
encode: (params, encodedAttrs) => {
|
|
27379
|
-
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
27380
|
-
},
|
|
27381
|
-
decode: function({ node }, context) {
|
|
27382
|
-
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.shading || {} } });
|
|
27383
|
-
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
27384
|
-
}
|
|
27385
|
-
});
|
|
27386
|
-
const translator$W = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
|
|
27387
|
-
const translator$V = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
|
|
27388
|
-
const translator$U = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
|
|
27389
|
-
const translator$T = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
|
|
27390
|
-
const translator$S = NodeTranslator.from({
|
|
27391
|
-
xmlName: "w:tblLook",
|
|
27392
|
-
sdNodeOrKeyName: "tblLook",
|
|
27393
|
-
attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
|
|
27394
|
-
encode: (params, encodedAttrs) => {
|
|
27395
|
-
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
27396
|
-
},
|
|
27397
|
-
decode: function({ node }, context) {
|
|
27398
|
-
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.tblLook || {} } });
|
|
27399
|
-
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
27400
|
-
}
|
|
27401
|
-
});
|
|
27402
|
-
const translator$R = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
|
|
27403
|
-
const translator$Q = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
|
|
27404
|
-
const translator$P = NodeTranslator.from(
|
|
27405
|
-
createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
|
|
27406
|
-
);
|
|
27407
|
-
const translator$O = NodeTranslator.from(
|
|
27408
|
-
createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
|
|
27409
|
-
);
|
|
27410
|
-
const translator$N = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
|
|
27411
|
-
const translator$M = NodeTranslator.from({
|
|
27412
|
-
xmlName: "w:tblpPr",
|
|
27413
|
-
sdNodeOrKeyName: "floatingTableProperties",
|
|
27414
|
-
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))),
|
|
27415
|
-
encode: (params, encodedAttrs) => {
|
|
27416
|
-
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
27417
|
-
},
|
|
27418
|
-
decode: function({ node }, context) {
|
|
27419
|
-
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.floatingTableProperties || {} } });
|
|
27420
|
-
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
27421
|
-
}
|
|
27422
|
-
});
|
|
27423
|
-
const translator$L = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
|
|
27424
|
-
const translator$K = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
|
|
27425
|
-
const translator$J = NodeTranslator.from(createBorderPropertyHandler("w:end"));
|
|
27426
|
-
const translator$I = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
|
|
27427
|
-
const translator$H = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
|
|
27428
|
-
const translator$G = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
|
|
27429
|
-
const translator$F = NodeTranslator.from(createBorderPropertyHandler("w:left"));
|
|
27430
|
-
const translator$E = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
|
|
27431
|
-
const translator$D = NodeTranslator.from(createBorderPropertyHandler("w:right"));
|
|
27432
|
-
const translator$C = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
|
|
27433
|
-
const translator$B = NodeTranslator.from(createBorderPropertyHandler("w:start"));
|
|
27434
|
-
const translator$A = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
|
|
27435
|
-
const translator$z = NodeTranslator.from(createBorderPropertyHandler("w:top"));
|
|
27436
|
-
const translator$y = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
|
|
27437
|
-
const propertyTranslators$5 = [
|
|
27438
|
-
translator$L,
|
|
27439
|
-
translator$J,
|
|
27440
|
-
translator$H,
|
|
27441
|
-
translator$G,
|
|
27442
|
-
translator$F,
|
|
27443
|
-
translator$D,
|
|
27444
|
-
translator$B,
|
|
27445
|
-
translator$z
|
|
27446
|
-
];
|
|
27447
|
-
const translator$x = NodeTranslator.from(
|
|
27448
|
-
createNestedPropertiesTranslator("w:tblBorders", "borders", propertyTranslators$5)
|
|
27449
|
-
);
|
|
27450
|
-
const propertyTranslators$4 = [
|
|
27451
|
-
translator$K,
|
|
27452
|
-
translator$I,
|
|
27453
|
-
translator$E,
|
|
27454
|
-
translator$C,
|
|
27455
|
-
translator$A,
|
|
27456
|
-
translator$y
|
|
27457
|
-
];
|
|
27458
|
-
const translator$w = NodeTranslator.from(
|
|
27459
|
-
createNestedPropertiesTranslator("w:tblCellMar", "cellMargins", propertyTranslators$4)
|
|
27460
|
-
);
|
|
27461
|
-
const propertyTranslators$3 = [
|
|
27462
|
-
translator$Y,
|
|
27463
|
-
translator$14,
|
|
27464
|
-
translator$X,
|
|
27465
|
-
translator$W,
|
|
27466
|
-
translator$13,
|
|
27467
|
-
translator$V,
|
|
27468
|
-
translator$U,
|
|
27469
|
-
translator$T,
|
|
27470
|
-
translator$S,
|
|
27471
|
-
translator$R,
|
|
27472
|
-
translator$Q,
|
|
27473
|
-
translator$P,
|
|
27474
|
-
translator$O,
|
|
27475
|
-
translator$N,
|
|
27476
|
-
translator$M,
|
|
27477
|
-
translator$x,
|
|
27478
|
-
translator$w
|
|
27479
|
-
];
|
|
27480
|
-
const translator$v = NodeTranslator.from(
|
|
27481
|
-
createNestedPropertiesTranslator("w:tblPr", "tableProperties", propertyTranslators$3)
|
|
27482
|
-
);
|
|
27483
|
-
const translator$u = NodeTranslator.from(
|
|
27484
|
-
createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
|
|
27485
|
-
);
|
|
27486
|
-
const DEFAULT_COLUMN_WIDTH_PX = 100;
|
|
27487
|
-
const normalizeTwipWidth = (value) => {
|
|
27488
|
-
if (value == null) return null;
|
|
27489
|
-
const numericValue = typeof value === "string" ? parseInt(value, 10) : value;
|
|
27490
|
-
if (!Number.isFinite(numericValue) || Number.isNaN(numericValue) || numericValue <= 0) {
|
|
27491
|
-
return null;
|
|
27492
|
-
}
|
|
27493
|
-
return numericValue;
|
|
27494
|
-
};
|
|
27495
|
-
const getSchemaDefaultColumnWidthPx = (params) => {
|
|
27496
|
-
const defaultValue = params?.editor?.schema?.nodes?.tableCell?.spec?.attrs?.colwidth?.default;
|
|
27497
|
-
if (Array.isArray(defaultValue)) {
|
|
27498
|
-
const numericWidth = defaultValue.find((width) => typeof width === "number" && Number.isFinite(width) && width > 0);
|
|
27499
|
-
if (numericWidth != null) return numericWidth;
|
|
27500
|
-
} else if (typeof defaultValue === "number" && Number.isFinite(defaultValue) && defaultValue > 0) {
|
|
27501
|
-
return defaultValue;
|
|
27502
|
-
}
|
|
27503
|
-
return DEFAULT_COLUMN_WIDTH_PX;
|
|
27504
|
-
};
|
|
27505
|
-
const getTableWidthPx = (params) => {
|
|
27506
|
-
const explicitWidth = params?.node?.attrs?.tableWidth?.width;
|
|
27507
|
-
if (typeof explicitWidth === "number" && explicitWidth > 0) return explicitWidth;
|
|
27508
|
-
const tableWidth = params?.node?.attrs?.tableProperties?.tableWidth;
|
|
27509
|
-
if (tableWidth?.value != null && typeof tableWidth.value === "number" && tableWidth.value > 0) {
|
|
27510
|
-
const { value, type: type2 } = tableWidth;
|
|
27511
|
-
if (!type2 || type2 === "auto" || type2 === "dxa") {
|
|
27512
|
-
return twipsToPixels(value);
|
|
27347
|
+
if (pendingForNextBlock.length) {
|
|
27348
|
+
if (normalized.length) {
|
|
27349
|
+
const lastIndex = normalized.length - 1;
|
|
27350
|
+
const lastNode = normalized[lastIndex];
|
|
27351
|
+
if (lastNode && typeof lastNode.type === "string" && !isInlineNode(lastNode)) {
|
|
27352
|
+
const blockContent = ensureArray(lastNode);
|
|
27353
|
+
blockContent.push(...pendingForNextBlock);
|
|
27354
|
+
pendingForNextBlock.length = 0;
|
|
27355
|
+
}
|
|
27356
|
+
}
|
|
27357
|
+
if (pendingForNextBlock.length) {
|
|
27358
|
+
normalized.push({
|
|
27359
|
+
type: "paragraph",
|
|
27360
|
+
attrs: {},
|
|
27361
|
+
content: [...pendingForNextBlock]
|
|
27362
|
+
});
|
|
27363
|
+
pendingForNextBlock.length = 0;
|
|
27513
27364
|
}
|
|
27514
27365
|
}
|
|
27515
|
-
return
|
|
27516
|
-
}
|
|
27517
|
-
const
|
|
27518
|
-
|
|
27519
|
-
|
|
27520
|
-
|
|
27521
|
-
|
|
27522
|
-
|
|
27523
|
-
|
|
27524
|
-
|
|
27525
|
-
|
|
27526
|
-
|
|
27527
|
-
|
|
27528
|
-
const safeDefault = Math.max(pixelsToTwips(safeDefaultPx), cellMinWidthTwips);
|
|
27529
|
-
return safeDefault;
|
|
27530
|
-
}
|
|
27531
|
-
return Math.max(fallbackWidthTwips, cellMinWidthTwips);
|
|
27532
|
-
};
|
|
27533
|
-
const XML_NODE_NAME$g = "w:tblGrid";
|
|
27534
|
-
const SD_ATTR_KEY$3 = "grid";
|
|
27535
|
-
const cellMinWidth = pixelsToTwips(10);
|
|
27536
|
-
const encode$m = (params) => {
|
|
27537
|
-
const { nodes } = params;
|
|
27538
|
-
const node = nodes[0];
|
|
27539
|
-
const attributes = encodeProperties(node, { [translator$u.xmlName]: translator$u }, true);
|
|
27540
|
-
return {
|
|
27541
|
-
xmlName: XML_NODE_NAME$g,
|
|
27542
|
-
sdNodeOrKeyName: SD_ATTR_KEY$3,
|
|
27543
|
-
attributes
|
|
27544
|
-
};
|
|
27545
|
-
};
|
|
27546
|
-
const decode$o = (params) => {
|
|
27547
|
-
const { grid: rawGrid } = params.node.attrs || {};
|
|
27548
|
-
const grid = Array.isArray(rawGrid) ? rawGrid : [];
|
|
27549
|
-
const { firstRow = {} } = params.extraParams || {};
|
|
27550
|
-
const cellNodes = firstRow.content?.filter((n) => n.type === "tableCell") ?? [];
|
|
27551
|
-
const columnCountFromCells = cellNodes.reduce((count, cell) => {
|
|
27552
|
-
const spanCount = Math.max(1, cell?.attrs?.colspan ?? 1);
|
|
27553
|
-
return count + spanCount;
|
|
27554
|
-
}, 0);
|
|
27555
|
-
const totalColumns = Math.max(columnCountFromCells, grid.length);
|
|
27556
|
-
const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params, totalColumns, cellMinWidth);
|
|
27557
|
-
const elements = [];
|
|
27558
|
-
let columnIndex = 0;
|
|
27559
|
-
const pushColumn = (widthTwips, { enforceMinimum = false } = {}) => {
|
|
27560
|
-
let numericWidth = typeof widthTwips === "string" ? parseInt(widthTwips, 10) : widthTwips;
|
|
27561
|
-
let shouldEnforceMinimum = enforceMinimum;
|
|
27562
|
-
if (numericWidth == null || Number.isNaN(numericWidth) || numericWidth <= 0) {
|
|
27563
|
-
numericWidth = fallbackColumnWidthTwips;
|
|
27564
|
-
shouldEnforceMinimum = true;
|
|
27366
|
+
return normalized;
|
|
27367
|
+
}
|
|
27368
|
+
const processInlineCellBorders = (borders, rowBorders) => {
|
|
27369
|
+
if (!borders) return null;
|
|
27370
|
+
return ["bottom", "top", "left", "right"].reduce((acc, direction) => {
|
|
27371
|
+
const borderAttrs = borders[direction];
|
|
27372
|
+
const rowBorderAttrs = rowBorders[direction];
|
|
27373
|
+
if (borderAttrs && borderAttrs["val"] !== "nil") {
|
|
27374
|
+
const color = borderAttrs["color"];
|
|
27375
|
+
let size = borderAttrs["size"];
|
|
27376
|
+
if (size) size = eighthPointsToPixels(size);
|
|
27377
|
+
acc[direction] = { color, size, val: borderAttrs["val"] };
|
|
27378
|
+
return acc;
|
|
27565
27379
|
}
|
|
27566
|
-
|
|
27567
|
-
|
|
27568
|
-
|
|
27569
|
-
|
|
27570
|
-
node: { type: (
|
|
27571
|
-
/** @type {string} */
|
|
27572
|
-
translator$u.sdNodeOrKeyName
|
|
27573
|
-
), attrs: { col: safeWidth } }
|
|
27574
|
-
});
|
|
27575
|
-
if (decoded) elements.push(decoded);
|
|
27576
|
-
};
|
|
27577
|
-
cellNodes.forEach((cell) => {
|
|
27578
|
-
const { colspan = 1, colwidth } = cell?.attrs || {};
|
|
27579
|
-
const spanCount = Math.max(1, colspan);
|
|
27580
|
-
for (let span = 0; span < spanCount; span++) {
|
|
27581
|
-
const rawWidth = Array.isArray(colwidth) ? colwidth[span] : void 0;
|
|
27582
|
-
const cellWidthPixels = typeof rawWidth === "number" && Number.isFinite(rawWidth) ? rawWidth : Number(rawWidth);
|
|
27583
|
-
const hasCellWidth = Number.isFinite(cellWidthPixels) && cellWidthPixels > 0;
|
|
27584
|
-
const colGridAttrs = grid?.[columnIndex] || {};
|
|
27585
|
-
const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
|
|
27586
|
-
const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
|
|
27587
|
-
let cellWidthTwips;
|
|
27588
|
-
let enforceMinimum = false;
|
|
27589
|
-
if (hasCellWidth) {
|
|
27590
|
-
const tolerance = 0.5;
|
|
27591
|
-
if (gridWidthTwips != null && gridWidthPixels != null && Math.abs(gridWidthPixels - cellWidthPixels) <= tolerance) {
|
|
27592
|
-
cellWidthTwips = gridWidthTwips;
|
|
27593
|
-
} else {
|
|
27594
|
-
cellWidthTwips = pixelsToTwips(cellWidthPixels);
|
|
27595
|
-
}
|
|
27596
|
-
} else if (gridWidthTwips != null) {
|
|
27597
|
-
cellWidthTwips = gridWidthTwips;
|
|
27380
|
+
if (borderAttrs && borderAttrs["val"] === "nil") {
|
|
27381
|
+
const border = Object.assign({}, rowBorderAttrs || {});
|
|
27382
|
+
if (!Object.keys(border).length) {
|
|
27383
|
+
return acc;
|
|
27598
27384
|
} else {
|
|
27599
|
-
|
|
27600
|
-
|
|
27385
|
+
border["val"] = "none";
|
|
27386
|
+
acc[direction] = border;
|
|
27387
|
+
return acc;
|
|
27601
27388
|
}
|
|
27602
|
-
pushColumn(cellWidthTwips, { enforceMinimum });
|
|
27603
|
-
columnIndex++;
|
|
27604
27389
|
}
|
|
27605
|
-
|
|
27606
|
-
|
|
27607
|
-
const gridWidthTwips = normalizeTwipWidth(grid[columnIndex]?.col);
|
|
27608
|
-
pushColumn(gridWidthTwips);
|
|
27609
|
-
columnIndex++;
|
|
27610
|
-
}
|
|
27611
|
-
const newNode = {
|
|
27612
|
-
name: XML_NODE_NAME$g,
|
|
27613
|
-
attributes: {},
|
|
27614
|
-
elements
|
|
27615
|
-
};
|
|
27616
|
-
return newNode;
|
|
27390
|
+
return acc;
|
|
27391
|
+
}, {});
|
|
27617
27392
|
};
|
|
27618
|
-
const
|
|
27619
|
-
|
|
27620
|
-
|
|
27621
|
-
|
|
27622
|
-
|
|
27393
|
+
const getTableCellVMerge = (node) => {
|
|
27394
|
+
const tcPr = node.elements.find((el) => el.name === "w:tcPr");
|
|
27395
|
+
const vMerge = tcPr?.elements?.find((el) => el.name === "w:vMerge");
|
|
27396
|
+
if (!vMerge) return null;
|
|
27397
|
+
return vMerge.attributes?.["w:val"] || "continue";
|
|
27623
27398
|
};
|
|
27624
|
-
const
|
|
27625
|
-
const
|
|
27626
|
-
|
|
27627
|
-
const
|
|
27628
|
-
const
|
|
27629
|
-
const
|
|
27630
|
-
|
|
27631
|
-
|
|
27632
|
-
}
|
|
27633
|
-
|
|
27634
|
-
|
|
27635
|
-
|
|
27636
|
-
|
|
27637
|
-
|
|
27638
|
-
|
|
27639
|
-
|
|
27640
|
-
|
|
27641
|
-
if (percent == null || percent <= 0) return null;
|
|
27642
|
-
const widthTwips = resolveContentWidthTwips() * percent / 100;
|
|
27643
|
-
return twipsToPixels(widthTwips);
|
|
27644
|
-
}
|
|
27645
|
-
return null;
|
|
27646
|
-
};
|
|
27647
|
-
const countColumnsInRow = (row) => {
|
|
27648
|
-
if (!row?.elements?.length) return 0;
|
|
27649
|
-
return row.elements.reduce((count, element) => {
|
|
27650
|
-
if (element.name !== "w:tc") return count;
|
|
27651
|
-
const tcPr = element.elements?.find((el) => el.name === "w:tcPr");
|
|
27652
|
-
const gridSpan = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
27653
|
-
const spanValue = parseInt(gridSpan?.attributes?.["w:val"] || "1", 10);
|
|
27654
|
-
return count + (Number.isFinite(spanValue) && spanValue > 0 ? spanValue : 1);
|
|
27655
|
-
}, 0);
|
|
27399
|
+
const getTableCellMargins = (inlineMargins, referencedStyles) => {
|
|
27400
|
+
const { cellMargins = {} } = referencedStyles;
|
|
27401
|
+
return ["left", "right", "top", "bottom"].reduce((acc, direction) => {
|
|
27402
|
+
const key = `margin${direction.charAt(0).toUpperCase() + direction.slice(1)}`;
|
|
27403
|
+
const inlineValue = inlineMargins ? inlineMargins?.[key]?.value : null;
|
|
27404
|
+
const styleValue = cellMargins ? cellMargins[key] : null;
|
|
27405
|
+
if (inlineValue != null) {
|
|
27406
|
+
acc[direction] = twipsToPixels(inlineValue);
|
|
27407
|
+
} else if (styleValue == null) {
|
|
27408
|
+
acc[direction] = void 0;
|
|
27409
|
+
} else if (typeof styleValue === "object") {
|
|
27410
|
+
acc[direction] = twipsToPixels(styleValue.value);
|
|
27411
|
+
} else {
|
|
27412
|
+
acc[direction] = twipsToPixels(styleValue);
|
|
27413
|
+
}
|
|
27414
|
+
return acc;
|
|
27415
|
+
}, {});
|
|
27656
27416
|
};
|
|
27657
|
-
|
|
27658
|
-
const
|
|
27659
|
-
|
|
27660
|
-
|
|
27661
|
-
|
|
27662
|
-
|
|
27663
|
-
|
|
27664
|
-
/** @type {any} */
|
|
27665
|
-
params
|
|
27666
|
-
);
|
|
27667
|
-
const minimumColumnWidthPx = Number.isFinite(schemaDefaultPx) && schemaDefaultPx > 0 ? schemaDefaultPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
27668
|
-
let totalWidthPx;
|
|
27669
|
-
if (tableWidthMeasurement) {
|
|
27670
|
-
const resolved = resolveMeasurementWidthPx(tableWidthMeasurement);
|
|
27671
|
-
if (resolved != null) totalWidthPx = resolved;
|
|
27672
|
-
}
|
|
27673
|
-
if (totalWidthPx == null && tableWidth?.width && tableWidth.width > 0) {
|
|
27674
|
-
totalWidthPx = tableWidth.width;
|
|
27675
|
-
}
|
|
27676
|
-
if (totalWidthPx == null) {
|
|
27677
|
-
totalWidthPx = minimumColumnWidthPx * columnCount;
|
|
27678
|
-
}
|
|
27679
|
-
const rawColumnWidthPx = Math.max(totalWidthPx / columnCount, minimumColumnWidthPx);
|
|
27680
|
-
const columnWidthTwips = clampColumnWidthTwips(pixelsToTwips(rawColumnWidthPx));
|
|
27681
|
-
const fallbackColumnWidthPx = twipsToPixels(columnWidthTwips);
|
|
27417
|
+
function translateTableCell(params) {
|
|
27418
|
+
const elements = translateChildNodes({
|
|
27419
|
+
...params,
|
|
27420
|
+
tableCell: params.node
|
|
27421
|
+
});
|
|
27422
|
+
const cellProps = generateTableCellProperties(params.node);
|
|
27423
|
+
elements.unshift(cellProps);
|
|
27682
27424
|
return {
|
|
27683
|
-
|
|
27684
|
-
|
|
27425
|
+
name: "w:tc",
|
|
27426
|
+
elements
|
|
27685
27427
|
};
|
|
27686
|
-
}
|
|
27687
|
-
|
|
27688
|
-
const
|
|
27689
|
-
const
|
|
27690
|
-
const {
|
|
27691
|
-
const
|
|
27692
|
-
const
|
|
27693
|
-
if (
|
|
27694
|
-
|
|
27695
|
-
|
|
27428
|
+
}
|
|
27429
|
+
function generateTableCellProperties(node) {
|
|
27430
|
+
const tableCellProperties = { ...node.attrs?.tableCellProperties || {} };
|
|
27431
|
+
const { attrs } = node;
|
|
27432
|
+
const { colwidth = [], cellWidthType = "dxa", widthUnit } = attrs;
|
|
27433
|
+
const colwidthSum = colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
27434
|
+
const propertiesWidthPixels = twipsToPixels(tableCellProperties.cellWidth?.value);
|
|
27435
|
+
if (propertiesWidthPixels !== colwidthSum) {
|
|
27436
|
+
tableCellProperties["cellWidth"] = {
|
|
27437
|
+
value: widthUnit === "px" ? pixelsToTwips(colwidthSum) : inchesToTwips(colwidthSum),
|
|
27438
|
+
type: cellWidthType
|
|
27439
|
+
};
|
|
27696
27440
|
}
|
|
27697
|
-
const
|
|
27698
|
-
if (
|
|
27699
|
-
|
|
27441
|
+
const { colspan } = attrs;
|
|
27442
|
+
if (colspan > 1 && tableCellProperties.gridSpan !== colspan) {
|
|
27443
|
+
tableCellProperties["gridSpan"] = colspan;
|
|
27444
|
+
} else if (!colspan || tableCellProperties?.gridSpan === 1) {
|
|
27445
|
+
delete tableCellProperties.gridSpan;
|
|
27700
27446
|
}
|
|
27701
|
-
|
|
27702
|
-
|
|
27703
|
-
"
|
|
27704
|
-
|
|
27705
|
-
|
|
27706
|
-
["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
|
|
27707
|
-
].forEach((prop) => {
|
|
27708
|
-
let key;
|
|
27709
|
-
let transform;
|
|
27710
|
-
if (Array.isArray(prop)) {
|
|
27711
|
-
[key, transform] = prop;
|
|
27712
|
-
} else {
|
|
27713
|
-
key = prop;
|
|
27714
|
-
transform = (v2) => v2;
|
|
27715
|
-
}
|
|
27716
|
-
if (encodedAttrs.tableProperties && encodedAttrs.tableProperties[key]) {
|
|
27717
|
-
encodedAttrs[key] = transform(encodedAttrs.tableProperties[key]);
|
|
27718
|
-
}
|
|
27719
|
-
});
|
|
27720
|
-
if (encodedAttrs.tableCellSpacing) {
|
|
27721
|
-
encodedAttrs["borderCollapse"] = "separate";
|
|
27447
|
+
const { background = {} } = attrs;
|
|
27448
|
+
if (background?.color && tableCellProperties.shading?.fill !== background?.color) {
|
|
27449
|
+
tableCellProperties["shading"] = { fill: background.color };
|
|
27450
|
+
} else if (!background?.color && tableCellProperties?.shading?.fill) {
|
|
27451
|
+
delete tableCellProperties.shading;
|
|
27722
27452
|
}
|
|
27723
|
-
|
|
27724
|
-
|
|
27725
|
-
|
|
27726
|
-
|
|
27727
|
-
|
|
27728
|
-
|
|
27729
|
-
|
|
27730
|
-
|
|
27731
|
-
|
|
27732
|
-
|
|
27733
|
-
|
|
27734
|
-
|
|
27735
|
-
}
|
|
27736
|
-
}
|
|
27453
|
+
const { cellMargins } = attrs;
|
|
27454
|
+
if (cellMargins) {
|
|
27455
|
+
["left", "right", "top", "bottom"].forEach((side) => {
|
|
27456
|
+
const key = `margin${side.charAt(0).toUpperCase() + side.slice(1)}`;
|
|
27457
|
+
if (cellMargins[side] != null) {
|
|
27458
|
+
if (!tableCellProperties.cellMargins) tableCellProperties["cellMargins"] = {};
|
|
27459
|
+
let currentPropertyValuePixels = twipsToPixels(tableCellProperties.cellMargins?.[key]?.value);
|
|
27460
|
+
if (currentPropertyValuePixels !== cellMargins[side]) {
|
|
27461
|
+
tableCellProperties.cellMargins[key] = { value: pixelsToTwips(cellMargins[side]), type: "dxa" };
|
|
27462
|
+
}
|
|
27463
|
+
} else if (tableCellProperties?.cellMargins?.[key]) {
|
|
27464
|
+
delete tableCellProperties.cellMargins[key];
|
|
27465
|
+
}
|
|
27466
|
+
});
|
|
27737
27467
|
}
|
|
27738
|
-
const {
|
|
27739
|
-
|
|
27740
|
-
|
|
27741
|
-
|
|
27742
|
-
|
|
27743
|
-
cellMargins: referencedStyles.cellMargins
|
|
27744
|
-
};
|
|
27468
|
+
const { verticalAlign } = attrs;
|
|
27469
|
+
if (verticalAlign && verticalAlign !== tableCellProperties.vAlign) {
|
|
27470
|
+
tableCellProperties["vAlign"] = verticalAlign;
|
|
27471
|
+
} else if (!verticalAlign && tableCellProperties?.vAlign) {
|
|
27472
|
+
delete tableCellProperties.vAlign;
|
|
27745
27473
|
}
|
|
27746
|
-
const
|
|
27747
|
-
|
|
27748
|
-
|
|
27749
|
-
|
|
27750
|
-
|
|
27751
|
-
|
|
27752
|
-
|
|
27753
|
-
const fallback = buildFallbackGridForTable({
|
|
27754
|
-
params,
|
|
27755
|
-
rows,
|
|
27756
|
-
tableWidth: encodedAttrs.tableWidth,
|
|
27757
|
-
tableWidthMeasurement: encodedAttrs.tableProperties?.tableWidth
|
|
27758
|
-
});
|
|
27759
|
-
if (fallback) {
|
|
27760
|
-
encodedAttrs.grid = fallback.grid;
|
|
27761
|
-
columnWidths = fallback.columnWidths;
|
|
27762
|
-
}
|
|
27474
|
+
const { rowspan } = attrs;
|
|
27475
|
+
if (rowspan && rowspan > 1 && tableCellProperties.vMerge !== "restart") {
|
|
27476
|
+
tableCellProperties["vMerge"] = "restart";
|
|
27477
|
+
} else if (attrs.continueMerge) {
|
|
27478
|
+
tableCellProperties["vMerge"] = "continue";
|
|
27479
|
+
} else if (tableCellProperties?.vMerge) {
|
|
27480
|
+
delete tableCellProperties.vMerge;
|
|
27763
27481
|
}
|
|
27764
|
-
const
|
|
27765
|
-
|
|
27766
|
-
|
|
27767
|
-
|
|
27768
|
-
|
|
27769
|
-
|
|
27770
|
-
|
|
27771
|
-
|
|
27772
|
-
|
|
27773
|
-
|
|
27774
|
-
|
|
27775
|
-
|
|
27776
|
-
|
|
27777
|
-
|
|
27778
|
-
|
|
27482
|
+
const { borders = {} } = attrs;
|
|
27483
|
+
if (!!borders && Object.keys(borders).length) {
|
|
27484
|
+
["top", "bottom", "left", "right"].forEach((side) => {
|
|
27485
|
+
if (borders[side]) {
|
|
27486
|
+
let currentPropertyValue = tableCellProperties.borders?.[side];
|
|
27487
|
+
let currentPropertySizePixels = eighthPointsToPixels(currentPropertyValue?.size);
|
|
27488
|
+
let color = borders[side].color;
|
|
27489
|
+
if (borders[side].color && color === "#000000") {
|
|
27490
|
+
color = "auto";
|
|
27491
|
+
}
|
|
27492
|
+
if (currentPropertySizePixels !== borders[side].size || currentPropertyValue?.color !== color || borders[side].val !== currentPropertyValue?.val) {
|
|
27493
|
+
if (!tableCellProperties.borders) tableCellProperties["borders"] = {};
|
|
27494
|
+
tableCellProperties.borders[side] = {
|
|
27495
|
+
size: pixelsToEightPoints(borders[side].size || 0),
|
|
27496
|
+
color,
|
|
27497
|
+
space: borders[side].space || 0,
|
|
27498
|
+
val: borders[side].val || "single"
|
|
27499
|
+
};
|
|
27500
|
+
}
|
|
27501
|
+
} else if (tableCellProperties.borders?.[side]) {
|
|
27502
|
+
delete tableCellProperties.borders[side];
|
|
27779
27503
|
}
|
|
27780
27504
|
});
|
|
27781
|
-
|
|
27782
|
-
|
|
27783
|
-
if (totalColumns > 0) {
|
|
27784
|
-
const activeRowSpansForCurrentRow = activeRowSpans.slice();
|
|
27785
|
-
for (let col = 0; col < totalColumns; col++) {
|
|
27786
|
-
if (activeRowSpans[col] > 0) {
|
|
27787
|
-
activeRowSpans[col] -= 1;
|
|
27788
|
-
}
|
|
27789
|
-
}
|
|
27790
|
-
let columnIndex = 0;
|
|
27791
|
-
const advanceColumnIndex = () => {
|
|
27792
|
-
while (columnIndex < totalColumns && activeRowSpansForCurrentRow[columnIndex] > 0) {
|
|
27793
|
-
columnIndex += 1;
|
|
27794
|
-
}
|
|
27795
|
-
};
|
|
27796
|
-
advanceColumnIndex();
|
|
27797
|
-
result.content?.forEach((cell) => {
|
|
27798
|
-
advanceColumnIndex();
|
|
27799
|
-
const colspan = Math.max(1, cell.attrs?.colspan || 1);
|
|
27800
|
-
const rowspan = Math.max(1, cell.attrs?.rowspan || 1);
|
|
27801
|
-
if (rowspan > 1) {
|
|
27802
|
-
for (let offset = 0; offset < colspan && columnIndex + offset < totalColumns; offset++) {
|
|
27803
|
-
const targetIndex = columnIndex + offset;
|
|
27804
|
-
const remainingRows = rowspan - 1;
|
|
27805
|
-
if (remainingRows > 0 && remainingRows > activeRowSpans[targetIndex]) {
|
|
27806
|
-
activeRowSpans[targetIndex] = remainingRows;
|
|
27807
|
-
}
|
|
27808
|
-
}
|
|
27809
|
-
}
|
|
27810
|
-
columnIndex += colspan;
|
|
27811
|
-
advanceColumnIndex();
|
|
27812
|
-
});
|
|
27813
|
-
}
|
|
27814
|
-
}
|
|
27815
|
-
});
|
|
27816
|
-
return {
|
|
27817
|
-
type: "table",
|
|
27818
|
-
content,
|
|
27819
|
-
attrs: encodedAttrs
|
|
27820
|
-
};
|
|
27821
|
-
};
|
|
27822
|
-
const decode$n = (params, decodedAttrs) => {
|
|
27823
|
-
params.node = preProcessVerticalMergeCells(params.node, params);
|
|
27824
|
-
const { node } = params;
|
|
27825
|
-
const elements = translateChildNodes(params);
|
|
27826
|
-
const firstRow = node.content?.find((n) => n.type === "tableRow");
|
|
27827
|
-
const properties = node.attrs.grid;
|
|
27828
|
-
const element = translator$t.decode({
|
|
27829
|
-
...params,
|
|
27830
|
-
node: { ...node, attrs: { ...node.attrs, grid: properties } },
|
|
27831
|
-
extraParams: {
|
|
27832
|
-
firstRow
|
|
27833
|
-
}
|
|
27834
|
-
});
|
|
27835
|
-
if (element) elements.unshift(element);
|
|
27836
|
-
if (node.attrs?.tableProperties) {
|
|
27837
|
-
const properties2 = { ...node.attrs.tableProperties };
|
|
27838
|
-
const element2 = translator$v.decode({
|
|
27839
|
-
...params,
|
|
27840
|
-
node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
|
|
27841
|
-
});
|
|
27842
|
-
if (element2) elements.unshift(element2);
|
|
27505
|
+
} else if (tableCellProperties?.borders) {
|
|
27506
|
+
delete tableCellProperties.borders;
|
|
27843
27507
|
}
|
|
27844
|
-
|
|
27845
|
-
|
|
27846
|
-
attributes: decodedAttrs || {},
|
|
27847
|
-
elements
|
|
27848
|
-
};
|
|
27849
|
-
};
|
|
27850
|
-
function _processTableBorders(rawBorders) {
|
|
27851
|
-
const borders = {};
|
|
27852
|
-
const rowBorders = {};
|
|
27853
|
-
Object.entries(rawBorders).forEach(([name, attributes]) => {
|
|
27854
|
-
const attrs = {};
|
|
27855
|
-
const color = attributes.color;
|
|
27856
|
-
const size = attributes.size;
|
|
27857
|
-
if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
|
|
27858
|
-
if (size && size !== "auto") attrs["size"] = eighthPointsToPixels(size);
|
|
27859
|
-
const rowBorderNames = ["insideH", "insideV"];
|
|
27860
|
-
if (rowBorderNames.includes(name)) rowBorders[name] = attrs;
|
|
27861
|
-
borders[name] = attrs;
|
|
27862
|
-
});
|
|
27863
|
-
return {
|
|
27864
|
-
borders,
|
|
27865
|
-
rowBorders
|
|
27866
|
-
};
|
|
27508
|
+
const result = translator$I.decode({ node: { ...node, attrs: { ...node.attrs, tableCellProperties } } });
|
|
27509
|
+
return result;
|
|
27867
27510
|
}
|
|
27868
|
-
|
|
27869
|
-
|
|
27870
|
-
|
|
27871
|
-
|
|
27872
|
-
const
|
|
27873
|
-
|
|
27874
|
-
|
|
27875
|
-
|
|
27876
|
-
|
|
27877
|
-
|
|
27878
|
-
|
|
27879
|
-
|
|
27880
|
-
|
|
27881
|
-
|
|
27882
|
-
|
|
27883
|
-
|
|
27884
|
-
|
|
27885
|
-
|
|
27886
|
-
|
|
27887
|
-
|
|
27888
|
-
|
|
27889
|
-
|
|
27890
|
-
|
|
27891
|
-
|
|
27892
|
-
|
|
27893
|
-
|
|
27894
|
-
|
|
27895
|
-
}
|
|
27896
|
-
const fontSize = rPr.elements.find((el) => el.name === "w:sz");
|
|
27897
|
-
if (fontSize?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize.attributes["w:val"]) + "pt";
|
|
27511
|
+
const XML_NODE_NAME$g = "w:tc";
|
|
27512
|
+
const SD_NODE_NAME$d = "tableCell";
|
|
27513
|
+
const validXmlAttributes$b = [];
|
|
27514
|
+
function encode$m(params, encodedAttrs) {
|
|
27515
|
+
const {
|
|
27516
|
+
node,
|
|
27517
|
+
table,
|
|
27518
|
+
row,
|
|
27519
|
+
rowBorders,
|
|
27520
|
+
columnIndex,
|
|
27521
|
+
columnWidth,
|
|
27522
|
+
columnWidths: allColumnWidths,
|
|
27523
|
+
_referencedStyles
|
|
27524
|
+
} = params.extraParams;
|
|
27525
|
+
const schemaNode = handleTableCellNode({
|
|
27526
|
+
params,
|
|
27527
|
+
node,
|
|
27528
|
+
table,
|
|
27529
|
+
row,
|
|
27530
|
+
rowBorders,
|
|
27531
|
+
columnIndex,
|
|
27532
|
+
columnWidth,
|
|
27533
|
+
allColumnWidths,
|
|
27534
|
+
_referencedStyles
|
|
27535
|
+
});
|
|
27536
|
+
if (encodedAttrs && Object.keys(encodedAttrs).length) {
|
|
27537
|
+
schemaNode.attrs = { ...schemaNode.attrs, ...encodedAttrs };
|
|
27898
27538
|
}
|
|
27899
|
-
|
|
27900
|
-
|
|
27901
|
-
|
|
27902
|
-
|
|
27903
|
-
|
|
27904
|
-
|
|
27905
|
-
const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
|
|
27906
|
-
if (borders) stylesToReturn.borders = borders;
|
|
27907
|
-
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
27908
|
-
const cellMargins = {};
|
|
27909
|
-
Object.entries(tableProperties.cellMargins || {}).forEach(([key, attrs]) => {
|
|
27910
|
-
if (attrs?.value != null) {
|
|
27911
|
-
cellMargins[key] = {
|
|
27912
|
-
value: attrs.value,
|
|
27913
|
-
type: attrs.type || "dxa"
|
|
27914
|
-
};
|
|
27915
|
-
}
|
|
27916
|
-
});
|
|
27917
|
-
if (Object.keys(cellMargins).length) stylesToReturn.cellMargins = cellMargins;
|
|
27539
|
+
return schemaNode;
|
|
27540
|
+
}
|
|
27541
|
+
function decode$o(params, decodedAttrs) {
|
|
27542
|
+
const translated = translateTableCell(params);
|
|
27543
|
+
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
27544
|
+
translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
|
|
27918
27545
|
}
|
|
27919
|
-
return
|
|
27546
|
+
return translated;
|
|
27920
27547
|
}
|
|
27921
|
-
const config$
|
|
27922
|
-
xmlName: XML_NODE_NAME$
|
|
27923
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
27548
|
+
const config$f = {
|
|
27549
|
+
xmlName: XML_NODE_NAME$g,
|
|
27550
|
+
sdNodeOrKeyName: SD_NODE_NAME$d,
|
|
27924
27551
|
type: NodeTranslator.translatorTypes.NODE,
|
|
27925
|
-
encode: encode$
|
|
27926
|
-
decode: decode$
|
|
27927
|
-
attributes:
|
|
27552
|
+
encode: encode$m,
|
|
27553
|
+
decode: decode$o,
|
|
27554
|
+
attributes: validXmlAttributes$b
|
|
27928
27555
|
};
|
|
27929
|
-
const translator$
|
|
27930
|
-
const
|
|
27931
|
-
|
|
27932
|
-
|
|
27933
|
-
|
|
27934
|
-
|
|
27935
|
-
|
|
27936
|
-
|
|
27937
|
-
|
|
27938
|
-
const { elements } = styles.elements[0];
|
|
27939
|
-
const styleElements = elements.filter((el) => el.name === "w:style");
|
|
27940
|
-
const styleTag = styleElements.find((el) => el.attributes["w:styleId"] === tableStyleReference);
|
|
27941
|
-
if (!styleTag) return null;
|
|
27942
|
-
stylesToReturn.name = styleTag.elements.find((el) => el.name === "w:name");
|
|
27943
|
-
const basedOn = styleTag.elements.find((el) => el.name === "w:basedOn");
|
|
27944
|
-
let baseTblPr;
|
|
27945
|
-
if (basedOn?.attributes) {
|
|
27946
|
-
const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
|
|
27947
|
-
baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
|
|
27948
|
-
}
|
|
27949
|
-
const pPr = styleTag.elements.find((el) => el.name === "w:pPr");
|
|
27950
|
-
if (pPr) {
|
|
27951
|
-
const justification = pPr.elements.find((el) => el.name === "w:jc");
|
|
27952
|
-
if (justification?.attributes) stylesToReturn.justification = justification.attributes["w:val"];
|
|
27953
|
-
}
|
|
27954
|
-
const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
|
|
27955
|
-
if (rPr) {
|
|
27956
|
-
const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
|
|
27957
|
-
if (fonts) {
|
|
27958
|
-
const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
|
|
27959
|
-
stylesToReturn.fonts = { ascii, hAnsi, cs };
|
|
27960
|
-
}
|
|
27961
|
-
const fontSize = rPr.elements.find((el) => el.name === "w:sz");
|
|
27962
|
-
if (fontSize?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize.attributes["w:val"]) + "pt";
|
|
27963
|
-
}
|
|
27964
|
-
const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
|
|
27965
|
-
if (tblPr && tblPr.elements) {
|
|
27966
|
-
if (baseTblPr && baseTblPr.elements) {
|
|
27967
|
-
tblPr.elements.push(...baseTblPr.elements);
|
|
27968
|
-
}
|
|
27969
|
-
const tableBorders = tblPr?.elements?.find((el) => el.name === "w:tblBorders");
|
|
27970
|
-
const { elements: borderElements = [] } = tableBorders || {};
|
|
27971
|
-
const { borders, rowBorders } = processTableBorders(borderElements);
|
|
27972
|
-
if (borders) stylesToReturn.borders = borders;
|
|
27973
|
-
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
27974
|
-
const tableCellMargin = tblPr?.elements.find((el) => el.name === "w:tblCellMar");
|
|
27975
|
-
if (tableCellMargin) {
|
|
27976
|
-
const marginLeft = tableCellMargin.elements.find((el) => el.name === "w:left");
|
|
27977
|
-
const marginRight = tableCellMargin.elements.find((el) => el.name === "w:right");
|
|
27978
|
-
const marginTop = tableCellMargin.elements.find((el) => el.name === "w:top");
|
|
27979
|
-
const marginBottom = tableCellMargin.elements.find((el) => el.name === "w:bottom");
|
|
27980
|
-
stylesToReturn.cellMargins = {
|
|
27981
|
-
marginLeft: marginLeft?.attributes["w:w"],
|
|
27982
|
-
marginRight: marginRight?.attributes["w:w"],
|
|
27983
|
-
marginTop: marginTop?.attributes["w:w"],
|
|
27984
|
-
marginBottom: marginBottom?.attributes["w:w"]
|
|
27985
|
-
};
|
|
27986
|
-
}
|
|
27987
|
-
}
|
|
27988
|
-
return stylesToReturn;
|
|
27989
|
-
}
|
|
27990
|
-
function processTableBorders(borderElements) {
|
|
27991
|
-
const borders = {};
|
|
27992
|
-
const rowBorders = {};
|
|
27993
|
-
borderElements.forEach((borderElement) => {
|
|
27994
|
-
const { name } = borderElement;
|
|
27995
|
-
const borderName = name.split("w:")[1];
|
|
27996
|
-
const { attributes } = borderElement;
|
|
27997
|
-
const attrs = {};
|
|
27998
|
-
const color = attributes["w:color"];
|
|
27999
|
-
const size = attributes["w:sz"];
|
|
28000
|
-
if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
|
|
28001
|
-
if (size && size !== "auto") attrs["size"] = eighthPointsToPixels(size);
|
|
28002
|
-
const rowBorderNames = ["insideH", "insideV"];
|
|
28003
|
-
if (rowBorderNames.includes(borderName)) rowBorders[borderName] = attrs;
|
|
28004
|
-
borders[borderName] = attrs;
|
|
28005
|
-
});
|
|
28006
|
-
return {
|
|
28007
|
-
borders,
|
|
28008
|
-
rowBorders
|
|
28009
|
-
};
|
|
28010
|
-
}
|
|
28011
|
-
const translator$r = NodeTranslator.from(createMeasurementPropertyHandler("w:tcW", "cellWidth"));
|
|
28012
|
-
const translator$q = NodeTranslator.from(
|
|
27556
|
+
const translator$H = NodeTranslator.from(config$f);
|
|
27557
|
+
const translator$G = NodeTranslator.from({
|
|
27558
|
+
xmlName: "w:cantSplit",
|
|
27559
|
+
sdNodeOrKeyName: "cantSplit",
|
|
27560
|
+
encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27561
|
+
decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
|
|
27562
|
+
});
|
|
27563
|
+
const translator$F = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
|
|
27564
|
+
const translator$E = NodeTranslator.from(
|
|
28013
27565
|
createSingleAttrPropertyHandler(
|
|
28014
|
-
"w:
|
|
27566
|
+
"w:gridAfter",
|
|
28015
27567
|
null,
|
|
28016
27568
|
"w:val",
|
|
28017
27569
|
(v2) => parseInteger(v2) ?? void 0,
|
|
28018
27570
|
(v2) => integerToString(v2)
|
|
28019
27571
|
)
|
|
28020
27572
|
);
|
|
28021
|
-
const translator$
|
|
28022
|
-
const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:tl2br"));
|
|
28023
|
-
const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:tr2bl"));
|
|
28024
|
-
const propertyTranslators$2 = [
|
|
28025
|
-
translator$z,
|
|
28026
|
-
translator$B,
|
|
28027
|
-
translator$F,
|
|
28028
|
-
translator$L,
|
|
28029
|
-
translator$J,
|
|
28030
|
-
translator$D,
|
|
28031
|
-
translator$H,
|
|
28032
|
-
translator$G,
|
|
28033
|
-
translator$o,
|
|
28034
|
-
translator$n
|
|
28035
|
-
];
|
|
28036
|
-
const translator$m = NodeTranslator.from(
|
|
28037
|
-
createNestedPropertiesTranslator("w:tcBorders", "borders", propertyTranslators$2)
|
|
28038
|
-
);
|
|
28039
|
-
const translator$l = NodeTranslator.from(
|
|
27573
|
+
const translator$D = NodeTranslator.from(
|
|
28040
27574
|
createSingleAttrPropertyHandler(
|
|
28041
|
-
"w:
|
|
27575
|
+
"w:gridBefore",
|
|
28042
27576
|
null,
|
|
28043
27577
|
"w:val",
|
|
28044
|
-
(v2) =>
|
|
28045
|
-
(v2) =>
|
|
27578
|
+
(v2) => parseInteger(v2) ?? void 0,
|
|
27579
|
+
(v2) => integerToString(v2)
|
|
28046
27580
|
)
|
|
28047
27581
|
);
|
|
28048
|
-
const
|
|
28049
|
-
|
|
28050
|
-
|
|
27582
|
+
const translator$C = NodeTranslator.from({
|
|
27583
|
+
xmlName: "w:hidden",
|
|
27584
|
+
sdNodeOrKeyName: "hidden",
|
|
27585
|
+
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27586
|
+
decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
|
|
27587
|
+
});
|
|
27588
|
+
const translator$B = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
|
|
27589
|
+
const translator$A = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
|
|
27590
|
+
const translator$z = NodeTranslator.from({
|
|
27591
|
+
xmlName: "w:tblHeader",
|
|
27592
|
+
sdNodeOrKeyName: "repeatHeader",
|
|
27593
|
+
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27594
|
+
decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
|
|
27595
|
+
});
|
|
27596
|
+
const translator$y = NodeTranslator.from({
|
|
27597
|
+
xmlName: "w:trHeight",
|
|
27598
|
+
sdNodeOrKeyName: "rowHeight",
|
|
27599
|
+
encode: ({ nodes }) => {
|
|
27600
|
+
const heightAttrs = {};
|
|
27601
|
+
const val = nodes[0].attributes["w:val"];
|
|
27602
|
+
if (val) {
|
|
27603
|
+
heightAttrs["value"] = parseInt(val, 10);
|
|
27604
|
+
}
|
|
27605
|
+
const rule = nodes[0].attributes["w:hRule"];
|
|
27606
|
+
if (rule) {
|
|
27607
|
+
heightAttrs["rule"] = rule;
|
|
27608
|
+
}
|
|
27609
|
+
return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
|
|
27610
|
+
},
|
|
27611
|
+
decode: ({ node }) => {
|
|
27612
|
+
if (!node.attrs?.rowHeight) return;
|
|
27613
|
+
const heightAttrs = {};
|
|
27614
|
+
if (typeof node.attrs.rowHeight.value === "number" && !isNaN(node.attrs.rowHeight.value)) {
|
|
27615
|
+
heightAttrs["w:val"] = String(node.attrs.rowHeight.value);
|
|
27616
|
+
}
|
|
27617
|
+
if (node.attrs.rowHeight.rule) {
|
|
27618
|
+
heightAttrs["w:hRule"] = node.attrs.rowHeight.rule;
|
|
27619
|
+
}
|
|
27620
|
+
return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
|
|
27621
|
+
}
|
|
27622
|
+
});
|
|
27623
|
+
const translator$x = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
|
|
27624
|
+
const translator$w = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
|
|
27625
|
+
const propertyTranslators$3 = [
|
|
27626
|
+
translator$G,
|
|
27627
|
+
translator$1a,
|
|
27628
|
+
translator$F,
|
|
28051
27629
|
translator$E,
|
|
27630
|
+
translator$D,
|
|
28052
27631
|
translator$C,
|
|
27632
|
+
translator$B,
|
|
28053
27633
|
translator$A,
|
|
28054
|
-
translator$
|
|
27634
|
+
translator$z,
|
|
27635
|
+
translator$y,
|
|
27636
|
+
translator$x,
|
|
27637
|
+
translator$w
|
|
28055
27638
|
];
|
|
28056
|
-
const translator$
|
|
28057
|
-
createNestedPropertiesTranslator("w:
|
|
28058
|
-
|
|
28059
|
-
|
|
28060
|
-
|
|
28061
|
-
|
|
28062
|
-
"w:tcFitText",
|
|
28063
|
-
null,
|
|
28064
|
-
"w:val",
|
|
28065
|
-
(v2) => parseBoolean(v2 ?? "true"),
|
|
28066
|
-
(v2) => booleanToString(v2)
|
|
28067
|
-
)
|
|
28068
|
-
);
|
|
28069
|
-
const translator$h = NodeTranslator.from(createSingleAttrPropertyHandler("w:vAlign"));
|
|
28070
|
-
const translator$g = NodeTranslator.from(
|
|
28071
|
-
createSingleAttrPropertyHandler(
|
|
28072
|
-
"w:hideMark",
|
|
28073
|
-
null,
|
|
28074
|
-
"w:val",
|
|
28075
|
-
(v2) => parseBoolean(v2 ?? "true"),
|
|
28076
|
-
(v2) => booleanToString(v2)
|
|
28077
|
-
)
|
|
27639
|
+
const translator$v = NodeTranslator.from(
|
|
27640
|
+
createNestedPropertiesTranslator("w:trPr", "tableRowProperties", propertyTranslators$3, {
|
|
27641
|
+
cantSplit: false,
|
|
27642
|
+
hidden: false,
|
|
27643
|
+
repeatHeader: false
|
|
27644
|
+
})
|
|
28078
27645
|
);
|
|
28079
|
-
const
|
|
28080
|
-
const
|
|
28081
|
-
const
|
|
28082
|
-
const encode$k = (params) => {
|
|
28083
|
-
const { nodes } = params;
|
|
28084
|
-
const node = nodes[0];
|
|
28085
|
-
const attributes = encodeProperties(node, { [translator$f.xmlName]: translator$f }, true);
|
|
27646
|
+
const createPlaceholderCell = (gridWidth, reason) => {
|
|
27647
|
+
const safeWidth = Number.isFinite(gridWidth) ? gridWidth : 0;
|
|
27648
|
+
const noBorder = { val: "none", size: 0 };
|
|
28086
27649
|
return {
|
|
28087
|
-
|
|
28088
|
-
|
|
28089
|
-
|
|
27650
|
+
type: "tableCell",
|
|
27651
|
+
attrs: {
|
|
27652
|
+
colspan: 1,
|
|
27653
|
+
rowspan: 1,
|
|
27654
|
+
colwidth: [safeWidth],
|
|
27655
|
+
__placeholder: reason,
|
|
27656
|
+
borders: {
|
|
27657
|
+
top: { ...noBorder },
|
|
27658
|
+
right: { ...noBorder },
|
|
27659
|
+
bottom: { ...noBorder },
|
|
27660
|
+
left: { ...noBorder }
|
|
27661
|
+
}
|
|
27662
|
+
},
|
|
27663
|
+
content: [{ type: "paragraph", content: [] }]
|
|
28090
27664
|
};
|
|
28091
27665
|
};
|
|
28092
|
-
const
|
|
28093
|
-
|
|
28094
|
-
|
|
28095
|
-
|
|
28096
|
-
|
|
28097
|
-
|
|
28098
|
-
|
|
28099
|
-
node: { type: "header", attrs: header }
|
|
28100
|
-
})
|
|
28101
|
-
)
|
|
28102
|
-
};
|
|
28103
|
-
return newNode;
|
|
27666
|
+
const advancePastRowSpans = (pendingRowSpans, startIndex, totalColumns) => {
|
|
27667
|
+
let index2 = startIndex;
|
|
27668
|
+
while (index2 < totalColumns && pendingRowSpans[index2] > 0) {
|
|
27669
|
+
pendingRowSpans[index2] -= 1;
|
|
27670
|
+
index2 += 1;
|
|
27671
|
+
}
|
|
27672
|
+
return index2;
|
|
28104
27673
|
};
|
|
28105
|
-
const
|
|
28106
|
-
|
|
28107
|
-
|
|
28108
|
-
|
|
28109
|
-
|
|
27674
|
+
const fillPlaceholderColumns = ({
|
|
27675
|
+
content,
|
|
27676
|
+
pendingRowSpans,
|
|
27677
|
+
currentIndex,
|
|
27678
|
+
targetIndex,
|
|
27679
|
+
totalColumns,
|
|
27680
|
+
gridColumnWidths,
|
|
27681
|
+
reason
|
|
27682
|
+
}) => {
|
|
27683
|
+
let index2 = currentIndex;
|
|
27684
|
+
while (index2 < targetIndex && index2 < totalColumns) {
|
|
27685
|
+
if (pendingRowSpans[index2] > 0) {
|
|
27686
|
+
pendingRowSpans[index2] -= 1;
|
|
27687
|
+
index2 += 1;
|
|
27688
|
+
continue;
|
|
27689
|
+
}
|
|
27690
|
+
const width = Array.isArray(gridColumnWidths) ? gridColumnWidths[index2] ?? 0 : 0;
|
|
27691
|
+
content.push(createPlaceholderCell(width, reason));
|
|
27692
|
+
index2 += 1;
|
|
27693
|
+
}
|
|
27694
|
+
return index2;
|
|
28110
27695
|
};
|
|
28111
|
-
const
|
|
28112
|
-
|
|
28113
|
-
|
|
28114
|
-
|
|
28115
|
-
|
|
28116
|
-
|
|
28117
|
-
|
|
28118
|
-
|
|
28119
|
-
|
|
28120
|
-
translator$k,
|
|
28121
|
-
translator$j,
|
|
28122
|
-
translator$i,
|
|
28123
|
-
translator$h,
|
|
28124
|
-
translator$g,
|
|
28125
|
-
translator$e
|
|
28126
|
-
];
|
|
28127
|
-
const translator$d = NodeTranslator.from(
|
|
28128
|
-
createNestedPropertiesTranslator("w:tcPr", "tableCellProperties", propertyTranslators)
|
|
28129
|
-
);
|
|
28130
|
-
function handleTableCellNode({
|
|
28131
|
-
params,
|
|
28132
|
-
node,
|
|
28133
|
-
table,
|
|
28134
|
-
row,
|
|
28135
|
-
rowBorders,
|
|
28136
|
-
styleTag,
|
|
28137
|
-
columnIndex,
|
|
28138
|
-
columnWidth = null,
|
|
28139
|
-
allColumnWidths = []
|
|
28140
|
-
}) {
|
|
28141
|
-
const { docx, nodeListHandler } = params;
|
|
28142
|
-
const attributes = {};
|
|
28143
|
-
const tcPr = node.elements.find((el) => el.name === "w:tcPr");
|
|
28144
|
-
const tableCellProperties = tcPr ? translator$d.encode({ ...params, nodes: [tcPr] }) ?? {} : {};
|
|
28145
|
-
attributes["tableCellProperties"] = tableCellProperties;
|
|
28146
|
-
if (rowBorders?.insideH) {
|
|
28147
|
-
rowBorders["bottom"] = rowBorders.insideH;
|
|
28148
|
-
delete rowBorders.insideH;
|
|
27696
|
+
const isPlaceholderCell = (cell) => {
|
|
27697
|
+
if (!cell) return false;
|
|
27698
|
+
if (cell.attrs?.__placeholder) return true;
|
|
27699
|
+
const widths = cell.attrs?.colwidth;
|
|
27700
|
+
if (Array.isArray(widths) && widths.length > 0) {
|
|
27701
|
+
const hasMeaningfulWidth = widths.some(
|
|
27702
|
+
(value) => typeof value === "number" && Number.isFinite(value) && Math.abs(value) > 1
|
|
27703
|
+
);
|
|
27704
|
+
if (!hasMeaningfulWidth) return true;
|
|
28149
27705
|
}
|
|
28150
|
-
|
|
28151
|
-
|
|
28152
|
-
|
|
27706
|
+
return false;
|
|
27707
|
+
};
|
|
27708
|
+
const XML_NODE_NAME$f = "w:tr";
|
|
27709
|
+
const SD_NODE_NAME$c = "tableRow";
|
|
27710
|
+
const validXmlAttributes$a = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
|
|
27711
|
+
(xmlName) => createAttributeHandler(xmlName)
|
|
27712
|
+
);
|
|
27713
|
+
const encode$l = (params, encodedAttrs) => {
|
|
27714
|
+
const { row } = params.extraParams;
|
|
27715
|
+
let tableRowProperties = {};
|
|
27716
|
+
const tPr = row.elements.find((el) => el.name === "w:trPr");
|
|
27717
|
+
if (tPr) {
|
|
27718
|
+
tableRowProperties = translator$v.encode({
|
|
27719
|
+
...params,
|
|
27720
|
+
nodes: [tPr]
|
|
27721
|
+
});
|
|
28153
27722
|
}
|
|
28154
|
-
|
|
28155
|
-
const
|
|
28156
|
-
|
|
28157
|
-
|
|
28158
|
-
|
|
28159
|
-
|
|
28160
|
-
const
|
|
28161
|
-
|
|
28162
|
-
|
|
28163
|
-
|
|
28164
|
-
|
|
28165
|
-
|
|
28166
|
-
|
|
28167
|
-
|
|
28168
|
-
|
|
28169
|
-
|
|
28170
|
-
|
|
28171
|
-
|
|
28172
|
-
|
|
28173
|
-
|
|
28174
|
-
|
|
28175
|
-
|
|
28176
|
-
|
|
28177
|
-
|
|
28178
|
-
|
|
27723
|
+
const gridBeforeRaw = tableRowProperties?.["gridBefore"];
|
|
27724
|
+
const safeGridBefore = typeof gridBeforeRaw === "number" && Number.isFinite(gridBeforeRaw) && gridBeforeRaw > 0 ? gridBeforeRaw : 0;
|
|
27725
|
+
encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
|
|
27726
|
+
encodedAttrs["rowHeight"] = twipsToPixels(tableRowProperties["rowHeight"]?.value);
|
|
27727
|
+
encodedAttrs["cantSplit"] = tableRowProperties["cantSplit"];
|
|
27728
|
+
const { columnWidths: gridColumnWidths, activeRowSpans = [] } = params.extraParams;
|
|
27729
|
+
const totalColumns = Array.isArray(gridColumnWidths) ? gridColumnWidths.length : 0;
|
|
27730
|
+
const pendingRowSpans = Array.isArray(activeRowSpans) ? activeRowSpans.slice() : [];
|
|
27731
|
+
while (pendingRowSpans.length < totalColumns) pendingRowSpans.push(0);
|
|
27732
|
+
const cellNodes = row.elements.filter((el) => el.name === "w:tc");
|
|
27733
|
+
const content = [];
|
|
27734
|
+
let currentColumnIndex = 0;
|
|
27735
|
+
const fillUntil = (target, reason) => {
|
|
27736
|
+
currentColumnIndex = fillPlaceholderColumns({
|
|
27737
|
+
content,
|
|
27738
|
+
pendingRowSpans,
|
|
27739
|
+
currentIndex: currentColumnIndex,
|
|
27740
|
+
targetIndex: target,
|
|
27741
|
+
totalColumns,
|
|
27742
|
+
gridColumnWidths,
|
|
27743
|
+
reason
|
|
27744
|
+
});
|
|
27745
|
+
};
|
|
27746
|
+
const skipOccupiedColumns = () => {
|
|
27747
|
+
currentColumnIndex = advancePastRowSpans(pendingRowSpans, currentColumnIndex, totalColumns);
|
|
27748
|
+
};
|
|
27749
|
+
fillUntil(safeGridBefore, "gridBefore");
|
|
27750
|
+
skipOccupiedColumns();
|
|
27751
|
+
cellNodes?.forEach((node) => {
|
|
27752
|
+
skipOccupiedColumns();
|
|
27753
|
+
const startColumn = currentColumnIndex;
|
|
27754
|
+
const columnWidth = gridColumnWidths?.[startColumn] || null;
|
|
27755
|
+
const result = translator$H.encode({
|
|
27756
|
+
...params,
|
|
27757
|
+
extraParams: {
|
|
27758
|
+
...params.extraParams,
|
|
27759
|
+
node,
|
|
27760
|
+
columnIndex: startColumn,
|
|
27761
|
+
columnWidth
|
|
28179
27762
|
}
|
|
28180
|
-
|
|
28181
|
-
|
|
27763
|
+
});
|
|
27764
|
+
if (result) {
|
|
27765
|
+
content.push(result);
|
|
27766
|
+
const colspan = Math.max(1, result.attrs?.colspan || 1);
|
|
27767
|
+
const rowspan = Math.max(1, result.attrs?.rowspan || 1);
|
|
27768
|
+
if (rowspan > 1) {
|
|
27769
|
+
for (let offset = 0; offset < colspan; offset += 1) {
|
|
27770
|
+
const target = startColumn + offset;
|
|
27771
|
+
if (target < pendingRowSpans.length) {
|
|
27772
|
+
pendingRowSpans[target] = Math.max(pendingRowSpans[target], rowspan - 1);
|
|
27773
|
+
}
|
|
27774
|
+
}
|
|
28182
27775
|
}
|
|
27776
|
+
currentColumnIndex = startColumn + colspan;
|
|
28183
27777
|
}
|
|
27778
|
+
});
|
|
27779
|
+
skipOccupiedColumns();
|
|
27780
|
+
fillUntil(totalColumns, "gridAfter");
|
|
27781
|
+
const newNode = {
|
|
27782
|
+
type: "tableRow",
|
|
27783
|
+
content,
|
|
27784
|
+
attrs: encodedAttrs
|
|
27785
|
+
};
|
|
27786
|
+
return newNode;
|
|
27787
|
+
};
|
|
27788
|
+
const decode$n = (params, decodedAttrs) => {
|
|
27789
|
+
const { node } = params;
|
|
27790
|
+
const cells = node.content || [];
|
|
27791
|
+
let leadingPlaceholders = 0;
|
|
27792
|
+
while (leadingPlaceholders < cells.length && isPlaceholderCell(cells[leadingPlaceholders])) {
|
|
27793
|
+
leadingPlaceholders += 1;
|
|
28184
27794
|
}
|
|
28185
|
-
|
|
28186
|
-
|
|
27795
|
+
let trailingPlaceholders = 0;
|
|
27796
|
+
while (trailingPlaceholders < cells.length - leadingPlaceholders && isPlaceholderCell(cells[cells.length - 1 - trailingPlaceholders])) {
|
|
27797
|
+
trailingPlaceholders += 1;
|
|
27798
|
+
}
|
|
27799
|
+
const trimmedSlice = cells.slice(leadingPlaceholders, cells.length - trailingPlaceholders);
|
|
27800
|
+
const sanitizedCells = trimmedSlice.map((cell) => {
|
|
27801
|
+
if (cell?.attrs && "__placeholder" in cell.attrs) {
|
|
27802
|
+
const { __placeholder, ...rest } = cell.attrs;
|
|
27803
|
+
return { ...cell, attrs: rest };
|
|
27804
|
+
}
|
|
27805
|
+
return cell;
|
|
27806
|
+
});
|
|
27807
|
+
const trimmedContent = sanitizedCells.filter((_2, index2) => !isPlaceholderCell(trimmedSlice[index2]));
|
|
27808
|
+
const translateParams = {
|
|
27809
|
+
...params,
|
|
27810
|
+
node: { ...node, content: trimmedContent }
|
|
28187
27811
|
};
|
|
28188
|
-
|
|
28189
|
-
|
|
28190
|
-
|
|
28191
|
-
|
|
28192
|
-
|
|
28193
|
-
const { fontSize, fonts = {} } = referencedStyles;
|
|
28194
|
-
const fontFamily = fonts["ascii"];
|
|
28195
|
-
if (fontSize) attributes["fontSize"] = fontSize;
|
|
28196
|
-
if (fontFamily) attributes["fontFamily"] = fontFamily;
|
|
28197
|
-
if (tableCellProperties.vMerge === "restart") {
|
|
28198
|
-
const rows = table.elements.filter((el) => el.name === "w:tr");
|
|
28199
|
-
const currentRowIndex = rows.findIndex((r) => r === row);
|
|
28200
|
-
const remainingRows = rows.slice(currentRowIndex + 1);
|
|
28201
|
-
const cellsInRow = row.elements.filter((el) => el.name === "w:tc");
|
|
28202
|
-
let cellIndex = cellsInRow.findIndex((el) => el === node);
|
|
28203
|
-
let rowspan = 1;
|
|
28204
|
-
for (let remainingRow of remainingRows) {
|
|
28205
|
-
const firstCell = remainingRow.elements.findIndex((el) => el.name === "w:tc");
|
|
28206
|
-
const cellAtIndex = remainingRow.elements[firstCell + cellIndex];
|
|
28207
|
-
if (!cellAtIndex) break;
|
|
28208
|
-
const vMerge = getTableCellVMerge(cellAtIndex);
|
|
28209
|
-
if (!vMerge || vMerge === "restart") {
|
|
28210
|
-
break;
|
|
28211
|
-
}
|
|
28212
|
-
rowspan++;
|
|
28213
|
-
remainingRow.elements.splice(firstCell + cellIndex, 1);
|
|
28214
|
-
}
|
|
28215
|
-
attributes["rowspan"] = rowspan;
|
|
28216
|
-
}
|
|
28217
|
-
return {
|
|
28218
|
-
type: "tableCell",
|
|
28219
|
-
content: normalizeTableCellContent(
|
|
28220
|
-
nodeListHandler.handler({
|
|
28221
|
-
...params,
|
|
28222
|
-
nodes: node.elements,
|
|
28223
|
-
path: [...params.path || [], node]
|
|
28224
|
-
}),
|
|
28225
|
-
params.editor
|
|
28226
|
-
),
|
|
28227
|
-
attrs: attributes
|
|
28228
|
-
};
|
|
28229
|
-
}
|
|
28230
|
-
function normalizeTableCellContent(content, editor) {
|
|
28231
|
-
if (!Array.isArray(content) || content.length === 0) return content;
|
|
28232
|
-
const normalized = [];
|
|
28233
|
-
const pendingForNextBlock = [];
|
|
28234
|
-
const schema = editor?.schema;
|
|
28235
|
-
const cloneBlock = (node) => {
|
|
28236
|
-
if (!node) return node;
|
|
28237
|
-
const cloned = { ...node };
|
|
28238
|
-
if (Array.isArray(node.content)) {
|
|
28239
|
-
cloned.content = [...node.content];
|
|
28240
|
-
}
|
|
28241
|
-
return cloned;
|
|
28242
|
-
};
|
|
28243
|
-
const ensureArray = (node) => {
|
|
28244
|
-
if (!Array.isArray(node.content)) {
|
|
28245
|
-
node.content = [];
|
|
28246
|
-
}
|
|
28247
|
-
return node.content;
|
|
28248
|
-
};
|
|
28249
|
-
const isInlineNode = (node) => {
|
|
28250
|
-
if (!node || typeof node.type !== "string") return false;
|
|
28251
|
-
if (node.type === "text") return true;
|
|
28252
|
-
if (node.type === "bookmarkStart" || node.type === "bookmarkEnd") return true;
|
|
28253
|
-
const nodeType = schema?.nodes?.[node.type];
|
|
28254
|
-
if (nodeType) {
|
|
28255
|
-
if (typeof nodeType.isInline === "boolean") return nodeType.isInline;
|
|
28256
|
-
if (nodeType.spec?.group && typeof nodeType.spec.group === "string") {
|
|
28257
|
-
return nodeType.spec.group.split(" ").includes("inline");
|
|
28258
|
-
}
|
|
28259
|
-
}
|
|
28260
|
-
return false;
|
|
28261
|
-
};
|
|
28262
|
-
for (const node of content) {
|
|
28263
|
-
if (!node || typeof node.type !== "string") {
|
|
28264
|
-
normalized.push(node);
|
|
28265
|
-
continue;
|
|
28266
|
-
}
|
|
28267
|
-
if (!isInlineNode(node)) {
|
|
28268
|
-
const blockNode = cloneBlock(node);
|
|
28269
|
-
if (pendingForNextBlock.length) {
|
|
28270
|
-
const blockContent = ensureArray(blockNode);
|
|
28271
|
-
const leadingInline = pendingForNextBlock.splice(0);
|
|
28272
|
-
blockNode.content = [...leadingInline, ...blockContent];
|
|
28273
|
-
} else if (Array.isArray(blockNode.content)) {
|
|
28274
|
-
blockNode.content = [...blockNode.content];
|
|
28275
|
-
}
|
|
28276
|
-
normalized.push(blockNode);
|
|
28277
|
-
continue;
|
|
27812
|
+
const elements = translateChildNodes(translateParams);
|
|
27813
|
+
if (node.attrs?.tableRowProperties) {
|
|
27814
|
+
const tableRowProperties = { ...node.attrs.tableRowProperties };
|
|
27815
|
+
if (leadingPlaceholders > 0) {
|
|
27816
|
+
tableRowProperties.gridBefore = leadingPlaceholders;
|
|
28278
27817
|
}
|
|
28279
|
-
|
|
28280
|
-
|
|
28281
|
-
pendingForNextBlock.push(node);
|
|
28282
|
-
} else {
|
|
28283
|
-
const lastIndex = normalized.length - 1;
|
|
28284
|
-
const lastNode = normalized[lastIndex];
|
|
28285
|
-
if (!lastNode || typeof lastNode.type !== "string" || isInlineNode(lastNode)) {
|
|
28286
|
-
pendingForNextBlock.push(node);
|
|
28287
|
-
continue;
|
|
28288
|
-
}
|
|
28289
|
-
const blockContent = ensureArray(lastNode);
|
|
28290
|
-
if (pendingForNextBlock.length) {
|
|
28291
|
-
blockContent.push(...pendingForNextBlock.splice(0));
|
|
28292
|
-
}
|
|
28293
|
-
blockContent.push(node);
|
|
27818
|
+
if (trailingPlaceholders > 0) {
|
|
27819
|
+
tableRowProperties.gridAfter = trailingPlaceholders;
|
|
28294
27820
|
}
|
|
28295
|
-
|
|
28296
|
-
|
|
28297
|
-
|
|
28298
|
-
|
|
28299
|
-
const lastNode = normalized[lastIndex];
|
|
28300
|
-
if (lastNode && typeof lastNode.type === "string" && !isInlineNode(lastNode)) {
|
|
28301
|
-
const blockContent = ensureArray(lastNode);
|
|
28302
|
-
blockContent.push(...pendingForNextBlock);
|
|
28303
|
-
pendingForNextBlock.length = 0;
|
|
27821
|
+
if (node.attrs.rowHeight != null) {
|
|
27822
|
+
const rowHeightPixels = twipsToPixels(node.attrs.tableRowProperties["rowHeight"]?.value);
|
|
27823
|
+
if (rowHeightPixels !== node.attrs.rowHeight) {
|
|
27824
|
+
tableRowProperties["rowHeight"] = { value: String(pixelsToTwips(node.attrs["rowHeight"])) };
|
|
28304
27825
|
}
|
|
28305
27826
|
}
|
|
28306
|
-
|
|
28307
|
-
|
|
28308
|
-
|
|
28309
|
-
|
|
28310
|
-
|
|
28311
|
-
|
|
28312
|
-
pendingForNextBlock.length = 0;
|
|
28313
|
-
}
|
|
27827
|
+
tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
|
|
27828
|
+
const trPr = translator$v.decode({
|
|
27829
|
+
...params,
|
|
27830
|
+
node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
|
|
27831
|
+
});
|
|
27832
|
+
if (trPr) elements.unshift(trPr);
|
|
28314
27833
|
}
|
|
28315
|
-
return normalized;
|
|
28316
|
-
}
|
|
28317
|
-
const processInlineCellBorders = (borders, rowBorders) => {
|
|
28318
|
-
if (!borders) return null;
|
|
28319
|
-
return ["bottom", "top", "left", "right"].reduce((acc, direction) => {
|
|
28320
|
-
const borderAttrs = borders[direction];
|
|
28321
|
-
const rowBorderAttrs = rowBorders[direction];
|
|
28322
|
-
if (borderAttrs && borderAttrs["val"] !== "nil") {
|
|
28323
|
-
const color = borderAttrs["color"];
|
|
28324
|
-
let size = borderAttrs["size"];
|
|
28325
|
-
if (size) size = eighthPointsToPixels(size);
|
|
28326
|
-
acc[direction] = { color, size, val: borderAttrs["val"] };
|
|
28327
|
-
return acc;
|
|
28328
|
-
}
|
|
28329
|
-
if (borderAttrs && borderAttrs["val"] === "nil") {
|
|
28330
|
-
const border = Object.assign({}, rowBorderAttrs || {});
|
|
28331
|
-
if (!Object.keys(border).length) {
|
|
28332
|
-
return acc;
|
|
28333
|
-
} else {
|
|
28334
|
-
border["val"] = "none";
|
|
28335
|
-
acc[direction] = border;
|
|
28336
|
-
return acc;
|
|
28337
|
-
}
|
|
28338
|
-
}
|
|
28339
|
-
return acc;
|
|
28340
|
-
}, {});
|
|
28341
|
-
};
|
|
28342
|
-
const getTableCellVMerge = (node) => {
|
|
28343
|
-
const tcPr = node.elements.find((el) => el.name === "w:tcPr");
|
|
28344
|
-
const vMerge = tcPr?.elements?.find((el) => el.name === "w:vMerge");
|
|
28345
|
-
if (!vMerge) return null;
|
|
28346
|
-
return vMerge.attributes?.["w:val"] || "continue";
|
|
28347
|
-
};
|
|
28348
|
-
const getTableCellMargins = (inlineMargins, referencedStyles) => {
|
|
28349
|
-
const { cellMargins = {} } = referencedStyles;
|
|
28350
|
-
return ["left", "right", "top", "bottom"].reduce((acc, direction) => {
|
|
28351
|
-
const key = `margin${direction.charAt(0).toUpperCase() + direction.slice(1)}`;
|
|
28352
|
-
const inlineValue = inlineMargins ? inlineMargins?.[key]?.value : null;
|
|
28353
|
-
const styleValue = cellMargins ? cellMargins[key] : null;
|
|
28354
|
-
if (inlineValue != null) {
|
|
28355
|
-
acc[direction] = twipsToPixels(inlineValue);
|
|
28356
|
-
} else if (styleValue == null) {
|
|
28357
|
-
acc[direction] = void 0;
|
|
28358
|
-
} else if (typeof styleValue === "object") {
|
|
28359
|
-
acc[direction] = twipsToPixels(styleValue.value);
|
|
28360
|
-
} else {
|
|
28361
|
-
acc[direction] = twipsToPixels(styleValue);
|
|
28362
|
-
}
|
|
28363
|
-
return acc;
|
|
28364
|
-
}, {});
|
|
28365
|
-
};
|
|
28366
|
-
function translateTableCell(params) {
|
|
28367
|
-
const elements = translateChildNodes({
|
|
28368
|
-
...params,
|
|
28369
|
-
tableCell: params.node
|
|
28370
|
-
});
|
|
28371
|
-
const cellProps = generateTableCellProperties(params.node);
|
|
28372
|
-
elements.unshift(cellProps);
|
|
28373
27834
|
return {
|
|
28374
|
-
name: "w:
|
|
27835
|
+
name: "w:tr",
|
|
27836
|
+
attributes: decodedAttrs || {},
|
|
28375
27837
|
elements
|
|
28376
27838
|
};
|
|
28377
|
-
}
|
|
28378
|
-
|
|
28379
|
-
|
|
28380
|
-
|
|
28381
|
-
|
|
28382
|
-
|
|
28383
|
-
|
|
28384
|
-
|
|
28385
|
-
|
|
28386
|
-
|
|
28387
|
-
|
|
28388
|
-
|
|
28389
|
-
|
|
28390
|
-
const { colspan } = attrs;
|
|
28391
|
-
if (colspan > 1 && tableCellProperties.gridSpan !== colspan) {
|
|
28392
|
-
tableCellProperties["gridSpan"] = colspan;
|
|
28393
|
-
} else if (!colspan || tableCellProperties?.gridSpan === 1) {
|
|
28394
|
-
delete tableCellProperties.gridSpan;
|
|
27839
|
+
};
|
|
27840
|
+
const config$e = {
|
|
27841
|
+
xmlName: XML_NODE_NAME$f,
|
|
27842
|
+
sdNodeOrKeyName: SD_NODE_NAME$c,
|
|
27843
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
27844
|
+
encode: encode$l,
|
|
27845
|
+
decode: decode$n,
|
|
27846
|
+
attributes: validXmlAttributes$a
|
|
27847
|
+
};
|
|
27848
|
+
const translator$u = NodeTranslator.from(config$e);
|
|
27849
|
+
function parseTagValueJSON(json) {
|
|
27850
|
+
if (typeof json !== "string") {
|
|
27851
|
+
return {};
|
|
28395
27852
|
}
|
|
28396
|
-
const
|
|
28397
|
-
if (
|
|
28398
|
-
|
|
28399
|
-
} else if (!background?.color && tableCellProperties?.shading?.fill) {
|
|
28400
|
-
delete tableCellProperties.shading;
|
|
27853
|
+
const trimmed = json.trim();
|
|
27854
|
+
if (!trimmed) {
|
|
27855
|
+
return {};
|
|
28401
27856
|
}
|
|
28402
|
-
|
|
28403
|
-
|
|
28404
|
-
|
|
28405
|
-
|
|
28406
|
-
if (cellMargins[side] != null) {
|
|
28407
|
-
if (!tableCellProperties.cellMargins) tableCellProperties["cellMargins"] = {};
|
|
28408
|
-
let currentPropertyValuePixels = twipsToPixels(tableCellProperties.cellMargins?.[key]?.value);
|
|
28409
|
-
if (currentPropertyValuePixels !== cellMargins[side]) {
|
|
28410
|
-
tableCellProperties.cellMargins[key] = { value: pixelsToTwips(cellMargins[side]), type: "dxa" };
|
|
28411
|
-
}
|
|
28412
|
-
} else if (tableCellProperties?.cellMargins?.[key]) {
|
|
28413
|
-
delete tableCellProperties.cellMargins[key];
|
|
28414
|
-
}
|
|
28415
|
-
});
|
|
27857
|
+
try {
|
|
27858
|
+
return JSON.parse(trimmed);
|
|
27859
|
+
} catch {
|
|
27860
|
+
return {};
|
|
28416
27861
|
}
|
|
28417
|
-
|
|
28418
|
-
|
|
28419
|
-
|
|
28420
|
-
|
|
28421
|
-
|
|
28422
|
-
}
|
|
28423
|
-
const { rowspan } = attrs;
|
|
28424
|
-
if (rowspan && rowspan > 1 && tableCellProperties.vMerge !== "restart") {
|
|
28425
|
-
tableCellProperties["vMerge"] = "restart";
|
|
28426
|
-
} else if (attrs.continueMerge) {
|
|
28427
|
-
tableCellProperties["vMerge"] = "continue";
|
|
28428
|
-
} else if (tableCellProperties?.vMerge) {
|
|
28429
|
-
delete tableCellProperties.vMerge;
|
|
28430
|
-
}
|
|
28431
|
-
const { borders = {} } = attrs;
|
|
28432
|
-
if (!!borders && Object.keys(borders).length) {
|
|
28433
|
-
["top", "bottom", "left", "right"].forEach((side) => {
|
|
28434
|
-
if (borders[side]) {
|
|
28435
|
-
let currentPropertyValue = tableCellProperties.borders?.[side];
|
|
28436
|
-
let currentPropertySizePixels = eighthPointsToPixels(currentPropertyValue?.size);
|
|
28437
|
-
let color = borders[side].color;
|
|
28438
|
-
if (borders[side].color && color === "#000000") {
|
|
28439
|
-
color = "auto";
|
|
28440
|
-
}
|
|
28441
|
-
if (currentPropertySizePixels !== borders[side].size || currentPropertyValue?.color !== color || borders[side].val !== currentPropertyValue?.val) {
|
|
28442
|
-
if (!tableCellProperties.borders) tableCellProperties["borders"] = {};
|
|
28443
|
-
tableCellProperties.borders[side] = {
|
|
28444
|
-
size: pixelsToEightPoints(borders[side].size || 0),
|
|
28445
|
-
color,
|
|
28446
|
-
space: borders[side].space || 0,
|
|
28447
|
-
val: borders[side].val || "single"
|
|
28448
|
-
};
|
|
28449
|
-
}
|
|
28450
|
-
} else if (tableCellProperties.borders?.[side]) {
|
|
28451
|
-
delete tableCellProperties.borders[side];
|
|
28452
|
-
}
|
|
28453
|
-
});
|
|
28454
|
-
} else if (tableCellProperties?.borders) {
|
|
28455
|
-
delete tableCellProperties.borders;
|
|
28456
|
-
}
|
|
28457
|
-
const result = translator$d.decode({ node: { ...node, attrs: { ...node.attrs, tableCellProperties } } });
|
|
28458
|
-
return result;
|
|
28459
|
-
}
|
|
28460
|
-
const XML_NODE_NAME$d = "w:tc";
|
|
28461
|
-
const SD_NODE_NAME$b = "tableCell";
|
|
28462
|
-
const validXmlAttributes$a = [];
|
|
28463
|
-
function encode$j(params, encodedAttrs) {
|
|
28464
|
-
const {
|
|
28465
|
-
node,
|
|
28466
|
-
table,
|
|
28467
|
-
row,
|
|
28468
|
-
rowBorders,
|
|
28469
|
-
styleTag,
|
|
28470
|
-
columnIndex,
|
|
28471
|
-
columnWidth,
|
|
28472
|
-
columnWidths: allColumnWidths
|
|
28473
|
-
} = params.extraParams;
|
|
28474
|
-
const schemaNode = handleTableCellNode({
|
|
28475
|
-
params,
|
|
28476
|
-
node,
|
|
28477
|
-
table,
|
|
28478
|
-
row,
|
|
28479
|
-
rowBorders,
|
|
28480
|
-
styleTag,
|
|
28481
|
-
columnIndex,
|
|
28482
|
-
columnWidth,
|
|
28483
|
-
allColumnWidths
|
|
28484
|
-
});
|
|
28485
|
-
if (encodedAttrs && Object.keys(encodedAttrs).length) {
|
|
28486
|
-
schemaNode.attrs = { ...schemaNode.attrs, ...encodedAttrs };
|
|
28487
|
-
}
|
|
28488
|
-
return schemaNode;
|
|
28489
|
-
}
|
|
28490
|
-
function decode$l(params, decodedAttrs) {
|
|
28491
|
-
const translated = translateTableCell(params);
|
|
28492
|
-
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
28493
|
-
translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
|
|
28494
|
-
}
|
|
28495
|
-
return translated;
|
|
28496
|
-
}
|
|
28497
|
-
const config$c = {
|
|
28498
|
-
xmlName: XML_NODE_NAME$d,
|
|
28499
|
-
sdNodeOrKeyName: SD_NODE_NAME$b,
|
|
28500
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
28501
|
-
encode: encode$j,
|
|
28502
|
-
decode: decode$l,
|
|
28503
|
-
attributes: validXmlAttributes$a
|
|
28504
|
-
};
|
|
28505
|
-
const translator$c = NodeTranslator.from(config$c);
|
|
28506
|
-
function parseTagValueJSON(json) {
|
|
28507
|
-
if (typeof json !== "string") {
|
|
28508
|
-
return {};
|
|
28509
|
-
}
|
|
28510
|
-
const trimmed = json.trim();
|
|
28511
|
-
if (!trimmed) {
|
|
28512
|
-
return {};
|
|
28513
|
-
}
|
|
28514
|
-
try {
|
|
28515
|
-
return JSON.parse(trimmed);
|
|
28516
|
-
} catch {
|
|
28517
|
-
return {};
|
|
28518
|
-
}
|
|
28519
|
-
}
|
|
28520
|
-
function handleAnnotationNode(params) {
|
|
28521
|
-
const { nodes } = params;
|
|
28522
|
-
if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
|
|
28523
|
-
return null;
|
|
27862
|
+
}
|
|
27863
|
+
function handleAnnotationNode(params) {
|
|
27864
|
+
const { nodes } = params;
|
|
27865
|
+
if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
|
|
27866
|
+
return null;
|
|
28524
27867
|
}
|
|
28525
27868
|
const node = nodes[0];
|
|
28526
27869
|
const sdtPr = node.elements.find((el) => el.name === "w:sdtPr");
|
|
@@ -29825,32 +29168,32 @@ function translateAnchorNode(params) {
|
|
|
29825
29168
|
elements: [...anchorElements, ...elementsWithWrap]
|
|
29826
29169
|
};
|
|
29827
29170
|
}
|
|
29828
|
-
const XML_NODE_NAME$
|
|
29829
|
-
const SD_NODE_NAME$
|
|
29171
|
+
const XML_NODE_NAME$e = "wp:anchor";
|
|
29172
|
+
const SD_NODE_NAME$b = ["image"];
|
|
29830
29173
|
const validXmlAttributes$9 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
29831
|
-
function encode$
|
|
29174
|
+
function encode$k(params) {
|
|
29832
29175
|
const { node } = params.extraParams;
|
|
29833
29176
|
if (!node || !node.type) {
|
|
29834
29177
|
return null;
|
|
29835
29178
|
}
|
|
29836
29179
|
return handleAnchorNode(params);
|
|
29837
29180
|
}
|
|
29838
|
-
function decode$
|
|
29181
|
+
function decode$m(params) {
|
|
29839
29182
|
const { node } = params;
|
|
29840
29183
|
if (!node || !node.type) {
|
|
29841
29184
|
return null;
|
|
29842
29185
|
}
|
|
29843
29186
|
return translateAnchorNode(params);
|
|
29844
29187
|
}
|
|
29845
|
-
const config$
|
|
29846
|
-
xmlName: XML_NODE_NAME$
|
|
29847
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
29188
|
+
const config$d = {
|
|
29189
|
+
xmlName: XML_NODE_NAME$e,
|
|
29190
|
+
sdNodeOrKeyName: SD_NODE_NAME$b,
|
|
29848
29191
|
type: NodeTranslator.translatorTypes.NODE,
|
|
29849
|
-
encode: encode$
|
|
29850
|
-
decode: decode$
|
|
29192
|
+
encode: encode$k,
|
|
29193
|
+
decode: decode$m,
|
|
29851
29194
|
attributes: validXmlAttributes$9
|
|
29852
29195
|
};
|
|
29853
|
-
const translator$
|
|
29196
|
+
const translator$t = NodeTranslator.from(config$d);
|
|
29854
29197
|
function handleInlineNode(params) {
|
|
29855
29198
|
const { node } = params.extraParams;
|
|
29856
29199
|
if (node.name !== "wp:inline") {
|
|
@@ -29866,41 +29209,41 @@ function translateInlineNode(params) {
|
|
|
29866
29209
|
elements: nodeElements.elements
|
|
29867
29210
|
};
|
|
29868
29211
|
}
|
|
29869
|
-
const XML_NODE_NAME$
|
|
29870
|
-
const SD_NODE_NAME$
|
|
29212
|
+
const XML_NODE_NAME$d = "wp:inline";
|
|
29213
|
+
const SD_NODE_NAME$a = ["image"];
|
|
29871
29214
|
const validXmlAttributes$8 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
29872
|
-
function encode$
|
|
29215
|
+
function encode$j(params) {
|
|
29873
29216
|
const { node } = params.extraParams;
|
|
29874
29217
|
if (!node || !node.type) {
|
|
29875
29218
|
return null;
|
|
29876
29219
|
}
|
|
29877
29220
|
return handleInlineNode(params);
|
|
29878
29221
|
}
|
|
29879
|
-
function decode$
|
|
29222
|
+
function decode$l(params) {
|
|
29880
29223
|
const { node } = params;
|
|
29881
29224
|
if (!node || !node.type) {
|
|
29882
29225
|
return null;
|
|
29883
29226
|
}
|
|
29884
29227
|
return translateInlineNode(params);
|
|
29885
29228
|
}
|
|
29886
|
-
const config$
|
|
29887
|
-
xmlName: XML_NODE_NAME$
|
|
29888
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
29229
|
+
const config$c = {
|
|
29230
|
+
xmlName: XML_NODE_NAME$d,
|
|
29231
|
+
sdNodeOrKeyName: SD_NODE_NAME$a,
|
|
29889
29232
|
type: NodeTranslator.translatorTypes.NODE,
|
|
29890
|
-
encode: encode$
|
|
29891
|
-
decode: decode$
|
|
29233
|
+
encode: encode$j,
|
|
29234
|
+
decode: decode$l,
|
|
29892
29235
|
attributes: validXmlAttributes$8
|
|
29893
29236
|
};
|
|
29894
|
-
const translator$
|
|
29895
|
-
const XML_NODE_NAME$
|
|
29896
|
-
const SD_NODE_NAME$
|
|
29237
|
+
const translator$s = NodeTranslator.from(config$c);
|
|
29238
|
+
const XML_NODE_NAME$c = "w:drawing";
|
|
29239
|
+
const SD_NODE_NAME$9 = [];
|
|
29897
29240
|
const validXmlAttributes$7 = [];
|
|
29898
|
-
function encode$
|
|
29241
|
+
function encode$i(params) {
|
|
29899
29242
|
const nodes = params.nodes;
|
|
29900
29243
|
const node = nodes[0];
|
|
29901
29244
|
const translatorByChildName = {
|
|
29902
|
-
"wp:anchor": translator$
|
|
29903
|
-
"wp:inline": translator$
|
|
29245
|
+
"wp:anchor": translator$t,
|
|
29246
|
+
"wp:inline": translator$s
|
|
29904
29247
|
};
|
|
29905
29248
|
return node.elements.reduce((acc, child) => {
|
|
29906
29249
|
if (acc) return acc;
|
|
@@ -29909,12 +29252,12 @@ function encode$g(params) {
|
|
|
29909
29252
|
return translator2.encode({ ...params, extraParams: { node: child } }) || acc;
|
|
29910
29253
|
}, null);
|
|
29911
29254
|
}
|
|
29912
|
-
function decode$
|
|
29255
|
+
function decode$k(params) {
|
|
29913
29256
|
const { node } = params;
|
|
29914
29257
|
if (!node || !node.type) {
|
|
29915
29258
|
return null;
|
|
29916
29259
|
}
|
|
29917
|
-
const childTranslator = node.attrs.isAnchor ? translator$
|
|
29260
|
+
const childTranslator = node.attrs.isAnchor ? translator$t : translator$s;
|
|
29918
29261
|
const resultNode = childTranslator.decode(params);
|
|
29919
29262
|
return wrapTextInRun(
|
|
29920
29263
|
{
|
|
@@ -29924,15 +29267,15 @@ function decode$i(params) {
|
|
|
29924
29267
|
[]
|
|
29925
29268
|
);
|
|
29926
29269
|
}
|
|
29927
|
-
const config$
|
|
29928
|
-
xmlName: XML_NODE_NAME$
|
|
29929
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
29270
|
+
const config$b = {
|
|
29271
|
+
xmlName: XML_NODE_NAME$c,
|
|
29272
|
+
sdNodeOrKeyName: SD_NODE_NAME$9,
|
|
29930
29273
|
type: NodeTranslator.translatorTypes.NODE,
|
|
29931
|
-
encode: encode$
|
|
29932
|
-
decode: decode$
|
|
29274
|
+
encode: encode$i,
|
|
29275
|
+
decode: decode$k,
|
|
29933
29276
|
attributes: validXmlAttributes$7
|
|
29934
29277
|
};
|
|
29935
|
-
const translator$
|
|
29278
|
+
const translator$r = NodeTranslator.from(config$b);
|
|
29936
29279
|
class CommandService {
|
|
29937
29280
|
/**
|
|
29938
29281
|
* @param {import('./commands/types/index.js').CommandServiceOptions} props
|
|
@@ -31198,433 +30541,1010 @@ function translateFieldAnnotation(params) {
|
|
|
31198
30541
|
if ((attrs.type === "image" || attrs.type === "signature") && !attrs.hash) {
|
|
31199
30542
|
attrs.hash = generateDocxRandomId(4);
|
|
31200
30543
|
}
|
|
31201
|
-
if (!attrs.sdtId) {
|
|
31202
|
-
id = generateRandomSigned32BitIntStrId();
|
|
30544
|
+
if (!attrs.sdtId) {
|
|
30545
|
+
id = generateRandomSigned32BitIntStrId();
|
|
30546
|
+
}
|
|
30547
|
+
if (isFinalDoc) {
|
|
30548
|
+
return annotationHandler(params);
|
|
30549
|
+
} else {
|
|
30550
|
+
processedNode = annotationHandler(params);
|
|
30551
|
+
sdtContentElements = [processedNode];
|
|
30552
|
+
if (attrs.type === "html") {
|
|
30553
|
+
const runElements = processedNode.elements[0].elements.filter((el) => el.name === "w:r");
|
|
30554
|
+
sdtContentElements = [...runElements];
|
|
30555
|
+
}
|
|
30556
|
+
}
|
|
30557
|
+
sdtContentElements = [...sdtContentElements];
|
|
30558
|
+
const fieldBackgroundTag = getFieldHighlightJson(fieldsHighlightColor);
|
|
30559
|
+
if (fieldBackgroundTag) {
|
|
30560
|
+
sdtContentElements.unshift(fieldBackgroundTag);
|
|
30561
|
+
}
|
|
30562
|
+
const annotationAttrs = {
|
|
30563
|
+
displayLabel: attrs.displayLabel,
|
|
30564
|
+
defaultDisplayLabel: attrs.defaultDisplayLabel,
|
|
30565
|
+
fieldId: attrs.fieldId,
|
|
30566
|
+
fieldType: attrs.fieldType,
|
|
30567
|
+
fieldTypeShort: attrs.type,
|
|
30568
|
+
fieldColor: attrs.fieldColor,
|
|
30569
|
+
fieldMultipleImage: attrs.multipleImage,
|
|
30570
|
+
fieldFontFamily: attrs.fontFamily,
|
|
30571
|
+
fieldFontSize: attrs.fontSize,
|
|
30572
|
+
fieldTextColor: attrs.textColor,
|
|
30573
|
+
fieldTextHighlight: attrs.textHighlight,
|
|
30574
|
+
hash: attrs.hash
|
|
30575
|
+
};
|
|
30576
|
+
const annotationAttrsJson = JSON.stringify(annotationAttrs);
|
|
30577
|
+
const result = {
|
|
30578
|
+
name: "w:sdt",
|
|
30579
|
+
elements: [
|
|
30580
|
+
{
|
|
30581
|
+
name: "w:sdtPr",
|
|
30582
|
+
elements: [
|
|
30583
|
+
{ name: "w:alias", attributes: { "w:val": attrs.displayLabel } },
|
|
30584
|
+
{ name: "w:tag", attributes: { "w:val": annotationAttrsJson } },
|
|
30585
|
+
{ name: "w:id", attributes: { "w:val": id } }
|
|
30586
|
+
]
|
|
30587
|
+
},
|
|
30588
|
+
{
|
|
30589
|
+
name: "w:sdtContent",
|
|
30590
|
+
elements: sdtContentElements
|
|
30591
|
+
}
|
|
30592
|
+
]
|
|
30593
|
+
};
|
|
30594
|
+
return result;
|
|
30595
|
+
}
|
|
30596
|
+
function getTranslationByAnnotationType(annotationType, annotationFieldType) {
|
|
30597
|
+
if (annotationType === "text" && annotationFieldType === "FILEUPLOADER") {
|
|
30598
|
+
return null;
|
|
30599
|
+
}
|
|
30600
|
+
const imageEmuSize = {
|
|
30601
|
+
w: 4286250,
|
|
30602
|
+
h: 4286250
|
|
30603
|
+
};
|
|
30604
|
+
const signatureEmuSize = {
|
|
30605
|
+
w: 99e4,
|
|
30606
|
+
h: 495e3
|
|
30607
|
+
};
|
|
30608
|
+
const dictionary = {
|
|
30609
|
+
text: prepareTextAnnotation,
|
|
30610
|
+
image: (params) => prepareImageAnnotation(params, imageEmuSize),
|
|
30611
|
+
signature: (params) => prepareImageAnnotation(params, signatureEmuSize),
|
|
30612
|
+
checkbox: prepareCheckboxAnnotation,
|
|
30613
|
+
html: prepareHtmlAnnotation,
|
|
30614
|
+
link: prepareUrlAnnotation
|
|
30615
|
+
};
|
|
30616
|
+
return dictionary[annotationType];
|
|
30617
|
+
}
|
|
30618
|
+
function prepareTextAnnotation(params) {
|
|
30619
|
+
const {
|
|
30620
|
+
node: { attrs = {}, marks = [] }
|
|
30621
|
+
} = params;
|
|
30622
|
+
const marksFromAttrs = translateFieldAttrsToMarks(attrs);
|
|
30623
|
+
return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params);
|
|
30624
|
+
}
|
|
30625
|
+
function prepareImageAnnotation(params, imageSize) {
|
|
30626
|
+
return translator$r.decode({
|
|
30627
|
+
...params,
|
|
30628
|
+
imageSize
|
|
30629
|
+
});
|
|
30630
|
+
}
|
|
30631
|
+
function prepareCheckboxAnnotation(params) {
|
|
30632
|
+
const {
|
|
30633
|
+
node: { attrs = {}, marks = [] }
|
|
30634
|
+
} = params;
|
|
30635
|
+
const content = he.decode(attrs.displayLabel);
|
|
30636
|
+
return getTextNodeForExport(content, marks, params);
|
|
30637
|
+
}
|
|
30638
|
+
function prepareHtmlAnnotation(params) {
|
|
30639
|
+
const {
|
|
30640
|
+
node: { attrs = {}, marks = [] },
|
|
30641
|
+
editorSchema
|
|
30642
|
+
} = params;
|
|
30643
|
+
let html = attrs.rawHtml || attrs.displayLabel;
|
|
30644
|
+
const paragraphHtmlContainer = sanitizeHtml(html);
|
|
30645
|
+
const marksFromAttrs = translateFieldAttrsToMarks(attrs);
|
|
30646
|
+
const allMarks = [...marks, ...marksFromAttrs];
|
|
30647
|
+
let state2 = EditorState.create({
|
|
30648
|
+
doc: DOMParser$1.fromSchema(editorSchema).parse(paragraphHtmlContainer)
|
|
30649
|
+
});
|
|
30650
|
+
if (allMarks.length) {
|
|
30651
|
+
state2 = applyMarksToHtmlAnnotation(state2, allMarks);
|
|
30652
|
+
}
|
|
30653
|
+
const htmlAnnotationNode = state2.doc.toJSON();
|
|
30654
|
+
const listTypes = ["bulletList", "orderedList"];
|
|
30655
|
+
const { editor } = params;
|
|
30656
|
+
const seenLists = /* @__PURE__ */ new Map();
|
|
30657
|
+
state2.doc.descendants((node) => {
|
|
30658
|
+
if (listTypes.includes(node.type.name)) {
|
|
30659
|
+
const listItem = node.firstChild;
|
|
30660
|
+
const { attrs: attrs2 } = listItem;
|
|
30661
|
+
const { level, numId } = attrs2;
|
|
30662
|
+
if (!seenLists.has(numId)) {
|
|
30663
|
+
const newNumId = ListHelpers.changeNumIdSameAbstract(numId, level, node.type.name, editor);
|
|
30664
|
+
listItem.attrs.numId = newNumId;
|
|
30665
|
+
seenLists.set(numId, newNumId);
|
|
30666
|
+
} else {
|
|
30667
|
+
const newNumId = seenLists.get(numId);
|
|
30668
|
+
listItem.attrs.numId = newNumId;
|
|
30669
|
+
}
|
|
30670
|
+
}
|
|
30671
|
+
});
|
|
30672
|
+
const elements = translateChildNodes({
|
|
30673
|
+
...params,
|
|
30674
|
+
node: htmlAnnotationNode
|
|
30675
|
+
});
|
|
30676
|
+
return {
|
|
30677
|
+
name: "htmlAnnotation",
|
|
30678
|
+
elements
|
|
30679
|
+
};
|
|
30680
|
+
}
|
|
30681
|
+
function prepareUrlAnnotation(params) {
|
|
30682
|
+
const {
|
|
30683
|
+
node: { attrs = {}, marks = [] }
|
|
30684
|
+
} = params;
|
|
30685
|
+
if (!attrs.linkUrl) return prepareTextAnnotation(params);
|
|
30686
|
+
const newId = addNewLinkRelationship(params, attrs.linkUrl);
|
|
30687
|
+
const linkTextNode = getTextNodeForExport(attrs.linkUrl, marks, params);
|
|
30688
|
+
const contentNode = processLinkContentNode(linkTextNode);
|
|
30689
|
+
return {
|
|
30690
|
+
name: "w:hyperlink",
|
|
30691
|
+
type: "element",
|
|
30692
|
+
attributes: {
|
|
30693
|
+
"r:id": newId,
|
|
30694
|
+
"w:history": 1
|
|
30695
|
+
},
|
|
30696
|
+
elements: [contentNode]
|
|
30697
|
+
};
|
|
30698
|
+
}
|
|
30699
|
+
function translateFieldAttrsToMarks(attrs = {}) {
|
|
30700
|
+
const { fontFamily, fontSize, bold, underline, italic, textColor, textHighlight } = attrs;
|
|
30701
|
+
const marks = [];
|
|
30702
|
+
if (fontFamily) marks.push({ type: "fontFamily", attrs: { fontFamily } });
|
|
30703
|
+
if (fontSize) marks.push({ type: "fontSize", attrs: { fontSize } });
|
|
30704
|
+
if (bold) marks.push({ type: "bold", attrs: {} });
|
|
30705
|
+
if (underline) marks.push({ type: "underline", attrs: {} });
|
|
30706
|
+
if (italic) marks.push({ type: "italic", attrs: {} });
|
|
30707
|
+
if (textColor) marks.push({ type: "color", attrs: { color: textColor } });
|
|
30708
|
+
if (textHighlight) marks.push({ type: "highlight", attrs: { color: textHighlight } });
|
|
30709
|
+
return marks;
|
|
30710
|
+
}
|
|
30711
|
+
function applyMarksToHtmlAnnotation(state2, marks) {
|
|
30712
|
+
const { tr, doc: doc2, schema } = state2;
|
|
30713
|
+
const allowedMarks = ["fontFamily", "fontSize", "highlight"];
|
|
30714
|
+
if (!marks.some((m2) => allowedMarks.includes(m2.type))) {
|
|
30715
|
+
return state2;
|
|
30716
|
+
}
|
|
30717
|
+
const fontFamily = marks.find((m2) => m2.type === "fontFamily");
|
|
30718
|
+
const fontSize = marks.find((m2) => m2.type === "fontSize");
|
|
30719
|
+
const highlight = marks.find((m2) => m2.type === "highlight");
|
|
30720
|
+
const textStyleType = schema.marks.textStyle;
|
|
30721
|
+
const highlightType = schema.marks.highlight;
|
|
30722
|
+
doc2.descendants((node, pos) => {
|
|
30723
|
+
if (!node.isText) return;
|
|
30724
|
+
const foundTextStyle = node.marks.find((m2) => m2.type.name === "textStyle");
|
|
30725
|
+
const foundHighlight = node.marks.find((m2) => m2.type.name === "highlight");
|
|
30726
|
+
if (!foundTextStyle) {
|
|
30727
|
+
tr.addMark(
|
|
30728
|
+
pos,
|
|
30729
|
+
pos + node.nodeSize,
|
|
30730
|
+
textStyleType.create({
|
|
30731
|
+
...fontFamily?.attrs,
|
|
30732
|
+
...fontSize?.attrs
|
|
30733
|
+
})
|
|
30734
|
+
);
|
|
30735
|
+
} else if (!foundTextStyle?.attrs.fontFamily && fontFamily) {
|
|
30736
|
+
tr.addMark(
|
|
30737
|
+
pos,
|
|
30738
|
+
pos + node.nodeSize,
|
|
30739
|
+
textStyleType.create({
|
|
30740
|
+
...foundTextStyle?.attrs,
|
|
30741
|
+
...fontFamily.attrs
|
|
30742
|
+
})
|
|
30743
|
+
);
|
|
30744
|
+
} else if (!foundTextStyle?.attrs.fontSize && fontSize) {
|
|
30745
|
+
tr.addMark(
|
|
30746
|
+
pos,
|
|
30747
|
+
pos + node.nodeSize,
|
|
30748
|
+
textStyleType.create({
|
|
30749
|
+
...foundTextStyle?.attrs,
|
|
30750
|
+
...fontSize.attrs
|
|
30751
|
+
})
|
|
30752
|
+
);
|
|
30753
|
+
}
|
|
30754
|
+
if (!foundHighlight) {
|
|
30755
|
+
tr.addMark(
|
|
30756
|
+
pos,
|
|
30757
|
+
pos + node.nodeSize,
|
|
30758
|
+
highlightType.create({
|
|
30759
|
+
...highlight?.attrs
|
|
30760
|
+
})
|
|
30761
|
+
);
|
|
30762
|
+
}
|
|
30763
|
+
});
|
|
30764
|
+
return state2.apply(tr);
|
|
30765
|
+
}
|
|
30766
|
+
function getFieldHighlightJson(fieldsHighlightColor) {
|
|
30767
|
+
if (!fieldsHighlightColor) return null;
|
|
30768
|
+
let parsedColor = fieldsHighlightColor.trim();
|
|
30769
|
+
const hexRegex = /^#?([A-Fa-f0-9]{3}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/;
|
|
30770
|
+
if (!hexRegex.test(parsedColor)) {
|
|
30771
|
+
console.warn(`Invalid HEX color provided to fieldsHighlightColor export param: ${fieldsHighlightColor}`);
|
|
30772
|
+
return null;
|
|
30773
|
+
}
|
|
30774
|
+
if (parsedColor.startsWith("#")) {
|
|
30775
|
+
parsedColor = parsedColor.slice(1);
|
|
30776
|
+
}
|
|
30777
|
+
return {
|
|
30778
|
+
name: "w:rPr",
|
|
30779
|
+
elements: [
|
|
30780
|
+
{
|
|
30781
|
+
name: "w:shd",
|
|
30782
|
+
attributes: {
|
|
30783
|
+
"w:fill": `#${parsedColor}`,
|
|
30784
|
+
"w:color": "auto",
|
|
30785
|
+
"w:val": "clear"
|
|
30786
|
+
}
|
|
30787
|
+
}
|
|
30788
|
+
]
|
|
30789
|
+
};
|
|
30790
|
+
}
|
|
30791
|
+
function translateDocumentSection(params) {
|
|
30792
|
+
const { node } = params;
|
|
30793
|
+
const { attrs = {} } = node;
|
|
30794
|
+
const childContent = translateChildNodes({ ...params, nodes: node.content });
|
|
30795
|
+
const nodeElements = [
|
|
30796
|
+
{
|
|
30797
|
+
name: "w:sdtContent",
|
|
30798
|
+
elements: childContent
|
|
30799
|
+
}
|
|
30800
|
+
];
|
|
30801
|
+
const exportedTag = JSON.stringify({
|
|
30802
|
+
type: "documentSection",
|
|
30803
|
+
description: attrs.description
|
|
30804
|
+
});
|
|
30805
|
+
const sdtPr = generateSdtPrTagForDocumentSection(attrs.id, attrs.title, exportedTag);
|
|
30806
|
+
const { isLocked } = attrs;
|
|
30807
|
+
if (isLocked) {
|
|
30808
|
+
sdtPr.elements.push({
|
|
30809
|
+
name: "w:lock",
|
|
30810
|
+
attributes: {
|
|
30811
|
+
"w:val": "sdtContentLocked"
|
|
30812
|
+
}
|
|
30813
|
+
});
|
|
30814
|
+
}
|
|
30815
|
+
nodeElements.unshift(sdtPr);
|
|
30816
|
+
const result = {
|
|
30817
|
+
name: "w:sdt",
|
|
30818
|
+
elements: nodeElements
|
|
30819
|
+
};
|
|
30820
|
+
return result;
|
|
30821
|
+
}
|
|
30822
|
+
const generateSdtPrTagForDocumentSection = (id, title, tag) => {
|
|
30823
|
+
return {
|
|
30824
|
+
name: "w:sdtPr",
|
|
30825
|
+
elements: [
|
|
30826
|
+
{
|
|
30827
|
+
name: "w:id",
|
|
30828
|
+
attributes: {
|
|
30829
|
+
"w:val": id
|
|
30830
|
+
}
|
|
30831
|
+
},
|
|
30832
|
+
{
|
|
30833
|
+
name: "w:alias",
|
|
30834
|
+
attributes: {
|
|
30835
|
+
"w:val": title
|
|
30836
|
+
}
|
|
30837
|
+
},
|
|
30838
|
+
{
|
|
30839
|
+
name: "w:tag",
|
|
30840
|
+
attributes: {
|
|
30841
|
+
"w:val": tag
|
|
30842
|
+
}
|
|
30843
|
+
}
|
|
30844
|
+
]
|
|
30845
|
+
};
|
|
30846
|
+
};
|
|
30847
|
+
function translateDocumentPartObj(params) {
|
|
30848
|
+
const { node } = params;
|
|
30849
|
+
const { attrs = {} } = node;
|
|
30850
|
+
const childContent = translateChildNodes({ ...params, nodes: node.content });
|
|
30851
|
+
const nodeElements = [
|
|
30852
|
+
{
|
|
30853
|
+
name: "w:sdtPr",
|
|
30854
|
+
elements: [
|
|
30855
|
+
{
|
|
30856
|
+
name: "w:id",
|
|
30857
|
+
attributes: {
|
|
30858
|
+
"w:val": attrs.id
|
|
30859
|
+
}
|
|
30860
|
+
},
|
|
30861
|
+
{
|
|
30862
|
+
name: "w:docPartObj",
|
|
30863
|
+
elements: [
|
|
30864
|
+
{
|
|
30865
|
+
name: "w:docPartGallery",
|
|
30866
|
+
attributes: {
|
|
30867
|
+
"w:val": attrs.docPartGallery
|
|
30868
|
+
}
|
|
30869
|
+
},
|
|
30870
|
+
...attrs.docPartUnique ? [
|
|
30871
|
+
{
|
|
30872
|
+
name: "w:docPartUnique"
|
|
30873
|
+
}
|
|
30874
|
+
] : []
|
|
30875
|
+
]
|
|
30876
|
+
}
|
|
30877
|
+
]
|
|
30878
|
+
},
|
|
30879
|
+
{
|
|
30880
|
+
name: "w:sdtContent",
|
|
30881
|
+
elements: childContent
|
|
30882
|
+
}
|
|
30883
|
+
];
|
|
30884
|
+
const result = {
|
|
30885
|
+
name: "w:sdt",
|
|
30886
|
+
elements: nodeElements
|
|
30887
|
+
};
|
|
30888
|
+
return result;
|
|
30889
|
+
}
|
|
30890
|
+
function translateStructuredContent(params) {
|
|
30891
|
+
const { node } = params;
|
|
30892
|
+
const childContent = translateChildNodes({ ...params, nodes: node.content });
|
|
30893
|
+
const sdtContent = { name: "w:sdtContent", elements: childContent };
|
|
30894
|
+
const sdtPr = generateSdtPrTagForStructuredContent({ node });
|
|
30895
|
+
const nodeElements = [sdtPr, sdtContent];
|
|
30896
|
+
const result = {
|
|
30897
|
+
name: "w:sdt",
|
|
30898
|
+
elements: nodeElements
|
|
30899
|
+
};
|
|
30900
|
+
return result;
|
|
30901
|
+
}
|
|
30902
|
+
function generateSdtPrTagForStructuredContent({ node }) {
|
|
30903
|
+
const { attrs = {} } = node;
|
|
30904
|
+
const id = {
|
|
30905
|
+
name: "w:id",
|
|
30906
|
+
type: "element",
|
|
30907
|
+
attributes: { "w:val": attrs.id }
|
|
30908
|
+
};
|
|
30909
|
+
const alias = {
|
|
30910
|
+
name: "w:alias",
|
|
30911
|
+
type: "element",
|
|
30912
|
+
attributes: { "w:val": attrs.alias }
|
|
30913
|
+
};
|
|
30914
|
+
const tag = {
|
|
30915
|
+
name: "w:tag",
|
|
30916
|
+
type: "element",
|
|
30917
|
+
attributes: { "w:val": attrs.tag }
|
|
30918
|
+
};
|
|
30919
|
+
const resultElements = [];
|
|
30920
|
+
if (attrs.id) resultElements.push(id);
|
|
30921
|
+
if (attrs.alias) resultElements.push(alias);
|
|
30922
|
+
if (attrs.tag) resultElements.push(tag);
|
|
30923
|
+
if (attrs.sdtPr) {
|
|
30924
|
+
const elements = attrs.sdtPr.elements || [];
|
|
30925
|
+
const elementsToExclude = ["w:id", "w:alias", "w:tag"];
|
|
30926
|
+
const restElements = elements.filter((el) => !elementsToExclude.includes(el.name));
|
|
30927
|
+
const result2 = {
|
|
30928
|
+
name: "w:sdtPr",
|
|
30929
|
+
type: "element",
|
|
30930
|
+
elements: [...resultElements, ...restElements]
|
|
30931
|
+
};
|
|
30932
|
+
return result2;
|
|
30933
|
+
}
|
|
30934
|
+
const result = {
|
|
30935
|
+
name: "w:sdtPr",
|
|
30936
|
+
type: "element",
|
|
30937
|
+
elements: resultElements
|
|
30938
|
+
};
|
|
30939
|
+
return result;
|
|
30940
|
+
}
|
|
30941
|
+
const XML_NODE_NAME$b = "w:sdt";
|
|
30942
|
+
const SD_NODE_NAME$8 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
|
|
30943
|
+
const validXmlAttributes$6 = [];
|
|
30944
|
+
function encode$h(params) {
|
|
30945
|
+
const nodes = params.nodes;
|
|
30946
|
+
const node = nodes[0];
|
|
30947
|
+
const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
|
|
30948
|
+
if (!handler2 || sdtType === "unknown") {
|
|
30949
|
+
return void 0;
|
|
30950
|
+
}
|
|
30951
|
+
const result = handler2(params);
|
|
30952
|
+
return result;
|
|
30953
|
+
}
|
|
30954
|
+
function decode$j(params) {
|
|
30955
|
+
const { node } = params;
|
|
30956
|
+
if (!node || !node.type) {
|
|
30957
|
+
return null;
|
|
30958
|
+
}
|
|
30959
|
+
const types2 = {
|
|
30960
|
+
fieldAnnotation: () => translateFieldAnnotation(params),
|
|
30961
|
+
structuredContent: () => translateStructuredContent(params),
|
|
30962
|
+
structuredContentBlock: () => translateStructuredContent(params),
|
|
30963
|
+
documentSection: () => translateDocumentSection(params),
|
|
30964
|
+
documentPartObject: () => translateDocumentPartObj(params),
|
|
30965
|
+
// Handled in doc-part-obj translator
|
|
30966
|
+
default: () => null
|
|
30967
|
+
};
|
|
30968
|
+
const decoder = types2[node.type] ?? types2.default;
|
|
30969
|
+
const result = decoder();
|
|
30970
|
+
return result;
|
|
30971
|
+
}
|
|
30972
|
+
const config$a = {
|
|
30973
|
+
xmlName: XML_NODE_NAME$b,
|
|
30974
|
+
sdNodeOrKeyName: SD_NODE_NAME$8,
|
|
30975
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
30976
|
+
encode: encode$h,
|
|
30977
|
+
decode: decode$j,
|
|
30978
|
+
attributes: validXmlAttributes$6
|
|
30979
|
+
};
|
|
30980
|
+
const translator$q = NodeTranslator.from(config$a);
|
|
30981
|
+
function preProcessVerticalMergeCells(table, { editorSchema }) {
|
|
30982
|
+
if (!table || !Array.isArray(table.content)) {
|
|
30983
|
+
return table;
|
|
30984
|
+
}
|
|
30985
|
+
const rows = table.content;
|
|
30986
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
30987
|
+
const row = rows[rowIndex];
|
|
30988
|
+
if (!row) continue;
|
|
30989
|
+
if (!Array.isArray(row.content)) {
|
|
30990
|
+
row.content = [];
|
|
30991
|
+
}
|
|
30992
|
+
for (let cellIndex = 0; cellIndex < row.content.length; cellIndex++) {
|
|
30993
|
+
const cell = row.content[cellIndex];
|
|
30994
|
+
if (!cell) continue;
|
|
30995
|
+
const attrs = cell.attrs || {};
|
|
30996
|
+
if (!attrs.rowspan || attrs.rowspan <= 1) continue;
|
|
30997
|
+
const maxRowspan = Math.min(attrs.rowspan, rows.length - rowIndex);
|
|
30998
|
+
for (let offset = 1; offset < maxRowspan; offset++) {
|
|
30999
|
+
const rowToChange = rows[rowIndex + offset];
|
|
31000
|
+
if (!rowToChange) continue;
|
|
31001
|
+
if (!Array.isArray(rowToChange.content)) {
|
|
31002
|
+
rowToChange.content = [];
|
|
31003
|
+
}
|
|
31004
|
+
const existingCell = rowToChange.content[cellIndex];
|
|
31005
|
+
if (existingCell?.attrs?.continueMerge) continue;
|
|
31006
|
+
const mergedCell = {
|
|
31007
|
+
type: cell.type,
|
|
31008
|
+
content: [editorSchema.nodes.paragraph.createAndFill().toJSON()],
|
|
31009
|
+
attrs: {
|
|
31010
|
+
...cell.attrs,
|
|
31011
|
+
rowspan: null,
|
|
31012
|
+
continueMerge: true
|
|
31013
|
+
}
|
|
31014
|
+
};
|
|
31015
|
+
rowToChange.content.splice(cellIndex, 0, mergedCell);
|
|
31016
|
+
}
|
|
31017
|
+
}
|
|
31018
|
+
}
|
|
31019
|
+
return table;
|
|
31020
|
+
}
|
|
31021
|
+
const translator$p = NodeTranslator.from({
|
|
31022
|
+
xmlName: "w:bidiVisual",
|
|
31023
|
+
sdNodeOrKeyName: "rightToLeft",
|
|
31024
|
+
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
31025
|
+
decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
|
|
31026
|
+
});
|
|
31027
|
+
const translator$o = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
|
|
31028
|
+
const translator$n = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
|
|
31029
|
+
const translator$m = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
|
|
31030
|
+
const translator$l = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
|
|
31031
|
+
const translator$k = NodeTranslator.from({
|
|
31032
|
+
xmlName: "w:tblLook",
|
|
31033
|
+
sdNodeOrKeyName: "tblLook",
|
|
31034
|
+
attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
|
|
31035
|
+
encode: (params, encodedAttrs) => {
|
|
31036
|
+
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
31037
|
+
},
|
|
31038
|
+
decode: function({ node }, context) {
|
|
31039
|
+
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.tblLook || {} } });
|
|
31040
|
+
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
31041
|
+
}
|
|
31042
|
+
});
|
|
31043
|
+
const translator$j = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
|
|
31044
|
+
const translator$i = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
|
|
31045
|
+
const translator$h = NodeTranslator.from(
|
|
31046
|
+
createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
|
|
31047
|
+
);
|
|
31048
|
+
const translator$g = NodeTranslator.from(
|
|
31049
|
+
createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
|
|
31050
|
+
);
|
|
31051
|
+
const translator$f = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
|
|
31052
|
+
const translator$e = NodeTranslator.from({
|
|
31053
|
+
xmlName: "w:tblpPr",
|
|
31054
|
+
sdNodeOrKeyName: "floatingTableProperties",
|
|
31055
|
+
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))),
|
|
31056
|
+
encode: (params, encodedAttrs) => {
|
|
31057
|
+
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
31058
|
+
},
|
|
31059
|
+
decode: function({ node }, context) {
|
|
31060
|
+
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.floatingTableProperties || {} } });
|
|
31061
|
+
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
31062
|
+
}
|
|
31063
|
+
});
|
|
31064
|
+
const propertyTranslators$2 = [
|
|
31065
|
+
translator$15,
|
|
31066
|
+
translator$13,
|
|
31067
|
+
translator$11,
|
|
31068
|
+
translator$10,
|
|
31069
|
+
translator$$,
|
|
31070
|
+
translator$Z,
|
|
31071
|
+
translator$X,
|
|
31072
|
+
translator$V
|
|
31073
|
+
];
|
|
31074
|
+
const translator$d = NodeTranslator.from(
|
|
31075
|
+
createNestedPropertiesTranslator("w:tblBorders", "borders", propertyTranslators$2)
|
|
31076
|
+
);
|
|
31077
|
+
const propertyTranslators$1 = [
|
|
31078
|
+
translator$14,
|
|
31079
|
+
translator$12,
|
|
31080
|
+
translator$_,
|
|
31081
|
+
translator$Y,
|
|
31082
|
+
translator$W,
|
|
31083
|
+
translator$U
|
|
31084
|
+
];
|
|
31085
|
+
const translator$c = NodeTranslator.from(
|
|
31086
|
+
createNestedPropertiesTranslator("w:tblCellMar", "cellMargins", propertyTranslators$1)
|
|
31087
|
+
);
|
|
31088
|
+
const propertyTranslators = [
|
|
31089
|
+
translator$p,
|
|
31090
|
+
translator$B,
|
|
31091
|
+
translator$19,
|
|
31092
|
+
translator$o,
|
|
31093
|
+
translator$A,
|
|
31094
|
+
translator$n,
|
|
31095
|
+
translator$m,
|
|
31096
|
+
translator$l,
|
|
31097
|
+
translator$k,
|
|
31098
|
+
translator$j,
|
|
31099
|
+
translator$i,
|
|
31100
|
+
translator$h,
|
|
31101
|
+
translator$g,
|
|
31102
|
+
translator$f,
|
|
31103
|
+
translator$e,
|
|
31104
|
+
translator$d,
|
|
31105
|
+
translator$c
|
|
31106
|
+
];
|
|
31107
|
+
const translator$b = NodeTranslator.from(
|
|
31108
|
+
createNestedPropertiesTranslator("w:tblPr", "tableProperties", propertyTranslators)
|
|
31109
|
+
);
|
|
31110
|
+
const translator$a = NodeTranslator.from(
|
|
31111
|
+
createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
|
|
31112
|
+
);
|
|
31113
|
+
const DEFAULT_COLUMN_WIDTH_PX = 100;
|
|
31114
|
+
const normalizeTwipWidth = (value) => {
|
|
31115
|
+
if (value == null) return null;
|
|
31116
|
+
const numericValue = typeof value === "string" ? parseInt(value, 10) : value;
|
|
31117
|
+
if (!Number.isFinite(numericValue) || Number.isNaN(numericValue) || numericValue <= 0) {
|
|
31118
|
+
return null;
|
|
31119
|
+
}
|
|
31120
|
+
return numericValue;
|
|
31121
|
+
};
|
|
31122
|
+
const getSchemaDefaultColumnWidthPx = (params) => {
|
|
31123
|
+
const defaultValue = params?.editor?.schema?.nodes?.tableCell?.spec?.attrs?.colwidth?.default;
|
|
31124
|
+
if (Array.isArray(defaultValue)) {
|
|
31125
|
+
const numericWidth = defaultValue.find((width) => typeof width === "number" && Number.isFinite(width) && width > 0);
|
|
31126
|
+
if (numericWidth != null) return numericWidth;
|
|
31127
|
+
} else if (typeof defaultValue === "number" && Number.isFinite(defaultValue) && defaultValue > 0) {
|
|
31128
|
+
return defaultValue;
|
|
31203
31129
|
}
|
|
31204
|
-
|
|
31205
|
-
|
|
31206
|
-
|
|
31207
|
-
|
|
31208
|
-
|
|
31209
|
-
|
|
31210
|
-
|
|
31211
|
-
|
|
31130
|
+
return DEFAULT_COLUMN_WIDTH_PX;
|
|
31131
|
+
};
|
|
31132
|
+
const getTableWidthPx = (params) => {
|
|
31133
|
+
const explicitWidth = params?.node?.attrs?.tableWidth?.width;
|
|
31134
|
+
if (typeof explicitWidth === "number" && explicitWidth > 0) return explicitWidth;
|
|
31135
|
+
const tableWidth = params?.node?.attrs?.tableProperties?.tableWidth;
|
|
31136
|
+
if (tableWidth?.value != null && typeof tableWidth.value === "number" && tableWidth.value > 0) {
|
|
31137
|
+
const { value, type: type2 } = tableWidth;
|
|
31138
|
+
if (!type2 || type2 === "auto" || type2 === "dxa") {
|
|
31139
|
+
return twipsToPixels(value);
|
|
31212
31140
|
}
|
|
31213
31141
|
}
|
|
31214
|
-
|
|
31215
|
-
|
|
31216
|
-
|
|
31217
|
-
|
|
31142
|
+
return null;
|
|
31143
|
+
};
|
|
31144
|
+
const resolveFallbackColumnWidthTwips = (params, totalColumns, cellMinWidthTwips) => {
|
|
31145
|
+
const columnCount = Math.max(totalColumns, 1);
|
|
31146
|
+
const defaultColumnWidthPx = getSchemaDefaultColumnWidthPx(params);
|
|
31147
|
+
const tableWidthPx = getTableWidthPx(params);
|
|
31148
|
+
const safeDefaultPx = Number.isFinite(defaultColumnWidthPx) && defaultColumnWidthPx > 0 ? defaultColumnWidthPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
31149
|
+
let fallbackWidthPx = safeDefaultPx;
|
|
31150
|
+
if (typeof tableWidthPx === "number" && tableWidthPx > 0) {
|
|
31151
|
+
fallbackWidthPx = tableWidthPx / columnCount;
|
|
31218
31152
|
}
|
|
31219
|
-
const
|
|
31220
|
-
|
|
31221
|
-
|
|
31222
|
-
|
|
31223
|
-
fieldType: attrs.fieldType,
|
|
31224
|
-
fieldTypeShort: attrs.type,
|
|
31225
|
-
fieldColor: attrs.fieldColor,
|
|
31226
|
-
fieldMultipleImage: attrs.multipleImage,
|
|
31227
|
-
fieldFontFamily: attrs.fontFamily,
|
|
31228
|
-
fieldFontSize: attrs.fontSize,
|
|
31229
|
-
fieldTextColor: attrs.textColor,
|
|
31230
|
-
fieldTextHighlight: attrs.textHighlight,
|
|
31231
|
-
hash: attrs.hash
|
|
31232
|
-
};
|
|
31233
|
-
const annotationAttrsJson = JSON.stringify(annotationAttrs);
|
|
31234
|
-
const result = {
|
|
31235
|
-
name: "w:sdt",
|
|
31236
|
-
elements: [
|
|
31237
|
-
{
|
|
31238
|
-
name: "w:sdtPr",
|
|
31239
|
-
elements: [
|
|
31240
|
-
{ name: "w:alias", attributes: { "w:val": attrs.displayLabel } },
|
|
31241
|
-
{ name: "w:tag", attributes: { "w:val": annotationAttrsJson } },
|
|
31242
|
-
{ name: "w:id", attributes: { "w:val": id } }
|
|
31243
|
-
]
|
|
31244
|
-
},
|
|
31245
|
-
{
|
|
31246
|
-
name: "w:sdtContent",
|
|
31247
|
-
elements: sdtContentElements
|
|
31248
|
-
}
|
|
31249
|
-
]
|
|
31250
|
-
};
|
|
31251
|
-
return result;
|
|
31252
|
-
}
|
|
31253
|
-
function getTranslationByAnnotationType(annotationType, annotationFieldType) {
|
|
31254
|
-
if (annotationType === "text" && annotationFieldType === "FILEUPLOADER") {
|
|
31255
|
-
return null;
|
|
31153
|
+
const fallbackWidthTwips = pixelsToTwips(fallbackWidthPx);
|
|
31154
|
+
if (!Number.isFinite(fallbackWidthTwips) || Number.isNaN(fallbackWidthTwips) || fallbackWidthTwips <= 0) {
|
|
31155
|
+
const safeDefault = Math.max(pixelsToTwips(safeDefaultPx), cellMinWidthTwips);
|
|
31156
|
+
return safeDefault;
|
|
31256
31157
|
}
|
|
31257
|
-
|
|
31258
|
-
|
|
31259
|
-
|
|
31260
|
-
|
|
31261
|
-
|
|
31262
|
-
|
|
31263
|
-
|
|
31158
|
+
return Math.max(fallbackWidthTwips, cellMinWidthTwips);
|
|
31159
|
+
};
|
|
31160
|
+
const XML_NODE_NAME$a = "w:tblGrid";
|
|
31161
|
+
const SD_ATTR_KEY$2 = "grid";
|
|
31162
|
+
const cellMinWidth = pixelsToTwips(10);
|
|
31163
|
+
const encode$g = (params) => {
|
|
31164
|
+
const { nodes } = params;
|
|
31165
|
+
const node = nodes[0];
|
|
31166
|
+
const attributes = encodeProperties(node, { [translator$a.xmlName]: translator$a }, true);
|
|
31167
|
+
return {
|
|
31168
|
+
xmlName: XML_NODE_NAME$a,
|
|
31169
|
+
sdNodeOrKeyName: SD_ATTR_KEY$2,
|
|
31170
|
+
attributes
|
|
31264
31171
|
};
|
|
31265
|
-
|
|
31266
|
-
|
|
31267
|
-
|
|
31268
|
-
|
|
31269
|
-
|
|
31270
|
-
|
|
31271
|
-
|
|
31172
|
+
};
|
|
31173
|
+
const decode$i = (params) => {
|
|
31174
|
+
const { grid: rawGrid } = params.node.attrs || {};
|
|
31175
|
+
const grid = Array.isArray(rawGrid) ? rawGrid : [];
|
|
31176
|
+
const { firstRow = {} } = params.extraParams || {};
|
|
31177
|
+
const cellNodes = firstRow.content?.filter((n) => n.type === "tableCell") ?? [];
|
|
31178
|
+
const columnCountFromCells = cellNodes.reduce((count, cell) => {
|
|
31179
|
+
const spanCount = Math.max(1, cell?.attrs?.colspan ?? 1);
|
|
31180
|
+
return count + spanCount;
|
|
31181
|
+
}, 0);
|
|
31182
|
+
const totalColumns = Math.max(columnCountFromCells, grid.length);
|
|
31183
|
+
const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params, totalColumns, cellMinWidth);
|
|
31184
|
+
const elements = [];
|
|
31185
|
+
let columnIndex = 0;
|
|
31186
|
+
const pushColumn = (widthTwips, { enforceMinimum = false } = {}) => {
|
|
31187
|
+
let numericWidth = typeof widthTwips === "string" ? parseInt(widthTwips, 10) : widthTwips;
|
|
31188
|
+
let shouldEnforceMinimum = enforceMinimum;
|
|
31189
|
+
if (numericWidth == null || Number.isNaN(numericWidth) || numericWidth <= 0) {
|
|
31190
|
+
numericWidth = fallbackColumnWidthTwips;
|
|
31191
|
+
shouldEnforceMinimum = true;
|
|
31192
|
+
}
|
|
31193
|
+
const roundedWidth = Math.round(numericWidth);
|
|
31194
|
+
const minimumWidth = shouldEnforceMinimum ? cellMinWidth : 1;
|
|
31195
|
+
const safeWidth = Math.max(roundedWidth, minimumWidth);
|
|
31196
|
+
const decoded = translator$a.decode({
|
|
31197
|
+
node: { type: (
|
|
31198
|
+
/** @type {string} */
|
|
31199
|
+
translator$a.sdNodeOrKeyName
|
|
31200
|
+
), attrs: { col: safeWidth } }
|
|
31201
|
+
});
|
|
31202
|
+
if (decoded) elements.push(decoded);
|
|
31272
31203
|
};
|
|
31273
|
-
|
|
31274
|
-
}
|
|
31275
|
-
|
|
31276
|
-
|
|
31277
|
-
|
|
31278
|
-
|
|
31279
|
-
|
|
31280
|
-
|
|
31281
|
-
|
|
31282
|
-
|
|
31283
|
-
|
|
31284
|
-
|
|
31285
|
-
|
|
31286
|
-
|
|
31287
|
-
|
|
31288
|
-
|
|
31289
|
-
|
|
31290
|
-
|
|
31291
|
-
|
|
31292
|
-
|
|
31293
|
-
|
|
31294
|
-
}
|
|
31295
|
-
|
|
31296
|
-
|
|
31297
|
-
|
|
31298
|
-
|
|
31299
|
-
|
|
31300
|
-
|
|
31301
|
-
const paragraphHtmlContainer = sanitizeHtml(html);
|
|
31302
|
-
const marksFromAttrs = translateFieldAttrsToMarks(attrs);
|
|
31303
|
-
const allMarks = [...marks, ...marksFromAttrs];
|
|
31304
|
-
let state2 = EditorState.create({
|
|
31305
|
-
doc: DOMParser$1.fromSchema(editorSchema).parse(paragraphHtmlContainer)
|
|
31204
|
+
cellNodes.forEach((cell) => {
|
|
31205
|
+
const { colspan = 1, colwidth } = cell?.attrs || {};
|
|
31206
|
+
const spanCount = Math.max(1, colspan);
|
|
31207
|
+
for (let span = 0; span < spanCount; span++) {
|
|
31208
|
+
const rawWidth = Array.isArray(colwidth) ? colwidth[span] : void 0;
|
|
31209
|
+
const cellWidthPixels = typeof rawWidth === "number" && Number.isFinite(rawWidth) ? rawWidth : Number(rawWidth);
|
|
31210
|
+
const hasCellWidth = Number.isFinite(cellWidthPixels) && cellWidthPixels > 0;
|
|
31211
|
+
const colGridAttrs = grid?.[columnIndex] || {};
|
|
31212
|
+
const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
|
|
31213
|
+
const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
|
|
31214
|
+
let cellWidthTwips;
|
|
31215
|
+
let enforceMinimum = false;
|
|
31216
|
+
if (hasCellWidth) {
|
|
31217
|
+
const tolerance = 0.5;
|
|
31218
|
+
if (gridWidthTwips != null && gridWidthPixels != null && Math.abs(gridWidthPixels - cellWidthPixels) <= tolerance) {
|
|
31219
|
+
cellWidthTwips = gridWidthTwips;
|
|
31220
|
+
} else {
|
|
31221
|
+
cellWidthTwips = pixelsToTwips(cellWidthPixels);
|
|
31222
|
+
}
|
|
31223
|
+
} else if (gridWidthTwips != null) {
|
|
31224
|
+
cellWidthTwips = gridWidthTwips;
|
|
31225
|
+
} else {
|
|
31226
|
+
cellWidthTwips = fallbackColumnWidthTwips;
|
|
31227
|
+
enforceMinimum = true;
|
|
31228
|
+
}
|
|
31229
|
+
pushColumn(cellWidthTwips, { enforceMinimum });
|
|
31230
|
+
columnIndex++;
|
|
31231
|
+
}
|
|
31306
31232
|
});
|
|
31307
|
-
|
|
31308
|
-
|
|
31233
|
+
while (columnIndex < grid.length) {
|
|
31234
|
+
const gridWidthTwips = normalizeTwipWidth(grid[columnIndex]?.col);
|
|
31235
|
+
pushColumn(gridWidthTwips);
|
|
31236
|
+
columnIndex++;
|
|
31237
|
+
}
|
|
31238
|
+
const newNode = {
|
|
31239
|
+
name: XML_NODE_NAME$a,
|
|
31240
|
+
attributes: {},
|
|
31241
|
+
elements
|
|
31242
|
+
};
|
|
31243
|
+
return newNode;
|
|
31244
|
+
};
|
|
31245
|
+
const config$9 = {
|
|
31246
|
+
xmlName: XML_NODE_NAME$a,
|
|
31247
|
+
sdNodeOrKeyName: SD_ATTR_KEY$2,
|
|
31248
|
+
encode: encode$g,
|
|
31249
|
+
decode: decode$i
|
|
31250
|
+
};
|
|
31251
|
+
const translator$9 = NodeTranslator.from(config$9);
|
|
31252
|
+
const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
|
|
31253
|
+
const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
|
|
31254
|
+
const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
|
|
31255
|
+
const MIN_COLUMN_WIDTH_TWIPS = pixelsToTwips(10);
|
|
31256
|
+
const pctToPercent = (value) => {
|
|
31257
|
+
if (value == null) return null;
|
|
31258
|
+
return value / 50;
|
|
31259
|
+
};
|
|
31260
|
+
const resolveContentWidthTwips = () => DEFAULT_CONTENT_WIDTH_TWIPS;
|
|
31261
|
+
const resolveMeasurementWidthPx = (measurement) => {
|
|
31262
|
+
if (!measurement || typeof measurement.value !== "number" || measurement.value <= 0) return null;
|
|
31263
|
+
const { value, type: type2 } = measurement;
|
|
31264
|
+
if (!type2 || type2 === "auto") return null;
|
|
31265
|
+
if (type2 === "dxa") return twipsToPixels(value);
|
|
31266
|
+
if (type2 === "pct") {
|
|
31267
|
+
const percent = pctToPercent(value);
|
|
31268
|
+
if (percent == null || percent <= 0) return null;
|
|
31269
|
+
const widthTwips = resolveContentWidthTwips() * percent / 100;
|
|
31270
|
+
return twipsToPixels(widthTwips);
|
|
31271
|
+
}
|
|
31272
|
+
return null;
|
|
31273
|
+
};
|
|
31274
|
+
const countColumnsInRow = (row) => {
|
|
31275
|
+
if (!row?.elements?.length) return 0;
|
|
31276
|
+
return row.elements.reduce((count, element) => {
|
|
31277
|
+
if (element.name !== "w:tc") return count;
|
|
31278
|
+
const tcPr = element.elements?.find((el) => el.name === "w:tcPr");
|
|
31279
|
+
const gridSpan = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
31280
|
+
const spanValue = parseInt(gridSpan?.attributes?.["w:val"] || "1", 10);
|
|
31281
|
+
return count + (Number.isFinite(spanValue) && spanValue > 0 ? spanValue : 1);
|
|
31282
|
+
}, 0);
|
|
31283
|
+
};
|
|
31284
|
+
const clampColumnWidthTwips = (value) => Math.max(Math.round(value), MIN_COLUMN_WIDTH_TWIPS);
|
|
31285
|
+
const createFallbackGrid = (columnCount, columnWidthTwips) => Array.from({ length: columnCount }, () => ({ col: clampColumnWidthTwips(columnWidthTwips) }));
|
|
31286
|
+
const buildFallbackGridForTable = ({ params, rows, tableWidth, tableWidthMeasurement }) => {
|
|
31287
|
+
const firstRow = rows.find((row) => row.elements?.some((el) => el.name === "w:tc"));
|
|
31288
|
+
const columnCount = countColumnsInRow(firstRow);
|
|
31289
|
+
if (!columnCount) return null;
|
|
31290
|
+
const schemaDefaultPx = getSchemaDefaultColumnWidthPx(
|
|
31291
|
+
/** @type {any} */
|
|
31292
|
+
params
|
|
31293
|
+
);
|
|
31294
|
+
const minimumColumnWidthPx = Number.isFinite(schemaDefaultPx) && schemaDefaultPx > 0 ? schemaDefaultPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
31295
|
+
let totalWidthPx;
|
|
31296
|
+
if (tableWidthMeasurement) {
|
|
31297
|
+
const resolved = resolveMeasurementWidthPx(tableWidthMeasurement);
|
|
31298
|
+
if (resolved != null) totalWidthPx = resolved;
|
|
31309
31299
|
}
|
|
31310
|
-
|
|
31311
|
-
|
|
31312
|
-
|
|
31313
|
-
|
|
31314
|
-
|
|
31315
|
-
|
|
31316
|
-
|
|
31317
|
-
|
|
31318
|
-
|
|
31319
|
-
if (!seenLists.has(numId)) {
|
|
31320
|
-
const newNumId = ListHelpers.changeNumIdSameAbstract(numId, level, node.type.name, editor);
|
|
31321
|
-
listItem.attrs.numId = newNumId;
|
|
31322
|
-
seenLists.set(numId, newNumId);
|
|
31323
|
-
} else {
|
|
31324
|
-
const newNumId = seenLists.get(numId);
|
|
31325
|
-
listItem.attrs.numId = newNumId;
|
|
31326
|
-
}
|
|
31327
|
-
}
|
|
31328
|
-
});
|
|
31329
|
-
const elements = translateChildNodes({
|
|
31330
|
-
...params,
|
|
31331
|
-
node: htmlAnnotationNode
|
|
31332
|
-
});
|
|
31333
|
-
return {
|
|
31334
|
-
name: "htmlAnnotation",
|
|
31335
|
-
elements
|
|
31336
|
-
};
|
|
31337
|
-
}
|
|
31338
|
-
function prepareUrlAnnotation(params) {
|
|
31339
|
-
const {
|
|
31340
|
-
node: { attrs = {}, marks = [] }
|
|
31341
|
-
} = params;
|
|
31342
|
-
if (!attrs.linkUrl) return prepareTextAnnotation(params);
|
|
31343
|
-
const newId = addNewLinkRelationship(params, attrs.linkUrl);
|
|
31344
|
-
const linkTextNode = getTextNodeForExport(attrs.linkUrl, marks, params);
|
|
31345
|
-
const contentNode = processLinkContentNode(linkTextNode);
|
|
31300
|
+
if (totalWidthPx == null && tableWidth?.width && tableWidth.width > 0) {
|
|
31301
|
+
totalWidthPx = tableWidth.width;
|
|
31302
|
+
}
|
|
31303
|
+
if (totalWidthPx == null) {
|
|
31304
|
+
totalWidthPx = minimumColumnWidthPx * columnCount;
|
|
31305
|
+
}
|
|
31306
|
+
const rawColumnWidthPx = Math.max(totalWidthPx / columnCount, minimumColumnWidthPx);
|
|
31307
|
+
const columnWidthTwips = clampColumnWidthTwips(pixelsToTwips(rawColumnWidthPx));
|
|
31308
|
+
const fallbackColumnWidthPx = twipsToPixels(columnWidthTwips);
|
|
31346
31309
|
return {
|
|
31347
|
-
|
|
31348
|
-
|
|
31349
|
-
attributes: {
|
|
31350
|
-
"r:id": newId,
|
|
31351
|
-
"w:history": 1
|
|
31352
|
-
},
|
|
31353
|
-
elements: [contentNode]
|
|
31310
|
+
grid: createFallbackGrid(columnCount, columnWidthTwips),
|
|
31311
|
+
columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
|
|
31354
31312
|
};
|
|
31355
|
-
}
|
|
31356
|
-
|
|
31357
|
-
|
|
31358
|
-
|
|
31359
|
-
|
|
31360
|
-
|
|
31361
|
-
|
|
31362
|
-
if (
|
|
31363
|
-
|
|
31364
|
-
|
|
31365
|
-
if (textHighlight) marks.push({ type: "highlight", attrs: { color: textHighlight } });
|
|
31366
|
-
return marks;
|
|
31367
|
-
}
|
|
31368
|
-
function applyMarksToHtmlAnnotation(state2, marks) {
|
|
31369
|
-
const { tr, doc: doc2, schema } = state2;
|
|
31370
|
-
const allowedMarks = ["fontFamily", "fontSize", "highlight"];
|
|
31371
|
-
if (!marks.some((m2) => allowedMarks.includes(m2.type))) {
|
|
31372
|
-
return state2;
|
|
31313
|
+
};
|
|
31314
|
+
const XML_NODE_NAME$9 = "w:tbl";
|
|
31315
|
+
const SD_NODE_NAME$7 = "table";
|
|
31316
|
+
const encode$f = (params, encodedAttrs) => {
|
|
31317
|
+
const { nodes } = params;
|
|
31318
|
+
const node = nodes[0];
|
|
31319
|
+
const tblPr = node.elements.find((el) => el.name === "w:tblPr");
|
|
31320
|
+
if (tblPr) {
|
|
31321
|
+
const encodedProperties = translator$b.encode({ ...params, nodes: [tblPr] });
|
|
31322
|
+
encodedAttrs["tableProperties"] = encodedProperties || {};
|
|
31373
31323
|
}
|
|
31374
|
-
const
|
|
31375
|
-
|
|
31376
|
-
|
|
31377
|
-
|
|
31378
|
-
|
|
31379
|
-
|
|
31380
|
-
|
|
31381
|
-
|
|
31382
|
-
|
|
31383
|
-
|
|
31384
|
-
|
|
31385
|
-
|
|
31386
|
-
|
|
31387
|
-
|
|
31388
|
-
|
|
31389
|
-
|
|
31390
|
-
|
|
31391
|
-
);
|
|
31392
|
-
} else if (!foundTextStyle?.attrs.fontFamily && fontFamily) {
|
|
31393
|
-
tr.addMark(
|
|
31394
|
-
pos,
|
|
31395
|
-
pos + node.nodeSize,
|
|
31396
|
-
textStyleType.create({
|
|
31397
|
-
...foundTextStyle?.attrs,
|
|
31398
|
-
...fontFamily.attrs
|
|
31399
|
-
})
|
|
31400
|
-
);
|
|
31401
|
-
} else if (!foundTextStyle?.attrs.fontSize && fontSize) {
|
|
31402
|
-
tr.addMark(
|
|
31403
|
-
pos,
|
|
31404
|
-
pos + node.nodeSize,
|
|
31405
|
-
textStyleType.create({
|
|
31406
|
-
...foundTextStyle?.attrs,
|
|
31407
|
-
...fontSize.attrs
|
|
31408
|
-
})
|
|
31409
|
-
);
|
|
31324
|
+
const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
|
|
31325
|
+
if (tblGrid) {
|
|
31326
|
+
encodedAttrs["grid"] = translator$9.encode({ ...params, nodes: [tblGrid] }).attributes;
|
|
31327
|
+
}
|
|
31328
|
+
[
|
|
31329
|
+
"tableStyleId",
|
|
31330
|
+
"justification",
|
|
31331
|
+
"tableLayout",
|
|
31332
|
+
["tableIndent", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
31333
|
+
["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
|
|
31334
|
+
].forEach((prop) => {
|
|
31335
|
+
let key;
|
|
31336
|
+
let transform;
|
|
31337
|
+
if (Array.isArray(prop)) {
|
|
31338
|
+
[key, transform] = prop;
|
|
31339
|
+
} else {
|
|
31340
|
+
key = prop;
|
|
31341
|
+
transform = (v2) => v2;
|
|
31410
31342
|
}
|
|
31411
|
-
if (
|
|
31412
|
-
|
|
31413
|
-
pos,
|
|
31414
|
-
pos + node.nodeSize,
|
|
31415
|
-
highlightType.create({
|
|
31416
|
-
...highlight?.attrs
|
|
31417
|
-
})
|
|
31418
|
-
);
|
|
31343
|
+
if (encodedAttrs.tableProperties && encodedAttrs.tableProperties[key]) {
|
|
31344
|
+
encodedAttrs[key] = transform(encodedAttrs.tableProperties[key]);
|
|
31419
31345
|
}
|
|
31420
31346
|
});
|
|
31421
|
-
|
|
31422
|
-
|
|
31423
|
-
function getFieldHighlightJson(fieldsHighlightColor) {
|
|
31424
|
-
if (!fieldsHighlightColor) return null;
|
|
31425
|
-
let parsedColor = fieldsHighlightColor.trim();
|
|
31426
|
-
const hexRegex = /^#?([A-Fa-f0-9]{3}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/;
|
|
31427
|
-
if (!hexRegex.test(parsedColor)) {
|
|
31428
|
-
console.warn(`Invalid HEX color provided to fieldsHighlightColor export param: ${fieldsHighlightColor}`);
|
|
31429
|
-
return null;
|
|
31347
|
+
if (encodedAttrs.tableCellSpacing) {
|
|
31348
|
+
encodedAttrs["borderCollapse"] = "separate";
|
|
31430
31349
|
}
|
|
31431
|
-
if (
|
|
31432
|
-
|
|
31350
|
+
if (encodedAttrs.tableProperties?.tableWidth) {
|
|
31351
|
+
const tableWidthMeasurement = encodedAttrs.tableProperties.tableWidth;
|
|
31352
|
+
const widthPx = twipsToPixels(tableWidthMeasurement.value);
|
|
31353
|
+
if (widthPx != null) {
|
|
31354
|
+
encodedAttrs.tableWidth = {
|
|
31355
|
+
width: widthPx,
|
|
31356
|
+
type: tableWidthMeasurement.type
|
|
31357
|
+
};
|
|
31358
|
+
} else if (tableWidthMeasurement.type === "auto") {
|
|
31359
|
+
encodedAttrs.tableWidth = {
|
|
31360
|
+
width: 0,
|
|
31361
|
+
type: tableWidthMeasurement.type
|
|
31362
|
+
};
|
|
31363
|
+
}
|
|
31433
31364
|
}
|
|
31434
|
-
|
|
31435
|
-
|
|
31436
|
-
|
|
31437
|
-
|
|
31438
|
-
|
|
31439
|
-
|
|
31440
|
-
|
|
31441
|
-
|
|
31442
|
-
|
|
31365
|
+
const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
|
|
31366
|
+
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params);
|
|
31367
|
+
if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
|
|
31368
|
+
encodedAttrs.tableProperties = {
|
|
31369
|
+
...encodedAttrs.tableProperties || {},
|
|
31370
|
+
cellMargins: referencedStyles.cellMargins
|
|
31371
|
+
};
|
|
31372
|
+
}
|
|
31373
|
+
const rows = node.elements.filter((el) => el.name === "w:tr");
|
|
31374
|
+
const borderData = Object.assign({}, referencedStyles?.borders || {}, borders || {});
|
|
31375
|
+
const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
|
|
31376
|
+
encodedAttrs["borders"] = borderData;
|
|
31377
|
+
let columnWidths = Array.isArray(encodedAttrs["grid"]) ? encodedAttrs["grid"].map((item) => twipsToPixels(item.col)) : [];
|
|
31378
|
+
if (!columnWidths.length) {
|
|
31379
|
+
const fallback = buildFallbackGridForTable({
|
|
31380
|
+
params,
|
|
31381
|
+
rows,
|
|
31382
|
+
tableWidth: encodedAttrs.tableWidth,
|
|
31383
|
+
tableWidthMeasurement: encodedAttrs.tableProperties?.tableWidth
|
|
31384
|
+
});
|
|
31385
|
+
if (fallback) {
|
|
31386
|
+
encodedAttrs.grid = fallback.grid;
|
|
31387
|
+
columnWidths = fallback.columnWidths;
|
|
31388
|
+
}
|
|
31389
|
+
}
|
|
31390
|
+
const content = [];
|
|
31391
|
+
const totalColumns = columnWidths.length;
|
|
31392
|
+
const activeRowSpans = totalColumns > 0 ? new Array(totalColumns).fill(0) : [];
|
|
31393
|
+
rows.forEach((row, rowIndex) => {
|
|
31394
|
+
const result = translator$u.encode({
|
|
31395
|
+
...params,
|
|
31396
|
+
nodes: [row],
|
|
31397
|
+
extraParams: {
|
|
31398
|
+
row,
|
|
31399
|
+
table: node,
|
|
31400
|
+
rowBorders: borderRowData,
|
|
31401
|
+
columnWidths,
|
|
31402
|
+
activeRowSpans: activeRowSpans.slice(),
|
|
31403
|
+
rowIndex,
|
|
31404
|
+
_referencedStyles: referencedStyles
|
|
31405
|
+
}
|
|
31406
|
+
});
|
|
31407
|
+
if (result) {
|
|
31408
|
+
content.push(result);
|
|
31409
|
+
if (totalColumns > 0) {
|
|
31410
|
+
const activeRowSpansForCurrentRow = activeRowSpans.slice();
|
|
31411
|
+
for (let col = 0; col < totalColumns; col++) {
|
|
31412
|
+
if (activeRowSpans[col] > 0) {
|
|
31413
|
+
activeRowSpans[col] -= 1;
|
|
31414
|
+
}
|
|
31443
31415
|
}
|
|
31416
|
+
let columnIndex = 0;
|
|
31417
|
+
const advanceColumnIndex = () => {
|
|
31418
|
+
while (columnIndex < totalColumns && activeRowSpansForCurrentRow[columnIndex] > 0) {
|
|
31419
|
+
columnIndex += 1;
|
|
31420
|
+
}
|
|
31421
|
+
};
|
|
31422
|
+
advanceColumnIndex();
|
|
31423
|
+
result.content?.forEach((cell) => {
|
|
31424
|
+
advanceColumnIndex();
|
|
31425
|
+
const colspan = Math.max(1, cell.attrs?.colspan || 1);
|
|
31426
|
+
const rowspan = Math.max(1, cell.attrs?.rowspan || 1);
|
|
31427
|
+
if (rowspan > 1) {
|
|
31428
|
+
for (let offset = 0; offset < colspan && columnIndex + offset < totalColumns; offset++) {
|
|
31429
|
+
const targetIndex = columnIndex + offset;
|
|
31430
|
+
const remainingRows = rowspan - 1;
|
|
31431
|
+
if (remainingRows > 0 && remainingRows > activeRowSpans[targetIndex]) {
|
|
31432
|
+
activeRowSpans[targetIndex] = remainingRows;
|
|
31433
|
+
}
|
|
31434
|
+
}
|
|
31435
|
+
}
|
|
31436
|
+
columnIndex += colspan;
|
|
31437
|
+
advanceColumnIndex();
|
|
31438
|
+
});
|
|
31444
31439
|
}
|
|
31445
|
-
|
|
31440
|
+
}
|
|
31441
|
+
});
|
|
31442
|
+
return {
|
|
31443
|
+
type: "table",
|
|
31444
|
+
content,
|
|
31445
|
+
attrs: encodedAttrs
|
|
31446
31446
|
};
|
|
31447
|
-
}
|
|
31448
|
-
|
|
31447
|
+
};
|
|
31448
|
+
const decode$h = (params, decodedAttrs) => {
|
|
31449
|
+
params.node = preProcessVerticalMergeCells(params.node, params);
|
|
31449
31450
|
const { node } = params;
|
|
31450
|
-
const
|
|
31451
|
-
const
|
|
31452
|
-
const
|
|
31453
|
-
|
|
31454
|
-
|
|
31455
|
-
|
|
31451
|
+
const elements = translateChildNodes(params);
|
|
31452
|
+
const firstRow = node.content?.find((n) => n.type === "tableRow");
|
|
31453
|
+
const properties = node.attrs.grid;
|
|
31454
|
+
const element = translator$9.decode({
|
|
31455
|
+
...params,
|
|
31456
|
+
node: { ...node, attrs: { ...node.attrs, grid: properties } },
|
|
31457
|
+
extraParams: {
|
|
31458
|
+
firstRow
|
|
31456
31459
|
}
|
|
31457
|
-
];
|
|
31458
|
-
const exportedTag = JSON.stringify({
|
|
31459
|
-
type: "documentSection",
|
|
31460
|
-
description: attrs.description
|
|
31461
31460
|
});
|
|
31462
|
-
|
|
31463
|
-
|
|
31464
|
-
|
|
31465
|
-
|
|
31466
|
-
|
|
31467
|
-
|
|
31468
|
-
"w:val": "sdtContentLocked"
|
|
31469
|
-
}
|
|
31461
|
+
if (element) elements.unshift(element);
|
|
31462
|
+
if (node.attrs?.tableProperties) {
|
|
31463
|
+
const properties2 = { ...node.attrs.tableProperties };
|
|
31464
|
+
const element2 = translator$b.decode({
|
|
31465
|
+
...params,
|
|
31466
|
+
node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
|
|
31470
31467
|
});
|
|
31468
|
+
if (element2) elements.unshift(element2);
|
|
31471
31469
|
}
|
|
31472
|
-
nodeElements.unshift(sdtPr);
|
|
31473
|
-
const result = {
|
|
31474
|
-
name: "w:sdt",
|
|
31475
|
-
elements: nodeElements
|
|
31476
|
-
};
|
|
31477
|
-
return result;
|
|
31478
|
-
}
|
|
31479
|
-
const generateSdtPrTagForDocumentSection = (id, title, tag) => {
|
|
31480
31470
|
return {
|
|
31481
|
-
name: "w:
|
|
31482
|
-
|
|
31483
|
-
|
|
31484
|
-
name: "w:id",
|
|
31485
|
-
attributes: {
|
|
31486
|
-
"w:val": id
|
|
31487
|
-
}
|
|
31488
|
-
},
|
|
31489
|
-
{
|
|
31490
|
-
name: "w:alias",
|
|
31491
|
-
attributes: {
|
|
31492
|
-
"w:val": title
|
|
31493
|
-
}
|
|
31494
|
-
},
|
|
31495
|
-
{
|
|
31496
|
-
name: "w:tag",
|
|
31497
|
-
attributes: {
|
|
31498
|
-
"w:val": tag
|
|
31499
|
-
}
|
|
31500
|
-
}
|
|
31501
|
-
]
|
|
31471
|
+
name: "w:tbl",
|
|
31472
|
+
attributes: decodedAttrs || {},
|
|
31473
|
+
elements
|
|
31502
31474
|
};
|
|
31503
31475
|
};
|
|
31504
|
-
function
|
|
31505
|
-
const
|
|
31506
|
-
const
|
|
31507
|
-
|
|
31508
|
-
|
|
31509
|
-
|
|
31510
|
-
|
|
31511
|
-
|
|
31512
|
-
|
|
31513
|
-
|
|
31514
|
-
|
|
31515
|
-
|
|
31516
|
-
|
|
31517
|
-
|
|
31518
|
-
|
|
31519
|
-
|
|
31520
|
-
elements: [
|
|
31521
|
-
{
|
|
31522
|
-
name: "w:docPartGallery",
|
|
31523
|
-
attributes: {
|
|
31524
|
-
"w:val": attrs.docPartGallery
|
|
31525
|
-
}
|
|
31526
|
-
},
|
|
31527
|
-
...attrs.docPartUnique ? [
|
|
31528
|
-
{
|
|
31529
|
-
name: "w:docPartUnique"
|
|
31530
|
-
}
|
|
31531
|
-
] : []
|
|
31532
|
-
]
|
|
31533
|
-
}
|
|
31534
|
-
]
|
|
31535
|
-
},
|
|
31536
|
-
{
|
|
31537
|
-
name: "w:sdtContent",
|
|
31538
|
-
elements: childContent
|
|
31539
|
-
}
|
|
31540
|
-
];
|
|
31541
|
-
const result = {
|
|
31542
|
-
name: "w:sdt",
|
|
31543
|
-
elements: nodeElements
|
|
31544
|
-
};
|
|
31545
|
-
return result;
|
|
31546
|
-
}
|
|
31547
|
-
function translateStructuredContent(params) {
|
|
31548
|
-
const { node } = params;
|
|
31549
|
-
const childContent = translateChildNodes({ ...params, nodes: node.content });
|
|
31550
|
-
const sdtContent = { name: "w:sdtContent", elements: childContent };
|
|
31551
|
-
const sdtPr = generateSdtPrTagForStructuredContent({ node });
|
|
31552
|
-
const nodeElements = [sdtPr, sdtContent];
|
|
31553
|
-
const result = {
|
|
31554
|
-
name: "w:sdt",
|
|
31555
|
-
elements: nodeElements
|
|
31476
|
+
function _processTableBorders(rawBorders) {
|
|
31477
|
+
const borders = {};
|
|
31478
|
+
const rowBorders = {};
|
|
31479
|
+
Object.entries(rawBorders).forEach(([name, attributes]) => {
|
|
31480
|
+
const attrs = {};
|
|
31481
|
+
const color = attributes.color;
|
|
31482
|
+
const size = attributes.size;
|
|
31483
|
+
if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
|
|
31484
|
+
if (size && size !== "auto") attrs["size"] = eighthPointsToPixels(size);
|
|
31485
|
+
const rowBorderNames = ["insideH", "insideV"];
|
|
31486
|
+
if (rowBorderNames.includes(name)) rowBorders[name] = attrs;
|
|
31487
|
+
borders[name] = attrs;
|
|
31488
|
+
});
|
|
31489
|
+
return {
|
|
31490
|
+
borders,
|
|
31491
|
+
rowBorders
|
|
31556
31492
|
};
|
|
31557
|
-
return result;
|
|
31558
31493
|
}
|
|
31559
|
-
function
|
|
31560
|
-
|
|
31561
|
-
const
|
|
31562
|
-
|
|
31563
|
-
|
|
31564
|
-
|
|
31565
|
-
|
|
31566
|
-
const
|
|
31567
|
-
|
|
31568
|
-
|
|
31569
|
-
|
|
31570
|
-
|
|
31571
|
-
|
|
31572
|
-
|
|
31573
|
-
|
|
31574
|
-
attributes: { "w:val": attrs.tag }
|
|
31575
|
-
};
|
|
31576
|
-
const resultElements = [];
|
|
31577
|
-
if (attrs.id) resultElements.push(id);
|
|
31578
|
-
if (attrs.alias) resultElements.push(alias);
|
|
31579
|
-
if (attrs.tag) resultElements.push(tag);
|
|
31580
|
-
if (attrs.sdtPr) {
|
|
31581
|
-
const elements = attrs.sdtPr.elements || [];
|
|
31582
|
-
const elementsToExclude = ["w:id", "w:alias", "w:tag"];
|
|
31583
|
-
const restElements = elements.filter((el) => !elementsToExclude.includes(el.name));
|
|
31584
|
-
const result2 = {
|
|
31585
|
-
name: "w:sdtPr",
|
|
31586
|
-
type: "element",
|
|
31587
|
-
elements: [...resultElements, ...restElements]
|
|
31588
|
-
};
|
|
31589
|
-
return result2;
|
|
31494
|
+
function _getReferencedTableStyles(tableStyleReference, params) {
|
|
31495
|
+
if (!tableStyleReference) return null;
|
|
31496
|
+
const stylesToReturn = {};
|
|
31497
|
+
const { docx } = params;
|
|
31498
|
+
const styles = docx["word/styles.xml"];
|
|
31499
|
+
const { elements } = styles.elements[0];
|
|
31500
|
+
const styleElements = elements.filter((el) => el.name === "w:style");
|
|
31501
|
+
const styleTag = styleElements.find((el) => el.attributes["w:styleId"] === tableStyleReference);
|
|
31502
|
+
if (!styleTag) return null;
|
|
31503
|
+
stylesToReturn.name = styleTag.elements.find((el) => el.name === "w:name");
|
|
31504
|
+
const basedOn = styleTag.elements.find((el) => el.name === "w:basedOn");
|
|
31505
|
+
let baseTblPr;
|
|
31506
|
+
if (basedOn?.attributes) {
|
|
31507
|
+
const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
|
|
31508
|
+
baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
|
|
31590
31509
|
}
|
|
31591
|
-
const
|
|
31592
|
-
|
|
31593
|
-
|
|
31594
|
-
|
|
31595
|
-
};
|
|
31596
|
-
return result;
|
|
31597
|
-
}
|
|
31598
|
-
const XML_NODE_NAME$9 = "w:sdt";
|
|
31599
|
-
const SD_NODE_NAME$7 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
|
|
31600
|
-
const validXmlAttributes$6 = [];
|
|
31601
|
-
function encode$f(params) {
|
|
31602
|
-
const nodes = params.nodes;
|
|
31603
|
-
const node = nodes[0];
|
|
31604
|
-
const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
|
|
31605
|
-
if (!handler2 || sdtType === "unknown") {
|
|
31606
|
-
return void 0;
|
|
31510
|
+
const pPr = styleTag.elements.find((el) => el.name === "w:pPr");
|
|
31511
|
+
if (pPr) {
|
|
31512
|
+
const justification = pPr.elements.find((el) => el.name === "w:jc");
|
|
31513
|
+
if (justification?.attributes) stylesToReturn.justification = justification.attributes["w:val"];
|
|
31607
31514
|
}
|
|
31608
|
-
const
|
|
31609
|
-
|
|
31610
|
-
|
|
31611
|
-
|
|
31612
|
-
|
|
31613
|
-
|
|
31614
|
-
|
|
31515
|
+
const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
|
|
31516
|
+
if (rPr) {
|
|
31517
|
+
const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
|
|
31518
|
+
if (fonts) {
|
|
31519
|
+
const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
|
|
31520
|
+
stylesToReturn.fonts = { ascii, hAnsi, cs };
|
|
31521
|
+
}
|
|
31522
|
+
const fontSize = rPr.elements.find((el) => el.name === "w:sz");
|
|
31523
|
+
if (fontSize?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize.attributes["w:val"]) + "pt";
|
|
31615
31524
|
}
|
|
31616
|
-
const
|
|
31617
|
-
|
|
31618
|
-
|
|
31619
|
-
|
|
31620
|
-
|
|
31621
|
-
|
|
31622
|
-
|
|
31623
|
-
|
|
31624
|
-
|
|
31625
|
-
|
|
31626
|
-
|
|
31627
|
-
|
|
31525
|
+
const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
|
|
31526
|
+
if (tblPr && tblPr.elements) {
|
|
31527
|
+
if (baseTblPr && baseTblPr.elements) {
|
|
31528
|
+
tblPr.elements.push(...baseTblPr.elements);
|
|
31529
|
+
}
|
|
31530
|
+
const tableProperties = translator$b.encode({ ...params, nodes: [tblPr] });
|
|
31531
|
+
if (tableProperties) {
|
|
31532
|
+
const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
|
|
31533
|
+
if (borders) stylesToReturn.borders = borders;
|
|
31534
|
+
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
31535
|
+
const cellMargins = {};
|
|
31536
|
+
Object.entries(tableProperties.cellMargins || {}).forEach(([key, attrs]) => {
|
|
31537
|
+
if (attrs?.value != null) {
|
|
31538
|
+
cellMargins[key] = {
|
|
31539
|
+
value: attrs.value,
|
|
31540
|
+
type: attrs.type || "dxa"
|
|
31541
|
+
};
|
|
31542
|
+
}
|
|
31543
|
+
});
|
|
31544
|
+
if (Object.keys(cellMargins).length) stylesToReturn.cellMargins = cellMargins;
|
|
31545
|
+
}
|
|
31546
|
+
}
|
|
31547
|
+
return stylesToReturn;
|
|
31628
31548
|
}
|
|
31629
31549
|
const config$8 = {
|
|
31630
31550
|
xmlName: XML_NODE_NAME$9,
|
|
@@ -31632,7 +31552,7 @@ const config$8 = {
|
|
|
31632
31552
|
type: NodeTranslator.translatorTypes.NODE,
|
|
31633
31553
|
encode: encode$f,
|
|
31634
31554
|
decode: decode$h,
|
|
31635
|
-
attributes:
|
|
31555
|
+
attributes: []
|
|
31636
31556
|
};
|
|
31637
31557
|
const translator$8 = NodeTranslator.from(config$8);
|
|
31638
31558
|
const encode$e = (attributes) => {
|
|
@@ -32147,7 +32067,7 @@ const handleDrawingNode = (params) => {
|
|
|
32147
32067
|
if (mainNode.name === "w:drawing") node = mainNode;
|
|
32148
32068
|
else node = mainNode.elements.find((el) => el.name === "w:drawing");
|
|
32149
32069
|
if (!node) return { nodes: [], consumed: 0 };
|
|
32150
|
-
const schemaNode = translator$
|
|
32070
|
+
const schemaNode = translator$r.encode(params);
|
|
32151
32071
|
const newNodes = schemaNode ? [schemaNode] : [];
|
|
32152
32072
|
return { nodes: newNodes, consumed: 1 };
|
|
32153
32073
|
};
|
|
@@ -32456,7 +32376,7 @@ const handleSdtNode = (params) => {
|
|
|
32456
32376
|
if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
|
|
32457
32377
|
return { nodes: [], consumed: 0 };
|
|
32458
32378
|
}
|
|
32459
|
-
const result = translator$
|
|
32379
|
+
const result = translator$q.encode(params);
|
|
32460
32380
|
if (!result) {
|
|
32461
32381
|
return { nodes: [], consumed: 0 };
|
|
32462
32382
|
}
|
|
@@ -33250,6 +33170,7 @@ const tabNodeEntityHandler = {
|
|
|
33250
33170
|
handlerName: "w:tabTranslator",
|
|
33251
33171
|
handler: handleTabNode
|
|
33252
33172
|
};
|
|
33173
|
+
const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$8);
|
|
33253
33174
|
const tableOfContentsHandlerEntity = generateV2HandlerEntity("tableOfContentsHandler", translator$4);
|
|
33254
33175
|
function preProcessPageInstruction(nodesToCombine) {
|
|
33255
33176
|
const pageNumNode = {
|
|
@@ -34259,14 +34180,14 @@ function exportSchemaToJson(params) {
|
|
|
34259
34180
|
bulletList: translateList,
|
|
34260
34181
|
orderedList: translateList,
|
|
34261
34182
|
lineBreak: translator$1r,
|
|
34262
|
-
table: translator$
|
|
34263
|
-
tableRow: translator$
|
|
34264
|
-
tableCell: translator$
|
|
34183
|
+
table: translator$8,
|
|
34184
|
+
tableRow: translator$u,
|
|
34185
|
+
tableCell: translator$H,
|
|
34265
34186
|
bookmarkStart: translator$7,
|
|
34266
34187
|
bookmarkEnd: translator$6,
|
|
34267
|
-
fieldAnnotation: translator$
|
|
34188
|
+
fieldAnnotation: translator$q,
|
|
34268
34189
|
tab: translator$1p,
|
|
34269
|
-
image: translator$
|
|
34190
|
+
image: translator$r,
|
|
34270
34191
|
hardBreak: translator$1r,
|
|
34271
34192
|
commentRangeStart: commentRangeStartTranslator,
|
|
34272
34193
|
commentRangeEnd: commentRangeEndTranslator,
|
|
@@ -34275,10 +34196,10 @@ function exportSchemaToJson(params) {
|
|
|
34275
34196
|
shapeTextbox: translator,
|
|
34276
34197
|
contentBlock: translator,
|
|
34277
34198
|
vectorShape: translateVectorShape,
|
|
34278
|
-
structuredContent: translator$
|
|
34279
|
-
structuredContentBlock: translator$
|
|
34280
|
-
documentPartObject: translator$
|
|
34281
|
-
documentSection: translator$
|
|
34199
|
+
structuredContent: translator$q,
|
|
34200
|
+
structuredContentBlock: translator$q,
|
|
34201
|
+
documentPartObject: translator$q,
|
|
34202
|
+
documentSection: translator$q,
|
|
34282
34203
|
"page-number": translatePageNumberNode,
|
|
34283
34204
|
"total-page-number": translateTotalPageNumberNode,
|
|
34284
34205
|
pageReference: translator$5,
|
|
@@ -36114,7 +36035,7 @@ export {
|
|
|
36114
36035
|
objectIncludes as Z,
|
|
36115
36036
|
AddMarkStep as _,
|
|
36116
36037
|
Plugin as a,
|
|
36117
|
-
translator$
|
|
36038
|
+
translator$t as a$,
|
|
36118
36039
|
twipsToLines as a0,
|
|
36119
36040
|
pixelsToTwips as a1,
|
|
36120
36041
|
helpers as a2,
|
|
@@ -36134,24 +36055,24 @@ export {
|
|
|
36134
36055
|
handleClipboardPaste as aG,
|
|
36135
36056
|
getFileObject as aH,
|
|
36136
36057
|
runPropertyTranslators as aI,
|
|
36137
|
-
translator$
|
|
36138
|
-
translator$
|
|
36139
|
-
translator$
|
|
36140
|
-
translator$
|
|
36141
|
-
translator$
|
|
36142
|
-
translator$
|
|
36143
|
-
translator$
|
|
36144
|
-
translator$
|
|
36145
|
-
translator$
|
|
36146
|
-
translator$
|
|
36147
|
-
translator$
|
|
36148
|
-
translator$
|
|
36149
|
-
translator$
|
|
36150
|
-
translator$
|
|
36151
|
-
translator$
|
|
36058
|
+
translator$I as aJ,
|
|
36059
|
+
translator$P as aK,
|
|
36060
|
+
translator$R as aL,
|
|
36061
|
+
translator$J as aM,
|
|
36062
|
+
translator$K as aN,
|
|
36063
|
+
translator$S as aO,
|
|
36064
|
+
translator$T as aP,
|
|
36065
|
+
translator$O as aQ,
|
|
36066
|
+
translator$L as aR,
|
|
36067
|
+
translator$18 as aS,
|
|
36068
|
+
translator$N as aT,
|
|
36069
|
+
translator$Q as aU,
|
|
36070
|
+
translator$M as aV,
|
|
36071
|
+
translator$17 as aW,
|
|
36072
|
+
translator$16 as aX,
|
|
36152
36073
|
commentRangeEndTranslator as aY,
|
|
36153
36074
|
commentRangeStartTranslator as aZ,
|
|
36154
|
-
translator$
|
|
36075
|
+
translator$s as a_,
|
|
36155
36076
|
hasSomeParentWithClass as aa,
|
|
36156
36077
|
isActive as ab,
|
|
36157
36078
|
unflattenListsInHtml as ac,
|
|
@@ -36180,67 +36101,67 @@ export {
|
|
|
36180
36101
|
commonjsGlobal as az,
|
|
36181
36102
|
Slice as b,
|
|
36182
36103
|
translator$5 as b$,
|
|
36183
|
-
translator
|
|
36184
|
-
translator$
|
|
36104
|
+
translator$w as b0,
|
|
36105
|
+
translator$x as b1,
|
|
36185
36106
|
translator$1l as b2,
|
|
36186
|
-
translator$
|
|
36187
|
-
translator$
|
|
36188
|
-
translator$
|
|
36189
|
-
translator$
|
|
36190
|
-
translator$
|
|
36191
|
-
translator$
|
|
36192
|
-
translator$
|
|
36107
|
+
translator$v as b3,
|
|
36108
|
+
translator$y as b4,
|
|
36109
|
+
translator$u as b5,
|
|
36110
|
+
translator$V as b6,
|
|
36111
|
+
translator$H as b7,
|
|
36112
|
+
translator$e as b8,
|
|
36113
|
+
translator$f as b9,
|
|
36193
36114
|
translator$1i as bA,
|
|
36194
36115
|
translator$1b as bB,
|
|
36195
36116
|
translator$1o as bC,
|
|
36196
|
-
translator
|
|
36197
|
-
translator$
|
|
36198
|
-
translator$
|
|
36199
|
-
translator$
|
|
36117
|
+
translator$$ as bD,
|
|
36118
|
+
translator$B as bE,
|
|
36119
|
+
translator$10 as bF,
|
|
36120
|
+
translator$11 as bG,
|
|
36200
36121
|
translator$1m as bH,
|
|
36201
36122
|
translator$1c as bI,
|
|
36202
36123
|
translator$1q as bJ,
|
|
36203
|
-
translator$
|
|
36204
|
-
translator$
|
|
36205
|
-
translator$
|
|
36206
|
-
translator$
|
|
36207
|
-
translator$
|
|
36208
|
-
translator$
|
|
36209
|
-
translator$
|
|
36124
|
+
translator$C as bK,
|
|
36125
|
+
translator$a as bL,
|
|
36126
|
+
translator$D as bM,
|
|
36127
|
+
translator$E as bN,
|
|
36128
|
+
translator$13 as bO,
|
|
36129
|
+
translator$r as bP,
|
|
36130
|
+
translator$F as bQ,
|
|
36210
36131
|
translator$1j as bR,
|
|
36211
|
-
translator$
|
|
36212
|
-
translator$
|
|
36132
|
+
translator$1a as bS,
|
|
36133
|
+
translator$G as bT,
|
|
36213
36134
|
translator$1r as bU,
|
|
36214
|
-
translator$
|
|
36135
|
+
translator$15 as bV,
|
|
36215
36136
|
translator$7 as bW,
|
|
36216
36137
|
translator$6 as bX,
|
|
36217
|
-
translator$
|
|
36138
|
+
translator$p as bY,
|
|
36218
36139
|
translator$1n as bZ,
|
|
36219
36140
|
translator$4 as b_,
|
|
36220
|
-
translator$
|
|
36221
|
-
translator$
|
|
36222
|
-
translator$
|
|
36223
|
-
translator$
|
|
36224
|
-
translator$
|
|
36225
|
-
translator$
|
|
36226
|
-
translator$
|
|
36227
|
-
translator$
|
|
36228
|
-
translator$
|
|
36229
|
-
translator$
|
|
36230
|
-
translator$
|
|
36231
|
-
translator$
|
|
36232
|
-
translator$
|
|
36233
|
-
translator$
|
|
36234
|
-
translator$
|
|
36235
|
-
translator$
|
|
36141
|
+
translator$g as ba,
|
|
36142
|
+
translator$h as bb,
|
|
36143
|
+
translator$i as bc,
|
|
36144
|
+
translator$b as bd,
|
|
36145
|
+
translator$j as be,
|
|
36146
|
+
translator$k as bf,
|
|
36147
|
+
translator$l as bg,
|
|
36148
|
+
translator$m as bh,
|
|
36149
|
+
translator$z as bi,
|
|
36150
|
+
translator$9 as bj,
|
|
36151
|
+
translator$n as bk,
|
|
36152
|
+
translator$A as bl,
|
|
36153
|
+
translator$c as bm,
|
|
36154
|
+
translator$o as bn,
|
|
36155
|
+
translator$d as bo,
|
|
36156
|
+
translator$8 as bp,
|
|
36236
36157
|
translator$1p as bq,
|
|
36237
36158
|
translator$1f as br,
|
|
36238
36159
|
translator$1g as bs,
|
|
36239
36160
|
translator$1k as bt,
|
|
36240
|
-
translator$
|
|
36241
|
-
translator$
|
|
36242
|
-
translator$
|
|
36243
|
-
translator$
|
|
36161
|
+
translator$X as bu,
|
|
36162
|
+
translator$19 as bv,
|
|
36163
|
+
translator$q as bw,
|
|
36164
|
+
translator$Z as bx,
|
|
36244
36165
|
translator$1h as by,
|
|
36245
36166
|
translator$1d as bz,
|
|
36246
36167
|
DOMParser$1 as c,
|