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
|
@@ -15409,6 +15409,38 @@ const hasSomeParentWithClass = (element, classname) => {
|
|
|
15409
15409
|
if (element.className?.split(" ")?.indexOf(classname) >= 0) return true;
|
|
15410
15410
|
return element.parentNode && hasSomeParentWithClass(element.parentNode, classname);
|
|
15411
15411
|
};
|
|
15412
|
+
function convertSizeToCSS(value, type2) {
|
|
15413
|
+
if (typeof value === "string" && value.endsWith("%")) {
|
|
15414
|
+
type2 = "pct";
|
|
15415
|
+
}
|
|
15416
|
+
if (value === null || value === void 0) {
|
|
15417
|
+
value = 0;
|
|
15418
|
+
}
|
|
15419
|
+
switch (type2) {
|
|
15420
|
+
case "dxa":
|
|
15421
|
+
case null:
|
|
15422
|
+
case void 0:
|
|
15423
|
+
return `${twipsToPixels(value)}px`;
|
|
15424
|
+
case "nil":
|
|
15425
|
+
return "0";
|
|
15426
|
+
case "auto":
|
|
15427
|
+
return null;
|
|
15428
|
+
case "pct":
|
|
15429
|
+
let percent2;
|
|
15430
|
+
if (typeof value === "number") {
|
|
15431
|
+
percent2 = value * 0.02;
|
|
15432
|
+
} else {
|
|
15433
|
+
if (value.endsWith("%")) {
|
|
15434
|
+
percent2 = parseFloat(value.slice(0, -1));
|
|
15435
|
+
} else {
|
|
15436
|
+
percent2 = parseFloat(value) * 0.02;
|
|
15437
|
+
}
|
|
15438
|
+
}
|
|
15439
|
+
return `${percent2}%`;
|
|
15440
|
+
default:
|
|
15441
|
+
return null;
|
|
15442
|
+
}
|
|
15443
|
+
}
|
|
15412
15444
|
const DEFAULT_DOCX_DEFS = {
|
|
15413
15445
|
"xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
|
15414
15446
|
"xmlns:cx": "http://schemas.microsoft.com/office/drawing/2014/chartex",
|
|
@@ -19221,7 +19253,7 @@ const resolveRunProperties = (params2, inlineRpr, resolvedPpr, isListNumber = fa
|
|
|
19221
19253
|
const finalProps = combineProperties(styleChain, ["fontFamily", "color"]);
|
|
19222
19254
|
return finalProps;
|
|
19223
19255
|
};
|
|
19224
|
-
function resolveParagraphProperties(params2, inlineProps, insideTable = false, overrideInlineStyleId = false) {
|
|
19256
|
+
function resolveParagraphProperties(params2, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) {
|
|
19225
19257
|
const defaultProps2 = getDefaultProperties(params2, translator$12);
|
|
19226
19258
|
const { properties: normalProps, isDefault: isNormalDefault } = getStyleProperties(params2, "Normal", translator$12);
|
|
19227
19259
|
let styleId = inlineProps?.styleId;
|
|
@@ -19246,13 +19278,14 @@ function resolveParagraphProperties(params2, inlineProps, insideTable = false, o
|
|
|
19246
19278
|
}
|
|
19247
19279
|
}
|
|
19248
19280
|
}
|
|
19281
|
+
const tableProps = tableStyleId ? resolveStyleChain(params2, tableStyleId, translator$12) : {};
|
|
19249
19282
|
let defaultsChain;
|
|
19250
19283
|
if (isNormalDefault) {
|
|
19251
19284
|
defaultsChain = [defaultProps2, normalProps];
|
|
19252
19285
|
} else {
|
|
19253
19286
|
defaultsChain = [normalProps, defaultProps2];
|
|
19254
19287
|
}
|
|
19255
|
-
const propsChain = [...defaultsChain, numberingProps, styleProps, inlineProps];
|
|
19288
|
+
const propsChain = [...defaultsChain, tableProps, numberingProps, styleProps, inlineProps];
|
|
19256
19289
|
let indentChain;
|
|
19257
19290
|
if (isList2) {
|
|
19258
19291
|
if (numberingDefinedInline) {
|
|
@@ -20003,6 +20036,21 @@ function getStrikeValue(attributes) {
|
|
|
20003
20036
|
if (value === "0" || value === "false" || value === "off") return "0";
|
|
20004
20037
|
return "1";
|
|
20005
20038
|
}
|
|
20039
|
+
function getTableStyleId(path) {
|
|
20040
|
+
const tbl = path.find((ancestor) => ancestor.name === "w:tbl");
|
|
20041
|
+
if (!tbl) {
|
|
20042
|
+
return;
|
|
20043
|
+
}
|
|
20044
|
+
const tblPr = tbl.elements?.find((child) => child.name === "w:tblPr");
|
|
20045
|
+
if (!tblPr) {
|
|
20046
|
+
return;
|
|
20047
|
+
}
|
|
20048
|
+
const tblStyle = tblPr.elements?.find((child) => child.name === "w:tblStyle");
|
|
20049
|
+
if (!tblStyle) {
|
|
20050
|
+
return;
|
|
20051
|
+
}
|
|
20052
|
+
return tblStyle.attributes?.["w:val"];
|
|
20053
|
+
}
|
|
20006
20054
|
const handleParagraphNode$1 = (params2) => {
|
|
20007
20055
|
const { nodes, nodeListHandler, filename } = params2;
|
|
20008
20056
|
const node = carbonCopy(nodes[0]);
|
|
@@ -20013,7 +20061,14 @@ const handleParagraphNode$1 = (params2) => {
|
|
|
20013
20061
|
inlineParagraphProperties = translator$12.encode({ ...params2, nodes: [pPr] }) || {};
|
|
20014
20062
|
}
|
|
20015
20063
|
const insideTable = (params2.path || []).some((ancestor) => ancestor.name === "w:tc");
|
|
20016
|
-
const
|
|
20064
|
+
const tableStyleId = getTableStyleId(params2.path || []);
|
|
20065
|
+
const resolvedParagraphProperties = resolveParagraphProperties(
|
|
20066
|
+
params2,
|
|
20067
|
+
inlineParagraphProperties,
|
|
20068
|
+
insideTable,
|
|
20069
|
+
false,
|
|
20070
|
+
tableStyleId
|
|
20071
|
+
);
|
|
20017
20072
|
const handleStandardNode2 = nodeListHandler.handlerEntities.find(
|
|
20018
20073
|
(e) => e.handlerName === "standardNodeHandler"
|
|
20019
20074
|
)?.handler;
|
|
@@ -21368,6 +21423,7 @@ const encode$m = (params2, encodedAttrs) => {
|
|
|
21368
21423
|
const columnWidth = gridColumnWidths?.[startColumn] || null;
|
|
21369
21424
|
const result = translator$G.encode({
|
|
21370
21425
|
...params2,
|
|
21426
|
+
path: [...params2.path || [], node],
|
|
21371
21427
|
extraParams: {
|
|
21372
21428
|
...params2.extraParams,
|
|
21373
21429
|
node,
|
|
@@ -31538,14 +31594,15 @@ const decode$j = (params2) => {
|
|
|
31538
31594
|
const grid = Array.isArray(rawGrid) ? rawGrid : [];
|
|
31539
31595
|
const { firstRow = {} } = params2.extraParams || {};
|
|
31540
31596
|
const cellNodes = firstRow.content?.filter((n) => n.type === "tableCell") ?? [];
|
|
31541
|
-
const
|
|
31597
|
+
const colWidthsFromCellNodes = cellNodes.flatMap((cell) => {
|
|
31542
31598
|
const spanCount = Math.max(1, cell?.attrs?.colspan ?? 1);
|
|
31543
|
-
|
|
31544
|
-
|
|
31599
|
+
const colwidth = cell.attrs?.colwidth;
|
|
31600
|
+
return Array.from({ length: spanCount }).map((_2, span) => Array.isArray(colwidth) ? colwidth[span] : void 0);
|
|
31601
|
+
});
|
|
31602
|
+
const columnCountFromCells = colWidthsFromCellNodes.length;
|
|
31545
31603
|
const totalColumns = Math.max(columnCountFromCells, grid.length);
|
|
31546
31604
|
const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params2, totalColumns, cellMinWidth);
|
|
31547
31605
|
const elements = [];
|
|
31548
|
-
let columnIndex = 0;
|
|
31549
31606
|
const pushColumn = (widthTwips, { enforceMinimum = false } = {}) => {
|
|
31550
31607
|
let numericWidth = typeof widthTwips === "string" ? parseInt(widthTwips, 10) : widthTwips;
|
|
31551
31608
|
let shouldEnforceMinimum = enforceMinimum;
|
|
@@ -31564,39 +31621,29 @@ const decode$j = (params2) => {
|
|
|
31564
31621
|
});
|
|
31565
31622
|
if (decoded) elements.push(decoded);
|
|
31566
31623
|
};
|
|
31567
|
-
|
|
31568
|
-
const
|
|
31569
|
-
const
|
|
31570
|
-
|
|
31571
|
-
|
|
31572
|
-
|
|
31573
|
-
|
|
31574
|
-
|
|
31575
|
-
|
|
31576
|
-
|
|
31577
|
-
|
|
31578
|
-
|
|
31579
|
-
|
|
31580
|
-
|
|
31581
|
-
if (gridWidthTwips != null && gridWidthPixels != null && Math.abs(gridWidthPixels - cellWidthPixels) <= tolerance) {
|
|
31582
|
-
cellWidthTwips = gridWidthTwips;
|
|
31583
|
-
} else {
|
|
31584
|
-
cellWidthTwips = pixelsToTwips(cellWidthPixels);
|
|
31585
|
-
}
|
|
31586
|
-
} else if (gridWidthTwips != null) {
|
|
31624
|
+
for (let columnIndex = 0; columnIndex < totalColumns; ++columnIndex) {
|
|
31625
|
+
const rawWidth = colWidthsFromCellNodes[columnIndex];
|
|
31626
|
+
const cellWidthPixels = typeof rawWidth === "number" && Number.isFinite(rawWidth) ? rawWidth : Number(rawWidth);
|
|
31627
|
+
const hasCellWidth = Number.isFinite(cellWidthPixels) && cellWidthPixels > 0;
|
|
31628
|
+
const colGridAttrs = grid?.[columnIndex] || {};
|
|
31629
|
+
const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
|
|
31630
|
+
const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
|
|
31631
|
+
let cellWidthTwips;
|
|
31632
|
+
let enforceMinimum = false;
|
|
31633
|
+
if (gridWidthTwips != null) {
|
|
31634
|
+
cellWidthTwips = gridWidthTwips;
|
|
31635
|
+
} else if (hasCellWidth) {
|
|
31636
|
+
const tolerance = 0.5;
|
|
31637
|
+
if (gridWidthTwips != null && gridWidthPixels != null && Math.abs(gridWidthPixels - cellWidthPixels) <= tolerance) {
|
|
31587
31638
|
cellWidthTwips = gridWidthTwips;
|
|
31588
31639
|
} else {
|
|
31589
|
-
cellWidthTwips =
|
|
31590
|
-
enforceMinimum = true;
|
|
31640
|
+
cellWidthTwips = pixelsToTwips(cellWidthPixels);
|
|
31591
31641
|
}
|
|
31592
|
-
|
|
31593
|
-
|
|
31642
|
+
} else {
|
|
31643
|
+
cellWidthTwips = fallbackColumnWidthTwips;
|
|
31644
|
+
enforceMinimum = true;
|
|
31594
31645
|
}
|
|
31595
|
-
|
|
31596
|
-
while (columnIndex < grid.length) {
|
|
31597
|
-
const gridWidthTwips = normalizeTwipWidth(grid[columnIndex]?.col);
|
|
31598
|
-
pushColumn(gridWidthTwips);
|
|
31599
|
-
columnIndex++;
|
|
31646
|
+
pushColumn(cellWidthTwips, { enforceMinimum });
|
|
31600
31647
|
}
|
|
31601
31648
|
const newNode = {
|
|
31602
31649
|
name: XML_NODE_NAME$b,
|
|
@@ -31683,6 +31730,8 @@ const encode$g = (params2, encodedAttrs) => {
|
|
|
31683
31730
|
if (tblPr) {
|
|
31684
31731
|
const encodedProperties = translator$c.encode({ ...params2, nodes: [tblPr] });
|
|
31685
31732
|
encodedAttrs["tableProperties"] = encodedProperties || {};
|
|
31733
|
+
} else {
|
|
31734
|
+
encodedAttrs["tableProperties"] || (encodedAttrs["tableProperties"] = {});
|
|
31686
31735
|
}
|
|
31687
31736
|
const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
|
|
31688
31737
|
if (tblGrid) {
|
|
@@ -31703,14 +31752,14 @@ const encode$g = (params2, encodedAttrs) => {
|
|
|
31703
31752
|
key2 = prop;
|
|
31704
31753
|
transform = (v2) => v2;
|
|
31705
31754
|
}
|
|
31706
|
-
if (encodedAttrs.tableProperties
|
|
31755
|
+
if (encodedAttrs.tableProperties[key2]) {
|
|
31707
31756
|
encodedAttrs[key2] = transform(encodedAttrs.tableProperties[key2]);
|
|
31708
31757
|
}
|
|
31709
31758
|
});
|
|
31710
31759
|
if (encodedAttrs.tableCellSpacing) {
|
|
31711
31760
|
encodedAttrs["borderCollapse"] = "separate";
|
|
31712
31761
|
}
|
|
31713
|
-
if (encodedAttrs.tableProperties
|
|
31762
|
+
if (encodedAttrs.tableProperties.tableWidth) {
|
|
31714
31763
|
const tableWidthMeasurement = encodedAttrs.tableProperties.tableWidth;
|
|
31715
31764
|
const widthPx = twipsToPixels(tableWidthMeasurement.value);
|
|
31716
31765
|
if (widthPx != null) {
|
|
@@ -31725,25 +31774,22 @@ const encode$g = (params2, encodedAttrs) => {
|
|
|
31725
31774
|
};
|
|
31726
31775
|
}
|
|
31727
31776
|
}
|
|
31728
|
-
const
|
|
31729
|
-
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2);
|
|
31730
|
-
|
|
31731
|
-
|
|
31732
|
-
|
|
31733
|
-
|
|
31734
|
-
|
|
31735
|
-
}
|
|
31777
|
+
const borderProps = _processTableBorders(encodedAttrs.tableProperties.borders || {});
|
|
31778
|
+
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2) || {};
|
|
31779
|
+
const rowBorders = { ...referencedStyles.rowBorders, ...borderProps.rowBorders };
|
|
31780
|
+
encodedAttrs.borders = { ...referencedStyles.borders, ...borderProps.borders };
|
|
31781
|
+
encodedAttrs.tableProperties.cellMargins = referencedStyles.cellMargins = {
|
|
31782
|
+
...referencedStyles.cellMargins,
|
|
31783
|
+
...encodedAttrs.tableProperties.cellMargins
|
|
31784
|
+
};
|
|
31736
31785
|
const rows = node.elements.filter((el) => el.name === "w:tr");
|
|
31737
|
-
const borderData = Object.assign({}, referencedStyles?.borders || {}, borders || {});
|
|
31738
|
-
const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
|
|
31739
|
-
encodedAttrs["borders"] = borderData;
|
|
31740
31786
|
let columnWidths = Array.isArray(encodedAttrs["grid"]) ? encodedAttrs["grid"].map((item) => twipsToPixels(item.col)) : [];
|
|
31741
31787
|
if (!columnWidths.length) {
|
|
31742
31788
|
const fallback = buildFallbackGridForTable({
|
|
31743
31789
|
params: params2,
|
|
31744
31790
|
rows,
|
|
31745
31791
|
tableWidth: encodedAttrs.tableWidth,
|
|
31746
|
-
tableWidthMeasurement: encodedAttrs.tableProperties
|
|
31792
|
+
tableWidthMeasurement: encodedAttrs.tableProperties.tableWidth
|
|
31747
31793
|
});
|
|
31748
31794
|
if (fallback) {
|
|
31749
31795
|
encodedAttrs.grid = fallback.grid;
|
|
@@ -31756,11 +31802,12 @@ const encode$g = (params2, encodedAttrs) => {
|
|
|
31756
31802
|
rows.forEach((row, rowIndex) => {
|
|
31757
31803
|
const result = translator$v.encode({
|
|
31758
31804
|
...params2,
|
|
31805
|
+
path: [...params2.path || [], node],
|
|
31759
31806
|
nodes: [row],
|
|
31760
31807
|
extraParams: {
|
|
31761
31808
|
row,
|
|
31762
31809
|
table: node,
|
|
31763
|
-
rowBorders
|
|
31810
|
+
rowBorders,
|
|
31764
31811
|
columnWidths,
|
|
31765
31812
|
activeRowSpans: activeRowSpans.slice(),
|
|
31766
31813
|
rowIndex,
|
|
@@ -35285,7 +35332,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
35285
35332
|
static getStoredSuperdocVersion(docx) {
|
|
35286
35333
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
35287
35334
|
}
|
|
35288
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.31.0-next.
|
|
35335
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.31.0-next.7") {
|
|
35289
35336
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
35290
35337
|
}
|
|
35291
35338
|
/**
|
|
@@ -52545,7 +52592,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
52545
52592
|
{ default: remarkStringify },
|
|
52546
52593
|
{ default: remarkGfm }
|
|
52547
52594
|
] = await Promise.all([
|
|
52548
|
-
import("./index-
|
|
52595
|
+
import("./index-BJ6cOegF-C-oX4LAe.es.js"),
|
|
52549
52596
|
import("./index-DRCvimau-Cw339678.es.js"),
|
|
52550
52597
|
import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
|
|
52551
52598
|
import("./index-D_sWOSiG-DE96TaT5.es.js"),
|
|
@@ -52746,7 +52793,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
52746
52793
|
* Process collaboration migrations
|
|
52747
52794
|
*/
|
|
52748
52795
|
processCollaborationMigrations() {
|
|
52749
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.31.0-next.
|
|
52796
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.31.0-next.7");
|
|
52750
52797
|
if (!this.options.ydoc) return;
|
|
52751
52798
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
52752
52799
|
let docVersion = metaMap.get("version");
|
|
@@ -55155,6 +55202,46 @@ function getStructuredContentTagsById(idOrIds, state2) {
|
|
|
55155
55202
|
});
|
|
55156
55203
|
return result;
|
|
55157
55204
|
}
|
|
55205
|
+
function createTagObject(tagData) {
|
|
55206
|
+
if (!tagData || typeof tagData !== "object") {
|
|
55207
|
+
return null;
|
|
55208
|
+
}
|
|
55209
|
+
return JSON.stringify(tagData);
|
|
55210
|
+
}
|
|
55211
|
+
function parseTagObject(tag) {
|
|
55212
|
+
if (typeof tag !== "string" || !tag.startsWith("{")) {
|
|
55213
|
+
return null;
|
|
55214
|
+
}
|
|
55215
|
+
try {
|
|
55216
|
+
const parsed = JSON.parse(tag);
|
|
55217
|
+
return parsed && typeof parsed === "object" ? parsed : null;
|
|
55218
|
+
} catch {
|
|
55219
|
+
return null;
|
|
55220
|
+
}
|
|
55221
|
+
}
|
|
55222
|
+
function hasGroup(tag) {
|
|
55223
|
+
const parsed = parseTagObject(tag);
|
|
55224
|
+
return parsed !== null && typeof parsed.group === "string";
|
|
55225
|
+
}
|
|
55226
|
+
function getGroup(tag) {
|
|
55227
|
+
const parsed = parseTagObject(tag);
|
|
55228
|
+
return parsed && typeof parsed.group === "string" ? parsed.group : null;
|
|
55229
|
+
}
|
|
55230
|
+
function getStructuredContentByGroup(groupOrGroups, state2) {
|
|
55231
|
+
const searchGroups = Array.isArray(groupOrGroups) ? groupOrGroups : [groupOrGroups];
|
|
55232
|
+
const result = findChildren$5(state2.doc, (node) => {
|
|
55233
|
+
const isStructuredContent = ["structuredContent", "structuredContentBlock"].includes(node.type.name);
|
|
55234
|
+
if (!isStructuredContent) {
|
|
55235
|
+
return false;
|
|
55236
|
+
}
|
|
55237
|
+
const nodeGroup = getGroup(node.attrs.tag);
|
|
55238
|
+
if (!nodeGroup) {
|
|
55239
|
+
return false;
|
|
55240
|
+
}
|
|
55241
|
+
return searchGroups.includes(nodeGroup);
|
|
55242
|
+
});
|
|
55243
|
+
return result;
|
|
55244
|
+
}
|
|
55158
55245
|
function getStructuredContentTags(state2) {
|
|
55159
55246
|
const result = findChildren$5(state2.doc, (node) => {
|
|
55160
55247
|
return node.type.name === "structuredContent" || node.type.name === "structuredContentBlock";
|
|
@@ -55187,11 +55274,16 @@ function getStructuredContentTablesById(id, state2) {
|
|
|
55187
55274
|
}
|
|
55188
55275
|
const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
55189
55276
|
__proto__: null,
|
|
55277
|
+
createTagObject,
|
|
55278
|
+
getGroup,
|
|
55190
55279
|
getStructuredContentBlockTags,
|
|
55280
|
+
getStructuredContentByGroup,
|
|
55191
55281
|
getStructuredContentInlineTags,
|
|
55192
55282
|
getStructuredContentTablesById,
|
|
55193
55283
|
getStructuredContentTags,
|
|
55194
|
-
getStructuredContentTagsById
|
|
55284
|
+
getStructuredContentTagsById,
|
|
55285
|
+
hasGroup,
|
|
55286
|
+
parseTagObject
|
|
55195
55287
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
55196
55288
|
const STRUCTURED_CONTENT_NAMES = ["structuredContent", "structuredContentBlock"];
|
|
55197
55289
|
const StructuredContentCommands = Extension.create({
|
|
@@ -55203,6 +55295,16 @@ const StructuredContentCommands = Extension.create({
|
|
|
55203
55295
|
* @category Command
|
|
55204
55296
|
* @param {StructuredContentInlineInsert} options
|
|
55205
55297
|
* @example
|
|
55298
|
+
* // With group for linking multiple fields
|
|
55299
|
+
* editor.commands.insertStructuredContentInline({
|
|
55300
|
+
* attrs: {
|
|
55301
|
+
* group: 'customer-info',
|
|
55302
|
+
* alias: 'Customer Name',
|
|
55303
|
+
* },
|
|
55304
|
+
* text: 'John Doe',
|
|
55305
|
+
* });
|
|
55306
|
+
*
|
|
55307
|
+
* // No group
|
|
55206
55308
|
* editor.commands.insertStructuredContentInline({
|
|
55207
55309
|
* attrs: {
|
|
55208
55310
|
* id: '123',
|
|
@@ -55231,12 +55333,17 @@ const StructuredContentCommands = Extension.create({
|
|
|
55231
55333
|
if (!content) {
|
|
55232
55334
|
content = schema.text(" ");
|
|
55233
55335
|
}
|
|
55336
|
+
let tag = options.attrs?.tag || "inline_text_sdt";
|
|
55337
|
+
if (options.attrs?.group) {
|
|
55338
|
+
tag = createTagObject({ group: options.attrs.group });
|
|
55339
|
+
}
|
|
55234
55340
|
const attrs = {
|
|
55235
|
-
...options.attrs,
|
|
55236
55341
|
id: options.attrs?.id || generateRandomSigned32BitIntStrId(),
|
|
55237
|
-
tag
|
|
55238
|
-
alias: options.attrs?.alias || "Structured content"
|
|
55342
|
+
tag,
|
|
55343
|
+
alias: options.attrs?.alias || "Structured content",
|
|
55344
|
+
...options.attrs
|
|
55239
55345
|
};
|
|
55346
|
+
delete attrs.group;
|
|
55240
55347
|
const node = schema.nodes.structuredContent.create(attrs, content, null);
|
|
55241
55348
|
const parent = findParentNode((node2) => node2.type.name === "structuredContent")(state2.selection);
|
|
55242
55349
|
if (parent) {
|
|
@@ -55252,14 +55359,22 @@ const StructuredContentCommands = Extension.create({
|
|
|
55252
55359
|
* @category Command
|
|
55253
55360
|
* @param {StructuredContentBlockInsert} options
|
|
55254
55361
|
* @example
|
|
55362
|
+
* // With group for linking multiple fields
|
|
55363
|
+
* editor.commands.insertStructuredContentBlock({
|
|
55364
|
+
* attrs: {
|
|
55365
|
+
* group: 'terms-section',
|
|
55366
|
+
* alias: 'Terms & Conditions',
|
|
55367
|
+
* },
|
|
55368
|
+
* html: '<p>Legal content...</p>',
|
|
55369
|
+
* });
|
|
55370
|
+
*
|
|
55371
|
+
* // No group
|
|
55255
55372
|
* editor.commands.insertStructuredContentBlock({
|
|
55256
55373
|
* attrs: {
|
|
55257
55374
|
* id: '456',
|
|
55258
55375
|
* alias: 'Terms & Conditions',
|
|
55259
55376
|
* },
|
|
55260
55377
|
* json: { type: 'paragraph', content: [{ type: 'text', text: 'Legal content...' }] }
|
|
55261
|
-
* // or
|
|
55262
|
-
* html: '<p>Legal content...</p>',
|
|
55263
55378
|
* });
|
|
55264
55379
|
*/
|
|
55265
55380
|
insertStructuredContentBlock: (options = {}) => ({ editor, dispatch, state: state2, tr }) => {
|
|
@@ -55282,12 +55397,17 @@ const StructuredContentCommands = Extension.create({
|
|
|
55282
55397
|
if (!content) {
|
|
55283
55398
|
content = schema.nodeFromJSON({ type: "paragraph", content: [] });
|
|
55284
55399
|
}
|
|
55400
|
+
let tag = options.attrs?.tag || "block_table_sdt";
|
|
55401
|
+
if (options.attrs?.group) {
|
|
55402
|
+
tag = createTagObject({ group: options.attrs.group });
|
|
55403
|
+
}
|
|
55285
55404
|
const attrs = {
|
|
55286
|
-
...options.attrs,
|
|
55287
55405
|
id: options.attrs?.id || generateRandomSigned32BitIntStrId(),
|
|
55288
|
-
tag
|
|
55289
|
-
alias: options.attrs?.alias || "Structured content"
|
|
55406
|
+
tag,
|
|
55407
|
+
alias: options.attrs?.alias || "Structured content",
|
|
55408
|
+
...options.attrs
|
|
55290
55409
|
};
|
|
55410
|
+
delete attrs.group;
|
|
55291
55411
|
const node = schema.nodes.structuredContentBlock.create(attrs, content, null);
|
|
55292
55412
|
const parent = findParentNode((node2) => node2.type.name === "structuredContentBlock")(state2.selection);
|
|
55293
55413
|
if (parent) {
|
|
@@ -55417,6 +55537,85 @@ const StructuredContentCommands = Extension.create({
|
|
|
55417
55537
|
}
|
|
55418
55538
|
return true;
|
|
55419
55539
|
},
|
|
55540
|
+
/**
|
|
55541
|
+
* Updates all structured content fields that share the same group identifier.
|
|
55542
|
+
* Groups allow linking multiple fields together for batch operations.
|
|
55543
|
+
* @category Command
|
|
55544
|
+
* @param {string} group - Group identifier shared by multiple fields
|
|
55545
|
+
* @param {StructuredContentUpdate} options
|
|
55546
|
+
* @example
|
|
55547
|
+
* // Update all fields in the customer-info group
|
|
55548
|
+
* editor.commands.updateStructuredContentByGroup('customer-info', { text: 'Jane Doe' });
|
|
55549
|
+
*
|
|
55550
|
+
* // Update block content in a group
|
|
55551
|
+
* editor.commands.updateStructuredContentByGroup('terms-section', {
|
|
55552
|
+
* html: '<p>Updated terms...</p>'
|
|
55553
|
+
* });
|
|
55554
|
+
*/
|
|
55555
|
+
updateStructuredContentByGroup: (group, options = {}) => ({ editor, dispatch, state: state2, tr }) => {
|
|
55556
|
+
const structuredContentTags = getStructuredContentByGroup(group, state2);
|
|
55557
|
+
if (!structuredContentTags.length) {
|
|
55558
|
+
return true;
|
|
55559
|
+
}
|
|
55560
|
+
const { schema } = editor;
|
|
55561
|
+
if (dispatch) {
|
|
55562
|
+
structuredContentTags.forEach((structuredContent) => {
|
|
55563
|
+
const { pos, node } = structuredContent;
|
|
55564
|
+
const posFrom = tr.mapping.map(pos);
|
|
55565
|
+
const posTo = tr.mapping.map(pos + node.nodeSize);
|
|
55566
|
+
let content = null;
|
|
55567
|
+
if (options.text) {
|
|
55568
|
+
content = schema.text(options.text);
|
|
55569
|
+
}
|
|
55570
|
+
if (options.html) {
|
|
55571
|
+
const html = htmlHandler(options.html, editor);
|
|
55572
|
+
const doc2 = DOMParser$1.fromSchema(schema).parse(html);
|
|
55573
|
+
content = doc2.content;
|
|
55574
|
+
}
|
|
55575
|
+
if (options.json) {
|
|
55576
|
+
content = schema.nodeFromJSON(options.json);
|
|
55577
|
+
}
|
|
55578
|
+
if (!content) {
|
|
55579
|
+
content = node.content;
|
|
55580
|
+
}
|
|
55581
|
+
const updatedNode = node.type.create({ ...node.attrs, ...options.attrs }, content, node.marks);
|
|
55582
|
+
const currentNode = tr.doc.nodeAt(posFrom);
|
|
55583
|
+
if (currentNode && node.eq(currentNode)) {
|
|
55584
|
+
tr.replaceWith(posFrom, posTo, updatedNode);
|
|
55585
|
+
}
|
|
55586
|
+
});
|
|
55587
|
+
}
|
|
55588
|
+
return true;
|
|
55589
|
+
},
|
|
55590
|
+
/**
|
|
55591
|
+
* Removes all structured content fields that share the same group identifier.
|
|
55592
|
+
* @category Command
|
|
55593
|
+
* @param {string | string[]} groupOrGroups - Single group or array of groups
|
|
55594
|
+
* @example
|
|
55595
|
+
* // Delete all fields in a group
|
|
55596
|
+
* editor.commands.deleteStructuredContentByGroup('customer-info');
|
|
55597
|
+
*
|
|
55598
|
+
* // Delete multiple groups
|
|
55599
|
+
* editor.commands.deleteStructuredContentByGroup(['header', 'footer']);
|
|
55600
|
+
*/
|
|
55601
|
+
deleteStructuredContentByGroup: (groupOrGroups) => ({ dispatch, state: state2, tr }) => {
|
|
55602
|
+
const structuredContentTags = getStructuredContentByGroup(groupOrGroups, state2);
|
|
55603
|
+
if (!structuredContentTags.length) {
|
|
55604
|
+
return true;
|
|
55605
|
+
}
|
|
55606
|
+
if (dispatch) {
|
|
55607
|
+
structuredContentTags.forEach((structuredContent) => {
|
|
55608
|
+
const { pos, node } = structuredContent;
|
|
55609
|
+
const posFrom = tr.mapping.map(pos);
|
|
55610
|
+
const posTo = tr.mapping.map(pos + node.nodeSize);
|
|
55611
|
+
const currentNode = tr.doc.nodeAt(posFrom);
|
|
55612
|
+
if (currentNode && node.eq(currentNode)) {
|
|
55613
|
+
tr.delete(posFrom, posTo);
|
|
55614
|
+
}
|
|
55615
|
+
});
|
|
55616
|
+
}
|
|
55617
|
+
return true;
|
|
55618
|
+
},
|
|
55420
55619
|
/**
|
|
55421
55620
|
* Append multiple rows to the end of a table inside a structured content block.
|
|
55422
55621
|
* Each inner array represents the cell values for one new row.
|
|
@@ -56565,7 +56764,7 @@ const applyLinkedStyleToTransaction = (tr, editor, style2) => {
|
|
|
56565
56764
|
let selection = tr.selection;
|
|
56566
56765
|
const state2 = editor.state;
|
|
56567
56766
|
const focusState = CustomSelectionPluginKey.getState(state2);
|
|
56568
|
-
if (selection.empty && focusState?.preservedSelection) {
|
|
56767
|
+
if (selection.empty && focusState?.preservedSelection && !focusState?.preservedSelection.empty) {
|
|
56569
56768
|
selection = focusState.preservedSelection;
|
|
56570
56769
|
tr.setSelection(selection);
|
|
56571
56770
|
} else if (selection.empty && editor.options.lastSelection) {
|
|
@@ -56632,6 +56831,31 @@ const applyLinkedStyleToTransaction = (tr, editor, style2) => {
|
|
|
56632
56831
|
});
|
|
56633
56832
|
return true;
|
|
56634
56833
|
};
|
|
56834
|
+
const stepInsertsTextIntoStyledParagraph = (tr, oldEditorState, step, stepIndex) => {
|
|
56835
|
+
if (!step.slice || step.slice.size === 0 || typeof step.from !== "number") {
|
|
56836
|
+
return false;
|
|
56837
|
+
}
|
|
56838
|
+
let insertsText = false;
|
|
56839
|
+
step.slice.content.descendants((node) => {
|
|
56840
|
+
if (node.type?.name === "text" && node.text?.length) {
|
|
56841
|
+
insertsText = true;
|
|
56842
|
+
return false;
|
|
56843
|
+
}
|
|
56844
|
+
return true;
|
|
56845
|
+
});
|
|
56846
|
+
if (!insertsText) return false;
|
|
56847
|
+
const docBeforeStep = tr.docs?.[stepIndex] || oldEditorState.doc;
|
|
56848
|
+
if (!docBeforeStep) return false;
|
|
56849
|
+
const resolvedPos = Math.min(step.from, docBeforeStep.content.size);
|
|
56850
|
+
const $pos = docBeforeStep.resolve(resolvedPos);
|
|
56851
|
+
for (let depth = $pos.depth; depth >= 0; depth--) {
|
|
56852
|
+
const node = $pos.node(depth);
|
|
56853
|
+
if (node?.type?.name === "paragraph") {
|
|
56854
|
+
return Boolean(node.attrs?.styleId);
|
|
56855
|
+
}
|
|
56856
|
+
}
|
|
56857
|
+
return false;
|
|
56858
|
+
};
|
|
56635
56859
|
const LinkedStylesPluginKey = new PluginKey("linkedStyles");
|
|
56636
56860
|
const createLinkedStylesPlugin = (editor) => {
|
|
56637
56861
|
return new Plugin({
|
|
@@ -56665,7 +56889,7 @@ const createLinkedStylesPlugin = (editor) => {
|
|
|
56665
56889
|
if (tr.docChanged) {
|
|
56666
56890
|
let mightAffectStyles = false;
|
|
56667
56891
|
const styleRelatedMarks = /* @__PURE__ */ new Set(["textStyle", "bold", "italic", "underline", "strike"]);
|
|
56668
|
-
tr.steps.forEach((step) => {
|
|
56892
|
+
tr.steps.forEach((step, index2) => {
|
|
56669
56893
|
if (step.slice) {
|
|
56670
56894
|
step.slice.content.descendants((node) => {
|
|
56671
56895
|
if (node.attrs?.styleId) {
|
|
@@ -56686,6 +56910,9 @@ const createLinkedStylesPlugin = (editor) => {
|
|
|
56686
56910
|
mightAffectStyles = true;
|
|
56687
56911
|
}
|
|
56688
56912
|
}
|
|
56913
|
+
if (!mightAffectStyles && stepInsertsTextIntoStyledParagraph(tr, oldEditorState, step, index2)) {
|
|
56914
|
+
mightAffectStyles = true;
|
|
56915
|
+
}
|
|
56689
56916
|
});
|
|
56690
56917
|
if (mightAffectStyles) {
|
|
56691
56918
|
const styles = LinkedStylesPluginKey.getState(editor.state).styles;
|
|
@@ -58036,6 +58263,8 @@ const Paragraph = OxmlNode.create({
|
|
|
58036
58263
|
}
|
|
58037
58264
|
},
|
|
58038
58265
|
styleId: {
|
|
58266
|
+
default: null,
|
|
58267
|
+
keepOnSplit: false,
|
|
58039
58268
|
renderDOM: (attrs) => {
|
|
58040
58269
|
if (!attrs.styleId) return {};
|
|
58041
58270
|
return { styleid: attrs.styleId };
|
|
@@ -58781,15 +59010,6 @@ const HardBreak = Node$1.create({
|
|
|
58781
59010
|
};
|
|
58782
59011
|
}
|
|
58783
59012
|
});
|
|
58784
|
-
const getColStyleDeclaration = (minWidth, width) => {
|
|
58785
|
-
if (width != null) {
|
|
58786
|
-
const numericWidth = Number(width);
|
|
58787
|
-
if (Number.isFinite(numericWidth) && numericWidth >= 0) {
|
|
58788
|
-
return ["width", `${numericWidth}px`];
|
|
58789
|
-
}
|
|
58790
|
-
}
|
|
58791
|
-
return ["min-width", `${minWidth}px`];
|
|
58792
|
-
};
|
|
58793
59013
|
const createTableView = ({ editor }) => {
|
|
58794
59014
|
return class TableView {
|
|
58795
59015
|
constructor(node, cellMinWidth2) {
|
|
@@ -58808,7 +59028,7 @@ const createTableView = ({ editor }) => {
|
|
|
58808
59028
|
this.table = this.dom.appendChild(document.createElement("table"));
|
|
58809
59029
|
this.colgroup = this.table.appendChild(document.createElement("colgroup"));
|
|
58810
59030
|
updateTable(this.editor, this.node, this.table);
|
|
58811
|
-
updateColumns(node, this.colgroup, this.table
|
|
59031
|
+
updateColumns(node, this.colgroup, this.table);
|
|
58812
59032
|
this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
58813
59033
|
setTimeout(() => {
|
|
58814
59034
|
updateTableWrapper(this.dom, this.table);
|
|
@@ -58820,7 +59040,7 @@ const createTableView = ({ editor }) => {
|
|
|
58820
59040
|
}
|
|
58821
59041
|
this.node = node;
|
|
58822
59042
|
updateTable(this.editor, node, this.table);
|
|
58823
|
-
updateColumns(node, this.colgroup, this.table, this.cellMinWidth
|
|
59043
|
+
updateColumns(node, this.colgroup, this.table, this.cellMinWidth);
|
|
58824
59044
|
updateTableWrapper(this.dom, this.table);
|
|
58825
59045
|
return true;
|
|
58826
59046
|
}
|
|
@@ -58833,43 +59053,20 @@ const createTableView = ({ editor }) => {
|
|
|
58833
59053
|
}
|
|
58834
59054
|
};
|
|
58835
59055
|
};
|
|
58836
|
-
function updateColumns(node, colgroup, table, cellMinWidth2
|
|
59056
|
+
function updateColumns(node, colgroup, table, cellMinWidth2) {
|
|
58837
59057
|
const gridColumns = Array.isArray(node.attrs?.grid) && node.attrs.grid.length ? node.attrs.grid.map((col) => twipsToPixels(col.col)) : null;
|
|
58838
59058
|
const totalColumns = gridColumns?.length ?? null;
|
|
58839
|
-
const pageBody = table.closest(".page__body");
|
|
58840
|
-
const wrapper = table.parentElement;
|
|
58841
|
-
let availableWidth = pageBody?.getBoundingClientRect?.().width;
|
|
58842
|
-
if (!availableWidth && wrapper) {
|
|
58843
|
-
availableWidth = wrapper.getBoundingClientRect().width;
|
|
58844
|
-
}
|
|
58845
|
-
if (typeof availableWidth === "number" && !Number.isNaN(availableWidth)) {
|
|
58846
|
-
availableWidth = Math.max(availableWidth - 2, 0);
|
|
58847
|
-
} else {
|
|
58848
|
-
availableWidth = null;
|
|
58849
|
-
}
|
|
58850
|
-
const pageStyles = editor?.converter?.pageStyles;
|
|
58851
|
-
if (pageStyles?.pageSize?.width) {
|
|
58852
|
-
const toNumber = (v2) => typeof v2 === "number" ? v2 : parseFloat(v2) || 0;
|
|
58853
|
-
const pageWidth = toNumber(pageStyles.pageSize.width);
|
|
58854
|
-
const marginLeft = toNumber(pageStyles.pageMargins?.left);
|
|
58855
|
-
const marginRight = toNumber(pageStyles.pageMargins?.right);
|
|
58856
|
-
const pageAvailableWidthPx = Math.max((pageWidth - marginLeft - marginRight) * PIXELS_PER_INCH, 0);
|
|
58857
|
-
if (pageAvailableWidthPx > 0) {
|
|
58858
|
-
availableWidth = availableWidth ? Math.min(availableWidth, pageAvailableWidthPx) : pageAvailableWidthPx;
|
|
58859
|
-
}
|
|
58860
|
-
}
|
|
58861
59059
|
const resolveColumnWidth = (colIndex2, colwidthValue) => {
|
|
58862
|
-
if (overrideCol === colIndex2) return overrideValue;
|
|
58863
59060
|
if (colwidthValue != null) return colwidthValue;
|
|
58864
59061
|
if (gridColumns && gridColumns[colIndex2] != null) return gridColumns[colIndex2];
|
|
58865
59062
|
return null;
|
|
58866
59063
|
};
|
|
58867
59064
|
const widths = [];
|
|
58868
|
-
const
|
|
59065
|
+
const firstRow = node.firstChild;
|
|
58869
59066
|
let colIndex = 0;
|
|
58870
|
-
if (
|
|
58871
|
-
for (let i = 0; i <
|
|
58872
|
-
const child =
|
|
59067
|
+
if (firstRow !== null) {
|
|
59068
|
+
for (let i = 0; i < firstRow.childCount; i++) {
|
|
59069
|
+
const child = firstRow.child(i);
|
|
58873
59070
|
const { colspan, colwidth } = child.attrs;
|
|
58874
59071
|
for (let span = 0; span < colspan; span += 1, colIndex += 1) {
|
|
58875
59072
|
widths.push(resolveColumnWidth(colIndex, colwidth && colwidth[span]));
|
|
@@ -58889,49 +59086,41 @@ function updateColumns(node, colgroup, table, cellMinWidth2, overrideCol, overri
|
|
|
58889
59086
|
if (numericWidth < 1) return 0;
|
|
58890
59087
|
return numericWidth;
|
|
58891
59088
|
});
|
|
58892
|
-
const
|
|
58893
|
-
|
|
58894
|
-
|
|
58895
|
-
|
|
58896
|
-
|
|
58897
|
-
let
|
|
58898
|
-
let hasUndefinedWidth = false;
|
|
58899
|
-
let dom = colgroup.firstChild;
|
|
59089
|
+
const tableWidthCSS = convertSizeToCSS(
|
|
59090
|
+
// TODO: why is tableWidth undefined in src/tests/import-export/font-default-styles.test.js?
|
|
59091
|
+
node.attrs.tableProperties.tableWidth?.value ?? null,
|
|
59092
|
+
node.attrs.tableProperties.tableWidth?.type ?? "auto"
|
|
59093
|
+
);
|
|
59094
|
+
let colElement = colgroup.firstChild;
|
|
58900
59095
|
normalizedWidths.forEach((width) => {
|
|
58901
|
-
|
|
58902
|
-
|
|
58903
|
-
scaledWidth = scaledWidth * scale;
|
|
58904
|
-
}
|
|
58905
|
-
const [propKey, propVal] = getColStyleDeclaration(cellMinWidth2, scaledWidth);
|
|
58906
|
-
if (scaledWidth == null) {
|
|
58907
|
-
totalWidth += cellMinWidth2;
|
|
58908
|
-
hasUndefinedWidth = true;
|
|
58909
|
-
} else {
|
|
58910
|
-
totalWidth += scaledWidth;
|
|
58911
|
-
}
|
|
58912
|
-
if (!dom) {
|
|
58913
|
-
const colElement = document.createElement("col");
|
|
58914
|
-
colElement.style.setProperty(propKey, propVal);
|
|
59096
|
+
if (!colElement) {
|
|
59097
|
+
colElement = document.createElement("col");
|
|
58915
59098
|
colgroup.appendChild(colElement);
|
|
58916
|
-
} else {
|
|
58917
|
-
dom.style.setProperty(propKey, propVal);
|
|
58918
|
-
dom = dom.nextSibling;
|
|
58919
59099
|
}
|
|
59100
|
+
colElement.style.width = width !== null && width !== void 0 ? `${width}px` : null;
|
|
59101
|
+
colElement = colElement.nextSibling;
|
|
58920
59102
|
});
|
|
58921
|
-
while (
|
|
58922
|
-
const next =
|
|
58923
|
-
|
|
58924
|
-
|
|
58925
|
-
}
|
|
58926
|
-
|
|
58927
|
-
|
|
58928
|
-
|
|
58929
|
-
|
|
59103
|
+
while (colElement) {
|
|
59104
|
+
const next = colElement.nextSibling;
|
|
59105
|
+
colElement.parentNode?.removeChild(colElement);
|
|
59106
|
+
colElement = next;
|
|
59107
|
+
}
|
|
59108
|
+
const tableIndent = convertSizeToCSS(
|
|
59109
|
+
node.attrs.tableProperties.tableIndent?.value ?? 0,
|
|
59110
|
+
node.attrs.tableProperties.tableIndent?.type ?? "dxa"
|
|
59111
|
+
);
|
|
59112
|
+
const firstRowFirstCellPaddingLeftPx = firstRow?.firstChild?.attrs?.cellMargins?.left ?? 0;
|
|
59113
|
+
const firstRowLastCellPaddingRightPx = firstRow?.lastChild?.attrs?.cellMargins?.right ?? 0;
|
|
59114
|
+
table.style.marginLeft = `${-firstRowFirstCellPaddingLeftPx}px`;
|
|
59115
|
+
if (tableIndent !== null) {
|
|
59116
|
+
table.style.marginLeft = tableIndent;
|
|
59117
|
+
}
|
|
59118
|
+
if (node.attrs.tableProperties.tableWidth?.type === "pct") {
|
|
59119
|
+
const padding = firstRowFirstCellPaddingLeftPx + firstRowLastCellPaddingRightPx;
|
|
59120
|
+
table.style.maxWidth = table.style.width = `calc(${tableWidthCSS} + ${padding}px)`;
|
|
58930
59121
|
} else {
|
|
58931
|
-
table.style.width =
|
|
58932
|
-
table.style.minWidth = `${totalWidth}px`;
|
|
59122
|
+
table.style.maxWidth = table.style.width = tableWidthCSS;
|
|
58933
59123
|
}
|
|
58934
|
-
table.style.maxWidth = "100%";
|
|
58935
59124
|
}
|
|
58936
59125
|
function updateTable(editor, node, table) {
|
|
58937
59126
|
const allExtensionsAttrs = editor.extensionService.attributes;
|
|
@@ -59009,6 +59198,15 @@ const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent =
|
|
|
59009
59198
|
const tableBorders = createTableBorders();
|
|
59010
59199
|
return types2.table.createChecked({ borders: tableBorders }, rows);
|
|
59011
59200
|
};
|
|
59201
|
+
const getColStyleDeclaration = (minWidth, width) => {
|
|
59202
|
+
if (width != null) {
|
|
59203
|
+
const numericWidth = Number(width);
|
|
59204
|
+
if (Number.isFinite(numericWidth) && numericWidth >= 0) {
|
|
59205
|
+
return ["width", `${numericWidth}px`];
|
|
59206
|
+
}
|
|
59207
|
+
}
|
|
59208
|
+
return ["min-width", `${minWidth}px`];
|
|
59209
|
+
};
|
|
59012
59210
|
const MIN_MEANINGFUL_WIDTH_PX = 1;
|
|
59013
59211
|
const createColGroup = (node, cellMinWidth2, overrideCol, overrideValue) => {
|
|
59014
59212
|
let totalWidth = 0;
|
|
@@ -61375,15 +61573,6 @@ const Table = Node$1.create({
|
|
|
61375
61573
|
},
|
|
61376
61574
|
addAttributes() {
|
|
61377
61575
|
return {
|
|
61378
|
-
/* tableWidth: {
|
|
61379
|
-
renderDOM: ({ tableWidth }) => {
|
|
61380
|
-
if (!tableWidth) return {};
|
|
61381
|
-
const { width, type = 'auto' } = tableWidth;
|
|
61382
|
-
return {
|
|
61383
|
-
style: `width: ${width}px`
|
|
61384
|
-
};
|
|
61385
|
-
},
|
|
61386
|
-
}, */
|
|
61387
61576
|
/**
|
|
61388
61577
|
* @private
|
|
61389
61578
|
* @category Attribute
|
|
@@ -61487,7 +61676,12 @@ const Table = Node$1.create({
|
|
|
61487
61676
|
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 371-483
|
|
61488
61677
|
*/
|
|
61489
61678
|
tableProperties: {
|
|
61490
|
-
default:
|
|
61679
|
+
default: {
|
|
61680
|
+
tableWidth: {
|
|
61681
|
+
value: null,
|
|
61682
|
+
type: "auto"
|
|
61683
|
+
}
|
|
61684
|
+
},
|
|
61491
61685
|
rendered: false
|
|
61492
61686
|
},
|
|
61493
61687
|
/**
|
|
@@ -62255,12 +62449,14 @@ const TableCell = Node$1.create({
|
|
|
62255
62449
|
}
|
|
62256
62450
|
},
|
|
62257
62451
|
cellMargins: {
|
|
62258
|
-
renderDOM({ cellMargins }) {
|
|
62452
|
+
renderDOM({ cellMargins, borders }) {
|
|
62259
62453
|
if (!cellMargins) return {};
|
|
62260
62454
|
const sides2 = ["top", "right", "bottom", "left"];
|
|
62261
62455
|
const style2 = sides2.map((side) => {
|
|
62262
|
-
const margin = cellMargins?.[side];
|
|
62263
|
-
|
|
62456
|
+
const margin = cellMargins?.[side] ?? 0;
|
|
62457
|
+
const border = borders?.[side];
|
|
62458
|
+
const borderSize = border && border.val !== "none" ? Math.ceil(border.size) : 0;
|
|
62459
|
+
if (margin) return `padding-${side}: ${Math.max(0, margin - borderSize)}px;`;
|
|
62264
62460
|
return "";
|
|
62265
62461
|
}).join(" ");
|
|
62266
62462
|
return { style: style2 };
|
|
@@ -91482,7 +91678,7 @@ const _sfc_main$1 = {
|
|
|
91482
91678
|
};
|
|
91483
91679
|
}
|
|
91484
91680
|
};
|
|
91485
|
-
const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
91681
|
+
const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-4615ea7d"]]);
|
|
91486
91682
|
const _hoisted_1 = ["innerHTML"];
|
|
91487
91683
|
const _sfc_main = {
|
|
91488
91684
|
__name: "SuperInput",
|