superdoc 0.31.0-next.6 → 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.
Files changed (50) hide show
  1. package/dist/chunks/{PdfViewer-BSud7RY4.cjs → PdfViewer-C_gVEaJa.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-DK93vPf1.es.js → PdfViewer-HhmcCtfd.es.js} +1 -1
  3. package/dist/chunks/{index-DAES86tg-Cjexh3WM.cjs → index-BJ6cOegF-BuvRSNoV.cjs} +1 -1
  4. package/dist/chunks/{index-DAES86tg-BDL6WVta.es.js → index-BJ6cOegF-C-oX4LAe.es.js} +1 -1
  5. package/dist/chunks/{index-Bz2Q2Xq2.es.js → index-Cz10rZ5n.es.js} +3 -3
  6. package/dist/chunks/{index-Crequs_q.cjs → index-wLtubQ87.cjs} +3 -3
  7. package/dist/chunks/{super-editor.es-D8NdQdlk.cjs → super-editor.es-Bz-s1Pw4.cjs} +319 -153
  8. package/dist/chunks/{super-editor.es-BWeMHRHm.es.js → super-editor.es-C20nShDu.es.js} +319 -153
  9. package/dist/style.css +10 -9
  10. package/dist/super-editor/ai-writer.es.js +2 -2
  11. package/dist/super-editor/chunks/{converter-DEQxlCAJ.js → converter-DVDL6NWz.js} +100 -53
  12. package/dist/super-editor/chunks/{docx-zipper-C6VMEIY_.js → docx-zipper-4ipmBNSH.js} +1 -1
  13. package/dist/super-editor/chunks/{editor-D0zFmUwx.js → editor-B8v33PJq.js} +221 -102
  14. package/dist/super-editor/chunks/{index-DAES86tg.js → index-BJ6cOegF.js} +1 -1
  15. package/dist/super-editor/chunks/{toolbar-Cwx5bBDV.js → toolbar-CfUofx7k.js} +2 -2
  16. package/dist/super-editor/converter.es.js +1 -1
  17. package/dist/super-editor/docx-zipper.es.js +2 -2
  18. package/dist/super-editor/editor.es.js +3 -3
  19. package/dist/super-editor/file-zipper.es.js +1 -1
  20. package/dist/super-editor/style.css +10 -9
  21. package/dist/super-editor/super-editor/src/core/super-converter/helpers.d.ts +7 -0
  22. package/dist/super-editor/super-editor/src/core/super-converter/helpers.d.ts.map +1 -1
  23. package/dist/super-editor/super-editor/src/core/super-converter/styles.d.ts +2 -1
  24. package/dist/super-editor/super-editor/src/core/super-converter/styles.d.ts.map +1 -1
  25. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/legacy-handle-paragraph-node.d.ts.map +1 -1
  26. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tbl/tbl-translator.d.ts +14 -10
  27. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tbl/tbl-translator.d.ts.map +1 -1
  28. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-translator.d.ts.map +1 -1
  29. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tr/tr-translator.d.ts.map +1 -1
  30. package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content-commands.d.ts +8 -2
  31. package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content-commands.d.ts.map +1 -1
  32. package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentByGroup.d.ts +19 -0
  33. package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentByGroup.d.ts.map +1 -0
  34. package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/index.d.ts +2 -0
  35. package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/tagUtils.d.ts +53 -0
  36. package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/tagUtils.d.ts.map +1 -0
  37. package/dist/super-editor/super-editor/src/extensions/table/TableView.d.ts +7 -1
  38. package/dist/super-editor/super-editor/src/extensions/table/TableView.d.ts.map +1 -1
  39. package/dist/super-editor/super-editor/src/extensions/table/table.d.ts +18 -0
  40. package/dist/super-editor/super-editor/src/extensions/table/table.d.ts.map +1 -1
  41. package/dist/super-editor/super-editor/src/extensions/table-cell/table-cell.d.ts.map +1 -1
  42. package/dist/super-editor/super-editor.es.js +7 -7
  43. package/dist/super-editor/toolbar.es.js +2 -2
  44. package/dist/super-editor.cjs +1 -1
  45. package/dist/super-editor.es.js +1 -1
  46. package/dist/superdoc.cjs +2 -2
  47. package/dist/superdoc.es.js +2 -2
  48. package/dist/superdoc.umd.js +320 -154
  49. package/dist/superdoc.umd.js.map +1 -1
  50. 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 resolvedParagraphProperties = resolveParagraphProperties(params2, inlineParagraphProperties, insideTable);
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 columnCountFromCells = cellNodes.reduce((count, cell) => {
31597
+ const colWidthsFromCellNodes = cellNodes.flatMap((cell) => {
31542
31598
  const spanCount = Math.max(1, cell?.attrs?.colspan ?? 1);
31543
- return count + spanCount;
31544
- }, 0);
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
- cellNodes.forEach((cell) => {
31568
- const { colspan = 1, colwidth } = cell?.attrs || {};
31569
- const spanCount = Math.max(1, colspan);
31570
- for (let span = 0; span < spanCount; span++) {
31571
- const rawWidth = Array.isArray(colwidth) ? colwidth[span] : void 0;
31572
- const cellWidthPixels = typeof rawWidth === "number" && Number.isFinite(rawWidth) ? rawWidth : Number(rawWidth);
31573
- const hasCellWidth = Number.isFinite(cellWidthPixels) && cellWidthPixels > 0;
31574
- const colGridAttrs = grid?.[columnIndex] || {};
31575
- const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
31576
- const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
31577
- let cellWidthTwips;
31578
- let enforceMinimum = false;
31579
- if (hasCellWidth) {
31580
- const tolerance = 0.5;
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 = fallbackColumnWidthTwips;
31590
- enforceMinimum = true;
31640
+ cellWidthTwips = pixelsToTwips(cellWidthPixels);
31591
31641
  }
31592
- pushColumn(cellWidthTwips, { enforceMinimum });
31593
- columnIndex++;
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 && encodedAttrs.tableProperties[key2]) {
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?.tableWidth) {
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 { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
31729
- const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2);
31730
- if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
31731
- encodedAttrs.tableProperties = {
31732
- ...encodedAttrs.tableProperties || {},
31733
- cellMargins: referencedStyles.cellMargins
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?.tableWidth
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: borderRowData,
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.6") {
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-DAES86tg-BDL6WVta.es.js"),
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.6");
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: "inline_text_sdt",
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: "block_table_sdt",
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.
@@ -58811,15 +59010,6 @@ const HardBreak = Node$1.create({
58811
59010
  };
58812
59011
  }
58813
59012
  });
58814
- const getColStyleDeclaration = (minWidth, width) => {
58815
- if (width != null) {
58816
- const numericWidth = Number(width);
58817
- if (Number.isFinite(numericWidth) && numericWidth >= 0) {
58818
- return ["width", `${numericWidth}px`];
58819
- }
58820
- }
58821
- return ["min-width", `${minWidth}px`];
58822
- };
58823
59013
  const createTableView = ({ editor }) => {
58824
59014
  return class TableView {
58825
59015
  constructor(node, cellMinWidth2) {
@@ -58838,7 +59028,7 @@ const createTableView = ({ editor }) => {
58838
59028
  this.table = this.dom.appendChild(document.createElement("table"));
58839
59029
  this.colgroup = this.table.appendChild(document.createElement("colgroup"));
58840
59030
  updateTable(this.editor, this.node, this.table);
58841
- updateColumns(node, this.colgroup, this.table, cellMinWidth2, void 0, void 0, this.editor);
59031
+ updateColumns(node, this.colgroup, this.table);
58842
59032
  this.contentDOM = this.table.appendChild(document.createElement("tbody"));
58843
59033
  setTimeout(() => {
58844
59034
  updateTableWrapper(this.dom, this.table);
@@ -58850,7 +59040,7 @@ const createTableView = ({ editor }) => {
58850
59040
  }
58851
59041
  this.node = node;
58852
59042
  updateTable(this.editor, node, this.table);
58853
- updateColumns(node, this.colgroup, this.table, this.cellMinWidth, void 0, void 0, this.editor);
59043
+ updateColumns(node, this.colgroup, this.table, this.cellMinWidth);
58854
59044
  updateTableWrapper(this.dom, this.table);
58855
59045
  return true;
58856
59046
  }
@@ -58863,43 +59053,20 @@ const createTableView = ({ editor }) => {
58863
59053
  }
58864
59054
  };
58865
59055
  };
58866
- function updateColumns(node, colgroup, table, cellMinWidth2, overrideCol, overrideValue, editor) {
59056
+ function updateColumns(node, colgroup, table, cellMinWidth2) {
58867
59057
  const gridColumns = Array.isArray(node.attrs?.grid) && node.attrs.grid.length ? node.attrs.grid.map((col) => twipsToPixels(col.col)) : null;
58868
59058
  const totalColumns = gridColumns?.length ?? null;
58869
- const pageBody = table.closest(".page__body");
58870
- const wrapper = table.parentElement;
58871
- let availableWidth = pageBody?.getBoundingClientRect?.().width;
58872
- if (!availableWidth && wrapper) {
58873
- availableWidth = wrapper.getBoundingClientRect().width;
58874
- }
58875
- if (typeof availableWidth === "number" && !Number.isNaN(availableWidth)) {
58876
- availableWidth = Math.max(availableWidth - 2, 0);
58877
- } else {
58878
- availableWidth = null;
58879
- }
58880
- const pageStyles = editor?.converter?.pageStyles;
58881
- if (pageStyles?.pageSize?.width) {
58882
- const toNumber = (v2) => typeof v2 === "number" ? v2 : parseFloat(v2) || 0;
58883
- const pageWidth = toNumber(pageStyles.pageSize.width);
58884
- const marginLeft = toNumber(pageStyles.pageMargins?.left);
58885
- const marginRight = toNumber(pageStyles.pageMargins?.right);
58886
- const pageAvailableWidthPx = Math.max((pageWidth - marginLeft - marginRight) * PIXELS_PER_INCH, 0);
58887
- if (pageAvailableWidthPx > 0) {
58888
- availableWidth = availableWidth ? Math.min(availableWidth, pageAvailableWidthPx) : pageAvailableWidthPx;
58889
- }
58890
- }
58891
59059
  const resolveColumnWidth = (colIndex2, colwidthValue) => {
58892
- if (overrideCol === colIndex2) return overrideValue;
58893
59060
  if (colwidthValue != null) return colwidthValue;
58894
59061
  if (gridColumns && gridColumns[colIndex2] != null) return gridColumns[colIndex2];
58895
59062
  return null;
58896
59063
  };
58897
59064
  const widths = [];
58898
- const row = node.firstChild;
59065
+ const firstRow = node.firstChild;
58899
59066
  let colIndex = 0;
58900
- if (row !== null) {
58901
- for (let i = 0; i < row.childCount; i++) {
58902
- const child = row.child(i);
59067
+ if (firstRow !== null) {
59068
+ for (let i = 0; i < firstRow.childCount; i++) {
59069
+ const child = firstRow.child(i);
58903
59070
  const { colspan, colwidth } = child.attrs;
58904
59071
  for (let span = 0; span < colspan; span += 1, colIndex += 1) {
58905
59072
  widths.push(resolveColumnWidth(colIndex, colwidth && colwidth[span]));
@@ -58919,49 +59086,41 @@ function updateColumns(node, colgroup, table, cellMinWidth2, overrideCol, overri
58919
59086
  if (numericWidth < 1) return 0;
58920
59087
  return numericWidth;
58921
59088
  });
58922
- const rawTotalWidth = normalizedWidths.reduce((sum, width) => sum + (width != null ? width : cellMinWidth2), 0);
58923
- let scale = 1;
58924
- if (availableWidth && rawTotalWidth > 0 && rawTotalWidth > availableWidth) {
58925
- scale = availableWidth / rawTotalWidth;
58926
- }
58927
- let totalWidth = 0;
58928
- let hasUndefinedWidth = false;
58929
- 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;
58930
59095
  normalizedWidths.forEach((width) => {
58931
- let scaledWidth = width;
58932
- if (scaledWidth != null) {
58933
- scaledWidth = scaledWidth * scale;
58934
- }
58935
- const [propKey, propVal] = getColStyleDeclaration(cellMinWidth2, scaledWidth);
58936
- if (scaledWidth == null) {
58937
- totalWidth += cellMinWidth2;
58938
- hasUndefinedWidth = true;
58939
- } else {
58940
- totalWidth += scaledWidth;
58941
- }
58942
- if (!dom) {
58943
- const colElement = document.createElement("col");
58944
- colElement.style.setProperty(propKey, propVal);
59096
+ if (!colElement) {
59097
+ colElement = document.createElement("col");
58945
59098
  colgroup.appendChild(colElement);
58946
- } else {
58947
- dom.style.setProperty(propKey, propVal);
58948
- dom = dom.nextSibling;
58949
59099
  }
59100
+ colElement.style.width = width !== null && width !== void 0 ? `${width}px` : null;
59101
+ colElement = colElement.nextSibling;
58950
59102
  });
58951
- while (dom) {
58952
- const next = dom.nextSibling;
58953
- dom.parentNode?.removeChild(dom);
58954
- dom = next;
58955
- }
58956
- if (scale < 1 || !hasUndefinedWidth) {
58957
- const clampedWidth = Math.min(totalWidth, availableWidth || totalWidth);
58958
- table.style.width = `${clampedWidth}px`;
58959
- table.style.minWidth = "";
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)`;
58960
59121
  } else {
58961
- table.style.width = "";
58962
- table.style.minWidth = `${totalWidth}px`;
59122
+ table.style.maxWidth = table.style.width = tableWidthCSS;
58963
59123
  }
58964
- table.style.maxWidth = "100%";
58965
59124
  }
58966
59125
  function updateTable(editor, node, table) {
58967
59126
  const allExtensionsAttrs = editor.extensionService.attributes;
@@ -59039,6 +59198,15 @@ const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent =
59039
59198
  const tableBorders = createTableBorders();
59040
59199
  return types2.table.createChecked({ borders: tableBorders }, rows);
59041
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
+ };
59042
59210
  const MIN_MEANINGFUL_WIDTH_PX = 1;
59043
59211
  const createColGroup = (node, cellMinWidth2, overrideCol, overrideValue) => {
59044
59212
  let totalWidth = 0;
@@ -61405,15 +61573,6 @@ const Table = Node$1.create({
61405
61573
  },
61406
61574
  addAttributes() {
61407
61575
  return {
61408
- /* tableWidth: {
61409
- renderDOM: ({ tableWidth }) => {
61410
- if (!tableWidth) return {};
61411
- const { width, type = 'auto' } = tableWidth;
61412
- return {
61413
- style: `width: ${width}px`
61414
- };
61415
- },
61416
- }, */
61417
61576
  /**
61418
61577
  * @private
61419
61578
  * @category Attribute
@@ -61517,7 +61676,12 @@ const Table = Node$1.create({
61517
61676
  * @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 371-483
61518
61677
  */
61519
61678
  tableProperties: {
61520
- default: null,
61679
+ default: {
61680
+ tableWidth: {
61681
+ value: null,
61682
+ type: "auto"
61683
+ }
61684
+ },
61521
61685
  rendered: false
61522
61686
  },
61523
61687
  /**
@@ -62285,12 +62449,14 @@ const TableCell = Node$1.create({
62285
62449
  }
62286
62450
  },
62287
62451
  cellMargins: {
62288
- renderDOM({ cellMargins }) {
62452
+ renderDOM({ cellMargins, borders }) {
62289
62453
  if (!cellMargins) return {};
62290
62454
  const sides2 = ["top", "right", "bottom", "left"];
62291
62455
  const style2 = sides2.map((side) => {
62292
- const margin = cellMargins?.[side];
62293
- if (margin) return `padding-${side}: ${margin}px;`;
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;`;
62294
62460
  return "";
62295
62461
  }).join(" ");
62296
62462
  return { style: style2 };
@@ -91512,7 +91678,7 @@ const _sfc_main$1 = {
91512
91678
  };
91513
91679
  }
91514
91680
  };
91515
- const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-cd3558fe"]]);
91681
+ const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-4615ea7d"]]);
91516
91682
  const _hoisted_1 = ["innerHTML"];
91517
91683
  const _sfc_main = {
91518
91684
  __name: "SuperInput",