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