@harbour-enterprises/superdoc 0.24.0-next.4 → 0.24.0-next.5
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-kOVuv-4I.cjs → PdfViewer-D6AmuQ3v.cjs} +1 -1
- package/dist/chunks/{PdfViewer-D7C8g2G4.es.js → PdfViewer-XhwjWR8o.es.js} +1 -1
- package/dist/chunks/{index-BFKwBQjS.cjs → index-DAdhqIN8.cjs} +66 -10
- package/dist/chunks/{index-CnEAVnHQ.es.js → index-OjiyjDUm.es.js} +66 -10
- package/dist/chunks/{super-editor.es-BmGTQ05x.cjs → super-editor.es-BPK2gF1W.cjs} +484 -132
- package/dist/chunks/{super-editor.es-CBPoWvjs.es.js → super-editor.es-bHlpz8m_.es.js} +484 -132
- 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-D-9mYZ83.js} +419 -192
- package/dist/super-editor/chunks/{docx-zipper-6Kc95yG-.js → docx-zipper-C1p3F7Ok.js} +1 -1
- package/dist/super-editor/chunks/{editor-Dx6AhT5N.js → editor-lJoa5ADp.js} +170 -43
- package/dist/super-editor/chunks/{toolbar-CXSg2lJ9.js → toolbar-B5-QnQ4l.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 +548 -140
- 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",
|
|
@@ -36234,6 +36406,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36234
36406
|
}
|
|
36235
36407
|
return { type: "unknown", handler: null };
|
|
36236
36408
|
}
|
|
36409
|
+
const DRAWING_XML_TAG = "w:drawing";
|
|
36237
36410
|
function handleImageNode(node, params2, isAnchor) {
|
|
36238
36411
|
const { docx, filename } = params2;
|
|
36239
36412
|
const { attributes } = node;
|
|
@@ -36245,32 +36418,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36245
36418
|
};
|
|
36246
36419
|
const extent = node.elements.find((el) => el.name === "wp:extent");
|
|
36247
36420
|
const size2 = {
|
|
36248
|
-
width: emuToPixels(extent
|
|
36249
|
-
height: emuToPixels(extent
|
|
36421
|
+
width: emuToPixels(extent?.attributes?.cx),
|
|
36422
|
+
height: emuToPixels(extent?.attributes?.cy)
|
|
36250
36423
|
};
|
|
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
36424
|
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
36425
|
const effectExtent = node.elements.find((el) => el.name === "wp:effectExtent");
|
|
36275
36426
|
if (effectExtent) {
|
|
36276
36427
|
const sanitizeEmuValue = (value) => {
|
|
@@ -36279,22 +36430,26 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36279
36430
|
return Number.isFinite(numeric) ? numeric : 0;
|
|
36280
36431
|
};
|
|
36281
36432
|
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"]))
|
|
36433
|
+
left: emuToPixels(sanitizeEmuValue(effectExtent.attributes?.["l"])),
|
|
36434
|
+
top: emuToPixels(sanitizeEmuValue(effectExtent.attributes?.["t"])),
|
|
36435
|
+
right: emuToPixels(sanitizeEmuValue(effectExtent.attributes?.["r"])),
|
|
36436
|
+
bottom: emuToPixels(sanitizeEmuValue(effectExtent.attributes?.["b"]))
|
|
36286
36437
|
};
|
|
36287
36438
|
}
|
|
36288
36439
|
const positionHTag = node.elements.find((el) => el.name === "wp:positionH");
|
|
36289
36440
|
const positionH = positionHTag?.elements.find((el) => el.name === "wp:posOffset");
|
|
36290
36441
|
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;
|
|
36442
|
+
const hRelativeFrom = positionHTag?.attributes?.relativeFrom;
|
|
36443
|
+
const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements?.[0]?.text;
|
|
36293
36444
|
const positionVTag = node.elements.find((el) => el.name === "wp:positionV");
|
|
36294
36445
|
const positionV = positionVTag?.elements?.find((el) => el.name === "wp:posOffset");
|
|
36295
36446
|
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;
|
|
36447
|
+
const vRelativeFrom = positionVTag?.attributes?.relativeFrom;
|
|
36448
|
+
const alignV = positionVTag?.elements?.find((el) => el.name === "wp:align")?.elements?.[0]?.text;
|
|
36449
|
+
const marginOffset = {
|
|
36450
|
+
horizontal: positionHValue,
|
|
36451
|
+
top: positionVValue
|
|
36452
|
+
};
|
|
36298
36453
|
const simplePos = node.elements.find((el) => el.name === "wp:simplePos");
|
|
36299
36454
|
const wrapNode = isAnchor ? node.elements.find(
|
|
36300
36455
|
(el) => ["wp:wrapNone", "wp:wrapSquare", "wp:wrapThrough", "wp:wrapTight", "wp:wrapTopAndBottom"].includes(el.name)
|
|
@@ -36302,38 +36457,40 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36302
36457
|
const wrap2 = isAnchor ? { type: wrapNode?.name.slice(7) || "None", attrs: {} } : { type: "Inline" };
|
|
36303
36458
|
switch (wrap2.type) {
|
|
36304
36459
|
case "Square":
|
|
36305
|
-
|
|
36306
|
-
|
|
36460
|
+
if (wrapNode?.attributes?.wrapText) {
|
|
36461
|
+
wrap2.attrs.wrapText = wrapNode.attributes.wrapText;
|
|
36462
|
+
}
|
|
36463
|
+
if ("distB" in (wrapNode?.attributes || {})) {
|
|
36307
36464
|
wrap2.attrs.distBottom = emuToPixels(wrapNode.attributes.distB);
|
|
36308
36465
|
}
|
|
36309
|
-
if ("distL" in (wrapNode
|
|
36466
|
+
if ("distL" in (wrapNode?.attributes || {})) {
|
|
36310
36467
|
wrap2.attrs.distLeft = emuToPixels(wrapNode.attributes.distL);
|
|
36311
36468
|
}
|
|
36312
|
-
if ("distR" in (wrapNode
|
|
36469
|
+
if ("distR" in (wrapNode?.attributes || {})) {
|
|
36313
36470
|
wrap2.attrs.distRight = emuToPixels(wrapNode.attributes.distR);
|
|
36314
36471
|
}
|
|
36315
|
-
if ("distT" in (wrapNode
|
|
36472
|
+
if ("distT" in (wrapNode?.attributes || {})) {
|
|
36316
36473
|
wrap2.attrs.distTop = emuToPixels(wrapNode.attributes.distT);
|
|
36317
36474
|
}
|
|
36318
36475
|
break;
|
|
36319
36476
|
case "Tight":
|
|
36320
36477
|
case "Through": {
|
|
36321
|
-
if ("distL" in (wrapNode
|
|
36478
|
+
if ("distL" in (wrapNode?.attributes || {})) {
|
|
36322
36479
|
wrap2.attrs.distLeft = emuToPixels(wrapNode.attributes.distL);
|
|
36323
36480
|
}
|
|
36324
|
-
if ("distR" in (wrapNode
|
|
36481
|
+
if ("distR" in (wrapNode?.attributes || {})) {
|
|
36325
36482
|
wrap2.attrs.distRight = emuToPixels(wrapNode.attributes.distR);
|
|
36326
36483
|
}
|
|
36327
|
-
if ("distT" in (wrapNode
|
|
36484
|
+
if ("distT" in (wrapNode?.attributes || {})) {
|
|
36328
36485
|
wrap2.attrs.distTop = emuToPixels(wrapNode.attributes.distT);
|
|
36329
36486
|
}
|
|
36330
|
-
if ("distB" in (wrapNode
|
|
36487
|
+
if ("distB" in (wrapNode?.attributes || {})) {
|
|
36331
36488
|
wrap2.attrs.distBottom = emuToPixels(wrapNode.attributes.distB);
|
|
36332
36489
|
}
|
|
36333
|
-
if ("wrapText" in (wrapNode
|
|
36490
|
+
if ("wrapText" in (wrapNode?.attributes || {})) {
|
|
36334
36491
|
wrap2.attrs.wrapText = wrapNode.attributes.wrapText;
|
|
36335
36492
|
}
|
|
36336
|
-
const polygon = wrapNode
|
|
36493
|
+
const polygon = wrapNode?.elements?.find((el) => el.name === "wp:wrapPolygon");
|
|
36337
36494
|
if (polygon) {
|
|
36338
36495
|
wrap2.attrs.polygon = polygonToObj(polygon);
|
|
36339
36496
|
if (polygon.attributes?.edited !== void 0) {
|
|
@@ -36343,10 +36500,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36343
36500
|
break;
|
|
36344
36501
|
}
|
|
36345
36502
|
case "TopAndBottom":
|
|
36346
|
-
if ("distB" in (wrapNode
|
|
36503
|
+
if ("distB" in (wrapNode?.attributes || {})) {
|
|
36347
36504
|
wrap2.attrs.distBottom = emuToPixels(wrapNode.attributes.distB);
|
|
36348
36505
|
}
|
|
36349
|
-
if ("distT" in (wrapNode
|
|
36506
|
+
if ("distT" in (wrapNode?.attributes || {})) {
|
|
36350
36507
|
wrap2.attrs.distTop = emuToPixels(wrapNode.attributes.distT);
|
|
36351
36508
|
}
|
|
36352
36509
|
break;
|
|
@@ -36364,17 +36521,42 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36364
36521
|
alignV
|
|
36365
36522
|
};
|
|
36366
36523
|
}
|
|
36367
|
-
const
|
|
36368
|
-
|
|
36369
|
-
|
|
36370
|
-
|
|
36524
|
+
const graphic = node.elements.find((el) => el.name === "a:graphic");
|
|
36525
|
+
const graphicData = graphic?.elements.find((el) => el.name === "a:graphicData");
|
|
36526
|
+
const { uri: uri2 } = graphicData?.attributes || {};
|
|
36527
|
+
const shapeURI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
36528
|
+
if (!!uri2 && uri2 === shapeURI) {
|
|
36529
|
+
const shapeMarginOffset = {
|
|
36530
|
+
left: positionHValue,
|
|
36531
|
+
horizontal: positionHValue,
|
|
36532
|
+
top: positionVValue
|
|
36533
|
+
};
|
|
36534
|
+
return handleShapeDrawing(params2, node, graphicData, size2, padding, shapeMarginOffset);
|
|
36535
|
+
}
|
|
36536
|
+
const picture = graphicData?.elements.find((el) => el.name === "pic:pic");
|
|
36537
|
+
if (!picture || !picture.elements) return null;
|
|
36538
|
+
const blipFill = picture.elements.find((el) => el.name === "pic:blipFill");
|
|
36539
|
+
const blip = blipFill?.elements.find((el) => el.name === "a:blip");
|
|
36540
|
+
if (!blip) return null;
|
|
36541
|
+
const spPr = picture.elements.find((el) => el.name === "pic:spPr");
|
|
36542
|
+
if (spPr) {
|
|
36543
|
+
const xfrm = spPr.elements.find((el) => el.name === "a:xfrm");
|
|
36544
|
+
if (xfrm?.attributes) {
|
|
36545
|
+
transformData = {
|
|
36546
|
+
...transformData,
|
|
36547
|
+
rotation: rotToDegrees(xfrm.attributes["rot"]),
|
|
36548
|
+
verticalFlip: xfrm.attributes["flipV"] === "1",
|
|
36549
|
+
horizontalFlip: xfrm.attributes["flipH"] === "1"
|
|
36550
|
+
};
|
|
36551
|
+
}
|
|
36552
|
+
}
|
|
36371
36553
|
const { attributes: blipAttributes = {} } = blip;
|
|
36372
36554
|
const rEmbed = blipAttributes["r:embed"];
|
|
36373
36555
|
if (!rEmbed) return null;
|
|
36374
36556
|
const currentFile = filename || "document.xml";
|
|
36375
36557
|
let rels = docx[`word/_rels/${currentFile}.rels`];
|
|
36376
36558
|
if (!rels) rels = docx[`word/_rels/document.xml.rels`];
|
|
36377
|
-
const relationships = rels
|
|
36559
|
+
const relationships = rels?.elements.find((el) => el.name === "Relationships");
|
|
36378
36560
|
const { elements } = relationships || [];
|
|
36379
36561
|
const rel = elements?.find((el) => el.attributes["Id"] === rEmbed);
|
|
36380
36562
|
if (!rel) return null;
|
|
@@ -36387,10 +36569,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36387
36569
|
type: "image",
|
|
36388
36570
|
attrs: {
|
|
36389
36571
|
src: path,
|
|
36390
|
-
alt: ["emf", "wmf"].includes(extension) ? "Unable to render EMF/WMF image" : docPr?.attributes
|
|
36572
|
+
alt: ["emf", "wmf"].includes(extension) ? "Unable to render EMF/WMF image" : docPr?.attributes?.name || "Image",
|
|
36391
36573
|
extension,
|
|
36392
|
-
id: docPr?.attributes
|
|
36393
|
-
title: docPr?.attributes
|
|
36574
|
+
id: docPr?.attributes?.id || "",
|
|
36575
|
+
title: docPr?.attributes?.descr || "Image",
|
|
36394
36576
|
inline: true,
|
|
36395
36577
|
padding,
|
|
36396
36578
|
marginOffset,
|
|
@@ -36405,6 +36587,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36405
36587
|
}
|
|
36406
36588
|
},
|
|
36407
36589
|
wrap: wrap2,
|
|
36590
|
+
...wrap2.type === "Square" && wrap2.attrs.wrapText ? {
|
|
36591
|
+
wrapText: wrap2.attrs.wrapText
|
|
36592
|
+
} : {},
|
|
36593
|
+
wrapTopAndBottom: wrap2.type === "TopAndBottom",
|
|
36408
36594
|
originalPadding: {
|
|
36409
36595
|
distT: attributes["distT"],
|
|
36410
36596
|
distB: attributes["distB"],
|
|
@@ -36416,7 +36602,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36416
36602
|
}
|
|
36417
36603
|
};
|
|
36418
36604
|
}
|
|
36419
|
-
const handleShapeDrawing = (params2, node, graphicData) => {
|
|
36605
|
+
const handleShapeDrawing = (params2, node, graphicData, size2, padding, marginOffset) => {
|
|
36420
36606
|
const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
|
|
36421
36607
|
const textBox = wsp.elements.find((el) => el.name === "wps:txbx");
|
|
36422
36608
|
const textBoxContent = textBox?.elements?.find((el) => el.name === "w:txbxContent");
|
|
@@ -36427,21 +36613,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36427
36613
|
return getRectangleShape(params2, spPr);
|
|
36428
36614
|
}
|
|
36429
36615
|
if (!textBoxContent) {
|
|
36430
|
-
return
|
|
36616
|
+
return buildShapePlaceholder(node, size2, padding, marginOffset, "drawing");
|
|
36431
36617
|
}
|
|
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];
|
|
36618
|
+
return buildShapePlaceholder(node, size2, padding, marginOffset, "textbox");
|
|
36440
36619
|
};
|
|
36441
36620
|
const getRectangleShape = (params2, node) => {
|
|
36442
36621
|
const schemaAttrs = {};
|
|
36443
36622
|
const [drawingNode] = params2.nodes;
|
|
36444
|
-
if (drawingNode?.name ===
|
|
36623
|
+
if (drawingNode?.name === DRAWING_XML_TAG) {
|
|
36445
36624
|
schemaAttrs.drawingContent = drawingNode;
|
|
36446
36625
|
}
|
|
36447
36626
|
const xfrm = node.elements.find((el) => el.name === "a:xfrm");
|
|
@@ -36465,6 +36644,52 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36465
36644
|
attrs: schemaAttrs
|
|
36466
36645
|
};
|
|
36467
36646
|
};
|
|
36647
|
+
const buildShapePlaceholder = (node, size2, padding, marginOffset, shapeType) => {
|
|
36648
|
+
const attrs = {
|
|
36649
|
+
drawingContent: {
|
|
36650
|
+
name: DRAWING_XML_TAG,
|
|
36651
|
+
elements: [carbonCopy(node)]
|
|
36652
|
+
},
|
|
36653
|
+
attributes: {
|
|
36654
|
+
"data-shape-type": shapeType
|
|
36655
|
+
}
|
|
36656
|
+
};
|
|
36657
|
+
if (size2 && (Number.isFinite(size2.width) || Number.isFinite(size2.height))) {
|
|
36658
|
+
attrs.size = {
|
|
36659
|
+
...Number.isFinite(size2.width) ? { width: size2.width } : {},
|
|
36660
|
+
...Number.isFinite(size2.height) ? { height: size2.height } : {}
|
|
36661
|
+
};
|
|
36662
|
+
}
|
|
36663
|
+
if (padding) {
|
|
36664
|
+
const paddingData = {};
|
|
36665
|
+
if (Number.isFinite(padding.top)) paddingData["data-padding-top"] = padding.top;
|
|
36666
|
+
if (Number.isFinite(padding.right)) paddingData["data-padding-right"] = padding.right;
|
|
36667
|
+
if (Number.isFinite(padding.bottom)) paddingData["data-padding-bottom"] = padding.bottom;
|
|
36668
|
+
if (Number.isFinite(padding.left)) paddingData["data-padding-left"] = padding.left;
|
|
36669
|
+
if (Object.keys(paddingData).length) {
|
|
36670
|
+
attrs.attributes = {
|
|
36671
|
+
...attrs.attributes,
|
|
36672
|
+
...paddingData
|
|
36673
|
+
};
|
|
36674
|
+
}
|
|
36675
|
+
}
|
|
36676
|
+
if (marginOffset) {
|
|
36677
|
+
const offsetData = {};
|
|
36678
|
+
const horizontal = Number.isFinite(marginOffset.horizontal) ? marginOffset.horizontal : Number.isFinite(marginOffset.left) ? marginOffset.left : void 0;
|
|
36679
|
+
if (Number.isFinite(horizontal)) offsetData["data-offset-x"] = horizontal;
|
|
36680
|
+
if (Number.isFinite(marginOffset.top)) offsetData["data-offset-y"] = marginOffset.top;
|
|
36681
|
+
if (Object.keys(offsetData).length) {
|
|
36682
|
+
attrs.attributes = {
|
|
36683
|
+
...attrs.attributes,
|
|
36684
|
+
...offsetData
|
|
36685
|
+
};
|
|
36686
|
+
}
|
|
36687
|
+
}
|
|
36688
|
+
return {
|
|
36689
|
+
type: "contentBlock",
|
|
36690
|
+
attrs
|
|
36691
|
+
};
|
|
36692
|
+
};
|
|
36468
36693
|
function handleAnchorNode(params2) {
|
|
36469
36694
|
const { node } = params2.extraParams;
|
|
36470
36695
|
if (node.name !== "wp:anchor") {
|
|
@@ -66646,8 +66871,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66646
66871
|
}
|
|
66647
66872
|
});
|
|
66648
66873
|
const getColStyleDeclaration = (minWidth, width) => {
|
|
66649
|
-
if (width) {
|
|
66650
|
-
|
|
66874
|
+
if (width != null) {
|
|
66875
|
+
const numericWidth = Number(width);
|
|
66876
|
+
if (Number.isFinite(numericWidth) && numericWidth >= 0) {
|
|
66877
|
+
return ["width", `${numericWidth}px`];
|
|
66878
|
+
}
|
|
66651
66879
|
}
|
|
66652
66880
|
return ["min-width", `${minWidth}px`];
|
|
66653
66881
|
};
|
|
@@ -66669,7 +66897,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66669
66897
|
this.table = this.dom.appendChild(document.createElement("table"));
|
|
66670
66898
|
this.colgroup = this.table.appendChild(document.createElement("colgroup"));
|
|
66671
66899
|
updateTable(this.editor, this.node, this.table);
|
|
66672
|
-
updateColumns(node, this.colgroup, this.table, cellMinWidth2);
|
|
66900
|
+
updateColumns(node, this.colgroup, this.table, cellMinWidth2, void 0, void 0, this.editor);
|
|
66673
66901
|
this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
66674
66902
|
setTimeout(() => {
|
|
66675
66903
|
updateTableWrapper(this.dom, this.table);
|
|
@@ -66681,7 +66909,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66681
66909
|
}
|
|
66682
66910
|
this.node = node;
|
|
66683
66911
|
updateTable(this.editor, node, this.table);
|
|
66684
|
-
updateColumns(node, this.colgroup, this.table, this.cellMinWidth);
|
|
66912
|
+
updateColumns(node, this.colgroup, this.table, this.cellMinWidth, void 0, void 0, this.editor);
|
|
66685
66913
|
updateTableWrapper(this.dom, this.table);
|
|
66686
66914
|
return true;
|
|
66687
66915
|
}
|
|
@@ -66694,46 +66922,105 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66694
66922
|
}
|
|
66695
66923
|
};
|
|
66696
66924
|
};
|
|
66697
|
-
function updateColumns(node, colgroup, table, cellMinWidth2, overrideCol, overrideValue) {
|
|
66698
|
-
|
|
66699
|
-
|
|
66700
|
-
|
|
66925
|
+
function updateColumns(node, colgroup, table, cellMinWidth2, overrideCol, overrideValue, editor) {
|
|
66926
|
+
const gridColumns = Array.isArray(node.attrs?.grid) && node.attrs.grid.length ? node.attrs.grid.map((col) => twipsToPixels(col.col)) : null;
|
|
66927
|
+
const totalColumns = gridColumns?.length ?? null;
|
|
66928
|
+
const pageBody = table.closest(".page__body");
|
|
66929
|
+
const wrapper = table.parentElement;
|
|
66930
|
+
let availableWidth = pageBody?.getBoundingClientRect?.().width;
|
|
66931
|
+
if (!availableWidth && wrapper) {
|
|
66932
|
+
availableWidth = wrapper.getBoundingClientRect().width;
|
|
66933
|
+
}
|
|
66934
|
+
if (typeof availableWidth === "number" && !Number.isNaN(availableWidth)) {
|
|
66935
|
+
availableWidth = Math.max(availableWidth - 2, 0);
|
|
66936
|
+
} else {
|
|
66937
|
+
availableWidth = null;
|
|
66938
|
+
}
|
|
66939
|
+
const pageStyles = editor?.converter?.pageStyles;
|
|
66940
|
+
if (pageStyles?.pageSize?.width) {
|
|
66941
|
+
const toNumber2 = (v2) => typeof v2 === "number" ? v2 : parseFloat(v2) || 0;
|
|
66942
|
+
const pageWidth = toNumber2(pageStyles.pageSize.width);
|
|
66943
|
+
const marginLeft = toNumber2(pageStyles.pageMargins?.left);
|
|
66944
|
+
const marginRight = toNumber2(pageStyles.pageMargins?.right);
|
|
66945
|
+
const pageAvailableWidthPx = Math.max((pageWidth - marginLeft - marginRight) * PIXELS_PER_INCH, 0);
|
|
66946
|
+
if (pageAvailableWidthPx > 0) {
|
|
66947
|
+
availableWidth = availableWidth ? Math.min(availableWidth, pageAvailableWidthPx) : pageAvailableWidthPx;
|
|
66948
|
+
}
|
|
66949
|
+
}
|
|
66950
|
+
const resolveColumnWidth = (colIndex2, colwidthValue) => {
|
|
66951
|
+
if (overrideCol === colIndex2) return overrideValue;
|
|
66952
|
+
if (colwidthValue != null) return colwidthValue;
|
|
66953
|
+
if (gridColumns && gridColumns[colIndex2] != null) return gridColumns[colIndex2];
|
|
66954
|
+
return null;
|
|
66955
|
+
};
|
|
66956
|
+
const widths = [];
|
|
66701
66957
|
const row = node.firstChild;
|
|
66958
|
+
let colIndex = 0;
|
|
66702
66959
|
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
|
-
}
|
|
66960
|
+
for (let i2 = 0; i2 < row.childCount; i2++) {
|
|
66961
|
+
const child = row.child(i2);
|
|
66962
|
+
const { colspan, colwidth } = child.attrs;
|
|
66963
|
+
for (let span = 0; span < colspan; span += 1, colIndex += 1) {
|
|
66964
|
+
widths.push(resolveColumnWidth(colIndex, colwidth && colwidth[span]));
|
|
66722
66965
|
}
|
|
66723
66966
|
}
|
|
66724
66967
|
}
|
|
66725
|
-
|
|
66726
|
-
|
|
66727
|
-
|
|
66728
|
-
|
|
66968
|
+
if (totalColumns != null && colIndex < totalColumns) {
|
|
66969
|
+
for (let col = colIndex; col < totalColumns; col += 1) {
|
|
66970
|
+
widths.push(resolveColumnWidth(col));
|
|
66971
|
+
}
|
|
66729
66972
|
}
|
|
66730
|
-
|
|
66731
|
-
|
|
66973
|
+
const normalizedWidths = widths.map((widthPx) => {
|
|
66974
|
+
const numericWidth = Number(widthPx);
|
|
66975
|
+
if (!Number.isFinite(numericWidth)) return null;
|
|
66976
|
+
if (numericWidth < 0) return null;
|
|
66977
|
+
if (numericWidth === 0) return 0;
|
|
66978
|
+
if (numericWidth < 1) return 0;
|
|
66979
|
+
return numericWidth;
|
|
66980
|
+
});
|
|
66981
|
+
const rawTotalWidth = normalizedWidths.reduce((sum, width) => sum + (width != null ? width : cellMinWidth2), 0);
|
|
66982
|
+
let scale = 1;
|
|
66983
|
+
if (availableWidth && rawTotalWidth > 0 && rawTotalWidth > availableWidth) {
|
|
66984
|
+
scale = availableWidth / rawTotalWidth;
|
|
66985
|
+
}
|
|
66986
|
+
let totalWidth = 0;
|
|
66987
|
+
let hasUndefinedWidth = false;
|
|
66988
|
+
let dom = colgroup.firstChild;
|
|
66989
|
+
normalizedWidths.forEach((width) => {
|
|
66990
|
+
let scaledWidth = width;
|
|
66991
|
+
if (scaledWidth != null) {
|
|
66992
|
+
scaledWidth = scaledWidth * scale;
|
|
66993
|
+
}
|
|
66994
|
+
const [propKey, propVal] = getColStyleDeclaration(cellMinWidth2, scaledWidth);
|
|
66995
|
+
if (scaledWidth == null) {
|
|
66996
|
+
totalWidth += cellMinWidth2;
|
|
66997
|
+
hasUndefinedWidth = true;
|
|
66998
|
+
} else {
|
|
66999
|
+
totalWidth += scaledWidth;
|
|
67000
|
+
}
|
|
67001
|
+
if (!dom) {
|
|
67002
|
+
const colElement = document.createElement("col");
|
|
67003
|
+
colElement.style.setProperty(propKey, propVal);
|
|
67004
|
+
colgroup.appendChild(colElement);
|
|
67005
|
+
} else {
|
|
67006
|
+
dom.style.setProperty(propKey, propVal);
|
|
67007
|
+
dom = dom.nextSibling;
|
|
67008
|
+
}
|
|
67009
|
+
});
|
|
67010
|
+
while (dom) {
|
|
67011
|
+
const next = dom.nextSibling;
|
|
67012
|
+
dom.parentNode?.removeChild(dom);
|
|
67013
|
+
dom = next;
|
|
67014
|
+
}
|
|
67015
|
+
if (scale < 1 || !hasUndefinedWidth) {
|
|
67016
|
+
const clampedWidth = Math.min(totalWidth, availableWidth || totalWidth);
|
|
67017
|
+
table.style.width = `${clampedWidth}px`;
|
|
66732
67018
|
table.style.minWidth = "";
|
|
66733
67019
|
} else {
|
|
66734
67020
|
table.style.width = "";
|
|
66735
67021
|
table.style.minWidth = `${totalWidth}px`;
|
|
66736
67022
|
}
|
|
67023
|
+
table.style.maxWidth = "100%";
|
|
66737
67024
|
}
|
|
66738
67025
|
function updateTable(editor, node, table) {
|
|
66739
67026
|
const allExtensionsAttrs = editor.extensionService.attributes;
|
|
@@ -66811,22 +67098,61 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66811
67098
|
const tableBorders = createTableBorders();
|
|
66812
67099
|
return types2.table.createChecked({ borders: tableBorders }, rows);
|
|
66813
67100
|
};
|
|
67101
|
+
const MIN_MEANINGFUL_WIDTH_PX = 1;
|
|
66814
67102
|
const createColGroup = (node, cellMinWidth2, overrideCol, overrideValue) => {
|
|
66815
67103
|
let totalWidth = 0;
|
|
66816
67104
|
let fixedWidth = true;
|
|
66817
67105
|
const cols = [];
|
|
66818
67106
|
const colsValues = [];
|
|
66819
67107
|
const row = node.firstChild;
|
|
67108
|
+
const gridColumns = Array.isArray(node.attrs?.grid) && node.attrs.grid.length ? node.attrs.grid.map((col) => twipsToPixels(col.col)) : null;
|
|
66820
67109
|
if (!row) return {};
|
|
66821
|
-
|
|
66822
|
-
|
|
66823
|
-
|
|
66824
|
-
|
|
66825
|
-
|
|
66826
|
-
|
|
66827
|
-
|
|
67110
|
+
const totalColumns = gridColumns?.length;
|
|
67111
|
+
const resolveColumnWidth = (colIndex2, colwidthValue) => {
|
|
67112
|
+
if (overrideCol === colIndex2) return overrideValue;
|
|
67113
|
+
if (colwidthValue != null) return colwidthValue;
|
|
67114
|
+
if (gridColumns && gridColumns[colIndex2] != null) return gridColumns[colIndex2];
|
|
67115
|
+
return null;
|
|
67116
|
+
};
|
|
67117
|
+
let colIndex = 0;
|
|
67118
|
+
for (let i2 = 0; i2 < row.childCount; i2++) {
|
|
67119
|
+
const child = row.child(i2);
|
|
67120
|
+
const { colspan, colwidth } = child.attrs;
|
|
67121
|
+
for (let j2 = 0; j2 < colspan; j2++, colIndex++) {
|
|
67122
|
+
const candidateWidth = resolveColumnWidth(colIndex, colwidth && colwidth[j2]);
|
|
67123
|
+
const numericWidth = Number(candidateWidth);
|
|
67124
|
+
let effectiveWidth = Number.isFinite(numericWidth) && numericWidth > 0 ? numericWidth : null;
|
|
67125
|
+
if (effectiveWidth != null && effectiveWidth < MIN_MEANINGFUL_WIDTH_PX) {
|
|
67126
|
+
effectiveWidth = 0;
|
|
67127
|
+
}
|
|
67128
|
+
if (effectiveWidth == null) {
|
|
67129
|
+
totalWidth += cellMinWidth2;
|
|
67130
|
+
fixedWidth = false;
|
|
67131
|
+
} else {
|
|
67132
|
+
totalWidth += effectiveWidth;
|
|
67133
|
+
}
|
|
67134
|
+
const [prop, value] = getColStyleDeclaration(cellMinWidth2, effectiveWidth);
|
|
67135
|
+
cols.push(["col", { style: `${prop}: ${value}` }]);
|
|
67136
|
+
colsValues.push(parseFloat(value));
|
|
67137
|
+
}
|
|
67138
|
+
}
|
|
67139
|
+
if (totalColumns != null) {
|
|
67140
|
+
for (let col = colIndex; col < totalColumns; col++) {
|
|
67141
|
+
const candidateWidth = resolveColumnWidth(col);
|
|
67142
|
+
const numericWidth = Number(candidateWidth);
|
|
67143
|
+
let effectiveWidth = Number.isFinite(numericWidth) && numericWidth > 0 ? numericWidth : null;
|
|
67144
|
+
if (effectiveWidth != null && effectiveWidth < MIN_MEANINGFUL_WIDTH_PX) {
|
|
67145
|
+
effectiveWidth = 0;
|
|
67146
|
+
}
|
|
67147
|
+
if (effectiveWidth == null) {
|
|
67148
|
+
totalWidth += cellMinWidth2;
|
|
67149
|
+
fixedWidth = false;
|
|
67150
|
+
} else {
|
|
67151
|
+
totalWidth += effectiveWidth;
|
|
67152
|
+
}
|
|
67153
|
+
const [prop, value] = getColStyleDeclaration(cellMinWidth2, effectiveWidth);
|
|
66828
67154
|
cols.push(["col", { style: `${prop}: ${value}` }]);
|
|
66829
|
-
colsValues.push(
|
|
67155
|
+
colsValues.push(parseFloat(value));
|
|
66830
67156
|
}
|
|
66831
67157
|
}
|
|
66832
67158
|
const tableWidth = fixedWidth ? `${totalWidth}px` : "";
|
|
@@ -69729,6 +70055,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
69729
70055
|
"data-colwidth": attrs.colwidth.join(",")
|
|
69730
70056
|
};
|
|
69731
70057
|
}
|
|
70058
|
+
},
|
|
70059
|
+
__placeholder: {
|
|
70060
|
+
default: null,
|
|
70061
|
+
parseDOM: (element) => {
|
|
70062
|
+
const value = element.getAttribute("data-placeholder");
|
|
70063
|
+
return value || null;
|
|
70064
|
+
},
|
|
70065
|
+
renderDOM({ __placeholder }) {
|
|
70066
|
+
if (!__placeholder) return {};
|
|
70067
|
+
return {
|
|
70068
|
+
"data-placeholder": __placeholder
|
|
70069
|
+
};
|
|
70070
|
+
}
|
|
69732
70071
|
}
|
|
69733
70072
|
};
|
|
69734
70073
|
},
|
|
@@ -69889,6 +70228,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
69889
70228
|
default: "px",
|
|
69890
70229
|
rendered: false
|
|
69891
70230
|
},
|
|
70231
|
+
__placeholder: {
|
|
70232
|
+
default: null,
|
|
70233
|
+
parseDOM: (element) => {
|
|
70234
|
+
const value = element.getAttribute("data-placeholder");
|
|
70235
|
+
return value || null;
|
|
70236
|
+
},
|
|
70237
|
+
renderDOM({ __placeholder }) {
|
|
70238
|
+
if (!__placeholder) return {};
|
|
70239
|
+
return {
|
|
70240
|
+
"data-placeholder": __placeholder
|
|
70241
|
+
};
|
|
70242
|
+
}
|
|
70243
|
+
},
|
|
69892
70244
|
/**
|
|
69893
70245
|
* @category Attribute
|
|
69894
70246
|
* @param {TableCellProperties} tableCellProperties - Properties for the table cell.
|
|
@@ -113053,17 +113405,62 @@ ${style2}
|
|
|
113053
113405
|
const highContrastModeStore = useHighContrastMode();
|
|
113054
113406
|
return { app, pinia, superdocStore, commentsStore, highContrastModeStore };
|
|
113055
113407
|
};
|
|
113056
|
-
const
|
|
113408
|
+
const MIME_TYPES = {
|
|
113409
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
113410
|
+
pdf: "application/pdf",
|
|
113411
|
+
zip: "application/zip",
|
|
113412
|
+
html: "text/html",
|
|
113413
|
+
txt: "text/plain;charset=utf-8",
|
|
113414
|
+
json: "application/json"
|
|
113415
|
+
};
|
|
113416
|
+
const getMimeType = (extension) => {
|
|
113417
|
+
if (!extension || typeof extension.toLowerCase !== "function") return "application/octet-stream";
|
|
113418
|
+
return MIME_TYPES[extension.toLowerCase()] || "application/octet-stream";
|
|
113419
|
+
};
|
|
113420
|
+
const ensureBlob = (data, extension) => {
|
|
113421
|
+
if (data instanceof Blob) return data;
|
|
113422
|
+
const mimeType = getMimeType(extension);
|
|
113423
|
+
if (data instanceof ArrayBuffer) {
|
|
113424
|
+
return new Blob([data], { type: mimeType });
|
|
113425
|
+
}
|
|
113426
|
+
if (ArrayBuffer.isView(data)) {
|
|
113427
|
+
const { buffer: buffer2, byteOffset, byteLength: byteLength2 } = data;
|
|
113428
|
+
const slice = buffer2.slice(byteOffset, byteOffset + byteLength2);
|
|
113429
|
+
return new Blob([slice], { type: mimeType });
|
|
113430
|
+
}
|
|
113431
|
+
if (typeof data === "string") {
|
|
113432
|
+
return new Blob([data], { type: mimeType });
|
|
113433
|
+
}
|
|
113434
|
+
if (data == null) {
|
|
113435
|
+
throw new TypeError("createDownload requires a Blob, ArrayBuffer, or ArrayBufferView.");
|
|
113436
|
+
}
|
|
113437
|
+
throw new TypeError(`Cannot create download from value of type ${typeof data}`);
|
|
113438
|
+
};
|
|
113439
|
+
const createDownload = (data, name, extension) => {
|
|
113440
|
+
const blob = ensureBlob(data, extension);
|
|
113441
|
+
if (typeof URL === "undefined" || typeof URL.createObjectURL !== "function") return blob;
|
|
113442
|
+
if (typeof document === "undefined" || typeof document.createElement !== "function") return blob;
|
|
113057
113443
|
const url = URL.createObjectURL(blob);
|
|
113058
113444
|
const a = document.createElement("a");
|
|
113059
113445
|
a.href = url;
|
|
113060
113446
|
a.download = `${name}.${extension}`;
|
|
113447
|
+
const shouldAppend = document.body && typeof document.body.appendChild === "function";
|
|
113448
|
+
if (shouldAppend) document.body.appendChild(a);
|
|
113061
113449
|
a.click();
|
|
113450
|
+
if (shouldAppend) document.body.removeChild(a);
|
|
113451
|
+
if (typeof URL.revokeObjectURL === "function") {
|
|
113452
|
+
setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
113453
|
+
}
|
|
113454
|
+
return blob;
|
|
113062
113455
|
};
|
|
113063
113456
|
const cleanName = (currentName) => {
|
|
113064
|
-
|
|
113457
|
+
const lowerName = currentName.toLowerCase();
|
|
113458
|
+
if (lowerName.endsWith(".docx")) {
|
|
113065
113459
|
return currentName.slice(0, -5);
|
|
113066
113460
|
}
|
|
113461
|
+
if (lowerName.endsWith(".pdf")) {
|
|
113462
|
+
return currentName.slice(0, -4);
|
|
113463
|
+
}
|
|
113067
113464
|
return currentName;
|
|
113068
113465
|
};
|
|
113069
113466
|
class SuperDoc extends EventEmitter {
|
|
@@ -113681,14 +114078,25 @@ ${style2}
|
|
|
113681
114078
|
comments.push(...this.commentsStore.translateCommentsForExport());
|
|
113682
114079
|
}
|
|
113683
114080
|
}
|
|
113684
|
-
const docxPromises =
|
|
113685
|
-
|
|
113686
|
-
const editor = doc2.getEditor();
|
|
113687
|
-
|
|
113688
|
-
|
|
114081
|
+
const docxPromises = this.superdocStore.documents.map(async (doc2) => {
|
|
114082
|
+
if (!doc2 || doc2.type !== DOCX) return null;
|
|
114083
|
+
const editor = typeof doc2.getEditor === "function" ? doc2.getEditor() : null;
|
|
114084
|
+
const fallbackDocx = () => {
|
|
114085
|
+
if (!doc2.data) return null;
|
|
114086
|
+
if (doc2.data.type && doc2.data.type !== DOCX) return null;
|
|
114087
|
+
return doc2.data;
|
|
114088
|
+
};
|
|
114089
|
+
if (!editor) return fallbackDocx();
|
|
114090
|
+
try {
|
|
114091
|
+
const exported = await editor.exportDocx({ isFinalDoc, comments, commentsType, fieldsHighlightColor });
|
|
114092
|
+
if (exported) return exported;
|
|
114093
|
+
} catch (error) {
|
|
114094
|
+
this.emit("exception", { error, document: doc2 });
|
|
113689
114095
|
}
|
|
114096
|
+
return fallbackDocx();
|
|
113690
114097
|
});
|
|
113691
|
-
|
|
114098
|
+
const docxFiles = await Promise.all(docxPromises);
|
|
114099
|
+
return docxFiles.filter(Boolean);
|
|
113692
114100
|
}
|
|
113693
114101
|
/**
|
|
113694
114102
|
* Request an immediate save from all collaboration documents
|