oasis-editor 0.0.122 → 0.0.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { E as EMPTY_PROJECTION_CONTEXT, d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageBodyBottom, b as getPageBodyTop, c as getPageContentWidth, F as FOOTNOTE_MARKER_GUTTER_PX, f as getParagraphText, h as getBlockParagraphs, i as getRunFootnoteReference, l as listReferencedEndnotes, j as getFootnoteDisplayMarker, k as createProjectionContext, m as getDocumentSections, n as getRunField, o as projectBlocksLayout, v as visitRun, q as assertNever, r as createSignal, s as createEditorStateFromDocument, t as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, u as fontSizePxToPt, w as probeLocalFontFamilies, x as createEditorParagraphFromRuns, y as isInlineObjectRun, z as createEditorStyledRun, A as getParagraphLength, B as getActiveZone, C as getActiveSectionIndex, D as getParagraphs, G as normalizeSelection, H as positionToParagraphOffset, I as paragraphOffsetToPosition, J as clampPosition, K as findParagraphIndex, L as createCollapsedSelection, M as isSelectionCollapsed, N as parseFontSizePtToPx, O as formatFontSizePt, P as createEditorParagraph, Q as resolveDefaultParagraphStyleId, R as findParagraphTableLocation, T as buildTableCellLayout, U as PT_PER_PX, V as createEditorTableCell, W as createEditorTableRow, X as createEditorTable, Y as PX_PER_POINT, Z as underlineStyleToCssDecorationStyle, _ as resolveImageSrc, $ as listKindForTag, a0 as isParagraphTag, a1 as collectInlineRuns, a2 as parseParagraphStyle, a3 as getRunImage, a4 as InlineShell, a5 as BalloonShell, a6 as DocumentShell, a7 as createMemo, a8 as getCaretRectFromSnapshot, a9 as getParagraphRectFromSnapshot, aa as createComponent, ab as CaretOverlay, ac as Show, ad as createRenderEffect, ae as style, af as setAttribute, ag as setStyleProperty, ah as memo, ai as template, aj as Button, ak as useI18n, al as createEffect, am as TextField, an as Dialog, ao as insert, ap as className, aq as Grid, ar as SelectField, as as StatusText, at as ColorField, au as UNDERLINE_STYLE_OPTIONS, av as Stack, aw as For, ax as ToggleChip, ay as FormField, az as Checkbox, aA as FieldGroup, aB as Tabs, aC as NumberField, aD as createStore, aE as reconcile, aF as RadioGroup, aG as Radio$1, aH as TextAreaField, aI as Text, aJ as SurfaceButton, aK as delegateEvents, aL as onMount, aM as onCleanup, aN as use, aO as PluginUiHost, aP as OasisEditorEditor, aQ as OasisBrandMark, aR as setPreciseFontPreference, aS as setWelcomeSeen, aT as enablePreciseFontMode, aU as TWIPS_PER_POINT, aV as PX_PER_INCH, aW as TWIPS_PER_INCH, aX as normalizeHex6, aY as TABLE_CONDITIONAL_FLAG_ATTRIBUTES, aZ as TABLE_BORDER_EDGE_KEYS, a_ as resolveEffectiveParagraphStyle, a$ as resolveEffectiveTextStyleForParagraph, b0 as EMU_PER_PT, b1 as OOXML_ROTATION_UNITS, b2 as OOXML_PERCENT_DENOMINATOR, b3 as parseHexColorToRgb255, b4 as EMU_PER_PX, b5 as getRunEndnoteReference, b6 as iterateFootnoteReferenceRuns, b7 as iterateEndnoteReferenceRuns, b8 as imageContentTypeDefaults, b9 as getRunFieldChar, ba as getRunFieldInstruction, bb as createEditorRun, bc as JSZip, bd as imageExtensionFromMime, be as pxToPt$1, bf as resolveFloatingObjectRect, bg as getTextBoxFloatingGeometry, bh as getPresetPathSegments, bi as buildListLabels, bj as DEFAULT_FONT_SIZE_PX, bk as resolveGradientAxis, bl as isDoubleUnderlineStyle, bm as isWavyUnderlineStyle, bn as underlineStyleLineWidthPx, bo as WAVY_UNDERLINE_WAVELENGTH_PX, bp as WAVY_UNDERLINE_AMPLITUDE_PX, bq as DOUBLE_UNDERLINE_OFFSET_PX, br as underlineStyleDashArray, bs as EMPHASIS_GLYPH, bt as rgb255ToHex, bu as getImageFloatingGeometry, bv as textStyleToFontSizePt, bw as TEXT_BASELINE_RATIO, bx as resolveOpenTypeFeatureTags, by as resolveDecorationLineY, bz as DOUBLE_STRIKE_OFFSET_PX, bA as resolveListLabel, bB as getListLabelInset, bC as getAlignedListLabelInset, bD as getParagraphBorderInsets, bE as buildSegmentTable, bF as buildCanvasTableLayout, bG as resolveCanvasTableWidth, bH as resolveFloatingTableRect, bI as normalizeFamily, bJ as ROBOTO_FONT_FILES, bK as loadFontAsset, bL as OFFICE_COMPAT_FONT_FAMILIES, bM as BinaryReader, bN as buildSfnt, bO as defaultFontDecoderRegistry, bP as SfntFontProgram, bQ as collectPdfFontFamilies, bR as outlineFrom, bS as getPageHeaderZoneTop, bT as getPageColumnRects, bU as findFootnoteReference, bV as resolveImporterForFile, bW as roundTo, bX as getDocumentSectionsCanonical, bY as getDocumentParagraphsCanonical, bZ as getDocumentParagraphs, b_ as getDocumentPageSettings, b$ as getTableCellContentWidthForParagraph, c0 as layoutMetricsEpoch, c1 as bumpLayoutMetricsEpoch, c2 as createCanvasLayoutSnapshotProvider, c3 as on, c4 as debounce, c5 as unwrap, c6 as perfTimer, c7 as getRunTextBox, c8 as createEditorDocument, c9 as resolveResizedDimensions, ca as resolveTextBoxRenderHeight, cb as getToolbarStyleState, cc as VERTICAL_HIT_WEIGHT, cd as getCachedCanvasImage, ce as measureParagraphMinContentWidthPx, cf as getEditableBlocksForZone, cg as findParagraphLocation, ch as createSectionBoundaryParagraph, ci as normalizePageSettings, cj as DEFAULT_EDITOR_PAGE_SETTINGS, ck as markStart, cl as markEnd, cm as getParagraphEntries, cn as getParagraphById, co as createEditorFootnote, cp as createFootnoteReferenceRun, cq as renumberFootnotes, cr as getHeadingLevel, cs as preciseFontModeVersion, ct as isPreciseFontModeEnabled, cu as resolveNamedTextStyle, cv as togglePreciseFontMode, cw as nextFontSizePt, cx as previousFontSizePt, cy as fontSizePtToPx, cz as createDefaultToolbarPreset, cA as MenuRegistry, cB as createToolbarRegistry, cC as Editor, cD as resolveCommandRef, cE as commandRefName, cF as createOasisEditorClient, cG as createEditorZoom, cH as startLongTaskObserver, cI as installGlobalReport, cJ as applyStoredPreciseFontPreference, cK as getWelcomeSeen, cL as isLocalFontAccessSupported, cM as EDITOR_SCROLL_PADDING_PX, cN as Toolbar, cO as OasisEditorLoading, cP as I18nProvider, cQ as createTranslator, cR as registerDomStatsSurface, cS as createEditorLogger } from "./index-YMlNF1Ya.js";
4
+ import { E as EMPTY_PROJECTION_CONTEXT, d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageBodyBottom, b as getPageBodyTop, c as getPageContentWidth, F as FOOTNOTE_MARKER_GUTTER_PX, f as getParagraphText, h as getBlockParagraphs, i as getRunFootnoteReference, l as listReferencedEndnotes, j as getFootnoteDisplayMarker, k as createProjectionContext, m as getDocumentSections, n as getRunField, o as projectBlocksLayout, v as visitRun, q as assertNever, r as createSignal, s as createEditorStateFromDocument, t as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, u as fontSizePxToPt, w as probeLocalFontFamilies, x as createEditorParagraphFromRuns, y as isInlineObjectRun, z as createEditorStyledRun, A as getParagraphLength, B as getActiveZone, C as getActiveSectionIndex, D as getParagraphs, G as normalizeSelection, H as positionToParagraphOffset, I as paragraphOffsetToPosition, J as clampPosition, K as findParagraphIndex, L as createCollapsedSelection, M as isSelectionCollapsed, N as parseFontSizePtToPx, O as formatFontSizePt, P as createEditorParagraph, Q as resolveDefaultParagraphStyleId, R as findParagraphTableLocation, T as buildTableCellLayout, U as PT_PER_PX, V as createEditorTableCell, W as createEditorTableRow, X as createEditorTable, Y as PX_PER_POINT, Z as underlineStyleToCssDecorationStyle, _ as resolveImageSrc, $ as listKindForTag, a0 as isParagraphTag, a1 as collectInlineRuns, a2 as parseParagraphStyle, a3 as getRunImage, a4 as InlineShell, a5 as BalloonShell, a6 as DocumentShell, a7 as createMemo, a8 as getCaretRectFromSnapshot, a9 as getParagraphRectFromSnapshot, aa as createComponent, ab as CaretOverlay, ac as Show, ad as createRenderEffect, ae as style, af as setAttribute, ag as setStyleProperty, ah as memo, ai as template, aj as Button, ak as useI18n, al as createEffect, am as TextField, an as Dialog, ao as insert, ap as className, aq as Grid, ar as SelectField, as as StatusText, at as ColorField, au as UNDERLINE_STYLE_OPTIONS, av as Stack, aw as For, ax as ToggleChip, ay as FormField, az as Checkbox, aA as FieldGroup, aB as Tabs, aC as NumberField, aD as createStore, aE as reconcile, aF as RadioGroup, aG as Radio$1, aH as TextAreaField, aI as Text, aJ as SurfaceButton, aK as delegateEvents, aL as onMount, aM as onCleanup, aN as use, aO as PluginUiHost, aP as OasisEditorEditor, aQ as OasisBrandMark, aR as setPreciseFontPreference, aS as setWelcomeSeen, aT as enablePreciseFontMode, aU as TWIPS_PER_POINT, aV as PX_PER_INCH, aW as TWIPS_PER_INCH, aX as normalizeHex6, aY as TABLE_CONDITIONAL_FLAG_ATTRIBUTES, aZ as TABLE_BORDER_EDGE_KEYS, a_ as resolveEffectiveParagraphStyle, a$ as resolveEffectiveTextStyleForParagraph, b0 as EMU_PER_PT, b1 as OOXML_ROTATION_UNITS, b2 as OOXML_PERCENT_DENOMINATOR, b3 as parseHexColorToRgb255, b4 as EMU_PER_PX, b5 as getRunEndnoteReference, b6 as iterateFootnoteReferenceRuns, b7 as iterateEndnoteReferenceRuns, b8 as imageContentTypeDefaults, b9 as getRunFieldChar, ba as getRunFieldInstruction, bb as createEditorRun, bc as JSZip, bd as imageExtensionFromMime, be as pxToPt$1, bf as resolveFloatingObjectRect, bg as getTextBoxFloatingGeometry, bh as getPresetPathSegments, bi as buildListLabels, bj as DEFAULT_FONT_SIZE_PX, bk as resolveGradientAxis, bl as isDoubleUnderlineStyle, bm as isWavyUnderlineStyle, bn as underlineStyleLineWidthPx, bo as WAVY_UNDERLINE_WAVELENGTH_PX, bp as WAVY_UNDERLINE_AMPLITUDE_PX, bq as DOUBLE_UNDERLINE_OFFSET_PX, br as underlineStyleDashArray, bs as EMPHASIS_GLYPH, bt as rgb255ToHex, bu as getImageFloatingGeometry, bv as textStyleToFontSizePt, bw as TEXT_BASELINE_RATIO, bx as resolveOpenTypeFeatureTags, by as resolveDecorationLineY, bz as DOUBLE_STRIKE_OFFSET_PX, bA as resolveListLabel, bB as getListLabelInset, bC as getAlignedListLabelInset, bD as getParagraphBorderInsets, bE as buildSegmentTable, bF as buildCanvasTableLayout, bG as resolveCanvasTableWidth, bH as resolveFloatingTableRect, bI as normalizeFamily, bJ as ROBOTO_FONT_FILES, bK as loadFontAsset, bL as OFFICE_COMPAT_FONT_FAMILIES, bM as BinaryReader, bN as buildSfnt, bO as defaultFontDecoderRegistry, bP as SfntFontProgram, bQ as collectPdfFontFamilies, bR as outlineFrom, bS as getPageHeaderZoneTop, bT as getPageColumnRects, bU as findFootnoteReference, bV as resolveImporterForFile, bW as roundTo, bX as getDocumentSectionsCanonical, bY as getDocumentParagraphsCanonical, bZ as getDocumentParagraphs, b_ as getDocumentPageSettings, b$ as getTableCellContentWidthForParagraph, c0 as layoutMetricsEpoch, c1 as bumpLayoutMetricsEpoch, c2 as createCanvasLayoutSnapshotProvider, c3 as on, c4 as debounce, c5 as unwrap, c6 as perfTimer, c7 as getRunTextBox, c8 as createEditorDocument, c9 as resolveResizedDimensions, ca as resolveTextBoxRenderHeight, cb as getToolbarStyleState, cc as VERTICAL_HIT_WEIGHT, cd as getCachedCanvasImage, ce as measureParagraphMinContentWidthPx, cf as getEditableBlocksForZone, cg as findParagraphLocation, ch as createSectionBoundaryParagraph, ci as normalizePageSettings, cj as DEFAULT_EDITOR_PAGE_SETTINGS, ck as markStart, cl as markEnd, cm as getParagraphEntries, cn as getParagraphById, co as createEditorFootnote, cp as createFootnoteReferenceRun, cq as renumberFootnotes, cr as getHeadingLevel, cs as preciseFontModeVersion, ct as isPreciseFontModeEnabled, cu as resolveNamedTextStyle, cv as togglePreciseFontMode, cw as nextFontSizePt, cx as previousFontSizePt, cy as fontSizePtToPx, cz as createDefaultToolbarPreset, cA as MenuRegistry, cB as createToolbarRegistry, cC as Editor, cD as resolveCommandRef, cE as commandRefName, cF as createOasisEditorClient, cG as createEditorZoom, cH as startLongTaskObserver, cI as installGlobalReport, cJ as applyStoredPreciseFontPreference, cK as getWelcomeSeen, cL as isLocalFontAccessSupported, cM as EDITOR_SCROLL_PADDING_PX, cN as Toolbar, cO as OasisEditorLoading, cP as I18nProvider, cQ as createTranslator, cR as registerDomStatsSurface, cS as createEditorLogger } from "./index-zlwh4WsF.js";
5
5
  function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
6
6
  const {
7
7
  pageIndex,
@@ -2623,7 +2623,7 @@ function OasisEditorAppLazy(props = {}) {
2623
2623
  onCleanup(() => {
2624
2624
  cancelled = true;
2625
2625
  });
2626
- import("./OasisEditorApp-Dwc5ee9G.js").then((m) => {
2626
+ import("./OasisEditorApp-gxYuoU70.js").then((m) => {
2627
2627
  cancelled = true;
2628
2628
  setProgress(1);
2629
2629
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -13866,6 +13866,151 @@ function getLineStartInset(paragraph, styles, isFirstLine) {
13866
13866
  const firstLineOffset = paragraphStyle.indentHanging ? -Math.abs(paragraphStyle.indentHanging) : paragraphStyle.indentFirstLine ?? 0;
13867
13867
  return baseInset + firstLineOffset;
13868
13868
  }
13869
+ function intersectsVertically(aTop, aBottom, bTop, bBottom) {
13870
+ return aTop < bBottom && aBottom > bTop;
13871
+ }
13872
+ function subtractInterval(segments, cutLeft, cutRight) {
13873
+ const result = [];
13874
+ for (const segment of segments) {
13875
+ if (cutRight <= segment.left || cutLeft >= segment.right) {
13876
+ result.push(segment);
13877
+ continue;
13878
+ }
13879
+ if (cutLeft > segment.left) {
13880
+ result.push({
13881
+ left: segment.left,
13882
+ right: Math.max(segment.left, cutLeft)
13883
+ });
13884
+ }
13885
+ if (cutRight < segment.right) {
13886
+ result.push({
13887
+ left: Math.min(segment.right, cutRight),
13888
+ right: segment.right
13889
+ });
13890
+ }
13891
+ }
13892
+ return result.filter((segment) => segment.right - segment.left > 1);
13893
+ }
13894
+ function mergeIntervals(intervals) {
13895
+ if (intervals.length <= 1) return intervals.slice();
13896
+ const sorted = intervals.filter((interval) => interval.right > interval.left).sort((a, b) => a.left - b.left);
13897
+ const merged = [];
13898
+ for (const interval of sorted) {
13899
+ const last = merged[merged.length - 1];
13900
+ if (last && interval.left <= last.right) {
13901
+ last.right = Math.max(last.right, interval.right);
13902
+ } else {
13903
+ merged.push({ ...interval });
13904
+ }
13905
+ }
13906
+ return merged;
13907
+ }
13908
+ function coveredIntervalsAtScanline(polygon2, y) {
13909
+ const xs = [];
13910
+ for (let i = 0; i < polygon2.length; i += 1) {
13911
+ const a = polygon2[i];
13912
+ const b = polygon2[(i + 1) % polygon2.length];
13913
+ const crosses = a.y <= y && b.y > y || b.y <= y && a.y > y;
13914
+ if (!crosses) continue;
13915
+ const t = (y - a.y) / (b.y - a.y);
13916
+ xs.push(a.x + t * (b.x - a.x));
13917
+ }
13918
+ xs.sort((p, q) => p - q);
13919
+ const intervals = [];
13920
+ for (let k = 0; k + 1 < xs.length; k += 2) {
13921
+ intervals.push({ left: xs[k], right: xs[k + 1] });
13922
+ }
13923
+ return intervals;
13924
+ }
13925
+ function polygonCoveredIntervals(polygon2, top, bottom) {
13926
+ const samples = 5;
13927
+ const collected = [];
13928
+ for (let s = 0; s < samples; s += 1) {
13929
+ const y = bottom === top ? top : top + (bottom - top) * s / (samples - 1);
13930
+ collected.push(...coveredIntervalsAtScanline(polygon2, y));
13931
+ }
13932
+ return mergeIntervals(collected);
13933
+ }
13934
+ function resolveLineFlowBox(options) {
13935
+ const {
13936
+ paragraph,
13937
+ styles,
13938
+ contentWidth,
13939
+ isFirstLine,
13940
+ lineTop,
13941
+ lineHeight,
13942
+ exclusions = []
13943
+ } = options;
13944
+ const baseLeft = getLineStartInset(paragraph, styles, isFirstLine);
13945
+ const baseWidth = getAvailableWidth(
13946
+ paragraph,
13947
+ styles,
13948
+ contentWidth,
13949
+ isFirstLine
13950
+ );
13951
+ const lineBottom = lineTop + lineHeight;
13952
+ let segments = [
13953
+ {
13954
+ left: baseLeft,
13955
+ right: baseLeft + baseWidth
13956
+ }
13957
+ ];
13958
+ let hasThrough = false;
13959
+ for (const exclusion of exclusions) {
13960
+ const exclusionBottom = exclusion.y + exclusion.height;
13961
+ if (!intersectsVertically(lineTop, lineBottom, exclusion.y, exclusionBottom)) {
13962
+ continue;
13963
+ }
13964
+ if (exclusion.wrap === "topAndBottom") {
13965
+ return {
13966
+ left: baseLeft,
13967
+ width: baseWidth,
13968
+ forcedTop: exclusionBottom,
13969
+ segments: [{ left: baseLeft, width: baseWidth }]
13970
+ };
13971
+ }
13972
+ if (exclusion.polygon) {
13973
+ if (exclusion.wrap === "through") {
13974
+ hasThrough = true;
13975
+ }
13976
+ for (const interval of polygonCoveredIntervals(
13977
+ exclusion.polygon,
13978
+ lineTop,
13979
+ lineBottom
13980
+ )) {
13981
+ segments = subtractInterval(segments, interval.left, interval.right);
13982
+ }
13983
+ } else {
13984
+ segments = subtractInterval(
13985
+ segments,
13986
+ exclusion.x,
13987
+ exclusion.x + exclusion.width
13988
+ );
13989
+ }
13990
+ }
13991
+ if (segments.length === 0) {
13992
+ const fallbackWidth = Math.max(1, baseWidth);
13993
+ return {
13994
+ left: baseLeft,
13995
+ width: fallbackWidth,
13996
+ segments: [{ left: baseLeft, width: fallbackWidth }]
13997
+ };
13998
+ }
13999
+ const ordered = segments.slice().sort((a, b) => a.left - b.left).map((segment) => ({
14000
+ left: segment.left,
14001
+ width: Math.max(1, segment.right - segment.left)
14002
+ }));
14003
+ const widest = ordered.reduce(
14004
+ (best, current) => current.width > best.width ? current : best
14005
+ );
14006
+ return {
14007
+ left: widest.left,
14008
+ width: widest.width,
14009
+ // Only "through" wrapping flows text across multiple gaps; every other mode
14010
+ // keeps text on the single widest side.
14011
+ segments: hasThrough ? ordered : [widest]
14012
+ };
14013
+ }
13869
14014
  const DEFAULT_LINE_HEIGHT$1 = 1.15;
13870
14015
  function resolveLineSpacing(paragraphStyle) {
13871
14016
  const rule = paragraphStyle.lineRule ?? "auto";
@@ -14307,151 +14452,6 @@ function findHyphenationPoints(word, lang) {
14307
14452
  }
14308
14453
  const DEFAULT_CONTENT_WIDTH = 624;
14309
14454
  const MIN_CONTENT_WIDTH = 120;
14310
- function intersectsVertically(aTop, aBottom, bTop, bBottom) {
14311
- return aTop < bBottom && aBottom > bTop;
14312
- }
14313
- function subtractInterval(segments, cutLeft, cutRight) {
14314
- const result = [];
14315
- for (const segment of segments) {
14316
- if (cutRight <= segment.left || cutLeft >= segment.right) {
14317
- result.push(segment);
14318
- continue;
14319
- }
14320
- if (cutLeft > segment.left) {
14321
- result.push({
14322
- left: segment.left,
14323
- right: Math.max(segment.left, cutLeft)
14324
- });
14325
- }
14326
- if (cutRight < segment.right) {
14327
- result.push({
14328
- left: Math.min(segment.right, cutRight),
14329
- right: segment.right
14330
- });
14331
- }
14332
- }
14333
- return result.filter((segment) => segment.right - segment.left > 1);
14334
- }
14335
- function mergeIntervals(intervals) {
14336
- if (intervals.length <= 1) return intervals.slice();
14337
- const sorted = intervals.filter((interval) => interval.right > interval.left).sort((a, b) => a.left - b.left);
14338
- const merged = [];
14339
- for (const interval of sorted) {
14340
- const last = merged[merged.length - 1];
14341
- if (last && interval.left <= last.right) {
14342
- last.right = Math.max(last.right, interval.right);
14343
- } else {
14344
- merged.push({ ...interval });
14345
- }
14346
- }
14347
- return merged;
14348
- }
14349
- function coveredIntervalsAtScanline(polygon2, y) {
14350
- const xs = [];
14351
- for (let i = 0; i < polygon2.length; i += 1) {
14352
- const a = polygon2[i];
14353
- const b = polygon2[(i + 1) % polygon2.length];
14354
- const crosses = a.y <= y && b.y > y || b.y <= y && a.y > y;
14355
- if (!crosses) continue;
14356
- const t = (y - a.y) / (b.y - a.y);
14357
- xs.push(a.x + t * (b.x - a.x));
14358
- }
14359
- xs.sort((p, q) => p - q);
14360
- const intervals = [];
14361
- for (let k = 0; k + 1 < xs.length; k += 2) {
14362
- intervals.push({ left: xs[k], right: xs[k + 1] });
14363
- }
14364
- return intervals;
14365
- }
14366
- function polygonCoveredIntervals(polygon2, top, bottom) {
14367
- const samples = 5;
14368
- const collected = [];
14369
- for (let s = 0; s < samples; s += 1) {
14370
- const y = bottom === top ? top : top + (bottom - top) * s / (samples - 1);
14371
- collected.push(...coveredIntervalsAtScanline(polygon2, y));
14372
- }
14373
- return mergeIntervals(collected);
14374
- }
14375
- function resolveLineFlowBox(options) {
14376
- const {
14377
- paragraph,
14378
- styles,
14379
- contentWidth,
14380
- isFirstLine,
14381
- lineTop,
14382
- lineHeight,
14383
- exclusions = []
14384
- } = options;
14385
- const baseLeft = getLineStartInset(paragraph, styles, isFirstLine);
14386
- const baseWidth = getAvailableWidth(
14387
- paragraph,
14388
- styles,
14389
- contentWidth,
14390
- isFirstLine
14391
- );
14392
- const lineBottom = lineTop + lineHeight;
14393
- let segments = [
14394
- {
14395
- left: baseLeft,
14396
- right: baseLeft + baseWidth
14397
- }
14398
- ];
14399
- let hasThrough = false;
14400
- for (const exclusion of exclusions) {
14401
- const exclusionBottom = exclusion.y + exclusion.height;
14402
- if (!intersectsVertically(lineTop, lineBottom, exclusion.y, exclusionBottom)) {
14403
- continue;
14404
- }
14405
- if (exclusion.wrap === "topAndBottom") {
14406
- return {
14407
- left: baseLeft,
14408
- width: baseWidth,
14409
- forcedTop: exclusionBottom,
14410
- segments: [{ left: baseLeft, width: baseWidth }]
14411
- };
14412
- }
14413
- if (exclusion.polygon) {
14414
- if (exclusion.wrap === "through") {
14415
- hasThrough = true;
14416
- }
14417
- for (const interval of polygonCoveredIntervals(
14418
- exclusion.polygon,
14419
- lineTop,
14420
- lineBottom
14421
- )) {
14422
- segments = subtractInterval(segments, interval.left, interval.right);
14423
- }
14424
- } else {
14425
- segments = subtractInterval(
14426
- segments,
14427
- exclusion.x,
14428
- exclusion.x + exclusion.width
14429
- );
14430
- }
14431
- }
14432
- if (segments.length === 0) {
14433
- const fallbackWidth = Math.max(1, baseWidth);
14434
- return {
14435
- left: baseLeft,
14436
- width: fallbackWidth,
14437
- segments: [{ left: baseLeft, width: fallbackWidth }]
14438
- };
14439
- }
14440
- const ordered = segments.slice().sort((a, b) => a.left - b.left).map((segment) => ({
14441
- left: segment.left,
14442
- width: Math.max(1, segment.right - segment.left)
14443
- }));
14444
- const widest = ordered.reduce(
14445
- (best, current) => current.width > best.width ? current : best
14446
- );
14447
- return {
14448
- left: widest.left,
14449
- width: widest.width,
14450
- // Only "through" wrapping flows text across multiple gaps; every other mode
14451
- // keeps text on the single widest side.
14452
- segments: hasThrough ? ordered : [widest]
14453
- };
14454
- }
14455
14455
  function measureParagraphMinContentWidthPx(paragraph, styles) {
14456
14456
  const fragments = buildParagraphFragments(paragraph);
14457
14457
  const measuredChars = buildMeasuredChars(paragraph, fragments, styles);
@@ -14479,6 +14479,7 @@ function measureParagraphMinContentWidthPx(paragraph, styles) {
14479
14479
  return Math.max(1, inset + largestUnbreakableToken, largestInlineObject);
14480
14480
  }
14481
14481
  function composeMeasuredParagraphLines(options) {
14482
+ var _a;
14482
14483
  const { paragraph, fragments, styles, contentWidth, defaultTabStop } = options;
14483
14484
  const exclusions = options.exclusions ?? [];
14484
14485
  const hyphenation = options.hyphenation;
@@ -14493,10 +14494,10 @@ function composeMeasuredParagraphLines(options) {
14493
14494
  DEFAULT_FONT_SIZE_PX,
14494
14495
  ...paragraph.runs.map(
14495
14496
  (run) => {
14496
- var _a;
14497
+ var _a2;
14497
14498
  return resolveEffectiveTextStyleForParagraph(
14498
14499
  run.styles,
14499
- (_a = paragraph.style) == null ? void 0 : _a.styleId,
14500
+ (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
14500
14501
  styles
14501
14502
  ).fontSize ?? DEFAULT_FONT_SIZE_PX;
14502
14503
  }
@@ -14683,7 +14684,7 @@ function composeMeasuredParagraphLines(options) {
14683
14684
  const hyphenLimit = (hyphenation == null ? void 0 : hyphenation.consecutiveLimit) ?? 0;
14684
14685
  const canHyphenateMore = () => hyphenLimit <= 0 || consecutiveHyphens < hyphenLimit;
14685
14686
  const tryHyphenate = (chars2, remainingWidth) => {
14686
- var _a, _b, _c, _d;
14687
+ var _a2, _b, _c, _d;
14687
14688
  if (!(hyphenation == null ? void 0 : hyphenation.enabled) || !canHyphenateMore()) return null;
14688
14689
  const word = chars2.map((char) => char.char).join("");
14689
14690
  if (!shouldHyphenateWord(word, {
@@ -14691,12 +14692,12 @@ function composeMeasuredParagraphLines(options) {
14691
14692
  })) {
14692
14693
  return null;
14693
14694
  }
14694
- const langTag = (_c = (_b = (_a = chars2.find(
14695
+ const langTag = (_c = (_b = (_a2 = chars2.find(
14695
14696
  (char) => {
14696
- var _a2, _b2;
14697
- return (_b2 = (_a2 = char.style) == null ? void 0 : _a2.language) == null ? void 0 : _b2.value;
14697
+ var _a3, _b2;
14698
+ return (_b2 = (_a3 = char.style) == null ? void 0 : _a3.language) == null ? void 0 : _b2.value;
14698
14699
  }
14699
- )) == null ? void 0 : _a.style) == null ? void 0 : _b.language) == null ? void 0 : _c.value;
14700
+ )) == null ? void 0 : _a2.style) == null ? void 0 : _b.language) == null ? void 0 : _c.value;
14700
14701
  const points = findHyphenationPoints(
14701
14702
  word,
14702
14703
  resolveHyphenationLanguage(langTag ?? void 0)
@@ -14778,7 +14779,8 @@ function composeMeasuredParagraphLines(options) {
14778
14779
  resetLine(token.chars[0].offset);
14779
14780
  layoutFreshWord(token.chars);
14780
14781
  }
14781
- if (lines.length === 0 || lineStartOffset !== lineEndOffset || lineSlotLefts.length > 1) {
14782
+ const endsWithTrailingLineBreak = ((_a = tokens[tokens.length - 1]) == null ? void 0 : _a.kind) === "newline";
14783
+ if (lines.length === 0 || lineStartOffset !== lineEndOffset || lineSlotLefts.length > 1 || endsWithTrailingLineBreak) {
14782
14784
  flushLine();
14783
14785
  }
14784
14786
  return applyParagraphAlignment(
@@ -1,4 +1,4 @@
1
- import { cT, a5, aj, az, at, cU, cV, cW, an, cX, a6, cC, aA, cY, cZ, ay, aq, c_, c$, d0, a4, d1, cA, aC, d2, d3, d4, d5, d6, cO, d7, d8, d9, aG, aF, da, ar, db, dc, dd, de, df, dg, av, as, dh, aJ, aB, aI, aH, am, ax, cN, di, cU as cU2, c_ as c_2, d1 as d12, da as da2, db as db2, dg as dg2, dj, cE, cz, dk, dl, dm, cB, dn, dp, cD } from "./index-YMlNF1Ya.js";
1
+ import { cT, a5, aj, az, at, cU, cV, cW, an, cX, a6, cC, aA, cY, cZ, ay, aq, c_, c$, d0, a4, d1, cA, aC, d2, d3, d4, d5, d6, cO, d7, d8, d9, aG, aF, da, ar, db, dc, dd, de, df, dg, av, as, dh, aJ, aB, aI, aH, am, ax, cN, di, cU as cU2, c_ as c_2, d1 as d12, da as da2, db as db2, dg as dg2, dj, cE, cz, dk, dl, dm, cB, dn, dp, cD } from "./index-zlwh4WsF.js";
2
2
  export {
3
3
  cT as ActionRow,
4
4
  a5 as BalloonShell,