@harbour-enterprises/superdoc 1.5.0-next.4 → 1.5.0-next.6

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.
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const vue = require("./vue-De9wkgLl.cjs");
4
- const superdoc = require("./index-Cx9Sx4Ap.cjs");
5
- const index = require("./index-CEzpmlwg.cjs");
4
+ const superdoc = require("./index-RKdc-5FM.cjs");
5
+ const index = require("./index-224wdSXe.cjs");
6
6
  function self(vars) {
7
7
  const {
8
8
  opacityDisabled,
@@ -1,6 +1,6 @@
1
1
  import { d as defineComponent, h, T as Transition, p as process$1, w as watchEffect, c as computed, r as ref, f as onMounted, X as onUnmounted, E as createElementBlock, G as openBlock, K as createBaseVNode, M as createCommentVNode, I as createVNode, v as unref } from "./vue-BnBKJwCW.es.js";
2
- import { N as NBaseLoading, u as useSuperdocStore, s as storeToRefs, a as useSelection } from "./index-Be6dYM8u.es.js";
3
- import { C as derived, r as c, q as cB, aF as fadeInTransition, y as cM, I as warnOnce, J as useConfig, N as useTheme, aG as pxfy, P as createKey, Q as useThemeClass, aH as useCompitable, ai as _export_sfc } from "./index-QGIv94xy.es.js";
2
+ import { N as NBaseLoading, u as useSuperdocStore, s as storeToRefs, a as useSelection } from "./index-BhJCVQFg.es.js";
3
+ import { C as derived, r as c, q as cB, aF as fadeInTransition, y as cM, I as warnOnce, J as useConfig, N as useTheme, aG as pxfy, P as createKey, Q as useThemeClass, aH as useCompitable, ai as _export_sfc } from "./index-BgZnM0Uj.es.js";
4
4
  function self(vars) {
5
5
  const {
6
6
  opacityDisabled,
@@ -10087,6 +10087,11 @@ const SD_NODE_NAME$g = "tableRow";
10087
10087
  const validXmlAttributes$9 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
10088
10088
  (xmlName) => createAttributeHandler(xmlName)
10089
10089
  );
10090
+ const getColspan$1 = (cell) => {
10091
+ const rawColspan = cell?.attrs?.colspan;
10092
+ const numericColspan = typeof rawColspan === "string" ? parseInt(rawColspan, 10) : rawColspan;
10093
+ return Number.isFinite(numericColspan) && numericColspan > 0 ? numericColspan : 1;
10094
+ };
10090
10095
  const encode$v = (params, encodedAttrs) => {
10091
10096
  const { row } = params.extraParams;
10092
10097
  let tableRowProperties = {};
@@ -10219,7 +10224,27 @@ const decode$x = (params, decodedAttrs) => {
10219
10224
  }
10220
10225
  return cell;
10221
10226
  });
10222
- const trimmedContent = sanitizedCells.filter((_2, index2) => !isPlaceholderCell(trimmedSlice[index2]));
10227
+ let trimmedContent = sanitizedCells.filter((_2, index2) => !isPlaceholderCell(trimmedSlice[index2]));
10228
+ const preferTableGrid = params.extraParams?.preferTableGrid === true;
10229
+ const totalColumns = params.extraParams?.totalColumns;
10230
+ if (preferTableGrid && typeof totalColumns === "number" && Number.isFinite(totalColumns) && totalColumns > 0) {
10231
+ const rawGridBefore = node.attrs?.tableRowProperties?.gridBefore;
10232
+ const numericGridBefore = typeof rawGridBefore === "string" ? parseInt(rawGridBefore, 10) : rawGridBefore;
10233
+ const safeGridBefore = Number.isFinite(numericGridBefore) && numericGridBefore > 0 ? numericGridBefore : 0;
10234
+ const effectiveGridBefore = leadingPlaceholders > 0 ? leadingPlaceholders : safeGridBefore;
10235
+ const availableColumns = Math.max(totalColumns - effectiveGridBefore, 0);
10236
+ let usedColumns = 0;
10237
+ const constrainedCells = [];
10238
+ for (const cell of trimmedContent) {
10239
+ const colspan = getColspan$1(cell);
10240
+ if (usedColumns + colspan > availableColumns) {
10241
+ break;
10242
+ }
10243
+ constrainedCells.push(cell);
10244
+ usedColumns += colspan;
10245
+ }
10246
+ trimmedContent = constrainedCells;
10247
+ }
10223
10248
  const translateParams = {
10224
10249
  ...params,
10225
10250
  node: { ...node, content: trimmedContent }
@@ -25964,6 +25989,53 @@ const config$d = {
25964
25989
  attributes: validXmlAttributes$5
25965
25990
  };
25966
25991
  const translator$s = NodeTranslator.from(config$d);
25992
+ const getColspan = (cell) => {
25993
+ const rawColspan = cell?.attrs?.colspan;
25994
+ const numericColspan = typeof rawColspan === "string" ? parseInt(rawColspan, 10) : rawColspan;
25995
+ return Number.isFinite(numericColspan) && numericColspan > 0 ? numericColspan : 1;
25996
+ };
25997
+ const resolveGridBefore = (row) => {
25998
+ const rawGridBefore = row?.attrs?.tableRowProperties?.gridBefore ?? row?.attrs?.gridBefore;
25999
+ const numericGridBefore = typeof rawGridBefore === "string" ? parseInt(rawGridBefore, 10) : rawGridBefore;
26000
+ if (!Number.isFinite(numericGridBefore) || numericGridBefore <= 0) return 0;
26001
+ const cells = Array.isArray(row.content) ? row.content : [];
26002
+ let leadingGridBefore = 0;
26003
+ while (leadingGridBefore < cells.length && cells[leadingGridBefore]?.attrs?.__placeholder === "gridBefore") {
26004
+ leadingGridBefore += 1;
26005
+ }
26006
+ return leadingGridBefore > 0 ? 0 : numericGridBefore;
26007
+ };
26008
+ const advanceColumnsForCell = (columnIndex, cell) => columnIndex + getColspan(cell);
26009
+ const getCellStartColumn = (row, targetCell) => {
26010
+ const cells = Array.isArray(row.content) ? row.content : [];
26011
+ let columnIndex = resolveGridBefore(row);
26012
+ for (const cell of cells) {
26013
+ if (cell === targetCell) return columnIndex;
26014
+ columnIndex = advanceColumnsForCell(columnIndex, cell);
26015
+ }
26016
+ return columnIndex;
26017
+ };
26018
+ const findCellCoveringColumn = (row, targetColumn) => {
26019
+ const cells = Array.isArray(row.content) ? row.content : [];
26020
+ let columnIndex = resolveGridBefore(row);
26021
+ for (const cell of cells) {
26022
+ const colspan = getColspan(cell);
26023
+ if (targetColumn >= columnIndex && targetColumn < columnIndex + colspan) {
26024
+ return cell;
26025
+ }
26026
+ columnIndex = advanceColumnsForCell(columnIndex, cell);
26027
+ }
26028
+ return null;
26029
+ };
26030
+ const findInsertionIndexForColumn = (row, targetColumn) => {
26031
+ const cells = Array.isArray(row.content) ? row.content : [];
26032
+ let columnIndex = resolveGridBefore(row);
26033
+ for (let index2 = 0; index2 < cells.length; index2++) {
26034
+ if (columnIndex >= targetColumn) return index2;
26035
+ columnIndex = advanceColumnsForCell(columnIndex, cells[index2]);
26036
+ }
26037
+ return cells.length;
26038
+ };
25967
26039
  function preProcessVerticalMergeCells(table, { editorSchema }) {
25968
26040
  if (!table || !Array.isArray(table.content)) {
25969
26041
  return table;
@@ -25979,15 +26051,17 @@ function preProcessVerticalMergeCells(table, { editorSchema }) {
25979
26051
  const cell = row.content[cellIndex];
25980
26052
  if (!cell) continue;
25981
26053
  const attrs = cell.attrs || {};
25982
- if (!attrs.rowspan || attrs.rowspan <= 1) continue;
25983
- const maxRowspan = Math.min(attrs.rowspan, rows.length - rowIndex);
26054
+ const rawRowspan = typeof attrs.rowspan === "string" ? parseInt(attrs.rowspan, 10) : attrs.rowspan;
26055
+ if (!Number.isFinite(rawRowspan) || rawRowspan <= 1) continue;
26056
+ const maxRowspan = Math.min(rawRowspan, rows.length - rowIndex);
26057
+ const startColumn = getCellStartColumn(row, cell);
25984
26058
  for (let offset = 1; offset < maxRowspan; offset++) {
25985
26059
  const rowToChange = rows[rowIndex + offset];
25986
26060
  if (!rowToChange) continue;
25987
26061
  if (!Array.isArray(rowToChange.content)) {
25988
26062
  rowToChange.content = [];
25989
26063
  }
25990
- const existingCell = rowToChange.content[cellIndex];
26064
+ const existingCell = findCellCoveringColumn(rowToChange, startColumn);
25991
26065
  if (existingCell?.attrs?.continueMerge) continue;
25992
26066
  const mergedCell = {
25993
26067
  type: cell.type,
@@ -25998,7 +26072,8 @@ function preProcessVerticalMergeCells(table, { editorSchema }) {
25998
26072
  continueMerge: true
25999
26073
  }
26000
26074
  };
26001
- rowToChange.content.splice(cellIndex, 0, mergedCell);
26075
+ const insertionIndex = findInsertionIndexForColumn(rowToChange, startColumn);
26076
+ rowToChange.content.splice(insertionIndex, 0, mergedCell);
26002
26077
  }
26003
26078
  }
26004
26079
  }
@@ -26150,15 +26225,24 @@ const encode$q = (params) => {
26150
26225
  const decode$s = (params) => {
26151
26226
  const { grid: rawGrid } = params.node.attrs || {};
26152
26227
  const grid = Array.isArray(rawGrid) ? rawGrid : [];
26153
- const { firstRow = {} } = params.extraParams || {};
26228
+ const { firstRow = {}, preferTableGrid = false, totalColumns: requestedColumns } = params.extraParams || {};
26154
26229
  const cellNodes = firstRow.content?.filter((n) => n.type === "tableCell") ?? [];
26155
- const colWidthsFromCellNodes = cellNodes.flatMap((cell) => {
26230
+ let colWidthsFromCellNodes = cellNodes.flatMap((cell) => {
26156
26231
  const spanCount = Math.max(1, cell?.attrs?.colspan ?? 1);
26157
26232
  const colwidth = cell.attrs?.colwidth;
26158
26233
  return Array.from({ length: spanCount }).map((_2, span) => Array.isArray(colwidth) ? colwidth[span] : void 0);
26159
26234
  });
26160
26235
  const columnCountFromCells = colWidthsFromCellNodes.length;
26161
- const totalColumns = Math.max(columnCountFromCells, grid.length);
26236
+ const gridColumnCount = grid.length;
26237
+ let totalColumns = Math.max(columnCountFromCells, gridColumnCount);
26238
+ if (typeof requestedColumns === "number" && Number.isFinite(requestedColumns) && requestedColumns > 0) {
26239
+ totalColumns = requestedColumns;
26240
+ } else if (preferTableGrid && gridColumnCount > 0) {
26241
+ totalColumns = gridColumnCount;
26242
+ }
26243
+ if (colWidthsFromCellNodes.length > totalColumns) {
26244
+ colWidthsFromCellNodes = colWidthsFromCellNodes.slice(0, totalColumns);
26245
+ }
26162
26246
  const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params, totalColumns, cellMinWidth);
26163
26247
  const elements = [];
26164
26248
  const pushColumn = (widthTwips, { enforceMinimum = false } = {}) => {
@@ -26418,22 +26502,31 @@ const encode$p = (params, encodedAttrs) => {
26418
26502
  const decode$r = (params, decodedAttrs) => {
26419
26503
  params.node = preProcessVerticalMergeCells(params.node, params);
26420
26504
  const { node } = params;
26421
- const elements = translateChildNodes(params);
26505
+ const rawGrid = node.attrs?.grid;
26506
+ const grid = Array.isArray(rawGrid) ? rawGrid : [];
26507
+ const preferTableGrid = node.attrs?.userEdited !== true && grid.length > 0;
26508
+ const totalColumns = preferTableGrid ? grid.length : void 0;
26509
+ const extraParams = {
26510
+ ...params.extraParams || {},
26511
+ preferTableGrid,
26512
+ totalColumns
26513
+ };
26514
+ const elements = translateChildNodes({ ...params, extraParams });
26422
26515
  const firstRow = node.content?.find((n) => n.type === "tableRow");
26423
- const properties = node.attrs.grid;
26424
26516
  const element = translator$c.decode({
26425
26517
  ...params,
26426
- node: { ...node, attrs: { ...node.attrs, grid: properties } },
26518
+ node: { ...node, attrs: { ...node.attrs, grid } },
26427
26519
  extraParams: {
26520
+ ...extraParams,
26428
26521
  firstRow
26429
26522
  }
26430
26523
  });
26431
26524
  if (element) elements.unshift(element);
26432
26525
  if (node.attrs?.tableProperties) {
26433
- const properties2 = { ...node.attrs.tableProperties };
26526
+ const properties = { ...node.attrs.tableProperties };
26434
26527
  const element2 = translator$e.decode({
26435
26528
  ...params,
26436
- node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
26529
+ node: { ...node, attrs: { ...node.attrs, tableProperties: properties } }
26437
26530
  });
26438
26531
  if (element2) elements.unshift(element2);
26439
26532
  }
@@ -29679,10 +29772,10 @@ function ensureSectionProperties(bodyNode) {
29679
29772
  function getStyleDefinitions(docx) {
29680
29773
  const styles = docx["word/styles.xml"];
29681
29774
  if (!styles) return [];
29682
- const { elements } = styles.elements[0];
29775
+ const elements = styles.elements?.[0]?.elements ?? [];
29683
29776
  const styleDefinitions = elements.filter((el) => el.name === "w:style");
29684
29777
  const latentStyles = elements.find((el) => el.name === "w:latentStyles");
29685
- latentStyles?.elements.forEach((el) => {
29778
+ (latentStyles?.elements ?? []).forEach((el) => {
29686
29779
  const { attributes } = el;
29687
29780
  styleDefinitions.find((style) => style.attributes["w:styleId"] === attributes["w:name"]);
29688
29781
  });
@@ -31565,7 +31658,7 @@ class SuperConverter {
31565
31658
  static getStoredSuperdocVersion(docx) {
31566
31659
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
31567
31660
  }
31568
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.5.0-next.4") {
31661
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.5.0-next.6") {
31569
31662
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
31570
31663
  }
31571
31664
  /**
@@ -10086,6 +10086,11 @@ const SD_NODE_NAME$g = "tableRow";
10086
10086
  const validXmlAttributes$9 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
10087
10087
  (xmlName) => createAttributeHandler(xmlName)
10088
10088
  );
10089
+ const getColspan$1 = (cell) => {
10090
+ const rawColspan = cell?.attrs?.colspan;
10091
+ const numericColspan = typeof rawColspan === "string" ? parseInt(rawColspan, 10) : rawColspan;
10092
+ return Number.isFinite(numericColspan) && numericColspan > 0 ? numericColspan : 1;
10093
+ };
10089
10094
  const encode$v = (params, encodedAttrs) => {
10090
10095
  const { row } = params.extraParams;
10091
10096
  let tableRowProperties = {};
@@ -10218,7 +10223,27 @@ const decode$x = (params, decodedAttrs) => {
10218
10223
  }
10219
10224
  return cell;
10220
10225
  });
10221
- const trimmedContent = sanitizedCells.filter((_2, index2) => !isPlaceholderCell(trimmedSlice[index2]));
10226
+ let trimmedContent = sanitizedCells.filter((_2, index2) => !isPlaceholderCell(trimmedSlice[index2]));
10227
+ const preferTableGrid = params.extraParams?.preferTableGrid === true;
10228
+ const totalColumns = params.extraParams?.totalColumns;
10229
+ if (preferTableGrid && typeof totalColumns === "number" && Number.isFinite(totalColumns) && totalColumns > 0) {
10230
+ const rawGridBefore = node.attrs?.tableRowProperties?.gridBefore;
10231
+ const numericGridBefore = typeof rawGridBefore === "string" ? parseInt(rawGridBefore, 10) : rawGridBefore;
10232
+ const safeGridBefore = Number.isFinite(numericGridBefore) && numericGridBefore > 0 ? numericGridBefore : 0;
10233
+ const effectiveGridBefore = leadingPlaceholders > 0 ? leadingPlaceholders : safeGridBefore;
10234
+ const availableColumns = Math.max(totalColumns - effectiveGridBefore, 0);
10235
+ let usedColumns = 0;
10236
+ const constrainedCells = [];
10237
+ for (const cell of trimmedContent) {
10238
+ const colspan = getColspan$1(cell);
10239
+ if (usedColumns + colspan > availableColumns) {
10240
+ break;
10241
+ }
10242
+ constrainedCells.push(cell);
10243
+ usedColumns += colspan;
10244
+ }
10245
+ trimmedContent = constrainedCells;
10246
+ }
10222
10247
  const translateParams = {
10223
10248
  ...params,
10224
10249
  node: { ...node, content: trimmedContent }
@@ -25963,6 +25988,53 @@ const config$d = {
25963
25988
  attributes: validXmlAttributes$5
25964
25989
  };
25965
25990
  const translator$s = NodeTranslator.from(config$d);
25991
+ const getColspan = (cell) => {
25992
+ const rawColspan = cell?.attrs?.colspan;
25993
+ const numericColspan = typeof rawColspan === "string" ? parseInt(rawColspan, 10) : rawColspan;
25994
+ return Number.isFinite(numericColspan) && numericColspan > 0 ? numericColspan : 1;
25995
+ };
25996
+ const resolveGridBefore = (row) => {
25997
+ const rawGridBefore = row?.attrs?.tableRowProperties?.gridBefore ?? row?.attrs?.gridBefore;
25998
+ const numericGridBefore = typeof rawGridBefore === "string" ? parseInt(rawGridBefore, 10) : rawGridBefore;
25999
+ if (!Number.isFinite(numericGridBefore) || numericGridBefore <= 0) return 0;
26000
+ const cells = Array.isArray(row.content) ? row.content : [];
26001
+ let leadingGridBefore = 0;
26002
+ while (leadingGridBefore < cells.length && cells[leadingGridBefore]?.attrs?.__placeholder === "gridBefore") {
26003
+ leadingGridBefore += 1;
26004
+ }
26005
+ return leadingGridBefore > 0 ? 0 : numericGridBefore;
26006
+ };
26007
+ const advanceColumnsForCell = (columnIndex, cell) => columnIndex + getColspan(cell);
26008
+ const getCellStartColumn = (row, targetCell) => {
26009
+ const cells = Array.isArray(row.content) ? row.content : [];
26010
+ let columnIndex = resolveGridBefore(row);
26011
+ for (const cell of cells) {
26012
+ if (cell === targetCell) return columnIndex;
26013
+ columnIndex = advanceColumnsForCell(columnIndex, cell);
26014
+ }
26015
+ return columnIndex;
26016
+ };
26017
+ const findCellCoveringColumn = (row, targetColumn) => {
26018
+ const cells = Array.isArray(row.content) ? row.content : [];
26019
+ let columnIndex = resolveGridBefore(row);
26020
+ for (const cell of cells) {
26021
+ const colspan = getColspan(cell);
26022
+ if (targetColumn >= columnIndex && targetColumn < columnIndex + colspan) {
26023
+ return cell;
26024
+ }
26025
+ columnIndex = advanceColumnsForCell(columnIndex, cell);
26026
+ }
26027
+ return null;
26028
+ };
26029
+ const findInsertionIndexForColumn = (row, targetColumn) => {
26030
+ const cells = Array.isArray(row.content) ? row.content : [];
26031
+ let columnIndex = resolveGridBefore(row);
26032
+ for (let index2 = 0; index2 < cells.length; index2++) {
26033
+ if (columnIndex >= targetColumn) return index2;
26034
+ columnIndex = advanceColumnsForCell(columnIndex, cells[index2]);
26035
+ }
26036
+ return cells.length;
26037
+ };
25966
26038
  function preProcessVerticalMergeCells(table, { editorSchema }) {
25967
26039
  if (!table || !Array.isArray(table.content)) {
25968
26040
  return table;
@@ -25978,15 +26050,17 @@ function preProcessVerticalMergeCells(table, { editorSchema }) {
25978
26050
  const cell = row.content[cellIndex];
25979
26051
  if (!cell) continue;
25980
26052
  const attrs = cell.attrs || {};
25981
- if (!attrs.rowspan || attrs.rowspan <= 1) continue;
25982
- const maxRowspan = Math.min(attrs.rowspan, rows.length - rowIndex);
26053
+ const rawRowspan = typeof attrs.rowspan === "string" ? parseInt(attrs.rowspan, 10) : attrs.rowspan;
26054
+ if (!Number.isFinite(rawRowspan) || rawRowspan <= 1) continue;
26055
+ const maxRowspan = Math.min(rawRowspan, rows.length - rowIndex);
26056
+ const startColumn = getCellStartColumn(row, cell);
25983
26057
  for (let offset = 1; offset < maxRowspan; offset++) {
25984
26058
  const rowToChange = rows[rowIndex + offset];
25985
26059
  if (!rowToChange) continue;
25986
26060
  if (!Array.isArray(rowToChange.content)) {
25987
26061
  rowToChange.content = [];
25988
26062
  }
25989
- const existingCell = rowToChange.content[cellIndex];
26063
+ const existingCell = findCellCoveringColumn(rowToChange, startColumn);
25990
26064
  if (existingCell?.attrs?.continueMerge) continue;
25991
26065
  const mergedCell = {
25992
26066
  type: cell.type,
@@ -25997,7 +26071,8 @@ function preProcessVerticalMergeCells(table, { editorSchema }) {
25997
26071
  continueMerge: true
25998
26072
  }
25999
26073
  };
26000
- rowToChange.content.splice(cellIndex, 0, mergedCell);
26074
+ const insertionIndex = findInsertionIndexForColumn(rowToChange, startColumn);
26075
+ rowToChange.content.splice(insertionIndex, 0, mergedCell);
26001
26076
  }
26002
26077
  }
26003
26078
  }
@@ -26149,15 +26224,24 @@ const encode$q = (params) => {
26149
26224
  const decode$s = (params) => {
26150
26225
  const { grid: rawGrid } = params.node.attrs || {};
26151
26226
  const grid = Array.isArray(rawGrid) ? rawGrid : [];
26152
- const { firstRow = {} } = params.extraParams || {};
26227
+ const { firstRow = {}, preferTableGrid = false, totalColumns: requestedColumns } = params.extraParams || {};
26153
26228
  const cellNodes = firstRow.content?.filter((n) => n.type === "tableCell") ?? [];
26154
- const colWidthsFromCellNodes = cellNodes.flatMap((cell) => {
26229
+ let colWidthsFromCellNodes = cellNodes.flatMap((cell) => {
26155
26230
  const spanCount = Math.max(1, cell?.attrs?.colspan ?? 1);
26156
26231
  const colwidth = cell.attrs?.colwidth;
26157
26232
  return Array.from({ length: spanCount }).map((_2, span) => Array.isArray(colwidth) ? colwidth[span] : void 0);
26158
26233
  });
26159
26234
  const columnCountFromCells = colWidthsFromCellNodes.length;
26160
- const totalColumns = Math.max(columnCountFromCells, grid.length);
26235
+ const gridColumnCount = grid.length;
26236
+ let totalColumns = Math.max(columnCountFromCells, gridColumnCount);
26237
+ if (typeof requestedColumns === "number" && Number.isFinite(requestedColumns) && requestedColumns > 0) {
26238
+ totalColumns = requestedColumns;
26239
+ } else if (preferTableGrid && gridColumnCount > 0) {
26240
+ totalColumns = gridColumnCount;
26241
+ }
26242
+ if (colWidthsFromCellNodes.length > totalColumns) {
26243
+ colWidthsFromCellNodes = colWidthsFromCellNodes.slice(0, totalColumns);
26244
+ }
26161
26245
  const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params, totalColumns, cellMinWidth);
26162
26246
  const elements = [];
26163
26247
  const pushColumn = (widthTwips, { enforceMinimum = false } = {}) => {
@@ -26417,22 +26501,31 @@ const encode$p = (params, encodedAttrs) => {
26417
26501
  const decode$r = (params, decodedAttrs) => {
26418
26502
  params.node = preProcessVerticalMergeCells(params.node, params);
26419
26503
  const { node } = params;
26420
- const elements = translateChildNodes(params);
26504
+ const rawGrid = node.attrs?.grid;
26505
+ const grid = Array.isArray(rawGrid) ? rawGrid : [];
26506
+ const preferTableGrid = node.attrs?.userEdited !== true && grid.length > 0;
26507
+ const totalColumns = preferTableGrid ? grid.length : void 0;
26508
+ const extraParams = {
26509
+ ...params.extraParams || {},
26510
+ preferTableGrid,
26511
+ totalColumns
26512
+ };
26513
+ const elements = translateChildNodes({ ...params, extraParams });
26421
26514
  const firstRow = node.content?.find((n) => n.type === "tableRow");
26422
- const properties = node.attrs.grid;
26423
26515
  const element = translator$c.decode({
26424
26516
  ...params,
26425
- node: { ...node, attrs: { ...node.attrs, grid: properties } },
26517
+ node: { ...node, attrs: { ...node.attrs, grid } },
26426
26518
  extraParams: {
26519
+ ...extraParams,
26427
26520
  firstRow
26428
26521
  }
26429
26522
  });
26430
26523
  if (element) elements.unshift(element);
26431
26524
  if (node.attrs?.tableProperties) {
26432
- const properties2 = { ...node.attrs.tableProperties };
26525
+ const properties = { ...node.attrs.tableProperties };
26433
26526
  const element2 = translator$e.decode({
26434
26527
  ...params,
26435
- node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
26528
+ node: { ...node, attrs: { ...node.attrs, tableProperties: properties } }
26436
26529
  });
26437
26530
  if (element2) elements.unshift(element2);
26438
26531
  }
@@ -29678,10 +29771,10 @@ function ensureSectionProperties(bodyNode) {
29678
29771
  function getStyleDefinitions(docx) {
29679
29772
  const styles = docx["word/styles.xml"];
29680
29773
  if (!styles) return [];
29681
- const { elements } = styles.elements[0];
29774
+ const elements = styles.elements?.[0]?.elements ?? [];
29682
29775
  const styleDefinitions = elements.filter((el) => el.name === "w:style");
29683
29776
  const latentStyles = elements.find((el) => el.name === "w:latentStyles");
29684
- latentStyles?.elements.forEach((el) => {
29777
+ (latentStyles?.elements ?? []).forEach((el) => {
29685
29778
  const { attributes } = el;
29686
29779
  styleDefinitions.find((style) => style.attributes["w:styleId"] === attributes["w:name"]);
29687
29780
  });
@@ -31564,7 +31657,7 @@ class SuperConverter {
31564
31657
  static getStoredSuperdocVersion(docx) {
31565
31658
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
31566
31659
  }
31567
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.5.0-next.4") {
31660
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.5.0-next.6") {
31568
31661
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
31569
31662
  }
31570
31663
  /**
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const jszip = require("./jszip-C8_CqJxM.cjs");
3
3
  const helpers$1 = require("./helpers-nOdwpmwb.cjs");
4
- const superEditor_converter = require("./SuperConverter-C2G21inU.cjs");
4
+ const superEditor_converter = require("./SuperConverter-Cih2T-NE.cjs");
5
5
  const vue = require("./vue-De9wkgLl.cjs");
6
6
  require("./jszip.min-BPh2MMAa.cjs");
7
7
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
@@ -15524,7 +15524,7 @@ const canUseDOM = () => {
15524
15524
  return false;
15525
15525
  }
15526
15526
  };
15527
- const summaryVersion = "1.5.0-next.4";
15527
+ const summaryVersion = "1.5.0-next.6";
15528
15528
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15529
15529
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15530
15530
  function mapAttributes(attrs) {
@@ -18181,7 +18181,7 @@ class Editor extends EventEmitter {
18181
18181
  * Process collaboration migrations
18182
18182
  */
18183
18183
  processCollaborationMigrations() {
18184
- console.debug("[checkVersionMigrations] Current editor version", "1.5.0-next.4");
18184
+ console.debug("[checkVersionMigrations] Current editor version", "1.5.0-next.6");
18185
18185
  if (!this.options.ydoc) return;
18186
18186
  const metaMap = this.options.ydoc.getMap("meta");
18187
18187
  let docVersion = metaMap.get("version");
@@ -1,6 +1,6 @@
1
1
  import { B as Buffer$2 } from "./jszip-B1fkPkPJ.es.js";
2
2
  import { t as twipsToInches, i as inchesToTwips, p as ptToTwips, l as linesToTwips, a as twipsToLines, b as pixelsToTwips, h as halfPointToPoints, c as twipsToPixels$2, d as convertSizeToCSS, e as inchesToPixels } from "./helpers-C8e9wR5l.es.js";
3
- import { g as generateDocxRandomId, T as TextSelection$1, o as objectIncludes, w as wrapTextsInRuns, D as DOMParser$1, c as createDocFromMarkdown, a as createDocFromHTML, b as chainableEditorState, d as convertMarkdownToHTML, f as findParentNode, e as findParentNodeClosestToPos, h as generateRandom32BitHex, i as generateRandomSigned32BitIntStrId, P as PluginKey, j as Plugin, M as Mapping, N as NodeSelection, k as Selection, l as Slice, m as DOMSerializer, F as Fragment, n as Mark$1, p as dropPoint, A as AllSelection, q as Schema$1, s as canSplit, t as resolveRunProperties, u as encodeMarksFromRPr, v as liftTarget, x as canJoin, y as joinPoint, z as replaceStep$1, R as ReplaceAroundStep$1, B as htmlHandler, C as ReplaceStep, E as getResolvedParagraphProperties, G as changeListLevel, H as isList$1, I as updateNumberingProperties, L as ListHelpers, J as inputRulesPlugin, K as TrackDeleteMarkName$1, O as TrackInsertMarkName$1, Q as TrackFormatMarkName$1, U as AddMarkStep, V as RemoveMarkStep, W as CommandService, S as SuperConverter, X as EditorState, Y as unflattenListsInHtml, Z as SelectionRange, _ as Transform, $ as createOoxmlResolver, a0 as translator, a1 as translator$1, a2 as resolveDocxFontFamily, a3 as combineIndentProperties, a4 as _getReferencedTableStyles, a5 as decodeRPrFromMarks, a6 as calculateResolvedParagraphProperties, a7 as encodeCSSFromPPr, a8 as encodeCSSFromRPr, a9 as generateOrderedListIndex, aa as docxNumberingHelpers, ab as InputRule, ac as insertNewRelationship, ad as kebabCase$1, ae as getUnderlineCssString } from "./SuperConverter-C1C9dtqW.es.js";
3
+ import { g as generateDocxRandomId, T as TextSelection$1, o as objectIncludes, w as wrapTextsInRuns, D as DOMParser$1, c as createDocFromMarkdown, a as createDocFromHTML, b as chainableEditorState, d as convertMarkdownToHTML, f as findParentNode, e as findParentNodeClosestToPos, h as generateRandom32BitHex, i as generateRandomSigned32BitIntStrId, P as PluginKey, j as Plugin, M as Mapping, N as NodeSelection, k as Selection, l as Slice, m as DOMSerializer, F as Fragment, n as Mark$1, p as dropPoint, A as AllSelection, q as Schema$1, s as canSplit, t as resolveRunProperties, u as encodeMarksFromRPr, v as liftTarget, x as canJoin, y as joinPoint, z as replaceStep$1, R as ReplaceAroundStep$1, B as htmlHandler, C as ReplaceStep, E as getResolvedParagraphProperties, G as changeListLevel, H as isList$1, I as updateNumberingProperties, L as ListHelpers, J as inputRulesPlugin, K as TrackDeleteMarkName$1, O as TrackInsertMarkName$1, Q as TrackFormatMarkName$1, U as AddMarkStep, V as RemoveMarkStep, W as CommandService, S as SuperConverter, X as EditorState, Y as unflattenListsInHtml, Z as SelectionRange, _ as Transform, $ as createOoxmlResolver, a0 as translator, a1 as translator$1, a2 as resolveDocxFontFamily, a3 as combineIndentProperties, a4 as _getReferencedTableStyles, a5 as decodeRPrFromMarks, a6 as calculateResolvedParagraphProperties, a7 as encodeCSSFromPPr, a8 as encodeCSSFromRPr, a9 as generateOrderedListIndex, aa as docxNumberingHelpers, ab as InputRule, ac as insertNewRelationship, ad as kebabCase$1, ae as getUnderlineCssString } from "./SuperConverter-q49H1rID.es.js";
4
4
  import { p as process$1, r as ref, C as global$1, c as computed, E as createElementBlock, F as Fragment$1, S as renderList, O as withModifiers, G as openBlock, P as normalizeClass, M as createCommentVNode, H as toDisplayString, K as createBaseVNode, U as createApp, f as onMounted, X as onUnmounted, R as withDirectives, v as unref, Y as vModelText, y as nextTick, L as normalizeStyle, u as watch, Z as withKeys, _ as createTextVNode, I as createVNode, h as h$1, $ as readonly, s as getCurrentInstance, o as onBeforeUnmount, j as reactive, b as onBeforeMount, i as inject, a0 as onActivated, a1 as onDeactivated, a2 as Comment, d as defineComponent, a as provide, g as Teleport, t as toRef, a3 as renderSlot, a4 as isVNode, D as shallowRef, w as watchEffect, T as Transition, a5 as mergeProps, a6 as vShow, a7 as cloneVNode, a8 as Text$2, m as markRaw, N as createBlock, J as withCtx, a9 as useCssVars, V as resolveDynamicComponent, aa as normalizeProps, ab as guardReactiveProps } from "./vue-BnBKJwCW.es.js";
5
5
  import "./jszip.min-DCl8qkFO.es.js";
6
6
  import { E as EventEmitter$1 } from "./eventemitter3-CwrdEv8r.es.js";
@@ -15507,7 +15507,7 @@ const canUseDOM = () => {
15507
15507
  return false;
15508
15508
  }
15509
15509
  };
15510
- const summaryVersion = "1.5.0-next.4";
15510
+ const summaryVersion = "1.5.0-next.6";
15511
15511
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15512
15512
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15513
15513
  function mapAttributes(attrs) {
@@ -18164,7 +18164,7 @@ class Editor extends EventEmitter {
18164
18164
  * Process collaboration migrations
18165
18165
  */
18166
18166
  processCollaborationMigrations() {
18167
- console.debug("[checkVersionMigrations] Current editor version", "1.5.0-next.4");
18167
+ console.debug("[checkVersionMigrations] Current editor version", "1.5.0-next.6");
18168
18168
  if (!this.options.ydoc) return;
18169
18169
  const metaMap = this.options.ydoc.getMap("meta");
18170
18170
  let docVersion = metaMap.get("version");
@@ -1,5 +1,5 @@
1
- import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-QGIv94xy.es.js";
2
- import "./SuperConverter-C1C9dtqW.es.js";
1
+ import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-BgZnM0Uj.es.js";
2
+ import "./SuperConverter-q49H1rID.es.js";
3
3
  import { B as BlankDOCX } from "./blank-docx-ABm6XYAA.es.js";
4
4
  import { E as EventEmitter } from "./eventemitter3-CwrdEv8r.es.js";
5
5
  import { HocuspocusProvider, HocuspocusProviderWebsocket } from "@hocuspocus/provider";
@@ -7513,7 +7513,7 @@ const _sfc_main = {
7513
7513
  __name: "SuperDoc",
7514
7514
  emits: ["selection-update"],
7515
7515
  setup(__props, { emit: __emit }) {
7516
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-CNp14NHv.es.js"));
7516
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-DICnVjkl.es.js"));
7517
7517
  const superdocStore = useSuperdocStore();
7518
7518
  const commentsStore = useCommentsStore();
7519
7519
  const {
@@ -8467,7 +8467,7 @@ class SuperDoc extends EventEmitter {
8467
8467
  this.config.colors = shuffleArray(this.config.colors);
8468
8468
  this.userColorMap = /* @__PURE__ */ new Map();
8469
8469
  this.colorIndex = 0;
8470
- this.version = "1.5.0-next.4";
8470
+ this.version = "1.5.0-next.6";
8471
8471
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8472
8472
  this.superdocId = config.superdocId || v4();
8473
8473
  this.colors = this.config.colors;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const index = require("./index-CEzpmlwg.cjs");
3
- require("./SuperConverter-C2G21inU.cjs");
2
+ const index = require("./index-224wdSXe.cjs");
3
+ require("./SuperConverter-Cih2T-NE.cjs");
4
4
  const blankDocx = require("./blank-docx-DfW3Eeh2.cjs");
5
5
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
6
6
  const provider = require("@hocuspocus/provider");
@@ -7530,7 +7530,7 @@ const _sfc_main = {
7530
7530
  __name: "SuperDoc",
7531
7531
  emits: ["selection-update"],
7532
7532
  setup(__props, { emit: __emit }) {
7533
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-DQXxuY1J.cjs")));
7533
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-Bm3aYkue.cjs")));
7534
7534
  const superdocStore = useSuperdocStore();
7535
7535
  const commentsStore = useCommentsStore();
7536
7536
  const {
@@ -8484,7 +8484,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
8484
8484
  this.config.colors = shuffleArray(this.config.colors);
8485
8485
  this.userColorMap = /* @__PURE__ */ new Map();
8486
8486
  this.colorIndex = 0;
8487
- this.version = "1.5.0-next.4";
8487
+ this.version = "1.5.0-next.6";
8488
8488
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8489
8489
  this.superdocId = config.superdocId || uuid.v4();
8490
8490
  this.colors = this.config.colors;
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("../chunks/jszip-C8_CqJxM.cjs");
4
4
  require("../chunks/helpers-nOdwpmwb.cjs");
5
- const superEditor_converter = require("../chunks/SuperConverter-C2G21inU.cjs");
5
+ const superEditor_converter = require("../chunks/SuperConverter-Cih2T-NE.cjs");
6
6
  require("../chunks/uuid-R7L08bOx.cjs");
7
7
  exports.SuperConverter = superEditor_converter.SuperConverter;
@@ -1,6 +1,6 @@
1
1
  import "../chunks/jszip-B1fkPkPJ.es.js";
2
2
  import "../chunks/helpers-C8e9wR5l.es.js";
3
- import { S } from "../chunks/SuperConverter-C1C9dtqW.es.js";
3
+ import { S } from "../chunks/SuperConverter-q49H1rID.es.js";
4
4
  import "../chunks/uuid-CjlX8hrF.es.js";
5
5
  export {
6
6
  S as SuperConverter
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./chunks/index-CEzpmlwg.cjs");
3
+ const index = require("./chunks/index-224wdSXe.cjs");
4
4
  const superEditor_docxZipper = require("./super-editor/docx-zipper.cjs");
5
5
  const superEditor_fileZipper = require("./super-editor/file-zipper.cjs");
6
6
  const vue = require("./chunks/vue-De9wkgLl.cjs");
7
- const superEditor_converter = require("./chunks/SuperConverter-C2G21inU.cjs");
7
+ const superEditor_converter = require("./chunks/SuperConverter-Cih2T-NE.cjs");
8
8
  function isNodeType(node, name) {
9
9
  return node.type.name === name;
10
10
  }
@@ -1,9 +1,9 @@
1
- import { ax as Node, ay as Mark } from "./chunks/index-QGIv94xy.es.js";
2
- import { ao, au, a9, ab, aw, am, av, aA, an, ak, aq, az, aa, as, aC, aE, aB, ac, aD, ar, at } from "./chunks/index-QGIv94xy.es.js";
1
+ import { ax as Node, ay as Mark } from "./chunks/index-BgZnM0Uj.es.js";
2
+ import { ao, au, a9, ab, aw, am, av, aA, an, ak, aq, az, aa, as, aC, aE, aB, ac, aD, ar, at } from "./chunks/index-BgZnM0Uj.es.js";
3
3
  import { default as default2 } from "./super-editor/docx-zipper.es.js";
4
4
  import { createZip } from "./super-editor/file-zipper.es.js";
5
5
  import { d as defineComponent, E as createElementBlock, G as openBlock, K as createBaseVNode } from "./chunks/vue-BnBKJwCW.es.js";
6
- import { S, r } from "./chunks/SuperConverter-C1C9dtqW.es.js";
6
+ import { S, r } from "./chunks/SuperConverter-q49H1rID.es.js";
7
7
  function isNodeType(node, name) {
8
8
  return node.type.name === name;
9
9
  }
package/dist/superdoc.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./chunks/index-CEzpmlwg.cjs");
4
- const superdoc = require("./chunks/index-Cx9Sx4Ap.cjs");
5
- const superEditor_converter = require("./chunks/SuperConverter-C2G21inU.cjs");
3
+ const index = require("./chunks/index-224wdSXe.cjs");
4
+ const superdoc = require("./chunks/index-RKdc-5FM.cjs");
5
+ const superEditor_converter = require("./chunks/SuperConverter-Cih2T-NE.cjs");
6
6
  const blankDocx = require("./chunks/blank-docx-DfW3Eeh2.cjs");
7
7
  require("./chunks/jszip-C8_CqJxM.cjs");
8
8
  require("./chunks/helpers-nOdwpmwb.cjs");
@@ -1,6 +1,6 @@
1
- import { au, ab, aw, av, as, a7, ac, ar, at } from "./chunks/index-QGIv94xy.es.js";
2
- import { D, H, P, S, c } from "./chunks/index-Be6dYM8u.es.js";
3
- import { S as S2, r } from "./chunks/SuperConverter-C1C9dtqW.es.js";
1
+ import { au, ab, aw, av, as, a7, ac, ar, at } from "./chunks/index-BgZnM0Uj.es.js";
2
+ import { D, H, P, S, c } from "./chunks/index-BhJCVQFg.es.js";
3
+ import { S as S2, r } from "./chunks/SuperConverter-q49H1rID.es.js";
4
4
  import { B } from "./chunks/blank-docx-ABm6XYAA.es.js";
5
5
  import "./chunks/jszip-B1fkPkPJ.es.js";
6
6
  import "./chunks/helpers-C8e9wR5l.es.js";