oasis-editor 0.0.114 → 0.0.116

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/{OasisEditorApp-XloOiKSu.js → OasisEditorApp-DY_N4M54.js} +424 -366
  2. package/dist/adapters/react.d.ts +11 -0
  3. package/dist/adapters/ui.d.ts +2 -0
  4. package/dist/adapters/vue.d.ts +23 -0
  5. package/dist/assets/{importDocxWorker-D0F0jbcF.js → importDocxWorker-nIS-zjkj.js} +1 -1
  6. package/dist/core/decorationGeometry.d.ts +10 -0
  7. package/dist/core/gradientAxis.d.ts +11 -0
  8. package/dist/core/html/inlineImageParser.d.ts +7 -0
  9. package/dist/core/layoutConstants.d.ts +18 -0
  10. package/dist/core/textStyleMappings.d.ts +2 -0
  11. package/dist/export/pdf/draw/drawFragment.d.ts +4 -4
  12. package/dist/export/pdf/draw/fragment/pdfColor.d.ts +1 -0
  13. package/dist/export/pdf/draw/fragment/pdfEmphasisAndTabLeaders.d.ts +5 -0
  14. package/dist/export/pdf/draw/fragment/pdfGradient.d.ts +4 -0
  15. package/dist/export/pdf/draw/fragment/pdfRunBackground.d.ts +12 -0
  16. package/dist/export/pdf/draw/fragment/pdfTextChunks.d.ts +25 -0
  17. package/dist/export/pdf/draw/fragment/pdfTextDecoration.d.ts +4 -0
  18. package/dist/{index-CwpzM--5.js → index-DLKF27_V.js} +1211 -1121
  19. package/dist/layoutProjection/blocksPaginationTypes.d.ts +2 -0
  20. package/dist/layoutProjection/headerFooterLayoutContext.d.ts +2 -0
  21. package/dist/layoutProjection/paginationTrack.d.ts +2 -0
  22. package/dist/layoutProjection/paragraphPagination.d.ts +8 -3
  23. package/dist/layoutProjection/sectionPagination.d.ts +3 -0
  24. package/dist/layoutProjection/tableRowSlicing.d.ts +2 -1
  25. package/dist/oasis-editor.js +55 -55
  26. package/dist/oasis-editor.umd.cjs +4 -4
  27. package/dist/react.d.ts +7 -8
  28. package/dist/react.js +18 -22
  29. package/dist/ui/canvas/CanvasTableLayout.d.ts +12 -63
  30. package/dist/ui/canvas/canvasParagraphPainter.d.ts +4 -22
  31. package/dist/ui/canvas/paragraph/canvasEmphasis.d.ts +3 -0
  32. package/dist/ui/canvas/paragraph/canvasInlineImage.d.ts +26 -0
  33. package/dist/ui/canvas/paragraph/canvasRunBackground.d.ts +13 -0
  34. package/dist/ui/canvas/paragraph/canvasTabLeaders.d.ts +4 -0
  35. package/dist/ui/canvas/paragraph/canvasTextDecoration.d.ts +4 -0
  36. package/dist/ui/canvas/paragraph/canvasTextEffects.d.ts +43 -0
  37. package/dist/ui/canvas/table/assembleCellEntries.d.ts +15 -0
  38. package/dist/ui/canvas/table/prepareCells.d.ts +53 -0
  39. package/dist/ui/canvas/table/resolveRowHeights.d.ts +9 -0
  40. package/dist/ui/canvas/table/tableCellGeometry.d.ts +37 -0
  41. package/dist/ui/canvas/table/types.d.ts +63 -0
  42. package/dist/ui/components/FindReplace/FindReplaceDialog.d.ts +1 -2
  43. package/dist/ui/components/Menubar/Menubar.d.ts +1 -2
  44. package/dist/ui/components/PageBreak.d.ts +1 -1
  45. package/dist/ui.d.ts +2 -42
  46. package/dist/ui.js +19 -18
  47. package/dist/utils/performanceMetrics.d.ts +0 -6
  48. package/dist/utils/round.d.ts +7 -0
  49. package/dist/vue.d.ts +22 -8
  50. package/dist/vue.js +18 -24
  51. package/package.json +9 -6
@@ -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 { d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageContentWidth, b as getPageBodyTop, c as getPageBodyBottom, l as listReferencedEndnotes, f as getFootnoteDisplayMarker, s as setActiveHyphenation, h as getDocumentSections, i as buildFootnoteReservations, M as MAX_FOOTNOTE_LAYOUT_ITERATIONS, r as reservationSignature, j as applyFootnotesToPages, k as getRunField, m as projectBlocksLayout, v as visitRun, n as assertNever, o as createSignal, q 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 getParagraphText, C as getActiveZone, D as getActiveSectionIndex, E as getParagraphs, F as normalizeSelection, G as positionToParagraphOffset, H as paragraphOffsetToPosition, I as clampPosition, J as findParagraphIndex, K as createCollapsedSelection, L as isSelectionCollapsed, N as parseFontSizePtToPx, O as formatFontSizePt, P as createEditorParagraph, Q as getBlockParagraphs, R as findParagraphTableLocation, T as buildTableCellLayout, U as PT_PER_PX, V as createEditorTableCell, W as createEditorTableRow, X as createEditorTable, Y as underlineStyleToCssDecorationStyle, Z as resolveImageSrc, _ as listKindForTag, $ as isParagraphTag, a0 as collectInlineRuns, a1 as parseParagraphStyle, a2 as getRunImage, a3 as InlineShell, a4 as BalloonShell, a5 as DocumentShell, a6 as createMemo, a7 as getCaretRectFromSnapshot, a8 as getParagraphRectFromSnapshot, a9 as createComponent, aa as CaretOverlay, ab as Show, ac as createRenderEffect, ad as style, ae as setAttribute, af as setStyleProperty, ag as memo, ah as template, ai as addEventListener, aj as insert, ak as delegateEvents, al as useI18n, am as createEffect, an as use, ao as Dialog, ap as className, aq as For, ar as UNDERLINE_STYLE_OPTIONS, as as Tabs, at as createStore, au as reconcile, av as onMount, aw as onCleanup, ax as PluginUiHost, ay as OasisEditorEditor, az as OasisBrandMark, aA as setPreciseFontPreference, aB as setWelcomeSeen, aC as enablePreciseFontMode, aD as TWIPS_PER_POINT, aE as PX_PER_INCH, aF as TWIPS_PER_INCH, aG as normalizeHex6, aH as TABLE_CONDITIONAL_FLAG_ATTRIBUTES, aI as TABLE_BORDER_EDGE_KEYS, aJ as resolveEffectiveParagraphStyle, aK as resolveEffectiveTextStyleForParagraph, aL as EMU_PER_PT, aM as OOXML_ROTATION_UNITS, aN as OOXML_PERCENT_DENOMINATOR, aO as parseHexColorToRgb255, aP as EMU_PER_PX, aQ as getRunFootnoteReference, aR as getRunEndnoteReference, aS as iterateFootnoteReferenceRuns, aT as iterateEndnoteReferenceRuns, aU as imageContentTypeDefaults, aV as getRunFieldChar, aW as getRunFieldInstruction, aX as createEditorRun, aY as JSZip, aZ as imageExtensionFromMime, a_ as pxToPt$1, a$ as resolveFloatingObjectRect, b0 as getTextBoxFloatingGeometry, b1 as getPresetPathSegments, b2 as buildListLabels, b3 as getImageFloatingGeometry, b4 as textStyleToFontSizePt, b5 as PX_PER_POINT, b6 as DEFAULT_FONT_SIZE_PX, b7 as resolveOpenTypeFeatureTags, b8 as rgb255ToHex, b9 as isDoubleUnderlineStyle, ba as isWavyUnderlineStyle, bb as underlineStyleLineWidthPx, bc as WAVY_UNDERLINE_WAVELENGTH_PX, bd as WAVY_UNDERLINE_AMPLITUDE_PX, be as underlineStyleDashArray, bf as resolveListLabel, bg as getListLabelInset, bh as getAlignedListLabelInset, bi as getParagraphBorderInsets, bj as buildSegmentTable, bk as buildCanvasTableLayout, bl as resolveCanvasTableWidth, bm as resolveFloatingTableRect, bn as normalizeFamily, bo as ROBOTO_FONT_FILES, bp as loadFontAsset, bq as OFFICE_COMPAT_FONT_FAMILIES, br as BinaryReader, bs as buildSfnt, bt as defaultFontDecoderRegistry, bu as SfntFontProgram, bv as collectPdfFontFamilies, bw as outlineFrom, bx as getPageHeaderZoneTop, by as getPageColumnRects, bz as findFootnoteReference, bA as FOOTNOTE_MARKER_GUTTER_PX, bB as resolveImporterForFile, bC as getDocumentSectionsCanonical, bD as getDocumentParagraphsCanonical, bE as getDocumentParagraphs, bF as getDocumentPageSettings, bG as getTableCellContentWidthForParagraph, bH as layoutMetricsEpoch, bI as bumpLayoutMetricsEpoch, bJ as createCanvasLayoutSnapshotProvider, bK as on, bL as debounce, bM as unwrap, bN as perfTimer, bO as getRunTextBox, bP as createEditorDocument, bQ as resolveResizedDimensions, bR as resolveTextBoxRenderHeight, bS as getToolbarStyleState, bT as getCachedCanvasImage, bU as measureParagraphMinContentWidthPx, bV as getEditableBlocksForZone, bW as findParagraphLocation, bX as createSectionBoundaryParagraph, bY as normalizePageSettings, bZ as DEFAULT_EDITOR_PAGE_SETTINGS, b_ as markStart, b$ as markEnd, c0 as getParagraphEntries, c1 as getParagraphById, c2 as createEditorFootnote, c3 as createFootnoteReferenceRun, c4 as renumberFootnotes, c5 as getHeadingLevel, c6 as preciseFontModeVersion, c7 as isPreciseFontModeEnabled, c8 as resolveNamedTextStyle, c9 as togglePreciseFontMode, ca as nextFontSizePt, cb as previousFontSizePt, cc as fontSizePtToPx, cd as createDefaultToolbarPreset, ce as MenuRegistry, cf as createToolbarRegistry, cg as Editor, ch as resolveCommandRef, ci as commandRefName, cj as createOasisEditorClient, ck as createEditorZoom, cl as startLongTaskObserver, cm as installGlobalReport, cn as applyStoredPreciseFontPreference, co as getWelcomeSeen, cp as isLocalFontAccessSupported, cq as EDITOR_SCROLL_PADDING_PX, cr as Toolbar, cs as OasisEditorLoading, ct as I18nProvider, cu as createTranslator, cv as createEditorLogger, cw as registerDomStatsSurface } from "./index-CwpzM--5.js";
4
+ import { E as EMPTY_PROJECTION_CONTEXT, d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageContentWidth, b as getPageBodyTop, c as getPageBodyBottom, l as listReferencedEndnotes, f as getFootnoteDisplayMarker, h as createProjectionContext, i as getDocumentSections, j as buildFootnoteReservations, M as MAX_FOOTNOTE_LAYOUT_ITERATIONS, r as reservationSignature, k as applyFootnotesToPages, m as getRunField, n as projectBlocksLayout, v as visitRun, o as assertNever, q 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 getParagraphText, C as getActiveZone, D as getActiveSectionIndex, F as getParagraphs, G as normalizeSelection, H as positionToParagraphOffset, I as paragraphOffsetToPosition, J as clampPosition, K as findParagraphIndex, L as createCollapsedSelection, N as isSelectionCollapsed, O as parseFontSizePtToPx, P as formatFontSizePt, Q as createEditorParagraph, R as getBlockParagraphs, T as findParagraphTableLocation, U as buildTableCellLayout, V as PT_PER_PX, W as createEditorTableCell, X as createEditorTableRow, Y as createEditorTable, Z as PX_PER_POINT, _ as underlineStyleToCssDecorationStyle, $ as resolveImageSrc, a0 as listKindForTag, a1 as isParagraphTag, a2 as collectInlineRuns, a3 as parseParagraphStyle, a4 as getRunImage, a5 as InlineShell, a6 as BalloonShell, a7 as DocumentShell, a8 as createMemo, a9 as getCaretRectFromSnapshot, aa as getParagraphRectFromSnapshot, ab as createComponent, ac as CaretOverlay, ad as Show, ae as createRenderEffect, af as style, ag as setAttribute, ah as setStyleProperty, ai as memo, aj as template, ak as addEventListener, al as insert, am as delegateEvents, an as useI18n, ao as createEffect, ap as use, aq as Dialog, ar as className, as as For, at as UNDERLINE_STYLE_OPTIONS, au as Tabs, av as createStore, aw as reconcile, ax as onMount, ay as onCleanup, az as PluginUiHost, aA as OasisEditorEditor, aB as OasisBrandMark, aC as setPreciseFontPreference, aD as setWelcomeSeen, aE as enablePreciseFontMode, aF as TWIPS_PER_POINT, aG as PX_PER_INCH, aH as TWIPS_PER_INCH, aI as normalizeHex6, aJ as TABLE_CONDITIONAL_FLAG_ATTRIBUTES, aK as TABLE_BORDER_EDGE_KEYS, aL as resolveEffectiveParagraphStyle, aM as resolveEffectiveTextStyleForParagraph, aN as EMU_PER_PT, aO as OOXML_ROTATION_UNITS, aP as OOXML_PERCENT_DENOMINATOR, aQ as parseHexColorToRgb255, aR as EMU_PER_PX, aS as getRunFootnoteReference, aT as getRunEndnoteReference, aU as iterateFootnoteReferenceRuns, aV as iterateEndnoteReferenceRuns, aW as imageContentTypeDefaults, aX as getRunFieldChar, aY as getRunFieldInstruction, aZ as createEditorRun, a_ as JSZip, a$ as imageExtensionFromMime, b0 as pxToPt$1, b1 as resolveFloatingObjectRect, b2 as getTextBoxFloatingGeometry, b3 as getPresetPathSegments, b4 as buildListLabels, b5 as DEFAULT_FONT_SIZE_PX, b6 as resolveGradientAxis, b7 as isDoubleUnderlineStyle, b8 as isWavyUnderlineStyle, b9 as underlineStyleLineWidthPx, ba as WAVY_UNDERLINE_WAVELENGTH_PX, bb as WAVY_UNDERLINE_AMPLITUDE_PX, bc as DOUBLE_UNDERLINE_OFFSET_PX, bd as underlineStyleDashArray, be as EMPHASIS_GLYPH, bf as rgb255ToHex, bg as getImageFloatingGeometry, bh as textStyleToFontSizePt, bi as TEXT_BASELINE_RATIO, bj as resolveOpenTypeFeatureTags, bk as resolveDecorationLineY, bl as DOUBLE_STRIKE_OFFSET_PX, bm as resolveListLabel, bn as getListLabelInset, bo as getAlignedListLabelInset, bp as getParagraphBorderInsets, bq as buildSegmentTable, br as buildCanvasTableLayout, bs as resolveCanvasTableWidth, bt as resolveFloatingTableRect, bu as normalizeFamily, bv as ROBOTO_FONT_FILES, bw as loadFontAsset, bx as OFFICE_COMPAT_FONT_FAMILIES, by as BinaryReader, bz as buildSfnt, bA as defaultFontDecoderRegistry, bB as SfntFontProgram, bC as collectPdfFontFamilies, bD as outlineFrom, bE as getPageHeaderZoneTop, bF as getPageColumnRects, bG as findFootnoteReference, bH as FOOTNOTE_MARKER_GUTTER_PX, bI as resolveImporterForFile, bJ as roundTo, bK as getDocumentSectionsCanonical, bL as getDocumentParagraphsCanonical, bM as getDocumentParagraphs, bN as getDocumentPageSettings, bO as getTableCellContentWidthForParagraph, bP as layoutMetricsEpoch, bQ as bumpLayoutMetricsEpoch, bR as createCanvasLayoutSnapshotProvider, bS as on, bT as debounce, bU as unwrap, bV as perfTimer, bW as getRunTextBox, bX as createEditorDocument, bY as resolveResizedDimensions, bZ as resolveTextBoxRenderHeight, b_ as getToolbarStyleState, b$ as VERTICAL_HIT_WEIGHT, c0 as getCachedCanvasImage, c1 as measureParagraphMinContentWidthPx, c2 as getEditableBlocksForZone, c3 as findParagraphLocation, c4 as createSectionBoundaryParagraph, c5 as normalizePageSettings, c6 as DEFAULT_EDITOR_PAGE_SETTINGS, c7 as markStart, c8 as markEnd, c9 as getParagraphEntries, ca as getParagraphById, cb as createEditorFootnote, cc as createFootnoteReferenceRun, cd as renumberFootnotes, ce as getHeadingLevel, cf as preciseFontModeVersion, cg as isPreciseFontModeEnabled, ch as resolveNamedTextStyle, ci as togglePreciseFontMode, cj as nextFontSizePt, ck as previousFontSizePt, cl as fontSizePtToPx, cm as createDefaultToolbarPreset, cn as MenuRegistry, co as createToolbarRegistry, cp as Editor, cq as resolveCommandRef, cr as commandRefName, cs as createOasisEditorClient, ct as createEditorZoom, cu as startLongTaskObserver, cv as installGlobalReport, cw as applyStoredPreciseFontPreference, cx as getWelcomeSeen, cy as isLocalFontAccessSupported, cz as EDITOR_SCROLL_PADDING_PX, cA as Toolbar, cB as OasisEditorLoading, cC as I18nProvider, cD as createTranslator, cE as createEditorLogger, cF as registerDomStatsSurface } from "./index-DLKF27_V.js";
5
5
  function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
6
6
  const {
7
7
  pageIndex,
@@ -54,10 +54,20 @@ function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
54
54
  });
55
55
  }
56
56
  function projectHeaderFooterBlocks(blocks, context = {}) {
57
+ const projectionCtx = context.projectionContext ?? EMPTY_PROJECTION_CONTEXT;
57
58
  return projectHeaderFooterBlocksWithDependencies(
58
59
  blocks,
59
60
  {
60
- projectParagraphLayout,
61
+ projectParagraphLayout: (paragraph, pageIndex, totalPages, styles, contentWidth, measurer, defaultTabStop) => projectParagraphLayout(
62
+ paragraph,
63
+ pageIndex,
64
+ totalPages,
65
+ styles,
66
+ contentWidth,
67
+ measurer,
68
+ defaultTabStop,
69
+ projectionCtx
70
+ ),
61
71
  estimateTableBlockHeight,
62
72
  getProjectedParagraphBlockHeight
63
73
  },
@@ -126,7 +136,8 @@ function createHeaderFooterVariantProjector(context) {
126
136
  styles: context.documentStyles,
127
137
  contentWidth,
128
138
  measurer: context.measurer,
129
- defaultTabStop: context.defaultTabStop
139
+ defaultTabStop: context.defaultTabStop,
140
+ projectionContext: context.projectionContext
130
141
  }) : void 0;
131
142
  }
132
143
  function projectTallestHeaderVariant(section, contentWidth, projectHeaderFooterVariant) {
@@ -180,7 +191,8 @@ function calculateTotalPages(context, projectHeaderFooterVariant) {
180
191
  pageOffset: isContinuous ? currentTotal - 1 : currentTotal,
181
192
  existingPages: isContinuous ? [activePages[activePages.length - 1]] : [],
182
193
  measurer: context.measurer,
183
- defaultTabStop: context.defaultTabStop
194
+ defaultTabStop: context.defaultTabStop,
195
+ projectionContext: context.projectionContext
184
196
  });
185
197
  if (isContinuous) {
186
198
  activePages.pop();
@@ -227,7 +239,8 @@ function projectAllPages(context, totalPages, projectHeaderFooterVariant, reserv
227
239
  existingPages: isContinuous ? [allPages[allPages.length - 1]] : [],
228
240
  measurer: context.measurer,
229
241
  reservedHeightByPageIndex,
230
- defaultTabStop: context.defaultTabStop
242
+ defaultTabStop: context.defaultTabStop,
243
+ projectionContext: context.projectionContext
231
244
  });
232
245
  if (isContinuous) {
233
246
  allPages.pop();
@@ -398,7 +411,7 @@ function documentContainsNumPagesField(document2) {
398
411
  function projectDocumentLayout(document2, maxPageHeightOverride, measuredHeights, measuredParagraphLayouts, options = {}) {
399
412
  var _a2, _b2;
400
413
  const measurer = options.measurer ?? domTextMeasurer;
401
- setActiveHyphenation(
414
+ const projectionContext = createProjectionContext(
402
415
  ((_a2 = document2.settings) == null ? void 0 : _a2.autoHyphenation) ? {
403
416
  enabled: true,
404
417
  zone: document2.settings.hyphenationZone,
@@ -419,13 +432,13 @@ function projectDocumentLayout(document2, maxPageHeightOverride, measuredHeights
419
432
  defaultTabStop: (_b2 = document2.settings) == null ? void 0 : _b2.defaultTabStop,
420
433
  needsTotalPages,
421
434
  projectBlocks: projectBlocksLayout,
422
- projectHeaderFooterBlocks
435
+ projectHeaderFooterBlocks,
436
+ projectionContext
423
437
  };
424
438
  const projectedSections = projectDocumentSections(sectionContext);
425
439
  let pages = projectedSections.pages;
426
440
  const totalPages = projectedSections.totalPages;
427
441
  if (!document2.footnotes || Object.keys(document2.footnotes.items).length === 0) {
428
- setActiveHyphenation(void 0);
429
442
  return { pages };
430
443
  }
431
444
  const footnoteContext = {
@@ -447,11 +460,9 @@ function projectDocumentLayout(document2, maxPageHeightOverride, measuredHeights
447
460
  pages = projectDocumentSections(sectionContext, reservations).pages;
448
461
  reservations = buildFootnoteReservations(pages, footnoteContext);
449
462
  }
450
- const result = {
463
+ return {
451
464
  pages: applyFootnotesToPages(pages, footnoteContext)
452
465
  };
453
- setActiveHyphenation(void 0);
454
- return result;
455
466
  }
456
467
  function cloneStyle(style2) {
457
468
  return style2 ? { ...style2 } : void 0;
@@ -30038,19 +30049,15 @@ function textRunStylesToCss(style2) {
30038
30049
  }
30039
30050
  }
30040
30051
  if (style2.textOutline) {
30041
- const widthPx = style2.textOutline.widthPt * (96 / 72);
30052
+ const widthPx = style2.textOutline.widthPt * PX_PER_POINT;
30042
30053
  const color = style2.textOutline.color ?? "#000000";
30043
30054
  parts.push(`-webkit-text-stroke:${widthPx.toFixed(2)}px ${color}`);
30044
30055
  }
30045
30056
  if (style2.textShadow) {
30046
30057
  const dirRad = style2.textShadow.dirDeg * Math.PI / 180;
30047
- const px = (pt) => (pt * (96 / 72)).toFixed(2);
30048
- const ox = (Math.cos(dirRad) * style2.textShadow.distPt * (96 / 72)).toFixed(
30049
- 2
30050
- );
30051
- const oy = (Math.sin(dirRad) * style2.textShadow.distPt * (96 / 72)).toFixed(
30052
- 2
30053
- );
30058
+ const px = (pt) => (pt * PX_PER_POINT).toFixed(2);
30059
+ const ox = (Math.cos(dirRad) * style2.textShadow.distPt * PX_PER_POINT).toFixed(2);
30060
+ const oy = (Math.sin(dirRad) * style2.textShadow.distPt * PX_PER_POINT).toFixed(2);
30054
30061
  const blur = px(style2.textShadow.blurPt);
30055
30062
  const alpha = style2.textShadow.alpha ?? 1;
30056
30063
  const r = parseInt(style2.textShadow.color.slice(1, 3), 16);
@@ -30060,7 +30067,7 @@ function textRunStylesToCss(style2) {
30060
30067
  `text-shadow:${ox}px ${oy}px ${blur}px rgba(${r},${g},${b},${alpha})`
30061
30068
  );
30062
30069
  } else if (style2.glow) {
30063
- const blur = (style2.glow.radiusPt * (96 / 72)).toFixed(2);
30070
+ const blur = (style2.glow.radiusPt * PX_PER_POINT).toFixed(2);
30064
30071
  const alpha = style2.glow.alpha ?? 0.7;
30065
30072
  const r = parseInt(style2.glow.color.slice(1, 3), 16);
30066
30073
  const g = parseInt(style2.glow.color.slice(3, 5), 16);
@@ -34108,10 +34115,9 @@ function serializeFloatingTableProperties(floating) {
34108
34115
  function serializeTableBorders(style2) {
34109
34116
  const borders = style2 == null ? void 0 : style2.borders;
34110
34117
  if (!borders) return "";
34111
- const xml = TABLE_BORDER_EDGE_KEYS.map(([name, key]) => [
34112
- name,
34113
- borders[key]
34114
- ]).filter((entry) => !!entry[1]).map(([name, border]) => `<w:${name} ${serializeDocxBorderAttrs(border)}`).join("");
34118
+ const xml = TABLE_BORDER_EDGE_KEYS.map(
34119
+ ([name, key]) => [name, borders[key]]
34120
+ ).filter((entry) => !!entry[1]).map(([name, border]) => `<w:${name} ${serializeDocxBorderAttrs(border)}`).join("");
34115
34121
  return xml ? `<w:tblBorders>${xml}</w:tblBorders>` : "";
34116
34122
  }
34117
34123
  function serializeTableProperties(table) {
@@ -36236,7 +36242,10 @@ function writeNotePart(zip, partName, part) {
36236
36242
  if (part.partContext.images.length > 0 || part.partContext.hyperlinks.length > 0) {
36237
36243
  zip.file(
36238
36244
  `word/_rels/${partName}.xml.rels`,
36239
- buildPartRelationshipsXml(part.partContext.images, part.partContext.hyperlinks)
36245
+ buildPartRelationshipsXml(
36246
+ part.partContext.images,
36247
+ part.partContext.hyperlinks
36248
+ )
36240
36249
  );
36241
36250
  }
36242
36251
  }
@@ -36835,56 +36844,12 @@ function resolveFragmentBounds(line, fragment, fontSizePx) {
36835
36844
  right: (nextSlot == null ? void 0 : nextSlot.left) ?? last.left + fontSizePx * 0.55
36836
36845
  };
36837
36846
  }
36838
- async function drawFloatingImagesForParagraph(options) {
36839
- for (const line of options.lines) {
36840
- const slots = new Map(line.slots.map((slot) => [slot.offset, slot]));
36841
- for (const fragment of line.fragments) {
36842
- const image = fragment.image;
36843
- if (!(image == null ? void 0 : image.floating)) continue;
36844
- const isBehind = Boolean(image.floating.behindDoc);
36845
- if (options.layer === "behind" !== isBehind) continue;
36846
- const slot = slots.get(fragment.startOffset);
36847
- const rect = resolveFloatingObjectRect({
36848
- object: getImageFloatingGeometry(image),
36849
- pageSettings: options.pageSettings,
36850
- contentLeft: options.contentLeft,
36851
- contentTop: options.contentTop,
36852
- contentWidth: options.contentWidth,
36853
- paragraphTop: options.paragraphTop,
36854
- lineTop: options.paragraphTop + line.top,
36855
- anchorLeft: options.contentLeft + ((slot == null ? void 0 : slot.left) ?? 0)
36856
- });
36857
- const resourceName = await registerPdfImageRun(
36858
- options.writer,
36859
- options.document,
36860
- image
36861
- );
36862
- if (!resourceName) continue;
36863
- options.writer.drawImage(options.pageIndex, {
36864
- resourceName,
36865
- x: pxToPt$1(rect.x),
36866
- y: pxToPt$1(rect.y),
36867
- width: pxToPt$1(rect.width),
36868
- height: pxToPt$1(rect.height),
36869
- rotation: image.rotation
36870
- });
36871
- }
36872
- }
36873
- }
36874
- function blendColorWithWhite(hex, alpha) {
36875
- const rgb = parseHexColorToRgb255(hex);
36876
- if (!rgb) {
36877
- return hex;
36878
- }
36879
- const a = Math.max(0, Math.min(1, alpha));
36880
- return rgb255ToHex(
36881
- 255 + (rgb[0] - 255) * a,
36882
- 255 + (rgb[1] - 255) * a,
36883
- 255 + (rgb[2] - 255) * a
36884
- );
36885
- }
36886
36847
  function fragmentRectPt(line, fragment, styles, originX, originY, yOffset, heightShrink) {
36887
- const bounds = resolveFragmentBounds(line, fragment, styles.fontSize ?? DEFAULT_FONT_SIZE_PX);
36848
+ const bounds = resolveFragmentBounds(
36849
+ line,
36850
+ fragment,
36851
+ styles.fontSize ?? DEFAULT_FONT_SIZE_PX
36852
+ );
36888
36853
  if (!bounds) return null;
36889
36854
  return {
36890
36855
  x: pxToPt$1(originX + bounds.left),
@@ -36905,141 +36870,43 @@ function drawFragmentShading(writer, pageIndex, line, fragment, originX, originY
36905
36870
  if (!rect) return;
36906
36871
  writer.drawRect(pageIndex, { ...rect, fill: styles.shading });
36907
36872
  }
36873
+ function drawFragmentBorder(writer, pageIndex, line, fragment, originX, originY, styles) {
36874
+ const border = styles.textBorder;
36875
+ if (!border || border.type === "none" || border.width <= 0) return;
36876
+ const rect = fragmentRectPt(line, fragment, styles, originX, originY, 1, 2);
36877
+ if (!rect) return;
36878
+ writer.drawRect(pageIndex, {
36879
+ ...rect,
36880
+ stroke: border.color,
36881
+ lineWidth: pxToPt$1(Math.max(0.5, border.width * PX_PER_POINT))
36882
+ });
36883
+ }
36908
36884
  function resolveGradientShadingName(writer, pageIndex, line, fragment, originX, originY, styles) {
36909
36885
  const fill = styles.textFill;
36910
- if (!fill || fill.type !== "gradient" || fill.stops.length < 2) {
36886
+ if (!fill || fill.type !== "gradient" || fill.stops.length < 2)
36911
36887
  return void 0;
36912
- }
36913
36888
  const bounds = resolveFragmentBounds(
36914
36889
  line,
36915
36890
  fragment,
36916
36891
  styles.fontSize ?? DEFAULT_FONT_SIZE_PX
36917
36892
  );
36918
- if (!bounds) {
36919
- return void 0;
36920
- }
36893
+ if (!bounds) return void 0;
36921
36894
  const x0px = originX + bounds.left;
36922
36895
  const x1px = originX + bounds.right;
36923
36896
  const y0px = originY + line.top;
36924
36897
  const y1px = originY + line.top + line.height;
36925
- const cx = (x0px + x1px) / 2;
36926
- const cy = (y0px + y1px) / 2;
36927
- const rad = (fill.angle ?? 0) * Math.PI / 180;
36928
- const dx = Math.cos(rad) * (x1px - x0px) / 2;
36929
- const dy = Math.sin(rad) * (y1px - y0px) / 2;
36898
+ const axis = resolveGradientAxis(x0px, y0px, x1px, y1px, fill.angle ?? 0);
36930
36899
  return writer.registerAxialGradient(pageIndex, {
36931
- x0: pxToPt$1(cx - dx),
36932
- y0: pxToPt$1(cy - dy),
36933
- x1: pxToPt$1(cx + dx),
36934
- y1: pxToPt$1(cy + dy),
36900
+ x0: pxToPt$1(axis.x0),
36901
+ y0: pxToPt$1(axis.y0),
36902
+ x1: pxToPt$1(axis.x1),
36903
+ y1: pxToPt$1(axis.y1),
36935
36904
  stops: fill.stops.map((stop) => ({
36936
36905
  offset: stop.position,
36937
36906
  color: stop.color
36938
36907
  }))
36939
36908
  }) ?? void 0;
36940
36909
  }
36941
- function drawFragmentBorder(writer, pageIndex, line, fragment, originX, originY, styles) {
36942
- const border = styles.textBorder;
36943
- if (!border || border.type === "none" || border.width <= 0) {
36944
- return;
36945
- }
36946
- const rect = fragmentRectPt(line, fragment, styles, originX, originY, 1, 2);
36947
- if (!rect) return;
36948
- writer.drawRect(pageIndex, {
36949
- ...rect,
36950
- stroke: border.color,
36951
- lineWidth: pxToPt$1(Math.max(0.5, border.width * PX_PER_POINT))
36952
- });
36953
- }
36954
- const PDF_EMPHASIS_GLYPH = {
36955
- dot: "•",
36956
- comma: "‚",
36957
- circle: "○",
36958
- underDot: "•"
36959
- };
36960
- function drawFragmentEmphasis(writer, pageIndex, line, fragment, originX, originY, styles) {
36961
- const mark = styles.emphasisMark;
36962
- if (!mark || mark === "none") {
36963
- return;
36964
- }
36965
- const glyph = PDF_EMPHASIS_GLYPH[mark];
36966
- if (!glyph) {
36967
- return;
36968
- }
36969
- const slots = resolveFragmentSlots(line, fragment);
36970
- const below = mark === "underDot";
36971
- const size = Math.max(4, line.height * 0.35);
36972
- const y = below ? originY + line.top + line.height + size : originY + line.top + size;
36973
- for (let i = 0; i < slots.length; i += 1) {
36974
- const slot = slots[i];
36975
- if (slot.char === " " || slot.char === " " || slot.char === "\n") {
36976
- continue;
36977
- }
36978
- const next = slots[i + 1];
36979
- const centerX = next ? (slot.left + next.left) / 2 : slot.left + line.height * 0.25;
36980
- writer.drawText(pageIndex, {
36981
- x: pxToPt$1(originX + centerX - size * 0.25),
36982
- y: pxToPt$1(y),
36983
- text: glyph,
36984
- fontSize: pxToPt$1(size),
36985
- color: styles.color ?? "#000000"
36986
- });
36987
- }
36988
- }
36989
- function drawFragmentDecoration(writer, pageIndex, line, fragment, originX, originY, styles, kind) {
36990
- const bounds = resolveFragmentBounds(
36991
- line,
36992
- fragment,
36993
- styles.fontSize ?? DEFAULT_FONT_SIZE_PX
36994
- );
36995
- if (!bounds) {
36996
- return;
36997
- }
36998
- const y = kind === "underline" ? originY + line.top + line.height - 2 : kind === "doubleStrike" ? originY + line.top + line.height * 0.5 : originY + line.top + line.height * 0.52;
36999
- const x1 = originX + bounds.left;
37000
- const x2 = originX + bounds.right;
37001
- const stroke = kind === "underline" ? styles.underlineColor ?? styles.color ?? "#000000" : styles.color ?? "#000000";
37002
- if (kind === "strike") {
37003
- writer.drawLine(pageIndex, {
37004
- x1: pxToPt$1(x1),
37005
- y1: pxToPt$1(y),
37006
- x2: pxToPt$1(x2),
37007
- y2: pxToPt$1(y),
37008
- stroke,
37009
- lineWidth: pxToPt$1(1)
37010
- });
37011
- return;
37012
- }
37013
- if (kind === "doubleStrike") {
37014
- const offset = 1.3;
37015
- writer.drawLine(pageIndex, {
37016
- x1: pxToPt$1(x1),
37017
- y1: pxToPt$1(y - offset),
37018
- x2: pxToPt$1(x2),
37019
- y2: pxToPt$1(y - offset),
37020
- stroke,
37021
- lineWidth: pxToPt$1(1)
37022
- });
37023
- writer.drawLine(pageIndex, {
37024
- x1: pxToPt$1(x1),
37025
- y1: pxToPt$1(y + offset),
37026
- x2: pxToPt$1(x2),
37027
- y2: pxToPt$1(y + offset),
37028
- stroke,
37029
- lineWidth: pxToPt$1(1)
37030
- });
37031
- return;
37032
- }
37033
- drawUnderlineWithStyle(
37034
- writer,
37035
- pageIndex,
37036
- x1,
37037
- x2,
37038
- y,
37039
- stroke,
37040
- styles.underlineStyle
37041
- );
37042
- }
37043
36910
  function drawUnderlineWithStyle(writer, pageIndex, x1, x2, y, stroke, underlineStyle) {
37044
36911
  const lineWidthPx = underlineStyleLineWidthPx(underlineStyle);
37045
36912
  const drawAt = (yy, dash) => {
@@ -37054,8 +36921,8 @@ function drawUnderlineWithStyle(writer, pageIndex, x1, x2, y, stroke, underlineS
37054
36921
  });
37055
36922
  };
37056
36923
  if (isDoubleUnderlineStyle(underlineStyle)) {
37057
- drawAt(y - 1.5);
37058
- drawAt(y + 1.5);
36924
+ drawAt(y - DOUBLE_UNDERLINE_OFFSET_PX);
36925
+ drawAt(y + DOUBLE_UNDERLINE_OFFSET_PX);
37059
36926
  return;
37060
36927
  }
37061
36928
  if (isWavyUnderlineStyle(underlineStyle)) {
@@ -37082,72 +36949,49 @@ function drawWavyUnderline(writer, pageIndex, x1, x2, y, stroke, lineWidthPx) {
37082
36949
  prevY = curY;
37083
36950
  }
37084
36951
  }
37085
- function groupSlotChunksByWhitespace(chars) {
37086
- const chunks = [];
37087
- let currentChunk = [];
37088
- for (const char of chars) {
37089
- if (char.char === " ") {
37090
- if (currentChunk.length > 0) {
37091
- chunks.push(currentChunk);
37092
- currentChunk = [];
37093
- }
37094
- continue;
37095
- }
37096
- currentChunk.push(char);
37097
- }
37098
- if (currentChunk.length > 0) {
37099
- chunks.push(currentChunk);
37100
- }
37101
- return chunks;
37102
- }
37103
- function groupSlotChunksByOffsetGaps(chars) {
37104
- const chunks = [];
37105
- let currentChunk = [];
37106
- for (const char of chars) {
37107
- const previous = currentChunk[currentChunk.length - 1];
37108
- if (previous && char.offset > previous.offset + 1) {
37109
- chunks.push(currentChunk);
37110
- currentChunk = [];
37111
- }
37112
- currentChunk.push(char);
37113
- }
37114
- if (currentChunk.length > 0) {
37115
- chunks.push(currentChunk);
36952
+ function drawFragmentEmphasis(writer, pageIndex, line, fragment, originX, originY, styles) {
36953
+ const mark = styles.emphasisMark;
36954
+ if (!mark || mark === "none") return;
36955
+ const glyph = EMPHASIS_GLYPH[mark];
36956
+ if (!glyph) return;
36957
+ const slots = resolveFragmentSlots(line, fragment);
36958
+ const below = mark === "underDot";
36959
+ const size = Math.max(4, line.height * 0.35);
36960
+ const y = below ? originY + line.top + line.height + size : originY + line.top + size;
36961
+ for (let i = 0; i < slots.length; i += 1) {
36962
+ const slot = slots[i];
36963
+ if (slot.char === " " || slot.char === " " || slot.char === "\n") continue;
36964
+ const next = slots[i + 1];
36965
+ const centerX = next ? (slot.left + next.left) / 2 : slot.left + line.height * 0.25;
36966
+ writer.drawText(pageIndex, {
36967
+ x: pxToPt$1(originX + centerX - size * 0.25),
36968
+ y: pxToPt$1(y),
36969
+ text: glyph,
36970
+ fontSize: pxToPt$1(size),
36971
+ color: styles.color ?? "#000000"
36972
+ });
37116
36973
  }
37117
- return chunks;
37118
36974
  }
37119
- function resolveTabLeader(paragraph, line, tabLeft, document2) {
36975
+ function drawTabLeaders(writer, pageIndex, paragraph, line, fragment, document2, originX, baselineY, color) {
37120
36976
  var _a2;
36977
+ const slotByOffset = new Map(
36978
+ line.slots.map((slot) => [slot.offset, slot])
36979
+ );
37121
36980
  const paragraphStyle = resolveEffectiveParagraphStyle(
37122
36981
  paragraph.style,
37123
36982
  document2.styles
37124
36983
  );
37125
36984
  const tabs = paragraphStyle.tabs ?? [];
37126
- if (tabs.length === 0) {
37127
- return void 0;
37128
- }
37129
- const lineStart = ((_a2 = line.slots[0]) == null ? void 0 : _a2.left) ?? 0;
37130
- const relativeLeft = tabLeft - lineStart;
37131
- const stop = tabs.filter((tab) => tab.type !== "clear").map((tab) => ({ ...tab, positionPx: tab.position * PX_PER_POINT })).filter((tab) => tab.positionPx > relativeLeft + 0.01).sort((a, b) => a.positionPx - b.positionPx)[0];
37132
- return (stop == null ? void 0 : stop.leader) && stop.leader !== "none" ? stop.leader : void 0;
37133
- }
37134
- function drawTabLeaders(writer, pageIndex, paragraph, line, fragment, document2, originX, baselineY, color) {
37135
- const slotByOffset = new Map(
37136
- line.slots.map((slot) => [slot.offset, slot])
37137
- );
37138
36985
  for (const char of fragment.chars) {
37139
- if (char.char !== " ") {
37140
- continue;
37141
- }
36986
+ if (char.char !== " ") continue;
37142
36987
  const slot = slotByOffset.get(char.paragraphOffset);
37143
36988
  const nextSlot = slotByOffset.get(char.paragraphOffset + 1);
37144
- if (!slot || !nextSlot) {
37145
- continue;
37146
- }
37147
- const leader = resolveTabLeader(paragraph, line, slot.left, document2);
37148
- if (!leader) {
37149
- continue;
37150
- }
36989
+ if (!slot || !nextSlot) continue;
36990
+ const lineStart = ((_a2 = line.slots[0]) == null ? void 0 : _a2.left) ?? 0;
36991
+ const relativeLeft = slot.left - lineStart;
36992
+ const stop = tabs.filter((tab) => tab.type !== "clear").map((tab) => ({ ...tab, positionPx: tab.position * PX_PER_POINT })).filter((tab) => tab.positionPx > relativeLeft + 0.01).sort((a, b) => a.positionPx - b.positionPx)[0];
36993
+ const leader = (stop == null ? void 0 : stop.leader) && stop.leader !== "none" ? stop.leader : void 0;
36994
+ if (!leader) continue;
37151
36995
  const y = leader === "underscore" ? baselineY + 2 : baselineY;
37152
36996
  writer.drawLine(pageIndex, {
37153
36997
  x1: pxToPt$1(originX + slot.left),
@@ -37160,24 +37004,14 @@ function drawTabLeaders(writer, pageIndex, paragraph, line, fragment, document2,
37160
37004
  });
37161
37005
  }
37162
37006
  }
37163
- async function drawInlineTextBoxFragment(writer, pageIndex, line, fragment, document2, originX, originY, fontRegistry, drawers) {
37164
- const textBox = fragment.textBox;
37165
- if (!textBox || textBox.floating) {
37166
- return;
37167
- }
37168
- const slot = line.slots.find((candidate) => candidate.offset === fragment.startOffset) ?? line.slots.find((candidate) => candidate.offset >= fragment.startOffset);
37169
- if (!slot) {
37170
- return;
37171
- }
37172
- await paintTextBox(
37173
- writer,
37174
- textBox,
37175
- { document: document2, fontRegistry, pageIndex },
37176
- originX + slot.left,
37177
- originY + line.top + line.height - textBox.height,
37178
- textBox.width,
37179
- textBox.height,
37180
- drawers
37007
+ function blendColorWithWhite(hex, alpha) {
37008
+ const rgb = parseHexColorToRgb255(hex);
37009
+ if (!rgb) return hex;
37010
+ const a = Math.max(0, Math.min(1, alpha));
37011
+ return rgb255ToHex(
37012
+ 255 + (rgb[0] - 255) * a,
37013
+ 255 + (rgb[1] - 255) * a,
37014
+ 255 + (rgb[2] - 255) * a
37181
37015
  );
37182
37016
  }
37183
37017
  function emitTextChunk(ctx, leftPx, text) {
@@ -37265,8 +37099,6 @@ function emitTextChunk(ctx, leftPx, text) {
37265
37099
  y: pxToPt$1(baselineY),
37266
37100
  text,
37267
37101
  color: mainColor,
37268
- // A gradient fill paints the glyphs via the shading clip; it supersedes
37269
- // both the solid color and any outline/stroke render mode.
37270
37102
  ...gradientShadingName ? { gradientShadingName } : textOutline ? {
37271
37103
  renderMode: 2,
37272
37104
  strokeColor: textOutline.color ?? mainColor,
@@ -37274,26 +37106,164 @@ function emitTextChunk(ctx, leftPx, text) {
37274
37106
  } : { renderMode: styles.outline ? 1 : 0 }
37275
37107
  });
37276
37108
  }
37109
+ function groupSlotChunksByWhitespace(chars) {
37110
+ const chunks = [];
37111
+ let current = [];
37112
+ for (const char of chars) {
37113
+ if (char.char === " ") {
37114
+ if (current.length > 0) {
37115
+ chunks.push(current);
37116
+ current = [];
37117
+ }
37118
+ continue;
37119
+ }
37120
+ current.push(char);
37121
+ }
37122
+ if (current.length > 0) chunks.push(current);
37123
+ return chunks;
37124
+ }
37125
+ function groupSlotChunksByOffsetGaps(chars) {
37126
+ const chunks = [];
37127
+ let current = [];
37128
+ for (const char of chars) {
37129
+ const previous = current[current.length - 1];
37130
+ if (previous && char.offset > previous.offset + 1) {
37131
+ chunks.push(current);
37132
+ current = [];
37133
+ }
37134
+ current.push(char);
37135
+ }
37136
+ if (current.length > 0) chunks.push(current);
37137
+ return chunks;
37138
+ }
37139
+ async function drawFloatingImagesForParagraph(options) {
37140
+ for (const line of options.lines) {
37141
+ const slots = new Map(line.slots.map((slot) => [slot.offset, slot]));
37142
+ for (const fragment of line.fragments) {
37143
+ const image = fragment.image;
37144
+ if (!(image == null ? void 0 : image.floating)) continue;
37145
+ const isBehind = Boolean(image.floating.behindDoc);
37146
+ if (options.layer === "behind" !== isBehind) continue;
37147
+ const slot = slots.get(fragment.startOffset);
37148
+ const rect = resolveFloatingObjectRect({
37149
+ object: getImageFloatingGeometry(image),
37150
+ pageSettings: options.pageSettings,
37151
+ contentLeft: options.contentLeft,
37152
+ contentTop: options.contentTop,
37153
+ contentWidth: options.contentWidth,
37154
+ paragraphTop: options.paragraphTop,
37155
+ lineTop: options.paragraphTop + line.top,
37156
+ anchorLeft: options.contentLeft + ((slot == null ? void 0 : slot.left) ?? 0)
37157
+ });
37158
+ const resourceName = await registerPdfImageRun(
37159
+ options.writer,
37160
+ options.document,
37161
+ image
37162
+ );
37163
+ if (!resourceName) continue;
37164
+ options.writer.drawImage(options.pageIndex, {
37165
+ resourceName,
37166
+ x: pxToPt$1(rect.x),
37167
+ y: pxToPt$1(rect.y),
37168
+ width: pxToPt$1(rect.width),
37169
+ height: pxToPt$1(rect.height),
37170
+ rotation: image.rotation
37171
+ });
37172
+ }
37173
+ }
37174
+ }
37175
+ function drawFragmentDecoration(writer, pageIndex, line, fragment, originX, originY, styles, kind) {
37176
+ const bounds = resolveFragmentBounds(
37177
+ line,
37178
+ fragment,
37179
+ styles.fontSize ?? DEFAULT_FONT_SIZE_PX
37180
+ );
37181
+ if (!bounds) return;
37182
+ const y = originY + resolveDecorationLineY(kind, line.top, line.height);
37183
+ const x1 = originX + bounds.left;
37184
+ const x2 = originX + bounds.right;
37185
+ const stroke = kind === "underline" ? styles.underlineColor ?? styles.color ?? "#000000" : styles.color ?? "#000000";
37186
+ if (kind === "strike") {
37187
+ writer.drawLine(pageIndex, {
37188
+ x1: pxToPt$1(x1),
37189
+ y1: pxToPt$1(y),
37190
+ x2: pxToPt$1(x2),
37191
+ y2: pxToPt$1(y),
37192
+ stroke,
37193
+ lineWidth: pxToPt$1(1)
37194
+ });
37195
+ return;
37196
+ }
37197
+ if (kind === "doubleStrike") {
37198
+ writer.drawLine(pageIndex, {
37199
+ x1: pxToPt$1(x1),
37200
+ y1: pxToPt$1(y - DOUBLE_STRIKE_OFFSET_PX),
37201
+ x2: pxToPt$1(x2),
37202
+ y2: pxToPt$1(y - DOUBLE_STRIKE_OFFSET_PX),
37203
+ stroke,
37204
+ lineWidth: pxToPt$1(1)
37205
+ });
37206
+ writer.drawLine(pageIndex, {
37207
+ x1: pxToPt$1(x1),
37208
+ y1: pxToPt$1(y + DOUBLE_STRIKE_OFFSET_PX),
37209
+ x2: pxToPt$1(x2),
37210
+ y2: pxToPt$1(y + DOUBLE_STRIKE_OFFSET_PX),
37211
+ stroke,
37212
+ lineWidth: pxToPt$1(1)
37213
+ });
37214
+ return;
37215
+ }
37216
+ drawUnderlineWithStyle(
37217
+ writer,
37218
+ pageIndex,
37219
+ x1,
37220
+ x2,
37221
+ y,
37222
+ stroke,
37223
+ styles.underlineStyle
37224
+ );
37225
+ }
37226
+ function drawLinkAnnotation(writer, pageIndex, line, fragment, originX, originY, styles) {
37227
+ if (!styles.link) return;
37228
+ const linkBounds = resolveFragmentBounds(
37229
+ line,
37230
+ fragment,
37231
+ styles.fontSize ?? DEFAULT_FONT_SIZE_PX
37232
+ );
37233
+ if (!linkBounds || linkBounds.right <= linkBounds.left) return;
37234
+ const isInternal = styles.link.startsWith("#");
37235
+ writer.addLinkAnnotation(pageIndex, {
37236
+ x: pxToPt$1(originX + linkBounds.left),
37237
+ y: pxToPt$1(originY + line.top),
37238
+ width: pxToPt$1(linkBounds.right - linkBounds.left),
37239
+ height: pxToPt$1(line.height),
37240
+ ...isInternal ? { destName: styles.link.slice(1) } : { uri: styles.link }
37241
+ });
37242
+ }
37243
+ function emitFragmentGlyphs(chunkCtx, chars, originX, styles, line, fragment, paragraphAlign) {
37244
+ const chunks = paragraphAlign === "justify" ? groupSlotChunksByWhitespace(chars) : groupSlotChunksByOffsetGaps(chars);
37245
+ for (const chunk of chunks) {
37246
+ const chunkText = chunk.map((c) => styles.allCaps ? c.char.toUpperCase() : c.char).join("");
37247
+ if (chunkText.length === 0) continue;
37248
+ emitTextChunk(chunkCtx, originX + chunk[0].left, chunkText);
37249
+ }
37250
+ if (line.trailingHyphen && fragment.endOffset >= line.endOffset) {
37251
+ const endSlot = line.slots.find((slot) => slot.offset === line.endOffset) ?? line.slots[line.slots.length - 1];
37252
+ if (endSlot) emitTextChunk(chunkCtx, originX + endSlot.left, "-");
37253
+ }
37254
+ }
37277
37255
  async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, document2, originX, originY, fontRegistry, drawers) {
37278
37256
  var _a2, _b2, _c;
37279
37257
  if (fragment.image) {
37280
- if (fragment.image.floating) {
37281
- return;
37282
- }
37283
- const slot = line.slots.find(
37284
- (candidate) => candidate.offset === fragment.startOffset
37285
- ) ?? line.slots.find((candidate) => candidate.offset >= fragment.startOffset);
37286
- if (!slot) {
37287
- return;
37288
- }
37258
+ if (fragment.image.floating) return;
37259
+ const slot = line.slots.find((c) => c.offset === fragment.startOffset) ?? line.slots.find((c) => c.offset >= fragment.startOffset);
37260
+ if (!slot) return;
37289
37261
  const resourceName = await registerPdfImageRun(
37290
37262
  writer,
37291
37263
  document2,
37292
37264
  fragment.image
37293
37265
  );
37294
- if (!resourceName) {
37295
- return;
37296
- }
37266
+ if (!resourceName) return;
37297
37267
  writer.drawImage(pageIndex, {
37298
37268
  resourceName,
37299
37269
  x: pxToPt$1(originX + slot.left),
@@ -37305,15 +37275,17 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37305
37275
  return;
37306
37276
  }
37307
37277
  if (fragment.textBox) {
37308
- await drawInlineTextBoxFragment(
37278
+ if (fragment.textBox.floating) return;
37279
+ const slot = line.slots.find((c) => c.offset === fragment.startOffset) ?? line.slots.find((c) => c.offset >= fragment.startOffset);
37280
+ if (!slot) return;
37281
+ await paintTextBox(
37309
37282
  writer,
37310
- pageIndex,
37311
- line,
37312
- fragment,
37313
- document2,
37314
- originX,
37315
- originY,
37316
- fontRegistry,
37283
+ fragment.textBox,
37284
+ { document: document2, fontRegistry, pageIndex },
37285
+ originX + slot.left,
37286
+ originY + line.top + line.height - fragment.textBox.height,
37287
+ fragment.textBox.width,
37288
+ fragment.textBox.height,
37317
37289
  drawers
37318
37290
  );
37319
37291
  return;
@@ -37323,9 +37295,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37323
37295
  (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
37324
37296
  document2.styles
37325
37297
  );
37326
- if (styles.hidden) {
37327
- return;
37328
- }
37298
+ if (styles.hidden) return;
37329
37299
  const fontFace = fontRegistry.resolveFontFace({
37330
37300
  fontFamily: styles.fontFamily,
37331
37301
  bold: styles.bold,
@@ -37333,30 +37303,12 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37333
37303
  });
37334
37304
  const fontSizePt = styles.smallCaps ? textStyleToFontSizePt(styles) * 0.8 : textStyleToFontSizePt(styles);
37335
37305
  const baselineShiftPx = (styles.baselineShift ?? 0) * PX_PER_POINT;
37336
- const baselineY = originY + line.top + line.height * 0.8 - baselineShiftPx;
37306
+ const baselineY = originY + line.top + line.height * TEXT_BASELINE_RATIO - baselineShiftPx;
37337
37307
  const chars = resolveFragmentSlots(line, fragment);
37338
37308
  const text = chars.map((char) => styles.allCaps ? char.char.toUpperCase() : char.char).join("");
37339
37309
  const firstChar = chars[0];
37340
- if (!firstChar || text.length === 0) {
37341
- return;
37342
- }
37343
- if (styles.link) {
37344
- const linkBounds = resolveFragmentBounds(
37345
- line,
37346
- fragment,
37347
- styles.fontSize ?? DEFAULT_FONT_SIZE_PX
37348
- );
37349
- if (linkBounds && linkBounds.right > linkBounds.left) {
37350
- const isInternal = styles.link.startsWith("#");
37351
- writer.addLinkAnnotation(pageIndex, {
37352
- x: pxToPt$1(originX + linkBounds.left),
37353
- y: pxToPt$1(originY + line.top),
37354
- width: pxToPt$1(linkBounds.right - linkBounds.left),
37355
- height: pxToPt$1(line.height),
37356
- ...isInternal ? { destName: styles.link.slice(1) } : { uri: styles.link }
37357
- });
37358
- }
37359
- }
37310
+ if (!firstChar || text.length === 0) return;
37311
+ drawLinkAnnotation(writer, pageIndex, line, fragment, originX, originY, styles);
37360
37312
  drawFragmentShading(
37361
37313
  writer,
37362
37314
  pageIndex,
@@ -37429,18 +37381,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37429
37381
  styles,
37430
37382
  baseTextOptions
37431
37383
  };
37432
- const chunks = paragraphAlign === "justify" ? groupSlotChunksByWhitespace(chars) : groupSlotChunksByOffsetGaps(chars);
37433
- for (const chunk of chunks) {
37434
- const chunkText = chunk.map((c) => styles.allCaps ? c.char.toUpperCase() : c.char).join("");
37435
- if (chunkText.length === 0) continue;
37436
- emitTextChunk(chunkCtx, originX + chunk[0].left, chunkText);
37437
- }
37438
- if (line.trailingHyphen && fragment.endOffset >= line.endOffset) {
37439
- const endSlot = line.slots.find((slot) => slot.offset === line.endOffset) ?? line.slots[line.slots.length - 1];
37440
- if (endSlot) {
37441
- emitTextChunk(chunkCtx, originX + endSlot.left, "-");
37442
- }
37443
- }
37384
+ emitFragmentGlyphs(chunkCtx, chars, originX, styles, line, fragment, paragraphAlign);
37444
37385
  if (styles.underline) {
37445
37386
  drawFragmentDecoration(
37446
37387
  writer,
@@ -37526,7 +37467,7 @@ function drawListPrefix(writer, pageIndex, paragraph, line, document2, originX,
37526
37467
  );
37527
37468
  writer.drawText(pageIndex, {
37528
37469
  x: pxToPt$1(originX + Math.max(0, alignedInset || labelInset)),
37529
- y: pxToPt$1(originY + line.top + line.height * 0.8),
37470
+ y: pxToPt$1(originY + line.top + line.height * TEXT_BASELINE_RATIO),
37530
37471
  text: prefix,
37531
37472
  fontSize: fontSizePt,
37532
37473
  color: styles.color ?? "#000000",
@@ -38690,12 +38631,20 @@ function parseLayoutTableHeader(reader) {
38690
38631
  function parseLookupList(reader, lookupListOffset, parseSubtable2) {
38691
38632
  reader.seek(lookupListOffset);
38692
38633
  const lookupCount = reader.u16();
38693
- const lookupOffsets = readU16OffsetArray(reader, lookupCount, lookupListOffset);
38634
+ const lookupOffsets = readU16OffsetArray(
38635
+ reader,
38636
+ lookupCount,
38637
+ lookupListOffset
38638
+ );
38694
38639
  return lookupOffsets.map((lookupOffset) => {
38695
38640
  reader.seek(lookupOffset);
38696
38641
  const lookupType = reader.u16();
38697
38642
  reader.skip(2);
38698
- const subtableOffsets = readU16OffsetArray(reader, reader.u16(), lookupOffset);
38643
+ const subtableOffsets = readU16OffsetArray(
38644
+ reader,
38645
+ reader.u16(),
38646
+ lookupOffset
38647
+ );
38699
38648
  const subtables = [];
38700
38649
  for (const subtableOffset of subtableOffsets) {
38701
38650
  try {
@@ -38873,9 +38822,21 @@ function parseChainContextSubst(reader, offset) {
38873
38822
  reader.seek(offset);
38874
38823
  const format = reader.u16();
38875
38824
  if (format === 3) {
38876
- const backtrackCoverageOffsets = readU16OffsetArray(reader, reader.u16(), offset);
38877
- const inputCoverageOffsets = readU16OffsetArray(reader, reader.u16(), offset);
38878
- const lookaheadCoverageOffsets = readU16OffsetArray(reader, reader.u16(), offset);
38825
+ const backtrackCoverageOffsets = readU16OffsetArray(
38826
+ reader,
38827
+ reader.u16(),
38828
+ offset
38829
+ );
38830
+ const inputCoverageOffsets = readU16OffsetArray(
38831
+ reader,
38832
+ reader.u16(),
38833
+ offset
38834
+ );
38835
+ const lookaheadCoverageOffsets = readU16OffsetArray(
38836
+ reader,
38837
+ reader.u16(),
38838
+ offset
38839
+ );
38879
38840
  const substCount = reader.u16();
38880
38841
  const records = readSubstLookupRecords(reader, substCount);
38881
38842
  const backtrack = backtrackCoverageOffsets.map(
@@ -41180,7 +41141,7 @@ function buildImportedDocumentDiagnostics(document2) {
41180
41141
  );
41181
41142
  return {
41182
41143
  index,
41183
- text: getParagraphText(paragraph).slice(0, 160),
41144
+ textLength: getParagraphText(paragraph).length,
41184
41145
  runCount: paragraph.runs.length,
41185
41146
  rawParagraphStyle: paragraph.style,
41186
41147
  align: paragraphStyle.align,
@@ -41221,7 +41182,7 @@ function createDocumentImporter(deps) {
41221
41182
  const arrayBuffer = await readFileBuffer(file);
41222
41183
  deps.logger.info("import:phase", {
41223
41184
  phase: "reading-file",
41224
- durationMs: Math.round((deps.now() - readingStartedAt) * 100) / 100
41185
+ durationMs: roundTo(deps.now() - readingStartedAt, 2)
41225
41186
  });
41226
41187
  let lastProgressStage = null;
41227
41188
  let lastProgressValue = -1;
@@ -41249,7 +41210,7 @@ function createDocumentImporter(deps) {
41249
41210
  }
41250
41211
  }
41251
41212
  );
41252
- deps.logger.info(
41213
+ deps.logger.debug(
41253
41214
  "import:document-diagnostics",
41254
41215
  buildImportedDocumentDiagnostics(document2)
41255
41216
  );
@@ -41261,7 +41222,7 @@ function createDocumentImporter(deps) {
41261
41222
  await deps.stabilizeLayoutAfterImport();
41262
41223
  deps.logger.info("import:phase", {
41263
41224
  phase: "stabilizing-layout",
41264
- durationMs: Math.round((deps.now() - stabilizationStartedAt) * 100) / 100
41225
+ durationMs: roundTo(deps.now() - stabilizationStartedAt, 2)
41265
41226
  });
41266
41227
  const sections = getDocumentSectionsCanonical(document2);
41267
41228
  const canonicalBlocks = sections.reduce(
@@ -41277,7 +41238,7 @@ function createDocumentImporter(deps) {
41277
41238
  format: importer.id,
41278
41239
  blocks: canonicalBlocks,
41279
41240
  paragraphs: canonicalParagraphs,
41280
- durationMs: Math.round((deps.now() - startedAt) * 100) / 100
41241
+ durationMs: roundTo(deps.now() - startedAt, 2)
41281
41242
  });
41282
41243
  deps.focusInput();
41283
41244
  } catch (error) {
@@ -41448,7 +41409,10 @@ function patchSelectedImage(state, updater) {
41448
41409
  return cloneStateWithParagraphs(
41449
41410
  state,
41450
41411
  nextParagraphs,
41451
- preserveSelectionByParagraphOffsets(nextParagraphs, normalizeSelection(state))
41412
+ preserveSelectionByParagraphOffsets(
41413
+ nextParagraphs,
41414
+ normalizeSelection(state)
41415
+ )
41452
41416
  );
41453
41417
  }
41454
41418
  function patchSelectedImageFloating(state, next) {
@@ -42684,9 +42648,17 @@ function putItem(db, storeName, key, value) {
42684
42648
  )
42685
42649
  );
42686
42650
  };
42687
- request.onsuccess = () => {
42651
+ transaction.oncomplete = () => {
42688
42652
  resolve();
42689
42653
  };
42654
+ transaction.onabort = transaction.onerror = () => {
42655
+ var _a2;
42656
+ reject(
42657
+ new Error(
42658
+ `Transaction failed putting item in ${storeName}: ${(_a2 = transaction.error) == null ? void 0 : _a2.message}`
42659
+ )
42660
+ );
42661
+ };
42690
42662
  } catch (err) {
42691
42663
  reject(err);
42692
42664
  }
@@ -42728,9 +42700,17 @@ function deleteItem(db, storeName, key) {
42728
42700
  )
42729
42701
  );
42730
42702
  };
42731
- request.onsuccess = () => {
42703
+ transaction.oncomplete = () => {
42732
42704
  resolve();
42733
42705
  };
42706
+ transaction.onabort = transaction.onerror = () => {
42707
+ var _a2;
42708
+ reject(
42709
+ new Error(
42710
+ `Transaction failed deleting item from ${storeName}: ${(_a2 = transaction.error) == null ? void 0 : _a2.message}`
42711
+ )
42712
+ );
42713
+ };
42734
42714
  } catch (err) {
42735
42715
  reject(err);
42736
42716
  }
@@ -43753,7 +43733,12 @@ function createTableCellSpanOperations(deps) {
43753
43733
  if (!nextParagraph) {
43754
43734
  return current;
43755
43735
  }
43756
- return commitTableMutation(current, targetBlocks, range.zone, nextParagraph);
43736
+ return commitTableMutation(
43737
+ current,
43738
+ targetBlocks,
43739
+ range.zone,
43740
+ nextParagraph
43741
+ );
43757
43742
  };
43758
43743
  const mergeSelectedTableRows = (current) => {
43759
43744
  const range = deps.resolveVerticalTableCellRange(current);
@@ -43826,7 +43811,12 @@ function createTableCellSpanOperations(deps) {
43826
43811
  if (!nextParagraph) {
43827
43812
  return current;
43828
43813
  }
43829
- return commitTableMutation(current, targetBlocks, range.zone, nextParagraph);
43814
+ return commitTableMutation(
43815
+ current,
43816
+ targetBlocks,
43817
+ range.zone,
43818
+ nextParagraph
43819
+ );
43830
43820
  };
43831
43821
  const mergeSelectedTable = (current) => {
43832
43822
  if (deps.canMergeSelectedTableCells(current)) {
@@ -43894,7 +43884,12 @@ function createTableCellSpanOperations(deps) {
43894
43884
  if (!nextParagraph) {
43895
43885
  return current;
43896
43886
  }
43897
- return commitTableMutation(current, targetBlocks, location.zone, nextParagraph);
43887
+ return commitTableMutation(
43888
+ current,
43889
+ targetBlocks,
43890
+ location.zone,
43891
+ nextParagraph
43892
+ );
43898
43893
  };
43899
43894
  const splitSelectedTableCell = (current) => {
43900
43895
  var _a2;
@@ -43947,7 +43942,12 @@ function createTableCellSpanOperations(deps) {
43947
43942
  if (!nextParagraph) {
43948
43943
  return current;
43949
43944
  }
43950
- return commitTableMutation(current, targetBlocks, location.zone, nextParagraph);
43945
+ return commitTableMutation(
43946
+ current,
43947
+ targetBlocks,
43948
+ location.zone,
43949
+ nextParagraph
43950
+ );
43951
43951
  };
43952
43952
  const splitSelectedTable = (current) => {
43953
43953
  if (deps.canSplitSelectedTableCellVertically(current)) {
@@ -44038,7 +44038,12 @@ function createTableRowColumnOperations(deps) {
44038
44038
  const nextParagraph2 = (targetCell2 == null ? void 0 : targetCell2.blocks[0]) ?? ((_a2 = blankRow.cells.find(
44039
44039
  (cell) => cell.vMerge !== "continue" && cell.blocks[0]
44040
44040
  )) == null ? void 0 : _a2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
44041
- return commitTableMutation(current, targetBlocks, location.zone, nextParagraph2);
44041
+ return commitTableMutation(
44042
+ current,
44043
+ targetBlocks,
44044
+ location.zone,
44045
+ nextParagraph2
44046
+ );
44042
44047
  }
44043
44048
  blankRow = createEditorTableRow(
44044
44049
  sourceRow.cells.map(
@@ -44062,7 +44067,12 @@ function createTableRowColumnOperations(deps) {
44062
44067
  const nextParagraph = (targetCell == null ? void 0 : targetCell.blocks[0]) ?? ((_b2 = blankRow.cells.find(
44063
44068
  (cell) => cell.vMerge !== "continue" && cell.blocks[0]
44064
44069
  )) == null ? void 0 : _b2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
44065
- return commitTableMutation(current, targetBlocks, location.zone, nextParagraph);
44070
+ return commitTableMutation(
44071
+ current,
44072
+ targetBlocks,
44073
+ location.zone,
44074
+ nextParagraph
44075
+ );
44066
44076
  };
44067
44077
  const deleteSelectedTableRow = (current) => {
44068
44078
  const mut = resolveLocationTableMutation(current, deps.getTargetBlocks);
@@ -44123,7 +44133,12 @@ function createTableRowColumnOperations(deps) {
44123
44133
  )
44124
44134
  ) : null;
44125
44135
  const nextParagraph = (targetCell == null ? void 0 : targetCell.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
44126
- return commitTableMutation(current, targetBlocks, location.zone, nextParagraph);
44136
+ return commitTableMutation(
44137
+ current,
44138
+ targetBlocks,
44139
+ location.zone,
44140
+ nextParagraph
44141
+ );
44127
44142
  };
44128
44143
  const insertSelectedTableColumn = (current, direction) => {
44129
44144
  var _a2;
@@ -44200,7 +44215,12 @@ function createTableRowColumnOperations(deps) {
44200
44215
  const targetRow2 = tableBlock.rows[location.rowIndex];
44201
44216
  const targetCell2 = targetRow2 ? findCellAtVisualColumn(targetRow2, insertVisualColumn) : null;
44202
44217
  const nextParagraph2 = (targetCell2 == null ? void 0 : targetCell2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
44203
- return commitTableMutation(current, targetBlocks, location.zone, nextParagraph2);
44218
+ return commitTableMutation(
44219
+ current,
44220
+ targetBlocks,
44221
+ location.zone,
44222
+ nextParagraph2
44223
+ );
44204
44224
  }
44205
44225
  const insertIndex = Math.max(
44206
44226
  0,
@@ -44224,7 +44244,12 @@ function createTableRowColumnOperations(deps) {
44224
44244
  const targetRow = tableBlock.rows[location.rowIndex];
44225
44245
  const targetCell = targetRow == null ? void 0 : targetRow.cells[insertIndex];
44226
44246
  const nextParagraph = (targetCell == null ? void 0 : targetCell.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
44227
- return commitTableMutation(current, targetBlocks, location.zone, nextParagraph);
44247
+ return commitTableMutation(
44248
+ current,
44249
+ targetBlocks,
44250
+ location.zone,
44251
+ nextParagraph
44252
+ );
44228
44253
  };
44229
44254
  const deleteSelectedTableColumn = (current) => {
44230
44255
  var _a2;
@@ -44291,7 +44316,12 @@ function createTableRowColumnOperations(deps) {
44291
44316
  )
44292
44317
  );
44293
44318
  const nextParagraph2 = (targetCell2 == null ? void 0 : targetCell2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
44294
- return commitTableMutation(current, targetBlocks, location.zone, nextParagraph2);
44319
+ return commitTableMutation(
44320
+ current,
44321
+ targetBlocks,
44322
+ location.zone,
44323
+ nextParagraph2
44324
+ );
44295
44325
  }
44296
44326
  if (((_a2 = tableBlock.rows[0]) == null ? void 0 : _a2.cells.length) <= 1) {
44297
44327
  return current;
@@ -44302,7 +44332,12 @@ function createTableRowColumnOperations(deps) {
44302
44332
  const targetRow = tableBlock.rows[location.rowIndex];
44303
44333
  const targetCell = targetRow == null ? void 0 : targetRow.cells[Math.min(location.cellIndex, targetRow.cells.length - 1)];
44304
44334
  const nextParagraph = (targetCell == null ? void 0 : targetCell.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
44305
- return commitTableMutation(current, targetBlocks, location.zone, nextParagraph);
44335
+ return commitTableMutation(
44336
+ current,
44337
+ targetBlocks,
44338
+ location.zone,
44339
+ nextParagraph
44340
+ );
44306
44341
  };
44307
44342
  return {
44308
44343
  insertSelectedTableRow,
@@ -45268,7 +45303,7 @@ function scoreRectDistance(left, top, width, height, clientX, clientY) {
45268
45303
  const bottom = top + height;
45269
45304
  const verticalDelta = clientY < top ? top - clientY : clientY > bottom ? clientY - bottom : 0;
45270
45305
  const horizontalDelta = clientX < left ? left - clientX : clientX > right ? clientX - right : 0;
45271
- return verticalDelta * 1e3 + horizontalDelta;
45306
+ return verticalDelta * VERTICAL_HIT_WEIGHT + horizontalDelta;
45272
45307
  }
45273
45308
  function resolveZoneFromPage(page, clientY) {
45274
45309
  const localY = clientY - page.top;
@@ -45311,7 +45346,7 @@ function resolveClosestOffsetInLine(line, clientX, clientY) {
45311
45346
  for (const slot of line.slots) {
45312
45347
  const verticalDelta = clientY < slot.top ? slot.top - clientY : clientY > slot.top + slot.height ? clientY - (slot.top + slot.height) : 0;
45313
45348
  const horizontalDelta = Math.abs(clientX - slot.left);
45314
- const score = verticalDelta * 1e3 + horizontalDelta;
45349
+ const score = verticalDelta * VERTICAL_HIT_WEIGHT + horizontalDelta;
45315
45350
  if (score < bestScore) {
45316
45351
  bestScore = score;
45317
45352
  bestOffset = slot.offset;
@@ -46724,11 +46759,10 @@ function createEditorTableDrag(deps) {
46724
46759
  const table = findTable();
46725
46760
  if ((table == null ? void 0 : table.type) === "table" && ((_a2 = table.style) == null ? void 0 : _a2.floating)) {
46726
46761
  const floating = table.style.floating;
46727
- const pointsPerPixel = 72 / 96;
46728
46762
  return setActiveTableStyleValue(current, tableId, "floating", {
46729
46763
  ...floating,
46730
- x: (floating.x ?? 0) + (event.clientX - startClientX()) * pointsPerPixel,
46731
- y: (floating.y ?? 0) + (event.clientY - startClientY()) * pointsPerPixel,
46764
+ x: (floating.x ?? 0) + (event.clientX - startClientX()) * PT_PER_PX,
46765
+ y: (floating.y ?? 0) + (event.clientY - startClientY()) * PT_PER_PX,
46732
46766
  xAlign: void 0,
46733
46767
  yAlign: void 0
46734
46768
  });
@@ -47033,7 +47067,10 @@ function createEditorSurfaceEvents(deps) {
47033
47067
  hit.zone,
47034
47068
  {
47035
47069
  ...state,
47036
- selection: { anchor: { ...hit.position }, focus: { ...hit.position } }
47070
+ selection: {
47071
+ anchor: { ...hit.position },
47072
+ focus: { ...hit.position }
47073
+ }
47037
47074
  },
47038
47075
  hit.position
47039
47076
  );
@@ -47053,9 +47090,20 @@ function createEditorSurfaceEvents(deps) {
47053
47090
  return;
47054
47091
  }
47055
47092
  dragAnchor = null;
47056
- const start = paragraphOffsetToPosition(textBoxParagraph, hit.textBox.startOffset);
47057
- const end = paragraphOffsetToPosition(textBoxParagraph, hit.textBox.endOffset);
47058
- applyWithZone(state, hit.zone, setSelection(state, { anchor: start, focus: end }), start);
47093
+ const start = paragraphOffsetToPosition(
47094
+ textBoxParagraph,
47095
+ hit.textBox.startOffset
47096
+ );
47097
+ const end = paragraphOffsetToPosition(
47098
+ textBoxParagraph,
47099
+ hit.textBox.endOffset
47100
+ );
47101
+ applyWithZone(
47102
+ state,
47103
+ hit.zone,
47104
+ setSelection(state, { anchor: start, focus: end }),
47105
+ start
47106
+ );
47059
47107
  stopDragging();
47060
47108
  deps.focusInputAfterPointerSelection();
47061
47109
  };
@@ -47069,9 +47117,17 @@ function createEditorSurfaceEvents(deps) {
47069
47117
  return;
47070
47118
  }
47071
47119
  dragAnchor = null;
47072
- const start = paragraphOffsetToPosition(imageParagraph, hit.image.startOffset);
47120
+ const start = paragraphOffsetToPosition(
47121
+ imageParagraph,
47122
+ hit.image.startOffset
47123
+ );
47073
47124
  const end = paragraphOffsetToPosition(imageParagraph, hit.image.endOffset);
47074
- applyWithZone(state, hit.zone, setSelection(state, { anchor: start, focus: end }), start);
47125
+ applyWithZone(
47126
+ state,
47127
+ hit.zone,
47128
+ setSelection(state, { anchor: start, focus: end }),
47129
+ start
47130
+ );
47075
47131
  stopDragging();
47076
47132
  deps.imageOps.startImageDrag(
47077
47133
  hit.image.paragraphId,
@@ -47091,7 +47147,10 @@ function createEditorSurfaceEvents(deps) {
47091
47147
  applyWithZone(
47092
47148
  state,
47093
47149
  hit.zone,
47094
- setSelection(state, { anchor: state.selection.anchor, focus: hit.position }),
47150
+ setSelection(state, {
47151
+ anchor: state.selection.anchor,
47152
+ focus: hit.position
47153
+ }),
47095
47154
  hit.position
47096
47155
  );
47097
47156
  window.addEventListener("mousemove", handleWindowMouseMove);
@@ -47112,7 +47171,10 @@ function createEditorSurfaceEvents(deps) {
47112
47171
  };
47113
47172
  const handleDoubleClickDown = (state, hit, paragraph) => {
47114
47173
  dragAnchor = null;
47115
- const word = resolveWordSelection(getParagraphText(paragraph), hit.paragraphOffset);
47174
+ const word = resolveWordSelection(
47175
+ getParagraphText(paragraph),
47176
+ hit.paragraphOffset
47177
+ );
47116
47178
  const startPos = paragraphOffsetToPosition(paragraph, word.start);
47117
47179
  const endPos = paragraphOffsetToPosition(paragraph, word.end);
47118
47180
  applyWithZone(
@@ -49867,7 +49929,7 @@ function buildEntryParagraph(heading, pageNumber, rightTabPositionPt) {
49867
49929
  function rightTabPositionForSection(section) {
49868
49930
  const { width, margins } = section.pageSettings;
49869
49931
  const contentWidthPx = Math.max(0, width - margins.left - margins.right);
49870
- return Math.round(contentWidthPx * PT_PER_PX * 100) / 100;
49932
+ return roundTo(contentWidthPx * PT_PER_PX, 2);
49871
49933
  }
49872
49934
  function buildStartMarkerParagraph() {
49873
49935
  return makeParagraph([
@@ -51780,11 +51842,8 @@ function OasisEditorApp(props = {}) {
51780
51842
  canvasSnapshotProvider
51781
51843
  });
51782
51844
  const {
51783
- selectedImageRun,
51784
51845
  layoutOptionsOverlay,
51785
51846
  fr,
51786
- resolveSurfaceHitAtPoint,
51787
- resolvePositionAtSurfacePoint,
51788
51847
  tableOps,
51789
51848
  imageOps,
51790
51849
  textBoxOps,
@@ -51796,7 +51855,6 @@ function OasisEditorApp(props = {}) {
51796
51855
  textDrag,
51797
51856
  surfaceEventsWithTextDrag,
51798
51857
  textInput,
51799
- navigation,
51800
51858
  handleCopy,
51801
51859
  handleCut,
51802
51860
  handlePaste,