superdoc 0.31.0-next.5 → 0.31.0-next.7
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-DXwcotXc.cjs → PdfViewer-C_gVEaJa.cjs} +1 -1
- package/dist/chunks/{PdfViewer-BjFaPQBd.es.js → PdfViewer-HhmcCtfd.es.js} +1 -1
- package/dist/chunks/{index-B7dC-H-Q-DfBEU7rR.cjs → index-BJ6cOegF-BuvRSNoV.cjs} +1 -1
- package/dist/chunks/{index-B7dC-H-Q-BeQx_MXI.es.js → index-BJ6cOegF-C-oX4LAe.es.js} +1 -1
- package/dist/chunks/{index-B6TttOzK.es.js → index-Cz10rZ5n.es.js} +3 -3
- package/dist/chunks/{index-BF_Yvius.cjs → index-wLtubQ87.cjs} +3 -3
- package/dist/chunks/{super-editor.es-CVDIAxlg.cjs → super-editor.es-Bz-s1Pw4.cjs} +351 -155
- package/dist/chunks/{super-editor.es-M2e4wbRW.es.js → super-editor.es-C20nShDu.es.js} +351 -155
- package/dist/style.css +10 -9
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-BIsS-JzD.js → converter-DVDL6NWz.js} +100 -53
- package/dist/super-editor/chunks/{docx-zipper-DVDiaIyD.js → docx-zipper-4ipmBNSH.js} +1 -1
- package/dist/super-editor/chunks/{editor-ZbcM1RTL.js → editor-B8v33PJq.js} +253 -104
- package/dist/super-editor/chunks/{index-B7dC-H-Q.js → index-BJ6cOegF.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-8qqw8IXG.js → toolbar-CfUofx7k.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 -9
- package/dist/super-editor/super-editor/src/core/super-converter/helpers.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/helpers.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/styles.d.ts +2 -1
- package/dist/super-editor/super-editor/src/core/super-converter/styles.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/legacy-handle-paragraph-node.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tbl/tbl-translator.d.ts +14 -10
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tbl/tbl-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tr/tr-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/linked-styles/helpers.d.ts +1 -0
- package/dist/super-editor/super-editor/src/extensions/linked-styles/helpers.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/linked-styles/plugin.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/paragraph/paragraph.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content-commands.d.ts +8 -2
- package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content-commands.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentByGroup.d.ts +19 -0
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentByGroup.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/tagUtils.d.ts +53 -0
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/tagUtils.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/extensions/table/TableView.d.ts +7 -1
- package/dist/super-editor/super-editor/src/extensions/table/TableView.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/table/table.d.ts +18 -0
- package/dist/super-editor/super-editor/src/extensions/table/table.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/table-cell/table-cell.d.ts.map +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 +352 -156
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -15426,6 +15426,38 @@ const hasSomeParentWithClass = (element, classname) => {
|
|
|
15426
15426
|
if (element.className?.split(" ")?.indexOf(classname) >= 0) return true;
|
|
15427
15427
|
return element.parentNode && hasSomeParentWithClass(element.parentNode, classname);
|
|
15428
15428
|
};
|
|
15429
|
+
function convertSizeToCSS(value, type2) {
|
|
15430
|
+
if (typeof value === "string" && value.endsWith("%")) {
|
|
15431
|
+
type2 = "pct";
|
|
15432
|
+
}
|
|
15433
|
+
if (value === null || value === void 0) {
|
|
15434
|
+
value = 0;
|
|
15435
|
+
}
|
|
15436
|
+
switch (type2) {
|
|
15437
|
+
case "dxa":
|
|
15438
|
+
case null:
|
|
15439
|
+
case void 0:
|
|
15440
|
+
return `${twipsToPixels(value)}px`;
|
|
15441
|
+
case "nil":
|
|
15442
|
+
return "0";
|
|
15443
|
+
case "auto":
|
|
15444
|
+
return null;
|
|
15445
|
+
case "pct":
|
|
15446
|
+
let percent2;
|
|
15447
|
+
if (typeof value === "number") {
|
|
15448
|
+
percent2 = value * 0.02;
|
|
15449
|
+
} else {
|
|
15450
|
+
if (value.endsWith("%")) {
|
|
15451
|
+
percent2 = parseFloat(value.slice(0, -1));
|
|
15452
|
+
} else {
|
|
15453
|
+
percent2 = parseFloat(value) * 0.02;
|
|
15454
|
+
}
|
|
15455
|
+
}
|
|
15456
|
+
return `${percent2}%`;
|
|
15457
|
+
default:
|
|
15458
|
+
return null;
|
|
15459
|
+
}
|
|
15460
|
+
}
|
|
15429
15461
|
const DEFAULT_DOCX_DEFS = {
|
|
15430
15462
|
"xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
|
15431
15463
|
"xmlns:cx": "http://schemas.microsoft.com/office/drawing/2014/chartex",
|
|
@@ -19238,7 +19270,7 @@ const resolveRunProperties = (params2, inlineRpr, resolvedPpr, isListNumber = fa
|
|
|
19238
19270
|
const finalProps = combineProperties(styleChain, ["fontFamily", "color"]);
|
|
19239
19271
|
return finalProps;
|
|
19240
19272
|
};
|
|
19241
|
-
function resolveParagraphProperties(params2, inlineProps, insideTable = false, overrideInlineStyleId = false) {
|
|
19273
|
+
function resolveParagraphProperties(params2, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) {
|
|
19242
19274
|
const defaultProps2 = getDefaultProperties(params2, translator$12);
|
|
19243
19275
|
const { properties: normalProps, isDefault: isNormalDefault } = getStyleProperties(params2, "Normal", translator$12);
|
|
19244
19276
|
let styleId = inlineProps?.styleId;
|
|
@@ -19263,13 +19295,14 @@ function resolveParagraphProperties(params2, inlineProps, insideTable = false, o
|
|
|
19263
19295
|
}
|
|
19264
19296
|
}
|
|
19265
19297
|
}
|
|
19298
|
+
const tableProps = tableStyleId ? resolveStyleChain(params2, tableStyleId, translator$12) : {};
|
|
19266
19299
|
let defaultsChain;
|
|
19267
19300
|
if (isNormalDefault) {
|
|
19268
19301
|
defaultsChain = [defaultProps2, normalProps];
|
|
19269
19302
|
} else {
|
|
19270
19303
|
defaultsChain = [normalProps, defaultProps2];
|
|
19271
19304
|
}
|
|
19272
|
-
const propsChain = [...defaultsChain, numberingProps, styleProps, inlineProps];
|
|
19305
|
+
const propsChain = [...defaultsChain, tableProps, numberingProps, styleProps, inlineProps];
|
|
19273
19306
|
let indentChain;
|
|
19274
19307
|
if (isList2) {
|
|
19275
19308
|
if (numberingDefinedInline) {
|
|
@@ -20020,6 +20053,21 @@ function getStrikeValue(attributes) {
|
|
|
20020
20053
|
if (value === "0" || value === "false" || value === "off") return "0";
|
|
20021
20054
|
return "1";
|
|
20022
20055
|
}
|
|
20056
|
+
function getTableStyleId(path) {
|
|
20057
|
+
const tbl = path.find((ancestor) => ancestor.name === "w:tbl");
|
|
20058
|
+
if (!tbl) {
|
|
20059
|
+
return;
|
|
20060
|
+
}
|
|
20061
|
+
const tblPr = tbl.elements?.find((child) => child.name === "w:tblPr");
|
|
20062
|
+
if (!tblPr) {
|
|
20063
|
+
return;
|
|
20064
|
+
}
|
|
20065
|
+
const tblStyle = tblPr.elements?.find((child) => child.name === "w:tblStyle");
|
|
20066
|
+
if (!tblStyle) {
|
|
20067
|
+
return;
|
|
20068
|
+
}
|
|
20069
|
+
return tblStyle.attributes?.["w:val"];
|
|
20070
|
+
}
|
|
20023
20071
|
const handleParagraphNode$1 = (params2) => {
|
|
20024
20072
|
const { nodes, nodeListHandler, filename } = params2;
|
|
20025
20073
|
const node = carbonCopy(nodes[0]);
|
|
@@ -20030,7 +20078,14 @@ const handleParagraphNode$1 = (params2) => {
|
|
|
20030
20078
|
inlineParagraphProperties = translator$12.encode({ ...params2, nodes: [pPr] }) || {};
|
|
20031
20079
|
}
|
|
20032
20080
|
const insideTable = (params2.path || []).some((ancestor) => ancestor.name === "w:tc");
|
|
20033
|
-
const
|
|
20081
|
+
const tableStyleId = getTableStyleId(params2.path || []);
|
|
20082
|
+
const resolvedParagraphProperties = resolveParagraphProperties(
|
|
20083
|
+
params2,
|
|
20084
|
+
inlineParagraphProperties,
|
|
20085
|
+
insideTable,
|
|
20086
|
+
false,
|
|
20087
|
+
tableStyleId
|
|
20088
|
+
);
|
|
20034
20089
|
const handleStandardNode2 = nodeListHandler.handlerEntities.find(
|
|
20035
20090
|
(e) => e.handlerName === "standardNodeHandler"
|
|
20036
20091
|
)?.handler;
|
|
@@ -21385,6 +21440,7 @@ const encode$m = (params2, encodedAttrs) => {
|
|
|
21385
21440
|
const columnWidth = gridColumnWidths?.[startColumn] || null;
|
|
21386
21441
|
const result = translator$G.encode({
|
|
21387
21442
|
...params2,
|
|
21443
|
+
path: [...params2.path || [], node],
|
|
21388
21444
|
extraParams: {
|
|
21389
21445
|
...params2.extraParams,
|
|
21390
21446
|
node,
|
|
@@ -31555,14 +31611,15 @@ const decode$j = (params2) => {
|
|
|
31555
31611
|
const grid = Array.isArray(rawGrid) ? rawGrid : [];
|
|
31556
31612
|
const { firstRow = {} } = params2.extraParams || {};
|
|
31557
31613
|
const cellNodes = firstRow.content?.filter((n) => n.type === "tableCell") ?? [];
|
|
31558
|
-
const
|
|
31614
|
+
const colWidthsFromCellNodes = cellNodes.flatMap((cell) => {
|
|
31559
31615
|
const spanCount = Math.max(1, cell?.attrs?.colspan ?? 1);
|
|
31560
|
-
|
|
31561
|
-
|
|
31616
|
+
const colwidth = cell.attrs?.colwidth;
|
|
31617
|
+
return Array.from({ length: spanCount }).map((_2, span) => Array.isArray(colwidth) ? colwidth[span] : void 0);
|
|
31618
|
+
});
|
|
31619
|
+
const columnCountFromCells = colWidthsFromCellNodes.length;
|
|
31562
31620
|
const totalColumns = Math.max(columnCountFromCells, grid.length);
|
|
31563
31621
|
const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params2, totalColumns, cellMinWidth);
|
|
31564
31622
|
const elements = [];
|
|
31565
|
-
let columnIndex = 0;
|
|
31566
31623
|
const pushColumn = (widthTwips, { enforceMinimum = false } = {}) => {
|
|
31567
31624
|
let numericWidth = typeof widthTwips === "string" ? parseInt(widthTwips, 10) : widthTwips;
|
|
31568
31625
|
let shouldEnforceMinimum = enforceMinimum;
|
|
@@ -31581,39 +31638,29 @@ const decode$j = (params2) => {
|
|
|
31581
31638
|
});
|
|
31582
31639
|
if (decoded) elements.push(decoded);
|
|
31583
31640
|
};
|
|
31584
|
-
|
|
31585
|
-
const
|
|
31586
|
-
const
|
|
31587
|
-
|
|
31588
|
-
|
|
31589
|
-
|
|
31590
|
-
|
|
31591
|
-
|
|
31592
|
-
|
|
31593
|
-
|
|
31594
|
-
|
|
31595
|
-
|
|
31596
|
-
|
|
31597
|
-
|
|
31598
|
-
if (gridWidthTwips != null && gridWidthPixels != null && Math.abs(gridWidthPixels - cellWidthPixels) <= tolerance) {
|
|
31599
|
-
cellWidthTwips = gridWidthTwips;
|
|
31600
|
-
} else {
|
|
31601
|
-
cellWidthTwips = pixelsToTwips(cellWidthPixels);
|
|
31602
|
-
}
|
|
31603
|
-
} else if (gridWidthTwips != null) {
|
|
31641
|
+
for (let columnIndex = 0; columnIndex < totalColumns; ++columnIndex) {
|
|
31642
|
+
const rawWidth = colWidthsFromCellNodes[columnIndex];
|
|
31643
|
+
const cellWidthPixels = typeof rawWidth === "number" && Number.isFinite(rawWidth) ? rawWidth : Number(rawWidth);
|
|
31644
|
+
const hasCellWidth = Number.isFinite(cellWidthPixels) && cellWidthPixels > 0;
|
|
31645
|
+
const colGridAttrs = grid?.[columnIndex] || {};
|
|
31646
|
+
const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
|
|
31647
|
+
const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
|
|
31648
|
+
let cellWidthTwips;
|
|
31649
|
+
let enforceMinimum = false;
|
|
31650
|
+
if (gridWidthTwips != null) {
|
|
31651
|
+
cellWidthTwips = gridWidthTwips;
|
|
31652
|
+
} else if (hasCellWidth) {
|
|
31653
|
+
const tolerance = 0.5;
|
|
31654
|
+
if (gridWidthTwips != null && gridWidthPixels != null && Math.abs(gridWidthPixels - cellWidthPixels) <= tolerance) {
|
|
31604
31655
|
cellWidthTwips = gridWidthTwips;
|
|
31605
31656
|
} else {
|
|
31606
|
-
cellWidthTwips =
|
|
31607
|
-
enforceMinimum = true;
|
|
31657
|
+
cellWidthTwips = pixelsToTwips(cellWidthPixels);
|
|
31608
31658
|
}
|
|
31609
|
-
|
|
31610
|
-
|
|
31659
|
+
} else {
|
|
31660
|
+
cellWidthTwips = fallbackColumnWidthTwips;
|
|
31661
|
+
enforceMinimum = true;
|
|
31611
31662
|
}
|
|
31612
|
-
|
|
31613
|
-
while (columnIndex < grid.length) {
|
|
31614
|
-
const gridWidthTwips = normalizeTwipWidth(grid[columnIndex]?.col);
|
|
31615
|
-
pushColumn(gridWidthTwips);
|
|
31616
|
-
columnIndex++;
|
|
31663
|
+
pushColumn(cellWidthTwips, { enforceMinimum });
|
|
31617
31664
|
}
|
|
31618
31665
|
const newNode = {
|
|
31619
31666
|
name: XML_NODE_NAME$b,
|
|
@@ -31700,6 +31747,8 @@ const encode$g = (params2, encodedAttrs) => {
|
|
|
31700
31747
|
if (tblPr) {
|
|
31701
31748
|
const encodedProperties = translator$c.encode({ ...params2, nodes: [tblPr] });
|
|
31702
31749
|
encodedAttrs["tableProperties"] = encodedProperties || {};
|
|
31750
|
+
} else {
|
|
31751
|
+
encodedAttrs["tableProperties"] || (encodedAttrs["tableProperties"] = {});
|
|
31703
31752
|
}
|
|
31704
31753
|
const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
|
|
31705
31754
|
if (tblGrid) {
|
|
@@ -31720,14 +31769,14 @@ const encode$g = (params2, encodedAttrs) => {
|
|
|
31720
31769
|
key2 = prop;
|
|
31721
31770
|
transform = (v2) => v2;
|
|
31722
31771
|
}
|
|
31723
|
-
if (encodedAttrs.tableProperties
|
|
31772
|
+
if (encodedAttrs.tableProperties[key2]) {
|
|
31724
31773
|
encodedAttrs[key2] = transform(encodedAttrs.tableProperties[key2]);
|
|
31725
31774
|
}
|
|
31726
31775
|
});
|
|
31727
31776
|
if (encodedAttrs.tableCellSpacing) {
|
|
31728
31777
|
encodedAttrs["borderCollapse"] = "separate";
|
|
31729
31778
|
}
|
|
31730
|
-
if (encodedAttrs.tableProperties
|
|
31779
|
+
if (encodedAttrs.tableProperties.tableWidth) {
|
|
31731
31780
|
const tableWidthMeasurement = encodedAttrs.tableProperties.tableWidth;
|
|
31732
31781
|
const widthPx = twipsToPixels(tableWidthMeasurement.value);
|
|
31733
31782
|
if (widthPx != null) {
|
|
@@ -31742,25 +31791,22 @@ const encode$g = (params2, encodedAttrs) => {
|
|
|
31742
31791
|
};
|
|
31743
31792
|
}
|
|
31744
31793
|
}
|
|
31745
|
-
const
|
|
31746
|
-
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2);
|
|
31747
|
-
|
|
31748
|
-
|
|
31749
|
-
|
|
31750
|
-
|
|
31751
|
-
|
|
31752
|
-
}
|
|
31794
|
+
const borderProps = _processTableBorders(encodedAttrs.tableProperties.borders || {});
|
|
31795
|
+
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2) || {};
|
|
31796
|
+
const rowBorders = { ...referencedStyles.rowBorders, ...borderProps.rowBorders };
|
|
31797
|
+
encodedAttrs.borders = { ...referencedStyles.borders, ...borderProps.borders };
|
|
31798
|
+
encodedAttrs.tableProperties.cellMargins = referencedStyles.cellMargins = {
|
|
31799
|
+
...referencedStyles.cellMargins,
|
|
31800
|
+
...encodedAttrs.tableProperties.cellMargins
|
|
31801
|
+
};
|
|
31753
31802
|
const rows = node.elements.filter((el) => el.name === "w:tr");
|
|
31754
|
-
const borderData = Object.assign({}, referencedStyles?.borders || {}, borders || {});
|
|
31755
|
-
const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
|
|
31756
|
-
encodedAttrs["borders"] = borderData;
|
|
31757
31803
|
let columnWidths = Array.isArray(encodedAttrs["grid"]) ? encodedAttrs["grid"].map((item) => twipsToPixels(item.col)) : [];
|
|
31758
31804
|
if (!columnWidths.length) {
|
|
31759
31805
|
const fallback = buildFallbackGridForTable({
|
|
31760
31806
|
params: params2,
|
|
31761
31807
|
rows,
|
|
31762
31808
|
tableWidth: encodedAttrs.tableWidth,
|
|
31763
|
-
tableWidthMeasurement: encodedAttrs.tableProperties
|
|
31809
|
+
tableWidthMeasurement: encodedAttrs.tableProperties.tableWidth
|
|
31764
31810
|
});
|
|
31765
31811
|
if (fallback) {
|
|
31766
31812
|
encodedAttrs.grid = fallback.grid;
|
|
@@ -31773,11 +31819,12 @@ const encode$g = (params2, encodedAttrs) => {
|
|
|
31773
31819
|
rows.forEach((row, rowIndex) => {
|
|
31774
31820
|
const result = translator$v.encode({
|
|
31775
31821
|
...params2,
|
|
31822
|
+
path: [...params2.path || [], node],
|
|
31776
31823
|
nodes: [row],
|
|
31777
31824
|
extraParams: {
|
|
31778
31825
|
row,
|
|
31779
31826
|
table: node,
|
|
31780
|
-
rowBorders
|
|
31827
|
+
rowBorders,
|
|
31781
31828
|
columnWidths,
|
|
31782
31829
|
activeRowSpans: activeRowSpans.slice(),
|
|
31783
31830
|
rowIndex,
|
|
@@ -35302,7 +35349,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
35302
35349
|
static getStoredSuperdocVersion(docx) {
|
|
35303
35350
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
35304
35351
|
}
|
|
35305
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.31.0-next.
|
|
35352
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.31.0-next.7") {
|
|
35306
35353
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
35307
35354
|
}
|
|
35308
35355
|
/**
|
|
@@ -52562,7 +52609,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
52562
52609
|
{ default: remarkStringify },
|
|
52563
52610
|
{ default: remarkGfm }
|
|
52564
52611
|
] = await Promise.all([
|
|
52565
|
-
Promise.resolve().then(() => require("./index-
|
|
52612
|
+
Promise.resolve().then(() => require("./index-BJ6cOegF-BuvRSNoV.cjs")),
|
|
52566
52613
|
Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
|
|
52567
52614
|
Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
|
|
52568
52615
|
Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
|
|
@@ -52763,7 +52810,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
52763
52810
|
* Process collaboration migrations
|
|
52764
52811
|
*/
|
|
52765
52812
|
processCollaborationMigrations() {
|
|
52766
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.31.0-next.
|
|
52813
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.31.0-next.7");
|
|
52767
52814
|
if (!this.options.ydoc) return;
|
|
52768
52815
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
52769
52816
|
let docVersion = metaMap.get("version");
|
|
@@ -55172,6 +55219,46 @@ function getStructuredContentTagsById(idOrIds, state2) {
|
|
|
55172
55219
|
});
|
|
55173
55220
|
return result;
|
|
55174
55221
|
}
|
|
55222
|
+
function createTagObject(tagData) {
|
|
55223
|
+
if (!tagData || typeof tagData !== "object") {
|
|
55224
|
+
return null;
|
|
55225
|
+
}
|
|
55226
|
+
return JSON.stringify(tagData);
|
|
55227
|
+
}
|
|
55228
|
+
function parseTagObject(tag) {
|
|
55229
|
+
if (typeof tag !== "string" || !tag.startsWith("{")) {
|
|
55230
|
+
return null;
|
|
55231
|
+
}
|
|
55232
|
+
try {
|
|
55233
|
+
const parsed = JSON.parse(tag);
|
|
55234
|
+
return parsed && typeof parsed === "object" ? parsed : null;
|
|
55235
|
+
} catch {
|
|
55236
|
+
return null;
|
|
55237
|
+
}
|
|
55238
|
+
}
|
|
55239
|
+
function hasGroup(tag) {
|
|
55240
|
+
const parsed = parseTagObject(tag);
|
|
55241
|
+
return parsed !== null && typeof parsed.group === "string";
|
|
55242
|
+
}
|
|
55243
|
+
function getGroup(tag) {
|
|
55244
|
+
const parsed = parseTagObject(tag);
|
|
55245
|
+
return parsed && typeof parsed.group === "string" ? parsed.group : null;
|
|
55246
|
+
}
|
|
55247
|
+
function getStructuredContentByGroup(groupOrGroups, state2) {
|
|
55248
|
+
const searchGroups = Array.isArray(groupOrGroups) ? groupOrGroups : [groupOrGroups];
|
|
55249
|
+
const result = findChildren$5(state2.doc, (node) => {
|
|
55250
|
+
const isStructuredContent = ["structuredContent", "structuredContentBlock"].includes(node.type.name);
|
|
55251
|
+
if (!isStructuredContent) {
|
|
55252
|
+
return false;
|
|
55253
|
+
}
|
|
55254
|
+
const nodeGroup = getGroup(node.attrs.tag);
|
|
55255
|
+
if (!nodeGroup) {
|
|
55256
|
+
return false;
|
|
55257
|
+
}
|
|
55258
|
+
return searchGroups.includes(nodeGroup);
|
|
55259
|
+
});
|
|
55260
|
+
return result;
|
|
55261
|
+
}
|
|
55175
55262
|
function getStructuredContentTags(state2) {
|
|
55176
55263
|
const result = findChildren$5(state2.doc, (node) => {
|
|
55177
55264
|
return node.type.name === "structuredContent" || node.type.name === "structuredContentBlock";
|
|
@@ -55204,11 +55291,16 @@ function getStructuredContentTablesById(id, state2) {
|
|
|
55204
55291
|
}
|
|
55205
55292
|
const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
55206
55293
|
__proto__: null,
|
|
55294
|
+
createTagObject,
|
|
55295
|
+
getGroup,
|
|
55207
55296
|
getStructuredContentBlockTags,
|
|
55297
|
+
getStructuredContentByGroup,
|
|
55208
55298
|
getStructuredContentInlineTags,
|
|
55209
55299
|
getStructuredContentTablesById,
|
|
55210
55300
|
getStructuredContentTags,
|
|
55211
|
-
getStructuredContentTagsById
|
|
55301
|
+
getStructuredContentTagsById,
|
|
55302
|
+
hasGroup,
|
|
55303
|
+
parseTagObject
|
|
55212
55304
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
55213
55305
|
const STRUCTURED_CONTENT_NAMES = ["structuredContent", "structuredContentBlock"];
|
|
55214
55306
|
const StructuredContentCommands = Extension.create({
|
|
@@ -55220,6 +55312,16 @@ const StructuredContentCommands = Extension.create({
|
|
|
55220
55312
|
* @category Command
|
|
55221
55313
|
* @param {StructuredContentInlineInsert} options
|
|
55222
55314
|
* @example
|
|
55315
|
+
* // With group for linking multiple fields
|
|
55316
|
+
* editor.commands.insertStructuredContentInline({
|
|
55317
|
+
* attrs: {
|
|
55318
|
+
* group: 'customer-info',
|
|
55319
|
+
* alias: 'Customer Name',
|
|
55320
|
+
* },
|
|
55321
|
+
* text: 'John Doe',
|
|
55322
|
+
* });
|
|
55323
|
+
*
|
|
55324
|
+
* // No group
|
|
55223
55325
|
* editor.commands.insertStructuredContentInline({
|
|
55224
55326
|
* attrs: {
|
|
55225
55327
|
* id: '123',
|
|
@@ -55248,12 +55350,17 @@ const StructuredContentCommands = Extension.create({
|
|
|
55248
55350
|
if (!content) {
|
|
55249
55351
|
content = schema.text(" ");
|
|
55250
55352
|
}
|
|
55353
|
+
let tag = options.attrs?.tag || "inline_text_sdt";
|
|
55354
|
+
if (options.attrs?.group) {
|
|
55355
|
+
tag = createTagObject({ group: options.attrs.group });
|
|
55356
|
+
}
|
|
55251
55357
|
const attrs = {
|
|
55252
|
-
...options.attrs,
|
|
55253
55358
|
id: options.attrs?.id || generateRandomSigned32BitIntStrId(),
|
|
55254
|
-
tag
|
|
55255
|
-
alias: options.attrs?.alias || "Structured content"
|
|
55359
|
+
tag,
|
|
55360
|
+
alias: options.attrs?.alias || "Structured content",
|
|
55361
|
+
...options.attrs
|
|
55256
55362
|
};
|
|
55363
|
+
delete attrs.group;
|
|
55257
55364
|
const node = schema.nodes.structuredContent.create(attrs, content, null);
|
|
55258
55365
|
const parent = findParentNode((node2) => node2.type.name === "structuredContent")(state2.selection);
|
|
55259
55366
|
if (parent) {
|
|
@@ -55269,14 +55376,22 @@ const StructuredContentCommands = Extension.create({
|
|
|
55269
55376
|
* @category Command
|
|
55270
55377
|
* @param {StructuredContentBlockInsert} options
|
|
55271
55378
|
* @example
|
|
55379
|
+
* // With group for linking multiple fields
|
|
55380
|
+
* editor.commands.insertStructuredContentBlock({
|
|
55381
|
+
* attrs: {
|
|
55382
|
+
* group: 'terms-section',
|
|
55383
|
+
* alias: 'Terms & Conditions',
|
|
55384
|
+
* },
|
|
55385
|
+
* html: '<p>Legal content...</p>',
|
|
55386
|
+
* });
|
|
55387
|
+
*
|
|
55388
|
+
* // No group
|
|
55272
55389
|
* editor.commands.insertStructuredContentBlock({
|
|
55273
55390
|
* attrs: {
|
|
55274
55391
|
* id: '456',
|
|
55275
55392
|
* alias: 'Terms & Conditions',
|
|
55276
55393
|
* },
|
|
55277
55394
|
* json: { type: 'paragraph', content: [{ type: 'text', text: 'Legal content...' }] }
|
|
55278
|
-
* // or
|
|
55279
|
-
* html: '<p>Legal content...</p>',
|
|
55280
55395
|
* });
|
|
55281
55396
|
*/
|
|
55282
55397
|
insertStructuredContentBlock: (options = {}) => ({ editor, dispatch, state: state2, tr }) => {
|
|
@@ -55299,12 +55414,17 @@ const StructuredContentCommands = Extension.create({
|
|
|
55299
55414
|
if (!content) {
|
|
55300
55415
|
content = schema.nodeFromJSON({ type: "paragraph", content: [] });
|
|
55301
55416
|
}
|
|
55417
|
+
let tag = options.attrs?.tag || "block_table_sdt";
|
|
55418
|
+
if (options.attrs?.group) {
|
|
55419
|
+
tag = createTagObject({ group: options.attrs.group });
|
|
55420
|
+
}
|
|
55302
55421
|
const attrs = {
|
|
55303
|
-
...options.attrs,
|
|
55304
55422
|
id: options.attrs?.id || generateRandomSigned32BitIntStrId(),
|
|
55305
|
-
tag
|
|
55306
|
-
alias: options.attrs?.alias || "Structured content"
|
|
55423
|
+
tag,
|
|
55424
|
+
alias: options.attrs?.alias || "Structured content",
|
|
55425
|
+
...options.attrs
|
|
55307
55426
|
};
|
|
55427
|
+
delete attrs.group;
|
|
55308
55428
|
const node = schema.nodes.structuredContentBlock.create(attrs, content, null);
|
|
55309
55429
|
const parent = findParentNode((node2) => node2.type.name === "structuredContentBlock")(state2.selection);
|
|
55310
55430
|
if (parent) {
|
|
@@ -55434,6 +55554,85 @@ const StructuredContentCommands = Extension.create({
|
|
|
55434
55554
|
}
|
|
55435
55555
|
return true;
|
|
55436
55556
|
},
|
|
55557
|
+
/**
|
|
55558
|
+
* Updates all structured content fields that share the same group identifier.
|
|
55559
|
+
* Groups allow linking multiple fields together for batch operations.
|
|
55560
|
+
* @category Command
|
|
55561
|
+
* @param {string} group - Group identifier shared by multiple fields
|
|
55562
|
+
* @param {StructuredContentUpdate} options
|
|
55563
|
+
* @example
|
|
55564
|
+
* // Update all fields in the customer-info group
|
|
55565
|
+
* editor.commands.updateStructuredContentByGroup('customer-info', { text: 'Jane Doe' });
|
|
55566
|
+
*
|
|
55567
|
+
* // Update block content in a group
|
|
55568
|
+
* editor.commands.updateStructuredContentByGroup('terms-section', {
|
|
55569
|
+
* html: '<p>Updated terms...</p>'
|
|
55570
|
+
* });
|
|
55571
|
+
*/
|
|
55572
|
+
updateStructuredContentByGroup: (group, options = {}) => ({ editor, dispatch, state: state2, tr }) => {
|
|
55573
|
+
const structuredContentTags = getStructuredContentByGroup(group, state2);
|
|
55574
|
+
if (!structuredContentTags.length) {
|
|
55575
|
+
return true;
|
|
55576
|
+
}
|
|
55577
|
+
const { schema } = editor;
|
|
55578
|
+
if (dispatch) {
|
|
55579
|
+
structuredContentTags.forEach((structuredContent) => {
|
|
55580
|
+
const { pos, node } = structuredContent;
|
|
55581
|
+
const posFrom = tr.mapping.map(pos);
|
|
55582
|
+
const posTo = tr.mapping.map(pos + node.nodeSize);
|
|
55583
|
+
let content = null;
|
|
55584
|
+
if (options.text) {
|
|
55585
|
+
content = schema.text(options.text);
|
|
55586
|
+
}
|
|
55587
|
+
if (options.html) {
|
|
55588
|
+
const html = htmlHandler(options.html, editor);
|
|
55589
|
+
const doc2 = DOMParser$1.fromSchema(schema).parse(html);
|
|
55590
|
+
content = doc2.content;
|
|
55591
|
+
}
|
|
55592
|
+
if (options.json) {
|
|
55593
|
+
content = schema.nodeFromJSON(options.json);
|
|
55594
|
+
}
|
|
55595
|
+
if (!content) {
|
|
55596
|
+
content = node.content;
|
|
55597
|
+
}
|
|
55598
|
+
const updatedNode = node.type.create({ ...node.attrs, ...options.attrs }, content, node.marks);
|
|
55599
|
+
const currentNode = tr.doc.nodeAt(posFrom);
|
|
55600
|
+
if (currentNode && node.eq(currentNode)) {
|
|
55601
|
+
tr.replaceWith(posFrom, posTo, updatedNode);
|
|
55602
|
+
}
|
|
55603
|
+
});
|
|
55604
|
+
}
|
|
55605
|
+
return true;
|
|
55606
|
+
},
|
|
55607
|
+
/**
|
|
55608
|
+
* Removes all structured content fields that share the same group identifier.
|
|
55609
|
+
* @category Command
|
|
55610
|
+
* @param {string | string[]} groupOrGroups - Single group or array of groups
|
|
55611
|
+
* @example
|
|
55612
|
+
* // Delete all fields in a group
|
|
55613
|
+
* editor.commands.deleteStructuredContentByGroup('customer-info');
|
|
55614
|
+
*
|
|
55615
|
+
* // Delete multiple groups
|
|
55616
|
+
* editor.commands.deleteStructuredContentByGroup(['header', 'footer']);
|
|
55617
|
+
*/
|
|
55618
|
+
deleteStructuredContentByGroup: (groupOrGroups) => ({ dispatch, state: state2, tr }) => {
|
|
55619
|
+
const structuredContentTags = getStructuredContentByGroup(groupOrGroups, state2);
|
|
55620
|
+
if (!structuredContentTags.length) {
|
|
55621
|
+
return true;
|
|
55622
|
+
}
|
|
55623
|
+
if (dispatch) {
|
|
55624
|
+
structuredContentTags.forEach((structuredContent) => {
|
|
55625
|
+
const { pos, node } = structuredContent;
|
|
55626
|
+
const posFrom = tr.mapping.map(pos);
|
|
55627
|
+
const posTo = tr.mapping.map(pos + node.nodeSize);
|
|
55628
|
+
const currentNode = tr.doc.nodeAt(posFrom);
|
|
55629
|
+
if (currentNode && node.eq(currentNode)) {
|
|
55630
|
+
tr.delete(posFrom, posTo);
|
|
55631
|
+
}
|
|
55632
|
+
});
|
|
55633
|
+
}
|
|
55634
|
+
return true;
|
|
55635
|
+
},
|
|
55437
55636
|
/**
|
|
55438
55637
|
* Append multiple rows to the end of a table inside a structured content block.
|
|
55439
55638
|
* Each inner array represents the cell values for one new row.
|
|
@@ -56582,7 +56781,7 @@ const applyLinkedStyleToTransaction = (tr, editor, style2) => {
|
|
|
56582
56781
|
let selection = tr.selection;
|
|
56583
56782
|
const state2 = editor.state;
|
|
56584
56783
|
const focusState = CustomSelectionPluginKey.getState(state2);
|
|
56585
|
-
if (selection.empty && focusState?.preservedSelection) {
|
|
56784
|
+
if (selection.empty && focusState?.preservedSelection && !focusState?.preservedSelection.empty) {
|
|
56586
56785
|
selection = focusState.preservedSelection;
|
|
56587
56786
|
tr.setSelection(selection);
|
|
56588
56787
|
} else if (selection.empty && editor.options.lastSelection) {
|
|
@@ -56649,6 +56848,31 @@ const applyLinkedStyleToTransaction = (tr, editor, style2) => {
|
|
|
56649
56848
|
});
|
|
56650
56849
|
return true;
|
|
56651
56850
|
};
|
|
56851
|
+
const stepInsertsTextIntoStyledParagraph = (tr, oldEditorState, step, stepIndex) => {
|
|
56852
|
+
if (!step.slice || step.slice.size === 0 || typeof step.from !== "number") {
|
|
56853
|
+
return false;
|
|
56854
|
+
}
|
|
56855
|
+
let insertsText = false;
|
|
56856
|
+
step.slice.content.descendants((node) => {
|
|
56857
|
+
if (node.type?.name === "text" && node.text?.length) {
|
|
56858
|
+
insertsText = true;
|
|
56859
|
+
return false;
|
|
56860
|
+
}
|
|
56861
|
+
return true;
|
|
56862
|
+
});
|
|
56863
|
+
if (!insertsText) return false;
|
|
56864
|
+
const docBeforeStep = tr.docs?.[stepIndex] || oldEditorState.doc;
|
|
56865
|
+
if (!docBeforeStep) return false;
|
|
56866
|
+
const resolvedPos = Math.min(step.from, docBeforeStep.content.size);
|
|
56867
|
+
const $pos = docBeforeStep.resolve(resolvedPos);
|
|
56868
|
+
for (let depth = $pos.depth; depth >= 0; depth--) {
|
|
56869
|
+
const node = $pos.node(depth);
|
|
56870
|
+
if (node?.type?.name === "paragraph") {
|
|
56871
|
+
return Boolean(node.attrs?.styleId);
|
|
56872
|
+
}
|
|
56873
|
+
}
|
|
56874
|
+
return false;
|
|
56875
|
+
};
|
|
56652
56876
|
const LinkedStylesPluginKey = new PluginKey("linkedStyles");
|
|
56653
56877
|
const createLinkedStylesPlugin = (editor) => {
|
|
56654
56878
|
return new Plugin({
|
|
@@ -56682,7 +56906,7 @@ const createLinkedStylesPlugin = (editor) => {
|
|
|
56682
56906
|
if (tr.docChanged) {
|
|
56683
56907
|
let mightAffectStyles = false;
|
|
56684
56908
|
const styleRelatedMarks = /* @__PURE__ */ new Set(["textStyle", "bold", "italic", "underline", "strike"]);
|
|
56685
|
-
tr.steps.forEach((step) => {
|
|
56909
|
+
tr.steps.forEach((step, index2) => {
|
|
56686
56910
|
if (step.slice) {
|
|
56687
56911
|
step.slice.content.descendants((node) => {
|
|
56688
56912
|
if (node.attrs?.styleId) {
|
|
@@ -56703,6 +56927,9 @@ const createLinkedStylesPlugin = (editor) => {
|
|
|
56703
56927
|
mightAffectStyles = true;
|
|
56704
56928
|
}
|
|
56705
56929
|
}
|
|
56930
|
+
if (!mightAffectStyles && stepInsertsTextIntoStyledParagraph(tr, oldEditorState, step, index2)) {
|
|
56931
|
+
mightAffectStyles = true;
|
|
56932
|
+
}
|
|
56706
56933
|
});
|
|
56707
56934
|
if (mightAffectStyles) {
|
|
56708
56935
|
const styles = LinkedStylesPluginKey.getState(editor.state).styles;
|
|
@@ -58053,6 +58280,8 @@ const Paragraph = OxmlNode.create({
|
|
|
58053
58280
|
}
|
|
58054
58281
|
},
|
|
58055
58282
|
styleId: {
|
|
58283
|
+
default: null,
|
|
58284
|
+
keepOnSplit: false,
|
|
58056
58285
|
renderDOM: (attrs) => {
|
|
58057
58286
|
if (!attrs.styleId) return {};
|
|
58058
58287
|
return { styleid: attrs.styleId };
|
|
@@ -58798,15 +59027,6 @@ const HardBreak = Node$1.create({
|
|
|
58798
59027
|
};
|
|
58799
59028
|
}
|
|
58800
59029
|
});
|
|
58801
|
-
const getColStyleDeclaration = (minWidth, width) => {
|
|
58802
|
-
if (width != null) {
|
|
58803
|
-
const numericWidth = Number(width);
|
|
58804
|
-
if (Number.isFinite(numericWidth) && numericWidth >= 0) {
|
|
58805
|
-
return ["width", `${numericWidth}px`];
|
|
58806
|
-
}
|
|
58807
|
-
}
|
|
58808
|
-
return ["min-width", `${minWidth}px`];
|
|
58809
|
-
};
|
|
58810
59030
|
const createTableView = ({ editor }) => {
|
|
58811
59031
|
return class TableView {
|
|
58812
59032
|
constructor(node, cellMinWidth2) {
|
|
@@ -58825,7 +59045,7 @@ const createTableView = ({ editor }) => {
|
|
|
58825
59045
|
this.table = this.dom.appendChild(document.createElement("table"));
|
|
58826
59046
|
this.colgroup = this.table.appendChild(document.createElement("colgroup"));
|
|
58827
59047
|
updateTable(this.editor, this.node, this.table);
|
|
58828
|
-
updateColumns(node, this.colgroup, this.table
|
|
59048
|
+
updateColumns(node, this.colgroup, this.table);
|
|
58829
59049
|
this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
58830
59050
|
setTimeout(() => {
|
|
58831
59051
|
updateTableWrapper(this.dom, this.table);
|
|
@@ -58837,7 +59057,7 @@ const createTableView = ({ editor }) => {
|
|
|
58837
59057
|
}
|
|
58838
59058
|
this.node = node;
|
|
58839
59059
|
updateTable(this.editor, node, this.table);
|
|
58840
|
-
updateColumns(node, this.colgroup, this.table, this.cellMinWidth
|
|
59060
|
+
updateColumns(node, this.colgroup, this.table, this.cellMinWidth);
|
|
58841
59061
|
updateTableWrapper(this.dom, this.table);
|
|
58842
59062
|
return true;
|
|
58843
59063
|
}
|
|
@@ -58850,43 +59070,20 @@ const createTableView = ({ editor }) => {
|
|
|
58850
59070
|
}
|
|
58851
59071
|
};
|
|
58852
59072
|
};
|
|
58853
|
-
function updateColumns(node, colgroup, table, cellMinWidth2
|
|
59073
|
+
function updateColumns(node, colgroup, table, cellMinWidth2) {
|
|
58854
59074
|
const gridColumns = Array.isArray(node.attrs?.grid) && node.attrs.grid.length ? node.attrs.grid.map((col) => twipsToPixels(col.col)) : null;
|
|
58855
59075
|
const totalColumns = gridColumns?.length ?? null;
|
|
58856
|
-
const pageBody = table.closest(".page__body");
|
|
58857
|
-
const wrapper = table.parentElement;
|
|
58858
|
-
let availableWidth = pageBody?.getBoundingClientRect?.().width;
|
|
58859
|
-
if (!availableWidth && wrapper) {
|
|
58860
|
-
availableWidth = wrapper.getBoundingClientRect().width;
|
|
58861
|
-
}
|
|
58862
|
-
if (typeof availableWidth === "number" && !Number.isNaN(availableWidth)) {
|
|
58863
|
-
availableWidth = Math.max(availableWidth - 2, 0);
|
|
58864
|
-
} else {
|
|
58865
|
-
availableWidth = null;
|
|
58866
|
-
}
|
|
58867
|
-
const pageStyles = editor?.converter?.pageStyles;
|
|
58868
|
-
if (pageStyles?.pageSize?.width) {
|
|
58869
|
-
const toNumber = (v2) => typeof v2 === "number" ? v2 : parseFloat(v2) || 0;
|
|
58870
|
-
const pageWidth = toNumber(pageStyles.pageSize.width);
|
|
58871
|
-
const marginLeft = toNumber(pageStyles.pageMargins?.left);
|
|
58872
|
-
const marginRight = toNumber(pageStyles.pageMargins?.right);
|
|
58873
|
-
const pageAvailableWidthPx = Math.max((pageWidth - marginLeft - marginRight) * PIXELS_PER_INCH, 0);
|
|
58874
|
-
if (pageAvailableWidthPx > 0) {
|
|
58875
|
-
availableWidth = availableWidth ? Math.min(availableWidth, pageAvailableWidthPx) : pageAvailableWidthPx;
|
|
58876
|
-
}
|
|
58877
|
-
}
|
|
58878
59076
|
const resolveColumnWidth = (colIndex2, colwidthValue) => {
|
|
58879
|
-
if (overrideCol === colIndex2) return overrideValue;
|
|
58880
59077
|
if (colwidthValue != null) return colwidthValue;
|
|
58881
59078
|
if (gridColumns && gridColumns[colIndex2] != null) return gridColumns[colIndex2];
|
|
58882
59079
|
return null;
|
|
58883
59080
|
};
|
|
58884
59081
|
const widths = [];
|
|
58885
|
-
const
|
|
59082
|
+
const firstRow = node.firstChild;
|
|
58886
59083
|
let colIndex = 0;
|
|
58887
|
-
if (
|
|
58888
|
-
for (let i = 0; i <
|
|
58889
|
-
const child =
|
|
59084
|
+
if (firstRow !== null) {
|
|
59085
|
+
for (let i = 0; i < firstRow.childCount; i++) {
|
|
59086
|
+
const child = firstRow.child(i);
|
|
58890
59087
|
const { colspan, colwidth } = child.attrs;
|
|
58891
59088
|
for (let span = 0; span < colspan; span += 1, colIndex += 1) {
|
|
58892
59089
|
widths.push(resolveColumnWidth(colIndex, colwidth && colwidth[span]));
|
|
@@ -58906,49 +59103,41 @@ function updateColumns(node, colgroup, table, cellMinWidth2, overrideCol, overri
|
|
|
58906
59103
|
if (numericWidth < 1) return 0;
|
|
58907
59104
|
return numericWidth;
|
|
58908
59105
|
});
|
|
58909
|
-
const
|
|
58910
|
-
|
|
58911
|
-
|
|
58912
|
-
|
|
58913
|
-
|
|
58914
|
-
let
|
|
58915
|
-
let hasUndefinedWidth = false;
|
|
58916
|
-
let dom = colgroup.firstChild;
|
|
59106
|
+
const tableWidthCSS = convertSizeToCSS(
|
|
59107
|
+
// TODO: why is tableWidth undefined in src/tests/import-export/font-default-styles.test.js?
|
|
59108
|
+
node.attrs.tableProperties.tableWidth?.value ?? null,
|
|
59109
|
+
node.attrs.tableProperties.tableWidth?.type ?? "auto"
|
|
59110
|
+
);
|
|
59111
|
+
let colElement = colgroup.firstChild;
|
|
58917
59112
|
normalizedWidths.forEach((width) => {
|
|
58918
|
-
|
|
58919
|
-
|
|
58920
|
-
scaledWidth = scaledWidth * scale;
|
|
58921
|
-
}
|
|
58922
|
-
const [propKey, propVal] = getColStyleDeclaration(cellMinWidth2, scaledWidth);
|
|
58923
|
-
if (scaledWidth == null) {
|
|
58924
|
-
totalWidth += cellMinWidth2;
|
|
58925
|
-
hasUndefinedWidth = true;
|
|
58926
|
-
} else {
|
|
58927
|
-
totalWidth += scaledWidth;
|
|
58928
|
-
}
|
|
58929
|
-
if (!dom) {
|
|
58930
|
-
const colElement = document.createElement("col");
|
|
58931
|
-
colElement.style.setProperty(propKey, propVal);
|
|
59113
|
+
if (!colElement) {
|
|
59114
|
+
colElement = document.createElement("col");
|
|
58932
59115
|
colgroup.appendChild(colElement);
|
|
58933
|
-
} else {
|
|
58934
|
-
dom.style.setProperty(propKey, propVal);
|
|
58935
|
-
dom = dom.nextSibling;
|
|
58936
59116
|
}
|
|
59117
|
+
colElement.style.width = width !== null && width !== void 0 ? `${width}px` : null;
|
|
59118
|
+
colElement = colElement.nextSibling;
|
|
58937
59119
|
});
|
|
58938
|
-
while (
|
|
58939
|
-
const next =
|
|
58940
|
-
|
|
58941
|
-
|
|
58942
|
-
}
|
|
58943
|
-
|
|
58944
|
-
|
|
58945
|
-
|
|
58946
|
-
|
|
59120
|
+
while (colElement) {
|
|
59121
|
+
const next = colElement.nextSibling;
|
|
59122
|
+
colElement.parentNode?.removeChild(colElement);
|
|
59123
|
+
colElement = next;
|
|
59124
|
+
}
|
|
59125
|
+
const tableIndent = convertSizeToCSS(
|
|
59126
|
+
node.attrs.tableProperties.tableIndent?.value ?? 0,
|
|
59127
|
+
node.attrs.tableProperties.tableIndent?.type ?? "dxa"
|
|
59128
|
+
);
|
|
59129
|
+
const firstRowFirstCellPaddingLeftPx = firstRow?.firstChild?.attrs?.cellMargins?.left ?? 0;
|
|
59130
|
+
const firstRowLastCellPaddingRightPx = firstRow?.lastChild?.attrs?.cellMargins?.right ?? 0;
|
|
59131
|
+
table.style.marginLeft = `${-firstRowFirstCellPaddingLeftPx}px`;
|
|
59132
|
+
if (tableIndent !== null) {
|
|
59133
|
+
table.style.marginLeft = tableIndent;
|
|
59134
|
+
}
|
|
59135
|
+
if (node.attrs.tableProperties.tableWidth?.type === "pct") {
|
|
59136
|
+
const padding = firstRowFirstCellPaddingLeftPx + firstRowLastCellPaddingRightPx;
|
|
59137
|
+
table.style.maxWidth = table.style.width = `calc(${tableWidthCSS} + ${padding}px)`;
|
|
58947
59138
|
} else {
|
|
58948
|
-
table.style.width =
|
|
58949
|
-
table.style.minWidth = `${totalWidth}px`;
|
|
59139
|
+
table.style.maxWidth = table.style.width = tableWidthCSS;
|
|
58950
59140
|
}
|
|
58951
|
-
table.style.maxWidth = "100%";
|
|
58952
59141
|
}
|
|
58953
59142
|
function updateTable(editor, node, table) {
|
|
58954
59143
|
const allExtensionsAttrs = editor.extensionService.attributes;
|
|
@@ -59026,6 +59215,15 @@ const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent =
|
|
|
59026
59215
|
const tableBorders = createTableBorders();
|
|
59027
59216
|
return types2.table.createChecked({ borders: tableBorders }, rows);
|
|
59028
59217
|
};
|
|
59218
|
+
const getColStyleDeclaration = (minWidth, width) => {
|
|
59219
|
+
if (width != null) {
|
|
59220
|
+
const numericWidth = Number(width);
|
|
59221
|
+
if (Number.isFinite(numericWidth) && numericWidth >= 0) {
|
|
59222
|
+
return ["width", `${numericWidth}px`];
|
|
59223
|
+
}
|
|
59224
|
+
}
|
|
59225
|
+
return ["min-width", `${minWidth}px`];
|
|
59226
|
+
};
|
|
59029
59227
|
const MIN_MEANINGFUL_WIDTH_PX = 1;
|
|
59030
59228
|
const createColGroup = (node, cellMinWidth2, overrideCol, overrideValue) => {
|
|
59031
59229
|
let totalWidth = 0;
|
|
@@ -61392,15 +61590,6 @@ const Table = Node$1.create({
|
|
|
61392
61590
|
},
|
|
61393
61591
|
addAttributes() {
|
|
61394
61592
|
return {
|
|
61395
|
-
/* tableWidth: {
|
|
61396
|
-
renderDOM: ({ tableWidth }) => {
|
|
61397
|
-
if (!tableWidth) return {};
|
|
61398
|
-
const { width, type = 'auto' } = tableWidth;
|
|
61399
|
-
return {
|
|
61400
|
-
style: `width: ${width}px`
|
|
61401
|
-
};
|
|
61402
|
-
},
|
|
61403
|
-
}, */
|
|
61404
61593
|
/**
|
|
61405
61594
|
* @private
|
|
61406
61595
|
* @category Attribute
|
|
@@ -61504,7 +61693,12 @@ const Table = Node$1.create({
|
|
|
61504
61693
|
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 371-483
|
|
61505
61694
|
*/
|
|
61506
61695
|
tableProperties: {
|
|
61507
|
-
default:
|
|
61696
|
+
default: {
|
|
61697
|
+
tableWidth: {
|
|
61698
|
+
value: null,
|
|
61699
|
+
type: "auto"
|
|
61700
|
+
}
|
|
61701
|
+
},
|
|
61508
61702
|
rendered: false
|
|
61509
61703
|
},
|
|
61510
61704
|
/**
|
|
@@ -62272,12 +62466,14 @@ const TableCell = Node$1.create({
|
|
|
62272
62466
|
}
|
|
62273
62467
|
},
|
|
62274
62468
|
cellMargins: {
|
|
62275
|
-
renderDOM({ cellMargins }) {
|
|
62469
|
+
renderDOM({ cellMargins, borders }) {
|
|
62276
62470
|
if (!cellMargins) return {};
|
|
62277
62471
|
const sides2 = ["top", "right", "bottom", "left"];
|
|
62278
62472
|
const style2 = sides2.map((side) => {
|
|
62279
|
-
const margin = cellMargins?.[side];
|
|
62280
|
-
|
|
62473
|
+
const margin = cellMargins?.[side] ?? 0;
|
|
62474
|
+
const border = borders?.[side];
|
|
62475
|
+
const borderSize = border && border.val !== "none" ? Math.ceil(border.size) : 0;
|
|
62476
|
+
if (margin) return `padding-${side}: ${Math.max(0, margin - borderSize)}px;`;
|
|
62281
62477
|
return "";
|
|
62282
62478
|
}).join(" ");
|
|
62283
62479
|
return { style: style2 };
|
|
@@ -91499,7 +91695,7 @@ const _sfc_main$1 = {
|
|
|
91499
91695
|
};
|
|
91500
91696
|
}
|
|
91501
91697
|
};
|
|
91502
|
-
const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
91698
|
+
const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-4615ea7d"]]);
|
|
91503
91699
|
const _hoisted_1 = ["innerHTML"];
|
|
91504
91700
|
const _sfc_main = {
|
|
91505
91701
|
__name: "SuperInput",
|