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

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 +454 -372
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -2918,6 +2918,47 @@ var init_operation_definitions = __esm(() => {
2918
2918
  referenceDocPath: "tables/get-properties.mdx",
2919
2919
  referenceGroup: "tables"
2920
2920
  },
2921
+ "tables.getStyles": {
2922
+ memberPath: "tables.getStyles",
2923
+ description: "List all table styles and the document-level default table style setting.",
2924
+ expectedResult: "Returns a TablesGetStylesOutput with the style catalog, explicit default, and effective default.",
2925
+ requiresDocumentContext: true,
2926
+ metadata: readOperation({ idempotency: "idempotent" }),
2927
+ referenceDocPath: "tables/get-styles.mdx",
2928
+ referenceGroup: "tables"
2929
+ },
2930
+ "tables.setDefaultStyle": {
2931
+ memberPath: "tables.setDefaultStyle",
2932
+ description: "Set the document-level default table style (w:defaultTableStyle in settings.xml).",
2933
+ expectedResult: "Returns a DocumentMutationResult; reports NO_OP if the default already matches.",
2934
+ requiresDocumentContext: true,
2935
+ metadata: mutationOperation({
2936
+ idempotency: "idempotent",
2937
+ supportsDryRun: true,
2938
+ supportsTrackedMode: false,
2939
+ possibleFailureCodes: ["NO_OP", "INVALID_INPUT"],
2940
+ throws: ["CAPABILITY_UNAVAILABLE", "INVALID_INPUT"],
2941
+ historyUnsafe: true
2942
+ }),
2943
+ referenceDocPath: "tables/set-default-style.mdx",
2944
+ referenceGroup: "tables"
2945
+ },
2946
+ "tables.clearDefaultStyle": {
2947
+ memberPath: "tables.clearDefaultStyle",
2948
+ description: "Remove the document-level default table style setting.",
2949
+ expectedResult: "Returns a DocumentMutationResult; reports NO_OP if no default is set.",
2950
+ requiresDocumentContext: true,
2951
+ metadata: mutationOperation({
2952
+ idempotency: "conditional",
2953
+ supportsDryRun: true,
2954
+ supportsTrackedMode: false,
2955
+ possibleFailureCodes: ["NO_OP"],
2956
+ throws: ["CAPABILITY_UNAVAILABLE"],
2957
+ historyUnsafe: true
2958
+ }),
2959
+ referenceDocPath: "tables/clear-default-style.mdx",
2960
+ referenceGroup: "tables"
2961
+ },
2921
2962
  "create.tableOfContents": {
2922
2963
  memberPath: "create.tableOfContents",
2923
2964
  description: "Insert a new table of contents at the target position.",
@@ -6051,6 +6092,47 @@ var init_schemas = __esm(() => {
6051
6092
  })
6052
6093
  }, ["nodeId"])
6053
6094
  },
6095
+ "tables.getStyles": {
6096
+ input: strictEmptyObjectSchema,
6097
+ output: objectSchema({
6098
+ explicitDefaultStyleId: { type: ["string", "null"] },
6099
+ effectiveDefaultStyleId: { type: ["string", "null"] },
6100
+ effectiveDefaultSource: { type: "string" },
6101
+ styles: arraySchema(objectSchema({
6102
+ id: { type: "string" },
6103
+ name: { type: ["string", "null"] },
6104
+ basedOn: { type: ["string", "null"] },
6105
+ isDefault: { type: "boolean" },
6106
+ isCustom: { type: "boolean" },
6107
+ uiPriority: { type: ["integer", "null"] },
6108
+ hidden: { type: "boolean" },
6109
+ quickFormat: { type: "boolean" },
6110
+ conditionalRegions: arraySchema({ type: "string" })
6111
+ }, [
6112
+ "id",
6113
+ "name",
6114
+ "basedOn",
6115
+ "isDefault",
6116
+ "isCustom",
6117
+ "uiPriority",
6118
+ "hidden",
6119
+ "quickFormat",
6120
+ "conditionalRegions"
6121
+ ]))
6122
+ }, ["explicitDefaultStyleId", "effectiveDefaultStyleId", "effectiveDefaultSource", "styles"])
6123
+ },
6124
+ "tables.setDefaultStyle": {
6125
+ input: objectSchema({ styleId: { type: "string" } }, ["styleId"]),
6126
+ output: documentMutationResultSchemaFor("tables.setDefaultStyle"),
6127
+ success: documentMutationSuccessSchema,
6128
+ failure: sectionMutationFailureSchemaFor("tables.setDefaultStyle")
6129
+ },
6130
+ "tables.clearDefaultStyle": {
6131
+ input: strictEmptyObjectSchema,
6132
+ output: documentMutationResultSchemaFor("tables.clearDefaultStyle"),
6133
+ success: documentMutationSuccessSchema,
6134
+ failure: sectionMutationFailureSchemaFor("tables.clearDefaultStyle")
6135
+ },
6054
6136
  "history.get": {
6055
6137
  input: strictEmptyObjectSchema,
6056
6138
  output: objectSchema({
@@ -7498,6 +7580,9 @@ function buildDispatchTable(api) {
7498
7580
  "tables.get": (input) => api.tables.get(input),
7499
7581
  "tables.getCells": (input) => api.tables.getCells(input),
7500
7582
  "tables.getProperties": (input) => api.tables.getProperties(input),
7583
+ "tables.getStyles": (input) => api.tables.getStyles(input),
7584
+ "tables.setDefaultStyle": (input, options) => api.tables.setDefaultStyle(input, options),
7585
+ "tables.clearDefaultStyle": (input, options) => api.tables.clearDefaultStyle(input, options),
7501
7586
  "create.tableOfContents": (input, options) => api.create.tableOfContents(input, options),
7502
7587
  "toc.list": (input) => api.toc.list(input),
7503
7588
  "toc.get": (input) => api.toc.get(input),
@@ -8406,6 +8491,15 @@ function createDocumentApi(adapters) {
8406
8491
  },
8407
8492
  getProperties(input) {
8408
8493
  return adapters.tables.getProperties(input);
8494
+ },
8495
+ getStyles(input) {
8496
+ return adapters.tables.getStyles(input);
8497
+ },
8498
+ setDefaultStyle(input, options) {
8499
+ return adapters.tables.setDefaultStyle(input, options);
8500
+ },
8501
+ clearDefaultStyle(input, options) {
8502
+ return adapters.tables.clearDefaultStyle(input, options);
8409
8503
  }
8410
8504
  },
8411
8505
  toc: {
@@ -9279,6 +9373,9 @@ var init_operation_hints = __esm(() => {
9279
9373
  "tables.get": "resolved table",
9280
9374
  "tables.getCells": "listed cells",
9281
9375
  "tables.getProperties": "resolved table properties",
9376
+ "tables.getStyles": "listed table styles",
9377
+ "tables.setDefaultStyle": "set default table style",
9378
+ "tables.clearDefaultStyle": "cleared default table style",
9282
9379
  "history.get": "retrieved history state",
9283
9380
  "history.undo": "undid last change",
9284
9381
  "history.redo": "redid last change"
@@ -9379,6 +9476,9 @@ var init_operation_hints = __esm(() => {
9379
9476
  "tables.get": "tableInfo",
9380
9477
  "tables.getCells": "tableCellList",
9381
9478
  "tables.getProperties": "tablePropertiesInfo",
9479
+ "tables.getStyles": "plain",
9480
+ "tables.setDefaultStyle": "plain",
9481
+ "tables.clearDefaultStyle": "plain",
9382
9482
  "history.get": "plain",
9383
9483
  "history.undo": "plain",
9384
9484
  "history.redo": "plain"
@@ -9479,6 +9579,9 @@ var init_operation_hints = __esm(() => {
9479
9579
  "tables.get": "result",
9480
9580
  "tables.getCells": "result",
9481
9581
  "tables.getProperties": "result",
9582
+ "tables.getStyles": "result",
9583
+ "tables.setDefaultStyle": "result",
9584
+ "tables.clearDefaultStyle": "result",
9482
9585
  "history.get": "result",
9483
9586
  "history.undo": "result",
9484
9587
  "history.redo": "result"
@@ -9586,6 +9689,9 @@ var init_operation_hints = __esm(() => {
9586
9689
  "tables.get": "tables",
9587
9690
  "tables.getCells": "tables",
9588
9691
  "tables.getProperties": "tables",
9692
+ "tables.getStyles": "tables",
9693
+ "tables.setDefaultStyle": "tables",
9694
+ "tables.clearDefaultStyle": "tables",
9589
9695
  "history.get": "query",
9590
9696
  "history.undo": "general",
9591
9697
  "history.redo": "general"
@@ -12630,7 +12736,9 @@ var init_capabilities_adapter = __esm(() => {
12630
12736
  REQUIRED_HELPERS = {
12631
12737
  "blocks.delete": (editor) => typeof editor.helpers?.blockNode?.getBlockNodeById === "function",
12632
12738
  "sections.setOddEvenHeadersFooters": (editor) => Boolean(editor.converter),
12633
- "sections.setHeaderFooterRef": (editor) => Boolean(editor.converter)
12739
+ "sections.setHeaderFooterRef": (editor) => Boolean(editor.converter),
12740
+ "tables.setDefaultStyle": (editor) => Boolean(editor.converter),
12741
+ "tables.clearDefaultStyle": (editor) => Boolean(editor.converter)
12634
12742
  };
12635
12743
  SUPPORTED_STEP_OPS = [
12636
12744
  "text.rewrite",
@@ -42707,11 +42815,6 @@ function eighthPointsToPixels(eighthPoints) {
42707
42815
  const pixels = points * 1.3333;
42708
42816
  return pixels;
42709
42817
  }
42710
- function pixelsToEightPoints(pixels) {
42711
- if (pixels == null)
42712
- return;
42713
- return Math.round(pixels * 6);
42714
- }
42715
42818
  function twipsToPt(twips) {
42716
42819
  if (twips == null)
42717
42820
  return;
@@ -48401,16 +48504,9 @@ function handleTableCellNode({
48401
48504
  table,
48402
48505
  row,
48403
48506
  tableProperties,
48404
- rowBorders,
48405
- baseTableBorders,
48406
- tableLook,
48407
- rowCnfStyle,
48408
48507
  columnIndex,
48409
48508
  columnWidth = null,
48410
48509
  allColumnWidths = [],
48411
- rowIndex = 0,
48412
- totalRows = 1,
48413
- totalColumns,
48414
48510
  preferTableGridWidths = false,
48415
48511
  _referencedStyles
48416
48512
  }) {
@@ -48420,26 +48516,7 @@ function handleTableCellNode({
48420
48516
  const tcPr = node3.elements.find((el) => el.name === "w:tcPr");
48421
48517
  const tableCellProperties = tcPr ? translator116.encode({ ...params2, nodes: [tcPr] }) ?? {} : {};
48422
48518
  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
48519
  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
48520
  if (colspan > 1)
48444
48521
  attributes["colspan"] = colspan;
48445
48522
  let width = null;
@@ -48615,112 +48692,7 @@ function normalizeTableCellContent(content3, editor) {
48615
48692
  }
48616
48693
  return normalized;
48617
48694
  }
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) => {
48695
+ var getTableCellVMerge = (node3) => {
48724
48696
  const tcPr = node3.elements.find((el) => el.name === "w:tcPr");
48725
48697
  const vMerge = tcPr?.elements?.find((el) => el.name === "w:vMerge");
48726
48698
  if (!vMerge)
@@ -48749,6 +48721,38 @@ var init_legacy_handle_table_cell_node = __esm(() => {
48749
48721
  init_tcPr();
48750
48722
  });
48751
48723
 
48724
+ // ../../packages/super-editor/src/extensions/table-cell/helpers/legacyBorderMigration.js
48725
+ function isLegacySchemaDefaultBorders(borders) {
48726
+ if (!borders || typeof borders !== "object")
48727
+ return false;
48728
+ return SIDES.every((side) => {
48729
+ const b = borders[side];
48730
+ if (!b || typeof b !== "object")
48731
+ return false;
48732
+ return !("val" in b) && b.size === 0.66665 && b.color === "#000000";
48733
+ });
48734
+ }
48735
+ function convertBordersToOoxmlFormat(borders) {
48736
+ const result = {};
48737
+ for (const side of SIDES) {
48738
+ const b = borders[side];
48739
+ if (!b || typeof b !== "object")
48740
+ continue;
48741
+ result[side] = {
48742
+ val: b.val || "single",
48743
+ size: typeof b.size === "number" ? pxToEighthPoints(b.size) : 4,
48744
+ space: b.space || 0,
48745
+ color: b.color === "#000000" ? "auto" : b.color || "auto"
48746
+ };
48747
+ }
48748
+ return result;
48749
+ }
48750
+ var PX_PER_PT, pxToEighthPoints = (px) => Math.round(px / PX_PER_PT * 8), SIDES;
48751
+ var init_legacyBorderMigration = __esm(() => {
48752
+ PX_PER_PT = 96 / 72;
48753
+ SIDES = ["top", "right", "bottom", "left"];
48754
+ });
48755
+
48752
48756
  // ../../packages/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/translate-table-cell.js
48753
48757
  function translateTableCell(params2) {
48754
48758
  const elements = translateChildNodes({
@@ -48763,7 +48767,7 @@ function translateTableCell(params2) {
48763
48767
  };
48764
48768
  }
48765
48769
  function generateTableCellProperties(node3) {
48766
- const tableCellProperties = { ...node3.attrs?.tableCellProperties || {} };
48770
+ let tableCellProperties = { ...node3.attrs?.tableCellProperties || {} };
48767
48771
  const { attrs } = node3;
48768
48772
  const { colwidth: rawColwidth, widthUnit = "px" } = attrs;
48769
48773
  const resolvedWidthType = attrs.cellWidthType ?? (attrs.widthType !== "auto" ? attrs.widthType : undefined) ?? tableCellProperties.cellWidth?.type ?? "dxa";
@@ -48820,32 +48824,13 @@ function generateTableCellProperties(node3) {
48820
48824
  } else {
48821
48825
  delete tableCellProperties.vMerge;
48822
48826
  }
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;
48827
+ if (!tableCellProperties?.borders && attrs.borders != null) {
48828
+ if (!isLegacySchemaDefaultBorders(attrs.borders)) {
48829
+ tableCellProperties = {
48830
+ ...tableCellProperties ?? {},
48831
+ borders: convertBordersToOoxmlFormat(attrs.borders)
48832
+ };
48833
+ }
48849
48834
  }
48850
48835
  const result = translator116.decode({ node: { ...node3, attrs: { ...node3.attrs, tableCellProperties } } });
48851
48836
  return result;
@@ -48854,6 +48839,7 @@ var init_translate_table_cell = __esm(() => {
48854
48839
  init_helpers();
48855
48840
  init_helpers2();
48856
48841
  init_tcPr();
48842
+ init_legacyBorderMigration();
48857
48843
  });
48858
48844
 
48859
48845
  // ../../packages/super-editor/src/core/super-converter/v3/handlers/w/tc/tc-translator.js
@@ -48863,16 +48849,9 @@ function encode30(params2, encodedAttrs) {
48863
48849
  table,
48864
48850
  row,
48865
48851
  tableProperties,
48866
- rowBorders,
48867
- baseTableBorders,
48868
- tableLook,
48869
- rowCnfStyle,
48870
48852
  columnIndex,
48871
48853
  columnWidth,
48872
48854
  columnWidths: allColumnWidths,
48873
- rowIndex,
48874
- totalRows,
48875
- totalColumns,
48876
48855
  preferTableGridWidths,
48877
48856
  _referencedStyles
48878
48857
  } = params2.extraParams;
@@ -48882,16 +48861,9 @@ function encode30(params2, encodedAttrs) {
48882
48861
  table,
48883
48862
  row,
48884
48863
  tableProperties,
48885
- rowBorders,
48886
- baseTableBorders,
48887
- tableLook,
48888
- rowCnfStyle,
48889
48864
  columnIndex,
48890
48865
  columnWidth,
48891
48866
  allColumnWidths,
48892
- rowIndex,
48893
- totalRows,
48894
- totalColumns,
48895
48867
  preferTableGridWidths,
48896
48868
  _referencedStyles
48897
48869
  });
@@ -49221,50 +49193,12 @@ var createPlaceholderCell = (gridWidth, reason) => {
49221
49193
  };
49222
49194
 
49223
49195
  // ../../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
49196
  var XML_NODE_NAME10 = "w:tr", SD_NODE_NAME7 = "tableRow", validXmlAttributes4, getColspan = (cell) => {
49263
49197
  const rawColspan = cell?.attrs?.colspan;
49264
49198
  const numericColspan = typeof rawColspan === "string" ? parseInt(rawColspan, 10) : rawColspan;
49265
49199
  return Number.isFinite(numericColspan) && numericColspan > 0 ? numericColspan : 1;
49266
49200
  }, encode31 = (params2, encodedAttrs) => {
49267
- const { row, tableLook } = params2.extraParams;
49201
+ const { row } = params2.extraParams;
49268
49202
  let tableRowProperties = {};
49269
49203
  const tPr = row.elements.find((el) => el.name === "w:trPr");
49270
49204
  if (tPr) {
@@ -49275,16 +49209,17 @@ var XML_NODE_NAME10 = "w:tr", SD_NODE_NAME7 = "tableRow", validXmlAttributes4, g
49275
49209
  }
49276
49210
  const gridBeforeRaw = tableRowProperties?.["gridBefore"];
49277
49211
  const safeGridBefore = typeof gridBeforeRaw === "number" && Number.isFinite(gridBeforeRaw) && gridBeforeRaw > 0 ? gridBeforeRaw : 0;
49212
+ const tblPrEx = row.elements?.find((el) => el.name === "w:tblPrEx");
49213
+ const tblPrExBorders = tblPrEx?.elements?.find((el) => el.name === "w:tblBorders");
49214
+ if (tblPrExBorders) {
49215
+ const parsed = translator118.encode({ ...params2, nodes: [tblPrExBorders] });
49216
+ if (parsed && Object.keys(parsed).length > 0) {
49217
+ tableRowProperties = { ...tableRowProperties, tblPrExBorders: parsed };
49218
+ }
49219
+ }
49278
49220
  encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
49279
49221
  encodedAttrs["rowHeight"] = twipsToPixels(tableRowProperties["rowHeight"]?.value);
49280
49222
  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
49223
  const { columnWidths: gridColumnWidths, activeRowSpans = [] } = params2.extraParams;
49289
49224
  const totalColumns = Array.isArray(gridColumnWidths) ? gridColumnWidths.length : 0;
49290
49225
  const pendingRowSpans = Array.isArray(activeRowSpans) ? activeRowSpans.slice() : [];
@@ -49319,10 +49254,6 @@ var XML_NODE_NAME10 = "w:tr", SD_NODE_NAME7 = "tableRow", validXmlAttributes4, g
49319
49254
  path: [...params2.path || [], node3],
49320
49255
  extraParams: {
49321
49256
  ...params2.extraParams,
49322
- rowBorders,
49323
- baseTableBorders: baseBorders,
49324
- tableLook,
49325
- rowCnfStyle,
49326
49257
  node: node3,
49327
49258
  columnIndex: startColumn,
49328
49259
  columnWidth
@@ -49411,9 +49342,19 @@ var XML_NODE_NAME10 = "w:tr", SD_NODE_NAME7 = "tableRow", validXmlAttributes4, g
49411
49342
  }
49412
49343
  }
49413
49344
  tableRowProperties["cantSplit"] = node3.attrs["cantSplit"];
49345
+ const { tblPrExBorders, ...trPrProperties } = tableRowProperties;
49346
+ if (tblPrExBorders && typeof tblPrExBorders === "object" && Object.keys(tblPrExBorders).length > 0) {
49347
+ const bordersXml = translator118.decode({
49348
+ ...params2,
49349
+ node: { type: "tableRow", attrs: { borders: tblPrExBorders } }
49350
+ });
49351
+ if (bordersXml) {
49352
+ elements.unshift({ name: "w:tblPrEx", elements: [bordersXml] });
49353
+ }
49354
+ }
49414
49355
  const trPr = translator128.decode({
49415
49356
  ...params2,
49416
- node: { ...node3, attrs: { ...node3.attrs, tableRowProperties } }
49357
+ node: { ...node3, attrs: { ...node3.attrs, tableRowProperties: trPrProperties } }
49417
49358
  });
49418
49359
  if (trPr)
49419
49360
  elements.unshift(trPr);
@@ -56768,6 +56709,49 @@ function combineIndentProperties(indentChain) {
56768
56709
  });
56769
56710
  }
56770
56711
 
56712
+ // ../../packages/layout-engine/style-engine/src/ooxml/table-style-selection.ts
56713
+ function isKnownTableStyleId(styleId, translatedLinkedStyles) {
56714
+ if (!styleId || !translatedLinkedStyles?.styles)
56715
+ return false;
56716
+ const def = translatedLinkedStyles.styles[styleId];
56717
+ return def != null && def.type === "table";
56718
+ }
56719
+ function findTypeDefaultTableStyleId(translatedLinkedStyles) {
56720
+ if (!translatedLinkedStyles?.styles)
56721
+ return null;
56722
+ for (const [styleId, def] of Object.entries(translatedLinkedStyles.styles)) {
56723
+ if (def.type === "table" && def.default === true) {
56724
+ return styleId;
56725
+ }
56726
+ }
56727
+ return null;
56728
+ }
56729
+ function resolvePreferredNewTableStyleId(settingsDefaultTableStyleId, translatedLinkedStyles) {
56730
+ if (settingsDefaultTableStyleId && isKnownTableStyleId(settingsDefaultTableStyleId, translatedLinkedStyles)) {
56731
+ return { styleId: settingsDefaultTableStyleId, source: "settings-default" };
56732
+ }
56733
+ const typeDefault = findTypeDefaultTableStyleId(translatedLinkedStyles);
56734
+ if (typeDefault && typeDefault !== TABLE_STYLE_ID_TABLE_NORMAL) {
56735
+ return { styleId: typeDefault, source: "type-default" };
56736
+ }
56737
+ if (isKnownTableStyleId(TABLE_STYLE_ID_TABLE_GRID, translatedLinkedStyles)) {
56738
+ return { styleId: TABLE_STYLE_ID_TABLE_GRID, source: "builtin-fallback" };
56739
+ }
56740
+ return { styleId: null, source: "none" };
56741
+ }
56742
+ var TABLE_STYLE_ID_TABLE_GRID = "TableGrid", TABLE_STYLE_ID_TABLE_NORMAL = "TableNormal", TABLE_FALLBACK_BORDER, TABLE_FALLBACK_BORDERS;
56743
+ var init_table_style_selection = __esm(() => {
56744
+ TABLE_FALLBACK_BORDER = { val: "single", size: 4, color: "#000000" };
56745
+ TABLE_FALLBACK_BORDERS = {
56746
+ top: { ...TABLE_FALLBACK_BORDER },
56747
+ left: { ...TABLE_FALLBACK_BORDER },
56748
+ bottom: { ...TABLE_FALLBACK_BORDER },
56749
+ right: { ...TABLE_FALLBACK_BORDER },
56750
+ insideH: { ...TABLE_FALLBACK_BORDER },
56751
+ insideV: { ...TABLE_FALLBACK_BORDER }
56752
+ };
56753
+ });
56754
+
56771
56755
  // ../../packages/layout-engine/style-engine/src/ooxml/index.ts
56772
56756
  function resolveRunProperties(params2, inlineRpr, resolvedPpr, tableInfo = null, isListNumber = false, numberingDefinedInline = false) {
56773
56757
  if (!params2.translatedLinkedStyles?.styles) {
@@ -56910,13 +56894,13 @@ function resolveStyleChain(propertyType, params2, styleId, followBasedOnChain =
56910
56894
  const styleProps = styleDef[propertyType] ?? {};
56911
56895
  const basedOn = styleDef.basedOn;
56912
56896
  let styleChain = [styleProps];
56913
- const seenStyles = new Set;
56897
+ const seenStyles = new Set([styleId]);
56914
56898
  let nextBasedOn = basedOn;
56915
56899
  while (followBasedOnChain && nextBasedOn) {
56916
56900
  if (seenStyles.has(nextBasedOn)) {
56917
56901
  break;
56918
56902
  }
56919
- seenStyles.add(basedOn);
56903
+ seenStyles.add(nextBasedOn);
56920
56904
  const basedOnStyleDef = params2.translatedLinkedStyles?.styles?.[nextBasedOn];
56921
56905
  const basedOnProps = basedOnStyleDef?.[propertyType];
56922
56906
  if (basedOnProps && Object.keys(basedOnProps).length) {
@@ -57071,7 +57055,9 @@ function determineCellStyleTypes(tblLook, rowIndex, cellIndex, numRows, numCells
57071
57055
  }
57072
57056
  return styleTypes;
57073
57057
  }
57074
- var init_ooxml = () => {};
57058
+ var init_ooxml = __esm(() => {
57059
+ init_table_style_selection();
57060
+ });
57075
57061
 
57076
57062
  // ../../packages/super-editor/src/core/super-converter/v3/handlers/wp/helpers/textbox-content-helpers.js
57077
57063
  function collectTextBoxParagraphs(nodes, paragraphs = []) {
@@ -60529,7 +60515,6 @@ var validXmlAttributes9, XML_NODE_NAME16 = "w:tbl", SD_NODE_NAME12 = "table", IN
60529
60515
  };
60530
60516
  }
60531
60517
  }
60532
- const tableLook = encodedAttrs.tableProperties.tblLook;
60533
60518
  const borderProps = _processTableBorders(encodedAttrs.tableProperties.borders || {});
60534
60519
  const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2) || {};
60535
60520
  encodedAttrs.borders = { ...referencedStyles.borders, ...borderProps };
@@ -60577,8 +60562,6 @@ var validXmlAttributes9, XML_NODE_NAME16 = "w:tbl", SD_NODE_NAME12 = "table", IN
60577
60562
  row,
60578
60563
  table: node3,
60579
60564
  tableProperties: encodedAttrs.tableProperties,
60580
- tableBorders: encodedAttrs.borders,
60581
- tableLook,
60582
60565
  columnWidths,
60583
60566
  activeRowSpans: activeRowSpans.slice(),
60584
60567
  rowIndex,
@@ -66808,7 +66791,7 @@ function translateContentBlock(params2) {
66808
66791
  return wrapTextInRun(alternateContent);
66809
66792
  }
66810
66793
  function pxToPt(px) {
66811
- const pt = Math.round(px / PX_PER_PT * 10) / 10;
66794
+ const pt = Math.round(px / PX_PER_PT2 * 10) / 10;
66812
66795
  return `${pt}pt`;
66813
66796
  }
66814
66797
  function sizeToPt(value, options = {}) {
@@ -66911,7 +66894,7 @@ function translateVRectContentBlock(params2) {
66911
66894
  };
66912
66895
  return wrapTextInRun(pict);
66913
66896
  }
66914
- var FULL_WIDTH_PT = "468pt", FULL_WIDTH_PT_VALUE = 468, PX_PER_PT = 1.33;
66897
+ var FULL_WIDTH_PT = "468pt", FULL_WIDTH_PT_VALUE = 468, PX_PER_PT2 = 1.33;
66915
66898
  var init_translate_content_block = __esm(() => {
66916
66899
  init_altermateContent();
66917
66900
  init_exporter();
@@ -69911,21 +69894,6 @@ var init_InputRule = __esm(() => {
69911
69894
  init_google_docs_paste();
69912
69895
  });
69913
69896
 
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
69897
  // ../../packages/super-editor/src/core/helpers/catchAllSchema.js
69930
69898
  function detectUnsupportedContent(element, schema) {
69931
69899
  const itemsByTag = new Map;
@@ -70037,46 +70005,9 @@ function createDocFromHTML(content3, editor, options = {}) {
70037
70005
  }
70038
70006
  }
70039
70007
  let doc = DOMParser2.fromSchema(editor.schema).parse(parsedContent);
70040
- if (isImport) {
70041
- doc = normalizeImportedHtmlTableHeaders(doc);
70042
- }
70043
70008
  doc = wrapTextsInRuns(doc);
70044
70009
  return doc;
70045
70010
  }
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
70011
  var init_importHtml = __esm(() => {
70081
70012
  init_dist();
70082
70013
  init_InputRule();
@@ -70893,7 +70824,8 @@ function convertTable(node3, ctx) {
70893
70824
  return {
70894
70825
  type: "table",
70895
70826
  attrs: {
70896
- tableStyleId: "TableGrid",
70827
+ tableStyleId: null,
70828
+ needsTableStyleNormalization: true,
70897
70829
  tableProperties: {
70898
70830
  tableWidth: {
70899
70831
  value: FULL_WIDTH_TABLE_PCT,
@@ -76665,6 +76597,103 @@ var init_table_target_resolver = __esm(() => {
76665
76597
  init_errors3();
76666
76598
  });
76667
76599
 
76600
+ // ../../packages/super-editor/src/document-api-adapters/document-settings.ts
76601
+ function createSettingsPart() {
76602
+ return {
76603
+ type: "element",
76604
+ name: "document",
76605
+ elements: [
76606
+ {
76607
+ type: "element",
76608
+ name: "w:settings",
76609
+ elements: []
76610
+ }
76611
+ ]
76612
+ };
76613
+ }
76614
+ function findSettingsRoot(part) {
76615
+ if (part.name === "w:settings")
76616
+ return part;
76617
+ if (!Array.isArray(part.elements))
76618
+ return null;
76619
+ return part.elements.find((entry) => entry.name === "w:settings") ?? null;
76620
+ }
76621
+ function ensureSettingsRootElements(settingsRoot) {
76622
+ if (!Array.isArray(settingsRoot.elements))
76623
+ settingsRoot.elements = [];
76624
+ return settingsRoot.elements;
76625
+ }
76626
+ function readSettingsRoot(converter) {
76627
+ const part = converter.convertedXml?.[SETTINGS_PART_PATH];
76628
+ if (!part)
76629
+ return null;
76630
+ return findSettingsRoot(part);
76631
+ }
76632
+ function ensureSettingsRoot(converter) {
76633
+ if (!converter.convertedXml)
76634
+ converter.convertedXml = {};
76635
+ let part = converter.convertedXml[SETTINGS_PART_PATH];
76636
+ if (!part) {
76637
+ part = createSettingsPart();
76638
+ converter.convertedXml[SETTINGS_PART_PATH] = part;
76639
+ }
76640
+ const settingsRoot = findSettingsRoot(part);
76641
+ if (settingsRoot)
76642
+ return settingsRoot;
76643
+ const fallbackRoot = {
76644
+ type: "element",
76645
+ name: "w:settings",
76646
+ elements: []
76647
+ };
76648
+ if (!Array.isArray(part.elements))
76649
+ part.elements = [];
76650
+ part.elements.push(fallbackRoot);
76651
+ return fallbackRoot;
76652
+ }
76653
+ function readDefaultTableStyle(settingsRoot) {
76654
+ const el = settingsRoot.elements?.find((entry) => entry.name === "w:defaultTableStyle");
76655
+ if (!el)
76656
+ return null;
76657
+ const val = el.attributes?.["w:val"];
76658
+ return typeof val === "string" && val.length > 0 ? val : null;
76659
+ }
76660
+ function setDefaultTableStyle(settingsRoot, styleId) {
76661
+ const elements = ensureSettingsRootElements(settingsRoot);
76662
+ const idx = elements.findIndex((entry) => entry.name === "w:defaultTableStyle");
76663
+ const newEl = {
76664
+ type: "element",
76665
+ name: "w:defaultTableStyle",
76666
+ attributes: { "w:val": styleId },
76667
+ elements: []
76668
+ };
76669
+ if (idx !== -1) {
76670
+ elements[idx] = newEl;
76671
+ } else {
76672
+ elements.push(newEl);
76673
+ }
76674
+ }
76675
+ function removeDefaultTableStyle(settingsRoot) {
76676
+ const elements = ensureSettingsRootElements(settingsRoot);
76677
+ settingsRoot.elements = elements.filter((entry) => entry.name !== "w:defaultTableStyle");
76678
+ }
76679
+ function hasOddEvenHeadersFooters(settingsRoot) {
76680
+ return settingsRoot.elements?.some((entry) => entry.name === "w:evenAndOddHeaders") === true;
76681
+ }
76682
+ function setOddEvenHeadersFooters(settingsRoot, enabled) {
76683
+ const elements = ensureSettingsRootElements(settingsRoot);
76684
+ const hadFlag = hasOddEvenHeadersFooters(settingsRoot);
76685
+ if (enabled) {
76686
+ if (!hadFlag) {
76687
+ elements.push({ type: "element", name: "w:evenAndOddHeaders", elements: [] });
76688
+ }
76689
+ } else {
76690
+ settingsRoot.elements = elements.filter((entry) => entry.name !== "w:evenAndOddHeaders");
76691
+ }
76692
+ const hasFlag = hasOddEvenHeadersFooters(settingsRoot);
76693
+ return hadFlag !== hasFlag;
76694
+ }
76695
+ var SETTINGS_PART_PATH = "word/settings.xml";
76696
+
76668
76697
  // ../../packages/super-editor/src/document-api-adapters/tables-adapter.ts
76669
76698
  function generateParaId() {
76670
76699
  return Array.from({ length: 8 }, () => Math.floor(Math.random() * 16).toString(16)).join("").toUpperCase();
@@ -76862,12 +76891,11 @@ function cellSidesForEdge(edge, row, col, lastRow, lastCol) {
76862
76891
  function tableBorderToCellBorder(border) {
76863
76892
  const val = typeof border.val === "string" ? border.val : "single";
76864
76893
  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;
76894
+ const size2 = typeof border.size === "number" ? border.size : 0;
76867
76895
  return {
76868
76896
  val,
76869
76897
  color: color2,
76870
- size: sizePx,
76898
+ size: val === "none" || val === "nil" ? 0 : size2,
76871
76899
  space: 0
76872
76900
  };
76873
76901
  }
@@ -76892,13 +76920,16 @@ function applyTableEdgeToCellBorders(tr, tablePos, tableNode, edge, borderSpec)
76892
76920
  if (!cellNode)
76893
76921
  continue;
76894
76922
  const cellAttrs = cellNode.attrs;
76895
- const borders = { ...cellAttrs.borders ?? {} };
76923
+ const tcp = { ...cellAttrs.tableCellProperties ?? {} };
76924
+ const borders = { ...tcp.borders ?? {} };
76896
76925
  for (const side of targetSides) {
76897
76926
  borders[side] = { ...cellBorder };
76898
76927
  }
76928
+ tcp.borders = borders;
76899
76929
  tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(tableStart + relPos), null, {
76900
76930
  ...cellAttrs,
76901
- borders
76931
+ borders: null,
76932
+ tableCellProperties: tcp
76902
76933
  });
76903
76934
  }
76904
76935
  }
@@ -76924,7 +76955,8 @@ function applyTableBorderPresetToCellBorders(tr, tablePos, tableNode, preset) {
76924
76955
  if (!cellNode)
76925
76956
  continue;
76926
76957
  const cellAttrs = cellNode.attrs;
76927
- const borders = { ...cellAttrs.borders ?? {} };
76958
+ const tcp = { ...cellAttrs.tableCellProperties ?? {} };
76959
+ const borders = { ...tcp.borders ?? {} };
76928
76960
  if (preset === "none") {
76929
76961
  borders.top = { ...noneBorder };
76930
76962
  borders.bottom = { ...noneBorder };
@@ -76941,9 +76973,11 @@ function applyTableBorderPresetToCellBorders(tr, tablePos, tableNode, preset) {
76941
76973
  borders.left = { ...singleBorder };
76942
76974
  borders.right = { ...singleBorder };
76943
76975
  }
76976
+ tcp.borders = borders;
76944
76977
  tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(tableStart + relPos), null, {
76945
76978
  ...cellAttrs,
76946
- borders
76979
+ borders: null,
76980
+ tableCellProperties: tcp
76947
76981
  });
76948
76982
  }
76949
76983
  }
@@ -78587,7 +78621,8 @@ function tablesSetBorderAdapter(editor, input, options) {
78587
78621
  };
78588
78622
  currentProps.borders = currentBorders;
78589
78623
  const syncAttrs = resolved.scope === "table" ? syncExtractedTableAttrs(currentProps) : {};
78590
- tr.setNodeMarkup(resolved.pos, null, { ...currentAttrs, [propsKey]: currentProps, ...syncAttrs });
78624
+ const cellClear = resolved.scope === "cell" ? { borders: null } : {};
78625
+ tr.setNodeMarkup(resolved.pos, null, { ...currentAttrs, [propsKey]: currentProps, ...syncAttrs, ...cellClear });
78591
78626
  if (resolved.scope === "table" && isBoundaryEdge(input.edge)) {
78592
78627
  applyTableEdgeToCellBorders(tr, resolved.pos, resolved.node, input.edge, currentBorders[input.edge]);
78593
78628
  }
@@ -78617,7 +78652,8 @@ function tablesClearBorderAdapter(editor, input, options) {
78617
78652
  currentBorders[input.edge] = { val: "nil", size: 0, color: "auto" };
78618
78653
  currentProps.borders = currentBorders;
78619
78654
  const syncAttrs = resolved.scope === "table" ? syncExtractedTableAttrs(currentProps) : {};
78620
- tr.setNodeMarkup(resolved.pos, null, { ...currentAttrs, [propsKey]: currentProps, ...syncAttrs });
78655
+ const cellClear = resolved.scope === "cell" ? { borders: null } : {};
78656
+ tr.setNodeMarkup(resolved.pos, null, { ...currentAttrs, [propsKey]: currentProps, ...syncAttrs, ...cellClear });
78621
78657
  if (resolved.scope === "table" && isBoundaryEdge(input.edge)) {
78622
78658
  applyTableEdgeToCellBorders(tr, resolved.pos, resolved.node, input.edge, currentBorders[input.edge]);
78623
78659
  }
@@ -79130,6 +79166,118 @@ function tablesGetPropertiesAdapter(editor, input) {
79130
79166
  }
79131
79167
  return result;
79132
79168
  }
79169
+ function getConverterForStyles(editor) {
79170
+ return editor.converter;
79171
+ }
79172
+ function toDocumentMutationFailure(code4, message) {
79173
+ return {
79174
+ success: false,
79175
+ failure: { code: code4, message }
79176
+ };
79177
+ }
79178
+ function toDocumentMutationSuccess() {
79179
+ return { success: true };
79180
+ }
79181
+ function tablesGetStylesAdapter(editor, _input) {
79182
+ const converter = getConverterForStyles(editor);
79183
+ if (!converter) {
79184
+ return {
79185
+ explicitDefaultStyleId: null,
79186
+ effectiveDefaultStyleId: null,
79187
+ effectiveDefaultSource: "none",
79188
+ styles: []
79189
+ };
79190
+ }
79191
+ const translatedLinkedStyles = converter.translatedLinkedStyles ?? null;
79192
+ const allStyles = translatedLinkedStyles?.styles ?? {};
79193
+ const styles = [];
79194
+ for (const [id2, def] of Object.entries(allStyles)) {
79195
+ if (def.type !== "table")
79196
+ continue;
79197
+ styles.push({
79198
+ id: id2,
79199
+ name: def.name ?? null,
79200
+ basedOn: def.basedOn ?? null,
79201
+ isDefault: def.default === true,
79202
+ isCustom: def.customStyle === true,
79203
+ uiPriority: def.uiPriority ?? null,
79204
+ hidden: def.hidden === true || def.semiHidden === true,
79205
+ quickFormat: def.qFormat === true,
79206
+ conditionalRegions: def.tableStyleProperties ? Object.keys(def.tableStyleProperties) : []
79207
+ });
79208
+ }
79209
+ let explicitDefaultStyleId = null;
79210
+ const settingsRoot = readSettingsRoot(converter);
79211
+ if (settingsRoot) {
79212
+ explicitDefaultStyleId = readDefaultTableStyle(settingsRoot);
79213
+ }
79214
+ const resolved = resolvePreferredNewTableStyleId(explicitDefaultStyleId, translatedLinkedStyles);
79215
+ return {
79216
+ explicitDefaultStyleId,
79217
+ effectiveDefaultStyleId: resolved.styleId,
79218
+ effectiveDefaultSource: resolved.source,
79219
+ styles
79220
+ };
79221
+ }
79222
+ function tablesSetDefaultStyleAdapter(editor, input, options) {
79223
+ rejectTrackedMode("tables.setDefaultStyle", options);
79224
+ const converter = getConverterForStyles(editor);
79225
+ if (!converter) {
79226
+ throw new DocumentApiAdapterError("CAPABILITY_UNAVAILABLE", "tables.setDefaultStyle requires an active document converter.");
79227
+ }
79228
+ if (!isKnownTableStyleId(input.styleId, converter.translatedLinkedStyles)) {
79229
+ throw new DocumentApiAdapterError("INVALID_INPUT", `tables.setDefaultStyle: "${input.styleId}" is not a known table style.`);
79230
+ }
79231
+ return executeOutOfBandMutation(editor, (dryRun) => {
79232
+ const existingRoot = readSettingsRoot(converter);
79233
+ const current = existingRoot ? readDefaultTableStyle(existingRoot) : null;
79234
+ if (current === input.styleId) {
79235
+ return {
79236
+ changed: false,
79237
+ payload: toDocumentMutationFailure("NO_OP", "tables.setDefaultStyle did not produce a document settings change.")
79238
+ };
79239
+ }
79240
+ if (!dryRun) {
79241
+ const settingsRoot = ensureSettingsRoot(converter);
79242
+ setDefaultTableStyle(settingsRoot, input.styleId);
79243
+ }
79244
+ return {
79245
+ changed: true,
79246
+ payload: toDocumentMutationSuccess()
79247
+ };
79248
+ }, {
79249
+ dryRun: options?.dryRun === true,
79250
+ expectedRevision: options?.expectedRevision
79251
+ });
79252
+ }
79253
+ function tablesClearDefaultStyleAdapter(editor, _input, options) {
79254
+ rejectTrackedMode("tables.clearDefaultStyle", options);
79255
+ const converter = getConverterForStyles(editor);
79256
+ if (!converter) {
79257
+ throw new DocumentApiAdapterError("CAPABILITY_UNAVAILABLE", "tables.clearDefaultStyle requires an active document converter.");
79258
+ }
79259
+ return executeOutOfBandMutation(editor, (dryRun) => {
79260
+ const existingRoot = readSettingsRoot(converter);
79261
+ const current = existingRoot ? readDefaultTableStyle(existingRoot) : null;
79262
+ if (current === null) {
79263
+ return {
79264
+ changed: false,
79265
+ payload: toDocumentMutationFailure("NO_OP", "tables.clearDefaultStyle did not produce a document settings change.")
79266
+ };
79267
+ }
79268
+ if (!dryRun) {
79269
+ const settingsRoot = ensureSettingsRoot(converter);
79270
+ removeDefaultTableStyle(settingsRoot);
79271
+ }
79272
+ return {
79273
+ changed: true,
79274
+ payload: toDocumentMutationSuccess()
79275
+ };
79276
+ }, {
79277
+ dryRun: options?.dryRun === true,
79278
+ expectedRevision: options?.expectedRevision
79279
+ });
79280
+ }
79133
79281
  var POINTS_TO_PIXELS, POINTS_TO_TWIPS = 20, PIXELS_TO_TWIPS, DEFAULT_TABLE_GRID_WIDTH_TWIPS = 1500;
79134
79282
  var init_tables_adapter = __esm(() => {
79135
79283
  init_wrapper();
@@ -79141,6 +79289,8 @@ var init_tables_adapter = __esm(() => {
79141
79289
  init_errors3();
79142
79290
  init_node_address_resolver();
79143
79291
  init_helpers();
79292
+ init_ooxml();
79293
+ init_out_of_band_mutation();
79144
79294
  POINTS_TO_PIXELS = 96 / 72;
79145
79295
  PIXELS_TO_TWIPS = 1440 / 96;
79146
79296
  });
@@ -79470,77 +79620,6 @@ var init_create_table_wrapper = __esm(() => {
79470
79620
  init_tables_adapter();
79471
79621
  });
79472
79622
 
79473
- // ../../packages/super-editor/src/document-api-adapters/document-settings.ts
79474
- function createSettingsPart() {
79475
- return {
79476
- type: "element",
79477
- name: "document",
79478
- elements: [
79479
- {
79480
- type: "element",
79481
- name: "w:settings",
79482
- elements: []
79483
- }
79484
- ]
79485
- };
79486
- }
79487
- function findSettingsRoot(part) {
79488
- if (part.name === "w:settings")
79489
- return part;
79490
- if (!Array.isArray(part.elements))
79491
- return null;
79492
- return part.elements.find((entry) => entry.name === "w:settings") ?? null;
79493
- }
79494
- function ensureSettingsRootElements(settingsRoot) {
79495
- if (!Array.isArray(settingsRoot.elements))
79496
- settingsRoot.elements = [];
79497
- return settingsRoot.elements;
79498
- }
79499
- function readSettingsRoot(converter) {
79500
- const part = converter.convertedXml?.[SETTINGS_PART_PATH];
79501
- if (!part)
79502
- return null;
79503
- return findSettingsRoot(part);
79504
- }
79505
- function ensureSettingsRoot(converter) {
79506
- if (!converter.convertedXml)
79507
- converter.convertedXml = {};
79508
- let part = converter.convertedXml[SETTINGS_PART_PATH];
79509
- if (!part) {
79510
- part = createSettingsPart();
79511
- converter.convertedXml[SETTINGS_PART_PATH] = part;
79512
- }
79513
- const settingsRoot = findSettingsRoot(part);
79514
- if (settingsRoot)
79515
- return settingsRoot;
79516
- const fallbackRoot = {
79517
- type: "element",
79518
- name: "w:settings",
79519
- elements: []
79520
- };
79521
- if (!Array.isArray(part.elements))
79522
- part.elements = [];
79523
- part.elements.push(fallbackRoot);
79524
- return fallbackRoot;
79525
- }
79526
- function hasOddEvenHeadersFooters(settingsRoot) {
79527
- return settingsRoot.elements?.some((entry) => entry.name === "w:evenAndOddHeaders") === true;
79528
- }
79529
- function setOddEvenHeadersFooters(settingsRoot, enabled) {
79530
- const elements = ensureSettingsRootElements(settingsRoot);
79531
- const hadFlag = hasOddEvenHeadersFooters(settingsRoot);
79532
- if (enabled) {
79533
- if (!hadFlag) {
79534
- elements.push({ type: "element", name: "w:evenAndOddHeaders", elements: [] });
79535
- }
79536
- } else {
79537
- settingsRoot.elements = elements.filter((entry) => entry.name !== "w:evenAndOddHeaders");
79538
- }
79539
- const hasFlag = hasOddEvenHeadersFooters(settingsRoot);
79540
- return hadFlag !== hasFlag;
79541
- }
79542
- var SETTINGS_PART_PATH = "word/settings.xml";
79543
-
79544
79623
  // ../../packages/layout-engine/pm-adapter/src/sections/types.ts
79545
79624
  var DEFAULT_PARAGRAPH_SECTION_TYPE = "nextPage" /* NEXT_PAGE */, DEFAULT_BODY_SECTION_TYPE = "continuous" /* CONTINUOUS */;
79546
79625
  var init_types5 = () => {};
@@ -82594,7 +82673,10 @@ function assembleDocumentApiAdapters(editor) {
82594
82673
  clearCellSpacing: (input, options) => tablesClearCellSpacingWrapper(editor, input, options),
82595
82674
  get: (input) => tablesGetAdapter(editor, input),
82596
82675
  getCells: (input) => tablesGetCellsAdapter(editor, input),
82597
- getProperties: (input) => tablesGetPropertiesAdapter(editor, input)
82676
+ getProperties: (input) => tablesGetPropertiesAdapter(editor, input),
82677
+ getStyles: (input) => tablesGetStylesAdapter(editor, input),
82678
+ setDefaultStyle: (input, options) => tablesSetDefaultStyleAdapter(editor, input, options),
82679
+ clearDefaultStyle: (input, options) => tablesClearDefaultStyleAdapter(editor, input, options)
82598
82680
  },
82599
82681
  toc: {
82600
82682
  list: (query2) => tocListWrapper(editor, query2),
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.59",
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.59",
33
+ "@superdoc-dev/cli-darwin-x64": "0.2.0-next.59",
34
+ "@superdoc-dev/cli-linux-x64": "0.2.0-next.59",
35
+ "@superdoc-dev/cli-windows-x64": "0.2.0-next.59",
36
+ "@superdoc-dev/cli-linux-arm64": "0.2.0-next.59"
37
37
  },
38
38
  "scripts": {
39
39
  "dev": "bun run src/index.ts",