oasis-editor 0.0.114 → 0.0.115

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 (28) hide show
  1. package/dist/{OasisEditorApp-XloOiKSu.js → OasisEditorApp-C1dyjJoH.js} +197 -365
  2. package/dist/core/decorationGeometry.d.ts +10 -0
  3. package/dist/core/gradientAxis.d.ts +11 -0
  4. package/dist/core/textStyleMappings.d.ts +2 -0
  5. package/dist/export/pdf/draw/drawFragment.d.ts +4 -4
  6. package/dist/export/pdf/draw/fragment/pdfColor.d.ts +1 -0
  7. package/dist/export/pdf/draw/fragment/pdfEmphasisAndTabLeaders.d.ts +5 -0
  8. package/dist/export/pdf/draw/fragment/pdfGradient.d.ts +4 -0
  9. package/dist/export/pdf/draw/fragment/pdfRunBackground.d.ts +12 -0
  10. package/dist/export/pdf/draw/fragment/pdfTextChunks.d.ts +25 -0
  11. package/dist/export/pdf/draw/fragment/pdfTextDecoration.d.ts +4 -0
  12. package/dist/{index-CwpzM--5.js → index-Cq3YFYX2.js} +833 -866
  13. package/dist/oasis-editor.js +50 -50
  14. package/dist/oasis-editor.umd.cjs +4 -4
  15. package/dist/ui/canvas/CanvasTableLayout.d.ts +12 -63
  16. package/dist/ui/canvas/canvasParagraphPainter.d.ts +4 -22
  17. package/dist/ui/canvas/paragraph/canvasEmphasis.d.ts +3 -0
  18. package/dist/ui/canvas/paragraph/canvasInlineImage.d.ts +26 -0
  19. package/dist/ui/canvas/paragraph/canvasRunBackground.d.ts +13 -0
  20. package/dist/ui/canvas/paragraph/canvasTabLeaders.d.ts +4 -0
  21. package/dist/ui/canvas/paragraph/canvasTextDecoration.d.ts +4 -0
  22. package/dist/ui/canvas/paragraph/canvasTextEffects.d.ts +43 -0
  23. package/dist/ui/canvas/table/assembleCellEntries.d.ts +15 -0
  24. package/dist/ui/canvas/table/prepareCells.d.ts +53 -0
  25. package/dist/ui/canvas/table/resolveRowHeights.d.ts +9 -0
  26. package/dist/ui/canvas/table/tableCellGeometry.d.ts +37 -0
  27. package/dist/ui/canvas/table/types.d.ts +63 -0
  28. package/package.json +1 -1
@@ -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 { 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 PX_PER_POINT, b4 as DEFAULT_FONT_SIZE_PX, b5 as resolveGradientAxis, b6 as isDoubleUnderlineStyle, b7 as isWavyUnderlineStyle, b8 as underlineStyleLineWidthPx, b9 as WAVY_UNDERLINE_WAVELENGTH_PX, ba as WAVY_UNDERLINE_AMPLITUDE_PX, bb as DOUBLE_UNDERLINE_OFFSET_PX, bc as underlineStyleDashArray, bd as EMPHASIS_GLYPH, be as rgb255ToHex, bf as getImageFloatingGeometry, bg as textStyleToFontSizePt, bh as resolveOpenTypeFeatureTags, bi as resolveDecorationLineY, bj as DOUBLE_STRIKE_OFFSET_PX, bk as resolveListLabel, bl as getListLabelInset, bm as getAlignedListLabelInset, bn as getParagraphBorderInsets, bo as buildSegmentTable, bp as buildCanvasTableLayout, bq as resolveCanvasTableWidth, br as resolveFloatingTableRect, bs as normalizeFamily, bt as ROBOTO_FONT_FILES, bu as loadFontAsset, bv as OFFICE_COMPAT_FONT_FAMILIES, bw as BinaryReader, bx as buildSfnt, by as defaultFontDecoderRegistry, bz as SfntFontProgram, bA as collectPdfFontFamilies, bB as outlineFrom, bC as getPageHeaderZoneTop, bD as getPageColumnRects, bE as findFootnoteReference, bF as FOOTNOTE_MARKER_GUTTER_PX, bG as resolveImporterForFile, bH as getDocumentSectionsCanonical, bI as getDocumentParagraphsCanonical, bJ as getDocumentParagraphs, bK as getDocumentPageSettings, bL as getTableCellContentWidthForParagraph, bM as layoutMetricsEpoch, bN as bumpLayoutMetricsEpoch, bO as createCanvasLayoutSnapshotProvider, bP as on, bQ as debounce, bR as unwrap, bS as perfTimer, bT as getRunTextBox, bU as createEditorDocument, bV as resolveResizedDimensions, bW as resolveTextBoxRenderHeight, bX as getToolbarStyleState, bY as getCachedCanvasImage, bZ as measureParagraphMinContentWidthPx, b_ as getEditableBlocksForZone, b$ as findParagraphLocation, c0 as createSectionBoundaryParagraph, c1 as normalizePageSettings, c2 as DEFAULT_EDITOR_PAGE_SETTINGS, c3 as markStart, c4 as markEnd, c5 as getParagraphEntries, c6 as getParagraphById, c7 as createEditorFootnote, c8 as createFootnoteReferenceRun, c9 as renumberFootnotes, ca as getHeadingLevel, cb as preciseFontModeVersion, cc as isPreciseFontModeEnabled, cd as resolveNamedTextStyle, ce as togglePreciseFontMode, cf as nextFontSizePt, cg as previousFontSizePt, ch as fontSizePtToPx, ci as createDefaultToolbarPreset, cj as MenuRegistry, ck as createToolbarRegistry, cl as Editor, cm as resolveCommandRef, cn as commandRefName, co as createOasisEditorClient, cp as createEditorZoom, cq as startLongTaskObserver, cr as installGlobalReport, cs as applyStoredPreciseFontPreference, ct as getWelcomeSeen, cu as isLocalFontAccessSupported, cv as EDITOR_SCROLL_PADDING_PX, cw as Toolbar, cx as OasisEditorLoading, cy as I18nProvider, cz as createTranslator, cA as createEditorLogger, cB as registerDomStatsSurface } from "./index-Cq3YFYX2.js";
5
5
  function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
6
6
  const {
7
7
  pageIndex,
@@ -36835,54 +36835,6 @@ function resolveFragmentBounds(line, fragment, fontSizePx) {
36835
36835
  right: (nextSlot == null ? void 0 : nextSlot.left) ?? last.left + fontSizePx * 0.55
36836
36836
  };
36837
36837
  }
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
36838
  function fragmentRectPt(line, fragment, styles, originX, originY, yOffset, heightShrink) {
36887
36839
  const bounds = resolveFragmentBounds(line, fragment, styles.fontSize ?? DEFAULT_FONT_SIZE_PX);
36888
36840
  if (!bounds) return null;
@@ -36905,141 +36857,42 @@ function drawFragmentShading(writer, pageIndex, line, fragment, originX, originY
36905
36857
  if (!rect) return;
36906
36858
  writer.drawRect(pageIndex, { ...rect, fill: styles.shading });
36907
36859
  }
36860
+ function drawFragmentBorder(writer, pageIndex, line, fragment, originX, originY, styles) {
36861
+ const border = styles.textBorder;
36862
+ if (!border || border.type === "none" || border.width <= 0) return;
36863
+ const rect = fragmentRectPt(line, fragment, styles, originX, originY, 1, 2);
36864
+ if (!rect) return;
36865
+ writer.drawRect(pageIndex, {
36866
+ ...rect,
36867
+ stroke: border.color,
36868
+ lineWidth: pxToPt$1(Math.max(0.5, border.width * PX_PER_POINT))
36869
+ });
36870
+ }
36908
36871
  function resolveGradientShadingName(writer, pageIndex, line, fragment, originX, originY, styles) {
36909
36872
  const fill = styles.textFill;
36910
- if (!fill || fill.type !== "gradient" || fill.stops.length < 2) {
36911
- return void 0;
36912
- }
36873
+ if (!fill || fill.type !== "gradient" || fill.stops.length < 2) return void 0;
36913
36874
  const bounds = resolveFragmentBounds(
36914
36875
  line,
36915
36876
  fragment,
36916
36877
  styles.fontSize ?? DEFAULT_FONT_SIZE_PX
36917
36878
  );
36918
- if (!bounds) {
36919
- return void 0;
36920
- }
36879
+ if (!bounds) return void 0;
36921
36880
  const x0px = originX + bounds.left;
36922
36881
  const x1px = originX + bounds.right;
36923
36882
  const y0px = originY + line.top;
36924
36883
  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;
36884
+ const axis = resolveGradientAxis(x0px, y0px, x1px, y1px, fill.angle ?? 0);
36930
36885
  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),
36886
+ x0: pxToPt$1(axis.x0),
36887
+ y0: pxToPt$1(axis.y0),
36888
+ x1: pxToPt$1(axis.x1),
36889
+ y1: pxToPt$1(axis.y1),
36935
36890
  stops: fill.stops.map((stop) => ({
36936
36891
  offset: stop.position,
36937
36892
  color: stop.color
36938
36893
  }))
36939
36894
  }) ?? void 0;
36940
36895
  }
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
36896
  function drawUnderlineWithStyle(writer, pageIndex, x1, x2, y, stroke, underlineStyle) {
37044
36897
  const lineWidthPx = underlineStyleLineWidthPx(underlineStyle);
37045
36898
  const drawAt = (yy, dash) => {
@@ -37054,8 +36907,8 @@ function drawUnderlineWithStyle(writer, pageIndex, x1, x2, y, stroke, underlineS
37054
36907
  });
37055
36908
  };
37056
36909
  if (isDoubleUnderlineStyle(underlineStyle)) {
37057
- drawAt(y - 1.5);
37058
- drawAt(y + 1.5);
36910
+ drawAt(y - DOUBLE_UNDERLINE_OFFSET_PX);
36911
+ drawAt(y + DOUBLE_UNDERLINE_OFFSET_PX);
37059
36912
  return;
37060
36913
  }
37061
36914
  if (isWavyUnderlineStyle(underlineStyle)) {
@@ -37082,72 +36935,46 @@ function drawWavyUnderline(writer, pageIndex, x1, x2, y, stroke, lineWidthPx) {
37082
36935
  prevY = curY;
37083
36936
  }
37084
36937
  }
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);
37116
- }
37117
- return chunks;
37118
- }
37119
- function resolveTabLeader(paragraph, line, tabLeft, document2) {
37120
- var _a2;
37121
- const paragraphStyle = resolveEffectiveParagraphStyle(
37122
- paragraph.style,
37123
- document2.styles
37124
- );
37125
- const tabs = paragraphStyle.tabs ?? [];
37126
- if (tabs.length === 0) {
37127
- return void 0;
36938
+ function drawFragmentEmphasis(writer, pageIndex, line, fragment, originX, originY, styles) {
36939
+ const mark = styles.emphasisMark;
36940
+ if (!mark || mark === "none") return;
36941
+ const glyph = EMPHASIS_GLYPH[mark];
36942
+ if (!glyph) return;
36943
+ const slots = resolveFragmentSlots(line, fragment);
36944
+ const below = mark === "underDot";
36945
+ const size = Math.max(4, line.height * 0.35);
36946
+ const y = below ? originY + line.top + line.height + size : originY + line.top + size;
36947
+ for (let i = 0; i < slots.length; i += 1) {
36948
+ const slot = slots[i];
36949
+ if (slot.char === " " || slot.char === " " || slot.char === "\n") continue;
36950
+ const next = slots[i + 1];
36951
+ const centerX = next ? (slot.left + next.left) / 2 : slot.left + line.height * 0.25;
36952
+ writer.drawText(pageIndex, {
36953
+ x: pxToPt$1(originX + centerX - size * 0.25),
36954
+ y: pxToPt$1(y),
36955
+ text: glyph,
36956
+ fontSize: pxToPt$1(size),
36957
+ color: styles.color ?? "#000000"
36958
+ });
37128
36959
  }
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
36960
  }
37134
36961
  function drawTabLeaders(writer, pageIndex, paragraph, line, fragment, document2, originX, baselineY, color) {
36962
+ var _a2;
37135
36963
  const slotByOffset = new Map(
37136
36964
  line.slots.map((slot) => [slot.offset, slot])
37137
36965
  );
36966
+ const paragraphStyle = resolveEffectiveParagraphStyle(paragraph.style, document2.styles);
36967
+ const tabs = paragraphStyle.tabs ?? [];
37138
36968
  for (const char of fragment.chars) {
37139
- if (char.char !== " ") {
37140
- continue;
37141
- }
36969
+ if (char.char !== " ") continue;
37142
36970
  const slot = slotByOffset.get(char.paragraphOffset);
37143
36971
  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
- }
36972
+ if (!slot || !nextSlot) continue;
36973
+ const lineStart = ((_a2 = line.slots[0]) == null ? void 0 : _a2.left) ?? 0;
36974
+ const relativeLeft = slot.left - lineStart;
36975
+ 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];
36976
+ const leader = (stop == null ? void 0 : stop.leader) && stop.leader !== "none" ? stop.leader : void 0;
36977
+ if (!leader) continue;
37151
36978
  const y = leader === "underscore" ? baselineY + 2 : baselineY;
37152
36979
  writer.drawLine(pageIndex, {
37153
36980
  x1: pxToPt$1(originX + slot.left),
@@ -37160,24 +36987,14 @@ function drawTabLeaders(writer, pageIndex, paragraph, line, fragment, document2,
37160
36987
  });
37161
36988
  }
37162
36989
  }
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
36990
+ function blendColorWithWhite(hex, alpha) {
36991
+ const rgb = parseHexColorToRgb255(hex);
36992
+ if (!rgb) return hex;
36993
+ const a = Math.max(0, Math.min(1, alpha));
36994
+ return rgb255ToHex(
36995
+ 255 + (rgb[0] - 255) * a,
36996
+ 255 + (rgb[1] - 255) * a,
36997
+ 255 + (rgb[2] - 255) * a
37181
36998
  );
37182
36999
  }
37183
37000
  function emitTextChunk(ctx, leftPx, text) {
@@ -37265,35 +37082,126 @@ function emitTextChunk(ctx, leftPx, text) {
37265
37082
  y: pxToPt$1(baselineY),
37266
37083
  text,
37267
37084
  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
- ...gradientShadingName ? { gradientShadingName } : textOutline ? {
37271
- renderMode: 2,
37272
- strokeColor: textOutline.color ?? mainColor,
37273
- strokeWidth: textOutline.widthPt
37274
- } : { renderMode: styles.outline ? 1 : 0 }
37085
+ ...gradientShadingName ? { gradientShadingName } : textOutline ? { renderMode: 2, strokeColor: textOutline.color ?? mainColor, strokeWidth: textOutline.widthPt } : { renderMode: styles.outline ? 1 : 0 }
37275
37086
  });
37276
37087
  }
37277
- async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, document2, originX, originY, fontRegistry, drawers) {
37278
- var _a2, _b2, _c;
37279
- if (fragment.image) {
37280
- if (fragment.image.floating) {
37281
- return;
37088
+ function groupSlotChunksByWhitespace(chars) {
37089
+ const chunks = [];
37090
+ let current = [];
37091
+ for (const char of chars) {
37092
+ if (char.char === " ") {
37093
+ if (current.length > 0) {
37094
+ chunks.push(current);
37095
+ current = [];
37096
+ }
37097
+ continue;
37282
37098
  }
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;
37099
+ current.push(char);
37100
+ }
37101
+ if (current.length > 0) chunks.push(current);
37102
+ return chunks;
37103
+ }
37104
+ function groupSlotChunksByOffsetGaps(chars) {
37105
+ const chunks = [];
37106
+ let current = [];
37107
+ for (const char of chars) {
37108
+ const previous = current[current.length - 1];
37109
+ if (previous && char.offset > previous.offset + 1) {
37110
+ chunks.push(current);
37111
+ current = [];
37288
37112
  }
37289
- const resourceName = await registerPdfImageRun(
37290
- writer,
37291
- document2,
37292
- fragment.image
37293
- );
37294
- if (!resourceName) {
37295
- return;
37113
+ current.push(char);
37114
+ }
37115
+ if (current.length > 0) chunks.push(current);
37116
+ return chunks;
37117
+ }
37118
+ async function drawFloatingImagesForParagraph(options) {
37119
+ for (const line of options.lines) {
37120
+ const slots = new Map(line.slots.map((slot) => [slot.offset, slot]));
37121
+ for (const fragment of line.fragments) {
37122
+ const image = fragment.image;
37123
+ if (!(image == null ? void 0 : image.floating)) continue;
37124
+ const isBehind = Boolean(image.floating.behindDoc);
37125
+ if (options.layer === "behind" !== isBehind) continue;
37126
+ const slot = slots.get(fragment.startOffset);
37127
+ const rect = resolveFloatingObjectRect({
37128
+ object: getImageFloatingGeometry(image),
37129
+ pageSettings: options.pageSettings,
37130
+ contentLeft: options.contentLeft,
37131
+ contentTop: options.contentTop,
37132
+ contentWidth: options.contentWidth,
37133
+ paragraphTop: options.paragraphTop,
37134
+ lineTop: options.paragraphTop + line.top,
37135
+ anchorLeft: options.contentLeft + ((slot == null ? void 0 : slot.left) ?? 0)
37136
+ });
37137
+ const resourceName = await registerPdfImageRun(
37138
+ options.writer,
37139
+ options.document,
37140
+ image
37141
+ );
37142
+ if (!resourceName) continue;
37143
+ options.writer.drawImage(options.pageIndex, {
37144
+ resourceName,
37145
+ x: pxToPt$1(rect.x),
37146
+ y: pxToPt$1(rect.y),
37147
+ width: pxToPt$1(rect.width),
37148
+ height: pxToPt$1(rect.height),
37149
+ rotation: image.rotation
37150
+ });
37296
37151
  }
37152
+ }
37153
+ }
37154
+ function drawFragmentDecoration(writer, pageIndex, line, fragment, originX, originY, styles, kind) {
37155
+ const bounds = resolveFragmentBounds(
37156
+ line,
37157
+ fragment,
37158
+ styles.fontSize ?? DEFAULT_FONT_SIZE_PX
37159
+ );
37160
+ if (!bounds) return;
37161
+ const y = originY + resolveDecorationLineY(kind, line.top, line.height);
37162
+ const x1 = originX + bounds.left;
37163
+ const x2 = originX + bounds.right;
37164
+ const stroke = kind === "underline" ? styles.underlineColor ?? styles.color ?? "#000000" : styles.color ?? "#000000";
37165
+ if (kind === "strike") {
37166
+ writer.drawLine(pageIndex, {
37167
+ x1: pxToPt$1(x1),
37168
+ y1: pxToPt$1(y),
37169
+ x2: pxToPt$1(x2),
37170
+ y2: pxToPt$1(y),
37171
+ stroke,
37172
+ lineWidth: pxToPt$1(1)
37173
+ });
37174
+ return;
37175
+ }
37176
+ if (kind === "doubleStrike") {
37177
+ writer.drawLine(pageIndex, {
37178
+ x1: pxToPt$1(x1),
37179
+ y1: pxToPt$1(y - DOUBLE_STRIKE_OFFSET_PX),
37180
+ x2: pxToPt$1(x2),
37181
+ y2: pxToPt$1(y - DOUBLE_STRIKE_OFFSET_PX),
37182
+ stroke,
37183
+ lineWidth: pxToPt$1(1)
37184
+ });
37185
+ writer.drawLine(pageIndex, {
37186
+ x1: pxToPt$1(x1),
37187
+ y1: pxToPt$1(y + DOUBLE_STRIKE_OFFSET_PX),
37188
+ x2: pxToPt$1(x2),
37189
+ y2: pxToPt$1(y + DOUBLE_STRIKE_OFFSET_PX),
37190
+ stroke,
37191
+ lineWidth: pxToPt$1(1)
37192
+ });
37193
+ return;
37194
+ }
37195
+ drawUnderlineWithStyle(writer, pageIndex, x1, x2, y, stroke, styles.underlineStyle);
37196
+ }
37197
+ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, document2, originX, originY, fontRegistry, drawers) {
37198
+ var _a2, _b2, _c;
37199
+ if (fragment.image) {
37200
+ if (fragment.image.floating) return;
37201
+ const slot = line.slots.find((c) => c.offset === fragment.startOffset) ?? line.slots.find((c) => c.offset >= fragment.startOffset);
37202
+ if (!slot) return;
37203
+ const resourceName = await registerPdfImageRun(writer, document2, fragment.image);
37204
+ if (!resourceName) return;
37297
37205
  writer.drawImage(pageIndex, {
37298
37206
  resourceName,
37299
37207
  x: pxToPt$1(originX + slot.left),
@@ -37305,15 +37213,17 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37305
37213
  return;
37306
37214
  }
37307
37215
  if (fragment.textBox) {
37308
- await drawInlineTextBoxFragment(
37216
+ if (fragment.textBox.floating) return;
37217
+ const slot = line.slots.find((c) => c.offset === fragment.startOffset) ?? line.slots.find((c) => c.offset >= fragment.startOffset);
37218
+ if (!slot) return;
37219
+ await paintTextBox(
37309
37220
  writer,
37310
- pageIndex,
37311
- line,
37312
- fragment,
37313
- document2,
37314
- originX,
37315
- originY,
37316
- fontRegistry,
37221
+ fragment.textBox,
37222
+ { document: document2, fontRegistry, pageIndex },
37223
+ originX + slot.left,
37224
+ originY + line.top + line.height - fragment.textBox.height,
37225
+ fragment.textBox.width,
37226
+ fragment.textBox.height,
37317
37227
  drawers
37318
37228
  );
37319
37229
  return;
@@ -37323,9 +37233,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37323
37233
  (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
37324
37234
  document2.styles
37325
37235
  );
37326
- if (styles.hidden) {
37327
- return;
37328
- }
37236
+ if (styles.hidden) return;
37329
37237
  const fontFace = fontRegistry.resolveFontFace({
37330
37238
  fontFamily: styles.fontFamily,
37331
37239
  bold: styles.bold,
@@ -37337,9 +37245,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37337
37245
  const chars = resolveFragmentSlots(line, fragment);
37338
37246
  const text = chars.map((char) => styles.allCaps ? char.char.toUpperCase() : char.char).join("");
37339
37247
  const firstChar = chars[0];
37340
- if (!firstChar || text.length === 0) {
37341
- return;
37342
- }
37248
+ if (!firstChar || text.length === 0) return;
37343
37249
  if (styles.link) {
37344
37250
  const linkBounds = resolveFragmentBounds(
37345
37251
  line,
@@ -37357,49 +37263,12 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37357
37263
  });
37358
37264
  }
37359
37265
  }
37360
- drawFragmentShading(
37361
- writer,
37362
- pageIndex,
37363
- line,
37364
- fragment,
37365
- originX,
37366
- originY,
37367
- styles
37368
- );
37369
- drawFragmentHighlight(
37370
- writer,
37371
- pageIndex,
37372
- line,
37373
- fragment,
37374
- originX,
37375
- originY,
37376
- styles
37377
- );
37378
- drawFragmentBorder(
37379
- writer,
37380
- pageIndex,
37381
- line,
37382
- fragment,
37383
- originX,
37384
- originY,
37385
- styles
37386
- );
37387
- drawTabLeaders(
37388
- writer,
37389
- pageIndex,
37390
- paragraph,
37391
- line,
37392
- fragment,
37393
- document2,
37394
- originX,
37395
- baselineY,
37396
- styles.color ?? "#000000"
37397
- );
37266
+ drawFragmentShading(writer, pageIndex, line, fragment, originX, originY, styles);
37267
+ drawFragmentHighlight(writer, pageIndex, line, fragment, originX, originY, styles);
37268
+ drawFragmentBorder(writer, pageIndex, line, fragment, originX, originY, styles);
37269
+ drawTabLeaders(writer, pageIndex, paragraph, line, fragment, document2, originX, baselineY, styles.color ?? "#000000");
37398
37270
  const paragraphAlign = resolveEffectiveParagraphStyle(paragraph.style, document2.styles).align ?? "left";
37399
- const fontFeatures = resolveOpenTypeFeatureTags(
37400
- styles,
37401
- textStyleToFontSizePt(styles)
37402
- );
37271
+ const fontFeatures = resolveOpenTypeFeatureTags(styles, textStyleToFontSizePt(styles));
37403
37272
  const baseTextOptions = {
37404
37273
  fontSize: fontSizePt,
37405
37274
  bold: styles.bold,
@@ -37437,56 +37306,19 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37437
37306
  }
37438
37307
  if (line.trailingHyphen && fragment.endOffset >= line.endOffset) {
37439
37308
  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
- }
37309
+ if (endSlot) emitTextChunk(chunkCtx, originX + endSlot.left, "-");
37443
37310
  }
37444
37311
  if (styles.underline) {
37445
- drawFragmentDecoration(
37446
- writer,
37447
- pageIndex,
37448
- line,
37449
- fragment,
37450
- originX,
37451
- originY,
37452
- styles,
37453
- "underline"
37454
- );
37312
+ drawFragmentDecoration(writer, pageIndex, line, fragment, originX, originY, styles, "underline");
37455
37313
  }
37456
37314
  if (styles.strike) {
37457
- drawFragmentDecoration(
37458
- writer,
37459
- pageIndex,
37460
- line,
37461
- fragment,
37462
- originX,
37463
- originY,
37464
- styles,
37465
- "strike"
37466
- );
37315
+ drawFragmentDecoration(writer, pageIndex, line, fragment, originX, originY, styles, "strike");
37467
37316
  }
37468
37317
  if (styles.doubleStrike) {
37469
- drawFragmentDecoration(
37470
- writer,
37471
- pageIndex,
37472
- line,
37473
- fragment,
37474
- originX,
37475
- originY,
37476
- styles,
37477
- "doubleStrike"
37478
- );
37318
+ drawFragmentDecoration(writer, pageIndex, line, fragment, originX, originY, styles, "doubleStrike");
37479
37319
  }
37480
37320
  if (styles.emphasisMark) {
37481
- drawFragmentEmphasis(
37482
- writer,
37483
- pageIndex,
37484
- line,
37485
- fragment,
37486
- originX,
37487
- originY,
37488
- styles
37489
- );
37321
+ drawFragmentEmphasis(writer, pageIndex, line, fragment, originX, originY, styles);
37490
37322
  }
37491
37323
  }
37492
37324
  function getListOrdinals(document2) {