@superdoc-dev/cli 0.2.0-next.62 → 0.2.0-next.63

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 +330 -144
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -30514,7 +30514,7 @@ var init_remark_gfm_z_sDF4ss_es = __esm(() => {
30514
30514
  emptyOptions2 = {};
30515
30515
  });
30516
30516
 
30517
- // ../../packages/superdoc/dist/chunks/SuperConverter-Ba_l6vso.es.js
30517
+ // ../../packages/superdoc/dist/chunks/SuperConverter-C1hZYQNS.es.js
30518
30518
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
30519
30519
  const fieldValue = extension$1.config[field];
30520
30520
  if (typeof fieldValue === "function")
@@ -34892,21 +34892,56 @@ function resolveDocxFontFamily(attributes, docx, toCssFontFamily) {
34892
34892
  return toCssFontFamily(resolved, docx ?? undefined);
34893
34893
  return resolved;
34894
34894
  }
34895
+ function resolveEffectiveBandSizes(styleId, translatedLinkedStyles) {
34896
+ const seen = /* @__PURE__ */ new Set;
34897
+ let currentId = styleId;
34898
+ let rowBandSize;
34899
+ let colBandSize;
34900
+ while (currentId && !seen.has(currentId)) {
34901
+ seen.add(currentId);
34902
+ const def = translatedLinkedStyles.styles?.[currentId];
34903
+ const tblProps = def?.tableProperties;
34904
+ if (rowBandSize == null && tblProps?.tableStyleRowBandSize != null)
34905
+ rowBandSize = tblProps.tableStyleRowBandSize;
34906
+ if (colBandSize == null && tblProps?.tableStyleColBandSize != null)
34907
+ colBandSize = tblProps.tableStyleColBandSize;
34908
+ if (rowBandSize != null && colBandSize != null)
34909
+ break;
34910
+ currentId = def?.basedOn;
34911
+ }
34912
+ return {
34913
+ rowBandSize: rowBandSize ?? 1,
34914
+ colBandSize: colBandSize ?? 1
34915
+ };
34916
+ }
34917
+ function resolveConditionalProps(propertyType, styleType, styleId, translatedLinkedStyles) {
34918
+ const chain = [];
34919
+ const seen = /* @__PURE__ */ new Set;
34920
+ let currentId = styleId;
34921
+ while (currentId && !seen.has(currentId)) {
34922
+ seen.add(currentId);
34923
+ const def = translatedLinkedStyles.styles?.[currentId];
34924
+ const props = def?.tableStyleProperties?.[styleType]?.[propertyType];
34925
+ if (props)
34926
+ chain.push(props);
34927
+ currentId = def?.basedOn;
34928
+ }
34929
+ if (chain.length === 0)
34930
+ return;
34931
+ chain.reverse();
34932
+ return combineProperties(chain);
34933
+ }
34895
34934
  function resolveCellStyles(propertyType, tableInfo, translatedLinkedStyles) {
34896
34935
  if (tableInfo == null || !tableInfo.tableProperties?.tableStyleId)
34897
34936
  return [];
34898
34937
  const cellStyleProps = [];
34899
- if (tableInfo != null && tableInfo.tableProperties.tableStyleId) {
34900
- const tableStyleDef = translatedLinkedStyles.styles[tableInfo.tableProperties.tableStyleId];
34901
- const tableStylePropsDef = tableStyleDef?.tableProperties;
34902
- const rowBandSize = tableStylePropsDef?.tableStyleRowBandSize ?? 1;
34903
- const colBandSize = tableStylePropsDef?.tableStyleColBandSize ?? 1;
34904
- determineCellStyleTypes(tableInfo.tableProperties?.tblLook, tableInfo.rowIndex, tableInfo.cellIndex, tableInfo.numRows, tableInfo.numCells, rowBandSize, colBandSize).forEach((styleType) => {
34905
- const typeProps = tableStyleDef?.tableStyleProperties?.[styleType]?.[propertyType];
34906
- if (typeProps)
34907
- cellStyleProps.push(typeProps);
34908
- });
34909
- }
34938
+ const tableStyleId = tableInfo.tableProperties.tableStyleId;
34939
+ const { rowBandSize, colBandSize } = resolveEffectiveBandSizes(tableStyleId, translatedLinkedStyles);
34940
+ determineCellStyleTypes(tableInfo.tableProperties?.tblLook ?? DEFAULT_TBL_LOOK, tableInfo.rowIndex, tableInfo.cellIndex, tableInfo.numRows, tableInfo.numCells, rowBandSize, colBandSize, tableInfo.rowCnfStyle, tableInfo.cellCnfStyle).forEach((styleType) => {
34941
+ const typeProps = resolveConditionalProps(propertyType, styleType, tableStyleId, translatedLinkedStyles);
34942
+ if (typeProps)
34943
+ cellStyleProps.push(typeProps);
34944
+ });
34910
34945
  return cellStyleProps;
34911
34946
  }
34912
34947
  function resolveTableCellProperties(inlineProps, tableInfo, translatedLinkedStyles) {
@@ -34920,8 +34955,8 @@ function resolveTableCellProperties(inlineProps, tableInfo, translatedLinkedStyl
34920
34955
  chain.push(inlineProps);
34921
34956
  return combineProperties(chain, { fullOverrideProps: ["shading"] });
34922
34957
  }
34923
- function determineCellStyleTypes(tblLook, rowIndex, cellIndex, numRows, numCells, rowBandSize = 1, colBandSize = 1) {
34924
- const styleTypes = ["wholeTable"];
34958
+ function determineCellStyleTypes(tblLook, rowIndex, cellIndex, numRows, numCells, rowBandSize = 1, colBandSize = 1, rowCnfStyle, cellCnfStyle) {
34959
+ const applicable = new Set(["wholeTable"]);
34925
34960
  const normalizedRowBandSize = rowBandSize > 0 ? rowBandSize : 1;
34926
34961
  const normalizedColBandSize = colBandSize > 0 ? colBandSize : 1;
34927
34962
  const bandRowIndex = Math.max(0, rowIndex - (tblLook?.firstRow ? 1 : 0));
@@ -34929,32 +34964,33 @@ function determineCellStyleTypes(tblLook, rowIndex, cellIndex, numRows, numCells
34929
34964
  const rowGroup = Math.floor(bandRowIndex / normalizedRowBandSize);
34930
34965
  const colGroup = Math.floor(bandColIndex / normalizedColBandSize);
34931
34966
  if (!tblLook?.noHBand)
34932
- if (rowGroup % 2 === 0)
34933
- styleTypes.push("band1Horz");
34934
- else
34935
- styleTypes.push("band2Horz");
34967
+ applicable.add(rowGroup % 2 === 0 ? "band1Horz" : "band2Horz");
34936
34968
  if (!tblLook?.noVBand)
34937
- if (colGroup % 2 === 0)
34938
- styleTypes.push("band1Vert");
34939
- else
34940
- styleTypes.push("band2Vert");
34969
+ applicable.add(colGroup % 2 === 0 ? "band1Vert" : "band2Vert");
34941
34970
  if (tblLook?.firstRow && rowIndex === 0)
34942
- styleTypes.push("firstRow");
34971
+ applicable.add("firstRow");
34943
34972
  if (tblLook?.firstColumn && cellIndex === 0)
34944
- styleTypes.push("firstCol");
34973
+ applicable.add("firstCol");
34945
34974
  if (tblLook?.lastRow && numRows != null && numRows > 0 && rowIndex === numRows - 1)
34946
- styleTypes.push("lastRow");
34975
+ applicable.add("lastRow");
34947
34976
  if (tblLook?.lastColumn && numCells != null && numCells > 0 && cellIndex === numCells - 1)
34948
- styleTypes.push("lastCol");
34977
+ applicable.add("lastCol");
34949
34978
  if (rowIndex === 0 && cellIndex === 0)
34950
- styleTypes.push("nwCell");
34979
+ applicable.add("nwCell");
34951
34980
  if (rowIndex === 0 && numCells != null && numCells > 0 && cellIndex === numCells - 1)
34952
- styleTypes.push("neCell");
34981
+ applicable.add("neCell");
34953
34982
  if (numRows != null && numRows > 0 && rowIndex === numRows - 1 && cellIndex === 0)
34954
- styleTypes.push("swCell");
34983
+ applicable.add("swCell");
34955
34984
  if (numRows != null && numRows > 0 && numCells != null && numCells > 0 && rowIndex === numRows - 1 && cellIndex === numCells - 1)
34956
- styleTypes.push("seCell");
34957
- return styleTypes;
34985
+ applicable.add("seCell");
34986
+ if (rowCnfStyle || cellCnfStyle)
34987
+ for (const [flag, styleType] of CNF_STYLE_MAP) {
34988
+ const rowFlag = rowCnfStyle?.[flag];
34989
+ const cellFlag = cellCnfStyle?.[flag];
34990
+ if (rowFlag === true || cellFlag === true)
34991
+ applicable.add(styleType);
34992
+ }
34993
+ return TABLE_STYLE_PRECEDENCE.filter((t) => applicable.has(t));
34958
34994
  }
34959
34995
  function encodeMarksFromRPr(runProperties, docx) {
34960
34996
  if (!runProperties || typeof runProperties !== "object")
@@ -49782,7 +49818,7 @@ var isRegExp = (value) => {
49782
49818
  return true;
49783
49819
  }, areAttrsEqual = (attrsA = {}, attrsB = {}) => {
49784
49820
  return objectIncludes(attrsA, attrsB);
49785
- }, TrackInsertMarkName = "trackInsert", TrackDeleteMarkName = "trackDelete", TrackFormatMarkName = "trackFormat", TABLE_STYLE_ID_TABLE_GRID = "TableGrid", TABLE_FALLBACK_BORDER, TABLE_FALLBACK_BORDERS, TABLE_FALLBACK_CELL_PADDING, getToCssFontFamily = () => {
49821
+ }, TrackInsertMarkName = "trackInsert", TrackDeleteMarkName = "trackDelete", TrackFormatMarkName = "trackFormat", TABLE_STYLE_ID_TABLE_GRID = "TableGrid", TABLE_FALLBACK_BORDER, TABLE_FALLBACK_BORDERS, TABLE_FALLBACK_CELL_PADDING, DEFAULT_TBL_LOOK, CNF_STYLE_MAP, TABLE_STYLE_PRECEDENCE, getToCssFontFamily = () => {
49786
49822
  return SuperConverter.toCssFontFamily;
49787
49823
  }, SUBSCRIPT_SUPERSCRIPT_SCALE = 0.65, getSpacingStyle = (spacing, isListItem) => {
49788
49824
  let { before, after, line, lineRule, beforeAutospacing, afterAutospacing } = spacing;
@@ -60887,7 +60923,7 @@ var isRegExp = (value) => {
60887
60923
  state.kern = kernNode.attributes["w:val"];
60888
60924
  }
60889
60925
  }, SuperConverter;
60890
- var init_SuperConverter_Ba_l6vso_es = __esm(() => {
60926
+ var init_SuperConverter_C1hZYQNS_es = __esm(() => {
60891
60927
  init_rolldown_runtime_B2q5OVn9_es();
60892
60928
  init_jszip_ChlR43oI_es();
60893
60929
  init_xml_js_DLE8mr0n_es();
@@ -69073,6 +69109,43 @@ var init_SuperConverter_Ba_l6vso_es = __esm(() => {
69073
69109
  left: 108,
69074
69110
  right: 108
69075
69111
  };
69112
+ DEFAULT_TBL_LOOK = {
69113
+ firstRow: true,
69114
+ lastRow: false,
69115
+ firstColumn: true,
69116
+ lastColumn: false,
69117
+ noHBand: false,
69118
+ noVBand: true
69119
+ };
69120
+ CNF_STYLE_MAP = [
69121
+ ["oddHBand", "band1Horz"],
69122
+ ["evenHBand", "band2Horz"],
69123
+ ["oddVBand", "band1Vert"],
69124
+ ["evenVBand", "band2Vert"],
69125
+ ["firstRow", "firstRow"],
69126
+ ["firstColumn", "firstCol"],
69127
+ ["lastRow", "lastRow"],
69128
+ ["lastColumn", "lastCol"],
69129
+ ["firstRowFirstColumn", "nwCell"],
69130
+ ["firstRowLastColumn", "neCell"],
69131
+ ["lastRowFirstColumn", "swCell"],
69132
+ ["lastRowLastColumn", "seCell"]
69133
+ ];
69134
+ TABLE_STYLE_PRECEDENCE = [
69135
+ "wholeTable",
69136
+ "band1Horz",
69137
+ "band2Horz",
69138
+ "band1Vert",
69139
+ "band2Vert",
69140
+ "firstCol",
69141
+ "lastCol",
69142
+ "firstRow",
69143
+ "lastRow",
69144
+ "nwCell",
69145
+ "neCell",
69146
+ "swCell",
69147
+ "seCell"
69148
+ ];
69076
69149
  SUPPORTED_ALTERNATE_CONTENT_REQUIRES = new Set([
69077
69150
  "wps",
69078
69151
  "wpg",
@@ -105714,9 +105787,9 @@ var init_remark_gfm_CQ3Jg4PR_es = __esm(() => {
105714
105787
  init_remark_gfm_z_sDF4ss_es();
105715
105788
  });
105716
105789
 
105717
- // ../../packages/superdoc/dist/chunks/src-DarWYxL0.es.js
105718
- var exports_src_DarWYxL0_es = {};
105719
- __export(exports_src_DarWYxL0_es, {
105790
+ // ../../packages/superdoc/dist/chunks/src-B1yNdREj.es.js
105791
+ var exports_src_B1yNdREj_es = {};
105792
+ __export(exports_src_B1yNdREj_es, {
105720
105793
  zt: () => defineMark,
105721
105794
  z: () => cM,
105722
105795
  yt: () => removeAwarenessStates,
@@ -144796,9 +144869,22 @@ function normalizeNewTableAttrs(editor) {
144796
144869
  };
144797
144870
  return {
144798
144871
  tableStyleId: resolved.styleId,
144799
- tableProperties: { tableStyleId: resolved.styleId }
144872
+ tableProperties: {
144873
+ tableStyleId: resolved.styleId,
144874
+ tblLook: { ...DEFAULT_TBL_LOOK }
144875
+ }
144800
144876
  };
144801
144877
  }
144878
+ function computeColumnWidths(editor, columnCount) {
144879
+ const { pageSize = {}, pageMargins = {} } = editor?.converter?.pageStyles ?? {};
144880
+ const { width: pageWidth } = pageSize;
144881
+ const { left: left$1 = 0, right: right$1 = 0 } = pageMargins;
144882
+ if (!pageWidth)
144883
+ return null;
144884
+ const availableWidth = (pageWidth - left$1 - right$1) * 96;
144885
+ const columnWidth = Math.floor(availableWidth / columnCount);
144886
+ return Array(columnCount).fill(columnWidth);
144887
+ }
144802
144888
  function cellAround($pos) {
144803
144889
  for (let d = $pos.depth - 1;d > 0; d--)
144804
144890
  if ($pos.node(d).type.spec.tableRole == "row")
@@ -167173,21 +167259,6 @@ var Node$13 = class Node$14 {
167173
167259
  if (history$1 != null)
167174
167260
  link2.history = history$1;
167175
167261
  return link2;
167176
- }, TRACK_INSERT_MARK = "trackInsert", TRACK_DELETE_MARK = "trackDelete", TRACK_FORMAT_MARK = "trackFormat", TRACK_CHANGE_KIND_MAP, TRACK_CHANGE_PRIORITY, MAX_RUN_MARK_JSON_LENGTH = 1e4, MAX_RUN_MARK_ARRAY_LENGTH = 100, MAX_RUN_MARK_DEPTH = 5, RANDOM_ID_LENGTH = 9, generateRandomBase36Id = (length$1) => {
167177
- let randomId = "";
167178
- while (randomId.length < length$1)
167179
- randomId += Math.random().toString(36).slice(2);
167180
- return randomId.slice(0, length$1);
167181
- }, validateDepth = (obj, currentDepth = 0) => {
167182
- if (currentDepth > MAX_RUN_MARK_DEPTH)
167183
- return false;
167184
- if (obj && typeof obj === "object") {
167185
- const values = Array.isArray(obj) ? obj : Object.values(obj);
167186
- for (const value of values)
167187
- if (!validateDepth(value, currentDepth + 1))
167188
- return false;
167189
- }
167190
- return true;
167191
167262
  }, parseThemePercentage = (value) => {
167192
167263
  if (typeof value !== "string")
167193
167264
  return;
@@ -167198,13 +167269,13 @@ var Node$13 = class Node$14 {
167198
167269
  if (Number.isNaN(parsed))
167199
167270
  return;
167200
167271
  return Math.max(0, Math.min(parsed / 255, 1));
167201
- }, expandHex = (hex$1) => {
167272
+ }, expandHex$1 = (hex$1) => {
167202
167273
  const normalized = hex$1.replace("#", "");
167203
167274
  if (normalized.length === 3)
167204
167275
  return normalized.split("").map((char) => char + char).join("");
167205
167276
  return normalized;
167206
- }, hexToRgb2 = (hex$1) => {
167207
- const cleaned = expandHex(hex$1);
167277
+ }, hexToRgb$1 = (hex$1) => {
167278
+ const cleaned = expandHex$1(hex$1);
167208
167279
  if (cleaned.length !== 6)
167209
167280
  return null;
167210
167281
  const r$1 = Number.parseInt(cleaned.slice(0, 2), 16);
@@ -167227,7 +167298,7 @@ var Node$13 = class Node$14 {
167227
167298
  };
167228
167299
  return `#${toHex$1(value.r)}${toHex$1(value.g)}${toHex$1(value.b)}`;
167229
167300
  }, applyThemeTint = (baseHex, ratio) => {
167230
- const rgb = hexToRgb2(baseHex);
167301
+ const rgb = hexToRgb$1(baseHex);
167231
167302
  if (!rgb)
167232
167303
  return baseHex;
167233
167304
  return rgbToHex2({
@@ -167236,7 +167307,7 @@ var Node$13 = class Node$14 {
167236
167307
  b: Math.round(rgb.b + (255 - rgb.b) * ratio)
167237
167308
  });
167238
167309
  }, applyThemeShade = (baseHex, ratio) => {
167239
- const rgb = hexToRgb2(baseHex);
167310
+ const rgb = hexToRgb$1(baseHex);
167240
167311
  if (!rgb)
167241
167312
  return baseHex;
167242
167313
  return rgbToHex2({
@@ -167244,6 +167315,59 @@ var Node$13 = class Node$14 {
167244
167315
  g: Math.round(rgb.g * ratio),
167245
167316
  b: Math.round(rgb.b * ratio)
167246
167317
  });
167318
+ }, resolveThemeColorValue = (themeKey, tint, shade, themeColors) => {
167319
+ const key$1 = themeKey.trim();
167320
+ if (!key$1)
167321
+ return;
167322
+ const base$2 = themeColors[key$1];
167323
+ if (!base$2)
167324
+ return;
167325
+ let computed$12 = base$2;
167326
+ const tintRatio = parseThemePercentage(tint);
167327
+ const shadeRatio = parseThemePercentage(shade);
167328
+ if (tintRatio != null)
167329
+ computed$12 = applyThemeTint(computed$12, tintRatio);
167330
+ if (shadeRatio != null)
167331
+ computed$12 = applyThemeShade(computed$12, shadeRatio);
167332
+ return computed$12;
167333
+ }, TRACK_INSERT_MARK = "trackInsert", TRACK_DELETE_MARK = "trackDelete", TRACK_FORMAT_MARK = "trackFormat", TRACK_CHANGE_KIND_MAP, TRACK_CHANGE_PRIORITY, MAX_RUN_MARK_JSON_LENGTH = 1e4, MAX_RUN_MARK_ARRAY_LENGTH = 100, MAX_RUN_MARK_DEPTH = 5, RANDOM_ID_LENGTH = 9, generateRandomBase36Id = (length$1) => {
167334
+ let randomId = "";
167335
+ while (randomId.length < length$1)
167336
+ randomId += Math.random().toString(36).slice(2);
167337
+ return randomId.slice(0, length$1);
167338
+ }, validateDepth = (obj, currentDepth = 0) => {
167339
+ if (currentDepth > MAX_RUN_MARK_DEPTH)
167340
+ return false;
167341
+ if (obj && typeof obj === "object") {
167342
+ const values = Array.isArray(obj) ? obj : Object.values(obj);
167343
+ for (const value of values)
167344
+ if (!validateDepth(value, currentDepth + 1))
167345
+ return false;
167346
+ }
167347
+ return true;
167348
+ }, expandHex = (hex$1) => {
167349
+ const normalized = hex$1.replace("#", "");
167350
+ if (normalized.length === 3)
167351
+ return normalized.split("").map((char) => char + char).join("");
167352
+ return normalized;
167353
+ }, hexToRgb2 = (hex$1) => {
167354
+ const cleaned = expandHex(hex$1);
167355
+ if (cleaned.length !== 6)
167356
+ return null;
167357
+ const r$1 = Number.parseInt(cleaned.slice(0, 2), 16);
167358
+ const g$1 = Number.parseInt(cleaned.slice(2, 4), 16);
167359
+ const b$1 = Number.parseInt(cleaned.slice(4, 6), 16);
167360
+ if ([
167361
+ r$1,
167362
+ g$1,
167363
+ b$1
167364
+ ].some((channel) => Number.isNaN(channel)))
167365
+ return null;
167366
+ return {
167367
+ r: r$1,
167368
+ g: g$1,
167369
+ b: b$1
167370
+ };
167247
167371
  }, getLuminance = (hexColor) => {
167248
167372
  const rgb = hexToRgb2(hexColor);
167249
167373
  if (!rgb)
@@ -167264,20 +167388,7 @@ var Node$13 = class Node$14 {
167264
167388
  const rawKey = attrs.themeColor;
167265
167389
  if (typeof rawKey !== "string")
167266
167390
  return;
167267
- const key$1 = rawKey.trim();
167268
- if (!key$1)
167269
- return;
167270
- const base$2 = themeColors[key$1];
167271
- if (!base$2)
167272
- return;
167273
- const tint = parseThemePercentage(attrs.themeTint);
167274
- const shade = parseThemePercentage(attrs.themeShade);
167275
- let computed$12 = base$2;
167276
- if (tint != null)
167277
- computed$12 = applyThemeTint(computed$12, tint);
167278
- if (shade != null)
167279
- computed$12 = applyThemeShade(computed$12, shade);
167280
- return computed$12;
167391
+ return resolveThemeColorValue(rawKey, attrs.themeTint, attrs.themeShade, themeColors);
167281
167392
  }, resolveColorFromAttributes = (attrs, themeColors) => {
167282
167393
  if (!attrs)
167283
167394
  return;
@@ -168102,14 +168213,19 @@ var Node$13 = class Node$14 {
168102
168213
  if (!isTableCellNode(cellNode) || !Array.isArray(cellNode.content))
168103
168214
  return null;
168104
168215
  const blocks2 = [];
168105
- const inlineTcProps = cellNode.attrs?.tableCellProperties;
168106
- const resolvedTcProps = resolveTableCellProperties(inlineTcProps, tableProperties ? {
168216
+ const rowCnfStyle = args$1.rowCnfStyle ?? null;
168217
+ const cellCnfStyle = cellNode.attrs?.tableCellProperties?.cnfStyle ?? null;
168218
+ const tableInfo = tableProperties ? {
168107
168219
  tableProperties,
168108
168220
  rowIndex,
168109
168221
  cellIndex,
168110
168222
  numCells,
168111
- numRows
168112
- } : undefined, context.converterContext?.translatedLinkedStyles);
168223
+ numRows,
168224
+ rowCnfStyle,
168225
+ cellCnfStyle
168226
+ } : undefined;
168227
+ const inlineTcProps = cellNode.attrs?.tableCellProperties;
168228
+ const resolvedTcProps = resolveTableCellProperties(inlineTcProps, tableInfo, context.converterContext?.translatedLinkedStyles);
168113
168229
  const cellBackground = cellNode.attrs?.background;
168114
168230
  let cellBackgroundColor;
168115
168231
  if (cellBackground && typeof cellBackground.color === "string") {
@@ -168120,20 +168236,20 @@ var Node$13 = class Node$14 {
168120
168236
  cellBackgroundColor = normalized;
168121
168237
  }
168122
168238
  }
168123
- if (!cellBackgroundColor && resolvedTcProps?.shading?.fill) {
168124
- const fill = resolvedTcProps.shading.fill;
168125
- if (fill !== "auto")
168126
- cellBackgroundColor = fill.startsWith("#") ? fill : `#${fill}`;
168239
+ if (!cellBackgroundColor && resolvedTcProps?.shading) {
168240
+ const { fill, themeFill, themeFillTint, themeFillShade } = resolvedTcProps.shading;
168241
+ const normalizedFill = normalizeShadingColor(fill);
168242
+ if (normalizedFill)
168243
+ cellBackgroundColor = normalizedFill;
168244
+ else if (themeFill && context.themeColors) {
168245
+ const normalizedTheme = normalizeShadingColor(resolveThemeColorValue(themeFill, themeFillTint, themeFillShade, context.themeColors));
168246
+ if (normalizedTheme)
168247
+ cellBackgroundColor = normalizedTheme;
168248
+ }
168127
168249
  }
168128
- const cellConverterContext = tableProperties || cellBackgroundColor ? {
168250
+ const cellConverterContext = tableInfo || cellBackgroundColor ? {
168129
168251
  ...context.converterContext,
168130
- ...tableProperties && { tableInfo: {
168131
- tableProperties,
168132
- rowIndex,
168133
- cellIndex,
168134
- numCells,
168135
- numRows
168136
- } },
168252
+ ...tableInfo && { tableInfo },
168137
168253
  ...cellBackgroundColor && { backgroundColor: cellBackgroundColor }
168138
168254
  } : context.converterContext;
168139
168255
  const paragraphToFlowBlocks$1 = context.converters.paragraphToFlowBlocks;
@@ -168328,6 +168444,7 @@ var Node$13 = class Node$14 {
168328
168444
  if (!isTableRowNode(rowNode) || !Array.isArray(rowNode.content))
168329
168445
  return null;
168330
168446
  const cells = [];
168447
+ const rowCnfStyle = rowNode.attrs?.tableRowProperties?.cnfStyle;
168331
168448
  rowNode.content.forEach((cellNode, cellIndex) => {
168332
168449
  const parsedCell = parseTableCell({
168333
168450
  cellNode,
@@ -168337,7 +168454,8 @@ var Node$13 = class Node$14 {
168337
168454
  defaultCellPadding,
168338
168455
  tableProperties,
168339
168456
  numCells: rowNode?.content?.length || 1,
168340
- numRows
168457
+ numRows,
168458
+ rowCnfStyle
168341
168459
  });
168342
168460
  if (parsedCell)
168343
168461
  cells.push(parsedCell);
@@ -180015,9 +180133,9 @@ var Node$13 = class Node$14 {
180015
180133
  trackedChanges: context.trackedChanges ?? []
180016
180134
  });
180017
180135
  }, _hoisted_1$6, _hoisted_2$2, _hoisted_3, _hoisted_4, ContextMenu_default, _hoisted_1$5, BasicUpload_default, _hoisted_1$4, MIN_WIDTH = 200, PPI = 96, alignment = "flex-end", Ruler_default, GenericPopover_default, _hoisted_1$3, _hoisted_2$1, RESIZE_HANDLE_WIDTH_PX = 9, RESIZE_HANDLE_HEIGHT_PX = 9, RESIZE_HANDLE_OFFSET_PX = 4, DRAG_OVERLAY_EXTENSION_PX = 1000, MIN_DRAG_OVERLAY_WIDTH_PX = 2000, THROTTLE_INTERVAL_MS = 16, MIN_RESIZE_DELTA_PX = 1, TableResizeOverlay_default, _hoisted_1$2, OVERLAY_EXPANSION_PX = 2000, RESIZE_HANDLE_SIZE_PX = 12, MOUSE_MOVE_THROTTLE_MS = 16, DIMENSION_CHANGE_THRESHOLD_PX = 1, Z_INDEX_OVERLAY = 10, Z_INDEX_HANDLE = 15, Z_INDEX_GUIDELINE = 20, ImageResizeOverlay_default, LINK_CLICK_DEBOUNCE_MS = 300, CURSOR_UPDATE_TIMEOUT_MS = 10, POPOVER_VERTICAL_OFFSET_PX = 15, LinkClickHandler_default, _hoisted_1$1, _hoisted_2, DOCX2 = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", TABLE_RESIZE_HOVER_THRESHOLD = 8, TABLE_RESIZE_THROTTLE_MS = 16, SuperEditor_default, _hoisted_1, SuperInput_default, SlashMenu, Extensions;
180018
- var init_src_DarWYxL0_es = __esm(() => {
180136
+ var init_src_B1yNdREj_es = __esm(() => {
180019
180137
  init_rolldown_runtime_B2q5OVn9_es();
180020
- init_SuperConverter_Ba_l6vso_es();
180138
+ init_SuperConverter_C1hZYQNS_es();
180021
180139
  init_jszip_ChlR43oI_es();
180022
180140
  init_uuid_2IzDu5nl_es();
180023
180141
  init_constants_CqvgVEDh_es();
@@ -203532,17 +203650,7 @@ function print() { __p += __j.call(arguments, '') }
203532
203650
  }).run();
203533
203651
  },
203534
203652
  insertTable: ({ rows = 3, cols = 3, withHeaderRow = false, columnWidths = null } = {}) => ({ tr, dispatch, editor }) => {
203535
- let widths = columnWidths;
203536
- if (!widths) {
203537
- const { pageSize = {}, pageMargins = {} } = editor.converter?.pageStyles ?? {};
203538
- const { width: pageWidth } = pageSize;
203539
- const { left: left$1 = 0, right: right$1 = 0 } = pageMargins;
203540
- if (pageWidth) {
203541
- const availableWidth = (pageWidth - left$1 - right$1) * 96;
203542
- const columnWidth = Math.floor(availableWidth / cols);
203543
- widths = Array(cols).fill(columnWidth);
203544
- }
203545
- }
203653
+ const widths = columnWidths ?? computeColumnWidths(editor, cols);
203546
203654
  const resolved = normalizeNewTableAttrs(editor);
203547
203655
  const tableAttrs = {
203548
203656
  ...resolved.tableStyleId ? { tableStyleId: resolved.tableStyleId } : {},
@@ -203572,11 +203680,16 @@ function print() { __p += __j.call(arguments, '') }
203572
203680
  return false;
203573
203681
  try {
203574
203682
  const genParaId = () => Array.from({ length: 8 }, () => Math.floor(Math.random() * 16).toString(16)).join("").toUpperCase();
203683
+ const widths = computeColumnWidths(editor, columns);
203575
203684
  const rowNodes = [];
203576
203685
  for (let r$1 = 0;r$1 < rows; r$1++) {
203577
203686
  const cellNodes = [];
203578
203687
  for (let c$3 = 0;c$3 < columns; c$3++) {
203579
- const cell2 = tableCellType.createAndFill({ paraId: genParaId() });
203688
+ const cellAttrs = {
203689
+ paraId: genParaId(),
203690
+ ...widths ? { colwidth: [widths[c$3]] } : {}
203691
+ };
203692
+ const cell2 = tableCellType.createAndFill(cellAttrs);
203580
203693
  if (!cell2)
203581
203694
  return false;
203582
203695
  cellNodes.push(cell2);
@@ -211322,8 +211435,8 @@ function print() { __p += __j.call(arguments, '') }
211322
211435
  return isObjectLike_default(value) && hasOwnProperty$8.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
211323
211436
  };
211324
211437
  stubFalse_default = stubFalse;
211325
- freeExports$2 = typeof exports_src_DarWYxL0_es == "object" && exports_src_DarWYxL0_es && !exports_src_DarWYxL0_es.nodeType && exports_src_DarWYxL0_es;
211326
- freeModule$2 = freeExports$2 && typeof module_src_DarWYxL0_es == "object" && module_src_DarWYxL0_es && !module_src_DarWYxL0_es.nodeType && module_src_DarWYxL0_es;
211438
+ freeExports$2 = typeof exports_src_B1yNdREj_es == "object" && exports_src_B1yNdREj_es && !exports_src_B1yNdREj_es.nodeType && exports_src_B1yNdREj_es;
211439
+ freeModule$2 = freeExports$2 && typeof module_src_B1yNdREj_es == "object" && module_src_B1yNdREj_es && !module_src_B1yNdREj_es.nodeType && module_src_B1yNdREj_es;
211327
211440
  Buffer$1 = freeModule$2 && freeModule$2.exports === freeExports$2 ? _root_default.Buffer : undefined;
211328
211441
  isBuffer_default = (Buffer$1 ? Buffer$1.isBuffer : undefined) || stubFalse_default;
211329
211442
  typedArrayTags = {};
@@ -211331,8 +211444,8 @@ function print() { __p += __j.call(arguments, '') }
211331
211444
  typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] = typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] = typedArrayTags[objectTag$3] = typedArrayTags[regexpTag$1] = typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag$1] = false;
211332
211445
  _baseIsTypedArray_default = baseIsTypedArray;
211333
211446
  _baseUnary_default = baseUnary;
211334
- freeExports$1 = typeof exports_src_DarWYxL0_es == "object" && exports_src_DarWYxL0_es && !exports_src_DarWYxL0_es.nodeType && exports_src_DarWYxL0_es;
211335
- freeModule$1 = freeExports$1 && typeof module_src_DarWYxL0_es == "object" && module_src_DarWYxL0_es && !module_src_DarWYxL0_es.nodeType && module_src_DarWYxL0_es;
211447
+ freeExports$1 = typeof exports_src_B1yNdREj_es == "object" && exports_src_B1yNdREj_es && !exports_src_B1yNdREj_es.nodeType && exports_src_B1yNdREj_es;
211448
+ freeModule$1 = freeExports$1 && typeof module_src_B1yNdREj_es == "object" && module_src_B1yNdREj_es && !module_src_B1yNdREj_es.nodeType && module_src_B1yNdREj_es;
211336
211449
  freeProcess = freeModule$1 && freeModule$1.exports === freeExports$1 && _freeGlobal_default.process;
211337
211450
  _nodeUtil_default = function() {
211338
211451
  try {
@@ -211437,8 +211550,8 @@ function print() { __p += __j.call(arguments, '') }
211437
211550
  Stack.prototype.has = _stackHas_default;
211438
211551
  Stack.prototype.set = _stackSet_default;
211439
211552
  _Stack_default = Stack;
211440
- freeExports = typeof exports_src_DarWYxL0_es == "object" && exports_src_DarWYxL0_es && !exports_src_DarWYxL0_es.nodeType && exports_src_DarWYxL0_es;
211441
- freeModule = freeExports && typeof module_src_DarWYxL0_es == "object" && module_src_DarWYxL0_es && !module_src_DarWYxL0_es.nodeType && module_src_DarWYxL0_es;
211553
+ freeExports = typeof exports_src_B1yNdREj_es == "object" && exports_src_B1yNdREj_es && !exports_src_B1yNdREj_es.nodeType && exports_src_B1yNdREj_es;
211554
+ freeModule = freeExports && typeof module_src_B1yNdREj_es == "object" && module_src_B1yNdREj_es && !module_src_B1yNdREj_es.nodeType && module_src_B1yNdREj_es;
211442
211555
  Buffer4 = freeModule && freeModule.exports === freeExports ? _root_default.Buffer : undefined;
211443
211556
  allocUnsafe = Buffer4 ? Buffer4.allocUnsafe : undefined;
211444
211557
  _cloneBuffer_default = cloneBuffer;
@@ -219518,8 +219631,8 @@ var init_zipper_Cnk_HjM2_es = __esm(() => {
219518
219631
 
219519
219632
  // ../../packages/superdoc/dist/super-editor.es.js
219520
219633
  var init_super_editor_es = __esm(() => {
219521
- init_src_DarWYxL0_es();
219522
- init_SuperConverter_Ba_l6vso_es();
219634
+ init_src_B1yNdREj_es();
219635
+ init_SuperConverter_C1hZYQNS_es();
219523
219636
  init_jszip_ChlR43oI_es();
219524
219637
  init_xml_js_DLE8mr0n_es();
219525
219638
  init_constants_CqvgVEDh_es();
@@ -261254,28 +261367,62 @@ function resolveDocxFontFamily2(attributes, docx, toCssFontFamily2) {
261254
261367
  }
261255
261368
  return resolved;
261256
261369
  }
261370
+ function resolveEffectiveBandSizes2(styleId, translatedLinkedStyles) {
261371
+ const seen = new Set;
261372
+ let currentId = styleId;
261373
+ let rowBandSize;
261374
+ let colBandSize;
261375
+ while (currentId && !seen.has(currentId)) {
261376
+ seen.add(currentId);
261377
+ const def2 = translatedLinkedStyles.styles?.[currentId];
261378
+ const tblProps = def2?.tableProperties;
261379
+ if (rowBandSize == null && tblProps?.tableStyleRowBandSize != null) {
261380
+ rowBandSize = tblProps.tableStyleRowBandSize;
261381
+ }
261382
+ if (colBandSize == null && tblProps?.tableStyleColBandSize != null) {
261383
+ colBandSize = tblProps.tableStyleColBandSize;
261384
+ }
261385
+ if (rowBandSize != null && colBandSize != null)
261386
+ break;
261387
+ currentId = def2?.basedOn;
261388
+ }
261389
+ return { rowBandSize: rowBandSize ?? 1, colBandSize: colBandSize ?? 1 };
261390
+ }
261391
+ function resolveConditionalProps2(propertyType, styleType, styleId, translatedLinkedStyles) {
261392
+ const chain = [];
261393
+ const seen = new Set;
261394
+ let currentId = styleId;
261395
+ while (currentId && !seen.has(currentId)) {
261396
+ seen.add(currentId);
261397
+ const def2 = translatedLinkedStyles.styles?.[currentId];
261398
+ const props = def2?.tableStyleProperties?.[styleType]?.[propertyType];
261399
+ if (props)
261400
+ chain.push(props);
261401
+ currentId = def2?.basedOn;
261402
+ }
261403
+ if (chain.length === 0)
261404
+ return;
261405
+ chain.reverse();
261406
+ return combineProperties2(chain);
261407
+ }
261257
261408
  function resolveCellStyles2(propertyType, tableInfo, translatedLinkedStyles) {
261258
261409
  if (tableInfo == null || !tableInfo.tableProperties?.tableStyleId) {
261259
261410
  return [];
261260
261411
  }
261261
261412
  const cellStyleProps = [];
261262
- if (tableInfo != null && tableInfo.tableProperties.tableStyleId) {
261263
- const tableStyleDef = translatedLinkedStyles.styles[tableInfo.tableProperties.tableStyleId];
261264
- const tableStylePropsDef = tableStyleDef?.tableProperties;
261265
- const rowBandSize = tableStylePropsDef?.tableStyleRowBandSize ?? 1;
261266
- const colBandSize = tableStylePropsDef?.tableStyleColBandSize ?? 1;
261267
- const cellStyleTypes = determineCellStyleTypes2(tableInfo.tableProperties?.tblLook, tableInfo.rowIndex, tableInfo.cellIndex, tableInfo.numRows, tableInfo.numCells, rowBandSize, colBandSize);
261268
- cellStyleTypes.forEach((styleType) => {
261269
- const typeProps = tableStyleDef?.tableStyleProperties?.[styleType]?.[propertyType];
261270
- if (typeProps) {
261271
- cellStyleProps.push(typeProps);
261272
- }
261273
- });
261274
- }
261413
+ const tableStyleId = tableInfo.tableProperties.tableStyleId;
261414
+ const { rowBandSize, colBandSize } = resolveEffectiveBandSizes2(tableStyleId, translatedLinkedStyles);
261415
+ const cellStyleTypes = determineCellStyleTypes2(tableInfo.tableProperties?.tblLook ?? DEFAULT_TBL_LOOK2, tableInfo.rowIndex, tableInfo.cellIndex, tableInfo.numRows, tableInfo.numCells, rowBandSize, colBandSize, tableInfo.rowCnfStyle, tableInfo.cellCnfStyle);
261416
+ cellStyleTypes.forEach((styleType) => {
261417
+ const typeProps = resolveConditionalProps2(propertyType, styleType, tableStyleId, translatedLinkedStyles);
261418
+ if (typeProps) {
261419
+ cellStyleProps.push(typeProps);
261420
+ }
261421
+ });
261275
261422
  return cellStyleProps;
261276
261423
  }
261277
- function determineCellStyleTypes2(tblLook, rowIndex, cellIndex, numRows, numCells, rowBandSize = 1, colBandSize = 1) {
261278
- const styleTypes = ["wholeTable"];
261424
+ function determineCellStyleTypes2(tblLook, rowIndex, cellIndex, numRows, numCells, rowBandSize = 1, colBandSize = 1, rowCnfStyle, cellCnfStyle) {
261425
+ const applicable = new Set(["wholeTable"]);
261279
261426
  const normalizedRowBandSize = rowBandSize > 0 ? rowBandSize : 1;
261280
261427
  const normalizedColBandSize = colBandSize > 0 ? colBandSize : 1;
261281
261428
  const bandRowIndex = Math.max(0, rowIndex - (tblLook?.firstRow ? 1 : 0));
@@ -261283,47 +261430,86 @@ function determineCellStyleTypes2(tblLook, rowIndex, cellIndex, numRows, numCell
261283
261430
  const rowGroup = Math.floor(bandRowIndex / normalizedRowBandSize);
261284
261431
  const colGroup = Math.floor(bandColIndex / normalizedColBandSize);
261285
261432
  if (!tblLook?.noHBand) {
261286
- if (rowGroup % 2 === 0) {
261287
- styleTypes.push("band1Horz");
261288
- } else {
261289
- styleTypes.push("band2Horz");
261290
- }
261433
+ applicable.add(rowGroup % 2 === 0 ? "band1Horz" : "band2Horz");
261291
261434
  }
261292
261435
  if (!tblLook?.noVBand) {
261293
- if (colGroup % 2 === 0) {
261294
- styleTypes.push("band1Vert");
261295
- } else {
261296
- styleTypes.push("band2Vert");
261297
- }
261436
+ applicable.add(colGroup % 2 === 0 ? "band1Vert" : "band2Vert");
261298
261437
  }
261299
261438
  if (tblLook?.firstRow && rowIndex === 0) {
261300
- styleTypes.push("firstRow");
261439
+ applicable.add("firstRow");
261301
261440
  }
261302
261441
  if (tblLook?.firstColumn && cellIndex === 0) {
261303
- styleTypes.push("firstCol");
261442
+ applicable.add("firstCol");
261304
261443
  }
261305
261444
  if (tblLook?.lastRow && numRows != null && numRows > 0 && rowIndex === numRows - 1) {
261306
- styleTypes.push("lastRow");
261445
+ applicable.add("lastRow");
261307
261446
  }
261308
261447
  if (tblLook?.lastColumn && numCells != null && numCells > 0 && cellIndex === numCells - 1) {
261309
- styleTypes.push("lastCol");
261448
+ applicable.add("lastCol");
261310
261449
  }
261311
261450
  if (rowIndex === 0 && cellIndex === 0) {
261312
- styleTypes.push("nwCell");
261451
+ applicable.add("nwCell");
261313
261452
  }
261314
261453
  if (rowIndex === 0 && numCells != null && numCells > 0 && cellIndex === numCells - 1) {
261315
- styleTypes.push("neCell");
261454
+ applicable.add("neCell");
261316
261455
  }
261317
261456
  if (numRows != null && numRows > 0 && rowIndex === numRows - 1 && cellIndex === 0) {
261318
- styleTypes.push("swCell");
261457
+ applicable.add("swCell");
261319
261458
  }
261320
261459
  if (numRows != null && numRows > 0 && numCells != null && numCells > 0 && rowIndex === numRows - 1 && cellIndex === numCells - 1) {
261321
- styleTypes.push("seCell");
261460
+ applicable.add("seCell");
261322
261461
  }
261323
- return styleTypes;
261462
+ if (rowCnfStyle || cellCnfStyle) {
261463
+ for (const [flag, styleType] of CNF_STYLE_MAP2) {
261464
+ const rowFlag = rowCnfStyle?.[flag];
261465
+ const cellFlag = cellCnfStyle?.[flag];
261466
+ if (rowFlag === true || cellFlag === true) {
261467
+ applicable.add(styleType);
261468
+ }
261469
+ }
261470
+ }
261471
+ return TABLE_STYLE_PRECEDENCE2.filter((t) => applicable.has(t));
261324
261472
  }
261473
+ var DEFAULT_TBL_LOOK2, CNF_STYLE_MAP2, TABLE_STYLE_PRECEDENCE2;
261325
261474
  var init_ooxml = __esm(() => {
261326
261475
  init_table_style_selection();
261476
+ DEFAULT_TBL_LOOK2 = {
261477
+ firstRow: true,
261478
+ lastRow: false,
261479
+ firstColumn: true,
261480
+ lastColumn: false,
261481
+ noHBand: false,
261482
+ noVBand: true
261483
+ };
261484
+ CNF_STYLE_MAP2 = [
261485
+ ["oddHBand", "band1Horz"],
261486
+ ["evenHBand", "band2Horz"],
261487
+ ["oddVBand", "band1Vert"],
261488
+ ["evenVBand", "band2Vert"],
261489
+ ["firstRow", "firstRow"],
261490
+ ["firstColumn", "firstCol"],
261491
+ ["lastRow", "lastRow"],
261492
+ ["lastColumn", "lastCol"],
261493
+ ["firstRowFirstColumn", "nwCell"],
261494
+ ["firstRowLastColumn", "neCell"],
261495
+ ["lastRowFirstColumn", "swCell"],
261496
+ ["lastRowLastColumn", "seCell"]
261497
+ ];
261498
+ TABLE_STYLE_PRECEDENCE2 = [
261499
+ "wholeTable",
261500
+ "band1Horz",
261501
+ "band2Horz",
261502
+ "band1Vert",
261503
+ "band2Vert",
261504
+ "firstCol",
261505
+ "lastCol",
261506
+ "firstRow",
261507
+ "lastRow",
261508
+ "nwCell",
261509
+ "neCell",
261510
+ "swCell",
261511
+ "seCell"
261512
+ ];
261327
261513
  });
261328
261514
 
261329
261515
  // ../../packages/super-editor/src/core/super-converter/v3/handlers/wp/helpers/textbox-content-helpers.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.2.0-next.62",
3
+ "version": "0.2.0-next.63",
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/document-api": "0.0.1",
23
22
  "@superdoc/pm-adapter": "0.0.0",
23
+ "@superdoc/document-api": "0.0.1",
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.62",
33
- "@superdoc-dev/cli-darwin-x64": "0.2.0-next.62",
34
- "@superdoc-dev/cli-linux-x64": "0.2.0-next.62",
35
- "@superdoc-dev/cli-linux-arm64": "0.2.0-next.62",
36
- "@superdoc-dev/cli-windows-x64": "0.2.0-next.62"
32
+ "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.63",
33
+ "@superdoc-dev/cli-darwin-x64": "0.2.0-next.63",
34
+ "@superdoc-dev/cli-linux-x64": "0.2.0-next.63",
35
+ "@superdoc-dev/cli-linux-arm64": "0.2.0-next.63",
36
+ "@superdoc-dev/cli-windows-x64": "0.2.0-next.63"
37
37
  },
38
38
  "scripts": {
39
39
  "dev": "bun run src/index.ts",