oasis-editor 0.0.112 → 0.0.113

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.
@@ -2539,7 +2539,7 @@ function OasisEditorAppLazy(props = {}) {
2539
2539
  onCleanup(() => {
2540
2540
  cancelled = true;
2541
2541
  });
2542
- import("./OasisEditorApp-p9k7O_1i.js").then((m) => {
2542
+ import("./OasisEditorApp-BKPrQtm5.js").then((m) => {
2543
2543
  cancelled = true;
2544
2544
  setProgress(1);
2545
2545
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -16271,6 +16271,30 @@ class PaginationTrack {
16271
16271
  return this.pages;
16272
16272
  }
16273
16273
  }
16274
+ function paginateSegments(track, sourceId, segmenter) {
16275
+ var _a, _b;
16276
+ let segmentIndex = 0;
16277
+ while (segmenter.hasMore()) {
16278
+ const segmentId = `${sourceId}:segment:${segmentIndex}`;
16279
+ const remaining = track.currentMaxHeight - track.height;
16280
+ let block = segmenter.fit(segmentId, remaining);
16281
+ if (block === null && track.blocks.length > 0) {
16282
+ (_a = segmenter.onBeforeFlush) == null ? void 0 : _a.call(segmenter);
16283
+ track.flush();
16284
+ continue;
16285
+ }
16286
+ if (block === null) {
16287
+ block = segmenter.force(segmentId);
16288
+ }
16289
+ track.blocks.push(block);
16290
+ track.height += block.estimatedHeight;
16291
+ (_b = segmenter.onAfterPush) == null ? void 0 : _b.call(segmenter, block, segmentIndex);
16292
+ segmentIndex += 1;
16293
+ if (segmenter.hasMore()) {
16294
+ track.flush();
16295
+ }
16296
+ }
16297
+ }
16274
16298
  const TEXT_BOX_AUTOFIT_SAFETY_PX$1 = 2;
16275
16299
  const PARAGRAPH_FIT_HEIGHT_TOLERANCE_PX = 1.5;
16276
16300
  function registerParagraphFloatingExclusions(options) {
@@ -16457,93 +16481,13 @@ function paginateParagraphBlock(track, params, sourceBlock, nextBlock, index) {
16457
16481
  return;
16458
16482
  }
16459
16483
  let startLineIndex = 0;
16460
- let segmentIndex = 0;
16461
- while (startLineIndex < paragraphLayout.lines.length) {
16462
- const remainingHeight = track.currentMaxHeight - track.height;
16463
- let lineEndIndex = startLineIndex;
16464
- let segmentHeight = 0;
16465
- while (lineEndIndex < paragraphLayout.lines.length) {
16466
- const candidateLines = paragraphLayout.lines.slice(
16467
- startLineIndex,
16468
- lineEndIndex + 1
16469
- );
16470
- const candidateHeight = getParagraphSegmentHeight(
16471
- sourceBlock,
16472
- candidateLines,
16473
- startLineIndex === 0,
16474
- lineEndIndex === paragraphLayout.lines.length - 1,
16475
- styles,
16476
- !collapseWithPrevious
16477
- );
16478
- const candidateFitHeight = getParagraphSegmentFitHeight(
16479
- sourceBlock,
16480
- candidateHeight,
16481
- lineEndIndex === paragraphLayout.lines.length - 1,
16482
- styles
16483
- );
16484
- if (candidateFitHeight > remainingHeight + PARAGRAPH_FIT_HEIGHT_TOLERANCE_PX && lineEndIndex === startLineIndex && track.blocks.length > 0) {
16485
- break;
16486
- }
16487
- if (candidateFitHeight > remainingHeight + PARAGRAPH_FIT_HEIGHT_TOLERANCE_PX && lineEndIndex > startLineIndex) {
16488
- break;
16489
- }
16490
- segmentHeight = candidateHeight;
16491
- lineEndIndex += 1;
16492
- }
16493
- if (lineEndIndex === startLineIndex && track.blocks.length > 0) {
16494
- if (contextualAdjustedPreviousBlock && contextualAdjustedAmount > 0) {
16495
- contextualAdjustedPreviousBlock.estimatedHeight += contextualAdjustedAmount;
16496
- track.height += contextualAdjustedAmount;
16497
- contextualAdjustedPreviousBlock = void 0;
16498
- contextualAdjustedAmount = 0;
16499
- }
16500
- collapseWithPrevious = false;
16501
- track.flush();
16502
- continue;
16503
- }
16504
- if (lineEndIndex === startLineIndex) {
16505
- lineEndIndex = Math.min(paragraphLayout.lines.length, startLineIndex + 1);
16506
- segmentHeight = getParagraphSegmentHeight(
16507
- sourceBlock,
16508
- paragraphLayout.lines.slice(startLineIndex, lineEndIndex),
16509
- startLineIndex === 0,
16510
- lineEndIndex === paragraphLayout.lines.length,
16511
- styles,
16512
- !collapseWithPrevious
16513
- );
16514
- }
16515
- if (lineEndIndex < paragraphLayout.lines.length) {
16516
- const widowOrphanAdjusted = applyWidowOrphanControl(
16517
- sourceBlock,
16518
- paragraphLayout.lines,
16519
- startLineIndex,
16520
- lineEndIndex,
16521
- styles,
16522
- !collapseWithPrevious,
16523
- true,
16524
- track.blocks.length > 0
16525
- );
16526
- lineEndIndex = widowOrphanAdjusted.endLineIndexExclusive;
16527
- segmentHeight = widowOrphanAdjusted.height;
16528
- if (lineEndIndex === startLineIndex) {
16529
- if (contextualAdjustedPreviousBlock && contextualAdjustedAmount > 0) {
16530
- contextualAdjustedPreviousBlock.estimatedHeight += contextualAdjustedAmount;
16531
- track.height += contextualAdjustedAmount;
16532
- contextualAdjustedPreviousBlock = void 0;
16533
- contextualAdjustedAmount = 0;
16534
- }
16535
- collapseWithPrevious = false;
16536
- track.flush();
16537
- continue;
16538
- }
16539
- }
16484
+ const buildSegmentBlock = (originalStart, lineEndIndex, segmentHeight, segmentId) => {
16540
16485
  const segmentLayout = createParagraphSegmentLayout(
16541
16486
  paragraphLayout,
16542
- startLineIndex,
16487
+ originalStart,
16543
16488
  lineEndIndex
16544
16489
  );
16545
- const segmentId = `${sourceBlock.id}:segment:${segmentIndex}`;
16546
- const isWholeParagraphSegment = startLineIndex === 0 && lineEndIndex === paragraphLayout.lines.length;
16490
+ const isWholeParagraphSegment = originalStart === 0 && lineEndIndex === paragraphLayout.lines.length;
16547
16491
  const rawMeasuredHeight = getParagraphMeasuredHeight(
16548
16492
  measuredHeights,
16549
16493
  sourceBlock.id,
@@ -16552,8 +16496,8 @@ function paginateParagraphBlock(track, params, sourceBlock, nextBlock, index) {
16552
16496
  segmentHeight
16553
16497
  );
16554
16498
  const hasMeasuredHeight = (measuredHeights == null ? void 0 : measuredHeights[segmentId]) !== void 0 || isWholeParagraphSegment && (measuredHeights == null ? void 0 : measuredHeights[sourceBlock.id]) !== void 0;
16555
- const measuredHeight = collapseWithPrevious && startLineIndex === 0 && hasMeasuredHeight ? Math.max(0, rawMeasuredHeight - (paragraphStyle.spacingBefore ?? 0)) : rawMeasuredHeight;
16556
- track.blocks.push({
16499
+ const measuredHeight = collapseWithPrevious && originalStart === 0 && hasMeasuredHeight ? Math.max(0, rawMeasuredHeight - (paragraphStyle.spacingBefore ?? 0)) : rawMeasuredHeight;
16500
+ return {
16557
16501
  blockId: segmentId,
16558
16502
  sourceBlockId: sourceBlock.id,
16559
16503
  blockType: sourceBlock.type,
@@ -16562,23 +16506,111 @@ function paginateParagraphBlock(track, params, sourceBlock, nextBlock, index) {
16562
16506
  estimatedHeight: measuredHeight,
16563
16507
  layout: segmentLayout,
16564
16508
  sourceBlock
16565
- });
16566
- track.height += measuredHeight;
16567
- if (startLineIndex === 0) {
16568
- registerParagraphFloatingExclusions({
16569
- track,
16570
- layout: segmentLayout,
16571
- blockTop: track.height - measuredHeight + (paragraphStyle.spacingBefore ?? 0),
16572
- params,
16573
- resolveTextBoxHeight
16574
- });
16575
- }
16576
- startLineIndex = lineEndIndex;
16577
- segmentIndex += 1;
16578
- if (startLineIndex < paragraphLayout.lines.length) {
16579
- track.flush();
16509
+ };
16510
+ };
16511
+ paginateSegments(track, sourceBlock.id, {
16512
+ hasMore: () => startLineIndex < paragraphLayout.lines.length,
16513
+ fit(segmentId, remaining) {
16514
+ const originalStart = startLineIndex;
16515
+ let lineEndIndex = originalStart;
16516
+ let segmentHeight = 0;
16517
+ while (lineEndIndex < paragraphLayout.lines.length) {
16518
+ const candidateLines = paragraphLayout.lines.slice(
16519
+ originalStart,
16520
+ lineEndIndex + 1
16521
+ );
16522
+ const candidateHeight = getParagraphSegmentHeight(
16523
+ sourceBlock,
16524
+ candidateLines,
16525
+ originalStart === 0,
16526
+ lineEndIndex === paragraphLayout.lines.length - 1,
16527
+ styles,
16528
+ !collapseWithPrevious
16529
+ );
16530
+ const candidateFitHeight = getParagraphSegmentFitHeight(
16531
+ sourceBlock,
16532
+ candidateHeight,
16533
+ lineEndIndex === paragraphLayout.lines.length - 1,
16534
+ styles
16535
+ );
16536
+ if (candidateFitHeight > remaining + PARAGRAPH_FIT_HEIGHT_TOLERANCE_PX && lineEndIndex === originalStart && track.blocks.length > 0) {
16537
+ break;
16538
+ }
16539
+ if (candidateFitHeight > remaining + PARAGRAPH_FIT_HEIGHT_TOLERANCE_PX && lineEndIndex > originalStart) {
16540
+ break;
16541
+ }
16542
+ segmentHeight = candidateHeight;
16543
+ lineEndIndex += 1;
16544
+ }
16545
+ if (lineEndIndex === originalStart) return null;
16546
+ if (lineEndIndex < paragraphLayout.lines.length) {
16547
+ const widowOrphanAdjusted = applyWidowOrphanControl(
16548
+ sourceBlock,
16549
+ paragraphLayout.lines,
16550
+ originalStart,
16551
+ lineEndIndex,
16552
+ styles,
16553
+ !collapseWithPrevious,
16554
+ true,
16555
+ track.blocks.length > 0
16556
+ );
16557
+ lineEndIndex = widowOrphanAdjusted.endLineIndexExclusive;
16558
+ segmentHeight = widowOrphanAdjusted.height;
16559
+ if (lineEndIndex === originalStart) return null;
16560
+ }
16561
+ const block = buildSegmentBlock(
16562
+ originalStart,
16563
+ lineEndIndex,
16564
+ segmentHeight,
16565
+ segmentId
16566
+ );
16567
+ startLineIndex = lineEndIndex;
16568
+ return block;
16569
+ },
16570
+ force(segmentId) {
16571
+ const originalStart = startLineIndex;
16572
+ const lineEndIndex = Math.min(
16573
+ paragraphLayout.lines.length,
16574
+ originalStart + 1
16575
+ );
16576
+ const segmentHeight = getParagraphSegmentHeight(
16577
+ sourceBlock,
16578
+ paragraphLayout.lines.slice(originalStart, lineEndIndex),
16579
+ originalStart === 0,
16580
+ lineEndIndex === paragraphLayout.lines.length,
16581
+ styles,
16582
+ !collapseWithPrevious
16583
+ );
16584
+ const block = buildSegmentBlock(
16585
+ originalStart,
16586
+ lineEndIndex,
16587
+ segmentHeight,
16588
+ segmentId
16589
+ );
16590
+ startLineIndex = lineEndIndex;
16591
+ return block;
16592
+ },
16593
+ onBeforeFlush() {
16594
+ if (contextualAdjustedPreviousBlock && contextualAdjustedAmount > 0) {
16595
+ contextualAdjustedPreviousBlock.estimatedHeight += contextualAdjustedAmount;
16596
+ track.height += contextualAdjustedAmount;
16597
+ contextualAdjustedPreviousBlock = void 0;
16598
+ contextualAdjustedAmount = 0;
16599
+ }
16600
+ collapseWithPrevious = false;
16601
+ },
16602
+ onAfterPush(block, si) {
16603
+ if (si === 0) {
16604
+ registerParagraphFloatingExclusions({
16605
+ track,
16606
+ layout: block.layout,
16607
+ blockTop: track.height - block.estimatedHeight + (paragraphStyle.spacingBefore ?? 0),
16608
+ params,
16609
+ resolveTextBoxHeight
16610
+ });
16611
+ }
16580
16612
  }
16581
- }
16613
+ });
16582
16614
  }
16583
16615
  function normalizeCellStartPositions(row, starts, legacyStarts) {
16584
16616
  return row.cells.map((_, cellIdx) => {
@@ -16867,139 +16899,192 @@ function paginateTableBlock(track, params, sourceBlock, index) {
16867
16899
  rowGroups
16868
16900
  );
16869
16901
  let groupStartIndex = 0;
16870
- let segmentIndex = 0;
16871
16902
  let currentCellBlockPositions;
16872
- while (groupStartIndex < rowGroups.length) {
16873
- const startRowIndex = rowGroups[groupStartIndex].startRowIndex;
16874
- const repeatedHeaderRowCount = startRowIndex > 0 ? headerRowCount : 0;
16875
- const remainingHeight = track.currentMaxHeight - track.height;
16876
- let groupEndIndex = groupStartIndex;
16877
- let segmentHeight = 0;
16878
- let splitEnds;
16879
- let splitEndPositions;
16880
- let isLastRowSplit = false;
16881
- while (groupEndIndex < rowGroups.length) {
16882
- const candidateEndRowIndex = rowGroups[groupEndIndex].endRowIndexExclusive;
16883
- let candidateHeight = 0;
16884
- if (groupEndIndex === groupStartIndex && currentCellBlockPositions) {
16885
- const firstRow2 = sourceBlock.rows[startRowIndex];
16886
- const starts = normalizeCellStartPositions(
16887
- firstRow2,
16888
- currentCellBlockPositions,
16889
- void 0
16890
- );
16891
- const ends = firstRow2.cells.map((cell) => ({
16892
- blockIndex: cell.blocks.length
16893
- }));
16894
- const slicedFirstRow = buildRowSliceFromPositions(
16895
- firstRow2,
16896
- starts,
16897
- ends
16898
- );
16899
- candidateHeight = getTableSegmentHeight(
16900
- {
16901
- ...sourceBlock,
16902
- rows: [slicedFirstRow]
16903
- },
16904
- 0,
16905
- 1,
16906
- repeatedHeaderRowCount,
16907
- styles,
16908
- contentWidth,
16909
- measurer,
16910
- defaultTabStop
16911
- );
16903
+ const buildTableBlock = (segmentId, startRowIndex, groupEndIndex, repeatedHeaderRowCount, segmentHeight, splitEnds, splitEndPositions, startCellPositions) => {
16904
+ const endRowIndex = rowGroups[groupEndIndex - 1].endRowIndexExclusive;
16905
+ const measuredSegmentHeight = (measuredHeights == null ? void 0 : measuredHeights[segmentId]) ?? segmentHeight;
16906
+ return {
16907
+ blockId: segmentId,
16908
+ sourceBlockId: sourceBlock.id,
16909
+ blockType: sourceBlock.type,
16910
+ globalIndex: index,
16911
+ estimatedHeight: measuredSegmentHeight,
16912
+ tableSegment: {
16913
+ startRowIndex,
16914
+ endRowIndex,
16915
+ repeatedHeaderRowCount,
16916
+ startRowCellBlockStarts: positionsToBlockIndexes(startCellPositions),
16917
+ endRowCellBlockEnds: splitEnds,
16918
+ startRowCellBlockPositions: hasPartialPositions(startCellPositions) ? startCellPositions : void 0,
16919
+ endRowCellBlockPositions: hasPartialPositions(splitEndPositions) ? splitEndPositions : void 0
16920
+ },
16921
+ sourceBlock
16922
+ };
16923
+ };
16924
+ const advanceCursor = (groupEndIndex, isLastRowSplit, splitEnds, splitEndPositions) => {
16925
+ if (isLastRowSplit) {
16926
+ const lastRowIndex = rowGroups[groupEndIndex - 1].startRowIndex;
16927
+ const lastRow = sourceBlock.rows[lastRowIndex];
16928
+ const ends = splitEndPositions ?? (splitEnds == null ? void 0 : splitEnds.map((blockIndex) => ({ blockIndex }))) ?? [];
16929
+ if (positionsFinishedRow(lastRow, ends)) {
16930
+ currentCellBlockPositions = void 0;
16931
+ groupStartIndex = groupEndIndex;
16912
16932
  } else {
16913
- candidateHeight = getTableSegmentHeight(
16914
- sourceBlock,
16915
- startRowIndex,
16916
- candidateEndRowIndex,
16917
- repeatedHeaderRowCount,
16918
- styles,
16919
- contentWidth,
16920
- measurer,
16921
- defaultTabStop
16922
- );
16923
- }
16924
- if (candidateHeight <= remainingHeight) {
16925
- segmentHeight = candidateHeight;
16926
- groupEndIndex += 1;
16927
- continue;
16933
+ currentCellBlockPositions = ends;
16934
+ groupStartIndex = groupEndIndex - 1;
16928
16935
  }
16929
- const isSingleRowGroup = candidateEndRowIndex === rowGroups[groupEndIndex].startRowIndex + 1;
16930
- const targetRow = sourceBlock.rows[rowGroups[groupEndIndex].startRowIndex];
16931
- const isSplitCandidate = isSingleRowGroup && canSplitTableRow(targetRow);
16932
- if (isSplitCandidate) {
16933
- const precedingHeight = groupEndIndex > groupStartIndex ? getTableSegmentHeight(
16934
- sourceBlock,
16935
- startRowIndex,
16936
- rowGroups[groupEndIndex].startRowIndex,
16937
- repeatedHeaderRowCount,
16938
- styles,
16939
- contentWidth,
16940
- measurer,
16941
- defaultTabStop
16942
- ) : 0;
16943
- const availableForSplitRow = remainingHeight - precedingHeight;
16944
- if (availableForSplitRow > 0) {
16936
+ } else {
16937
+ currentCellBlockPositions = void 0;
16938
+ groupStartIndex = groupEndIndex;
16939
+ }
16940
+ };
16941
+ paginateSegments(track, sourceBlock.id, {
16942
+ hasMore: () => groupStartIndex < rowGroups.length,
16943
+ fit(segmentId, remaining) {
16944
+ const startRowIndex = rowGroups[groupStartIndex].startRowIndex;
16945
+ const repeatedHeaderRowCount = startRowIndex > 0 ? headerRowCount : 0;
16946
+ const startCellPositions = currentCellBlockPositions;
16947
+ let groupEndIndex = groupStartIndex;
16948
+ let segmentHeight = 0;
16949
+ let splitEnds;
16950
+ let splitEndPositions;
16951
+ let isLastRowSplit = false;
16952
+ while (groupEndIndex < rowGroups.length) {
16953
+ const candidateEndRowIndex = rowGroups[groupEndIndex].endRowIndexExclusive;
16954
+ let candidateHeight = 0;
16955
+ if (groupEndIndex === groupStartIndex && currentCellBlockPositions) {
16956
+ const firstRow2 = sourceBlock.rows[startRowIndex];
16945
16957
  const starts = normalizeCellStartPositions(
16946
- targetRow,
16947
- groupEndIndex === groupStartIndex ? currentCellBlockPositions : void 0,
16958
+ firstRow2,
16959
+ currentCellBlockPositions,
16948
16960
  void 0
16949
16961
  );
16950
- const ends = targetRow.cells.map(
16951
- (_, cellIdx) => findCellSplitEndPosition(
16952
- targetRow,
16953
- cellIdx,
16954
- starts[cellIdx] ?? { blockIndex: 0 },
16955
- availableForSplitRow,
16956
- styles,
16957
- measurer,
16958
- defaultTabStop,
16959
- contentWidth,
16960
- sourceBlock,
16961
- rowGroups[groupEndIndex].startRowIndex
16962
- )
16962
+ const ends = firstRow2.cells.map((cell) => ({
16963
+ blockIndex: cell.blocks.length
16964
+ }));
16965
+ const slicedFirstRow = buildRowSliceFromPositions(
16966
+ firstRow2,
16967
+ starts,
16968
+ ends
16963
16969
  );
16964
- const canProgress = positionsProgressed(starts, ends);
16965
- if (canProgress) {
16966
- splitEnds = positionsToBlockIndexes(ends);
16967
- isLastRowSplit = true;
16968
- const slicedLastRow = buildRowSliceFromPositions(
16970
+ candidateHeight = getTableSegmentHeight(
16971
+ { ...sourceBlock, rows: [slicedFirstRow] },
16972
+ 0,
16973
+ 1,
16974
+ repeatedHeaderRowCount,
16975
+ styles,
16976
+ contentWidth,
16977
+ measurer,
16978
+ defaultTabStop
16979
+ );
16980
+ } else {
16981
+ candidateHeight = getTableSegmentHeight(
16982
+ sourceBlock,
16983
+ startRowIndex,
16984
+ candidateEndRowIndex,
16985
+ repeatedHeaderRowCount,
16986
+ styles,
16987
+ contentWidth,
16988
+ measurer,
16989
+ defaultTabStop
16990
+ );
16991
+ }
16992
+ if (candidateHeight <= remaining) {
16993
+ segmentHeight = candidateHeight;
16994
+ groupEndIndex += 1;
16995
+ continue;
16996
+ }
16997
+ const isSingleRowGroup = candidateEndRowIndex === rowGroups[groupEndIndex].startRowIndex + 1;
16998
+ const targetRow = sourceBlock.rows[rowGroups[groupEndIndex].startRowIndex];
16999
+ const isSplitCandidate = isSingleRowGroup && canSplitTableRow(targetRow);
17000
+ if (isSplitCandidate) {
17001
+ const precedingHeight = groupEndIndex > groupStartIndex ? getTableSegmentHeight(
17002
+ sourceBlock,
17003
+ startRowIndex,
17004
+ rowGroups[groupEndIndex].startRowIndex,
17005
+ repeatedHeaderRowCount,
17006
+ styles,
17007
+ contentWidth,
17008
+ measurer,
17009
+ defaultTabStop
17010
+ ) : 0;
17011
+ const availableForSplitRow = remaining - precedingHeight;
17012
+ if (availableForSplitRow > 0) {
17013
+ const starts = normalizeCellStartPositions(
16969
17014
  targetRow,
16970
- starts,
16971
- ends
17015
+ groupEndIndex === groupStartIndex ? currentCellBlockPositions : void 0,
17016
+ void 0
16972
17017
  );
16973
- const segmentRows = [
16974
- ...sourceBlock.rows.slice(
16975
- startRowIndex,
17018
+ const ends = targetRow.cells.map(
17019
+ (_, cellIdx) => findCellSplitEndPosition(
17020
+ targetRow,
17021
+ cellIdx,
17022
+ starts[cellIdx] ?? { blockIndex: 0 },
17023
+ availableForSplitRow,
17024
+ styles,
17025
+ measurer,
17026
+ defaultTabStop,
17027
+ contentWidth,
17028
+ sourceBlock,
16976
17029
  rowGroups[groupEndIndex].startRowIndex
16977
- ),
16978
- slicedLastRow
16979
- ];
16980
- segmentHeight = getTableSegmentHeight(
16981
- { ...sourceBlock, rows: segmentRows },
16982
- 0,
16983
- segmentRows.length,
16984
- repeatedHeaderRowCount,
16985
- styles,
16986
- contentWidth,
16987
- measurer,
16988
- defaultTabStop
17030
+ )
16989
17031
  );
16990
- splitEndPositions = ends;
16991
- groupEndIndex += 1;
16992
- break;
17032
+ if (positionsProgressed(starts, ends)) {
17033
+ splitEnds = positionsToBlockIndexes(ends);
17034
+ isLastRowSplit = true;
17035
+ const slicedLastRow = buildRowSliceFromPositions(
17036
+ targetRow,
17037
+ starts,
17038
+ ends
17039
+ );
17040
+ const segmentRows = [
17041
+ ...sourceBlock.rows.slice(
17042
+ startRowIndex,
17043
+ rowGroups[groupEndIndex].startRowIndex
17044
+ ),
17045
+ slicedLastRow
17046
+ ];
17047
+ segmentHeight = getTableSegmentHeight(
17048
+ { ...sourceBlock, rows: segmentRows },
17049
+ 0,
17050
+ segmentRows.length,
17051
+ repeatedHeaderRowCount,
17052
+ styles,
17053
+ contentWidth,
17054
+ measurer,
17055
+ defaultTabStop
17056
+ );
17057
+ splitEndPositions = ends;
17058
+ groupEndIndex += 1;
17059
+ break;
17060
+ }
16993
17061
  }
16994
17062
  }
17063
+ break;
16995
17064
  }
16996
- break;
16997
- }
16998
- if (groupEndIndex === groupStartIndex && track.blocks.length > 0) {
16999
- track.flush();
17000
- continue;
17001
- }
17002
- if (groupEndIndex === groupStartIndex) {
17065
+ if (groupEndIndex === groupStartIndex) return null;
17066
+ const block = buildTableBlock(
17067
+ segmentId,
17068
+ startRowIndex,
17069
+ groupEndIndex,
17070
+ repeatedHeaderRowCount,
17071
+ segmentHeight,
17072
+ splitEnds,
17073
+ splitEndPositions,
17074
+ startCellPositions
17075
+ );
17076
+ advanceCursor(groupEndIndex, isLastRowSplit, splitEnds, splitEndPositions);
17077
+ return block;
17078
+ },
17079
+ force(segmentId) {
17080
+ const startRowIndex = rowGroups[groupStartIndex].startRowIndex;
17081
+ const repeatedHeaderRowCount = startRowIndex > 0 ? headerRowCount : 0;
17082
+ const startCellPositions = currentCellBlockPositions;
17083
+ let groupEndIndex = groupStartIndex;
17084
+ let segmentHeight = 0;
17085
+ let splitEnds;
17086
+ let splitEndPositions;
17087
+ let isLastRowSplit = false;
17003
17088
  const targetRow = sourceBlock.rows[startRowIndex];
17004
17089
  const isSingleRowGroup = rowGroups[groupStartIndex].endRowIndexExclusive === startRowIndex + 1;
17005
17090
  const isSplitCandidate = isSingleRowGroup && canSplitTableRow(targetRow);
@@ -17034,11 +17119,7 @@ function paginateTableBlock(track, params, sourceBlock, index) {
17034
17119
  splitEnds = positionsToBlockIndexes(ends);
17035
17120
  splitEndPositions = ends;
17036
17121
  isLastRowSplit = true;
17037
- const slicedLastRow = buildRowSliceFromPositions(
17038
- targetRow,
17039
- starts,
17040
- ends
17041
- );
17122
+ const slicedLastRow = buildRowSliceFromPositions(targetRow, starts, ends);
17042
17123
  segmentHeight = getTableSegmentHeight(
17043
17124
  { ...sourceBlock, rows: [slicedLastRow] },
17044
17125
  0,
@@ -17063,53 +17144,20 @@ function paginateTableBlock(track, params, sourceBlock, index) {
17063
17144
  defaultTabStop
17064
17145
  );
17065
17146
  }
17066
- }
17067
- const segmentId = `${sourceBlock.id}:segment:${segmentIndex}`;
17068
- const measuredSegmentHeight = (measuredHeights == null ? void 0 : measuredHeights[segmentId]) ?? segmentHeight;
17069
- const endRowIndex = rowGroups[groupEndIndex - 1].endRowIndexExclusive;
17070
- track.blocks.push({
17071
- blockId: segmentId,
17072
- sourceBlockId: sourceBlock.id,
17073
- blockType: sourceBlock.type,
17074
- globalIndex: index,
17075
- estimatedHeight: measuredSegmentHeight,
17076
- tableSegment: {
17147
+ const block = buildTableBlock(
17148
+ segmentId,
17077
17149
  startRowIndex,
17078
- endRowIndex,
17150
+ groupEndIndex,
17079
17151
  repeatedHeaderRowCount,
17080
- startRowCellBlockStarts: positionsToBlockIndexes(
17081
- currentCellBlockPositions
17082
- ),
17083
- endRowCellBlockEnds: splitEnds,
17084
- startRowCellBlockPositions: hasPartialPositions(
17085
- currentCellBlockPositions
17086
- ) ? currentCellBlockPositions : void 0,
17087
- endRowCellBlockPositions: hasPartialPositions(splitEndPositions) ? splitEndPositions : void 0
17088
- },
17089
- sourceBlock
17090
- });
17091
- track.height += measuredSegmentHeight;
17092
- segmentIndex += 1;
17093
- if (isLastRowSplit) {
17094
- const lastRowIndex = rowGroups[groupEndIndex - 1].startRowIndex;
17095
- const lastRow = sourceBlock.rows[lastRowIndex];
17096
- const ends = splitEndPositions ?? (splitEnds == null ? void 0 : splitEnds.map((blockIndex) => ({ blockIndex }))) ?? [];
17097
- const isFinished = positionsFinishedRow(lastRow, ends);
17098
- if (isFinished) {
17099
- currentCellBlockPositions = void 0;
17100
- groupStartIndex = groupEndIndex;
17101
- } else {
17102
- currentCellBlockPositions = ends;
17103
- groupStartIndex = groupEndIndex - 1;
17104
- }
17105
- } else {
17106
- currentCellBlockPositions = void 0;
17107
- groupStartIndex = groupEndIndex;
17108
- }
17109
- if (groupStartIndex < rowGroups.length) {
17110
- track.flush();
17152
+ segmentHeight,
17153
+ splitEnds,
17154
+ splitEndPositions,
17155
+ startCellPositions
17156
+ );
17157
+ advanceCursor(groupEndIndex, isLastRowSplit, splitEnds, splitEndPositions);
17158
+ return block;
17111
17159
  }
17112
- }
17160
+ });
17113
17161
  }
17114
17162
  function projectBlocksLayout(context2) {
17115
17163
  const columns = context2.pageSettings.columns;
@@ -17519,6 +17567,19 @@ function applyCanvasTextFeatureHints(ctx, styles, fontSizePx) {
17519
17567
  featureCtx.textRendering = (styles == null ? void 0 : styles.ligatures) && styles.ligatures !== "none" ? "optimizeLegibility" : "optimizeSpeed";
17520
17568
  }
17521
17569
  }
17570
+ function resolveCanvasRunPaintStyle(styles) {
17571
+ const fontSize = (styles == null ? void 0 : styles.fontSize) ?? DEFAULT_FONT_SIZE_PX;
17572
+ const fontFamily = resolveCanvasFontFamily(styles == null ? void 0 : styles.fontFamily);
17573
+ const fontWeight = (styles == null ? void 0 : styles.bold) ? "700" : "400";
17574
+ const fontStyle = (styles == null ? void 0 : styles.italic) ? "italic" : "normal";
17575
+ const renderMetrics = resolveCanvasTextRenderMetrics(styles, fontSize);
17576
+ return {
17577
+ font: `${fontStyle} ${fontWeight} ${renderMetrics.fontSize}px ${fontFamily}`,
17578
+ fillStyle: (styles == null ? void 0 : styles.color) ?? "#000000",
17579
+ renderMetrics,
17580
+ scale: (styles == null ? void 0 : styles.characterScale) && styles.characterScale > 0 ? styles.characterScale / 100 : 1
17581
+ };
17582
+ }
17522
17583
  function resolveVerticalMode(direction) {
17523
17584
  switch (direction) {
17524
17585
  case "tbRl":
@@ -17649,10 +17710,8 @@ function layoutStackedGlyphs(paragraph, state, box, startColumn, columnsRtl = tr
17649
17710
  state.document.styles
17650
17711
  );
17651
17712
  const fontSize = styles.fontSize ?? DEFAULT_FONT_SIZE_PX;
17652
- const metrics = resolveCanvasTextRenderMetrics(styles, fontSize);
17713
+ const { font, fillStyle: color } = resolveCanvasRunPaintStyle(styles);
17653
17714
  const glyphHeight = fontSize * STACK_LINE_FACTOR;
17654
- const font = `${styles.italic ? "italic" : "normal"} ${styles.bold ? "700" : "400"} ${metrics.fontSize}px ${resolveCanvasFontFamily(styles.fontFamily)}`;
17655
- const color = styles.color ?? "#000000";
17656
17715
  for (const char of run.text) {
17657
17716
  if (char === "\n") {
17658
17717
  newColumn();
@@ -20490,13 +20549,10 @@ function drawParagraph(ctx, paragraph, lines, state, originX, originY, onUpdate,
20490
20549
  (_b = paragraph.style) == null ? void 0 : _b.styleId,
20491
20550
  state.document.styles
20492
20551
  );
20493
- const prefixFontSize = prefixStyles.fontSize ?? DEFAULT_FONT_SIZE_PX;
20494
- const prefixWeight = prefixStyles.bold ? "700" : "400";
20495
- const prefixStyle = prefixStyles.italic ? "italic" : "normal";
20496
- const prefixFamily = resolveCanvasFontFamily(prefixStyles.fontFamily);
20552
+ const { font: prefixFont, fillStyle: prefixFillStyle } = resolveCanvasRunPaintStyle(prefixStyles);
20497
20553
  ctx.save();
20498
- ctx.font = `${prefixStyle} ${prefixWeight} ${prefixFontSize}px ${prefixFamily}`;
20499
- ctx.fillStyle = prefixStyles.color ?? "#000000";
20554
+ ctx.font = prefixFont;
20555
+ ctx.fillStyle = prefixFillStyle;
20500
20556
  const first = line.slots[0];
20501
20557
  const gap = ctx.measureText(`${listPrefix} `).width;
20502
20558
  const labelInset = getListLabelInset(paragraph, state.document.styles);
@@ -20524,12 +20580,9 @@ function drawParagraph(ctx, paragraph, lines, state, originX, originY, onUpdate,
20524
20580
  const metricFamily = resolveMetricCompatibleFamily(
20525
20581
  styles.fontFamily ?? "Calibri"
20526
20582
  );
20527
- const fontFamily = resolveCanvasFontFamily(styles.fontFamily);
20528
- const fontWeight = styles.bold ? "700" : "400";
20529
- const fontStyle = styles.italic ? "italic" : "normal";
20530
- const renderMetrics = resolveCanvasTextRenderMetrics(styles, fontSize);
20583
+ const { font, renderMetrics } = resolveCanvasRunPaintStyle(styles);
20531
20584
  ctx.save();
20532
- ctx.font = `${fontStyle} ${fontWeight} ${renderMetrics.fontSize}px ${fontFamily}`;
20585
+ ctx.font = font;
20533
20586
  applyCanvasTextFeatureHints(ctx, styles, fontSize);
20534
20587
  logCanvasFontUse({
20535
20588
  requestedFamily: styles.fontFamily,
@@ -20698,18 +20751,10 @@ function drawParagraph(ctx, paragraph, lines, state, originX, originY, onUpdate,
20698
20751
  state.document.styles
20699
20752
  );
20700
20753
  if (!styles.hidden) {
20701
- const fontSize = styles.fontSize ?? DEFAULT_FONT_SIZE_PX;
20702
- const fontFamily = resolveCanvasFontFamily(styles.fontFamily);
20703
- const fontWeight = styles.bold ? "700" : "400";
20704
- const fontStyle = styles.italic ? "italic" : "normal";
20705
- const renderMetrics = resolveCanvasTextRenderMetrics(
20706
- styles,
20707
- fontSize
20708
- );
20709
- const scale = styles.characterScale && styles.characterScale > 0 ? styles.characterScale / 100 : 1;
20754
+ const { font, fillStyle, renderMetrics, scale } = resolveCanvasRunPaintStyle(styles);
20710
20755
  ctx.save();
20711
- ctx.font = `${fontStyle} ${fontWeight} ${renderMetrics.fontSize}px ${fontFamily}`;
20712
- ctx.fillStyle = styles.color ?? "#000000";
20756
+ ctx.font = font;
20757
+ ctx.fillStyle = fillStyle;
20713
20758
  drawStyledText(
20714
20759
  ctx,
20715
20760
  "-",
@@ -21248,18 +21293,14 @@ function drawDropCapForParagraph(options) {
21248
21293
  return;
21249
21294
  }
21250
21295
  const style2 = dropCap.style;
21251
- const fontSize = (style2 == null ? void 0 : style2.fontSize) ?? DEFAULT_FONT_SIZE_PX;
21252
- const bodyLineHeight = ((_a = lines[0]) == null ? void 0 : _a.height) ?? fontSize;
21253
- const renderMetrics = resolveCanvasTextRenderMetrics(style2, fontSize);
21254
- const fontWeight = (style2 == null ? void 0 : style2.bold) ? "700" : "400";
21255
- const fontStyle = (style2 == null ? void 0 : style2.italic) ? "italic" : "normal";
21256
- const fontFamily = resolveCanvasFontFamily(style2 == null ? void 0 : style2.fontFamily);
21296
+ const { font, fillStyle, renderMetrics } = resolveCanvasRunPaintStyle(style2);
21297
+ const bodyLineHeight = ((_a = lines[0]) == null ? void 0 : _a.height) ?? ((style2 == null ? void 0 : style2.fontSize) ?? DEFAULT_FONT_SIZE_PX);
21257
21298
  const glyphWidth = measureDropCapWidth(dropCap);
21258
21299
  const x = dropCap.type === "margin" ? originX - glyphWidth : originX;
21259
21300
  const baselineY = paragraphTop + (dropCap.lines - 0.2) * bodyLineHeight + renderMetrics.baselineOffset;
21260
21301
  ctx.save();
21261
- ctx.font = `${fontStyle} ${fontWeight} ${renderMetrics.fontSize}px ${fontFamily}`;
21262
- ctx.fillStyle = (style2 == null ? void 0 : style2.color) ?? "#000000";
21302
+ ctx.font = font;
21303
+ ctx.fillStyle = fillStyle;
21263
21304
  ctx.textBaseline = "alphabetic";
21264
21305
  ctx.fillText(dropCap.text, x, baselineY);
21265
21306
  ctx.restore();
@@ -42671,13 +42712,13 @@ export {
42671
42712
  setStyleProperty as af,
42672
42713
  memo as ag,
42673
42714
  template as ah,
42674
- useI18n as ai,
42675
- createEffect as aj,
42676
- insert as ak,
42677
- use as al,
42678
- addEventListener as am,
42679
- Dialog as an,
42680
- delegateEvents as ao,
42715
+ addEventListener as ai,
42716
+ insert as aj,
42717
+ delegateEvents as ak,
42718
+ useI18n as al,
42719
+ createEffect as am,
42720
+ use as an,
42721
+ Dialog as ao,
42681
42722
  className as ap,
42682
42723
  For as aq,
42683
42724
  UNDERLINE_STYLE_OPTIONS as ar,