oasis-editor 0.0.90 → 0.0.91

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.
@@ -2519,7 +2519,7 @@ function OasisEditorAppLazy(props = {}) {
2519
2519
  onCleanup(() => {
2520
2520
  cancelled = true;
2521
2521
  });
2522
- import("./OasisEditorApp-2b7y3aGj.js").then((m) => {
2522
+ import("./OasisEditorApp-Cwd5XBHr.js").then((m) => {
2523
2523
  cancelled = true;
2524
2524
  setProgress(1);
2525
2525
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -3963,8 +3963,11 @@ function resolveEffectiveTableCellFormatting(options) {
3963
3963
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
3964
3964
  const { table, rowIndex, cellIndex, visualColumnIndex, columnCount, styles } = options;
3965
3965
  const named = resolveNamedTableStyle((_a = table.style) == null ? void 0 : _a.styleId, styles);
3966
- const baseTableStyle = mergeTableStyles(named.tableStyle, table.style);
3967
3966
  const row = table.rows[rowIndex];
3967
+ const baseTableStyle = (row == null ? void 0 : row.propertyExceptions) ? mergeTableStyles(
3968
+ mergeTableStyles(named.tableStyle, table.style),
3969
+ row.propertyExceptions
3970
+ ) : mergeTableStyles(named.tableStyle, table.style);
3968
3971
  const cell = row == null ? void 0 : row.cells[cellIndex];
3969
3972
  const keys = conditionalKeys({
3970
3973
  rowIndex,
@@ -5452,19 +5455,16 @@ function projectFootnoteBlocksForPage(document2, footnoteReferenceIds, page, tot
5452
5455
  for (const footnoteId of footnoteReferenceIds) {
5453
5456
  const footnote = (_b = (_a = document2.footnotes) == null ? void 0 : _a.items) == null ? void 0 : _b[footnoteId];
5454
5457
  if (!footnote) continue;
5455
- const projected = projectBlocks(
5456
- footnote.blocks,
5457
- {
5458
- pageIndex: page.index,
5459
- totalPages,
5460
- measuredHeights,
5461
- measuredParagraphLayouts,
5462
- styles: document2.styles,
5463
- contentWidth,
5464
- measurer,
5465
- defaultTabStop: (_c = document2.settings) == null ? void 0 : _c.defaultTabStop
5466
- }
5467
- );
5458
+ const projected = projectBlocks(footnote.blocks, {
5459
+ pageIndex: page.index,
5460
+ totalPages,
5461
+ measuredHeights,
5462
+ measuredParagraphLayouts,
5463
+ styles: document2.styles,
5464
+ contentWidth,
5465
+ measurer,
5466
+ defaultTabStop: (_c = document2.settings) == null ? void 0 : _c.defaultTabStop
5467
+ });
5468
5468
  for (const block of projected) {
5469
5469
  blocks.push({
5470
5470
  ...block,
@@ -12979,25 +12979,12 @@ function estimateTableRowHeight(row, styles, measurer, defaultTabStop, contentWi
12979
12979
  let blockHeights = 0;
12980
12980
  for (let blockIndex = 0; blockIndex < cell.blocks.length; blockIndex += 1) {
12981
12981
  const paragraph = cell.blocks[blockIndex];
12982
- const previousParagraph = cell.blocks[blockIndex - 1];
12983
- const nextParagraph = cell.blocks[blockIndex + 1];
12984
12982
  blockHeights += estimateParagraphBlockHeight(
12985
12983
  paragraph,
12986
12984
  styles,
12987
12985
  paragraphContentWidth,
12988
12986
  measurer,
12989
- {
12990
- allowSpacingBefore: !shouldCollapseContextualSpacing(
12991
- previousParagraph,
12992
- paragraph,
12993
- styles
12994
- ),
12995
- allowSpacingAfter: !shouldCollapseContextualSpacing(
12996
- paragraph,
12997
- nextParagraph,
12998
- styles
12999
- )
13000
- },
12987
+ {},
13001
12988
  defaultTabStop
13002
12989
  );
13003
12990
  }
@@ -13195,7 +13182,12 @@ function projectHeaderFooterBlocks(blocks, context2 = {}) {
13195
13182
  const MAX_COLUMN_BALANCE_ITERATIONS = 100;
13196
13183
  function projectColumnedBlocksLayout(context2, count, runTrackLayout) {
13197
13184
  var _a, _b;
13198
- const { pageSettings, maxPageHeight, pageOffset = 0, existingPages = [] } = context2;
13185
+ const {
13186
+ pageSettings,
13187
+ maxPageHeight,
13188
+ pageOffset = 0,
13189
+ existingPages = []
13190
+ } = context2;
13199
13191
  const colWidth = ((_a = getPageColumnRects(pageSettings)[0]) == null ? void 0 : _a.width) ?? getPageContentWidth(pageSettings);
13200
13192
  const runTracks = (blocks, trackHeight) => runTrackLayout({
13201
13193
  ...context2,
@@ -14293,19 +14285,16 @@ function resolveEffectiveVerticalMetrics(pageSettings, headerBlocks, footerBlock
14293
14285
  };
14294
14286
  }
14295
14287
  function createHeaderFooterVariantProjector(context2) {
14296
- return (blocks, contentWidth, pageIndex, totalPageCount) => blocks ? context2.projectHeaderFooterBlocks(
14297
- blocks,
14298
- {
14299
- pageIndex,
14300
- totalPages: totalPageCount,
14301
- measuredHeights: context2.measuredHeights,
14302
- measuredParagraphLayouts: context2.measuredParagraphLayouts,
14303
- styles: context2.documentStyles,
14304
- contentWidth,
14305
- measurer: context2.measurer,
14306
- defaultTabStop: context2.defaultTabStop
14307
- }
14308
- ) : void 0;
14288
+ return (blocks, contentWidth, pageIndex, totalPageCount) => blocks ? context2.projectHeaderFooterBlocks(blocks, {
14289
+ pageIndex,
14290
+ totalPages: totalPageCount,
14291
+ measuredHeights: context2.measuredHeights,
14292
+ measuredParagraphLayouts: context2.measuredParagraphLayouts,
14293
+ styles: context2.documentStyles,
14294
+ contentWidth,
14295
+ measurer: context2.measurer,
14296
+ defaultTabStop: context2.defaultTabStop
14297
+ }) : void 0;
14309
14298
  }
14310
14299
  function projectTallestHeaderVariant(section, contentWidth, projectHeaderFooterVariant) {
14311
14300
  const variants = [
@@ -15167,6 +15156,35 @@ function resolveTableIndentLeft(table) {
15167
15156
  const raw = (_a = table.style) == null ? void 0 : _a.indentLeft;
15168
15157
  return typeof raw === "number" && Number.isFinite(raw) ? toPx(raw) : 0;
15169
15158
  }
15159
+ function resolveTableCellSpacingPx(table) {
15160
+ var _a;
15161
+ const px = parseDimensionToPx((_a = table.style) == null ? void 0 : _a.cellSpacing);
15162
+ return px !== null && px > 0 ? px : 0;
15163
+ }
15164
+ function lineNaturalWidth(line) {
15165
+ if (line.slots.length < 2) return 0;
15166
+ return line.slots[line.slots.length - 1].left - line.slots[0].left;
15167
+ }
15168
+ function applyFitTextScale(paragraph, scalePercent) {
15169
+ return {
15170
+ ...paragraph,
15171
+ runs: paragraph.runs.map((run) => {
15172
+ var _a;
15173
+ const existing = (_a = run.styles) == null ? void 0 : _a.characterScale;
15174
+ const combined = typeof existing === "number" && existing > 0 ? existing * scalePercent / 100 : scalePercent;
15175
+ return { ...run, styles: { ...run.styles, characterScale: combined } };
15176
+ })
15177
+ };
15178
+ }
15179
+ function resolveTableLeftOffset(table, tableWidth, contentWidth) {
15180
+ var _a;
15181
+ const align = (_a = table.style) == null ? void 0 : _a.align;
15182
+ if (align === "center" || align === "right") {
15183
+ const slack = Math.max(0, contentWidth - tableWidth);
15184
+ return align === "center" ? slack / 2 : slack;
15185
+ }
15186
+ return resolveTableIndentLeft(table);
15187
+ }
15170
15188
  function resolveDefaultBorder() {
15171
15189
  return { width: 1, color: "#6f6f6f", type: "solid" };
15172
15190
  }
@@ -15230,7 +15248,7 @@ function resolveVerticalContentOffset(cell, contentHeightPx, contentNaturalHeigh
15230
15248
  return 0;
15231
15249
  }
15232
15250
  function buildCanvasTableLayout(options) {
15233
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
15251
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J;
15234
15252
  const {
15235
15253
  table: sourceTable,
15236
15254
  state,
@@ -15245,7 +15263,8 @@ function buildCanvasTableLayout(options) {
15245
15263
  style: resolveEffectiveTableStyle(sourceTable, state.document.styles)
15246
15264
  };
15247
15265
  const tableWidth = resolveCanvasTableWidth(table, contentWidth);
15248
- const tableLeft = originX + resolveTableIndentLeft(table);
15266
+ const tableLeft = originX + resolveTableLeftOffset(table, tableWidth, contentWidth);
15267
+ const cellSpacingPx = resolveTableCellSpacingPx(table);
15249
15268
  const tableEntries = buildTableCellLayout(table);
15250
15269
  const unsupported = [];
15251
15270
  const visualColumnCount = Math.max(
@@ -15254,13 +15273,17 @@ function buildCanvasTableLayout(options) {
15254
15273
  (entry) => entry.visualColumnIndex + Math.max(1, entry.colSpan)
15255
15274
  )
15256
15275
  );
15276
+ const columnsWidthBudget = Math.max(
15277
+ visualColumnCount,
15278
+ tableWidth - (visualColumnCount + 1) * cellSpacingPx
15279
+ );
15257
15280
  let resolvedColumnWidths = [];
15258
15281
  if (table.gridCols && table.gridCols.length >= visualColumnCount) {
15259
15282
  const gridTotalWidth = table.gridCols.reduce((a, b) => a + b, 0);
15260
- const scale = gridTotalWidth > 0 ? tableWidth / gridTotalWidth : 1;
15283
+ const scale = gridTotalWidth > 0 ? columnsWidthBudget / gridTotalWidth : 1;
15261
15284
  resolvedColumnWidths = table.gridCols.map((w) => w * scale);
15262
15285
  } else {
15263
- const baseCellWidth = tableWidth / visualColumnCount;
15286
+ const baseCellWidth = columnsWidthBudget / visualColumnCount;
15264
15287
  resolvedColumnWidths = Array(visualColumnCount).fill(baseCellWidth);
15265
15288
  for (const entry of tableEntries) {
15266
15289
  if (Math.max(1, entry.colSpan) !== 1) continue;
@@ -15283,9 +15306,9 @@ function buildCanvasTableLayout(options) {
15283
15306
  }
15284
15307
  }
15285
15308
  }
15286
- const columnOffsets = [0];
15309
+ const columnOffsets = [cellSpacingPx];
15287
15310
  for (let i = 0; i < resolvedColumnWidths.length; i++) {
15288
- columnOffsets[i + 1] = columnOffsets[i] + resolvedColumnWidths[i];
15311
+ columnOffsets[i + 1] = columnOffsets[i] + resolvedColumnWidths[i] + cellSpacingPx;
15289
15312
  }
15290
15313
  const cellEntriesByKey = new Map(
15291
15314
  tableEntries.map(
@@ -15311,8 +15334,14 @@ function buildCanvasTableLayout(options) {
15311
15334
  if ((_f = effectiveRowStyles[rowIndex]) == null ? void 0 : _f.hidden) {
15312
15335
  continue;
15313
15336
  }
15337
+ if (((_h = (_g = effectiveRowStyles[rowIndex]) == null ? void 0 : _g.revision) == null ? void 0 : _h.type) === "delete") {
15338
+ continue;
15339
+ }
15314
15340
  for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {
15315
15341
  const sourceCell = row.cells[cellIndex];
15342
+ if (((_j = (_i = sourceCell.style) == null ? void 0 : _i.revision) == null ? void 0 : _j.type) === "delete") {
15343
+ continue;
15344
+ }
15316
15345
  const entry = cellEntriesByKey.get(`${rowIndex}:${cellIndex}`);
15317
15346
  if (!entry) {
15318
15347
  continue;
@@ -15359,22 +15388,22 @@ function buildCanvasTableLayout(options) {
15359
15388
  const colSpan = Math.max(1, entry.colSpan);
15360
15389
  const width = Math.max(
15361
15390
  1,
15362
- (columnOffsets[visualCol + colSpan] ?? tableWidth) - (columnOffsets[visualCol] ?? 0)
15391
+ (columnOffsets[visualCol + colSpan] ?? tableWidth) - (columnOffsets[visualCol] ?? 0) - cellSpacingPx
15363
15392
  );
15364
15393
  const padding = resolveCellPadding(cell);
15365
- const logicalLeft = ((_g = table.style) == null ? void 0 : _g.bidiVisual) ? (_h = cell.style) == null ? void 0 : _h.borderEnd : (_i = cell.style) == null ? void 0 : _i.borderStart;
15366
- const logicalRight = ((_j = table.style) == null ? void 0 : _j.bidiVisual) ? (_k = cell.style) == null ? void 0 : _k.borderStart : (_l = cell.style) == null ? void 0 : _l.borderEnd;
15394
+ const logicalLeft = ((_k = table.style) == null ? void 0 : _k.bidiVisual) ? (_l = cell.style) == null ? void 0 : _l.borderEnd : (_m = cell.style) == null ? void 0 : _m.borderStart;
15395
+ const logicalRight = ((_n = table.style) == null ? void 0 : _n.bidiVisual) ? (_o = cell.style) == null ? void 0 : _o.borderStart : (_p = cell.style) == null ? void 0 : _p.borderEnd;
15367
15396
  const borders = {
15368
- top: resolveBorder((_m = cell.style) == null ? void 0 : _m.borderTop),
15369
- right: resolveBorder(((_n = cell.style) == null ? void 0 : _n.borderRight) ?? logicalRight),
15370
- bottom: resolveBorder((_o = cell.style) == null ? void 0 : _o.borderBottom),
15371
- left: resolveBorder(((_p = cell.style) == null ? void 0 : _p.borderLeft) ?? logicalLeft),
15372
- ...((_q = cell.style) == null ? void 0 : _q.borderTopLeftToBottomRight) ? {
15397
+ top: resolveBorder((_q = cell.style) == null ? void 0 : _q.borderTop),
15398
+ right: resolveBorder(((_r = cell.style) == null ? void 0 : _r.borderRight) ?? logicalRight),
15399
+ bottom: resolveBorder((_s = cell.style) == null ? void 0 : _s.borderBottom),
15400
+ left: resolveBorder(((_t = cell.style) == null ? void 0 : _t.borderLeft) ?? logicalLeft),
15401
+ ...((_u = cell.style) == null ? void 0 : _u.borderTopLeftToBottomRight) ? {
15373
15402
  topLeftToBottomRight: resolveBorder(
15374
15403
  cell.style.borderTopLeftToBottomRight
15375
15404
  )
15376
15405
  } : {},
15377
- ...((_r = cell.style) == null ? void 0 : _r.borderTopRightToBottomLeft) ? {
15406
+ ...((_v = cell.style) == null ? void 0 : _v.borderTopRightToBottomLeft) ? {
15378
15407
  topRightToBottomLeft: resolveBorder(
15379
15408
  cell.style.borderTopRightToBottomLeft
15380
15409
  )
@@ -15387,15 +15416,35 @@ function buildCanvasTableLayout(options) {
15387
15416
  const verticalMode = resolveCellVerticalMode(cell);
15388
15417
  const isRotated = verticalMode === "rotate-cw" || verticalMode === "rotate-ccw";
15389
15418
  const isStacked = verticalMode === "stack";
15419
+ const isFitText = !!((_w = cell.style) == null ? void 0 : _w.fitText) && !isRotated && !isStacked;
15390
15420
  const explicitRowHeightPx = parseDimensionToPx(effectiveRow.height);
15391
- const wrapWidth = isRotated || ((_s = cell.style) == null ? void 0 : _s.noWrap) ? isRotated && explicitRowHeightPx !== null && explicitRowHeightPx > 0 ? Math.max(
15421
+ const wrapWidth = isRotated || ((_x = cell.style) == null ? void 0 : _x.noWrap) ? isRotated && explicitRowHeightPx !== null && explicitRowHeightPx > 0 ? Math.max(
15392
15422
  MIN_TABLE_CELL_CONTENT_WIDTH_PX,
15393
15423
  explicitRowHeightPx - borders.top.width - borders.bottom.width - padding.top - padding.bottom
15394
15424
  ) : NO_WRAP_WIDTH_PX : contentWidthPx;
15395
15425
  const projectedParagraphs = [];
15396
15426
  let contentNaturalHeightPx = 0;
15397
15427
  for (const original of cell.blocks) {
15398
- const paragraph = fitImagesToCellWidth(original, contentWidthPx);
15428
+ let paragraph = fitImagesToCellWidth(original, contentWidthPx);
15429
+ if (isFitText) {
15430
+ const noWrapProjected = projectParagraphLayout(
15431
+ paragraph,
15432
+ pageIndex,
15433
+ void 0,
15434
+ state.document.styles,
15435
+ NO_WRAP_WIDTH_PX,
15436
+ void 0,
15437
+ (_y = state.document.settings) == null ? void 0 : _y.defaultTabStop
15438
+ );
15439
+ const naturalWidth = noWrapProjected.lines.length > 0 ? lineNaturalWidth(noWrapProjected.lines[0]) : 0;
15440
+ if (naturalWidth > 0 && contentWidthPx > 0) {
15441
+ const scalePercent = Math.max(
15442
+ 1,
15443
+ Math.min(600, contentWidthPx / naturalWidth * 100)
15444
+ );
15445
+ paragraph = applyFitTextScale(paragraph, scalePercent);
15446
+ }
15447
+ }
15399
15448
  const paragraphStyle = resolveEffectiveParagraphStyle(
15400
15449
  paragraph.style,
15401
15450
  state.document.styles
@@ -15412,7 +15461,7 @@ function buildCanvasTableLayout(options) {
15412
15461
  spacingAfter
15413
15462
  });
15414
15463
  const hasExplicitRowHeight = explicitRowHeightPx !== null && explicitRowHeightPx > 0;
15415
- const paragraphStyleSize = ((_u = (_t = paragraph.runs[0]) == null ? void 0 : _t.styles) == null ? void 0 : _u.fontSize) ?? 14.6667;
15464
+ const paragraphStyleSize = ((_A = (_z = paragraph.runs[0]) == null ? void 0 : _z.styles) == null ? void 0 : _A.fontSize) ?? 14.6667;
15416
15465
  contentNaturalHeightPx = Math.max(
15417
15466
  contentNaturalHeightPx,
15418
15467
  hasExplicitRowHeight ? paragraphStyleSize * 1.25 : stackLength
@@ -15426,23 +15475,38 @@ function buildCanvasTableLayout(options) {
15426
15475
  state.document.styles,
15427
15476
  wrapWidth,
15428
15477
  void 0,
15429
- (_v = state.document.settings) == null ? void 0 : _v.defaultTabStop
15478
+ (_B = state.document.settings) == null ? void 0 : _B.defaultTabStop
15430
15479
  );
15431
15480
  const linesBottom = projected.lines.length > 0 ? Math.max(...projected.lines.map((line) => line.top + line.height)) : 1;
15432
15481
  let effectiveSpacingBefore = spacingBefore;
15433
15482
  if (!isRotated && projectedParagraphs.length > 0) {
15434
15483
  const previous = projectedParagraphs[projectedParagraphs.length - 1];
15435
- const collapsed = Math.min(previous.spacingAfter, spacingBefore);
15436
- if (collapsed > 0) {
15437
- if (previous.spacingAfter >= spacingBefore) {
15438
- effectiveSpacingBefore = 0;
15439
- } else {
15440
- const previousHeight = previous.height;
15441
- previous.height = Math.max(1, previous.height - collapsed);
15442
- contentNaturalHeightPx = Math.max(
15443
- 0,
15444
- contentNaturalHeightPx - (previousHeight - previous.height)
15445
- );
15484
+ if (((_C = state.document.settings) == null ? void 0 : _C.allowSpaceOfSameStyleInTable) && shouldCollapseContextualSpacing(
15485
+ previous.paragraph,
15486
+ paragraph,
15487
+ state.document.styles
15488
+ )) {
15489
+ const removedAfter = previous.spacingAfter;
15490
+ previous.height = Math.max(1, previous.height - removedAfter);
15491
+ previous.spacingAfter = 0;
15492
+ contentNaturalHeightPx = Math.max(
15493
+ 0,
15494
+ contentNaturalHeightPx - removedAfter
15495
+ );
15496
+ effectiveSpacingBefore = 0;
15497
+ } else {
15498
+ const collapsed = Math.min(previous.spacingAfter, spacingBefore);
15499
+ if (collapsed > 0) {
15500
+ if (previous.spacingAfter >= spacingBefore) {
15501
+ effectiveSpacingBefore = 0;
15502
+ } else {
15503
+ const previousHeight = previous.height;
15504
+ previous.height = Math.max(1, previous.height - collapsed);
15505
+ contentNaturalHeightPx = Math.max(
15506
+ 0,
15507
+ contentNaturalHeightPx - (previousHeight - previous.height)
15508
+ );
15509
+ }
15446
15510
  }
15447
15511
  }
15448
15512
  }
@@ -15474,6 +15538,16 @@ function buildCanvasTableLayout(options) {
15474
15538
  contentNaturalHeightPx += paragraphHeight;
15475
15539
  }
15476
15540
  }
15541
+ if ((_D = cell.style) == null ? void 0 : _D.hideMark) {
15542
+ const allEmpty = cell.blocks.every(
15543
+ (para) => para.runs.every(
15544
+ (run) => (run.kind === "text" || run.kind === void 0) && (!run.text || run.text.length === 0)
15545
+ )
15546
+ );
15547
+ if (allEmpty) {
15548
+ contentNaturalHeightPx = 0;
15549
+ }
15550
+ }
15477
15551
  prepared.push({
15478
15552
  rowIndex,
15479
15553
  cellIndex,
@@ -15493,9 +15567,10 @@ function buildCanvasTableLayout(options) {
15493
15567
  }
15494
15568
  const rowCount = Math.max(1, table.rows.length);
15495
15569
  const explicitRowHeights = table.rows.map((row) => {
15570
+ var _a2;
15496
15571
  const rowIndex = table.rows.indexOf(row);
15497
15572
  const effective = effectiveRowStyles[rowIndex];
15498
- if (effective == null ? void 0 : effective.hidden) {
15573
+ if ((effective == null ? void 0 : effective.hidden) || ((_a2 = effective == null ? void 0 : effective.revision) == null ? void 0 : _a2.type) === "delete") {
15499
15574
  return 0;
15500
15575
  }
15501
15576
  const explicit = parseDimensionToPx(effective == null ? void 0 : effective.height);
@@ -15504,7 +15579,7 @@ function buildCanvasTableLayout(options) {
15504
15579
  const fallbackPerRow = estimatedHeight > 0 ? estimatedHeight / rowCount : DEFAULT_TABLE_ROW_HEIGHT;
15505
15580
  const rowHeights = [];
15506
15581
  for (let rowIndex = 0; rowIndex < table.rows.length; rowIndex += 1) {
15507
- if ((_w = effectiveRowStyles[rowIndex]) == null ? void 0 : _w.hidden) {
15582
+ if (((_E = effectiveRowStyles[rowIndex]) == null ? void 0 : _E.hidden) || ((_G = (_F = effectiveRowStyles[rowIndex]) == null ? void 0 : _F.revision) == null ? void 0 : _G.type) === "delete") {
15508
15583
  rowHeights[rowIndex] = 0;
15509
15584
  continue;
15510
15585
  }
@@ -15520,10 +15595,10 @@ function buildCanvasTableLayout(options) {
15520
15595
  rowHeights[rowIndex] = Math.max(baseFloor, measured, 1);
15521
15596
  }
15522
15597
  const rowOffsets = [];
15523
- let cumulativeY = 0;
15598
+ let cumulativeY = cellSpacingPx;
15524
15599
  for (let rowIndex = 0; rowIndex < table.rows.length; rowIndex += 1) {
15525
15600
  rowOffsets[rowIndex] = cumulativeY;
15526
- cumulativeY += rowHeights[rowIndex] ?? DEFAULT_TABLE_ROW_HEIGHT;
15601
+ cumulativeY += (rowHeights[rowIndex] ?? DEFAULT_TABLE_ROW_HEIGHT) + cellSpacingPx;
15527
15602
  }
15528
15603
  const cells = [];
15529
15604
  for (const cellEntry of prepared) {
@@ -15542,7 +15617,7 @@ function buildCanvasTableLayout(options) {
15542
15617
  const top = originY + (rowOffsets[rowIndex] ?? 0);
15543
15618
  const height = Math.max(
15544
15619
  1,
15545
- rowHeights.slice(rowIndex, rowIndex + rowSpan).reduce((sum, current) => sum + current, 0)
15620
+ rowHeights.slice(rowIndex, rowIndex + rowSpan).reduce((sum, current) => sum + current, 0) + (rowSpan - 1) * cellSpacingPx
15546
15621
  );
15547
15622
  const contentLeft = left + borders.left.width + padding.left;
15548
15623
  const contentTop = top + borders.top.width + padding.top;
@@ -15588,13 +15663,13 @@ function buildCanvasTableLayout(options) {
15588
15663
  contentTop,
15589
15664
  contentWidth: contentWidthPx,
15590
15665
  contentHeight: contentHeightPx,
15591
- shading: (_x = cell.style) == null ? void 0 : _x.shading,
15666
+ shading: (_H = cell.style) == null ? void 0 : _H.shading,
15592
15667
  anchorPosition,
15593
15668
  padding,
15594
15669
  borders,
15595
15670
  paragraphs,
15596
15671
  verticalMode: cellEntry.verticalMode,
15597
- revision: ((_y = cell.style) == null ? void 0 : _y.revision) ?? (((_z = cell.style) == null ? void 0 : _z.propertyRevision) ? { ...cell.style.propertyRevision, type: "property" } : void 0)
15672
+ revision: ((_I = cell.style) == null ? void 0 : _I.revision) ?? (((_J = cell.style) == null ? void 0 : _J.propertyRevision) ? { ...cell.style.propertyRevision, type: "property" } : void 0)
15598
15673
  });
15599
15674
  }
15600
15675
  return {
@@ -15602,7 +15677,8 @@ function buildCanvasTableLayout(options) {
15602
15677
  left: tableLeft,
15603
15678
  top: originY,
15604
15679
  width: tableWidth,
15605
- height: rowHeights.reduce((sum, current) => sum + current, 0),
15680
+ // Total height includes the leading/trailing/inter-row cell-spacing gaps.
15681
+ height: rowHeights.reduce((sum, current) => sum + current, 0) + (rowHeights.length + 1) * cellSpacingPx,
15606
15682
  rowHeights,
15607
15683
  cells,
15608
15684
  unsupported: Array.from(new Set(unsupported))
@@ -18567,7 +18643,9 @@ async function loadPreciseFontProgramsForFamilies(families) {
18567
18643
  const buffer = await font.blob().then((blob) => blob.arrayBuffer());
18568
18644
  const program = selectFaceProgram(new Uint8Array(buffer), font);
18569
18645
  registerPreciseFont(family, bold, italic, program);
18570
- registered.push(`${family} ${bold ? "B" : ""}${italic ? "I" : ""}`.trim());
18646
+ registered.push(
18647
+ `${family} ${bold ? "B" : ""}${italic ? "I" : ""}`.trim()
18648
+ );
18571
18649
  changed = true;
18572
18650
  } catch (error) {
18573
18651
  failed.push(`${family} (${font.style ?? "?"}): ${String(error)}`);
@@ -32064,6 +32142,7 @@ const WORD_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
32064
32142
  const DRAWINGML_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
32065
32143
  const OFFICE_REL_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
32066
32144
  const WORD14_NS = "http://schemas.microsoft.com/office/word/2010/wordml";
32145
+ const MARKUP_COMPAT_NS = "http://schemas.openxmlformats.org/markup-compatibility/2006";
32067
32146
  function getChildrenByTagNameNS(element, namespace, localName) {
32068
32147
  if (!element) {
32069
32148
  return [];
@@ -32071,8 +32150,22 @@ function getChildrenByTagNameNS(element, namespace, localName) {
32071
32150
  const result = [];
32072
32151
  for (let index = 0; index < element.childNodes.length; index += 1) {
32073
32152
  const node = element.childNodes[index];
32074
- if ((node == null ? void 0 : node.nodeType) === node.ELEMENT_NODE && node.namespaceURI === namespace && node.localName === localName) {
32075
- result.push(node);
32153
+ if ((node == null ? void 0 : node.nodeType) !== node.ELEMENT_NODE) continue;
32154
+ const el = node;
32155
+ if (el.namespaceURI === MARKUP_COMPAT_NS && el.localName === "AlternateContent") {
32156
+ for (let j = 0; j < el.childNodes.length; j += 1) {
32157
+ const child = el.childNodes[j];
32158
+ if ((child == null ? void 0 : child.nodeType) !== child.ELEMENT_NODE) continue;
32159
+ const childEl = child;
32160
+ if (childEl.namespaceURI === MARKUP_COMPAT_NS && childEl.localName === "Fallback") {
32161
+ result.push(...getChildrenByTagNameNS(childEl, namespace, localName));
32162
+ break;
32163
+ }
32164
+ }
32165
+ continue;
32166
+ }
32167
+ if (el.namespaceURI === namespace && el.localName === localName) {
32168
+ result.push(el);
32076
32169
  }
32077
32170
  }
32078
32171
  return result;
@@ -32108,6 +32201,19 @@ function findElementDeep(element, localName) {
32108
32201
  }
32109
32202
  return null;
32110
32203
  }
32204
+ function collectExtAttributes(element) {
32205
+ const result = {};
32206
+ const attrs = element.attributes;
32207
+ for (let i = 0; i < attrs.length; i += 1) {
32208
+ const attr = attrs[i];
32209
+ if (!attr) continue;
32210
+ const ns = attr.namespaceURI;
32211
+ if (!ns || ns === WORD_NS) continue;
32212
+ if (attr.prefix === "xmlns" || attr.localName === "xmlns") continue;
32213
+ result[`${attr.prefix}:${attr.localName}`] = attr.value;
32214
+ }
32215
+ return Object.keys(result).length > 0 ? result : void 0;
32216
+ }
32111
32217
  function isWordTrue(value) {
32112
32218
  return value === "1" || value === "true" || value === "on";
32113
32219
  }
@@ -32480,6 +32586,15 @@ function parseSettings(xml) {
32480
32586
  const val = getAttributeValue(adjustLineHeightInTable, "val");
32481
32587
  settings.adjustLineHeightInTable = val !== "0" && val !== "false";
32482
32588
  }
32589
+ const allowSpace = getFirstChildByTagNameNS(
32590
+ compat,
32591
+ WORD_NS,
32592
+ "allowSpaceOfSameStyleInTable"
32593
+ );
32594
+ if (allowSpace) {
32595
+ const val = getAttributeValue(allowSpace, "val");
32596
+ settings.allowSpaceOfSameStyleInTable = val !== "0" && val !== "false";
32597
+ }
32483
32598
  }
32484
32599
  return settings;
32485
32600
  }
@@ -33500,8 +33615,12 @@ function parseTableStyle(tblPr, tableStyleId) {
33500
33615
  getFirstChildByTagNameNS(tblPr, WORD_NS, "jc"),
33501
33616
  "val"
33502
33617
  );
33503
- if (jc === "left" || jc === "center" || jc === "right") {
33504
- style2.align = jc;
33618
+ if (jc === "left" || jc === "start") {
33619
+ style2.align = "left";
33620
+ } else if (jc === "center") {
33621
+ style2.align = "center";
33622
+ } else if (jc === "right" || jc === "end") {
33623
+ style2.align = "right";
33505
33624
  }
33506
33625
  const layout = parseTableLayout(tblPr);
33507
33626
  if (layout) {
@@ -33621,6 +33740,17 @@ function parseTableRowStyle(rowProperties) {
33621
33740
  if (cellSpacing !== void 0) {
33622
33741
  style2.cellSpacing = cellSpacing;
33623
33742
  }
33743
+ const rowJc = getAttributeValue(
33744
+ getFirstChildByTagNameNS(rowProperties, WORD_NS, "jc"),
33745
+ "val"
33746
+ );
33747
+ if (rowJc === "left" || rowJc === "start") {
33748
+ style2.align = "left";
33749
+ } else if (rowJc === "center") {
33750
+ style2.align = "center";
33751
+ } else if (rowJc === "right" || rowJc === "end") {
33752
+ style2.align = "right";
33753
+ }
33624
33754
  const cantSplit = parseOnOffProperty(rowProperties, "cantSplit");
33625
33755
  if (cantSplit !== void 0) {
33626
33756
  style2.cantSplit = cantSplit;
@@ -33673,6 +33803,17 @@ function getTableCellVMerge(cellProperties) {
33673
33803
  const value = getAttributeValue(vMerge, "val");
33674
33804
  return value === "restart" ? "restart" : "continue";
33675
33805
  }
33806
+ function getTableCellHMerge(cellProperties) {
33807
+ if (!cellProperties) {
33808
+ return void 0;
33809
+ }
33810
+ const hMerge = getFirstChildByTagNameNS(cellProperties, WORD_NS, "hMerge");
33811
+ if (!hMerge) {
33812
+ return void 0;
33813
+ }
33814
+ const value = getAttributeValue(hMerge, "val");
33815
+ return value === "restart" ? "restart" : "continue";
33816
+ }
33676
33817
  function parseTableCellVerticalAlign(cellProperties) {
33677
33818
  if (!cellProperties) {
33678
33819
  return void 0;
@@ -35538,6 +35679,12 @@ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, th
35538
35679
  }
35539
35680
  collapseCellAutospacing(paragraphs, autospacingFlags);
35540
35681
  const colSpan = getTableCellColSpan(cellProperties);
35682
+ const hMerge = getTableCellHMerge(cellProperties);
35683
+ if (hMerge === "continue" && cells.length > 0) {
35684
+ const anchor = cells[cells.length - 1];
35685
+ anchor.colSpan = (anchor.colSpan ?? 1) + colSpan;
35686
+ continue;
35687
+ }
35541
35688
  const vMerge = getTableCellVMerge(cellProperties);
35542
35689
  const cellStyle = parseTableCellStyle(cellProperties);
35543
35690
  const cell = createEditorTableCell(
@@ -35547,6 +35694,8 @@ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, th
35547
35694
  );
35548
35695
  if (cellStyle) cell.style = cellStyle;
35549
35696
  cell.conditionalStyle = parseTableConditionalFlags(cellProperties);
35697
+ const cellExtAttrs = collectExtAttributes(cellNode);
35698
+ if (cellExtAttrs) cell.extAttributes = cellExtAttrs;
35550
35699
  if (vMerge === "continue") {
35551
35700
  cell.blocks = [];
35552
35701
  }
@@ -35561,9 +35710,22 @@ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, th
35561
35710
  row.style = rowStyle;
35562
35711
  }
35563
35712
  row.conditionalStyle = rowConditionalStyle;
35713
+ const rowExtAttrs = collectExtAttributes(rowNode);
35714
+ if (rowExtAttrs) row.extAttributes = rowExtAttrs;
35564
35715
  const tblPrEx = getFirstChildByTagNameNS(rowNode, WORD_NS, "tblPrEx");
35565
35716
  if (tblPrEx) {
35566
- row.tblPrExXml = new XMLSerializer().serializeToString(tblPrEx);
35717
+ const exceptions = parseTableStyle(tblPrEx);
35718
+ if (exceptions) {
35719
+ row.propertyExceptions = exceptions;
35720
+ }
35721
+ const changeEl = getFirstChildByTagNameNS(
35722
+ tblPrEx,
35723
+ WORD_NS,
35724
+ "tblPrExChange"
35725
+ );
35726
+ if (changeEl) {
35727
+ row.tblPrExChangeXml = new XMLSerializer().serializeToString(changeEl);
35728
+ }
35567
35729
  }
35568
35730
  rows.push(row);
35569
35731
  }
@@ -36394,6 +36556,12 @@ async function importDocxToEditorDocument(buffer, options = {}) {
36394
36556
  defaultTabStop: docSettings.defaultTabStop
36395
36557
  };
36396
36558
  }
36559
+ if (docSettings.allowSpaceOfSameStyleInTable) {
36560
+ doc2.settings = {
36561
+ ...doc2.settings ?? {},
36562
+ allowSpaceOfSameStyleInTable: true
36563
+ };
36564
+ }
36397
36565
  let result = doc2;
36398
36566
  if (editorFootnotes) {
36399
36567
  result.footnotes = editorFootnotes;
@@ -36580,7 +36748,7 @@ function importDocxInWorker(buffer, options = {}) {
36580
36748
  const worker = new Worker(
36581
36749
  new URL(
36582
36750
  /* @vite-ignore */
36583
- "" + new URL("assets/importDocxWorker-BN5o1geV.js", import.meta.url).href,
36751
+ "" + new URL("assets/importDocxWorker-6DqfSWfq.js", import.meta.url).href,
36584
36752
  import.meta.url
36585
36753
  ),
36586
36754
  {
@@ -39130,7 +39298,11 @@ function parseFontSizePtToPx(pt) {
39130
39298
  return fontSizePtToPx(value);
39131
39299
  }
39132
39300
  const UNDERLINE_STYLE_OPTIONS = [
39133
- { value: "single", labelKey: "underline.style.single", preview: { borderStyle: "solid" } },
39301
+ {
39302
+ value: "single",
39303
+ labelKey: "underline.style.single",
39304
+ preview: { borderStyle: "solid" }
39305
+ },
39134
39306
  {
39135
39307
  value: "double",
39136
39308
  labelKey: "underline.style.double",
@@ -39141,13 +39313,21 @@ const UNDERLINE_STYLE_OPTIONS = [
39141
39313
  labelKey: "underline.style.thick",
39142
39314
  preview: { borderStyle: "solid", borderBottomWidth: "3px" }
39143
39315
  },
39144
- { value: "dotted", labelKey: "underline.style.dotted", preview: { borderStyle: "dotted" } },
39316
+ {
39317
+ value: "dotted",
39318
+ labelKey: "underline.style.dotted",
39319
+ preview: { borderStyle: "dotted" }
39320
+ },
39145
39321
  {
39146
39322
  value: "dottedHeavy",
39147
39323
  labelKey: "underline.style.dottedHeavy",
39148
39324
  preview: { borderStyle: "dotted", borderBottomWidth: "3px" }
39149
39325
  },
39150
- { value: "dash", labelKey: "underline.style.dashed", preview: { borderStyle: "dashed" } },
39326
+ {
39327
+ value: "dash",
39328
+ labelKey: "underline.style.dashed",
39329
+ preview: { borderStyle: "dashed" }
39330
+ },
39151
39331
  {
39152
39332
  value: "dashedHeavy",
39153
39333
  labelKey: "underline.style.dashedHeavy",
@@ -39163,7 +39343,11 @@ const UNDERLINE_STYLE_OPTIONS = [
39163
39343
  labelKey: "underline.style.longDashesHeavy",
39164
39344
  preview: { borderStyle: "dashed", borderBottomWidth: "3px" }
39165
39345
  },
39166
- { value: "dotDash", labelKey: "underline.style.dotDash", preview: { borderStyle: "dashed" } },
39346
+ {
39347
+ value: "dotDash",
39348
+ labelKey: "underline.style.dotDash",
39349
+ preview: { borderStyle: "dashed" }
39350
+ },
39167
39351
  {
39168
39352
  value: "dashDotHeavy",
39169
39353
  labelKey: "underline.style.dotDashHeavy",