@harbour-enterprises/superdoc 0.24.0-next.4 → 0.24.0-next.5

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 (33) hide show
  1. package/dist/chunks/{PdfViewer-kOVuv-4I.cjs → PdfViewer-D6AmuQ3v.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-D7C8g2G4.es.js → PdfViewer-XhwjWR8o.es.js} +1 -1
  3. package/dist/chunks/{index-BFKwBQjS.cjs → index-DAdhqIN8.cjs} +66 -10
  4. package/dist/chunks/{index-CnEAVnHQ.es.js → index-OjiyjDUm.es.js} +66 -10
  5. package/dist/chunks/{super-editor.es-BmGTQ05x.cjs → super-editor.es-BPK2gF1W.cjs} +484 -132
  6. package/dist/chunks/{super-editor.es-CBPoWvjs.es.js → super-editor.es-bHlpz8m_.es.js} +484 -132
  7. package/dist/core/SuperDoc.d.ts.map +1 -1
  8. package/dist/core/helpers/export.d.ts +1 -1
  9. package/dist/core/helpers/export.d.ts.map +1 -1
  10. package/dist/core/types/index.d.ts.map +1 -1
  11. package/dist/style.css +10 -0
  12. package/dist/super-editor/ai-writer.es.js +2 -2
  13. package/dist/super-editor/chunks/{converter-DpPj67OW.js → converter-D-9mYZ83.js} +419 -192
  14. package/dist/super-editor/chunks/{docx-zipper-6Kc95yG-.js → docx-zipper-C1p3F7Ok.js} +1 -1
  15. package/dist/super-editor/chunks/{editor-Dx6AhT5N.js → editor-lJoa5ADp.js} +170 -43
  16. package/dist/super-editor/chunks/{toolbar-CXSg2lJ9.js → toolbar-B5-QnQ4l.js} +2 -2
  17. package/dist/super-editor/converter.es.js +1 -1
  18. package/dist/super-editor/docx-zipper.es.js +2 -2
  19. package/dist/super-editor/editor.es.js +3 -3
  20. package/dist/super-editor/file-zipper.es.js +1 -1
  21. package/dist/super-editor/style.css +10 -0
  22. package/dist/super-editor/super-editor/src/core/super-converter/helpers.d.ts +1 -0
  23. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tr/tr-helpers.d.ts +16 -0
  24. package/dist/super-editor/super-editor/src/extensions/table/TableView.d.ts +1 -1
  25. package/dist/super-editor/super-editor.es.js +7 -7
  26. package/dist/super-editor/toolbar.es.js +2 -2
  27. package/dist/super-editor.cjs +1 -1
  28. package/dist/super-editor.es.js +1 -1
  29. package/dist/superdoc.cjs +2 -2
  30. package/dist/superdoc.es.js +2 -2
  31. package/dist/superdoc.umd.js +548 -140
  32. package/dist/superdoc.umd.js.map +1 -1
  33. package/package.json +1 -1
@@ -15076,6 +15076,7 @@ async function readFromClipboard(state2) {
15076
15076
  }
15077
15077
  return content;
15078
15078
  }
15079
+ const PIXELS_PER_INCH = 96;
15079
15080
  function inchesToTwips(inches) {
15080
15081
  if (inches == null) return;
15081
15082
  if (typeof inches === "string") inches = parseFloat(inches);
@@ -15098,12 +15099,12 @@ function pixelsToTwips(pixels) {
15098
15099
  }
15099
15100
  function inchesToPixels(inches) {
15100
15101
  if (inches == null) return;
15101
- const pixels = inches * 96;
15102
+ const pixels = inches * PIXELS_PER_INCH;
15102
15103
  return Math.round(pixels * 1e3) / 1e3;
15103
15104
  }
15104
15105
  function pixelsToInches(pixels) {
15105
15106
  if (pixels == null) return;
15106
- const inches = Number(pixels) / 96;
15107
+ const inches = Number(pixels) / PIXELS_PER_INCH;
15107
15108
  return inches;
15108
15109
  }
15109
15110
  function twipsToLines(twips) {
@@ -15121,7 +15122,7 @@ function halfPointToPoints(halfPoints) {
15121
15122
  function emuToPixels(emu) {
15122
15123
  if (emu == null) return;
15123
15124
  if (typeof emu === "string") emu = parseFloat(emu);
15124
- const pixels = emu * 96 / 914400;
15125
+ const pixels = emu * PIXELS_PER_INCH / 914400;
15125
15126
  return Math.round(pixels);
15126
15127
  }
15127
15128
  function pixelsToEmu(px) {
@@ -15157,12 +15158,12 @@ function degreesToRot(degrees) {
15157
15158
  }
15158
15159
  function pixelsToPolygonUnits(pixels) {
15159
15160
  if (pixels == null) return;
15160
- const pu = pixels * 96;
15161
+ const pu = pixels * PIXELS_PER_INCH;
15161
15162
  return Math.round(pu);
15162
15163
  }
15163
15164
  function polygonUnitsToPixels(pu) {
15164
15165
  if (pu == null) return;
15165
- const pixels = Number(pu) / 96;
15166
+ const pixels = Number(pu) / PIXELS_PER_INCH;
15166
15167
  return Math.round(pixels * 1e3) / 1e3;
15167
15168
  }
15168
15169
  function polygonToObj(polygonNode) {
@@ -27038,6 +27039,68 @@ const translator$_ = NodeTranslator.from(
27038
27039
  repeatHeader: false
27039
27040
  })
27040
27041
  );
27042
+ const createPlaceholderCell = (gridWidth, reason) => {
27043
+ const safeWidth = Number.isFinite(gridWidth) ? gridWidth : 0;
27044
+ const noBorder = { val: "none", size: 0 };
27045
+ return {
27046
+ type: "tableCell",
27047
+ attrs: {
27048
+ colspan: 1,
27049
+ rowspan: 1,
27050
+ colwidth: [safeWidth],
27051
+ __placeholder: reason,
27052
+ borders: {
27053
+ top: { ...noBorder },
27054
+ right: { ...noBorder },
27055
+ bottom: { ...noBorder },
27056
+ left: { ...noBorder }
27057
+ }
27058
+ },
27059
+ content: [{ type: "paragraph", content: [] }]
27060
+ };
27061
+ };
27062
+ const advancePastRowSpans = (pendingRowSpans, startIndex, totalColumns) => {
27063
+ let index2 = startIndex;
27064
+ while (index2 < totalColumns && pendingRowSpans[index2] > 0) {
27065
+ pendingRowSpans[index2] -= 1;
27066
+ index2 += 1;
27067
+ }
27068
+ return index2;
27069
+ };
27070
+ const fillPlaceholderColumns = ({
27071
+ content,
27072
+ pendingRowSpans,
27073
+ currentIndex,
27074
+ targetIndex,
27075
+ totalColumns,
27076
+ gridColumnWidths,
27077
+ reason
27078
+ }) => {
27079
+ let index2 = currentIndex;
27080
+ while (index2 < targetIndex && index2 < totalColumns) {
27081
+ if (pendingRowSpans[index2] > 0) {
27082
+ pendingRowSpans[index2] -= 1;
27083
+ index2 += 1;
27084
+ continue;
27085
+ }
27086
+ const width = Array.isArray(gridColumnWidths) ? gridColumnWidths[index2] ?? 0 : 0;
27087
+ content.push(createPlaceholderCell(width, reason));
27088
+ index2 += 1;
27089
+ }
27090
+ return index2;
27091
+ };
27092
+ const isPlaceholderCell = (cell) => {
27093
+ if (!cell) return false;
27094
+ if (cell.attrs?.__placeholder) return true;
27095
+ const widths = cell.attrs?.colwidth;
27096
+ if (Array.isArray(widths) && widths.length > 0) {
27097
+ const hasMeaningfulWidth = widths.some(
27098
+ (value) => typeof value === "number" && Number.isFinite(value) && Math.abs(value) > 1
27099
+ );
27100
+ if (!hasMeaningfulWidth) return true;
27101
+ }
27102
+ return false;
27103
+ };
27041
27104
  const XML_NODE_NAME$h = "w:tr";
27042
27105
  const SD_NODE_NAME$d = "tableRow";
27043
27106
  const validXmlAttributes$b = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
@@ -27053,29 +27116,64 @@ const encode$n = (params2, encodedAttrs) => {
27053
27116
  nodes: [tPr]
27054
27117
  });
27055
27118
  }
27119
+ const gridBeforeRaw = tableRowProperties?.["gridBefore"];
27120
+ const safeGridBefore = typeof gridBeforeRaw === "number" && Number.isFinite(gridBeforeRaw) && gridBeforeRaw > 0 ? gridBeforeRaw : 0;
27056
27121
  encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
27057
27122
  encodedAttrs["rowHeight"] = twipsToPixels(tableRowProperties["rowHeight"]?.value);
27058
27123
  encodedAttrs["cantSplit"] = tableRowProperties["cantSplit"];
27059
- const { columnWidths: gridColumnWidths } = params2.extraParams;
27124
+ const { columnWidths: gridColumnWidths, activeRowSpans = [] } = params2.extraParams;
27125
+ const totalColumns = Array.isArray(gridColumnWidths) ? gridColumnWidths.length : 0;
27126
+ const pendingRowSpans = Array.isArray(activeRowSpans) ? activeRowSpans.slice() : [];
27127
+ while (pendingRowSpans.length < totalColumns) pendingRowSpans.push(0);
27060
27128
  const cellNodes = row.elements.filter((el) => el.name === "w:tc");
27129
+ const content = [];
27061
27130
  let currentColumnIndex = 0;
27062
- const content = cellNodes?.map((n) => {
27063
- let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
27131
+ const fillUntil = (target, reason) => {
27132
+ currentColumnIndex = fillPlaceholderColumns({
27133
+ content,
27134
+ pendingRowSpans,
27135
+ currentIndex: currentColumnIndex,
27136
+ targetIndex: target,
27137
+ totalColumns,
27138
+ gridColumnWidths,
27139
+ reason
27140
+ });
27141
+ };
27142
+ const skipOccupiedColumns = () => {
27143
+ currentColumnIndex = advancePastRowSpans(pendingRowSpans, currentColumnIndex, totalColumns);
27144
+ };
27145
+ fillUntil(safeGridBefore, "gridBefore");
27146
+ skipOccupiedColumns();
27147
+ cellNodes?.forEach((node) => {
27148
+ skipOccupiedColumns();
27149
+ const startColumn = currentColumnIndex;
27150
+ const columnWidth = gridColumnWidths?.[startColumn] || null;
27064
27151
  const result = translator$c.encode({
27065
27152
  ...params2,
27066
27153
  extraParams: {
27067
27154
  ...params2.extraParams,
27068
- node: n,
27069
- columnIndex: currentColumnIndex,
27155
+ node,
27156
+ columnIndex: startColumn,
27070
27157
  columnWidth
27071
27158
  }
27072
27159
  });
27073
- const tcPr = n.elements?.find((el) => el.name === "w:tcPr");
27074
- const colspanTag = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
27075
- const colspan = parseInt(colspanTag?.attributes["w:val"] || 1, 10);
27076
- currentColumnIndex += colspan;
27077
- return result;
27078
- }) || [];
27160
+ if (result) {
27161
+ content.push(result);
27162
+ const colspan = Math.max(1, result.attrs?.colspan || 1);
27163
+ const rowspan = Math.max(1, result.attrs?.rowspan || 1);
27164
+ if (rowspan > 1) {
27165
+ for (let offset2 = 0; offset2 < colspan; offset2 += 1) {
27166
+ const target = startColumn + offset2;
27167
+ if (target < pendingRowSpans.length) {
27168
+ pendingRowSpans[target] = Math.max(pendingRowSpans[target], rowspan - 1);
27169
+ }
27170
+ }
27171
+ }
27172
+ currentColumnIndex = startColumn + colspan;
27173
+ }
27174
+ });
27175
+ skipOccupiedColumns();
27176
+ fillUntil(totalColumns, "gridAfter");
27079
27177
  const newNode = {
27080
27178
  type: "tableRow",
27081
27179
  content,
@@ -27085,9 +27183,37 @@ const encode$n = (params2, encodedAttrs) => {
27085
27183
  };
27086
27184
  const decode$p = (params2, decodedAttrs) => {
27087
27185
  const { node } = params2;
27088
- const elements = translateChildNodes(params2);
27186
+ const cells = node.content || [];
27187
+ let leadingPlaceholders = 0;
27188
+ while (leadingPlaceholders < cells.length && isPlaceholderCell(cells[leadingPlaceholders])) {
27189
+ leadingPlaceholders += 1;
27190
+ }
27191
+ let trailingPlaceholders = 0;
27192
+ while (trailingPlaceholders < cells.length - leadingPlaceholders && isPlaceholderCell(cells[cells.length - 1 - trailingPlaceholders])) {
27193
+ trailingPlaceholders += 1;
27194
+ }
27195
+ const trimmedSlice = cells.slice(leadingPlaceholders, cells.length - trailingPlaceholders);
27196
+ const sanitizedCells = trimmedSlice.map((cell) => {
27197
+ if (cell?.attrs && "__placeholder" in cell.attrs) {
27198
+ const { __placeholder, ...rest } = cell.attrs;
27199
+ return { ...cell, attrs: rest };
27200
+ }
27201
+ return cell;
27202
+ });
27203
+ const trimmedContent = sanitizedCells.filter((_2, index2) => !isPlaceholderCell(trimmedSlice[index2]));
27204
+ const translateParams = {
27205
+ ...params2,
27206
+ node: { ...node, content: trimmedContent }
27207
+ };
27208
+ const elements = translateChildNodes(translateParams);
27089
27209
  if (node.attrs?.tableRowProperties) {
27090
27210
  const tableRowProperties = { ...node.attrs.tableRowProperties };
27211
+ if (leadingPlaceholders > 0) {
27212
+ tableRowProperties.gridBefore = leadingPlaceholders;
27213
+ }
27214
+ if (trailingPlaceholders > 0) {
27215
+ tableRowProperties.gridAfter = trailingPlaceholders;
27216
+ }
27091
27217
  if (node.attrs.rowHeight != null) {
27092
27218
  const rowHeightPixels = twipsToPixels(node.attrs.tableRowProperties["rowHeight"]?.value);
27093
27219
  if (rowHeightPixels !== node.attrs.rowHeight) {
@@ -27317,17 +27443,21 @@ const decode$o = (params2) => {
27317
27443
  const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params2, totalColumns, cellMinWidth);
27318
27444
  const elements = [];
27319
27445
  let columnIndex = 0;
27320
- const pushColumn = (widthTwips) => {
27446
+ const pushColumn = (widthTwips, { enforceMinimum = false } = {}) => {
27321
27447
  let numericWidth = typeof widthTwips === "string" ? parseInt(widthTwips, 10) : widthTwips;
27448
+ let shouldEnforceMinimum = enforceMinimum;
27322
27449
  if (numericWidth == null || Number.isNaN(numericWidth) || numericWidth <= 0) {
27323
27450
  numericWidth = fallbackColumnWidthTwips;
27451
+ shouldEnforceMinimum = true;
27324
27452
  }
27325
- numericWidth = Math.max(numericWidth, cellMinWidth);
27453
+ const roundedWidth = Math.round(numericWidth);
27454
+ const minimumWidth = shouldEnforceMinimum ? cellMinWidth : 1;
27455
+ const safeWidth = Math.max(roundedWidth, minimumWidth);
27326
27456
  const decoded = translator$u.decode({
27327
27457
  node: { type: (
27328
27458
  /** @type {string} */
27329
27459
  translator$u.sdNodeOrKeyName
27330
- ), attrs: { col: numericWidth } }
27460
+ ), attrs: { col: safeWidth } }
27331
27461
  });
27332
27462
  if (decoded) elements.push(decoded);
27333
27463
  };
@@ -27335,13 +27465,17 @@ const decode$o = (params2) => {
27335
27465
  const { colspan = 1, colwidth } = cell?.attrs || {};
27336
27466
  const spanCount = Math.max(1, colspan);
27337
27467
  for (let span = 0; span < spanCount; span++) {
27338
- const cellWidthPixels = Array.isArray(colwidth) ? colwidth[span] : void 0;
27468
+ const rawWidth = Array.isArray(colwidth) ? colwidth[span] : void 0;
27469
+ const cellWidthPixels = typeof rawWidth === "number" && Number.isFinite(rawWidth) ? rawWidth : Number(rawWidth);
27470
+ const hasCellWidth = Number.isFinite(cellWidthPixels) && cellWidthPixels > 0;
27339
27471
  const colGridAttrs = grid?.[columnIndex] || {};
27340
27472
  const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
27341
27473
  const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
27342
27474
  let cellWidthTwips;
27343
- if (cellWidthPixels != null) {
27344
- if (gridWidthTwips != null && gridWidthPixels === cellWidthPixels) {
27475
+ let enforceMinimum = false;
27476
+ if (hasCellWidth) {
27477
+ const tolerance = 0.5;
27478
+ if (gridWidthTwips != null && gridWidthPixels != null && Math.abs(gridWidthPixels - cellWidthPixels) <= tolerance) {
27345
27479
  cellWidthTwips = gridWidthTwips;
27346
27480
  } else {
27347
27481
  cellWidthTwips = pixelsToTwips(cellWidthPixels);
@@ -27350,8 +27484,9 @@ const decode$o = (params2) => {
27350
27484
  cellWidthTwips = gridWidthTwips;
27351
27485
  } else {
27352
27486
  cellWidthTwips = fallbackColumnWidthTwips;
27487
+ enforceMinimum = true;
27353
27488
  }
27354
- pushColumn(cellWidthTwips);
27489
+ pushColumn(cellWidthTwips, { enforceMinimum });
27355
27490
  columnIndex++;
27356
27491
  }
27357
27492
  });
@@ -27514,7 +27649,9 @@ const encode$l = (params2, encodedAttrs) => {
27514
27649
  }
27515
27650
  }
27516
27651
  const content = [];
27517
- rows.forEach((row) => {
27652
+ const totalColumns = columnWidths.length;
27653
+ const activeRowSpans = totalColumns > 0 ? new Array(totalColumns).fill(0) : [];
27654
+ rows.forEach((row, rowIndex) => {
27518
27655
  const result = translator$Z.encode({
27519
27656
  ...params2,
27520
27657
  nodes: [row],
@@ -27523,10 +27660,45 @@ const encode$l = (params2, encodedAttrs) => {
27523
27660
  table: node,
27524
27661
  rowBorders: borderRowData,
27525
27662
  styleTag: tblStyleTag,
27526
- columnWidths
27663
+ columnWidths,
27664
+ activeRowSpans: activeRowSpans.slice(),
27665
+ rowIndex
27527
27666
  }
27528
27667
  });
27529
- if (result) content.push(result);
27668
+ if (result) {
27669
+ content.push(result);
27670
+ if (totalColumns > 0) {
27671
+ const activeRowSpansForCurrentRow = activeRowSpans.slice();
27672
+ for (let col = 0; col < totalColumns; col++) {
27673
+ if (activeRowSpans[col] > 0) {
27674
+ activeRowSpans[col] -= 1;
27675
+ }
27676
+ }
27677
+ let columnIndex = 0;
27678
+ const advanceColumnIndex = () => {
27679
+ while (columnIndex < totalColumns && activeRowSpansForCurrentRow[columnIndex] > 0) {
27680
+ columnIndex += 1;
27681
+ }
27682
+ };
27683
+ advanceColumnIndex();
27684
+ result.content?.forEach((cell) => {
27685
+ advanceColumnIndex();
27686
+ const colspan = Math.max(1, cell.attrs?.colspan || 1);
27687
+ const rowspan = Math.max(1, cell.attrs?.rowspan || 1);
27688
+ if (rowspan > 1) {
27689
+ for (let offset2 = 0; offset2 < colspan && columnIndex + offset2 < totalColumns; offset2++) {
27690
+ const targetIndex = columnIndex + offset2;
27691
+ const remainingRows = rowspan - 1;
27692
+ if (remainingRows > 0 && remainingRows > activeRowSpans[targetIndex]) {
27693
+ activeRowSpans[targetIndex] = remainingRows;
27694
+ }
27695
+ }
27696
+ }
27697
+ columnIndex += colspan;
27698
+ advanceColumnIndex();
27699
+ });
27700
+ }
27701
+ }
27530
27702
  });
27531
27703
  return {
27532
27704
  type: "table",
@@ -28492,6 +28664,7 @@ function sdtNodeTypeStrategy(node) {
28492
28664
  }
28493
28665
  return { type: "unknown", handler: null };
28494
28666
  }
28667
+ const DRAWING_XML_TAG = "w:drawing";
28495
28668
  function handleImageNode(node, params2, isAnchor) {
28496
28669
  const { docx, filename } = params2;
28497
28670
  const { attributes } = node;
@@ -28503,32 +28676,10 @@ function handleImageNode(node, params2, isAnchor) {
28503
28676
  };
28504
28677
  const extent = node.elements.find((el) => el.name === "wp:extent");
28505
28678
  const size2 = {
28506
- width: emuToPixels(extent.attributes?.cx),
28507
- height: emuToPixels(extent.attributes?.cy)
28679
+ width: emuToPixels(extent?.attributes?.cx),
28680
+ height: emuToPixels(extent?.attributes?.cy)
28508
28681
  };
28509
- const graphic = node.elements.find((el) => el.name === "a:graphic");
28510
- const graphicData = graphic.elements.find((el) => el.name === "a:graphicData");
28511
- const { uri: uri2 } = graphicData?.attributes || {};
28512
- const shapeURI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
28513
- if (!!uri2 && uri2 === shapeURI) {
28514
- return handleShapeDrawing(params2, node, graphicData);
28515
- }
28516
- const picture = graphicData.elements.find((el) => el.name === "pic:pic");
28517
- if (!picture || !picture.elements) return null;
28518
- const blipFill = picture.elements.find((el) => el.name === "pic:blipFill");
28519
- const blip = blipFill.elements.find((el) => el.name === "a:blip");
28520
- const spPr = picture.elements.find((el) => el.name === "pic:spPr");
28521
28682
  let transformData = {};
28522
- if (spPr) {
28523
- const xfrm = spPr.elements.find((el) => el.name === "a:xfrm");
28524
- if (xfrm?.attributes) {
28525
- transformData = {
28526
- rotation: rotToDegrees(xfrm.attributes["rot"]),
28527
- verticalFlip: xfrm.attributes["flipV"] === "1",
28528
- horizontalFlip: xfrm.attributes["flipH"] === "1"
28529
- };
28530
- }
28531
- }
28532
28683
  const effectExtent = node.elements.find((el) => el.name === "wp:effectExtent");
28533
28684
  if (effectExtent) {
28534
28685
  const sanitizeEmuValue = (value) => {
@@ -28537,22 +28688,26 @@ function handleImageNode(node, params2, isAnchor) {
28537
28688
  return Number.isFinite(numeric) ? numeric : 0;
28538
28689
  };
28539
28690
  transformData.sizeExtension = {
28540
- left: emuToPixels(sanitizeEmuValue(effectExtent.attributes["l"])),
28541
- top: emuToPixels(sanitizeEmuValue(effectExtent.attributes["t"])),
28542
- right: emuToPixels(sanitizeEmuValue(effectExtent.attributes["r"])),
28543
- bottom: emuToPixels(sanitizeEmuValue(effectExtent.attributes["b"]))
28691
+ left: emuToPixels(sanitizeEmuValue(effectExtent.attributes?.["l"])),
28692
+ top: emuToPixels(sanitizeEmuValue(effectExtent.attributes?.["t"])),
28693
+ right: emuToPixels(sanitizeEmuValue(effectExtent.attributes?.["r"])),
28694
+ bottom: emuToPixels(sanitizeEmuValue(effectExtent.attributes?.["b"]))
28544
28695
  };
28545
28696
  }
28546
28697
  const positionHTag = node.elements.find((el) => el.name === "wp:positionH");
28547
28698
  const positionH = positionHTag?.elements.find((el) => el.name === "wp:posOffset");
28548
28699
  const positionHValue = emuToPixels(positionH?.elements[0]?.text);
28549
- const hRelativeFrom = positionHTag?.attributes.relativeFrom;
28550
- const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements[0]?.text;
28700
+ const hRelativeFrom = positionHTag?.attributes?.relativeFrom;
28701
+ const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements?.[0]?.text;
28551
28702
  const positionVTag = node.elements.find((el) => el.name === "wp:positionV");
28552
28703
  const positionV = positionVTag?.elements?.find((el) => el.name === "wp:posOffset");
28553
28704
  const positionVValue = emuToPixels(positionV?.elements[0]?.text);
28554
- const vRelativeFrom = positionVTag?.attributes.relativeFrom;
28555
- const alignV = positionVTag?.elements?.find((el) => el.name === "wp:align")?.elements[0]?.text;
28705
+ const vRelativeFrom = positionVTag?.attributes?.relativeFrom;
28706
+ const alignV = positionVTag?.elements?.find((el) => el.name === "wp:align")?.elements?.[0]?.text;
28707
+ const marginOffset = {
28708
+ horizontal: positionHValue,
28709
+ top: positionVValue
28710
+ };
28556
28711
  const simplePos = node.elements.find((el) => el.name === "wp:simplePos");
28557
28712
  const wrapNode = isAnchor ? node.elements.find(
28558
28713
  (el) => ["wp:wrapNone", "wp:wrapSquare", "wp:wrapThrough", "wp:wrapTight", "wp:wrapTopAndBottom"].includes(el.name)
@@ -28560,38 +28715,40 @@ function handleImageNode(node, params2, isAnchor) {
28560
28715
  const wrap2 = isAnchor ? { type: wrapNode?.name.slice(7) || "None", attrs: {} } : { type: "Inline" };
28561
28716
  switch (wrap2.type) {
28562
28717
  case "Square":
28563
- wrap2.attrs.wrapText = wrapNode.attributes.wrapText;
28564
- if ("distB" in (wrapNode.attributes || {})) {
28718
+ if (wrapNode?.attributes?.wrapText) {
28719
+ wrap2.attrs.wrapText = wrapNode.attributes.wrapText;
28720
+ }
28721
+ if ("distB" in (wrapNode?.attributes || {})) {
28565
28722
  wrap2.attrs.distBottom = emuToPixels(wrapNode.attributes.distB);
28566
28723
  }
28567
- if ("distL" in (wrapNode.attributes || {})) {
28724
+ if ("distL" in (wrapNode?.attributes || {})) {
28568
28725
  wrap2.attrs.distLeft = emuToPixels(wrapNode.attributes.distL);
28569
28726
  }
28570
- if ("distR" in (wrapNode.attributes || {})) {
28727
+ if ("distR" in (wrapNode?.attributes || {})) {
28571
28728
  wrap2.attrs.distRight = emuToPixels(wrapNode.attributes.distR);
28572
28729
  }
28573
- if ("distT" in (wrapNode.attributes || {})) {
28730
+ if ("distT" in (wrapNode?.attributes || {})) {
28574
28731
  wrap2.attrs.distTop = emuToPixels(wrapNode.attributes.distT);
28575
28732
  }
28576
28733
  break;
28577
28734
  case "Tight":
28578
28735
  case "Through": {
28579
- if ("distL" in (wrapNode.attributes || {})) {
28736
+ if ("distL" in (wrapNode?.attributes || {})) {
28580
28737
  wrap2.attrs.distLeft = emuToPixels(wrapNode.attributes.distL);
28581
28738
  }
28582
- if ("distR" in (wrapNode.attributes || {})) {
28739
+ if ("distR" in (wrapNode?.attributes || {})) {
28583
28740
  wrap2.attrs.distRight = emuToPixels(wrapNode.attributes.distR);
28584
28741
  }
28585
- if ("distT" in (wrapNode.attributes || {})) {
28742
+ if ("distT" in (wrapNode?.attributes || {})) {
28586
28743
  wrap2.attrs.distTop = emuToPixels(wrapNode.attributes.distT);
28587
28744
  }
28588
- if ("distB" in (wrapNode.attributes || {})) {
28745
+ if ("distB" in (wrapNode?.attributes || {})) {
28589
28746
  wrap2.attrs.distBottom = emuToPixels(wrapNode.attributes.distB);
28590
28747
  }
28591
- if ("wrapText" in (wrapNode.attributes || {})) {
28748
+ if ("wrapText" in (wrapNode?.attributes || {})) {
28592
28749
  wrap2.attrs.wrapText = wrapNode.attributes.wrapText;
28593
28750
  }
28594
- const polygon = wrapNode.elements?.find((el) => el.name === "wp:wrapPolygon");
28751
+ const polygon = wrapNode?.elements?.find((el) => el.name === "wp:wrapPolygon");
28595
28752
  if (polygon) {
28596
28753
  wrap2.attrs.polygon = polygonToObj(polygon);
28597
28754
  if (polygon.attributes?.edited !== void 0) {
@@ -28601,10 +28758,10 @@ function handleImageNode(node, params2, isAnchor) {
28601
28758
  break;
28602
28759
  }
28603
28760
  case "TopAndBottom":
28604
- if ("distB" in (wrapNode.attributes || {})) {
28761
+ if ("distB" in (wrapNode?.attributes || {})) {
28605
28762
  wrap2.attrs.distBottom = emuToPixels(wrapNode.attributes.distB);
28606
28763
  }
28607
- if ("distT" in (wrapNode.attributes || {})) {
28764
+ if ("distT" in (wrapNode?.attributes || {})) {
28608
28765
  wrap2.attrs.distTop = emuToPixels(wrapNode.attributes.distT);
28609
28766
  }
28610
28767
  break;
@@ -28622,17 +28779,42 @@ function handleImageNode(node, params2, isAnchor) {
28622
28779
  alignV
28623
28780
  };
28624
28781
  }
28625
- const marginOffset = {
28626
- horizontal: positionHValue,
28627
- top: positionVValue
28628
- };
28782
+ const graphic = node.elements.find((el) => el.name === "a:graphic");
28783
+ const graphicData = graphic?.elements.find((el) => el.name === "a:graphicData");
28784
+ const { uri: uri2 } = graphicData?.attributes || {};
28785
+ const shapeURI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
28786
+ if (!!uri2 && uri2 === shapeURI) {
28787
+ const shapeMarginOffset = {
28788
+ left: positionHValue,
28789
+ horizontal: positionHValue,
28790
+ top: positionVValue
28791
+ };
28792
+ return handleShapeDrawing(params2, node, graphicData, size2, padding, shapeMarginOffset);
28793
+ }
28794
+ const picture = graphicData?.elements.find((el) => el.name === "pic:pic");
28795
+ if (!picture || !picture.elements) return null;
28796
+ const blipFill = picture.elements.find((el) => el.name === "pic:blipFill");
28797
+ const blip = blipFill?.elements.find((el) => el.name === "a:blip");
28798
+ if (!blip) return null;
28799
+ const spPr = picture.elements.find((el) => el.name === "pic:spPr");
28800
+ if (spPr) {
28801
+ const xfrm = spPr.elements.find((el) => el.name === "a:xfrm");
28802
+ if (xfrm?.attributes) {
28803
+ transformData = {
28804
+ ...transformData,
28805
+ rotation: rotToDegrees(xfrm.attributes["rot"]),
28806
+ verticalFlip: xfrm.attributes["flipV"] === "1",
28807
+ horizontalFlip: xfrm.attributes["flipH"] === "1"
28808
+ };
28809
+ }
28810
+ }
28629
28811
  const { attributes: blipAttributes = {} } = blip;
28630
28812
  const rEmbed = blipAttributes["r:embed"];
28631
28813
  if (!rEmbed) return null;
28632
28814
  const currentFile = filename || "document.xml";
28633
28815
  let rels = docx[`word/_rels/${currentFile}.rels`];
28634
28816
  if (!rels) rels = docx[`word/_rels/document.xml.rels`];
28635
- const relationships = rels.elements.find((el) => el.name === "Relationships");
28817
+ const relationships = rels?.elements.find((el) => el.name === "Relationships");
28636
28818
  const { elements } = relationships || [];
28637
28819
  const rel = elements?.find((el) => el.attributes["Id"] === rEmbed);
28638
28820
  if (!rel) return null;
@@ -28645,10 +28827,10 @@ function handleImageNode(node, params2, isAnchor) {
28645
28827
  type: "image",
28646
28828
  attrs: {
28647
28829
  src: path,
28648
- alt: ["emf", "wmf"].includes(extension) ? "Unable to render EMF/WMF image" : docPr?.attributes.name || "Image",
28830
+ alt: ["emf", "wmf"].includes(extension) ? "Unable to render EMF/WMF image" : docPr?.attributes?.name || "Image",
28649
28831
  extension,
28650
- id: docPr?.attributes.id || "",
28651
- title: docPr?.attributes.descr || "Image",
28832
+ id: docPr?.attributes?.id || "",
28833
+ title: docPr?.attributes?.descr || "Image",
28652
28834
  inline: true,
28653
28835
  padding,
28654
28836
  marginOffset,
@@ -28663,6 +28845,10 @@ function handleImageNode(node, params2, isAnchor) {
28663
28845
  }
28664
28846
  },
28665
28847
  wrap: wrap2,
28848
+ ...wrap2.type === "Square" && wrap2.attrs.wrapText ? {
28849
+ wrapText: wrap2.attrs.wrapText
28850
+ } : {},
28851
+ wrapTopAndBottom: wrap2.type === "TopAndBottom",
28666
28852
  originalPadding: {
28667
28853
  distT: attributes["distT"],
28668
28854
  distB: attributes["distB"],
@@ -28674,7 +28860,7 @@ function handleImageNode(node, params2, isAnchor) {
28674
28860
  }
28675
28861
  };
28676
28862
  }
28677
- const handleShapeDrawing = (params2, node, graphicData) => {
28863
+ const handleShapeDrawing = (params2, node, graphicData, size2, padding, marginOffset) => {
28678
28864
  const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
28679
28865
  const textBox = wsp.elements.find((el) => el.name === "wps:txbx");
28680
28866
  const textBoxContent = textBox?.elements?.find((el) => el.name === "w:txbxContent");
@@ -28685,21 +28871,14 @@ const handleShapeDrawing = (params2, node, graphicData) => {
28685
28871
  return getRectangleShape(params2, spPr);
28686
28872
  }
28687
28873
  if (!textBoxContent) {
28688
- return null;
28874
+ return buildShapePlaceholder(node, size2, padding, marginOffset, "drawing");
28689
28875
  }
28690
- const { nodeListHandler } = params2;
28691
- const translatedElement = nodeListHandler.handler({
28692
- ...params2,
28693
- node: textBoxContent.elements[0],
28694
- nodes: textBoxContent.elements,
28695
- path: [...params2.path || [], textBoxContent]
28696
- });
28697
- return translatedElement[0];
28876
+ return buildShapePlaceholder(node, size2, padding, marginOffset, "textbox");
28698
28877
  };
28699
28878
  const getRectangleShape = (params2, node) => {
28700
28879
  const schemaAttrs = {};
28701
28880
  const [drawingNode] = params2.nodes;
28702
- if (drawingNode?.name === "w:drawing") {
28881
+ if (drawingNode?.name === DRAWING_XML_TAG) {
28703
28882
  schemaAttrs.drawingContent = drawingNode;
28704
28883
  }
28705
28884
  const xfrm = node.elements.find((el) => el.name === "a:xfrm");
@@ -28723,6 +28902,52 @@ const getRectangleShape = (params2, node) => {
28723
28902
  attrs: schemaAttrs
28724
28903
  };
28725
28904
  };
28905
+ const buildShapePlaceholder = (node, size2, padding, marginOffset, shapeType) => {
28906
+ const attrs = {
28907
+ drawingContent: {
28908
+ name: DRAWING_XML_TAG,
28909
+ elements: [carbonCopy(node)]
28910
+ },
28911
+ attributes: {
28912
+ "data-shape-type": shapeType
28913
+ }
28914
+ };
28915
+ if (size2 && (Number.isFinite(size2.width) || Number.isFinite(size2.height))) {
28916
+ attrs.size = {
28917
+ ...Number.isFinite(size2.width) ? { width: size2.width } : {},
28918
+ ...Number.isFinite(size2.height) ? { height: size2.height } : {}
28919
+ };
28920
+ }
28921
+ if (padding) {
28922
+ const paddingData = {};
28923
+ if (Number.isFinite(padding.top)) paddingData["data-padding-top"] = padding.top;
28924
+ if (Number.isFinite(padding.right)) paddingData["data-padding-right"] = padding.right;
28925
+ if (Number.isFinite(padding.bottom)) paddingData["data-padding-bottom"] = padding.bottom;
28926
+ if (Number.isFinite(padding.left)) paddingData["data-padding-left"] = padding.left;
28927
+ if (Object.keys(paddingData).length) {
28928
+ attrs.attributes = {
28929
+ ...attrs.attributes,
28930
+ ...paddingData
28931
+ };
28932
+ }
28933
+ }
28934
+ if (marginOffset) {
28935
+ const offsetData = {};
28936
+ const horizontal = Number.isFinite(marginOffset.horizontal) ? marginOffset.horizontal : Number.isFinite(marginOffset.left) ? marginOffset.left : void 0;
28937
+ if (Number.isFinite(horizontal)) offsetData["data-offset-x"] = horizontal;
28938
+ if (Number.isFinite(marginOffset.top)) offsetData["data-offset-y"] = marginOffset.top;
28939
+ if (Object.keys(offsetData).length) {
28940
+ attrs.attributes = {
28941
+ ...attrs.attributes,
28942
+ ...offsetData
28943
+ };
28944
+ }
28945
+ }
28946
+ return {
28947
+ type: "contentBlock",
28948
+ attrs
28949
+ };
28950
+ };
28726
28951
  function handleAnchorNode(params2) {
28727
28952
  const { node } = params2.extraParams;
28728
28953
  if (node.name !== "wp:anchor") {
@@ -58931,8 +59156,11 @@ const HardBreak = Node$1.create({
58931
59156
  }
58932
59157
  });
58933
59158
  const getColStyleDeclaration = (minWidth, width) => {
58934
- if (width) {
58935
- return ["width", `${Math.max(width, minWidth)}px`];
59159
+ if (width != null) {
59160
+ const numericWidth = Number(width);
59161
+ if (Number.isFinite(numericWidth) && numericWidth >= 0) {
59162
+ return ["width", `${numericWidth}px`];
59163
+ }
58936
59164
  }
58937
59165
  return ["min-width", `${minWidth}px`];
58938
59166
  };
@@ -58954,7 +59182,7 @@ const createTableView = ({ editor }) => {
58954
59182
  this.table = this.dom.appendChild(document.createElement("table"));
58955
59183
  this.colgroup = this.table.appendChild(document.createElement("colgroup"));
58956
59184
  updateTable(this.editor, this.node, this.table);
58957
- updateColumns(node, this.colgroup, this.table, cellMinWidth2);
59185
+ updateColumns(node, this.colgroup, this.table, cellMinWidth2, void 0, void 0, this.editor);
58958
59186
  this.contentDOM = this.table.appendChild(document.createElement("tbody"));
58959
59187
  setTimeout(() => {
58960
59188
  updateTableWrapper(this.dom, this.table);
@@ -58966,7 +59194,7 @@ const createTableView = ({ editor }) => {
58966
59194
  }
58967
59195
  this.node = node;
58968
59196
  updateTable(this.editor, node, this.table);
58969
- updateColumns(node, this.colgroup, this.table, this.cellMinWidth);
59197
+ updateColumns(node, this.colgroup, this.table, this.cellMinWidth, void 0, void 0, this.editor);
58970
59198
  updateTableWrapper(this.dom, this.table);
58971
59199
  return true;
58972
59200
  }
@@ -58979,46 +59207,105 @@ const createTableView = ({ editor }) => {
58979
59207
  }
58980
59208
  };
58981
59209
  };
58982
- function updateColumns(node, colgroup, table, cellMinWidth2, overrideCol, overrideValue) {
58983
- let totalWidth = 0;
58984
- let fixedWidth = true;
58985
- let nextDOM = colgroup.firstChild;
59210
+ function updateColumns(node, colgroup, table, cellMinWidth2, overrideCol, overrideValue, editor) {
59211
+ const gridColumns = Array.isArray(node.attrs?.grid) && node.attrs.grid.length ? node.attrs.grid.map((col) => twipsToPixels(col.col)) : null;
59212
+ const totalColumns = gridColumns?.length ?? null;
59213
+ const pageBody = table.closest(".page__body");
59214
+ const wrapper = table.parentElement;
59215
+ let availableWidth = pageBody?.getBoundingClientRect?.().width;
59216
+ if (!availableWidth && wrapper) {
59217
+ availableWidth = wrapper.getBoundingClientRect().width;
59218
+ }
59219
+ if (typeof availableWidth === "number" && !Number.isNaN(availableWidth)) {
59220
+ availableWidth = Math.max(availableWidth - 2, 0);
59221
+ } else {
59222
+ availableWidth = null;
59223
+ }
59224
+ const pageStyles = editor?.converter?.pageStyles;
59225
+ if (pageStyles?.pageSize?.width) {
59226
+ const toNumber = (v2) => typeof v2 === "number" ? v2 : parseFloat(v2) || 0;
59227
+ const pageWidth = toNumber(pageStyles.pageSize.width);
59228
+ const marginLeft = toNumber(pageStyles.pageMargins?.left);
59229
+ const marginRight = toNumber(pageStyles.pageMargins?.right);
59230
+ const pageAvailableWidthPx = Math.max((pageWidth - marginLeft - marginRight) * PIXELS_PER_INCH, 0);
59231
+ if (pageAvailableWidthPx > 0) {
59232
+ availableWidth = availableWidth ? Math.min(availableWidth, pageAvailableWidthPx) : pageAvailableWidthPx;
59233
+ }
59234
+ }
59235
+ const resolveColumnWidth = (colIndex2, colwidthValue) => {
59236
+ if (overrideCol === colIndex2) return overrideValue;
59237
+ if (colwidthValue != null) return colwidthValue;
59238
+ if (gridColumns && gridColumns[colIndex2] != null) return gridColumns[colIndex2];
59239
+ return null;
59240
+ };
59241
+ const widths = [];
58986
59242
  const row = node.firstChild;
59243
+ let colIndex = 0;
58987
59244
  if (row !== null) {
58988
- for (let i = 0, col = 0; i < row.childCount; i++) {
58989
- const { colspan, colwidth } = row.child(i).attrs;
58990
- for (let j2 = 0; j2 < colspan; j2++, col++) {
58991
- const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j2];
58992
- const cssWidth = hasWidth ? `${hasWidth}px` : "";
58993
- totalWidth += hasWidth || cellMinWidth2;
58994
- if (!hasWidth) fixedWidth = false;
58995
- if (!nextDOM) {
58996
- const col2 = document.createElement("col");
58997
- const [propKey, propVal] = getColStyleDeclaration(cellMinWidth2, hasWidth);
58998
- col2.style.setProperty(propKey, propVal);
58999
- colgroup.appendChild(col2);
59000
- } else {
59001
- if (nextDOM.style.width !== cssWidth) {
59002
- const [propKey, propVal] = getColStyleDeclaration(cellMinWidth2, hasWidth);
59003
- nextDOM.style.setProperty(propKey, propVal);
59004
- }
59005
- nextDOM = nextDOM.nextSibling;
59006
- }
59245
+ for (let i = 0; i < row.childCount; i++) {
59246
+ const child = row.child(i);
59247
+ const { colspan, colwidth } = child.attrs;
59248
+ for (let span = 0; span < colspan; span += 1, colIndex += 1) {
59249
+ widths.push(resolveColumnWidth(colIndex, colwidth && colwidth[span]));
59007
59250
  }
59008
59251
  }
59009
59252
  }
59010
- while (nextDOM) {
59011
- const after = nextDOM.nextSibling;
59012
- nextDOM.parentNode?.removeChild(nextDOM);
59013
- nextDOM = after;
59253
+ if (totalColumns != null && colIndex < totalColumns) {
59254
+ for (let col = colIndex; col < totalColumns; col += 1) {
59255
+ widths.push(resolveColumnWidth(col));
59256
+ }
59014
59257
  }
59015
- if (fixedWidth) {
59016
- table.style.width = `${totalWidth}px`;
59258
+ const normalizedWidths = widths.map((widthPx) => {
59259
+ const numericWidth = Number(widthPx);
59260
+ if (!Number.isFinite(numericWidth)) return null;
59261
+ if (numericWidth < 0) return null;
59262
+ if (numericWidth === 0) return 0;
59263
+ if (numericWidth < 1) return 0;
59264
+ return numericWidth;
59265
+ });
59266
+ const rawTotalWidth = normalizedWidths.reduce((sum, width) => sum + (width != null ? width : cellMinWidth2), 0);
59267
+ let scale = 1;
59268
+ if (availableWidth && rawTotalWidth > 0 && rawTotalWidth > availableWidth) {
59269
+ scale = availableWidth / rawTotalWidth;
59270
+ }
59271
+ let totalWidth = 0;
59272
+ let hasUndefinedWidth = false;
59273
+ let dom = colgroup.firstChild;
59274
+ normalizedWidths.forEach((width) => {
59275
+ let scaledWidth = width;
59276
+ if (scaledWidth != null) {
59277
+ scaledWidth = scaledWidth * scale;
59278
+ }
59279
+ const [propKey, propVal] = getColStyleDeclaration(cellMinWidth2, scaledWidth);
59280
+ if (scaledWidth == null) {
59281
+ totalWidth += cellMinWidth2;
59282
+ hasUndefinedWidth = true;
59283
+ } else {
59284
+ totalWidth += scaledWidth;
59285
+ }
59286
+ if (!dom) {
59287
+ const colElement = document.createElement("col");
59288
+ colElement.style.setProperty(propKey, propVal);
59289
+ colgroup.appendChild(colElement);
59290
+ } else {
59291
+ dom.style.setProperty(propKey, propVal);
59292
+ dom = dom.nextSibling;
59293
+ }
59294
+ });
59295
+ while (dom) {
59296
+ const next = dom.nextSibling;
59297
+ dom.parentNode?.removeChild(dom);
59298
+ dom = next;
59299
+ }
59300
+ if (scale < 1 || !hasUndefinedWidth) {
59301
+ const clampedWidth = Math.min(totalWidth, availableWidth || totalWidth);
59302
+ table.style.width = `${clampedWidth}px`;
59017
59303
  table.style.minWidth = "";
59018
59304
  } else {
59019
59305
  table.style.width = "";
59020
59306
  table.style.minWidth = `${totalWidth}px`;
59021
59307
  }
59308
+ table.style.maxWidth = "100%";
59022
59309
  }
59023
59310
  function updateTable(editor, node, table) {
59024
59311
  const allExtensionsAttrs = editor.extensionService.attributes;
@@ -59096,22 +59383,61 @@ const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent =
59096
59383
  const tableBorders = createTableBorders();
59097
59384
  return types2.table.createChecked({ borders: tableBorders }, rows);
59098
59385
  };
59386
+ const MIN_MEANINGFUL_WIDTH_PX = 1;
59099
59387
  const createColGroup = (node, cellMinWidth2, overrideCol, overrideValue) => {
59100
59388
  let totalWidth = 0;
59101
59389
  let fixedWidth = true;
59102
59390
  const cols = [];
59103
59391
  const colsValues = [];
59104
59392
  const row = node.firstChild;
59393
+ const gridColumns = Array.isArray(node.attrs?.grid) && node.attrs.grid.length ? node.attrs.grid.map((col) => twipsToPixels(col.col)) : null;
59105
59394
  if (!row) return {};
59106
- for (let i = 0, col = 0; i < row.childCount; i++) {
59107
- const { colspan, colwidth } = row.child(i).attrs;
59108
- for (let j2 = 0; j2 < colspan; j2++, col++) {
59109
- const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j2];
59110
- totalWidth += hasWidth || cellMinWidth2;
59111
- if (!hasWidth) fixedWidth = false;
59112
- const [prop, value] = getColStyleDeclaration(cellMinWidth2, hasWidth);
59395
+ const totalColumns = gridColumns?.length;
59396
+ const resolveColumnWidth = (colIndex2, colwidthValue) => {
59397
+ if (overrideCol === colIndex2) return overrideValue;
59398
+ if (colwidthValue != null) return colwidthValue;
59399
+ if (gridColumns && gridColumns[colIndex2] != null) return gridColumns[colIndex2];
59400
+ return null;
59401
+ };
59402
+ let colIndex = 0;
59403
+ for (let i = 0; i < row.childCount; i++) {
59404
+ const child = row.child(i);
59405
+ const { colspan, colwidth } = child.attrs;
59406
+ for (let j2 = 0; j2 < colspan; j2++, colIndex++) {
59407
+ const candidateWidth = resolveColumnWidth(colIndex, colwidth && colwidth[j2]);
59408
+ const numericWidth = Number(candidateWidth);
59409
+ let effectiveWidth = Number.isFinite(numericWidth) && numericWidth > 0 ? numericWidth : null;
59410
+ if (effectiveWidth != null && effectiveWidth < MIN_MEANINGFUL_WIDTH_PX) {
59411
+ effectiveWidth = 0;
59412
+ }
59413
+ if (effectiveWidth == null) {
59414
+ totalWidth += cellMinWidth2;
59415
+ fixedWidth = false;
59416
+ } else {
59417
+ totalWidth += effectiveWidth;
59418
+ }
59419
+ const [prop, value] = getColStyleDeclaration(cellMinWidth2, effectiveWidth);
59113
59420
  cols.push(["col", { style: `${prop}: ${value}` }]);
59114
- colsValues.push(parseInt(value, 10));
59421
+ colsValues.push(parseFloat(value));
59422
+ }
59423
+ }
59424
+ if (totalColumns != null) {
59425
+ for (let col = colIndex; col < totalColumns; col++) {
59426
+ const candidateWidth = resolveColumnWidth(col);
59427
+ const numericWidth = Number(candidateWidth);
59428
+ let effectiveWidth = Number.isFinite(numericWidth) && numericWidth > 0 ? numericWidth : null;
59429
+ if (effectiveWidth != null && effectiveWidth < MIN_MEANINGFUL_WIDTH_PX) {
59430
+ effectiveWidth = 0;
59431
+ }
59432
+ if (effectiveWidth == null) {
59433
+ totalWidth += cellMinWidth2;
59434
+ fixedWidth = false;
59435
+ } else {
59436
+ totalWidth += effectiveWidth;
59437
+ }
59438
+ const [prop, value] = getColStyleDeclaration(cellMinWidth2, effectiveWidth);
59439
+ cols.push(["col", { style: `${prop}: ${value}` }]);
59440
+ colsValues.push(parseFloat(value));
59115
59441
  }
59116
59442
  }
59117
59443
  const tableWidth = fixedWidth ? `${totalWidth}px` : "";
@@ -62014,6 +62340,19 @@ const TableHeader = Node$1.create({
62014
62340
  "data-colwidth": attrs.colwidth.join(",")
62015
62341
  };
62016
62342
  }
62343
+ },
62344
+ __placeholder: {
62345
+ default: null,
62346
+ parseDOM: (element) => {
62347
+ const value = element.getAttribute("data-placeholder");
62348
+ return value || null;
62349
+ },
62350
+ renderDOM({ __placeholder }) {
62351
+ if (!__placeholder) return {};
62352
+ return {
62353
+ "data-placeholder": __placeholder
62354
+ };
62355
+ }
62017
62356
  }
62018
62357
  };
62019
62358
  },
@@ -62174,6 +62513,19 @@ const TableCell = Node$1.create({
62174
62513
  default: "px",
62175
62514
  rendered: false
62176
62515
  },
62516
+ __placeholder: {
62517
+ default: null,
62518
+ parseDOM: (element) => {
62519
+ const value = element.getAttribute("data-placeholder");
62520
+ return value || null;
62521
+ },
62522
+ renderDOM({ __placeholder }) {
62523
+ if (!__placeholder) return {};
62524
+ return {
62525
+ "data-placeholder": __placeholder
62526
+ };
62527
+ }
62528
+ },
62177
62529
  /**
62178
62530
  * @category Attribute
62179
62531
  * @param {TableCellProperties} tableCellProperties - Properties for the table cell.