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
@@ -15427,6 +15427,38 @@
15427
15427
  if (element2.className?.split(" ")?.indexOf(classname) >= 0) return true;
15428
15428
  return element2.parentNode && hasSomeParentWithClass(element2.parentNode, classname);
15429
15429
  };
15430
+ function convertSizeToCSS(value, type2) {
15431
+ if (typeof value === "string" && value.endsWith("%")) {
15432
+ type2 = "pct";
15433
+ }
15434
+ if (value === null || value === void 0) {
15435
+ value = 0;
15436
+ }
15437
+ switch (type2) {
15438
+ case "dxa":
15439
+ case null:
15440
+ case void 0:
15441
+ return `${twipsToPixels(value)}px`;
15442
+ case "nil":
15443
+ return "0";
15444
+ case "auto":
15445
+ return null;
15446
+ case "pct":
15447
+ let percent2;
15448
+ if (typeof value === "number") {
15449
+ percent2 = value * 0.02;
15450
+ } else {
15451
+ if (value.endsWith("%")) {
15452
+ percent2 = parseFloat(value.slice(0, -1));
15453
+ } else {
15454
+ percent2 = parseFloat(value) * 0.02;
15455
+ }
15456
+ }
15457
+ return `${percent2}%`;
15458
+ default:
15459
+ return null;
15460
+ }
15461
+ }
15430
15462
  const DEFAULT_DOCX_DEFS = {
15431
15463
  "xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
15432
15464
  "xmlns:cx": "http://schemas.microsoft.com/office/drawing/2014/chartex",
@@ -19239,7 +19271,7 @@
19239
19271
  const finalProps = combineProperties(styleChain, ["fontFamily", "color"]);
19240
19272
  return finalProps;
19241
19273
  };
19242
- function resolveParagraphProperties(params2, inlineProps, insideTable = false, overrideInlineStyleId = false) {
19274
+ function resolveParagraphProperties(params2, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) {
19243
19275
  const defaultProps2 = getDefaultProperties(params2, translator$12);
19244
19276
  const { properties: normalProps, isDefault: isNormalDefault } = getStyleProperties(params2, "Normal", translator$12);
19245
19277
  let styleId = inlineProps?.styleId;
@@ -19264,13 +19296,14 @@
19264
19296
  }
19265
19297
  }
19266
19298
  }
19299
+ const tableProps = tableStyleId ? resolveStyleChain(params2, tableStyleId, translator$12) : {};
19267
19300
  let defaultsChain;
19268
19301
  if (isNormalDefault) {
19269
19302
  defaultsChain = [defaultProps2, normalProps];
19270
19303
  } else {
19271
19304
  defaultsChain = [normalProps, defaultProps2];
19272
19305
  }
19273
- const propsChain = [...defaultsChain, numberingProps, styleProps, inlineProps];
19306
+ const propsChain = [...defaultsChain, tableProps, numberingProps, styleProps, inlineProps];
19274
19307
  let indentChain;
19275
19308
  if (isList2) {
19276
19309
  if (numberingDefinedInline) {
@@ -20021,6 +20054,21 @@
20021
20054
  if (value === "0" || value === "false" || value === "off") return "0";
20022
20055
  return "1";
20023
20056
  }
20057
+ function getTableStyleId(path2) {
20058
+ const tbl = path2.find((ancestor) => ancestor.name === "w:tbl");
20059
+ if (!tbl) {
20060
+ return;
20061
+ }
20062
+ const tblPr = tbl.elements?.find((child) => child.name === "w:tblPr");
20063
+ if (!tblPr) {
20064
+ return;
20065
+ }
20066
+ const tblStyle = tblPr.elements?.find((child) => child.name === "w:tblStyle");
20067
+ if (!tblStyle) {
20068
+ return;
20069
+ }
20070
+ return tblStyle.attributes?.["w:val"];
20071
+ }
20024
20072
  const handleParagraphNode$1 = (params2) => {
20025
20073
  const { nodes, nodeListHandler, filename } = params2;
20026
20074
  const node2 = carbonCopy(nodes[0]);
@@ -20031,7 +20079,14 @@
20031
20079
  inlineParagraphProperties = translator$12.encode({ ...params2, nodes: [pPr] }) || {};
20032
20080
  }
20033
20081
  const insideTable = (params2.path || []).some((ancestor) => ancestor.name === "w:tc");
20034
- const resolvedParagraphProperties = resolveParagraphProperties(params2, inlineParagraphProperties, insideTable);
20082
+ const tableStyleId = getTableStyleId(params2.path || []);
20083
+ const resolvedParagraphProperties = resolveParagraphProperties(
20084
+ params2,
20085
+ inlineParagraphProperties,
20086
+ insideTable,
20087
+ false,
20088
+ tableStyleId
20089
+ );
20035
20090
  const handleStandardNode2 = nodeListHandler.handlerEntities.find(
20036
20091
  (e) => e.handlerName === "standardNodeHandler"
20037
20092
  )?.handler;
@@ -21386,6 +21441,7 @@
21386
21441
  const columnWidth = gridColumnWidths?.[startColumn] || null;
21387
21442
  const result = translator$G.encode({
21388
21443
  ...params2,
21444
+ path: [...params2.path || [], node2],
21389
21445
  extraParams: {
21390
21446
  ...params2.extraParams,
21391
21447
  node: node2,
@@ -31556,14 +31612,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31556
31612
  const grid = Array.isArray(rawGrid) ? rawGrid : [];
31557
31613
  const { firstRow = {} } = params2.extraParams || {};
31558
31614
  const cellNodes = firstRow.content?.filter((n) => n.type === "tableCell") ?? [];
31559
- const columnCountFromCells = cellNodes.reduce((count, cell2) => {
31615
+ const colWidthsFromCellNodes = cellNodes.flatMap((cell2) => {
31560
31616
  const spanCount = Math.max(1, cell2?.attrs?.colspan ?? 1);
31561
- return count + spanCount;
31562
- }, 0);
31617
+ const colwidth = cell2.attrs?.colwidth;
31618
+ return Array.from({ length: spanCount }).map((_2, span) => Array.isArray(colwidth) ? colwidth[span] : void 0);
31619
+ });
31620
+ const columnCountFromCells = colWidthsFromCellNodes.length;
31563
31621
  const totalColumns = Math.max(columnCountFromCells, grid.length);
31564
31622
  const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params2, totalColumns, cellMinWidth);
31565
31623
  const elements = [];
31566
- let columnIndex = 0;
31567
31624
  const pushColumn = (widthTwips, { enforceMinimum = false } = {}) => {
31568
31625
  let numericWidth = typeof widthTwips === "string" ? parseInt(widthTwips, 10) : widthTwips;
31569
31626
  let shouldEnforceMinimum = enforceMinimum;
@@ -31582,39 +31639,29 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31582
31639
  });
31583
31640
  if (decoded) elements.push(decoded);
31584
31641
  };
31585
- cellNodes.forEach((cell2) => {
31586
- const { colspan = 1, colwidth } = cell2?.attrs || {};
31587
- const spanCount = Math.max(1, colspan);
31588
- for (let span = 0; span < spanCount; span++) {
31589
- const rawWidth = Array.isArray(colwidth) ? colwidth[span] : void 0;
31590
- const cellWidthPixels = typeof rawWidth === "number" && Number.isFinite(rawWidth) ? rawWidth : Number(rawWidth);
31591
- const hasCellWidth = Number.isFinite(cellWidthPixels) && cellWidthPixels > 0;
31592
- const colGridAttrs = grid?.[columnIndex] || {};
31593
- const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
31594
- const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
31595
- let cellWidthTwips;
31596
- let enforceMinimum = false;
31597
- if (hasCellWidth) {
31598
- const tolerance = 0.5;
31599
- if (gridWidthTwips != null && gridWidthPixels != null && Math.abs(gridWidthPixels - cellWidthPixels) <= tolerance) {
31600
- cellWidthTwips = gridWidthTwips;
31601
- } else {
31602
- cellWidthTwips = pixelsToTwips(cellWidthPixels);
31603
- }
31604
- } else if (gridWidthTwips != null) {
31642
+ for (let columnIndex = 0; columnIndex < totalColumns; ++columnIndex) {
31643
+ const rawWidth = colWidthsFromCellNodes[columnIndex];
31644
+ const cellWidthPixels = typeof rawWidth === "number" && Number.isFinite(rawWidth) ? rawWidth : Number(rawWidth);
31645
+ const hasCellWidth = Number.isFinite(cellWidthPixels) && cellWidthPixels > 0;
31646
+ const colGridAttrs = grid?.[columnIndex] || {};
31647
+ const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
31648
+ const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
31649
+ let cellWidthTwips;
31650
+ let enforceMinimum = false;
31651
+ if (gridWidthTwips != null) {
31652
+ cellWidthTwips = gridWidthTwips;
31653
+ } else if (hasCellWidth) {
31654
+ const tolerance = 0.5;
31655
+ if (gridWidthTwips != null && gridWidthPixels != null && Math.abs(gridWidthPixels - cellWidthPixels) <= tolerance) {
31605
31656
  cellWidthTwips = gridWidthTwips;
31606
31657
  } else {
31607
- cellWidthTwips = fallbackColumnWidthTwips;
31608
- enforceMinimum = true;
31658
+ cellWidthTwips = pixelsToTwips(cellWidthPixels);
31609
31659
  }
31610
- pushColumn(cellWidthTwips, { enforceMinimum });
31611
- columnIndex++;
31660
+ } else {
31661
+ cellWidthTwips = fallbackColumnWidthTwips;
31662
+ enforceMinimum = true;
31612
31663
  }
31613
- });
31614
- while (columnIndex < grid.length) {
31615
- const gridWidthTwips = normalizeTwipWidth(grid[columnIndex]?.col);
31616
- pushColumn(gridWidthTwips);
31617
- columnIndex++;
31664
+ pushColumn(cellWidthTwips, { enforceMinimum });
31618
31665
  }
31619
31666
  const newNode = {
31620
31667
  name: XML_NODE_NAME$b,
@@ -31701,6 +31748,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31701
31748
  if (tblPr) {
31702
31749
  const encodedProperties = translator$c.encode({ ...params2, nodes: [tblPr] });
31703
31750
  encodedAttrs["tableProperties"] = encodedProperties || {};
31751
+ } else {
31752
+ encodedAttrs["tableProperties"] || (encodedAttrs["tableProperties"] = {});
31704
31753
  }
31705
31754
  const tblGrid = node2.elements.find((el) => el.name === "w:tblGrid");
31706
31755
  if (tblGrid) {
@@ -31721,14 +31770,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31721
31770
  key2 = prop;
31722
31771
  transform = (v2) => v2;
31723
31772
  }
31724
- if (encodedAttrs.tableProperties && encodedAttrs.tableProperties[key2]) {
31773
+ if (encodedAttrs.tableProperties[key2]) {
31725
31774
  encodedAttrs[key2] = transform(encodedAttrs.tableProperties[key2]);
31726
31775
  }
31727
31776
  });
31728
31777
  if (encodedAttrs.tableCellSpacing) {
31729
31778
  encodedAttrs["borderCollapse"] = "separate";
31730
31779
  }
31731
- if (encodedAttrs.tableProperties?.tableWidth) {
31780
+ if (encodedAttrs.tableProperties.tableWidth) {
31732
31781
  const tableWidthMeasurement = encodedAttrs.tableProperties.tableWidth;
31733
31782
  const widthPx = twipsToPixels(tableWidthMeasurement.value);
31734
31783
  if (widthPx != null) {
@@ -31743,25 +31792,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31743
31792
  };
31744
31793
  }
31745
31794
  }
31746
- const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
31747
- const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2);
31748
- if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
31749
- encodedAttrs.tableProperties = {
31750
- ...encodedAttrs.tableProperties || {},
31751
- cellMargins: referencedStyles.cellMargins
31752
- };
31753
- }
31795
+ const borderProps = _processTableBorders(encodedAttrs.tableProperties.borders || {});
31796
+ const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2) || {};
31797
+ const rowBorders = { ...referencedStyles.rowBorders, ...borderProps.rowBorders };
31798
+ encodedAttrs.borders = { ...referencedStyles.borders, ...borderProps.borders };
31799
+ encodedAttrs.tableProperties.cellMargins = referencedStyles.cellMargins = {
31800
+ ...referencedStyles.cellMargins,
31801
+ ...encodedAttrs.tableProperties.cellMargins
31802
+ };
31754
31803
  const rows = node2.elements.filter((el) => el.name === "w:tr");
31755
- const borderData = Object.assign({}, referencedStyles?.borders || {}, borders || {});
31756
- const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
31757
- encodedAttrs["borders"] = borderData;
31758
31804
  let columnWidths = Array.isArray(encodedAttrs["grid"]) ? encodedAttrs["grid"].map((item) => twipsToPixels(item.col)) : [];
31759
31805
  if (!columnWidths.length) {
31760
31806
  const fallback = buildFallbackGridForTable({
31761
31807
  params: params2,
31762
31808
  rows,
31763
31809
  tableWidth: encodedAttrs.tableWidth,
31764
- tableWidthMeasurement: encodedAttrs.tableProperties?.tableWidth
31810
+ tableWidthMeasurement: encodedAttrs.tableProperties.tableWidth
31765
31811
  });
31766
31812
  if (fallback) {
31767
31813
  encodedAttrs.grid = fallback.grid;
@@ -31774,11 +31820,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31774
31820
  rows.forEach((row2, rowIndex) => {
31775
31821
  const result = translator$v.encode({
31776
31822
  ...params2,
31823
+ path: [...params2.path || [], node2],
31777
31824
  nodes: [row2],
31778
31825
  extraParams: {
31779
31826
  row: row2,
31780
31827
  table: node2,
31781
- rowBorders: borderRowData,
31828
+ rowBorders,
31782
31829
  columnWidths,
31783
31830
  activeRowSpans: activeRowSpans.slice(),
31784
31831
  rowIndex,
@@ -35303,7 +35350,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35303
35350
  static getStoredSuperdocVersion(docx) {
35304
35351
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
35305
35352
  }
35306
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.31.0-next.6") {
35353
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.31.0-next.7") {
35307
35354
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
35308
35355
  }
35309
35356
  /**
@@ -60304,7 +60351,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
60304
60351
  { default: remarkStringify2 },
60305
60352
  { default: remarkGfm2 }
60306
60353
  ] = await Promise.all([
60307
- Promise.resolve().then(() => indexDAES86tg),
60354
+ Promise.resolve().then(() => indexBJ6cOegF),
60308
60355
  Promise.resolve().then(() => indexDRCvimau),
60309
60356
  Promise.resolve().then(() => indexC_x_N6Uh),
60310
60357
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -60505,7 +60552,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
60505
60552
  * Process collaboration migrations
60506
60553
  */
60507
60554
  processCollaborationMigrations() {
60508
- console.debug("[checkVersionMigrations] Current editor version", "0.31.0-next.6");
60555
+ console.debug("[checkVersionMigrations] Current editor version", "0.31.0-next.7");
60509
60556
  if (!this.options.ydoc) return;
60510
60557
  const metaMap = this.options.ydoc.getMap("meta");
60511
60558
  let docVersion = metaMap.get("version");
@@ -62914,6 +62961,46 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62914
62961
  });
62915
62962
  return result;
62916
62963
  }
62964
+ function createTagObject(tagData) {
62965
+ if (!tagData || typeof tagData !== "object") {
62966
+ return null;
62967
+ }
62968
+ return JSON.stringify(tagData);
62969
+ }
62970
+ function parseTagObject(tag) {
62971
+ if (typeof tag !== "string" || !tag.startsWith("{")) {
62972
+ return null;
62973
+ }
62974
+ try {
62975
+ const parsed = JSON.parse(tag);
62976
+ return parsed && typeof parsed === "object" ? parsed : null;
62977
+ } catch {
62978
+ return null;
62979
+ }
62980
+ }
62981
+ function hasGroup(tag) {
62982
+ const parsed = parseTagObject(tag);
62983
+ return parsed !== null && typeof parsed.group === "string";
62984
+ }
62985
+ function getGroup(tag) {
62986
+ const parsed = parseTagObject(tag);
62987
+ return parsed && typeof parsed.group === "string" ? parsed.group : null;
62988
+ }
62989
+ function getStructuredContentByGroup(groupOrGroups, state2) {
62990
+ const searchGroups = Array.isArray(groupOrGroups) ? groupOrGroups : [groupOrGroups];
62991
+ const result = findChildren$5(state2.doc, (node2) => {
62992
+ const isStructuredContent = ["structuredContent", "structuredContentBlock"].includes(node2.type.name);
62993
+ if (!isStructuredContent) {
62994
+ return false;
62995
+ }
62996
+ const nodeGroup = getGroup(node2.attrs.tag);
62997
+ if (!nodeGroup) {
62998
+ return false;
62999
+ }
63000
+ return searchGroups.includes(nodeGroup);
63001
+ });
63002
+ return result;
63003
+ }
62917
63004
  function getStructuredContentTags(state2) {
62918
63005
  const result = findChildren$5(state2.doc, (node2) => {
62919
63006
  return node2.type.name === "structuredContent" || node2.type.name === "structuredContentBlock";
@@ -62946,11 +63033,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62946
63033
  }
62947
63034
  const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
62948
63035
  __proto__: null,
63036
+ createTagObject,
63037
+ getGroup,
62949
63038
  getStructuredContentBlockTags,
63039
+ getStructuredContentByGroup,
62950
63040
  getStructuredContentInlineTags,
62951
63041
  getStructuredContentTablesById,
62952
63042
  getStructuredContentTags,
62953
- getStructuredContentTagsById
63043
+ getStructuredContentTagsById,
63044
+ hasGroup,
63045
+ parseTagObject
62954
63046
  }, Symbol.toStringTag, { value: "Module" }));
62955
63047
  const STRUCTURED_CONTENT_NAMES = ["structuredContent", "structuredContentBlock"];
62956
63048
  const StructuredContentCommands = Extension.create({
@@ -62962,6 +63054,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62962
63054
  * @category Command
62963
63055
  * @param {StructuredContentInlineInsert} options
62964
63056
  * @example
63057
+ * // With group for linking multiple fields
63058
+ * editor.commands.insertStructuredContentInline({
63059
+ * attrs: {
63060
+ * group: 'customer-info',
63061
+ * alias: 'Customer Name',
63062
+ * },
63063
+ * text: 'John Doe',
63064
+ * });
63065
+ *
63066
+ * // No group
62965
63067
  * editor.commands.insertStructuredContentInline({
62966
63068
  * attrs: {
62967
63069
  * id: '123',
@@ -62990,12 +63092,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62990
63092
  if (!content2) {
62991
63093
  content2 = schema.text(" ");
62992
63094
  }
63095
+ let tag = options.attrs?.tag || "inline_text_sdt";
63096
+ if (options.attrs?.group) {
63097
+ tag = createTagObject({ group: options.attrs.group });
63098
+ }
62993
63099
  const attrs = {
62994
- ...options.attrs,
62995
63100
  id: options.attrs?.id || generateRandomSigned32BitIntStrId(),
62996
- tag: "inline_text_sdt",
62997
- alias: options.attrs?.alias || "Structured content"
63101
+ tag,
63102
+ alias: options.attrs?.alias || "Structured content",
63103
+ ...options.attrs
62998
63104
  };
63105
+ delete attrs.group;
62999
63106
  const node2 = schema.nodes.structuredContent.create(attrs, content2, null);
63000
63107
  const parent = findParentNode((node22) => node22.type.name === "structuredContent")(state2.selection);
63001
63108
  if (parent) {
@@ -63011,14 +63118,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63011
63118
  * @category Command
63012
63119
  * @param {StructuredContentBlockInsert} options
63013
63120
  * @example
63121
+ * // With group for linking multiple fields
63122
+ * editor.commands.insertStructuredContentBlock({
63123
+ * attrs: {
63124
+ * group: 'terms-section',
63125
+ * alias: 'Terms & Conditions',
63126
+ * },
63127
+ * html: '<p>Legal content...</p>',
63128
+ * });
63129
+ *
63130
+ * // No group
63014
63131
  * editor.commands.insertStructuredContentBlock({
63015
63132
  * attrs: {
63016
63133
  * id: '456',
63017
63134
  * alias: 'Terms & Conditions',
63018
63135
  * },
63019
63136
  * json: { type: 'paragraph', content: [{ type: 'text', text: 'Legal content...' }] }
63020
- * // or
63021
- * html: '<p>Legal content...</p>',
63022
63137
  * });
63023
63138
  */
63024
63139
  insertStructuredContentBlock: (options = {}) => ({ editor, dispatch, state: state2, tr }) => {
@@ -63041,12 +63156,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63041
63156
  if (!content2) {
63042
63157
  content2 = schema.nodeFromJSON({ type: "paragraph", content: [] });
63043
63158
  }
63159
+ let tag = options.attrs?.tag || "block_table_sdt";
63160
+ if (options.attrs?.group) {
63161
+ tag = createTagObject({ group: options.attrs.group });
63162
+ }
63044
63163
  const attrs = {
63045
- ...options.attrs,
63046
63164
  id: options.attrs?.id || generateRandomSigned32BitIntStrId(),
63047
- tag: "block_table_sdt",
63048
- alias: options.attrs?.alias || "Structured content"
63165
+ tag,
63166
+ alias: options.attrs?.alias || "Structured content",
63167
+ ...options.attrs
63049
63168
  };
63169
+ delete attrs.group;
63050
63170
  const node2 = schema.nodes.structuredContentBlock.create(attrs, content2, null);
63051
63171
  const parent = findParentNode((node22) => node22.type.name === "structuredContentBlock")(state2.selection);
63052
63172
  if (parent) {
@@ -63176,6 +63296,85 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63176
63296
  }
63177
63297
  return true;
63178
63298
  },
63299
+ /**
63300
+ * Updates all structured content fields that share the same group identifier.
63301
+ * Groups allow linking multiple fields together for batch operations.
63302
+ * @category Command
63303
+ * @param {string} group - Group identifier shared by multiple fields
63304
+ * @param {StructuredContentUpdate} options
63305
+ * @example
63306
+ * // Update all fields in the customer-info group
63307
+ * editor.commands.updateStructuredContentByGroup('customer-info', { text: 'Jane Doe' });
63308
+ *
63309
+ * // Update block content in a group
63310
+ * editor.commands.updateStructuredContentByGroup('terms-section', {
63311
+ * html: '<p>Updated terms...</p>'
63312
+ * });
63313
+ */
63314
+ updateStructuredContentByGroup: (group, options = {}) => ({ editor, dispatch, state: state2, tr }) => {
63315
+ const structuredContentTags = getStructuredContentByGroup(group, state2);
63316
+ if (!structuredContentTags.length) {
63317
+ return true;
63318
+ }
63319
+ const { schema } = editor;
63320
+ if (dispatch) {
63321
+ structuredContentTags.forEach((structuredContent) => {
63322
+ const { pos, node: node2 } = structuredContent;
63323
+ const posFrom = tr.mapping.map(pos);
63324
+ const posTo = tr.mapping.map(pos + node2.nodeSize);
63325
+ let content2 = null;
63326
+ if (options.text) {
63327
+ content2 = schema.text(options.text);
63328
+ }
63329
+ if (options.html) {
63330
+ const html2 = htmlHandler(options.html, editor);
63331
+ const doc2 = DOMParser$1.fromSchema(schema).parse(html2);
63332
+ content2 = doc2.content;
63333
+ }
63334
+ if (options.json) {
63335
+ content2 = schema.nodeFromJSON(options.json);
63336
+ }
63337
+ if (!content2) {
63338
+ content2 = node2.content;
63339
+ }
63340
+ const updatedNode = node2.type.create({ ...node2.attrs, ...options.attrs }, content2, node2.marks);
63341
+ const currentNode = tr.doc.nodeAt(posFrom);
63342
+ if (currentNode && node2.eq(currentNode)) {
63343
+ tr.replaceWith(posFrom, posTo, updatedNode);
63344
+ }
63345
+ });
63346
+ }
63347
+ return true;
63348
+ },
63349
+ /**
63350
+ * Removes all structured content fields that share the same group identifier.
63351
+ * @category Command
63352
+ * @param {string | string[]} groupOrGroups - Single group or array of groups
63353
+ * @example
63354
+ * // Delete all fields in a group
63355
+ * editor.commands.deleteStructuredContentByGroup('customer-info');
63356
+ *
63357
+ * // Delete multiple groups
63358
+ * editor.commands.deleteStructuredContentByGroup(['header', 'footer']);
63359
+ */
63360
+ deleteStructuredContentByGroup: (groupOrGroups) => ({ dispatch, state: state2, tr }) => {
63361
+ const structuredContentTags = getStructuredContentByGroup(groupOrGroups, state2);
63362
+ if (!structuredContentTags.length) {
63363
+ return true;
63364
+ }
63365
+ if (dispatch) {
63366
+ structuredContentTags.forEach((structuredContent) => {
63367
+ const { pos, node: node2 } = structuredContent;
63368
+ const posFrom = tr.mapping.map(pos);
63369
+ const posTo = tr.mapping.map(pos + node2.nodeSize);
63370
+ const currentNode = tr.doc.nodeAt(posFrom);
63371
+ if (currentNode && node2.eq(currentNode)) {
63372
+ tr.delete(posFrom, posTo);
63373
+ }
63374
+ });
63375
+ }
63376
+ return true;
63377
+ },
63179
63378
  /**
63180
63379
  * Append multiple rows to the end of a table inside a structured content block.
63181
63380
  * Each inner array represents the cell values for one new row.
@@ -66570,15 +66769,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66570
66769
  };
66571
66770
  }
66572
66771
  });
66573
- const getColStyleDeclaration = (minWidth, width) => {
66574
- if (width != null) {
66575
- const numericWidth = Number(width);
66576
- if (Number.isFinite(numericWidth) && numericWidth >= 0) {
66577
- return ["width", `${numericWidth}px`];
66578
- }
66579
- }
66580
- return ["min-width", `${minWidth}px`];
66581
- };
66582
66772
  const createTableView = ({ editor }) => {
66583
66773
  return class TableView {
66584
66774
  constructor(node2, cellMinWidth2) {
@@ -66597,7 +66787,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66597
66787
  this.table = this.dom.appendChild(document.createElement("table"));
66598
66788
  this.colgroup = this.table.appendChild(document.createElement("colgroup"));
66599
66789
  updateTable(this.editor, this.node, this.table);
66600
- updateColumns(node2, this.colgroup, this.table, cellMinWidth2, void 0, void 0, this.editor);
66790
+ updateColumns(node2, this.colgroup, this.table);
66601
66791
  this.contentDOM = this.table.appendChild(document.createElement("tbody"));
66602
66792
  setTimeout(() => {
66603
66793
  updateTableWrapper(this.dom, this.table);
@@ -66609,7 +66799,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66609
66799
  }
66610
66800
  this.node = node2;
66611
66801
  updateTable(this.editor, node2, this.table);
66612
- updateColumns(node2, this.colgroup, this.table, this.cellMinWidth, void 0, void 0, this.editor);
66802
+ updateColumns(node2, this.colgroup, this.table, this.cellMinWidth);
66613
66803
  updateTableWrapper(this.dom, this.table);
66614
66804
  return true;
66615
66805
  }
@@ -66622,43 +66812,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66622
66812
  }
66623
66813
  };
66624
66814
  };
66625
- function updateColumns(node2, colgroup, table2, cellMinWidth2, overrideCol, overrideValue, editor) {
66815
+ function updateColumns(node2, colgroup, table2, cellMinWidth2) {
66626
66816
  const gridColumns = Array.isArray(node2.attrs?.grid) && node2.attrs.grid.length ? node2.attrs.grid.map((col) => twipsToPixels(col.col)) : null;
66627
66817
  const totalColumns = gridColumns?.length ?? null;
66628
- const pageBody = table2.closest(".page__body");
66629
- const wrapper = table2.parentElement;
66630
- let availableWidth = pageBody?.getBoundingClientRect?.().width;
66631
- if (!availableWidth && wrapper) {
66632
- availableWidth = wrapper.getBoundingClientRect().width;
66633
- }
66634
- if (typeof availableWidth === "number" && !Number.isNaN(availableWidth)) {
66635
- availableWidth = Math.max(availableWidth - 2, 0);
66636
- } else {
66637
- availableWidth = null;
66638
- }
66639
- const pageStyles = editor?.converter?.pageStyles;
66640
- if (pageStyles?.pageSize?.width) {
66641
- const toNumber2 = (v2) => typeof v2 === "number" ? v2 : parseFloat(v2) || 0;
66642
- const pageWidth = toNumber2(pageStyles.pageSize.width);
66643
- const marginLeft = toNumber2(pageStyles.pageMargins?.left);
66644
- const marginRight = toNumber2(pageStyles.pageMargins?.right);
66645
- const pageAvailableWidthPx = Math.max((pageWidth - marginLeft - marginRight) * PIXELS_PER_INCH, 0);
66646
- if (pageAvailableWidthPx > 0) {
66647
- availableWidth = availableWidth ? Math.min(availableWidth, pageAvailableWidthPx) : pageAvailableWidthPx;
66648
- }
66649
- }
66650
66818
  const resolveColumnWidth = (colIndex2, colwidthValue) => {
66651
- if (overrideCol === colIndex2) return overrideValue;
66652
66819
  if (colwidthValue != null) return colwidthValue;
66653
66820
  if (gridColumns && gridColumns[colIndex2] != null) return gridColumns[colIndex2];
66654
66821
  return null;
66655
66822
  };
66656
66823
  const widths = [];
66657
- const row2 = node2.firstChild;
66824
+ const firstRow = node2.firstChild;
66658
66825
  let colIndex = 0;
66659
- if (row2 !== null) {
66660
- for (let i2 = 0; i2 < row2.childCount; i2++) {
66661
- const child = row2.child(i2);
66826
+ if (firstRow !== null) {
66827
+ for (let i2 = 0; i2 < firstRow.childCount; i2++) {
66828
+ const child = firstRow.child(i2);
66662
66829
  const { colspan, colwidth } = child.attrs;
66663
66830
  for (let span = 0; span < colspan; span += 1, colIndex += 1) {
66664
66831
  widths.push(resolveColumnWidth(colIndex, colwidth && colwidth[span]));
@@ -66678,49 +66845,41 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66678
66845
  if (numericWidth < 1) return 0;
66679
66846
  return numericWidth;
66680
66847
  });
66681
- const rawTotalWidth = normalizedWidths.reduce((sum, width) => sum + (width != null ? width : cellMinWidth2), 0);
66682
- let scale = 1;
66683
- if (availableWidth && rawTotalWidth > 0 && rawTotalWidth > availableWidth) {
66684
- scale = availableWidth / rawTotalWidth;
66685
- }
66686
- let totalWidth = 0;
66687
- let hasUndefinedWidth = false;
66688
- let dom = colgroup.firstChild;
66848
+ const tableWidthCSS = convertSizeToCSS(
66849
+ // TODO: why is tableWidth undefined in src/tests/import-export/font-default-styles.test.js?
66850
+ node2.attrs.tableProperties.tableWidth?.value ?? null,
66851
+ node2.attrs.tableProperties.tableWidth?.type ?? "auto"
66852
+ );
66853
+ let colElement = colgroup.firstChild;
66689
66854
  normalizedWidths.forEach((width) => {
66690
- let scaledWidth = width;
66691
- if (scaledWidth != null) {
66692
- scaledWidth = scaledWidth * scale;
66693
- }
66694
- const [propKey, propVal] = getColStyleDeclaration(cellMinWidth2, scaledWidth);
66695
- if (scaledWidth == null) {
66696
- totalWidth += cellMinWidth2;
66697
- hasUndefinedWidth = true;
66698
- } else {
66699
- totalWidth += scaledWidth;
66700
- }
66701
- if (!dom) {
66702
- const colElement = document.createElement("col");
66703
- colElement.style.setProperty(propKey, propVal);
66855
+ if (!colElement) {
66856
+ colElement = document.createElement("col");
66704
66857
  colgroup.appendChild(colElement);
66705
- } else {
66706
- dom.style.setProperty(propKey, propVal);
66707
- dom = dom.nextSibling;
66708
66858
  }
66859
+ colElement.style.width = width !== null && width !== void 0 ? `${width}px` : null;
66860
+ colElement = colElement.nextSibling;
66709
66861
  });
66710
- while (dom) {
66711
- const next2 = dom.nextSibling;
66712
- dom.parentNode?.removeChild(dom);
66713
- dom = next2;
66862
+ while (colElement) {
66863
+ const next2 = colElement.nextSibling;
66864
+ colElement.parentNode?.removeChild(colElement);
66865
+ colElement = next2;
66714
66866
  }
66715
- if (scale < 1 || !hasUndefinedWidth) {
66716
- const clampedWidth = Math.min(totalWidth, availableWidth || totalWidth);
66717
- table2.style.width = `${clampedWidth}px`;
66718
- table2.style.minWidth = "";
66867
+ const tableIndent = convertSizeToCSS(
66868
+ node2.attrs.tableProperties.tableIndent?.value ?? 0,
66869
+ node2.attrs.tableProperties.tableIndent?.type ?? "dxa"
66870
+ );
66871
+ const firstRowFirstCellPaddingLeftPx = firstRow?.firstChild?.attrs?.cellMargins?.left ?? 0;
66872
+ const firstRowLastCellPaddingRightPx = firstRow?.lastChild?.attrs?.cellMargins?.right ?? 0;
66873
+ table2.style.marginLeft = `${-firstRowFirstCellPaddingLeftPx}px`;
66874
+ if (tableIndent !== null) {
66875
+ table2.style.marginLeft = tableIndent;
66876
+ }
66877
+ if (node2.attrs.tableProperties.tableWidth?.type === "pct") {
66878
+ const padding = firstRowFirstCellPaddingLeftPx + firstRowLastCellPaddingRightPx;
66879
+ table2.style.maxWidth = table2.style.width = `calc(${tableWidthCSS} + ${padding}px)`;
66719
66880
  } else {
66720
- table2.style.width = "";
66721
- table2.style.minWidth = `${totalWidth}px`;
66881
+ table2.style.maxWidth = table2.style.width = tableWidthCSS;
66722
66882
  }
66723
- table2.style.maxWidth = "100%";
66724
66883
  }
66725
66884
  function updateTable(editor, node2, table2) {
66726
66885
  const allExtensionsAttrs = editor.extensionService.attributes;
@@ -66798,6 +66957,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66798
66957
  const tableBorders = createTableBorders();
66799
66958
  return types2.table.createChecked({ borders: tableBorders }, rows);
66800
66959
  };
66960
+ const getColStyleDeclaration = (minWidth, width) => {
66961
+ if (width != null) {
66962
+ const numericWidth = Number(width);
66963
+ if (Number.isFinite(numericWidth) && numericWidth >= 0) {
66964
+ return ["width", `${numericWidth}px`];
66965
+ }
66966
+ }
66967
+ return ["min-width", `${minWidth}px`];
66968
+ };
66801
66969
  const MIN_MEANINGFUL_WIDTH_PX = 1;
66802
66970
  const createColGroup = (node2, cellMinWidth2, overrideCol, overrideValue) => {
66803
66971
  let totalWidth = 0;
@@ -69164,15 +69332,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
69164
69332
  },
69165
69333
  addAttributes() {
69166
69334
  return {
69167
- /* tableWidth: {
69168
- renderDOM: ({ tableWidth }) => {
69169
- if (!tableWidth) return {};
69170
- const { width, type = 'auto' } = tableWidth;
69171
- return {
69172
- style: `width: ${width}px`
69173
- };
69174
- },
69175
- }, */
69176
69335
  /**
69177
69336
  * @private
69178
69337
  * @category Attribute
@@ -69276,7 +69435,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
69276
69435
  * @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 371-483
69277
69436
  */
69278
69437
  tableProperties: {
69279
- default: null,
69438
+ default: {
69439
+ tableWidth: {
69440
+ value: null,
69441
+ type: "auto"
69442
+ }
69443
+ },
69280
69444
  rendered: false
69281
69445
  },
69282
69446
  /**
@@ -70044,12 +70208,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
70044
70208
  }
70045
70209
  },
70046
70210
  cellMargins: {
70047
- renderDOM({ cellMargins }) {
70211
+ renderDOM({ cellMargins, borders }) {
70048
70212
  if (!cellMargins) return {};
70049
70213
  const sides2 = ["top", "right", "bottom", "left"];
70050
70214
  const style2 = sides2.map((side) => {
70051
- const margin = cellMargins?.[side];
70052
- if (margin) return `padding-${side}: ${margin}px;`;
70215
+ const margin = cellMargins?.[side] ?? 0;
70216
+ const border = borders?.[side];
70217
+ const borderSize = border && border.val !== "none" ? Math.ceil(border.size) : 0;
70218
+ if (margin) return `padding-${side}: ${Math.max(0, margin - borderSize)}px;`;
70053
70219
  return "";
70054
70220
  }).join(" ");
70055
70221
  return { style: style2 };
@@ -99244,7 +99410,7 @@ ${style2}
99244
99410
  };
99245
99411
  }
99246
99412
  };
99247
- const SuperEditor = /* @__PURE__ */ _export_sfc$1(_sfc_main$1$1, [["__scopeId", "data-v-cd3558fe"]]);
99413
+ const SuperEditor = /* @__PURE__ */ _export_sfc$1(_sfc_main$1$1, [["__scopeId", "data-v-4615ea7d"]]);
99248
99414
  const _hoisted_1$h = ["innerHTML"];
99249
99415
  const _sfc_main$i = {
99250
99416
  __name: "SuperInput",
@@ -116660,7 +116826,7 @@ ${style2}
116660
116826
  this.config.colors = shuffleArray(this.config.colors);
116661
116827
  this.userColorMap = /* @__PURE__ */ new Map();
116662
116828
  this.colorIndex = 0;
116663
- this.version = "0.31.0-next.6";
116829
+ this.version = "0.31.0-next.7";
116664
116830
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
116665
116831
  this.superdocId = config2.superdocId || v4();
116666
116832
  this.colors = this.config.colors;
@@ -119060,7 +119226,7 @@ ${style2}
119060
119226
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
119061
119227
  );
119062
119228
  }
119063
- const indexDAES86tg = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
119229
+ const indexBJ6cOegF = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
119064
119230
  __proto__: null,
119065
119231
  unified
119066
119232
  }, Symbol.toStringTag, { value: "Module" }));