@superdoc-dev/cli 0.2.0-next.32 → 0.2.0-next.34

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 +248 -49
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -101805,9 +101805,9 @@ var init_remark_gfm_CQ3Jg4PR_es = __esm(() => {
101805
101805
  init_remark_gfm_z_sDF4ss_es();
101806
101806
  });
101807
101807
 
101808
- // ../../packages/superdoc/dist/chunks/src-DKGc94QA.es.js
101809
- var exports_src_DKGc94QA_es = {};
101810
- __export(exports_src_DKGc94QA_es, {
101808
+ // ../../packages/superdoc/dist/chunks/src-DoNUa3rb.es.js
101809
+ var exports_src_DoNUa3rb_es = {};
101810
+ __export(exports_src_DoNUa3rb_es, {
101811
101811
  zt: () => defineMark,
101812
101812
  z: () => cM,
101813
101813
  yt: () => removeAwarenessStates,
@@ -116907,19 +116907,69 @@ function tablesInsertCellAdapter(editor, input2, options) {
116907
116907
  return buildTableSuccess(table2.address);
116908
116908
  try {
116909
116909
  const tr = editor.state.tr;
116910
- const tableStart = table2.candidate.pos + 1;
116910
+ const tablePos = table2.candidate.pos;
116911
+ const tableStart = tablePos + 1;
116911
116912
  const tableNode = table2.candidate.node;
116912
116913
  const map$22 = TableMap.get(tableNode);
116913
116914
  const schema = editor.state.schema;
116914
116915
  if (input2.mode === "shiftRight") {
116915
- const lastColIdx = rowIndex * map$22.width + (map$22.width - 1);
116916
- const lastCellPos = map$22.map[lastColIdx];
116917
- const lastCell = tableNode.nodeAt(lastCellPos);
116918
- if (lastCell)
116919
- tr.delete(tableStart + lastCellPos, tableStart + lastCellPos + lastCell.nodeSize);
116920
- const newCell = schema.nodes.tableCell.createAndFill();
116921
- const mappedCellPos = tr.mapping.map(cellPos);
116922
- tr.insert(mappedCellPos, newCell);
116916
+ const slotCount = map$22.width * map$22.height;
116917
+ if (new Set(map$22.map).size !== slotCount)
116918
+ return toTableFailure("INVALID_TARGET", "Cell insertion with shiftRight is not supported for merged cells in this version.");
116919
+ const makeEmptyCell = (preferHeader = false) => {
116920
+ const candidateType = preferHeader ? schema.nodes.tableHeader ?? schema.nodes.tableCell : schema.nodes.tableCell;
116921
+ return candidateType.createAndFill({
116922
+ sdBlockId: v4_default(),
116923
+ paraId: generateParaId()
116924
+ }) ?? candidateType.createAndFill();
116925
+ };
116926
+ const overflowRowCells = [];
116927
+ for (let col = 0;col < map$22.width; col++) {
116928
+ const templateOffset = map$22.map[(map$22.height - 1) * map$22.width + col];
116929
+ const templateCell = tableNode.nodeAt(templateOffset);
116930
+ overflowRowCells.push(makeEmptyCell(templateCell?.type.name === "tableHeader"));
116931
+ }
116932
+ const overflowRowAttrs = {
116933
+ ...tableNode.child(Math.max(0, map$22.height - 1)).attrs ?? {},
116934
+ sdBlockId: v4_default(),
116935
+ paraId: generateParaId()
116936
+ };
116937
+ const overflowRow = schema.nodes.tableRow.createAndFill(overflowRowAttrs, overflowRowCells) ?? schema.nodes.tableRow.create(overflowRowAttrs, overflowRowCells);
116938
+ if (!overflowRow)
116939
+ return toTableFailure("INVALID_TARGET", "Cell insertion could not construct an overflow row.");
116940
+ tr.insert(tablePos + tableNode.nodeSize - 1, overflowRow);
116941
+ const expandedTableNode = tr.doc.nodeAt(tablePos);
116942
+ if (!expandedTableNode || expandedTableNode.type.name !== "table")
116943
+ return toTableFailure("INVALID_TARGET", "Cell insertion could not locate expanded table state.");
116944
+ const expandedMap = TableMap.get(expandedTableNode);
116945
+ const expandedSlotCount = expandedMap.width * expandedMap.height;
116946
+ if (new Set(expandedMap.map).size !== expandedSlotCount)
116947
+ return toTableFailure("INVALID_TARGET", "Cell insertion with shiftRight produced an unsupported merged-table shape.");
116948
+ const rowMajorCells = [];
116949
+ for (let i$1 = 0;i$1 < expandedSlotCount; i$1++) {
116950
+ const offset$1 = expandedMap.map[i$1];
116951
+ const cell2 = expandedTableNode.nodeAt(offset$1);
116952
+ if (!cell2)
116953
+ return toTableFailure("INVALID_TARGET", "Cell insertion could not resolve expanded table cells.");
116954
+ rowMajorCells.push(cell2);
116955
+ }
116956
+ const targetLinearIndex = rowIndex * expandedMap.width + columnIndex;
116957
+ const targetOffset = expandedMap.map[targetLinearIndex];
116958
+ const targetCell = expandedTableNode.nodeAt(targetOffset);
116959
+ rowMajorCells.splice(targetLinearIndex, 0, makeEmptyCell(targetCell?.type.name === "tableHeader"));
116960
+ rowMajorCells.pop();
116961
+ const rebuiltRows = [];
116962
+ const rebuiltRowCount = rowMajorCells.length / expandedMap.width;
116963
+ for (let rebuiltRowIndex = 0;rebuiltRowIndex < rebuiltRowCount; rebuiltRowIndex++) {
116964
+ const rowAttrs = expandedTableNode.child(rebuiltRowIndex).attrs ?? {};
116965
+ const rowCells = rowMajorCells.slice(rebuiltRowIndex * expandedMap.width, (rebuiltRowIndex + 1) * expandedMap.width);
116966
+ const rebuiltRow = schema.nodes.tableRow.createAndFill(rowAttrs, rowCells) ?? schema.nodes.tableRow.create(rowAttrs, rowCells);
116967
+ if (!rebuiltRow)
116968
+ return toTableFailure("INVALID_TARGET", "Cell insertion could not construct a replacement row.");
116969
+ rebuiltRows.push(rebuiltRow);
116970
+ }
116971
+ const rebuiltTable = schema.nodes.table.create(expandedTableNode.attrs, rebuiltRows);
116972
+ tr.replaceWith(tablePos, tablePos + expandedTableNode.nodeSize, rebuiltTable);
116923
116973
  } else {
116924
116974
  const lastRowIdx = (map$22.height - 1) * map$22.width + columnIndex;
116925
116975
  const lastCellPos = map$22.map[lastRowIdx];
@@ -116943,26 +116993,69 @@ function tablesInsertCellAdapter(editor, input2, options) {
116943
116993
  function tablesDeleteCellAdapter(editor, input2, options) {
116944
116994
  rejectTrackedMode("tables.deleteCell", options);
116945
116995
  const { table: table2, cellPos, cellNode, rowIndex, columnIndex } = resolveCellLocator(editor, input2, "tables.deleteCell");
116996
+ const row2 = table2.candidate.node.child(rowIndex);
116997
+ const deletedColspan = Math.max(1, cellNode.attrs.colspan || 1);
116998
+ const deletedColwidth = Array.isArray(cellNode.attrs.colwidth) ? [...cellNode.attrs.colwidth] : null;
116999
+ if (input2.mode === "shiftLeft" && row2.childCount <= 1)
117000
+ return toTableFailure("NO_OP", "Cannot shift-left delete the last remaining cell in a row.");
116946
117001
  if (options?.dryRun)
116947
117002
  return buildTableSuccess(table2.address);
116948
117003
  try {
116949
117004
  const tr = editor.state.tr;
116950
- const tableStart = table2.candidate.pos + 1;
117005
+ const tablePos = table2.candidate.pos;
117006
+ const tableStart = tablePos + 1;
116951
117007
  const tableNode = table2.candidate.node;
116952
117008
  const map$22 = TableMap.get(tableNode);
116953
117009
  const schema = editor.state.schema;
116954
117010
  tr.delete(cellPos, cellPos + cellNode.nodeSize);
116955
117011
  if (input2.mode === "shiftLeft") {
116956
- const row2 = tableNode.child(rowIndex);
116957
- tr.mapping.map(tableStart + map$22.positionAt(rowIndex, map$22.width - 1, tableNode));
116958
- const lastCell = row2.child(row2.childCount - 1);
116959
- tr.mapping.map(cellPos + cellNode.nodeSize + lastCell.nodeSize - cellNode.nodeSize);
116960
- let rowEndPos = table2.candidate.pos + 1;
116961
- for (let i$1 = 0;i$1 <= rowIndex; i$1++)
116962
- rowEndPos += tableNode.child(i$1).nodeSize;
116963
- const mappedRowEnd = tr.mapping.map(rowEndPos - 1);
116964
- const newCell = schema.nodes.tableCell.createAndFill();
116965
- tr.insert(mappedRowEnd, newCell);
117012
+ const currentTableNode = tr.doc.nodeAt(tablePos);
117013
+ if (!currentTableNode || currentTableNode.type.name !== "table")
117014
+ return toTableFailure("INVALID_TARGET", "Cell deletion could not locate the updated table.");
117015
+ const currentRow = currentTableNode.child(rowIndex);
117016
+ const lastCellIndex = currentRow.childCount - 1;
117017
+ const lastAttrs = currentRow.child(lastCellIndex).attrs;
117018
+ const tableCellProperties = lastAttrs.tableCellProperties ?? {};
117019
+ const lastRowspan = Math.max(1, lastAttrs.rowspan || 1);
117020
+ const hasVerticalMerge = tableCellProperties.vMerge != null;
117021
+ if (lastRowspan > 1 || hasVerticalMerge) {
117022
+ let rowEndPos = tablePos + 1;
117023
+ for (let i$1 = 0;i$1 <= rowIndex; i$1++)
117024
+ rowEndPos += currentTableNode.child(i$1).nodeSize;
117025
+ const mappedRowEnd = rowEndPos - 1;
117026
+ const newCell = schema.nodes.tableCell.createAndFill();
117027
+ tr.insert(mappedRowEnd, newCell);
117028
+ } else {
117029
+ const nextColspan = Math.max(1, lastAttrs.colspan || 1) + deletedColspan;
117030
+ const nextTableCellProps = { ...tableCellProperties };
117031
+ if (nextColspan > 1)
117032
+ nextTableCellProps.gridSpan = nextColspan;
117033
+ else
117034
+ delete nextTableCellProps.gridSpan;
117035
+ const nextColwidth = Array.isArray(lastAttrs.colwidth) ? [...lastAttrs.colwidth] : null;
117036
+ if (nextColwidth) {
117037
+ if (deletedColwidth)
117038
+ for (const width of deletedColwidth) {
117039
+ if (nextColwidth.length >= nextColspan)
117040
+ break;
117041
+ nextColwidth.push(typeof width === "number" ? width : 0);
117042
+ }
117043
+ while (nextColwidth.length < nextColspan)
117044
+ nextColwidth.push(0);
117045
+ }
117046
+ let rowOffset = 0;
117047
+ for (let i$1 = 0;i$1 < rowIndex; i$1++)
117048
+ rowOffset += currentTableNode.child(i$1).nodeSize;
117049
+ let lastCellOffset = rowOffset + 1;
117050
+ for (let i$1 = 0;i$1 < lastCellIndex; i$1++)
117051
+ lastCellOffset += currentRow.child(i$1).nodeSize;
117052
+ tr.setNodeMarkup(tableStart + lastCellOffset, null, {
117053
+ ...lastAttrs,
117054
+ colspan: nextColspan,
117055
+ colwidth: nextColwidth,
117056
+ tableCellProperties: nextTableCellProps
117057
+ });
117058
+ }
116966
117059
  } else {
116967
117060
  const lastRowIndex = map$22.height - 1;
116968
117061
  const colOffset = map$22.map[lastRowIndex * map$22.width + columnIndex];
@@ -172993,7 +173086,7 @@ var Node$13 = class Node$14 {
172993
173086
  trackedChanges: context.trackedChanges ?? []
172994
173087
  });
172995
173088
  }, _hoisted_1$6, _hoisted_2$1, _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, RESIZE_HANDLE_WIDTH_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, 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;
172996
- var init_src_DKGc94QA_es = __esm(() => {
173089
+ var init_src_DoNUa3rb_es = __esm(() => {
172997
173090
  init_rolldown_runtime_B2q5OVn9_es();
172998
173091
  init_SuperConverter_BSZgN87C_es();
172999
173092
  init_jszip_ChlR43oI_es();
@@ -203886,8 +203979,8 @@ function print() { __p += __j.call(arguments, '') }
203886
203979
  return isObjectLike_default(value) && hasOwnProperty$8.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
203887
203980
  };
203888
203981
  stubFalse_default = stubFalse;
203889
- freeExports$2 = typeof exports_src_DKGc94QA_es == "object" && exports_src_DKGc94QA_es && !exports_src_DKGc94QA_es.nodeType && exports_src_DKGc94QA_es;
203890
- freeModule$2 = freeExports$2 && typeof module_src_DKGc94QA_es == "object" && module_src_DKGc94QA_es && !module_src_DKGc94QA_es.nodeType && module_src_DKGc94QA_es;
203982
+ freeExports$2 = typeof exports_src_DoNUa3rb_es == "object" && exports_src_DoNUa3rb_es && !exports_src_DoNUa3rb_es.nodeType && exports_src_DoNUa3rb_es;
203983
+ freeModule$2 = freeExports$2 && typeof module_src_DoNUa3rb_es == "object" && module_src_DoNUa3rb_es && !module_src_DoNUa3rb_es.nodeType && module_src_DoNUa3rb_es;
203891
203984
  Buffer$1 = freeModule$2 && freeModule$2.exports === freeExports$2 ? _root_default.Buffer : undefined;
203892
203985
  isBuffer_default = (Buffer$1 ? Buffer$1.isBuffer : undefined) || stubFalse_default;
203893
203986
  typedArrayTags = {};
@@ -203895,8 +203988,8 @@ function print() { __p += __j.call(arguments, '') }
203895
203988
  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;
203896
203989
  _baseIsTypedArray_default = baseIsTypedArray;
203897
203990
  _baseUnary_default = baseUnary;
203898
- freeExports$1 = typeof exports_src_DKGc94QA_es == "object" && exports_src_DKGc94QA_es && !exports_src_DKGc94QA_es.nodeType && exports_src_DKGc94QA_es;
203899
- freeModule$1 = freeExports$1 && typeof module_src_DKGc94QA_es == "object" && module_src_DKGc94QA_es && !module_src_DKGc94QA_es.nodeType && module_src_DKGc94QA_es;
203991
+ freeExports$1 = typeof exports_src_DoNUa3rb_es == "object" && exports_src_DoNUa3rb_es && !exports_src_DoNUa3rb_es.nodeType && exports_src_DoNUa3rb_es;
203992
+ freeModule$1 = freeExports$1 && typeof module_src_DoNUa3rb_es == "object" && module_src_DoNUa3rb_es && !module_src_DoNUa3rb_es.nodeType && module_src_DoNUa3rb_es;
203900
203993
  freeProcess = freeModule$1 && freeModule$1.exports === freeExports$1 && _freeGlobal_default.process;
203901
203994
  _nodeUtil_default = function() {
203902
203995
  try {
@@ -204001,8 +204094,8 @@ function print() { __p += __j.call(arguments, '') }
204001
204094
  Stack.prototype.has = _stackHas_default;
204002
204095
  Stack.prototype.set = _stackSet_default;
204003
204096
  _Stack_default = Stack;
204004
- freeExports = typeof exports_src_DKGc94QA_es == "object" && exports_src_DKGc94QA_es && !exports_src_DKGc94QA_es.nodeType && exports_src_DKGc94QA_es;
204005
- freeModule = freeExports && typeof module_src_DKGc94QA_es == "object" && module_src_DKGc94QA_es && !module_src_DKGc94QA_es.nodeType && module_src_DKGc94QA_es;
204097
+ freeExports = typeof exports_src_DoNUa3rb_es == "object" && exports_src_DoNUa3rb_es && !exports_src_DoNUa3rb_es.nodeType && exports_src_DoNUa3rb_es;
204098
+ freeModule = freeExports && typeof module_src_DoNUa3rb_es == "object" && module_src_DoNUa3rb_es && !module_src_DoNUa3rb_es.nodeType && module_src_DoNUa3rb_es;
204006
204099
  Buffer4 = freeModule && freeModule.exports === freeExports ? _root_default.Buffer : undefined;
204007
204100
  allocUnsafe = Buffer4 ? Buffer4.allocUnsafe : undefined;
204008
204101
  _cloneBuffer_default = cloneBuffer;
@@ -211654,7 +211747,7 @@ var init_zipper_Cnk_HjM2_es = __esm(() => {
211654
211747
 
211655
211748
  // ../../packages/superdoc/dist/super-editor.es.js
211656
211749
  var init_super_editor_es = __esm(() => {
211657
- init_src_DKGc94QA_es();
211750
+ init_src_DoNUa3rb_es();
211658
211751
  init_SuperConverter_BSZgN87C_es();
211659
211752
  init_jszip_ChlR43oI_es();
211660
211753
  init_xml_js_DLE8mr0n_es();
@@ -272352,15 +272445,72 @@ function tablesInsertCellAdapter2(editor, input2, options) {
272352
272445
  const map8 = TableMap2.get(tableNode);
272353
272446
  const schema = editor.state.schema;
272354
272447
  if (input2.mode === "shiftRight") {
272355
- const lastColIdx = rowIndex * map8.width + (map8.width - 1);
272356
- const lastCellPos = map8.map[lastColIdx];
272357
- const lastCell = tableNode.nodeAt(lastCellPos);
272358
- if (lastCell) {
272359
- tr.delete(tableStart + lastCellPos, tableStart + lastCellPos + lastCell.nodeSize);
272448
+ const slotCount = map8.width * map8.height;
272449
+ const uniqueOffsets = new Set(map8.map);
272450
+ if (uniqueOffsets.size !== slotCount) {
272451
+ return toTableFailure2("INVALID_TARGET", "Cell insertion with shiftRight is not supported for merged cells in this version.");
272452
+ }
272453
+ const makeEmptyCell = (preferHeader = false) => {
272454
+ const candidateType = preferHeader ? schema.nodes.tableHeader ?? schema.nodes.tableCell : schema.nodes.tableCell;
272455
+ return candidateType.createAndFill({
272456
+ sdBlockId: v42(),
272457
+ paraId: generateParaId2()
272458
+ }) ?? candidateType.createAndFill();
272459
+ };
272460
+ const overflowRowCells = [];
272461
+ for (let col = 0;col < map8.width; col++) {
272462
+ const templateOffset = map8.map[(map8.height - 1) * map8.width + col];
272463
+ const templateCell = tableNode.nodeAt(templateOffset);
272464
+ overflowRowCells.push(makeEmptyCell(templateCell?.type.name === "tableHeader"));
272360
272465
  }
272361
- const newCell = schema.nodes.tableCell.createAndFill();
272362
- const mappedCellPos = tr.mapping.map(cellPos);
272363
- tr.insert(mappedCellPos, newCell);
272466
+ const templateRowAttrs = tableNode.child(Math.max(0, map8.height - 1)).attrs ?? {};
272467
+ const overflowRowAttrs = {
272468
+ ...templateRowAttrs,
272469
+ sdBlockId: v42(),
272470
+ paraId: generateParaId2()
272471
+ };
272472
+ const overflowRow = schema.nodes.tableRow.createAndFill(overflowRowAttrs, overflowRowCells) ?? schema.nodes.tableRow.create(overflowRowAttrs, overflowRowCells);
272473
+ if (!overflowRow) {
272474
+ return toTableFailure2("INVALID_TARGET", "Cell insertion could not construct an overflow row.");
272475
+ }
272476
+ tr.insert(tablePos + tableNode.nodeSize - 1, overflowRow);
272477
+ const expandedTableNode = tr.doc.nodeAt(tablePos);
272478
+ if (!expandedTableNode || expandedTableNode.type.name !== "table") {
272479
+ return toTableFailure2("INVALID_TARGET", "Cell insertion could not locate expanded table state.");
272480
+ }
272481
+ const expandedMap = TableMap2.get(expandedTableNode);
272482
+ const expandedSlotCount = expandedMap.width * expandedMap.height;
272483
+ if (new Set(expandedMap.map).size !== expandedSlotCount) {
272484
+ return toTableFailure2("INVALID_TARGET", "Cell insertion with shiftRight produced an unsupported merged-table shape.");
272485
+ }
272486
+ const rowMajorCells = [];
272487
+ for (let i5 = 0;i5 < expandedSlotCount; i5++) {
272488
+ const offset2 = expandedMap.map[i5];
272489
+ const cell2 = expandedTableNode.nodeAt(offset2);
272490
+ if (!cell2) {
272491
+ return toTableFailure2("INVALID_TARGET", "Cell insertion could not resolve expanded table cells.");
272492
+ }
272493
+ rowMajorCells.push(cell2);
272494
+ }
272495
+ const targetLinearIndex = rowIndex * expandedMap.width + columnIndex;
272496
+ const targetOffset = expandedMap.map[targetLinearIndex];
272497
+ const targetCell = expandedTableNode.nodeAt(targetOffset);
272498
+ rowMajorCells.splice(targetLinearIndex, 0, makeEmptyCell(targetCell?.type.name === "tableHeader"));
272499
+ rowMajorCells.pop();
272500
+ const rebuiltRows = [];
272501
+ const rebuiltRowCount = rowMajorCells.length / expandedMap.width;
272502
+ for (let rebuiltRowIndex = 0;rebuiltRowIndex < rebuiltRowCount; rebuiltRowIndex++) {
272503
+ const sourceRow = expandedTableNode.child(rebuiltRowIndex);
272504
+ const rowAttrs = sourceRow.attrs ?? {};
272505
+ const rowCells = rowMajorCells.slice(rebuiltRowIndex * expandedMap.width, (rebuiltRowIndex + 1) * expandedMap.width);
272506
+ const rebuiltRow = schema.nodes.tableRow.createAndFill(rowAttrs, rowCells) ?? schema.nodes.tableRow.create(rowAttrs, rowCells);
272507
+ if (!rebuiltRow) {
272508
+ return toTableFailure2("INVALID_TARGET", "Cell insertion could not construct a replacement row.");
272509
+ }
272510
+ rebuiltRows.push(rebuiltRow);
272511
+ }
272512
+ const rebuiltTable = schema.nodes.table.create(expandedTableNode.attrs, rebuiltRows);
272513
+ tr.replaceWith(tablePos, tablePos + expandedTableNode.nodeSize, rebuiltTable);
272364
272514
  } else {
272365
272515
  const lastRowIdx = (map8.height - 1) * map8.width + columnIndex;
272366
272516
  const lastCellPos = map8.map[lastRowIdx];
@@ -272386,6 +272536,12 @@ function tablesDeleteCellAdapter2(editor, input2, options) {
272386
272536
  rejectTrackedMode2("tables.deleteCell", options);
272387
272537
  const resolved = resolveCellLocator2(editor, input2, "tables.deleteCell");
272388
272538
  const { table: table2, cellPos, cellNode, rowIndex, columnIndex } = resolved;
272539
+ const row2 = table2.candidate.node.child(rowIndex);
272540
+ const deletedColspan = Math.max(1, cellNode.attrs.colspan || 1);
272541
+ const deletedColwidth = Array.isArray(cellNode.attrs.colwidth) ? [...cellNode.attrs.colwidth] : null;
272542
+ if (input2.mode === "shiftLeft" && row2.childCount <= 1) {
272543
+ return toTableFailure2("NO_OP", "Cannot shift-left delete the last remaining cell in a row.");
272544
+ }
272389
272545
  if (options?.dryRun) {
272390
272546
  return buildTableSuccess2(table2.address);
272391
272547
  }
@@ -272398,16 +272554,59 @@ function tablesDeleteCellAdapter2(editor, input2, options) {
272398
272554
  const schema = editor.state.schema;
272399
272555
  tr.delete(cellPos, cellPos + cellNode.nodeSize);
272400
272556
  if (input2.mode === "shiftLeft") {
272401
- const row2 = tableNode.child(rowIndex);
272402
- const rowEnd = tr.mapping.map(tableStart + map8.positionAt(rowIndex, map8.width - 1, tableNode));
272403
- const lastCell = row2.child(row2.childCount - 1);
272404
- const insertPos = tr.mapping.map(cellPos + cellNode.nodeSize + lastCell.nodeSize - cellNode.nodeSize);
272405
- let rowEndPos = table2.candidate.pos + 1;
272406
- for (let i5 = 0;i5 <= rowIndex; i5++)
272407
- rowEndPos += tableNode.child(i5).nodeSize;
272408
- const mappedRowEnd = tr.mapping.map(rowEndPos - 1);
272409
- const newCell = schema.nodes.tableCell.createAndFill();
272410
- tr.insert(mappedRowEnd, newCell);
272557
+ const currentTableNode = tr.doc.nodeAt(tablePos);
272558
+ if (!currentTableNode || currentTableNode.type.name !== "table") {
272559
+ return toTableFailure2("INVALID_TARGET", "Cell deletion could not locate the updated table.");
272560
+ }
272561
+ const currentRow = currentTableNode.child(rowIndex);
272562
+ const lastCellIndex = currentRow.childCount - 1;
272563
+ const lastCell = currentRow.child(lastCellIndex);
272564
+ const lastAttrs = lastCell.attrs;
272565
+ const tableCellProperties = lastAttrs.tableCellProperties ?? {};
272566
+ const lastRowspan = Math.max(1, lastAttrs.rowspan || 1);
272567
+ const hasVerticalMerge = tableCellProperties.vMerge != null;
272568
+ if (lastRowspan > 1 || hasVerticalMerge) {
272569
+ let rowEndPos = tablePos + 1;
272570
+ for (let i5 = 0;i5 <= rowIndex; i5++)
272571
+ rowEndPos += currentTableNode.child(i5).nodeSize;
272572
+ const mappedRowEnd = rowEndPos - 1;
272573
+ const newCell = schema.nodes.tableCell.createAndFill();
272574
+ tr.insert(mappedRowEnd, newCell);
272575
+ } else {
272576
+ const lastColspan = Math.max(1, lastAttrs.colspan || 1);
272577
+ const nextColspan = lastColspan + deletedColspan;
272578
+ const nextTableCellProps = {
272579
+ ...tableCellProperties
272580
+ };
272581
+ if (nextColspan > 1)
272582
+ nextTableCellProps.gridSpan = nextColspan;
272583
+ else
272584
+ delete nextTableCellProps.gridSpan;
272585
+ const nextColwidth = Array.isArray(lastAttrs.colwidth) ? [...lastAttrs.colwidth] : null;
272586
+ if (nextColwidth) {
272587
+ if (deletedColwidth) {
272588
+ for (const width of deletedColwidth) {
272589
+ if (nextColwidth.length >= nextColspan)
272590
+ break;
272591
+ nextColwidth.push(typeof width === "number" ? width : 0);
272592
+ }
272593
+ }
272594
+ while (nextColwidth.length < nextColspan)
272595
+ nextColwidth.push(0);
272596
+ }
272597
+ let rowOffset = 0;
272598
+ for (let i5 = 0;i5 < rowIndex; i5++)
272599
+ rowOffset += currentTableNode.child(i5).nodeSize;
272600
+ let lastCellOffset = rowOffset + 1;
272601
+ for (let i5 = 0;i5 < lastCellIndex; i5++)
272602
+ lastCellOffset += currentRow.child(i5).nodeSize;
272603
+ tr.setNodeMarkup(tableStart + lastCellOffset, null, {
272604
+ ...lastAttrs,
272605
+ colspan: nextColspan,
272606
+ colwidth: nextColwidth,
272607
+ tableCellProperties: nextTableCellProps
272608
+ });
272609
+ }
272411
272610
  } else {
272412
272611
  const lastRowIndex = map8.height - 1;
272413
272612
  const colOffset = map8.map[lastRowIndex * map8.width + columnIndex];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.2.0-next.32",
3
+ "version": "0.2.0-next.34",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -29,11 +29,11 @@
29
29
  "access": "public"
30
30
  },
31
31
  "optionalDependencies": {
32
- "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.32",
33
- "@superdoc-dev/cli-darwin-x64": "0.2.0-next.32",
34
- "@superdoc-dev/cli-linux-x64": "0.2.0-next.32",
35
- "@superdoc-dev/cli-linux-arm64": "0.2.0-next.32",
36
- "@superdoc-dev/cli-windows-x64": "0.2.0-next.32"
32
+ "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.34",
33
+ "@superdoc-dev/cli-linux-x64": "0.2.0-next.34",
34
+ "@superdoc-dev/cli-linux-arm64": "0.2.0-next.34",
35
+ "@superdoc-dev/cli-darwin-x64": "0.2.0-next.34",
36
+ "@superdoc-dev/cli-windows-x64": "0.2.0-next.34"
37
37
  },
38
38
  "scripts": {
39
39
  "dev": "bun run src/index.ts",