oasis-editor 0.0.131 → 0.0.133

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 (78) hide show
  1. package/dist/{OasisEditorApp-Dn2I2b-M.js → OasisEditorApp-DmXn9H33.js} +716 -684
  2. package/dist/adapters/mountController.d.ts +12 -0
  3. package/dist/adapters/vue.d.ts +5 -5
  4. package/dist/app/controllers/EditorCommandRegistry.d.ts +2 -1
  5. package/dist/app/controllers/tableResize/tableResizeUnits.d.ts +3 -1
  6. package/dist/assets/{importDocxWorker-DdpdjbOY.js → importDocxWorker-CCwhxVSR.js} +1 -1
  7. package/dist/core/commands/builtinCommands.d.ts +1 -1
  8. package/dist/core/editorState/defaultStyles.d.ts +3 -0
  9. package/dist/core/editorState/documentFactories.d.ts +8 -0
  10. package/dist/core/editorState/nodeFactories.d.ts +35 -0
  11. package/dist/core/editorState/stateFactories.d.ts +26 -0
  12. package/dist/core/editorState.d.ts +4 -66
  13. package/dist/core/units/parseUnitToPt.d.ts +6 -0
  14. package/dist/export/docx/xmlUtils.d.ts +2 -0
  15. package/dist/import/docx/runs/drawingAnchorLayout.d.ts +12 -0
  16. package/dist/{index-BXo_oqOC.js → index-BOj4-NlJ.js} +2244 -2177
  17. package/dist/layoutProjection/presetGeometry/families/arrows.d.ts +3 -0
  18. package/dist/layoutProjection/presetGeometry/families/banners.d.ts +5 -0
  19. package/dist/layoutProjection/presetGeometry/families/bracesBrackets.d.ts +4 -0
  20. package/dist/layoutProjection/presetGeometry/families/callouts.d.ts +3 -0
  21. package/dist/layoutProjection/presetGeometry/families/connectors.d.ts +3 -0
  22. package/dist/layoutProjection/presetGeometry/families/containers3d.d.ts +11 -0
  23. package/dist/layoutProjection/presetGeometry/families/decorative.d.ts +9 -0
  24. package/dist/layoutProjection/presetGeometry/families/flowchart.d.ts +4 -0
  25. package/dist/layoutProjection/presetGeometry/families/mathSymbols.d.ts +8 -0
  26. package/dist/layoutProjection/presetGeometry/families/rectVariants.d.ts +5 -0
  27. package/dist/mountController-D2srsZ5t.js +15 -0
  28. package/dist/mountController.d.ts +12 -0
  29. package/dist/oasis-editor.css +1 -1
  30. package/dist/oasis-editor.js +54 -54
  31. package/dist/oasis-editor.umd.cjs +4 -4
  32. package/dist/plugins/internal/essentialsCapabilities.d.ts +2 -1
  33. package/dist/plugins/internal/essentialsCommandBuilders.d.ts +8 -7
  34. package/dist/plugins/internal/essentialsCommandGroups/coreFormatting.d.ts +17 -0
  35. package/dist/plugins/internal/essentialsCommandGroups/documentAndBrowser.d.ts +15 -0
  36. package/dist/plugins/internal/essentialsCommandGroups/paragraphAndSection.d.ts +13 -0
  37. package/dist/plugins/internal/essentialsCommandGroups/table.d.ts +11 -0
  38. package/dist/react.js +14 -15
  39. package/dist/text/fontMetricsUtil.d.ts +16 -0
  40. package/dist/text/fonts/opentype/extensionLookup.d.ts +9 -0
  41. package/dist/ui/EditorImportProgressOverlay.d.ts +7 -0
  42. package/dist/ui/EditorStatusBar.d.ts +13 -0
  43. package/dist/ui/OasisEditorEditor.d.ts +3 -117
  44. package/dist/ui/OasisEditorEditorProps.d.ts +118 -0
  45. package/dist/ui/app/createEditorEssentialsPlugin.d.ts +2 -41
  46. package/dist/ui/app/essentials/browser.d.ts +3 -0
  47. package/dist/ui/app/essentials/document.d.ts +4 -0
  48. package/dist/ui/app/essentials/formatting.d.ts +9 -0
  49. package/dist/ui/app/essentials/gate.d.ts +4 -0
  50. package/dist/ui/app/essentials/history.d.ts +4 -0
  51. package/dist/ui/app/essentials/image.d.ts +4 -0
  52. package/dist/ui/app/essentials/link.d.ts +4 -0
  53. package/dist/ui/app/essentials/paragraph.d.ts +4 -0
  54. package/dist/ui/app/essentials/section.d.ts +4 -0
  55. package/dist/ui/app/essentials/selection.d.ts +4 -0
  56. package/dist/ui/app/essentials/style.d.ts +4 -0
  57. package/dist/ui/app/essentials/table.d.ts +4 -0
  58. package/dist/ui/app/essentials/types.d.ts +41 -0
  59. package/dist/ui/canvas/canvasLineSlotLookup.d.ts +8 -0
  60. package/dist/ui/canvas/canvasSnapshotLines.d.ts +22 -0
  61. package/dist/ui/canvas/canvasSnapshotWalkers.d.ts +41 -0
  62. package/dist/ui/canvas/canvasTheme.d.ts +6 -0
  63. package/dist/ui/components/Dialogs/ParagraphDialog.d.ts +2 -69
  64. package/dist/ui/components/Dialogs/paragraph-dialog/ParagraphDialogTypes.d.ts +82 -0
  65. package/dist/ui/components/Dialogs/paragraph-dialog/useParagraphDialogController.d.ts +66 -0
  66. package/dist/ui/components/Dialogs/table-properties/TablePropertiesTypes.d.ts +0 -1
  67. package/dist/ui/components/Toolbar/LineSpacingButton.d.ts +10 -0
  68. package/dist/ui/components/Toolbar/presets/defaultToolbar/buttonSpecs.d.ts +27 -0
  69. package/dist/ui/components/Toolbar/presets/defaultToolbar/optionBuilders.d.ts +10 -0
  70. package/dist/ui/components/Toolbar/presets/defaultToolbar/ribbonPlacements.d.ts +3 -0
  71. package/dist/ui/components/Toolbar/primitives/DropdownChevron.d.ts +20 -0
  72. package/dist/ui/utils/customIcons.d.ts +30 -0
  73. package/dist/utils/parseNumber.d.ts +5 -0
  74. package/dist/vue.d.ts +5 -5
  75. package/dist/vue.js +10 -12
  76. package/package.json +1 -1
  77. package/dist/layoutProjection/presetGeometry/families.d.ts +0 -37
  78. package/dist/plugins/internal/essentialsCommandGroups.d.ts +0 -41
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { E as EMPTY_PROJECTION_CONTEXT, d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageBodyBottom, b as getPageBodyTop, c as getPageContentWidth, F as FOOTNOTE_MARKER_GUTTER_PX, f as getParagraphText, h as getBlockParagraphs, i as getRunFootnoteReference, l as listReferencedEndnotes, j as getFootnoteDisplayMarker, k as createProjectionContext, m as getDocumentSections, n as getRunField, o as projectBlocksLayout, v as visitRun, q as assertNever, r as createSignal, s as createEditorStateFromDocument, t as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, u as fontSizePxToPt, w as probeLocalFontFamilies, x as createEditorParagraphFromRuns, y as isInlineObjectRun, z as createEditorStyledRun, A as getParagraphLength, B as getActiveZone, C as getActiveSectionIndex, D as getParagraphs, G as normalizeSelection, H as positionToParagraphOffset, I as paragraphOffsetToPosition, J as clampPosition, K as findParagraphIndex, L as createCollapsedSelection, M as isSelectionCollapsed, N as parseFontSizePtToPx, O as formatFontSizePt, P as createEditorParagraph, Q as resolveDefaultParagraphStyleId, R as findParagraphTableLocation, T as buildTableCellLayout, U as PT_PER_PX, V as createEditorTableCell, W as createEditorTableRow, X as createEditorTable, Y as PX_PER_POINT, Z as underlineStyleToCssDecorationStyle, _ as resolveImageSrc, $ as listKindForTag, a0 as isParagraphTag, a1 as collectInlineRuns, a2 as parseParagraphStyle, a3 as getRunImage, a4 as InlineShell, a5 as BalloonShell, a6 as DocumentShell, a7 as createMemo, a8 as getCaretRectFromSnapshot, a9 as getParagraphRectFromSnapshot, aa as createComponent, ab as CaretOverlay, ac as Show, ad as createRenderEffect, ae as style, af as setStyleProperty, ag as setAttribute, ah as memo, ai as template, aj as Button, ak as useI18n, al as createEffect, am as TextField, an as Dialog, ao as insert, ap as className, aq as Grid, ar as SelectField, as as StatusText, at as ColorField, au as UNDERLINE_STYLE_OPTIONS, av as Stack, aw as For, ax as ToggleChip, ay as FormField, az as Checkbox, aA as FieldGroup, aB as Tabs, aC as NumberField, aD as createStore, aE as reconcile, aF as RadioGroup, aG as Radio$1, aH as TextAreaField, aI as Text, aJ as SurfaceButton, aK as delegateEvents, aL as onMount, aM as onCleanup, aN as use, aO as PluginUiHost, aP as OasisEditorEditor, aQ as OasisBrandMark, aR as setPreciseFontPreference, aS as setWelcomeSeen, aT as enablePreciseFontMode, aU as TWIPS_PER_POINT, aV as PX_PER_INCH, aW as TWIPS_PER_INCH, aX as normalizeHex6, aY as TABLE_CONDITIONAL_FLAG_ATTRIBUTES, aZ as TABLE_BORDER_EDGE_KEYS, a_ as resolveEffectiveParagraphStyle, a$ as resolveEffectiveTextStyleForParagraph, b0 as EMU_PER_PT, b1 as OOXML_ROTATION_UNITS, b2 as OOXML_PERCENT_DENOMINATOR, b3 as parseHexColorToRgb255, b4 as EMU_PER_PX, b5 as getRunEndnoteReference, b6 as iterateFootnoteReferenceRuns, b7 as iterateEndnoteReferenceRuns, b8 as imageContentTypeDefaults, b9 as getRunFieldChar, ba as getRunFieldInstruction, bb as createEditorRun, bc as JSZip, bd as imageExtensionFromMime, be as pxToPt$1, bf as resolveFloatingObjectRect, bg as getTextBoxFloatingGeometry, bh as getPresetPathSegments, bi as buildListLabels, bj as DEFAULT_FONT_SIZE_PX, bk as resolveGradientAxis, bl as isDoubleUnderlineStyle, bm as isWavyUnderlineStyle, bn as underlineStyleLineWidthPx, bo as WAVY_UNDERLINE_WAVELENGTH_PX, bp as WAVY_UNDERLINE_AMPLITUDE_PX, bq as DOUBLE_UNDERLINE_OFFSET_PX, br as underlineStyleDashArray, bs as EMPHASIS_GLYPH, bt as rgb255ToHex, bu as getImageFloatingGeometry, bv as textStyleToFontSizePt, bw as resolveTextAlignmentBaselineOffset, bx as TEXT_BASELINE_RATIO, by as resolveOpenTypeFeatureTags, bz as resolveDecorationLineY, bA as DOUBLE_STRIKE_OFFSET_PX, 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 paragraphBetweenBorderMatches, bK as normalizeFamily, bL as ROBOTO_FONT_FILES, bM as loadFontAsset, bN as OFFICE_COMPAT_FONT_FAMILIES, bO as BinaryReader, bP as buildSfnt, bQ as defaultFontDecoderRegistry, bR as SfntFontProgram, bS as collectPdfFontFamilies, bT as outlineFrom, bU as getPageHeaderZoneTop, bV as getPageColumnRects, bW as findFootnoteReference, bX as resolveImporterForFile, bY as roundTo, bZ as getDocumentSectionsCanonical, b_ as getDocumentParagraphsCanonical, b$ as getDocumentParagraphs, c0 as getDocumentPageSettings, c1 as getTableCellContentWidthForParagraph, c2 as layoutMetricsEpoch, c3 as bumpLayoutMetricsEpoch, c4 as createCanvasLayoutSnapshotProvider, c5 as on, c6 as debounce, c7 as unwrap, c8 as perfTimer, c9 as getRunTextBox, ca as createEditorDocument, cb as resolveResizedDimensions, cc as resolveTextBoxRenderHeight, cd as getToolbarStyleState, ce as VERTICAL_HIT_WEIGHT, cf as getCachedCanvasImage, cg as measureParagraphMinContentWidthPx, ch as getEditableBlocksForZone, ci as findParagraphLocation, cj as createSectionBoundaryParagraph, ck as normalizePageSettings, cl as DEFAULT_EDITOR_PAGE_SETTINGS, cm as markStart, cn as markEnd, co as getParagraphEntries, cp as getParagraphById, cq as createEditorFootnote, cr as createFootnoteReferenceRun, cs as renumberFootnotes, ct as getHeadingLevel, cu as preciseFontModeVersion, cv as isPreciseFontModeEnabled, cw as resolveNamedTextStyle, cx as togglePreciseFontMode, cy as nextFontSizePt, cz as previousFontSizePt, cA as fontSizePtToPx, cB as createDefaultToolbarPreset, cC as MenuRegistry, cD as createToolbarRegistry, cE as Editor, cF as resolveCommandRef, cG as commandRefName, cH as createOasisEditorClient, cI as createEditorZoom, cJ as startLongTaskObserver, cK as installGlobalReport, cL as applyStoredPreciseFontPreference, cM as getWelcomeSeen, cN as isLocalFontAccessSupported, cO as EDITOR_SCROLL_PADDING_PX, cP as Toolbar, cQ as OasisEditorLoading, cR as I18nProvider, cS as createTranslator, cT as registerDomStatsSurface, cU as createEditorLogger } from "./index-BXo_oqOC.js";
4
+ import { E as EMPTY_PROJECTION_CONTEXT, d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageBodyBottom, b as getPageBodyTop, c as getPageContentWidth, F as FOOTNOTE_MARKER_GUTTER_PX, f as getParagraphText, h as getBlockParagraphs, i as getRunFootnoteReference, l as listReferencedEndnotes, j as getFootnoteDisplayMarker, k as createProjectionContext, m as getDocumentSections, n as getRunField, o as projectBlocksLayout, v as visitRun, q as assertNever, r as createSignal, s as createEditorStateFromDocument, t as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, u as fontSizePxToPt, w as probeLocalFontFamilies, x as createEditorParagraphFromRuns, y as isInlineObjectRun, z as createEditorStyledRun, A as getParagraphLength, B as getActiveZone, C as getActiveSectionIndex, D as getParagraphs, G as normalizeSelection, H as positionToParagraphOffset, I as paragraphOffsetToPosition, J as clampPosition, K as findParagraphIndex, L as createCollapsedSelection, M as isSelectionCollapsed, N as parseFontSizePtToPx, O as formatFontSizePt, P as createEditorParagraph, Q as resolveDefaultParagraphStyleId, R as findParagraphTableLocation, T as buildTableCellLayout, U as PT_PER_PX, V as createEditorTableCell, W as createEditorTableRow, X as createEditorTable, Y as PX_PER_POINT, Z as underlineStyleToCssDecorationStyle, _ as resolveImageSrc, $ as listKindForTag, a0 as isParagraphTag, a1 as collectInlineRuns, a2 as parseParagraphStyle, a3 as getRunImage, a4 as InlineShell, a5 as BalloonShell, a6 as DocumentShell, a7 as createMemo, a8 as getCaretRectFromSnapshot, a9 as getParagraphRectFromSnapshot, aa as createComponent, ab as CaretOverlay, ac as Show, ad as createRenderEffect, ae as style, af as setStyleProperty, ag as setAttribute, ah as memo, ai as template, aj as Button, ak as useI18n, al as createEffect, am as TextField, an as Dialog, ao as insert, ap as className, aq as Grid, ar as SelectField, as as StatusText, at as ColorField, au as UNDERLINE_STYLE_OPTIONS, av as Stack, aw as For, ax as ToggleChip, ay as FormField, az as Checkbox, aA as FieldGroup, aB as Tabs, aC as NumberField, aD as parseNumber, aE as createStore, aF as reconcile, aG as RadioGroup, aH as Radio$1, aI as TextAreaField, aJ as Text, aK as SurfaceButton, aL as delegateEvents, aM as onMount, aN as onCleanup, aO as CheckIcon, aP as use, aQ as PluginUiHost, aR as OasisEditorEditor, aS as OasisBrandMark, aT as setPreciseFontPreference, aU as setWelcomeSeen, aV as enablePreciseFontMode, aW as TWIPS_PER_POINT, aX as PX_PER_INCH, aY as TWIPS_PER_INCH, aZ as normalizeHex6, a_ as TABLE_CONDITIONAL_FLAG_ATTRIBUTES, a$ as TABLE_BORDER_EDGE_KEYS, b0 as resolveEffectiveParagraphStyle, b1 as resolveEffectiveTextStyleForParagraph, b2 as EMU_PER_PT, b3 as OOXML_ROTATION_UNITS, b4 as OOXML_PERCENT_DENOMINATOR, b5 as parseHexColorToRgb255, b6 as EMU_PER_PX, b7 as getRunEndnoteReference, b8 as iterateFootnoteReferenceRuns, b9 as iterateEndnoteReferenceRuns, ba as imageContentTypeDefaults, bb as getRunFieldChar, bc as getRunFieldInstruction, bd as createEditorRun, be as JSZip, bf as imageExtensionFromMime, bg as pxToPt$1, bh as resolveFloatingObjectRect, bi as getTextBoxFloatingGeometry, bj as getPresetPathSegments, bk as buildListLabels, bl as DEFAULT_FONT_SIZE_PX, bm as resolveGradientAxis, bn as isDoubleUnderlineStyle, bo as isWavyUnderlineStyle, bp as underlineStyleLineWidthPx, bq as WAVY_UNDERLINE_WAVELENGTH_PX, br as WAVY_UNDERLINE_AMPLITUDE_PX, bs as DOUBLE_UNDERLINE_OFFSET_PX, bt as underlineStyleDashArray, bu as EMPHASIS_GLYPH, bv as rgb255ToHex, bw as getImageFloatingGeometry, bx as textStyleToFontSizePt, by as resolveTextAlignmentBaselineOffset, bz as TEXT_BASELINE_RATIO, bA as resolveOpenTypeFeatureTags, bB as resolveDecorationLineY, bC as DOUBLE_STRIKE_OFFSET_PX, bD as resolveListLabel, bE as getListLabelInset, bF as getAlignedListLabelInset, bG as getParagraphBorderInsets, bH as buildSegmentTable, bI as buildCanvasTableLayout, bJ as resolveCanvasTableWidth, bK as resolveFloatingTableRect, bL as paragraphBetweenBorderMatches, bM as normalizeFamily, bN as ROBOTO_FONT_FILES, bO as loadFontAsset, bP as OFFICE_COMPAT_FONT_FAMILIES, bQ as BinaryReader, bR as buildSfnt, bS as defaultFontDecoderRegistry, bT as SfntFontProgram, bU as collectPdfFontFamilies, bV as outlineFrom, bW as getPageHeaderZoneTop, bX as getPageColumnRects, bY as findFootnoteReference, bZ as resolveImporterForFile, b_ as roundTo, b$ as getDocumentSectionsCanonical, c0 as getDocumentParagraphsCanonical, c1 as getDocumentParagraphs, c2 as getDocumentPageSettings, c3 as getTableCellContentWidthForParagraph, c4 as layoutMetricsEpoch, c5 as bumpLayoutMetricsEpoch, c6 as createCanvasLayoutSnapshotProvider, c7 as on, c8 as debounce, c9 as unwrap, ca as perfTimer, cb as getRunTextBox, cc as createEditorDocument, cd as resolveResizedDimensions, ce as resolveTextBoxRenderHeight, cf as getToolbarStyleState, cg as VERTICAL_HIT_WEIGHT, ch as getCachedCanvasImage, ci as measureParagraphMinContentWidthPx, cj as getEditableBlocksForZone, ck as findParagraphLocation, cl as createSectionBoundaryParagraph, cm as normalizePageSettings, cn as DEFAULT_EDITOR_PAGE_SETTINGS, co as markStart, cp as markEnd, cq as getParagraphEntries, cr as getParagraphById, cs as createEditorFootnote, ct as createFootnoteReferenceRun, cu as renumberFootnotes, cv as preciseFontModeVersion, cw as isPreciseFontModeEnabled, cx as getHeadingLevel, cy as togglePreciseFontMode, cz as nextFontSizePt, cA as previousFontSizePt, cB as fontSizePtToPx, cC as resolveNamedTextStyle, cD as createDefaultToolbarPreset, cE as MenuRegistry, cF as createToolbarRegistry, cG as Editor, cH as resolveCommandRef, cI as commandRefName, cJ as createOasisEditorClient, cK as createEditorZoom, cL as startLongTaskObserver, cM as installGlobalReport, cN as applyStoredPreciseFontPreference, cO as getWelcomeSeen, cP as isLocalFontAccessSupported, cQ as EDITOR_SCROLL_PADDING_PX, cR as Toolbar, cS as OasisEditorLoading, cT as I18nProvider, cU as createTranslator, cV as registerDomStatsSurface, cW as createEditorLogger } from "./index-BOj4-NlJ.js";
5
5
  function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
6
6
  const {
7
7
  pageIndex,
@@ -29808,8 +29808,7 @@ function distributeSelectedTableRows(state) {
29808
29808
  return { ...table, rows: nextRows };
29809
29809
  });
29810
29810
  }
29811
- const DEFAULT_DISTRIBUTED_COLUMN_PT = 120;
29812
- function parseWidthToPt(value) {
29811
+ function parseUnitToPt(value) {
29813
29812
  if (typeof value === "number" && Number.isFinite(value)) {
29814
29813
  return value;
29815
29814
  }
@@ -29834,6 +29833,7 @@ function parseWidthToPt(value) {
29834
29833
  const parsed = Number.parseFloat(trimmed);
29835
29834
  return Number.isFinite(parsed) ? parsed : null;
29836
29835
  }
29836
+ const DEFAULT_DISTRIBUTED_COLUMN_PT = 120;
29837
29837
  function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableIndentLeft) {
29838
29838
  const updateTable = (table) => {
29839
29839
  var _a2;
@@ -29849,7 +29849,7 @@ function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableInd
29849
29849
  let hasGridOverride = false;
29850
29850
  let canResolveGrid = true;
29851
29851
  for (let columnIndex = 0; columnIndex < visualColumnCount; columnIndex += 1) {
29852
- const override = parseWidthToPt(columnWidths[columnIndex]);
29852
+ const override = parseUnitToPt(columnWidths[columnIndex]);
29853
29853
  if (override !== null) {
29854
29854
  nextGridCols[columnIndex] = Math.max(1, override);
29855
29855
  hasGridOverride = true;
@@ -33335,47 +33335,22 @@ function TabStopsDialog(props) {
33335
33335
  }
33336
33336
  });
33337
33337
  }
33338
- var _tmpl$$a = /* @__PURE__ */ template(`<div class=oasis-editor-paragraph-dialog-panel>`), _tmpl$2$2 = /* @__PURE__ */ template(`<div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>`), _tmpl$3$1 = /* @__PURE__ */ template(`<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>`);
33339
33338
  const PT_TO_PX = 96 / 72;
33340
33339
  const DEFAULT_BORDER_WIDTH_PT$1 = 0.5;
33341
33340
  const DEFAULT_BORDER_COLOR$1 = "#000000";
33342
33341
  const OUTLINE_BODY = "";
33343
- function parseNumber$1(value) {
33344
- if (value.trim() === "") return null;
33345
- const num = Number(value);
33346
- return Number.isFinite(num) ? num : null;
33347
- }
33348
33342
  function deriveLineSpacing(lineRule, lineHeight) {
33349
33343
  if (lineRule === "exact" || lineRule === "atLeast") {
33350
33344
  const pt = lineHeight !== null ? Math.round(lineHeight / PT_TO_PX) : null;
33351
- return {
33352
- mode: lineRule,
33353
- at: pt
33354
- };
33345
+ return { mode: lineRule, at: pt };
33355
33346
  }
33356
- if (lineHeight === null) return {
33357
- mode: "multiple",
33358
- at: null
33359
- };
33360
- if (lineHeight === 1) return {
33361
- mode: "single",
33362
- at: null
33363
- };
33364
- if (lineHeight === 1.5) return {
33365
- mode: "onePointFive",
33366
- at: null
33367
- };
33368
- if (lineHeight === 2) return {
33369
- mode: "double",
33370
- at: null
33371
- };
33372
- return {
33373
- mode: "multiple",
33374
- at: lineHeight
33375
- };
33347
+ if (lineHeight === null) return { mode: "multiple", at: null };
33348
+ if (lineHeight === 1) return { mode: "single", at: null };
33349
+ if (lineHeight === 1.5) return { mode: "onePointFive", at: null };
33350
+ if (lineHeight === 2) return { mode: "double", at: null };
33351
+ return { mode: "multiple", at: lineHeight };
33376
33352
  }
33377
- function ParagraphDialog(props) {
33378
- const t = useI18n();
33353
+ function useParagraphDialogController(props) {
33379
33354
  const [align, setAlign] = createSignal("");
33380
33355
  const [outlineLevel, setOutlineLevel] = createSignal(OUTLINE_BODY);
33381
33356
  const [indentLeft, setIndentLeft] = createSignal(null);
@@ -33401,27 +33376,28 @@ function ParagraphDialog(props) {
33401
33376
  const [keepLinesTogether, setKeepLinesTogether] = createSignal(false);
33402
33377
  const [widowControl, setWidowControl] = createSignal(true);
33403
33378
  const [tabs, setTabs] = createSignal([]);
33404
- const [tabsDialogOpen, setTabsDialogOpen] = createSignal(false);
33405
33379
  createEffect(() => {
33406
33380
  if (props.isOpen) {
33407
33381
  setAlign(props.initial.align ?? "");
33408
33382
  setOutlineLevel(props.initial.outlineLevel ?? OUTLINE_BODY);
33409
- setIndentLeft(parseNumber$1(props.initial.indentLeft ?? ""));
33410
- setIndentRight(parseNumber$1(props.initial.indentRight ?? ""));
33383
+ setIndentLeft(parseNumber(props.initial.indentLeft ?? ""));
33384
+ setIndentRight(parseNumber(props.initial.indentRight ?? ""));
33411
33385
  setMirrorIndents(props.initial.mirrorIndents ?? false);
33412
- setSpacingBefore(parseNumber$1(props.initial.spacingBefore ?? ""));
33413
- setSpacingAfter(parseNumber$1(props.initial.spacingAfter ?? ""));
33386
+ setSpacingBefore(parseNumber(props.initial.spacingBefore ?? ""));
33387
+ setSpacingAfter(parseNumber(props.initial.spacingAfter ?? ""));
33414
33388
  setContextualSpacing(props.initial.contextualSpacing ?? false);
33415
33389
  setShading(props.initial.shading ?? "");
33416
- const {
33417
- mode,
33418
- at
33419
- } = deriveLineSpacing(props.initial.lineRule ?? "", parseNumber$1(props.initial.lineHeight ?? ""));
33390
+ const { mode, at } = deriveLineSpacing(
33391
+ props.initial.lineRule ?? "",
33392
+ parseNumber(props.initial.lineHeight ?? "")
33393
+ );
33420
33394
  setLineMode(mode);
33421
33395
  setLineAt(at);
33422
33396
  const initialBorderStyle = props.initial.borderStyle;
33423
- setBorderStyle(initialBorderStyle === "solid" || initialBorderStyle === "dashed" || initialBorderStyle === "dotted" ? initialBorderStyle : "none");
33424
- setBorderWidth(parseNumber$1(props.initial.borderWidth ?? ""));
33397
+ setBorderStyle(
33398
+ initialBorderStyle === "solid" || initialBorderStyle === "dashed" || initialBorderStyle === "dotted" ? initialBorderStyle : "none"
33399
+ );
33400
+ setBorderWidth(parseNumber(props.initial.borderWidth ?? ""));
33425
33401
  setBorderColor(props.initial.borderColor ?? "");
33426
33402
  setSideTop(props.initial.borderSideTop ?? false);
33427
33403
  setSideRight(props.initial.borderSideRight ?? false);
@@ -33432,8 +33408,8 @@ function ParagraphDialog(props) {
33432
33408
  setKeepLinesTogether(props.initial.keepLinesTogether ?? false);
33433
33409
  setWidowControl(props.initial.widowControl ?? true);
33434
33410
  setTabs(props.initial.tabs ?? []);
33435
- const firstLine = parseNumber$1(props.initial.indentFirstLine ?? "");
33436
- const hanging = parseNumber$1(props.initial.indentHanging ?? "");
33411
+ const firstLine = parseNumber(props.initial.indentFirstLine ?? "");
33412
+ const hanging = parseNumber(props.initial.indentHanging ?? "");
33437
33413
  if (hanging !== null && hanging > 0) {
33438
33414
  setSpecial("hanging");
33439
33415
  setSpecialBy(hanging);
@@ -33450,25 +33426,13 @@ function ParagraphDialog(props) {
33450
33426
  const resolveLineSpacing = () => {
33451
33427
  switch (lineMode()) {
33452
33428
  case "single":
33453
- return {
33454
- lineHeight: 1,
33455
- lineRule: null
33456
- };
33429
+ return { lineHeight: 1, lineRule: null };
33457
33430
  case "onePointFive":
33458
- return {
33459
- lineHeight: 1.5,
33460
- lineRule: null
33461
- };
33431
+ return { lineHeight: 1.5, lineRule: null };
33462
33432
  case "double":
33463
- return {
33464
- lineHeight: 2,
33465
- lineRule: null
33466
- };
33433
+ return { lineHeight: 2, lineRule: null };
33467
33434
  case "multiple":
33468
- return {
33469
- lineHeight: lineAt(),
33470
- lineRule: null
33471
- };
33435
+ return { lineHeight: lineAt(), lineRule: null };
33472
33436
  case "atLeast":
33473
33437
  return {
33474
33438
  lineHeight: lineAt() !== null ? lineAt() * PT_TO_PX : null,
@@ -33488,10 +33452,7 @@ function ParagraphDialog(props) {
33488
33452
  const hanging = special() === "hanging" ? specialBy() : null;
33489
33453
  const textIndent = firstLine !== null ? firstLine : hanging !== null ? -hanging : null;
33490
33454
  const borderCss = borderStyle() !== "none" ? `${borderWidth() ?? DEFAULT_BORDER_WIDTH_PT$1}pt ${borderStyle()} ${borderColor().trim() || DEFAULT_BORDER_COLOR$1}` : void 0;
33491
- const {
33492
- lineHeight,
33493
- lineRule
33494
- } = resolveLineSpacing();
33455
+ const { lineHeight, lineRule } = resolveLineSpacing();
33495
33456
  const lineHeightCss = lineHeight === null ? void 0 : lineRule === "exact" || lineRule === "atLeast" ? `${lineHeight}px` : String(lineHeight);
33496
33457
  return {
33497
33458
  "text-align": align() || void 0,
@@ -33509,12 +33470,7 @@ function ParagraphDialog(props) {
33509
33470
  const resolveBorders = () => {
33510
33471
  const style2 = borderStyle();
33511
33472
  if (style2 === "none") {
33512
- return {
33513
- top: null,
33514
- right: null,
33515
- bottom: null,
33516
- left: null
33517
- };
33473
+ return { top: null, right: null, bottom: null, left: null };
33518
33474
  }
33519
33475
  const width = borderWidth();
33520
33476
  const border = {
@@ -33531,10 +33487,7 @@ function ParagraphDialog(props) {
33531
33487
  };
33532
33488
  const collectValues = () => {
33533
33489
  const by = specialBy();
33534
- const {
33535
- lineHeight,
33536
- lineRule
33537
- } = resolveLineSpacing();
33490
+ const { lineHeight, lineRule } = resolveLineSpacing();
33538
33491
  const outline = outlineLevel();
33539
33492
  return {
33540
33493
  align: align() || null,
@@ -33567,6 +33520,123 @@ function ParagraphDialog(props) {
33567
33520
  (_a2 = props.onSetDefault) == null ? void 0 : _a2.call(props, collectValues());
33568
33521
  props.onClose();
33569
33522
  };
33523
+ return {
33524
+ align,
33525
+ setAlign,
33526
+ outlineLevel,
33527
+ setOutlineLevel,
33528
+ indentLeft,
33529
+ setIndentLeft,
33530
+ indentRight,
33531
+ setIndentRight,
33532
+ special,
33533
+ setSpecial,
33534
+ specialBy,
33535
+ setSpecialBy,
33536
+ mirrorIndents,
33537
+ setMirrorIndents,
33538
+ spacingBefore,
33539
+ setSpacingBefore,
33540
+ spacingAfter,
33541
+ setSpacingAfter,
33542
+ lineMode,
33543
+ setLineMode,
33544
+ lineAt,
33545
+ setLineAt,
33546
+ contextualSpacing,
33547
+ setContextualSpacing,
33548
+ shading,
33549
+ setShading,
33550
+ borderStyle,
33551
+ setBorderStyle,
33552
+ borderWidth,
33553
+ setBorderWidth,
33554
+ borderColor,
33555
+ setBorderColor,
33556
+ sideTop,
33557
+ setSideTop,
33558
+ sideRight,
33559
+ setSideRight,
33560
+ sideBottom,
33561
+ setSideBottom,
33562
+ sideLeft,
33563
+ setSideLeft,
33564
+ pageBreakBefore,
33565
+ setPageBreakBefore,
33566
+ keepWithNext,
33567
+ setKeepWithNext,
33568
+ keepLinesTogether,
33569
+ setKeepLinesTogether,
33570
+ widowControl,
33571
+ setWidowControl,
33572
+ tabs,
33573
+ setTabs,
33574
+ atEnabled,
33575
+ previewStyle,
33576
+ handleApply,
33577
+ handleSetDefault
33578
+ };
33579
+ }
33580
+ var _tmpl$$a = /* @__PURE__ */ template(`<div class=oasis-editor-paragraph-dialog-panel>`), _tmpl$2$2 = /* @__PURE__ */ template(`<div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>`), _tmpl$3$1 = /* @__PURE__ */ template(`<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>`);
33581
+ function ParagraphDialog(props) {
33582
+ const t = useI18n();
33583
+ const [tabsDialogOpen, setTabsDialogOpen] = createSignal(false);
33584
+ const {
33585
+ align,
33586
+ setAlign,
33587
+ outlineLevel,
33588
+ setOutlineLevel,
33589
+ indentLeft,
33590
+ setIndentLeft,
33591
+ indentRight,
33592
+ setIndentRight,
33593
+ special,
33594
+ setSpecial,
33595
+ specialBy,
33596
+ setSpecialBy,
33597
+ mirrorIndents,
33598
+ setMirrorIndents,
33599
+ spacingBefore,
33600
+ setSpacingBefore,
33601
+ spacingAfter,
33602
+ setSpacingAfter,
33603
+ lineMode,
33604
+ setLineMode,
33605
+ lineAt,
33606
+ setLineAt,
33607
+ contextualSpacing,
33608
+ setContextualSpacing,
33609
+ shading,
33610
+ setShading,
33611
+ borderStyle,
33612
+ setBorderStyle,
33613
+ borderWidth,
33614
+ setBorderWidth,
33615
+ borderColor,
33616
+ setBorderColor,
33617
+ sideTop,
33618
+ setSideTop,
33619
+ sideRight,
33620
+ setSideRight,
33621
+ sideBottom,
33622
+ setSideBottom,
33623
+ sideLeft,
33624
+ setSideLeft,
33625
+ pageBreakBefore,
33626
+ setPageBreakBefore,
33627
+ keepWithNext,
33628
+ setKeepWithNext,
33629
+ keepLinesTogether,
33630
+ setKeepLinesTogether,
33631
+ widowControl,
33632
+ setWidowControl,
33633
+ tabs,
33634
+ setTabs,
33635
+ atEnabled,
33636
+ previewStyle,
33637
+ handleApply,
33638
+ handleSetDefault
33639
+ } = useParagraphDialogController(props);
33570
33640
  const alignField = createComponent(SelectField, {
33571
33641
  get label() {
33572
33642
  return t("paragraph.alignLabel");
@@ -34236,11 +34306,6 @@ function ParagraphDialog(props) {
34236
34306
  }
34237
34307
  const DEFAULT_BORDER_WIDTH_PT = 0.5;
34238
34308
  const DEFAULT_BORDER_COLOR = "#000000";
34239
- function parseNumber(value) {
34240
- if (value.trim() === "") return null;
34241
- const parsed = Number(value);
34242
- return Number.isFinite(parsed) ? parsed : null;
34243
- }
34244
34309
  function parseWidth(value, unit) {
34245
34310
  const parsed = parseNumber(value);
34246
34311
  if (parsed === null) return null;
@@ -35564,7 +35629,7 @@ function FindReplaceDialog(props) {
35564
35629
  });
35565
35630
  }
35566
35631
  delegateEvents(["keydown"]);
35567
- var _tmpl$$3 = /* @__PURE__ */ template(`<div class=oasis-editor-context-menu role=menu data-testid=editor-context-menu>`), _tmpl$2 = /* @__PURE__ */ template(`<i>`), _tmpl$3 = /* @__PURE__ */ template(`<span class=oasis-editor-context-menu-shortcut>`), _tmpl$4 = /* @__PURE__ */ template(`<button type=button class=oasis-editor-context-menu-item role=menuitem><span class=oasis-editor-context-menu-label>`), _tmpl$5 = /* @__PURE__ */ template(`<div class=oasis-editor-context-menu-separator>`), _tmpl$6 = /* @__PURE__ */ template(`<i data-lucide=check style=visibility:hidden>`);
35632
+ var _tmpl$$3 = /* @__PURE__ */ template(`<div class=oasis-editor-context-menu role=menu data-testid=editor-context-menu>`), _tmpl$2 = /* @__PURE__ */ template(`<i>`), _tmpl$3 = /* @__PURE__ */ template(`<span class=oasis-editor-context-menu-shortcut>`), _tmpl$4 = /* @__PURE__ */ template(`<button type=button class=oasis-editor-context-menu-item role=menuitem><span class=oasis-editor-context-menu-label>`), _tmpl$5 = /* @__PURE__ */ template(`<div class=oasis-editor-context-menu-separator>`), _tmpl$6 = /* @__PURE__ */ template(`<span aria-hidden=true style=visibility:hidden;flex-shrink:0>`);
35568
35633
  function ContextMenu(props) {
35569
35634
  let menuRef;
35570
35635
  const handleKeyDown = (event) => {
@@ -35648,7 +35713,13 @@ function ContextMenu(props) {
35648
35713
  return item.icon;
35649
35714
  },
35650
35715
  get fallback() {
35651
- return _tmpl$6();
35716
+ return (() => {
35717
+ var _el$7 = _tmpl$6();
35718
+ insert(_el$7, createComponent(CheckIcon, {
35719
+ size: 16
35720
+ }));
35721
+ return _el$7;
35722
+ })();
35652
35723
  },
35653
35724
  get children() {
35654
35725
  var _el$3 = _tmpl$2();
@@ -36161,6 +36232,9 @@ function pointsToTwips(value) {
36161
36232
  function normalizeDocxColor(color, fallback = "000000") {
36162
36233
  return normalizeHex6(color) ?? fallback;
36163
36234
  }
36235
+ function serializeShading(fill) {
36236
+ return `<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(fill, "FFFFFF")}"/>`;
36237
+ }
36164
36238
  function buildBookmarkExportPlan(document2) {
36165
36239
  const registry = document2.bookmarks;
36166
36240
  if (!registry || registry.order.length === 0) {
@@ -36501,9 +36575,7 @@ function serializeTableCellProperties(cell, fallbackWidthPt) {
36501
36575
  parts.push("<w:vMerge/>");
36502
36576
  }
36503
36577
  if ((_b2 = cell.style) == null ? void 0 : _b2.shading) {
36504
- parts.push(
36505
- `<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(cell.style.shading, "FFFFFF")}"/>`
36506
- );
36578
+ parts.push(serializeShading(cell.style.shading));
36507
36579
  }
36508
36580
  const noWrap = serializeOnOffElement("noWrap", (_c = cell.style) == null ? void 0 : _c.noWrap);
36509
36581
  if (noWrap) {
@@ -37068,9 +37140,7 @@ function serializeParagraphStyleXml(style2) {
37068
37140
  parts.push(paragraphBorders);
37069
37141
  }
37070
37142
  if (style2.shading) {
37071
- parts.push(
37072
- `<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(style2.shading, "FFFFFF")}"/>`
37073
- );
37143
+ parts.push(serializeShading(style2.shading));
37074
37144
  }
37075
37145
  if (style2.textDirection) {
37076
37146
  parts.push(`<w:textDirection w:val="${style2.textDirection}"/>`);
@@ -37134,9 +37204,7 @@ function serializeParagraphProperties(paragraph, numberingInfo, styles, override
37134
37204
  parts.push(paragraphBorders);
37135
37205
  }
37136
37206
  if (style2.shading) {
37137
- parts.push(
37138
- `<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(style2.shading, "FFFFFF")}"/>`
37139
- );
37207
+ parts.push(serializeShading(style2.shading));
37140
37208
  }
37141
37209
  if (style2.textDirection) {
37142
37210
  parts.push(`<w:textDirection w:val="${style2.textDirection}"/>`);
@@ -37427,9 +37495,7 @@ function serializeRunProperties(styles) {
37427
37495
  );
37428
37496
  }
37429
37497
  if (styles.shading) {
37430
- parts.push(
37431
- `<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(styles.shading, "FFFFFF")}"/>`
37432
- );
37498
+ parts.push(serializeShading(styles.shading));
37433
37499
  }
37434
37500
  if (styles.fitText !== void 0 && styles.fitText !== null && Number.isFinite(styles.fitText)) {
37435
37501
  const twips = pointsToSignedTwips(styles.fitText);
@@ -41258,6 +41324,14 @@ class PdfContentStream {
41258
41324
  );
41259
41325
  }
41260
41326
  }
41327
+ function parseExtensionLookup(reader, offset, parseSubtable2) {
41328
+ reader.seek(offset);
41329
+ const format = reader.u16();
41330
+ if (format !== 1) return null;
41331
+ const extensionType = reader.u16();
41332
+ const extensionOffset = offset + reader.u32();
41333
+ return parseSubtable2(reader, extensionOffset, extensionType);
41334
+ }
41261
41335
  function readU16Array(reader, count) {
41262
41336
  const array = new Array(count);
41263
41337
  for (let i = 0; i < count; i += 1) array[i] = reader.u16();
@@ -41769,14 +41843,8 @@ function parseSubtable$1(reader, offset, lookupType) {
41769
41843
  return parseLigatureSubst(reader, offset);
41770
41844
  case 6:
41771
41845
  return parseChainContextSubst(reader, offset);
41772
- case 7: {
41773
- reader.seek(offset);
41774
- const format = reader.u16();
41775
- if (format !== 1) return null;
41776
- const extensionType = reader.u16();
41777
- const extensionOffset = offset + reader.u32();
41778
- return parseSubtable$1(reader, extensionOffset, extensionType);
41779
- }
41846
+ case 7:
41847
+ return parseExtensionLookup(reader, offset, parseSubtable$1);
41780
41848
  default:
41781
41849
  return null;
41782
41850
  }
@@ -41999,14 +42067,8 @@ function parseSubtable(reader, offset, lookupType) {
41999
42067
  return parseSinglePos(reader, offset);
42000
42068
  case 2:
42001
42069
  return parsePairPos(reader, offset);
42002
- case 9: {
42003
- reader.seek(offset);
42004
- const format = reader.u16();
42005
- if (format !== 1) return null;
42006
- const extensionType = reader.u16();
42007
- const extensionOffset = offset + reader.u32();
42008
- return parseSubtable(reader, extensionOffset, extensionType);
42009
- }
42070
+ case 9:
42071
+ return parseExtensionLookup(reader, offset, parseSubtable);
42010
42072
  default:
42011
42073
  return null;
42012
42074
  }
@@ -46880,12 +46942,23 @@ function createTableCellSpanOperationsImpl(deps) {
46880
46942
  splitSelectedTable
46881
46943
  };
46882
46944
  }
46945
+ function markTableRevision(target, type) {
46946
+ target.style = {
46947
+ ...target.style ?? {},
46948
+ revision: { ...createTableRevisionMetadata(), type }
46949
+ };
46950
+ }
46951
+ function resolveNextTableParagraph(tableBlock, targetCell, fallbackRow) {
46952
+ var _a2;
46953
+ return (targetCell == null ? void 0 : targetCell.blocks[0]) ?? ((_a2 = fallbackRow == null ? void 0 : fallbackRow.cells.find(
46954
+ (cell) => cell.vMerge !== "continue" && cell.blocks[0]
46955
+ )) == null ? void 0 : _a2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
46956
+ }
46883
46957
  function createTableRowColumnOperations(deps) {
46884
46958
  return createTableRowColumnOperationsImpl(deps);
46885
46959
  }
46886
46960
  function createTableRowColumnOperationsImpl(deps) {
46887
46961
  const insertSelectedTableRow = (current, direction) => {
46888
- var _a2, _b2;
46889
46962
  const mut = resolveLocationTableMutation(current, deps.getTargetBlocks);
46890
46963
  if (!mut) return current;
46891
46964
  const { tableBlock, location, targetBlocks } = mut;
@@ -46940,20 +47013,16 @@ function createTableRowColumnOperationsImpl(deps) {
46940
47013
  })
46941
47014
  );
46942
47015
  if (current.trackChangesEnabled) {
46943
- blankRow.style = {
46944
- ...blankRow.style ?? {},
46945
- revision: {
46946
- ...createTableRevisionMetadata(),
46947
- type: "insert"
46948
- }
46949
- };
47016
+ markTableRevision(blankRow, "insert");
46950
47017
  }
46951
47018
  tableBlock.rows.splice(insertIndex, 0, blankRow);
46952
47019
  const targetVisualColumn = (selectedEntry == null ? void 0 : selectedEntry.visualColumnIndex) ?? location.cellIndex;
46953
47020
  const targetCell2 = findCellAtVisualColumn(blankRow, targetVisualColumn);
46954
- const nextParagraph2 = (targetCell2 == null ? void 0 : targetCell2.blocks[0]) ?? ((_a2 = blankRow.cells.find(
46955
- (cell) => cell.vMerge !== "continue" && cell.blocks[0]
46956
- )) == null ? void 0 : _a2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
47021
+ const nextParagraph2 = resolveNextTableParagraph(
47022
+ tableBlock,
47023
+ targetCell2,
47024
+ blankRow
47025
+ );
46957
47026
  return commitTableMutation(
46958
47027
  current,
46959
47028
  targetBlocks,
@@ -46970,19 +47039,15 @@ function createTableRowColumnOperationsImpl(deps) {
46970
47039
  )
46971
47040
  );
46972
47041
  if (current.trackChangesEnabled) {
46973
- blankRow.style = {
46974
- ...blankRow.style ?? {},
46975
- revision: {
46976
- ...createTableRevisionMetadata(),
46977
- type: "insert"
46978
- }
46979
- };
47042
+ markTableRevision(blankRow, "insert");
46980
47043
  }
46981
47044
  tableBlock.rows.splice(insertIndex, 0, blankRow);
46982
47045
  const targetCell = blankRow.cells[Math.min(location.cellIndex, blankRow.cells.length - 1)];
46983
- const nextParagraph = (targetCell == null ? void 0 : targetCell.blocks[0]) ?? ((_b2 = blankRow.cells.find(
46984
- (cell) => cell.vMerge !== "continue" && cell.blocks[0]
46985
- )) == null ? void 0 : _b2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
47046
+ const nextParagraph = resolveNextTableParagraph(
47047
+ tableBlock,
47048
+ targetCell,
47049
+ blankRow
47050
+ );
46986
47051
  return commitTableMutation(
46987
47052
  current,
46988
47053
  targetBlocks,
@@ -47002,13 +47067,7 @@ function createTableRowColumnOperationsImpl(deps) {
47002
47067
  return current;
47003
47068
  }
47004
47069
  if (current.trackChangesEnabled) {
47005
- rowToDelete.style = {
47006
- ...rowToDelete.style ?? {},
47007
- revision: {
47008
- ...createTableRevisionMetadata(),
47009
- type: "delete"
47010
- }
47011
- };
47070
+ markTableRevision(rowToDelete, "delete");
47012
47071
  return commitTableMutation(current, targetBlocks, location.zone, null);
47013
47072
  }
47014
47073
  const blockedByRestartCell = rowToDelete.cells.some(
@@ -47048,7 +47107,7 @@ function createTableRowColumnOperationsImpl(deps) {
47048
47107
  Math.max(0, getRowVisualWidth(nextRow) - 1)
47049
47108
  )
47050
47109
  ) : null;
47051
- const nextParagraph = (targetCell == null ? void 0 : targetCell.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
47110
+ const nextParagraph = resolveNextTableParagraph(tableBlock, targetCell);
47052
47111
  return commitTableMutation(
47053
47112
  current,
47054
47113
  targetBlocks,
@@ -47081,12 +47140,7 @@ function createTableRowColumnOperationsImpl(deps) {
47081
47140
  createEditorParagraph("")
47082
47141
  ]);
47083
47142
  if (current.trackChangesEnabled) {
47084
- insertedCell.style = {
47085
- revision: {
47086
- ...createTableRevisionMetadata(),
47087
- type: "insert"
47088
- }
47089
- };
47143
+ markTableRevision(insertedCell, "insert");
47090
47144
  }
47091
47145
  nextCells.push(insertedCell);
47092
47146
  inserted = true;
@@ -47117,12 +47171,7 @@ function createTableRowColumnOperationsImpl(deps) {
47117
47171
  createEditorParagraph("")
47118
47172
  ]);
47119
47173
  if (current.trackChangesEnabled) {
47120
- insertedCell.style = {
47121
- revision: {
47122
- ...createTableRevisionMetadata(),
47123
- type: "insert"
47124
- }
47125
- };
47174
+ markTableRevision(insertedCell, "insert");
47126
47175
  }
47127
47176
  nextCells.push(insertedCell);
47128
47177
  }
@@ -47130,7 +47179,7 @@ function createTableRowColumnOperationsImpl(deps) {
47130
47179
  }
47131
47180
  const targetRow2 = tableBlock.rows[location.rowIndex];
47132
47181
  const targetCell2 = targetRow2 ? findCellAtVisualColumn(targetRow2, insertVisualColumn) : null;
47133
- const nextParagraph2 = (targetCell2 == null ? void 0 : targetCell2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
47182
+ const nextParagraph2 = resolveNextTableParagraph(tableBlock, targetCell2);
47134
47183
  return commitTableMutation(
47135
47184
  current,
47136
47185
  targetBlocks,
@@ -47148,18 +47197,13 @@ function createTableRowColumnOperationsImpl(deps) {
47148
47197
  for (const row of tableBlock.rows) {
47149
47198
  const insertedCell = createEditorTableCell([createEditorParagraph("")]);
47150
47199
  if (current.trackChangesEnabled) {
47151
- insertedCell.style = {
47152
- revision: {
47153
- ...createTableRevisionMetadata(),
47154
- type: "insert"
47155
- }
47156
- };
47200
+ markTableRevision(insertedCell, "insert");
47157
47201
  }
47158
47202
  row.cells.splice(insertIndex, 0, insertedCell);
47159
47203
  }
47160
47204
  const targetRow = tableBlock.rows[location.rowIndex];
47161
47205
  const targetCell = targetRow == null ? void 0 : targetRow.cells[insertIndex];
47162
- const nextParagraph = (targetCell == null ? void 0 : targetCell.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
47206
+ const nextParagraph = resolveNextTableParagraph(tableBlock, targetCell);
47163
47207
  return commitTableMutation(
47164
47208
  current,
47165
47209
  targetBlocks,
@@ -47184,13 +47228,7 @@ function createTableRowColumnOperationsImpl(deps) {
47184
47228
  for (const row of tableBlock.rows) {
47185
47229
  const cell = findCellAtVisualColumn(row, visualColumn);
47186
47230
  if (cell) {
47187
- cell.style = {
47188
- ...cell.style ?? {},
47189
- revision: {
47190
- ...createTableRevisionMetadata(),
47191
- type: "delete"
47192
- }
47193
- };
47231
+ markTableRevision(cell, "delete");
47194
47232
  }
47195
47233
  }
47196
47234
  return commitTableMutation(current, targetBlocks, location.zone, null);
@@ -47231,7 +47269,7 @@ function createTableRowColumnOperationsImpl(deps) {
47231
47269
  Math.max(0, getRowVisualWidth(targetRow2) - 1)
47232
47270
  )
47233
47271
  );
47234
- const nextParagraph2 = (targetCell2 == null ? void 0 : targetCell2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
47272
+ const nextParagraph2 = resolveNextTableParagraph(tableBlock, targetCell2);
47235
47273
  return commitTableMutation(
47236
47274
  current,
47237
47275
  targetBlocks,
@@ -47247,7 +47285,7 @@ function createTableRowColumnOperationsImpl(deps) {
47247
47285
  }
47248
47286
  const targetRow = tableBlock.rows[location.rowIndex];
47249
47287
  const targetCell = targetRow == null ? void 0 : targetRow.cells[Math.min(location.cellIndex, targetRow.cells.length - 1)];
47250
- const nextParagraph = (targetCell == null ? void 0 : targetCell.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
47288
+ const nextParagraph = resolveNextTableParagraph(tableBlock, targetCell);
47251
47289
  return commitTableMutation(
47252
47290
  current,
47253
47291
  targetBlocks,
@@ -49179,34 +49217,7 @@ function pxToPt(px) {
49179
49217
  function ptToPx(pt) {
49180
49218
  return pt * PIXELS_PER_POINT;
49181
49219
  }
49182
- function parseSizeToPt(value) {
49183
- if (typeof value === "number" && Number.isFinite(value)) {
49184
- return value;
49185
- }
49186
- if (typeof value !== "string") {
49187
- return null;
49188
- }
49189
- const trimmed = value.trim().toLowerCase();
49190
- if (!trimmed) {
49191
- return null;
49192
- }
49193
- if (trimmed.endsWith("pt")) {
49194
- const parsed2 = Number.parseFloat(trimmed.slice(0, -2));
49195
- return Number.isFinite(parsed2) ? parsed2 : null;
49196
- }
49197
- if (trimmed.endsWith("px")) {
49198
- const parsed2 = Number.parseFloat(trimmed.slice(0, -2));
49199
- return Number.isFinite(parsed2) ? pxToPt(parsed2) : null;
49200
- }
49201
- if (trimmed.includes("%")) {
49202
- return null;
49203
- }
49204
- if (!/^[+-]?\d+(\.\d+)?$/.test(trimmed)) {
49205
- return null;
49206
- }
49207
- const parsed = Number.parseFloat(trimmed);
49208
- return Number.isFinite(parsed) ? parsed : null;
49209
- }
49220
+ const parseSizeToPt = parseUnitToPt;
49210
49221
  const CONTENT_MIN_WIDTH_GUARD_PX = 12;
49211
49222
  const CONTENT_MIN_HEIGHT_GUARD_PX = 4;
49212
49223
  const DEFAULT_CELL_PADDING_LEFT_RIGHT_PX = 7.2;
@@ -49963,6 +49974,15 @@ function findNextWordBoundary(text, offset) {
49963
49974
  }
49964
49975
  const REUSE_MOUSE_DOWN_HIT_MAX_AGE_MS = 600;
49965
49976
  const REUSE_MOUSE_DOWN_HIT_MAX_DISTANCE_PX = 8;
49977
+ function resolveZoneFirstParagraph(blocks, zone) {
49978
+ if (!blocks || blocks.length === 0) {
49979
+ const paragraph2 = createSectionBoundaryParagraph(zone);
49980
+ return { paragraph: paragraph2, blocks: [paragraph2] };
49981
+ }
49982
+ const firstBlock = blocks[0];
49983
+ const paragraph = firstBlock.type === "paragraph" ? firstBlock : getBlockParagraphs(firstBlock)[0] ?? null;
49984
+ return { paragraph, blocks };
49985
+ }
49966
49986
  function resolveTripleClickParagraphRange(state, paragraph, targetZone) {
49967
49987
  const zoneParagraphs = getDocumentParagraphs(state.document).filter(
49968
49988
  (candidate) => {
@@ -50043,21 +50063,13 @@ function createEditorSurfaceEventsImpl(deps) {
50043
50063
  let newFooter = section.footer;
50044
50064
  let zoneParagraph = null;
50045
50065
  if (targetZone === "header") {
50046
- if (!newHeader || newHeader.length === 0) {
50047
- zoneParagraph = createSectionBoundaryParagraph("header");
50048
- newHeader = [zoneParagraph];
50049
- } else {
50050
- const firstBlock = newHeader[0];
50051
- zoneParagraph = firstBlock.type === "paragraph" ? firstBlock : getBlockParagraphs(firstBlock)[0] ?? null;
50052
- }
50066
+ const resolved = resolveZoneFirstParagraph(newHeader, "header");
50067
+ zoneParagraph = resolved.paragraph;
50068
+ newHeader = resolved.blocks;
50053
50069
  } else if (targetZone === "footer") {
50054
- if (!newFooter || newFooter.length === 0) {
50055
- zoneParagraph = createSectionBoundaryParagraph("footer");
50056
- newFooter = [zoneParagraph];
50057
- } else {
50058
- const firstBlock = newFooter[0];
50059
- zoneParagraph = firstBlock.type === "paragraph" ? firstBlock : getBlockParagraphs(firstBlock)[0] ?? null;
50060
- }
50070
+ const resolved = resolveZoneFirstParagraph(newFooter, "footer");
50071
+ zoneParagraph = resolved.paragraph;
50072
+ newFooter = resolved.blocks;
50061
50073
  }
50062
50074
  if (newHeader !== section.header || newFooter !== section.footer) {
50063
50075
  const newSections = [...sections];
@@ -53015,224 +53027,6 @@ function connectEditorClientHost(controller, deps) {
53015
53027
  exportPdf: () => Promise.resolve(deps.docIO.handleExportPdf())
53016
53028
  });
53017
53029
  }
53018
- const SHAPE_DEFAULT_WIDTH = 150;
53019
- const SHAPE_DEFAULT_HEIGHT = 100;
53020
- const SHAPE_DEFAULT_FILL = "#4472C4";
53021
- const SHAPE_DEFAULT_BORDER_COLOR = "#2F528F";
53022
- const SHAPE_DEFAULT_BORDER_WIDTH_PT = 1;
53023
- function insertShapeAtSelection(state, preset) {
53024
- const collapsedState = isSelectionCollapsed(state.selection) ? state : deleteSelectionRange(state);
53025
- const { paragraph, index, offset } = getFocusParagraph(collapsedState);
53026
- const textBox = {
53027
- width: SHAPE_DEFAULT_WIDTH,
53028
- height: SHAPE_DEFAULT_HEIGHT,
53029
- blocks: [createEditorParagraph("")],
53030
- shape: {
53031
- preset,
53032
- fill: SHAPE_DEFAULT_FILL,
53033
- borderColor: SHAPE_DEFAULT_BORDER_COLOR,
53034
- borderWidthPt: SHAPE_DEFAULT_BORDER_WIDTH_PT
53035
- },
53036
- floating: wrapPresetToFloating(void 0, "front")
53037
- };
53038
- const insertedRun = createEditorStyledRun(
53039
- "",
53040
- getStyleAtOffset(paragraph, offset),
53041
- void 0,
53042
- textBox
53043
- );
53044
- const nextParagraph = insertRunsAtOffset(paragraph, offset, [insertedRun]);
53045
- const paragraphs = getParagraphs(collapsedState);
53046
- const nextParagraphs = paragraphs.map(
53047
- (candidate, candidateIndex) => candidateIndex === index ? nextParagraph : cloneParagraph(candidate)
53048
- );
53049
- return cloneStateWithParagraphs(
53050
- collapsedState,
53051
- nextParagraphs,
53052
- withSelection(paragraphOffsetToPosition(nextParagraph, offset + 1))
53053
- );
53054
- }
53055
- const DEFAULT_TOC_MAX_LEVEL = 3;
53056
- const TOC_INSTRUCTION = ' TOC \\o "1-3" \\h \\z \\u ';
53057
- const twipsToPx = (twips) => Math.round(twips / TWIPS_PER_INCH * PX_PER_INCH);
53058
- function collectTocHeadings(state, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
53059
- var _a2;
53060
- const headings = [];
53061
- for (const paragraph of getDocumentParagraphs(state.document)) {
53062
- const level = getHeadingLevel((_a2 = paragraph.style) == null ? void 0 : _a2.styleId);
53063
- if (level === null || level > maxLevel) continue;
53064
- const text = getParagraphText(paragraph).trim();
53065
- if (!text) continue;
53066
- headings.push({ id: paragraph.id, level, text });
53067
- }
53068
- return headings;
53069
- }
53070
- function makeRun(partial) {
53071
- const id = createEditorRun(partial.text).id;
53072
- if (partial.fieldChar) {
53073
- return {
53074
- id,
53075
- text: partial.text,
53076
- kind: "fieldChar",
53077
- fieldChar: partial.fieldChar
53078
- };
53079
- }
53080
- if (partial.fieldInstruction !== void 0) {
53081
- return {
53082
- id,
53083
- text: partial.text,
53084
- kind: "fieldInstruction",
53085
- fieldInstruction: partial.fieldInstruction
53086
- };
53087
- }
53088
- return { id, text: partial.text, kind: "text" };
53089
- }
53090
- function makeParagraph(runs, style2) {
53091
- const paragraph = createEditorParagraph("");
53092
- paragraph.runs = runs;
53093
- if (style2) paragraph.style = style2;
53094
- return paragraph;
53095
- }
53096
- function buildEntryParagraph(heading, pageNumber, rightTabPositionPt) {
53097
- const pageLabel = pageNumber !== void 0 ? String(pageNumber) : "";
53098
- const run = makeRun({ text: `${heading.text} ${pageLabel}` });
53099
- const style2 = {
53100
- tabs: [{ position: rightTabPositionPt, type: "right", leader: "dot" }],
53101
- spacingAfter: twipsToPx(40),
53102
- indentLeft: twipsToPx((heading.level - 1) * 397)
53103
- };
53104
- return makeParagraph([run], style2);
53105
- }
53106
- function rightTabPositionForSection(section) {
53107
- const { width, margins } = section.pageSettings;
53108
- const contentWidthPx = Math.max(0, width - margins.left - margins.right);
53109
- return roundTo(contentWidthPx * PT_PER_PX, 2);
53110
- }
53111
- function buildStartMarkerParagraph() {
53112
- return makeParagraph([
53113
- makeRun({ text: "", fieldChar: { kind: "begin" } }),
53114
- makeRun({ text: "", fieldInstruction: TOC_INSTRUCTION }),
53115
- makeRun({ text: "", fieldChar: { kind: "separate" } })
53116
- ]);
53117
- }
53118
- function buildEndMarkerParagraph() {
53119
- return makeParagraph([makeRun({ text: "", fieldChar: { kind: "end" } })]);
53120
- }
53121
- function buildTocBlocks(headings, resolvePage, rightTabPositionPt) {
53122
- const entries = headings.map(
53123
- (heading) => buildEntryParagraph(heading, resolvePage(heading.id), rightTabPositionPt)
53124
- );
53125
- return [buildStartMarkerParagraph(), ...entries, buildEndMarkerParagraph()];
53126
- }
53127
- function replaceSectionBlocks(state, sectionIndex, nextBlocks, selectionParagraph) {
53128
- const sections = getDocumentSections(state.document);
53129
- const section = sections[sectionIndex];
53130
- if (!section) return state;
53131
- const nextSections = [...sections];
53132
- nextSections[sectionIndex] = { ...section, blocks: nextBlocks };
53133
- return {
53134
- ...state,
53135
- document: { ...state.document, sections: nextSections },
53136
- selection: withSelection(paragraphOffsetToPosition(selectionParagraph, 0))
53137
- };
53138
- }
53139
- function insertTableOfContents(state, resolvePage = () => void 0, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
53140
- const zone = getActiveZone(state);
53141
- if (zone !== "main") return state;
53142
- const sectionIndex = getActiveSectionIndex(state);
53143
- const sections = getDocumentSections(state.document);
53144
- const section = sections[sectionIndex];
53145
- if (!section) return state;
53146
- const headings = collectTocHeadings(state, maxLevel);
53147
- const tocBlocks = buildTocBlocks(
53148
- headings,
53149
- resolvePage,
53150
- rightTabPositionForSection(section)
53151
- );
53152
- const focus = clampPosition(state, state.selection.focus);
53153
- const blockIndex = section.blocks.findIndex((block) => {
53154
- if (block.id === focus.paragraphId) return true;
53155
- if (block.type === "paragraph") return false;
53156
- return getBlockParagraphs(block).some(
53157
- (p) => p.id === focus.paragraphId
53158
- );
53159
- });
53160
- const insertAt = blockIndex === -1 ? section.blocks.length : blockIndex + 1;
53161
- const nextBlocks = [
53162
- ...section.blocks.slice(0, insertAt),
53163
- ...tocBlocks,
53164
- ...section.blocks.slice(insertAt)
53165
- ];
53166
- return replaceSectionBlocks(state, sectionIndex, nextBlocks, tocBlocks[0]);
53167
- }
53168
- function findTocRegion(blocks) {
53169
- let depth = 0;
53170
- let instruction = "";
53171
- let separateBlockIndex = -1;
53172
- let beginBlockIndex = -1;
53173
- let isToc = false;
53174
- for (let i = 0; i < blocks.length; i += 1) {
53175
- const block = blocks[i];
53176
- if (block.type !== "paragraph") continue;
53177
- for (const run of block.runs) {
53178
- const fieldChar = getRunFieldChar(run);
53179
- const fieldInstruction = getRunFieldInstruction(run);
53180
- if ((fieldChar == null ? void 0 : fieldChar.kind) === "begin") {
53181
- depth += 1;
53182
- if (depth === 1) {
53183
- beginBlockIndex = i;
53184
- instruction = "";
53185
- isToc = false;
53186
- separateBlockIndex = -1;
53187
- }
53188
- } else if (depth === 1 && fieldInstruction !== void 0) {
53189
- instruction += fieldInstruction;
53190
- if (/\bTOC\b/i.test(instruction)) isToc = true;
53191
- } else if ((fieldChar == null ? void 0 : fieldChar.kind) === "separate") {
53192
- if (depth === 1) separateBlockIndex = i;
53193
- } else if ((fieldChar == null ? void 0 : fieldChar.kind) === "end") {
53194
- if (depth === 1) {
53195
- if (isToc) {
53196
- return {
53197
- startBlockIndex: separateBlockIndex >= 0 ? separateBlockIndex : beginBlockIndex,
53198
- endBlockIndex: i
53199
- };
53200
- }
53201
- }
53202
- depth = Math.max(0, depth - 1);
53203
- }
53204
- }
53205
- }
53206
- return null;
53207
- }
53208
- function updateTableOfContents(state, resolvePage = () => void 0, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
53209
- const sectionIndex = getActiveSectionIndex(state);
53210
- const sections = getDocumentSections(state.document);
53211
- const section = sections[sectionIndex];
53212
- if (!section) return state;
53213
- const region = findTocRegion(section.blocks);
53214
- if (!region) return state;
53215
- const headings = collectTocHeadings(state, maxLevel);
53216
- const entries = headings.map(
53217
- (heading) => buildEntryParagraph(
53218
- heading,
53219
- resolvePage(heading.id),
53220
- rightTabPositionForSection(section)
53221
- )
53222
- );
53223
- const nextBlocks = [
53224
- ...section.blocks.slice(0, region.startBlockIndex + 1),
53225
- ...entries,
53226
- ...section.blocks.slice(region.endBlockIndex)
53227
- ];
53228
- const selectionParagraph = entries[0] ?? section.blocks[region.startBlockIndex];
53229
- return replaceSectionBlocks(
53230
- state,
53231
- sectionIndex,
53232
- nextBlocks,
53233
- selectionParagraph
53234
- );
53235
- }
53236
53030
  function createCommandBuilder(isCommandEnabled) {
53237
53031
  return (name, execute, state) => ({
53238
53032
  execute,
@@ -53894,16 +53688,211 @@ function createEssentialsPlugin(deps) {
53894
53688
  }
53895
53689
  };
53896
53690
  }
53897
- function createEditorEssentialsRuntimePlugin(options) {
53898
- const essentialsGate = {
53691
+ function buildEssentialsGate(options) {
53692
+ return {
53899
53693
  isCommandEnabled: (commandName) => !options.isReadOnly() && (commandName !== "insertFootnote" || options.commandsController.canInsertFootnoteCommand())
53900
53694
  };
53901
- const essentialsStyle = {
53695
+ }
53696
+ function buildEssentialsStyle(options) {
53697
+ return {
53902
53698
  state: () => options.styleController.toolbarStyleState()
53903
53699
  };
53904
- const essentialsSelection = {
53700
+ }
53701
+ function buildEssentialsSelection(options) {
53702
+ return {
53905
53703
  isCollapsed: () => isSelectionCollapsed(options.state().selection)
53906
53704
  };
53705
+ }
53706
+ function buildEssentialsHistory(options) {
53707
+ return {
53708
+ canUndo: () => options.undoStack().length > 0,
53709
+ canRedo: () => options.redoStack().length > 0,
53710
+ undo: () => (options.historyActions.performUndo(), true),
53711
+ redo: () => (options.historyActions.performRedo(), true)
53712
+ };
53713
+ }
53714
+ const DEFAULT_TOC_MAX_LEVEL = 3;
53715
+ const TOC_INSTRUCTION = ' TOC \\o "1-3" \\h \\z \\u ';
53716
+ const twipsToPx = (twips) => Math.round(twips / TWIPS_PER_INCH * PX_PER_INCH);
53717
+ function collectTocHeadings(state, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
53718
+ var _a2;
53719
+ const headings = [];
53720
+ for (const paragraph of getDocumentParagraphs(state.document)) {
53721
+ const level = getHeadingLevel((_a2 = paragraph.style) == null ? void 0 : _a2.styleId);
53722
+ if (level === null || level > maxLevel) continue;
53723
+ const text = getParagraphText(paragraph).trim();
53724
+ if (!text) continue;
53725
+ headings.push({ id: paragraph.id, level, text });
53726
+ }
53727
+ return headings;
53728
+ }
53729
+ function makeRun(partial) {
53730
+ const id = createEditorRun(partial.text).id;
53731
+ if (partial.fieldChar) {
53732
+ return {
53733
+ id,
53734
+ text: partial.text,
53735
+ kind: "fieldChar",
53736
+ fieldChar: partial.fieldChar
53737
+ };
53738
+ }
53739
+ if (partial.fieldInstruction !== void 0) {
53740
+ return {
53741
+ id,
53742
+ text: partial.text,
53743
+ kind: "fieldInstruction",
53744
+ fieldInstruction: partial.fieldInstruction
53745
+ };
53746
+ }
53747
+ return { id, text: partial.text, kind: "text" };
53748
+ }
53749
+ function makeParagraph(runs, style2) {
53750
+ const paragraph = createEditorParagraph("");
53751
+ paragraph.runs = runs;
53752
+ if (style2) paragraph.style = style2;
53753
+ return paragraph;
53754
+ }
53755
+ function buildEntryParagraph(heading, pageNumber, rightTabPositionPt) {
53756
+ const pageLabel = pageNumber !== void 0 ? String(pageNumber) : "";
53757
+ const run = makeRun({ text: `${heading.text} ${pageLabel}` });
53758
+ const style2 = {
53759
+ tabs: [{ position: rightTabPositionPt, type: "right", leader: "dot" }],
53760
+ spacingAfter: twipsToPx(40),
53761
+ indentLeft: twipsToPx((heading.level - 1) * 397)
53762
+ };
53763
+ return makeParagraph([run], style2);
53764
+ }
53765
+ function rightTabPositionForSection(section) {
53766
+ const { width, margins } = section.pageSettings;
53767
+ const contentWidthPx = Math.max(0, width - margins.left - margins.right);
53768
+ return roundTo(contentWidthPx * PT_PER_PX, 2);
53769
+ }
53770
+ function buildStartMarkerParagraph() {
53771
+ return makeParagraph([
53772
+ makeRun({ text: "", fieldChar: { kind: "begin" } }),
53773
+ makeRun({ text: "", fieldInstruction: TOC_INSTRUCTION }),
53774
+ makeRun({ text: "", fieldChar: { kind: "separate" } })
53775
+ ]);
53776
+ }
53777
+ function buildEndMarkerParagraph() {
53778
+ return makeParagraph([makeRun({ text: "", fieldChar: { kind: "end" } })]);
53779
+ }
53780
+ function buildTocBlocks(headings, resolvePage, rightTabPositionPt) {
53781
+ const entries = headings.map(
53782
+ (heading) => buildEntryParagraph(heading, resolvePage(heading.id), rightTabPositionPt)
53783
+ );
53784
+ return [buildStartMarkerParagraph(), ...entries, buildEndMarkerParagraph()];
53785
+ }
53786
+ function replaceSectionBlocks(state, sectionIndex, nextBlocks, selectionParagraph) {
53787
+ const sections = getDocumentSections(state.document);
53788
+ const section = sections[sectionIndex];
53789
+ if (!section) return state;
53790
+ const nextSections = [...sections];
53791
+ nextSections[sectionIndex] = { ...section, blocks: nextBlocks };
53792
+ return {
53793
+ ...state,
53794
+ document: { ...state.document, sections: nextSections },
53795
+ selection: withSelection(paragraphOffsetToPosition(selectionParagraph, 0))
53796
+ };
53797
+ }
53798
+ function insertTableOfContents(state, resolvePage = () => void 0, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
53799
+ const zone = getActiveZone(state);
53800
+ if (zone !== "main") return state;
53801
+ const sectionIndex = getActiveSectionIndex(state);
53802
+ const sections = getDocumentSections(state.document);
53803
+ const section = sections[sectionIndex];
53804
+ if (!section) return state;
53805
+ const headings = collectTocHeadings(state, maxLevel);
53806
+ const tocBlocks = buildTocBlocks(
53807
+ headings,
53808
+ resolvePage,
53809
+ rightTabPositionForSection(section)
53810
+ );
53811
+ const focus = clampPosition(state, state.selection.focus);
53812
+ const blockIndex = section.blocks.findIndex((block) => {
53813
+ if (block.id === focus.paragraphId) return true;
53814
+ if (block.type === "paragraph") return false;
53815
+ return getBlockParagraphs(block).some(
53816
+ (p) => p.id === focus.paragraphId
53817
+ );
53818
+ });
53819
+ const insertAt = blockIndex === -1 ? section.blocks.length : blockIndex + 1;
53820
+ const nextBlocks = [
53821
+ ...section.blocks.slice(0, insertAt),
53822
+ ...tocBlocks,
53823
+ ...section.blocks.slice(insertAt)
53824
+ ];
53825
+ return replaceSectionBlocks(state, sectionIndex, nextBlocks, tocBlocks[0]);
53826
+ }
53827
+ function findTocRegion(blocks) {
53828
+ let depth = 0;
53829
+ let instruction = "";
53830
+ let separateBlockIndex = -1;
53831
+ let beginBlockIndex = -1;
53832
+ let isToc = false;
53833
+ for (let i = 0; i < blocks.length; i += 1) {
53834
+ const block = blocks[i];
53835
+ if (block.type !== "paragraph") continue;
53836
+ for (const run of block.runs) {
53837
+ const fieldChar = getRunFieldChar(run);
53838
+ const fieldInstruction = getRunFieldInstruction(run);
53839
+ if ((fieldChar == null ? void 0 : fieldChar.kind) === "begin") {
53840
+ depth += 1;
53841
+ if (depth === 1) {
53842
+ beginBlockIndex = i;
53843
+ instruction = "";
53844
+ isToc = false;
53845
+ separateBlockIndex = -1;
53846
+ }
53847
+ } else if (depth === 1 && fieldInstruction !== void 0) {
53848
+ instruction += fieldInstruction;
53849
+ if (/\bTOC\b/i.test(instruction)) isToc = true;
53850
+ } else if ((fieldChar == null ? void 0 : fieldChar.kind) === "separate") {
53851
+ if (depth === 1) separateBlockIndex = i;
53852
+ } else if ((fieldChar == null ? void 0 : fieldChar.kind) === "end") {
53853
+ if (depth === 1) {
53854
+ if (isToc) {
53855
+ return {
53856
+ startBlockIndex: separateBlockIndex >= 0 ? separateBlockIndex : beginBlockIndex,
53857
+ endBlockIndex: i
53858
+ };
53859
+ }
53860
+ }
53861
+ depth = Math.max(0, depth - 1);
53862
+ }
53863
+ }
53864
+ }
53865
+ return null;
53866
+ }
53867
+ function updateTableOfContents(state, resolvePage = () => void 0, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
53868
+ const sectionIndex = getActiveSectionIndex(state);
53869
+ const sections = getDocumentSections(state.document);
53870
+ const section = sections[sectionIndex];
53871
+ if (!section) return state;
53872
+ const region = findTocRegion(section.blocks);
53873
+ if (!region) return state;
53874
+ const headings = collectTocHeadings(state, maxLevel);
53875
+ const entries = headings.map(
53876
+ (heading) => buildEntryParagraph(
53877
+ heading,
53878
+ resolvePage(heading.id),
53879
+ rightTabPositionForSection(section)
53880
+ )
53881
+ );
53882
+ const nextBlocks = [
53883
+ ...section.blocks.slice(0, region.startBlockIndex + 1),
53884
+ ...entries,
53885
+ ...section.blocks.slice(region.endBlockIndex)
53886
+ ];
53887
+ const selectionParagraph = entries[0] ?? section.blocks[region.startBlockIndex];
53888
+ return replaceSectionBlocks(
53889
+ state,
53890
+ sectionIndex,
53891
+ nextBlocks,
53892
+ selectionParagraph
53893
+ );
53894
+ }
53895
+ function buildEssentialsFormatting(options) {
53907
53896
  const stepFontSize = (direction) => {
53908
53897
  const currentPx = Number(
53909
53898
  options.styleController.toolbarStyleState().fontSize
@@ -53916,12 +53905,6 @@ function createEditorEssentialsRuntimePlugin(options) {
53916
53905
  );
53917
53906
  return true;
53918
53907
  };
53919
- const essentialsHistory = {
53920
- canUndo: () => options.undoStack().length > 0,
53921
- canRedo: () => options.redoStack().length > 0,
53922
- undo: () => (options.historyActions.performUndo(), true),
53923
- redo: () => (options.historyActions.performRedo(), true)
53924
- };
53925
53908
  const buildTocPageResolver = (state) => {
53926
53909
  const layout = projectDocumentLayout(state.document);
53927
53910
  const pageByParagraph = /* @__PURE__ */ new Map();
@@ -53935,7 +53918,7 @@ function createEditorEssentialsRuntimePlugin(options) {
53935
53918
  }
53936
53919
  return (headingId) => pageByParagraph.get(headingId);
53937
53920
  };
53938
- const essentialsFormatting = {
53921
+ return {
53939
53922
  selectAll: () => {
53940
53923
  const paragraphs = getDocumentParagraphs(options.state().document);
53941
53924
  if (paragraphs.length === 0) return false;
@@ -54054,7 +54037,46 @@ function createEditorEssentialsRuntimePlugin(options) {
54054
54037
  ), true),
54055
54038
  setUnderlineStyle: (value) => options.styleController.applyToolbarValueStyleCommand("underlineStyle", value)
54056
54039
  };
54057
- const essentialsDocument = {
54040
+ }
54041
+ const SHAPE_DEFAULT_WIDTH = 150;
54042
+ const SHAPE_DEFAULT_HEIGHT = 100;
54043
+ const SHAPE_DEFAULT_FILL = "#4472C4";
54044
+ const SHAPE_DEFAULT_BORDER_COLOR = "#2F528F";
54045
+ const SHAPE_DEFAULT_BORDER_WIDTH_PT = 1;
54046
+ function insertShapeAtSelection(state, preset) {
54047
+ const collapsedState = isSelectionCollapsed(state.selection) ? state : deleteSelectionRange(state);
54048
+ const { paragraph, index, offset } = getFocusParagraph(collapsedState);
54049
+ const textBox = {
54050
+ width: SHAPE_DEFAULT_WIDTH,
54051
+ height: SHAPE_DEFAULT_HEIGHT,
54052
+ blocks: [createEditorParagraph("")],
54053
+ shape: {
54054
+ preset,
54055
+ fill: SHAPE_DEFAULT_FILL,
54056
+ borderColor: SHAPE_DEFAULT_BORDER_COLOR,
54057
+ borderWidthPt: SHAPE_DEFAULT_BORDER_WIDTH_PT
54058
+ },
54059
+ floating: wrapPresetToFloating(void 0, "front")
54060
+ };
54061
+ const insertedRun = createEditorStyledRun(
54062
+ "",
54063
+ getStyleAtOffset(paragraph, offset),
54064
+ void 0,
54065
+ textBox
54066
+ );
54067
+ const nextParagraph = insertRunsAtOffset(paragraph, offset, [insertedRun]);
54068
+ const paragraphs = getParagraphs(collapsedState);
54069
+ const nextParagraphs = paragraphs.map(
54070
+ (candidate, candidateIndex) => candidateIndex === index ? nextParagraph : cloneParagraph(candidate)
54071
+ );
54072
+ return cloneStateWithParagraphs(
54073
+ collapsedState,
54074
+ nextParagraphs,
54075
+ withSelection(paragraphOffsetToPosition(nextParagraph, offset + 1))
54076
+ );
54077
+ }
54078
+ function buildEssentialsDocument(options) {
54079
+ return {
54058
54080
  documentStyles: () => {
54059
54081
  var _a2, _b2;
54060
54082
  const document2 = options.state().document;
@@ -54100,23 +54122,31 @@ function createEditorEssentialsRuntimePlugin(options) {
54100
54122
  (current) => insertShapeAtSelection(current, preset)
54101
54123
  )
54102
54124
  };
54103
- const essentialsLink = {
54125
+ }
54126
+ function buildEssentialsLink(options) {
54127
+ return {
54104
54128
  prompt: () => options.commandsController.promptForLink(),
54105
54129
  remove: () => options.commandsController.removeLinkCommand(),
54106
54130
  canPrompt: () => !isSelectionCollapsed(options.state().selection) || Boolean(options.styleController.toolbarStyleState().link)
54107
54131
  };
54108
- const essentialsImage = {
54132
+ }
54133
+ function buildEssentialsImage(options) {
54134
+ return {
54109
54135
  promptAlt: () => options.commandsController.promptForImageAlt(),
54110
54136
  promptCaption: () => options.commandsController.promptForImageCaption(),
54111
54137
  isSelected: () => Boolean(options.selectedImageRun())
54112
54138
  };
54113
- const essentialsBrowser = {
54139
+ }
54140
+ function buildEssentialsBrowser() {
54141
+ return {
54114
54142
  print: () => window.print(),
54115
54143
  copy: () => {
54116
54144
  document.execCommand("copy");
54117
54145
  }
54118
54146
  };
54119
- const essentialsParagraph = {
54147
+ }
54148
+ function buildEssentialsParagraph(options) {
54149
+ return {
54120
54150
  togglePageBreakBefore: () => options.commandsController.toggleParagraphFlagCommand("pageBreakBefore"),
54121
54151
  toggleKeepWithNext: () => options.commandsController.toggleParagraphFlagCommand("keepWithNext"),
54122
54152
  setSpacingAfter: (value) => options.commandsController.applyParagraphStyleCommand(
@@ -54190,21 +54220,23 @@ function createEditorEssentialsRuntimePlugin(options) {
54190
54220
  outdent: () => void options.commandsController.handleListTab("outdent"),
54191
54221
  indent: () => void options.commandsController.handleListTab("indent")
54192
54222
  };
54193
- const essentialsSection = {
54223
+ }
54224
+ function buildEssentialsSection(options) {
54225
+ const section = {
54194
54226
  isLandscape: () => {
54195
54227
  var _a2, _b2;
54196
54228
  const idx = getActiveSectionIndex(options.state());
54197
- const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54198
- return ((_b2 = section == null ? void 0 : section.pageSettings) == null ? void 0 : _b2.orientation) === "landscape";
54229
+ const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54230
+ return ((_b2 = target == null ? void 0 : target.pageSettings) == null ? void 0 : _b2.orientation) === "landscape";
54199
54231
  },
54200
54232
  setOrientation: (orientation) => {
54201
54233
  var _a2;
54202
54234
  const idx = getActiveSectionIndex(options.state());
54203
- const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54204
- if (!section) return;
54235
+ const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54236
+ if (!target) return;
54205
54237
  options.commandsController.applyUpdateSectionSettingsCommand(idx, {
54206
54238
  pageSettings: {
54207
- ...section.pageSettings,
54239
+ ...target.pageSettings,
54208
54240
  orientation
54209
54241
  }
54210
54242
  });
@@ -54212,259 +54244,259 @@ function createEditorEssentialsRuntimePlugin(options) {
54212
54244
  toggleOrientation: () => {
54213
54245
  var _a2, _b2;
54214
54246
  const idx = getActiveSectionIndex(options.state());
54215
- const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54216
- if (!section) return;
54217
- const current = ((_b2 = section.pageSettings) == null ? void 0 : _b2.orientation) ?? "portrait";
54218
- essentialsSection.setOrientation(
54219
- current === "portrait" ? "landscape" : "portrait"
54220
- );
54247
+ const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54248
+ if (!target) return;
54249
+ const current = ((_b2 = target.pageSettings) == null ? void 0 : _b2.orientation) ?? "portrait";
54250
+ section.setOrientation(current === "portrait" ? "landscape" : "portrait");
54221
54251
  },
54222
54252
  breakNextPage: () => options.commandsController.applyInsertSectionBreakCommand("nextPage"),
54223
54253
  breakContinuous: () => options.commandsController.applyInsertSectionBreakCommand("continuous"),
54224
54254
  getMargins: () => {
54225
54255
  var _a2, _b2;
54226
54256
  const idx = getActiveSectionIndex(options.state());
54227
- const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54228
- return (_b2 = section == null ? void 0 : section.pageSettings) == null ? void 0 : _b2.margins;
54257
+ const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54258
+ return (_b2 = target == null ? void 0 : target.pageSettings) == null ? void 0 : _b2.margins;
54229
54259
  },
54230
54260
  setPageMargins: (margins) => {
54231
54261
  var _a2;
54232
54262
  const idx = getActiveSectionIndex(options.state());
54233
- const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54234
- if (!(section == null ? void 0 : section.pageSettings)) return;
54263
+ const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54264
+ if (!(target == null ? void 0 : target.pageSettings)) return;
54235
54265
  options.commandsController.applyUpdateSectionSettingsCommand(idx, {
54236
54266
  pageSettings: {
54237
- ...section.pageSettings,
54267
+ ...target.pageSettings,
54238
54268
  margins: {
54239
- ...section.pageSettings.margins,
54269
+ ...target.pageSettings.margins,
54240
54270
  ...margins
54241
54271
  }
54242
54272
  }
54243
54273
  });
54244
54274
  }
54245
54275
  };
54246
- const buildEssentialsTable = () => {
54247
- const insideTable = () => Boolean(
54248
- findParagraphTableLocation(
54249
- options.state().document,
54250
- options.state().selection.focus.paragraphId,
54251
- getActiveSectionIndex(options.state())
54252
- )
54276
+ return section;
54277
+ }
54278
+ function buildEssentialsTable(options) {
54279
+ const insideTable = () => Boolean(
54280
+ findParagraphTableLocation(
54281
+ options.state().document,
54282
+ options.state().selection.focus.paragraphId,
54283
+ getActiveSectionIndex(options.state())
54284
+ )
54285
+ );
54286
+ const apply = (producer, mergeKey) => {
54287
+ options.applyTransactionalState(producer, { mergeKey });
54288
+ options.focusInput();
54289
+ };
54290
+ const RAW_TBL_LOOK_DEFAULTS = {
54291
+ firstRow: false,
54292
+ lastRow: false,
54293
+ firstCol: false,
54294
+ lastCol: false,
54295
+ noHBand: false,
54296
+ noVBand: false
54297
+ };
54298
+ const selectedTableIn = (state) => {
54299
+ const secIdx = getActiveSectionIndex(state);
54300
+ const loc = findParagraphTableLocation(
54301
+ state.document,
54302
+ state.selection.focus.paragraphId,
54303
+ secIdx
54253
54304
  );
54254
- const apply = (producer, mergeKey) => {
54255
- options.applyTransactionalState(producer, { mergeKey });
54256
- options.focusInput();
54257
- };
54258
- const RAW_TBL_LOOK_DEFAULTS = {
54259
- firstRow: false,
54260
- lastRow: false,
54261
- firstCol: false,
54262
- lastCol: false,
54263
- noHBand: false,
54264
- noVBand: false
54265
- };
54266
- const selectedTableIn = (state) => {
54267
- const secIdx = getActiveSectionIndex(state);
54268
- const loc = findParagraphTableLocation(
54269
- state.document,
54270
- state.selection.focus.paragraphId,
54271
- secIdx
54272
- );
54273
- if (!loc) return null;
54274
- const section = getDocumentSections(state.document)[secIdx];
54275
- if (!section) return null;
54276
- const blocks = loc.zone === "header" ? section.header ?? [] : loc.zone === "footer" ? section.footer ?? [] : section.blocks;
54277
- const table = blocks[loc.blockIndex];
54278
- return table && table.type === "table" ? table : null;
54279
- };
54280
- const rawTblLookIn = (state) => {
54281
- var _a2;
54282
- const table = selectedTableIn(state);
54283
- if (!table) return null;
54284
- return { ...RAW_TBL_LOOK_DEFAULTS, ...((_a2 = table.style) == null ? void 0 : _a2.tblLook) ?? {} };
54285
- };
54286
- const selectionLabel = () => {
54287
- const normalized = normalizeSelection(options.state());
54288
- if (normalized.isCollapsed) return null;
54289
- const secIdx = getActiveSectionIndex(options.state());
54290
- const anchorLoc = findParagraphTableLocation(
54291
- options.state().document,
54292
- options.state().selection.anchor.paragraphId,
54293
- secIdx
54294
- );
54295
- const focusLoc = findParagraphTableLocation(
54296
- options.state().document,
54297
- options.state().selection.focus.paragraphId,
54298
- secIdx
54299
- );
54300
- if (!anchorLoc || !focusLoc || anchorLoc.blockIndex !== focusLoc.blockIndex || anchorLoc.rowIndex === focusLoc.rowIndex && anchorLoc.cellIndex === focusLoc.cellIndex) {
54301
- return null;
54305
+ if (!loc) return null;
54306
+ const section = getDocumentSections(state.document)[secIdx];
54307
+ if (!section) return null;
54308
+ const blocks = loc.zone === "header" ? section.header ?? [] : loc.zone === "footer" ? section.footer ?? [] : section.blocks;
54309
+ const table = blocks[loc.blockIndex];
54310
+ return table && table.type === "table" ? table : null;
54311
+ };
54312
+ const rawTblLookIn = (state) => {
54313
+ var _a2;
54314
+ const table = selectedTableIn(state);
54315
+ if (!table) return null;
54316
+ return { ...RAW_TBL_LOOK_DEFAULTS, ...((_a2 = table.style) == null ? void 0 : _a2.tblLook) ?? {} };
54317
+ };
54318
+ const selectionLabel = () => {
54319
+ const normalized = normalizeSelection(options.state());
54320
+ if (normalized.isCollapsed) return null;
54321
+ const secIdx = getActiveSectionIndex(options.state());
54322
+ const anchorLoc = findParagraphTableLocation(
54323
+ options.state().document,
54324
+ options.state().selection.anchor.paragraphId,
54325
+ secIdx
54326
+ );
54327
+ const focusLoc = findParagraphTableLocation(
54328
+ options.state().document,
54329
+ options.state().selection.focus.paragraphId,
54330
+ secIdx
54331
+ );
54332
+ if (!anchorLoc || !focusLoc || anchorLoc.blockIndex !== focusLoc.blockIndex || anchorLoc.rowIndex === focusLoc.rowIndex && anchorLoc.cellIndex === focusLoc.cellIndex) {
54333
+ return null;
54334
+ }
54335
+ const count = options.selectionBoxes().length;
54336
+ if (count === 0) return null;
54337
+ return `Table selection: ${count} cell${count === 1 ? "" : "s"}`;
54338
+ };
54339
+ return {
54340
+ insideTable,
54341
+ selectionLabel,
54342
+ getTblLook: () => {
54343
+ const raw = rawTblLookIn(options.state());
54344
+ if (!raw) return null;
54345
+ return {
54346
+ firstRow: raw.firstRow,
54347
+ lastRow: raw.lastRow,
54348
+ firstCol: raw.firstCol,
54349
+ lastCol: raw.lastCol,
54350
+ // Banding is stored as the negated "no band" flags in OOXML.
54351
+ bandedRows: !raw.noHBand,
54352
+ bandedCols: !raw.noVBand
54353
+ };
54354
+ },
54355
+ toggleTblLook: (flag) => apply((current) => {
54356
+ const raw = rawTblLookIn(current);
54357
+ if (!raw) return current;
54358
+ const next = { ...raw };
54359
+ switch (flag) {
54360
+ case "firstRow":
54361
+ next.firstRow = !raw.firstRow;
54362
+ break;
54363
+ case "lastRow":
54364
+ next.lastRow = !raw.lastRow;
54365
+ break;
54366
+ case "firstCol":
54367
+ next.firstCol = !raw.firstCol;
54368
+ break;
54369
+ case "lastCol":
54370
+ next.lastCol = !raw.lastCol;
54371
+ break;
54372
+ case "bandedRows":
54373
+ next.noHBand = !raw.noHBand;
54374
+ break;
54375
+ case "bandedCols":
54376
+ next.noVBand = !raw.noVBand;
54377
+ break;
54302
54378
  }
54303
- const count = options.selectionBoxes().length;
54304
- if (count === 0) return null;
54305
- return `Table selection: ${count} cell${count === 1 ? "" : "s"}`;
54306
- };
54307
- return {
54308
- insideTable,
54309
- selectionLabel,
54310
- getTblLook: () => {
54311
- const raw = rawTblLookIn(options.state());
54312
- if (!raw) return null;
54313
- return {
54314
- firstRow: raw.firstRow,
54315
- lastRow: raw.lastRow,
54316
- firstCol: raw.firstCol,
54317
- lastCol: raw.lastCol,
54318
- // Banding is stored as the negated "no band" flags in OOXML.
54319
- bandedRows: !raw.noHBand,
54320
- bandedCols: !raw.noVBand
54321
- };
54322
- },
54323
- toggleTblLook: (flag) => apply((current) => {
54324
- const raw = rawTblLookIn(current);
54325
- if (!raw) return current;
54326
- const next = { ...raw };
54327
- switch (flag) {
54328
- case "firstRow":
54329
- next.firstRow = !raw.firstRow;
54330
- break;
54331
- case "lastRow":
54332
- next.lastRow = !raw.lastRow;
54333
- break;
54334
- case "firstCol":
54335
- next.firstCol = !raw.firstCol;
54336
- break;
54337
- case "lastCol":
54338
- next.lastCol = !raw.lastCol;
54339
- break;
54340
- case "bandedRows":
54341
- next.noHBand = !raw.noHBand;
54342
- break;
54343
- case "bandedCols":
54344
- next.noVBand = !raw.noVBand;
54345
- break;
54346
- }
54347
- return setTableStyleValue(current, "tblLook", next);
54348
- }, MERGE_KEYS.tableStyleOptions),
54349
- getStyleId: () => {
54350
- var _a2, _b2;
54351
- return ((_b2 = (_a2 = selectedTableIn(options.state())) == null ? void 0 : _a2.style) == null ? void 0 : _b2.styleId) ?? null;
54352
- },
54353
- setStyleId: (styleId) => apply(
54354
- (current) => setTableStyleValue(current, "styleId", styleId || null),
54355
- MERGE_KEYS.tableStyleGallery
54356
- ),
54357
- getLayout: () => {
54358
- var _a2, _b2;
54359
- return ((_b2 = (_a2 = selectedTableIn(options.state())) == null ? void 0 : _a2.style) == null ? void 0 : _b2.layout) ?? null;
54360
- },
54361
- toggleAutoFit: () => apply((current) => {
54362
- var _a2;
54363
- const table = selectedTableIn(current);
54364
- const nextLayout = ((_a2 = table == null ? void 0 : table.style) == null ? void 0 : _a2.layout) === "autofit" ? "fixed" : "autofit";
54365
- return setTableStyleValue(current, "layout", nextLayout);
54366
- }, MERGE_KEYS.tableDistribute),
54367
- distributeColumns: () => apply(
54368
- (current) => distributeSelectedTableColumns(current),
54369
- MERGE_KEYS.tableDistribute
54370
- ),
54371
- distributeRows: () => apply(
54372
- (current) => distributeSelectedTableRows(current),
54373
- MERGE_KEYS.tableDistribute
54374
- ),
54375
- canMerge: () => options.tableOps.canMergeSelectedTable(options.state()),
54376
- canSplit: () => options.tableOps.canSplitSelectedTable(options.state()),
54377
- canEditColumn: () => options.tableOps.canEditSelectedTableColumn(options.state()),
54378
- canEditRow: () => options.tableOps.canEditSelectedTableRow(options.state()),
54379
- merge: () => apply(
54380
- (current) => options.tableOps.mergeSelectedTable(current),
54381
- MERGE_KEYS.mergeTable
54382
- ),
54383
- split: () => apply(
54384
- (current) => options.tableOps.splitSelectedTable(current),
54385
- MERGE_KEYS.splitTable
54386
- ),
54387
- insertColumnBefore: () => apply(
54388
- (current) => options.tableOps.insertSelectedTableColumn(current, -1),
54389
- MERGE_KEYS.insertTableColumn
54390
- ),
54391
- insertColumnAfter: () => apply(
54392
- (current) => options.tableOps.insertSelectedTableColumn(current, 1),
54393
- MERGE_KEYS.insertTableColumn
54394
- ),
54395
- deleteColumn: () => apply(
54396
- (current) => options.tableOps.deleteSelectedTableColumn(current),
54397
- MERGE_KEYS.deleteTableColumn
54398
- ),
54399
- insertRowBefore: () => apply(
54400
- (current) => options.tableOps.insertSelectedTableRow(current, -1),
54401
- MERGE_KEYS.insertTableRow
54402
- ),
54403
- insertRowAfter: () => apply(
54404
- (current) => options.tableOps.insertSelectedTableRow(current, 1),
54405
- MERGE_KEYS.insertTableRow
54406
- ),
54407
- deleteRow: () => apply(
54408
- (current) => options.tableOps.deleteSelectedTableRow(current),
54409
- MERGE_KEYS.deleteTableRow
54410
- ),
54411
- cellShading: (color) => apply(
54412
- (current) => setTableCellStyleValue(current, "shading", color || null),
54413
- MERGE_KEYS.tableShading
54414
- ),
54415
- cellBorders: () => apply(
54416
- (current) => setTableCellBorders(current, {
54417
- width: 1,
54418
- type: "solid",
54419
- color: "#64748b"
54420
- }),
54421
- MERGE_KEYS.tableBorders
54422
- ),
54423
- cellNoBorders: () => apply(
54424
- (current) => setTableCellBorders(current, {
54425
- width: 0,
54426
- type: "none",
54427
- color: "transparent"
54428
- }),
54429
- MERGE_KEYS.tableBorders
54430
- ),
54431
- width100: () => apply(
54432
- (current) => setTableStyleValue(current, "width", "100%"),
54433
- MERGE_KEYS.tableWidth
54434
- ),
54435
- alignLeft: () => apply(
54436
- (current) => setTableCellStyleValue(current, "horizontalAlign", "left"),
54437
- MERGE_KEYS.tableAlign
54438
- ),
54439
- alignCenter: () => apply(
54440
- (current) => setTableCellStyleValue(current, "horizontalAlign", "center"),
54441
- MERGE_KEYS.tableAlign
54442
- ),
54443
- alignRight: () => apply(
54444
- (current) => setTableCellStyleValue(current, "horizontalAlign", "right"),
54445
- MERGE_KEYS.tableAlign
54446
- ),
54447
- setCellWidth: (width) => apply(
54448
- (current) => setTableCellWidth(current, width),
54449
- MERGE_KEYS.tableCellWidth
54450
- ),
54451
- insert: (rows, cols) => options.tableOps.insertTableCommand(rows, cols)
54452
- };
54379
+ return setTableStyleValue(current, "tblLook", next);
54380
+ }, MERGE_KEYS.tableStyleOptions),
54381
+ getStyleId: () => {
54382
+ var _a2, _b2;
54383
+ return ((_b2 = (_a2 = selectedTableIn(options.state())) == null ? void 0 : _a2.style) == null ? void 0 : _b2.styleId) ?? null;
54384
+ },
54385
+ setStyleId: (styleId) => apply(
54386
+ (current) => setTableStyleValue(current, "styleId", styleId || null),
54387
+ MERGE_KEYS.tableStyleGallery
54388
+ ),
54389
+ getLayout: () => {
54390
+ var _a2, _b2;
54391
+ return ((_b2 = (_a2 = selectedTableIn(options.state())) == null ? void 0 : _a2.style) == null ? void 0 : _b2.layout) ?? null;
54392
+ },
54393
+ toggleAutoFit: () => apply((current) => {
54394
+ var _a2;
54395
+ const table = selectedTableIn(current);
54396
+ const nextLayout = ((_a2 = table == null ? void 0 : table.style) == null ? void 0 : _a2.layout) === "autofit" ? "fixed" : "autofit";
54397
+ return setTableStyleValue(current, "layout", nextLayout);
54398
+ }, MERGE_KEYS.tableDistribute),
54399
+ distributeColumns: () => apply(
54400
+ (current) => distributeSelectedTableColumns(current),
54401
+ MERGE_KEYS.tableDistribute
54402
+ ),
54403
+ distributeRows: () => apply(
54404
+ (current) => distributeSelectedTableRows(current),
54405
+ MERGE_KEYS.tableDistribute
54406
+ ),
54407
+ canMerge: () => options.tableOps.canMergeSelectedTable(options.state()),
54408
+ canSplit: () => options.tableOps.canSplitSelectedTable(options.state()),
54409
+ canEditColumn: () => options.tableOps.canEditSelectedTableColumn(options.state()),
54410
+ canEditRow: () => options.tableOps.canEditSelectedTableRow(options.state()),
54411
+ merge: () => apply(
54412
+ (current) => options.tableOps.mergeSelectedTable(current),
54413
+ MERGE_KEYS.mergeTable
54414
+ ),
54415
+ split: () => apply(
54416
+ (current) => options.tableOps.splitSelectedTable(current),
54417
+ MERGE_KEYS.splitTable
54418
+ ),
54419
+ insertColumnBefore: () => apply(
54420
+ (current) => options.tableOps.insertSelectedTableColumn(current, -1),
54421
+ MERGE_KEYS.insertTableColumn
54422
+ ),
54423
+ insertColumnAfter: () => apply(
54424
+ (current) => options.tableOps.insertSelectedTableColumn(current, 1),
54425
+ MERGE_KEYS.insertTableColumn
54426
+ ),
54427
+ deleteColumn: () => apply(
54428
+ (current) => options.tableOps.deleteSelectedTableColumn(current),
54429
+ MERGE_KEYS.deleteTableColumn
54430
+ ),
54431
+ insertRowBefore: () => apply(
54432
+ (current) => options.tableOps.insertSelectedTableRow(current, -1),
54433
+ MERGE_KEYS.insertTableRow
54434
+ ),
54435
+ insertRowAfter: () => apply(
54436
+ (current) => options.tableOps.insertSelectedTableRow(current, 1),
54437
+ MERGE_KEYS.insertTableRow
54438
+ ),
54439
+ deleteRow: () => apply(
54440
+ (current) => options.tableOps.deleteSelectedTableRow(current),
54441
+ MERGE_KEYS.deleteTableRow
54442
+ ),
54443
+ cellShading: (color) => apply(
54444
+ (current) => setTableCellStyleValue(current, "shading", color || null),
54445
+ MERGE_KEYS.tableShading
54446
+ ),
54447
+ cellBorders: () => apply(
54448
+ (current) => setTableCellBorders(current, {
54449
+ width: 1,
54450
+ type: "solid",
54451
+ color: "#64748b"
54452
+ }),
54453
+ MERGE_KEYS.tableBorders
54454
+ ),
54455
+ cellNoBorders: () => apply(
54456
+ (current) => setTableCellBorders(current, {
54457
+ width: 0,
54458
+ type: "none",
54459
+ color: "transparent"
54460
+ }),
54461
+ MERGE_KEYS.tableBorders
54462
+ ),
54463
+ width100: () => apply(
54464
+ (current) => setTableStyleValue(current, "width", "100%"),
54465
+ MERGE_KEYS.tableWidth
54466
+ ),
54467
+ alignLeft: () => apply(
54468
+ (current) => setTableCellStyleValue(current, "horizontalAlign", "left"),
54469
+ MERGE_KEYS.tableAlign
54470
+ ),
54471
+ alignCenter: () => apply(
54472
+ (current) => setTableCellStyleValue(current, "horizontalAlign", "center"),
54473
+ MERGE_KEYS.tableAlign
54474
+ ),
54475
+ alignRight: () => apply(
54476
+ (current) => setTableCellStyleValue(current, "horizontalAlign", "right"),
54477
+ MERGE_KEYS.tableAlign
54478
+ ),
54479
+ setCellWidth: (width) => apply(
54480
+ (current) => setTableCellWidth(current, width),
54481
+ MERGE_KEYS.tableCellWidth
54482
+ ),
54483
+ insert: (rows, cols) => options.tableOps.insertTableCommand(rows, cols)
54453
54484
  };
54454
- const essentialsTable = buildEssentialsTable();
54485
+ }
54486
+ function createEditorEssentialsRuntimePlugin(options) {
54455
54487
  return createEssentialsPlugin({
54456
- gate: essentialsGate,
54457
- style: essentialsStyle,
54458
- selection: essentialsSelection,
54459
- history: essentialsHistory,
54460
- formatting: essentialsFormatting,
54461
- document: essentialsDocument,
54462
- link: essentialsLink,
54463
- image: essentialsImage,
54464
- browser: essentialsBrowser,
54465
- paragraph: essentialsParagraph,
54466
- section: essentialsSection,
54467
- table: essentialsTable
54488
+ gate: buildEssentialsGate(options),
54489
+ style: buildEssentialsStyle(options),
54490
+ selection: buildEssentialsSelection(options),
54491
+ history: buildEssentialsHistory(options),
54492
+ formatting: buildEssentialsFormatting(options),
54493
+ document: buildEssentialsDocument(options),
54494
+ link: buildEssentialsLink(options),
54495
+ image: buildEssentialsImage(options),
54496
+ browser: buildEssentialsBrowser(),
54497
+ paragraph: buildEssentialsParagraph(options),
54498
+ section: buildEssentialsSection(options),
54499
+ table: buildEssentialsTable(options)
54468
54500
  });
54469
54501
  }
54470
54502
  const defaultMenuItems = [