@harbour-enterprises/superdoc 0.24.0-next.4 → 0.24.0-next.6
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-D7C8g2G4.es.js → PdfViewer-BiHh3x6b.es.js} +1 -1
- package/dist/chunks/{PdfViewer-kOVuv-4I.cjs → PdfViewer-qk_hITc5.cjs} +1 -1
- package/dist/chunks/{index-BFKwBQjS.cjs → index-Di6nG2sc.cjs} +66 -10
- package/dist/chunks/{index-CnEAVnHQ.es.js → index-aMnFs35I.es.js} +66 -10
- package/dist/chunks/{super-editor.es-BmGTQ05x.cjs → super-editor.es-BKZvTraR.cjs} +579 -137
- package/dist/chunks/{super-editor.es-CBPoWvjs.es.js → super-editor.es-Dz7y81Yr.es.js} +579 -137
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/core/helpers/export.d.ts +1 -1
- package/dist/core/helpers/export.d.ts.map +1 -1
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/style.css +10 -0
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-DpPj67OW.js → converter-CI3WqmGV.js} +514 -197
- package/dist/super-editor/chunks/{docx-zipper-6Kc95yG-.js → docx-zipper-D4fk50d9.js} +1 -1
- package/dist/super-editor/chunks/{editor-Dx6AhT5N.js → editor-DC6pZVp1.js} +170 -43
- package/dist/super-editor/chunks/{toolbar-CXSg2lJ9.js → toolbar-DMobfM6u.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/style.css +10 -0
- package/dist/super-editor/super-editor/src/core/super-converter/helpers.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tr/tr-helpers.d.ts +16 -0
- package/dist/super-editor/super-editor/src/extensions/table/TableView.d.ts +1 -1
- package/dist/super-editor/super-editor.es.js +7 -7
- 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 +643 -145
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/superdoc.umd.js
CHANGED
|
@@ -22818,6 +22818,7 @@
|
|
|
22818
22818
|
}
|
|
22819
22819
|
return content;
|
|
22820
22820
|
}
|
|
22821
|
+
const PIXELS_PER_INCH = 96;
|
|
22821
22822
|
function inchesToTwips(inches) {
|
|
22822
22823
|
if (inches == null) return;
|
|
22823
22824
|
if (typeof inches === "string") inches = parseFloat(inches);
|
|
@@ -22840,12 +22841,12 @@
|
|
|
22840
22841
|
}
|
|
22841
22842
|
function inchesToPixels(inches) {
|
|
22842
22843
|
if (inches == null) return;
|
|
22843
|
-
const pixels = inches *
|
|
22844
|
+
const pixels = inches * PIXELS_PER_INCH;
|
|
22844
22845
|
return Math.round(pixels * 1e3) / 1e3;
|
|
22845
22846
|
}
|
|
22846
22847
|
function pixelsToInches(pixels) {
|
|
22847
22848
|
if (pixels == null) return;
|
|
22848
|
-
const inches = Number(pixels) /
|
|
22849
|
+
const inches = Number(pixels) / PIXELS_PER_INCH;
|
|
22849
22850
|
return inches;
|
|
22850
22851
|
}
|
|
22851
22852
|
function twipsToLines(twips) {
|
|
@@ -22863,7 +22864,7 @@
|
|
|
22863
22864
|
function emuToPixels(emu) {
|
|
22864
22865
|
if (emu == null) return;
|
|
22865
22866
|
if (typeof emu === "string") emu = parseFloat(emu);
|
|
22866
|
-
const pixels = emu *
|
|
22867
|
+
const pixels = emu * PIXELS_PER_INCH / 914400;
|
|
22867
22868
|
return Math.round(pixels);
|
|
22868
22869
|
}
|
|
22869
22870
|
function pixelsToEmu(px) {
|
|
@@ -22899,12 +22900,12 @@
|
|
|
22899
22900
|
}
|
|
22900
22901
|
function pixelsToPolygonUnits(pixels) {
|
|
22901
22902
|
if (pixels == null) return;
|
|
22902
|
-
const pu = pixels *
|
|
22903
|
+
const pu = pixels * PIXELS_PER_INCH;
|
|
22903
22904
|
return Math.round(pu);
|
|
22904
22905
|
}
|
|
22905
22906
|
function polygonUnitsToPixels(pu) {
|
|
22906
22907
|
if (pu == null) return;
|
|
22907
|
-
const pixels = Number(pu) /
|
|
22908
|
+
const pixels = Number(pu) / PIXELS_PER_INCH;
|
|
22908
22909
|
return Math.round(pixels * 1e3) / 1e3;
|
|
22909
22910
|
}
|
|
22910
22911
|
function polygonToObj(polygonNode) {
|
|
@@ -34780,6 +34781,68 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34780
34781
|
repeatHeader: false
|
|
34781
34782
|
})
|
|
34782
34783
|
);
|
|
34784
|
+
const createPlaceholderCell = (gridWidth, reason) => {
|
|
34785
|
+
const safeWidth = Number.isFinite(gridWidth) ? gridWidth : 0;
|
|
34786
|
+
const noBorder = { val: "none", size: 0 };
|
|
34787
|
+
return {
|
|
34788
|
+
type: "tableCell",
|
|
34789
|
+
attrs: {
|
|
34790
|
+
colspan: 1,
|
|
34791
|
+
rowspan: 1,
|
|
34792
|
+
colwidth: [safeWidth],
|
|
34793
|
+
__placeholder: reason,
|
|
34794
|
+
borders: {
|
|
34795
|
+
top: { ...noBorder },
|
|
34796
|
+
right: { ...noBorder },
|
|
34797
|
+
bottom: { ...noBorder },
|
|
34798
|
+
left: { ...noBorder }
|
|
34799
|
+
}
|
|
34800
|
+
},
|
|
34801
|
+
content: [{ type: "paragraph", content: [] }]
|
|
34802
|
+
};
|
|
34803
|
+
};
|
|
34804
|
+
const advancePastRowSpans = (pendingRowSpans, startIndex, totalColumns) => {
|
|
34805
|
+
let index2 = startIndex;
|
|
34806
|
+
while (index2 < totalColumns && pendingRowSpans[index2] > 0) {
|
|
34807
|
+
pendingRowSpans[index2] -= 1;
|
|
34808
|
+
index2 += 1;
|
|
34809
|
+
}
|
|
34810
|
+
return index2;
|
|
34811
|
+
};
|
|
34812
|
+
const fillPlaceholderColumns = ({
|
|
34813
|
+
content,
|
|
34814
|
+
pendingRowSpans,
|
|
34815
|
+
currentIndex,
|
|
34816
|
+
targetIndex,
|
|
34817
|
+
totalColumns,
|
|
34818
|
+
gridColumnWidths,
|
|
34819
|
+
reason
|
|
34820
|
+
}) => {
|
|
34821
|
+
let index2 = currentIndex;
|
|
34822
|
+
while (index2 < targetIndex && index2 < totalColumns) {
|
|
34823
|
+
if (pendingRowSpans[index2] > 0) {
|
|
34824
|
+
pendingRowSpans[index2] -= 1;
|
|
34825
|
+
index2 += 1;
|
|
34826
|
+
continue;
|
|
34827
|
+
}
|
|
34828
|
+
const width = Array.isArray(gridColumnWidths) ? gridColumnWidths[index2] ?? 0 : 0;
|
|
34829
|
+
content.push(createPlaceholderCell(width, reason));
|
|
34830
|
+
index2 += 1;
|
|
34831
|
+
}
|
|
34832
|
+
return index2;
|
|
34833
|
+
};
|
|
34834
|
+
const isPlaceholderCell = (cell) => {
|
|
34835
|
+
if (!cell) return false;
|
|
34836
|
+
if (cell.attrs?.__placeholder) return true;
|
|
34837
|
+
const widths = cell.attrs?.colwidth;
|
|
34838
|
+
if (Array.isArray(widths) && widths.length > 0) {
|
|
34839
|
+
const hasMeaningfulWidth = widths.some(
|
|
34840
|
+
(value) => typeof value === "number" && Number.isFinite(value) && Math.abs(value) > 1
|
|
34841
|
+
);
|
|
34842
|
+
if (!hasMeaningfulWidth) return true;
|
|
34843
|
+
}
|
|
34844
|
+
return false;
|
|
34845
|
+
};
|
|
34783
34846
|
const XML_NODE_NAME$h = "w:tr";
|
|
34784
34847
|
const SD_NODE_NAME$d = "tableRow";
|
|
34785
34848
|
const validXmlAttributes$b = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
|
|
@@ -34795,29 +34858,64 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34795
34858
|
nodes: [tPr]
|
|
34796
34859
|
});
|
|
34797
34860
|
}
|
|
34861
|
+
const gridBeforeRaw = tableRowProperties?.["gridBefore"];
|
|
34862
|
+
const safeGridBefore = typeof gridBeforeRaw === "number" && Number.isFinite(gridBeforeRaw) && gridBeforeRaw > 0 ? gridBeforeRaw : 0;
|
|
34798
34863
|
encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
|
|
34799
34864
|
encodedAttrs["rowHeight"] = twipsToPixels(tableRowProperties["rowHeight"]?.value);
|
|
34800
34865
|
encodedAttrs["cantSplit"] = tableRowProperties["cantSplit"];
|
|
34801
|
-
const { columnWidths: gridColumnWidths } = params2.extraParams;
|
|
34866
|
+
const { columnWidths: gridColumnWidths, activeRowSpans = [] } = params2.extraParams;
|
|
34867
|
+
const totalColumns = Array.isArray(gridColumnWidths) ? gridColumnWidths.length : 0;
|
|
34868
|
+
const pendingRowSpans = Array.isArray(activeRowSpans) ? activeRowSpans.slice() : [];
|
|
34869
|
+
while (pendingRowSpans.length < totalColumns) pendingRowSpans.push(0);
|
|
34802
34870
|
const cellNodes = row.elements.filter((el) => el.name === "w:tc");
|
|
34871
|
+
const content = [];
|
|
34803
34872
|
let currentColumnIndex = 0;
|
|
34804
|
-
const
|
|
34805
|
-
|
|
34873
|
+
const fillUntil = (target, reason) => {
|
|
34874
|
+
currentColumnIndex = fillPlaceholderColumns({
|
|
34875
|
+
content,
|
|
34876
|
+
pendingRowSpans,
|
|
34877
|
+
currentIndex: currentColumnIndex,
|
|
34878
|
+
targetIndex: target,
|
|
34879
|
+
totalColumns,
|
|
34880
|
+
gridColumnWidths,
|
|
34881
|
+
reason
|
|
34882
|
+
});
|
|
34883
|
+
};
|
|
34884
|
+
const skipOccupiedColumns = () => {
|
|
34885
|
+
currentColumnIndex = advancePastRowSpans(pendingRowSpans, currentColumnIndex, totalColumns);
|
|
34886
|
+
};
|
|
34887
|
+
fillUntil(safeGridBefore, "gridBefore");
|
|
34888
|
+
skipOccupiedColumns();
|
|
34889
|
+
cellNodes?.forEach((node) => {
|
|
34890
|
+
skipOccupiedColumns();
|
|
34891
|
+
const startColumn = currentColumnIndex;
|
|
34892
|
+
const columnWidth = gridColumnWidths?.[startColumn] || null;
|
|
34806
34893
|
const result = translator$c.encode({
|
|
34807
34894
|
...params2,
|
|
34808
34895
|
extraParams: {
|
|
34809
34896
|
...params2.extraParams,
|
|
34810
|
-
node
|
|
34811
|
-
columnIndex:
|
|
34897
|
+
node,
|
|
34898
|
+
columnIndex: startColumn,
|
|
34812
34899
|
columnWidth
|
|
34813
34900
|
}
|
|
34814
34901
|
});
|
|
34815
|
-
|
|
34816
|
-
|
|
34817
|
-
|
|
34818
|
-
|
|
34819
|
-
|
|
34820
|
-
|
|
34902
|
+
if (result) {
|
|
34903
|
+
content.push(result);
|
|
34904
|
+
const colspan = Math.max(1, result.attrs?.colspan || 1);
|
|
34905
|
+
const rowspan = Math.max(1, result.attrs?.rowspan || 1);
|
|
34906
|
+
if (rowspan > 1) {
|
|
34907
|
+
for (let offset2 = 0; offset2 < colspan; offset2 += 1) {
|
|
34908
|
+
const target = startColumn + offset2;
|
|
34909
|
+
if (target < pendingRowSpans.length) {
|
|
34910
|
+
pendingRowSpans[target] = Math.max(pendingRowSpans[target], rowspan - 1);
|
|
34911
|
+
}
|
|
34912
|
+
}
|
|
34913
|
+
}
|
|
34914
|
+
currentColumnIndex = startColumn + colspan;
|
|
34915
|
+
}
|
|
34916
|
+
});
|
|
34917
|
+
skipOccupiedColumns();
|
|
34918
|
+
fillUntil(totalColumns, "gridAfter");
|
|
34821
34919
|
const newNode = {
|
|
34822
34920
|
type: "tableRow",
|
|
34823
34921
|
content,
|
|
@@ -34827,9 +34925,37 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34827
34925
|
};
|
|
34828
34926
|
const decode$p = (params2, decodedAttrs) => {
|
|
34829
34927
|
const { node } = params2;
|
|
34830
|
-
const
|
|
34928
|
+
const cells = node.content || [];
|
|
34929
|
+
let leadingPlaceholders = 0;
|
|
34930
|
+
while (leadingPlaceholders < cells.length && isPlaceholderCell(cells[leadingPlaceholders])) {
|
|
34931
|
+
leadingPlaceholders += 1;
|
|
34932
|
+
}
|
|
34933
|
+
let trailingPlaceholders = 0;
|
|
34934
|
+
while (trailingPlaceholders < cells.length - leadingPlaceholders && isPlaceholderCell(cells[cells.length - 1 - trailingPlaceholders])) {
|
|
34935
|
+
trailingPlaceholders += 1;
|
|
34936
|
+
}
|
|
34937
|
+
const trimmedSlice = cells.slice(leadingPlaceholders, cells.length - trailingPlaceholders);
|
|
34938
|
+
const sanitizedCells = trimmedSlice.map((cell) => {
|
|
34939
|
+
if (cell?.attrs && "__placeholder" in cell.attrs) {
|
|
34940
|
+
const { __placeholder, ...rest } = cell.attrs;
|
|
34941
|
+
return { ...cell, attrs: rest };
|
|
34942
|
+
}
|
|
34943
|
+
return cell;
|
|
34944
|
+
});
|
|
34945
|
+
const trimmedContent = sanitizedCells.filter((_2, index2) => !isPlaceholderCell(trimmedSlice[index2]));
|
|
34946
|
+
const translateParams = {
|
|
34947
|
+
...params2,
|
|
34948
|
+
node: { ...node, content: trimmedContent }
|
|
34949
|
+
};
|
|
34950
|
+
const elements = translateChildNodes(translateParams);
|
|
34831
34951
|
if (node.attrs?.tableRowProperties) {
|
|
34832
34952
|
const tableRowProperties = { ...node.attrs.tableRowProperties };
|
|
34953
|
+
if (leadingPlaceholders > 0) {
|
|
34954
|
+
tableRowProperties.gridBefore = leadingPlaceholders;
|
|
34955
|
+
}
|
|
34956
|
+
if (trailingPlaceholders > 0) {
|
|
34957
|
+
tableRowProperties.gridAfter = trailingPlaceholders;
|
|
34958
|
+
}
|
|
34833
34959
|
if (node.attrs.rowHeight != null) {
|
|
34834
34960
|
const rowHeightPixels = twipsToPixels(node.attrs.tableRowProperties["rowHeight"]?.value);
|
|
34835
34961
|
if (rowHeightPixels !== node.attrs.rowHeight) {
|
|
@@ -35059,17 +35185,21 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35059
35185
|
const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params2, totalColumns, cellMinWidth);
|
|
35060
35186
|
const elements = [];
|
|
35061
35187
|
let columnIndex = 0;
|
|
35062
|
-
const pushColumn = (widthTwips) => {
|
|
35188
|
+
const pushColumn = (widthTwips, { enforceMinimum = false } = {}) => {
|
|
35063
35189
|
let numericWidth = typeof widthTwips === "string" ? parseInt(widthTwips, 10) : widthTwips;
|
|
35190
|
+
let shouldEnforceMinimum = enforceMinimum;
|
|
35064
35191
|
if (numericWidth == null || Number.isNaN(numericWidth) || numericWidth <= 0) {
|
|
35065
35192
|
numericWidth = fallbackColumnWidthTwips;
|
|
35193
|
+
shouldEnforceMinimum = true;
|
|
35066
35194
|
}
|
|
35067
|
-
|
|
35195
|
+
const roundedWidth = Math.round(numericWidth);
|
|
35196
|
+
const minimumWidth = shouldEnforceMinimum ? cellMinWidth : 1;
|
|
35197
|
+
const safeWidth = Math.max(roundedWidth, minimumWidth);
|
|
35068
35198
|
const decoded = translator$u.decode({
|
|
35069
35199
|
node: { type: (
|
|
35070
35200
|
/** @type {string} */
|
|
35071
35201
|
translator$u.sdNodeOrKeyName
|
|
35072
|
-
), attrs: { col:
|
|
35202
|
+
), attrs: { col: safeWidth } }
|
|
35073
35203
|
});
|
|
35074
35204
|
if (decoded) elements.push(decoded);
|
|
35075
35205
|
};
|
|
@@ -35077,13 +35207,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35077
35207
|
const { colspan = 1, colwidth } = cell?.attrs || {};
|
|
35078
35208
|
const spanCount = Math.max(1, colspan);
|
|
35079
35209
|
for (let span = 0; span < spanCount; span++) {
|
|
35080
|
-
const
|
|
35210
|
+
const rawWidth = Array.isArray(colwidth) ? colwidth[span] : void 0;
|
|
35211
|
+
const cellWidthPixels = typeof rawWidth === "number" && Number.isFinite(rawWidth) ? rawWidth : Number(rawWidth);
|
|
35212
|
+
const hasCellWidth = Number.isFinite(cellWidthPixels) && cellWidthPixels > 0;
|
|
35081
35213
|
const colGridAttrs = grid?.[columnIndex] || {};
|
|
35082
35214
|
const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
|
|
35083
35215
|
const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
|
|
35084
35216
|
let cellWidthTwips;
|
|
35085
|
-
|
|
35086
|
-
|
|
35217
|
+
let enforceMinimum = false;
|
|
35218
|
+
if (hasCellWidth) {
|
|
35219
|
+
const tolerance = 0.5;
|
|
35220
|
+
if (gridWidthTwips != null && gridWidthPixels != null && Math.abs(gridWidthPixels - cellWidthPixels) <= tolerance) {
|
|
35087
35221
|
cellWidthTwips = gridWidthTwips;
|
|
35088
35222
|
} else {
|
|
35089
35223
|
cellWidthTwips = pixelsToTwips(cellWidthPixels);
|
|
@@ -35092,8 +35226,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35092
35226
|
cellWidthTwips = gridWidthTwips;
|
|
35093
35227
|
} else {
|
|
35094
35228
|
cellWidthTwips = fallbackColumnWidthTwips;
|
|
35229
|
+
enforceMinimum = true;
|
|
35095
35230
|
}
|
|
35096
|
-
pushColumn(cellWidthTwips);
|
|
35231
|
+
pushColumn(cellWidthTwips, { enforceMinimum });
|
|
35097
35232
|
columnIndex++;
|
|
35098
35233
|
}
|
|
35099
35234
|
});
|
|
@@ -35256,7 +35391,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35256
35391
|
}
|
|
35257
35392
|
}
|
|
35258
35393
|
const content = [];
|
|
35259
|
-
|
|
35394
|
+
const totalColumns = columnWidths.length;
|
|
35395
|
+
const activeRowSpans = totalColumns > 0 ? new Array(totalColumns).fill(0) : [];
|
|
35396
|
+
rows.forEach((row, rowIndex) => {
|
|
35260
35397
|
const result = translator$Z.encode({
|
|
35261
35398
|
...params2,
|
|
35262
35399
|
nodes: [row],
|
|
@@ -35265,10 +35402,45 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35265
35402
|
table: node,
|
|
35266
35403
|
rowBorders: borderRowData,
|
|
35267
35404
|
styleTag: tblStyleTag,
|
|
35268
|
-
columnWidths
|
|
35405
|
+
columnWidths,
|
|
35406
|
+
activeRowSpans: activeRowSpans.slice(),
|
|
35407
|
+
rowIndex
|
|
35269
35408
|
}
|
|
35270
35409
|
});
|
|
35271
|
-
if (result)
|
|
35410
|
+
if (result) {
|
|
35411
|
+
content.push(result);
|
|
35412
|
+
if (totalColumns > 0) {
|
|
35413
|
+
const activeRowSpansForCurrentRow = activeRowSpans.slice();
|
|
35414
|
+
for (let col = 0; col < totalColumns; col++) {
|
|
35415
|
+
if (activeRowSpans[col] > 0) {
|
|
35416
|
+
activeRowSpans[col] -= 1;
|
|
35417
|
+
}
|
|
35418
|
+
}
|
|
35419
|
+
let columnIndex = 0;
|
|
35420
|
+
const advanceColumnIndex = () => {
|
|
35421
|
+
while (columnIndex < totalColumns && activeRowSpansForCurrentRow[columnIndex] > 0) {
|
|
35422
|
+
columnIndex += 1;
|
|
35423
|
+
}
|
|
35424
|
+
};
|
|
35425
|
+
advanceColumnIndex();
|
|
35426
|
+
result.content?.forEach((cell) => {
|
|
35427
|
+
advanceColumnIndex();
|
|
35428
|
+
const colspan = Math.max(1, cell.attrs?.colspan || 1);
|
|
35429
|
+
const rowspan = Math.max(1, cell.attrs?.rowspan || 1);
|
|
35430
|
+
if (rowspan > 1) {
|
|
35431
|
+
for (let offset2 = 0; offset2 < colspan && columnIndex + offset2 < totalColumns; offset2++) {
|
|
35432
|
+
const targetIndex = columnIndex + offset2;
|
|
35433
|
+
const remainingRows = rowspan - 1;
|
|
35434
|
+
if (remainingRows > 0 && remainingRows > activeRowSpans[targetIndex]) {
|
|
35435
|
+
activeRowSpans[targetIndex] = remainingRows;
|
|
35436
|
+
}
|
|
35437
|
+
}
|
|
35438
|
+
}
|
|
35439
|
+
columnIndex += colspan;
|
|
35440
|
+
advanceColumnIndex();
|
|
35441
|
+
});
|
|
35442
|
+
}
|
|
35443
|
+
}
|
|
35272
35444
|
});
|
|
35273
35445
|
return {
|
|
35274
35446
|
type: "table",
|
|
@@ -35673,14 +35845,104 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35673
35845
|
}
|
|
35674
35846
|
return {
|
|
35675
35847
|
type: "tableCell",
|
|
35676
|
-
content:
|
|
35677
|
-
|
|
35678
|
-
|
|
35679
|
-
|
|
35680
|
-
|
|
35848
|
+
content: normalizeTableCellContent(
|
|
35849
|
+
nodeListHandler.handler({
|
|
35850
|
+
...params2,
|
|
35851
|
+
nodes: node.elements,
|
|
35852
|
+
path: [...params2.path || [], node]
|
|
35853
|
+
}),
|
|
35854
|
+
params2.editor
|
|
35855
|
+
),
|
|
35681
35856
|
attrs: attributes
|
|
35682
35857
|
};
|
|
35683
35858
|
}
|
|
35859
|
+
function normalizeTableCellContent(content, editor) {
|
|
35860
|
+
if (!Array.isArray(content) || content.length === 0) return content;
|
|
35861
|
+
const normalized = [];
|
|
35862
|
+
const pendingForNextBlock = [];
|
|
35863
|
+
const schema = editor?.schema;
|
|
35864
|
+
const cloneBlock = (node) => {
|
|
35865
|
+
if (!node) return node;
|
|
35866
|
+
const cloned = { ...node };
|
|
35867
|
+
if (Array.isArray(node.content)) {
|
|
35868
|
+
cloned.content = [...node.content];
|
|
35869
|
+
}
|
|
35870
|
+
return cloned;
|
|
35871
|
+
};
|
|
35872
|
+
const ensureArray = (node) => {
|
|
35873
|
+
if (!Array.isArray(node.content)) {
|
|
35874
|
+
node.content = [];
|
|
35875
|
+
}
|
|
35876
|
+
return node.content;
|
|
35877
|
+
};
|
|
35878
|
+
const isInlineNode = (node) => {
|
|
35879
|
+
if (!node || typeof node.type !== "string") return false;
|
|
35880
|
+
if (node.type === "text") return true;
|
|
35881
|
+
if (node.type === "bookmarkStart" || node.type === "bookmarkEnd") return true;
|
|
35882
|
+
const nodeType = schema?.nodes?.[node.type];
|
|
35883
|
+
if (nodeType) {
|
|
35884
|
+
if (typeof nodeType.isInline === "boolean") return nodeType.isInline;
|
|
35885
|
+
if (nodeType.spec?.group && typeof nodeType.spec.group === "string") {
|
|
35886
|
+
return nodeType.spec.group.split(" ").includes("inline");
|
|
35887
|
+
}
|
|
35888
|
+
}
|
|
35889
|
+
return false;
|
|
35890
|
+
};
|
|
35891
|
+
for (const node of content) {
|
|
35892
|
+
if (!node || typeof node.type !== "string") {
|
|
35893
|
+
normalized.push(node);
|
|
35894
|
+
continue;
|
|
35895
|
+
}
|
|
35896
|
+
if (!isInlineNode(node)) {
|
|
35897
|
+
const blockNode = cloneBlock(node);
|
|
35898
|
+
if (pendingForNextBlock.length) {
|
|
35899
|
+
const blockContent = ensureArray(blockNode);
|
|
35900
|
+
const leadingInline = pendingForNextBlock.splice(0);
|
|
35901
|
+
blockNode.content = [...leadingInline, ...blockContent];
|
|
35902
|
+
} else if (Array.isArray(blockNode.content)) {
|
|
35903
|
+
blockNode.content = [...blockNode.content];
|
|
35904
|
+
}
|
|
35905
|
+
normalized.push(blockNode);
|
|
35906
|
+
continue;
|
|
35907
|
+
}
|
|
35908
|
+
const targetIsNextBlock = node.type === "bookmarkStart" || normalized.length === 0;
|
|
35909
|
+
if (targetIsNextBlock) {
|
|
35910
|
+
pendingForNextBlock.push(node);
|
|
35911
|
+
} else {
|
|
35912
|
+
const lastIndex = normalized.length - 1;
|
|
35913
|
+
const lastNode = normalized[lastIndex];
|
|
35914
|
+
if (!lastNode || typeof lastNode.type !== "string" || isInlineNode(lastNode)) {
|
|
35915
|
+
pendingForNextBlock.push(node);
|
|
35916
|
+
continue;
|
|
35917
|
+
}
|
|
35918
|
+
const blockContent = ensureArray(lastNode);
|
|
35919
|
+
if (pendingForNextBlock.length) {
|
|
35920
|
+
blockContent.push(...pendingForNextBlock.splice(0));
|
|
35921
|
+
}
|
|
35922
|
+
blockContent.push(node);
|
|
35923
|
+
}
|
|
35924
|
+
}
|
|
35925
|
+
if (pendingForNextBlock.length) {
|
|
35926
|
+
if (normalized.length) {
|
|
35927
|
+
const lastIndex = normalized.length - 1;
|
|
35928
|
+
const lastNode = normalized[lastIndex];
|
|
35929
|
+
if (lastNode && typeof lastNode.type === "string" && !isInlineNode(lastNode)) {
|
|
35930
|
+
const blockContent = ensureArray(lastNode);
|
|
35931
|
+
blockContent.push(...pendingForNextBlock);
|
|
35932
|
+
pendingForNextBlock.length = 0;
|
|
35933
|
+
}
|
|
35934
|
+
}
|
|
35935
|
+
if (pendingForNextBlock.length) {
|
|
35936
|
+
normalized.push({
|
|
35937
|
+
type: "paragraph",
|
|
35938
|
+
attrs: {},
|
|
35939
|
+
content: [...pendingForNextBlock]
|
|
35940
|
+
});
|
|
35941
|
+
pendingForNextBlock.length = 0;
|
|
35942
|
+
}
|
|
35943
|
+
}
|
|
35944
|
+
return normalized;
|
|
35945
|
+
}
|
|
35684
35946
|
const processInlineCellBorders = (borders, rowBorders) => {
|
|
35685
35947
|
if (!borders) return null;
|
|
35686
35948
|
return ["bottom", "top", "left", "right"].reduce((acc, direction) => {
|
|
@@ -36234,6 +36496,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36234
36496
|
}
|
|
36235
36497
|
return { type: "unknown", handler: null };
|
|
36236
36498
|
}
|
|
36499
|
+
const DRAWING_XML_TAG = "w:drawing";
|
|
36237
36500
|
function handleImageNode(node, params2, isAnchor) {
|
|
36238
36501
|
const { docx, filename } = params2;
|
|
36239
36502
|
const { attributes } = node;
|
|
@@ -36245,32 +36508,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36245
36508
|
};
|
|
36246
36509
|
const extent = node.elements.find((el) => el.name === "wp:extent");
|
|
36247
36510
|
const size2 = {
|
|
36248
|
-
width: emuToPixels(extent
|
|
36249
|
-
height: emuToPixels(extent
|
|
36511
|
+
width: emuToPixels(extent?.attributes?.cx),
|
|
36512
|
+
height: emuToPixels(extent?.attributes?.cy)
|
|
36250
36513
|
};
|
|
36251
|
-
const graphic = node.elements.find((el) => el.name === "a:graphic");
|
|
36252
|
-
const graphicData = graphic.elements.find((el) => el.name === "a:graphicData");
|
|
36253
|
-
const { uri: uri2 } = graphicData?.attributes || {};
|
|
36254
|
-
const shapeURI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
36255
|
-
if (!!uri2 && uri2 === shapeURI) {
|
|
36256
|
-
return handleShapeDrawing(params2, node, graphicData);
|
|
36257
|
-
}
|
|
36258
|
-
const picture = graphicData.elements.find((el) => el.name === "pic:pic");
|
|
36259
|
-
if (!picture || !picture.elements) return null;
|
|
36260
|
-
const blipFill = picture.elements.find((el) => el.name === "pic:blipFill");
|
|
36261
|
-
const blip = blipFill.elements.find((el) => el.name === "a:blip");
|
|
36262
|
-
const spPr = picture.elements.find((el) => el.name === "pic:spPr");
|
|
36263
36514
|
let transformData = {};
|
|
36264
|
-
if (spPr) {
|
|
36265
|
-
const xfrm = spPr.elements.find((el) => el.name === "a:xfrm");
|
|
36266
|
-
if (xfrm?.attributes) {
|
|
36267
|
-
transformData = {
|
|
36268
|
-
rotation: rotToDegrees(xfrm.attributes["rot"]),
|
|
36269
|
-
verticalFlip: xfrm.attributes["flipV"] === "1",
|
|
36270
|
-
horizontalFlip: xfrm.attributes["flipH"] === "1"
|
|
36271
|
-
};
|
|
36272
|
-
}
|
|
36273
|
-
}
|
|
36274
36515
|
const effectExtent = node.elements.find((el) => el.name === "wp:effectExtent");
|
|
36275
36516
|
if (effectExtent) {
|
|
36276
36517
|
const sanitizeEmuValue = (value) => {
|
|
@@ -36279,22 +36520,26 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36279
36520
|
return Number.isFinite(numeric) ? numeric : 0;
|
|
36280
36521
|
};
|
|
36281
36522
|
transformData.sizeExtension = {
|
|
36282
|
-
left: emuToPixels(sanitizeEmuValue(effectExtent.attributes["l"])),
|
|
36283
|
-
top: emuToPixels(sanitizeEmuValue(effectExtent.attributes["t"])),
|
|
36284
|
-
right: emuToPixels(sanitizeEmuValue(effectExtent.attributes["r"])),
|
|
36285
|
-
bottom: emuToPixels(sanitizeEmuValue(effectExtent.attributes["b"]))
|
|
36523
|
+
left: emuToPixels(sanitizeEmuValue(effectExtent.attributes?.["l"])),
|
|
36524
|
+
top: emuToPixels(sanitizeEmuValue(effectExtent.attributes?.["t"])),
|
|
36525
|
+
right: emuToPixels(sanitizeEmuValue(effectExtent.attributes?.["r"])),
|
|
36526
|
+
bottom: emuToPixels(sanitizeEmuValue(effectExtent.attributes?.["b"]))
|
|
36286
36527
|
};
|
|
36287
36528
|
}
|
|
36288
36529
|
const positionHTag = node.elements.find((el) => el.name === "wp:positionH");
|
|
36289
36530
|
const positionH = positionHTag?.elements.find((el) => el.name === "wp:posOffset");
|
|
36290
36531
|
const positionHValue = emuToPixels(positionH?.elements[0]?.text);
|
|
36291
|
-
const hRelativeFrom = positionHTag?.attributes
|
|
36292
|
-
const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
36532
|
+
const hRelativeFrom = positionHTag?.attributes?.relativeFrom;
|
|
36533
|
+
const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements?.[0]?.text;
|
|
36293
36534
|
const positionVTag = node.elements.find((el) => el.name === "wp:positionV");
|
|
36294
36535
|
const positionV = positionVTag?.elements?.find((el) => el.name === "wp:posOffset");
|
|
36295
36536
|
const positionVValue = emuToPixels(positionV?.elements[0]?.text);
|
|
36296
|
-
const vRelativeFrom = positionVTag?.attributes
|
|
36297
|
-
const alignV = positionVTag?.elements?.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
36537
|
+
const vRelativeFrom = positionVTag?.attributes?.relativeFrom;
|
|
36538
|
+
const alignV = positionVTag?.elements?.find((el) => el.name === "wp:align")?.elements?.[0]?.text;
|
|
36539
|
+
const marginOffset = {
|
|
36540
|
+
horizontal: positionHValue,
|
|
36541
|
+
top: positionVValue
|
|
36542
|
+
};
|
|
36298
36543
|
const simplePos = node.elements.find((el) => el.name === "wp:simplePos");
|
|
36299
36544
|
const wrapNode = isAnchor ? node.elements.find(
|
|
36300
36545
|
(el) => ["wp:wrapNone", "wp:wrapSquare", "wp:wrapThrough", "wp:wrapTight", "wp:wrapTopAndBottom"].includes(el.name)
|
|
@@ -36302,38 +36547,40 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36302
36547
|
const wrap2 = isAnchor ? { type: wrapNode?.name.slice(7) || "None", attrs: {} } : { type: "Inline" };
|
|
36303
36548
|
switch (wrap2.type) {
|
|
36304
36549
|
case "Square":
|
|
36305
|
-
|
|
36306
|
-
|
|
36550
|
+
if (wrapNode?.attributes?.wrapText) {
|
|
36551
|
+
wrap2.attrs.wrapText = wrapNode.attributes.wrapText;
|
|
36552
|
+
}
|
|
36553
|
+
if ("distB" in (wrapNode?.attributes || {})) {
|
|
36307
36554
|
wrap2.attrs.distBottom = emuToPixels(wrapNode.attributes.distB);
|
|
36308
36555
|
}
|
|
36309
|
-
if ("distL" in (wrapNode
|
|
36556
|
+
if ("distL" in (wrapNode?.attributes || {})) {
|
|
36310
36557
|
wrap2.attrs.distLeft = emuToPixels(wrapNode.attributes.distL);
|
|
36311
36558
|
}
|
|
36312
|
-
if ("distR" in (wrapNode
|
|
36559
|
+
if ("distR" in (wrapNode?.attributes || {})) {
|
|
36313
36560
|
wrap2.attrs.distRight = emuToPixels(wrapNode.attributes.distR);
|
|
36314
36561
|
}
|
|
36315
|
-
if ("distT" in (wrapNode
|
|
36562
|
+
if ("distT" in (wrapNode?.attributes || {})) {
|
|
36316
36563
|
wrap2.attrs.distTop = emuToPixels(wrapNode.attributes.distT);
|
|
36317
36564
|
}
|
|
36318
36565
|
break;
|
|
36319
36566
|
case "Tight":
|
|
36320
36567
|
case "Through": {
|
|
36321
|
-
if ("distL" in (wrapNode
|
|
36568
|
+
if ("distL" in (wrapNode?.attributes || {})) {
|
|
36322
36569
|
wrap2.attrs.distLeft = emuToPixels(wrapNode.attributes.distL);
|
|
36323
36570
|
}
|
|
36324
|
-
if ("distR" in (wrapNode
|
|
36571
|
+
if ("distR" in (wrapNode?.attributes || {})) {
|
|
36325
36572
|
wrap2.attrs.distRight = emuToPixels(wrapNode.attributes.distR);
|
|
36326
36573
|
}
|
|
36327
|
-
if ("distT" in (wrapNode
|
|
36574
|
+
if ("distT" in (wrapNode?.attributes || {})) {
|
|
36328
36575
|
wrap2.attrs.distTop = emuToPixels(wrapNode.attributes.distT);
|
|
36329
36576
|
}
|
|
36330
|
-
if ("distB" in (wrapNode
|
|
36577
|
+
if ("distB" in (wrapNode?.attributes || {})) {
|
|
36331
36578
|
wrap2.attrs.distBottom = emuToPixels(wrapNode.attributes.distB);
|
|
36332
36579
|
}
|
|
36333
|
-
if ("wrapText" in (wrapNode
|
|
36580
|
+
if ("wrapText" in (wrapNode?.attributes || {})) {
|
|
36334
36581
|
wrap2.attrs.wrapText = wrapNode.attributes.wrapText;
|
|
36335
36582
|
}
|
|
36336
|
-
const polygon = wrapNode
|
|
36583
|
+
const polygon = wrapNode?.elements?.find((el) => el.name === "wp:wrapPolygon");
|
|
36337
36584
|
if (polygon) {
|
|
36338
36585
|
wrap2.attrs.polygon = polygonToObj(polygon);
|
|
36339
36586
|
if (polygon.attributes?.edited !== void 0) {
|
|
@@ -36343,10 +36590,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36343
36590
|
break;
|
|
36344
36591
|
}
|
|
36345
36592
|
case "TopAndBottom":
|
|
36346
|
-
if ("distB" in (wrapNode
|
|
36593
|
+
if ("distB" in (wrapNode?.attributes || {})) {
|
|
36347
36594
|
wrap2.attrs.distBottom = emuToPixels(wrapNode.attributes.distB);
|
|
36348
36595
|
}
|
|
36349
|
-
if ("distT" in (wrapNode
|
|
36596
|
+
if ("distT" in (wrapNode?.attributes || {})) {
|
|
36350
36597
|
wrap2.attrs.distTop = emuToPixels(wrapNode.attributes.distT);
|
|
36351
36598
|
}
|
|
36352
36599
|
break;
|
|
@@ -36364,17 +36611,42 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36364
36611
|
alignV
|
|
36365
36612
|
};
|
|
36366
36613
|
}
|
|
36367
|
-
const
|
|
36368
|
-
|
|
36369
|
-
|
|
36370
|
-
|
|
36614
|
+
const graphic = node.elements.find((el) => el.name === "a:graphic");
|
|
36615
|
+
const graphicData = graphic?.elements.find((el) => el.name === "a:graphicData");
|
|
36616
|
+
const { uri: uri2 } = graphicData?.attributes || {};
|
|
36617
|
+
const shapeURI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
36618
|
+
if (!!uri2 && uri2 === shapeURI) {
|
|
36619
|
+
const shapeMarginOffset = {
|
|
36620
|
+
left: positionHValue,
|
|
36621
|
+
horizontal: positionHValue,
|
|
36622
|
+
top: positionVValue
|
|
36623
|
+
};
|
|
36624
|
+
return handleShapeDrawing(params2, node, graphicData, size2, padding, shapeMarginOffset);
|
|
36625
|
+
}
|
|
36626
|
+
const picture = graphicData?.elements.find((el) => el.name === "pic:pic");
|
|
36627
|
+
if (!picture || !picture.elements) return null;
|
|
36628
|
+
const blipFill = picture.elements.find((el) => el.name === "pic:blipFill");
|
|
36629
|
+
const blip = blipFill?.elements.find((el) => el.name === "a:blip");
|
|
36630
|
+
if (!blip) return null;
|
|
36631
|
+
const spPr = picture.elements.find((el) => el.name === "pic:spPr");
|
|
36632
|
+
if (spPr) {
|
|
36633
|
+
const xfrm = spPr.elements.find((el) => el.name === "a:xfrm");
|
|
36634
|
+
if (xfrm?.attributes) {
|
|
36635
|
+
transformData = {
|
|
36636
|
+
...transformData,
|
|
36637
|
+
rotation: rotToDegrees(xfrm.attributes["rot"]),
|
|
36638
|
+
verticalFlip: xfrm.attributes["flipV"] === "1",
|
|
36639
|
+
horizontalFlip: xfrm.attributes["flipH"] === "1"
|
|
36640
|
+
};
|
|
36641
|
+
}
|
|
36642
|
+
}
|
|
36371
36643
|
const { attributes: blipAttributes = {} } = blip;
|
|
36372
36644
|
const rEmbed = blipAttributes["r:embed"];
|
|
36373
36645
|
if (!rEmbed) return null;
|
|
36374
36646
|
const currentFile = filename || "document.xml";
|
|
36375
36647
|
let rels = docx[`word/_rels/${currentFile}.rels`];
|
|
36376
36648
|
if (!rels) rels = docx[`word/_rels/document.xml.rels`];
|
|
36377
|
-
const relationships = rels
|
|
36649
|
+
const relationships = rels?.elements.find((el) => el.name === "Relationships");
|
|
36378
36650
|
const { elements } = relationships || [];
|
|
36379
36651
|
const rel = elements?.find((el) => el.attributes["Id"] === rEmbed);
|
|
36380
36652
|
if (!rel) return null;
|
|
@@ -36387,10 +36659,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36387
36659
|
type: "image",
|
|
36388
36660
|
attrs: {
|
|
36389
36661
|
src: path,
|
|
36390
|
-
alt: ["emf", "wmf"].includes(extension) ? "Unable to render EMF/WMF image" : docPr?.attributes
|
|
36662
|
+
alt: ["emf", "wmf"].includes(extension) ? "Unable to render EMF/WMF image" : docPr?.attributes?.name || "Image",
|
|
36391
36663
|
extension,
|
|
36392
|
-
id: docPr?.attributes
|
|
36393
|
-
title: docPr?.attributes
|
|
36664
|
+
id: docPr?.attributes?.id || "",
|
|
36665
|
+
title: docPr?.attributes?.descr || "Image",
|
|
36394
36666
|
inline: true,
|
|
36395
36667
|
padding,
|
|
36396
36668
|
marginOffset,
|
|
@@ -36405,6 +36677,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36405
36677
|
}
|
|
36406
36678
|
},
|
|
36407
36679
|
wrap: wrap2,
|
|
36680
|
+
...wrap2.type === "Square" && wrap2.attrs.wrapText ? {
|
|
36681
|
+
wrapText: wrap2.attrs.wrapText
|
|
36682
|
+
} : {},
|
|
36683
|
+
wrapTopAndBottom: wrap2.type === "TopAndBottom",
|
|
36408
36684
|
originalPadding: {
|
|
36409
36685
|
distT: attributes["distT"],
|
|
36410
36686
|
distB: attributes["distB"],
|
|
@@ -36416,7 +36692,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36416
36692
|
}
|
|
36417
36693
|
};
|
|
36418
36694
|
}
|
|
36419
|
-
const handleShapeDrawing = (params2, node, graphicData) => {
|
|
36695
|
+
const handleShapeDrawing = (params2, node, graphicData, size2, padding, marginOffset) => {
|
|
36420
36696
|
const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
|
|
36421
36697
|
const textBox = wsp.elements.find((el) => el.name === "wps:txbx");
|
|
36422
36698
|
const textBoxContent = textBox?.elements?.find((el) => el.name === "w:txbxContent");
|
|
@@ -36427,21 +36703,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36427
36703
|
return getRectangleShape(params2, spPr);
|
|
36428
36704
|
}
|
|
36429
36705
|
if (!textBoxContent) {
|
|
36430
|
-
return
|
|
36706
|
+
return buildShapePlaceholder(node, size2, padding, marginOffset, "drawing");
|
|
36431
36707
|
}
|
|
36432
|
-
|
|
36433
|
-
const translatedElement = nodeListHandler.handler({
|
|
36434
|
-
...params2,
|
|
36435
|
-
node: textBoxContent.elements[0],
|
|
36436
|
-
nodes: textBoxContent.elements,
|
|
36437
|
-
path: [...params2.path || [], textBoxContent]
|
|
36438
|
-
});
|
|
36439
|
-
return translatedElement[0];
|
|
36708
|
+
return buildShapePlaceholder(node, size2, padding, marginOffset, "textbox");
|
|
36440
36709
|
};
|
|
36441
36710
|
const getRectangleShape = (params2, node) => {
|
|
36442
36711
|
const schemaAttrs = {};
|
|
36443
36712
|
const [drawingNode] = params2.nodes;
|
|
36444
|
-
if (drawingNode?.name ===
|
|
36713
|
+
if (drawingNode?.name === DRAWING_XML_TAG) {
|
|
36445
36714
|
schemaAttrs.drawingContent = drawingNode;
|
|
36446
36715
|
}
|
|
36447
36716
|
const xfrm = node.elements.find((el) => el.name === "a:xfrm");
|
|
@@ -36465,6 +36734,52 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36465
36734
|
attrs: schemaAttrs
|
|
36466
36735
|
};
|
|
36467
36736
|
};
|
|
36737
|
+
const buildShapePlaceholder = (node, size2, padding, marginOffset, shapeType) => {
|
|
36738
|
+
const attrs = {
|
|
36739
|
+
drawingContent: {
|
|
36740
|
+
name: DRAWING_XML_TAG,
|
|
36741
|
+
elements: [carbonCopy(node)]
|
|
36742
|
+
},
|
|
36743
|
+
attributes: {
|
|
36744
|
+
"data-shape-type": shapeType
|
|
36745
|
+
}
|
|
36746
|
+
};
|
|
36747
|
+
if (size2 && (Number.isFinite(size2.width) || Number.isFinite(size2.height))) {
|
|
36748
|
+
attrs.size = {
|
|
36749
|
+
...Number.isFinite(size2.width) ? { width: size2.width } : {},
|
|
36750
|
+
...Number.isFinite(size2.height) ? { height: size2.height } : {}
|
|
36751
|
+
};
|
|
36752
|
+
}
|
|
36753
|
+
if (padding) {
|
|
36754
|
+
const paddingData = {};
|
|
36755
|
+
if (Number.isFinite(padding.top)) paddingData["data-padding-top"] = padding.top;
|
|
36756
|
+
if (Number.isFinite(padding.right)) paddingData["data-padding-right"] = padding.right;
|
|
36757
|
+
if (Number.isFinite(padding.bottom)) paddingData["data-padding-bottom"] = padding.bottom;
|
|
36758
|
+
if (Number.isFinite(padding.left)) paddingData["data-padding-left"] = padding.left;
|
|
36759
|
+
if (Object.keys(paddingData).length) {
|
|
36760
|
+
attrs.attributes = {
|
|
36761
|
+
...attrs.attributes,
|
|
36762
|
+
...paddingData
|
|
36763
|
+
};
|
|
36764
|
+
}
|
|
36765
|
+
}
|
|
36766
|
+
if (marginOffset) {
|
|
36767
|
+
const offsetData = {};
|
|
36768
|
+
const horizontal = Number.isFinite(marginOffset.horizontal) ? marginOffset.horizontal : Number.isFinite(marginOffset.left) ? marginOffset.left : void 0;
|
|
36769
|
+
if (Number.isFinite(horizontal)) offsetData["data-offset-x"] = horizontal;
|
|
36770
|
+
if (Number.isFinite(marginOffset.top)) offsetData["data-offset-y"] = marginOffset.top;
|
|
36771
|
+
if (Object.keys(offsetData).length) {
|
|
36772
|
+
attrs.attributes = {
|
|
36773
|
+
...attrs.attributes,
|
|
36774
|
+
...offsetData
|
|
36775
|
+
};
|
|
36776
|
+
}
|
|
36777
|
+
}
|
|
36778
|
+
return {
|
|
36779
|
+
type: "contentBlock",
|
|
36780
|
+
attrs
|
|
36781
|
+
};
|
|
36782
|
+
};
|
|
36468
36783
|
function handleAnchorNode(params2) {
|
|
36469
36784
|
const { node } = params2.extraParams;
|
|
36470
36785
|
if (node.name !== "wp:anchor") {
|
|
@@ -66646,8 +66961,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66646
66961
|
}
|
|
66647
66962
|
});
|
|
66648
66963
|
const getColStyleDeclaration = (minWidth, width) => {
|
|
66649
|
-
if (width) {
|
|
66650
|
-
|
|
66964
|
+
if (width != null) {
|
|
66965
|
+
const numericWidth = Number(width);
|
|
66966
|
+
if (Number.isFinite(numericWidth) && numericWidth >= 0) {
|
|
66967
|
+
return ["width", `${numericWidth}px`];
|
|
66968
|
+
}
|
|
66651
66969
|
}
|
|
66652
66970
|
return ["min-width", `${minWidth}px`];
|
|
66653
66971
|
};
|
|
@@ -66669,7 +66987,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66669
66987
|
this.table = this.dom.appendChild(document.createElement("table"));
|
|
66670
66988
|
this.colgroup = this.table.appendChild(document.createElement("colgroup"));
|
|
66671
66989
|
updateTable(this.editor, this.node, this.table);
|
|
66672
|
-
updateColumns(node, this.colgroup, this.table, cellMinWidth2);
|
|
66990
|
+
updateColumns(node, this.colgroup, this.table, cellMinWidth2, void 0, void 0, this.editor);
|
|
66673
66991
|
this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
66674
66992
|
setTimeout(() => {
|
|
66675
66993
|
updateTableWrapper(this.dom, this.table);
|
|
@@ -66681,7 +66999,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66681
66999
|
}
|
|
66682
67000
|
this.node = node;
|
|
66683
67001
|
updateTable(this.editor, node, this.table);
|
|
66684
|
-
updateColumns(node, this.colgroup, this.table, this.cellMinWidth);
|
|
67002
|
+
updateColumns(node, this.colgroup, this.table, this.cellMinWidth, void 0, void 0, this.editor);
|
|
66685
67003
|
updateTableWrapper(this.dom, this.table);
|
|
66686
67004
|
return true;
|
|
66687
67005
|
}
|
|
@@ -66694,46 +67012,105 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66694
67012
|
}
|
|
66695
67013
|
};
|
|
66696
67014
|
};
|
|
66697
|
-
function updateColumns(node, colgroup, table, cellMinWidth2, overrideCol, overrideValue) {
|
|
66698
|
-
|
|
66699
|
-
|
|
66700
|
-
|
|
67015
|
+
function updateColumns(node, colgroup, table, cellMinWidth2, overrideCol, overrideValue, editor) {
|
|
67016
|
+
const gridColumns = Array.isArray(node.attrs?.grid) && node.attrs.grid.length ? node.attrs.grid.map((col) => twipsToPixels(col.col)) : null;
|
|
67017
|
+
const totalColumns = gridColumns?.length ?? null;
|
|
67018
|
+
const pageBody = table.closest(".page__body");
|
|
67019
|
+
const wrapper = table.parentElement;
|
|
67020
|
+
let availableWidth = pageBody?.getBoundingClientRect?.().width;
|
|
67021
|
+
if (!availableWidth && wrapper) {
|
|
67022
|
+
availableWidth = wrapper.getBoundingClientRect().width;
|
|
67023
|
+
}
|
|
67024
|
+
if (typeof availableWidth === "number" && !Number.isNaN(availableWidth)) {
|
|
67025
|
+
availableWidth = Math.max(availableWidth - 2, 0);
|
|
67026
|
+
} else {
|
|
67027
|
+
availableWidth = null;
|
|
67028
|
+
}
|
|
67029
|
+
const pageStyles = editor?.converter?.pageStyles;
|
|
67030
|
+
if (pageStyles?.pageSize?.width) {
|
|
67031
|
+
const toNumber2 = (v2) => typeof v2 === "number" ? v2 : parseFloat(v2) || 0;
|
|
67032
|
+
const pageWidth = toNumber2(pageStyles.pageSize.width);
|
|
67033
|
+
const marginLeft = toNumber2(pageStyles.pageMargins?.left);
|
|
67034
|
+
const marginRight = toNumber2(pageStyles.pageMargins?.right);
|
|
67035
|
+
const pageAvailableWidthPx = Math.max((pageWidth - marginLeft - marginRight) * PIXELS_PER_INCH, 0);
|
|
67036
|
+
if (pageAvailableWidthPx > 0) {
|
|
67037
|
+
availableWidth = availableWidth ? Math.min(availableWidth, pageAvailableWidthPx) : pageAvailableWidthPx;
|
|
67038
|
+
}
|
|
67039
|
+
}
|
|
67040
|
+
const resolveColumnWidth = (colIndex2, colwidthValue) => {
|
|
67041
|
+
if (overrideCol === colIndex2) return overrideValue;
|
|
67042
|
+
if (colwidthValue != null) return colwidthValue;
|
|
67043
|
+
if (gridColumns && gridColumns[colIndex2] != null) return gridColumns[colIndex2];
|
|
67044
|
+
return null;
|
|
67045
|
+
};
|
|
67046
|
+
const widths = [];
|
|
66701
67047
|
const row = node.firstChild;
|
|
67048
|
+
let colIndex = 0;
|
|
66702
67049
|
if (row !== null) {
|
|
66703
|
-
for (let i2 = 0
|
|
66704
|
-
const
|
|
66705
|
-
|
|
66706
|
-
|
|
66707
|
-
|
|
66708
|
-
totalWidth += hasWidth || cellMinWidth2;
|
|
66709
|
-
if (!hasWidth) fixedWidth = false;
|
|
66710
|
-
if (!nextDOM) {
|
|
66711
|
-
const col2 = document.createElement("col");
|
|
66712
|
-
const [propKey, propVal] = getColStyleDeclaration(cellMinWidth2, hasWidth);
|
|
66713
|
-
col2.style.setProperty(propKey, propVal);
|
|
66714
|
-
colgroup.appendChild(col2);
|
|
66715
|
-
} else {
|
|
66716
|
-
if (nextDOM.style.width !== cssWidth) {
|
|
66717
|
-
const [propKey, propVal] = getColStyleDeclaration(cellMinWidth2, hasWidth);
|
|
66718
|
-
nextDOM.style.setProperty(propKey, propVal);
|
|
66719
|
-
}
|
|
66720
|
-
nextDOM = nextDOM.nextSibling;
|
|
66721
|
-
}
|
|
67050
|
+
for (let i2 = 0; i2 < row.childCount; i2++) {
|
|
67051
|
+
const child = row.child(i2);
|
|
67052
|
+
const { colspan, colwidth } = child.attrs;
|
|
67053
|
+
for (let span = 0; span < colspan; span += 1, colIndex += 1) {
|
|
67054
|
+
widths.push(resolveColumnWidth(colIndex, colwidth && colwidth[span]));
|
|
66722
67055
|
}
|
|
66723
67056
|
}
|
|
66724
67057
|
}
|
|
66725
|
-
|
|
66726
|
-
|
|
66727
|
-
|
|
66728
|
-
|
|
67058
|
+
if (totalColumns != null && colIndex < totalColumns) {
|
|
67059
|
+
for (let col = colIndex; col < totalColumns; col += 1) {
|
|
67060
|
+
widths.push(resolveColumnWidth(col));
|
|
67061
|
+
}
|
|
66729
67062
|
}
|
|
66730
|
-
|
|
66731
|
-
|
|
67063
|
+
const normalizedWidths = widths.map((widthPx) => {
|
|
67064
|
+
const numericWidth = Number(widthPx);
|
|
67065
|
+
if (!Number.isFinite(numericWidth)) return null;
|
|
67066
|
+
if (numericWidth < 0) return null;
|
|
67067
|
+
if (numericWidth === 0) return 0;
|
|
67068
|
+
if (numericWidth < 1) return 0;
|
|
67069
|
+
return numericWidth;
|
|
67070
|
+
});
|
|
67071
|
+
const rawTotalWidth = normalizedWidths.reduce((sum, width) => sum + (width != null ? width : cellMinWidth2), 0);
|
|
67072
|
+
let scale = 1;
|
|
67073
|
+
if (availableWidth && rawTotalWidth > 0 && rawTotalWidth > availableWidth) {
|
|
67074
|
+
scale = availableWidth / rawTotalWidth;
|
|
67075
|
+
}
|
|
67076
|
+
let totalWidth = 0;
|
|
67077
|
+
let hasUndefinedWidth = false;
|
|
67078
|
+
let dom = colgroup.firstChild;
|
|
67079
|
+
normalizedWidths.forEach((width) => {
|
|
67080
|
+
let scaledWidth = width;
|
|
67081
|
+
if (scaledWidth != null) {
|
|
67082
|
+
scaledWidth = scaledWidth * scale;
|
|
67083
|
+
}
|
|
67084
|
+
const [propKey, propVal] = getColStyleDeclaration(cellMinWidth2, scaledWidth);
|
|
67085
|
+
if (scaledWidth == null) {
|
|
67086
|
+
totalWidth += cellMinWidth2;
|
|
67087
|
+
hasUndefinedWidth = true;
|
|
67088
|
+
} else {
|
|
67089
|
+
totalWidth += scaledWidth;
|
|
67090
|
+
}
|
|
67091
|
+
if (!dom) {
|
|
67092
|
+
const colElement = document.createElement("col");
|
|
67093
|
+
colElement.style.setProperty(propKey, propVal);
|
|
67094
|
+
colgroup.appendChild(colElement);
|
|
67095
|
+
} else {
|
|
67096
|
+
dom.style.setProperty(propKey, propVal);
|
|
67097
|
+
dom = dom.nextSibling;
|
|
67098
|
+
}
|
|
67099
|
+
});
|
|
67100
|
+
while (dom) {
|
|
67101
|
+
const next = dom.nextSibling;
|
|
67102
|
+
dom.parentNode?.removeChild(dom);
|
|
67103
|
+
dom = next;
|
|
67104
|
+
}
|
|
67105
|
+
if (scale < 1 || !hasUndefinedWidth) {
|
|
67106
|
+
const clampedWidth = Math.min(totalWidth, availableWidth || totalWidth);
|
|
67107
|
+
table.style.width = `${clampedWidth}px`;
|
|
66732
67108
|
table.style.minWidth = "";
|
|
66733
67109
|
} else {
|
|
66734
67110
|
table.style.width = "";
|
|
66735
67111
|
table.style.minWidth = `${totalWidth}px`;
|
|
66736
67112
|
}
|
|
67113
|
+
table.style.maxWidth = "100%";
|
|
66737
67114
|
}
|
|
66738
67115
|
function updateTable(editor, node, table) {
|
|
66739
67116
|
const allExtensionsAttrs = editor.extensionService.attributes;
|
|
@@ -66811,22 +67188,61 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66811
67188
|
const tableBorders = createTableBorders();
|
|
66812
67189
|
return types2.table.createChecked({ borders: tableBorders }, rows);
|
|
66813
67190
|
};
|
|
67191
|
+
const MIN_MEANINGFUL_WIDTH_PX = 1;
|
|
66814
67192
|
const createColGroup = (node, cellMinWidth2, overrideCol, overrideValue) => {
|
|
66815
67193
|
let totalWidth = 0;
|
|
66816
67194
|
let fixedWidth = true;
|
|
66817
67195
|
const cols = [];
|
|
66818
67196
|
const colsValues = [];
|
|
66819
67197
|
const row = node.firstChild;
|
|
67198
|
+
const gridColumns = Array.isArray(node.attrs?.grid) && node.attrs.grid.length ? node.attrs.grid.map((col) => twipsToPixels(col.col)) : null;
|
|
66820
67199
|
if (!row) return {};
|
|
66821
|
-
|
|
66822
|
-
|
|
66823
|
-
|
|
66824
|
-
|
|
66825
|
-
|
|
66826
|
-
|
|
66827
|
-
|
|
67200
|
+
const totalColumns = gridColumns?.length;
|
|
67201
|
+
const resolveColumnWidth = (colIndex2, colwidthValue) => {
|
|
67202
|
+
if (overrideCol === colIndex2) return overrideValue;
|
|
67203
|
+
if (colwidthValue != null) return colwidthValue;
|
|
67204
|
+
if (gridColumns && gridColumns[colIndex2] != null) return gridColumns[colIndex2];
|
|
67205
|
+
return null;
|
|
67206
|
+
};
|
|
67207
|
+
let colIndex = 0;
|
|
67208
|
+
for (let i2 = 0; i2 < row.childCount; i2++) {
|
|
67209
|
+
const child = row.child(i2);
|
|
67210
|
+
const { colspan, colwidth } = child.attrs;
|
|
67211
|
+
for (let j2 = 0; j2 < colspan; j2++, colIndex++) {
|
|
67212
|
+
const candidateWidth = resolveColumnWidth(colIndex, colwidth && colwidth[j2]);
|
|
67213
|
+
const numericWidth = Number(candidateWidth);
|
|
67214
|
+
let effectiveWidth = Number.isFinite(numericWidth) && numericWidth > 0 ? numericWidth : null;
|
|
67215
|
+
if (effectiveWidth != null && effectiveWidth < MIN_MEANINGFUL_WIDTH_PX) {
|
|
67216
|
+
effectiveWidth = 0;
|
|
67217
|
+
}
|
|
67218
|
+
if (effectiveWidth == null) {
|
|
67219
|
+
totalWidth += cellMinWidth2;
|
|
67220
|
+
fixedWidth = false;
|
|
67221
|
+
} else {
|
|
67222
|
+
totalWidth += effectiveWidth;
|
|
67223
|
+
}
|
|
67224
|
+
const [prop, value] = getColStyleDeclaration(cellMinWidth2, effectiveWidth);
|
|
66828
67225
|
cols.push(["col", { style: `${prop}: ${value}` }]);
|
|
66829
|
-
colsValues.push(
|
|
67226
|
+
colsValues.push(parseFloat(value));
|
|
67227
|
+
}
|
|
67228
|
+
}
|
|
67229
|
+
if (totalColumns != null) {
|
|
67230
|
+
for (let col = colIndex; col < totalColumns; col++) {
|
|
67231
|
+
const candidateWidth = resolveColumnWidth(col);
|
|
67232
|
+
const numericWidth = Number(candidateWidth);
|
|
67233
|
+
let effectiveWidth = Number.isFinite(numericWidth) && numericWidth > 0 ? numericWidth : null;
|
|
67234
|
+
if (effectiveWidth != null && effectiveWidth < MIN_MEANINGFUL_WIDTH_PX) {
|
|
67235
|
+
effectiveWidth = 0;
|
|
67236
|
+
}
|
|
67237
|
+
if (effectiveWidth == null) {
|
|
67238
|
+
totalWidth += cellMinWidth2;
|
|
67239
|
+
fixedWidth = false;
|
|
67240
|
+
} else {
|
|
67241
|
+
totalWidth += effectiveWidth;
|
|
67242
|
+
}
|
|
67243
|
+
const [prop, value] = getColStyleDeclaration(cellMinWidth2, effectiveWidth);
|
|
67244
|
+
cols.push(["col", { style: `${prop}: ${value}` }]);
|
|
67245
|
+
colsValues.push(parseFloat(value));
|
|
66830
67246
|
}
|
|
66831
67247
|
}
|
|
66832
67248
|
const tableWidth = fixedWidth ? `${totalWidth}px` : "";
|
|
@@ -69729,6 +70145,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
69729
70145
|
"data-colwidth": attrs.colwidth.join(",")
|
|
69730
70146
|
};
|
|
69731
70147
|
}
|
|
70148
|
+
},
|
|
70149
|
+
__placeholder: {
|
|
70150
|
+
default: null,
|
|
70151
|
+
parseDOM: (element) => {
|
|
70152
|
+
const value = element.getAttribute("data-placeholder");
|
|
70153
|
+
return value || null;
|
|
70154
|
+
},
|
|
70155
|
+
renderDOM({ __placeholder }) {
|
|
70156
|
+
if (!__placeholder) return {};
|
|
70157
|
+
return {
|
|
70158
|
+
"data-placeholder": __placeholder
|
|
70159
|
+
};
|
|
70160
|
+
}
|
|
69732
70161
|
}
|
|
69733
70162
|
};
|
|
69734
70163
|
},
|
|
@@ -69889,6 +70318,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
69889
70318
|
default: "px",
|
|
69890
70319
|
rendered: false
|
|
69891
70320
|
},
|
|
70321
|
+
__placeholder: {
|
|
70322
|
+
default: null,
|
|
70323
|
+
parseDOM: (element) => {
|
|
70324
|
+
const value = element.getAttribute("data-placeholder");
|
|
70325
|
+
return value || null;
|
|
70326
|
+
},
|
|
70327
|
+
renderDOM({ __placeholder }) {
|
|
70328
|
+
if (!__placeholder) return {};
|
|
70329
|
+
return {
|
|
70330
|
+
"data-placeholder": __placeholder
|
|
70331
|
+
};
|
|
70332
|
+
}
|
|
70333
|
+
},
|
|
69892
70334
|
/**
|
|
69893
70335
|
* @category Attribute
|
|
69894
70336
|
* @param {TableCellProperties} tableCellProperties - Properties for the table cell.
|
|
@@ -113053,17 +113495,62 @@ ${style2}
|
|
|
113053
113495
|
const highContrastModeStore = useHighContrastMode();
|
|
113054
113496
|
return { app, pinia, superdocStore, commentsStore, highContrastModeStore };
|
|
113055
113497
|
};
|
|
113056
|
-
const
|
|
113498
|
+
const MIME_TYPES = {
|
|
113499
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
113500
|
+
pdf: "application/pdf",
|
|
113501
|
+
zip: "application/zip",
|
|
113502
|
+
html: "text/html",
|
|
113503
|
+
txt: "text/plain;charset=utf-8",
|
|
113504
|
+
json: "application/json"
|
|
113505
|
+
};
|
|
113506
|
+
const getMimeType = (extension) => {
|
|
113507
|
+
if (!extension || typeof extension.toLowerCase !== "function") return "application/octet-stream";
|
|
113508
|
+
return MIME_TYPES[extension.toLowerCase()] || "application/octet-stream";
|
|
113509
|
+
};
|
|
113510
|
+
const ensureBlob = (data, extension) => {
|
|
113511
|
+
if (data instanceof Blob) return data;
|
|
113512
|
+
const mimeType = getMimeType(extension);
|
|
113513
|
+
if (data instanceof ArrayBuffer) {
|
|
113514
|
+
return new Blob([data], { type: mimeType });
|
|
113515
|
+
}
|
|
113516
|
+
if (ArrayBuffer.isView(data)) {
|
|
113517
|
+
const { buffer: buffer2, byteOffset, byteLength: byteLength2 } = data;
|
|
113518
|
+
const slice = buffer2.slice(byteOffset, byteOffset + byteLength2);
|
|
113519
|
+
return new Blob([slice], { type: mimeType });
|
|
113520
|
+
}
|
|
113521
|
+
if (typeof data === "string") {
|
|
113522
|
+
return new Blob([data], { type: mimeType });
|
|
113523
|
+
}
|
|
113524
|
+
if (data == null) {
|
|
113525
|
+
throw new TypeError("createDownload requires a Blob, ArrayBuffer, or ArrayBufferView.");
|
|
113526
|
+
}
|
|
113527
|
+
throw new TypeError(`Cannot create download from value of type ${typeof data}`);
|
|
113528
|
+
};
|
|
113529
|
+
const createDownload = (data, name, extension) => {
|
|
113530
|
+
const blob = ensureBlob(data, extension);
|
|
113531
|
+
if (typeof URL === "undefined" || typeof URL.createObjectURL !== "function") return blob;
|
|
113532
|
+
if (typeof document === "undefined" || typeof document.createElement !== "function") return blob;
|
|
113057
113533
|
const url = URL.createObjectURL(blob);
|
|
113058
113534
|
const a = document.createElement("a");
|
|
113059
113535
|
a.href = url;
|
|
113060
113536
|
a.download = `${name}.${extension}`;
|
|
113537
|
+
const shouldAppend = document.body && typeof document.body.appendChild === "function";
|
|
113538
|
+
if (shouldAppend) document.body.appendChild(a);
|
|
113061
113539
|
a.click();
|
|
113540
|
+
if (shouldAppend) document.body.removeChild(a);
|
|
113541
|
+
if (typeof URL.revokeObjectURL === "function") {
|
|
113542
|
+
setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
113543
|
+
}
|
|
113544
|
+
return blob;
|
|
113062
113545
|
};
|
|
113063
113546
|
const cleanName = (currentName) => {
|
|
113064
|
-
|
|
113547
|
+
const lowerName = currentName.toLowerCase();
|
|
113548
|
+
if (lowerName.endsWith(".docx")) {
|
|
113065
113549
|
return currentName.slice(0, -5);
|
|
113066
113550
|
}
|
|
113551
|
+
if (lowerName.endsWith(".pdf")) {
|
|
113552
|
+
return currentName.slice(0, -4);
|
|
113553
|
+
}
|
|
113067
113554
|
return currentName;
|
|
113068
113555
|
};
|
|
113069
113556
|
class SuperDoc extends EventEmitter {
|
|
@@ -113681,14 +114168,25 @@ ${style2}
|
|
|
113681
114168
|
comments.push(...this.commentsStore.translateCommentsForExport());
|
|
113682
114169
|
}
|
|
113683
114170
|
}
|
|
113684
|
-
const docxPromises =
|
|
113685
|
-
|
|
113686
|
-
const editor = doc2.getEditor();
|
|
113687
|
-
|
|
113688
|
-
|
|
114171
|
+
const docxPromises = this.superdocStore.documents.map(async (doc2) => {
|
|
114172
|
+
if (!doc2 || doc2.type !== DOCX) return null;
|
|
114173
|
+
const editor = typeof doc2.getEditor === "function" ? doc2.getEditor() : null;
|
|
114174
|
+
const fallbackDocx = () => {
|
|
114175
|
+
if (!doc2.data) return null;
|
|
114176
|
+
if (doc2.data.type && doc2.data.type !== DOCX) return null;
|
|
114177
|
+
return doc2.data;
|
|
114178
|
+
};
|
|
114179
|
+
if (!editor) return fallbackDocx();
|
|
114180
|
+
try {
|
|
114181
|
+
const exported = await editor.exportDocx({ isFinalDoc, comments, commentsType, fieldsHighlightColor });
|
|
114182
|
+
if (exported) return exported;
|
|
114183
|
+
} catch (error) {
|
|
114184
|
+
this.emit("exception", { error, document: doc2 });
|
|
113689
114185
|
}
|
|
114186
|
+
return fallbackDocx();
|
|
113690
114187
|
});
|
|
113691
|
-
|
|
114188
|
+
const docxFiles = await Promise.all(docxPromises);
|
|
114189
|
+
return docxFiles.filter(Boolean);
|
|
113692
114190
|
}
|
|
113693
114191
|
/**
|
|
113694
114192
|
* Request an immediate save from all collaboration documents
|