@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
|
@@ -27007,53 +27007,7 @@ const config$h = {
|
|
|
27007
27007
|
attributes: validXmlAttributes$c
|
|
27008
27008
|
};
|
|
27009
27009
|
const translator$1b = NodeTranslator.from(config$h);
|
|
27010
|
-
function preProcessVerticalMergeCells(table, { editorSchema }) {
|
|
27011
|
-
if (!table || !Array.isArray(table.content)) {
|
|
27012
|
-
return table;
|
|
27013
|
-
}
|
|
27014
|
-
const rows = table.content;
|
|
27015
|
-
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
27016
|
-
const row = rows[rowIndex];
|
|
27017
|
-
if (!row) continue;
|
|
27018
|
-
if (!Array.isArray(row.content)) {
|
|
27019
|
-
row.content = [];
|
|
27020
|
-
}
|
|
27021
|
-
for (let cellIndex = 0; cellIndex < row.content.length; cellIndex++) {
|
|
27022
|
-
const cell = row.content[cellIndex];
|
|
27023
|
-
if (!cell) continue;
|
|
27024
|
-
const attrs = cell.attrs || {};
|
|
27025
|
-
if (!attrs.rowspan || attrs.rowspan <= 1) continue;
|
|
27026
|
-
const maxRowspan = Math.min(attrs.rowspan, rows.length - rowIndex);
|
|
27027
|
-
for (let offset2 = 1; offset2 < maxRowspan; offset2++) {
|
|
27028
|
-
const rowToChange = rows[rowIndex + offset2];
|
|
27029
|
-
if (!rowToChange) continue;
|
|
27030
|
-
if (!Array.isArray(rowToChange.content)) {
|
|
27031
|
-
rowToChange.content = [];
|
|
27032
|
-
}
|
|
27033
|
-
const existingCell = rowToChange.content[cellIndex];
|
|
27034
|
-
if (existingCell?.attrs?.continueMerge) continue;
|
|
27035
|
-
const mergedCell = {
|
|
27036
|
-
type: cell.type,
|
|
27037
|
-
content: [editorSchema.nodes.paragraph.createAndFill().toJSON()],
|
|
27038
|
-
attrs: {
|
|
27039
|
-
...cell.attrs,
|
|
27040
|
-
rowspan: null,
|
|
27041
|
-
continueMerge: true
|
|
27042
|
-
}
|
|
27043
|
-
};
|
|
27044
|
-
rowToChange.content.splice(cellIndex, 0, mergedCell);
|
|
27045
|
-
}
|
|
27046
|
-
}
|
|
27047
|
-
}
|
|
27048
|
-
return table;
|
|
27049
|
-
}
|
|
27050
27010
|
const translator$1a = NodeTranslator.from({
|
|
27051
|
-
xmlName: "w:cantSplit",
|
|
27052
|
-
sdNodeOrKeyName: "cantSplit",
|
|
27053
|
-
encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27054
|
-
decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
|
|
27055
|
-
});
|
|
27056
|
-
const translator$19 = NodeTranslator.from({
|
|
27057
27011
|
xmlName: "w:cnfStyle",
|
|
27058
27012
|
sdNodeOrKeyName: "cnfStyle",
|
|
27059
27013
|
attributes: [
|
|
@@ -27079,1329 +27033,426 @@ const translator$19 = NodeTranslator.from({
|
|
|
27079
27033
|
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
27080
27034
|
}
|
|
27081
27035
|
});
|
|
27082
|
-
const translator$
|
|
27036
|
+
const translator$19 = NodeTranslator.from({
|
|
27037
|
+
xmlName: "w:shd",
|
|
27038
|
+
sdNodeOrKeyName: "shading",
|
|
27039
|
+
attributes: [
|
|
27040
|
+
"w:color",
|
|
27041
|
+
"w:fill",
|
|
27042
|
+
"w:themeColor",
|
|
27043
|
+
"w:themeFill",
|
|
27044
|
+
"w:themeFillShade",
|
|
27045
|
+
"w:themeFillTint",
|
|
27046
|
+
"w:themeShade",
|
|
27047
|
+
"w:themeTint",
|
|
27048
|
+
"w:val"
|
|
27049
|
+
].map((attr) => createAttributeHandler(attr)),
|
|
27050
|
+
encode: (params2, encodedAttrs) => {
|
|
27051
|
+
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
27052
|
+
},
|
|
27053
|
+
decode: function({ node }, context) {
|
|
27054
|
+
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.shading || {} } });
|
|
27055
|
+
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
27056
|
+
}
|
|
27057
|
+
});
|
|
27058
|
+
const translator$18 = NodeTranslator.from(createMeasurementPropertyHandler("w:tcW", "cellWidth"));
|
|
27083
27059
|
const translator$17 = NodeTranslator.from(
|
|
27084
27060
|
createSingleAttrPropertyHandler(
|
|
27085
|
-
"w:
|
|
27061
|
+
"w:gridSpan",
|
|
27086
27062
|
null,
|
|
27087
27063
|
"w:val",
|
|
27088
27064
|
(v2) => parseInteger(v2) ?? void 0,
|
|
27089
27065
|
(v2) => integerToString(v2)
|
|
27090
27066
|
)
|
|
27091
27067
|
);
|
|
27092
|
-
const translator$16 = NodeTranslator.from(
|
|
27068
|
+
const translator$16 = NodeTranslator.from(createSingleAttrPropertyHandler("w:vMerge"));
|
|
27069
|
+
const translator$15 = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
|
|
27070
|
+
const translator$14 = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
|
|
27071
|
+
const translator$13 = NodeTranslator.from(createBorderPropertyHandler("w:end"));
|
|
27072
|
+
const translator$12 = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
|
|
27073
|
+
const translator$11 = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
|
|
27074
|
+
const translator$10 = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
|
|
27075
|
+
const translator$$ = NodeTranslator.from(createBorderPropertyHandler("w:left"));
|
|
27076
|
+
const translator$_ = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
|
|
27077
|
+
const translator$Z = NodeTranslator.from(createBorderPropertyHandler("w:right"));
|
|
27078
|
+
const translator$Y = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
|
|
27079
|
+
const translator$X = NodeTranslator.from(createBorderPropertyHandler("w:start"));
|
|
27080
|
+
const translator$W = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
|
|
27081
|
+
const translator$V = NodeTranslator.from(createBorderPropertyHandler("w:top"));
|
|
27082
|
+
const translator$U = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
|
|
27083
|
+
const translator$T = NodeTranslator.from(createBorderPropertyHandler("w:tl2br"));
|
|
27084
|
+
const translator$S = NodeTranslator.from(createBorderPropertyHandler("w:tr2bl"));
|
|
27085
|
+
const propertyTranslators$6 = [
|
|
27086
|
+
translator$V,
|
|
27087
|
+
translator$X,
|
|
27088
|
+
translator$$,
|
|
27089
|
+
translator$15,
|
|
27090
|
+
translator$13,
|
|
27091
|
+
translator$Z,
|
|
27092
|
+
translator$11,
|
|
27093
|
+
translator$10,
|
|
27094
|
+
translator$T,
|
|
27095
|
+
translator$S
|
|
27096
|
+
];
|
|
27097
|
+
const translator$R = NodeTranslator.from(
|
|
27098
|
+
createNestedPropertiesTranslator("w:tcBorders", "borders", propertyTranslators$6)
|
|
27099
|
+
);
|
|
27100
|
+
const translator$Q = NodeTranslator.from(
|
|
27093
27101
|
createSingleAttrPropertyHandler(
|
|
27094
|
-
"w:
|
|
27102
|
+
"w:noWrap",
|
|
27095
27103
|
null,
|
|
27096
27104
|
"w:val",
|
|
27097
|
-
(v2) =>
|
|
27098
|
-
(v2) =>
|
|
27105
|
+
(v2) => parseBoolean(v2 ?? "true"),
|
|
27106
|
+
(v2) => booleanToString(v2)
|
|
27099
27107
|
)
|
|
27100
27108
|
);
|
|
27101
|
-
const
|
|
27102
|
-
xmlName: "w:hidden",
|
|
27103
|
-
sdNodeOrKeyName: "hidden",
|
|
27104
|
-
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27105
|
-
decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
|
|
27106
|
-
});
|
|
27107
|
-
const translator$14 = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
|
|
27108
|
-
const translator$13 = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
|
|
27109
|
-
const translator$12 = NodeTranslator.from({
|
|
27110
|
-
xmlName: "w:tblHeader",
|
|
27111
|
-
sdNodeOrKeyName: "repeatHeader",
|
|
27112
|
-
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27113
|
-
decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
|
|
27114
|
-
});
|
|
27115
|
-
const translator$11 = NodeTranslator.from({
|
|
27116
|
-
xmlName: "w:trHeight",
|
|
27117
|
-
sdNodeOrKeyName: "rowHeight",
|
|
27118
|
-
encode: ({ nodes }) => {
|
|
27119
|
-
const heightAttrs = {};
|
|
27120
|
-
const val = nodes[0].attributes["w:val"];
|
|
27121
|
-
if (val) {
|
|
27122
|
-
heightAttrs["value"] = parseInt(val, 10);
|
|
27123
|
-
}
|
|
27124
|
-
const rule = nodes[0].attributes["w:hRule"];
|
|
27125
|
-
if (rule) {
|
|
27126
|
-
heightAttrs["rule"] = rule;
|
|
27127
|
-
}
|
|
27128
|
-
return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
|
|
27129
|
-
},
|
|
27130
|
-
decode: ({ node }) => {
|
|
27131
|
-
if (!node.attrs?.rowHeight) return;
|
|
27132
|
-
const heightAttrs = {};
|
|
27133
|
-
if (typeof node.attrs.rowHeight.value === "number" && !isNaN(node.attrs.rowHeight.value)) {
|
|
27134
|
-
heightAttrs["w:val"] = String(node.attrs.rowHeight.value);
|
|
27135
|
-
}
|
|
27136
|
-
if (node.attrs.rowHeight.rule) {
|
|
27137
|
-
heightAttrs["w:hRule"] = node.attrs.rowHeight.rule;
|
|
27138
|
-
}
|
|
27139
|
-
return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
|
|
27140
|
-
}
|
|
27141
|
-
});
|
|
27142
|
-
const translator$10 = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
|
|
27143
|
-
const translator$$ = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
|
|
27144
|
-
const propertyTranslators$6 = [
|
|
27145
|
-
translator$1a,
|
|
27146
|
-
translator$19,
|
|
27147
|
-
translator$18,
|
|
27148
|
-
translator$17,
|
|
27149
|
-
translator$16,
|
|
27150
|
-
translator$15,
|
|
27109
|
+
const propertyTranslators$5 = [
|
|
27151
27110
|
translator$14,
|
|
27152
|
-
translator$13,
|
|
27153
27111
|
translator$12,
|
|
27154
|
-
translator$
|
|
27155
|
-
translator$
|
|
27156
|
-
translator
|
|
27112
|
+
translator$_,
|
|
27113
|
+
translator$Y,
|
|
27114
|
+
translator$W,
|
|
27115
|
+
translator$U
|
|
27157
27116
|
];
|
|
27158
|
-
const translator$
|
|
27159
|
-
createNestedPropertiesTranslator("w:
|
|
27160
|
-
cantSplit: false,
|
|
27161
|
-
hidden: false,
|
|
27162
|
-
repeatHeader: false
|
|
27163
|
-
})
|
|
27117
|
+
const translator$P = NodeTranslator.from(
|
|
27118
|
+
createNestedPropertiesTranslator("w:tcMar", "cellMargins", propertyTranslators$5)
|
|
27164
27119
|
);
|
|
27165
|
-
const
|
|
27166
|
-
|
|
27167
|
-
|
|
27120
|
+
const translator$O = NodeTranslator.from(createSingleAttrPropertyHandler("w:textDirection"));
|
|
27121
|
+
const translator$N = NodeTranslator.from(
|
|
27122
|
+
createSingleAttrPropertyHandler(
|
|
27123
|
+
"w:tcFitText",
|
|
27124
|
+
null,
|
|
27125
|
+
"w:val",
|
|
27126
|
+
(v2) => parseBoolean(v2 ?? "true"),
|
|
27127
|
+
(v2) => booleanToString(v2)
|
|
27128
|
+
)
|
|
27129
|
+
);
|
|
27130
|
+
const translator$M = NodeTranslator.from(createSingleAttrPropertyHandler("w:vAlign"));
|
|
27131
|
+
const translator$L = NodeTranslator.from(
|
|
27132
|
+
createSingleAttrPropertyHandler(
|
|
27133
|
+
"w:hideMark",
|
|
27134
|
+
null,
|
|
27135
|
+
"w:val",
|
|
27136
|
+
(v2) => parseBoolean(v2 ?? "true"),
|
|
27137
|
+
(v2) => booleanToString(v2)
|
|
27138
|
+
)
|
|
27139
|
+
);
|
|
27140
|
+
const translator$K = NodeTranslator.from(createSingleAttrPropertyHandler("w:header"));
|
|
27141
|
+
const XML_NODE_NAME$h = "w:headers";
|
|
27142
|
+
const SD_ATTR_KEY$3 = "headers";
|
|
27143
|
+
const encode$n = (params2) => {
|
|
27144
|
+
const { nodes } = params2;
|
|
27145
|
+
const node = nodes[0];
|
|
27146
|
+
const attributes = encodeProperties(node, { [translator$K.xmlName]: translator$K }, true);
|
|
27168
27147
|
return {
|
|
27169
|
-
|
|
27170
|
-
|
|
27171
|
-
|
|
27172
|
-
rowspan: 1,
|
|
27173
|
-
colwidth: [safeWidth],
|
|
27174
|
-
__placeholder: reason,
|
|
27175
|
-
borders: {
|
|
27176
|
-
top: { ...noBorder },
|
|
27177
|
-
right: { ...noBorder },
|
|
27178
|
-
bottom: { ...noBorder },
|
|
27179
|
-
left: { ...noBorder }
|
|
27180
|
-
}
|
|
27181
|
-
},
|
|
27182
|
-
content: [{ type: "paragraph", content: [] }]
|
|
27148
|
+
xmlName: XML_NODE_NAME$h,
|
|
27149
|
+
sdNodeOrKeyName: SD_ATTR_KEY$3,
|
|
27150
|
+
attributes
|
|
27183
27151
|
};
|
|
27184
27152
|
};
|
|
27185
|
-
const
|
|
27186
|
-
|
|
27187
|
-
while (index2 < totalColumns && pendingRowSpans[index2] > 0) {
|
|
27188
|
-
pendingRowSpans[index2] -= 1;
|
|
27189
|
-
index2 += 1;
|
|
27190
|
-
}
|
|
27191
|
-
return index2;
|
|
27192
|
-
};
|
|
27193
|
-
const fillPlaceholderColumns = ({
|
|
27194
|
-
content,
|
|
27195
|
-
pendingRowSpans,
|
|
27196
|
-
currentIndex,
|
|
27197
|
-
targetIndex,
|
|
27198
|
-
totalColumns,
|
|
27199
|
-
gridColumnWidths,
|
|
27200
|
-
reason
|
|
27201
|
-
}) => {
|
|
27202
|
-
let index2 = currentIndex;
|
|
27203
|
-
while (index2 < targetIndex && index2 < totalColumns) {
|
|
27204
|
-
if (pendingRowSpans[index2] > 0) {
|
|
27205
|
-
pendingRowSpans[index2] -= 1;
|
|
27206
|
-
index2 += 1;
|
|
27207
|
-
continue;
|
|
27208
|
-
}
|
|
27209
|
-
const width = Array.isArray(gridColumnWidths) ? gridColumnWidths[index2] ?? 0 : 0;
|
|
27210
|
-
content.push(createPlaceholderCell(width, reason));
|
|
27211
|
-
index2 += 1;
|
|
27212
|
-
}
|
|
27213
|
-
return index2;
|
|
27214
|
-
};
|
|
27215
|
-
const isPlaceholderCell = (cell) => {
|
|
27216
|
-
if (!cell) return false;
|
|
27217
|
-
if (cell.attrs?.__placeholder) return true;
|
|
27218
|
-
const widths = cell.attrs?.colwidth;
|
|
27219
|
-
if (Array.isArray(widths) && widths.length > 0) {
|
|
27220
|
-
const hasMeaningfulWidth = widths.some(
|
|
27221
|
-
(value) => typeof value === "number" && Number.isFinite(value) && Math.abs(value) > 1
|
|
27222
|
-
);
|
|
27223
|
-
if (!hasMeaningfulWidth) return true;
|
|
27224
|
-
}
|
|
27225
|
-
return false;
|
|
27226
|
-
};
|
|
27227
|
-
const XML_NODE_NAME$h = "w:tr";
|
|
27228
|
-
const SD_NODE_NAME$d = "tableRow";
|
|
27229
|
-
const validXmlAttributes$b = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
|
|
27230
|
-
(xmlName) => createAttributeHandler(xmlName)
|
|
27231
|
-
);
|
|
27232
|
-
const encode$n = (params2, encodedAttrs) => {
|
|
27233
|
-
const { row } = params2.extraParams;
|
|
27234
|
-
let tableRowProperties = {};
|
|
27235
|
-
const tPr = row.elements.find((el) => el.name === "w:trPr");
|
|
27236
|
-
if (tPr) {
|
|
27237
|
-
tableRowProperties = translator$_.encode({
|
|
27238
|
-
...params2,
|
|
27239
|
-
nodes: [tPr]
|
|
27240
|
-
});
|
|
27241
|
-
}
|
|
27242
|
-
const gridBeforeRaw = tableRowProperties?.["gridBefore"];
|
|
27243
|
-
const safeGridBefore = typeof gridBeforeRaw === "number" && Number.isFinite(gridBeforeRaw) && gridBeforeRaw > 0 ? gridBeforeRaw : 0;
|
|
27244
|
-
encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
|
|
27245
|
-
encodedAttrs["rowHeight"] = twipsToPixels(tableRowProperties["rowHeight"]?.value);
|
|
27246
|
-
encodedAttrs["cantSplit"] = tableRowProperties["cantSplit"];
|
|
27247
|
-
const { columnWidths: gridColumnWidths, activeRowSpans = [] } = params2.extraParams;
|
|
27248
|
-
const totalColumns = Array.isArray(gridColumnWidths) ? gridColumnWidths.length : 0;
|
|
27249
|
-
const pendingRowSpans = Array.isArray(activeRowSpans) ? activeRowSpans.slice() : [];
|
|
27250
|
-
while (pendingRowSpans.length < totalColumns) pendingRowSpans.push(0);
|
|
27251
|
-
const cellNodes = row.elements.filter((el) => el.name === "w:tc");
|
|
27252
|
-
const content = [];
|
|
27253
|
-
let currentColumnIndex = 0;
|
|
27254
|
-
const fillUntil = (target, reason) => {
|
|
27255
|
-
currentColumnIndex = fillPlaceholderColumns({
|
|
27256
|
-
content,
|
|
27257
|
-
pendingRowSpans,
|
|
27258
|
-
currentIndex: currentColumnIndex,
|
|
27259
|
-
targetIndex: target,
|
|
27260
|
-
totalColumns,
|
|
27261
|
-
gridColumnWidths,
|
|
27262
|
-
reason
|
|
27263
|
-
});
|
|
27264
|
-
};
|
|
27265
|
-
const skipOccupiedColumns = () => {
|
|
27266
|
-
currentColumnIndex = advancePastRowSpans(pendingRowSpans, currentColumnIndex, totalColumns);
|
|
27267
|
-
};
|
|
27268
|
-
fillUntil(safeGridBefore, "gridBefore");
|
|
27269
|
-
skipOccupiedColumns();
|
|
27270
|
-
cellNodes?.forEach((node) => {
|
|
27271
|
-
skipOccupiedColumns();
|
|
27272
|
-
const startColumn = currentColumnIndex;
|
|
27273
|
-
const columnWidth = gridColumnWidths?.[startColumn] || null;
|
|
27274
|
-
const result = translator$c.encode({
|
|
27275
|
-
...params2,
|
|
27276
|
-
extraParams: {
|
|
27277
|
-
...params2.extraParams,
|
|
27278
|
-
node,
|
|
27279
|
-
columnIndex: startColumn,
|
|
27280
|
-
columnWidth
|
|
27281
|
-
}
|
|
27282
|
-
});
|
|
27283
|
-
if (result) {
|
|
27284
|
-
content.push(result);
|
|
27285
|
-
const colspan = Math.max(1, result.attrs?.colspan || 1);
|
|
27286
|
-
const rowspan = Math.max(1, result.attrs?.rowspan || 1);
|
|
27287
|
-
if (rowspan > 1) {
|
|
27288
|
-
for (let offset2 = 0; offset2 < colspan; offset2 += 1) {
|
|
27289
|
-
const target = startColumn + offset2;
|
|
27290
|
-
if (target < pendingRowSpans.length) {
|
|
27291
|
-
pendingRowSpans[target] = Math.max(pendingRowSpans[target], rowspan - 1);
|
|
27292
|
-
}
|
|
27293
|
-
}
|
|
27294
|
-
}
|
|
27295
|
-
currentColumnIndex = startColumn + colspan;
|
|
27296
|
-
}
|
|
27297
|
-
});
|
|
27298
|
-
skipOccupiedColumns();
|
|
27299
|
-
fillUntil(totalColumns, "gridAfter");
|
|
27153
|
+
const decode$p = (params2) => {
|
|
27154
|
+
const { headers = [] } = params2.node.attrs || {};
|
|
27300
27155
|
const newNode = {
|
|
27301
|
-
|
|
27302
|
-
|
|
27303
|
-
|
|
27156
|
+
name: XML_NODE_NAME$h,
|
|
27157
|
+
attributes: {},
|
|
27158
|
+
elements: headers.map(
|
|
27159
|
+
(header) => translator$K.decode({
|
|
27160
|
+
node: { type: "header", attrs: header }
|
|
27161
|
+
})
|
|
27162
|
+
)
|
|
27304
27163
|
};
|
|
27305
27164
|
return newNode;
|
|
27306
27165
|
};
|
|
27307
|
-
const decode$p = (params2, decodedAttrs) => {
|
|
27308
|
-
const { node } = params2;
|
|
27309
|
-
const cells = node.content || [];
|
|
27310
|
-
let leadingPlaceholders = 0;
|
|
27311
|
-
while (leadingPlaceholders < cells.length && isPlaceholderCell(cells[leadingPlaceholders])) {
|
|
27312
|
-
leadingPlaceholders += 1;
|
|
27313
|
-
}
|
|
27314
|
-
let trailingPlaceholders = 0;
|
|
27315
|
-
while (trailingPlaceholders < cells.length - leadingPlaceholders && isPlaceholderCell(cells[cells.length - 1 - trailingPlaceholders])) {
|
|
27316
|
-
trailingPlaceholders += 1;
|
|
27317
|
-
}
|
|
27318
|
-
const trimmedSlice = cells.slice(leadingPlaceholders, cells.length - trailingPlaceholders);
|
|
27319
|
-
const sanitizedCells = trimmedSlice.map((cell) => {
|
|
27320
|
-
if (cell?.attrs && "__placeholder" in cell.attrs) {
|
|
27321
|
-
const { __placeholder, ...rest } = cell.attrs;
|
|
27322
|
-
return { ...cell, attrs: rest };
|
|
27323
|
-
}
|
|
27324
|
-
return cell;
|
|
27325
|
-
});
|
|
27326
|
-
const trimmedContent = sanitizedCells.filter((_2, index2) => !isPlaceholderCell(trimmedSlice[index2]));
|
|
27327
|
-
const translateParams = {
|
|
27328
|
-
...params2,
|
|
27329
|
-
node: { ...node, content: trimmedContent }
|
|
27330
|
-
};
|
|
27331
|
-
const elements = translateChildNodes(translateParams);
|
|
27332
|
-
if (node.attrs?.tableRowProperties) {
|
|
27333
|
-
const tableRowProperties = { ...node.attrs.tableRowProperties };
|
|
27334
|
-
if (leadingPlaceholders > 0) {
|
|
27335
|
-
tableRowProperties.gridBefore = leadingPlaceholders;
|
|
27336
|
-
}
|
|
27337
|
-
if (trailingPlaceholders > 0) {
|
|
27338
|
-
tableRowProperties.gridAfter = trailingPlaceholders;
|
|
27339
|
-
}
|
|
27340
|
-
if (node.attrs.rowHeight != null) {
|
|
27341
|
-
const rowHeightPixels = twipsToPixels(node.attrs.tableRowProperties["rowHeight"]?.value);
|
|
27342
|
-
if (rowHeightPixels !== node.attrs.rowHeight) {
|
|
27343
|
-
tableRowProperties["rowHeight"] = { value: String(pixelsToTwips(node.attrs["rowHeight"])) };
|
|
27344
|
-
}
|
|
27345
|
-
}
|
|
27346
|
-
tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
|
|
27347
|
-
const trPr = translator$_.decode({
|
|
27348
|
-
...params2,
|
|
27349
|
-
node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
|
|
27350
|
-
});
|
|
27351
|
-
if (trPr) elements.unshift(trPr);
|
|
27352
|
-
}
|
|
27353
|
-
return {
|
|
27354
|
-
name: "w:tr",
|
|
27355
|
-
attributes: decodedAttrs || {},
|
|
27356
|
-
elements
|
|
27357
|
-
};
|
|
27358
|
-
};
|
|
27359
27166
|
const config$g = {
|
|
27360
27167
|
xmlName: XML_NODE_NAME$h,
|
|
27361
|
-
sdNodeOrKeyName:
|
|
27362
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
27168
|
+
sdNodeOrKeyName: SD_ATTR_KEY$3,
|
|
27363
27169
|
encode: encode$n,
|
|
27364
|
-
decode: decode$p
|
|
27365
|
-
attributes: validXmlAttributes$b
|
|
27170
|
+
decode: decode$p
|
|
27366
27171
|
};
|
|
27367
|
-
const translator$
|
|
27368
|
-
const translator$Y = NodeTranslator.from({
|
|
27369
|
-
xmlName: "w:bidiVisual",
|
|
27370
|
-
sdNodeOrKeyName: "rightToLeft",
|
|
27371
|
-
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27372
|
-
decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
|
|
27373
|
-
});
|
|
27374
|
-
const translator$X = NodeTranslator.from({
|
|
27375
|
-
xmlName: "w:shd",
|
|
27376
|
-
sdNodeOrKeyName: "shading",
|
|
27377
|
-
attributes: [
|
|
27378
|
-
"w:color",
|
|
27379
|
-
"w:fill",
|
|
27380
|
-
"w:themeColor",
|
|
27381
|
-
"w:themeFill",
|
|
27382
|
-
"w:themeFillShade",
|
|
27383
|
-
"w:themeFillTint",
|
|
27384
|
-
"w:themeShade",
|
|
27385
|
-
"w:themeTint",
|
|
27386
|
-
"w:val"
|
|
27387
|
-
].map((attr) => createAttributeHandler(attr)),
|
|
27388
|
-
encode: (params2, encodedAttrs) => {
|
|
27389
|
-
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
27390
|
-
},
|
|
27391
|
-
decode: function({ node }, context) {
|
|
27392
|
-
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.shading || {} } });
|
|
27393
|
-
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
27394
|
-
}
|
|
27395
|
-
});
|
|
27396
|
-
const translator$W = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
|
|
27397
|
-
const translator$V = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
|
|
27398
|
-
const translator$U = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
|
|
27399
|
-
const translator$T = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
|
|
27400
|
-
const translator$S = NodeTranslator.from({
|
|
27401
|
-
xmlName: "w:tblLook",
|
|
27402
|
-
sdNodeOrKeyName: "tblLook",
|
|
27403
|
-
attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
|
|
27404
|
-
encode: (params2, encodedAttrs) => {
|
|
27405
|
-
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
27406
|
-
},
|
|
27407
|
-
decode: function({ node }, context) {
|
|
27408
|
-
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.tblLook || {} } });
|
|
27409
|
-
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
27410
|
-
}
|
|
27411
|
-
});
|
|
27412
|
-
const translator$R = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
|
|
27413
|
-
const translator$Q = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
|
|
27414
|
-
const translator$P = NodeTranslator.from(
|
|
27415
|
-
createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
|
|
27416
|
-
);
|
|
27417
|
-
const translator$O = NodeTranslator.from(
|
|
27418
|
-
createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
|
|
27419
|
-
);
|
|
27420
|
-
const translator$N = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
|
|
27421
|
-
const translator$M = NodeTranslator.from({
|
|
27422
|
-
xmlName: "w:tblpPr",
|
|
27423
|
-
sdNodeOrKeyName: "floatingTableProperties",
|
|
27424
|
-
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))),
|
|
27425
|
-
encode: (params2, encodedAttrs) => {
|
|
27426
|
-
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
27427
|
-
},
|
|
27428
|
-
decode: function({ node }, context) {
|
|
27429
|
-
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.floatingTableProperties || {} } });
|
|
27430
|
-
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
27431
|
-
}
|
|
27432
|
-
});
|
|
27433
|
-
const translator$L = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
|
|
27434
|
-
const translator$K = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
|
|
27435
|
-
const translator$J = NodeTranslator.from(createBorderPropertyHandler("w:end"));
|
|
27436
|
-
const translator$I = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
|
|
27437
|
-
const translator$H = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
|
|
27438
|
-
const translator$G = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
|
|
27439
|
-
const translator$F = NodeTranslator.from(createBorderPropertyHandler("w:left"));
|
|
27440
|
-
const translator$E = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
|
|
27441
|
-
const translator$D = NodeTranslator.from(createBorderPropertyHandler("w:right"));
|
|
27442
|
-
const translator$C = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
|
|
27443
|
-
const translator$B = NodeTranslator.from(createBorderPropertyHandler("w:start"));
|
|
27444
|
-
const translator$A = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
|
|
27445
|
-
const translator$z = NodeTranslator.from(createBorderPropertyHandler("w:top"));
|
|
27446
|
-
const translator$y = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
|
|
27447
|
-
const propertyTranslators$5 = [
|
|
27448
|
-
translator$L,
|
|
27449
|
-
translator$J,
|
|
27450
|
-
translator$H,
|
|
27451
|
-
translator$G,
|
|
27452
|
-
translator$F,
|
|
27453
|
-
translator$D,
|
|
27454
|
-
translator$B,
|
|
27455
|
-
translator$z
|
|
27456
|
-
];
|
|
27457
|
-
const translator$x = NodeTranslator.from(
|
|
27458
|
-
createNestedPropertiesTranslator("w:tblBorders", "borders", propertyTranslators$5)
|
|
27459
|
-
);
|
|
27172
|
+
const translator$J = NodeTranslator.from(config$g);
|
|
27460
27173
|
const propertyTranslators$4 = [
|
|
27461
|
-
translator$
|
|
27462
|
-
translator$
|
|
27463
|
-
translator$
|
|
27464
|
-
translator$
|
|
27465
|
-
translator$A,
|
|
27466
|
-
translator$y
|
|
27467
|
-
];
|
|
27468
|
-
const translator$w = NodeTranslator.from(
|
|
27469
|
-
createNestedPropertiesTranslator("w:tblCellMar", "cellMargins", propertyTranslators$4)
|
|
27470
|
-
);
|
|
27471
|
-
const propertyTranslators$3 = [
|
|
27472
|
-
translator$Y,
|
|
27473
|
-
translator$14,
|
|
27474
|
-
translator$X,
|
|
27475
|
-
translator$W,
|
|
27476
|
-
translator$13,
|
|
27477
|
-
translator$V,
|
|
27478
|
-
translator$U,
|
|
27479
|
-
translator$T,
|
|
27480
|
-
translator$S,
|
|
27174
|
+
translator$1a,
|
|
27175
|
+
translator$18,
|
|
27176
|
+
translator$17,
|
|
27177
|
+
translator$16,
|
|
27481
27178
|
translator$R,
|
|
27179
|
+
translator$19,
|
|
27482
27180
|
translator$Q,
|
|
27483
27181
|
translator$P,
|
|
27484
27182
|
translator$O,
|
|
27485
27183
|
translator$N,
|
|
27486
27184
|
translator$M,
|
|
27487
|
-
translator$
|
|
27488
|
-
translator$
|
|
27185
|
+
translator$L,
|
|
27186
|
+
translator$J
|
|
27489
27187
|
];
|
|
27490
|
-
const translator$
|
|
27491
|
-
createNestedPropertiesTranslator("w:
|
|
27188
|
+
const translator$I = NodeTranslator.from(
|
|
27189
|
+
createNestedPropertiesTranslator("w:tcPr", "tableCellProperties", propertyTranslators$4)
|
|
27492
27190
|
);
|
|
27493
|
-
|
|
27494
|
-
|
|
27495
|
-
|
|
27496
|
-
|
|
27497
|
-
|
|
27498
|
-
|
|
27499
|
-
|
|
27500
|
-
|
|
27501
|
-
|
|
27191
|
+
function handleTableCellNode({
|
|
27192
|
+
params: params2,
|
|
27193
|
+
node,
|
|
27194
|
+
table,
|
|
27195
|
+
row,
|
|
27196
|
+
rowBorders,
|
|
27197
|
+
columnIndex,
|
|
27198
|
+
columnWidth = null,
|
|
27199
|
+
allColumnWidths = [],
|
|
27200
|
+
_referencedStyles
|
|
27201
|
+
}) {
|
|
27202
|
+
const { nodeListHandler } = params2;
|
|
27203
|
+
const attributes = {};
|
|
27204
|
+
const referencedStyles = _referencedStyles ?? { fontSize: null, fonts: {}, cellMargins: {} };
|
|
27205
|
+
const tcPr = node.elements.find((el) => el.name === "w:tcPr");
|
|
27206
|
+
const tableCellProperties = tcPr ? translator$I.encode({ ...params2, nodes: [tcPr] }) ?? {} : {};
|
|
27207
|
+
attributes["tableCellProperties"] = tableCellProperties;
|
|
27208
|
+
if (rowBorders?.insideH) {
|
|
27209
|
+
rowBorders["bottom"] = rowBorders.insideH;
|
|
27210
|
+
delete rowBorders.insideH;
|
|
27502
27211
|
}
|
|
27503
|
-
|
|
27504
|
-
|
|
27505
|
-
|
|
27506
|
-
const defaultValue = params2?.editor?.schema?.nodes?.tableCell?.spec?.attrs?.colwidth?.default;
|
|
27507
|
-
if (Array.isArray(defaultValue)) {
|
|
27508
|
-
const numericWidth = defaultValue.find((width) => typeof width === "number" && Number.isFinite(width) && width > 0);
|
|
27509
|
-
if (numericWidth != null) return numericWidth;
|
|
27510
|
-
} else if (typeof defaultValue === "number" && Number.isFinite(defaultValue) && defaultValue > 0) {
|
|
27511
|
-
return defaultValue;
|
|
27212
|
+
if (rowBorders?.insideV) {
|
|
27213
|
+
rowBorders["right"] = rowBorders.insideV;
|
|
27214
|
+
delete rowBorders?.insideV;
|
|
27512
27215
|
}
|
|
27513
|
-
|
|
27514
|
-
|
|
27515
|
-
|
|
27516
|
-
const
|
|
27517
|
-
if (
|
|
27518
|
-
|
|
27519
|
-
|
|
27520
|
-
|
|
27521
|
-
|
|
27522
|
-
|
|
27216
|
+
if (rowBorders) attributes["borders"] = { ...rowBorders };
|
|
27217
|
+
const inlineBorders = processInlineCellBorders(tableCellProperties.borders, rowBorders);
|
|
27218
|
+
if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"] || {}, inlineBorders);
|
|
27219
|
+
const colspan = tableCellProperties.gridSpan;
|
|
27220
|
+
if (colspan && !isNaN(parseInt(colspan, 10))) attributes["colspan"] = parseInt(colspan, 10);
|
|
27221
|
+
let width = tableCellProperties.cellWidth?.value ? twipsToPixels(tableCellProperties.cellWidth?.value) : null;
|
|
27222
|
+
const widthType = tableCellProperties.cellWidth?.type;
|
|
27223
|
+
if (widthType) attributes["widthType"] = widthType;
|
|
27224
|
+
if (!width && columnWidth) width = columnWidth;
|
|
27225
|
+
if (width) {
|
|
27226
|
+
attributes["colwidth"] = [width];
|
|
27227
|
+
attributes["widthUnit"] = "px";
|
|
27228
|
+
const defaultColWidths = allColumnWidths;
|
|
27229
|
+
const hasDefaultColWidths = allColumnWidths && allColumnWidths.length > 0;
|
|
27230
|
+
const colspanNum = parseInt(colspan || 1, 10);
|
|
27231
|
+
if (colspanNum && colspanNum > 1 && hasDefaultColWidths) {
|
|
27232
|
+
let colwidth = [];
|
|
27233
|
+
for (let i = 0; i < colspanNum; i++) {
|
|
27234
|
+
let colwidthValue = defaultColWidths[columnIndex + i];
|
|
27235
|
+
let defaultColwidth = 100;
|
|
27236
|
+
if (typeof colwidthValue !== "undefined") {
|
|
27237
|
+
colwidth.push(colwidthValue);
|
|
27238
|
+
} else {
|
|
27239
|
+
colwidth.push(defaultColwidth);
|
|
27240
|
+
}
|
|
27241
|
+
}
|
|
27242
|
+
if (colwidth.length) {
|
|
27243
|
+
attributes["colwidth"] = [...colwidth];
|
|
27244
|
+
}
|
|
27523
27245
|
}
|
|
27524
27246
|
}
|
|
27525
|
-
|
|
27526
|
-
|
|
27527
|
-
|
|
27528
|
-
|
|
27529
|
-
const
|
|
27530
|
-
|
|
27531
|
-
|
|
27532
|
-
|
|
27533
|
-
|
|
27534
|
-
|
|
27535
|
-
|
|
27536
|
-
|
|
27537
|
-
|
|
27538
|
-
const
|
|
27539
|
-
|
|
27247
|
+
const background = {
|
|
27248
|
+
color: tableCellProperties.shading?.fill
|
|
27249
|
+
};
|
|
27250
|
+
if (background.color) attributes["background"] = background;
|
|
27251
|
+
const verticalAlign = tableCellProperties.vAlign;
|
|
27252
|
+
if (verticalAlign) attributes["verticalAlign"] = verticalAlign;
|
|
27253
|
+
attributes.cellMargins = getTableCellMargins(tableCellProperties.cellMargins, referencedStyles);
|
|
27254
|
+
const { fontSize: fontSize2, fonts = {} } = referencedStyles;
|
|
27255
|
+
const fontFamily2 = fonts["ascii"];
|
|
27256
|
+
if (fontSize2) attributes["fontSize"] = fontSize2;
|
|
27257
|
+
if (fontFamily2) attributes["fontFamily"] = fontFamily2;
|
|
27258
|
+
if (tableCellProperties.vMerge === "restart") {
|
|
27259
|
+
const rows = table.elements.filter((el) => el.name === "w:tr");
|
|
27260
|
+
const currentRowIndex = rows.findIndex((r2) => r2 === row);
|
|
27261
|
+
const remainingRows = rows.slice(currentRowIndex + 1);
|
|
27262
|
+
const cellsInRow = row.elements.filter((el) => el.name === "w:tc");
|
|
27263
|
+
let cellIndex = cellsInRow.findIndex((el) => el === node);
|
|
27264
|
+
let rowspan = 1;
|
|
27265
|
+
for (let remainingRow of remainingRows) {
|
|
27266
|
+
const firstCell = remainingRow.elements.findIndex((el) => el.name === "w:tc");
|
|
27267
|
+
const cellAtIndex = remainingRow.elements[firstCell + cellIndex];
|
|
27268
|
+
if (!cellAtIndex) break;
|
|
27269
|
+
const vMerge = getTableCellVMerge(cellAtIndex);
|
|
27270
|
+
if (!vMerge || vMerge === "restart") {
|
|
27271
|
+
break;
|
|
27272
|
+
}
|
|
27273
|
+
rowspan++;
|
|
27274
|
+
remainingRow.elements.splice(firstCell + cellIndex, 1);
|
|
27275
|
+
}
|
|
27276
|
+
attributes["rowspan"] = rowspan;
|
|
27540
27277
|
}
|
|
27541
|
-
return Math.max(fallbackWidthTwips, cellMinWidthTwips);
|
|
27542
|
-
};
|
|
27543
|
-
const XML_NODE_NAME$g = "w:tblGrid";
|
|
27544
|
-
const SD_ATTR_KEY$3 = "grid";
|
|
27545
|
-
const cellMinWidth = pixelsToTwips(10);
|
|
27546
|
-
const encode$m = (params2) => {
|
|
27547
|
-
const { nodes } = params2;
|
|
27548
|
-
const node = nodes[0];
|
|
27549
|
-
const attributes = encodeProperties(node, { [translator$u.xmlName]: translator$u }, true);
|
|
27550
27278
|
return {
|
|
27551
|
-
|
|
27552
|
-
|
|
27553
|
-
|
|
27279
|
+
type: "tableCell",
|
|
27280
|
+
content: normalizeTableCellContent(
|
|
27281
|
+
nodeListHandler.handler({
|
|
27282
|
+
...params2,
|
|
27283
|
+
nodes: node.elements,
|
|
27284
|
+
path: [...params2.path || [], node]
|
|
27285
|
+
}),
|
|
27286
|
+
params2.editor
|
|
27287
|
+
),
|
|
27288
|
+
attrs: attributes
|
|
27554
27289
|
};
|
|
27555
|
-
}
|
|
27556
|
-
|
|
27557
|
-
|
|
27558
|
-
const
|
|
27559
|
-
const
|
|
27560
|
-
const
|
|
27561
|
-
const
|
|
27562
|
-
|
|
27563
|
-
|
|
27564
|
-
|
|
27565
|
-
|
|
27566
|
-
const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params2, totalColumns, cellMinWidth);
|
|
27567
|
-
const elements = [];
|
|
27568
|
-
let columnIndex = 0;
|
|
27569
|
-
const pushColumn = (widthTwips, { enforceMinimum = false } = {}) => {
|
|
27570
|
-
let numericWidth = typeof widthTwips === "string" ? parseInt(widthTwips, 10) : widthTwips;
|
|
27571
|
-
let shouldEnforceMinimum = enforceMinimum;
|
|
27572
|
-
if (numericWidth == null || Number.isNaN(numericWidth) || numericWidth <= 0) {
|
|
27573
|
-
numericWidth = fallbackColumnWidthTwips;
|
|
27574
|
-
shouldEnforceMinimum = true;
|
|
27290
|
+
}
|
|
27291
|
+
function normalizeTableCellContent(content, editor) {
|
|
27292
|
+
if (!Array.isArray(content) || content.length === 0) return content;
|
|
27293
|
+
const normalized = [];
|
|
27294
|
+
const pendingForNextBlock = [];
|
|
27295
|
+
const schema = editor?.schema;
|
|
27296
|
+
const cloneBlock = (node) => {
|
|
27297
|
+
if (!node) return node;
|
|
27298
|
+
const cloned = { ...node };
|
|
27299
|
+
if (Array.isArray(node.content)) {
|
|
27300
|
+
cloned.content = [...node.content];
|
|
27575
27301
|
}
|
|
27576
|
-
|
|
27577
|
-
const minimumWidth = shouldEnforceMinimum ? cellMinWidth : 1;
|
|
27578
|
-
const safeWidth = Math.max(roundedWidth, minimumWidth);
|
|
27579
|
-
const decoded = translator$u.decode({
|
|
27580
|
-
node: { type: (
|
|
27581
|
-
/** @type {string} */
|
|
27582
|
-
translator$u.sdNodeOrKeyName
|
|
27583
|
-
), attrs: { col: safeWidth } }
|
|
27584
|
-
});
|
|
27585
|
-
if (decoded) elements.push(decoded);
|
|
27302
|
+
return cloned;
|
|
27586
27303
|
};
|
|
27587
|
-
|
|
27588
|
-
|
|
27589
|
-
|
|
27590
|
-
for (let span = 0; span < spanCount; span++) {
|
|
27591
|
-
const rawWidth = Array.isArray(colwidth) ? colwidth[span] : void 0;
|
|
27592
|
-
const cellWidthPixels = typeof rawWidth === "number" && Number.isFinite(rawWidth) ? rawWidth : Number(rawWidth);
|
|
27593
|
-
const hasCellWidth = Number.isFinite(cellWidthPixels) && cellWidthPixels > 0;
|
|
27594
|
-
const colGridAttrs = grid?.[columnIndex] || {};
|
|
27595
|
-
const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
|
|
27596
|
-
const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
|
|
27597
|
-
let cellWidthTwips;
|
|
27598
|
-
let enforceMinimum = false;
|
|
27599
|
-
if (hasCellWidth) {
|
|
27600
|
-
const tolerance = 0.5;
|
|
27601
|
-
if (gridWidthTwips != null && gridWidthPixels != null && Math.abs(gridWidthPixels - cellWidthPixels) <= tolerance) {
|
|
27602
|
-
cellWidthTwips = gridWidthTwips;
|
|
27603
|
-
} else {
|
|
27604
|
-
cellWidthTwips = pixelsToTwips(cellWidthPixels);
|
|
27605
|
-
}
|
|
27606
|
-
} else if (gridWidthTwips != null) {
|
|
27607
|
-
cellWidthTwips = gridWidthTwips;
|
|
27608
|
-
} else {
|
|
27609
|
-
cellWidthTwips = fallbackColumnWidthTwips;
|
|
27610
|
-
enforceMinimum = true;
|
|
27611
|
-
}
|
|
27612
|
-
pushColumn(cellWidthTwips, { enforceMinimum });
|
|
27613
|
-
columnIndex++;
|
|
27304
|
+
const ensureArray = (node) => {
|
|
27305
|
+
if (!Array.isArray(node.content)) {
|
|
27306
|
+
node.content = [];
|
|
27614
27307
|
}
|
|
27615
|
-
|
|
27616
|
-
while (columnIndex < grid.length) {
|
|
27617
|
-
const gridWidthTwips = normalizeTwipWidth(grid[columnIndex]?.col);
|
|
27618
|
-
pushColumn(gridWidthTwips);
|
|
27619
|
-
columnIndex++;
|
|
27620
|
-
}
|
|
27621
|
-
const newNode = {
|
|
27622
|
-
name: XML_NODE_NAME$g,
|
|
27623
|
-
attributes: {},
|
|
27624
|
-
elements
|
|
27308
|
+
return node.content;
|
|
27625
27309
|
};
|
|
27626
|
-
|
|
27627
|
-
|
|
27628
|
-
|
|
27629
|
-
|
|
27630
|
-
|
|
27631
|
-
|
|
27632
|
-
|
|
27633
|
-
|
|
27634
|
-
|
|
27635
|
-
|
|
27636
|
-
|
|
27637
|
-
|
|
27638
|
-
const MIN_COLUMN_WIDTH_TWIPS = pixelsToTwips(10);
|
|
27639
|
-
const pctToPercent = (value) => {
|
|
27640
|
-
if (value == null) return null;
|
|
27641
|
-
return value / 50;
|
|
27642
|
-
};
|
|
27643
|
-
const resolveContentWidthTwips = () => DEFAULT_CONTENT_WIDTH_TWIPS;
|
|
27644
|
-
const resolveMeasurementWidthPx = (measurement) => {
|
|
27645
|
-
if (!measurement || typeof measurement.value !== "number" || measurement.value <= 0) return null;
|
|
27646
|
-
const { value, type: type2 } = measurement;
|
|
27647
|
-
if (!type2 || type2 === "auto") return null;
|
|
27648
|
-
if (type2 === "dxa") return twipsToPixels(value);
|
|
27649
|
-
if (type2 === "pct") {
|
|
27650
|
-
const percent2 = pctToPercent(value);
|
|
27651
|
-
if (percent2 == null || percent2 <= 0) return null;
|
|
27652
|
-
const widthTwips = resolveContentWidthTwips() * percent2 / 100;
|
|
27653
|
-
return twipsToPixels(widthTwips);
|
|
27654
|
-
}
|
|
27655
|
-
return null;
|
|
27656
|
-
};
|
|
27657
|
-
const countColumnsInRow = (row) => {
|
|
27658
|
-
if (!row?.elements?.length) return 0;
|
|
27659
|
-
return row.elements.reduce((count, element) => {
|
|
27660
|
-
if (element.name !== "w:tc") return count;
|
|
27661
|
-
const tcPr = element.elements?.find((el) => el.name === "w:tcPr");
|
|
27662
|
-
const gridSpan = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
27663
|
-
const spanValue = parseInt(gridSpan?.attributes?.["w:val"] || "1", 10);
|
|
27664
|
-
return count + (Number.isFinite(spanValue) && spanValue > 0 ? spanValue : 1);
|
|
27665
|
-
}, 0);
|
|
27666
|
-
};
|
|
27667
|
-
const clampColumnWidthTwips = (value) => Math.max(Math.round(value), MIN_COLUMN_WIDTH_TWIPS);
|
|
27668
|
-
const createFallbackGrid = (columnCount, columnWidthTwips) => Array.from({ length: columnCount }, () => ({ col: clampColumnWidthTwips(columnWidthTwips) }));
|
|
27669
|
-
const buildFallbackGridForTable = ({ params: params2, rows, tableWidth, tableWidthMeasurement }) => {
|
|
27670
|
-
const firstRow = rows.find((row) => row.elements?.some((el) => el.name === "w:tc"));
|
|
27671
|
-
const columnCount = countColumnsInRow(firstRow);
|
|
27672
|
-
if (!columnCount) return null;
|
|
27673
|
-
const schemaDefaultPx = getSchemaDefaultColumnWidthPx(
|
|
27674
|
-
/** @type {any} */
|
|
27675
|
-
params2
|
|
27676
|
-
);
|
|
27677
|
-
const minimumColumnWidthPx = Number.isFinite(schemaDefaultPx) && schemaDefaultPx > 0 ? schemaDefaultPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
27678
|
-
let totalWidthPx;
|
|
27679
|
-
if (tableWidthMeasurement) {
|
|
27680
|
-
const resolved = resolveMeasurementWidthPx(tableWidthMeasurement);
|
|
27681
|
-
if (resolved != null) totalWidthPx = resolved;
|
|
27682
|
-
}
|
|
27683
|
-
if (totalWidthPx == null && tableWidth?.width && tableWidth.width > 0) {
|
|
27684
|
-
totalWidthPx = tableWidth.width;
|
|
27685
|
-
}
|
|
27686
|
-
if (totalWidthPx == null) {
|
|
27687
|
-
totalWidthPx = minimumColumnWidthPx * columnCount;
|
|
27688
|
-
}
|
|
27689
|
-
const rawColumnWidthPx = Math.max(totalWidthPx / columnCount, minimumColumnWidthPx);
|
|
27690
|
-
const columnWidthTwips = clampColumnWidthTwips(pixelsToTwips(rawColumnWidthPx));
|
|
27691
|
-
const fallbackColumnWidthPx = twipsToPixels(columnWidthTwips);
|
|
27692
|
-
return {
|
|
27693
|
-
grid: createFallbackGrid(columnCount, columnWidthTwips),
|
|
27694
|
-
columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
|
|
27310
|
+
const isInlineNode = (node) => {
|
|
27311
|
+
if (!node || typeof node.type !== "string") return false;
|
|
27312
|
+
if (node.type === "text") return true;
|
|
27313
|
+
if (node.type === "bookmarkStart" || node.type === "bookmarkEnd") return true;
|
|
27314
|
+
const nodeType = schema?.nodes?.[node.type];
|
|
27315
|
+
if (nodeType) {
|
|
27316
|
+
if (typeof nodeType.isInline === "boolean") return nodeType.isInline;
|
|
27317
|
+
if (nodeType.spec?.group && typeof nodeType.spec.group === "string") {
|
|
27318
|
+
return nodeType.spec.group.split(" ").includes("inline");
|
|
27319
|
+
}
|
|
27320
|
+
}
|
|
27321
|
+
return false;
|
|
27695
27322
|
};
|
|
27696
|
-
|
|
27697
|
-
|
|
27698
|
-
|
|
27699
|
-
|
|
27700
|
-
const { nodes } = params2;
|
|
27701
|
-
const node = nodes[0];
|
|
27702
|
-
const tblPr = node.elements.find((el) => el.name === "w:tblPr");
|
|
27703
|
-
if (tblPr) {
|
|
27704
|
-
const encodedProperties = translator$v.encode({ ...params2, nodes: [tblPr] });
|
|
27705
|
-
encodedAttrs["tableProperties"] = encodedProperties || {};
|
|
27706
|
-
}
|
|
27707
|
-
const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
|
|
27708
|
-
if (tblGrid) {
|
|
27709
|
-
encodedAttrs["grid"] = translator$t.encode({ ...params2, nodes: [tblGrid] }).attributes;
|
|
27710
|
-
}
|
|
27711
|
-
[
|
|
27712
|
-
"tableStyleId",
|
|
27713
|
-
"justification",
|
|
27714
|
-
"tableLayout",
|
|
27715
|
-
["tableIndent", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
27716
|
-
["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
|
|
27717
|
-
].forEach((prop) => {
|
|
27718
|
-
let key2;
|
|
27719
|
-
let transform;
|
|
27720
|
-
if (Array.isArray(prop)) {
|
|
27721
|
-
[key2, transform] = prop;
|
|
27722
|
-
} else {
|
|
27723
|
-
key2 = prop;
|
|
27724
|
-
transform = (v2) => v2;
|
|
27323
|
+
for (const node of content) {
|
|
27324
|
+
if (!node || typeof node.type !== "string") {
|
|
27325
|
+
normalized.push(node);
|
|
27326
|
+
continue;
|
|
27725
27327
|
}
|
|
27726
|
-
if (
|
|
27727
|
-
|
|
27328
|
+
if (!isInlineNode(node)) {
|
|
27329
|
+
const blockNode = cloneBlock(node);
|
|
27330
|
+
if (pendingForNextBlock.length) {
|
|
27331
|
+
const blockContent = ensureArray(blockNode);
|
|
27332
|
+
const leadingInline = pendingForNextBlock.splice(0);
|
|
27333
|
+
blockNode.content = [...leadingInline, ...blockContent];
|
|
27334
|
+
} else if (Array.isArray(blockNode.content)) {
|
|
27335
|
+
blockNode.content = [...blockNode.content];
|
|
27336
|
+
}
|
|
27337
|
+
normalized.push(blockNode);
|
|
27338
|
+
continue;
|
|
27728
27339
|
}
|
|
27729
|
-
|
|
27730
|
-
|
|
27731
|
-
|
|
27732
|
-
|
|
27733
|
-
|
|
27734
|
-
|
|
27735
|
-
|
|
27736
|
-
|
|
27737
|
-
|
|
27738
|
-
|
|
27739
|
-
|
|
27740
|
-
|
|
27741
|
-
|
|
27742
|
-
|
|
27743
|
-
|
|
27744
|
-
type: tableWidthMeasurement.type
|
|
27745
|
-
};
|
|
27340
|
+
const targetIsNextBlock = node.type === "bookmarkStart" || normalized.length === 0;
|
|
27341
|
+
if (targetIsNextBlock) {
|
|
27342
|
+
pendingForNextBlock.push(node);
|
|
27343
|
+
} else {
|
|
27344
|
+
const lastIndex = normalized.length - 1;
|
|
27345
|
+
const lastNode = normalized[lastIndex];
|
|
27346
|
+
if (!lastNode || typeof lastNode.type !== "string" || isInlineNode(lastNode)) {
|
|
27347
|
+
pendingForNextBlock.push(node);
|
|
27348
|
+
continue;
|
|
27349
|
+
}
|
|
27350
|
+
const blockContent = ensureArray(lastNode);
|
|
27351
|
+
if (pendingForNextBlock.length) {
|
|
27352
|
+
blockContent.push(...pendingForNextBlock.splice(0));
|
|
27353
|
+
}
|
|
27354
|
+
blockContent.push(node);
|
|
27746
27355
|
}
|
|
27747
27356
|
}
|
|
27748
|
-
|
|
27749
|
-
|
|
27750
|
-
|
|
27751
|
-
|
|
27752
|
-
|
|
27753
|
-
|
|
27754
|
-
|
|
27755
|
-
|
|
27756
|
-
|
|
27757
|
-
|
|
27758
|
-
|
|
27759
|
-
|
|
27760
|
-
|
|
27761
|
-
|
|
27762
|
-
|
|
27763
|
-
|
|
27764
|
-
|
|
27765
|
-
rows,
|
|
27766
|
-
tableWidth: encodedAttrs.tableWidth,
|
|
27767
|
-
tableWidthMeasurement: encodedAttrs.tableProperties?.tableWidth
|
|
27768
|
-
});
|
|
27769
|
-
if (fallback) {
|
|
27770
|
-
encodedAttrs.grid = fallback.grid;
|
|
27771
|
-
columnWidths = fallback.columnWidths;
|
|
27357
|
+
if (pendingForNextBlock.length) {
|
|
27358
|
+
if (normalized.length) {
|
|
27359
|
+
const lastIndex = normalized.length - 1;
|
|
27360
|
+
const lastNode = normalized[lastIndex];
|
|
27361
|
+
if (lastNode && typeof lastNode.type === "string" && !isInlineNode(lastNode)) {
|
|
27362
|
+
const blockContent = ensureArray(lastNode);
|
|
27363
|
+
blockContent.push(...pendingForNextBlock);
|
|
27364
|
+
pendingForNextBlock.length = 0;
|
|
27365
|
+
}
|
|
27366
|
+
}
|
|
27367
|
+
if (pendingForNextBlock.length) {
|
|
27368
|
+
normalized.push({
|
|
27369
|
+
type: "paragraph",
|
|
27370
|
+
attrs: {},
|
|
27371
|
+
content: [...pendingForNextBlock]
|
|
27372
|
+
});
|
|
27373
|
+
pendingForNextBlock.length = 0;
|
|
27772
27374
|
}
|
|
27773
27375
|
}
|
|
27774
|
-
|
|
27775
|
-
|
|
27776
|
-
|
|
27777
|
-
|
|
27778
|
-
|
|
27779
|
-
|
|
27780
|
-
|
|
27781
|
-
|
|
27782
|
-
|
|
27783
|
-
|
|
27784
|
-
|
|
27785
|
-
|
|
27786
|
-
|
|
27787
|
-
|
|
27788
|
-
|
|
27789
|
-
}
|
|
27790
|
-
|
|
27791
|
-
|
|
27792
|
-
|
|
27793
|
-
|
|
27794
|
-
|
|
27795
|
-
|
|
27796
|
-
if (activeRowSpans[col] > 0) {
|
|
27797
|
-
activeRowSpans[col] -= 1;
|
|
27798
|
-
}
|
|
27799
|
-
}
|
|
27800
|
-
let columnIndex = 0;
|
|
27801
|
-
const advanceColumnIndex = () => {
|
|
27802
|
-
while (columnIndex < totalColumns && activeRowSpansForCurrentRow[columnIndex] > 0) {
|
|
27803
|
-
columnIndex += 1;
|
|
27804
|
-
}
|
|
27805
|
-
};
|
|
27806
|
-
advanceColumnIndex();
|
|
27807
|
-
result.content?.forEach((cell) => {
|
|
27808
|
-
advanceColumnIndex();
|
|
27809
|
-
const colspan = Math.max(1, cell.attrs?.colspan || 1);
|
|
27810
|
-
const rowspan = Math.max(1, cell.attrs?.rowspan || 1);
|
|
27811
|
-
if (rowspan > 1) {
|
|
27812
|
-
for (let offset2 = 0; offset2 < colspan && columnIndex + offset2 < totalColumns; offset2++) {
|
|
27813
|
-
const targetIndex = columnIndex + offset2;
|
|
27814
|
-
const remainingRows = rowspan - 1;
|
|
27815
|
-
if (remainingRows > 0 && remainingRows > activeRowSpans[targetIndex]) {
|
|
27816
|
-
activeRowSpans[targetIndex] = remainingRows;
|
|
27817
|
-
}
|
|
27818
|
-
}
|
|
27819
|
-
}
|
|
27820
|
-
columnIndex += colspan;
|
|
27821
|
-
advanceColumnIndex();
|
|
27822
|
-
});
|
|
27376
|
+
return normalized;
|
|
27377
|
+
}
|
|
27378
|
+
const processInlineCellBorders = (borders, rowBorders) => {
|
|
27379
|
+
if (!borders) return null;
|
|
27380
|
+
return ["bottom", "top", "left", "right"].reduce((acc, direction) => {
|
|
27381
|
+
const borderAttrs = borders[direction];
|
|
27382
|
+
const rowBorderAttrs = rowBorders[direction];
|
|
27383
|
+
if (borderAttrs && borderAttrs["val"] !== "nil") {
|
|
27384
|
+
const color = borderAttrs["color"];
|
|
27385
|
+
let size2 = borderAttrs["size"];
|
|
27386
|
+
if (size2) size2 = eighthPointsToPixels(size2);
|
|
27387
|
+
acc[direction] = { color, size: size2, val: borderAttrs["val"] };
|
|
27388
|
+
return acc;
|
|
27389
|
+
}
|
|
27390
|
+
if (borderAttrs && borderAttrs["val"] === "nil") {
|
|
27391
|
+
const border = Object.assign({}, rowBorderAttrs || {});
|
|
27392
|
+
if (!Object.keys(border).length) {
|
|
27393
|
+
return acc;
|
|
27394
|
+
} else {
|
|
27395
|
+
border["val"] = "none";
|
|
27396
|
+
acc[direction] = border;
|
|
27397
|
+
return acc;
|
|
27823
27398
|
}
|
|
27824
27399
|
}
|
|
27825
|
-
|
|
27826
|
-
|
|
27827
|
-
type: "table",
|
|
27828
|
-
content,
|
|
27829
|
-
attrs: encodedAttrs
|
|
27830
|
-
};
|
|
27400
|
+
return acc;
|
|
27401
|
+
}, {});
|
|
27831
27402
|
};
|
|
27832
|
-
const
|
|
27833
|
-
|
|
27834
|
-
const
|
|
27835
|
-
|
|
27836
|
-
|
|
27837
|
-
|
|
27838
|
-
|
|
27839
|
-
|
|
27840
|
-
|
|
27841
|
-
|
|
27842
|
-
|
|
27403
|
+
const getTableCellVMerge = (node) => {
|
|
27404
|
+
const tcPr = node.elements.find((el) => el.name === "w:tcPr");
|
|
27405
|
+
const vMerge = tcPr?.elements?.find((el) => el.name === "w:vMerge");
|
|
27406
|
+
if (!vMerge) return null;
|
|
27407
|
+
return vMerge.attributes?.["w:val"] || "continue";
|
|
27408
|
+
};
|
|
27409
|
+
const getTableCellMargins = (inlineMargins, referencedStyles) => {
|
|
27410
|
+
const { cellMargins = {} } = referencedStyles;
|
|
27411
|
+
return ["left", "right", "top", "bottom"].reduce((acc, direction) => {
|
|
27412
|
+
const key2 = `margin${direction.charAt(0).toUpperCase() + direction.slice(1)}`;
|
|
27413
|
+
const inlineValue = inlineMargins ? inlineMargins?.[key2]?.value : null;
|
|
27414
|
+
const styleValue = cellMargins ? cellMargins[key2] : null;
|
|
27415
|
+
if (inlineValue != null) {
|
|
27416
|
+
acc[direction] = twipsToPixels(inlineValue);
|
|
27417
|
+
} else if (styleValue == null) {
|
|
27418
|
+
acc[direction] = void 0;
|
|
27419
|
+
} else if (typeof styleValue === "object") {
|
|
27420
|
+
acc[direction] = twipsToPixels(styleValue.value);
|
|
27421
|
+
} else {
|
|
27422
|
+
acc[direction] = twipsToPixels(styleValue);
|
|
27843
27423
|
}
|
|
27844
|
-
|
|
27845
|
-
|
|
27846
|
-
if (node.attrs?.tableProperties) {
|
|
27847
|
-
const properties2 = { ...node.attrs.tableProperties };
|
|
27848
|
-
const element2 = translator$v.decode({
|
|
27849
|
-
...params2,
|
|
27850
|
-
node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
|
|
27851
|
-
});
|
|
27852
|
-
if (element2) elements.unshift(element2);
|
|
27853
|
-
}
|
|
27854
|
-
return {
|
|
27855
|
-
name: "w:tbl",
|
|
27856
|
-
attributes: decodedAttrs || {},
|
|
27857
|
-
elements
|
|
27858
|
-
};
|
|
27424
|
+
return acc;
|
|
27425
|
+
}, {});
|
|
27859
27426
|
};
|
|
27860
|
-
function
|
|
27861
|
-
const
|
|
27862
|
-
|
|
27863
|
-
|
|
27864
|
-
const attrs = {};
|
|
27865
|
-
const color = attributes.color;
|
|
27866
|
-
const size2 = attributes.size;
|
|
27867
|
-
if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
|
|
27868
|
-
if (size2 && size2 !== "auto") attrs["size"] = eighthPointsToPixels(size2);
|
|
27869
|
-
const rowBorderNames = ["insideH", "insideV"];
|
|
27870
|
-
if (rowBorderNames.includes(name)) rowBorders[name] = attrs;
|
|
27871
|
-
borders[name] = attrs;
|
|
27427
|
+
function translateTableCell(params2) {
|
|
27428
|
+
const elements = translateChildNodes({
|
|
27429
|
+
...params2,
|
|
27430
|
+
tableCell: params2.node
|
|
27872
27431
|
});
|
|
27432
|
+
const cellProps = generateTableCellProperties(params2.node);
|
|
27433
|
+
elements.unshift(cellProps);
|
|
27873
27434
|
return {
|
|
27874
|
-
|
|
27875
|
-
|
|
27435
|
+
name: "w:tc",
|
|
27436
|
+
elements
|
|
27876
27437
|
};
|
|
27877
27438
|
}
|
|
27878
|
-
function
|
|
27879
|
-
|
|
27880
|
-
const
|
|
27881
|
-
const {
|
|
27882
|
-
const
|
|
27883
|
-
const
|
|
27884
|
-
|
|
27885
|
-
|
|
27886
|
-
|
|
27887
|
-
|
|
27888
|
-
|
|
27889
|
-
let baseTblPr;
|
|
27890
|
-
if (basedOn?.attributes) {
|
|
27891
|
-
const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
|
|
27892
|
-
baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
|
|
27439
|
+
function generateTableCellProperties(node) {
|
|
27440
|
+
const tableCellProperties = { ...node.attrs?.tableCellProperties || {} };
|
|
27441
|
+
const { attrs } = node;
|
|
27442
|
+
const { colwidth = [], cellWidthType = "dxa", widthUnit } = attrs;
|
|
27443
|
+
const colwidthSum = colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
27444
|
+
const propertiesWidthPixels = twipsToPixels(tableCellProperties.cellWidth?.value);
|
|
27445
|
+
if (propertiesWidthPixels !== colwidthSum) {
|
|
27446
|
+
tableCellProperties["cellWidth"] = {
|
|
27447
|
+
value: widthUnit === "px" ? pixelsToTwips(colwidthSum) : inchesToTwips(colwidthSum),
|
|
27448
|
+
type: cellWidthType
|
|
27449
|
+
};
|
|
27893
27450
|
}
|
|
27894
|
-
const
|
|
27895
|
-
if (
|
|
27896
|
-
|
|
27897
|
-
|
|
27898
|
-
|
|
27899
|
-
const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
|
|
27900
|
-
if (rPr) {
|
|
27901
|
-
const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
|
|
27902
|
-
if (fonts) {
|
|
27903
|
-
const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
|
|
27904
|
-
stylesToReturn.fonts = { ascii, hAnsi, cs };
|
|
27905
|
-
}
|
|
27906
|
-
const fontSize2 = rPr.elements.find((el) => el.name === "w:sz");
|
|
27907
|
-
if (fontSize2?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize2.attributes["w:val"]) + "pt";
|
|
27908
|
-
}
|
|
27909
|
-
const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
|
|
27910
|
-
if (tblPr && tblPr.elements) {
|
|
27911
|
-
if (baseTblPr && baseTblPr.elements) {
|
|
27912
|
-
tblPr.elements.push(...baseTblPr.elements);
|
|
27913
|
-
}
|
|
27914
|
-
const tableProperties = translator$v.encode({ ...params2, nodes: [tblPr] });
|
|
27915
|
-
const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
|
|
27916
|
-
if (borders) stylesToReturn.borders = borders;
|
|
27917
|
-
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
27918
|
-
const cellMargins = {};
|
|
27919
|
-
Object.entries(tableProperties.cellMargins || {}).forEach(([key2, attrs]) => {
|
|
27920
|
-
if (attrs?.value != null) {
|
|
27921
|
-
cellMargins[key2] = {
|
|
27922
|
-
value: attrs.value,
|
|
27923
|
-
type: attrs.type || "dxa"
|
|
27924
|
-
};
|
|
27925
|
-
}
|
|
27926
|
-
});
|
|
27927
|
-
if (Object.keys(cellMargins).length) stylesToReturn.cellMargins = cellMargins;
|
|
27928
|
-
}
|
|
27929
|
-
return stylesToReturn;
|
|
27930
|
-
}
|
|
27931
|
-
const config$e = {
|
|
27932
|
-
xmlName: XML_NODE_NAME$f,
|
|
27933
|
-
sdNodeOrKeyName: SD_NODE_NAME$c,
|
|
27934
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
27935
|
-
encode: encode$l,
|
|
27936
|
-
decode: decode$n,
|
|
27937
|
-
attributes: []
|
|
27938
|
-
};
|
|
27939
|
-
const translator$s = NodeTranslator.from(config$e);
|
|
27940
|
-
const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$s);
|
|
27941
|
-
function getReferencedTableStyles(tblStyleTag, docx) {
|
|
27942
|
-
if (!tblStyleTag) return null;
|
|
27943
|
-
const stylesToReturn = {};
|
|
27944
|
-
const { attributes = {} } = tblStyleTag;
|
|
27945
|
-
const tableStyleReference = attributes["w:val"];
|
|
27946
|
-
if (!tableStyleReference) return null;
|
|
27947
|
-
const styles = docx["word/styles.xml"];
|
|
27948
|
-
const { elements } = styles.elements[0];
|
|
27949
|
-
const styleElements = elements.filter((el) => el.name === "w:style");
|
|
27950
|
-
const styleTag = styleElements.find((el) => el.attributes["w:styleId"] === tableStyleReference);
|
|
27951
|
-
if (!styleTag) return null;
|
|
27952
|
-
stylesToReturn.name = styleTag.elements.find((el) => el.name === "w:name");
|
|
27953
|
-
const basedOn = styleTag.elements.find((el) => el.name === "w:basedOn");
|
|
27954
|
-
let baseTblPr;
|
|
27955
|
-
if (basedOn?.attributes) {
|
|
27956
|
-
const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
|
|
27957
|
-
baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
|
|
27958
|
-
}
|
|
27959
|
-
const pPr = styleTag.elements.find((el) => el.name === "w:pPr");
|
|
27960
|
-
if (pPr) {
|
|
27961
|
-
const justification = pPr.elements.find((el) => el.name === "w:jc");
|
|
27962
|
-
if (justification?.attributes) stylesToReturn.justification = justification.attributes["w:val"];
|
|
27963
|
-
}
|
|
27964
|
-
const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
|
|
27965
|
-
if (rPr) {
|
|
27966
|
-
const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
|
|
27967
|
-
if (fonts) {
|
|
27968
|
-
const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
|
|
27969
|
-
stylesToReturn.fonts = { ascii, hAnsi, cs };
|
|
27970
|
-
}
|
|
27971
|
-
const fontSize2 = rPr.elements.find((el) => el.name === "w:sz");
|
|
27972
|
-
if (fontSize2?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize2.attributes["w:val"]) + "pt";
|
|
27973
|
-
}
|
|
27974
|
-
const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
|
|
27975
|
-
if (tblPr && tblPr.elements) {
|
|
27976
|
-
if (baseTblPr && baseTblPr.elements) {
|
|
27977
|
-
tblPr.elements.push(...baseTblPr.elements);
|
|
27978
|
-
}
|
|
27979
|
-
const tableBorders = tblPr?.elements?.find((el) => el.name === "w:tblBorders");
|
|
27980
|
-
const { elements: borderElements = [] } = tableBorders || {};
|
|
27981
|
-
const { borders, rowBorders } = processTableBorders(borderElements);
|
|
27982
|
-
if (borders) stylesToReturn.borders = borders;
|
|
27983
|
-
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
27984
|
-
const tableCellMargin = tblPr?.elements.find((el) => el.name === "w:tblCellMar");
|
|
27985
|
-
if (tableCellMargin) {
|
|
27986
|
-
const marginLeft = tableCellMargin.elements.find((el) => el.name === "w:left");
|
|
27987
|
-
const marginRight = tableCellMargin.elements.find((el) => el.name === "w:right");
|
|
27988
|
-
const marginTop = tableCellMargin.elements.find((el) => el.name === "w:top");
|
|
27989
|
-
const marginBottom = tableCellMargin.elements.find((el) => el.name === "w:bottom");
|
|
27990
|
-
stylesToReturn.cellMargins = {
|
|
27991
|
-
marginLeft: marginLeft?.attributes["w:w"],
|
|
27992
|
-
marginRight: marginRight?.attributes["w:w"],
|
|
27993
|
-
marginTop: marginTop?.attributes["w:w"],
|
|
27994
|
-
marginBottom: marginBottom?.attributes["w:w"]
|
|
27995
|
-
};
|
|
27996
|
-
}
|
|
27997
|
-
}
|
|
27998
|
-
return stylesToReturn;
|
|
27999
|
-
}
|
|
28000
|
-
function processTableBorders(borderElements) {
|
|
28001
|
-
const borders = {};
|
|
28002
|
-
const rowBorders = {};
|
|
28003
|
-
borderElements.forEach((borderElement) => {
|
|
28004
|
-
const { name } = borderElement;
|
|
28005
|
-
const borderName = name.split("w:")[1];
|
|
28006
|
-
const { attributes } = borderElement;
|
|
28007
|
-
const attrs = {};
|
|
28008
|
-
const color = attributes["w:color"];
|
|
28009
|
-
const size2 = attributes["w:sz"];
|
|
28010
|
-
if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
|
|
28011
|
-
if (size2 && size2 !== "auto") attrs["size"] = eighthPointsToPixels(size2);
|
|
28012
|
-
const rowBorderNames = ["insideH", "insideV"];
|
|
28013
|
-
if (rowBorderNames.includes(borderName)) rowBorders[borderName] = attrs;
|
|
28014
|
-
borders[borderName] = attrs;
|
|
28015
|
-
});
|
|
28016
|
-
return {
|
|
28017
|
-
borders,
|
|
28018
|
-
rowBorders
|
|
28019
|
-
};
|
|
28020
|
-
}
|
|
28021
|
-
const translator$r = NodeTranslator.from(createMeasurementPropertyHandler("w:tcW", "cellWidth"));
|
|
28022
|
-
const translator$q = NodeTranslator.from(
|
|
28023
|
-
createSingleAttrPropertyHandler(
|
|
28024
|
-
"w:gridSpan",
|
|
28025
|
-
null,
|
|
28026
|
-
"w:val",
|
|
28027
|
-
(v2) => parseInteger(v2) ?? void 0,
|
|
28028
|
-
(v2) => integerToString(v2)
|
|
28029
|
-
)
|
|
28030
|
-
);
|
|
28031
|
-
const translator$p = NodeTranslator.from(createSingleAttrPropertyHandler("w:vMerge"));
|
|
28032
|
-
const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:tl2br"));
|
|
28033
|
-
const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:tr2bl"));
|
|
28034
|
-
const propertyTranslators$2 = [
|
|
28035
|
-
translator$z,
|
|
28036
|
-
translator$B,
|
|
28037
|
-
translator$F,
|
|
28038
|
-
translator$L,
|
|
28039
|
-
translator$J,
|
|
28040
|
-
translator$D,
|
|
28041
|
-
translator$H,
|
|
28042
|
-
translator$G,
|
|
28043
|
-
translator$o,
|
|
28044
|
-
translator$n
|
|
28045
|
-
];
|
|
28046
|
-
const translator$m = NodeTranslator.from(
|
|
28047
|
-
createNestedPropertiesTranslator("w:tcBorders", "borders", propertyTranslators$2)
|
|
28048
|
-
);
|
|
28049
|
-
const translator$l = NodeTranslator.from(
|
|
28050
|
-
createSingleAttrPropertyHandler(
|
|
28051
|
-
"w:noWrap",
|
|
28052
|
-
null,
|
|
28053
|
-
"w:val",
|
|
28054
|
-
(v2) => parseBoolean(v2 ?? "true"),
|
|
28055
|
-
(v2) => booleanToString(v2)
|
|
28056
|
-
)
|
|
28057
|
-
);
|
|
28058
|
-
const propertyTranslators$1 = [
|
|
28059
|
-
translator$K,
|
|
28060
|
-
translator$I,
|
|
28061
|
-
translator$E,
|
|
28062
|
-
translator$C,
|
|
28063
|
-
translator$A,
|
|
28064
|
-
translator$y
|
|
28065
|
-
];
|
|
28066
|
-
const translator$k = NodeTranslator.from(
|
|
28067
|
-
createNestedPropertiesTranslator("w:tcMar", "cellMargins", propertyTranslators$1)
|
|
28068
|
-
);
|
|
28069
|
-
const translator$j = NodeTranslator.from(createSingleAttrPropertyHandler("w:textDirection"));
|
|
28070
|
-
const translator$i = NodeTranslator.from(
|
|
28071
|
-
createSingleAttrPropertyHandler(
|
|
28072
|
-
"w:tcFitText",
|
|
28073
|
-
null,
|
|
28074
|
-
"w:val",
|
|
28075
|
-
(v2) => parseBoolean(v2 ?? "true"),
|
|
28076
|
-
(v2) => booleanToString(v2)
|
|
28077
|
-
)
|
|
28078
|
-
);
|
|
28079
|
-
const translator$h = NodeTranslator.from(createSingleAttrPropertyHandler("w:vAlign"));
|
|
28080
|
-
const translator$g = NodeTranslator.from(
|
|
28081
|
-
createSingleAttrPropertyHandler(
|
|
28082
|
-
"w:hideMark",
|
|
28083
|
-
null,
|
|
28084
|
-
"w:val",
|
|
28085
|
-
(v2) => parseBoolean(v2 ?? "true"),
|
|
28086
|
-
(v2) => booleanToString(v2)
|
|
28087
|
-
)
|
|
28088
|
-
);
|
|
28089
|
-
const translator$f = NodeTranslator.from(createSingleAttrPropertyHandler("w:header"));
|
|
28090
|
-
const XML_NODE_NAME$e = "w:headers";
|
|
28091
|
-
const SD_ATTR_KEY$2 = "headers";
|
|
28092
|
-
const encode$k = (params2) => {
|
|
28093
|
-
const { nodes } = params2;
|
|
28094
|
-
const node = nodes[0];
|
|
28095
|
-
const attributes = encodeProperties(node, { [translator$f.xmlName]: translator$f }, true);
|
|
28096
|
-
return {
|
|
28097
|
-
xmlName: XML_NODE_NAME$e,
|
|
28098
|
-
sdNodeOrKeyName: SD_ATTR_KEY$2,
|
|
28099
|
-
attributes
|
|
28100
|
-
};
|
|
28101
|
-
};
|
|
28102
|
-
const decode$m = (params2) => {
|
|
28103
|
-
const { headers = [] } = params2.node.attrs || {};
|
|
28104
|
-
const newNode = {
|
|
28105
|
-
name: XML_NODE_NAME$e,
|
|
28106
|
-
attributes: {},
|
|
28107
|
-
elements: headers.map(
|
|
28108
|
-
(header) => translator$f.decode({
|
|
28109
|
-
node: { type: "header", attrs: header }
|
|
28110
|
-
})
|
|
28111
|
-
)
|
|
28112
|
-
};
|
|
28113
|
-
return newNode;
|
|
28114
|
-
};
|
|
28115
|
-
const config$d = {
|
|
28116
|
-
xmlName: XML_NODE_NAME$e,
|
|
28117
|
-
sdNodeOrKeyName: SD_ATTR_KEY$2,
|
|
28118
|
-
encode: encode$k,
|
|
28119
|
-
decode: decode$m
|
|
28120
|
-
};
|
|
28121
|
-
const translator$e = NodeTranslator.from(config$d);
|
|
28122
|
-
const propertyTranslators = [
|
|
28123
|
-
translator$19,
|
|
28124
|
-
translator$r,
|
|
28125
|
-
translator$q,
|
|
28126
|
-
translator$p,
|
|
28127
|
-
translator$m,
|
|
28128
|
-
translator$X,
|
|
28129
|
-
translator$l,
|
|
28130
|
-
translator$k,
|
|
28131
|
-
translator$j,
|
|
28132
|
-
translator$i,
|
|
28133
|
-
translator$h,
|
|
28134
|
-
translator$g,
|
|
28135
|
-
translator$e
|
|
28136
|
-
];
|
|
28137
|
-
const translator$d = NodeTranslator.from(
|
|
28138
|
-
createNestedPropertiesTranslator("w:tcPr", "tableCellProperties", propertyTranslators)
|
|
28139
|
-
);
|
|
28140
|
-
function handleTableCellNode({
|
|
28141
|
-
params: params2,
|
|
28142
|
-
node,
|
|
28143
|
-
table,
|
|
28144
|
-
row,
|
|
28145
|
-
rowBorders,
|
|
28146
|
-
styleTag,
|
|
28147
|
-
columnIndex,
|
|
28148
|
-
columnWidth = null,
|
|
28149
|
-
allColumnWidths = []
|
|
28150
|
-
}) {
|
|
28151
|
-
const { docx, nodeListHandler } = params2;
|
|
28152
|
-
const attributes = {};
|
|
28153
|
-
const tcPr = node.elements.find((el) => el.name === "w:tcPr");
|
|
28154
|
-
const tableCellProperties = tcPr ? translator$d.encode({ ...params2, nodes: [tcPr] }) ?? {} : {};
|
|
28155
|
-
attributes["tableCellProperties"] = tableCellProperties;
|
|
28156
|
-
if (rowBorders?.insideH) {
|
|
28157
|
-
rowBorders["bottom"] = rowBorders.insideH;
|
|
28158
|
-
delete rowBorders.insideH;
|
|
28159
|
-
}
|
|
28160
|
-
if (rowBorders?.insideV) {
|
|
28161
|
-
rowBorders["right"] = rowBorders.insideV;
|
|
28162
|
-
delete rowBorders?.insideV;
|
|
28163
|
-
}
|
|
28164
|
-
if (rowBorders) attributes["borders"] = { ...rowBorders };
|
|
28165
|
-
const inlineBorders = processInlineCellBorders(tableCellProperties.borders, rowBorders);
|
|
28166
|
-
if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"] || {}, inlineBorders);
|
|
28167
|
-
const colspan = tableCellProperties.gridSpan;
|
|
28168
|
-
if (colspan && !isNaN(parseInt(colspan, 10))) attributes["colspan"] = parseInt(colspan, 10);
|
|
28169
|
-
let width = tableCellProperties.cellWidth?.value ? twipsToPixels(tableCellProperties.cellWidth?.value) : null;
|
|
28170
|
-
const widthType = tableCellProperties.cellWidth?.type;
|
|
28171
|
-
if (widthType) attributes["widthType"] = widthType;
|
|
28172
|
-
if (!width && columnWidth) width = columnWidth;
|
|
28173
|
-
if (width) {
|
|
28174
|
-
attributes["colwidth"] = [width];
|
|
28175
|
-
attributes["widthUnit"] = "px";
|
|
28176
|
-
const defaultColWidths = allColumnWidths;
|
|
28177
|
-
const hasDefaultColWidths = allColumnWidths && allColumnWidths.length > 0;
|
|
28178
|
-
const colspanNum = parseInt(colspan || 1, 10);
|
|
28179
|
-
if (colspanNum && colspanNum > 1 && hasDefaultColWidths) {
|
|
28180
|
-
let colwidth = [];
|
|
28181
|
-
for (let i = 0; i < colspanNum; i++) {
|
|
28182
|
-
let colwidthValue = defaultColWidths[columnIndex + i];
|
|
28183
|
-
let defaultColwidth = 100;
|
|
28184
|
-
if (typeof colwidthValue !== "undefined") {
|
|
28185
|
-
colwidth.push(colwidthValue);
|
|
28186
|
-
} else {
|
|
28187
|
-
colwidth.push(defaultColwidth);
|
|
28188
|
-
}
|
|
28189
|
-
}
|
|
28190
|
-
if (colwidth.length) {
|
|
28191
|
-
attributes["colwidth"] = [...colwidth];
|
|
28192
|
-
}
|
|
28193
|
-
}
|
|
28194
|
-
}
|
|
28195
|
-
const background = {
|
|
28196
|
-
color: tableCellProperties.shading?.fill
|
|
28197
|
-
};
|
|
28198
|
-
if (background.color) attributes["background"] = background;
|
|
28199
|
-
const verticalAlign = tableCellProperties.vAlign;
|
|
28200
|
-
if (verticalAlign) attributes["verticalAlign"] = verticalAlign;
|
|
28201
|
-
const referencedStyles = getReferencedTableStyles(styleTag, docx) || { fontSize: null, fonts: {}, cellMargins: {} };
|
|
28202
|
-
attributes.cellMargins = getTableCellMargins(tableCellProperties.cellMargins, referencedStyles);
|
|
28203
|
-
const { fontSize: fontSize2, fonts = {} } = referencedStyles;
|
|
28204
|
-
const fontFamily2 = fonts["ascii"];
|
|
28205
|
-
if (fontSize2) attributes["fontSize"] = fontSize2;
|
|
28206
|
-
if (fontFamily2) attributes["fontFamily"] = fontFamily2;
|
|
28207
|
-
if (tableCellProperties.vMerge === "restart") {
|
|
28208
|
-
const rows = table.elements.filter((el) => el.name === "w:tr");
|
|
28209
|
-
const currentRowIndex = rows.findIndex((r2) => r2 === row);
|
|
28210
|
-
const remainingRows = rows.slice(currentRowIndex + 1);
|
|
28211
|
-
const cellsInRow = row.elements.filter((el) => el.name === "w:tc");
|
|
28212
|
-
let cellIndex = cellsInRow.findIndex((el) => el === node);
|
|
28213
|
-
let rowspan = 1;
|
|
28214
|
-
for (let remainingRow of remainingRows) {
|
|
28215
|
-
const firstCell = remainingRow.elements.findIndex((el) => el.name === "w:tc");
|
|
28216
|
-
const cellAtIndex = remainingRow.elements[firstCell + cellIndex];
|
|
28217
|
-
if (!cellAtIndex) break;
|
|
28218
|
-
const vMerge = getTableCellVMerge(cellAtIndex);
|
|
28219
|
-
if (!vMerge || vMerge === "restart") {
|
|
28220
|
-
break;
|
|
28221
|
-
}
|
|
28222
|
-
rowspan++;
|
|
28223
|
-
remainingRow.elements.splice(firstCell + cellIndex, 1);
|
|
28224
|
-
}
|
|
28225
|
-
attributes["rowspan"] = rowspan;
|
|
28226
|
-
}
|
|
28227
|
-
return {
|
|
28228
|
-
type: "tableCell",
|
|
28229
|
-
content: normalizeTableCellContent(
|
|
28230
|
-
nodeListHandler.handler({
|
|
28231
|
-
...params2,
|
|
28232
|
-
nodes: node.elements,
|
|
28233
|
-
path: [...params2.path || [], node]
|
|
28234
|
-
}),
|
|
28235
|
-
params2.editor
|
|
28236
|
-
),
|
|
28237
|
-
attrs: attributes
|
|
28238
|
-
};
|
|
28239
|
-
}
|
|
28240
|
-
function normalizeTableCellContent(content, editor) {
|
|
28241
|
-
if (!Array.isArray(content) || content.length === 0) return content;
|
|
28242
|
-
const normalized = [];
|
|
28243
|
-
const pendingForNextBlock = [];
|
|
28244
|
-
const schema = editor?.schema;
|
|
28245
|
-
const cloneBlock = (node) => {
|
|
28246
|
-
if (!node) return node;
|
|
28247
|
-
const cloned = { ...node };
|
|
28248
|
-
if (Array.isArray(node.content)) {
|
|
28249
|
-
cloned.content = [...node.content];
|
|
28250
|
-
}
|
|
28251
|
-
return cloned;
|
|
28252
|
-
};
|
|
28253
|
-
const ensureArray = (node) => {
|
|
28254
|
-
if (!Array.isArray(node.content)) {
|
|
28255
|
-
node.content = [];
|
|
28256
|
-
}
|
|
28257
|
-
return node.content;
|
|
28258
|
-
};
|
|
28259
|
-
const isInlineNode = (node) => {
|
|
28260
|
-
if (!node || typeof node.type !== "string") return false;
|
|
28261
|
-
if (node.type === "text") return true;
|
|
28262
|
-
if (node.type === "bookmarkStart" || node.type === "bookmarkEnd") return true;
|
|
28263
|
-
const nodeType = schema?.nodes?.[node.type];
|
|
28264
|
-
if (nodeType) {
|
|
28265
|
-
if (typeof nodeType.isInline === "boolean") return nodeType.isInline;
|
|
28266
|
-
if (nodeType.spec?.group && typeof nodeType.spec.group === "string") {
|
|
28267
|
-
return nodeType.spec.group.split(" ").includes("inline");
|
|
28268
|
-
}
|
|
28269
|
-
}
|
|
28270
|
-
return false;
|
|
28271
|
-
};
|
|
28272
|
-
for (const node of content) {
|
|
28273
|
-
if (!node || typeof node.type !== "string") {
|
|
28274
|
-
normalized.push(node);
|
|
28275
|
-
continue;
|
|
28276
|
-
}
|
|
28277
|
-
if (!isInlineNode(node)) {
|
|
28278
|
-
const blockNode = cloneBlock(node);
|
|
28279
|
-
if (pendingForNextBlock.length) {
|
|
28280
|
-
const blockContent = ensureArray(blockNode);
|
|
28281
|
-
const leadingInline = pendingForNextBlock.splice(0);
|
|
28282
|
-
blockNode.content = [...leadingInline, ...blockContent];
|
|
28283
|
-
} else if (Array.isArray(blockNode.content)) {
|
|
28284
|
-
blockNode.content = [...blockNode.content];
|
|
28285
|
-
}
|
|
28286
|
-
normalized.push(blockNode);
|
|
28287
|
-
continue;
|
|
28288
|
-
}
|
|
28289
|
-
const targetIsNextBlock = node.type === "bookmarkStart" || normalized.length === 0;
|
|
28290
|
-
if (targetIsNextBlock) {
|
|
28291
|
-
pendingForNextBlock.push(node);
|
|
28292
|
-
} else {
|
|
28293
|
-
const lastIndex = normalized.length - 1;
|
|
28294
|
-
const lastNode = normalized[lastIndex];
|
|
28295
|
-
if (!lastNode || typeof lastNode.type !== "string" || isInlineNode(lastNode)) {
|
|
28296
|
-
pendingForNextBlock.push(node);
|
|
28297
|
-
continue;
|
|
28298
|
-
}
|
|
28299
|
-
const blockContent = ensureArray(lastNode);
|
|
28300
|
-
if (pendingForNextBlock.length) {
|
|
28301
|
-
blockContent.push(...pendingForNextBlock.splice(0));
|
|
28302
|
-
}
|
|
28303
|
-
blockContent.push(node);
|
|
28304
|
-
}
|
|
28305
|
-
}
|
|
28306
|
-
if (pendingForNextBlock.length) {
|
|
28307
|
-
if (normalized.length) {
|
|
28308
|
-
const lastIndex = normalized.length - 1;
|
|
28309
|
-
const lastNode = normalized[lastIndex];
|
|
28310
|
-
if (lastNode && typeof lastNode.type === "string" && !isInlineNode(lastNode)) {
|
|
28311
|
-
const blockContent = ensureArray(lastNode);
|
|
28312
|
-
blockContent.push(...pendingForNextBlock);
|
|
28313
|
-
pendingForNextBlock.length = 0;
|
|
28314
|
-
}
|
|
28315
|
-
}
|
|
28316
|
-
if (pendingForNextBlock.length) {
|
|
28317
|
-
normalized.push({
|
|
28318
|
-
type: "paragraph",
|
|
28319
|
-
attrs: {},
|
|
28320
|
-
content: [...pendingForNextBlock]
|
|
28321
|
-
});
|
|
28322
|
-
pendingForNextBlock.length = 0;
|
|
28323
|
-
}
|
|
28324
|
-
}
|
|
28325
|
-
return normalized;
|
|
28326
|
-
}
|
|
28327
|
-
const processInlineCellBorders = (borders, rowBorders) => {
|
|
28328
|
-
if (!borders) return null;
|
|
28329
|
-
return ["bottom", "top", "left", "right"].reduce((acc, direction) => {
|
|
28330
|
-
const borderAttrs = borders[direction];
|
|
28331
|
-
const rowBorderAttrs = rowBorders[direction];
|
|
28332
|
-
if (borderAttrs && borderAttrs["val"] !== "nil") {
|
|
28333
|
-
const color = borderAttrs["color"];
|
|
28334
|
-
let size2 = borderAttrs["size"];
|
|
28335
|
-
if (size2) size2 = eighthPointsToPixels(size2);
|
|
28336
|
-
acc[direction] = { color, size: size2, val: borderAttrs["val"] };
|
|
28337
|
-
return acc;
|
|
28338
|
-
}
|
|
28339
|
-
if (borderAttrs && borderAttrs["val"] === "nil") {
|
|
28340
|
-
const border = Object.assign({}, rowBorderAttrs || {});
|
|
28341
|
-
if (!Object.keys(border).length) {
|
|
28342
|
-
return acc;
|
|
28343
|
-
} else {
|
|
28344
|
-
border["val"] = "none";
|
|
28345
|
-
acc[direction] = border;
|
|
28346
|
-
return acc;
|
|
28347
|
-
}
|
|
28348
|
-
}
|
|
28349
|
-
return acc;
|
|
28350
|
-
}, {});
|
|
28351
|
-
};
|
|
28352
|
-
const getTableCellVMerge = (node) => {
|
|
28353
|
-
const tcPr = node.elements.find((el) => el.name === "w:tcPr");
|
|
28354
|
-
const vMerge = tcPr?.elements?.find((el) => el.name === "w:vMerge");
|
|
28355
|
-
if (!vMerge) return null;
|
|
28356
|
-
return vMerge.attributes?.["w:val"] || "continue";
|
|
28357
|
-
};
|
|
28358
|
-
const getTableCellMargins = (inlineMargins, referencedStyles) => {
|
|
28359
|
-
const { cellMargins = {} } = referencedStyles;
|
|
28360
|
-
return ["left", "right", "top", "bottom"].reduce((acc, direction) => {
|
|
28361
|
-
const key2 = `margin${direction.charAt(0).toUpperCase() + direction.slice(1)}`;
|
|
28362
|
-
const inlineValue = inlineMargins ? inlineMargins?.[key2]?.value : null;
|
|
28363
|
-
const styleValue = cellMargins ? cellMargins[key2] : null;
|
|
28364
|
-
if (inlineValue != null) {
|
|
28365
|
-
acc[direction] = twipsToPixels(inlineValue);
|
|
28366
|
-
} else if (styleValue == null) {
|
|
28367
|
-
acc[direction] = void 0;
|
|
28368
|
-
} else if (typeof styleValue === "object") {
|
|
28369
|
-
acc[direction] = twipsToPixels(styleValue.value);
|
|
28370
|
-
} else {
|
|
28371
|
-
acc[direction] = twipsToPixels(styleValue);
|
|
28372
|
-
}
|
|
28373
|
-
return acc;
|
|
28374
|
-
}, {});
|
|
28375
|
-
};
|
|
28376
|
-
function translateTableCell(params2) {
|
|
28377
|
-
const elements = translateChildNodes({
|
|
28378
|
-
...params2,
|
|
28379
|
-
tableCell: params2.node
|
|
28380
|
-
});
|
|
28381
|
-
const cellProps = generateTableCellProperties(params2.node);
|
|
28382
|
-
elements.unshift(cellProps);
|
|
28383
|
-
return {
|
|
28384
|
-
name: "w:tc",
|
|
28385
|
-
elements
|
|
28386
|
-
};
|
|
28387
|
-
}
|
|
28388
|
-
function generateTableCellProperties(node) {
|
|
28389
|
-
const tableCellProperties = { ...node.attrs?.tableCellProperties || {} };
|
|
28390
|
-
const { attrs } = node;
|
|
28391
|
-
const { colwidth = [], cellWidthType = "dxa", widthUnit } = attrs;
|
|
28392
|
-
const colwidthSum = colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
28393
|
-
const propertiesWidthPixels = twipsToPixels(tableCellProperties.cellWidth?.value);
|
|
28394
|
-
if (propertiesWidthPixels !== colwidthSum) {
|
|
28395
|
-
tableCellProperties["cellWidth"] = {
|
|
28396
|
-
value: widthUnit === "px" ? pixelsToTwips(colwidthSum) : inchesToTwips(colwidthSum),
|
|
28397
|
-
type: cellWidthType
|
|
28398
|
-
};
|
|
28399
|
-
}
|
|
28400
|
-
const { colspan } = attrs;
|
|
28401
|
-
if (colspan > 1 && tableCellProperties.gridSpan !== colspan) {
|
|
28402
|
-
tableCellProperties["gridSpan"] = colspan;
|
|
28403
|
-
} else if (!colspan || tableCellProperties?.gridSpan === 1) {
|
|
28404
|
-
delete tableCellProperties.gridSpan;
|
|
27451
|
+
const { colspan } = attrs;
|
|
27452
|
+
if (colspan > 1 && tableCellProperties.gridSpan !== colspan) {
|
|
27453
|
+
tableCellProperties["gridSpan"] = colspan;
|
|
27454
|
+
} else if (!colspan || tableCellProperties?.gridSpan === 1) {
|
|
27455
|
+
delete tableCellProperties.gridSpan;
|
|
28405
27456
|
}
|
|
28406
27457
|
const { background = {} } = attrs;
|
|
28407
27458
|
if (background?.color && tableCellProperties.shading?.fill !== background?.color) {
|
|
@@ -28464,22 +27515,22 @@ function generateTableCellProperties(node) {
|
|
|
28464
27515
|
} else if (tableCellProperties?.borders) {
|
|
28465
27516
|
delete tableCellProperties.borders;
|
|
28466
27517
|
}
|
|
28467
|
-
const result = translator$
|
|
27518
|
+
const result = translator$I.decode({ node: { ...node, attrs: { ...node.attrs, tableCellProperties } } });
|
|
28468
27519
|
return result;
|
|
28469
27520
|
}
|
|
28470
|
-
const XML_NODE_NAME$
|
|
28471
|
-
const SD_NODE_NAME$
|
|
28472
|
-
const validXmlAttributes$
|
|
28473
|
-
function encode$
|
|
27521
|
+
const XML_NODE_NAME$g = "w:tc";
|
|
27522
|
+
const SD_NODE_NAME$d = "tableCell";
|
|
27523
|
+
const validXmlAttributes$b = [];
|
|
27524
|
+
function encode$m(params2, encodedAttrs) {
|
|
28474
27525
|
const {
|
|
28475
27526
|
node,
|
|
28476
27527
|
table,
|
|
28477
27528
|
row,
|
|
28478
27529
|
rowBorders,
|
|
28479
|
-
styleTag,
|
|
28480
27530
|
columnIndex,
|
|
28481
27531
|
columnWidth,
|
|
28482
|
-
columnWidths: allColumnWidths
|
|
27532
|
+
columnWidths: allColumnWidths,
|
|
27533
|
+
_referencedStyles
|
|
28483
27534
|
} = params2.extraParams;
|
|
28484
27535
|
const schemaNode = handleTableCellNode({
|
|
28485
27536
|
params: params2,
|
|
@@ -28487,57 +27538,349 @@ function encode$j(params2, encodedAttrs) {
|
|
|
28487
27538
|
table,
|
|
28488
27539
|
row,
|
|
28489
27540
|
rowBorders,
|
|
28490
|
-
styleTag,
|
|
28491
27541
|
columnIndex,
|
|
28492
27542
|
columnWidth,
|
|
28493
|
-
allColumnWidths
|
|
27543
|
+
allColumnWidths,
|
|
27544
|
+
_referencedStyles
|
|
28494
27545
|
});
|
|
28495
27546
|
if (encodedAttrs && Object.keys(encodedAttrs).length) {
|
|
28496
27547
|
schemaNode.attrs = { ...schemaNode.attrs, ...encodedAttrs };
|
|
28497
27548
|
}
|
|
28498
27549
|
return schemaNode;
|
|
28499
27550
|
}
|
|
28500
|
-
function decode$
|
|
27551
|
+
function decode$o(params2, decodedAttrs) {
|
|
28501
27552
|
const translated = translateTableCell(params2);
|
|
28502
27553
|
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
28503
27554
|
translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
|
|
28504
27555
|
}
|
|
28505
27556
|
return translated;
|
|
28506
27557
|
}
|
|
28507
|
-
const config$
|
|
28508
|
-
xmlName: XML_NODE_NAME$
|
|
28509
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
27558
|
+
const config$f = {
|
|
27559
|
+
xmlName: XML_NODE_NAME$g,
|
|
27560
|
+
sdNodeOrKeyName: SD_NODE_NAME$d,
|
|
28510
27561
|
type: NodeTranslator.translatorTypes.NODE,
|
|
28511
|
-
encode: encode$
|
|
28512
|
-
decode: decode$
|
|
28513
|
-
attributes: validXmlAttributes$
|
|
27562
|
+
encode: encode$m,
|
|
27563
|
+
decode: decode$o,
|
|
27564
|
+
attributes: validXmlAttributes$b
|
|
28514
27565
|
};
|
|
28515
|
-
const translator$
|
|
28516
|
-
|
|
28517
|
-
|
|
28518
|
-
|
|
28519
|
-
}
|
|
28520
|
-
|
|
28521
|
-
|
|
28522
|
-
|
|
28523
|
-
|
|
28524
|
-
|
|
28525
|
-
|
|
28526
|
-
|
|
28527
|
-
|
|
28528
|
-
|
|
28529
|
-
|
|
28530
|
-
|
|
28531
|
-
|
|
28532
|
-
|
|
28533
|
-
|
|
27566
|
+
const translator$H = NodeTranslator.from(config$f);
|
|
27567
|
+
const translator$G = NodeTranslator.from({
|
|
27568
|
+
xmlName: "w:cantSplit",
|
|
27569
|
+
sdNodeOrKeyName: "cantSplit",
|
|
27570
|
+
encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27571
|
+
decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
|
|
27572
|
+
});
|
|
27573
|
+
const translator$F = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
|
|
27574
|
+
const translator$E = NodeTranslator.from(
|
|
27575
|
+
createSingleAttrPropertyHandler(
|
|
27576
|
+
"w:gridAfter",
|
|
27577
|
+
null,
|
|
27578
|
+
"w:val",
|
|
27579
|
+
(v2) => parseInteger(v2) ?? void 0,
|
|
27580
|
+
(v2) => integerToString(v2)
|
|
27581
|
+
)
|
|
27582
|
+
);
|
|
27583
|
+
const translator$D = NodeTranslator.from(
|
|
27584
|
+
createSingleAttrPropertyHandler(
|
|
27585
|
+
"w:gridBefore",
|
|
27586
|
+
null,
|
|
27587
|
+
"w:val",
|
|
27588
|
+
(v2) => parseInteger(v2) ?? void 0,
|
|
27589
|
+
(v2) => integerToString(v2)
|
|
27590
|
+
)
|
|
27591
|
+
);
|
|
27592
|
+
const translator$C = NodeTranslator.from({
|
|
27593
|
+
xmlName: "w:hidden",
|
|
27594
|
+
sdNodeOrKeyName: "hidden",
|
|
27595
|
+
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27596
|
+
decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
|
|
27597
|
+
});
|
|
27598
|
+
const translator$B = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
|
|
27599
|
+
const translator$A = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
|
|
27600
|
+
const translator$z = NodeTranslator.from({
|
|
27601
|
+
xmlName: "w:tblHeader",
|
|
27602
|
+
sdNodeOrKeyName: "repeatHeader",
|
|
27603
|
+
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27604
|
+
decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
|
|
27605
|
+
});
|
|
27606
|
+
const translator$y = NodeTranslator.from({
|
|
27607
|
+
xmlName: "w:trHeight",
|
|
27608
|
+
sdNodeOrKeyName: "rowHeight",
|
|
27609
|
+
encode: ({ nodes }) => {
|
|
27610
|
+
const heightAttrs = {};
|
|
27611
|
+
const val = nodes[0].attributes["w:val"];
|
|
27612
|
+
if (val) {
|
|
27613
|
+
heightAttrs["value"] = parseInt(val, 10);
|
|
27614
|
+
}
|
|
27615
|
+
const rule = nodes[0].attributes["w:hRule"];
|
|
27616
|
+
if (rule) {
|
|
27617
|
+
heightAttrs["rule"] = rule;
|
|
27618
|
+
}
|
|
27619
|
+
return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
|
|
27620
|
+
},
|
|
27621
|
+
decode: ({ node }) => {
|
|
27622
|
+
if (!node.attrs?.rowHeight) return;
|
|
27623
|
+
const heightAttrs = {};
|
|
27624
|
+
if (typeof node.attrs.rowHeight.value === "number" && !isNaN(node.attrs.rowHeight.value)) {
|
|
27625
|
+
heightAttrs["w:val"] = String(node.attrs.rowHeight.value);
|
|
27626
|
+
}
|
|
27627
|
+
if (node.attrs.rowHeight.rule) {
|
|
27628
|
+
heightAttrs["w:hRule"] = node.attrs.rowHeight.rule;
|
|
27629
|
+
}
|
|
27630
|
+
return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
|
|
28534
27631
|
}
|
|
28535
|
-
|
|
28536
|
-
|
|
28537
|
-
|
|
28538
|
-
|
|
28539
|
-
|
|
28540
|
-
|
|
27632
|
+
});
|
|
27633
|
+
const translator$x = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
|
|
27634
|
+
const translator$w = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
|
|
27635
|
+
const propertyTranslators$3 = [
|
|
27636
|
+
translator$G,
|
|
27637
|
+
translator$1a,
|
|
27638
|
+
translator$F,
|
|
27639
|
+
translator$E,
|
|
27640
|
+
translator$D,
|
|
27641
|
+
translator$C,
|
|
27642
|
+
translator$B,
|
|
27643
|
+
translator$A,
|
|
27644
|
+
translator$z,
|
|
27645
|
+
translator$y,
|
|
27646
|
+
translator$x,
|
|
27647
|
+
translator$w
|
|
27648
|
+
];
|
|
27649
|
+
const translator$v = NodeTranslator.from(
|
|
27650
|
+
createNestedPropertiesTranslator("w:trPr", "tableRowProperties", propertyTranslators$3, {
|
|
27651
|
+
cantSplit: false,
|
|
27652
|
+
hidden: false,
|
|
27653
|
+
repeatHeader: false
|
|
27654
|
+
})
|
|
27655
|
+
);
|
|
27656
|
+
const createPlaceholderCell = (gridWidth, reason) => {
|
|
27657
|
+
const safeWidth = Number.isFinite(gridWidth) ? gridWidth : 0;
|
|
27658
|
+
const noBorder = { val: "none", size: 0 };
|
|
27659
|
+
return {
|
|
27660
|
+
type: "tableCell",
|
|
27661
|
+
attrs: {
|
|
27662
|
+
colspan: 1,
|
|
27663
|
+
rowspan: 1,
|
|
27664
|
+
colwidth: [safeWidth],
|
|
27665
|
+
__placeholder: reason,
|
|
27666
|
+
borders: {
|
|
27667
|
+
top: { ...noBorder },
|
|
27668
|
+
right: { ...noBorder },
|
|
27669
|
+
bottom: { ...noBorder },
|
|
27670
|
+
left: { ...noBorder }
|
|
27671
|
+
}
|
|
27672
|
+
},
|
|
27673
|
+
content: [{ type: "paragraph", content: [] }]
|
|
27674
|
+
};
|
|
27675
|
+
};
|
|
27676
|
+
const advancePastRowSpans = (pendingRowSpans, startIndex, totalColumns) => {
|
|
27677
|
+
let index2 = startIndex;
|
|
27678
|
+
while (index2 < totalColumns && pendingRowSpans[index2] > 0) {
|
|
27679
|
+
pendingRowSpans[index2] -= 1;
|
|
27680
|
+
index2 += 1;
|
|
27681
|
+
}
|
|
27682
|
+
return index2;
|
|
27683
|
+
};
|
|
27684
|
+
const fillPlaceholderColumns = ({
|
|
27685
|
+
content,
|
|
27686
|
+
pendingRowSpans,
|
|
27687
|
+
currentIndex,
|
|
27688
|
+
targetIndex,
|
|
27689
|
+
totalColumns,
|
|
27690
|
+
gridColumnWidths,
|
|
27691
|
+
reason
|
|
27692
|
+
}) => {
|
|
27693
|
+
let index2 = currentIndex;
|
|
27694
|
+
while (index2 < targetIndex && index2 < totalColumns) {
|
|
27695
|
+
if (pendingRowSpans[index2] > 0) {
|
|
27696
|
+
pendingRowSpans[index2] -= 1;
|
|
27697
|
+
index2 += 1;
|
|
27698
|
+
continue;
|
|
27699
|
+
}
|
|
27700
|
+
const width = Array.isArray(gridColumnWidths) ? gridColumnWidths[index2] ?? 0 : 0;
|
|
27701
|
+
content.push(createPlaceholderCell(width, reason));
|
|
27702
|
+
index2 += 1;
|
|
27703
|
+
}
|
|
27704
|
+
return index2;
|
|
27705
|
+
};
|
|
27706
|
+
const isPlaceholderCell = (cell) => {
|
|
27707
|
+
if (!cell) return false;
|
|
27708
|
+
if (cell.attrs?.__placeholder) return true;
|
|
27709
|
+
const widths = cell.attrs?.colwidth;
|
|
27710
|
+
if (Array.isArray(widths) && widths.length > 0) {
|
|
27711
|
+
const hasMeaningfulWidth = widths.some(
|
|
27712
|
+
(value) => typeof value === "number" && Number.isFinite(value) && Math.abs(value) > 1
|
|
27713
|
+
);
|
|
27714
|
+
if (!hasMeaningfulWidth) return true;
|
|
27715
|
+
}
|
|
27716
|
+
return false;
|
|
27717
|
+
};
|
|
27718
|
+
const XML_NODE_NAME$f = "w:tr";
|
|
27719
|
+
const SD_NODE_NAME$c = "tableRow";
|
|
27720
|
+
const validXmlAttributes$a = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
|
|
27721
|
+
(xmlName) => createAttributeHandler(xmlName)
|
|
27722
|
+
);
|
|
27723
|
+
const encode$l = (params2, encodedAttrs) => {
|
|
27724
|
+
const { row } = params2.extraParams;
|
|
27725
|
+
let tableRowProperties = {};
|
|
27726
|
+
const tPr = row.elements.find((el) => el.name === "w:trPr");
|
|
27727
|
+
if (tPr) {
|
|
27728
|
+
tableRowProperties = translator$v.encode({
|
|
27729
|
+
...params2,
|
|
27730
|
+
nodes: [tPr]
|
|
27731
|
+
});
|
|
27732
|
+
}
|
|
27733
|
+
const gridBeforeRaw = tableRowProperties?.["gridBefore"];
|
|
27734
|
+
const safeGridBefore = typeof gridBeforeRaw === "number" && Number.isFinite(gridBeforeRaw) && gridBeforeRaw > 0 ? gridBeforeRaw : 0;
|
|
27735
|
+
encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
|
|
27736
|
+
encodedAttrs["rowHeight"] = twipsToPixels(tableRowProperties["rowHeight"]?.value);
|
|
27737
|
+
encodedAttrs["cantSplit"] = tableRowProperties["cantSplit"];
|
|
27738
|
+
const { columnWidths: gridColumnWidths, activeRowSpans = [] } = params2.extraParams;
|
|
27739
|
+
const totalColumns = Array.isArray(gridColumnWidths) ? gridColumnWidths.length : 0;
|
|
27740
|
+
const pendingRowSpans = Array.isArray(activeRowSpans) ? activeRowSpans.slice() : [];
|
|
27741
|
+
while (pendingRowSpans.length < totalColumns) pendingRowSpans.push(0);
|
|
27742
|
+
const cellNodes = row.elements.filter((el) => el.name === "w:tc");
|
|
27743
|
+
const content = [];
|
|
27744
|
+
let currentColumnIndex = 0;
|
|
27745
|
+
const fillUntil = (target, reason) => {
|
|
27746
|
+
currentColumnIndex = fillPlaceholderColumns({
|
|
27747
|
+
content,
|
|
27748
|
+
pendingRowSpans,
|
|
27749
|
+
currentIndex: currentColumnIndex,
|
|
27750
|
+
targetIndex: target,
|
|
27751
|
+
totalColumns,
|
|
27752
|
+
gridColumnWidths,
|
|
27753
|
+
reason
|
|
27754
|
+
});
|
|
27755
|
+
};
|
|
27756
|
+
const skipOccupiedColumns = () => {
|
|
27757
|
+
currentColumnIndex = advancePastRowSpans(pendingRowSpans, currentColumnIndex, totalColumns);
|
|
27758
|
+
};
|
|
27759
|
+
fillUntil(safeGridBefore, "gridBefore");
|
|
27760
|
+
skipOccupiedColumns();
|
|
27761
|
+
cellNodes?.forEach((node) => {
|
|
27762
|
+
skipOccupiedColumns();
|
|
27763
|
+
const startColumn = currentColumnIndex;
|
|
27764
|
+
const columnWidth = gridColumnWidths?.[startColumn] || null;
|
|
27765
|
+
const result = translator$H.encode({
|
|
27766
|
+
...params2,
|
|
27767
|
+
extraParams: {
|
|
27768
|
+
...params2.extraParams,
|
|
27769
|
+
node,
|
|
27770
|
+
columnIndex: startColumn,
|
|
27771
|
+
columnWidth
|
|
27772
|
+
}
|
|
27773
|
+
});
|
|
27774
|
+
if (result) {
|
|
27775
|
+
content.push(result);
|
|
27776
|
+
const colspan = Math.max(1, result.attrs?.colspan || 1);
|
|
27777
|
+
const rowspan = Math.max(1, result.attrs?.rowspan || 1);
|
|
27778
|
+
if (rowspan > 1) {
|
|
27779
|
+
for (let offset2 = 0; offset2 < colspan; offset2 += 1) {
|
|
27780
|
+
const target = startColumn + offset2;
|
|
27781
|
+
if (target < pendingRowSpans.length) {
|
|
27782
|
+
pendingRowSpans[target] = Math.max(pendingRowSpans[target], rowspan - 1);
|
|
27783
|
+
}
|
|
27784
|
+
}
|
|
27785
|
+
}
|
|
27786
|
+
currentColumnIndex = startColumn + colspan;
|
|
27787
|
+
}
|
|
27788
|
+
});
|
|
27789
|
+
skipOccupiedColumns();
|
|
27790
|
+
fillUntil(totalColumns, "gridAfter");
|
|
27791
|
+
const newNode = {
|
|
27792
|
+
type: "tableRow",
|
|
27793
|
+
content,
|
|
27794
|
+
attrs: encodedAttrs
|
|
27795
|
+
};
|
|
27796
|
+
return newNode;
|
|
27797
|
+
};
|
|
27798
|
+
const decode$n = (params2, decodedAttrs) => {
|
|
27799
|
+
const { node } = params2;
|
|
27800
|
+
const cells = node.content || [];
|
|
27801
|
+
let leadingPlaceholders = 0;
|
|
27802
|
+
while (leadingPlaceholders < cells.length && isPlaceholderCell(cells[leadingPlaceholders])) {
|
|
27803
|
+
leadingPlaceholders += 1;
|
|
27804
|
+
}
|
|
27805
|
+
let trailingPlaceholders = 0;
|
|
27806
|
+
while (trailingPlaceholders < cells.length - leadingPlaceholders && isPlaceholderCell(cells[cells.length - 1 - trailingPlaceholders])) {
|
|
27807
|
+
trailingPlaceholders += 1;
|
|
27808
|
+
}
|
|
27809
|
+
const trimmedSlice = cells.slice(leadingPlaceholders, cells.length - trailingPlaceholders);
|
|
27810
|
+
const sanitizedCells = trimmedSlice.map((cell) => {
|
|
27811
|
+
if (cell?.attrs && "__placeholder" in cell.attrs) {
|
|
27812
|
+
const { __placeholder, ...rest } = cell.attrs;
|
|
27813
|
+
return { ...cell, attrs: rest };
|
|
27814
|
+
}
|
|
27815
|
+
return cell;
|
|
27816
|
+
});
|
|
27817
|
+
const trimmedContent = sanitizedCells.filter((_2, index2) => !isPlaceholderCell(trimmedSlice[index2]));
|
|
27818
|
+
const translateParams = {
|
|
27819
|
+
...params2,
|
|
27820
|
+
node: { ...node, content: trimmedContent }
|
|
27821
|
+
};
|
|
27822
|
+
const elements = translateChildNodes(translateParams);
|
|
27823
|
+
if (node.attrs?.tableRowProperties) {
|
|
27824
|
+
const tableRowProperties = { ...node.attrs.tableRowProperties };
|
|
27825
|
+
if (leadingPlaceholders > 0) {
|
|
27826
|
+
tableRowProperties.gridBefore = leadingPlaceholders;
|
|
27827
|
+
}
|
|
27828
|
+
if (trailingPlaceholders > 0) {
|
|
27829
|
+
tableRowProperties.gridAfter = trailingPlaceholders;
|
|
27830
|
+
}
|
|
27831
|
+
if (node.attrs.rowHeight != null) {
|
|
27832
|
+
const rowHeightPixels = twipsToPixels(node.attrs.tableRowProperties["rowHeight"]?.value);
|
|
27833
|
+
if (rowHeightPixels !== node.attrs.rowHeight) {
|
|
27834
|
+
tableRowProperties["rowHeight"] = { value: String(pixelsToTwips(node.attrs["rowHeight"])) };
|
|
27835
|
+
}
|
|
27836
|
+
}
|
|
27837
|
+
tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
|
|
27838
|
+
const trPr = translator$v.decode({
|
|
27839
|
+
...params2,
|
|
27840
|
+
node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
|
|
27841
|
+
});
|
|
27842
|
+
if (trPr) elements.unshift(trPr);
|
|
27843
|
+
}
|
|
27844
|
+
return {
|
|
27845
|
+
name: "w:tr",
|
|
27846
|
+
attributes: decodedAttrs || {},
|
|
27847
|
+
elements
|
|
27848
|
+
};
|
|
27849
|
+
};
|
|
27850
|
+
const config$e = {
|
|
27851
|
+
xmlName: XML_NODE_NAME$f,
|
|
27852
|
+
sdNodeOrKeyName: SD_NODE_NAME$c,
|
|
27853
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
27854
|
+
encode: encode$l,
|
|
27855
|
+
decode: decode$n,
|
|
27856
|
+
attributes: validXmlAttributes$a
|
|
27857
|
+
};
|
|
27858
|
+
const translator$u = NodeTranslator.from(config$e);
|
|
27859
|
+
function parseTagValueJSON(json) {
|
|
27860
|
+
if (typeof json !== "string") {
|
|
27861
|
+
return {};
|
|
27862
|
+
}
|
|
27863
|
+
const trimmed = json.trim();
|
|
27864
|
+
if (!trimmed) {
|
|
27865
|
+
return {};
|
|
27866
|
+
}
|
|
27867
|
+
try {
|
|
27868
|
+
return JSON.parse(trimmed);
|
|
27869
|
+
} catch {
|
|
27870
|
+
return {};
|
|
27871
|
+
}
|
|
27872
|
+
}
|
|
27873
|
+
function handleAnnotationNode(params2) {
|
|
27874
|
+
const { nodes } = params2;
|
|
27875
|
+
if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
|
|
27876
|
+
return null;
|
|
27877
|
+
}
|
|
27878
|
+
const node = nodes[0];
|
|
27879
|
+
const sdtPr = node.elements.find((el) => el.name === "w:sdtPr");
|
|
27880
|
+
const sdtContent = node.elements.find((el) => el.name === "w:sdtContent");
|
|
27881
|
+
const sdtId = sdtPr?.elements?.find((el) => el.name === "w:id");
|
|
27882
|
+
const alias = sdtPr?.elements.find((el) => el.name === "w:alias");
|
|
27883
|
+
const tag = sdtPr?.elements.find((el) => el.name === "w:tag");
|
|
28541
27884
|
const tagValue = tag?.attributes["w:val"];
|
|
28542
27885
|
const shouldProcessAsJson = tagValue?.startsWith("{") && tagValue?.endsWith("}");
|
|
28543
27886
|
let attrs = {};
|
|
@@ -29835,32 +29178,32 @@ function translateAnchorNode(params2) {
|
|
|
29835
29178
|
elements: [...anchorElements, ...elementsWithWrap]
|
|
29836
29179
|
};
|
|
29837
29180
|
}
|
|
29838
|
-
const XML_NODE_NAME$
|
|
29839
|
-
const SD_NODE_NAME$
|
|
29181
|
+
const XML_NODE_NAME$e = "wp:anchor";
|
|
29182
|
+
const SD_NODE_NAME$b = ["image"];
|
|
29840
29183
|
const validXmlAttributes$9 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
29841
|
-
function encode$
|
|
29184
|
+
function encode$k(params2) {
|
|
29842
29185
|
const { node } = params2.extraParams;
|
|
29843
29186
|
if (!node || !node.type) {
|
|
29844
29187
|
return null;
|
|
29845
29188
|
}
|
|
29846
29189
|
return handleAnchorNode(params2);
|
|
29847
29190
|
}
|
|
29848
|
-
function decode$
|
|
29191
|
+
function decode$m(params2) {
|
|
29849
29192
|
const { node } = params2;
|
|
29850
29193
|
if (!node || !node.type) {
|
|
29851
29194
|
return null;
|
|
29852
29195
|
}
|
|
29853
29196
|
return translateAnchorNode(params2);
|
|
29854
29197
|
}
|
|
29855
|
-
const config$
|
|
29856
|
-
xmlName: XML_NODE_NAME$
|
|
29857
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
29198
|
+
const config$d = {
|
|
29199
|
+
xmlName: XML_NODE_NAME$e,
|
|
29200
|
+
sdNodeOrKeyName: SD_NODE_NAME$b,
|
|
29858
29201
|
type: NodeTranslator.translatorTypes.NODE,
|
|
29859
|
-
encode: encode$
|
|
29860
|
-
decode: decode$
|
|
29202
|
+
encode: encode$k,
|
|
29203
|
+
decode: decode$m,
|
|
29861
29204
|
attributes: validXmlAttributes$9
|
|
29862
29205
|
};
|
|
29863
|
-
const translator$
|
|
29206
|
+
const translator$t = NodeTranslator.from(config$d);
|
|
29864
29207
|
function handleInlineNode(params2) {
|
|
29865
29208
|
const { node } = params2.extraParams;
|
|
29866
29209
|
if (node.name !== "wp:inline") {
|
|
@@ -29876,41 +29219,41 @@ function translateInlineNode(params2) {
|
|
|
29876
29219
|
elements: nodeElements.elements
|
|
29877
29220
|
};
|
|
29878
29221
|
}
|
|
29879
|
-
const XML_NODE_NAME$
|
|
29880
|
-
const SD_NODE_NAME$
|
|
29222
|
+
const XML_NODE_NAME$d = "wp:inline";
|
|
29223
|
+
const SD_NODE_NAME$a = ["image"];
|
|
29881
29224
|
const validXmlAttributes$8 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
29882
|
-
function encode$
|
|
29225
|
+
function encode$j(params2) {
|
|
29883
29226
|
const { node } = params2.extraParams;
|
|
29884
29227
|
if (!node || !node.type) {
|
|
29885
29228
|
return null;
|
|
29886
29229
|
}
|
|
29887
29230
|
return handleInlineNode(params2);
|
|
29888
29231
|
}
|
|
29889
|
-
function decode$
|
|
29232
|
+
function decode$l(params2) {
|
|
29890
29233
|
const { node } = params2;
|
|
29891
29234
|
if (!node || !node.type) {
|
|
29892
29235
|
return null;
|
|
29893
29236
|
}
|
|
29894
29237
|
return translateInlineNode(params2);
|
|
29895
29238
|
}
|
|
29896
|
-
const config$
|
|
29897
|
-
xmlName: XML_NODE_NAME$
|
|
29898
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
29239
|
+
const config$c = {
|
|
29240
|
+
xmlName: XML_NODE_NAME$d,
|
|
29241
|
+
sdNodeOrKeyName: SD_NODE_NAME$a,
|
|
29899
29242
|
type: NodeTranslator.translatorTypes.NODE,
|
|
29900
|
-
encode: encode$
|
|
29901
|
-
decode: decode$
|
|
29243
|
+
encode: encode$j,
|
|
29244
|
+
decode: decode$l,
|
|
29902
29245
|
attributes: validXmlAttributes$8
|
|
29903
29246
|
};
|
|
29904
|
-
const translator$
|
|
29905
|
-
const XML_NODE_NAME$
|
|
29906
|
-
const SD_NODE_NAME$
|
|
29247
|
+
const translator$s = NodeTranslator.from(config$c);
|
|
29248
|
+
const XML_NODE_NAME$c = "w:drawing";
|
|
29249
|
+
const SD_NODE_NAME$9 = [];
|
|
29907
29250
|
const validXmlAttributes$7 = [];
|
|
29908
|
-
function encode$
|
|
29251
|
+
function encode$i(params2) {
|
|
29909
29252
|
const nodes = params2.nodes;
|
|
29910
29253
|
const node = nodes[0];
|
|
29911
29254
|
const translatorByChildName = {
|
|
29912
|
-
"wp:anchor": translator$
|
|
29913
|
-
"wp:inline": translator$
|
|
29255
|
+
"wp:anchor": translator$t,
|
|
29256
|
+
"wp:inline": translator$s
|
|
29914
29257
|
};
|
|
29915
29258
|
return node.elements.reduce((acc, child) => {
|
|
29916
29259
|
if (acc) return acc;
|
|
@@ -29919,12 +29262,12 @@ function encode$g(params2) {
|
|
|
29919
29262
|
return translator2.encode({ ...params2, extraParams: { node: child } }) || acc;
|
|
29920
29263
|
}, null);
|
|
29921
29264
|
}
|
|
29922
|
-
function decode$
|
|
29265
|
+
function decode$k(params2) {
|
|
29923
29266
|
const { node } = params2;
|
|
29924
29267
|
if (!node || !node.type) {
|
|
29925
29268
|
return null;
|
|
29926
29269
|
}
|
|
29927
|
-
const childTranslator = node.attrs.isAnchor ? translator$
|
|
29270
|
+
const childTranslator = node.attrs.isAnchor ? translator$t : translator$s;
|
|
29928
29271
|
const resultNode = childTranslator.decode(params2);
|
|
29929
29272
|
return wrapTextInRun(
|
|
29930
29273
|
{
|
|
@@ -29934,15 +29277,15 @@ function decode$i(params2) {
|
|
|
29934
29277
|
[]
|
|
29935
29278
|
);
|
|
29936
29279
|
}
|
|
29937
|
-
const config$
|
|
29938
|
-
xmlName: XML_NODE_NAME$
|
|
29939
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
29280
|
+
const config$b = {
|
|
29281
|
+
xmlName: XML_NODE_NAME$c,
|
|
29282
|
+
sdNodeOrKeyName: SD_NODE_NAME$9,
|
|
29940
29283
|
type: NodeTranslator.translatorTypes.NODE,
|
|
29941
|
-
encode: encode$
|
|
29942
|
-
decode: decode$
|
|
29284
|
+
encode: encode$i,
|
|
29285
|
+
decode: decode$k,
|
|
29943
29286
|
attributes: validXmlAttributes$7
|
|
29944
29287
|
};
|
|
29945
|
-
const translator$
|
|
29288
|
+
const translator$r = NodeTranslator.from(config$b);
|
|
29946
29289
|
class CommandService {
|
|
29947
29290
|
/**
|
|
29948
29291
|
* @param {import('./commands/types/index.js').CommandServiceOptions} props
|
|
@@ -31290,7 +30633,7 @@ function prepareTextAnnotation(params2) {
|
|
|
31290
30633
|
return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params2);
|
|
31291
30634
|
}
|
|
31292
30635
|
function prepareImageAnnotation(params2, imageSize) {
|
|
31293
|
-
return translator$
|
|
30636
|
+
return translator$r.decode({
|
|
31294
30637
|
...params2,
|
|
31295
30638
|
imageSize
|
|
31296
30639
|
});
|
|
@@ -31317,324 +30660,901 @@ function prepareHtmlAnnotation(params2) {
|
|
|
31317
30660
|
if (allMarks.length) {
|
|
31318
30661
|
state2 = applyMarksToHtmlAnnotation(state2, allMarks);
|
|
31319
30662
|
}
|
|
31320
|
-
const htmlAnnotationNode = state2.doc.toJSON();
|
|
31321
|
-
const listTypes = ["bulletList", "orderedList"];
|
|
31322
|
-
const { editor } = params2;
|
|
31323
|
-
const seenLists = /* @__PURE__ */ new Map();
|
|
31324
|
-
state2.doc.descendants((node) => {
|
|
31325
|
-
if (listTypes.includes(node.type.name)) {
|
|
31326
|
-
const listItem = node.firstChild;
|
|
31327
|
-
const { attrs: attrs2 } = listItem;
|
|
31328
|
-
const { level, numId } = attrs2;
|
|
31329
|
-
if (!seenLists.has(numId)) {
|
|
31330
|
-
const newNumId = ListHelpers.changeNumIdSameAbstract(numId, level, node.type.name, editor);
|
|
31331
|
-
listItem.attrs.numId = newNumId;
|
|
31332
|
-
seenLists.set(numId, newNumId);
|
|
31333
|
-
} else {
|
|
31334
|
-
const newNumId = seenLists.get(numId);
|
|
31335
|
-
listItem.attrs.numId = newNumId;
|
|
31336
|
-
}
|
|
31337
|
-
}
|
|
31338
|
-
});
|
|
31339
|
-
const elements = translateChildNodes({
|
|
31340
|
-
...params2,
|
|
31341
|
-
node: htmlAnnotationNode
|
|
31342
|
-
});
|
|
31343
|
-
return {
|
|
31344
|
-
name: "htmlAnnotation",
|
|
31345
|
-
elements
|
|
31346
|
-
};
|
|
31347
|
-
}
|
|
31348
|
-
function prepareUrlAnnotation(params2) {
|
|
31349
|
-
const {
|
|
31350
|
-
node: { attrs = {}, marks = [] }
|
|
31351
|
-
} = params2;
|
|
31352
|
-
if (!attrs.linkUrl) return prepareTextAnnotation(params2);
|
|
31353
|
-
const newId = addNewLinkRelationship(params2, attrs.linkUrl);
|
|
31354
|
-
const linkTextNode = getTextNodeForExport(attrs.linkUrl, marks, params2);
|
|
31355
|
-
const contentNode = processLinkContentNode(linkTextNode);
|
|
30663
|
+
const htmlAnnotationNode = state2.doc.toJSON();
|
|
30664
|
+
const listTypes = ["bulletList", "orderedList"];
|
|
30665
|
+
const { editor } = params2;
|
|
30666
|
+
const seenLists = /* @__PURE__ */ new Map();
|
|
30667
|
+
state2.doc.descendants((node) => {
|
|
30668
|
+
if (listTypes.includes(node.type.name)) {
|
|
30669
|
+
const listItem = node.firstChild;
|
|
30670
|
+
const { attrs: attrs2 } = listItem;
|
|
30671
|
+
const { level, numId } = attrs2;
|
|
30672
|
+
if (!seenLists.has(numId)) {
|
|
30673
|
+
const newNumId = ListHelpers.changeNumIdSameAbstract(numId, level, node.type.name, editor);
|
|
30674
|
+
listItem.attrs.numId = newNumId;
|
|
30675
|
+
seenLists.set(numId, newNumId);
|
|
30676
|
+
} else {
|
|
30677
|
+
const newNumId = seenLists.get(numId);
|
|
30678
|
+
listItem.attrs.numId = newNumId;
|
|
30679
|
+
}
|
|
30680
|
+
}
|
|
30681
|
+
});
|
|
30682
|
+
const elements = translateChildNodes({
|
|
30683
|
+
...params2,
|
|
30684
|
+
node: htmlAnnotationNode
|
|
30685
|
+
});
|
|
30686
|
+
return {
|
|
30687
|
+
name: "htmlAnnotation",
|
|
30688
|
+
elements
|
|
30689
|
+
};
|
|
30690
|
+
}
|
|
30691
|
+
function prepareUrlAnnotation(params2) {
|
|
30692
|
+
const {
|
|
30693
|
+
node: { attrs = {}, marks = [] }
|
|
30694
|
+
} = params2;
|
|
30695
|
+
if (!attrs.linkUrl) return prepareTextAnnotation(params2);
|
|
30696
|
+
const newId = addNewLinkRelationship(params2, attrs.linkUrl);
|
|
30697
|
+
const linkTextNode = getTextNodeForExport(attrs.linkUrl, marks, params2);
|
|
30698
|
+
const contentNode = processLinkContentNode(linkTextNode);
|
|
30699
|
+
return {
|
|
30700
|
+
name: "w:hyperlink",
|
|
30701
|
+
type: "element",
|
|
30702
|
+
attributes: {
|
|
30703
|
+
"r:id": newId,
|
|
30704
|
+
"w:history": 1
|
|
30705
|
+
},
|
|
30706
|
+
elements: [contentNode]
|
|
30707
|
+
};
|
|
30708
|
+
}
|
|
30709
|
+
function translateFieldAttrsToMarks(attrs = {}) {
|
|
30710
|
+
const { fontFamily: fontFamily2, fontSize: fontSize2, bold, underline, italic, textColor, textHighlight } = attrs;
|
|
30711
|
+
const marks = [];
|
|
30712
|
+
if (fontFamily2) marks.push({ type: "fontFamily", attrs: { fontFamily: fontFamily2 } });
|
|
30713
|
+
if (fontSize2) marks.push({ type: "fontSize", attrs: { fontSize: fontSize2 } });
|
|
30714
|
+
if (bold) marks.push({ type: "bold", attrs: {} });
|
|
30715
|
+
if (underline) marks.push({ type: "underline", attrs: {} });
|
|
30716
|
+
if (italic) marks.push({ type: "italic", attrs: {} });
|
|
30717
|
+
if (textColor) marks.push({ type: "color", attrs: { color: textColor } });
|
|
30718
|
+
if (textHighlight) marks.push({ type: "highlight", attrs: { color: textHighlight } });
|
|
30719
|
+
return marks;
|
|
30720
|
+
}
|
|
30721
|
+
function applyMarksToHtmlAnnotation(state2, marks) {
|
|
30722
|
+
const { tr, doc: doc2, schema } = state2;
|
|
30723
|
+
const allowedMarks = ["fontFamily", "fontSize", "highlight"];
|
|
30724
|
+
if (!marks.some((m2) => allowedMarks.includes(m2.type))) {
|
|
30725
|
+
return state2;
|
|
30726
|
+
}
|
|
30727
|
+
const fontFamily2 = marks.find((m2) => m2.type === "fontFamily");
|
|
30728
|
+
const fontSize2 = marks.find((m2) => m2.type === "fontSize");
|
|
30729
|
+
const highlight = marks.find((m2) => m2.type === "highlight");
|
|
30730
|
+
const textStyleType = schema.marks.textStyle;
|
|
30731
|
+
const highlightType = schema.marks.highlight;
|
|
30732
|
+
doc2.descendants((node, pos) => {
|
|
30733
|
+
if (!node.isText) return;
|
|
30734
|
+
const foundTextStyle = node.marks.find((m2) => m2.type.name === "textStyle");
|
|
30735
|
+
const foundHighlight = node.marks.find((m2) => m2.type.name === "highlight");
|
|
30736
|
+
if (!foundTextStyle) {
|
|
30737
|
+
tr.addMark(
|
|
30738
|
+
pos,
|
|
30739
|
+
pos + node.nodeSize,
|
|
30740
|
+
textStyleType.create({
|
|
30741
|
+
...fontFamily2?.attrs,
|
|
30742
|
+
...fontSize2?.attrs
|
|
30743
|
+
})
|
|
30744
|
+
);
|
|
30745
|
+
} else if (!foundTextStyle?.attrs.fontFamily && fontFamily2) {
|
|
30746
|
+
tr.addMark(
|
|
30747
|
+
pos,
|
|
30748
|
+
pos + node.nodeSize,
|
|
30749
|
+
textStyleType.create({
|
|
30750
|
+
...foundTextStyle?.attrs,
|
|
30751
|
+
...fontFamily2.attrs
|
|
30752
|
+
})
|
|
30753
|
+
);
|
|
30754
|
+
} else if (!foundTextStyle?.attrs.fontSize && fontSize2) {
|
|
30755
|
+
tr.addMark(
|
|
30756
|
+
pos,
|
|
30757
|
+
pos + node.nodeSize,
|
|
30758
|
+
textStyleType.create({
|
|
30759
|
+
...foundTextStyle?.attrs,
|
|
30760
|
+
...fontSize2.attrs
|
|
30761
|
+
})
|
|
30762
|
+
);
|
|
30763
|
+
}
|
|
30764
|
+
if (!foundHighlight) {
|
|
30765
|
+
tr.addMark(
|
|
30766
|
+
pos,
|
|
30767
|
+
pos + node.nodeSize,
|
|
30768
|
+
highlightType.create({
|
|
30769
|
+
...highlight?.attrs
|
|
30770
|
+
})
|
|
30771
|
+
);
|
|
30772
|
+
}
|
|
30773
|
+
});
|
|
30774
|
+
return state2.apply(tr);
|
|
30775
|
+
}
|
|
30776
|
+
function getFieldHighlightJson(fieldsHighlightColor) {
|
|
30777
|
+
if (!fieldsHighlightColor) return null;
|
|
30778
|
+
let parsedColor = fieldsHighlightColor.trim();
|
|
30779
|
+
const hexRegex2 = /^#?([A-Fa-f0-9]{3}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/;
|
|
30780
|
+
if (!hexRegex2.test(parsedColor)) {
|
|
30781
|
+
console.warn(`Invalid HEX color provided to fieldsHighlightColor export param: ${fieldsHighlightColor}`);
|
|
30782
|
+
return null;
|
|
30783
|
+
}
|
|
30784
|
+
if (parsedColor.startsWith("#")) {
|
|
30785
|
+
parsedColor = parsedColor.slice(1);
|
|
30786
|
+
}
|
|
30787
|
+
return {
|
|
30788
|
+
name: "w:rPr",
|
|
30789
|
+
elements: [
|
|
30790
|
+
{
|
|
30791
|
+
name: "w:shd",
|
|
30792
|
+
attributes: {
|
|
30793
|
+
"w:fill": `#${parsedColor}`,
|
|
30794
|
+
"w:color": "auto",
|
|
30795
|
+
"w:val": "clear"
|
|
30796
|
+
}
|
|
30797
|
+
}
|
|
30798
|
+
]
|
|
30799
|
+
};
|
|
30800
|
+
}
|
|
30801
|
+
function translateDocumentSection(params2) {
|
|
30802
|
+
const { node } = params2;
|
|
30803
|
+
const { attrs = {} } = node;
|
|
30804
|
+
const childContent = translateChildNodes({ ...params2, nodes: node.content });
|
|
30805
|
+
const nodeElements = [
|
|
30806
|
+
{
|
|
30807
|
+
name: "w:sdtContent",
|
|
30808
|
+
elements: childContent
|
|
30809
|
+
}
|
|
30810
|
+
];
|
|
30811
|
+
const exportedTag = JSON.stringify({
|
|
30812
|
+
type: "documentSection",
|
|
30813
|
+
description: attrs.description
|
|
30814
|
+
});
|
|
30815
|
+
const sdtPr = generateSdtPrTagForDocumentSection(attrs.id, attrs.title, exportedTag);
|
|
30816
|
+
const { isLocked } = attrs;
|
|
30817
|
+
if (isLocked) {
|
|
30818
|
+
sdtPr.elements.push({
|
|
30819
|
+
name: "w:lock",
|
|
30820
|
+
attributes: {
|
|
30821
|
+
"w:val": "sdtContentLocked"
|
|
30822
|
+
}
|
|
30823
|
+
});
|
|
30824
|
+
}
|
|
30825
|
+
nodeElements.unshift(sdtPr);
|
|
30826
|
+
const result = {
|
|
30827
|
+
name: "w:sdt",
|
|
30828
|
+
elements: nodeElements
|
|
30829
|
+
};
|
|
30830
|
+
return result;
|
|
30831
|
+
}
|
|
30832
|
+
const generateSdtPrTagForDocumentSection = (id, title, tag) => {
|
|
30833
|
+
return {
|
|
30834
|
+
name: "w:sdtPr",
|
|
30835
|
+
elements: [
|
|
30836
|
+
{
|
|
30837
|
+
name: "w:id",
|
|
30838
|
+
attributes: {
|
|
30839
|
+
"w:val": id
|
|
30840
|
+
}
|
|
30841
|
+
},
|
|
30842
|
+
{
|
|
30843
|
+
name: "w:alias",
|
|
30844
|
+
attributes: {
|
|
30845
|
+
"w:val": title
|
|
30846
|
+
}
|
|
30847
|
+
},
|
|
30848
|
+
{
|
|
30849
|
+
name: "w:tag",
|
|
30850
|
+
attributes: {
|
|
30851
|
+
"w:val": tag
|
|
30852
|
+
}
|
|
30853
|
+
}
|
|
30854
|
+
]
|
|
30855
|
+
};
|
|
30856
|
+
};
|
|
30857
|
+
function translateDocumentPartObj(params2) {
|
|
30858
|
+
const { node } = params2;
|
|
30859
|
+
const { attrs = {} } = node;
|
|
30860
|
+
const childContent = translateChildNodes({ ...params2, nodes: node.content });
|
|
30861
|
+
const nodeElements = [
|
|
30862
|
+
{
|
|
30863
|
+
name: "w:sdtPr",
|
|
30864
|
+
elements: [
|
|
30865
|
+
{
|
|
30866
|
+
name: "w:id",
|
|
30867
|
+
attributes: {
|
|
30868
|
+
"w:val": attrs.id
|
|
30869
|
+
}
|
|
30870
|
+
},
|
|
30871
|
+
{
|
|
30872
|
+
name: "w:docPartObj",
|
|
30873
|
+
elements: [
|
|
30874
|
+
{
|
|
30875
|
+
name: "w:docPartGallery",
|
|
30876
|
+
attributes: {
|
|
30877
|
+
"w:val": attrs.docPartGallery
|
|
30878
|
+
}
|
|
30879
|
+
},
|
|
30880
|
+
...attrs.docPartUnique ? [
|
|
30881
|
+
{
|
|
30882
|
+
name: "w:docPartUnique"
|
|
30883
|
+
}
|
|
30884
|
+
] : []
|
|
30885
|
+
]
|
|
30886
|
+
}
|
|
30887
|
+
]
|
|
30888
|
+
},
|
|
30889
|
+
{
|
|
30890
|
+
name: "w:sdtContent",
|
|
30891
|
+
elements: childContent
|
|
30892
|
+
}
|
|
30893
|
+
];
|
|
30894
|
+
const result = {
|
|
30895
|
+
name: "w:sdt",
|
|
30896
|
+
elements: nodeElements
|
|
30897
|
+
};
|
|
30898
|
+
return result;
|
|
30899
|
+
}
|
|
30900
|
+
function translateStructuredContent(params2) {
|
|
30901
|
+
const { node } = params2;
|
|
30902
|
+
const childContent = translateChildNodes({ ...params2, nodes: node.content });
|
|
30903
|
+
const sdtContent = { name: "w:sdtContent", elements: childContent };
|
|
30904
|
+
const sdtPr = generateSdtPrTagForStructuredContent({ node });
|
|
30905
|
+
const nodeElements = [sdtPr, sdtContent];
|
|
30906
|
+
const result = {
|
|
30907
|
+
name: "w:sdt",
|
|
30908
|
+
elements: nodeElements
|
|
30909
|
+
};
|
|
30910
|
+
return result;
|
|
30911
|
+
}
|
|
30912
|
+
function generateSdtPrTagForStructuredContent({ node }) {
|
|
30913
|
+
const { attrs = {} } = node;
|
|
30914
|
+
const id = {
|
|
30915
|
+
name: "w:id",
|
|
30916
|
+
type: "element",
|
|
30917
|
+
attributes: { "w:val": attrs.id }
|
|
30918
|
+
};
|
|
30919
|
+
const alias = {
|
|
30920
|
+
name: "w:alias",
|
|
30921
|
+
type: "element",
|
|
30922
|
+
attributes: { "w:val": attrs.alias }
|
|
30923
|
+
};
|
|
30924
|
+
const tag = {
|
|
30925
|
+
name: "w:tag",
|
|
30926
|
+
type: "element",
|
|
30927
|
+
attributes: { "w:val": attrs.tag }
|
|
30928
|
+
};
|
|
30929
|
+
const resultElements = [];
|
|
30930
|
+
if (attrs.id) resultElements.push(id);
|
|
30931
|
+
if (attrs.alias) resultElements.push(alias);
|
|
30932
|
+
if (attrs.tag) resultElements.push(tag);
|
|
30933
|
+
if (attrs.sdtPr) {
|
|
30934
|
+
const elements = attrs.sdtPr.elements || [];
|
|
30935
|
+
const elementsToExclude = ["w:id", "w:alias", "w:tag"];
|
|
30936
|
+
const restElements = elements.filter((el) => !elementsToExclude.includes(el.name));
|
|
30937
|
+
const result2 = {
|
|
30938
|
+
name: "w:sdtPr",
|
|
30939
|
+
type: "element",
|
|
30940
|
+
elements: [...resultElements, ...restElements]
|
|
30941
|
+
};
|
|
30942
|
+
return result2;
|
|
30943
|
+
}
|
|
30944
|
+
const result = {
|
|
30945
|
+
name: "w:sdtPr",
|
|
30946
|
+
type: "element",
|
|
30947
|
+
elements: resultElements
|
|
30948
|
+
};
|
|
30949
|
+
return result;
|
|
30950
|
+
}
|
|
30951
|
+
const XML_NODE_NAME$b = "w:sdt";
|
|
30952
|
+
const SD_NODE_NAME$8 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
|
|
30953
|
+
const validXmlAttributes$6 = [];
|
|
30954
|
+
function encode$h(params2) {
|
|
30955
|
+
const nodes = params2.nodes;
|
|
30956
|
+
const node = nodes[0];
|
|
30957
|
+
const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
|
|
30958
|
+
if (!handler2 || sdtType === "unknown") {
|
|
30959
|
+
return void 0;
|
|
30960
|
+
}
|
|
30961
|
+
const result = handler2(params2);
|
|
30962
|
+
return result;
|
|
30963
|
+
}
|
|
30964
|
+
function decode$j(params2) {
|
|
30965
|
+
const { node } = params2;
|
|
30966
|
+
if (!node || !node.type) {
|
|
30967
|
+
return null;
|
|
30968
|
+
}
|
|
30969
|
+
const types2 = {
|
|
30970
|
+
fieldAnnotation: () => translateFieldAnnotation(params2),
|
|
30971
|
+
structuredContent: () => translateStructuredContent(params2),
|
|
30972
|
+
structuredContentBlock: () => translateStructuredContent(params2),
|
|
30973
|
+
documentSection: () => translateDocumentSection(params2),
|
|
30974
|
+
documentPartObject: () => translateDocumentPartObj(params2),
|
|
30975
|
+
// Handled in doc-part-obj translator
|
|
30976
|
+
default: () => null
|
|
30977
|
+
};
|
|
30978
|
+
const decoder = types2[node.type] ?? types2.default;
|
|
30979
|
+
const result = decoder();
|
|
30980
|
+
return result;
|
|
30981
|
+
}
|
|
30982
|
+
const config$a = {
|
|
30983
|
+
xmlName: XML_NODE_NAME$b,
|
|
30984
|
+
sdNodeOrKeyName: SD_NODE_NAME$8,
|
|
30985
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
30986
|
+
encode: encode$h,
|
|
30987
|
+
decode: decode$j,
|
|
30988
|
+
attributes: validXmlAttributes$6
|
|
30989
|
+
};
|
|
30990
|
+
const translator$q = NodeTranslator.from(config$a);
|
|
30991
|
+
function preProcessVerticalMergeCells(table, { editorSchema }) {
|
|
30992
|
+
if (!table || !Array.isArray(table.content)) {
|
|
30993
|
+
return table;
|
|
30994
|
+
}
|
|
30995
|
+
const rows = table.content;
|
|
30996
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
30997
|
+
const row = rows[rowIndex];
|
|
30998
|
+
if (!row) continue;
|
|
30999
|
+
if (!Array.isArray(row.content)) {
|
|
31000
|
+
row.content = [];
|
|
31001
|
+
}
|
|
31002
|
+
for (let cellIndex = 0; cellIndex < row.content.length; cellIndex++) {
|
|
31003
|
+
const cell = row.content[cellIndex];
|
|
31004
|
+
if (!cell) continue;
|
|
31005
|
+
const attrs = cell.attrs || {};
|
|
31006
|
+
if (!attrs.rowspan || attrs.rowspan <= 1) continue;
|
|
31007
|
+
const maxRowspan = Math.min(attrs.rowspan, rows.length - rowIndex);
|
|
31008
|
+
for (let offset2 = 1; offset2 < maxRowspan; offset2++) {
|
|
31009
|
+
const rowToChange = rows[rowIndex + offset2];
|
|
31010
|
+
if (!rowToChange) continue;
|
|
31011
|
+
if (!Array.isArray(rowToChange.content)) {
|
|
31012
|
+
rowToChange.content = [];
|
|
31013
|
+
}
|
|
31014
|
+
const existingCell = rowToChange.content[cellIndex];
|
|
31015
|
+
if (existingCell?.attrs?.continueMerge) continue;
|
|
31016
|
+
const mergedCell = {
|
|
31017
|
+
type: cell.type,
|
|
31018
|
+
content: [editorSchema.nodes.paragraph.createAndFill().toJSON()],
|
|
31019
|
+
attrs: {
|
|
31020
|
+
...cell.attrs,
|
|
31021
|
+
rowspan: null,
|
|
31022
|
+
continueMerge: true
|
|
31023
|
+
}
|
|
31024
|
+
};
|
|
31025
|
+
rowToChange.content.splice(cellIndex, 0, mergedCell);
|
|
31026
|
+
}
|
|
31027
|
+
}
|
|
31028
|
+
}
|
|
31029
|
+
return table;
|
|
31030
|
+
}
|
|
31031
|
+
const translator$p = NodeTranslator.from({
|
|
31032
|
+
xmlName: "w:bidiVisual",
|
|
31033
|
+
sdNodeOrKeyName: "rightToLeft",
|
|
31034
|
+
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
31035
|
+
decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
|
|
31036
|
+
});
|
|
31037
|
+
const translator$o = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
|
|
31038
|
+
const translator$n = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
|
|
31039
|
+
const translator$m = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
|
|
31040
|
+
const translator$l = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
|
|
31041
|
+
const translator$k = NodeTranslator.from({
|
|
31042
|
+
xmlName: "w:tblLook",
|
|
31043
|
+
sdNodeOrKeyName: "tblLook",
|
|
31044
|
+
attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
|
|
31045
|
+
encode: (params2, encodedAttrs) => {
|
|
31046
|
+
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
31047
|
+
},
|
|
31048
|
+
decode: function({ node }, context) {
|
|
31049
|
+
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.tblLook || {} } });
|
|
31050
|
+
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
31051
|
+
}
|
|
31052
|
+
});
|
|
31053
|
+
const translator$j = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
|
|
31054
|
+
const translator$i = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
|
|
31055
|
+
const translator$h = NodeTranslator.from(
|
|
31056
|
+
createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
|
|
31057
|
+
);
|
|
31058
|
+
const translator$g = NodeTranslator.from(
|
|
31059
|
+
createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
|
|
31060
|
+
);
|
|
31061
|
+
const translator$f = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
|
|
31062
|
+
const translator$e = NodeTranslator.from({
|
|
31063
|
+
xmlName: "w:tblpPr",
|
|
31064
|
+
sdNodeOrKeyName: "floatingTableProperties",
|
|
31065
|
+
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))),
|
|
31066
|
+
encode: (params2, encodedAttrs) => {
|
|
31067
|
+
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
31068
|
+
},
|
|
31069
|
+
decode: function({ node }, context) {
|
|
31070
|
+
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.floatingTableProperties || {} } });
|
|
31071
|
+
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
31072
|
+
}
|
|
31073
|
+
});
|
|
31074
|
+
const propertyTranslators$2 = [
|
|
31075
|
+
translator$15,
|
|
31076
|
+
translator$13,
|
|
31077
|
+
translator$11,
|
|
31078
|
+
translator$10,
|
|
31079
|
+
translator$$,
|
|
31080
|
+
translator$Z,
|
|
31081
|
+
translator$X,
|
|
31082
|
+
translator$V
|
|
31083
|
+
];
|
|
31084
|
+
const translator$d = NodeTranslator.from(
|
|
31085
|
+
createNestedPropertiesTranslator("w:tblBorders", "borders", propertyTranslators$2)
|
|
31086
|
+
);
|
|
31087
|
+
const propertyTranslators$1 = [
|
|
31088
|
+
translator$14,
|
|
31089
|
+
translator$12,
|
|
31090
|
+
translator$_,
|
|
31091
|
+
translator$Y,
|
|
31092
|
+
translator$W,
|
|
31093
|
+
translator$U
|
|
31094
|
+
];
|
|
31095
|
+
const translator$c = NodeTranslator.from(
|
|
31096
|
+
createNestedPropertiesTranslator("w:tblCellMar", "cellMargins", propertyTranslators$1)
|
|
31097
|
+
);
|
|
31098
|
+
const propertyTranslators = [
|
|
31099
|
+
translator$p,
|
|
31100
|
+
translator$B,
|
|
31101
|
+
translator$19,
|
|
31102
|
+
translator$o,
|
|
31103
|
+
translator$A,
|
|
31104
|
+
translator$n,
|
|
31105
|
+
translator$m,
|
|
31106
|
+
translator$l,
|
|
31107
|
+
translator$k,
|
|
31108
|
+
translator$j,
|
|
31109
|
+
translator$i,
|
|
31110
|
+
translator$h,
|
|
31111
|
+
translator$g,
|
|
31112
|
+
translator$f,
|
|
31113
|
+
translator$e,
|
|
31114
|
+
translator$d,
|
|
31115
|
+
translator$c
|
|
31116
|
+
];
|
|
31117
|
+
const translator$b = NodeTranslator.from(
|
|
31118
|
+
createNestedPropertiesTranslator("w:tblPr", "tableProperties", propertyTranslators)
|
|
31119
|
+
);
|
|
31120
|
+
const translator$a = NodeTranslator.from(
|
|
31121
|
+
createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
|
|
31122
|
+
);
|
|
31123
|
+
const DEFAULT_COLUMN_WIDTH_PX = 100;
|
|
31124
|
+
const normalizeTwipWidth = (value) => {
|
|
31125
|
+
if (value == null) return null;
|
|
31126
|
+
const numericValue = typeof value === "string" ? parseInt(value, 10) : value;
|
|
31127
|
+
if (!Number.isFinite(numericValue) || Number.isNaN(numericValue) || numericValue <= 0) {
|
|
31128
|
+
return null;
|
|
31129
|
+
}
|
|
31130
|
+
return numericValue;
|
|
31131
|
+
};
|
|
31132
|
+
const getSchemaDefaultColumnWidthPx = (params2) => {
|
|
31133
|
+
const defaultValue = params2?.editor?.schema?.nodes?.tableCell?.spec?.attrs?.colwidth?.default;
|
|
31134
|
+
if (Array.isArray(defaultValue)) {
|
|
31135
|
+
const numericWidth = defaultValue.find((width) => typeof width === "number" && Number.isFinite(width) && width > 0);
|
|
31136
|
+
if (numericWidth != null) return numericWidth;
|
|
31137
|
+
} else if (typeof defaultValue === "number" && Number.isFinite(defaultValue) && defaultValue > 0) {
|
|
31138
|
+
return defaultValue;
|
|
31139
|
+
}
|
|
31140
|
+
return DEFAULT_COLUMN_WIDTH_PX;
|
|
31141
|
+
};
|
|
31142
|
+
const getTableWidthPx = (params2) => {
|
|
31143
|
+
const explicitWidth = params2?.node?.attrs?.tableWidth?.width;
|
|
31144
|
+
if (typeof explicitWidth === "number" && explicitWidth > 0) return explicitWidth;
|
|
31145
|
+
const tableWidth = params2?.node?.attrs?.tableProperties?.tableWidth;
|
|
31146
|
+
if (tableWidth?.value != null && typeof tableWidth.value === "number" && tableWidth.value > 0) {
|
|
31147
|
+
const { value, type: type2 } = tableWidth;
|
|
31148
|
+
if (!type2 || type2 === "auto" || type2 === "dxa") {
|
|
31149
|
+
return twipsToPixels(value);
|
|
31150
|
+
}
|
|
31151
|
+
}
|
|
31152
|
+
return null;
|
|
31153
|
+
};
|
|
31154
|
+
const resolveFallbackColumnWidthTwips = (params2, totalColumns, cellMinWidthTwips) => {
|
|
31155
|
+
const columnCount = Math.max(totalColumns, 1);
|
|
31156
|
+
const defaultColumnWidthPx = getSchemaDefaultColumnWidthPx(params2);
|
|
31157
|
+
const tableWidthPx = getTableWidthPx(params2);
|
|
31158
|
+
const safeDefaultPx = Number.isFinite(defaultColumnWidthPx) && defaultColumnWidthPx > 0 ? defaultColumnWidthPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
31159
|
+
let fallbackWidthPx = safeDefaultPx;
|
|
31160
|
+
if (typeof tableWidthPx === "number" && tableWidthPx > 0) {
|
|
31161
|
+
fallbackWidthPx = tableWidthPx / columnCount;
|
|
31162
|
+
}
|
|
31163
|
+
const fallbackWidthTwips = pixelsToTwips(fallbackWidthPx);
|
|
31164
|
+
if (!Number.isFinite(fallbackWidthTwips) || Number.isNaN(fallbackWidthTwips) || fallbackWidthTwips <= 0) {
|
|
31165
|
+
const safeDefault = Math.max(pixelsToTwips(safeDefaultPx), cellMinWidthTwips);
|
|
31166
|
+
return safeDefault;
|
|
31167
|
+
}
|
|
31168
|
+
return Math.max(fallbackWidthTwips, cellMinWidthTwips);
|
|
31169
|
+
};
|
|
31170
|
+
const XML_NODE_NAME$a = "w:tblGrid";
|
|
31171
|
+
const SD_ATTR_KEY$2 = "grid";
|
|
31172
|
+
const cellMinWidth = pixelsToTwips(10);
|
|
31173
|
+
const encode$g = (params2) => {
|
|
31174
|
+
const { nodes } = params2;
|
|
31175
|
+
const node = nodes[0];
|
|
31176
|
+
const attributes = encodeProperties(node, { [translator$a.xmlName]: translator$a }, true);
|
|
31177
|
+
return {
|
|
31178
|
+
xmlName: XML_NODE_NAME$a,
|
|
31179
|
+
sdNodeOrKeyName: SD_ATTR_KEY$2,
|
|
31180
|
+
attributes
|
|
31181
|
+
};
|
|
31182
|
+
};
|
|
31183
|
+
const decode$i = (params2) => {
|
|
31184
|
+
const { grid: rawGrid } = params2.node.attrs || {};
|
|
31185
|
+
const grid = Array.isArray(rawGrid) ? rawGrid : [];
|
|
31186
|
+
const { firstRow = {} } = params2.extraParams || {};
|
|
31187
|
+
const cellNodes = firstRow.content?.filter((n) => n.type === "tableCell") ?? [];
|
|
31188
|
+
const columnCountFromCells = cellNodes.reduce((count, cell) => {
|
|
31189
|
+
const spanCount = Math.max(1, cell?.attrs?.colspan ?? 1);
|
|
31190
|
+
return count + spanCount;
|
|
31191
|
+
}, 0);
|
|
31192
|
+
const totalColumns = Math.max(columnCountFromCells, grid.length);
|
|
31193
|
+
const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params2, totalColumns, cellMinWidth);
|
|
31194
|
+
const elements = [];
|
|
31195
|
+
let columnIndex = 0;
|
|
31196
|
+
const pushColumn = (widthTwips, { enforceMinimum = false } = {}) => {
|
|
31197
|
+
let numericWidth = typeof widthTwips === "string" ? parseInt(widthTwips, 10) : widthTwips;
|
|
31198
|
+
let shouldEnforceMinimum = enforceMinimum;
|
|
31199
|
+
if (numericWidth == null || Number.isNaN(numericWidth) || numericWidth <= 0) {
|
|
31200
|
+
numericWidth = fallbackColumnWidthTwips;
|
|
31201
|
+
shouldEnforceMinimum = true;
|
|
31202
|
+
}
|
|
31203
|
+
const roundedWidth = Math.round(numericWidth);
|
|
31204
|
+
const minimumWidth = shouldEnforceMinimum ? cellMinWidth : 1;
|
|
31205
|
+
const safeWidth = Math.max(roundedWidth, minimumWidth);
|
|
31206
|
+
const decoded = translator$a.decode({
|
|
31207
|
+
node: { type: (
|
|
31208
|
+
/** @type {string} */
|
|
31209
|
+
translator$a.sdNodeOrKeyName
|
|
31210
|
+
), attrs: { col: safeWidth } }
|
|
31211
|
+
});
|
|
31212
|
+
if (decoded) elements.push(decoded);
|
|
31213
|
+
};
|
|
31214
|
+
cellNodes.forEach((cell) => {
|
|
31215
|
+
const { colspan = 1, colwidth } = cell?.attrs || {};
|
|
31216
|
+
const spanCount = Math.max(1, colspan);
|
|
31217
|
+
for (let span = 0; span < spanCount; span++) {
|
|
31218
|
+
const rawWidth = Array.isArray(colwidth) ? colwidth[span] : void 0;
|
|
31219
|
+
const cellWidthPixels = typeof rawWidth === "number" && Number.isFinite(rawWidth) ? rawWidth : Number(rawWidth);
|
|
31220
|
+
const hasCellWidth = Number.isFinite(cellWidthPixels) && cellWidthPixels > 0;
|
|
31221
|
+
const colGridAttrs = grid?.[columnIndex] || {};
|
|
31222
|
+
const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
|
|
31223
|
+
const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
|
|
31224
|
+
let cellWidthTwips;
|
|
31225
|
+
let enforceMinimum = false;
|
|
31226
|
+
if (hasCellWidth) {
|
|
31227
|
+
const tolerance = 0.5;
|
|
31228
|
+
if (gridWidthTwips != null && gridWidthPixels != null && Math.abs(gridWidthPixels - cellWidthPixels) <= tolerance) {
|
|
31229
|
+
cellWidthTwips = gridWidthTwips;
|
|
31230
|
+
} else {
|
|
31231
|
+
cellWidthTwips = pixelsToTwips(cellWidthPixels);
|
|
31232
|
+
}
|
|
31233
|
+
} else if (gridWidthTwips != null) {
|
|
31234
|
+
cellWidthTwips = gridWidthTwips;
|
|
31235
|
+
} else {
|
|
31236
|
+
cellWidthTwips = fallbackColumnWidthTwips;
|
|
31237
|
+
enforceMinimum = true;
|
|
31238
|
+
}
|
|
31239
|
+
pushColumn(cellWidthTwips, { enforceMinimum });
|
|
31240
|
+
columnIndex++;
|
|
31241
|
+
}
|
|
31242
|
+
});
|
|
31243
|
+
while (columnIndex < grid.length) {
|
|
31244
|
+
const gridWidthTwips = normalizeTwipWidth(grid[columnIndex]?.col);
|
|
31245
|
+
pushColumn(gridWidthTwips);
|
|
31246
|
+
columnIndex++;
|
|
31247
|
+
}
|
|
31248
|
+
const newNode = {
|
|
31249
|
+
name: XML_NODE_NAME$a,
|
|
31250
|
+
attributes: {},
|
|
31251
|
+
elements
|
|
31252
|
+
};
|
|
31253
|
+
return newNode;
|
|
31254
|
+
};
|
|
31255
|
+
const config$9 = {
|
|
31256
|
+
xmlName: XML_NODE_NAME$a,
|
|
31257
|
+
sdNodeOrKeyName: SD_ATTR_KEY$2,
|
|
31258
|
+
encode: encode$g,
|
|
31259
|
+
decode: decode$i
|
|
31260
|
+
};
|
|
31261
|
+
const translator$9 = NodeTranslator.from(config$9);
|
|
31262
|
+
const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
|
|
31263
|
+
const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
|
|
31264
|
+
const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
|
|
31265
|
+
const MIN_COLUMN_WIDTH_TWIPS = pixelsToTwips(10);
|
|
31266
|
+
const pctToPercent = (value) => {
|
|
31267
|
+
if (value == null) return null;
|
|
31268
|
+
return value / 50;
|
|
31269
|
+
};
|
|
31270
|
+
const resolveContentWidthTwips = () => DEFAULT_CONTENT_WIDTH_TWIPS;
|
|
31271
|
+
const resolveMeasurementWidthPx = (measurement) => {
|
|
31272
|
+
if (!measurement || typeof measurement.value !== "number" || measurement.value <= 0) return null;
|
|
31273
|
+
const { value, type: type2 } = measurement;
|
|
31274
|
+
if (!type2 || type2 === "auto") return null;
|
|
31275
|
+
if (type2 === "dxa") return twipsToPixels(value);
|
|
31276
|
+
if (type2 === "pct") {
|
|
31277
|
+
const percent2 = pctToPercent(value);
|
|
31278
|
+
if (percent2 == null || percent2 <= 0) return null;
|
|
31279
|
+
const widthTwips = resolveContentWidthTwips() * percent2 / 100;
|
|
31280
|
+
return twipsToPixels(widthTwips);
|
|
31281
|
+
}
|
|
31282
|
+
return null;
|
|
31283
|
+
};
|
|
31284
|
+
const countColumnsInRow = (row) => {
|
|
31285
|
+
if (!row?.elements?.length) return 0;
|
|
31286
|
+
return row.elements.reduce((count, element) => {
|
|
31287
|
+
if (element.name !== "w:tc") return count;
|
|
31288
|
+
const tcPr = element.elements?.find((el) => el.name === "w:tcPr");
|
|
31289
|
+
const gridSpan = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
31290
|
+
const spanValue = parseInt(gridSpan?.attributes?.["w:val"] || "1", 10);
|
|
31291
|
+
return count + (Number.isFinite(spanValue) && spanValue > 0 ? spanValue : 1);
|
|
31292
|
+
}, 0);
|
|
31293
|
+
};
|
|
31294
|
+
const clampColumnWidthTwips = (value) => Math.max(Math.round(value), MIN_COLUMN_WIDTH_TWIPS);
|
|
31295
|
+
const createFallbackGrid = (columnCount, columnWidthTwips) => Array.from({ length: columnCount }, () => ({ col: clampColumnWidthTwips(columnWidthTwips) }));
|
|
31296
|
+
const buildFallbackGridForTable = ({ params: params2, rows, tableWidth, tableWidthMeasurement }) => {
|
|
31297
|
+
const firstRow = rows.find((row) => row.elements?.some((el) => el.name === "w:tc"));
|
|
31298
|
+
const columnCount = countColumnsInRow(firstRow);
|
|
31299
|
+
if (!columnCount) return null;
|
|
31300
|
+
const schemaDefaultPx = getSchemaDefaultColumnWidthPx(
|
|
31301
|
+
/** @type {any} */
|
|
31302
|
+
params2
|
|
31303
|
+
);
|
|
31304
|
+
const minimumColumnWidthPx = Number.isFinite(schemaDefaultPx) && schemaDefaultPx > 0 ? schemaDefaultPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
31305
|
+
let totalWidthPx;
|
|
31306
|
+
if (tableWidthMeasurement) {
|
|
31307
|
+
const resolved = resolveMeasurementWidthPx(tableWidthMeasurement);
|
|
31308
|
+
if (resolved != null) totalWidthPx = resolved;
|
|
31309
|
+
}
|
|
31310
|
+
if (totalWidthPx == null && tableWidth?.width && tableWidth.width > 0) {
|
|
31311
|
+
totalWidthPx = tableWidth.width;
|
|
31312
|
+
}
|
|
31313
|
+
if (totalWidthPx == null) {
|
|
31314
|
+
totalWidthPx = minimumColumnWidthPx * columnCount;
|
|
31315
|
+
}
|
|
31316
|
+
const rawColumnWidthPx = Math.max(totalWidthPx / columnCount, minimumColumnWidthPx);
|
|
31317
|
+
const columnWidthTwips = clampColumnWidthTwips(pixelsToTwips(rawColumnWidthPx));
|
|
31318
|
+
const fallbackColumnWidthPx = twipsToPixels(columnWidthTwips);
|
|
31356
31319
|
return {
|
|
31357
|
-
|
|
31358
|
-
|
|
31359
|
-
attributes: {
|
|
31360
|
-
"r:id": newId,
|
|
31361
|
-
"w:history": 1
|
|
31362
|
-
},
|
|
31363
|
-
elements: [contentNode]
|
|
31320
|
+
grid: createFallbackGrid(columnCount, columnWidthTwips),
|
|
31321
|
+
columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
|
|
31364
31322
|
};
|
|
31365
|
-
}
|
|
31366
|
-
|
|
31367
|
-
|
|
31368
|
-
|
|
31369
|
-
|
|
31370
|
-
|
|
31371
|
-
|
|
31372
|
-
if (
|
|
31373
|
-
|
|
31374
|
-
|
|
31375
|
-
if (textHighlight) marks.push({ type: "highlight", attrs: { color: textHighlight } });
|
|
31376
|
-
return marks;
|
|
31377
|
-
}
|
|
31378
|
-
function applyMarksToHtmlAnnotation(state2, marks) {
|
|
31379
|
-
const { tr, doc: doc2, schema } = state2;
|
|
31380
|
-
const allowedMarks = ["fontFamily", "fontSize", "highlight"];
|
|
31381
|
-
if (!marks.some((m2) => allowedMarks.includes(m2.type))) {
|
|
31382
|
-
return state2;
|
|
31323
|
+
};
|
|
31324
|
+
const XML_NODE_NAME$9 = "w:tbl";
|
|
31325
|
+
const SD_NODE_NAME$7 = "table";
|
|
31326
|
+
const encode$f = (params2, encodedAttrs) => {
|
|
31327
|
+
const { nodes } = params2;
|
|
31328
|
+
const node = nodes[0];
|
|
31329
|
+
const tblPr = node.elements.find((el) => el.name === "w:tblPr");
|
|
31330
|
+
if (tblPr) {
|
|
31331
|
+
const encodedProperties = translator$b.encode({ ...params2, nodes: [tblPr] });
|
|
31332
|
+
encodedAttrs["tableProperties"] = encodedProperties || {};
|
|
31383
31333
|
}
|
|
31384
|
-
const
|
|
31385
|
-
|
|
31386
|
-
|
|
31387
|
-
|
|
31388
|
-
|
|
31389
|
-
|
|
31390
|
-
|
|
31391
|
-
|
|
31392
|
-
|
|
31393
|
-
|
|
31394
|
-
|
|
31395
|
-
|
|
31396
|
-
|
|
31397
|
-
|
|
31398
|
-
|
|
31399
|
-
|
|
31400
|
-
|
|
31401
|
-
);
|
|
31402
|
-
} else if (!foundTextStyle?.attrs.fontFamily && fontFamily2) {
|
|
31403
|
-
tr.addMark(
|
|
31404
|
-
pos,
|
|
31405
|
-
pos + node.nodeSize,
|
|
31406
|
-
textStyleType.create({
|
|
31407
|
-
...foundTextStyle?.attrs,
|
|
31408
|
-
...fontFamily2.attrs
|
|
31409
|
-
})
|
|
31410
|
-
);
|
|
31411
|
-
} else if (!foundTextStyle?.attrs.fontSize && fontSize2) {
|
|
31412
|
-
tr.addMark(
|
|
31413
|
-
pos,
|
|
31414
|
-
pos + node.nodeSize,
|
|
31415
|
-
textStyleType.create({
|
|
31416
|
-
...foundTextStyle?.attrs,
|
|
31417
|
-
...fontSize2.attrs
|
|
31418
|
-
})
|
|
31419
|
-
);
|
|
31334
|
+
const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
|
|
31335
|
+
if (tblGrid) {
|
|
31336
|
+
encodedAttrs["grid"] = translator$9.encode({ ...params2, nodes: [tblGrid] }).attributes;
|
|
31337
|
+
}
|
|
31338
|
+
[
|
|
31339
|
+
"tableStyleId",
|
|
31340
|
+
"justification",
|
|
31341
|
+
"tableLayout",
|
|
31342
|
+
["tableIndent", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
31343
|
+
["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
|
|
31344
|
+
].forEach((prop) => {
|
|
31345
|
+
let key2;
|
|
31346
|
+
let transform;
|
|
31347
|
+
if (Array.isArray(prop)) {
|
|
31348
|
+
[key2, transform] = prop;
|
|
31349
|
+
} else {
|
|
31350
|
+
key2 = prop;
|
|
31351
|
+
transform = (v2) => v2;
|
|
31420
31352
|
}
|
|
31421
|
-
if (
|
|
31422
|
-
|
|
31423
|
-
pos,
|
|
31424
|
-
pos + node.nodeSize,
|
|
31425
|
-
highlightType.create({
|
|
31426
|
-
...highlight?.attrs
|
|
31427
|
-
})
|
|
31428
|
-
);
|
|
31353
|
+
if (encodedAttrs.tableProperties && encodedAttrs.tableProperties[key2]) {
|
|
31354
|
+
encodedAttrs[key2] = transform(encodedAttrs.tableProperties[key2]);
|
|
31429
31355
|
}
|
|
31430
31356
|
});
|
|
31431
|
-
|
|
31432
|
-
|
|
31433
|
-
function getFieldHighlightJson(fieldsHighlightColor) {
|
|
31434
|
-
if (!fieldsHighlightColor) return null;
|
|
31435
|
-
let parsedColor = fieldsHighlightColor.trim();
|
|
31436
|
-
const hexRegex2 = /^#?([A-Fa-f0-9]{3}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/;
|
|
31437
|
-
if (!hexRegex2.test(parsedColor)) {
|
|
31438
|
-
console.warn(`Invalid HEX color provided to fieldsHighlightColor export param: ${fieldsHighlightColor}`);
|
|
31439
|
-
return null;
|
|
31357
|
+
if (encodedAttrs.tableCellSpacing) {
|
|
31358
|
+
encodedAttrs["borderCollapse"] = "separate";
|
|
31440
31359
|
}
|
|
31441
|
-
if (
|
|
31442
|
-
|
|
31360
|
+
if (encodedAttrs.tableProperties?.tableWidth) {
|
|
31361
|
+
const tableWidthMeasurement = encodedAttrs.tableProperties.tableWidth;
|
|
31362
|
+
const widthPx = twipsToPixels(tableWidthMeasurement.value);
|
|
31363
|
+
if (widthPx != null) {
|
|
31364
|
+
encodedAttrs.tableWidth = {
|
|
31365
|
+
width: widthPx,
|
|
31366
|
+
type: tableWidthMeasurement.type
|
|
31367
|
+
};
|
|
31368
|
+
} else if (tableWidthMeasurement.type === "auto") {
|
|
31369
|
+
encodedAttrs.tableWidth = {
|
|
31370
|
+
width: 0,
|
|
31371
|
+
type: tableWidthMeasurement.type
|
|
31372
|
+
};
|
|
31373
|
+
}
|
|
31443
31374
|
}
|
|
31444
|
-
|
|
31445
|
-
|
|
31446
|
-
|
|
31447
|
-
|
|
31448
|
-
|
|
31449
|
-
|
|
31450
|
-
|
|
31451
|
-
|
|
31452
|
-
|
|
31375
|
+
const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
|
|
31376
|
+
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2);
|
|
31377
|
+
if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
|
|
31378
|
+
encodedAttrs.tableProperties = {
|
|
31379
|
+
...encodedAttrs.tableProperties || {},
|
|
31380
|
+
cellMargins: referencedStyles.cellMargins
|
|
31381
|
+
};
|
|
31382
|
+
}
|
|
31383
|
+
const rows = node.elements.filter((el) => el.name === "w:tr");
|
|
31384
|
+
const borderData = Object.assign({}, referencedStyles?.borders || {}, borders || {});
|
|
31385
|
+
const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
|
|
31386
|
+
encodedAttrs["borders"] = borderData;
|
|
31387
|
+
let columnWidths = Array.isArray(encodedAttrs["grid"]) ? encodedAttrs["grid"].map((item) => twipsToPixels(item.col)) : [];
|
|
31388
|
+
if (!columnWidths.length) {
|
|
31389
|
+
const fallback = buildFallbackGridForTable({
|
|
31390
|
+
params: params2,
|
|
31391
|
+
rows,
|
|
31392
|
+
tableWidth: encodedAttrs.tableWidth,
|
|
31393
|
+
tableWidthMeasurement: encodedAttrs.tableProperties?.tableWidth
|
|
31394
|
+
});
|
|
31395
|
+
if (fallback) {
|
|
31396
|
+
encodedAttrs.grid = fallback.grid;
|
|
31397
|
+
columnWidths = fallback.columnWidths;
|
|
31398
|
+
}
|
|
31399
|
+
}
|
|
31400
|
+
const content = [];
|
|
31401
|
+
const totalColumns = columnWidths.length;
|
|
31402
|
+
const activeRowSpans = totalColumns > 0 ? new Array(totalColumns).fill(0) : [];
|
|
31403
|
+
rows.forEach((row, rowIndex) => {
|
|
31404
|
+
const result = translator$u.encode({
|
|
31405
|
+
...params2,
|
|
31406
|
+
nodes: [row],
|
|
31407
|
+
extraParams: {
|
|
31408
|
+
row,
|
|
31409
|
+
table: node,
|
|
31410
|
+
rowBorders: borderRowData,
|
|
31411
|
+
columnWidths,
|
|
31412
|
+
activeRowSpans: activeRowSpans.slice(),
|
|
31413
|
+
rowIndex,
|
|
31414
|
+
_referencedStyles: referencedStyles
|
|
31415
|
+
}
|
|
31416
|
+
});
|
|
31417
|
+
if (result) {
|
|
31418
|
+
content.push(result);
|
|
31419
|
+
if (totalColumns > 0) {
|
|
31420
|
+
const activeRowSpansForCurrentRow = activeRowSpans.slice();
|
|
31421
|
+
for (let col = 0; col < totalColumns; col++) {
|
|
31422
|
+
if (activeRowSpans[col] > 0) {
|
|
31423
|
+
activeRowSpans[col] -= 1;
|
|
31424
|
+
}
|
|
31453
31425
|
}
|
|
31426
|
+
let columnIndex = 0;
|
|
31427
|
+
const advanceColumnIndex = () => {
|
|
31428
|
+
while (columnIndex < totalColumns && activeRowSpansForCurrentRow[columnIndex] > 0) {
|
|
31429
|
+
columnIndex += 1;
|
|
31430
|
+
}
|
|
31431
|
+
};
|
|
31432
|
+
advanceColumnIndex();
|
|
31433
|
+
result.content?.forEach((cell) => {
|
|
31434
|
+
advanceColumnIndex();
|
|
31435
|
+
const colspan = Math.max(1, cell.attrs?.colspan || 1);
|
|
31436
|
+
const rowspan = Math.max(1, cell.attrs?.rowspan || 1);
|
|
31437
|
+
if (rowspan > 1) {
|
|
31438
|
+
for (let offset2 = 0; offset2 < colspan && columnIndex + offset2 < totalColumns; offset2++) {
|
|
31439
|
+
const targetIndex = columnIndex + offset2;
|
|
31440
|
+
const remainingRows = rowspan - 1;
|
|
31441
|
+
if (remainingRows > 0 && remainingRows > activeRowSpans[targetIndex]) {
|
|
31442
|
+
activeRowSpans[targetIndex] = remainingRows;
|
|
31443
|
+
}
|
|
31444
|
+
}
|
|
31445
|
+
}
|
|
31446
|
+
columnIndex += colspan;
|
|
31447
|
+
advanceColumnIndex();
|
|
31448
|
+
});
|
|
31454
31449
|
}
|
|
31455
|
-
|
|
31450
|
+
}
|
|
31451
|
+
});
|
|
31452
|
+
return {
|
|
31453
|
+
type: "table",
|
|
31454
|
+
content,
|
|
31455
|
+
attrs: encodedAttrs
|
|
31456
31456
|
};
|
|
31457
|
-
}
|
|
31458
|
-
|
|
31457
|
+
};
|
|
31458
|
+
const decode$h = (params2, decodedAttrs) => {
|
|
31459
|
+
params2.node = preProcessVerticalMergeCells(params2.node, params2);
|
|
31459
31460
|
const { node } = params2;
|
|
31460
|
-
const
|
|
31461
|
-
const
|
|
31462
|
-
const
|
|
31463
|
-
|
|
31464
|
-
|
|
31465
|
-
|
|
31461
|
+
const elements = translateChildNodes(params2);
|
|
31462
|
+
const firstRow = node.content?.find((n) => n.type === "tableRow");
|
|
31463
|
+
const properties = node.attrs.grid;
|
|
31464
|
+
const element = translator$9.decode({
|
|
31465
|
+
...params2,
|
|
31466
|
+
node: { ...node, attrs: { ...node.attrs, grid: properties } },
|
|
31467
|
+
extraParams: {
|
|
31468
|
+
firstRow
|
|
31466
31469
|
}
|
|
31467
|
-
];
|
|
31468
|
-
const exportedTag = JSON.stringify({
|
|
31469
|
-
type: "documentSection",
|
|
31470
|
-
description: attrs.description
|
|
31471
31470
|
});
|
|
31472
|
-
|
|
31473
|
-
|
|
31474
|
-
|
|
31475
|
-
|
|
31476
|
-
|
|
31477
|
-
|
|
31478
|
-
"w:val": "sdtContentLocked"
|
|
31479
|
-
}
|
|
31471
|
+
if (element) elements.unshift(element);
|
|
31472
|
+
if (node.attrs?.tableProperties) {
|
|
31473
|
+
const properties2 = { ...node.attrs.tableProperties };
|
|
31474
|
+
const element2 = translator$b.decode({
|
|
31475
|
+
...params2,
|
|
31476
|
+
node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
|
|
31480
31477
|
});
|
|
31478
|
+
if (element2) elements.unshift(element2);
|
|
31481
31479
|
}
|
|
31482
|
-
nodeElements.unshift(sdtPr);
|
|
31483
|
-
const result = {
|
|
31484
|
-
name: "w:sdt",
|
|
31485
|
-
elements: nodeElements
|
|
31486
|
-
};
|
|
31487
|
-
return result;
|
|
31488
|
-
}
|
|
31489
|
-
const generateSdtPrTagForDocumentSection = (id, title, tag) => {
|
|
31490
31480
|
return {
|
|
31491
|
-
name: "w:
|
|
31492
|
-
|
|
31493
|
-
|
|
31494
|
-
name: "w:id",
|
|
31495
|
-
attributes: {
|
|
31496
|
-
"w:val": id
|
|
31497
|
-
}
|
|
31498
|
-
},
|
|
31499
|
-
{
|
|
31500
|
-
name: "w:alias",
|
|
31501
|
-
attributes: {
|
|
31502
|
-
"w:val": title
|
|
31503
|
-
}
|
|
31504
|
-
},
|
|
31505
|
-
{
|
|
31506
|
-
name: "w:tag",
|
|
31507
|
-
attributes: {
|
|
31508
|
-
"w:val": tag
|
|
31509
|
-
}
|
|
31510
|
-
}
|
|
31511
|
-
]
|
|
31481
|
+
name: "w:tbl",
|
|
31482
|
+
attributes: decodedAttrs || {},
|
|
31483
|
+
elements
|
|
31512
31484
|
};
|
|
31513
31485
|
};
|
|
31514
|
-
function
|
|
31515
|
-
const
|
|
31516
|
-
const
|
|
31517
|
-
|
|
31518
|
-
|
|
31519
|
-
|
|
31520
|
-
|
|
31521
|
-
|
|
31522
|
-
|
|
31523
|
-
|
|
31524
|
-
|
|
31525
|
-
|
|
31526
|
-
|
|
31527
|
-
|
|
31528
|
-
|
|
31529
|
-
|
|
31530
|
-
elements: [
|
|
31531
|
-
{
|
|
31532
|
-
name: "w:docPartGallery",
|
|
31533
|
-
attributes: {
|
|
31534
|
-
"w:val": attrs.docPartGallery
|
|
31535
|
-
}
|
|
31536
|
-
},
|
|
31537
|
-
...attrs.docPartUnique ? [
|
|
31538
|
-
{
|
|
31539
|
-
name: "w:docPartUnique"
|
|
31540
|
-
}
|
|
31541
|
-
] : []
|
|
31542
|
-
]
|
|
31543
|
-
}
|
|
31544
|
-
]
|
|
31545
|
-
},
|
|
31546
|
-
{
|
|
31547
|
-
name: "w:sdtContent",
|
|
31548
|
-
elements: childContent
|
|
31549
|
-
}
|
|
31550
|
-
];
|
|
31551
|
-
const result = {
|
|
31552
|
-
name: "w:sdt",
|
|
31553
|
-
elements: nodeElements
|
|
31554
|
-
};
|
|
31555
|
-
return result;
|
|
31556
|
-
}
|
|
31557
|
-
function translateStructuredContent(params2) {
|
|
31558
|
-
const { node } = params2;
|
|
31559
|
-
const childContent = translateChildNodes({ ...params2, nodes: node.content });
|
|
31560
|
-
const sdtContent = { name: "w:sdtContent", elements: childContent };
|
|
31561
|
-
const sdtPr = generateSdtPrTagForStructuredContent({ node });
|
|
31562
|
-
const nodeElements = [sdtPr, sdtContent];
|
|
31563
|
-
const result = {
|
|
31564
|
-
name: "w:sdt",
|
|
31565
|
-
elements: nodeElements
|
|
31486
|
+
function _processTableBorders(rawBorders) {
|
|
31487
|
+
const borders = {};
|
|
31488
|
+
const rowBorders = {};
|
|
31489
|
+
Object.entries(rawBorders).forEach(([name, attributes]) => {
|
|
31490
|
+
const attrs = {};
|
|
31491
|
+
const color = attributes.color;
|
|
31492
|
+
const size2 = attributes.size;
|
|
31493
|
+
if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
|
|
31494
|
+
if (size2 && size2 !== "auto") attrs["size"] = eighthPointsToPixels(size2);
|
|
31495
|
+
const rowBorderNames = ["insideH", "insideV"];
|
|
31496
|
+
if (rowBorderNames.includes(name)) rowBorders[name] = attrs;
|
|
31497
|
+
borders[name] = attrs;
|
|
31498
|
+
});
|
|
31499
|
+
return {
|
|
31500
|
+
borders,
|
|
31501
|
+
rowBorders
|
|
31566
31502
|
};
|
|
31567
|
-
return result;
|
|
31568
31503
|
}
|
|
31569
|
-
function
|
|
31570
|
-
|
|
31571
|
-
const
|
|
31572
|
-
|
|
31573
|
-
|
|
31574
|
-
|
|
31575
|
-
|
|
31576
|
-
const
|
|
31577
|
-
|
|
31578
|
-
|
|
31579
|
-
|
|
31580
|
-
|
|
31581
|
-
|
|
31582
|
-
|
|
31583
|
-
|
|
31584
|
-
attributes: { "w:val": attrs.tag }
|
|
31585
|
-
};
|
|
31586
|
-
const resultElements = [];
|
|
31587
|
-
if (attrs.id) resultElements.push(id);
|
|
31588
|
-
if (attrs.alias) resultElements.push(alias);
|
|
31589
|
-
if (attrs.tag) resultElements.push(tag);
|
|
31590
|
-
if (attrs.sdtPr) {
|
|
31591
|
-
const elements = attrs.sdtPr.elements || [];
|
|
31592
|
-
const elementsToExclude = ["w:id", "w:alias", "w:tag"];
|
|
31593
|
-
const restElements = elements.filter((el) => !elementsToExclude.includes(el.name));
|
|
31594
|
-
const result2 = {
|
|
31595
|
-
name: "w:sdtPr",
|
|
31596
|
-
type: "element",
|
|
31597
|
-
elements: [...resultElements, ...restElements]
|
|
31598
|
-
};
|
|
31599
|
-
return result2;
|
|
31504
|
+
function _getReferencedTableStyles(tableStyleReference, params2) {
|
|
31505
|
+
if (!tableStyleReference) return null;
|
|
31506
|
+
const stylesToReturn = {};
|
|
31507
|
+
const { docx } = params2;
|
|
31508
|
+
const styles = docx["word/styles.xml"];
|
|
31509
|
+
const { elements } = styles.elements[0];
|
|
31510
|
+
const styleElements = elements.filter((el) => el.name === "w:style");
|
|
31511
|
+
const styleTag = styleElements.find((el) => el.attributes["w:styleId"] === tableStyleReference);
|
|
31512
|
+
if (!styleTag) return null;
|
|
31513
|
+
stylesToReturn.name = styleTag.elements.find((el) => el.name === "w:name");
|
|
31514
|
+
const basedOn = styleTag.elements.find((el) => el.name === "w:basedOn");
|
|
31515
|
+
let baseTblPr;
|
|
31516
|
+
if (basedOn?.attributes) {
|
|
31517
|
+
const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
|
|
31518
|
+
baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
|
|
31600
31519
|
}
|
|
31601
|
-
const
|
|
31602
|
-
|
|
31603
|
-
|
|
31604
|
-
|
|
31605
|
-
};
|
|
31606
|
-
return result;
|
|
31607
|
-
}
|
|
31608
|
-
const XML_NODE_NAME$9 = "w:sdt";
|
|
31609
|
-
const SD_NODE_NAME$7 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
|
|
31610
|
-
const validXmlAttributes$6 = [];
|
|
31611
|
-
function encode$f(params2) {
|
|
31612
|
-
const nodes = params2.nodes;
|
|
31613
|
-
const node = nodes[0];
|
|
31614
|
-
const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
|
|
31615
|
-
if (!handler2 || sdtType === "unknown") {
|
|
31616
|
-
return void 0;
|
|
31520
|
+
const pPr = styleTag.elements.find((el) => el.name === "w:pPr");
|
|
31521
|
+
if (pPr) {
|
|
31522
|
+
const justification = pPr.elements.find((el) => el.name === "w:jc");
|
|
31523
|
+
if (justification?.attributes) stylesToReturn.justification = justification.attributes["w:val"];
|
|
31617
31524
|
}
|
|
31618
|
-
const
|
|
31619
|
-
|
|
31620
|
-
|
|
31621
|
-
|
|
31622
|
-
|
|
31623
|
-
|
|
31624
|
-
|
|
31525
|
+
const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
|
|
31526
|
+
if (rPr) {
|
|
31527
|
+
const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
|
|
31528
|
+
if (fonts) {
|
|
31529
|
+
const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
|
|
31530
|
+
stylesToReturn.fonts = { ascii, hAnsi, cs };
|
|
31531
|
+
}
|
|
31532
|
+
const fontSize2 = rPr.elements.find((el) => el.name === "w:sz");
|
|
31533
|
+
if (fontSize2?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize2.attributes["w:val"]) + "pt";
|
|
31625
31534
|
}
|
|
31626
|
-
const
|
|
31627
|
-
|
|
31628
|
-
|
|
31629
|
-
|
|
31630
|
-
|
|
31631
|
-
|
|
31632
|
-
|
|
31633
|
-
|
|
31634
|
-
|
|
31635
|
-
|
|
31636
|
-
|
|
31637
|
-
|
|
31535
|
+
const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
|
|
31536
|
+
if (tblPr && tblPr.elements) {
|
|
31537
|
+
if (baseTblPr && baseTblPr.elements) {
|
|
31538
|
+
tblPr.elements.push(...baseTblPr.elements);
|
|
31539
|
+
}
|
|
31540
|
+
const tableProperties = translator$b.encode({ ...params2, nodes: [tblPr] });
|
|
31541
|
+
if (tableProperties) {
|
|
31542
|
+
const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
|
|
31543
|
+
if (borders) stylesToReturn.borders = borders;
|
|
31544
|
+
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
31545
|
+
const cellMargins = {};
|
|
31546
|
+
Object.entries(tableProperties.cellMargins || {}).forEach(([key2, attrs]) => {
|
|
31547
|
+
if (attrs?.value != null) {
|
|
31548
|
+
cellMargins[key2] = {
|
|
31549
|
+
value: attrs.value,
|
|
31550
|
+
type: attrs.type || "dxa"
|
|
31551
|
+
};
|
|
31552
|
+
}
|
|
31553
|
+
});
|
|
31554
|
+
if (Object.keys(cellMargins).length) stylesToReturn.cellMargins = cellMargins;
|
|
31555
|
+
}
|
|
31556
|
+
}
|
|
31557
|
+
return stylesToReturn;
|
|
31638
31558
|
}
|
|
31639
31559
|
const config$8 = {
|
|
31640
31560
|
xmlName: XML_NODE_NAME$9,
|
|
@@ -31642,7 +31562,7 @@ const config$8 = {
|
|
|
31642
31562
|
type: NodeTranslator.translatorTypes.NODE,
|
|
31643
31563
|
encode: encode$f,
|
|
31644
31564
|
decode: decode$h,
|
|
31645
|
-
attributes:
|
|
31565
|
+
attributes: []
|
|
31646
31566
|
};
|
|
31647
31567
|
const translator$8 = NodeTranslator.from(config$8);
|
|
31648
31568
|
const encode$e = (attributes) => {
|
|
@@ -32157,7 +32077,7 @@ const handleDrawingNode = (params2) => {
|
|
|
32157
32077
|
if (mainNode.name === "w:drawing") node = mainNode;
|
|
32158
32078
|
else node = mainNode.elements.find((el) => el.name === "w:drawing");
|
|
32159
32079
|
if (!node) return { nodes: [], consumed: 0 };
|
|
32160
|
-
const schemaNode = translator$
|
|
32080
|
+
const schemaNode = translator$r.encode(params2);
|
|
32161
32081
|
const newNodes = schemaNode ? [schemaNode] : [];
|
|
32162
32082
|
return { nodes: newNodes, consumed: 1 };
|
|
32163
32083
|
};
|
|
@@ -32466,7 +32386,7 @@ const handleSdtNode = (params2) => {
|
|
|
32466
32386
|
if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
|
|
32467
32387
|
return { nodes: [], consumed: 0 };
|
|
32468
32388
|
}
|
|
32469
|
-
const result = translator$
|
|
32389
|
+
const result = translator$q.encode(params2);
|
|
32470
32390
|
if (!result) {
|
|
32471
32391
|
return { nodes: [], consumed: 0 };
|
|
32472
32392
|
}
|
|
@@ -33260,6 +33180,7 @@ const tabNodeEntityHandler = {
|
|
|
33260
33180
|
handlerName: "w:tabTranslator",
|
|
33261
33181
|
handler: handleTabNode
|
|
33262
33182
|
};
|
|
33183
|
+
const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$8);
|
|
33263
33184
|
const tableOfContentsHandlerEntity = generateV2HandlerEntity("tableOfContentsHandler", translator$4);
|
|
33264
33185
|
function preProcessPageInstruction(nodesToCombine) {
|
|
33265
33186
|
const pageNumNode = {
|
|
@@ -34269,14 +34190,14 @@ function exportSchemaToJson(params2) {
|
|
|
34269
34190
|
bulletList: translateList,
|
|
34270
34191
|
orderedList: translateList,
|
|
34271
34192
|
lineBreak: translator$1r,
|
|
34272
|
-
table: translator$
|
|
34273
|
-
tableRow: translator$
|
|
34274
|
-
tableCell: translator$
|
|
34193
|
+
table: translator$8,
|
|
34194
|
+
tableRow: translator$u,
|
|
34195
|
+
tableCell: translator$H,
|
|
34275
34196
|
bookmarkStart: translator$7,
|
|
34276
34197
|
bookmarkEnd: translator$6,
|
|
34277
|
-
fieldAnnotation: translator$
|
|
34198
|
+
fieldAnnotation: translator$q,
|
|
34278
34199
|
tab: translator$1p,
|
|
34279
|
-
image: translator$
|
|
34200
|
+
image: translator$r,
|
|
34280
34201
|
hardBreak: translator$1r,
|
|
34281
34202
|
commentRangeStart: commentRangeStartTranslator,
|
|
34282
34203
|
commentRangeEnd: commentRangeEndTranslator,
|
|
@@ -34285,10 +34206,10 @@ function exportSchemaToJson(params2) {
|
|
|
34285
34206
|
shapeTextbox: translator,
|
|
34286
34207
|
contentBlock: translator,
|
|
34287
34208
|
vectorShape: translateVectorShape,
|
|
34288
|
-
structuredContent: translator$
|
|
34289
|
-
structuredContentBlock: translator$
|
|
34290
|
-
documentPartObject: translator$
|
|
34291
|
-
documentSection: translator$
|
|
34209
|
+
structuredContent: translator$q,
|
|
34210
|
+
structuredContentBlock: translator$q,
|
|
34211
|
+
documentPartObject: translator$q,
|
|
34212
|
+
documentSection: translator$q,
|
|
34292
34213
|
"page-number": translatePageNumberNode,
|
|
34293
34214
|
"total-page-number": translateTotalPageNumberNode,
|
|
34294
34215
|
pageReference: translator$5,
|
|
@@ -91855,86 +91776,86 @@ const additionalHandlers = Object.freeze({
|
|
|
91855
91776
|
"sd:pageReference": translator$5,
|
|
91856
91777
|
"sd:tableOfContents": translator$4,
|
|
91857
91778
|
"w:b": translator$1n,
|
|
91858
|
-
"w:bidiVisual": translator$
|
|
91779
|
+
"w:bidiVisual": translator$p,
|
|
91859
91780
|
"w:bookmarkEnd": translator$6,
|
|
91860
91781
|
"w:bookmarkStart": translator$7,
|
|
91861
|
-
"w:bottom": translator$
|
|
91782
|
+
"w:bottom": translator$15,
|
|
91862
91783
|
"w:br": translator$1r,
|
|
91863
|
-
"w:cantSplit": translator$
|
|
91864
|
-
"w:cnfStyle": translator$
|
|
91784
|
+
"w:cantSplit": translator$G,
|
|
91785
|
+
"w:cnfStyle": translator$1a,
|
|
91865
91786
|
"w:color": translator$1j,
|
|
91866
|
-
"w:divId": translator$
|
|
91867
|
-
"w:drawing": translator$
|
|
91868
|
-
"w:end": translator$
|
|
91869
|
-
"w:gridAfter": translator$
|
|
91870
|
-
"w:gridBefore": translator$
|
|
91871
|
-
"w:gridCol": translator$
|
|
91872
|
-
"w:hidden": translator$
|
|
91787
|
+
"w:divId": translator$F,
|
|
91788
|
+
"w:drawing": translator$r,
|
|
91789
|
+
"w:end": translator$13,
|
|
91790
|
+
"w:gridAfter": translator$E,
|
|
91791
|
+
"w:gridBefore": translator$D,
|
|
91792
|
+
"w:gridCol": translator$a,
|
|
91793
|
+
"w:hidden": translator$C,
|
|
91873
91794
|
"w:highlight": translator$1q,
|
|
91874
91795
|
"w:hyperlink": translator$1c,
|
|
91875
91796
|
"w:i": translator$1m,
|
|
91876
|
-
"w:insideH": translator$
|
|
91877
|
-
"w:insideV": translator$
|
|
91878
|
-
"w:jc": translator$
|
|
91879
|
-
"w:left": translator
|
|
91797
|
+
"w:insideH": translator$11,
|
|
91798
|
+
"w:insideV": translator$10,
|
|
91799
|
+
"w:jc": translator$B,
|
|
91800
|
+
"w:left": translator$$,
|
|
91880
91801
|
"w:p": translator$1o,
|
|
91881
91802
|
"w:r": translator$1b,
|
|
91882
91803
|
"w:rFonts": translator$1i,
|
|
91883
91804
|
"w:rPr": translator$1d,
|
|
91884
91805
|
"w:rStyle": translator$1h,
|
|
91885
|
-
"w:right": translator$
|
|
91886
|
-
"w:sdt": translator$
|
|
91887
|
-
"w:shd": translator$
|
|
91888
|
-
"w:start": translator$
|
|
91806
|
+
"w:right": translator$Z,
|
|
91807
|
+
"w:sdt": translator$q,
|
|
91808
|
+
"w:shd": translator$19,
|
|
91809
|
+
"w:start": translator$X,
|
|
91889
91810
|
"w:strike": translator$1k,
|
|
91890
91811
|
"w:sz": translator$1g,
|
|
91891
91812
|
"w:szCs": translator$1f,
|
|
91892
91813
|
"w:tab": translator$1p,
|
|
91893
|
-
"w:tbl": translator$
|
|
91894
|
-
"w:tblBorders": translator$
|
|
91895
|
-
"w:tblCaption": translator$
|
|
91896
|
-
"w:tblCellMar": translator$
|
|
91897
|
-
"w:tblCellSpacing": translator$
|
|
91898
|
-
"w:tblDescription": translator$
|
|
91899
|
-
"w:tblGrid": translator$
|
|
91900
|
-
"w:tblHeader": translator$
|
|
91901
|
-
"w:tblInd": translator$
|
|
91902
|
-
"w:tblLayout": translator$
|
|
91903
|
-
"w:tblLook": translator$
|
|
91904
|
-
"w:tblOverlap": translator$
|
|
91905
|
-
"w:tblPr": translator$
|
|
91906
|
-
"w:tblStyle": translator$
|
|
91907
|
-
"w:tblStyleColBandSize": translator$
|
|
91908
|
-
"w:tblStyleRowBandSize": translator$
|
|
91909
|
-
"w:tblW": translator$
|
|
91910
|
-
"w:tblpPr": translator$
|
|
91911
|
-
"w:tc": translator$
|
|
91912
|
-
"w:top": translator$
|
|
91913
|
-
"w:tr": translator$
|
|
91914
|
-
"w:trHeight": translator$
|
|
91915
|
-
"w:trPr": translator$
|
|
91814
|
+
"w:tbl": translator$8,
|
|
91815
|
+
"w:tblBorders": translator$d,
|
|
91816
|
+
"w:tblCaption": translator$o,
|
|
91817
|
+
"w:tblCellMar": translator$c,
|
|
91818
|
+
"w:tblCellSpacing": translator$A,
|
|
91819
|
+
"w:tblDescription": translator$n,
|
|
91820
|
+
"w:tblGrid": translator$9,
|
|
91821
|
+
"w:tblHeader": translator$z,
|
|
91822
|
+
"w:tblInd": translator$m,
|
|
91823
|
+
"w:tblLayout": translator$l,
|
|
91824
|
+
"w:tblLook": translator$k,
|
|
91825
|
+
"w:tblOverlap": translator$j,
|
|
91826
|
+
"w:tblPr": translator$b,
|
|
91827
|
+
"w:tblStyle": translator$i,
|
|
91828
|
+
"w:tblStyleColBandSize": translator$h,
|
|
91829
|
+
"w:tblStyleRowBandSize": translator$g,
|
|
91830
|
+
"w:tblW": translator$f,
|
|
91831
|
+
"w:tblpPr": translator$e,
|
|
91832
|
+
"w:tc": translator$H,
|
|
91833
|
+
"w:top": translator$V,
|
|
91834
|
+
"w:tr": translator$u,
|
|
91835
|
+
"w:trHeight": translator$y,
|
|
91836
|
+
"w:trPr": translator$v,
|
|
91916
91837
|
"w:u": translator$1l,
|
|
91917
|
-
"w:wAfter": translator$
|
|
91918
|
-
"w:wBefore": translator
|
|
91919
|
-
"wp:anchor": translator$
|
|
91920
|
-
"wp:inline": translator$
|
|
91838
|
+
"w:wAfter": translator$x,
|
|
91839
|
+
"w:wBefore": translator$w,
|
|
91840
|
+
"wp:anchor": translator$t,
|
|
91841
|
+
"wp:inline": translator$s,
|
|
91921
91842
|
"w:commentRangeStart": commentRangeStartTranslator,
|
|
91922
91843
|
"w:commentRangeEnd": commentRangeEndTranslator,
|
|
91923
|
-
"w:vMerge": translator$
|
|
91924
|
-
"w:gridSpan": translator$
|
|
91925
|
-
"w:vAlign": translator$
|
|
91926
|
-
"w:noWrap": translator$
|
|
91927
|
-
"w:tcFitText": translator$
|
|
91928
|
-
"w:tcW": translator$
|
|
91929
|
-
"w:hideMark": translator$
|
|
91930
|
-
"w:textDirection": translator$
|
|
91931
|
-
"w:tl2br": translator$
|
|
91932
|
-
"w:tr2bl": translator$
|
|
91933
|
-
"w:header": translator$
|
|
91934
|
-
"w:headers": translator$
|
|
91935
|
-
"w:tcBorders": translator$
|
|
91936
|
-
"w:tcMar": translator$
|
|
91937
|
-
"w:tcPr": translator$
|
|
91844
|
+
"w:vMerge": translator$16,
|
|
91845
|
+
"w:gridSpan": translator$17,
|
|
91846
|
+
"w:vAlign": translator$M,
|
|
91847
|
+
"w:noWrap": translator$Q,
|
|
91848
|
+
"w:tcFitText": translator$N,
|
|
91849
|
+
"w:tcW": translator$18,
|
|
91850
|
+
"w:hideMark": translator$L,
|
|
91851
|
+
"w:textDirection": translator$O,
|
|
91852
|
+
"w:tl2br": translator$T,
|
|
91853
|
+
"w:tr2bl": translator$S,
|
|
91854
|
+
"w:header": translator$K,
|
|
91855
|
+
"w:headers": translator$J,
|
|
91856
|
+
"w:tcBorders": translator$R,
|
|
91857
|
+
"w:tcMar": translator$P,
|
|
91858
|
+
"w:tcPr": translator$I
|
|
91938
91859
|
});
|
|
91939
91860
|
const baseHandlers = {
|
|
91940
91861
|
...runPropertyTranslators,
|