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