@superdoc-dev/cli 0.2.0-next.57 → 0.2.0-next.58

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 (2) hide show
  1. package/dist/index.js +101 -299
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -42707,11 +42707,6 @@ function eighthPointsToPixels(eighthPoints) {
42707
42707
  const pixels = points * 1.3333;
42708
42708
  return pixels;
42709
42709
  }
42710
- function pixelsToEightPoints(pixels) {
42711
- if (pixels == null)
42712
- return;
42713
- return Math.round(pixels * 6);
42714
- }
42715
42710
  function twipsToPt(twips) {
42716
42711
  if (twips == null)
42717
42712
  return;
@@ -48401,16 +48396,9 @@ function handleTableCellNode({
48401
48396
  table,
48402
48397
  row,
48403
48398
  tableProperties,
48404
- rowBorders,
48405
- baseTableBorders,
48406
- tableLook,
48407
- rowCnfStyle,
48408
48399
  columnIndex,
48409
48400
  columnWidth = null,
48410
48401
  allColumnWidths = [],
48411
- rowIndex = 0,
48412
- totalRows = 1,
48413
- totalColumns,
48414
48402
  preferTableGridWidths = false,
48415
48403
  _referencedStyles
48416
48404
  }) {
@@ -48420,26 +48408,7 @@ function handleTableCellNode({
48420
48408
  const tcPr = node3.elements.find((el) => el.name === "w:tcPr");
48421
48409
  const tableCellProperties = tcPr ? translator116.encode({ ...params2, nodes: [tcPr] }) ?? {} : {};
48422
48410
  attributes["tableCellProperties"] = tableCellProperties;
48423
- const effectiveTotalColumns = totalColumns ?? (allColumnWidths.length || 1);
48424
- const effectiveTotalRows = totalRows ?? (table?.elements?.filter((el) => el.name === "w:tr").length || 1);
48425
48411
  const colspan = parseInt(tableCellProperties.gridSpan || 1, 10);
48426
- const isFirstRow = rowIndex === 0;
48427
- const isLastRow = rowIndex === effectiveTotalRows - 1;
48428
- const isFirstColumn = columnIndex === 0;
48429
- const isLastColumn = columnIndex + colspan >= effectiveTotalColumns;
48430
- attributes["borders"] = processCellBorders({
48431
- baseTableBorders,
48432
- rowBorders,
48433
- tableLook,
48434
- rowCnfStyle,
48435
- isFirstRow,
48436
- isLastRow,
48437
- isFirstColumn,
48438
- isLastColumn,
48439
- tableCellProperties,
48440
- referencedStyles,
48441
- hasBorderSpacing: !!tableProperties?.tableCellSpacing
48442
- });
48443
48412
  if (colspan > 1)
48444
48413
  attributes["colspan"] = colspan;
48445
48414
  let width = null;
@@ -48615,112 +48584,7 @@ function normalizeTableCellContent(content3, editor) {
48615
48584
  }
48616
48585
  return normalized;
48617
48586
  }
48618
- var processInlineCellBorders = (borders, rowBorders) => {
48619
- if (!borders)
48620
- return null;
48621
- return ["bottom", "top", "left", "right"].reduce((acc, direction) => {
48622
- const borderAttrs = borders[direction];
48623
- const rowBorderAttrs = rowBorders[direction];
48624
- if (borderAttrs && borderAttrs["val"] !== "none") {
48625
- const color2 = borderAttrs["color"];
48626
- let size2 = borderAttrs["size"];
48627
- if (size2)
48628
- size2 = eighthPointsToPixels(size2);
48629
- acc[direction] = { color: color2, size: size2, val: borderAttrs["val"] };
48630
- return acc;
48631
- }
48632
- if (borderAttrs && borderAttrs["val"] === "none") {
48633
- const border = Object.assign({}, rowBorderAttrs || {});
48634
- border["val"] = "none";
48635
- acc[direction] = border;
48636
- return acc;
48637
- }
48638
- return acc;
48639
- }, {});
48640
- }, processCellBorders = ({
48641
- baseTableBorders,
48642
- rowBorders,
48643
- tableLook,
48644
- rowCnfStyle,
48645
- isFirstRow,
48646
- isLastRow,
48647
- isFirstColumn,
48648
- isLastColumn,
48649
- tableCellProperties,
48650
- referencedStyles,
48651
- hasBorderSpacing
48652
- }) => {
48653
- let cellBorders = {};
48654
- if (baseTableBorders) {
48655
- if ((isFirstRow || hasBorderSpacing) && baseTableBorders.top) {
48656
- cellBorders.top = baseTableBorders.top;
48657
- }
48658
- if ((isLastRow || hasBorderSpacing) && baseTableBorders.bottom) {
48659
- cellBorders.bottom = baseTableBorders.bottom;
48660
- }
48661
- if ((isFirstColumn || hasBorderSpacing) && baseTableBorders.left) {
48662
- cellBorders.left = baseTableBorders.left;
48663
- }
48664
- if ((isLastColumn || hasBorderSpacing) && baseTableBorders.right) {
48665
- cellBorders.right = baseTableBorders.right;
48666
- }
48667
- }
48668
- if (rowBorders) {
48669
- if (rowBorders.top?.val) {
48670
- cellBorders.top = rowBorders.top;
48671
- }
48672
- if (rowBorders.bottom?.val) {
48673
- cellBorders.bottom = rowBorders.bottom;
48674
- }
48675
- if (rowBorders.left?.val) {
48676
- const applyLeftToAll = rowBorders.left.val === "none";
48677
- if (applyLeftToAll || isFirstColumn) {
48678
- cellBorders.left = rowBorders.left;
48679
- }
48680
- }
48681
- if (rowBorders.right?.val) {
48682
- const applyRightToAll = rowBorders.right.val === "none";
48683
- if (applyRightToAll || isLastColumn) {
48684
- cellBorders.right = rowBorders.right;
48685
- }
48686
- }
48687
- if (!isLastRow && rowBorders.insideH) {
48688
- cellBorders.bottom = rowBorders.insideH;
48689
- }
48690
- if (!isLastColumn && rowBorders.insideV) {
48691
- cellBorders.right = rowBorders.insideV;
48692
- }
48693
- }
48694
- const getStyleTableCellBorders = (styleVariant) => styleVariant?.tableCellProperties?.borders ?? null;
48695
- const cellCnfStyle = tableCellProperties?.cnfStyle;
48696
- const getFlag = (source, flag) => source && Object.prototype.hasOwnProperty.call(source, flag) ? source[flag] : undefined;
48697
- const isStyleEnabled = (flag) => getFlag(cellCnfStyle, flag) ?? getFlag(rowCnfStyle, flag) ?? getFlag(tableLook, flag) ?? true;
48698
- const applyStyleBorders = (styleVariant, allowedDirections) => {
48699
- const styleBorders = getStyleTableCellBorders(styleVariant);
48700
- if (!styleBorders)
48701
- return;
48702
- const filteredBorders = allowedDirections.reduce((acc, direction) => {
48703
- if (styleBorders[direction])
48704
- acc[direction] = styleBorders[direction];
48705
- return acc;
48706
- }, {});
48707
- const styleOverrides = processInlineCellBorders(filteredBorders, cellBorders);
48708
- if (styleOverrides)
48709
- cellBorders = Object.assign(cellBorders, styleOverrides);
48710
- };
48711
- if (isFirstRow && isStyleEnabled("firstRow"))
48712
- applyStyleBorders(referencedStyles?.firstRow, ["top", "bottom"]);
48713
- if (isLastRow && isStyleEnabled("lastRow"))
48714
- applyStyleBorders(referencedStyles?.lastRow, ["top", "bottom"]);
48715
- if (isFirstColumn && isStyleEnabled("firstColumn"))
48716
- applyStyleBorders(referencedStyles?.firstCol, ["left", "right"]);
48717
- if (isLastColumn && isStyleEnabled("lastColumn"))
48718
- applyStyleBorders(referencedStyles?.lastCol, ["left", "right"]);
48719
- const inlineBorders = processInlineCellBorders(tableCellProperties.borders, cellBorders);
48720
- if (inlineBorders)
48721
- cellBorders = Object.assign(cellBorders, inlineBorders);
48722
- return cellBorders;
48723
- }, getTableCellVMerge = (node3) => {
48587
+ var getTableCellVMerge = (node3) => {
48724
48588
  const tcPr = node3.elements.find((el) => el.name === "w:tcPr");
48725
48589
  const vMerge = tcPr?.elements?.find((el) => el.name === "w:vMerge");
48726
48590
  if (!vMerge)
@@ -48749,6 +48613,38 @@ var init_legacy_handle_table_cell_node = __esm(() => {
48749
48613
  init_tcPr();
48750
48614
  });
48751
48615
 
48616
+ // ../../packages/super-editor/src/extensions/table-cell/helpers/legacyBorderMigration.js
48617
+ function isLegacySchemaDefaultBorders(borders) {
48618
+ if (!borders || typeof borders !== "object")
48619
+ return false;
48620
+ return SIDES.every((side) => {
48621
+ const b = borders[side];
48622
+ if (!b || typeof b !== "object")
48623
+ return false;
48624
+ return !("val" in b) && b.size === 0.66665 && b.color === "#000000";
48625
+ });
48626
+ }
48627
+ function convertBordersToOoxmlFormat(borders) {
48628
+ const result = {};
48629
+ for (const side of SIDES) {
48630
+ const b = borders[side];
48631
+ if (!b || typeof b !== "object")
48632
+ continue;
48633
+ result[side] = {
48634
+ val: b.val || "single",
48635
+ size: typeof b.size === "number" ? pxToEighthPoints(b.size) : 4,
48636
+ space: b.space || 0,
48637
+ color: b.color === "#000000" ? "auto" : b.color || "auto"
48638
+ };
48639
+ }
48640
+ return result;
48641
+ }
48642
+ var PX_PER_PT, pxToEighthPoints = (px) => Math.round(px / PX_PER_PT * 8), SIDES;
48643
+ var init_legacyBorderMigration = __esm(() => {
48644
+ PX_PER_PT = 96 / 72;
48645
+ SIDES = ["top", "right", "bottom", "left"];
48646
+ });
48647
+
48752
48648
  // ../../packages/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/translate-table-cell.js
48753
48649
  function translateTableCell(params2) {
48754
48650
  const elements = translateChildNodes({
@@ -48763,7 +48659,7 @@ function translateTableCell(params2) {
48763
48659
  };
48764
48660
  }
48765
48661
  function generateTableCellProperties(node3) {
48766
- const tableCellProperties = { ...node3.attrs?.tableCellProperties || {} };
48662
+ let tableCellProperties = { ...node3.attrs?.tableCellProperties || {} };
48767
48663
  const { attrs } = node3;
48768
48664
  const { colwidth: rawColwidth, widthUnit = "px" } = attrs;
48769
48665
  const resolvedWidthType = attrs.cellWidthType ?? (attrs.widthType !== "auto" ? attrs.widthType : undefined) ?? tableCellProperties.cellWidth?.type ?? "dxa";
@@ -48820,32 +48716,13 @@ function generateTableCellProperties(node3) {
48820
48716
  } else {
48821
48717
  delete tableCellProperties.vMerge;
48822
48718
  }
48823
- const { borders = {} } = attrs;
48824
- if (!!borders && Object.keys(borders).length) {
48825
- ["top", "bottom", "left", "right"].forEach((side) => {
48826
- if (borders[side]) {
48827
- let currentPropertyValue = tableCellProperties.borders?.[side];
48828
- let currentPropertySizePixels = eighthPointsToPixels(currentPropertyValue?.size);
48829
- let color2 = borders[side].color;
48830
- if (borders[side].color && color2 === "#000000") {
48831
- color2 = "auto";
48832
- }
48833
- if (currentPropertySizePixels !== borders[side].size || currentPropertyValue?.color !== color2 || borders[side].val !== currentPropertyValue?.val) {
48834
- if (!tableCellProperties.borders)
48835
- tableCellProperties["borders"] = {};
48836
- tableCellProperties.borders[side] = {
48837
- size: pixelsToEightPoints(borders[side].size || 0),
48838
- color: color2,
48839
- space: borders[side].space || 0,
48840
- val: borders[side].val || "single"
48841
- };
48842
- }
48843
- } else if (tableCellProperties.borders?.[side]) {
48844
- delete tableCellProperties.borders[side];
48845
- }
48846
- });
48847
- } else if (tableCellProperties?.borders) {
48848
- delete tableCellProperties.borders;
48719
+ if (!tableCellProperties?.borders && attrs.borders != null) {
48720
+ if (!isLegacySchemaDefaultBorders(attrs.borders)) {
48721
+ tableCellProperties = {
48722
+ ...tableCellProperties ?? {},
48723
+ borders: convertBordersToOoxmlFormat(attrs.borders)
48724
+ };
48725
+ }
48849
48726
  }
48850
48727
  const result = translator116.decode({ node: { ...node3, attrs: { ...node3.attrs, tableCellProperties } } });
48851
48728
  return result;
@@ -48854,6 +48731,7 @@ var init_translate_table_cell = __esm(() => {
48854
48731
  init_helpers();
48855
48732
  init_helpers2();
48856
48733
  init_tcPr();
48734
+ init_legacyBorderMigration();
48857
48735
  });
48858
48736
 
48859
48737
  // ../../packages/super-editor/src/core/super-converter/v3/handlers/w/tc/tc-translator.js
@@ -48863,16 +48741,9 @@ function encode30(params2, encodedAttrs) {
48863
48741
  table,
48864
48742
  row,
48865
48743
  tableProperties,
48866
- rowBorders,
48867
- baseTableBorders,
48868
- tableLook,
48869
- rowCnfStyle,
48870
48744
  columnIndex,
48871
48745
  columnWidth,
48872
48746
  columnWidths: allColumnWidths,
48873
- rowIndex,
48874
- totalRows,
48875
- totalColumns,
48876
48747
  preferTableGridWidths,
48877
48748
  _referencedStyles
48878
48749
  } = params2.extraParams;
@@ -48882,16 +48753,9 @@ function encode30(params2, encodedAttrs) {
48882
48753
  table,
48883
48754
  row,
48884
48755
  tableProperties,
48885
- rowBorders,
48886
- baseTableBorders,
48887
- tableLook,
48888
- rowCnfStyle,
48889
48756
  columnIndex,
48890
48757
  columnWidth,
48891
48758
  allColumnWidths,
48892
- rowIndex,
48893
- totalRows,
48894
- totalColumns,
48895
48759
  preferTableGridWidths,
48896
48760
  _referencedStyles
48897
48761
  });
@@ -49221,50 +49085,12 @@ var createPlaceholderCell = (gridWidth, reason) => {
49221
49085
  };
49222
49086
 
49223
49087
  // ../../packages/super-editor/src/core/super-converter/v3/handlers/w/tr/tr-translator.js
49224
- function getRowBorders({ params: params2, row, baseBorders }) {
49225
- const tblPrEx = row?.elements?.find?.((el) => el.name === "w:tblPrEx");
49226
- const tblBorders = tblPrEx?.elements?.find?.((el) => el.name === "w:tblBorders");
49227
- const rowBaseBorders = {};
49228
- if (baseBorders?.insideV) {
49229
- rowBaseBorders.insideV = baseBorders?.insideV;
49230
- }
49231
- if (baseBorders?.insideH) {
49232
- rowBaseBorders.insideH = baseBorders?.insideH;
49233
- }
49234
- if (!tblBorders) {
49235
- return rowBaseBorders;
49236
- }
49237
- const rawOverrides = translator118.encode({ ...params2, nodes: [tblBorders] }) || {};
49238
- const overrides = processRawTableBorders(rawOverrides);
49239
- if (!Object.keys(overrides).length) {
49240
- return rowBaseBorders;
49241
- }
49242
- const rowBorders = { ...rowBaseBorders, ...overrides };
49243
- return rowBorders;
49244
- }
49245
- function processRawTableBorders(rawBorders) {
49246
- const borders = {};
49247
- Object.entries(rawBorders || {}).forEach(([name, attributes]) => {
49248
- const attrs = {};
49249
- const color2 = attributes?.color;
49250
- const size2 = attributes?.size;
49251
- const val = attributes?.val;
49252
- if (color2 && color2 !== "auto")
49253
- attrs.color = color2.startsWith("#") ? color2 : `#${color2}`;
49254
- if (size2 != null && size2 !== "auto")
49255
- attrs.size = eighthPointsToPixels(size2);
49256
- if (val)
49257
- attrs.val = val;
49258
- borders[name] = attrs;
49259
- });
49260
- return borders;
49261
- }
49262
49088
  var XML_NODE_NAME10 = "w:tr", SD_NODE_NAME7 = "tableRow", validXmlAttributes4, getColspan = (cell) => {
49263
49089
  const rawColspan = cell?.attrs?.colspan;
49264
49090
  const numericColspan = typeof rawColspan === "string" ? parseInt(rawColspan, 10) : rawColspan;
49265
49091
  return Number.isFinite(numericColspan) && numericColspan > 0 ? numericColspan : 1;
49266
49092
  }, encode31 = (params2, encodedAttrs) => {
49267
- const { row, tableLook } = params2.extraParams;
49093
+ const { row } = params2.extraParams;
49268
49094
  let tableRowProperties = {};
49269
49095
  const tPr = row.elements.find((el) => el.name === "w:trPr");
49270
49096
  if (tPr) {
@@ -49275,16 +49101,17 @@ var XML_NODE_NAME10 = "w:tr", SD_NODE_NAME7 = "tableRow", validXmlAttributes4, g
49275
49101
  }
49276
49102
  const gridBeforeRaw = tableRowProperties?.["gridBefore"];
49277
49103
  const safeGridBefore = typeof gridBeforeRaw === "number" && Number.isFinite(gridBeforeRaw) && gridBeforeRaw > 0 ? gridBeforeRaw : 0;
49104
+ const tblPrEx = row.elements?.find((el) => el.name === "w:tblPrEx");
49105
+ const tblPrExBorders = tblPrEx?.elements?.find((el) => el.name === "w:tblBorders");
49106
+ if (tblPrExBorders) {
49107
+ const parsed = translator118.encode({ ...params2, nodes: [tblPrExBorders] });
49108
+ if (parsed && Object.keys(parsed).length > 0) {
49109
+ tableRowProperties = { ...tableRowProperties, tblPrExBorders: parsed };
49110
+ }
49111
+ }
49278
49112
  encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
49279
49113
  encodedAttrs["rowHeight"] = twipsToPixels(tableRowProperties["rowHeight"]?.value);
49280
49114
  encodedAttrs["cantSplit"] = tableRowProperties["cantSplit"];
49281
- const rowCnfStyle = tableRowProperties?.cnfStyle;
49282
- const baseBorders = params2.extraParams?.tableBorders;
49283
- const rowBorders = getRowBorders({
49284
- params: params2,
49285
- row,
49286
- baseBorders
49287
- });
49288
49115
  const { columnWidths: gridColumnWidths, activeRowSpans = [] } = params2.extraParams;
49289
49116
  const totalColumns = Array.isArray(gridColumnWidths) ? gridColumnWidths.length : 0;
49290
49117
  const pendingRowSpans = Array.isArray(activeRowSpans) ? activeRowSpans.slice() : [];
@@ -49319,10 +49146,6 @@ var XML_NODE_NAME10 = "w:tr", SD_NODE_NAME7 = "tableRow", validXmlAttributes4, g
49319
49146
  path: [...params2.path || [], node3],
49320
49147
  extraParams: {
49321
49148
  ...params2.extraParams,
49322
- rowBorders,
49323
- baseTableBorders: baseBorders,
49324
- tableLook,
49325
- rowCnfStyle,
49326
49149
  node: node3,
49327
49150
  columnIndex: startColumn,
49328
49151
  columnWidth
@@ -49411,9 +49234,19 @@ var XML_NODE_NAME10 = "w:tr", SD_NODE_NAME7 = "tableRow", validXmlAttributes4, g
49411
49234
  }
49412
49235
  }
49413
49236
  tableRowProperties["cantSplit"] = node3.attrs["cantSplit"];
49237
+ const { tblPrExBorders, ...trPrProperties } = tableRowProperties;
49238
+ if (tblPrExBorders && typeof tblPrExBorders === "object" && Object.keys(tblPrExBorders).length > 0) {
49239
+ const bordersXml = translator118.decode({
49240
+ ...params2,
49241
+ node: { type: "tableRow", attrs: { borders: tblPrExBorders } }
49242
+ });
49243
+ if (bordersXml) {
49244
+ elements.unshift({ name: "w:tblPrEx", elements: [bordersXml] });
49245
+ }
49246
+ }
49414
49247
  const trPr = translator128.decode({
49415
49248
  ...params2,
49416
- node: { ...node3, attrs: { ...node3.attrs, tableRowProperties } }
49249
+ node: { ...node3, attrs: { ...node3.attrs, tableRowProperties: trPrProperties } }
49417
49250
  });
49418
49251
  if (trPr)
49419
49252
  elements.unshift(trPr);
@@ -56768,6 +56601,20 @@ function combineIndentProperties(indentChain) {
56768
56601
  });
56769
56602
  }
56770
56603
 
56604
+ // ../../packages/layout-engine/style-engine/src/ooxml/table-style-selection.ts
56605
+ var TABLE_FALLBACK_BORDER, TABLE_FALLBACK_BORDERS;
56606
+ var init_table_style_selection = __esm(() => {
56607
+ TABLE_FALLBACK_BORDER = { val: "single", size: 4, color: "#000000" };
56608
+ TABLE_FALLBACK_BORDERS = {
56609
+ top: { ...TABLE_FALLBACK_BORDER },
56610
+ left: { ...TABLE_FALLBACK_BORDER },
56611
+ bottom: { ...TABLE_FALLBACK_BORDER },
56612
+ right: { ...TABLE_FALLBACK_BORDER },
56613
+ insideH: { ...TABLE_FALLBACK_BORDER },
56614
+ insideV: { ...TABLE_FALLBACK_BORDER }
56615
+ };
56616
+ });
56617
+
56771
56618
  // ../../packages/layout-engine/style-engine/src/ooxml/index.ts
56772
56619
  function resolveRunProperties(params2, inlineRpr, resolvedPpr, tableInfo = null, isListNumber = false, numberingDefinedInline = false) {
56773
56620
  if (!params2.translatedLinkedStyles?.styles) {
@@ -56910,13 +56757,13 @@ function resolveStyleChain(propertyType, params2, styleId, followBasedOnChain =
56910
56757
  const styleProps = styleDef[propertyType] ?? {};
56911
56758
  const basedOn = styleDef.basedOn;
56912
56759
  let styleChain = [styleProps];
56913
- const seenStyles = new Set;
56760
+ const seenStyles = new Set([styleId]);
56914
56761
  let nextBasedOn = basedOn;
56915
56762
  while (followBasedOnChain && nextBasedOn) {
56916
56763
  if (seenStyles.has(nextBasedOn)) {
56917
56764
  break;
56918
56765
  }
56919
- seenStyles.add(basedOn);
56766
+ seenStyles.add(nextBasedOn);
56920
56767
  const basedOnStyleDef = params2.translatedLinkedStyles?.styles?.[nextBasedOn];
56921
56768
  const basedOnProps = basedOnStyleDef?.[propertyType];
56922
56769
  if (basedOnProps && Object.keys(basedOnProps).length) {
@@ -57071,7 +56918,9 @@ function determineCellStyleTypes(tblLook, rowIndex, cellIndex, numRows, numCells
57071
56918
  }
57072
56919
  return styleTypes;
57073
56920
  }
57074
- var init_ooxml = () => {};
56921
+ var init_ooxml = __esm(() => {
56922
+ init_table_style_selection();
56923
+ });
57075
56924
 
57076
56925
  // ../../packages/super-editor/src/core/super-converter/v3/handlers/wp/helpers/textbox-content-helpers.js
57077
56926
  function collectTextBoxParagraphs(nodes, paragraphs = []) {
@@ -60529,7 +60378,6 @@ var validXmlAttributes9, XML_NODE_NAME16 = "w:tbl", SD_NODE_NAME12 = "table", IN
60529
60378
  };
60530
60379
  }
60531
60380
  }
60532
- const tableLook = encodedAttrs.tableProperties.tblLook;
60533
60381
  const borderProps = _processTableBorders(encodedAttrs.tableProperties.borders || {});
60534
60382
  const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2) || {};
60535
60383
  encodedAttrs.borders = { ...referencedStyles.borders, ...borderProps };
@@ -60577,8 +60425,6 @@ var validXmlAttributes9, XML_NODE_NAME16 = "w:tbl", SD_NODE_NAME12 = "table", IN
60577
60425
  row,
60578
60426
  table: node3,
60579
60427
  tableProperties: encodedAttrs.tableProperties,
60580
- tableBorders: encodedAttrs.borders,
60581
- tableLook,
60582
60428
  columnWidths,
60583
60429
  activeRowSpans: activeRowSpans.slice(),
60584
60430
  rowIndex,
@@ -66808,7 +66654,7 @@ function translateContentBlock(params2) {
66808
66654
  return wrapTextInRun(alternateContent);
66809
66655
  }
66810
66656
  function pxToPt(px) {
66811
- const pt = Math.round(px / PX_PER_PT * 10) / 10;
66657
+ const pt = Math.round(px / PX_PER_PT2 * 10) / 10;
66812
66658
  return `${pt}pt`;
66813
66659
  }
66814
66660
  function sizeToPt(value, options = {}) {
@@ -66911,7 +66757,7 @@ function translateVRectContentBlock(params2) {
66911
66757
  };
66912
66758
  return wrapTextInRun(pict);
66913
66759
  }
66914
- var FULL_WIDTH_PT = "468pt", FULL_WIDTH_PT_VALUE = 468, PX_PER_PT = 1.33;
66760
+ var FULL_WIDTH_PT = "468pt", FULL_WIDTH_PT_VALUE = 468, PX_PER_PT2 = 1.33;
66915
66761
  var init_translate_content_block = __esm(() => {
66916
66762
  init_altermateContent();
66917
66763
  init_exporter();
@@ -69911,21 +69757,6 @@ var init_InputRule = __esm(() => {
69911
69757
  init_google_docs_paste();
69912
69758
  });
69913
69759
 
69914
- // ../../packages/super-editor/src/extensions/table-cell/helpers/createCellBorders.js
69915
- var createCellBorders = (borderSpec = {}) => {
69916
- borderSpec = {
69917
- size: 0.66665,
69918
- color: "#000000",
69919
- ...borderSpec
69920
- };
69921
- return {
69922
- top: borderSpec,
69923
- left: borderSpec,
69924
- bottom: borderSpec,
69925
- right: borderSpec
69926
- };
69927
- };
69928
-
69929
69760
  // ../../packages/super-editor/src/core/helpers/catchAllSchema.js
69930
69761
  function detectUnsupportedContent(element, schema) {
69931
69762
  const itemsByTag = new Map;
@@ -70037,46 +69868,9 @@ function createDocFromHTML(content3, editor, options = {}) {
70037
69868
  }
70038
69869
  }
70039
69870
  let doc = DOMParser2.fromSchema(editor.schema).parse(parsedContent);
70040
- if (isImport) {
70041
- doc = normalizeImportedHtmlTableHeaders(doc);
70042
- }
70043
69871
  doc = wrapTextsInRuns(doc);
70044
69872
  return doc;
70045
69873
  }
70046
- var TABLE_HEADER_NODE_NAME = "tableHeader", hasMeaningfulCellBorders = (borderValue) => {
70047
- if (!borderValue || typeof borderValue !== "object")
70048
- return false;
70049
- return Object.values(borderValue).some((side) => side && typeof side === "object" && Object.keys(side).length > 0);
70050
- }, normalizeImportedHtmlTableHeaders = (doc) => {
70051
- const normalizeNode = (node3) => {
70052
- let nextNode = node3;
70053
- if (node3.childCount > 0) {
70054
- const nextChildren = [];
70055
- let childrenChanged = false;
70056
- node3.forEach((child) => {
70057
- const normalizedChild = normalizeNode(child);
70058
- if (normalizedChild !== child)
70059
- childrenChanged = true;
70060
- nextChildren.push(normalizedChild);
70061
- });
70062
- if (childrenChanged) {
70063
- nextNode = node3.copy(Fragment.fromArray(nextChildren));
70064
- }
70065
- }
70066
- if (nextNode.type.name !== TABLE_HEADER_NODE_NAME) {
70067
- return nextNode;
70068
- }
70069
- if (hasMeaningfulCellBorders(nextNode.attrs?.borders)) {
70070
- return nextNode;
70071
- }
70072
- const nextAttrs = {
70073
- ...nextNode.attrs,
70074
- borders: createCellBorders()
70075
- };
70076
- return nextNode.type.create(nextAttrs, nextNode.content, nextNode.marks);
70077
- };
70078
- return normalizeNode(doc);
70079
- };
70080
69874
  var init_importHtml = __esm(() => {
70081
69875
  init_dist();
70082
69876
  init_InputRule();
@@ -70893,7 +70687,8 @@ function convertTable(node3, ctx) {
70893
70687
  return {
70894
70688
  type: "table",
70895
70689
  attrs: {
70896
- tableStyleId: "TableGrid",
70690
+ tableStyleId: null,
70691
+ needsTableStyleNormalization: true,
70897
70692
  tableProperties: {
70898
70693
  tableWidth: {
70899
70694
  value: FULL_WIDTH_TABLE_PCT,
@@ -76862,12 +76657,11 @@ function cellSidesForEdge(edge, row, col, lastRow, lastCol) {
76862
76657
  function tableBorderToCellBorder(border) {
76863
76658
  const val = typeof border.val === "string" ? border.val : "single";
76864
76659
  const color2 = typeof border.color === "string" ? border.color : "auto";
76865
- const sizeEighthPoints = typeof border.size === "number" ? border.size : 0;
76866
- const sizePx = val === "none" || val === "nil" ? 0 : sizeEighthPoints / 8 * POINTS_TO_PIXELS;
76660
+ const size2 = typeof border.size === "number" ? border.size : 0;
76867
76661
  return {
76868
76662
  val,
76869
76663
  color: color2,
76870
- size: sizePx,
76664
+ size: val === "none" || val === "nil" ? 0 : size2,
76871
76665
  space: 0
76872
76666
  };
76873
76667
  }
@@ -76892,13 +76686,16 @@ function applyTableEdgeToCellBorders(tr, tablePos, tableNode, edge, borderSpec)
76892
76686
  if (!cellNode)
76893
76687
  continue;
76894
76688
  const cellAttrs = cellNode.attrs;
76895
- const borders = { ...cellAttrs.borders ?? {} };
76689
+ const tcp = { ...cellAttrs.tableCellProperties ?? {} };
76690
+ const borders = { ...tcp.borders ?? {} };
76896
76691
  for (const side of targetSides) {
76897
76692
  borders[side] = { ...cellBorder };
76898
76693
  }
76694
+ tcp.borders = borders;
76899
76695
  tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(tableStart + relPos), null, {
76900
76696
  ...cellAttrs,
76901
- borders
76697
+ borders: null,
76698
+ tableCellProperties: tcp
76902
76699
  });
76903
76700
  }
76904
76701
  }
@@ -76924,7 +76721,8 @@ function applyTableBorderPresetToCellBorders(tr, tablePos, tableNode, preset) {
76924
76721
  if (!cellNode)
76925
76722
  continue;
76926
76723
  const cellAttrs = cellNode.attrs;
76927
- const borders = { ...cellAttrs.borders ?? {} };
76724
+ const tcp = { ...cellAttrs.tableCellProperties ?? {} };
76725
+ const borders = { ...tcp.borders ?? {} };
76928
76726
  if (preset === "none") {
76929
76727
  borders.top = { ...noneBorder };
76930
76728
  borders.bottom = { ...noneBorder };
@@ -76941,9 +76739,11 @@ function applyTableBorderPresetToCellBorders(tr, tablePos, tableNode, preset) {
76941
76739
  borders.left = { ...singleBorder };
76942
76740
  borders.right = { ...singleBorder };
76943
76741
  }
76742
+ tcp.borders = borders;
76944
76743
  tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(tableStart + relPos), null, {
76945
76744
  ...cellAttrs,
76946
- borders
76745
+ borders: null,
76746
+ tableCellProperties: tcp
76947
76747
  });
76948
76748
  }
76949
76749
  }
@@ -78587,7 +78387,8 @@ function tablesSetBorderAdapter(editor, input, options) {
78587
78387
  };
78588
78388
  currentProps.borders = currentBorders;
78589
78389
  const syncAttrs = resolved.scope === "table" ? syncExtractedTableAttrs(currentProps) : {};
78590
- tr.setNodeMarkup(resolved.pos, null, { ...currentAttrs, [propsKey]: currentProps, ...syncAttrs });
78390
+ const cellClear = resolved.scope === "cell" ? { borders: null } : {};
78391
+ tr.setNodeMarkup(resolved.pos, null, { ...currentAttrs, [propsKey]: currentProps, ...syncAttrs, ...cellClear });
78591
78392
  if (resolved.scope === "table" && isBoundaryEdge(input.edge)) {
78592
78393
  applyTableEdgeToCellBorders(tr, resolved.pos, resolved.node, input.edge, currentBorders[input.edge]);
78593
78394
  }
@@ -78617,7 +78418,8 @@ function tablesClearBorderAdapter(editor, input, options) {
78617
78418
  currentBorders[input.edge] = { val: "nil", size: 0, color: "auto" };
78618
78419
  currentProps.borders = currentBorders;
78619
78420
  const syncAttrs = resolved.scope === "table" ? syncExtractedTableAttrs(currentProps) : {};
78620
- tr.setNodeMarkup(resolved.pos, null, { ...currentAttrs, [propsKey]: currentProps, ...syncAttrs });
78421
+ const cellClear = resolved.scope === "cell" ? { borders: null } : {};
78422
+ tr.setNodeMarkup(resolved.pos, null, { ...currentAttrs, [propsKey]: currentProps, ...syncAttrs, ...cellClear });
78621
78423
  if (resolved.scope === "table" && isBoundaryEdge(input.edge)) {
78622
78424
  applyTableEdgeToCellBorders(tr, resolved.pos, resolved.node, input.edge, currentBorders[input.edge]);
78623
78425
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.2.0-next.57",
3
+ "version": "0.2.0-next.58",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -19,8 +19,8 @@
19
19
  "@types/bun": "^1.3.8",
20
20
  "@types/node": "22.19.2",
21
21
  "typescript": "^5.9.2",
22
- "@superdoc/pm-adapter": "0.0.0",
23
22
  "@superdoc/document-api": "0.0.1",
23
+ "@superdoc/pm-adapter": "0.0.0",
24
24
  "@superdoc/super-editor": "0.0.1",
25
25
  "superdoc": "1.16.0"
26
26
  },
@@ -29,11 +29,11 @@
29
29
  "access": "public"
30
30
  },
31
31
  "optionalDependencies": {
32
- "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.57",
33
- "@superdoc-dev/cli-darwin-x64": "0.2.0-next.57",
34
- "@superdoc-dev/cli-linux-x64": "0.2.0-next.57",
35
- "@superdoc-dev/cli-linux-arm64": "0.2.0-next.57",
36
- "@superdoc-dev/cli-windows-x64": "0.2.0-next.57"
32
+ "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.58",
33
+ "@superdoc-dev/cli-darwin-x64": "0.2.0-next.58",
34
+ "@superdoc-dev/cli-linux-arm64": "0.2.0-next.58",
35
+ "@superdoc-dev/cli-windows-x64": "0.2.0-next.58",
36
+ "@superdoc-dev/cli-linux-x64": "0.2.0-next.58"
37
37
  },
38
38
  "scripts": {
39
39
  "dev": "bun run src/index.ts",