@harbour-enterprises/superdoc 0.27.3-next.1 → 0.28.0-next.1
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-Bnj3c-92.es.js → PdfViewer-9z5hlRyt.es.js} +1 -1
- package/dist/chunks/{PdfViewer-BkJGiP2u.cjs → PdfViewer-Jb55JUCS.cjs} +1 -1
- package/dist/chunks/{index-CuLDIhMe.cjs → index-D0UvyM8m.cjs} +10 -4
- package/dist/chunks/{index-lF5qA9nw.es.js → index-DqP-8_tO.es.js} +10 -4
- package/dist/chunks/{super-editor.es-6ikSS3Qu.es.js → super-editor.es-BBJIKdhr.es.js} +1690 -1674
- package/dist/chunks/{super-editor.es-RvLsj0rg.cjs → super-editor.es-Ca5D3ZTW.cjs} +1690 -1674
- package/dist/chunks/uuid-CjlX8hrF.es.js +35 -0
- package/dist/chunks/uuid-R7L08bOx.cjs +34 -0
- package/dist/components/CommentsLayer/use-comment.d.ts.map +1 -1
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/stores/comments-store.d.ts.map +1 -1
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-GcMLdei-.js → converter-AR-76siZ.js} +1344 -1416
- package/dist/super-editor/chunks/{docx-zipper-Y0x9TJvc.js → docx-zipper-DVb-VGgt.js} +1 -1
- package/dist/super-editor/chunks/{editor-B97ToSSc.js → editor-mK_uimq6.js} +93 -5
- package/dist/super-editor/chunks/{toolbar-Cm21JZgi.js → toolbar-ByoNwr7x.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/components/toolbar/use-toolbar-item.d.ts +1 -1
- package/dist/super-editor/super-editor/src/core/commands/getSelectionMarks.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/commands/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/commands/setTextSelection.d.ts +4 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/tableImporter.d.ts +0 -16
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/legacy-handle-table-cell-node.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/comment/comments-plugin.d.ts +2 -1
- package/dist/super-editor/super-editor/src/tests/helpers/helpers.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 +1722 -1702
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +5 -8
- package/dist/chunks/uuid-CQzaMNgL.cjs +0 -36
- package/dist/chunks/uuid-DIIKH5Zc.es.js +0 -37
- package/dist/images/altText_add.svg +0 -3
- package/dist/images/altText_done.svg +0 -3
- package/dist/images/annotation-check.svg +0 -11
- package/dist/images/annotation-comment.svg +0 -16
- package/dist/images/annotation-help.svg +0 -26
- package/dist/images/annotation-insert.svg +0 -10
- package/dist/images/annotation-key.svg +0 -11
- package/dist/images/annotation-newparagraph.svg +0 -11
- package/dist/images/annotation-noicon.svg +0 -7
- package/dist/images/annotation-note.svg +0 -42
- package/dist/images/annotation-paperclip.svg +0 -6
- package/dist/images/annotation-paragraph.svg +0 -16
- package/dist/images/annotation-pushpin.svg +0 -7
- package/dist/images/cursor-editorFreeHighlight.svg +0 -6
- package/dist/images/cursor-editorFreeText.svg +0 -3
- package/dist/images/cursor-editorInk.svg +0 -4
- package/dist/images/cursor-editorTextHighlight.svg +0 -8
- package/dist/images/editor-toolbar-delete.svg +0 -5
- package/dist/images/loading-icon.gif +0 -0
- package/dist/images/toolbarButton-editorHighlight.svg +0 -6
- package/dist/images/toolbarButton-menuArrow.svg +0 -3
|
@@ -11347,39 +11347,37 @@ function requireLib() {
|
|
|
11347
11347
|
}
|
|
11348
11348
|
var libExports = requireLib();
|
|
11349
11349
|
const xmljs = /* @__PURE__ */ getDefaultExportFromCjs$2(libExports);
|
|
11350
|
-
|
|
11351
|
-
|
|
11350
|
+
let getRandomValues;
|
|
11351
|
+
const rnds8 = new Uint8Array(16);
|
|
11352
11352
|
function rng() {
|
|
11353
11353
|
if (!getRandomValues) {
|
|
11354
|
-
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto)
|
|
11354
|
+
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
11355
11355
|
if (!getRandomValues) {
|
|
11356
11356
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
11357
11357
|
}
|
|
11358
11358
|
}
|
|
11359
11359
|
return getRandomValues(rnds8);
|
|
11360
11360
|
}
|
|
11361
|
-
const
|
|
11362
|
-
|
|
11363
|
-
|
|
11361
|
+
const byteToHex = [];
|
|
11362
|
+
for (let i = 0; i < 256; ++i) {
|
|
11363
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
11364
11364
|
}
|
|
11365
|
-
|
|
11366
|
-
|
|
11367
|
-
byteToHex.push((i$2 + 256).toString(16).substr(1));
|
|
11368
|
-
}
|
|
11369
|
-
function stringify(arr) {
|
|
11370
|
-
var offset2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
|
|
11371
|
-
var uuid = (byteToHex[arr[offset2 + 0]] + byteToHex[arr[offset2 + 1]] + byteToHex[arr[offset2 + 2]] + byteToHex[arr[offset2 + 3]] + "-" + byteToHex[arr[offset2 + 4]] + byteToHex[arr[offset2 + 5]] + "-" + byteToHex[arr[offset2 + 6]] + byteToHex[arr[offset2 + 7]] + "-" + byteToHex[arr[offset2 + 8]] + byteToHex[arr[offset2 + 9]] + "-" + byteToHex[arr[offset2 + 10]] + byteToHex[arr[offset2 + 11]] + byteToHex[arr[offset2 + 12]] + byteToHex[arr[offset2 + 13]] + byteToHex[arr[offset2 + 14]] + byteToHex[arr[offset2 + 15]]).toLowerCase();
|
|
11372
|
-
if (!validate(uuid)) {
|
|
11373
|
-
throw TypeError("Stringified UUID is invalid");
|
|
11374
|
-
}
|
|
11375
|
-
return uuid;
|
|
11365
|
+
function unsafeStringify(arr, offset2 = 0) {
|
|
11366
|
+
return byteToHex[arr[offset2 + 0]] + byteToHex[arr[offset2 + 1]] + byteToHex[arr[offset2 + 2]] + byteToHex[arr[offset2 + 3]] + "-" + byteToHex[arr[offset2 + 4]] + byteToHex[arr[offset2 + 5]] + "-" + byteToHex[arr[offset2 + 6]] + byteToHex[arr[offset2 + 7]] + "-" + byteToHex[arr[offset2 + 8]] + byteToHex[arr[offset2 + 9]] + "-" + byteToHex[arr[offset2 + 10]] + byteToHex[arr[offset2 + 11]] + byteToHex[arr[offset2 + 12]] + byteToHex[arr[offset2 + 13]] + byteToHex[arr[offset2 + 14]] + byteToHex[arr[offset2 + 15]];
|
|
11376
11367
|
}
|
|
11368
|
+
const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
11369
|
+
const native = {
|
|
11370
|
+
randomUUID
|
|
11371
|
+
};
|
|
11377
11372
|
function v4(options, buf, offset2) {
|
|
11373
|
+
if (native.randomUUID && true && !options) {
|
|
11374
|
+
return native.randomUUID();
|
|
11375
|
+
}
|
|
11378
11376
|
options = options || {};
|
|
11379
|
-
|
|
11377
|
+
const rnds = options.random || (options.rng || rng)();
|
|
11380
11378
|
rnds[6] = rnds[6] & 15 | 64;
|
|
11381
11379
|
rnds[8] = rnds[8] & 63 | 128;
|
|
11382
|
-
return
|
|
11380
|
+
return unsafeStringify(rnds);
|
|
11383
11381
|
}
|
|
11384
11382
|
function getDefaultExportFromCjs(x) {
|
|
11385
11383
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -14432,6 +14430,7 @@ class ParseContext {
|
|
|
14432
14430
|
addTextNode(dom, marks) {
|
|
14433
14431
|
let value = dom.nodeValue;
|
|
14434
14432
|
let top2 = this.top, preserveWS = top2.options & OPT_PRESERVE_WS_FULL ? "full" : this.localPreserveWS || (top2.options & OPT_PRESERVE_WS) > 0;
|
|
14433
|
+
let { schema } = this.parser;
|
|
14435
14434
|
if (preserveWS === "full" || top2.inlineContext(dom) || /[^ \t\r\n\u000c]/.test(value)) {
|
|
14436
14435
|
if (!preserveWS) {
|
|
14437
14436
|
value = value.replace(/[ \t\r\n\u000c]+/g, " ");
|
|
@@ -14441,13 +14440,22 @@ class ParseContext {
|
|
|
14441
14440
|
if (!nodeBefore || domNodeBefore && domNodeBefore.nodeName == "BR" || nodeBefore.isText && /[ \t\r\n\u000c]$/.test(nodeBefore.text))
|
|
14442
14441
|
value = value.slice(1);
|
|
14443
14442
|
}
|
|
14444
|
-
} else if (preserveWS
|
|
14445
|
-
value = value.replace(/\r?\n|\r/g, " ");
|
|
14446
|
-
} else {
|
|
14443
|
+
} else if (preserveWS === "full") {
|
|
14447
14444
|
value = value.replace(/\r\n?/g, "\n");
|
|
14445
|
+
} else if (schema.linebreakReplacement && /[\r\n]/.test(value) && this.top.findWrapping(schema.linebreakReplacement.create())) {
|
|
14446
|
+
let lines = value.split(/\r?\n|\r/);
|
|
14447
|
+
for (let i = 0; i < lines.length; i++) {
|
|
14448
|
+
if (i)
|
|
14449
|
+
this.insertNode(schema.linebreakReplacement.create(), marks, true);
|
|
14450
|
+
if (lines[i])
|
|
14451
|
+
this.insertNode(schema.text(lines[i]), marks, !/\S/.test(lines[i]));
|
|
14452
|
+
}
|
|
14453
|
+
value = "";
|
|
14454
|
+
} else {
|
|
14455
|
+
value = value.replace(/\r?\n|\r/g, " ");
|
|
14448
14456
|
}
|
|
14449
14457
|
if (value)
|
|
14450
|
-
this.insertNode(
|
|
14458
|
+
this.insertNode(schema.text(value), marks, !/\S/.test(value));
|
|
14451
14459
|
this.findInText(dom);
|
|
14452
14460
|
} else {
|
|
14453
14461
|
this.findInside(dom);
|
|
@@ -19007,7 +19015,6 @@ class Transaction extends Transform {
|
|
|
19007
19015
|
} else {
|
|
19008
19016
|
if (to == null)
|
|
19009
19017
|
to = from2;
|
|
19010
|
-
to = to == null ? from2 : to;
|
|
19011
19018
|
if (!text)
|
|
19012
19019
|
return this.deleteRange(from2, to);
|
|
19013
19020
|
let marks = this.storedMarks;
|
|
@@ -19016,7 +19023,7 @@ class Transaction extends Transform {
|
|
|
19016
19023
|
marks = to == from2 ? $from.marks() : $from.marksAcross(this.doc.resolve(to));
|
|
19017
19024
|
}
|
|
19018
19025
|
this.replaceRangeWith(from2, to, schema.text(text, marks));
|
|
19019
|
-
if (!this.selection.empty)
|
|
19026
|
+
if (!this.selection.empty && this.selection.to == from2 + text.length)
|
|
19020
19027
|
this.setSelection(Selection.near(this.selection.$to));
|
|
19021
19028
|
return this;
|
|
19022
19029
|
}
|
|
@@ -19208,7 +19215,7 @@ class EditorState {
|
|
|
19208
19215
|
return newInstance;
|
|
19209
19216
|
}
|
|
19210
19217
|
/**
|
|
19211
|
-
|
|
19218
|
+
Accessor that constructs and returns a new [transaction](https://prosemirror.net/docs/ref/#state.Transaction) from this state.
|
|
19212
19219
|
*/
|
|
19213
19220
|
get tr() {
|
|
19214
19221
|
return new Transaction(this);
|
|
@@ -27007,53 +27014,7 @@ const config$h = {
|
|
|
27007
27014
|
attributes: validXmlAttributes$c
|
|
27008
27015
|
};
|
|
27009
27016
|
const translator$1b = NodeTranslator.from(config$h);
|
|
27010
|
-
function preProcessVerticalMergeCells(table, { editorSchema }) {
|
|
27011
|
-
if (!table || !Array.isArray(table.content)) {
|
|
27012
|
-
return table;
|
|
27013
|
-
}
|
|
27014
|
-
const rows = table.content;
|
|
27015
|
-
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
27016
|
-
const row = rows[rowIndex];
|
|
27017
|
-
if (!row) continue;
|
|
27018
|
-
if (!Array.isArray(row.content)) {
|
|
27019
|
-
row.content = [];
|
|
27020
|
-
}
|
|
27021
|
-
for (let cellIndex = 0; cellIndex < row.content.length; cellIndex++) {
|
|
27022
|
-
const cell = row.content[cellIndex];
|
|
27023
|
-
if (!cell) continue;
|
|
27024
|
-
const attrs = cell.attrs || {};
|
|
27025
|
-
if (!attrs.rowspan || attrs.rowspan <= 1) continue;
|
|
27026
|
-
const maxRowspan = Math.min(attrs.rowspan, rows.length - rowIndex);
|
|
27027
|
-
for (let offset2 = 1; offset2 < maxRowspan; offset2++) {
|
|
27028
|
-
const rowToChange = rows[rowIndex + offset2];
|
|
27029
|
-
if (!rowToChange) continue;
|
|
27030
|
-
if (!Array.isArray(rowToChange.content)) {
|
|
27031
|
-
rowToChange.content = [];
|
|
27032
|
-
}
|
|
27033
|
-
const existingCell = rowToChange.content[cellIndex];
|
|
27034
|
-
if (existingCell?.attrs?.continueMerge) continue;
|
|
27035
|
-
const mergedCell = {
|
|
27036
|
-
type: cell.type,
|
|
27037
|
-
content: [editorSchema.nodes.paragraph.createAndFill().toJSON()],
|
|
27038
|
-
attrs: {
|
|
27039
|
-
...cell.attrs,
|
|
27040
|
-
rowspan: null,
|
|
27041
|
-
continueMerge: true
|
|
27042
|
-
}
|
|
27043
|
-
};
|
|
27044
|
-
rowToChange.content.splice(cellIndex, 0, mergedCell);
|
|
27045
|
-
}
|
|
27046
|
-
}
|
|
27047
|
-
}
|
|
27048
|
-
return table;
|
|
27049
|
-
}
|
|
27050
27017
|
const translator$1a = NodeTranslator.from({
|
|
27051
|
-
xmlName: "w:cantSplit",
|
|
27052
|
-
sdNodeOrKeyName: "cantSplit",
|
|
27053
|
-
encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27054
|
-
decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
|
|
27055
|
-
});
|
|
27056
|
-
const translator$19 = NodeTranslator.from({
|
|
27057
27018
|
xmlName: "w:cnfStyle",
|
|
27058
27019
|
sdNodeOrKeyName: "cnfStyle",
|
|
27059
27020
|
attributes: [
|
|
@@ -27079,299 +27040,7 @@ const translator$19 = NodeTranslator.from({
|
|
|
27079
27040
|
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
27080
27041
|
}
|
|
27081
27042
|
});
|
|
27082
|
-
const translator$
|
|
27083
|
-
const translator$17 = NodeTranslator.from(
|
|
27084
|
-
createSingleAttrPropertyHandler(
|
|
27085
|
-
"w:gridAfter",
|
|
27086
|
-
null,
|
|
27087
|
-
"w:val",
|
|
27088
|
-
(v2) => parseInteger(v2) ?? void 0,
|
|
27089
|
-
(v2) => integerToString(v2)
|
|
27090
|
-
)
|
|
27091
|
-
);
|
|
27092
|
-
const translator$16 = NodeTranslator.from(
|
|
27093
|
-
createSingleAttrPropertyHandler(
|
|
27094
|
-
"w:gridBefore",
|
|
27095
|
-
null,
|
|
27096
|
-
"w:val",
|
|
27097
|
-
(v2) => parseInteger(v2) ?? void 0,
|
|
27098
|
-
(v2) => integerToString(v2)
|
|
27099
|
-
)
|
|
27100
|
-
);
|
|
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,
|
|
27151
|
-
translator$14,
|
|
27152
|
-
translator$13,
|
|
27153
|
-
translator$12,
|
|
27154
|
-
translator$11,
|
|
27155
|
-
translator$10,
|
|
27156
|
-
translator$$
|
|
27157
|
-
];
|
|
27158
|
-
const translator$_ = NodeTranslator.from(
|
|
27159
|
-
createNestedPropertiesTranslator("w:trPr", "tableRowProperties", propertyTranslators$6, {
|
|
27160
|
-
cantSplit: false,
|
|
27161
|
-
hidden: false,
|
|
27162
|
-
repeatHeader: false
|
|
27163
|
-
})
|
|
27164
|
-
);
|
|
27165
|
-
const createPlaceholderCell = (gridWidth, reason) => {
|
|
27166
|
-
const safeWidth = Number.isFinite(gridWidth) ? gridWidth : 0;
|
|
27167
|
-
const noBorder = { val: "none", size: 0 };
|
|
27168
|
-
return {
|
|
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: [] }]
|
|
27183
|
-
};
|
|
27184
|
-
};
|
|
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");
|
|
27300
|
-
const newNode = {
|
|
27301
|
-
type: "tableRow",
|
|
27302
|
-
content,
|
|
27303
|
-
attrs: encodedAttrs
|
|
27304
|
-
};
|
|
27305
|
-
return newNode;
|
|
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
|
-
};
|
|
27359
|
-
const config$g = {
|
|
27360
|
-
xmlName: XML_NODE_NAME$h,
|
|
27361
|
-
sdNodeOrKeyName: SD_NODE_NAME$d,
|
|
27362
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
27363
|
-
encode: encode$n,
|
|
27364
|
-
decode: decode$p,
|
|
27365
|
-
attributes: validXmlAttributes$b
|
|
27366
|
-
};
|
|
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({
|
|
27043
|
+
const translator$19 = NodeTranslator.from({
|
|
27375
27044
|
xmlName: "w:shd",
|
|
27376
27045
|
sdNodeOrKeyName: "shading",
|
|
27377
27046
|
attributes: [
|
|
@@ -27393,895 +27062,284 @@ const translator$X = NodeTranslator.from({
|
|
|
27393
27062
|
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
27394
27063
|
}
|
|
27395
27064
|
});
|
|
27396
|
-
const translator$
|
|
27397
|
-
const translator$
|
|
27398
|
-
|
|
27399
|
-
|
|
27400
|
-
|
|
27401
|
-
|
|
27402
|
-
|
|
27403
|
-
|
|
27404
|
-
|
|
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")
|
|
27065
|
+
const translator$18 = NodeTranslator.from(createMeasurementPropertyHandler("w:tcW", "cellWidth"));
|
|
27066
|
+
const translator$17 = NodeTranslator.from(
|
|
27067
|
+
createSingleAttrPropertyHandler(
|
|
27068
|
+
"w:gridSpan",
|
|
27069
|
+
null,
|
|
27070
|
+
"w:val",
|
|
27071
|
+
(v2) => parseInteger(v2) ?? void 0,
|
|
27072
|
+
(v2) => integerToString(v2)
|
|
27073
|
+
)
|
|
27419
27074
|
);
|
|
27420
|
-
const translator$
|
|
27421
|
-
const translator$
|
|
27422
|
-
|
|
27423
|
-
|
|
27424
|
-
|
|
27425
|
-
|
|
27426
|
-
|
|
27427
|
-
|
|
27428
|
-
|
|
27429
|
-
|
|
27430
|
-
|
|
27431
|
-
|
|
27432
|
-
|
|
27433
|
-
const translator$
|
|
27434
|
-
const translator$
|
|
27435
|
-
const translator$
|
|
27436
|
-
const translator$
|
|
27437
|
-
const
|
|
27438
|
-
|
|
27439
|
-
|
|
27440
|
-
|
|
27441
|
-
|
|
27442
|
-
|
|
27443
|
-
|
|
27444
|
-
|
|
27445
|
-
|
|
27446
|
-
|
|
27447
|
-
|
|
27448
|
-
translator$L,
|
|
27449
|
-
translator$J,
|
|
27450
|
-
translator$H,
|
|
27451
|
-
translator$G,
|
|
27452
|
-
translator$F,
|
|
27453
|
-
translator$D,
|
|
27454
|
-
translator$B,
|
|
27455
|
-
translator$z
|
|
27075
|
+
const translator$16 = NodeTranslator.from(createSingleAttrPropertyHandler("w:vMerge"));
|
|
27076
|
+
const translator$15 = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
|
|
27077
|
+
const translator$14 = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
|
|
27078
|
+
const translator$13 = NodeTranslator.from(createBorderPropertyHandler("w:end"));
|
|
27079
|
+
const translator$12 = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
|
|
27080
|
+
const translator$11 = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
|
|
27081
|
+
const translator$10 = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
|
|
27082
|
+
const translator$$ = NodeTranslator.from(createBorderPropertyHandler("w:left"));
|
|
27083
|
+
const translator$_ = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
|
|
27084
|
+
const translator$Z = NodeTranslator.from(createBorderPropertyHandler("w:right"));
|
|
27085
|
+
const translator$Y = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
|
|
27086
|
+
const translator$X = NodeTranslator.from(createBorderPropertyHandler("w:start"));
|
|
27087
|
+
const translator$W = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
|
|
27088
|
+
const translator$V = NodeTranslator.from(createBorderPropertyHandler("w:top"));
|
|
27089
|
+
const translator$U = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
|
|
27090
|
+
const translator$T = NodeTranslator.from(createBorderPropertyHandler("w:tl2br"));
|
|
27091
|
+
const translator$S = NodeTranslator.from(createBorderPropertyHandler("w:tr2bl"));
|
|
27092
|
+
const propertyTranslators$6 = [
|
|
27093
|
+
translator$V,
|
|
27094
|
+
translator$X,
|
|
27095
|
+
translator$$,
|
|
27096
|
+
translator$15,
|
|
27097
|
+
translator$13,
|
|
27098
|
+
translator$Z,
|
|
27099
|
+
translator$11,
|
|
27100
|
+
translator$10,
|
|
27101
|
+
translator$T,
|
|
27102
|
+
translator$S
|
|
27456
27103
|
];
|
|
27457
|
-
const translator$
|
|
27458
|
-
createNestedPropertiesTranslator("w:
|
|
27104
|
+
const translator$R = NodeTranslator.from(
|
|
27105
|
+
createNestedPropertiesTranslator("w:tcBorders", "borders", propertyTranslators$6)
|
|
27459
27106
|
);
|
|
27460
|
-
const
|
|
27461
|
-
|
|
27462
|
-
|
|
27463
|
-
|
|
27464
|
-
|
|
27465
|
-
|
|
27466
|
-
|
|
27467
|
-
|
|
27468
|
-
const translator$w = NodeTranslator.from(
|
|
27469
|
-
createNestedPropertiesTranslator("w:tblCellMar", "cellMargins", propertyTranslators$4)
|
|
27107
|
+
const translator$Q = NodeTranslator.from(
|
|
27108
|
+
createSingleAttrPropertyHandler(
|
|
27109
|
+
"w:noWrap",
|
|
27110
|
+
null,
|
|
27111
|
+
"w:val",
|
|
27112
|
+
(v2) => parseBoolean(v2 ?? "true"),
|
|
27113
|
+
(v2) => booleanToString(v2)
|
|
27114
|
+
)
|
|
27470
27115
|
);
|
|
27471
|
-
const propertyTranslators$
|
|
27472
|
-
translator$Y,
|
|
27116
|
+
const propertyTranslators$5 = [
|
|
27473
27117
|
translator$14,
|
|
27474
|
-
translator$
|
|
27118
|
+
translator$12,
|
|
27119
|
+
translator$_,
|
|
27120
|
+
translator$Y,
|
|
27475
27121
|
translator$W,
|
|
27476
|
-
translator$
|
|
27477
|
-
translator$V,
|
|
27478
|
-
translator$U,
|
|
27479
|
-
translator$T,
|
|
27480
|
-
translator$S,
|
|
27481
|
-
translator$R,
|
|
27482
|
-
translator$Q,
|
|
27483
|
-
translator$P,
|
|
27484
|
-
translator$O,
|
|
27485
|
-
translator$N,
|
|
27486
|
-
translator$M,
|
|
27487
|
-
translator$x,
|
|
27488
|
-
translator$w
|
|
27122
|
+
translator$U
|
|
27489
27123
|
];
|
|
27490
|
-
const translator$
|
|
27491
|
-
createNestedPropertiesTranslator("w:
|
|
27124
|
+
const translator$P = NodeTranslator.from(
|
|
27125
|
+
createNestedPropertiesTranslator("w:tcMar", "cellMargins", propertyTranslators$5)
|
|
27492
27126
|
);
|
|
27493
|
-
const translator$
|
|
27494
|
-
|
|
27127
|
+
const translator$O = NodeTranslator.from(createSingleAttrPropertyHandler("w:textDirection"));
|
|
27128
|
+
const translator$N = NodeTranslator.from(
|
|
27129
|
+
createSingleAttrPropertyHandler(
|
|
27130
|
+
"w:tcFitText",
|
|
27131
|
+
null,
|
|
27132
|
+
"w:val",
|
|
27133
|
+
(v2) => parseBoolean(v2 ?? "true"),
|
|
27134
|
+
(v2) => booleanToString(v2)
|
|
27135
|
+
)
|
|
27495
27136
|
);
|
|
27496
|
-
const
|
|
27497
|
-
const
|
|
27498
|
-
|
|
27499
|
-
|
|
27500
|
-
|
|
27501
|
-
|
|
27502
|
-
|
|
27503
|
-
|
|
27504
|
-
|
|
27505
|
-
|
|
27506
|
-
|
|
27507
|
-
|
|
27508
|
-
|
|
27509
|
-
|
|
27510
|
-
} else if (typeof defaultValue === "number" && Number.isFinite(defaultValue) && defaultValue > 0) {
|
|
27511
|
-
return defaultValue;
|
|
27512
|
-
}
|
|
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);
|
|
27523
|
-
}
|
|
27524
|
-
}
|
|
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;
|
|
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) => {
|
|
27137
|
+
const translator$M = NodeTranslator.from(createSingleAttrPropertyHandler("w:vAlign"));
|
|
27138
|
+
const translator$L = NodeTranslator.from(
|
|
27139
|
+
createSingleAttrPropertyHandler(
|
|
27140
|
+
"w:hideMark",
|
|
27141
|
+
null,
|
|
27142
|
+
"w:val",
|
|
27143
|
+
(v2) => parseBoolean(v2 ?? "true"),
|
|
27144
|
+
(v2) => booleanToString(v2)
|
|
27145
|
+
)
|
|
27146
|
+
);
|
|
27147
|
+
const translator$K = NodeTranslator.from(createSingleAttrPropertyHandler("w:header"));
|
|
27148
|
+
const XML_NODE_NAME$h = "w:headers";
|
|
27149
|
+
const SD_ATTR_KEY$3 = "headers";
|
|
27150
|
+
const encode$n = (params2) => {
|
|
27547
27151
|
const { nodes } = params2;
|
|
27548
27152
|
const node = nodes[0];
|
|
27549
|
-
const attributes = encodeProperties(node, { [translator$
|
|
27153
|
+
const attributes = encodeProperties(node, { [translator$K.xmlName]: translator$K }, true);
|
|
27550
27154
|
return {
|
|
27551
|
-
xmlName: XML_NODE_NAME$
|
|
27155
|
+
xmlName: XML_NODE_NAME$h,
|
|
27552
27156
|
sdNodeOrKeyName: SD_ATTR_KEY$3,
|
|
27553
27157
|
attributes
|
|
27554
27158
|
};
|
|
27555
27159
|
};
|
|
27556
|
-
const decode$
|
|
27557
|
-
const {
|
|
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;
|
|
27575
|
-
}
|
|
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);
|
|
27586
|
-
};
|
|
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;
|
|
27611
|
-
}
|
|
27612
|
-
pushColumn(cellWidthTwips, { enforceMinimum });
|
|
27613
|
-
columnIndex++;
|
|
27614
|
-
}
|
|
27615
|
-
});
|
|
27616
|
-
while (columnIndex < grid.length) {
|
|
27617
|
-
const gridWidthTwips = normalizeTwipWidth(grid[columnIndex]?.col);
|
|
27618
|
-
pushColumn(gridWidthTwips);
|
|
27619
|
-
columnIndex++;
|
|
27620
|
-
}
|
|
27160
|
+
const decode$p = (params2) => {
|
|
27161
|
+
const { headers = [] } = params2.node.attrs || {};
|
|
27621
27162
|
const newNode = {
|
|
27622
|
-
name: XML_NODE_NAME$
|
|
27163
|
+
name: XML_NODE_NAME$h,
|
|
27623
27164
|
attributes: {},
|
|
27624
|
-
elements
|
|
27165
|
+
elements: headers.map(
|
|
27166
|
+
(header) => translator$K.decode({
|
|
27167
|
+
node: { type: "header", attrs: header }
|
|
27168
|
+
})
|
|
27169
|
+
)
|
|
27625
27170
|
};
|
|
27626
27171
|
return newNode;
|
|
27627
27172
|
};
|
|
27628
|
-
const config$
|
|
27629
|
-
xmlName: XML_NODE_NAME$
|
|
27173
|
+
const config$g = {
|
|
27174
|
+
xmlName: XML_NODE_NAME$h,
|
|
27630
27175
|
sdNodeOrKeyName: SD_ATTR_KEY$3,
|
|
27631
|
-
encode: encode$
|
|
27632
|
-
decode: decode$
|
|
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;
|
|
27176
|
+
encode: encode$n,
|
|
27177
|
+
decode: decode$p
|
|
27642
27178
|
};
|
|
27643
|
-
const
|
|
27644
|
-
const
|
|
27645
|
-
|
|
27646
|
-
|
|
27647
|
-
|
|
27648
|
-
|
|
27649
|
-
|
|
27650
|
-
|
|
27651
|
-
|
|
27652
|
-
|
|
27653
|
-
|
|
27179
|
+
const translator$J = NodeTranslator.from(config$g);
|
|
27180
|
+
const propertyTranslators$4 = [
|
|
27181
|
+
translator$1a,
|
|
27182
|
+
translator$18,
|
|
27183
|
+
translator$17,
|
|
27184
|
+
translator$16,
|
|
27185
|
+
translator$R,
|
|
27186
|
+
translator$19,
|
|
27187
|
+
translator$Q,
|
|
27188
|
+
translator$P,
|
|
27189
|
+
translator$O,
|
|
27190
|
+
translator$N,
|
|
27191
|
+
translator$M,
|
|
27192
|
+
translator$L,
|
|
27193
|
+
translator$J
|
|
27194
|
+
];
|
|
27195
|
+
const translator$I = NodeTranslator.from(
|
|
27196
|
+
createNestedPropertiesTranslator("w:tcPr", "tableCellProperties", propertyTranslators$4)
|
|
27197
|
+
);
|
|
27198
|
+
function handleTableCellNode({
|
|
27199
|
+
params: params2,
|
|
27200
|
+
node,
|
|
27201
|
+
table,
|
|
27202
|
+
row,
|
|
27203
|
+
rowBorders,
|
|
27204
|
+
columnIndex,
|
|
27205
|
+
columnWidth = null,
|
|
27206
|
+
allColumnWidths = [],
|
|
27207
|
+
_referencedStyles
|
|
27208
|
+
}) {
|
|
27209
|
+
const { nodeListHandler } = params2;
|
|
27210
|
+
const attributes = {};
|
|
27211
|
+
const referencedStyles = _referencedStyles ?? { fontSize: null, fonts: {}, cellMargins: {} };
|
|
27212
|
+
const tcPr = node.elements.find((el) => el.name === "w:tcPr");
|
|
27213
|
+
const tableCellProperties = tcPr ? translator$I.encode({ ...params2, nodes: [tcPr] }) ?? {} : {};
|
|
27214
|
+
attributes["tableCellProperties"] = tableCellProperties;
|
|
27215
|
+
if (rowBorders?.insideH) {
|
|
27216
|
+
rowBorders["bottom"] = rowBorders.insideH;
|
|
27217
|
+
delete rowBorders.insideH;
|
|
27654
27218
|
}
|
|
27655
|
-
|
|
27656
|
-
|
|
27657
|
-
|
|
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;
|
|
27219
|
+
if (rowBorders?.insideV) {
|
|
27220
|
+
rowBorders["right"] = rowBorders.insideV;
|
|
27221
|
+
delete rowBorders?.insideV;
|
|
27682
27222
|
}
|
|
27683
|
-
if (
|
|
27684
|
-
|
|
27223
|
+
if (rowBorders) attributes["borders"] = { ...rowBorders };
|
|
27224
|
+
const inlineBorders = processInlineCellBorders(tableCellProperties.borders, rowBorders);
|
|
27225
|
+
if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"] || {}, inlineBorders);
|
|
27226
|
+
const colspan = tableCellProperties.gridSpan;
|
|
27227
|
+
if (colspan && !isNaN(parseInt(colspan, 10))) attributes["colspan"] = parseInt(colspan, 10);
|
|
27228
|
+
let width = tableCellProperties.cellWidth?.value ? twipsToPixels(tableCellProperties.cellWidth?.value) : null;
|
|
27229
|
+
const widthType = tableCellProperties.cellWidth?.type;
|
|
27230
|
+
if (widthType) attributes["widthType"] = widthType;
|
|
27231
|
+
if (!width && columnWidth) width = columnWidth;
|
|
27232
|
+
if (width) {
|
|
27233
|
+
attributes["colwidth"] = [width];
|
|
27234
|
+
attributes["widthUnit"] = "px";
|
|
27235
|
+
const defaultColWidths = allColumnWidths;
|
|
27236
|
+
const hasDefaultColWidths = allColumnWidths && allColumnWidths.length > 0;
|
|
27237
|
+
const colspanNum = parseInt(colspan || 1, 10);
|
|
27238
|
+
if (colspanNum && colspanNum > 1 && hasDefaultColWidths) {
|
|
27239
|
+
let colwidth = [];
|
|
27240
|
+
for (let i = 0; i < colspanNum; i++) {
|
|
27241
|
+
let colwidthValue = defaultColWidths[columnIndex + i];
|
|
27242
|
+
let defaultColwidth = 100;
|
|
27243
|
+
if (typeof colwidthValue !== "undefined") {
|
|
27244
|
+
colwidth.push(colwidthValue);
|
|
27245
|
+
} else {
|
|
27246
|
+
colwidth.push(defaultColwidth);
|
|
27247
|
+
}
|
|
27248
|
+
}
|
|
27249
|
+
if (colwidth.length) {
|
|
27250
|
+
attributes["colwidth"] = [...colwidth];
|
|
27251
|
+
}
|
|
27252
|
+
}
|
|
27685
27253
|
}
|
|
27686
|
-
|
|
27687
|
-
|
|
27254
|
+
const background = {
|
|
27255
|
+
color: tableCellProperties.shading?.fill
|
|
27256
|
+
};
|
|
27257
|
+
if (background.color) attributes["background"] = background;
|
|
27258
|
+
const verticalAlign = tableCellProperties.vAlign;
|
|
27259
|
+
if (verticalAlign) attributes["verticalAlign"] = verticalAlign;
|
|
27260
|
+
attributes.cellMargins = getTableCellMargins(tableCellProperties.cellMargins, referencedStyles);
|
|
27261
|
+
const { fontSize: fontSize2, fonts = {} } = referencedStyles;
|
|
27262
|
+
const fontFamily2 = fonts["ascii"];
|
|
27263
|
+
if (fontSize2) attributes["fontSize"] = fontSize2;
|
|
27264
|
+
if (fontFamily2) attributes["fontFamily"] = fontFamily2;
|
|
27265
|
+
if (tableCellProperties.vMerge === "restart") {
|
|
27266
|
+
const rows = table.elements.filter((el) => el.name === "w:tr");
|
|
27267
|
+
const currentRowIndex = rows.findIndex((r2) => r2 === row);
|
|
27268
|
+
const remainingRows = rows.slice(currentRowIndex + 1);
|
|
27269
|
+
const cellsInRow = row.elements.filter((el) => el.name === "w:tc");
|
|
27270
|
+
let cellIndex = cellsInRow.findIndex((el) => el === node);
|
|
27271
|
+
let rowspan = 1;
|
|
27272
|
+
for (let remainingRow of remainingRows) {
|
|
27273
|
+
const firstCell = remainingRow.elements.findIndex((el) => el.name === "w:tc");
|
|
27274
|
+
const cellAtIndex = remainingRow.elements[firstCell + cellIndex];
|
|
27275
|
+
if (!cellAtIndex) break;
|
|
27276
|
+
const vMerge = getTableCellVMerge(cellAtIndex);
|
|
27277
|
+
if (!vMerge || vMerge === "restart") {
|
|
27278
|
+
break;
|
|
27279
|
+
}
|
|
27280
|
+
rowspan++;
|
|
27281
|
+
remainingRow.elements.splice(firstCell + cellIndex, 1);
|
|
27282
|
+
}
|
|
27283
|
+
attributes["rowspan"] = rowspan;
|
|
27688
27284
|
}
|
|
27689
|
-
const rawColumnWidthPx = Math.max(totalWidthPx / columnCount, minimumColumnWidthPx);
|
|
27690
|
-
const columnWidthTwips = clampColumnWidthTwips(pixelsToTwips(rawColumnWidthPx));
|
|
27691
|
-
const fallbackColumnWidthPx = twipsToPixels(columnWidthTwips);
|
|
27692
27285
|
return {
|
|
27693
|
-
|
|
27694
|
-
|
|
27286
|
+
type: "tableCell",
|
|
27287
|
+
content: normalizeTableCellContent(
|
|
27288
|
+
nodeListHandler.handler({
|
|
27289
|
+
...params2,
|
|
27290
|
+
nodes: node.elements,
|
|
27291
|
+
path: [...params2.path || [], node]
|
|
27292
|
+
}),
|
|
27293
|
+
params2.editor
|
|
27294
|
+
),
|
|
27295
|
+
attrs: attributes
|
|
27695
27296
|
};
|
|
27696
|
-
}
|
|
27697
|
-
|
|
27698
|
-
|
|
27699
|
-
const
|
|
27700
|
-
const
|
|
27701
|
-
const
|
|
27702
|
-
const
|
|
27703
|
-
|
|
27704
|
-
const
|
|
27705
|
-
|
|
27706
|
-
|
|
27707
|
-
const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
|
|
27708
|
-
if (tblGrid) {
|
|
27709
|
-
encodedAttrs["grid"] = translator$t.encode({ ...params2, nodes: [tblGrid] }).attributes;
|
|
27710
|
-
}
|
|
27711
|
-
[
|
|
27712
|
-
"tableStyleId",
|
|
27713
|
-
"justification",
|
|
27714
|
-
"tableLayout",
|
|
27715
|
-
["tableIndent", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
27716
|
-
["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
|
|
27717
|
-
].forEach((prop) => {
|
|
27718
|
-
let key2;
|
|
27719
|
-
let transform;
|
|
27720
|
-
if (Array.isArray(prop)) {
|
|
27721
|
-
[key2, transform] = prop;
|
|
27722
|
-
} else {
|
|
27723
|
-
key2 = prop;
|
|
27724
|
-
transform = (v2) => v2;
|
|
27297
|
+
}
|
|
27298
|
+
function normalizeTableCellContent(content, editor) {
|
|
27299
|
+
if (!Array.isArray(content) || content.length === 0) return content;
|
|
27300
|
+
const normalized = [];
|
|
27301
|
+
const pendingForNextBlock = [];
|
|
27302
|
+
const schema = editor?.schema;
|
|
27303
|
+
const cloneBlock = (node) => {
|
|
27304
|
+
if (!node) return node;
|
|
27305
|
+
const cloned = { ...node };
|
|
27306
|
+
if (Array.isArray(node.content)) {
|
|
27307
|
+
cloned.content = [...node.content];
|
|
27725
27308
|
}
|
|
27726
|
-
|
|
27727
|
-
|
|
27309
|
+
return cloned;
|
|
27310
|
+
};
|
|
27311
|
+
const ensureArray = (node) => {
|
|
27312
|
+
if (!Array.isArray(node.content)) {
|
|
27313
|
+
node.content = [];
|
|
27728
27314
|
}
|
|
27729
|
-
|
|
27730
|
-
|
|
27731
|
-
|
|
27732
|
-
|
|
27733
|
-
|
|
27734
|
-
|
|
27735
|
-
const
|
|
27736
|
-
if (
|
|
27737
|
-
|
|
27738
|
-
|
|
27739
|
-
|
|
27740
|
-
}
|
|
27741
|
-
} else if (tableWidthMeasurement.type === "auto") {
|
|
27742
|
-
encodedAttrs.tableWidth = {
|
|
27743
|
-
width: 0,
|
|
27744
|
-
type: tableWidthMeasurement.type
|
|
27745
|
-
};
|
|
27315
|
+
return node.content;
|
|
27316
|
+
};
|
|
27317
|
+
const isInlineNode = (node) => {
|
|
27318
|
+
if (!node || typeof node.type !== "string") return false;
|
|
27319
|
+
if (node.type === "text") return true;
|
|
27320
|
+
if (node.type === "bookmarkStart" || node.type === "bookmarkEnd") return true;
|
|
27321
|
+
const nodeType = schema?.nodes?.[node.type];
|
|
27322
|
+
if (nodeType) {
|
|
27323
|
+
if (typeof nodeType.isInline === "boolean") return nodeType.isInline;
|
|
27324
|
+
if (nodeType.spec?.group && typeof nodeType.spec.group === "string") {
|
|
27325
|
+
return nodeType.spec.group.split(" ").includes("inline");
|
|
27326
|
+
}
|
|
27746
27327
|
}
|
|
27747
|
-
|
|
27748
|
-
|
|
27749
|
-
const
|
|
27750
|
-
|
|
27751
|
-
|
|
27752
|
-
|
|
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;
|
|
27328
|
+
return false;
|
|
27329
|
+
};
|
|
27330
|
+
for (const node of content) {
|
|
27331
|
+
if (!node || typeof node.type !== "string") {
|
|
27332
|
+
normalized.push(node);
|
|
27333
|
+
continue;
|
|
27772
27334
|
}
|
|
27773
|
-
|
|
27774
|
-
|
|
27775
|
-
|
|
27776
|
-
|
|
27777
|
-
|
|
27778
|
-
|
|
27779
|
-
|
|
27780
|
-
|
|
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
|
-
});
|
|
27823
|
-
}
|
|
27824
|
-
}
|
|
27825
|
-
});
|
|
27826
|
-
return {
|
|
27827
|
-
type: "table",
|
|
27828
|
-
content,
|
|
27829
|
-
attrs: encodedAttrs
|
|
27830
|
-
};
|
|
27831
|
-
};
|
|
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({
|
|
27839
|
-
...params2,
|
|
27840
|
-
node: { ...node, attrs: { ...node.attrs, grid: properties } },
|
|
27841
|
-
extraParams: {
|
|
27842
|
-
firstRow
|
|
27843
|
-
}
|
|
27844
|
-
});
|
|
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
|
-
}
|
|
27854
|
-
return {
|
|
27855
|
-
name: "w:tbl",
|
|
27856
|
-
attributes: decodedAttrs || {},
|
|
27857
|
-
elements
|
|
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
|
-
};
|
|
27877
|
-
}
|
|
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") : {};
|
|
27893
|
-
}
|
|
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"];
|
|
27898
|
-
}
|
|
27899
|
-
const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
|
|
27900
|
-
if (rPr) {
|
|
27901
|
-
const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
|
|
27902
|
-
if (fonts) {
|
|
27903
|
-
const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
|
|
27904
|
-
stylesToReturn.fonts = { ascii, hAnsi, cs };
|
|
27905
|
-
}
|
|
27906
|
-
const fontSize2 = rPr.elements.find((el) => el.name === "w:sz");
|
|
27907
|
-
if (fontSize2?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize2.attributes["w:val"]) + "pt";
|
|
27908
|
-
}
|
|
27909
|
-
const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
|
|
27910
|
-
if (tblPr && tblPr.elements) {
|
|
27911
|
-
if (baseTblPr && baseTblPr.elements) {
|
|
27912
|
-
tblPr.elements.push(...baseTblPr.elements);
|
|
27913
|
-
}
|
|
27914
|
-
const tableProperties = translator$v.encode({ ...params2, nodes: [tblPr] });
|
|
27915
|
-
const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
|
|
27916
|
-
if (borders) stylesToReturn.borders = borders;
|
|
27917
|
-
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
27918
|
-
const cellMargins = {};
|
|
27919
|
-
Object.entries(tableProperties.cellMargins || {}).forEach(([key2, attrs]) => {
|
|
27920
|
-
if (attrs?.value != null) {
|
|
27921
|
-
cellMargins[key2] = {
|
|
27922
|
-
value: attrs.value,
|
|
27923
|
-
type: attrs.type || "dxa"
|
|
27924
|
-
};
|
|
27925
|
-
}
|
|
27926
|
-
});
|
|
27927
|
-
if (Object.keys(cellMargins).length) stylesToReturn.cellMargins = cellMargins;
|
|
27928
|
-
}
|
|
27929
|
-
return stylesToReturn;
|
|
27930
|
-
}
|
|
27931
|
-
const config$e = {
|
|
27932
|
-
xmlName: XML_NODE_NAME$f,
|
|
27933
|
-
sdNodeOrKeyName: SD_NODE_NAME$c,
|
|
27934
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
27935
|
-
encode: encode$l,
|
|
27936
|
-
decode: decode$n,
|
|
27937
|
-
attributes: []
|
|
27938
|
-
};
|
|
27939
|
-
const translator$s = NodeTranslator.from(config$e);
|
|
27940
|
-
const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$s);
|
|
27941
|
-
function getReferencedTableStyles(tblStyleTag, docx) {
|
|
27942
|
-
if (!tblStyleTag) return null;
|
|
27943
|
-
const stylesToReturn = {};
|
|
27944
|
-
const { attributes = {} } = tblStyleTag;
|
|
27945
|
-
const tableStyleReference = attributes["w:val"];
|
|
27946
|
-
if (!tableStyleReference) return null;
|
|
27947
|
-
const styles = docx["word/styles.xml"];
|
|
27948
|
-
const { elements } = styles.elements[0];
|
|
27949
|
-
const styleElements = elements.filter((el) => el.name === "w:style");
|
|
27950
|
-
const styleTag = styleElements.find((el) => el.attributes["w:styleId"] === tableStyleReference);
|
|
27951
|
-
if (!styleTag) return null;
|
|
27952
|
-
stylesToReturn.name = styleTag.elements.find((el) => el.name === "w:name");
|
|
27953
|
-
const basedOn = styleTag.elements.find((el) => el.name === "w:basedOn");
|
|
27954
|
-
let baseTblPr;
|
|
27955
|
-
if (basedOn?.attributes) {
|
|
27956
|
-
const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
|
|
27957
|
-
baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
|
|
27958
|
-
}
|
|
27959
|
-
const pPr = styleTag.elements.find((el) => el.name === "w:pPr");
|
|
27960
|
-
if (pPr) {
|
|
27961
|
-
const justification = pPr.elements.find((el) => el.name === "w:jc");
|
|
27962
|
-
if (justification?.attributes) stylesToReturn.justification = justification.attributes["w:val"];
|
|
27963
|
-
}
|
|
27964
|
-
const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
|
|
27965
|
-
if (rPr) {
|
|
27966
|
-
const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
|
|
27967
|
-
if (fonts) {
|
|
27968
|
-
const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
|
|
27969
|
-
stylesToReturn.fonts = { ascii, hAnsi, cs };
|
|
27970
|
-
}
|
|
27971
|
-
const fontSize2 = rPr.elements.find((el) => el.name === "w:sz");
|
|
27972
|
-
if (fontSize2?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize2.attributes["w:val"]) + "pt";
|
|
27973
|
-
}
|
|
27974
|
-
const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
|
|
27975
|
-
if (tblPr && tblPr.elements) {
|
|
27976
|
-
if (baseTblPr && baseTblPr.elements) {
|
|
27977
|
-
tblPr.elements.push(...baseTblPr.elements);
|
|
27978
|
-
}
|
|
27979
|
-
const tableBorders = tblPr?.elements?.find((el) => el.name === "w:tblBorders");
|
|
27980
|
-
const { elements: borderElements = [] } = tableBorders || {};
|
|
27981
|
-
const { borders, rowBorders } = processTableBorders(borderElements);
|
|
27982
|
-
if (borders) stylesToReturn.borders = borders;
|
|
27983
|
-
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
27984
|
-
const tableCellMargin = tblPr?.elements.find((el) => el.name === "w:tblCellMar");
|
|
27985
|
-
if (tableCellMargin) {
|
|
27986
|
-
const marginLeft = tableCellMargin.elements.find((el) => el.name === "w:left");
|
|
27987
|
-
const marginRight = tableCellMargin.elements.find((el) => el.name === "w:right");
|
|
27988
|
-
const marginTop = tableCellMargin.elements.find((el) => el.name === "w:top");
|
|
27989
|
-
const marginBottom = tableCellMargin.elements.find((el) => el.name === "w:bottom");
|
|
27990
|
-
stylesToReturn.cellMargins = {
|
|
27991
|
-
marginLeft: marginLeft?.attributes["w:w"],
|
|
27992
|
-
marginRight: marginRight?.attributes["w:w"],
|
|
27993
|
-
marginTop: marginTop?.attributes["w:w"],
|
|
27994
|
-
marginBottom: marginBottom?.attributes["w:w"]
|
|
27995
|
-
};
|
|
27996
|
-
}
|
|
27997
|
-
}
|
|
27998
|
-
return stylesToReturn;
|
|
27999
|
-
}
|
|
28000
|
-
function processTableBorders(borderElements) {
|
|
28001
|
-
const borders = {};
|
|
28002
|
-
const rowBorders = {};
|
|
28003
|
-
borderElements.forEach((borderElement) => {
|
|
28004
|
-
const { name } = borderElement;
|
|
28005
|
-
const borderName = name.split("w:")[1];
|
|
28006
|
-
const { attributes } = borderElement;
|
|
28007
|
-
const attrs = {};
|
|
28008
|
-
const color = attributes["w:color"];
|
|
28009
|
-
const size2 = attributes["w:sz"];
|
|
28010
|
-
if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
|
|
28011
|
-
if (size2 && size2 !== "auto") attrs["size"] = eighthPointsToPixels(size2);
|
|
28012
|
-
const rowBorderNames = ["insideH", "insideV"];
|
|
28013
|
-
if (rowBorderNames.includes(borderName)) rowBorders[borderName] = attrs;
|
|
28014
|
-
borders[borderName] = attrs;
|
|
28015
|
-
});
|
|
28016
|
-
return {
|
|
28017
|
-
borders,
|
|
28018
|
-
rowBorders
|
|
28019
|
-
};
|
|
28020
|
-
}
|
|
28021
|
-
const translator$r = NodeTranslator.from(createMeasurementPropertyHandler("w:tcW", "cellWidth"));
|
|
28022
|
-
const translator$q = NodeTranslator.from(
|
|
28023
|
-
createSingleAttrPropertyHandler(
|
|
28024
|
-
"w:gridSpan",
|
|
28025
|
-
null,
|
|
28026
|
-
"w:val",
|
|
28027
|
-
(v2) => parseInteger(v2) ?? void 0,
|
|
28028
|
-
(v2) => integerToString(v2)
|
|
28029
|
-
)
|
|
28030
|
-
);
|
|
28031
|
-
const translator$p = NodeTranslator.from(createSingleAttrPropertyHandler("w:vMerge"));
|
|
28032
|
-
const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:tl2br"));
|
|
28033
|
-
const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:tr2bl"));
|
|
28034
|
-
const propertyTranslators$2 = [
|
|
28035
|
-
translator$z,
|
|
28036
|
-
translator$B,
|
|
28037
|
-
translator$F,
|
|
28038
|
-
translator$L,
|
|
28039
|
-
translator$J,
|
|
28040
|
-
translator$D,
|
|
28041
|
-
translator$H,
|
|
28042
|
-
translator$G,
|
|
28043
|
-
translator$o,
|
|
28044
|
-
translator$n
|
|
28045
|
-
];
|
|
28046
|
-
const translator$m = NodeTranslator.from(
|
|
28047
|
-
createNestedPropertiesTranslator("w:tcBorders", "borders", propertyTranslators$2)
|
|
28048
|
-
);
|
|
28049
|
-
const translator$l = NodeTranslator.from(
|
|
28050
|
-
createSingleAttrPropertyHandler(
|
|
28051
|
-
"w:noWrap",
|
|
28052
|
-
null,
|
|
28053
|
-
"w:val",
|
|
28054
|
-
(v2) => parseBoolean(v2 ?? "true"),
|
|
28055
|
-
(v2) => booleanToString(v2)
|
|
28056
|
-
)
|
|
28057
|
-
);
|
|
28058
|
-
const propertyTranslators$1 = [
|
|
28059
|
-
translator$K,
|
|
28060
|
-
translator$I,
|
|
28061
|
-
translator$E,
|
|
28062
|
-
translator$C,
|
|
28063
|
-
translator$A,
|
|
28064
|
-
translator$y
|
|
28065
|
-
];
|
|
28066
|
-
const translator$k = NodeTranslator.from(
|
|
28067
|
-
createNestedPropertiesTranslator("w:tcMar", "cellMargins", propertyTranslators$1)
|
|
28068
|
-
);
|
|
28069
|
-
const translator$j = NodeTranslator.from(createSingleAttrPropertyHandler("w:textDirection"));
|
|
28070
|
-
const translator$i = NodeTranslator.from(
|
|
28071
|
-
createSingleAttrPropertyHandler(
|
|
28072
|
-
"w:tcFitText",
|
|
28073
|
-
null,
|
|
28074
|
-
"w:val",
|
|
28075
|
-
(v2) => parseBoolean(v2 ?? "true"),
|
|
28076
|
-
(v2) => booleanToString(v2)
|
|
28077
|
-
)
|
|
28078
|
-
);
|
|
28079
|
-
const translator$h = NodeTranslator.from(createSingleAttrPropertyHandler("w:vAlign"));
|
|
28080
|
-
const translator$g = NodeTranslator.from(
|
|
28081
|
-
createSingleAttrPropertyHandler(
|
|
28082
|
-
"w:hideMark",
|
|
28083
|
-
null,
|
|
28084
|
-
"w:val",
|
|
28085
|
-
(v2) => parseBoolean(v2 ?? "true"),
|
|
28086
|
-
(v2) => booleanToString(v2)
|
|
28087
|
-
)
|
|
28088
|
-
);
|
|
28089
|
-
const translator$f = NodeTranslator.from(createSingleAttrPropertyHandler("w:header"));
|
|
28090
|
-
const XML_NODE_NAME$e = "w:headers";
|
|
28091
|
-
const SD_ATTR_KEY$2 = "headers";
|
|
28092
|
-
const encode$k = (params2) => {
|
|
28093
|
-
const { nodes } = params2;
|
|
28094
|
-
const node = nodes[0];
|
|
28095
|
-
const attributes = encodeProperties(node, { [translator$f.xmlName]: translator$f }, true);
|
|
28096
|
-
return {
|
|
28097
|
-
xmlName: XML_NODE_NAME$e,
|
|
28098
|
-
sdNodeOrKeyName: SD_ATTR_KEY$2,
|
|
28099
|
-
attributes
|
|
28100
|
-
};
|
|
28101
|
-
};
|
|
28102
|
-
const decode$m = (params2) => {
|
|
28103
|
-
const { headers = [] } = params2.node.attrs || {};
|
|
28104
|
-
const newNode = {
|
|
28105
|
-
name: XML_NODE_NAME$e,
|
|
28106
|
-
attributes: {},
|
|
28107
|
-
elements: headers.map(
|
|
28108
|
-
(header) => translator$f.decode({
|
|
28109
|
-
node: { type: "header", attrs: header }
|
|
28110
|
-
})
|
|
28111
|
-
)
|
|
28112
|
-
};
|
|
28113
|
-
return newNode;
|
|
28114
|
-
};
|
|
28115
|
-
const config$d = {
|
|
28116
|
-
xmlName: XML_NODE_NAME$e,
|
|
28117
|
-
sdNodeOrKeyName: SD_ATTR_KEY$2,
|
|
28118
|
-
encode: encode$k,
|
|
28119
|
-
decode: decode$m
|
|
28120
|
-
};
|
|
28121
|
-
const translator$e = NodeTranslator.from(config$d);
|
|
28122
|
-
const propertyTranslators = [
|
|
28123
|
-
translator$19,
|
|
28124
|
-
translator$r,
|
|
28125
|
-
translator$q,
|
|
28126
|
-
translator$p,
|
|
28127
|
-
translator$m,
|
|
28128
|
-
translator$X,
|
|
28129
|
-
translator$l,
|
|
28130
|
-
translator$k,
|
|
28131
|
-
translator$j,
|
|
28132
|
-
translator$i,
|
|
28133
|
-
translator$h,
|
|
28134
|
-
translator$g,
|
|
28135
|
-
translator$e
|
|
28136
|
-
];
|
|
28137
|
-
const translator$d = NodeTranslator.from(
|
|
28138
|
-
createNestedPropertiesTranslator("w:tcPr", "tableCellProperties", propertyTranslators)
|
|
28139
|
-
);
|
|
28140
|
-
function handleTableCellNode({
|
|
28141
|
-
params: params2,
|
|
28142
|
-
node,
|
|
28143
|
-
table,
|
|
28144
|
-
row,
|
|
28145
|
-
rowBorders,
|
|
28146
|
-
styleTag,
|
|
28147
|
-
columnIndex,
|
|
28148
|
-
columnWidth = null,
|
|
28149
|
-
allColumnWidths = []
|
|
28150
|
-
}) {
|
|
28151
|
-
const { docx, nodeListHandler } = params2;
|
|
28152
|
-
const attributes = {};
|
|
28153
|
-
const tcPr = node.elements.find((el) => el.name === "w:tcPr");
|
|
28154
|
-
const tableCellProperties = tcPr ? translator$d.encode({ ...params2, nodes: [tcPr] }) ?? {} : {};
|
|
28155
|
-
attributes["tableCellProperties"] = tableCellProperties;
|
|
28156
|
-
if (rowBorders?.insideH) {
|
|
28157
|
-
rowBorders["bottom"] = rowBorders.insideH;
|
|
28158
|
-
delete rowBorders.insideH;
|
|
28159
|
-
}
|
|
28160
|
-
if (rowBorders?.insideV) {
|
|
28161
|
-
rowBorders["right"] = rowBorders.insideV;
|
|
28162
|
-
delete rowBorders?.insideV;
|
|
28163
|
-
}
|
|
28164
|
-
if (rowBorders) attributes["borders"] = { ...rowBorders };
|
|
28165
|
-
const inlineBorders = processInlineCellBorders(tableCellProperties.borders, rowBorders);
|
|
28166
|
-
if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"] || {}, inlineBorders);
|
|
28167
|
-
const colspan = tableCellProperties.gridSpan;
|
|
28168
|
-
if (colspan && !isNaN(parseInt(colspan, 10))) attributes["colspan"] = parseInt(colspan, 10);
|
|
28169
|
-
let width = tableCellProperties.cellWidth?.value ? twipsToPixels(tableCellProperties.cellWidth?.value) : null;
|
|
28170
|
-
const widthType = tableCellProperties.cellWidth?.type;
|
|
28171
|
-
if (widthType) attributes["widthType"] = widthType;
|
|
28172
|
-
if (!width && columnWidth) width = columnWidth;
|
|
28173
|
-
if (width) {
|
|
28174
|
-
attributes["colwidth"] = [width];
|
|
28175
|
-
attributes["widthUnit"] = "px";
|
|
28176
|
-
const defaultColWidths = allColumnWidths;
|
|
28177
|
-
const hasDefaultColWidths = allColumnWidths && allColumnWidths.length > 0;
|
|
28178
|
-
const colspanNum = parseInt(colspan || 1, 10);
|
|
28179
|
-
if (colspanNum && colspanNum > 1 && hasDefaultColWidths) {
|
|
28180
|
-
let colwidth = [];
|
|
28181
|
-
for (let i = 0; i < colspanNum; i++) {
|
|
28182
|
-
let colwidthValue = defaultColWidths[columnIndex + i];
|
|
28183
|
-
let defaultColwidth = 100;
|
|
28184
|
-
if (typeof colwidthValue !== "undefined") {
|
|
28185
|
-
colwidth.push(colwidthValue);
|
|
28186
|
-
} else {
|
|
28187
|
-
colwidth.push(defaultColwidth);
|
|
28188
|
-
}
|
|
28189
|
-
}
|
|
28190
|
-
if (colwidth.length) {
|
|
28191
|
-
attributes["colwidth"] = [...colwidth];
|
|
28192
|
-
}
|
|
28193
|
-
}
|
|
28194
|
-
}
|
|
28195
|
-
const background = {
|
|
28196
|
-
color: tableCellProperties.shading?.fill
|
|
28197
|
-
};
|
|
28198
|
-
if (background.color) attributes["background"] = background;
|
|
28199
|
-
const verticalAlign = tableCellProperties.vAlign;
|
|
28200
|
-
if (verticalAlign) attributes["verticalAlign"] = verticalAlign;
|
|
28201
|
-
const referencedStyles = getReferencedTableStyles(styleTag, docx) || { fontSize: null, fonts: {}, cellMargins: {} };
|
|
28202
|
-
attributes.cellMargins = getTableCellMargins(tableCellProperties.cellMargins, referencedStyles);
|
|
28203
|
-
const { fontSize: fontSize2, fonts = {} } = referencedStyles;
|
|
28204
|
-
const fontFamily2 = fonts["ascii"];
|
|
28205
|
-
if (fontSize2) attributes["fontSize"] = fontSize2;
|
|
28206
|
-
if (fontFamily2) attributes["fontFamily"] = fontFamily2;
|
|
28207
|
-
if (tableCellProperties.vMerge === "restart") {
|
|
28208
|
-
const rows = table.elements.filter((el) => el.name === "w:tr");
|
|
28209
|
-
const currentRowIndex = rows.findIndex((r2) => r2 === row);
|
|
28210
|
-
const remainingRows = rows.slice(currentRowIndex + 1);
|
|
28211
|
-
const cellsInRow = row.elements.filter((el) => el.name === "w:tc");
|
|
28212
|
-
let cellIndex = cellsInRow.findIndex((el) => el === node);
|
|
28213
|
-
let rowspan = 1;
|
|
28214
|
-
for (let remainingRow of remainingRows) {
|
|
28215
|
-
const firstCell = remainingRow.elements.findIndex((el) => el.name === "w:tc");
|
|
28216
|
-
const cellAtIndex = remainingRow.elements[firstCell + cellIndex];
|
|
28217
|
-
if (!cellAtIndex) break;
|
|
28218
|
-
const vMerge = getTableCellVMerge(cellAtIndex);
|
|
28219
|
-
if (!vMerge || vMerge === "restart") {
|
|
28220
|
-
break;
|
|
28221
|
-
}
|
|
28222
|
-
rowspan++;
|
|
28223
|
-
remainingRow.elements.splice(firstCell + cellIndex, 1);
|
|
28224
|
-
}
|
|
28225
|
-
attributes["rowspan"] = rowspan;
|
|
28226
|
-
}
|
|
28227
|
-
return {
|
|
28228
|
-
type: "tableCell",
|
|
28229
|
-
content: normalizeTableCellContent(
|
|
28230
|
-
nodeListHandler.handler({
|
|
28231
|
-
...params2,
|
|
28232
|
-
nodes: node.elements,
|
|
28233
|
-
path: [...params2.path || [], node]
|
|
28234
|
-
}),
|
|
28235
|
-
params2.editor
|
|
28236
|
-
),
|
|
28237
|
-
attrs: attributes
|
|
28238
|
-
};
|
|
28239
|
-
}
|
|
28240
|
-
function normalizeTableCellContent(content, editor) {
|
|
28241
|
-
if (!Array.isArray(content) || content.length === 0) return content;
|
|
28242
|
-
const normalized = [];
|
|
28243
|
-
const pendingForNextBlock = [];
|
|
28244
|
-
const schema = editor?.schema;
|
|
28245
|
-
const cloneBlock = (node) => {
|
|
28246
|
-
if (!node) return node;
|
|
28247
|
-
const cloned = { ...node };
|
|
28248
|
-
if (Array.isArray(node.content)) {
|
|
28249
|
-
cloned.content = [...node.content];
|
|
28250
|
-
}
|
|
28251
|
-
return cloned;
|
|
28252
|
-
};
|
|
28253
|
-
const ensureArray = (node) => {
|
|
28254
|
-
if (!Array.isArray(node.content)) {
|
|
28255
|
-
node.content = [];
|
|
28256
|
-
}
|
|
28257
|
-
return node.content;
|
|
28258
|
-
};
|
|
28259
|
-
const isInlineNode = (node) => {
|
|
28260
|
-
if (!node || typeof node.type !== "string") return false;
|
|
28261
|
-
if (node.type === "text") return true;
|
|
28262
|
-
if (node.type === "bookmarkStart" || node.type === "bookmarkEnd") return true;
|
|
28263
|
-
const nodeType = schema?.nodes?.[node.type];
|
|
28264
|
-
if (nodeType) {
|
|
28265
|
-
if (typeof nodeType.isInline === "boolean") return nodeType.isInline;
|
|
28266
|
-
if (nodeType.spec?.group && typeof nodeType.spec.group === "string") {
|
|
28267
|
-
return nodeType.spec.group.split(" ").includes("inline");
|
|
28268
|
-
}
|
|
28269
|
-
}
|
|
28270
|
-
return false;
|
|
28271
|
-
};
|
|
28272
|
-
for (const node of content) {
|
|
28273
|
-
if (!node || typeof node.type !== "string") {
|
|
28274
|
-
normalized.push(node);
|
|
28275
|
-
continue;
|
|
28276
|
-
}
|
|
28277
|
-
if (!isInlineNode(node)) {
|
|
28278
|
-
const blockNode = cloneBlock(node);
|
|
28279
|
-
if (pendingForNextBlock.length) {
|
|
28280
|
-
const blockContent = ensureArray(blockNode);
|
|
28281
|
-
const leadingInline = pendingForNextBlock.splice(0);
|
|
28282
|
-
blockNode.content = [...leadingInline, ...blockContent];
|
|
28283
|
-
} else if (Array.isArray(blockNode.content)) {
|
|
28284
|
-
blockNode.content = [...blockNode.content];
|
|
27335
|
+
if (!isInlineNode(node)) {
|
|
27336
|
+
const blockNode = cloneBlock(node);
|
|
27337
|
+
if (pendingForNextBlock.length) {
|
|
27338
|
+
const blockContent = ensureArray(blockNode);
|
|
27339
|
+
const leadingInline = pendingForNextBlock.splice(0);
|
|
27340
|
+
blockNode.content = [...leadingInline, ...blockContent];
|
|
27341
|
+
} else if (Array.isArray(blockNode.content)) {
|
|
27342
|
+
blockNode.content = [...blockNode.content];
|
|
28285
27343
|
}
|
|
28286
27344
|
normalized.push(blockNode);
|
|
28287
27345
|
continue;
|
|
@@ -28464,22 +27522,22 @@ function generateTableCellProperties(node) {
|
|
|
28464
27522
|
} else if (tableCellProperties?.borders) {
|
|
28465
27523
|
delete tableCellProperties.borders;
|
|
28466
27524
|
}
|
|
28467
|
-
const result = translator$
|
|
27525
|
+
const result = translator$I.decode({ node: { ...node, attrs: { ...node.attrs, tableCellProperties } } });
|
|
28468
27526
|
return result;
|
|
28469
27527
|
}
|
|
28470
|
-
const XML_NODE_NAME$
|
|
28471
|
-
const SD_NODE_NAME$
|
|
28472
|
-
const validXmlAttributes$
|
|
28473
|
-
function encode$
|
|
27528
|
+
const XML_NODE_NAME$g = "w:tc";
|
|
27529
|
+
const SD_NODE_NAME$d = "tableCell";
|
|
27530
|
+
const validXmlAttributes$b = [];
|
|
27531
|
+
function encode$m(params2, encodedAttrs) {
|
|
28474
27532
|
const {
|
|
28475
27533
|
node,
|
|
28476
27534
|
table,
|
|
28477
27535
|
row,
|
|
28478
27536
|
rowBorders,
|
|
28479
|
-
styleTag,
|
|
28480
27537
|
columnIndex,
|
|
28481
27538
|
columnWidth,
|
|
28482
|
-
columnWidths: allColumnWidths
|
|
27539
|
+
columnWidths: allColumnWidths,
|
|
27540
|
+
_referencedStyles
|
|
28483
27541
|
} = params2.extraParams;
|
|
28484
27542
|
const schemaNode = handleTableCellNode({
|
|
28485
27543
|
params: params2,
|
|
@@ -28487,96 +27545,388 @@ function encode$j(params2, encodedAttrs) {
|
|
|
28487
27545
|
table,
|
|
28488
27546
|
row,
|
|
28489
27547
|
rowBorders,
|
|
28490
|
-
styleTag,
|
|
28491
27548
|
columnIndex,
|
|
28492
27549
|
columnWidth,
|
|
28493
|
-
allColumnWidths
|
|
27550
|
+
allColumnWidths,
|
|
27551
|
+
_referencedStyles
|
|
28494
27552
|
});
|
|
28495
27553
|
if (encodedAttrs && Object.keys(encodedAttrs).length) {
|
|
28496
27554
|
schemaNode.attrs = { ...schemaNode.attrs, ...encodedAttrs };
|
|
28497
27555
|
}
|
|
28498
27556
|
return schemaNode;
|
|
28499
27557
|
}
|
|
28500
|
-
function decode$
|
|
27558
|
+
function decode$o(params2, decodedAttrs) {
|
|
28501
27559
|
const translated = translateTableCell(params2);
|
|
28502
27560
|
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
28503
27561
|
translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
|
|
28504
27562
|
}
|
|
28505
27563
|
return translated;
|
|
28506
27564
|
}
|
|
28507
|
-
const config$
|
|
28508
|
-
xmlName: XML_NODE_NAME$
|
|
28509
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
27565
|
+
const config$f = {
|
|
27566
|
+
xmlName: XML_NODE_NAME$g,
|
|
27567
|
+
sdNodeOrKeyName: SD_NODE_NAME$d,
|
|
28510
27568
|
type: NodeTranslator.translatorTypes.NODE,
|
|
28511
|
-
encode: encode$
|
|
28512
|
-
decode: decode$
|
|
28513
|
-
attributes: validXmlAttributes$
|
|
27569
|
+
encode: encode$m,
|
|
27570
|
+
decode: decode$o,
|
|
27571
|
+
attributes: validXmlAttributes$b
|
|
28514
27572
|
};
|
|
28515
|
-
const translator$
|
|
28516
|
-
|
|
28517
|
-
|
|
28518
|
-
|
|
28519
|
-
}
|
|
28520
|
-
|
|
28521
|
-
|
|
28522
|
-
|
|
28523
|
-
|
|
28524
|
-
|
|
28525
|
-
|
|
28526
|
-
|
|
28527
|
-
|
|
28528
|
-
|
|
28529
|
-
|
|
28530
|
-
|
|
28531
|
-
|
|
28532
|
-
|
|
28533
|
-
|
|
28534
|
-
|
|
28535
|
-
|
|
28536
|
-
|
|
28537
|
-
|
|
28538
|
-
|
|
28539
|
-
|
|
28540
|
-
|
|
28541
|
-
|
|
28542
|
-
|
|
28543
|
-
|
|
28544
|
-
|
|
28545
|
-
|
|
28546
|
-
|
|
28547
|
-
|
|
28548
|
-
|
|
28549
|
-
|
|
28550
|
-
|
|
28551
|
-
|
|
28552
|
-
|
|
28553
|
-
|
|
28554
|
-
|
|
28555
|
-
|
|
28556
|
-
|
|
28557
|
-
|
|
28558
|
-
|
|
28559
|
-
|
|
28560
|
-
|
|
28561
|
-
|
|
28562
|
-
|
|
28563
|
-
}
|
|
28564
|
-
const initialDisplayLabel = getSafeString(attrs.displayLabel);
|
|
28565
|
-
const extractedContent = getTextFromSdtContent(sdtContent);
|
|
28566
|
-
if (!attrs.defaultDisplayLabel) {
|
|
28567
|
-
if (initialDisplayLabel) {
|
|
28568
|
-
attrs.defaultDisplayLabel = initialDisplayLabel;
|
|
28569
|
-
} else if (aliasLabel) {
|
|
28570
|
-
attrs.defaultDisplayLabel = aliasLabel;
|
|
27573
|
+
const translator$H = NodeTranslator.from(config$f);
|
|
27574
|
+
const translator$G = NodeTranslator.from({
|
|
27575
|
+
xmlName: "w:cantSplit",
|
|
27576
|
+
sdNodeOrKeyName: "cantSplit",
|
|
27577
|
+
encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27578
|
+
decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
|
|
27579
|
+
});
|
|
27580
|
+
const translator$F = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
|
|
27581
|
+
const translator$E = NodeTranslator.from(
|
|
27582
|
+
createSingleAttrPropertyHandler(
|
|
27583
|
+
"w:gridAfter",
|
|
27584
|
+
null,
|
|
27585
|
+
"w:val",
|
|
27586
|
+
(v2) => parseInteger(v2) ?? void 0,
|
|
27587
|
+
(v2) => integerToString(v2)
|
|
27588
|
+
)
|
|
27589
|
+
);
|
|
27590
|
+
const translator$D = NodeTranslator.from(
|
|
27591
|
+
createSingleAttrPropertyHandler(
|
|
27592
|
+
"w:gridBefore",
|
|
27593
|
+
null,
|
|
27594
|
+
"w:val",
|
|
27595
|
+
(v2) => parseInteger(v2) ?? void 0,
|
|
27596
|
+
(v2) => integerToString(v2)
|
|
27597
|
+
)
|
|
27598
|
+
);
|
|
27599
|
+
const translator$C = NodeTranslator.from({
|
|
27600
|
+
xmlName: "w:hidden",
|
|
27601
|
+
sdNodeOrKeyName: "hidden",
|
|
27602
|
+
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27603
|
+
decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
|
|
27604
|
+
});
|
|
27605
|
+
const translator$B = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
|
|
27606
|
+
const translator$A = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
|
|
27607
|
+
const translator$z = NodeTranslator.from({
|
|
27608
|
+
xmlName: "w:tblHeader",
|
|
27609
|
+
sdNodeOrKeyName: "repeatHeader",
|
|
27610
|
+
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
27611
|
+
decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
|
|
27612
|
+
});
|
|
27613
|
+
const translator$y = NodeTranslator.from({
|
|
27614
|
+
xmlName: "w:trHeight",
|
|
27615
|
+
sdNodeOrKeyName: "rowHeight",
|
|
27616
|
+
encode: ({ nodes }) => {
|
|
27617
|
+
const heightAttrs = {};
|
|
27618
|
+
const val = nodes[0].attributes["w:val"];
|
|
27619
|
+
if (val) {
|
|
27620
|
+
heightAttrs["value"] = parseInt(val, 10);
|
|
28571
27621
|
}
|
|
28572
|
-
|
|
28573
|
-
|
|
28574
|
-
|
|
28575
|
-
|
|
28576
|
-
|
|
28577
|
-
|
|
28578
|
-
|
|
28579
|
-
attrs
|
|
27622
|
+
const rule = nodes[0].attributes["w:hRule"];
|
|
27623
|
+
if (rule) {
|
|
27624
|
+
heightAttrs["rule"] = rule;
|
|
27625
|
+
}
|
|
27626
|
+
return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
|
|
27627
|
+
},
|
|
27628
|
+
decode: ({ node }) => {
|
|
27629
|
+
if (!node.attrs?.rowHeight) return;
|
|
27630
|
+
const heightAttrs = {};
|
|
27631
|
+
if (typeof node.attrs.rowHeight.value === "number" && !isNaN(node.attrs.rowHeight.value)) {
|
|
27632
|
+
heightAttrs["w:val"] = String(node.attrs.rowHeight.value);
|
|
27633
|
+
}
|
|
27634
|
+
if (node.attrs.rowHeight.rule) {
|
|
27635
|
+
heightAttrs["w:hRule"] = node.attrs.rowHeight.rule;
|
|
27636
|
+
}
|
|
27637
|
+
return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
|
|
27638
|
+
}
|
|
27639
|
+
});
|
|
27640
|
+
const translator$x = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
|
|
27641
|
+
const translator$w = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
|
|
27642
|
+
const propertyTranslators$3 = [
|
|
27643
|
+
translator$G,
|
|
27644
|
+
translator$1a,
|
|
27645
|
+
translator$F,
|
|
27646
|
+
translator$E,
|
|
27647
|
+
translator$D,
|
|
27648
|
+
translator$C,
|
|
27649
|
+
translator$B,
|
|
27650
|
+
translator$A,
|
|
27651
|
+
translator$z,
|
|
27652
|
+
translator$y,
|
|
27653
|
+
translator$x,
|
|
27654
|
+
translator$w
|
|
27655
|
+
];
|
|
27656
|
+
const translator$v = NodeTranslator.from(
|
|
27657
|
+
createNestedPropertiesTranslator("w:trPr", "tableRowProperties", propertyTranslators$3, {
|
|
27658
|
+
cantSplit: false,
|
|
27659
|
+
hidden: false,
|
|
27660
|
+
repeatHeader: false
|
|
27661
|
+
})
|
|
27662
|
+
);
|
|
27663
|
+
const createPlaceholderCell = (gridWidth, reason) => {
|
|
27664
|
+
const safeWidth = Number.isFinite(gridWidth) ? gridWidth : 0;
|
|
27665
|
+
const noBorder = { val: "none", size: 0 };
|
|
27666
|
+
return {
|
|
27667
|
+
type: "tableCell",
|
|
27668
|
+
attrs: {
|
|
27669
|
+
colspan: 1,
|
|
27670
|
+
rowspan: 1,
|
|
27671
|
+
colwidth: [safeWidth],
|
|
27672
|
+
__placeholder: reason,
|
|
27673
|
+
borders: {
|
|
27674
|
+
top: { ...noBorder },
|
|
27675
|
+
right: { ...noBorder },
|
|
27676
|
+
bottom: { ...noBorder },
|
|
27677
|
+
left: { ...noBorder }
|
|
27678
|
+
}
|
|
27679
|
+
},
|
|
27680
|
+
content: [{ type: "paragraph", content: [] }]
|
|
27681
|
+
};
|
|
27682
|
+
};
|
|
27683
|
+
const advancePastRowSpans = (pendingRowSpans, startIndex, totalColumns) => {
|
|
27684
|
+
let index2 = startIndex;
|
|
27685
|
+
while (index2 < totalColumns && pendingRowSpans[index2] > 0) {
|
|
27686
|
+
pendingRowSpans[index2] -= 1;
|
|
27687
|
+
index2 += 1;
|
|
27688
|
+
}
|
|
27689
|
+
return index2;
|
|
27690
|
+
};
|
|
27691
|
+
const fillPlaceholderColumns = ({
|
|
27692
|
+
content,
|
|
27693
|
+
pendingRowSpans,
|
|
27694
|
+
currentIndex,
|
|
27695
|
+
targetIndex,
|
|
27696
|
+
totalColumns,
|
|
27697
|
+
gridColumnWidths,
|
|
27698
|
+
reason
|
|
27699
|
+
}) => {
|
|
27700
|
+
let index2 = currentIndex;
|
|
27701
|
+
while (index2 < targetIndex && index2 < totalColumns) {
|
|
27702
|
+
if (pendingRowSpans[index2] > 0) {
|
|
27703
|
+
pendingRowSpans[index2] -= 1;
|
|
27704
|
+
index2 += 1;
|
|
27705
|
+
continue;
|
|
27706
|
+
}
|
|
27707
|
+
const width = Array.isArray(gridColumnWidths) ? gridColumnWidths[index2] ?? 0 : 0;
|
|
27708
|
+
content.push(createPlaceholderCell(width, reason));
|
|
27709
|
+
index2 += 1;
|
|
27710
|
+
}
|
|
27711
|
+
return index2;
|
|
27712
|
+
};
|
|
27713
|
+
const isPlaceholderCell = (cell) => {
|
|
27714
|
+
if (!cell) return false;
|
|
27715
|
+
if (cell.attrs?.__placeholder) return true;
|
|
27716
|
+
const widths = cell.attrs?.colwidth;
|
|
27717
|
+
if (Array.isArray(widths) && widths.length > 0) {
|
|
27718
|
+
const hasMeaningfulWidth = widths.some(
|
|
27719
|
+
(value) => typeof value === "number" && Number.isFinite(value) && Math.abs(value) > 1
|
|
27720
|
+
);
|
|
27721
|
+
if (!hasMeaningfulWidth) return true;
|
|
27722
|
+
}
|
|
27723
|
+
return false;
|
|
27724
|
+
};
|
|
27725
|
+
const XML_NODE_NAME$f = "w:tr";
|
|
27726
|
+
const SD_NODE_NAME$c = "tableRow";
|
|
27727
|
+
const validXmlAttributes$a = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
|
|
27728
|
+
(xmlName) => createAttributeHandler(xmlName)
|
|
27729
|
+
);
|
|
27730
|
+
const encode$l = (params2, encodedAttrs) => {
|
|
27731
|
+
const { row } = params2.extraParams;
|
|
27732
|
+
let tableRowProperties = {};
|
|
27733
|
+
const tPr = row.elements.find((el) => el.name === "w:trPr");
|
|
27734
|
+
if (tPr) {
|
|
27735
|
+
tableRowProperties = translator$v.encode({
|
|
27736
|
+
...params2,
|
|
27737
|
+
nodes: [tPr]
|
|
27738
|
+
});
|
|
27739
|
+
}
|
|
27740
|
+
const gridBeforeRaw = tableRowProperties?.["gridBefore"];
|
|
27741
|
+
const safeGridBefore = typeof gridBeforeRaw === "number" && Number.isFinite(gridBeforeRaw) && gridBeforeRaw > 0 ? gridBeforeRaw : 0;
|
|
27742
|
+
encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
|
|
27743
|
+
encodedAttrs["rowHeight"] = twipsToPixels(tableRowProperties["rowHeight"]?.value);
|
|
27744
|
+
encodedAttrs["cantSplit"] = tableRowProperties["cantSplit"];
|
|
27745
|
+
const { columnWidths: gridColumnWidths, activeRowSpans = [] } = params2.extraParams;
|
|
27746
|
+
const totalColumns = Array.isArray(gridColumnWidths) ? gridColumnWidths.length : 0;
|
|
27747
|
+
const pendingRowSpans = Array.isArray(activeRowSpans) ? activeRowSpans.slice() : [];
|
|
27748
|
+
while (pendingRowSpans.length < totalColumns) pendingRowSpans.push(0);
|
|
27749
|
+
const cellNodes = row.elements.filter((el) => el.name === "w:tc");
|
|
27750
|
+
const content = [];
|
|
27751
|
+
let currentColumnIndex = 0;
|
|
27752
|
+
const fillUntil = (target, reason) => {
|
|
27753
|
+
currentColumnIndex = fillPlaceholderColumns({
|
|
27754
|
+
content,
|
|
27755
|
+
pendingRowSpans,
|
|
27756
|
+
currentIndex: currentColumnIndex,
|
|
27757
|
+
targetIndex: target,
|
|
27758
|
+
totalColumns,
|
|
27759
|
+
gridColumnWidths,
|
|
27760
|
+
reason
|
|
27761
|
+
});
|
|
27762
|
+
};
|
|
27763
|
+
const skipOccupiedColumns = () => {
|
|
27764
|
+
currentColumnIndex = advancePastRowSpans(pendingRowSpans, currentColumnIndex, totalColumns);
|
|
27765
|
+
};
|
|
27766
|
+
fillUntil(safeGridBefore, "gridBefore");
|
|
27767
|
+
skipOccupiedColumns();
|
|
27768
|
+
cellNodes?.forEach((node) => {
|
|
27769
|
+
skipOccupiedColumns();
|
|
27770
|
+
const startColumn = currentColumnIndex;
|
|
27771
|
+
const columnWidth = gridColumnWidths?.[startColumn] || null;
|
|
27772
|
+
const result = translator$H.encode({
|
|
27773
|
+
...params2,
|
|
27774
|
+
extraParams: {
|
|
27775
|
+
...params2.extraParams,
|
|
27776
|
+
node,
|
|
27777
|
+
columnIndex: startColumn,
|
|
27778
|
+
columnWidth
|
|
27779
|
+
}
|
|
27780
|
+
});
|
|
27781
|
+
if (result) {
|
|
27782
|
+
content.push(result);
|
|
27783
|
+
const colspan = Math.max(1, result.attrs?.colspan || 1);
|
|
27784
|
+
const rowspan = Math.max(1, result.attrs?.rowspan || 1);
|
|
27785
|
+
if (rowspan > 1) {
|
|
27786
|
+
for (let offset2 = 0; offset2 < colspan; offset2 += 1) {
|
|
27787
|
+
const target = startColumn + offset2;
|
|
27788
|
+
if (target < pendingRowSpans.length) {
|
|
27789
|
+
pendingRowSpans[target] = Math.max(pendingRowSpans[target], rowspan - 1);
|
|
27790
|
+
}
|
|
27791
|
+
}
|
|
27792
|
+
}
|
|
27793
|
+
currentColumnIndex = startColumn + colspan;
|
|
27794
|
+
}
|
|
27795
|
+
});
|
|
27796
|
+
skipOccupiedColumns();
|
|
27797
|
+
fillUntil(totalColumns, "gridAfter");
|
|
27798
|
+
const newNode = {
|
|
27799
|
+
type: "tableRow",
|
|
27800
|
+
content,
|
|
27801
|
+
attrs: encodedAttrs
|
|
27802
|
+
};
|
|
27803
|
+
return newNode;
|
|
27804
|
+
};
|
|
27805
|
+
const decode$n = (params2, decodedAttrs) => {
|
|
27806
|
+
const { node } = params2;
|
|
27807
|
+
const cells = node.content || [];
|
|
27808
|
+
let leadingPlaceholders = 0;
|
|
27809
|
+
while (leadingPlaceholders < cells.length && isPlaceholderCell(cells[leadingPlaceholders])) {
|
|
27810
|
+
leadingPlaceholders += 1;
|
|
27811
|
+
}
|
|
27812
|
+
let trailingPlaceholders = 0;
|
|
27813
|
+
while (trailingPlaceholders < cells.length - leadingPlaceholders && isPlaceholderCell(cells[cells.length - 1 - trailingPlaceholders])) {
|
|
27814
|
+
trailingPlaceholders += 1;
|
|
27815
|
+
}
|
|
27816
|
+
const trimmedSlice = cells.slice(leadingPlaceholders, cells.length - trailingPlaceholders);
|
|
27817
|
+
const sanitizedCells = trimmedSlice.map((cell) => {
|
|
27818
|
+
if (cell?.attrs && "__placeholder" in cell.attrs) {
|
|
27819
|
+
const { __placeholder, ...rest } = cell.attrs;
|
|
27820
|
+
return { ...cell, attrs: rest };
|
|
27821
|
+
}
|
|
27822
|
+
return cell;
|
|
27823
|
+
});
|
|
27824
|
+
const trimmedContent = sanitizedCells.filter((_2, index2) => !isPlaceholderCell(trimmedSlice[index2]));
|
|
27825
|
+
const translateParams = {
|
|
27826
|
+
...params2,
|
|
27827
|
+
node: { ...node, content: trimmedContent }
|
|
27828
|
+
};
|
|
27829
|
+
const elements = translateChildNodes(translateParams);
|
|
27830
|
+
if (node.attrs?.tableRowProperties) {
|
|
27831
|
+
const tableRowProperties = { ...node.attrs.tableRowProperties };
|
|
27832
|
+
if (leadingPlaceholders > 0) {
|
|
27833
|
+
tableRowProperties.gridBefore = leadingPlaceholders;
|
|
27834
|
+
}
|
|
27835
|
+
if (trailingPlaceholders > 0) {
|
|
27836
|
+
tableRowProperties.gridAfter = trailingPlaceholders;
|
|
27837
|
+
}
|
|
27838
|
+
if (node.attrs.rowHeight != null) {
|
|
27839
|
+
const rowHeightPixels = twipsToPixels(node.attrs.tableRowProperties["rowHeight"]?.value);
|
|
27840
|
+
if (rowHeightPixels !== node.attrs.rowHeight) {
|
|
27841
|
+
tableRowProperties["rowHeight"] = { value: String(pixelsToTwips(node.attrs["rowHeight"])) };
|
|
27842
|
+
}
|
|
27843
|
+
}
|
|
27844
|
+
tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
|
|
27845
|
+
const trPr = translator$v.decode({
|
|
27846
|
+
...params2,
|
|
27847
|
+
node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
|
|
27848
|
+
});
|
|
27849
|
+
if (trPr) elements.unshift(trPr);
|
|
27850
|
+
}
|
|
27851
|
+
return {
|
|
27852
|
+
name: "w:tr",
|
|
27853
|
+
attributes: decodedAttrs || {},
|
|
27854
|
+
elements
|
|
27855
|
+
};
|
|
27856
|
+
};
|
|
27857
|
+
const config$e = {
|
|
27858
|
+
xmlName: XML_NODE_NAME$f,
|
|
27859
|
+
sdNodeOrKeyName: SD_NODE_NAME$c,
|
|
27860
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
27861
|
+
encode: encode$l,
|
|
27862
|
+
decode: decode$n,
|
|
27863
|
+
attributes: validXmlAttributes$a
|
|
27864
|
+
};
|
|
27865
|
+
const translator$u = NodeTranslator.from(config$e);
|
|
27866
|
+
function parseTagValueJSON(json) {
|
|
27867
|
+
if (typeof json !== "string") {
|
|
27868
|
+
return {};
|
|
27869
|
+
}
|
|
27870
|
+
const trimmed = json.trim();
|
|
27871
|
+
if (!trimmed) {
|
|
27872
|
+
return {};
|
|
27873
|
+
}
|
|
27874
|
+
try {
|
|
27875
|
+
return JSON.parse(trimmed);
|
|
27876
|
+
} catch {
|
|
27877
|
+
return {};
|
|
27878
|
+
}
|
|
27879
|
+
}
|
|
27880
|
+
function handleAnnotationNode(params2) {
|
|
27881
|
+
const { nodes } = params2;
|
|
27882
|
+
if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
|
|
27883
|
+
return null;
|
|
27884
|
+
}
|
|
27885
|
+
const node = nodes[0];
|
|
27886
|
+
const sdtPr = node.elements.find((el) => el.name === "w:sdtPr");
|
|
27887
|
+
const sdtContent = node.elements.find((el) => el.name === "w:sdtContent");
|
|
27888
|
+
const sdtId = sdtPr?.elements?.find((el) => el.name === "w:id");
|
|
27889
|
+
const alias = sdtPr?.elements.find((el) => el.name === "w:alias");
|
|
27890
|
+
const tag = sdtPr?.elements.find((el) => el.name === "w:tag");
|
|
27891
|
+
const tagValue = tag?.attributes["w:val"];
|
|
27892
|
+
const shouldProcessAsJson = tagValue?.startsWith("{") && tagValue?.endsWith("}");
|
|
27893
|
+
let attrs = {};
|
|
27894
|
+
const aliasLabel = getSafeString(alias?.attributes?.["w:val"]);
|
|
27895
|
+
if (shouldProcessAsJson) {
|
|
27896
|
+
const parsedAttrs = parseTagValueJSON(tagValue);
|
|
27897
|
+
attrs = {
|
|
27898
|
+
type: parsedAttrs.fieldTypeShort,
|
|
27899
|
+
fieldId: parsedAttrs.fieldId,
|
|
27900
|
+
displayLabel: parsedAttrs.displayLabel,
|
|
27901
|
+
defaultDisplayLabel: parsedAttrs.defaultDisplayLabel,
|
|
27902
|
+
fieldType: parsedAttrs.fieldType,
|
|
27903
|
+
fieldColor: parsedAttrs.fieldColor,
|
|
27904
|
+
multipleImage: parsedAttrs.fieldMultipleImage,
|
|
27905
|
+
fontFamily: parsedAttrs.fieldFontFamily,
|
|
27906
|
+
fontSize: parsedAttrs.fieldFontSize,
|
|
27907
|
+
textColor: parsedAttrs.fieldTextColor,
|
|
27908
|
+
textHighlight: parsedAttrs.fieldTextHighlight,
|
|
27909
|
+
hash: parsedAttrs.hash
|
|
27910
|
+
};
|
|
27911
|
+
} else {
|
|
27912
|
+
attrs = getAttrsFromElements({ sdtPr, tag, alias, sdtId });
|
|
27913
|
+
}
|
|
27914
|
+
const initialDisplayLabel = getSafeString(attrs.displayLabel);
|
|
27915
|
+
const extractedContent = getTextFromSdtContent(sdtContent);
|
|
27916
|
+
if (!attrs.defaultDisplayLabel) {
|
|
27917
|
+
if (initialDisplayLabel) {
|
|
27918
|
+
attrs.defaultDisplayLabel = initialDisplayLabel;
|
|
27919
|
+
} else if (aliasLabel) {
|
|
27920
|
+
attrs.defaultDisplayLabel = aliasLabel;
|
|
27921
|
+
}
|
|
27922
|
+
}
|
|
27923
|
+
const placeholderLabel = getPlaceholderLabel(attrs, aliasLabel);
|
|
27924
|
+
const placeholderText = ensurePlaceholderFormat(placeholderLabel);
|
|
27925
|
+
const isAnnotationsEnabled = Boolean(params2.editor?.options?.annotations);
|
|
27926
|
+
const contentIsDistinct = shouldUseSdtContent(extractedContent, placeholderText);
|
|
27927
|
+
const shouldUseContent = !isAnnotationsEnabled && contentIsDistinct && (hasMoustache(extractedContent) || !placeholderText);
|
|
27928
|
+
if (contentIsDistinct) {
|
|
27929
|
+
attrs.displayLabel = extractedContent;
|
|
28580
27930
|
} else if (!attrs.displayLabel && placeholderLabel) {
|
|
28581
27931
|
attrs.displayLabel = placeholderLabel;
|
|
28582
27932
|
}
|
|
@@ -28918,11 +28268,11 @@ function applyColorModifier(hexColor, modifier, value) {
|
|
|
28918
28268
|
} else {
|
|
28919
28269
|
return hexColor;
|
|
28920
28270
|
}
|
|
28921
|
-
const
|
|
28271
|
+
const clamp2 = (n) => Math.max(0, Math.min(255, Math.round(n)));
|
|
28922
28272
|
const toHex2 = (n) => n.toString(16).padStart(2, "0");
|
|
28923
|
-
newR =
|
|
28924
|
-
newG =
|
|
28925
|
-
newB =
|
|
28273
|
+
newR = clamp2(newR);
|
|
28274
|
+
newG = clamp2(newG);
|
|
28275
|
+
newB = clamp2(newB);
|
|
28926
28276
|
const result = `#${toHex2(newR)}${toHex2(newG)}${toHex2(newB)}`;
|
|
28927
28277
|
return result;
|
|
28928
28278
|
}
|
|
@@ -29835,32 +29185,32 @@ function translateAnchorNode(params2) {
|
|
|
29835
29185
|
elements: [...anchorElements, ...elementsWithWrap]
|
|
29836
29186
|
};
|
|
29837
29187
|
}
|
|
29838
|
-
const XML_NODE_NAME$
|
|
29839
|
-
const SD_NODE_NAME$
|
|
29188
|
+
const XML_NODE_NAME$e = "wp:anchor";
|
|
29189
|
+
const SD_NODE_NAME$b = ["image"];
|
|
29840
29190
|
const validXmlAttributes$9 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
29841
|
-
function encode$
|
|
29191
|
+
function encode$k(params2) {
|
|
29842
29192
|
const { node } = params2.extraParams;
|
|
29843
29193
|
if (!node || !node.type) {
|
|
29844
29194
|
return null;
|
|
29845
29195
|
}
|
|
29846
29196
|
return handleAnchorNode(params2);
|
|
29847
29197
|
}
|
|
29848
|
-
function decode$
|
|
29198
|
+
function decode$m(params2) {
|
|
29849
29199
|
const { node } = params2;
|
|
29850
29200
|
if (!node || !node.type) {
|
|
29851
29201
|
return null;
|
|
29852
29202
|
}
|
|
29853
29203
|
return translateAnchorNode(params2);
|
|
29854
29204
|
}
|
|
29855
|
-
const config$
|
|
29856
|
-
xmlName: XML_NODE_NAME$
|
|
29857
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
29205
|
+
const config$d = {
|
|
29206
|
+
xmlName: XML_NODE_NAME$e,
|
|
29207
|
+
sdNodeOrKeyName: SD_NODE_NAME$b,
|
|
29858
29208
|
type: NodeTranslator.translatorTypes.NODE,
|
|
29859
|
-
encode: encode$
|
|
29860
|
-
decode: decode$
|
|
29209
|
+
encode: encode$k,
|
|
29210
|
+
decode: decode$m,
|
|
29861
29211
|
attributes: validXmlAttributes$9
|
|
29862
29212
|
};
|
|
29863
|
-
const translator$
|
|
29213
|
+
const translator$t = NodeTranslator.from(config$d);
|
|
29864
29214
|
function handleInlineNode(params2) {
|
|
29865
29215
|
const { node } = params2.extraParams;
|
|
29866
29216
|
if (node.name !== "wp:inline") {
|
|
@@ -29876,41 +29226,41 @@ function translateInlineNode(params2) {
|
|
|
29876
29226
|
elements: nodeElements.elements
|
|
29877
29227
|
};
|
|
29878
29228
|
}
|
|
29879
|
-
const XML_NODE_NAME$
|
|
29880
|
-
const SD_NODE_NAME$
|
|
29229
|
+
const XML_NODE_NAME$d = "wp:inline";
|
|
29230
|
+
const SD_NODE_NAME$a = ["image"];
|
|
29881
29231
|
const validXmlAttributes$8 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
29882
|
-
function encode$
|
|
29232
|
+
function encode$j(params2) {
|
|
29883
29233
|
const { node } = params2.extraParams;
|
|
29884
29234
|
if (!node || !node.type) {
|
|
29885
29235
|
return null;
|
|
29886
29236
|
}
|
|
29887
29237
|
return handleInlineNode(params2);
|
|
29888
29238
|
}
|
|
29889
|
-
function decode$
|
|
29239
|
+
function decode$l(params2) {
|
|
29890
29240
|
const { node } = params2;
|
|
29891
29241
|
if (!node || !node.type) {
|
|
29892
29242
|
return null;
|
|
29893
29243
|
}
|
|
29894
29244
|
return translateInlineNode(params2);
|
|
29895
29245
|
}
|
|
29896
|
-
const config$
|
|
29897
|
-
xmlName: XML_NODE_NAME$
|
|
29898
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
29246
|
+
const config$c = {
|
|
29247
|
+
xmlName: XML_NODE_NAME$d,
|
|
29248
|
+
sdNodeOrKeyName: SD_NODE_NAME$a,
|
|
29899
29249
|
type: NodeTranslator.translatorTypes.NODE,
|
|
29900
|
-
encode: encode$
|
|
29901
|
-
decode: decode$
|
|
29250
|
+
encode: encode$j,
|
|
29251
|
+
decode: decode$l,
|
|
29902
29252
|
attributes: validXmlAttributes$8
|
|
29903
29253
|
};
|
|
29904
|
-
const translator$
|
|
29905
|
-
const XML_NODE_NAME$
|
|
29906
|
-
const SD_NODE_NAME$
|
|
29254
|
+
const translator$s = NodeTranslator.from(config$c);
|
|
29255
|
+
const XML_NODE_NAME$c = "w:drawing";
|
|
29256
|
+
const SD_NODE_NAME$9 = [];
|
|
29907
29257
|
const validXmlAttributes$7 = [];
|
|
29908
|
-
function encode$
|
|
29258
|
+
function encode$i(params2) {
|
|
29909
29259
|
const nodes = params2.nodes;
|
|
29910
29260
|
const node = nodes[0];
|
|
29911
29261
|
const translatorByChildName = {
|
|
29912
|
-
"wp:anchor": translator$
|
|
29913
|
-
"wp:inline": translator$
|
|
29262
|
+
"wp:anchor": translator$t,
|
|
29263
|
+
"wp:inline": translator$s
|
|
29914
29264
|
};
|
|
29915
29265
|
return node.elements.reduce((acc, child) => {
|
|
29916
29266
|
if (acc) return acc;
|
|
@@ -29919,12 +29269,12 @@ function encode$g(params2) {
|
|
|
29919
29269
|
return translator2.encode({ ...params2, extraParams: { node: child } }) || acc;
|
|
29920
29270
|
}, null);
|
|
29921
29271
|
}
|
|
29922
|
-
function decode$
|
|
29272
|
+
function decode$k(params2) {
|
|
29923
29273
|
const { node } = params2;
|
|
29924
29274
|
if (!node || !node.type) {
|
|
29925
29275
|
return null;
|
|
29926
29276
|
}
|
|
29927
|
-
const childTranslator = node.attrs.isAnchor ? translator$
|
|
29277
|
+
const childTranslator = node.attrs.isAnchor ? translator$t : translator$s;
|
|
29928
29278
|
const resultNode = childTranslator.decode(params2);
|
|
29929
29279
|
return wrapTextInRun(
|
|
29930
29280
|
{
|
|
@@ -29934,15 +29284,15 @@ function decode$i(params2) {
|
|
|
29934
29284
|
[]
|
|
29935
29285
|
);
|
|
29936
29286
|
}
|
|
29937
|
-
const config$
|
|
29938
|
-
xmlName: XML_NODE_NAME$
|
|
29939
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
29287
|
+
const config$b = {
|
|
29288
|
+
xmlName: XML_NODE_NAME$c,
|
|
29289
|
+
sdNodeOrKeyName: SD_NODE_NAME$9,
|
|
29940
29290
|
type: NodeTranslator.translatorTypes.NODE,
|
|
29941
|
-
encode: encode$
|
|
29942
|
-
decode: decode$
|
|
29291
|
+
encode: encode$i,
|
|
29292
|
+
decode: decode$k,
|
|
29943
29293
|
attributes: validXmlAttributes$7
|
|
29944
29294
|
};
|
|
29945
|
-
const translator$
|
|
29295
|
+
const translator$r = NodeTranslator.from(config$b);
|
|
29946
29296
|
class CommandService {
|
|
29947
29297
|
/**
|
|
29948
29298
|
* @param {import('./commands/types/index.js').CommandServiceOptions} props
|
|
@@ -31290,7 +30640,7 @@ function prepareTextAnnotation(params2) {
|
|
|
31290
30640
|
return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params2);
|
|
31291
30641
|
}
|
|
31292
30642
|
function prepareImageAnnotation(params2, imageSize) {
|
|
31293
|
-
return translator$
|
|
30643
|
+
return translator$r.decode({
|
|
31294
30644
|
...params2,
|
|
31295
30645
|
imageSize
|
|
31296
30646
|
});
|
|
@@ -31354,287 +30704,864 @@ function prepareUrlAnnotation(params2) {
|
|
|
31354
30704
|
const linkTextNode = getTextNodeForExport(attrs.linkUrl, marks, params2);
|
|
31355
30705
|
const contentNode = processLinkContentNode(linkTextNode);
|
|
31356
30706
|
return {
|
|
31357
|
-
name: "w:hyperlink",
|
|
31358
|
-
type: "element",
|
|
31359
|
-
attributes: {
|
|
31360
|
-
"r:id": newId,
|
|
31361
|
-
"w:history": 1
|
|
31362
|
-
},
|
|
31363
|
-
elements: [contentNode]
|
|
30707
|
+
name: "w:hyperlink",
|
|
30708
|
+
type: "element",
|
|
30709
|
+
attributes: {
|
|
30710
|
+
"r:id": newId,
|
|
30711
|
+
"w:history": 1
|
|
30712
|
+
},
|
|
30713
|
+
elements: [contentNode]
|
|
30714
|
+
};
|
|
30715
|
+
}
|
|
30716
|
+
function translateFieldAttrsToMarks(attrs = {}) {
|
|
30717
|
+
const { fontFamily: fontFamily2, fontSize: fontSize2, bold, underline, italic, textColor, textHighlight } = attrs;
|
|
30718
|
+
const marks = [];
|
|
30719
|
+
if (fontFamily2) marks.push({ type: "fontFamily", attrs: { fontFamily: fontFamily2 } });
|
|
30720
|
+
if (fontSize2) marks.push({ type: "fontSize", attrs: { fontSize: fontSize2 } });
|
|
30721
|
+
if (bold) marks.push({ type: "bold", attrs: {} });
|
|
30722
|
+
if (underline) marks.push({ type: "underline", attrs: {} });
|
|
30723
|
+
if (italic) marks.push({ type: "italic", attrs: {} });
|
|
30724
|
+
if (textColor) marks.push({ type: "color", attrs: { color: textColor } });
|
|
30725
|
+
if (textHighlight) marks.push({ type: "highlight", attrs: { color: textHighlight } });
|
|
30726
|
+
return marks;
|
|
30727
|
+
}
|
|
30728
|
+
function applyMarksToHtmlAnnotation(state2, marks) {
|
|
30729
|
+
const { tr, doc: doc2, schema } = state2;
|
|
30730
|
+
const allowedMarks = ["fontFamily", "fontSize", "highlight"];
|
|
30731
|
+
if (!marks.some((m2) => allowedMarks.includes(m2.type))) {
|
|
30732
|
+
return state2;
|
|
30733
|
+
}
|
|
30734
|
+
const fontFamily2 = marks.find((m2) => m2.type === "fontFamily");
|
|
30735
|
+
const fontSize2 = marks.find((m2) => m2.type === "fontSize");
|
|
30736
|
+
const highlight = marks.find((m2) => m2.type === "highlight");
|
|
30737
|
+
const textStyleType = schema.marks.textStyle;
|
|
30738
|
+
const highlightType = schema.marks.highlight;
|
|
30739
|
+
doc2.descendants((node, pos) => {
|
|
30740
|
+
if (!node.isText) return;
|
|
30741
|
+
const foundTextStyle = node.marks.find((m2) => m2.type.name === "textStyle");
|
|
30742
|
+
const foundHighlight = node.marks.find((m2) => m2.type.name === "highlight");
|
|
30743
|
+
if (!foundTextStyle) {
|
|
30744
|
+
tr.addMark(
|
|
30745
|
+
pos,
|
|
30746
|
+
pos + node.nodeSize,
|
|
30747
|
+
textStyleType.create({
|
|
30748
|
+
...fontFamily2?.attrs,
|
|
30749
|
+
...fontSize2?.attrs
|
|
30750
|
+
})
|
|
30751
|
+
);
|
|
30752
|
+
} else if (!foundTextStyle?.attrs.fontFamily && fontFamily2) {
|
|
30753
|
+
tr.addMark(
|
|
30754
|
+
pos,
|
|
30755
|
+
pos + node.nodeSize,
|
|
30756
|
+
textStyleType.create({
|
|
30757
|
+
...foundTextStyle?.attrs,
|
|
30758
|
+
...fontFamily2.attrs
|
|
30759
|
+
})
|
|
30760
|
+
);
|
|
30761
|
+
} else if (!foundTextStyle?.attrs.fontSize && fontSize2) {
|
|
30762
|
+
tr.addMark(
|
|
30763
|
+
pos,
|
|
30764
|
+
pos + node.nodeSize,
|
|
30765
|
+
textStyleType.create({
|
|
30766
|
+
...foundTextStyle?.attrs,
|
|
30767
|
+
...fontSize2.attrs
|
|
30768
|
+
})
|
|
30769
|
+
);
|
|
30770
|
+
}
|
|
30771
|
+
if (!foundHighlight) {
|
|
30772
|
+
tr.addMark(
|
|
30773
|
+
pos,
|
|
30774
|
+
pos + node.nodeSize,
|
|
30775
|
+
highlightType.create({
|
|
30776
|
+
...highlight?.attrs
|
|
30777
|
+
})
|
|
30778
|
+
);
|
|
30779
|
+
}
|
|
30780
|
+
});
|
|
30781
|
+
return state2.apply(tr);
|
|
30782
|
+
}
|
|
30783
|
+
function getFieldHighlightJson(fieldsHighlightColor) {
|
|
30784
|
+
if (!fieldsHighlightColor) return null;
|
|
30785
|
+
let parsedColor = fieldsHighlightColor.trim();
|
|
30786
|
+
const hexRegex2 = /^#?([A-Fa-f0-9]{3}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/;
|
|
30787
|
+
if (!hexRegex2.test(parsedColor)) {
|
|
30788
|
+
console.warn(`Invalid HEX color provided to fieldsHighlightColor export param: ${fieldsHighlightColor}`);
|
|
30789
|
+
return null;
|
|
30790
|
+
}
|
|
30791
|
+
if (parsedColor.startsWith("#")) {
|
|
30792
|
+
parsedColor = parsedColor.slice(1);
|
|
30793
|
+
}
|
|
30794
|
+
return {
|
|
30795
|
+
name: "w:rPr",
|
|
30796
|
+
elements: [
|
|
30797
|
+
{
|
|
30798
|
+
name: "w:shd",
|
|
30799
|
+
attributes: {
|
|
30800
|
+
"w:fill": `#${parsedColor}`,
|
|
30801
|
+
"w:color": "auto",
|
|
30802
|
+
"w:val": "clear"
|
|
30803
|
+
}
|
|
30804
|
+
}
|
|
30805
|
+
]
|
|
30806
|
+
};
|
|
30807
|
+
}
|
|
30808
|
+
function translateDocumentSection(params2) {
|
|
30809
|
+
const { node } = params2;
|
|
30810
|
+
const { attrs = {} } = node;
|
|
30811
|
+
const childContent = translateChildNodes({ ...params2, nodes: node.content });
|
|
30812
|
+
const nodeElements = [
|
|
30813
|
+
{
|
|
30814
|
+
name: "w:sdtContent",
|
|
30815
|
+
elements: childContent
|
|
30816
|
+
}
|
|
30817
|
+
];
|
|
30818
|
+
const exportedTag = JSON.stringify({
|
|
30819
|
+
type: "documentSection",
|
|
30820
|
+
description: attrs.description
|
|
30821
|
+
});
|
|
30822
|
+
const sdtPr = generateSdtPrTagForDocumentSection(attrs.id, attrs.title, exportedTag);
|
|
30823
|
+
const { isLocked } = attrs;
|
|
30824
|
+
if (isLocked) {
|
|
30825
|
+
sdtPr.elements.push({
|
|
30826
|
+
name: "w:lock",
|
|
30827
|
+
attributes: {
|
|
30828
|
+
"w:val": "sdtContentLocked"
|
|
30829
|
+
}
|
|
30830
|
+
});
|
|
30831
|
+
}
|
|
30832
|
+
nodeElements.unshift(sdtPr);
|
|
30833
|
+
const result = {
|
|
30834
|
+
name: "w:sdt",
|
|
30835
|
+
elements: nodeElements
|
|
30836
|
+
};
|
|
30837
|
+
return result;
|
|
30838
|
+
}
|
|
30839
|
+
const generateSdtPrTagForDocumentSection = (id, title, tag) => {
|
|
30840
|
+
return {
|
|
30841
|
+
name: "w:sdtPr",
|
|
30842
|
+
elements: [
|
|
30843
|
+
{
|
|
30844
|
+
name: "w:id",
|
|
30845
|
+
attributes: {
|
|
30846
|
+
"w:val": id
|
|
30847
|
+
}
|
|
30848
|
+
},
|
|
30849
|
+
{
|
|
30850
|
+
name: "w:alias",
|
|
30851
|
+
attributes: {
|
|
30852
|
+
"w:val": title
|
|
30853
|
+
}
|
|
30854
|
+
},
|
|
30855
|
+
{
|
|
30856
|
+
name: "w:tag",
|
|
30857
|
+
attributes: {
|
|
30858
|
+
"w:val": tag
|
|
30859
|
+
}
|
|
30860
|
+
}
|
|
30861
|
+
]
|
|
30862
|
+
};
|
|
30863
|
+
};
|
|
30864
|
+
function translateDocumentPartObj(params2) {
|
|
30865
|
+
const { node } = params2;
|
|
30866
|
+
const { attrs = {} } = node;
|
|
30867
|
+
const childContent = translateChildNodes({ ...params2, nodes: node.content });
|
|
30868
|
+
const nodeElements = [
|
|
30869
|
+
{
|
|
30870
|
+
name: "w:sdtPr",
|
|
30871
|
+
elements: [
|
|
30872
|
+
{
|
|
30873
|
+
name: "w:id",
|
|
30874
|
+
attributes: {
|
|
30875
|
+
"w:val": attrs.id
|
|
30876
|
+
}
|
|
30877
|
+
},
|
|
30878
|
+
{
|
|
30879
|
+
name: "w:docPartObj",
|
|
30880
|
+
elements: [
|
|
30881
|
+
{
|
|
30882
|
+
name: "w:docPartGallery",
|
|
30883
|
+
attributes: {
|
|
30884
|
+
"w:val": attrs.docPartGallery
|
|
30885
|
+
}
|
|
30886
|
+
},
|
|
30887
|
+
...attrs.docPartUnique ? [
|
|
30888
|
+
{
|
|
30889
|
+
name: "w:docPartUnique"
|
|
30890
|
+
}
|
|
30891
|
+
] : []
|
|
30892
|
+
]
|
|
30893
|
+
}
|
|
30894
|
+
]
|
|
30895
|
+
},
|
|
30896
|
+
{
|
|
30897
|
+
name: "w:sdtContent",
|
|
30898
|
+
elements: childContent
|
|
30899
|
+
}
|
|
30900
|
+
];
|
|
30901
|
+
const result = {
|
|
30902
|
+
name: "w:sdt",
|
|
30903
|
+
elements: nodeElements
|
|
30904
|
+
};
|
|
30905
|
+
return result;
|
|
30906
|
+
}
|
|
30907
|
+
function translateStructuredContent(params2) {
|
|
30908
|
+
const { node } = params2;
|
|
30909
|
+
const childContent = translateChildNodes({ ...params2, nodes: node.content });
|
|
30910
|
+
const sdtContent = { name: "w:sdtContent", elements: childContent };
|
|
30911
|
+
const sdtPr = generateSdtPrTagForStructuredContent({ node });
|
|
30912
|
+
const nodeElements = [sdtPr, sdtContent];
|
|
30913
|
+
const result = {
|
|
30914
|
+
name: "w:sdt",
|
|
30915
|
+
elements: nodeElements
|
|
30916
|
+
};
|
|
30917
|
+
return result;
|
|
30918
|
+
}
|
|
30919
|
+
function generateSdtPrTagForStructuredContent({ node }) {
|
|
30920
|
+
const { attrs = {} } = node;
|
|
30921
|
+
const id = {
|
|
30922
|
+
name: "w:id",
|
|
30923
|
+
type: "element",
|
|
30924
|
+
attributes: { "w:val": attrs.id }
|
|
30925
|
+
};
|
|
30926
|
+
const alias = {
|
|
30927
|
+
name: "w:alias",
|
|
30928
|
+
type: "element",
|
|
30929
|
+
attributes: { "w:val": attrs.alias }
|
|
30930
|
+
};
|
|
30931
|
+
const tag = {
|
|
30932
|
+
name: "w:tag",
|
|
30933
|
+
type: "element",
|
|
30934
|
+
attributes: { "w:val": attrs.tag }
|
|
30935
|
+
};
|
|
30936
|
+
const resultElements = [];
|
|
30937
|
+
if (attrs.id) resultElements.push(id);
|
|
30938
|
+
if (attrs.alias) resultElements.push(alias);
|
|
30939
|
+
if (attrs.tag) resultElements.push(tag);
|
|
30940
|
+
if (attrs.sdtPr) {
|
|
30941
|
+
const elements = attrs.sdtPr.elements || [];
|
|
30942
|
+
const elementsToExclude = ["w:id", "w:alias", "w:tag"];
|
|
30943
|
+
const restElements = elements.filter((el) => !elementsToExclude.includes(el.name));
|
|
30944
|
+
const result2 = {
|
|
30945
|
+
name: "w:sdtPr",
|
|
30946
|
+
type: "element",
|
|
30947
|
+
elements: [...resultElements, ...restElements]
|
|
30948
|
+
};
|
|
30949
|
+
return result2;
|
|
30950
|
+
}
|
|
30951
|
+
const result = {
|
|
30952
|
+
name: "w:sdtPr",
|
|
30953
|
+
type: "element",
|
|
30954
|
+
elements: resultElements
|
|
30955
|
+
};
|
|
30956
|
+
return result;
|
|
30957
|
+
}
|
|
30958
|
+
const XML_NODE_NAME$b = "w:sdt";
|
|
30959
|
+
const SD_NODE_NAME$8 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
|
|
30960
|
+
const validXmlAttributes$6 = [];
|
|
30961
|
+
function encode$h(params2) {
|
|
30962
|
+
const nodes = params2.nodes;
|
|
30963
|
+
const node = nodes[0];
|
|
30964
|
+
const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
|
|
30965
|
+
if (!handler2 || sdtType === "unknown") {
|
|
30966
|
+
return void 0;
|
|
30967
|
+
}
|
|
30968
|
+
const result = handler2(params2);
|
|
30969
|
+
return result;
|
|
30970
|
+
}
|
|
30971
|
+
function decode$j(params2) {
|
|
30972
|
+
const { node } = params2;
|
|
30973
|
+
if (!node || !node.type) {
|
|
30974
|
+
return null;
|
|
30975
|
+
}
|
|
30976
|
+
const types2 = {
|
|
30977
|
+
fieldAnnotation: () => translateFieldAnnotation(params2),
|
|
30978
|
+
structuredContent: () => translateStructuredContent(params2),
|
|
30979
|
+
structuredContentBlock: () => translateStructuredContent(params2),
|
|
30980
|
+
documentSection: () => translateDocumentSection(params2),
|
|
30981
|
+
documentPartObject: () => translateDocumentPartObj(params2),
|
|
30982
|
+
// Handled in doc-part-obj translator
|
|
30983
|
+
default: () => null
|
|
30984
|
+
};
|
|
30985
|
+
const decoder = types2[node.type] ?? types2.default;
|
|
30986
|
+
const result = decoder();
|
|
30987
|
+
return result;
|
|
30988
|
+
}
|
|
30989
|
+
const config$a = {
|
|
30990
|
+
xmlName: XML_NODE_NAME$b,
|
|
30991
|
+
sdNodeOrKeyName: SD_NODE_NAME$8,
|
|
30992
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
30993
|
+
encode: encode$h,
|
|
30994
|
+
decode: decode$j,
|
|
30995
|
+
attributes: validXmlAttributes$6
|
|
30996
|
+
};
|
|
30997
|
+
const translator$q = NodeTranslator.from(config$a);
|
|
30998
|
+
function preProcessVerticalMergeCells(table, { editorSchema }) {
|
|
30999
|
+
if (!table || !Array.isArray(table.content)) {
|
|
31000
|
+
return table;
|
|
31001
|
+
}
|
|
31002
|
+
const rows = table.content;
|
|
31003
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
31004
|
+
const row = rows[rowIndex];
|
|
31005
|
+
if (!row) continue;
|
|
31006
|
+
if (!Array.isArray(row.content)) {
|
|
31007
|
+
row.content = [];
|
|
31008
|
+
}
|
|
31009
|
+
for (let cellIndex = 0; cellIndex < row.content.length; cellIndex++) {
|
|
31010
|
+
const cell = row.content[cellIndex];
|
|
31011
|
+
if (!cell) continue;
|
|
31012
|
+
const attrs = cell.attrs || {};
|
|
31013
|
+
if (!attrs.rowspan || attrs.rowspan <= 1) continue;
|
|
31014
|
+
const maxRowspan = Math.min(attrs.rowspan, rows.length - rowIndex);
|
|
31015
|
+
for (let offset2 = 1; offset2 < maxRowspan; offset2++) {
|
|
31016
|
+
const rowToChange = rows[rowIndex + offset2];
|
|
31017
|
+
if (!rowToChange) continue;
|
|
31018
|
+
if (!Array.isArray(rowToChange.content)) {
|
|
31019
|
+
rowToChange.content = [];
|
|
31020
|
+
}
|
|
31021
|
+
const existingCell = rowToChange.content[cellIndex];
|
|
31022
|
+
if (existingCell?.attrs?.continueMerge) continue;
|
|
31023
|
+
const mergedCell = {
|
|
31024
|
+
type: cell.type,
|
|
31025
|
+
content: [editorSchema.nodes.paragraph.createAndFill().toJSON()],
|
|
31026
|
+
attrs: {
|
|
31027
|
+
...cell.attrs,
|
|
31028
|
+
rowspan: null,
|
|
31029
|
+
continueMerge: true
|
|
31030
|
+
}
|
|
31031
|
+
};
|
|
31032
|
+
rowToChange.content.splice(cellIndex, 0, mergedCell);
|
|
31033
|
+
}
|
|
31034
|
+
}
|
|
31035
|
+
}
|
|
31036
|
+
return table;
|
|
31037
|
+
}
|
|
31038
|
+
const translator$p = NodeTranslator.from({
|
|
31039
|
+
xmlName: "w:bidiVisual",
|
|
31040
|
+
sdNodeOrKeyName: "rightToLeft",
|
|
31041
|
+
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
31042
|
+
decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
|
|
31043
|
+
});
|
|
31044
|
+
const translator$o = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
|
|
31045
|
+
const translator$n = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
|
|
31046
|
+
const translator$m = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
|
|
31047
|
+
const translator$l = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
|
|
31048
|
+
const translator$k = NodeTranslator.from({
|
|
31049
|
+
xmlName: "w:tblLook",
|
|
31050
|
+
sdNodeOrKeyName: "tblLook",
|
|
31051
|
+
attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
|
|
31052
|
+
encode: (params2, encodedAttrs) => {
|
|
31053
|
+
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
31054
|
+
},
|
|
31055
|
+
decode: function({ node }, context) {
|
|
31056
|
+
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.tblLook || {} } });
|
|
31057
|
+
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
31058
|
+
}
|
|
31059
|
+
});
|
|
31060
|
+
const translator$j = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
|
|
31061
|
+
const translator$i = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
|
|
31062
|
+
const translator$h = NodeTranslator.from(
|
|
31063
|
+
createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
|
|
31064
|
+
);
|
|
31065
|
+
const translator$g = NodeTranslator.from(
|
|
31066
|
+
createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
|
|
31067
|
+
);
|
|
31068
|
+
const translator$f = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
|
|
31069
|
+
const translator$e = NodeTranslator.from({
|
|
31070
|
+
xmlName: "w:tblpPr",
|
|
31071
|
+
sdNodeOrKeyName: "floatingTableProperties",
|
|
31072
|
+
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))),
|
|
31073
|
+
encode: (params2, encodedAttrs) => {
|
|
31074
|
+
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
31075
|
+
},
|
|
31076
|
+
decode: function({ node }, context) {
|
|
31077
|
+
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.floatingTableProperties || {} } });
|
|
31078
|
+
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
31079
|
+
}
|
|
31080
|
+
});
|
|
31081
|
+
const propertyTranslators$2 = [
|
|
31082
|
+
translator$15,
|
|
31083
|
+
translator$13,
|
|
31084
|
+
translator$11,
|
|
31085
|
+
translator$10,
|
|
31086
|
+
translator$$,
|
|
31087
|
+
translator$Z,
|
|
31088
|
+
translator$X,
|
|
31089
|
+
translator$V
|
|
31090
|
+
];
|
|
31091
|
+
const translator$d = NodeTranslator.from(
|
|
31092
|
+
createNestedPropertiesTranslator("w:tblBorders", "borders", propertyTranslators$2)
|
|
31093
|
+
);
|
|
31094
|
+
const propertyTranslators$1 = [
|
|
31095
|
+
translator$14,
|
|
31096
|
+
translator$12,
|
|
31097
|
+
translator$_,
|
|
31098
|
+
translator$Y,
|
|
31099
|
+
translator$W,
|
|
31100
|
+
translator$U
|
|
31101
|
+
];
|
|
31102
|
+
const translator$c = NodeTranslator.from(
|
|
31103
|
+
createNestedPropertiesTranslator("w:tblCellMar", "cellMargins", propertyTranslators$1)
|
|
31104
|
+
);
|
|
31105
|
+
const propertyTranslators = [
|
|
31106
|
+
translator$p,
|
|
31107
|
+
translator$B,
|
|
31108
|
+
translator$19,
|
|
31109
|
+
translator$o,
|
|
31110
|
+
translator$A,
|
|
31111
|
+
translator$n,
|
|
31112
|
+
translator$m,
|
|
31113
|
+
translator$l,
|
|
31114
|
+
translator$k,
|
|
31115
|
+
translator$j,
|
|
31116
|
+
translator$i,
|
|
31117
|
+
translator$h,
|
|
31118
|
+
translator$g,
|
|
31119
|
+
translator$f,
|
|
31120
|
+
translator$e,
|
|
31121
|
+
translator$d,
|
|
31122
|
+
translator$c
|
|
31123
|
+
];
|
|
31124
|
+
const translator$b = NodeTranslator.from(
|
|
31125
|
+
createNestedPropertiesTranslator("w:tblPr", "tableProperties", propertyTranslators)
|
|
31126
|
+
);
|
|
31127
|
+
const translator$a = NodeTranslator.from(
|
|
31128
|
+
createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
|
|
31129
|
+
);
|
|
31130
|
+
const DEFAULT_COLUMN_WIDTH_PX = 100;
|
|
31131
|
+
const normalizeTwipWidth = (value) => {
|
|
31132
|
+
if (value == null) return null;
|
|
31133
|
+
const numericValue = typeof value === "string" ? parseInt(value, 10) : value;
|
|
31134
|
+
if (!Number.isFinite(numericValue) || Number.isNaN(numericValue) || numericValue <= 0) {
|
|
31135
|
+
return null;
|
|
31136
|
+
}
|
|
31137
|
+
return numericValue;
|
|
31138
|
+
};
|
|
31139
|
+
const getSchemaDefaultColumnWidthPx = (params2) => {
|
|
31140
|
+
const defaultValue = params2?.editor?.schema?.nodes?.tableCell?.spec?.attrs?.colwidth?.default;
|
|
31141
|
+
if (Array.isArray(defaultValue)) {
|
|
31142
|
+
const numericWidth = defaultValue.find((width) => typeof width === "number" && Number.isFinite(width) && width > 0);
|
|
31143
|
+
if (numericWidth != null) return numericWidth;
|
|
31144
|
+
} else if (typeof defaultValue === "number" && Number.isFinite(defaultValue) && defaultValue > 0) {
|
|
31145
|
+
return defaultValue;
|
|
31146
|
+
}
|
|
31147
|
+
return DEFAULT_COLUMN_WIDTH_PX;
|
|
31148
|
+
};
|
|
31149
|
+
const getTableWidthPx = (params2) => {
|
|
31150
|
+
const explicitWidth = params2?.node?.attrs?.tableWidth?.width;
|
|
31151
|
+
if (typeof explicitWidth === "number" && explicitWidth > 0) return explicitWidth;
|
|
31152
|
+
const tableWidth = params2?.node?.attrs?.tableProperties?.tableWidth;
|
|
31153
|
+
if (tableWidth?.value != null && typeof tableWidth.value === "number" && tableWidth.value > 0) {
|
|
31154
|
+
const { value, type: type2 } = tableWidth;
|
|
31155
|
+
if (!type2 || type2 === "auto" || type2 === "dxa") {
|
|
31156
|
+
return twipsToPixels(value);
|
|
31157
|
+
}
|
|
31158
|
+
}
|
|
31159
|
+
return null;
|
|
31160
|
+
};
|
|
31161
|
+
const resolveFallbackColumnWidthTwips = (params2, totalColumns, cellMinWidthTwips) => {
|
|
31162
|
+
const columnCount = Math.max(totalColumns, 1);
|
|
31163
|
+
const defaultColumnWidthPx = getSchemaDefaultColumnWidthPx(params2);
|
|
31164
|
+
const tableWidthPx = getTableWidthPx(params2);
|
|
31165
|
+
const safeDefaultPx = Number.isFinite(defaultColumnWidthPx) && defaultColumnWidthPx > 0 ? defaultColumnWidthPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
31166
|
+
let fallbackWidthPx = safeDefaultPx;
|
|
31167
|
+
if (typeof tableWidthPx === "number" && tableWidthPx > 0) {
|
|
31168
|
+
fallbackWidthPx = tableWidthPx / columnCount;
|
|
31169
|
+
}
|
|
31170
|
+
const fallbackWidthTwips = pixelsToTwips(fallbackWidthPx);
|
|
31171
|
+
if (!Number.isFinite(fallbackWidthTwips) || Number.isNaN(fallbackWidthTwips) || fallbackWidthTwips <= 0) {
|
|
31172
|
+
const safeDefault = Math.max(pixelsToTwips(safeDefaultPx), cellMinWidthTwips);
|
|
31173
|
+
return safeDefault;
|
|
31174
|
+
}
|
|
31175
|
+
return Math.max(fallbackWidthTwips, cellMinWidthTwips);
|
|
31176
|
+
};
|
|
31177
|
+
const XML_NODE_NAME$a = "w:tblGrid";
|
|
31178
|
+
const SD_ATTR_KEY$2 = "grid";
|
|
31179
|
+
const cellMinWidth = pixelsToTwips(10);
|
|
31180
|
+
const encode$g = (params2) => {
|
|
31181
|
+
const { nodes } = params2;
|
|
31182
|
+
const node = nodes[0];
|
|
31183
|
+
const attributes = encodeProperties(node, { [translator$a.xmlName]: translator$a }, true);
|
|
31184
|
+
return {
|
|
31185
|
+
xmlName: XML_NODE_NAME$a,
|
|
31186
|
+
sdNodeOrKeyName: SD_ATTR_KEY$2,
|
|
31187
|
+
attributes
|
|
31188
|
+
};
|
|
31189
|
+
};
|
|
31190
|
+
const decode$i = (params2) => {
|
|
31191
|
+
const { grid: rawGrid } = params2.node.attrs || {};
|
|
31192
|
+
const grid = Array.isArray(rawGrid) ? rawGrid : [];
|
|
31193
|
+
const { firstRow = {} } = params2.extraParams || {};
|
|
31194
|
+
const cellNodes = firstRow.content?.filter((n) => n.type === "tableCell") ?? [];
|
|
31195
|
+
const columnCountFromCells = cellNodes.reduce((count, cell) => {
|
|
31196
|
+
const spanCount = Math.max(1, cell?.attrs?.colspan ?? 1);
|
|
31197
|
+
return count + spanCount;
|
|
31198
|
+
}, 0);
|
|
31199
|
+
const totalColumns = Math.max(columnCountFromCells, grid.length);
|
|
31200
|
+
const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params2, totalColumns, cellMinWidth);
|
|
31201
|
+
const elements = [];
|
|
31202
|
+
let columnIndex = 0;
|
|
31203
|
+
const pushColumn = (widthTwips, { enforceMinimum = false } = {}) => {
|
|
31204
|
+
let numericWidth = typeof widthTwips === "string" ? parseInt(widthTwips, 10) : widthTwips;
|
|
31205
|
+
let shouldEnforceMinimum = enforceMinimum;
|
|
31206
|
+
if (numericWidth == null || Number.isNaN(numericWidth) || numericWidth <= 0) {
|
|
31207
|
+
numericWidth = fallbackColumnWidthTwips;
|
|
31208
|
+
shouldEnforceMinimum = true;
|
|
31209
|
+
}
|
|
31210
|
+
const roundedWidth = Math.round(numericWidth);
|
|
31211
|
+
const minimumWidth = shouldEnforceMinimum ? cellMinWidth : 1;
|
|
31212
|
+
const safeWidth = Math.max(roundedWidth, minimumWidth);
|
|
31213
|
+
const decoded = translator$a.decode({
|
|
31214
|
+
node: { type: (
|
|
31215
|
+
/** @type {string} */
|
|
31216
|
+
translator$a.sdNodeOrKeyName
|
|
31217
|
+
), attrs: { col: safeWidth } }
|
|
31218
|
+
});
|
|
31219
|
+
if (decoded) elements.push(decoded);
|
|
31220
|
+
};
|
|
31221
|
+
cellNodes.forEach((cell) => {
|
|
31222
|
+
const { colspan = 1, colwidth } = cell?.attrs || {};
|
|
31223
|
+
const spanCount = Math.max(1, colspan);
|
|
31224
|
+
for (let span = 0; span < spanCount; span++) {
|
|
31225
|
+
const rawWidth = Array.isArray(colwidth) ? colwidth[span] : void 0;
|
|
31226
|
+
const cellWidthPixels = typeof rawWidth === "number" && Number.isFinite(rawWidth) ? rawWidth : Number(rawWidth);
|
|
31227
|
+
const hasCellWidth = Number.isFinite(cellWidthPixels) && cellWidthPixels > 0;
|
|
31228
|
+
const colGridAttrs = grid?.[columnIndex] || {};
|
|
31229
|
+
const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
|
|
31230
|
+
const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
|
|
31231
|
+
let cellWidthTwips;
|
|
31232
|
+
let enforceMinimum = false;
|
|
31233
|
+
if (hasCellWidth) {
|
|
31234
|
+
const tolerance = 0.5;
|
|
31235
|
+
if (gridWidthTwips != null && gridWidthPixels != null && Math.abs(gridWidthPixels - cellWidthPixels) <= tolerance) {
|
|
31236
|
+
cellWidthTwips = gridWidthTwips;
|
|
31237
|
+
} else {
|
|
31238
|
+
cellWidthTwips = pixelsToTwips(cellWidthPixels);
|
|
31239
|
+
}
|
|
31240
|
+
} else if (gridWidthTwips != null) {
|
|
31241
|
+
cellWidthTwips = gridWidthTwips;
|
|
31242
|
+
} else {
|
|
31243
|
+
cellWidthTwips = fallbackColumnWidthTwips;
|
|
31244
|
+
enforceMinimum = true;
|
|
31245
|
+
}
|
|
31246
|
+
pushColumn(cellWidthTwips, { enforceMinimum });
|
|
31247
|
+
columnIndex++;
|
|
31248
|
+
}
|
|
31249
|
+
});
|
|
31250
|
+
while (columnIndex < grid.length) {
|
|
31251
|
+
const gridWidthTwips = normalizeTwipWidth(grid[columnIndex]?.col);
|
|
31252
|
+
pushColumn(gridWidthTwips);
|
|
31253
|
+
columnIndex++;
|
|
31254
|
+
}
|
|
31255
|
+
const newNode = {
|
|
31256
|
+
name: XML_NODE_NAME$a,
|
|
31257
|
+
attributes: {},
|
|
31258
|
+
elements
|
|
31259
|
+
};
|
|
31260
|
+
return newNode;
|
|
31261
|
+
};
|
|
31262
|
+
const config$9 = {
|
|
31263
|
+
xmlName: XML_NODE_NAME$a,
|
|
31264
|
+
sdNodeOrKeyName: SD_ATTR_KEY$2,
|
|
31265
|
+
encode: encode$g,
|
|
31266
|
+
decode: decode$i
|
|
31267
|
+
};
|
|
31268
|
+
const translator$9 = NodeTranslator.from(config$9);
|
|
31269
|
+
const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
|
|
31270
|
+
const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
|
|
31271
|
+
const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
|
|
31272
|
+
const MIN_COLUMN_WIDTH_TWIPS = pixelsToTwips(10);
|
|
31273
|
+
const pctToPercent = (value) => {
|
|
31274
|
+
if (value == null) return null;
|
|
31275
|
+
return value / 50;
|
|
31276
|
+
};
|
|
31277
|
+
const resolveContentWidthTwips = () => DEFAULT_CONTENT_WIDTH_TWIPS;
|
|
31278
|
+
const resolveMeasurementWidthPx = (measurement) => {
|
|
31279
|
+
if (!measurement || typeof measurement.value !== "number" || measurement.value <= 0) return null;
|
|
31280
|
+
const { value, type: type2 } = measurement;
|
|
31281
|
+
if (!type2 || type2 === "auto") return null;
|
|
31282
|
+
if (type2 === "dxa") return twipsToPixels(value);
|
|
31283
|
+
if (type2 === "pct") {
|
|
31284
|
+
const percent2 = pctToPercent(value);
|
|
31285
|
+
if (percent2 == null || percent2 <= 0) return null;
|
|
31286
|
+
const widthTwips = resolveContentWidthTwips() * percent2 / 100;
|
|
31287
|
+
return twipsToPixels(widthTwips);
|
|
31288
|
+
}
|
|
31289
|
+
return null;
|
|
31290
|
+
};
|
|
31291
|
+
const countColumnsInRow = (row) => {
|
|
31292
|
+
if (!row?.elements?.length) return 0;
|
|
31293
|
+
return row.elements.reduce((count, element) => {
|
|
31294
|
+
if (element.name !== "w:tc") return count;
|
|
31295
|
+
const tcPr = element.elements?.find((el) => el.name === "w:tcPr");
|
|
31296
|
+
const gridSpan = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
31297
|
+
const spanValue = parseInt(gridSpan?.attributes?.["w:val"] || "1", 10);
|
|
31298
|
+
return count + (Number.isFinite(spanValue) && spanValue > 0 ? spanValue : 1);
|
|
31299
|
+
}, 0);
|
|
31300
|
+
};
|
|
31301
|
+
const clampColumnWidthTwips = (value) => Math.max(Math.round(value), MIN_COLUMN_WIDTH_TWIPS);
|
|
31302
|
+
const createFallbackGrid = (columnCount, columnWidthTwips) => Array.from({ length: columnCount }, () => ({ col: clampColumnWidthTwips(columnWidthTwips) }));
|
|
31303
|
+
const buildFallbackGridForTable = ({ params: params2, rows, tableWidth, tableWidthMeasurement }) => {
|
|
31304
|
+
const firstRow = rows.find((row) => row.elements?.some((el) => el.name === "w:tc"));
|
|
31305
|
+
const columnCount = countColumnsInRow(firstRow);
|
|
31306
|
+
if (!columnCount) return null;
|
|
31307
|
+
const schemaDefaultPx = getSchemaDefaultColumnWidthPx(
|
|
31308
|
+
/** @type {any} */
|
|
31309
|
+
params2
|
|
31310
|
+
);
|
|
31311
|
+
const minimumColumnWidthPx = Number.isFinite(schemaDefaultPx) && schemaDefaultPx > 0 ? schemaDefaultPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
31312
|
+
let totalWidthPx;
|
|
31313
|
+
if (tableWidthMeasurement) {
|
|
31314
|
+
const resolved = resolveMeasurementWidthPx(tableWidthMeasurement);
|
|
31315
|
+
if (resolved != null) totalWidthPx = resolved;
|
|
31316
|
+
}
|
|
31317
|
+
if (totalWidthPx == null && tableWidth?.width && tableWidth.width > 0) {
|
|
31318
|
+
totalWidthPx = tableWidth.width;
|
|
31319
|
+
}
|
|
31320
|
+
if (totalWidthPx == null) {
|
|
31321
|
+
totalWidthPx = minimumColumnWidthPx * columnCount;
|
|
31322
|
+
}
|
|
31323
|
+
const rawColumnWidthPx = Math.max(totalWidthPx / columnCount, minimumColumnWidthPx);
|
|
31324
|
+
const columnWidthTwips = clampColumnWidthTwips(pixelsToTwips(rawColumnWidthPx));
|
|
31325
|
+
const fallbackColumnWidthPx = twipsToPixels(columnWidthTwips);
|
|
31326
|
+
return {
|
|
31327
|
+
grid: createFallbackGrid(columnCount, columnWidthTwips),
|
|
31328
|
+
columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
|
|
31364
31329
|
};
|
|
31365
|
-
}
|
|
31366
|
-
|
|
31367
|
-
|
|
31368
|
-
|
|
31369
|
-
|
|
31370
|
-
|
|
31371
|
-
|
|
31372
|
-
if (
|
|
31373
|
-
|
|
31374
|
-
|
|
31375
|
-
if (textHighlight) marks.push({ type: "highlight", attrs: { color: textHighlight } });
|
|
31376
|
-
return marks;
|
|
31377
|
-
}
|
|
31378
|
-
function applyMarksToHtmlAnnotation(state2, marks) {
|
|
31379
|
-
const { tr, doc: doc2, schema } = state2;
|
|
31380
|
-
const allowedMarks = ["fontFamily", "fontSize", "highlight"];
|
|
31381
|
-
if (!marks.some((m2) => allowedMarks.includes(m2.type))) {
|
|
31382
|
-
return state2;
|
|
31330
|
+
};
|
|
31331
|
+
const XML_NODE_NAME$9 = "w:tbl";
|
|
31332
|
+
const SD_NODE_NAME$7 = "table";
|
|
31333
|
+
const encode$f = (params2, encodedAttrs) => {
|
|
31334
|
+
const { nodes } = params2;
|
|
31335
|
+
const node = nodes[0];
|
|
31336
|
+
const tblPr = node.elements.find((el) => el.name === "w:tblPr");
|
|
31337
|
+
if (tblPr) {
|
|
31338
|
+
const encodedProperties = translator$b.encode({ ...params2, nodes: [tblPr] });
|
|
31339
|
+
encodedAttrs["tableProperties"] = encodedProperties || {};
|
|
31383
31340
|
}
|
|
31384
|
-
const
|
|
31385
|
-
|
|
31386
|
-
|
|
31387
|
-
|
|
31388
|
-
|
|
31389
|
-
|
|
31390
|
-
|
|
31391
|
-
|
|
31392
|
-
|
|
31393
|
-
|
|
31394
|
-
|
|
31395
|
-
|
|
31396
|
-
|
|
31397
|
-
|
|
31398
|
-
|
|
31399
|
-
|
|
31400
|
-
|
|
31401
|
-
);
|
|
31402
|
-
} else if (!foundTextStyle?.attrs.fontFamily && fontFamily2) {
|
|
31403
|
-
tr.addMark(
|
|
31404
|
-
pos,
|
|
31405
|
-
pos + node.nodeSize,
|
|
31406
|
-
textStyleType.create({
|
|
31407
|
-
...foundTextStyle?.attrs,
|
|
31408
|
-
...fontFamily2.attrs
|
|
31409
|
-
})
|
|
31410
|
-
);
|
|
31411
|
-
} else if (!foundTextStyle?.attrs.fontSize && fontSize2) {
|
|
31412
|
-
tr.addMark(
|
|
31413
|
-
pos,
|
|
31414
|
-
pos + node.nodeSize,
|
|
31415
|
-
textStyleType.create({
|
|
31416
|
-
...foundTextStyle?.attrs,
|
|
31417
|
-
...fontSize2.attrs
|
|
31418
|
-
})
|
|
31419
|
-
);
|
|
31341
|
+
const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
|
|
31342
|
+
if (tblGrid) {
|
|
31343
|
+
encodedAttrs["grid"] = translator$9.encode({ ...params2, nodes: [tblGrid] }).attributes;
|
|
31344
|
+
}
|
|
31345
|
+
[
|
|
31346
|
+
"tableStyleId",
|
|
31347
|
+
"justification",
|
|
31348
|
+
"tableLayout",
|
|
31349
|
+
["tableIndent", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
31350
|
+
["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
|
|
31351
|
+
].forEach((prop) => {
|
|
31352
|
+
let key2;
|
|
31353
|
+
let transform;
|
|
31354
|
+
if (Array.isArray(prop)) {
|
|
31355
|
+
[key2, transform] = prop;
|
|
31356
|
+
} else {
|
|
31357
|
+
key2 = prop;
|
|
31358
|
+
transform = (v2) => v2;
|
|
31420
31359
|
}
|
|
31421
|
-
if (
|
|
31422
|
-
|
|
31423
|
-
pos,
|
|
31424
|
-
pos + node.nodeSize,
|
|
31425
|
-
highlightType.create({
|
|
31426
|
-
...highlight?.attrs
|
|
31427
|
-
})
|
|
31428
|
-
);
|
|
31360
|
+
if (encodedAttrs.tableProperties && encodedAttrs.tableProperties[key2]) {
|
|
31361
|
+
encodedAttrs[key2] = transform(encodedAttrs.tableProperties[key2]);
|
|
31429
31362
|
}
|
|
31430
31363
|
});
|
|
31431
|
-
|
|
31432
|
-
|
|
31433
|
-
function getFieldHighlightJson(fieldsHighlightColor) {
|
|
31434
|
-
if (!fieldsHighlightColor) return null;
|
|
31435
|
-
let parsedColor = fieldsHighlightColor.trim();
|
|
31436
|
-
const hexRegex2 = /^#?([A-Fa-f0-9]{3}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/;
|
|
31437
|
-
if (!hexRegex2.test(parsedColor)) {
|
|
31438
|
-
console.warn(`Invalid HEX color provided to fieldsHighlightColor export param: ${fieldsHighlightColor}`);
|
|
31439
|
-
return null;
|
|
31364
|
+
if (encodedAttrs.tableCellSpacing) {
|
|
31365
|
+
encodedAttrs["borderCollapse"] = "separate";
|
|
31440
31366
|
}
|
|
31441
|
-
if (
|
|
31442
|
-
|
|
31367
|
+
if (encodedAttrs.tableProperties?.tableWidth) {
|
|
31368
|
+
const tableWidthMeasurement = encodedAttrs.tableProperties.tableWidth;
|
|
31369
|
+
const widthPx = twipsToPixels(tableWidthMeasurement.value);
|
|
31370
|
+
if (widthPx != null) {
|
|
31371
|
+
encodedAttrs.tableWidth = {
|
|
31372
|
+
width: widthPx,
|
|
31373
|
+
type: tableWidthMeasurement.type
|
|
31374
|
+
};
|
|
31375
|
+
} else if (tableWidthMeasurement.type === "auto") {
|
|
31376
|
+
encodedAttrs.tableWidth = {
|
|
31377
|
+
width: 0,
|
|
31378
|
+
type: tableWidthMeasurement.type
|
|
31379
|
+
};
|
|
31380
|
+
}
|
|
31443
31381
|
}
|
|
31444
|
-
|
|
31445
|
-
|
|
31446
|
-
|
|
31447
|
-
|
|
31448
|
-
|
|
31449
|
-
|
|
31450
|
-
|
|
31451
|
-
|
|
31452
|
-
|
|
31382
|
+
const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
|
|
31383
|
+
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2);
|
|
31384
|
+
if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
|
|
31385
|
+
encodedAttrs.tableProperties = {
|
|
31386
|
+
...encodedAttrs.tableProperties || {},
|
|
31387
|
+
cellMargins: referencedStyles.cellMargins
|
|
31388
|
+
};
|
|
31389
|
+
}
|
|
31390
|
+
const rows = node.elements.filter((el) => el.name === "w:tr");
|
|
31391
|
+
const borderData = Object.assign({}, referencedStyles?.borders || {}, borders || {});
|
|
31392
|
+
const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
|
|
31393
|
+
encodedAttrs["borders"] = borderData;
|
|
31394
|
+
let columnWidths = Array.isArray(encodedAttrs["grid"]) ? encodedAttrs["grid"].map((item) => twipsToPixels(item.col)) : [];
|
|
31395
|
+
if (!columnWidths.length) {
|
|
31396
|
+
const fallback = buildFallbackGridForTable({
|
|
31397
|
+
params: params2,
|
|
31398
|
+
rows,
|
|
31399
|
+
tableWidth: encodedAttrs.tableWidth,
|
|
31400
|
+
tableWidthMeasurement: encodedAttrs.tableProperties?.tableWidth
|
|
31401
|
+
});
|
|
31402
|
+
if (fallback) {
|
|
31403
|
+
encodedAttrs.grid = fallback.grid;
|
|
31404
|
+
columnWidths = fallback.columnWidths;
|
|
31405
|
+
}
|
|
31406
|
+
}
|
|
31407
|
+
const content = [];
|
|
31408
|
+
const totalColumns = columnWidths.length;
|
|
31409
|
+
const activeRowSpans = totalColumns > 0 ? new Array(totalColumns).fill(0) : [];
|
|
31410
|
+
rows.forEach((row, rowIndex) => {
|
|
31411
|
+
const result = translator$u.encode({
|
|
31412
|
+
...params2,
|
|
31413
|
+
nodes: [row],
|
|
31414
|
+
extraParams: {
|
|
31415
|
+
row,
|
|
31416
|
+
table: node,
|
|
31417
|
+
rowBorders: borderRowData,
|
|
31418
|
+
columnWidths,
|
|
31419
|
+
activeRowSpans: activeRowSpans.slice(),
|
|
31420
|
+
rowIndex,
|
|
31421
|
+
_referencedStyles: referencedStyles
|
|
31422
|
+
}
|
|
31423
|
+
});
|
|
31424
|
+
if (result) {
|
|
31425
|
+
content.push(result);
|
|
31426
|
+
if (totalColumns > 0) {
|
|
31427
|
+
const activeRowSpansForCurrentRow = activeRowSpans.slice();
|
|
31428
|
+
for (let col = 0; col < totalColumns; col++) {
|
|
31429
|
+
if (activeRowSpans[col] > 0) {
|
|
31430
|
+
activeRowSpans[col] -= 1;
|
|
31431
|
+
}
|
|
31453
31432
|
}
|
|
31433
|
+
let columnIndex = 0;
|
|
31434
|
+
const advanceColumnIndex = () => {
|
|
31435
|
+
while (columnIndex < totalColumns && activeRowSpansForCurrentRow[columnIndex] > 0) {
|
|
31436
|
+
columnIndex += 1;
|
|
31437
|
+
}
|
|
31438
|
+
};
|
|
31439
|
+
advanceColumnIndex();
|
|
31440
|
+
result.content?.forEach((cell) => {
|
|
31441
|
+
advanceColumnIndex();
|
|
31442
|
+
const colspan = Math.max(1, cell.attrs?.colspan || 1);
|
|
31443
|
+
const rowspan = Math.max(1, cell.attrs?.rowspan || 1);
|
|
31444
|
+
if (rowspan > 1) {
|
|
31445
|
+
for (let offset2 = 0; offset2 < colspan && columnIndex + offset2 < totalColumns; offset2++) {
|
|
31446
|
+
const targetIndex = columnIndex + offset2;
|
|
31447
|
+
const remainingRows = rowspan - 1;
|
|
31448
|
+
if (remainingRows > 0 && remainingRows > activeRowSpans[targetIndex]) {
|
|
31449
|
+
activeRowSpans[targetIndex] = remainingRows;
|
|
31450
|
+
}
|
|
31451
|
+
}
|
|
31452
|
+
}
|
|
31453
|
+
columnIndex += colspan;
|
|
31454
|
+
advanceColumnIndex();
|
|
31455
|
+
});
|
|
31454
31456
|
}
|
|
31455
|
-
|
|
31457
|
+
}
|
|
31458
|
+
});
|
|
31459
|
+
return {
|
|
31460
|
+
type: "table",
|
|
31461
|
+
content,
|
|
31462
|
+
attrs: encodedAttrs
|
|
31456
31463
|
};
|
|
31457
|
-
}
|
|
31458
|
-
|
|
31464
|
+
};
|
|
31465
|
+
const decode$h = (params2, decodedAttrs) => {
|
|
31466
|
+
params2.node = preProcessVerticalMergeCells(params2.node, params2);
|
|
31459
31467
|
const { node } = params2;
|
|
31460
|
-
const
|
|
31461
|
-
const
|
|
31462
|
-
const
|
|
31463
|
-
|
|
31464
|
-
|
|
31465
|
-
|
|
31468
|
+
const elements = translateChildNodes(params2);
|
|
31469
|
+
const firstRow = node.content?.find((n) => n.type === "tableRow");
|
|
31470
|
+
const properties = node.attrs.grid;
|
|
31471
|
+
const element = translator$9.decode({
|
|
31472
|
+
...params2,
|
|
31473
|
+
node: { ...node, attrs: { ...node.attrs, grid: properties } },
|
|
31474
|
+
extraParams: {
|
|
31475
|
+
firstRow
|
|
31466
31476
|
}
|
|
31467
|
-
];
|
|
31468
|
-
const exportedTag = JSON.stringify({
|
|
31469
|
-
type: "documentSection",
|
|
31470
|
-
description: attrs.description
|
|
31471
31477
|
});
|
|
31472
|
-
|
|
31473
|
-
|
|
31474
|
-
|
|
31475
|
-
|
|
31476
|
-
|
|
31477
|
-
|
|
31478
|
-
"w:val": "sdtContentLocked"
|
|
31479
|
-
}
|
|
31478
|
+
if (element) elements.unshift(element);
|
|
31479
|
+
if (node.attrs?.tableProperties) {
|
|
31480
|
+
const properties2 = { ...node.attrs.tableProperties };
|
|
31481
|
+
const element2 = translator$b.decode({
|
|
31482
|
+
...params2,
|
|
31483
|
+
node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
|
|
31480
31484
|
});
|
|
31485
|
+
if (element2) elements.unshift(element2);
|
|
31481
31486
|
}
|
|
31482
|
-
nodeElements.unshift(sdtPr);
|
|
31483
|
-
const result = {
|
|
31484
|
-
name: "w:sdt",
|
|
31485
|
-
elements: nodeElements
|
|
31486
|
-
};
|
|
31487
|
-
return result;
|
|
31488
|
-
}
|
|
31489
|
-
const generateSdtPrTagForDocumentSection = (id, title, tag) => {
|
|
31490
31487
|
return {
|
|
31491
|
-
name: "w:
|
|
31492
|
-
|
|
31493
|
-
|
|
31494
|
-
name: "w:id",
|
|
31495
|
-
attributes: {
|
|
31496
|
-
"w:val": id
|
|
31497
|
-
}
|
|
31498
|
-
},
|
|
31499
|
-
{
|
|
31500
|
-
name: "w:alias",
|
|
31501
|
-
attributes: {
|
|
31502
|
-
"w:val": title
|
|
31503
|
-
}
|
|
31504
|
-
},
|
|
31505
|
-
{
|
|
31506
|
-
name: "w:tag",
|
|
31507
|
-
attributes: {
|
|
31508
|
-
"w:val": tag
|
|
31509
|
-
}
|
|
31510
|
-
}
|
|
31511
|
-
]
|
|
31488
|
+
name: "w:tbl",
|
|
31489
|
+
attributes: decodedAttrs || {},
|
|
31490
|
+
elements
|
|
31512
31491
|
};
|
|
31513
31492
|
};
|
|
31514
|
-
function
|
|
31515
|
-
const
|
|
31516
|
-
const
|
|
31517
|
-
|
|
31518
|
-
|
|
31519
|
-
|
|
31520
|
-
|
|
31521
|
-
|
|
31522
|
-
|
|
31523
|
-
|
|
31524
|
-
|
|
31525
|
-
|
|
31526
|
-
|
|
31527
|
-
|
|
31528
|
-
|
|
31529
|
-
|
|
31530
|
-
elements: [
|
|
31531
|
-
{
|
|
31532
|
-
name: "w:docPartGallery",
|
|
31533
|
-
attributes: {
|
|
31534
|
-
"w:val": attrs.docPartGallery
|
|
31535
|
-
}
|
|
31536
|
-
},
|
|
31537
|
-
...attrs.docPartUnique ? [
|
|
31538
|
-
{
|
|
31539
|
-
name: "w:docPartUnique"
|
|
31540
|
-
}
|
|
31541
|
-
] : []
|
|
31542
|
-
]
|
|
31543
|
-
}
|
|
31544
|
-
]
|
|
31545
|
-
},
|
|
31546
|
-
{
|
|
31547
|
-
name: "w:sdtContent",
|
|
31548
|
-
elements: childContent
|
|
31549
|
-
}
|
|
31550
|
-
];
|
|
31551
|
-
const result = {
|
|
31552
|
-
name: "w:sdt",
|
|
31553
|
-
elements: nodeElements
|
|
31554
|
-
};
|
|
31555
|
-
return result;
|
|
31556
|
-
}
|
|
31557
|
-
function translateStructuredContent(params2) {
|
|
31558
|
-
const { node } = params2;
|
|
31559
|
-
const childContent = translateChildNodes({ ...params2, nodes: node.content });
|
|
31560
|
-
const sdtContent = { name: "w:sdtContent", elements: childContent };
|
|
31561
|
-
const sdtPr = generateSdtPrTagForStructuredContent({ node });
|
|
31562
|
-
const nodeElements = [sdtPr, sdtContent];
|
|
31563
|
-
const result = {
|
|
31564
|
-
name: "w:sdt",
|
|
31565
|
-
elements: nodeElements
|
|
31493
|
+
function _processTableBorders(rawBorders) {
|
|
31494
|
+
const borders = {};
|
|
31495
|
+
const rowBorders = {};
|
|
31496
|
+
Object.entries(rawBorders).forEach(([name, attributes]) => {
|
|
31497
|
+
const attrs = {};
|
|
31498
|
+
const color = attributes.color;
|
|
31499
|
+
const size2 = attributes.size;
|
|
31500
|
+
if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
|
|
31501
|
+
if (size2 && size2 !== "auto") attrs["size"] = eighthPointsToPixels(size2);
|
|
31502
|
+
const rowBorderNames = ["insideH", "insideV"];
|
|
31503
|
+
if (rowBorderNames.includes(name)) rowBorders[name] = attrs;
|
|
31504
|
+
borders[name] = attrs;
|
|
31505
|
+
});
|
|
31506
|
+
return {
|
|
31507
|
+
borders,
|
|
31508
|
+
rowBorders
|
|
31566
31509
|
};
|
|
31567
|
-
return result;
|
|
31568
31510
|
}
|
|
31569
|
-
function
|
|
31570
|
-
|
|
31571
|
-
const
|
|
31572
|
-
|
|
31573
|
-
|
|
31574
|
-
|
|
31575
|
-
|
|
31576
|
-
const
|
|
31577
|
-
|
|
31578
|
-
|
|
31579
|
-
|
|
31580
|
-
|
|
31581
|
-
|
|
31582
|
-
|
|
31583
|
-
|
|
31584
|
-
attributes: { "w:val": attrs.tag }
|
|
31585
|
-
};
|
|
31586
|
-
const resultElements = [];
|
|
31587
|
-
if (attrs.id) resultElements.push(id);
|
|
31588
|
-
if (attrs.alias) resultElements.push(alias);
|
|
31589
|
-
if (attrs.tag) resultElements.push(tag);
|
|
31590
|
-
if (attrs.sdtPr) {
|
|
31591
|
-
const elements = attrs.sdtPr.elements || [];
|
|
31592
|
-
const elementsToExclude = ["w:id", "w:alias", "w:tag"];
|
|
31593
|
-
const restElements = elements.filter((el) => !elementsToExclude.includes(el.name));
|
|
31594
|
-
const result2 = {
|
|
31595
|
-
name: "w:sdtPr",
|
|
31596
|
-
type: "element",
|
|
31597
|
-
elements: [...resultElements, ...restElements]
|
|
31598
|
-
};
|
|
31599
|
-
return result2;
|
|
31511
|
+
function _getReferencedTableStyles(tableStyleReference, params2) {
|
|
31512
|
+
if (!tableStyleReference) return null;
|
|
31513
|
+
const stylesToReturn = {};
|
|
31514
|
+
const { docx } = params2;
|
|
31515
|
+
const styles = docx["word/styles.xml"];
|
|
31516
|
+
const { elements } = styles.elements[0];
|
|
31517
|
+
const styleElements = elements.filter((el) => el.name === "w:style");
|
|
31518
|
+
const styleTag = styleElements.find((el) => el.attributes["w:styleId"] === tableStyleReference);
|
|
31519
|
+
if (!styleTag) return null;
|
|
31520
|
+
stylesToReturn.name = styleTag.elements.find((el) => el.name === "w:name");
|
|
31521
|
+
const basedOn = styleTag.elements.find((el) => el.name === "w:basedOn");
|
|
31522
|
+
let baseTblPr;
|
|
31523
|
+
if (basedOn?.attributes) {
|
|
31524
|
+
const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
|
|
31525
|
+
baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
|
|
31600
31526
|
}
|
|
31601
|
-
const
|
|
31602
|
-
|
|
31603
|
-
|
|
31604
|
-
|
|
31605
|
-
};
|
|
31606
|
-
return result;
|
|
31607
|
-
}
|
|
31608
|
-
const XML_NODE_NAME$9 = "w:sdt";
|
|
31609
|
-
const SD_NODE_NAME$7 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
|
|
31610
|
-
const validXmlAttributes$6 = [];
|
|
31611
|
-
function encode$f(params2) {
|
|
31612
|
-
const nodes = params2.nodes;
|
|
31613
|
-
const node = nodes[0];
|
|
31614
|
-
const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
|
|
31615
|
-
if (!handler2 || sdtType === "unknown") {
|
|
31616
|
-
return void 0;
|
|
31527
|
+
const pPr = styleTag.elements.find((el) => el.name === "w:pPr");
|
|
31528
|
+
if (pPr) {
|
|
31529
|
+
const justification = pPr.elements.find((el) => el.name === "w:jc");
|
|
31530
|
+
if (justification?.attributes) stylesToReturn.justification = justification.attributes["w:val"];
|
|
31617
31531
|
}
|
|
31618
|
-
const
|
|
31619
|
-
|
|
31620
|
-
|
|
31621
|
-
|
|
31622
|
-
|
|
31623
|
-
|
|
31624
|
-
|
|
31532
|
+
const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
|
|
31533
|
+
if (rPr) {
|
|
31534
|
+
const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
|
|
31535
|
+
if (fonts) {
|
|
31536
|
+
const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
|
|
31537
|
+
stylesToReturn.fonts = { ascii, hAnsi, cs };
|
|
31538
|
+
}
|
|
31539
|
+
const fontSize2 = rPr.elements.find((el) => el.name === "w:sz");
|
|
31540
|
+
if (fontSize2?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize2.attributes["w:val"]) + "pt";
|
|
31625
31541
|
}
|
|
31626
|
-
const
|
|
31627
|
-
|
|
31628
|
-
|
|
31629
|
-
|
|
31630
|
-
|
|
31631
|
-
|
|
31632
|
-
|
|
31633
|
-
|
|
31634
|
-
|
|
31635
|
-
|
|
31636
|
-
|
|
31637
|
-
|
|
31542
|
+
const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
|
|
31543
|
+
if (tblPr && tblPr.elements) {
|
|
31544
|
+
if (baseTblPr && baseTblPr.elements) {
|
|
31545
|
+
tblPr.elements.push(...baseTblPr.elements);
|
|
31546
|
+
}
|
|
31547
|
+
const tableProperties = translator$b.encode({ ...params2, nodes: [tblPr] });
|
|
31548
|
+
if (tableProperties) {
|
|
31549
|
+
const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
|
|
31550
|
+
if (borders) stylesToReturn.borders = borders;
|
|
31551
|
+
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
31552
|
+
const cellMargins = {};
|
|
31553
|
+
Object.entries(tableProperties.cellMargins || {}).forEach(([key2, attrs]) => {
|
|
31554
|
+
if (attrs?.value != null) {
|
|
31555
|
+
cellMargins[key2] = {
|
|
31556
|
+
value: attrs.value,
|
|
31557
|
+
type: attrs.type || "dxa"
|
|
31558
|
+
};
|
|
31559
|
+
}
|
|
31560
|
+
});
|
|
31561
|
+
if (Object.keys(cellMargins).length) stylesToReturn.cellMargins = cellMargins;
|
|
31562
|
+
}
|
|
31563
|
+
}
|
|
31564
|
+
return stylesToReturn;
|
|
31638
31565
|
}
|
|
31639
31566
|
const config$8 = {
|
|
31640
31567
|
xmlName: XML_NODE_NAME$9,
|
|
@@ -31642,7 +31569,7 @@ const config$8 = {
|
|
|
31642
31569
|
type: NodeTranslator.translatorTypes.NODE,
|
|
31643
31570
|
encode: encode$f,
|
|
31644
31571
|
decode: decode$h,
|
|
31645
|
-
attributes:
|
|
31572
|
+
attributes: []
|
|
31646
31573
|
};
|
|
31647
31574
|
const translator$8 = NodeTranslator.from(config$8);
|
|
31648
31575
|
const encode$e = (attributes) => {
|
|
@@ -32157,7 +32084,7 @@ const handleDrawingNode = (params2) => {
|
|
|
32157
32084
|
if (mainNode.name === "w:drawing") node = mainNode;
|
|
32158
32085
|
else node = mainNode.elements.find((el) => el.name === "w:drawing");
|
|
32159
32086
|
if (!node) return { nodes: [], consumed: 0 };
|
|
32160
|
-
const schemaNode = translator$
|
|
32087
|
+
const schemaNode = translator$r.encode(params2);
|
|
32161
32088
|
const newNodes = schemaNode ? [schemaNode] : [];
|
|
32162
32089
|
return { nodes: newNodes, consumed: 1 };
|
|
32163
32090
|
};
|
|
@@ -32466,7 +32393,7 @@ const handleSdtNode = (params2) => {
|
|
|
32466
32393
|
if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
|
|
32467
32394
|
return { nodes: [], consumed: 0 };
|
|
32468
32395
|
}
|
|
32469
|
-
const result = translator$
|
|
32396
|
+
const result = translator$q.encode(params2);
|
|
32470
32397
|
if (!result) {
|
|
32471
32398
|
return { nodes: [], consumed: 0 };
|
|
32472
32399
|
}
|
|
@@ -33260,6 +33187,7 @@ const tabNodeEntityHandler = {
|
|
|
33260
33187
|
handlerName: "w:tabTranslator",
|
|
33261
33188
|
handler: handleTabNode
|
|
33262
33189
|
};
|
|
33190
|
+
const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$8);
|
|
33263
33191
|
const tableOfContentsHandlerEntity = generateV2HandlerEntity("tableOfContentsHandler", translator$4);
|
|
33264
33192
|
function preProcessPageInstruction(nodesToCombine) {
|
|
33265
33193
|
const pageNumNode = {
|
|
@@ -34269,14 +34197,14 @@ function exportSchemaToJson(params2) {
|
|
|
34269
34197
|
bulletList: translateList,
|
|
34270
34198
|
orderedList: translateList,
|
|
34271
34199
|
lineBreak: translator$1r,
|
|
34272
|
-
table: translator$
|
|
34273
|
-
tableRow: translator$
|
|
34274
|
-
tableCell: translator$
|
|
34200
|
+
table: translator$8,
|
|
34201
|
+
tableRow: translator$u,
|
|
34202
|
+
tableCell: translator$H,
|
|
34275
34203
|
bookmarkStart: translator$7,
|
|
34276
34204
|
bookmarkEnd: translator$6,
|
|
34277
|
-
fieldAnnotation: translator$
|
|
34205
|
+
fieldAnnotation: translator$q,
|
|
34278
34206
|
tab: translator$1p,
|
|
34279
|
-
image: translator$
|
|
34207
|
+
image: translator$r,
|
|
34280
34208
|
hardBreak: translator$1r,
|
|
34281
34209
|
commentRangeStart: commentRangeStartTranslator,
|
|
34282
34210
|
commentRangeEnd: commentRangeEndTranslator,
|
|
@@ -34285,10 +34213,10 @@ function exportSchemaToJson(params2) {
|
|
|
34285
34213
|
shapeTextbox: translator,
|
|
34286
34214
|
contentBlock: translator,
|
|
34287
34215
|
vectorShape: translateVectorShape,
|
|
34288
|
-
structuredContent: translator$
|
|
34289
|
-
structuredContentBlock: translator$
|
|
34290
|
-
documentPartObject: translator$
|
|
34291
|
-
documentSection: translator$
|
|
34216
|
+
structuredContent: translator$q,
|
|
34217
|
+
structuredContentBlock: translator$q,
|
|
34218
|
+
documentPartObject: translator$q,
|
|
34219
|
+
documentSection: translator$q,
|
|
34292
34220
|
"page-number": translatePageNumberNode,
|
|
34293
34221
|
"total-page-number": translateTotalPageNumberNode,
|
|
34294
34222
|
pageReference: translator$5,
|
|
@@ -36022,7 +35950,7 @@ exportProcessNewRelationships_fn = function(rels = []) {
|
|
|
36022
35950
|
});
|
|
36023
35951
|
relationships.elements = [...relationships.elements, ...newRels];
|
|
36024
35952
|
};
|
|
36025
|
-
exportProcessMediaFiles_fn = async function(media = {}
|
|
35953
|
+
exportProcessMediaFiles_fn = async function(media = {}) {
|
|
36026
35954
|
const processedData = {
|
|
36027
35955
|
...this.convertedXml.media || {}
|
|
36028
35956
|
};
|
|
@@ -43789,6 +43717,8 @@ function readDOMChange(view, from2, to, typeOver, addedNodes) {
|
|
|
43789
43717
|
let deflt = () => mkTr(view.state.tr.insertText(text, chFrom, chTo));
|
|
43790
43718
|
if (!view.someProp("handleTextInput", (f2) => f2(view, chFrom, chTo, text, deflt)))
|
|
43791
43719
|
view.dispatch(deflt());
|
|
43720
|
+
} else {
|
|
43721
|
+
view.dispatch(mkTr());
|
|
43792
43722
|
}
|
|
43793
43723
|
} else {
|
|
43794
43724
|
view.dispatch(mkTr());
|
|
@@ -48986,6 +48916,49 @@ const restoreSelection = () => ({ editor, state: state2, tr }) => {
|
|
|
48986
48916
|
editor.view.dispatch(selectionTr);
|
|
48987
48917
|
}
|
|
48988
48918
|
};
|
|
48919
|
+
const clamp = (value, min2, max2) => Math.max(min2, Math.min(value, max2));
|
|
48920
|
+
const setTextSelection = ({ from: from2, to }) => ({ state: state2, dispatch, editor }) => {
|
|
48921
|
+
if (typeof from2 !== "number" && typeof to !== "number") {
|
|
48922
|
+
return false;
|
|
48923
|
+
}
|
|
48924
|
+
const doc2 = state2.doc;
|
|
48925
|
+
const docSize = doc2.content.size;
|
|
48926
|
+
const nextFrom = clamp(typeof from2 === "number" ? from2 : state2.selection.from, 0, docSize);
|
|
48927
|
+
const nextToBase = typeof to === "number" ? to : nextFrom;
|
|
48928
|
+
const nextTo = clamp(nextToBase, 0, docSize);
|
|
48929
|
+
const [head, anchor] = nextFrom <= nextTo ? [nextFrom, nextTo] : [nextTo, nextFrom];
|
|
48930
|
+
const selection = TextSelection$1.create(doc2, head, anchor);
|
|
48931
|
+
if (dispatch) {
|
|
48932
|
+
const transaction = state2.tr.setSelection(selection);
|
|
48933
|
+
dispatch(transaction);
|
|
48934
|
+
}
|
|
48935
|
+
if (editor?.view?.focus) {
|
|
48936
|
+
editor.view.focus();
|
|
48937
|
+
}
|
|
48938
|
+
return true;
|
|
48939
|
+
};
|
|
48940
|
+
const getSelectionMarks = () => ({ state: state2, tr }) => {
|
|
48941
|
+
tr.setMeta("preventDispatch", true);
|
|
48942
|
+
const marks = getMarksFromSelection(state2) ?? [];
|
|
48943
|
+
const uniqueByType = /* @__PURE__ */ new Map();
|
|
48944
|
+
for (const mark of marks) {
|
|
48945
|
+
const typeName = typeof mark?.type === "string" ? mark.type : mark?.type?.name;
|
|
48946
|
+
if (!typeName) continue;
|
|
48947
|
+
const existing = uniqueByType.get(typeName);
|
|
48948
|
+
if (!existing) {
|
|
48949
|
+
uniqueByType.set(typeName, mark);
|
|
48950
|
+
continue;
|
|
48951
|
+
}
|
|
48952
|
+
const existingAttrs = existing?.attrs ?? {};
|
|
48953
|
+
const nextAttrs = mark?.attrs ?? {};
|
|
48954
|
+
const existingHasValues = Object.values(existingAttrs).some((value) => value != null);
|
|
48955
|
+
const nextHasValues = Object.values(nextAttrs).some((value) => value != null);
|
|
48956
|
+
if (!existingHasValues && nextHasValues) {
|
|
48957
|
+
uniqueByType.set(typeName, mark);
|
|
48958
|
+
}
|
|
48959
|
+
}
|
|
48960
|
+
return Array.from(uniqueByType.values());
|
|
48961
|
+
};
|
|
48989
48962
|
const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
48990
48963
|
__proto__: null,
|
|
48991
48964
|
atVisualParaEnd,
|
|
@@ -49001,6 +48974,7 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
49001
48974
|
first,
|
|
49002
48975
|
getEffectiveStyleId,
|
|
49003
48976
|
getParaCtx,
|
|
48977
|
+
getSelectionMarks,
|
|
49004
48978
|
getStyleIdFromMarks,
|
|
49005
48979
|
handleBackspaceNextToList,
|
|
49006
48980
|
handleDeleteNextToList,
|
|
@@ -49032,6 +49006,7 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
49032
49006
|
setMark,
|
|
49033
49007
|
setMeta,
|
|
49034
49008
|
setNode,
|
|
49009
|
+
setTextSelection,
|
|
49035
49010
|
sinkListItem,
|
|
49036
49011
|
splitBlock: splitBlock$1,
|
|
49037
49012
|
splitListItem,
|
|
@@ -49696,6 +49671,7 @@ const markInsertion = ({ tr, from: from2, to, user, date }) => {
|
|
|
49696
49671
|
id,
|
|
49697
49672
|
author: user.name,
|
|
49698
49673
|
authorEmail: user.email,
|
|
49674
|
+
authorImage: user.image,
|
|
49699
49675
|
date
|
|
49700
49676
|
});
|
|
49701
49677
|
tr.addMark(from2, to, insertionMark);
|
|
@@ -49732,6 +49708,7 @@ const markDeletion = ({ tr, from: from2, to, user, date, id: providedId }) => {
|
|
|
49732
49708
|
id,
|
|
49733
49709
|
author: user.name,
|
|
49734
49710
|
authorEmail: user.email,
|
|
49711
|
+
authorImage: user.image,
|
|
49735
49712
|
date
|
|
49736
49713
|
});
|
|
49737
49714
|
const deletionMap = new Mapping();
|
|
@@ -50428,6 +50405,9 @@ const normalizeCommentEventPayload = ({ conversation, editorOptions, fallbackCom
|
|
|
50428
50405
|
if (!normalized.creatorEmail && user?.email) {
|
|
50429
50406
|
normalized.creatorEmail = user.email;
|
|
50430
50407
|
}
|
|
50408
|
+
if (!normalized.creatorImage && user?.image) {
|
|
50409
|
+
normalized.creatorImage = user.image;
|
|
50410
|
+
}
|
|
50431
50411
|
if (!normalized.createdTime) {
|
|
50432
50412
|
normalized.createdTime = Date.now();
|
|
50433
50413
|
}
|
|
@@ -50886,7 +50866,7 @@ const createOrUpdateTrackedChangeComment = ({ event, marks, deletionNodes, nodes
|
|
|
50886
50866
|
const trackedMark = marks.insertedMark || marks.deletionMark || marks.formatMark;
|
|
50887
50867
|
const { type: type2, attrs } = trackedMark;
|
|
50888
50868
|
const { name: trackedChangeType } = type2;
|
|
50889
|
-
const { author, authorEmail, date, importedAuthor } = attrs;
|
|
50869
|
+
const { author, authorEmail, authorImage, date, importedAuthor } = attrs;
|
|
50890
50870
|
const id = attrs.id;
|
|
50891
50871
|
const node = nodes[0];
|
|
50892
50872
|
const isDeletionInsertion = !!(marks.insertedMark && marks.deletionMark);
|
|
@@ -50917,6 +50897,7 @@ const createOrUpdateTrackedChangeComment = ({ event, marks, deletionNodes, nodes
|
|
|
50917
50897
|
deletedText: marks.deletionMark ? deletionText : null,
|
|
50918
50898
|
author,
|
|
50919
50899
|
authorEmail,
|
|
50900
|
+
...authorImage && { authorImage },
|
|
50920
50901
|
date,
|
|
50921
50902
|
...importedAuthor && {
|
|
50922
50903
|
importedAuthor: {
|
|
@@ -51061,6 +51042,7 @@ const addMarkStep = ({ state: state2, step, newTr, doc: doc2, user, date }) => {
|
|
|
51061
51042
|
id: wid,
|
|
51062
51043
|
author: user.name,
|
|
51063
51044
|
authorEmail: user.email,
|
|
51045
|
+
authorImage: user.image,
|
|
51064
51046
|
date,
|
|
51065
51047
|
before,
|
|
51066
51048
|
after
|
|
@@ -51126,6 +51108,7 @@ const removeMarkStep = ({ state: state2, step, newTr, doc: doc2, user, date }) =
|
|
|
51126
51108
|
id: v4(),
|
|
51127
51109
|
author: user.name,
|
|
51128
51110
|
authorEmail: user.email,
|
|
51111
|
+
authorImage: user.image,
|
|
51129
51112
|
date,
|
|
51130
51113
|
before,
|
|
51131
51114
|
after
|
|
@@ -55125,6 +55108,9 @@ class GapBookmark {
|
|
|
55125
55108
|
return GapCursor.valid($pos) ? new GapCursor($pos) : Selection.near($pos);
|
|
55126
55109
|
}
|
|
55127
55110
|
}
|
|
55111
|
+
function needsGap(type2) {
|
|
55112
|
+
return type2.isAtom || type2.spec.isolating || type2.spec.createGapCursor;
|
|
55113
|
+
}
|
|
55128
55114
|
function closedBefore($pos) {
|
|
55129
55115
|
for (let d2 = $pos.depth; d2 >= 0; d2--) {
|
|
55130
55116
|
let index2 = $pos.index(d2), parent = $pos.node(d2);
|
|
@@ -55134,7 +55120,7 @@ function closedBefore($pos) {
|
|
|
55134
55120
|
continue;
|
|
55135
55121
|
}
|
|
55136
55122
|
for (let before = parent.child(index2 - 1); ; before = before.lastChild) {
|
|
55137
|
-
if (before.childCount == 0 && !before.inlineContent || before.
|
|
55123
|
+
if (before.childCount == 0 && !before.inlineContent || needsGap(before.type))
|
|
55138
55124
|
return true;
|
|
55139
55125
|
if (before.inlineContent)
|
|
55140
55126
|
return false;
|
|
@@ -55151,7 +55137,7 @@ function closedAfter($pos) {
|
|
|
55151
55137
|
continue;
|
|
55152
55138
|
}
|
|
55153
55139
|
for (let after = parent.child(index2); ; after = after.firstChild) {
|
|
55154
|
-
if (after.childCount == 0 && !after.inlineContent || after.
|
|
55140
|
+
if (after.childCount == 0 && !after.inlineContent || needsGap(after.type))
|
|
55155
55141
|
return true;
|
|
55156
55142
|
if (after.inlineContent)
|
|
55157
55143
|
return false;
|
|
@@ -70036,6 +70022,16 @@ const TrackInsert = Mark2.create({
|
|
|
70036
70022
|
};
|
|
70037
70023
|
}
|
|
70038
70024
|
},
|
|
70025
|
+
authorImage: {
|
|
70026
|
+
default: "",
|
|
70027
|
+
parseDOM: (elem) => elem.getAttribute("data-authorimage"),
|
|
70028
|
+
renderDOM: (attrs) => {
|
|
70029
|
+
if (!attrs.authorImage) return {};
|
|
70030
|
+
return {
|
|
70031
|
+
"data-authorimage": attrs.authorImage
|
|
70032
|
+
};
|
|
70033
|
+
}
|
|
70034
|
+
},
|
|
70039
70035
|
date: {
|
|
70040
70036
|
default: "",
|
|
70041
70037
|
parseDOM: (elem) => elem.getAttribute("data-date"),
|
|
@@ -70103,6 +70099,16 @@ const TrackDelete = Mark2.create({
|
|
|
70103
70099
|
};
|
|
70104
70100
|
}
|
|
70105
70101
|
},
|
|
70102
|
+
authorImage: {
|
|
70103
|
+
default: "",
|
|
70104
|
+
parseDOM: (elem) => elem.getAttribute("data-authorimage"),
|
|
70105
|
+
renderDOM: (attrs) => {
|
|
70106
|
+
if (!attrs.authorImage) return {};
|
|
70107
|
+
return {
|
|
70108
|
+
"data-authorimage": attrs.authorImage
|
|
70109
|
+
};
|
|
70110
|
+
}
|
|
70111
|
+
},
|
|
70106
70112
|
date: {
|
|
70107
70113
|
default: "",
|
|
70108
70114
|
parseDOM: (elem) => elem.getAttribute("data-date"),
|
|
@@ -70202,6 +70208,16 @@ const TrackFormat = Mark2.create({
|
|
|
70202
70208
|
};
|
|
70203
70209
|
}
|
|
70204
70210
|
},
|
|
70211
|
+
authorImage: {
|
|
70212
|
+
default: "",
|
|
70213
|
+
parseDOM: (elem) => elem.getAttribute("data-authorimage"),
|
|
70214
|
+
renderDOM: (attrs) => {
|
|
70215
|
+
if (!attrs.authorImage) return {};
|
|
70216
|
+
return {
|
|
70217
|
+
"data-authorimage": attrs.authorImage
|
|
70218
|
+
};
|
|
70219
|
+
}
|
|
70220
|
+
},
|
|
70205
70221
|
date: {
|
|
70206
70222
|
default: "",
|
|
70207
70223
|
parseDOM: (elem) => elem.getAttribute("data-date"),
|
|
@@ -91855,86 +91871,86 @@ const additionalHandlers = Object.freeze({
|
|
|
91855
91871
|
"sd:pageReference": translator$5,
|
|
91856
91872
|
"sd:tableOfContents": translator$4,
|
|
91857
91873
|
"w:b": translator$1n,
|
|
91858
|
-
"w:bidiVisual": translator$
|
|
91874
|
+
"w:bidiVisual": translator$p,
|
|
91859
91875
|
"w:bookmarkEnd": translator$6,
|
|
91860
91876
|
"w:bookmarkStart": translator$7,
|
|
91861
|
-
"w:bottom": translator$
|
|
91877
|
+
"w:bottom": translator$15,
|
|
91862
91878
|
"w:br": translator$1r,
|
|
91863
|
-
"w:cantSplit": translator$
|
|
91864
|
-
"w:cnfStyle": translator$
|
|
91879
|
+
"w:cantSplit": translator$G,
|
|
91880
|
+
"w:cnfStyle": translator$1a,
|
|
91865
91881
|
"w:color": translator$1j,
|
|
91866
|
-
"w:divId": translator$
|
|
91867
|
-
"w:drawing": translator$
|
|
91868
|
-
"w:end": translator$
|
|
91869
|
-
"w:gridAfter": translator$
|
|
91870
|
-
"w:gridBefore": translator$
|
|
91871
|
-
"w:gridCol": translator$
|
|
91872
|
-
"w:hidden": translator$
|
|
91882
|
+
"w:divId": translator$F,
|
|
91883
|
+
"w:drawing": translator$r,
|
|
91884
|
+
"w:end": translator$13,
|
|
91885
|
+
"w:gridAfter": translator$E,
|
|
91886
|
+
"w:gridBefore": translator$D,
|
|
91887
|
+
"w:gridCol": translator$a,
|
|
91888
|
+
"w:hidden": translator$C,
|
|
91873
91889
|
"w:highlight": translator$1q,
|
|
91874
91890
|
"w:hyperlink": translator$1c,
|
|
91875
91891
|
"w:i": translator$1m,
|
|
91876
|
-
"w:insideH": translator$
|
|
91877
|
-
"w:insideV": translator$
|
|
91878
|
-
"w:jc": translator$
|
|
91879
|
-
"w:left": translator
|
|
91892
|
+
"w:insideH": translator$11,
|
|
91893
|
+
"w:insideV": translator$10,
|
|
91894
|
+
"w:jc": translator$B,
|
|
91895
|
+
"w:left": translator$$,
|
|
91880
91896
|
"w:p": translator$1o,
|
|
91881
91897
|
"w:r": translator$1b,
|
|
91882
91898
|
"w:rFonts": translator$1i,
|
|
91883
91899
|
"w:rPr": translator$1d,
|
|
91884
91900
|
"w:rStyle": translator$1h,
|
|
91885
|
-
"w:right": translator$
|
|
91886
|
-
"w:sdt": translator$
|
|
91887
|
-
"w:shd": translator$
|
|
91888
|
-
"w:start": translator$
|
|
91901
|
+
"w:right": translator$Z,
|
|
91902
|
+
"w:sdt": translator$q,
|
|
91903
|
+
"w:shd": translator$19,
|
|
91904
|
+
"w:start": translator$X,
|
|
91889
91905
|
"w:strike": translator$1k,
|
|
91890
91906
|
"w:sz": translator$1g,
|
|
91891
91907
|
"w:szCs": translator$1f,
|
|
91892
91908
|
"w:tab": translator$1p,
|
|
91893
|
-
"w:tbl": translator$
|
|
91894
|
-
"w:tblBorders": translator$
|
|
91895
|
-
"w:tblCaption": translator$
|
|
91896
|
-
"w:tblCellMar": translator$
|
|
91897
|
-
"w:tblCellSpacing": translator$
|
|
91898
|
-
"w:tblDescription": translator$
|
|
91899
|
-
"w:tblGrid": translator$
|
|
91900
|
-
"w:tblHeader": translator$
|
|
91901
|
-
"w:tblInd": translator$
|
|
91902
|
-
"w:tblLayout": translator$
|
|
91903
|
-
"w:tblLook": translator$
|
|
91904
|
-
"w:tblOverlap": translator$
|
|
91905
|
-
"w:tblPr": translator$
|
|
91906
|
-
"w:tblStyle": translator$
|
|
91907
|
-
"w:tblStyleColBandSize": translator$
|
|
91908
|
-
"w:tblStyleRowBandSize": translator$
|
|
91909
|
-
"w:tblW": translator$
|
|
91910
|
-
"w:tblpPr": translator$
|
|
91911
|
-
"w:tc": translator$
|
|
91912
|
-
"w:top": translator$
|
|
91913
|
-
"w:tr": translator$
|
|
91914
|
-
"w:trHeight": translator$
|
|
91915
|
-
"w:trPr": translator$
|
|
91909
|
+
"w:tbl": translator$8,
|
|
91910
|
+
"w:tblBorders": translator$d,
|
|
91911
|
+
"w:tblCaption": translator$o,
|
|
91912
|
+
"w:tblCellMar": translator$c,
|
|
91913
|
+
"w:tblCellSpacing": translator$A,
|
|
91914
|
+
"w:tblDescription": translator$n,
|
|
91915
|
+
"w:tblGrid": translator$9,
|
|
91916
|
+
"w:tblHeader": translator$z,
|
|
91917
|
+
"w:tblInd": translator$m,
|
|
91918
|
+
"w:tblLayout": translator$l,
|
|
91919
|
+
"w:tblLook": translator$k,
|
|
91920
|
+
"w:tblOverlap": translator$j,
|
|
91921
|
+
"w:tblPr": translator$b,
|
|
91922
|
+
"w:tblStyle": translator$i,
|
|
91923
|
+
"w:tblStyleColBandSize": translator$h,
|
|
91924
|
+
"w:tblStyleRowBandSize": translator$g,
|
|
91925
|
+
"w:tblW": translator$f,
|
|
91926
|
+
"w:tblpPr": translator$e,
|
|
91927
|
+
"w:tc": translator$H,
|
|
91928
|
+
"w:top": translator$V,
|
|
91929
|
+
"w:tr": translator$u,
|
|
91930
|
+
"w:trHeight": translator$y,
|
|
91931
|
+
"w:trPr": translator$v,
|
|
91916
91932
|
"w:u": translator$1l,
|
|
91917
|
-
"w:wAfter": translator$
|
|
91918
|
-
"w:wBefore": translator
|
|
91919
|
-
"wp:anchor": translator$
|
|
91920
|
-
"wp:inline": translator$
|
|
91933
|
+
"w:wAfter": translator$x,
|
|
91934
|
+
"w:wBefore": translator$w,
|
|
91935
|
+
"wp:anchor": translator$t,
|
|
91936
|
+
"wp:inline": translator$s,
|
|
91921
91937
|
"w:commentRangeStart": commentRangeStartTranslator,
|
|
91922
91938
|
"w:commentRangeEnd": commentRangeEndTranslator,
|
|
91923
|
-
"w:vMerge": translator$
|
|
91924
|
-
"w:gridSpan": translator$
|
|
91925
|
-
"w:vAlign": translator$
|
|
91926
|
-
"w:noWrap": translator$
|
|
91927
|
-
"w:tcFitText": translator$
|
|
91928
|
-
"w:tcW": translator$
|
|
91929
|
-
"w:hideMark": translator$
|
|
91930
|
-
"w:textDirection": translator$
|
|
91931
|
-
"w:tl2br": translator$
|
|
91932
|
-
"w:tr2bl": translator$
|
|
91933
|
-
"w:header": translator$
|
|
91934
|
-
"w:headers": translator$
|
|
91935
|
-
"w:tcBorders": translator$
|
|
91936
|
-
"w:tcMar": translator$
|
|
91937
|
-
"w:tcPr": translator$
|
|
91939
|
+
"w:vMerge": translator$16,
|
|
91940
|
+
"w:gridSpan": translator$17,
|
|
91941
|
+
"w:vAlign": translator$M,
|
|
91942
|
+
"w:noWrap": translator$Q,
|
|
91943
|
+
"w:tcFitText": translator$N,
|
|
91944
|
+
"w:tcW": translator$18,
|
|
91945
|
+
"w:hideMark": translator$L,
|
|
91946
|
+
"w:textDirection": translator$O,
|
|
91947
|
+
"w:tl2br": translator$T,
|
|
91948
|
+
"w:tr2bl": translator$S,
|
|
91949
|
+
"w:header": translator$K,
|
|
91950
|
+
"w:headers": translator$J,
|
|
91951
|
+
"w:tcBorders": translator$R,
|
|
91952
|
+
"w:tcMar": translator$P,
|
|
91953
|
+
"w:tcPr": translator$I
|
|
91938
91954
|
});
|
|
91939
91955
|
const baseHandlers = {
|
|
91940
91956
|
...runPropertyTranslators,
|