@harbour-enterprises/superdoc 0.22.0-next.5 → 0.22.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-dsL5uHg1.es.js → PdfViewer-BMfm6DSP.es.js} +1 -1
- package/dist/chunks/{PdfViewer-Badqoc1e.cjs → PdfViewer-XMDxj-2m.cjs} +1 -1
- package/dist/chunks/{index-DVrbZM76.cjs → index-BlNiELtW.cjs} +2 -2
- package/dist/chunks/{index-DBNzXf1D.es.js → index-Cvi1utmk.es.js} +2 -2
- package/dist/chunks/{super-editor.es-p3eqHXlj.cjs → super-editor.es-BDsfLrnI.cjs} +90 -2
- package/dist/chunks/{super-editor.es-DruRanWK.es.js → super-editor.es-CmQ5GChv.es.js} +90 -2
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-DujfV3Zn.js → converter-D9kK7Smo.js} +90 -2
- package/dist/super-editor/chunks/{docx-zipper-DccEqL60.js → docx-zipper-D8HnWWpv.js} +1 -1
- package/dist/super-editor/chunks/{editor-Dq3xPdti.js → editor-Ddkz97dH.js} +2 -2
- package/dist/super-editor/chunks/{toolbar-u5oyT_9K.js → toolbar-BxjdbiUf.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/src/core/super-converter/helpers/tableFallbackHelpers.d.ts +24 -0
- package/dist/super-editor/super-editor.es.js +6 -6
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +90 -2
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/superdoc.umd.js
CHANGED
|
@@ -34902,6 +34902,68 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34902
34902
|
decode: decode$h
|
|
34903
34903
|
};
|
|
34904
34904
|
const translator$a = NodeTranslator.from(config$a);
|
|
34905
|
+
const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
|
|
34906
|
+
const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
|
|
34907
|
+
const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
|
|
34908
|
+
const MIN_COLUMN_WIDTH_TWIPS = pixelsToTwips(10);
|
|
34909
|
+
const pctToPercent = (value) => {
|
|
34910
|
+
if (value == null) return null;
|
|
34911
|
+
return value / 50;
|
|
34912
|
+
};
|
|
34913
|
+
const resolveContentWidthTwips = () => DEFAULT_CONTENT_WIDTH_TWIPS;
|
|
34914
|
+
const resolveMeasurementWidthPx = (measurement) => {
|
|
34915
|
+
if (!measurement || typeof measurement.value !== "number" || measurement.value <= 0) return null;
|
|
34916
|
+
const { value, type: type2 } = measurement;
|
|
34917
|
+
if (!type2 || type2 === "auto") return null;
|
|
34918
|
+
if (type2 === "dxa") return twipsToPixels(value);
|
|
34919
|
+
if (type2 === "pct") {
|
|
34920
|
+
const percent2 = pctToPercent(value);
|
|
34921
|
+
if (percent2 == null || percent2 <= 0) return null;
|
|
34922
|
+
const widthTwips = resolveContentWidthTwips() * percent2 / 100;
|
|
34923
|
+
return twipsToPixels(widthTwips);
|
|
34924
|
+
}
|
|
34925
|
+
return null;
|
|
34926
|
+
};
|
|
34927
|
+
const countColumnsInRow = (row) => {
|
|
34928
|
+
if (!row?.elements?.length) return 0;
|
|
34929
|
+
return row.elements.reduce((count, element) => {
|
|
34930
|
+
if (element.name !== "w:tc") return count;
|
|
34931
|
+
const tcPr = element.elements?.find((el) => el.name === "w:tcPr");
|
|
34932
|
+
const gridSpan = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
34933
|
+
const spanValue = parseInt(gridSpan?.attributes?.["w:val"] || "1", 10);
|
|
34934
|
+
return count + (Number.isFinite(spanValue) && spanValue > 0 ? spanValue : 1);
|
|
34935
|
+
}, 0);
|
|
34936
|
+
};
|
|
34937
|
+
const clampColumnWidthTwips = (value) => Math.max(Math.round(value), MIN_COLUMN_WIDTH_TWIPS);
|
|
34938
|
+
const createFallbackGrid = (columnCount, columnWidthTwips) => Array.from({ length: columnCount }, () => ({ col: clampColumnWidthTwips(columnWidthTwips) }));
|
|
34939
|
+
const buildFallbackGridForTable = ({ params: params2, rows, tableWidth, tableWidthMeasurement }) => {
|
|
34940
|
+
const firstRow = rows.find((row) => row.elements?.some((el) => el.name === "w:tc"));
|
|
34941
|
+
const columnCount = countColumnsInRow(firstRow);
|
|
34942
|
+
if (!columnCount) return null;
|
|
34943
|
+
const schemaDefaultPx = getSchemaDefaultColumnWidthPx(
|
|
34944
|
+
/** @type {any} */
|
|
34945
|
+
params2
|
|
34946
|
+
);
|
|
34947
|
+
const minimumColumnWidthPx = Number.isFinite(schemaDefaultPx) && schemaDefaultPx > 0 ? schemaDefaultPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
34948
|
+
let totalWidthPx;
|
|
34949
|
+
if (tableWidthMeasurement) {
|
|
34950
|
+
const resolved = resolveMeasurementWidthPx(tableWidthMeasurement);
|
|
34951
|
+
if (resolved != null) totalWidthPx = resolved;
|
|
34952
|
+
}
|
|
34953
|
+
if (totalWidthPx == null && tableWidth?.width && tableWidth.width > 0) {
|
|
34954
|
+
totalWidthPx = tableWidth.width;
|
|
34955
|
+
}
|
|
34956
|
+
if (totalWidthPx == null) {
|
|
34957
|
+
totalWidthPx = minimumColumnWidthPx * columnCount;
|
|
34958
|
+
}
|
|
34959
|
+
const rawColumnWidthPx = Math.max(totalWidthPx / columnCount, minimumColumnWidthPx);
|
|
34960
|
+
const columnWidthTwips = clampColumnWidthTwips(pixelsToTwips(rawColumnWidthPx));
|
|
34961
|
+
const fallbackColumnWidthPx = twipsToPixels(columnWidthTwips);
|
|
34962
|
+
return {
|
|
34963
|
+
grid: createFallbackGrid(columnCount, columnWidthTwips),
|
|
34964
|
+
columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
|
|
34965
|
+
};
|
|
34966
|
+
};
|
|
34905
34967
|
const XML_NODE_NAME$9 = "w:tbl";
|
|
34906
34968
|
const SD_NODE_NAME$9 = "table";
|
|
34907
34969
|
const encode$g = (params2, encodedAttrs) => {
|
|
@@ -34921,7 +34983,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34921
34983
|
"justification",
|
|
34922
34984
|
"tableLayout",
|
|
34923
34985
|
["tableIndent", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
34924
|
-
["tableWidth", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
34925
34986
|
["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
|
|
34926
34987
|
].forEach((prop) => {
|
|
34927
34988
|
let key2;
|
|
@@ -34939,6 +35000,21 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34939
35000
|
if (encodedAttrs.tableCellSpacing) {
|
|
34940
35001
|
encodedAttrs["borderCollapse"] = "separate";
|
|
34941
35002
|
}
|
|
35003
|
+
if (encodedAttrs.tableProperties?.tableWidth) {
|
|
35004
|
+
const tableWidthMeasurement = encodedAttrs.tableProperties.tableWidth;
|
|
35005
|
+
const widthPx = twipsToPixels(tableWidthMeasurement.value);
|
|
35006
|
+
if (widthPx != null) {
|
|
35007
|
+
encodedAttrs.tableWidth = {
|
|
35008
|
+
width: widthPx,
|
|
35009
|
+
type: tableWidthMeasurement.type
|
|
35010
|
+
};
|
|
35011
|
+
} else if (tableWidthMeasurement.type === "auto") {
|
|
35012
|
+
encodedAttrs.tableWidth = {
|
|
35013
|
+
width: 0,
|
|
35014
|
+
type: tableWidthMeasurement.type
|
|
35015
|
+
};
|
|
35016
|
+
}
|
|
35017
|
+
}
|
|
34942
35018
|
const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
|
|
34943
35019
|
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2);
|
|
34944
35020
|
if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
|
|
@@ -34952,7 +35028,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34952
35028
|
const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
|
|
34953
35029
|
encodedAttrs["borders"] = borderData;
|
|
34954
35030
|
const tblStyleTag = tblPr?.elements?.find((el) => el.name === "w:tblStyle");
|
|
34955
|
-
|
|
35031
|
+
let columnWidths = Array.isArray(encodedAttrs["grid"]) ? encodedAttrs["grid"].map((item) => twipsToPixels(item.col)) : [];
|
|
35032
|
+
if (!columnWidths.length) {
|
|
35033
|
+
const fallback = buildFallbackGridForTable({
|
|
35034
|
+
params: params2,
|
|
35035
|
+
rows,
|
|
35036
|
+
tableWidth: encodedAttrs.tableWidth,
|
|
35037
|
+
tableWidthMeasurement: encodedAttrs.tableProperties?.tableWidth
|
|
35038
|
+
});
|
|
35039
|
+
if (fallback) {
|
|
35040
|
+
encodedAttrs.grid = fallback.grid;
|
|
35041
|
+
columnWidths = fallback.columnWidths;
|
|
35042
|
+
}
|
|
35043
|
+
}
|
|
34956
35044
|
const content = [];
|
|
34957
35045
|
rows.forEach((row) => {
|
|
34958
35046
|
const result = translator$G.encode({
|