oasis-editor 0.0.113 → 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 (31) hide show
  1. package/dist/{OasisEditorApp-BKPrQtm5.js → OasisEditorApp-C1dyjJoH.js} +903 -1161
  2. package/dist/assets/{importDocxWorker-Bz2kZOBO.js → importDocxWorker-D0F0jbcF.js} +1 -1
  3. package/dist/core/decorationGeometry.d.ts +10 -0
  4. package/dist/core/gradientAxis.d.ts +11 -0
  5. package/dist/core/textStyleMappings.d.ts +4 -0
  6. package/dist/export/pdf/draw/drawFragment.d.ts +4 -4
  7. package/dist/export/pdf/draw/fragment/pdfColor.d.ts +1 -0
  8. package/dist/export/pdf/draw/fragment/pdfEmphasisAndTabLeaders.d.ts +5 -0
  9. package/dist/export/pdf/draw/fragment/pdfGradient.d.ts +4 -0
  10. package/dist/export/pdf/draw/fragment/pdfRunBackground.d.ts +12 -0
  11. package/dist/export/pdf/draw/fragment/pdfTextChunks.d.ts +25 -0
  12. package/dist/export/pdf/draw/fragment/pdfTextDecoration.d.ts +4 -0
  13. package/dist/{index-DSDwe-yy.js → index-Cq3YFYX2.js} +1007 -1001
  14. package/dist/oasis-editor.js +50 -50
  15. package/dist/oasis-editor.umd.cjs +4 -4
  16. package/dist/text/fonts/opentype/otLayoutCommon.d.ts +6 -0
  17. package/dist/ui/canvas/CanvasTableLayout.d.ts +12 -63
  18. package/dist/ui/canvas/canvasBorders.d.ts +1 -0
  19. package/dist/ui/canvas/canvasParagraphPainter.d.ts +4 -22
  20. package/dist/ui/canvas/paragraph/canvasEmphasis.d.ts +3 -0
  21. package/dist/ui/canvas/paragraph/canvasInlineImage.d.ts +26 -0
  22. package/dist/ui/canvas/paragraph/canvasRunBackground.d.ts +13 -0
  23. package/dist/ui/canvas/paragraph/canvasTabLeaders.d.ts +4 -0
  24. package/dist/ui/canvas/paragraph/canvasTextDecoration.d.ts +4 -0
  25. package/dist/ui/canvas/paragraph/canvasTextEffects.d.ts +43 -0
  26. package/dist/ui/canvas/table/assembleCellEntries.d.ts +15 -0
  27. package/dist/ui/canvas/table/prepareCells.d.ts +53 -0
  28. package/dist/ui/canvas/table/resolveRowHeights.d.ts +9 -0
  29. package/dist/ui/canvas/table/tableCellGeometry.d.ts +37 -0
  30. package/dist/ui/canvas/table/types.d.ts +63 -0
  31. 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 onMount, au as onCleanup, av as PluginUiHost, aw as OasisEditorEditor, ax as OasisBrandMark, ay as setPreciseFontPreference, az as setWelcomeSeen, aA as enablePreciseFontMode, aB as TWIPS_PER_POINT, aC as PX_PER_INCH, aD as TWIPS_PER_INCH, aE as normalizeHex6, aF as TABLE_CONDITIONAL_FLAG_ATTRIBUTES, aG as TABLE_BORDER_EDGE_KEYS, aH as resolveEffectiveParagraphStyle, aI as resolveEffectiveTextStyleForParagraph, aJ as EMU_PER_PT, aK as OOXML_ROTATION_UNITS, aL as OOXML_PERCENT_DENOMINATOR, aM as parseHexColorToRgb255, aN as EMU_PER_PX, aO as getRunFootnoteReference, aP as getRunEndnoteReference, aQ as iterateFootnoteReferenceRuns, aR as iterateEndnoteReferenceRuns, aS as imageContentTypeDefaults, aT as getRunFieldChar, aU as getRunFieldInstruction, aV as createEditorRun, aW as JSZip, aX as imageExtensionFromMime, aY as pxToPt$1, aZ as resolveFloatingObjectRect, a_ as getTextBoxFloatingGeometry, a$ as getPresetPathSegments, b0 as buildListLabels, b1 as getImageFloatingGeometry, b2 as textStyleToFontSizePt, b3 as PX_PER_POINT, b4 as DEFAULT_FONT_SIZE_PX, b5 as resolveOpenTypeFeatureTags, b6 as rgb255ToHex, b7 as isDoubleUnderlineStyle, b8 as isWavyUnderlineStyle, b9 as underlineStyleLineWidthPx, ba as underlineStyleDashArray, bb as resolveListLabel, bc as getListLabelInset, bd as getAlignedListLabelInset, be as getParagraphBorderInsets, bf as buildSegmentTable, bg as buildCanvasTableLayout, bh as resolveCanvasTableWidth, bi as resolveFloatingTableRect, bj as normalizeFamily, bk as ROBOTO_FONT_FILES, bl as loadFontAsset, bm as OFFICE_COMPAT_FONT_FAMILIES, bn as BinaryReader, bo as buildSfnt, bp as defaultFontDecoderRegistry, bq as SfntFontProgram, br as collectPdfFontFamilies, bs as outlineFrom, bt as getPageHeaderZoneTop, bu as getPageColumnRects, bv as findFootnoteReference, bw as FOOTNOTE_MARKER_GUTTER_PX, bx as resolveImporterForFile, by as getDocumentSectionsCanonical, bz as getDocumentParagraphsCanonical, bA as getDocumentParagraphs, bB as getDocumentPageSettings, bC as getTableCellContentWidthForParagraph, bD as layoutMetricsEpoch, bE as bumpLayoutMetricsEpoch, bF as createCanvasLayoutSnapshotProvider, bG as on, bH as debounce, bI as unwrap, bJ as perfTimer, bK as getRunTextBox, bL as createEditorDocument, bM as resolveResizedDimensions, bN as resolveTextBoxRenderHeight, bO as getToolbarStyleState, bP as getCachedCanvasImage, bQ as measureParagraphMinContentWidthPx, bR as getEditableBlocksForZone, bS as findParagraphLocation, bT as createSectionBoundaryParagraph, bU as normalizePageSettings, bV as DEFAULT_EDITOR_PAGE_SETTINGS, bW as markStart, bX as markEnd, bY as getParagraphEntries, bZ as getParagraphById, b_ as createEditorFootnote, b$ as createFootnoteReferenceRun, c0 as renumberFootnotes, c1 as getHeadingLevel, c2 as preciseFontModeVersion, c3 as isPreciseFontModeEnabled, c4 as resolveNamedTextStyle, c5 as togglePreciseFontMode, c6 as nextFontSizePt, c7 as previousFontSizePt, c8 as fontSizePtToPx, c9 as createDefaultToolbarPreset, ca as MenuRegistry, cb as createToolbarRegistry, cc as Editor, cd as resolveCommandRef, ce as commandRefName, cf as createOasisEditorClient, cg as createEditorZoom, ch as startLongTaskObserver, ci as installGlobalReport, cj as applyStoredPreciseFontPreference, ck as getWelcomeSeen, cl as isLocalFontAccessSupported, cm as EDITOR_SCROLL_PADDING_PX, cn as Toolbar, co as OasisEditorLoading, cp as I18nProvider, cq as createTranslator, cr as createEditorLogger, cs as registerDomStatsSurface } from "./index-DSDwe-yy.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,
@@ -32449,194 +32449,400 @@ function resolveBorder(style2, widthValue, colorValue) {
32449
32449
  color: colorValue.trim() || DEFAULT_BORDER_COLOR
32450
32450
  };
32451
32451
  }
32452
- function TablePropertiesDialog(props) {
32452
+ function numericInput(label, value, setter, testId, disabled = false, allowNegative = false) {
32453
+ return (() => {
32454
+ var _el$ = _tmpl$$5(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling;
32455
+ insert(_el$2, label);
32456
+ _el$3.$$input = (e) => setter(e.currentTarget.value);
32457
+ setAttribute(_el$3, "min", allowNegative ? void 0 : "0");
32458
+ _el$3.disabled = disabled;
32459
+ setAttribute(_el$3, "data-testid", testId);
32460
+ createRenderEffect(() => _el$3.value = value());
32461
+ return _el$;
32462
+ })();
32463
+ }
32464
+ function checkbox(label, checked, setter, testId, disabled = false) {
32465
+ return (() => {
32466
+ var _el$4 = _tmpl$2$1(), _el$5 = _el$4.firstChild;
32467
+ _el$5.addEventListener("change", (e) => setter(e.currentTarget.checked));
32468
+ _el$5.disabled = disabled;
32469
+ setAttribute(_el$5, "data-testid", testId);
32470
+ insert(_el$4, label, null);
32471
+ createRenderEffect(() => _el$5.checked = checked());
32472
+ return _el$4;
32473
+ })();
32474
+ }
32475
+ function TableTabPanel(p) {
32476
+ const t = useI18n();
32477
+ return (() => {
32478
+ var _el$6 = _tmpl$6$1(), _el$7 = _el$6.firstChild, _el$8 = _el$7.firstChild, _el$9 = _el$8.nextSibling, _el$0 = _el$9.firstChild, _el$1 = _el$0.firstChild, _el$10 = _el$1.nextSibling, _el$11 = _el$10.firstChild, _el$12 = _el$11.nextSibling, _el$13 = _el$7.nextSibling, _el$14 = _el$13.firstChild, _el$15 = _el$14.nextSibling, _el$16 = _el$15.nextSibling, _el$17 = _el$13.nextSibling, _el$18 = _el$17.firstChild, _el$19 = _el$18.nextSibling;
32479
+ insert(_el$8, () => t("table.sizeSection"));
32480
+ insert(_el$9, () => numericInput(t("table.preferredWidth"), () => p.form.tableWidth, (v) => p.set("tableWidth", v), "editor-table-properties-table-width"), _el$0);
32481
+ insert(_el$1, () => t("table.measureIn"));
32482
+ _el$10.addEventListener("change", (e) => p.set("tableWidthUnit", e.currentTarget.value));
32483
+ insert(_el$11, () => t("table.points"));
32484
+ insert(_el$12, () => t("table.percent"));
32485
+ insert(_el$14, () => t("table.alignmentSection"));
32486
+ insert(_el$15, () => ["left", "center", "right"].map((align) => (() => {
32487
+ var _el$43 = _tmpl$7(), _el$44 = _el$43.firstChild;
32488
+ _el$44.addEventListener("change", () => p.set("tableAlign", align));
32489
+ setAttribute(_el$44, "data-testid", `editor-table-properties-align-${align}`);
32490
+ insert(_el$43, () => t(`table.align${align[0].toUpperCase()}${align.slice(1)}`), null);
32491
+ createRenderEffect(() => _el$44.checked = p.form.tableAlign === align);
32492
+ return _el$43;
32493
+ })()));
32494
+ insert(_el$16, () => numericInput(t("table.indentFromLeft"), () => p.form.tableIndentLeft, (v) => p.set("tableIndentLeft", v), "editor-table-properties-indent-left"));
32495
+ insert(_el$18, () => t("table.textWrappingSection"));
32496
+ insert(_el$19, () => checkbox(t("table.wrapNone"), () => p.form.tableWrapping === "none", () => p.set("tableWrapping", "none"), "editor-table-properties-wrap-none"), null);
32497
+ insert(_el$19, () => checkbox(t("table.wrapAround"), () => p.form.tableWrapping === "around", () => p.set("tableWrapping", "around"), "editor-table-properties-wrap-around"), null);
32498
+ insert(_el$17, createComponent(Show, {
32499
+ get when() {
32500
+ return p.form.tableWrapping === "around";
32501
+ },
32502
+ get children() {
32503
+ return [(() => {
32504
+ var _el$20 = _tmpl$3$1(), _el$21 = _el$20.firstChild, _el$22 = _el$21.firstChild, _el$23 = _el$22.nextSibling, _el$24 = _el$23.firstChild, _el$25 = _el$24.nextSibling, _el$26 = _el$25.nextSibling, _el$27 = _el$21.nextSibling, _el$28 = _el$27.firstChild, _el$29 = _el$28.nextSibling, _el$30 = _el$29.firstChild, _el$31 = _el$30.nextSibling, _el$32 = _el$31.nextSibling;
32505
+ insert(_el$22, () => t("table.horizontalAnchor"));
32506
+ _el$23.addEventListener("change", (e) => p.set("floatingHorizontalAnchor", e.currentTarget.value));
32507
+ insert(_el$24, () => t("table.anchorMargin"));
32508
+ insert(_el$25, () => t("table.anchorPage"));
32509
+ insert(_el$26, () => t("table.anchorText"));
32510
+ insert(_el$28, () => t("table.verticalAnchor"));
32511
+ _el$29.addEventListener("change", (e) => p.set("floatingVerticalAnchor", e.currentTarget.value));
32512
+ insert(_el$30, () => t("table.anchorMargin"));
32513
+ insert(_el$31, () => t("table.anchorPage"));
32514
+ insert(_el$32, () => t("table.anchorText"));
32515
+ createRenderEffect(() => _el$23.value = p.form.floatingHorizontalAnchor);
32516
+ createRenderEffect(() => _el$29.value = p.form.floatingVerticalAnchor);
32517
+ return _el$20;
32518
+ })(), (() => {
32519
+ var _el$33 = _tmpl$4$1(), _el$34 = _el$33.firstChild, _el$35 = _el$34.firstChild, _el$36 = _el$35.nextSibling, _el$37 = _el$36.firstChild, _el$38 = _el$34.nextSibling, _el$39 = _el$38.firstChild, _el$40 = _el$39.nextSibling, _el$41 = _el$40.firstChild;
32520
+ insert(_el$33, () => numericInput(t("table.positionX"), () => p.form.floatingX, (v) => p.set("floatingX", v), "editor-table-properties-floating-x", Boolean(p.form.floatingXAlign), true), _el$34);
32521
+ insert(_el$33, () => numericInput(t("table.positionY"), () => p.form.floatingY, (v) => p.set("floatingY", v), "editor-table-properties-floating-y", Boolean(p.form.floatingYAlign), true), _el$34);
32522
+ insert(_el$35, () => t("table.horizontalAlignment"));
32523
+ _el$36.addEventListener("change", (e) => p.set("floatingXAlign", e.currentTarget.value));
32524
+ insert(_el$37, () => t("table.explicitOffset"));
32525
+ insert(_el$36, () => ["left", "center", "right", "inside", "outside"].map((value) => (() => {
32526
+ var _el$45 = _tmpl$8();
32527
+ _el$45.value = value;
32528
+ insert(_el$45, value);
32529
+ return _el$45;
32530
+ })()), null);
32531
+ insert(_el$39, () => t("table.verticalAlignment"));
32532
+ _el$40.addEventListener("change", (e) => p.set("floatingYAlign", e.currentTarget.value));
32533
+ insert(_el$41, () => t("table.explicitOffset"));
32534
+ insert(_el$40, () => ["top", "center", "bottom", "inside", "outside"].map((value) => (() => {
32535
+ var _el$46 = _tmpl$8();
32536
+ _el$46.value = value;
32537
+ insert(_el$46, value);
32538
+ return _el$46;
32539
+ })()), null);
32540
+ createRenderEffect(() => _el$36.value = p.form.floatingXAlign);
32541
+ createRenderEffect(() => _el$40.value = p.form.floatingYAlign);
32542
+ return _el$33;
32543
+ })(), (() => {
32544
+ var _el$42 = _tmpl$5$1();
32545
+ insert(_el$42, () => numericInput(t("table.distanceTop"), () => p.form.floatingDistanceTop, (v) => p.set("floatingDistanceTop", v), "editor-table-properties-floating-distance-top"), null);
32546
+ insert(_el$42, () => numericInput(t("table.distanceRight"), () => p.form.floatingDistanceRight, (v) => p.set("floatingDistanceRight", v), "editor-table-properties-floating-distance-right"), null);
32547
+ insert(_el$42, () => numericInput(t("table.distanceBottom"), () => p.form.floatingDistanceBottom, (v) => p.set("floatingDistanceBottom", v), "editor-table-properties-floating-distance-bottom"), null);
32548
+ insert(_el$42, () => numericInput(t("table.distanceLeft"), () => p.form.floatingDistanceLeft, (v) => p.set("floatingDistanceLeft", v), "editor-table-properties-floating-distance-left"), null);
32549
+ return _el$42;
32550
+ })(), memo(() => checkbox(t("table.allowOverlap"), () => p.form.floatingOverlap === "overlap", (value) => p.set("floatingOverlap", value ? "overlap" : "never"), "editor-table-properties-floating-overlap"))];
32551
+ }
32552
+ }), null);
32553
+ createRenderEffect(() => _el$10.value = p.form.tableWidthUnit);
32554
+ return _el$6;
32555
+ })();
32556
+ }
32557
+ function RowTabPanel(p) {
32558
+ const t = useI18n();
32559
+ return (() => {
32560
+ var _el$47 = _tmpl$9(), _el$48 = _el$47.firstChild, _el$49 = _el$48.firstChild, _el$50 = _el$49.firstChild, _el$51 = _el$50.nextSibling, _el$52 = _el$51.firstChild, _el$53 = _el$52.nextSibling, _el$54 = _el$53.nextSibling, _el$55 = _el$48.nextSibling;
32561
+ insert(_el$48, () => numericInput(t("table.rowHeight"), () => p.form.rowHeight, (v) => p.set("rowHeight", v), "editor-table-properties-row-height"), _el$49);
32562
+ insert(_el$50, () => t("table.rowHeightRule"));
32563
+ _el$51.addEventListener("change", (e) => p.set("rowHeightRule", e.currentTarget.value));
32564
+ insert(_el$52, () => t("table.rowAuto"));
32565
+ insert(_el$53, () => t("table.rowAtLeast"));
32566
+ insert(_el$54, () => t("table.rowExactly"));
32567
+ insert(_el$55, () => checkbox(t("table.repeatHeader"), () => p.form.repeatHeader, (v) => p.set("repeatHeader", v), "editor-table-properties-repeat-header"), null);
32568
+ insert(_el$55, () => checkbox(t("table.allowBreakAcrossPages"), () => p.form.allowBreakAcrossPages, (v) => p.set("allowBreakAcrossPages", v), "editor-table-properties-allow-break"), null);
32569
+ insert(_el$55, () => checkbox(t("table.hiddenRow"), () => p.form.hiddenRow, (v) => p.set("hiddenRow", v), "editor-table-properties-hidden-row"), null);
32570
+ createRenderEffect(() => _el$51.value = p.form.rowHeightRule);
32571
+ return _el$47;
32572
+ })();
32573
+ }
32574
+ function ColumnTabPanel(p) {
32575
+ const t = useI18n();
32576
+ return (() => {
32577
+ var _el$56 = _tmpl$0(), _el$57 = _el$56.firstChild;
32578
+ insert(_el$57, () => numericInput(t("table.columnWidth"), () => p.form.columnWidth, (v) => p.set("columnWidth", v), "editor-table-properties-column-width"));
32579
+ return _el$56;
32580
+ })();
32581
+ }
32582
+ function CellTabPanel(p) {
32453
32583
  const t = useI18n();
32454
- const [activeTab, setActiveTab] = createSignal("table");
32455
- const [tableWidth, setTableWidth] = createSignal("");
32456
- const [tableWidthUnit, setTableWidthUnit] = createSignal("points");
32457
- const [tableAlign, setTableAlign] = createSignal("");
32458
- const [tableIndentLeft, setTableIndentLeft] = createSignal("");
32459
- const [tableWrapping, setTableWrapping] = createSignal("none");
32460
- const [floatingHorizontalAnchor, setFloatingHorizontalAnchor] = createSignal("margin");
32461
- const [floatingVerticalAnchor, setFloatingVerticalAnchor] = createSignal("text");
32462
- const [floatingX, setFloatingX] = createSignal("");
32463
- const [floatingY, setFloatingY] = createSignal("");
32464
- const [floatingXAlign, setFloatingXAlign] = createSignal("");
32465
- const [floatingYAlign, setFloatingYAlign] = createSignal("");
32466
- const [floatingDistanceTop, setFloatingDistanceTop] = createSignal("");
32467
- const [floatingDistanceRight, setFloatingDistanceRight] = createSignal("");
32468
- const [floatingDistanceBottom, setFloatingDistanceBottom] = createSignal("");
32469
- const [floatingDistanceLeft, setFloatingDistanceLeft] = createSignal("");
32470
- const [floatingOverlap, setFloatingOverlap] = createSignal("overlap");
32471
- const [rowHeight, setRowHeight] = createSignal("");
32472
- const [rowHeightRule, setRowHeightRule] = createSignal("");
32473
- const [repeatHeader, setRepeatHeader] = createSignal(false);
32474
- const [allowBreakAcrossPages, setAllowBreakAcrossPages] = createSignal(true);
32475
- const [hiddenRow, setHiddenRow] = createSignal(false);
32476
- const [columnWidth, setColumnWidth] = createSignal("");
32477
- const [cellWidth, setCellWidth] = createSignal("");
32478
- const [cellVerticalAlign, setCellVerticalAlign] = createSignal("");
32479
- const [cellTextDirection, setCellTextDirection] = createSignal("");
32480
- const [cellNoWrap, setCellNoWrap] = createSignal(false);
32481
- const [cellFitText, setCellFitText] = createSignal(false);
32482
- const [cellHideMark, setCellHideMark] = createSignal(false);
32483
- const [marginTop, setMarginTop] = createSignal("");
32484
- const [marginRight, setMarginRight] = createSignal("");
32485
- const [marginBottom, setMarginBottom] = createSignal("");
32486
- const [marginLeft, setMarginLeft] = createSignal("");
32487
- const [borderStyle, setBorderStyle] = createSignal("none");
32488
- const [borderWidth, setBorderWidth] = createSignal("");
32489
- const [borderColor, setBorderColor] = createSignal("");
32490
- const [borderTop, setBorderTop] = createSignal(false);
32491
- const [borderRight, setBorderRight] = createSignal(false);
32492
- const [borderBottom, setBorderBottom] = createSignal(false);
32493
- const [borderLeft, setBorderLeft] = createSignal(false);
32494
- const [borderStart, setBorderStart] = createSignal(false);
32495
- const [borderEnd, setBorderEnd] = createSignal(false);
32496
- const [borderTlBr, setBorderTlBr] = createSignal(false);
32497
- const [borderTrBl, setBorderTrBl] = createSignal(false);
32498
- const [shading, setShading] = createSignal("");
32499
- const [altTitle, setAltTitle] = createSignal("");
32500
- const [altDescription, setAltDescription] = createSignal("");
32501
- createEffect(() => {
32502
- if (!props.isOpen) return;
32503
- setActiveTab(props.initial.activeTab ?? "table");
32504
- setTableWidth(props.initial.tableWidth);
32505
- setTableWidthUnit(props.initial.tableWidthUnit);
32506
- setTableAlign(props.initial.tableAlign);
32507
- setTableIndentLeft(props.initial.tableIndentLeft);
32508
- setTableWrapping(props.initial.tableWrapping);
32509
- setFloatingHorizontalAnchor(props.initial.floatingHorizontalAnchor);
32510
- setFloatingVerticalAnchor(props.initial.floatingVerticalAnchor);
32511
- setFloatingX(props.initial.floatingX);
32512
- setFloatingY(props.initial.floatingY);
32513
- setFloatingXAlign(props.initial.floatingXAlign);
32514
- setFloatingYAlign(props.initial.floatingYAlign);
32515
- setFloatingDistanceTop(props.initial.floatingDistanceTop);
32516
- setFloatingDistanceRight(props.initial.floatingDistanceRight);
32517
- setFloatingDistanceBottom(props.initial.floatingDistanceBottom);
32518
- setFloatingDistanceLeft(props.initial.floatingDistanceLeft);
32519
- setFloatingOverlap(props.initial.floatingOverlap);
32520
- setRowHeight(props.initial.rowHeight);
32521
- setRowHeightRule(props.initial.rowHeightRule);
32522
- setRepeatHeader(props.initial.repeatHeader);
32523
- setAllowBreakAcrossPages(props.initial.allowBreakAcrossPages);
32524
- setHiddenRow(props.initial.hiddenRow);
32525
- setColumnWidth(props.initial.columnWidth);
32526
- setCellWidth(props.initial.cellWidth);
32527
- setCellVerticalAlign(props.initial.cellVerticalAlign);
32528
- setCellTextDirection(props.initial.cellTextDirection);
32529
- setCellNoWrap(props.initial.cellNoWrap);
32530
- setCellFitText(props.initial.cellFitText);
32531
- setCellHideMark(props.initial.cellHideMark);
32532
- setMarginTop(props.initial.marginTop);
32533
- setMarginRight(props.initial.marginRight);
32534
- setMarginBottom(props.initial.marginBottom);
32535
- setMarginLeft(props.initial.marginLeft);
32536
- setBorderStyle(props.initial.borderStyle);
32537
- setBorderWidth(props.initial.borderWidth);
32538
- setBorderColor(props.initial.borderColor);
32539
- setBorderTop(props.initial.borderTop);
32540
- setBorderRight(props.initial.borderRight);
32541
- setBorderBottom(props.initial.borderBottom);
32542
- setBorderLeft(props.initial.borderLeft);
32543
- setBorderStart(props.initial.borderStart);
32544
- setBorderEnd(props.initial.borderEnd);
32545
- setBorderTlBr(props.initial.borderTopLeftToBottomRight);
32546
- setBorderTrBl(props.initial.borderTopRightToBottomLeft);
32547
- setShading(props.initial.shading);
32548
- setAltTitle(props.initial.altTitle);
32549
- setAltDescription(props.initial.altDescription);
32550
- });
32551
32584
  const borderPreview = createMemo(() => {
32552
- const border = resolveBorder(borderStyle(), borderWidth(), borderColor());
32585
+ const border = resolveBorder(p.form.borderStyle, p.form.borderWidth, p.form.borderColor);
32553
32586
  const css = border ? `${border.width}pt ${border.type} ${border.color}` : void 0;
32554
32587
  return {
32555
- "background-color": shading().trim() || void 0,
32556
- "border-top": css && borderTop() ? css : "1px solid #dadce0",
32557
- "border-right": css && borderRight() ? css : "1px solid #dadce0",
32558
- "border-bottom": css && borderBottom() ? css : "1px solid #dadce0",
32559
- "border-left": css && borderLeft() ? css : "1px solid #dadce0"
32588
+ "background-color": p.form.shading.trim() || void 0,
32589
+ "border-top": css && p.form.borderTop ? css : "1px solid #dadce0",
32590
+ "border-right": css && p.form.borderRight ? css : "1px solid #dadce0",
32591
+ "border-bottom": css && p.form.borderBottom ? css : "1px solid #dadce0",
32592
+ "border-left": css && p.form.borderLeft ? css : "1px solid #dadce0"
32560
32593
  };
32561
32594
  });
32595
+ return (() => {
32596
+ var _el$58 = _tmpl$1(), _el$59 = _el$58.firstChild, _el$60 = _el$59.firstChild, _el$61 = _el$60.firstChild, _el$62 = _el$61.nextSibling, _el$63 = _el$62.firstChild, _el$64 = _el$63.nextSibling, _el$65 = _el$64.nextSibling, _el$66 = _el$65.nextSibling, _el$67 = _el$60.nextSibling, _el$68 = _el$67.firstChild, _el$69 = _el$68.nextSibling, _el$70 = _el$69.firstChild, _el$71 = _el$59.nextSibling, _el$72 = _el$71.firstChild, _el$73 = _el$72.nextSibling, _el$74 = _el$71.nextSibling, _el$75 = _el$74.firstChild, _el$76 = _el$75.nextSibling, _el$77 = _el$74.nextSibling, _el$78 = _el$77.firstChild, _el$79 = _el$78.nextSibling, _el$80 = _el$79.firstChild, _el$81 = _el$80.firstChild, _el$82 = _el$81.nextSibling, _el$83 = _el$82.firstChild, _el$84 = _el$83.nextSibling, _el$85 = _el$84.nextSibling, _el$86 = _el$85.nextSibling, _el$87 = _el$80.nextSibling, _el$88 = _el$87.firstChild, _el$89 = _el$88.nextSibling, _el$90 = _el$87.nextSibling, _el$91 = _el$90.firstChild, _el$92 = _el$91.nextSibling, _el$93 = _el$79.nextSibling, _el$94 = _el$93.nextSibling;
32597
+ insert(_el$59, () => numericInput(t("table.cellWidth"), () => p.form.cellWidth, (v) => p.set("cellWidth", v), "editor-table-properties-cell-width"), _el$60);
32598
+ insert(_el$61, () => t("table.verticalAlignment"));
32599
+ _el$62.addEventListener("change", (e) => p.set("cellVerticalAlign", e.currentTarget.value));
32600
+ insert(_el$63, () => t("table.inherit"));
32601
+ insert(_el$64, () => t("table.valignTop"));
32602
+ insert(_el$65, () => t("table.valignMiddle"));
32603
+ insert(_el$66, () => t("table.valignBottom"));
32604
+ insert(_el$68, () => t("table.textDirection"));
32605
+ _el$69.addEventListener("change", (e) => p.set("cellTextDirection", e.currentTarget.value));
32606
+ insert(_el$70, () => t("table.inherit"));
32607
+ insert(_el$72, () => t("table.options"));
32608
+ insert(_el$73, () => checkbox(t("table.noWrap"), () => p.form.cellNoWrap, (v) => p.set("cellNoWrap", v), "editor-table-properties-cell-nowrap"), null);
32609
+ insert(_el$73, () => checkbox(t("table.fitText"), () => p.form.cellFitText, (v) => p.set("cellFitText", v), "editor-table-properties-cell-fit-text"), null);
32610
+ insert(_el$73, () => checkbox(t("table.hideMark"), () => p.form.cellHideMark, (v) => p.set("cellHideMark", v), "editor-table-properties-cell-hide-mark"), null);
32611
+ insert(_el$75, () => t("table.cellMargins"));
32612
+ insert(_el$76, () => numericInput(t("paragraph.borderSideTop"), () => p.form.marginTop, (v) => p.set("marginTop", v), "editor-table-properties-margin-top"), null);
32613
+ insert(_el$76, () => numericInput(t("paragraph.borderSideRight"), () => p.form.marginRight, (v) => p.set("marginRight", v), "editor-table-properties-margin-right"), null);
32614
+ insert(_el$76, () => numericInput(t("paragraph.borderSideBottom"), () => p.form.marginBottom, (v) => p.set("marginBottom", v), "editor-table-properties-margin-bottom"), null);
32615
+ insert(_el$76, () => numericInput(t("paragraph.borderSideLeft"), () => p.form.marginLeft, (v) => p.set("marginLeft", v), "editor-table-properties-margin-left"), null);
32616
+ insert(_el$78, () => t("paragraph.bordersSection"));
32617
+ insert(_el$81, () => t("paragraph.borderStyleLabel"));
32618
+ _el$82.addEventListener("change", (e) => {
32619
+ const next = e.currentTarget.value;
32620
+ p.set("borderStyle", next);
32621
+ if (next === "none") {
32622
+ p.set("borderTop", false);
32623
+ p.set("borderRight", false);
32624
+ p.set("borderBottom", false);
32625
+ p.set("borderLeft", false);
32626
+ p.set("borderStart", false);
32627
+ p.set("borderEnd", false);
32628
+ p.set("borderTlBr", false);
32629
+ p.set("borderTrBl", false);
32630
+ } else if (!p.form.borderTop && !p.form.borderRight && !p.form.borderBottom && !p.form.borderLeft) {
32631
+ p.set("borderTop", true);
32632
+ p.set("borderRight", true);
32633
+ p.set("borderBottom", true);
32634
+ p.set("borderLeft", true);
32635
+ }
32636
+ });
32637
+ insert(_el$83, () => t("paragraph.borderNone"));
32638
+ insert(_el$84, () => t("paragraph.borderSolid"));
32639
+ insert(_el$85, () => t("paragraph.borderDashed"));
32640
+ insert(_el$86, () => t("paragraph.borderDotted"));
32641
+ insert(_el$79, () => numericInput(t("paragraph.borderWidthLabel"), () => p.form.borderWidth, (v) => p.set("borderWidth", v), "editor-table-properties-border-width", p.form.borderStyle === "none"), _el$87);
32642
+ insert(_el$88, () => t("paragraph.borderColorLabel"));
32643
+ _el$89.$$input = (e) => p.set("borderColor", e.currentTarget.value);
32644
+ insert(_el$91, () => t("paragraph.shadingLabel"));
32645
+ _el$92.$$input = (e) => p.set("shading", e.currentTarget.value);
32646
+ insert(_el$93, () => checkbox(t("paragraph.borderSideTop"), () => p.form.borderTop, (v) => p.set("borderTop", v), "editor-table-properties-border-top", p.form.borderStyle === "none"), null);
32647
+ insert(_el$93, () => checkbox(t("paragraph.borderSideRight"), () => p.form.borderRight, (v) => p.set("borderRight", v), "editor-table-properties-border-right", p.form.borderStyle === "none"), null);
32648
+ insert(_el$93, () => checkbox(t("paragraph.borderSideBottom"), () => p.form.borderBottom, (v) => p.set("borderBottom", v), "editor-table-properties-border-bottom", p.form.borderStyle === "none"), null);
32649
+ insert(_el$93, () => checkbox(t("paragraph.borderSideLeft"), () => p.form.borderLeft, (v) => p.set("borderLeft", v), "editor-table-properties-border-left", p.form.borderStyle === "none"), null);
32650
+ insert(_el$93, () => checkbox(t("table.borderStart"), () => p.form.borderStart, (v) => p.set("borderStart", v), "editor-table-properties-border-start", p.form.borderStyle === "none"), null);
32651
+ insert(_el$93, () => checkbox(t("table.borderEnd"), () => p.form.borderEnd, (v) => p.set("borderEnd", v), "editor-table-properties-border-end", p.form.borderStyle === "none"), null);
32652
+ insert(_el$93, () => checkbox(t("table.borderTlBr"), () => p.form.borderTlBr, (v) => p.set("borderTlBr", v), "editor-table-properties-border-tlbr", p.form.borderStyle === "none"), null);
32653
+ insert(_el$93, () => checkbox(t("table.borderTrBl"), () => p.form.borderTrBl, (v) => p.set("borderTrBl", v), "editor-table-properties-border-trbl", p.form.borderStyle === "none"), null);
32654
+ createRenderEffect((_p$) => {
32655
+ var _v$ = p.form.borderStyle === "none", _v$2 = borderPreview();
32656
+ _v$ !== _p$.e && (_el$89.disabled = _p$.e = _v$);
32657
+ _p$.t = style(_el$94, _v$2, _p$.t);
32658
+ return _p$;
32659
+ }, {
32660
+ e: void 0,
32661
+ t: void 0
32662
+ });
32663
+ createRenderEffect(() => _el$62.value = p.form.cellVerticalAlign);
32664
+ createRenderEffect(() => _el$69.value = p.form.cellTextDirection);
32665
+ createRenderEffect(() => _el$82.value = p.form.borderStyle);
32666
+ createRenderEffect(() => _el$89.value = p.form.borderColor || DEFAULT_BORDER_COLOR);
32667
+ createRenderEffect(() => _el$92.value = p.form.shading || "#ffffff");
32668
+ return _el$58;
32669
+ })();
32670
+ }
32671
+ function AltTextTabPanel(p) {
32672
+ const t = useI18n();
32673
+ return (() => {
32674
+ var _el$95 = _tmpl$10(), _el$96 = _el$95.firstChild, _el$97 = _el$96.firstChild, _el$98 = _el$97.nextSibling, _el$99 = _el$96.nextSibling, _el$100 = _el$99.firstChild, _el$101 = _el$100.nextSibling;
32675
+ insert(_el$97, () => t("table.altTitle"));
32676
+ _el$98.$$input = (e) => p.set("altTitle", e.currentTarget.value);
32677
+ insert(_el$100, () => t("table.altDescription"));
32678
+ _el$101.$$input = (e) => p.set("altDescription", e.currentTarget.value);
32679
+ createRenderEffect(() => _el$98.value = p.form.altTitle);
32680
+ createRenderEffect(() => _el$101.value = p.form.altDescription);
32681
+ return _el$95;
32682
+ })();
32683
+ }
32684
+ function TablePropertiesDialog(props) {
32685
+ const t = useI18n();
32686
+ const [form, setForm] = createStore({
32687
+ activeTab: "table",
32688
+ tableWidth: "",
32689
+ tableWidthUnit: "points",
32690
+ tableAlign: "",
32691
+ tableIndentLeft: "",
32692
+ tableWrapping: "none",
32693
+ floatingHorizontalAnchor: "margin",
32694
+ floatingVerticalAnchor: "text",
32695
+ floatingX: "",
32696
+ floatingY: "",
32697
+ floatingXAlign: "",
32698
+ floatingYAlign: "",
32699
+ floatingDistanceTop: "",
32700
+ floatingDistanceRight: "",
32701
+ floatingDistanceBottom: "",
32702
+ floatingDistanceLeft: "",
32703
+ floatingOverlap: "overlap",
32704
+ rowHeight: "",
32705
+ rowHeightRule: "",
32706
+ repeatHeader: false,
32707
+ allowBreakAcrossPages: true,
32708
+ hiddenRow: false,
32709
+ columnWidth: "",
32710
+ cellWidth: "",
32711
+ cellVerticalAlign: "",
32712
+ cellTextDirection: "",
32713
+ cellNoWrap: false,
32714
+ cellFitText: false,
32715
+ cellHideMark: false,
32716
+ marginTop: "",
32717
+ marginRight: "",
32718
+ marginBottom: "",
32719
+ marginLeft: "",
32720
+ borderStyle: "none",
32721
+ borderWidth: "",
32722
+ borderColor: "",
32723
+ borderTop: false,
32724
+ borderRight: false,
32725
+ borderBottom: false,
32726
+ borderLeft: false,
32727
+ borderStart: false,
32728
+ borderEnd: false,
32729
+ borderTlBr: false,
32730
+ borderTrBl: false,
32731
+ shading: "",
32732
+ altTitle: "",
32733
+ altDescription: ""
32734
+ });
32735
+ createEffect(() => {
32736
+ if (!props.isOpen) return;
32737
+ setForm(reconcile({
32738
+ activeTab: props.initial.activeTab ?? "table",
32739
+ tableWidth: props.initial.tableWidth,
32740
+ tableWidthUnit: props.initial.tableWidthUnit,
32741
+ tableAlign: props.initial.tableAlign,
32742
+ tableIndentLeft: props.initial.tableIndentLeft,
32743
+ tableWrapping: props.initial.tableWrapping,
32744
+ floatingHorizontalAnchor: props.initial.floatingHorizontalAnchor,
32745
+ floatingVerticalAnchor: props.initial.floatingVerticalAnchor,
32746
+ floatingX: props.initial.floatingX,
32747
+ floatingY: props.initial.floatingY,
32748
+ floatingXAlign: props.initial.floatingXAlign,
32749
+ floatingYAlign: props.initial.floatingYAlign,
32750
+ floatingDistanceTop: props.initial.floatingDistanceTop,
32751
+ floatingDistanceRight: props.initial.floatingDistanceRight,
32752
+ floatingDistanceBottom: props.initial.floatingDistanceBottom,
32753
+ floatingDistanceLeft: props.initial.floatingDistanceLeft,
32754
+ floatingOverlap: props.initial.floatingOverlap,
32755
+ rowHeight: props.initial.rowHeight,
32756
+ rowHeightRule: props.initial.rowHeightRule,
32757
+ repeatHeader: props.initial.repeatHeader,
32758
+ allowBreakAcrossPages: props.initial.allowBreakAcrossPages,
32759
+ hiddenRow: props.initial.hiddenRow,
32760
+ columnWidth: props.initial.columnWidth,
32761
+ cellWidth: props.initial.cellWidth,
32762
+ cellVerticalAlign: props.initial.cellVerticalAlign,
32763
+ cellTextDirection: props.initial.cellTextDirection,
32764
+ cellNoWrap: props.initial.cellNoWrap,
32765
+ cellFitText: props.initial.cellFitText,
32766
+ cellHideMark: props.initial.cellHideMark,
32767
+ marginTop: props.initial.marginTop,
32768
+ marginRight: props.initial.marginRight,
32769
+ marginBottom: props.initial.marginBottom,
32770
+ marginLeft: props.initial.marginLeft,
32771
+ borderStyle: props.initial.borderStyle,
32772
+ borderWidth: props.initial.borderWidth,
32773
+ borderColor: props.initial.borderColor,
32774
+ borderTop: props.initial.borderTop,
32775
+ borderRight: props.initial.borderRight,
32776
+ borderBottom: props.initial.borderBottom,
32777
+ borderLeft: props.initial.borderLeft,
32778
+ borderStart: props.initial.borderStart,
32779
+ borderEnd: props.initial.borderEnd,
32780
+ borderTlBr: props.initial.borderTopLeftToBottomRight,
32781
+ borderTrBl: props.initial.borderTopRightToBottomLeft,
32782
+ shading: props.initial.shading,
32783
+ altTitle: props.initial.altTitle,
32784
+ altDescription: props.initial.altDescription
32785
+ }));
32786
+ });
32562
32787
  const handleApply = () => {
32563
- const border = resolveBorder(borderStyle(), borderWidth(), borderColor());
32788
+ const border = resolveBorder(form.borderStyle, form.borderWidth, form.borderColor);
32564
32789
  props.onApply({
32565
- tableWidth: parseWidth(tableWidth(), tableWidthUnit()),
32566
- tableAlign: tableAlign() || null,
32567
- tableIndentLeft: parseWidth(tableIndentLeft(), "points"),
32568
- tableFloating: tableWrapping() === "around" ? {
32569
- horizontalAnchor: floatingHorizontalAnchor(),
32570
- verticalAnchor: floatingVerticalAnchor(),
32571
- ...floatingXAlign() ? {
32572
- xAlign: floatingXAlign()
32790
+ tableWidth: parseWidth(form.tableWidth, form.tableWidthUnit),
32791
+ tableAlign: form.tableAlign || null,
32792
+ tableIndentLeft: parseWidth(form.tableIndentLeft, "points"),
32793
+ tableFloating: form.tableWrapping === "around" ? {
32794
+ horizontalAnchor: form.floatingHorizontalAnchor,
32795
+ verticalAnchor: form.floatingVerticalAnchor,
32796
+ ...form.floatingXAlign ? {
32797
+ xAlign: form.floatingXAlign
32573
32798
  } : {
32574
- x: parseNumber(floatingX()) ?? 0
32799
+ x: parseNumber(form.floatingX) ?? 0
32575
32800
  },
32576
- ...floatingYAlign() ? {
32577
- yAlign: floatingYAlign()
32801
+ ...form.floatingYAlign ? {
32802
+ yAlign: form.floatingYAlign
32578
32803
  } : {
32579
- y: parseNumber(floatingY()) ?? 0
32804
+ y: parseNumber(form.floatingY) ?? 0
32580
32805
  },
32581
- distanceTop: parseNumber(floatingDistanceTop()) ?? 0,
32582
- distanceRight: parseNumber(floatingDistanceRight()) ?? 0,
32583
- distanceBottom: parseNumber(floatingDistanceBottom()) ?? 0,
32584
- distanceLeft: parseNumber(floatingDistanceLeft()) ?? 0
32806
+ distanceTop: parseNumber(form.floatingDistanceTop) ?? 0,
32807
+ distanceRight: parseNumber(form.floatingDistanceRight) ?? 0,
32808
+ distanceBottom: parseNumber(form.floatingDistanceBottom) ?? 0,
32809
+ distanceLeft: parseNumber(form.floatingDistanceLeft) ?? 0
32585
32810
  } : null,
32586
- tableOverlap: tableWrapping() === "around" ? floatingOverlap() : null,
32587
- rowHeight: parseWidth(rowHeight(), "points"),
32588
- rowHeightRule: rowHeightRule() || null,
32589
- repeatHeader: repeatHeader(),
32590
- cantSplit: !allowBreakAcrossPages(),
32591
- hiddenRow: hiddenRow(),
32592
- columnWidth: parseWidth(columnWidth(), "points"),
32593
- cellWidth: parseWidth(cellWidth(), "points"),
32594
- cellVerticalAlign: cellVerticalAlign() || null,
32595
- cellTextDirection: cellTextDirection() || null,
32596
- cellNoWrap: cellNoWrap(),
32597
- cellFitText: cellFitText(),
32598
- cellHideMark: cellHideMark(),
32811
+ tableOverlap: form.tableWrapping === "around" ? form.floatingOverlap : null,
32812
+ rowHeight: parseWidth(form.rowHeight, "points"),
32813
+ rowHeightRule: form.rowHeightRule || null,
32814
+ repeatHeader: form.repeatHeader,
32815
+ cantSplit: !form.allowBreakAcrossPages,
32816
+ hiddenRow: form.hiddenRow,
32817
+ columnWidth: parseWidth(form.columnWidth, "points"),
32818
+ cellWidth: parseWidth(form.cellWidth, "points"),
32819
+ cellVerticalAlign: form.cellVerticalAlign || null,
32820
+ cellTextDirection: form.cellTextDirection || null,
32821
+ cellNoWrap: form.cellNoWrap,
32822
+ cellFitText: form.cellFitText,
32823
+ cellHideMark: form.cellHideMark,
32599
32824
  margins: {
32600
- top: parseNumber(marginTop()),
32601
- right: parseNumber(marginRight()),
32602
- bottom: parseNumber(marginBottom()),
32603
- left: parseNumber(marginLeft())
32825
+ top: parseNumber(form.marginTop),
32826
+ right: parseNumber(form.marginRight),
32827
+ bottom: parseNumber(form.marginBottom),
32828
+ left: parseNumber(form.marginLeft)
32604
32829
  },
32605
32830
  borders: {
32606
- top: borderTop() ? border : null,
32607
- right: borderRight() ? border : null,
32608
- bottom: borderBottom() ? border : null,
32609
- left: borderLeft() ? border : null,
32610
- start: borderStart() ? border : null,
32611
- end: borderEnd() ? border : null,
32612
- topLeftToBottomRight: borderTlBr() ? border : null,
32613
- topRightToBottomLeft: borderTrBl() ? border : null
32831
+ top: form.borderTop ? border : null,
32832
+ right: form.borderRight ? border : null,
32833
+ bottom: form.borderBottom ? border : null,
32834
+ left: form.borderLeft ? border : null,
32835
+ start: form.borderStart ? border : null,
32836
+ end: form.borderEnd ? border : null,
32837
+ topLeftToBottomRight: form.borderTlBr ? border : null,
32838
+ topRightToBottomLeft: form.borderTrBl ? border : null
32614
32839
  },
32615
- shading: shading().trim() || null,
32616
- altTitle: altTitle().trim() || null,
32617
- altDescription: altDescription().trim() || null
32840
+ shading: form.shading.trim() || null,
32841
+ altTitle: form.altTitle.trim() || null,
32842
+ altDescription: form.altDescription.trim() || null
32618
32843
  }, props.initial);
32619
32844
  props.onClose();
32620
32845
  };
32621
- const numericInput = (label, value, setter, testId, disabled = false, allowNegative = false) => (() => {
32622
- var _el$ = _tmpl$$5(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling;
32623
- insert(_el$2, label);
32624
- _el$3.$$input = (e) => setter(e.currentTarget.value);
32625
- setAttribute(_el$3, "min", allowNegative ? void 0 : "0");
32626
- _el$3.disabled = disabled;
32627
- setAttribute(_el$3, "data-testid", testId);
32628
- createRenderEffect(() => _el$3.value = value());
32629
- return _el$;
32630
- })();
32631
- const checkbox = (label, checked, setter, testId, disabled = false) => (() => {
32632
- var _el$4 = _tmpl$2$1(), _el$5 = _el$4.firstChild;
32633
- _el$5.addEventListener("change", (e) => setter(e.currentTarget.checked));
32634
- _el$5.disabled = disabled;
32635
- setAttribute(_el$5, "data-testid", testId);
32636
- insert(_el$4, label, null);
32637
- createRenderEffect(() => _el$5.checked = checked());
32638
- return _el$4;
32639
- })();
32640
32846
  return createComponent(Dialog, {
32641
32847
  get isOpen() {
32642
32848
  return props.isOpen;
@@ -32669,9 +32875,9 @@ function TablePropertiesDialog(props) {
32669
32875
  get children() {
32670
32876
  return createComponent(Tabs, {
32671
32877
  get value() {
32672
- return activeTab();
32878
+ return form.activeTab;
32673
32879
  },
32674
- onChange: setActiveTab,
32880
+ onChange: (tab) => setForm("activeTab", tab),
32675
32881
  get ariaLabel() {
32676
32882
  return t("table.propertiesTitle");
32677
32883
  },
@@ -32681,205 +32887,42 @@ function TablePropertiesDialog(props) {
32681
32887
  id: "table",
32682
32888
  label: t("table.tabTable"),
32683
32889
  testId: "editor-table-properties-tab-table",
32684
- panel: (() => {
32685
- var _el$6 = _tmpl$6$1(), _el$7 = _el$6.firstChild, _el$8 = _el$7.firstChild, _el$9 = _el$8.nextSibling, _el$0 = _el$9.firstChild, _el$1 = _el$0.firstChild, _el$10 = _el$1.nextSibling, _el$11 = _el$10.firstChild, _el$12 = _el$11.nextSibling, _el$13 = _el$7.nextSibling, _el$14 = _el$13.firstChild, _el$15 = _el$14.nextSibling, _el$16 = _el$15.nextSibling, _el$17 = _el$13.nextSibling, _el$18 = _el$17.firstChild, _el$19 = _el$18.nextSibling;
32686
- insert(_el$8, () => t("table.sizeSection"));
32687
- insert(_el$9, () => numericInput(t("table.preferredWidth"), tableWidth, setTableWidth, "editor-table-properties-table-width"), _el$0);
32688
- insert(_el$1, () => t("table.measureIn"));
32689
- _el$10.addEventListener("change", (e) => setTableWidthUnit(e.currentTarget.value));
32690
- insert(_el$11, () => t("table.points"));
32691
- insert(_el$12, () => t("table.percent"));
32692
- insert(_el$14, () => t("table.alignmentSection"));
32693
- insert(_el$15, () => ["left", "center", "right"].map((align) => (() => {
32694
- var _el$43 = _tmpl$7(), _el$44 = _el$43.firstChild;
32695
- _el$44.addEventListener("change", () => setTableAlign(align));
32696
- setAttribute(_el$44, "data-testid", `editor-table-properties-align-${align}`);
32697
- insert(_el$43, () => t(`table.align${align[0].toUpperCase()}${align.slice(1)}`), null);
32698
- createRenderEffect(() => _el$44.checked = tableAlign() === align);
32699
- return _el$43;
32700
- })()));
32701
- insert(_el$16, () => numericInput(t("table.indentFromLeft"), tableIndentLeft, setTableIndentLeft, "editor-table-properties-indent-left"));
32702
- insert(_el$18, () => t("table.textWrappingSection"));
32703
- insert(_el$19, () => checkbox(t("table.wrapNone"), () => tableWrapping() === "none", () => setTableWrapping("none"), "editor-table-properties-wrap-none"), null);
32704
- insert(_el$19, () => checkbox(t("table.wrapAround"), () => tableWrapping() === "around", () => setTableWrapping("around"), "editor-table-properties-wrap-around"), null);
32705
- insert(_el$17, createComponent(Show, {
32706
- get when() {
32707
- return tableWrapping() === "around";
32708
- },
32709
- get children() {
32710
- return [(() => {
32711
- var _el$20 = _tmpl$3$1(), _el$21 = _el$20.firstChild, _el$22 = _el$21.firstChild, _el$23 = _el$22.nextSibling, _el$24 = _el$23.firstChild, _el$25 = _el$24.nextSibling, _el$26 = _el$25.nextSibling, _el$27 = _el$21.nextSibling, _el$28 = _el$27.firstChild, _el$29 = _el$28.nextSibling, _el$30 = _el$29.firstChild, _el$31 = _el$30.nextSibling, _el$32 = _el$31.nextSibling;
32712
- insert(_el$22, () => t("table.horizontalAnchor"));
32713
- _el$23.addEventListener("change", (e) => setFloatingHorizontalAnchor(e.currentTarget.value));
32714
- insert(_el$24, () => t("table.anchorMargin"));
32715
- insert(_el$25, () => t("table.anchorPage"));
32716
- insert(_el$26, () => t("table.anchorText"));
32717
- insert(_el$28, () => t("table.verticalAnchor"));
32718
- _el$29.addEventListener("change", (e) => setFloatingVerticalAnchor(e.currentTarget.value));
32719
- insert(_el$30, () => t("table.anchorMargin"));
32720
- insert(_el$31, () => t("table.anchorPage"));
32721
- insert(_el$32, () => t("table.anchorText"));
32722
- createRenderEffect(() => _el$23.value = floatingHorizontalAnchor());
32723
- createRenderEffect(() => _el$29.value = floatingVerticalAnchor());
32724
- return _el$20;
32725
- })(), (() => {
32726
- var _el$33 = _tmpl$4$1(), _el$34 = _el$33.firstChild, _el$35 = _el$34.firstChild, _el$36 = _el$35.nextSibling, _el$37 = _el$36.firstChild, _el$38 = _el$34.nextSibling, _el$39 = _el$38.firstChild, _el$40 = _el$39.nextSibling, _el$41 = _el$40.firstChild;
32727
- insert(_el$33, () => numericInput(t("table.positionX"), floatingX, setFloatingX, "editor-table-properties-floating-x", Boolean(floatingXAlign()), true), _el$34);
32728
- insert(_el$33, () => numericInput(t("table.positionY"), floatingY, setFloatingY, "editor-table-properties-floating-y", Boolean(floatingYAlign()), true), _el$34);
32729
- insert(_el$35, () => t("table.horizontalAlignment"));
32730
- _el$36.addEventListener("change", (e) => setFloatingXAlign(e.currentTarget.value));
32731
- insert(_el$37, () => t("table.explicitOffset"));
32732
- insert(_el$36, () => ["left", "center", "right", "inside", "outside"].map((value) => (() => {
32733
- var _el$45 = _tmpl$8();
32734
- _el$45.value = value;
32735
- insert(_el$45, value);
32736
- return _el$45;
32737
- })()), null);
32738
- insert(_el$39, () => t("table.verticalAlignment"));
32739
- _el$40.addEventListener("change", (e) => setFloatingYAlign(e.currentTarget.value));
32740
- insert(_el$41, () => t("table.explicitOffset"));
32741
- insert(_el$40, () => ["top", "center", "bottom", "inside", "outside"].map((value) => (() => {
32742
- var _el$46 = _tmpl$8();
32743
- _el$46.value = value;
32744
- insert(_el$46, value);
32745
- return _el$46;
32746
- })()), null);
32747
- createRenderEffect(() => _el$36.value = floatingXAlign());
32748
- createRenderEffect(() => _el$40.value = floatingYAlign());
32749
- return _el$33;
32750
- })(), (() => {
32751
- var _el$42 = _tmpl$5$1();
32752
- insert(_el$42, () => numericInput(t("table.distanceTop"), floatingDistanceTop, setFloatingDistanceTop, "editor-table-properties-floating-distance-top"), null);
32753
- insert(_el$42, () => numericInput(t("table.distanceRight"), floatingDistanceRight, setFloatingDistanceRight, "editor-table-properties-floating-distance-right"), null);
32754
- insert(_el$42, () => numericInput(t("table.distanceBottom"), floatingDistanceBottom, setFloatingDistanceBottom, "editor-table-properties-floating-distance-bottom"), null);
32755
- insert(_el$42, () => numericInput(t("table.distanceLeft"), floatingDistanceLeft, setFloatingDistanceLeft, "editor-table-properties-floating-distance-left"), null);
32756
- return _el$42;
32757
- })(), memo(() => checkbox(t("table.allowOverlap"), () => floatingOverlap() === "overlap", (value) => setFloatingOverlap(value ? "overlap" : "never"), "editor-table-properties-floating-overlap"))];
32758
- }
32759
- }), null);
32760
- createRenderEffect(() => _el$10.value = tableWidthUnit());
32761
- return _el$6;
32762
- })()
32890
+ panel: createComponent(TableTabPanel, {
32891
+ form,
32892
+ set: setForm
32893
+ })
32763
32894
  }, {
32764
32895
  id: "row",
32765
32896
  label: t("table.tabRow"),
32766
32897
  testId: "editor-table-properties-tab-row",
32767
- panel: (() => {
32768
- var _el$47 = _tmpl$9(), _el$48 = _el$47.firstChild, _el$49 = _el$48.firstChild, _el$50 = _el$49.firstChild, _el$51 = _el$50.nextSibling, _el$52 = _el$51.firstChild, _el$53 = _el$52.nextSibling, _el$54 = _el$53.nextSibling, _el$55 = _el$48.nextSibling;
32769
- insert(_el$48, () => numericInput(t("table.rowHeight"), rowHeight, setRowHeight, "editor-table-properties-row-height"), _el$49);
32770
- insert(_el$50, () => t("table.rowHeightRule"));
32771
- _el$51.addEventListener("change", (e) => setRowHeightRule(e.currentTarget.value));
32772
- insert(_el$52, () => t("table.rowAuto"));
32773
- insert(_el$53, () => t("table.rowAtLeast"));
32774
- insert(_el$54, () => t("table.rowExactly"));
32775
- insert(_el$55, () => checkbox(t("table.repeatHeader"), repeatHeader, setRepeatHeader, "editor-table-properties-repeat-header"), null);
32776
- insert(_el$55, () => checkbox(t("table.allowBreakAcrossPages"), allowBreakAcrossPages, setAllowBreakAcrossPages, "editor-table-properties-allow-break"), null);
32777
- insert(_el$55, () => checkbox(t("table.hiddenRow"), hiddenRow, setHiddenRow, "editor-table-properties-hidden-row"), null);
32778
- createRenderEffect(() => _el$51.value = rowHeightRule());
32779
- return _el$47;
32780
- })()
32898
+ panel: createComponent(RowTabPanel, {
32899
+ form,
32900
+ set: setForm
32901
+ })
32781
32902
  }, {
32782
32903
  id: "column",
32783
32904
  label: t("table.tabColumn"),
32784
32905
  testId: "editor-table-properties-tab-column",
32785
- panel: (() => {
32786
- var _el$56 = _tmpl$0(), _el$57 = _el$56.firstChild;
32787
- insert(_el$57, () => numericInput(t("table.columnWidth"), columnWidth, setColumnWidth, "editor-table-properties-column-width"));
32788
- return _el$56;
32789
- })()
32906
+ panel: createComponent(ColumnTabPanel, {
32907
+ form,
32908
+ set: setForm
32909
+ })
32790
32910
  }, {
32791
32911
  id: "cell",
32792
32912
  label: t("table.tabCell"),
32793
32913
  testId: "editor-table-properties-tab-cell",
32794
- panel: (() => {
32795
- var _el$58 = _tmpl$1(), _el$59 = _el$58.firstChild, _el$60 = _el$59.firstChild, _el$61 = _el$60.firstChild, _el$62 = _el$61.nextSibling, _el$63 = _el$62.firstChild, _el$64 = _el$63.nextSibling, _el$65 = _el$64.nextSibling, _el$66 = _el$65.nextSibling, _el$67 = _el$60.nextSibling, _el$68 = _el$67.firstChild, _el$69 = _el$68.nextSibling, _el$70 = _el$69.firstChild, _el$71 = _el$59.nextSibling, _el$72 = _el$71.firstChild, _el$73 = _el$72.nextSibling, _el$74 = _el$71.nextSibling, _el$75 = _el$74.firstChild, _el$76 = _el$75.nextSibling, _el$77 = _el$74.nextSibling, _el$78 = _el$77.firstChild, _el$79 = _el$78.nextSibling, _el$80 = _el$79.firstChild, _el$81 = _el$80.firstChild, _el$82 = _el$81.nextSibling, _el$83 = _el$82.firstChild, _el$84 = _el$83.nextSibling, _el$85 = _el$84.nextSibling, _el$86 = _el$85.nextSibling, _el$87 = _el$80.nextSibling, _el$88 = _el$87.firstChild, _el$89 = _el$88.nextSibling, _el$90 = _el$87.nextSibling, _el$91 = _el$90.firstChild, _el$92 = _el$91.nextSibling, _el$93 = _el$79.nextSibling, _el$94 = _el$93.nextSibling;
32796
- insert(_el$59, () => numericInput(t("table.cellWidth"), cellWidth, setCellWidth, "editor-table-properties-cell-width"), _el$60);
32797
- insert(_el$61, () => t("table.verticalAlignment"));
32798
- _el$62.addEventListener("change", (e) => setCellVerticalAlign(e.currentTarget.value));
32799
- insert(_el$63, () => t("table.inherit"));
32800
- insert(_el$64, () => t("table.valignTop"));
32801
- insert(_el$65, () => t("table.valignMiddle"));
32802
- insert(_el$66, () => t("table.valignBottom"));
32803
- insert(_el$68, () => t("table.textDirection"));
32804
- _el$69.addEventListener("change", (e) => setCellTextDirection(e.currentTarget.value));
32805
- insert(_el$70, () => t("table.inherit"));
32806
- insert(_el$72, () => t("table.options"));
32807
- insert(_el$73, () => checkbox(t("table.noWrap"), cellNoWrap, setCellNoWrap, "editor-table-properties-cell-nowrap"), null);
32808
- insert(_el$73, () => checkbox(t("table.fitText"), cellFitText, setCellFitText, "editor-table-properties-cell-fit-text"), null);
32809
- insert(_el$73, () => checkbox(t("table.hideMark"), cellHideMark, setCellHideMark, "editor-table-properties-cell-hide-mark"), null);
32810
- insert(_el$75, () => t("table.cellMargins"));
32811
- insert(_el$76, () => numericInput(t("paragraph.borderSideTop"), marginTop, setMarginTop, "editor-table-properties-margin-top"), null);
32812
- insert(_el$76, () => numericInput(t("paragraph.borderSideRight"), marginRight, setMarginRight, "editor-table-properties-margin-right"), null);
32813
- insert(_el$76, () => numericInput(t("paragraph.borderSideBottom"), marginBottom, setMarginBottom, "editor-table-properties-margin-bottom"), null);
32814
- insert(_el$76, () => numericInput(t("paragraph.borderSideLeft"), marginLeft, setMarginLeft, "editor-table-properties-margin-left"), null);
32815
- insert(_el$78, () => t("paragraph.bordersSection"));
32816
- insert(_el$81, () => t("paragraph.borderStyleLabel"));
32817
- _el$82.addEventListener("change", (e) => {
32818
- const next = e.currentTarget.value;
32819
- setBorderStyle(next);
32820
- if (next === "none") {
32821
- setBorderTop(false);
32822
- setBorderRight(false);
32823
- setBorderBottom(false);
32824
- setBorderLeft(false);
32825
- setBorderStart(false);
32826
- setBorderEnd(false);
32827
- setBorderTlBr(false);
32828
- setBorderTrBl(false);
32829
- } else if (!borderTop() && !borderRight() && !borderBottom() && !borderLeft()) {
32830
- setBorderTop(true);
32831
- setBorderRight(true);
32832
- setBorderBottom(true);
32833
- setBorderLeft(true);
32834
- }
32835
- });
32836
- insert(_el$83, () => t("paragraph.borderNone"));
32837
- insert(_el$84, () => t("paragraph.borderSolid"));
32838
- insert(_el$85, () => t("paragraph.borderDashed"));
32839
- insert(_el$86, () => t("paragraph.borderDotted"));
32840
- insert(_el$79, () => numericInput(t("paragraph.borderWidthLabel"), borderWidth, setBorderWidth, "editor-table-properties-border-width", borderStyle() === "none"), _el$87);
32841
- insert(_el$88, () => t("paragraph.borderColorLabel"));
32842
- _el$89.$$input = (e) => setBorderColor(e.currentTarget.value);
32843
- insert(_el$91, () => t("paragraph.shadingLabel"));
32844
- _el$92.$$input = (e) => setShading(e.currentTarget.value);
32845
- insert(_el$93, () => checkbox(t("paragraph.borderSideTop"), borderTop, setBorderTop, "editor-table-properties-border-top", borderStyle() === "none"), null);
32846
- insert(_el$93, () => checkbox(t("paragraph.borderSideRight"), borderRight, setBorderRight, "editor-table-properties-border-right", borderStyle() === "none"), null);
32847
- insert(_el$93, () => checkbox(t("paragraph.borderSideBottom"), borderBottom, setBorderBottom, "editor-table-properties-border-bottom", borderStyle() === "none"), null);
32848
- insert(_el$93, () => checkbox(t("paragraph.borderSideLeft"), borderLeft, setBorderLeft, "editor-table-properties-border-left", borderStyle() === "none"), null);
32849
- insert(_el$93, () => checkbox(t("table.borderStart"), borderStart, setBorderStart, "editor-table-properties-border-start", borderStyle() === "none"), null);
32850
- insert(_el$93, () => checkbox(t("table.borderEnd"), borderEnd, setBorderEnd, "editor-table-properties-border-end", borderStyle() === "none"), null);
32851
- insert(_el$93, () => checkbox(t("table.borderTlBr"), borderTlBr, setBorderTlBr, "editor-table-properties-border-tlbr", borderStyle() === "none"), null);
32852
- insert(_el$93, () => checkbox(t("table.borderTrBl"), borderTrBl, setBorderTrBl, "editor-table-properties-border-trbl", borderStyle() === "none"), null);
32853
- createRenderEffect((_p$) => {
32854
- var _v$ = borderStyle() === "none", _v$2 = borderPreview();
32855
- _v$ !== _p$.e && (_el$89.disabled = _p$.e = _v$);
32856
- _p$.t = style(_el$94, _v$2, _p$.t);
32857
- return _p$;
32858
- }, {
32859
- e: void 0,
32860
- t: void 0
32861
- });
32862
- createRenderEffect(() => _el$62.value = cellVerticalAlign());
32863
- createRenderEffect(() => _el$69.value = cellTextDirection());
32864
- createRenderEffect(() => _el$82.value = borderStyle());
32865
- createRenderEffect(() => _el$89.value = borderColor() || DEFAULT_BORDER_COLOR);
32866
- createRenderEffect(() => _el$92.value = shading() || "#ffffff");
32867
- return _el$58;
32868
- })()
32914
+ panel: createComponent(CellTabPanel, {
32915
+ form,
32916
+ set: setForm
32917
+ })
32869
32918
  }, {
32870
32919
  id: "altText",
32871
32920
  label: t("table.tabAltText"),
32872
32921
  testId: "editor-table-properties-tab-alt-text",
32873
- panel: (() => {
32874
- var _el$95 = _tmpl$10(), _el$96 = _el$95.firstChild, _el$97 = _el$96.firstChild, _el$98 = _el$97.nextSibling, _el$99 = _el$96.nextSibling, _el$100 = _el$99.firstChild, _el$101 = _el$100.nextSibling;
32875
- insert(_el$97, () => t("table.altTitle"));
32876
- _el$98.$$input = (e) => setAltTitle(e.currentTarget.value);
32877
- insert(_el$100, () => t("table.altDescription"));
32878
- _el$101.$$input = (e) => setAltDescription(e.currentTarget.value);
32879
- createRenderEffect(() => _el$98.value = altTitle());
32880
- createRenderEffect(() => _el$101.value = altDescription());
32881
- return _el$95;
32882
- })()
32922
+ panel: createComponent(AltTextTabPanel, {
32923
+ form,
32924
+ set: setForm
32925
+ })
32883
32926
  }];
32884
32927
  }
32885
32928
  });
@@ -36187,6 +36230,16 @@ function buildPartContext(blocks, numberingContext, state, document2) {
36187
36230
  hyperlinkMap
36188
36231
  };
36189
36232
  }
36233
+ function writeNotePart(zip, partName, part) {
36234
+ if (!part) return;
36235
+ zip.file(`word/${partName}.xml`, part.xml);
36236
+ if (part.partContext.images.length > 0 || part.partContext.hyperlinks.length > 0) {
36237
+ zip.file(
36238
+ `word/_rels/${partName}.xml.rels`,
36239
+ buildPartRelationshipsXml(part.partContext.images, part.partContext.hyperlinks)
36240
+ );
36241
+ }
36242
+ }
36190
36243
  async function exportEditorDocumentToDocx(document2) {
36191
36244
  var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
36192
36245
  document2 = renumberImageCaptionsInDocument(document2);
@@ -36204,18 +36257,23 @@ async function exportEditorDocumentToDocx(document2) {
36204
36257
  const referencedEndnotes = collectReferencedEndnotesForExport(document2);
36205
36258
  const endnoteIdMap = buildEndnoteIdMap(referencedEndnotes);
36206
36259
  const hasEndnotes = referencedEndnotes.length > 0;
36207
- const bodyContext = buildPartContext(
36208
- sections.flatMap((section) => section.blocks),
36209
- numberingContext,
36210
- buildState,
36211
- document2
36212
- );
36213
- bodyContext.footnoteIdMap = footnoteIdMap;
36214
- bodyContext.endnoteIdMap = endnoteIdMap;
36215
36260
  const bookmarkEvents = buildBookmarkExportPlan(document2);
36216
- bodyContext.bookmarkEventsByParagraph = bookmarkEvents;
36217
36261
  const commentPlan = buildCommentExportPlan(document2);
36218
- bodyContext.commentEventsByParagraph = commentPlan == null ? void 0 : commentPlan.eventsByParagraph;
36262
+ const annotateContext = (ctx) => {
36263
+ ctx.footnoteIdMap = footnoteIdMap;
36264
+ ctx.endnoteIdMap = endnoteIdMap;
36265
+ ctx.bookmarkEventsByParagraph = bookmarkEvents;
36266
+ ctx.commentEventsByParagraph = commentPlan == null ? void 0 : commentPlan.eventsByParagraph;
36267
+ return ctx;
36268
+ };
36269
+ const bodyContext = annotateContext(
36270
+ buildPartContext(
36271
+ sections.flatMap((section) => section.blocks),
36272
+ numberingContext,
36273
+ buildState,
36274
+ document2
36275
+ )
36276
+ );
36219
36277
  const hasComments = commentPlan !== void 0;
36220
36278
  const parts = [];
36221
36279
  const sectionReferences = sections.map(
@@ -36233,16 +36291,9 @@ async function exportEditorDocumentToDocx(document2) {
36233
36291
  const relPrefix = kind === "header" ? "Header" : "Footer";
36234
36292
  const path = `${kind}${partIndex}.xml`;
36235
36293
  const relId = `rId${relPrefix}${partIndex}`;
36236
- const context = buildPartContext(
36237
- blocks,
36238
- numberingContext,
36239
- buildState,
36240
- document2
36294
+ const context = annotateContext(
36295
+ buildPartContext(blocks, numberingContext, buildState, document2)
36241
36296
  );
36242
- context.footnoteIdMap = footnoteIdMap;
36243
- context.endnoteIdMap = endnoteIdMap;
36244
- context.bookmarkEventsByParagraph = bookmarkEvents;
36245
- context.commentEventsByParagraph = commentPlan == null ? void 0 : commentPlan.eventsByParagraph;
36246
36297
  parts.push({
36247
36298
  kind,
36248
36299
  type,
@@ -36391,30 +36442,8 @@ async function exportEditorDocumentToDocx(document2) {
36391
36442
  );
36392
36443
  }
36393
36444
  }
36394
- if (footnotesPart) {
36395
- zip.file("word/footnotes.xml", footnotesPart.xml);
36396
- if (footnotesPart.partContext.images.length > 0 || footnotesPart.partContext.hyperlinks.length > 0) {
36397
- zip.file(
36398
- "word/_rels/footnotes.xml.rels",
36399
- buildPartRelationshipsXml(
36400
- footnotesPart.partContext.images,
36401
- footnotesPart.partContext.hyperlinks
36402
- )
36403
- );
36404
- }
36405
- }
36406
- if (endnotesPart) {
36407
- zip.file("word/endnotes.xml", endnotesPart.xml);
36408
- if (endnotesPart.partContext.images.length > 0 || endnotesPart.partContext.hyperlinks.length > 0) {
36409
- zip.file(
36410
- "word/_rels/endnotes.xml.rels",
36411
- buildPartRelationshipsXml(
36412
- endnotesPart.partContext.images,
36413
- endnotesPart.partContext.hyperlinks
36414
- )
36415
- );
36416
- }
36417
- }
36445
+ writeNotePart(zip, "footnotes", footnotesPart);
36446
+ writeNotePart(zip, "endnotes", endnotesPart);
36418
36447
  if (commentPlan) {
36419
36448
  zip.file("word/comments.xml", buildCommentsPartXml(commentPlan));
36420
36449
  zip.file(
@@ -36806,238 +36835,64 @@ function resolveFragmentBounds(line, fragment, fontSizePx) {
36806
36835
  right: (nextSlot == null ? void 0 : nextSlot.left) ?? last.left + fontSizePx * 0.55
36807
36836
  };
36808
36837
  }
36809
- async function drawFloatingImagesForParagraph(options) {
36810
- for (const line of options.lines) {
36811
- const slots = new Map(line.slots.map((slot) => [slot.offset, slot]));
36812
- for (const fragment of line.fragments) {
36813
- const image = fragment.image;
36814
- if (!(image == null ? void 0 : image.floating)) continue;
36815
- const isBehind = Boolean(image.floating.behindDoc);
36816
- if (options.layer === "behind" !== isBehind) continue;
36817
- const slot = slots.get(fragment.startOffset);
36818
- const rect = resolveFloatingObjectRect({
36819
- object: getImageFloatingGeometry(image),
36820
- pageSettings: options.pageSettings,
36821
- contentLeft: options.contentLeft,
36822
- contentTop: options.contentTop,
36823
- contentWidth: options.contentWidth,
36824
- paragraphTop: options.paragraphTop,
36825
- lineTop: options.paragraphTop + line.top,
36826
- anchorLeft: options.contentLeft + ((slot == null ? void 0 : slot.left) ?? 0)
36827
- });
36828
- const resourceName = await registerPdfImageRun(
36829
- options.writer,
36830
- options.document,
36831
- image
36832
- );
36833
- if (!resourceName) continue;
36834
- options.writer.drawImage(options.pageIndex, {
36835
- resourceName,
36836
- x: pxToPt$1(rect.x),
36837
- y: pxToPt$1(rect.y),
36838
- width: pxToPt$1(rect.width),
36839
- height: pxToPt$1(rect.height),
36840
- rotation: image.rotation
36841
- });
36842
- }
36843
- }
36844
- }
36845
- function blendColorWithWhite(hex, alpha) {
36846
- const rgb = parseHexColorToRgb255(hex);
36847
- if (!rgb) {
36848
- return hex;
36849
- }
36850
- const a = Math.max(0, Math.min(1, alpha));
36851
- return rgb255ToHex(
36852
- 255 + (rgb[0] - 255) * a,
36853
- 255 + (rgb[1] - 255) * a,
36854
- 255 + (rgb[2] - 255) * a
36855
- );
36856
- }
36857
- function drawFragmentHighlight(writer, pageIndex, line, fragment, originX, originY, styles) {
36858
- if (!styles.highlight) {
36859
- return;
36860
- }
36861
- const bounds = resolveFragmentBounds(
36862
- line,
36863
- fragment,
36864
- styles.fontSize ?? DEFAULT_FONT_SIZE_PX
36865
- );
36866
- if (!bounds) {
36867
- return;
36868
- }
36869
- writer.drawRect(pageIndex, {
36838
+ function fragmentRectPt(line, fragment, styles, originX, originY, yOffset, heightShrink) {
36839
+ const bounds = resolveFragmentBounds(line, fragment, styles.fontSize ?? DEFAULT_FONT_SIZE_PX);
36840
+ if (!bounds) return null;
36841
+ return {
36870
36842
  x: pxToPt$1(originX + bounds.left),
36871
- y: pxToPt$1(originY + line.top + 2),
36843
+ y: pxToPt$1(originY + line.top + yOffset),
36872
36844
  width: pxToPt$1(Math.max(0, bounds.right - bounds.left)),
36873
- height: pxToPt$1(Math.max(2, line.height - 4)),
36874
- fill: styles.highlight
36875
- });
36845
+ height: pxToPt$1(Math.max(2, line.height - heightShrink))
36846
+ };
36847
+ }
36848
+ function drawFragmentHighlight(writer, pageIndex, line, fragment, originX, originY, styles) {
36849
+ if (!styles.highlight) return;
36850
+ const rect = fragmentRectPt(line, fragment, styles, originX, originY, 2, 4);
36851
+ if (!rect) return;
36852
+ writer.drawRect(pageIndex, { ...rect, fill: styles.highlight });
36876
36853
  }
36877
36854
  function drawFragmentShading(writer, pageIndex, line, fragment, originX, originY, styles) {
36878
- if (!styles.shading) {
36879
- return;
36880
- }
36881
- const bounds = resolveFragmentBounds(
36882
- line,
36883
- fragment,
36884
- styles.fontSize ?? DEFAULT_FONT_SIZE_PX
36885
- );
36886
- if (!bounds) {
36887
- return;
36888
- }
36855
+ if (!styles.shading) return;
36856
+ const rect = fragmentRectPt(line, fragment, styles, originX, originY, 2, 4);
36857
+ if (!rect) return;
36858
+ writer.drawRect(pageIndex, { ...rect, fill: styles.shading });
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;
36889
36865
  writer.drawRect(pageIndex, {
36890
- x: pxToPt$1(originX + bounds.left),
36891
- y: pxToPt$1(originY + line.top + 2),
36892
- width: pxToPt$1(Math.max(0, bounds.right - bounds.left)),
36893
- height: pxToPt$1(Math.max(2, line.height - 4)),
36894
- fill: styles.shading
36866
+ ...rect,
36867
+ stroke: border.color,
36868
+ lineWidth: pxToPt$1(Math.max(0.5, border.width * PX_PER_POINT))
36895
36869
  });
36896
36870
  }
36897
36871
  function resolveGradientShadingName(writer, pageIndex, line, fragment, originX, originY, styles) {
36898
36872
  const fill = styles.textFill;
36899
- if (!fill || fill.type !== "gradient" || fill.stops.length < 2) {
36900
- return void 0;
36901
- }
36873
+ if (!fill || fill.type !== "gradient" || fill.stops.length < 2) return void 0;
36902
36874
  const bounds = resolveFragmentBounds(
36903
36875
  line,
36904
36876
  fragment,
36905
36877
  styles.fontSize ?? DEFAULT_FONT_SIZE_PX
36906
36878
  );
36907
- if (!bounds) {
36908
- return void 0;
36909
- }
36879
+ if (!bounds) return void 0;
36910
36880
  const x0px = originX + bounds.left;
36911
36881
  const x1px = originX + bounds.right;
36912
36882
  const y0px = originY + line.top;
36913
36883
  const y1px = originY + line.top + line.height;
36914
- const cx = (x0px + x1px) / 2;
36915
- const cy = (y0px + y1px) / 2;
36916
- const rad = (fill.angle ?? 0) * Math.PI / 180;
36917
- const dx = Math.cos(rad) * (x1px - x0px) / 2;
36918
- const dy = Math.sin(rad) * (y1px - y0px) / 2;
36884
+ const axis = resolveGradientAxis(x0px, y0px, x1px, y1px, fill.angle ?? 0);
36919
36885
  return writer.registerAxialGradient(pageIndex, {
36920
- x0: pxToPt$1(cx - dx),
36921
- y0: pxToPt$1(cy - dy),
36922
- x1: pxToPt$1(cx + dx),
36923
- 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),
36924
36890
  stops: fill.stops.map((stop) => ({
36925
36891
  offset: stop.position,
36926
36892
  color: stop.color
36927
36893
  }))
36928
36894
  }) ?? void 0;
36929
36895
  }
36930
- function drawFragmentBorder(writer, pageIndex, line, fragment, originX, originY, styles) {
36931
- const border = styles.textBorder;
36932
- if (!border || border.type === "none" || border.width <= 0) {
36933
- return;
36934
- }
36935
- const bounds = resolveFragmentBounds(
36936
- line,
36937
- fragment,
36938
- styles.fontSize ?? DEFAULT_FONT_SIZE_PX
36939
- );
36940
- if (!bounds) {
36941
- return;
36942
- }
36943
- writer.drawRect(pageIndex, {
36944
- x: pxToPt$1(originX + bounds.left),
36945
- y: pxToPt$1(originY + line.top + 1),
36946
- width: pxToPt$1(Math.max(0, bounds.right - bounds.left)),
36947
- height: pxToPt$1(Math.max(2, line.height - 2)),
36948
- stroke: border.color,
36949
- lineWidth: pxToPt$1(Math.max(0.5, border.width * PX_PER_POINT))
36950
- });
36951
- }
36952
- const PDF_EMPHASIS_GLYPH = {
36953
- dot: "•",
36954
- comma: "‚",
36955
- circle: "○",
36956
- underDot: "•"
36957
- };
36958
- function drawFragmentEmphasis(writer, pageIndex, line, fragment, originX, originY, styles) {
36959
- const mark = styles.emphasisMark;
36960
- if (!mark || mark === "none") {
36961
- return;
36962
- }
36963
- const glyph = PDF_EMPHASIS_GLYPH[mark];
36964
- if (!glyph) {
36965
- return;
36966
- }
36967
- const slots = resolveFragmentSlots(line, fragment);
36968
- const below = mark === "underDot";
36969
- const size = Math.max(4, line.height * 0.35);
36970
- const y = below ? originY + line.top + line.height + size : originY + line.top + size;
36971
- for (let i = 0; i < slots.length; i += 1) {
36972
- const slot = slots[i];
36973
- if (slot.char === " " || slot.char === " " || slot.char === "\n") {
36974
- continue;
36975
- }
36976
- const next = slots[i + 1];
36977
- const centerX = next ? (slot.left + next.left) / 2 : slot.left + line.height * 0.25;
36978
- writer.drawText(pageIndex, {
36979
- x: pxToPt$1(originX + centerX - size * 0.25),
36980
- y: pxToPt$1(y),
36981
- text: glyph,
36982
- fontSize: pxToPt$1(size),
36983
- color: styles.color ?? "#000000"
36984
- });
36985
- }
36986
- }
36987
- function drawFragmentDecoration(writer, pageIndex, line, fragment, originX, originY, styles, kind) {
36988
- const bounds = resolveFragmentBounds(
36989
- line,
36990
- fragment,
36991
- styles.fontSize ?? DEFAULT_FONT_SIZE_PX
36992
- );
36993
- if (!bounds) {
36994
- return;
36995
- }
36996
- 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;
36997
- const x1 = originX + bounds.left;
36998
- const x2 = originX + bounds.right;
36999
- const stroke = kind === "underline" ? styles.underlineColor ?? styles.color ?? "#000000" : styles.color ?? "#000000";
37000
- if (kind === "strike") {
37001
- writer.drawLine(pageIndex, {
37002
- x1: pxToPt$1(x1),
37003
- y1: pxToPt$1(y),
37004
- x2: pxToPt$1(x2),
37005
- y2: pxToPt$1(y),
37006
- stroke,
37007
- lineWidth: pxToPt$1(1)
37008
- });
37009
- return;
37010
- }
37011
- if (kind === "doubleStrike") {
37012
- const offset = 1.3;
37013
- writer.drawLine(pageIndex, {
37014
- x1: pxToPt$1(x1),
37015
- y1: pxToPt$1(y - offset),
37016
- x2: pxToPt$1(x2),
37017
- y2: pxToPt$1(y - offset),
37018
- stroke,
37019
- lineWidth: pxToPt$1(1)
37020
- });
37021
- writer.drawLine(pageIndex, {
37022
- x1: pxToPt$1(x1),
37023
- y1: pxToPt$1(y + offset),
37024
- x2: pxToPt$1(x2),
37025
- y2: pxToPt$1(y + offset),
37026
- stroke,
37027
- lineWidth: pxToPt$1(1)
37028
- });
37029
- return;
37030
- }
37031
- drawUnderlineWithStyle(
37032
- writer,
37033
- pageIndex,
37034
- x1,
37035
- x2,
37036
- y,
37037
- stroke,
37038
- styles.underlineStyle
37039
- );
37040
- }
37041
36896
  function drawUnderlineWithStyle(writer, pageIndex, x1, x2, y, stroke, underlineStyle) {
37042
36897
  const lineWidthPx = underlineStyleLineWidthPx(underlineStyle);
37043
36898
  const drawAt = (yy, dash) => {
@@ -37052,8 +36907,8 @@ function drawUnderlineWithStyle(writer, pageIndex, x1, x2, y, stroke, underlineS
37052
36907
  });
37053
36908
  };
37054
36909
  if (isDoubleUnderlineStyle(underlineStyle)) {
37055
- drawAt(y - 1.5);
37056
- drawAt(y + 1.5);
36910
+ drawAt(y - DOUBLE_UNDERLINE_OFFSET_PX);
36911
+ drawAt(y + DOUBLE_UNDERLINE_OFFSET_PX);
37057
36912
  return;
37058
36913
  }
37059
36914
  if (isWavyUnderlineStyle(underlineStyle)) {
@@ -37063,12 +36918,10 @@ function drawUnderlineWithStyle(writer, pageIndex, x1, x2, y, stroke, underlineS
37063
36918
  drawAt(y, underlineStyleDashArray(underlineStyle));
37064
36919
  }
37065
36920
  function drawWavyUnderline(writer, pageIndex, x1, x2, y, stroke, lineWidthPx) {
37066
- const wavelength = 4;
37067
- const amplitude = 1.5;
37068
36921
  let prevX = x1;
37069
36922
  let prevY = y;
37070
36923
  for (let x = x1; x <= x2; x += 1) {
37071
- const dy = Math.sin((x - x1) / wavelength * Math.PI) * amplitude;
36924
+ const dy = Math.sin((x - x1) / WAVY_UNDERLINE_WAVELENGTH_PX * Math.PI) * WAVY_UNDERLINE_AMPLITUDE_PX;
37072
36925
  const curY = y + dy;
37073
36926
  writer.drawLine(pageIndex, {
37074
36927
  x1: pxToPt$1(prevX),
@@ -37082,124 +36935,273 @@ function drawWavyUnderline(writer, pageIndex, x1, x2, y, stroke, lineWidthPx) {
37082
36935
  prevY = curY;
37083
36936
  }
37084
36937
  }
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
+ });
36959
+ }
36960
+ }
36961
+ function drawTabLeaders(writer, pageIndex, paragraph, line, fragment, document2, originX, baselineY, color) {
36962
+ var _a2;
36963
+ const slotByOffset = new Map(
36964
+ line.slots.map((slot) => [slot.offset, slot])
36965
+ );
36966
+ const paragraphStyle = resolveEffectiveParagraphStyle(paragraph.style, document2.styles);
36967
+ const tabs = paragraphStyle.tabs ?? [];
36968
+ for (const char of fragment.chars) {
36969
+ if (char.char !== " ") continue;
36970
+ const slot = slotByOffset.get(char.paragraphOffset);
36971
+ const nextSlot = slotByOffset.get(char.paragraphOffset + 1);
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;
36978
+ const y = leader === "underscore" ? baselineY + 2 : baselineY;
36979
+ writer.drawLine(pageIndex, {
36980
+ x1: pxToPt$1(originX + slot.left),
36981
+ y1: pxToPt$1(y),
36982
+ x2: pxToPt$1(originX + nextSlot.left),
36983
+ y2: pxToPt$1(y),
36984
+ stroke: color,
36985
+ lineWidth: pxToPt$1(leader === "heavy" ? 1.5 : 1),
36986
+ dashArray: leader === "dot" || leader === "middleDot" ? [1, 3] : leader === "hyphen" ? [5, 3] : void 0
36987
+ });
36988
+ }
36989
+ }
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
36998
+ );
36999
+ }
37000
+ function emitTextChunk(ctx, leftPx, text) {
37001
+ const {
37002
+ writer,
37003
+ pageIndex,
37004
+ baselineY,
37005
+ fontSizePt,
37006
+ mainColor,
37007
+ gradientShadingName,
37008
+ styles,
37009
+ baseTextOptions
37010
+ } = ctx;
37011
+ const offsetPt = pxToPt$1(1);
37012
+ if (styles.emboss || styles.imprint) {
37013
+ const dir = styles.imprint ? 1 : -1;
37014
+ writer.drawText(pageIndex, {
37015
+ ...baseTextOptions,
37016
+ x: pxToPt$1(leftPx) + offsetPt * dir,
37017
+ y: pxToPt$1(baselineY) + offsetPt * dir,
37018
+ text,
37019
+ color: "#BFBFBF"
37020
+ });
37021
+ }
37022
+ if (styles.glow) {
37023
+ const gl = styles.glow;
37024
+ const r = pxToPt$1(gl.radiusPt * PX_PER_POINT) * 0.5;
37025
+ const glowColor = blendColorWithWhite(gl.color, (gl.alpha ?? 0.5) * 0.4);
37026
+ const dirs = [
37027
+ [r, 0],
37028
+ [-r, 0],
37029
+ [0, r],
37030
+ [0, -r],
37031
+ [r * 0.7, r * 0.7],
37032
+ [-r * 0.7, r * 0.7],
37033
+ [r * 0.7, -r * 0.7],
37034
+ [-r * 0.7, -r * 0.7]
37035
+ ];
37036
+ for (const [dx, dy] of dirs) {
37037
+ writer.drawText(pageIndex, {
37038
+ ...baseTextOptions,
37039
+ x: pxToPt$1(leftPx) + dx,
37040
+ y: pxToPt$1(baselineY) + dy,
37041
+ text,
37042
+ color: glowColor
37043
+ });
37044
+ }
37045
+ }
37046
+ if (styles.textShadow) {
37047
+ const ts = styles.textShadow;
37048
+ const dirRad = ts.dirDeg * Math.PI / 180;
37049
+ const shadowOffsetPt = pxToPt$1(ts.distPt * PX_PER_POINT);
37050
+ writer.drawText(pageIndex, {
37051
+ ...baseTextOptions,
37052
+ x: pxToPt$1(leftPx) + Math.cos(dirRad) * shadowOffsetPt,
37053
+ y: pxToPt$1(baselineY) + Math.sin(dirRad) * shadowOffsetPt,
37054
+ text,
37055
+ color: ts.color
37056
+ });
37057
+ } else if (styles.shadow) {
37058
+ writer.drawText(pageIndex, {
37059
+ ...baseTextOptions,
37060
+ x: pxToPt$1(leftPx) + offsetPt,
37061
+ y: pxToPt$1(baselineY) + offsetPt,
37062
+ text,
37063
+ color: "#808080"
37064
+ });
37065
+ }
37066
+ if (styles.reflection) {
37067
+ const ref = styles.reflection;
37068
+ const avgAlpha = (ref.startAlpha + ref.endAlpha) / 2;
37069
+ const refColor = blendColorWithWhite(mainColor, avgAlpha * 0.6);
37070
+ writer.drawText(pageIndex, {
37071
+ ...baseTextOptions,
37072
+ x: pxToPt$1(leftPx),
37073
+ y: pxToPt$1(baselineY) + pxToPt$1(ref.distPt * PX_PER_POINT) + fontSizePt,
37074
+ text,
37075
+ color: refColor
37076
+ });
37077
+ }
37078
+ const textOutline = styles.textOutline;
37079
+ writer.drawText(pageIndex, {
37080
+ ...baseTextOptions,
37081
+ x: pxToPt$1(leftPx),
37082
+ y: pxToPt$1(baselineY),
37083
+ text,
37084
+ color: mainColor,
37085
+ ...gradientShadingName ? { gradientShadingName } : textOutline ? { renderMode: 2, strokeColor: textOutline.color ?? mainColor, strokeWidth: textOutline.widthPt } : { renderMode: styles.outline ? 1 : 0 }
37086
+ });
37087
+ }
37085
37088
  function groupSlotChunksByWhitespace(chars) {
37086
37089
  const chunks = [];
37087
- let currentChunk = [];
37090
+ let current = [];
37088
37091
  for (const char of chars) {
37089
37092
  if (char.char === " ") {
37090
- if (currentChunk.length > 0) {
37091
- chunks.push(currentChunk);
37092
- currentChunk = [];
37093
+ if (current.length > 0) {
37094
+ chunks.push(current);
37095
+ current = [];
37093
37096
  }
37094
37097
  continue;
37095
37098
  }
37096
- currentChunk.push(char);
37097
- }
37098
- if (currentChunk.length > 0) {
37099
- chunks.push(currentChunk);
37099
+ current.push(char);
37100
37100
  }
37101
+ if (current.length > 0) chunks.push(current);
37101
37102
  return chunks;
37102
37103
  }
37103
37104
  function groupSlotChunksByOffsetGaps(chars) {
37104
37105
  const chunks = [];
37105
- let currentChunk = [];
37106
+ let current = [];
37106
37107
  for (const char of chars) {
37107
- const previous = currentChunk[currentChunk.length - 1];
37108
+ const previous = current[current.length - 1];
37108
37109
  if (previous && char.offset > previous.offset + 1) {
37109
- chunks.push(currentChunk);
37110
- currentChunk = [];
37110
+ chunks.push(current);
37111
+ current = [];
37111
37112
  }
37112
- currentChunk.push(char);
37113
- }
37114
- if (currentChunk.length > 0) {
37115
- chunks.push(currentChunk);
37113
+ current.push(char);
37116
37114
  }
37115
+ if (current.length > 0) chunks.push(current);
37117
37116
  return chunks;
37118
37117
  }
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;
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
+ });
37151
+ }
37128
37152
  }
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
37153
  }
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])
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
37137
37159
  );
37138
- for (const char of fragment.chars) {
37139
- if (char.char !== " ") {
37140
- continue;
37141
- }
37142
- const slot = slotByOffset.get(char.paragraphOffset);
37143
- 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
- }
37151
- const y = leader === "underscore" ? baselineY + 2 : baselineY;
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") {
37152
37166
  writer.drawLine(pageIndex, {
37153
- x1: pxToPt$1(originX + slot.left),
37167
+ x1: pxToPt$1(x1),
37154
37168
  y1: pxToPt$1(y),
37155
- x2: pxToPt$1(originX + nextSlot.left),
37169
+ x2: pxToPt$1(x2),
37156
37170
  y2: pxToPt$1(y),
37157
- stroke: color,
37158
- lineWidth: pxToPt$1(leader === "heavy" ? 1.5 : 1),
37159
- dashArray: leader === "dot" || leader === "middleDot" ? [1, 3] : leader === "hyphen" ? [5, 3] : void 0
37171
+ stroke,
37172
+ lineWidth: pxToPt$1(1)
37160
37173
  });
37161
- }
37162
- }
37163
- async function drawInlineTextBoxFragment(writer, pageIndex, line, fragment, document2, originX, originY, fontRegistry, drawers) {
37164
- const textBox = fragment.textBox;
37165
- if (!textBox || textBox.floating) {
37166
37174
  return;
37167
37175
  }
37168
- const slot = line.slots.find((candidate) => candidate.offset === fragment.startOffset) ?? line.slots.find((candidate) => candidate.offset >= fragment.startOffset);
37169
- if (!slot) {
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
+ });
37170
37193
  return;
37171
37194
  }
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
37181
- );
37195
+ drawUnderlineWithStyle(writer, pageIndex, x1, x2, y, stroke, styles.underlineStyle);
37182
37196
  }
37183
37197
  async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, document2, originX, originY, fontRegistry, drawers) {
37184
37198
  var _a2, _b2, _c;
37185
37199
  if (fragment.image) {
37186
- if (fragment.image.floating) {
37187
- return;
37188
- }
37189
- const slot = line.slots.find(
37190
- (candidate) => candidate.offset === fragment.startOffset
37191
- ) ?? line.slots.find((candidate) => candidate.offset >= fragment.startOffset);
37192
- if (!slot) {
37193
- return;
37194
- }
37195
- const resourceName = await registerPdfImageRun(
37196
- writer,
37197
- document2,
37198
- fragment.image
37199
- );
37200
- if (!resourceName) {
37201
- return;
37202
- }
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;
37203
37205
  writer.drawImage(pageIndex, {
37204
37206
  resourceName,
37205
37207
  x: pxToPt$1(originX + slot.left),
@@ -37211,15 +37213,17 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37211
37213
  return;
37212
37214
  }
37213
37215
  if (fragment.textBox) {
37214
- 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(
37215
37220
  writer,
37216
- pageIndex,
37217
- line,
37218
- fragment,
37219
- document2,
37220
- originX,
37221
- originY,
37222
- 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,
37223
37227
  drawers
37224
37228
  );
37225
37229
  return;
@@ -37229,9 +37233,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37229
37233
  (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
37230
37234
  document2.styles
37231
37235
  );
37232
- if (styles.hidden) {
37233
- return;
37234
- }
37236
+ if (styles.hidden) return;
37235
37237
  const fontFace = fontRegistry.resolveFontFace({
37236
37238
  fontFamily: styles.fontFamily,
37237
37239
  bold: styles.bold,
@@ -37243,9 +37245,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37243
37245
  const chars = resolveFragmentSlots(line, fragment);
37244
37246
  const text = chars.map((char) => styles.allCaps ? char.char.toUpperCase() : char.char).join("");
37245
37247
  const firstChar = chars[0];
37246
- if (!firstChar || text.length === 0) {
37247
- return;
37248
- }
37248
+ if (!firstChar || text.length === 0) return;
37249
37249
  if (styles.link) {
37250
37250
  const linkBounds = resolveFragmentBounds(
37251
37251
  line,
@@ -37263,49 +37263,12 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37263
37263
  });
37264
37264
  }
37265
37265
  }
37266
- drawFragmentShading(
37267
- writer,
37268
- pageIndex,
37269
- line,
37270
- fragment,
37271
- originX,
37272
- originY,
37273
- styles
37274
- );
37275
- drawFragmentHighlight(
37276
- writer,
37277
- pageIndex,
37278
- line,
37279
- fragment,
37280
- originX,
37281
- originY,
37282
- styles
37283
- );
37284
- drawFragmentBorder(
37285
- writer,
37286
- pageIndex,
37287
- line,
37288
- fragment,
37289
- originX,
37290
- originY,
37291
- styles
37292
- );
37293
- drawTabLeaders(
37294
- writer,
37295
- pageIndex,
37296
- paragraph,
37297
- line,
37298
- fragment,
37299
- document2,
37300
- originX,
37301
- baselineY,
37302
- styles.color ?? "#000000"
37303
- );
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");
37304
37270
  const paragraphAlign = resolveEffectiveParagraphStyle(paragraph.style, document2.styles).align ?? "left";
37305
- const fontFeatures = resolveOpenTypeFeatureTags(
37306
- styles,
37307
- textStyleToFontSizePt(styles)
37308
- );
37271
+ const fontFeatures = resolveOpenTypeFeatureTags(styles, textStyleToFontSizePt(styles));
37309
37272
  const baseTextOptions = {
37310
37273
  fontSize: fontSizePt,
37311
37274
  bold: styles.bold,
@@ -37325,148 +37288,37 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37325
37288
  originY,
37326
37289
  styles
37327
37290
  );
37328
- const offsetPt = pxToPt$1(1);
37329
- const emitChunk = (leftPx, text2) => {
37330
- if (styles.emboss || styles.imprint) {
37331
- const dir = styles.imprint ? 1 : -1;
37332
- writer.drawText(pageIndex, {
37333
- ...baseTextOptions,
37334
- x: pxToPt$1(leftPx) + offsetPt * dir,
37335
- y: pxToPt$1(baselineY) + offsetPt * dir,
37336
- text: text2,
37337
- color: "#BFBFBF"
37338
- });
37339
- }
37340
- if (styles.glow) {
37341
- const gl = styles.glow;
37342
- const r = pxToPt$1(gl.radiusPt * PX_PER_POINT) * 0.5;
37343
- const glowColor = blendColorWithWhite(gl.color, (gl.alpha ?? 0.5) * 0.4);
37344
- const dirs = [
37345
- [r, 0],
37346
- [-r, 0],
37347
- [0, r],
37348
- [0, -r],
37349
- [r * 0.7, r * 0.7],
37350
- [-r * 0.7, r * 0.7],
37351
- [r * 0.7, -r * 0.7],
37352
- [-r * 0.7, -r * 0.7]
37353
- ];
37354
- for (const [dx, dy] of dirs) {
37355
- writer.drawText(pageIndex, {
37356
- ...baseTextOptions,
37357
- x: pxToPt$1(leftPx) + dx,
37358
- y: pxToPt$1(baselineY) + dy,
37359
- text: text2,
37360
- color: glowColor
37361
- });
37362
- }
37363
- }
37364
- if (styles.textShadow) {
37365
- const ts = styles.textShadow;
37366
- const dirRad = ts.dirDeg * Math.PI / 180;
37367
- const shadowOffsetPt = pxToPt$1(ts.distPt * PX_PER_POINT);
37368
- writer.drawText(pageIndex, {
37369
- ...baseTextOptions,
37370
- x: pxToPt$1(leftPx) + Math.cos(dirRad) * shadowOffsetPt,
37371
- y: pxToPt$1(baselineY) + Math.sin(dirRad) * shadowOffsetPt,
37372
- text: text2,
37373
- color: ts.color
37374
- });
37375
- } else if (styles.shadow) {
37376
- writer.drawText(pageIndex, {
37377
- ...baseTextOptions,
37378
- x: pxToPt$1(leftPx) + offsetPt,
37379
- y: pxToPt$1(baselineY) + offsetPt,
37380
- text: text2,
37381
- color: "#808080"
37382
- });
37383
- }
37384
- if (styles.reflection) {
37385
- const ref = styles.reflection;
37386
- const avgAlpha = (ref.startAlpha + ref.endAlpha) / 2;
37387
- const refColor = blendColorWithWhite(mainColor, avgAlpha * 0.6);
37388
- writer.drawText(pageIndex, {
37389
- ...baseTextOptions,
37390
- x: pxToPt$1(leftPx),
37391
- y: pxToPt$1(baselineY) + pxToPt$1(ref.distPt * PX_PER_POINT) + fontSizePt,
37392
- text: text2,
37393
- color: refColor
37394
- });
37395
- }
37396
- const textOutline = styles.textOutline;
37397
- writer.drawText(pageIndex, {
37398
- ...baseTextOptions,
37399
- x: pxToPt$1(leftPx),
37400
- y: pxToPt$1(baselineY),
37401
- text: text2,
37402
- color: mainColor,
37403
- // A gradient fill paints the glyphs via the shading clip; it supersedes
37404
- // both the solid color and any outline/stroke render mode.
37405
- ...gradientShadingName ? { gradientShadingName } : textOutline ? {
37406
- renderMode: 2,
37407
- strokeColor: textOutline.color ?? mainColor,
37408
- strokeWidth: textOutline.widthPt
37409
- } : { renderMode: styles.outline ? 1 : 0 }
37410
- });
37291
+ const chunkCtx = {
37292
+ writer,
37293
+ pageIndex,
37294
+ baselineY,
37295
+ fontSizePt,
37296
+ mainColor,
37297
+ gradientShadingName,
37298
+ styles,
37299
+ baseTextOptions
37411
37300
  };
37412
37301
  const chunks = paragraphAlign === "justify" ? groupSlotChunksByWhitespace(chars) : groupSlotChunksByOffsetGaps(chars);
37413
37302
  for (const chunk of chunks) {
37414
37303
  const chunkText = chunk.map((c) => styles.allCaps ? c.char.toUpperCase() : c.char).join("");
37415
37304
  if (chunkText.length === 0) continue;
37416
- emitChunk(originX + chunk[0].left, chunkText);
37305
+ emitTextChunk(chunkCtx, originX + chunk[0].left, chunkText);
37417
37306
  }
37418
37307
  if (line.trailingHyphen && fragment.endOffset >= line.endOffset) {
37419
37308
  const endSlot = line.slots.find((slot) => slot.offset === line.endOffset) ?? line.slots[line.slots.length - 1];
37420
- if (endSlot) {
37421
- emitChunk(originX + endSlot.left, "-");
37422
- }
37309
+ if (endSlot) emitTextChunk(chunkCtx, originX + endSlot.left, "-");
37423
37310
  }
37424
37311
  if (styles.underline) {
37425
- drawFragmentDecoration(
37426
- writer,
37427
- pageIndex,
37428
- line,
37429
- fragment,
37430
- originX,
37431
- originY,
37432
- styles,
37433
- "underline"
37434
- );
37312
+ drawFragmentDecoration(writer, pageIndex, line, fragment, originX, originY, styles, "underline");
37435
37313
  }
37436
37314
  if (styles.strike) {
37437
- drawFragmentDecoration(
37438
- writer,
37439
- pageIndex,
37440
- line,
37441
- fragment,
37442
- originX,
37443
- originY,
37444
- styles,
37445
- "strike"
37446
- );
37315
+ drawFragmentDecoration(writer, pageIndex, line, fragment, originX, originY, styles, "strike");
37447
37316
  }
37448
37317
  if (styles.doubleStrike) {
37449
- drawFragmentDecoration(
37450
- writer,
37451
- pageIndex,
37452
- line,
37453
- fragment,
37454
- originX,
37455
- originY,
37456
- styles,
37457
- "doubleStrike"
37458
- );
37318
+ drawFragmentDecoration(writer, pageIndex, line, fragment, originX, originY, styles, "doubleStrike");
37459
37319
  }
37460
37320
  if (styles.emphasisMark) {
37461
- drawFragmentEmphasis(
37462
- writer,
37463
- pageIndex,
37464
- line,
37465
- fragment,
37466
- originX,
37467
- originY,
37468
- styles
37469
- );
37321
+ drawFragmentEmphasis(writer, pageIndex, line, fragment, originX, originY, styles);
37470
37322
  }
37471
37323
  }
37472
37324
  function getListOrdinals(document2) {
@@ -38529,6 +38381,16 @@ class PdfContentStream {
38529
38381
  );
38530
38382
  }
38531
38383
  }
38384
+ function readU16Array(reader, count) {
38385
+ const array = new Array(count);
38386
+ for (let i = 0; i < count; i += 1) array[i] = reader.u16();
38387
+ return array;
38388
+ }
38389
+ function readU16OffsetArray(reader, count, baseOffset) {
38390
+ const array = new Array(count);
38391
+ for (let i = 0; i < count; i += 1) array[i] = baseOffset + reader.u16();
38392
+ return array;
38393
+ }
38532
38394
  function parseCoverage(reader, offset) {
38533
38395
  reader.seek(offset);
38534
38396
  const format = reader.u16();
@@ -38566,10 +38428,7 @@ function parseClassDef(reader, offset) {
38566
38428
  if (format === 1) {
38567
38429
  const startGlyph = reader.u16();
38568
38430
  const glyphCount = reader.u16();
38569
- const classes = new Array(glyphCount);
38570
- for (let i = 0; i < glyphCount; i += 1) {
38571
- classes[i] = reader.u16();
38572
- }
38431
+ const classes = readU16Array(reader, glyphCount);
38573
38432
  return (glyphId) => {
38574
38433
  const index = glyphId - startGlyph;
38575
38434
  return index >= 0 && index < glyphCount ? classes[index] : 0;
@@ -38608,10 +38467,7 @@ function parseFeatureList(reader, featureListOffset) {
38608
38467
  reader.seek(offset);
38609
38468
  reader.skip(2);
38610
38469
  const lookupIndexCount = reader.u16();
38611
- const lookupIndices = new Array(lookupIndexCount);
38612
- for (let i = 0; i < lookupIndexCount; i += 1) {
38613
- lookupIndices[i] = reader.u16();
38614
- }
38470
+ const lookupIndices = readU16Array(reader, lookupIndexCount);
38615
38471
  return { tag, lookupIndices };
38616
38472
  });
38617
38473
  }
@@ -38663,6 +38519,26 @@ function parseLayoutTableHeader(reader) {
38663
38519
  }
38664
38520
  return { featureToLookups, lookupListOffset };
38665
38521
  }
38522
+ function parseLookupList(reader, lookupListOffset, parseSubtable2) {
38523
+ reader.seek(lookupListOffset);
38524
+ const lookupCount = reader.u16();
38525
+ const lookupOffsets = readU16OffsetArray(reader, lookupCount, lookupListOffset);
38526
+ return lookupOffsets.map((lookupOffset) => {
38527
+ reader.seek(lookupOffset);
38528
+ const lookupType = reader.u16();
38529
+ reader.skip(2);
38530
+ const subtableOffsets = readU16OffsetArray(reader, reader.u16(), lookupOffset);
38531
+ const subtables = [];
38532
+ for (const subtableOffset of subtableOffsets) {
38533
+ try {
38534
+ const subtable = parseSubtable2(reader, subtableOffset, lookupType);
38535
+ if (subtable) subtables.push(subtable);
38536
+ } catch {
38537
+ }
38538
+ }
38539
+ return { lookupType, subtables };
38540
+ });
38541
+ }
38666
38542
  function collectLookupIndices(featureToLookups, tags) {
38667
38543
  const indices = /* @__PURE__ */ new Set();
38668
38544
  for (const tag of tags) {
@@ -38690,10 +38566,7 @@ function parseSingleSubst(reader, offset) {
38690
38566
  }
38691
38567
  if (format === 2) {
38692
38568
  const glyphCount = reader.u16();
38693
- const substitutes = new Array(glyphCount);
38694
- for (let i = 0; i < glyphCount; i += 1) {
38695
- substitutes[i] = reader.u16();
38696
- }
38569
+ const substitutes = readU16Array(reader, glyphCount);
38697
38570
  const coverage = parseCoverage(reader, coverageOffset);
38698
38571
  return {
38699
38572
  apply(glyphs, pos) {
@@ -38708,24 +38581,22 @@ function parseSingleSubst(reader, offset) {
38708
38581
  }
38709
38582
  return null;
38710
38583
  }
38711
- function parseMultipleSubst(reader, offset) {
38584
+ function parseGlyphSetArray(reader, offset) {
38712
38585
  reader.seek(offset);
38713
- const format = reader.u16();
38714
- if (format !== 1) return null;
38586
+ if (reader.u16() !== 1) return null;
38715
38587
  const coverageOffset = offset + reader.u16();
38716
- const sequenceCount = reader.u16();
38717
- const sequenceOffsets = new Array(sequenceCount);
38718
- for (let i = 0; i < sequenceCount; i += 1) {
38719
- sequenceOffsets[i] = offset + reader.u16();
38720
- }
38721
- const sequences = sequenceOffsets.map((seqOffset) => {
38722
- reader.seek(seqOffset);
38723
- const glyphCount = reader.u16();
38724
- const ids = new Array(glyphCount);
38725
- for (let i = 0; i < glyphCount; i += 1) ids[i] = reader.u16();
38726
- return ids;
38588
+ const count = reader.u16();
38589
+ const setOffsets = readU16OffsetArray(reader, count, offset);
38590
+ const sets = setOffsets.map((setOffset) => {
38591
+ reader.seek(setOffset);
38592
+ return readU16Array(reader, reader.u16());
38727
38593
  });
38728
- const coverage = parseCoverage(reader, coverageOffset);
38594
+ return { coverage: parseCoverage(reader, coverageOffset), sets };
38595
+ }
38596
+ function parseMultipleSubst(reader, offset) {
38597
+ const parsed = parseGlyphSetArray(reader, offset);
38598
+ if (!parsed) return null;
38599
+ const { coverage, sets: sequences } = parsed;
38729
38600
  return {
38730
38601
  apply(glyphs, pos) {
38731
38602
  const glyph = glyphs[pos];
@@ -38745,23 +38616,9 @@ function parseMultipleSubst(reader, offset) {
38745
38616
  };
38746
38617
  }
38747
38618
  function parseAlternateSubst(reader, offset) {
38748
- reader.seek(offset);
38749
- const format = reader.u16();
38750
- if (format !== 1) return null;
38751
- const coverageOffset = offset + reader.u16();
38752
- const altSetCount = reader.u16();
38753
- const altSetOffsets = new Array(altSetCount);
38754
- for (let i = 0; i < altSetCount; i += 1) {
38755
- altSetOffsets[i] = offset + reader.u16();
38756
- }
38757
- const altSets = altSetOffsets.map((setOffset) => {
38758
- reader.seek(setOffset);
38759
- const glyphCount = reader.u16();
38760
- const ids = new Array(glyphCount);
38761
- for (let i = 0; i < glyphCount; i += 1) ids[i] = reader.u16();
38762
- return ids;
38763
- });
38764
- const coverage = parseCoverage(reader, coverageOffset);
38619
+ const parsed = parseGlyphSetArray(reader, offset);
38620
+ if (!parsed) return null;
38621
+ const { coverage, sets: altSets } = parsed;
38765
38622
  return {
38766
38623
  apply(glyphs, pos) {
38767
38624
  const glyph = glyphs[pos];
@@ -38781,25 +38638,15 @@ function parseLigatureSubst(reader, offset) {
38781
38638
  if (format !== 1) return null;
38782
38639
  const coverageOffset = offset + reader.u16();
38783
38640
  const ligSetCount = reader.u16();
38784
- const ligSetOffsets = new Array(ligSetCount);
38785
- for (let i = 0; i < ligSetCount; i += 1) {
38786
- ligSetOffsets[i] = offset + reader.u16();
38787
- }
38641
+ const ligSetOffsets = readU16OffsetArray(reader, ligSetCount, offset);
38788
38642
  const ligatureSets = ligSetOffsets.map((setOffset) => {
38789
38643
  reader.seek(setOffset);
38790
- const ligCount = reader.u16();
38791
- const ligOffsets = new Array(ligCount);
38792
- for (let i = 0; i < ligCount; i += 1) {
38793
- ligOffsets[i] = setOffset + reader.u16();
38794
- }
38644
+ const ligOffsets = readU16OffsetArray(reader, reader.u16(), setOffset);
38795
38645
  return ligOffsets.map((ligOffset) => {
38796
38646
  reader.seek(ligOffset);
38797
38647
  const ligatureGlyph = reader.u16();
38798
38648
  const componentCount = reader.u16();
38799
- const components = new Array(Math.max(0, componentCount - 1));
38800
- for (let i = 0; i < components.length; i += 1) {
38801
- components[i] = reader.u16();
38802
- }
38649
+ const components = readU16Array(reader, Math.max(0, componentCount - 1));
38803
38650
  return { ligatureGlyph, components };
38804
38651
  });
38805
38652
  });
@@ -38858,21 +38705,9 @@ function parseChainContextSubst(reader, offset) {
38858
38705
  reader.seek(offset);
38859
38706
  const format = reader.u16();
38860
38707
  if (format === 3) {
38861
- const backtrackCount = reader.u16();
38862
- const backtrackCoverageOffsets = new Array(backtrackCount);
38863
- for (let i = 0; i < backtrackCount; i += 1) {
38864
- backtrackCoverageOffsets[i] = offset + reader.u16();
38865
- }
38866
- const inputCount = reader.u16();
38867
- const inputCoverageOffsets = new Array(inputCount);
38868
- for (let i = 0; i < inputCount; i += 1) {
38869
- inputCoverageOffsets[i] = offset + reader.u16();
38870
- }
38871
- const lookaheadCount = reader.u16();
38872
- const lookaheadCoverageOffsets = new Array(lookaheadCount);
38873
- for (let i = 0; i < lookaheadCount; i += 1) {
38874
- lookaheadCoverageOffsets[i] = offset + reader.u16();
38875
- }
38708
+ const backtrackCoverageOffsets = readU16OffsetArray(reader, reader.u16(), offset);
38709
+ const inputCoverageOffsets = readU16OffsetArray(reader, reader.u16(), offset);
38710
+ const lookaheadCoverageOffsets = readU16OffsetArray(reader, reader.u16(), offset);
38876
38711
  const substCount = reader.u16();
38877
38712
  const records = readSubstLookupRecords(reader, substCount);
38878
38713
  const backtrack = backtrackCoverageOffsets.map(
@@ -38905,10 +38740,7 @@ function parseChainContextSubst(reader, offset) {
38905
38740
  if (format === 1) {
38906
38741
  const coverageOffset = offset + reader.u16();
38907
38742
  const ruleSetCount = reader.u16();
38908
- const ruleSetOffsets = new Array(ruleSetCount);
38909
- for (let i = 0; i < ruleSetCount; i += 1) {
38910
- ruleSetOffsets[i] = offset + reader.u16();
38911
- }
38743
+ const ruleSetOffsets = readU16OffsetArray(reader, ruleSetCount, offset);
38912
38744
  const coverage = parseCoverage(reader, coverageOffset);
38913
38745
  const ruleSets = ruleSetOffsets.map(
38914
38746
  (setOffset) => parseChainRuleSet(reader, setOffset)
@@ -38962,23 +38794,13 @@ function parseChainContextSubst(reader, offset) {
38962
38794
  function parseChainRuleSet(reader, setOffset) {
38963
38795
  reader.seek(setOffset);
38964
38796
  const ruleCount = reader.u16();
38965
- const ruleOffsets = new Array(ruleCount);
38966
- for (let i = 0; i < ruleCount; i += 1) {
38967
- ruleOffsets[i] = setOffset + reader.u16();
38968
- }
38797
+ const ruleOffsets = readU16OffsetArray(reader, ruleCount, setOffset);
38969
38798
  return ruleOffsets.map((ruleOffset) => {
38970
38799
  reader.seek(ruleOffset);
38971
- const backtrackCount = reader.u16();
38972
- const backtrack = new Array(backtrackCount);
38973
- for (let i = 0; i < backtrackCount; i += 1) backtrack[i] = reader.u16();
38974
- const inputCount = reader.u16();
38975
- const input = new Array(Math.max(0, inputCount - 1));
38976
- for (let i = 0; i < input.length; i += 1) input[i] = reader.u16();
38977
- const lookaheadCount = reader.u16();
38978
- const lookahead = new Array(lookaheadCount);
38979
- for (let i = 0; i < lookaheadCount; i += 1) lookahead[i] = reader.u16();
38980
- const substCount = reader.u16();
38981
- const records = readSubstLookupRecords(reader, substCount);
38800
+ const backtrack = readU16Array(reader, reader.u16());
38801
+ const input = readU16Array(reader, Math.max(0, reader.u16() - 1));
38802
+ const lookahead = readU16Array(reader, reader.u16());
38803
+ const records = readSubstLookupRecords(reader, reader.u16());
38982
38804
  return { backtrack, input, lookahead, records };
38983
38805
  });
38984
38806
  }
@@ -39055,7 +38877,7 @@ class GsubTable {
39055
38877
  try {
39056
38878
  const reader = new BinaryReader(bytes);
39057
38879
  const { featureToLookups, lookupListOffset } = parseLayoutTableHeader(reader);
39058
- const lookups = parseLookupList$1(reader, lookupListOffset);
38880
+ const lookups = parseLookupList(reader, lookupListOffset, parseSubtable$1);
39059
38881
  return new GsubTable(lookups, featureToLookups);
39060
38882
  } catch {
39061
38883
  return null;
@@ -39096,33 +38918,6 @@ class GsubTable {
39096
38918
  }
39097
38919
  }
39098
38920
  }
39099
- function parseLookupList$1(reader, lookupListOffset) {
39100
- reader.seek(lookupListOffset);
39101
- const lookupCount = reader.u16();
39102
- const lookupOffsets = new Array(lookupCount);
39103
- for (let i = 0; i < lookupCount; i += 1) {
39104
- lookupOffsets[i] = lookupListOffset + reader.u16();
39105
- }
39106
- return lookupOffsets.map((lookupOffset) => {
39107
- reader.seek(lookupOffset);
39108
- const lookupType = reader.u16();
39109
- reader.skip(2);
39110
- const subTableCount = reader.u16();
39111
- const subtableOffsets = new Array(subTableCount);
39112
- for (let i = 0; i < subTableCount; i += 1) {
39113
- subtableOffsets[i] = lookupOffset + reader.u16();
39114
- }
39115
- const subtables = [];
39116
- for (const subtableOffset of subtableOffsets) {
39117
- try {
39118
- const subtable = parseSubtable$1(reader, subtableOffset, lookupType);
39119
- if (subtable) subtables.push(subtable);
39120
- } catch {
39121
- }
39122
- }
39123
- return { lookupType, subtables };
39124
- });
39125
- }
39126
38921
  const X_PLACEMENT = 1;
39127
38922
  const Y_PLACEMENT = 2;
39128
38923
  const X_ADVANCE = 4;
@@ -39200,10 +38995,7 @@ function parsePairPos(reader, offset) {
39200
38995
  const hasSecondAdjustment = (valueFormat2 & X_ADVANCE) !== 0;
39201
38996
  if (format === 1) {
39202
38997
  const pairSetCount = reader.u16();
39203
- const pairSetOffsets = new Array(pairSetCount);
39204
- for (let i = 0; i < pairSetCount; i += 1) {
39205
- pairSetOffsets[i] = offset + reader.u16();
39206
- }
38998
+ const pairSetOffsets = readU16OffsetArray(reader, pairSetCount, offset);
39207
38999
  const pairSets = pairSetOffsets.map(
39208
39000
  (setOffset) => {
39209
39001
  reader.seek(setOffset);
@@ -39305,33 +39097,6 @@ function parseSubtable(reader, offset, lookupType) {
39305
39097
  return null;
39306
39098
  }
39307
39099
  }
39308
- function parseLookupList(reader, lookupListOffset) {
39309
- reader.seek(lookupListOffset);
39310
- const lookupCount = reader.u16();
39311
- const lookupOffsets = new Array(lookupCount);
39312
- for (let i = 0; i < lookupCount; i += 1) {
39313
- lookupOffsets[i] = lookupListOffset + reader.u16();
39314
- }
39315
- return lookupOffsets.map((lookupOffset) => {
39316
- reader.seek(lookupOffset);
39317
- const lookupType = reader.u16();
39318
- reader.skip(2);
39319
- const subTableCount = reader.u16();
39320
- const subtableOffsets = new Array(subTableCount);
39321
- for (let i = 0; i < subTableCount; i += 1) {
39322
- subtableOffsets[i] = lookupOffset + reader.u16();
39323
- }
39324
- const subtables = [];
39325
- for (const subtableOffset of subtableOffsets) {
39326
- try {
39327
- const subtable = parseSubtable(reader, subtableOffset, lookupType);
39328
- if (subtable) subtables.push(subtable);
39329
- } catch {
39330
- }
39331
- }
39332
- return { lookupType, subtables };
39333
- });
39334
- }
39335
39100
  class GposTable {
39336
39101
  constructor(lookups, featureToLookups) {
39337
39102
  this.lookups = lookups;
@@ -39342,7 +39107,7 @@ class GposTable {
39342
39107
  try {
39343
39108
  const reader = new BinaryReader(bytes);
39344
39109
  const { featureToLookups, lookupListOffset } = parseLayoutTableHeader(reader);
39345
- const lookups = parseLookupList(reader, lookupListOffset);
39110
+ const lookups = parseLookupList(reader, lookupListOffset, parseSubtable);
39346
39111
  return new GposTable(lookups, featureToLookups);
39347
39112
  } catch {
39348
39113
  return null;
@@ -47086,6 +46851,111 @@ function createEditorSurfaceEvents(deps) {
47086
46851
  stopDragging();
47087
46852
  deps.focusInputAfterPointerSelection();
47088
46853
  };
46854
+ const handleZoneTransitionDown = (state, hit, clickDetail) => {
46855
+ if (clickDetail < 2) {
46856
+ dragAnchor = null;
46857
+ stopDragging();
46858
+ deps.focusInputAfterPointerSelection();
46859
+ return;
46860
+ }
46861
+ dragAnchor = null;
46862
+ if (hit.resolvedFromParagraph) {
46863
+ applyWithZone(
46864
+ state,
46865
+ hit.zone,
46866
+ {
46867
+ ...state,
46868
+ selection: { anchor: { ...hit.position }, focus: { ...hit.position } }
46869
+ },
46870
+ hit.position
46871
+ );
46872
+ } else {
46873
+ applyWithZone(state, hit.zone, state);
46874
+ }
46875
+ stopDragging();
46876
+ deps.focusInputAfterPointerSelection();
46877
+ };
46878
+ const handleTextBoxDown = (state, hit) => {
46879
+ const textBoxParagraph = deps.getParagraphById(
46880
+ state.document,
46881
+ hit.textBox.paragraphId
46882
+ );
46883
+ if (!textBoxParagraph) {
46884
+ deps.focusInputAfterPointerSelection();
46885
+ return;
46886
+ }
46887
+ dragAnchor = null;
46888
+ const start = paragraphOffsetToPosition(textBoxParagraph, hit.textBox.startOffset);
46889
+ const end = paragraphOffsetToPosition(textBoxParagraph, hit.textBox.endOffset);
46890
+ applyWithZone(state, hit.zone, setSelection(state, { anchor: start, focus: end }), start);
46891
+ stopDragging();
46892
+ deps.focusInputAfterPointerSelection();
46893
+ };
46894
+ const handleImageDown = (state, hit, event) => {
46895
+ const imageParagraph = deps.getParagraphById(
46896
+ state.document,
46897
+ hit.image.paragraphId
46898
+ );
46899
+ if (!imageParagraph) {
46900
+ deps.focusInputAfterPointerSelection();
46901
+ return;
46902
+ }
46903
+ dragAnchor = null;
46904
+ const start = paragraphOffsetToPosition(imageParagraph, hit.image.startOffset);
46905
+ const end = paragraphOffsetToPosition(imageParagraph, hit.image.endOffset);
46906
+ applyWithZone(state, hit.zone, setSelection(state, { anchor: start, focus: end }), start);
46907
+ stopDragging();
46908
+ deps.imageOps.startImageDrag(
46909
+ hit.image.paragraphId,
46910
+ hit.image.startOffset,
46911
+ event,
46912
+ {
46913
+ left: hit.image.left,
46914
+ top: hit.image.top,
46915
+ width: hit.image.width,
46916
+ height: hit.image.height
46917
+ }
46918
+ );
46919
+ deps.focusInputAfterPointerSelection();
46920
+ };
46921
+ const handleShiftClickDown = (state, hit) => {
46922
+ dragAnchor = state.selection.anchor;
46923
+ applyWithZone(
46924
+ state,
46925
+ hit.zone,
46926
+ setSelection(state, { anchor: state.selection.anchor, focus: hit.position }),
46927
+ hit.position
46928
+ );
46929
+ window.addEventListener("mousemove", handleWindowMouseMove);
46930
+ window.addEventListener("mouseup", handleWindowMouseUp);
46931
+ deps.focusInputAfterPointerSelection();
46932
+ };
46933
+ const handleTripleClickDown = (state, hit, paragraph) => {
46934
+ dragAnchor = null;
46935
+ const range = resolveTripleClickParagraphRange(state, paragraph, hit.zone);
46936
+ applyWithZone(
46937
+ state,
46938
+ hit.zone,
46939
+ setSelection(state, { anchor: range.start, focus: range.end }),
46940
+ range.start
46941
+ );
46942
+ stopDragging();
46943
+ deps.focusInputAfterPointerSelection();
46944
+ };
46945
+ const handleDoubleClickDown = (state, hit, paragraph) => {
46946
+ dragAnchor = null;
46947
+ const word = resolveWordSelection(getParagraphText(paragraph), hit.paragraphOffset);
46948
+ const startPos = paragraphOffsetToPosition(paragraph, word.start);
46949
+ const endPos = paragraphOffsetToPosition(paragraph, word.end);
46950
+ applyWithZone(
46951
+ state,
46952
+ hit.zone,
46953
+ setSelection(state, { anchor: startPos, focus: endPos }),
46954
+ startPos
46955
+ );
46956
+ stopDragging();
46957
+ deps.focusInputAfterPointerSelection();
46958
+ };
47089
46959
  const handleSurfaceMouseDown = (event) => {
47090
46960
  var _a2;
47091
46961
  if (event.button !== 0) {
@@ -47131,155 +47001,27 @@ function createEditorSurfaceEvents(deps) {
47131
47001
  const paragraph = deps.getParagraphById(state.document, hit.paragraphId);
47132
47002
  const isZoneTransition = hit.zone !== (state.activeZone ?? "main");
47133
47003
  if (isZoneTransition) {
47134
- if (clickDetail < 2) {
47135
- dragAnchor = null;
47136
- stopDragging();
47137
- deps.focusInputAfterPointerSelection();
47138
- return;
47139
- }
47140
- dragAnchor = null;
47141
- if (hit.resolvedFromParagraph) {
47142
- applyWithZone(
47143
- state,
47144
- hit.zone,
47145
- {
47146
- ...state,
47147
- selection: {
47148
- anchor: { ...hit.position },
47149
- focus: { ...hit.position }
47150
- }
47151
- },
47152
- hit.position
47153
- );
47154
- } else {
47155
- applyWithZone(state, hit.zone, state);
47156
- }
47157
- stopDragging();
47158
- deps.focusInputAfterPointerSelection();
47004
+ handleZoneTransitionDown(state, hit, clickDetail);
47159
47005
  return;
47160
47006
  }
47161
47007
  if (hit.textBox) {
47162
- const textBoxParagraph = deps.getParagraphById(
47163
- state.document,
47164
- hit.textBox.paragraphId
47165
- );
47166
- if (!textBoxParagraph) {
47167
- deps.focusInputAfterPointerSelection();
47168
- return;
47169
- }
47170
- dragAnchor = null;
47171
- const start = paragraphOffsetToPosition(
47172
- textBoxParagraph,
47173
- hit.textBox.startOffset
47174
- );
47175
- const end = paragraphOffsetToPosition(
47176
- textBoxParagraph,
47177
- hit.textBox.endOffset
47178
- );
47179
- applyWithZone(
47180
- state,
47181
- hit.zone,
47182
- setSelection(state, {
47183
- anchor: start,
47184
- focus: end
47185
- }),
47186
- start
47187
- );
47188
- stopDragging();
47189
- deps.focusInputAfterPointerSelection();
47008
+ handleTextBoxDown(state, hit);
47190
47009
  return;
47191
47010
  }
47192
47011
  if (hit.image) {
47193
- const imageParagraph = deps.getParagraphById(
47194
- state.document,
47195
- hit.image.paragraphId
47196
- );
47197
- if (!imageParagraph) {
47198
- deps.focusInputAfterPointerSelection();
47199
- return;
47200
- }
47201
- dragAnchor = null;
47202
- const start = paragraphOffsetToPosition(
47203
- imageParagraph,
47204
- hit.image.startOffset
47205
- );
47206
- const end = paragraphOffsetToPosition(
47207
- imageParagraph,
47208
- hit.image.endOffset
47209
- );
47210
- applyWithZone(
47211
- state,
47212
- hit.zone,
47213
- setSelection(state, {
47214
- anchor: start,
47215
- focus: end
47216
- }),
47217
- start
47218
- );
47219
- stopDragging();
47220
- deps.imageOps.startImageDrag(
47221
- hit.image.paragraphId,
47222
- hit.image.startOffset,
47223
- event,
47224
- {
47225
- left: hit.image.left,
47226
- top: hit.image.top,
47227
- width: hit.image.width,
47228
- height: hit.image.height
47229
- }
47230
- );
47231
- deps.focusInputAfterPointerSelection();
47012
+ handleImageDown(state, hit, event);
47232
47013
  return;
47233
47014
  }
47234
47015
  if (event.shiftKey && hit.resolvedFromParagraph) {
47235
- dragAnchor = state.selection.anchor;
47236
- applyWithZone(
47237
- state,
47238
- hit.zone,
47239
- setSelection(state, {
47240
- anchor: state.selection.anchor,
47241
- focus: hit.position
47242
- }),
47243
- hit.position
47244
- );
47245
- window.addEventListener("mousemove", handleWindowMouseMove);
47246
- window.addEventListener("mouseup", handleWindowMouseUp);
47247
- deps.focusInputAfterPointerSelection();
47016
+ handleShiftClickDown(state, hit);
47248
47017
  return;
47249
47018
  }
47250
47019
  if (clickDetail >= 3 && paragraph) {
47251
- dragAnchor = null;
47252
- const range = resolveTripleClickParagraphRange(
47253
- state,
47254
- paragraph,
47255
- hit.zone
47256
- );
47257
- applyWithZone(
47258
- state,
47259
- hit.zone,
47260
- setSelection(state, { anchor: range.start, focus: range.end }),
47261
- range.start
47262
- );
47263
- stopDragging();
47264
- deps.focusInputAfterPointerSelection();
47020
+ handleTripleClickDown(state, hit, paragraph);
47265
47021
  return;
47266
47022
  }
47267
47023
  if (clickDetail === 2 && paragraph) {
47268
- dragAnchor = null;
47269
- const word = resolveWordSelection(
47270
- getParagraphText(paragraph),
47271
- hit.paragraphOffset
47272
- );
47273
- const startPos = paragraphOffsetToPosition(paragraph, word.start);
47274
- const endPos = paragraphOffsetToPosition(paragraph, word.end);
47275
- applyWithZone(
47276
- state,
47277
- hit.zone,
47278
- setSelection(state, { anchor: startPos, focus: endPos }),
47279
- startPos
47280
- );
47281
- stopDragging();
47282
- deps.focusInputAfterPointerSelection();
47024
+ handleDoubleClickDown(state, hit, paragraph);
47283
47025
  return;
47284
47026
  }
47285
47027
  if (!hit.resolvedFromParagraph) {