oasis-editor 0.0.131 → 0.0.132

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 (74) hide show
  1. package/dist/{OasisEditorApp-Dn2I2b-M.js → OasisEditorApp-D-v1-Asf.js} +708 -682
  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-DEBNBBUG.js} +2015 -1977
  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.js +54 -54
  30. package/dist/oasis-editor.umd.cjs +4 -4
  31. package/dist/plugins/internal/essentialsCapabilities.d.ts +2 -1
  32. package/dist/plugins/internal/essentialsCommandBuilders.d.ts +8 -7
  33. package/dist/plugins/internal/essentialsCommandGroups/coreFormatting.d.ts +17 -0
  34. package/dist/plugins/internal/essentialsCommandGroups/documentAndBrowser.d.ts +15 -0
  35. package/dist/plugins/internal/essentialsCommandGroups/paragraphAndSection.d.ts +13 -0
  36. package/dist/plugins/internal/essentialsCommandGroups/table.d.ts +11 -0
  37. package/dist/react.js +14 -15
  38. package/dist/text/fontMetricsUtil.d.ts +16 -0
  39. package/dist/text/fonts/opentype/extensionLookup.d.ts +9 -0
  40. package/dist/ui/EditorImportProgressOverlay.d.ts +7 -0
  41. package/dist/ui/EditorStatusBar.d.ts +13 -0
  42. package/dist/ui/OasisEditorEditor.d.ts +3 -117
  43. package/dist/ui/OasisEditorEditorProps.d.ts +118 -0
  44. package/dist/ui/app/createEditorEssentialsPlugin.d.ts +2 -41
  45. package/dist/ui/app/essentials/browser.d.ts +3 -0
  46. package/dist/ui/app/essentials/document.d.ts +4 -0
  47. package/dist/ui/app/essentials/formatting.d.ts +9 -0
  48. package/dist/ui/app/essentials/gate.d.ts +4 -0
  49. package/dist/ui/app/essentials/history.d.ts +4 -0
  50. package/dist/ui/app/essentials/image.d.ts +4 -0
  51. package/dist/ui/app/essentials/link.d.ts +4 -0
  52. package/dist/ui/app/essentials/paragraph.d.ts +4 -0
  53. package/dist/ui/app/essentials/section.d.ts +4 -0
  54. package/dist/ui/app/essentials/selection.d.ts +4 -0
  55. package/dist/ui/app/essentials/style.d.ts +4 -0
  56. package/dist/ui/app/essentials/table.d.ts +4 -0
  57. package/dist/ui/app/essentials/types.d.ts +41 -0
  58. package/dist/ui/canvas/canvasLineSlotLookup.d.ts +8 -0
  59. package/dist/ui/canvas/canvasSnapshotLines.d.ts +22 -0
  60. package/dist/ui/canvas/canvasSnapshotWalkers.d.ts +41 -0
  61. package/dist/ui/canvas/canvasTheme.d.ts +6 -0
  62. package/dist/ui/components/Dialogs/ParagraphDialog.d.ts +2 -69
  63. package/dist/ui/components/Dialogs/paragraph-dialog/ParagraphDialogTypes.d.ts +82 -0
  64. package/dist/ui/components/Dialogs/paragraph-dialog/useParagraphDialogController.d.ts +66 -0
  65. package/dist/ui/components/Dialogs/table-properties/TablePropertiesTypes.d.ts +0 -1
  66. package/dist/ui/components/Toolbar/presets/defaultToolbar/buttonSpecs.d.ts +27 -0
  67. package/dist/ui/components/Toolbar/presets/defaultToolbar/optionBuilders.d.ts +10 -0
  68. package/dist/ui/components/Toolbar/presets/defaultToolbar/ribbonPlacements.d.ts +3 -0
  69. package/dist/utils/parseNumber.d.ts +5 -0
  70. package/dist/vue.d.ts +5 -5
  71. package/dist/vue.js +10 -12
  72. package/package.json +1 -1
  73. package/dist/layoutProjection/presetGeometry/families.d.ts +0 -37
  74. 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 use, aP as PluginUiHost, aQ as OasisEditorEditor, aR as OasisBrandMark, aS as setPreciseFontPreference, aT as setWelcomeSeen, aU as enablePreciseFontMode, aV as TWIPS_PER_POINT, aW as PX_PER_INCH, aX as TWIPS_PER_INCH, aY as normalizeHex6, aZ as TABLE_CONDITIONAL_FLAG_ATTRIBUTES, a_ as TABLE_BORDER_EDGE_KEYS, a$ as resolveEffectiveParagraphStyle, b0 as resolveEffectiveTextStyleForParagraph, b1 as EMU_PER_PT, b2 as OOXML_ROTATION_UNITS, b3 as OOXML_PERCENT_DENOMINATOR, b4 as parseHexColorToRgb255, b5 as EMU_PER_PX, b6 as getRunEndnoteReference, b7 as iterateFootnoteReferenceRuns, b8 as iterateEndnoteReferenceRuns, b9 as imageContentTypeDefaults, ba as getRunFieldChar, bb as getRunFieldInstruction, bc as createEditorRun, bd as JSZip, be as imageExtensionFromMime, bf as pxToPt$1, bg as resolveFloatingObjectRect, bh as getTextBoxFloatingGeometry, bi as getPresetPathSegments, bj as buildListLabels, bk as DEFAULT_FONT_SIZE_PX, bl as resolveGradientAxis, bm as isDoubleUnderlineStyle, bn as isWavyUnderlineStyle, bo as underlineStyleLineWidthPx, bp as WAVY_UNDERLINE_WAVELENGTH_PX, bq as WAVY_UNDERLINE_AMPLITUDE_PX, br as DOUBLE_UNDERLINE_OFFSET_PX, bs as underlineStyleDashArray, bt as EMPHASIS_GLYPH, bu as rgb255ToHex, bv as getImageFloatingGeometry, bw as textStyleToFontSizePt, bx as resolveTextAlignmentBaselineOffset, by as TEXT_BASELINE_RATIO, bz as resolveOpenTypeFeatureTags, bA as resolveDecorationLineY, bB as DOUBLE_STRIKE_OFFSET_PX, bC as resolveListLabel, bD as getListLabelInset, bE as getAlignedListLabelInset, bF as getParagraphBorderInsets, bG as buildSegmentTable, bH as buildCanvasTableLayout, bI as resolveCanvasTableWidth, bJ as resolveFloatingTableRect, bK as paragraphBetweenBorderMatches, bL as normalizeFamily, bM as ROBOTO_FONT_FILES, bN as loadFontAsset, bO as OFFICE_COMPAT_FONT_FAMILIES, bP as BinaryReader, bQ as buildSfnt, bR as defaultFontDecoderRegistry, bS as SfntFontProgram, bT as collectPdfFontFamilies, bU as outlineFrom, bV as getPageHeaderZoneTop, bW as getPageColumnRects, bX as findFootnoteReference, bY as resolveImporterForFile, bZ as roundTo, b_ as getDocumentSectionsCanonical, b$ as getDocumentParagraphsCanonical, c0 as getDocumentParagraphs, c1 as getDocumentPageSettings, c2 as getTableCellContentWidthForParagraph, c3 as layoutMetricsEpoch, c4 as bumpLayoutMetricsEpoch, c5 as createCanvasLayoutSnapshotProvider, c6 as on, c7 as debounce, c8 as unwrap, c9 as perfTimer, ca as getRunTextBox, cb as createEditorDocument, cc as resolveResizedDimensions, cd as resolveTextBoxRenderHeight, ce as getToolbarStyleState, cf as VERTICAL_HIT_WEIGHT, cg as getCachedCanvasImage, ch as measureParagraphMinContentWidthPx, ci as getEditableBlocksForZone, cj as findParagraphLocation, ck as createSectionBoundaryParagraph, cl as normalizePageSettings, cm as DEFAULT_EDITOR_PAGE_SETTINGS, cn as markStart, co as markEnd, cp as getParagraphEntries, cq as getParagraphById, cr as createEditorFootnote, cs as createFootnoteReferenceRun, ct as renumberFootnotes, cu as preciseFontModeVersion, cv as isPreciseFontModeEnabled, cw as getHeadingLevel, cx as togglePreciseFontMode, cy as nextFontSizePt, cz as previousFontSizePt, cA as fontSizePtToPx, cB as resolveNamedTextStyle, cC as createDefaultToolbarPreset, cD as MenuRegistry, cE as createToolbarRegistry, cF as Editor, cG as resolveCommandRef, cH as commandRefName, cI as createOasisEditorClient, cJ as createEditorZoom, cK as startLongTaskObserver, cL as installGlobalReport, cM as applyStoredPreciseFontPreference, cN as getWelcomeSeen, cO as isLocalFontAccessSupported, cP as EDITOR_SCROLL_PADDING_PX, cQ as Toolbar, cR as OasisEditorLoading, cS as I18nProvider, cT as createTranslator, cU as registerDomStatsSurface, cV as createEditorLogger } from "./index-DEBNBBUG.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;
@@ -36161,6 +36226,9 @@ function pointsToTwips(value) {
36161
36226
  function normalizeDocxColor(color, fallback = "000000") {
36162
36227
  return normalizeHex6(color) ?? fallback;
36163
36228
  }
36229
+ function serializeShading(fill) {
36230
+ return `<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(fill, "FFFFFF")}"/>`;
36231
+ }
36164
36232
  function buildBookmarkExportPlan(document2) {
36165
36233
  const registry = document2.bookmarks;
36166
36234
  if (!registry || registry.order.length === 0) {
@@ -36501,9 +36569,7 @@ function serializeTableCellProperties(cell, fallbackWidthPt) {
36501
36569
  parts.push("<w:vMerge/>");
36502
36570
  }
36503
36571
  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
- );
36572
+ parts.push(serializeShading(cell.style.shading));
36507
36573
  }
36508
36574
  const noWrap = serializeOnOffElement("noWrap", (_c = cell.style) == null ? void 0 : _c.noWrap);
36509
36575
  if (noWrap) {
@@ -37068,9 +37134,7 @@ function serializeParagraphStyleXml(style2) {
37068
37134
  parts.push(paragraphBorders);
37069
37135
  }
37070
37136
  if (style2.shading) {
37071
- parts.push(
37072
- `<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(style2.shading, "FFFFFF")}"/>`
37073
- );
37137
+ parts.push(serializeShading(style2.shading));
37074
37138
  }
37075
37139
  if (style2.textDirection) {
37076
37140
  parts.push(`<w:textDirection w:val="${style2.textDirection}"/>`);
@@ -37134,9 +37198,7 @@ function serializeParagraphProperties(paragraph, numberingInfo, styles, override
37134
37198
  parts.push(paragraphBorders);
37135
37199
  }
37136
37200
  if (style2.shading) {
37137
- parts.push(
37138
- `<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(style2.shading, "FFFFFF")}"/>`
37139
- );
37201
+ parts.push(serializeShading(style2.shading));
37140
37202
  }
37141
37203
  if (style2.textDirection) {
37142
37204
  parts.push(`<w:textDirection w:val="${style2.textDirection}"/>`);
@@ -37427,9 +37489,7 @@ function serializeRunProperties(styles) {
37427
37489
  );
37428
37490
  }
37429
37491
  if (styles.shading) {
37430
- parts.push(
37431
- `<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(styles.shading, "FFFFFF")}"/>`
37432
- );
37492
+ parts.push(serializeShading(styles.shading));
37433
37493
  }
37434
37494
  if (styles.fitText !== void 0 && styles.fitText !== null && Number.isFinite(styles.fitText)) {
37435
37495
  const twips = pointsToSignedTwips(styles.fitText);
@@ -41258,6 +41318,14 @@ class PdfContentStream {
41258
41318
  );
41259
41319
  }
41260
41320
  }
41321
+ function parseExtensionLookup(reader, offset, parseSubtable2) {
41322
+ reader.seek(offset);
41323
+ const format = reader.u16();
41324
+ if (format !== 1) return null;
41325
+ const extensionType = reader.u16();
41326
+ const extensionOffset = offset + reader.u32();
41327
+ return parseSubtable2(reader, extensionOffset, extensionType);
41328
+ }
41261
41329
  function readU16Array(reader, count) {
41262
41330
  const array = new Array(count);
41263
41331
  for (let i = 0; i < count; i += 1) array[i] = reader.u16();
@@ -41769,14 +41837,8 @@ function parseSubtable$1(reader, offset, lookupType) {
41769
41837
  return parseLigatureSubst(reader, offset);
41770
41838
  case 6:
41771
41839
  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
- }
41840
+ case 7:
41841
+ return parseExtensionLookup(reader, offset, parseSubtable$1);
41780
41842
  default:
41781
41843
  return null;
41782
41844
  }
@@ -41999,14 +42061,8 @@ function parseSubtable(reader, offset, lookupType) {
41999
42061
  return parseSinglePos(reader, offset);
42000
42062
  case 2:
42001
42063
  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
- }
42064
+ case 9:
42065
+ return parseExtensionLookup(reader, offset, parseSubtable);
42010
42066
  default:
42011
42067
  return null;
42012
42068
  }
@@ -46880,12 +46936,23 @@ function createTableCellSpanOperationsImpl(deps) {
46880
46936
  splitSelectedTable
46881
46937
  };
46882
46938
  }
46939
+ function markTableRevision(target, type) {
46940
+ target.style = {
46941
+ ...target.style ?? {},
46942
+ revision: { ...createTableRevisionMetadata(), type }
46943
+ };
46944
+ }
46945
+ function resolveNextTableParagraph(tableBlock, targetCell, fallbackRow) {
46946
+ var _a2;
46947
+ return (targetCell == null ? void 0 : targetCell.blocks[0]) ?? ((_a2 = fallbackRow == null ? void 0 : fallbackRow.cells.find(
46948
+ (cell) => cell.vMerge !== "continue" && cell.blocks[0]
46949
+ )) == null ? void 0 : _a2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
46950
+ }
46883
46951
  function createTableRowColumnOperations(deps) {
46884
46952
  return createTableRowColumnOperationsImpl(deps);
46885
46953
  }
46886
46954
  function createTableRowColumnOperationsImpl(deps) {
46887
46955
  const insertSelectedTableRow = (current, direction) => {
46888
- var _a2, _b2;
46889
46956
  const mut = resolveLocationTableMutation(current, deps.getTargetBlocks);
46890
46957
  if (!mut) return current;
46891
46958
  const { tableBlock, location, targetBlocks } = mut;
@@ -46940,20 +47007,16 @@ function createTableRowColumnOperationsImpl(deps) {
46940
47007
  })
46941
47008
  );
46942
47009
  if (current.trackChangesEnabled) {
46943
- blankRow.style = {
46944
- ...blankRow.style ?? {},
46945
- revision: {
46946
- ...createTableRevisionMetadata(),
46947
- type: "insert"
46948
- }
46949
- };
47010
+ markTableRevision(blankRow, "insert");
46950
47011
  }
46951
47012
  tableBlock.rows.splice(insertIndex, 0, blankRow);
46952
47013
  const targetVisualColumn = (selectedEntry == null ? void 0 : selectedEntry.visualColumnIndex) ?? location.cellIndex;
46953
47014
  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);
47015
+ const nextParagraph2 = resolveNextTableParagraph(
47016
+ tableBlock,
47017
+ targetCell2,
47018
+ blankRow
47019
+ );
46957
47020
  return commitTableMutation(
46958
47021
  current,
46959
47022
  targetBlocks,
@@ -46970,19 +47033,15 @@ function createTableRowColumnOperationsImpl(deps) {
46970
47033
  )
46971
47034
  );
46972
47035
  if (current.trackChangesEnabled) {
46973
- blankRow.style = {
46974
- ...blankRow.style ?? {},
46975
- revision: {
46976
- ...createTableRevisionMetadata(),
46977
- type: "insert"
46978
- }
46979
- };
47036
+ markTableRevision(blankRow, "insert");
46980
47037
  }
46981
47038
  tableBlock.rows.splice(insertIndex, 0, blankRow);
46982
47039
  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);
47040
+ const nextParagraph = resolveNextTableParagraph(
47041
+ tableBlock,
47042
+ targetCell,
47043
+ blankRow
47044
+ );
46986
47045
  return commitTableMutation(
46987
47046
  current,
46988
47047
  targetBlocks,
@@ -47002,13 +47061,7 @@ function createTableRowColumnOperationsImpl(deps) {
47002
47061
  return current;
47003
47062
  }
47004
47063
  if (current.trackChangesEnabled) {
47005
- rowToDelete.style = {
47006
- ...rowToDelete.style ?? {},
47007
- revision: {
47008
- ...createTableRevisionMetadata(),
47009
- type: "delete"
47010
- }
47011
- };
47064
+ markTableRevision(rowToDelete, "delete");
47012
47065
  return commitTableMutation(current, targetBlocks, location.zone, null);
47013
47066
  }
47014
47067
  const blockedByRestartCell = rowToDelete.cells.some(
@@ -47048,7 +47101,7 @@ function createTableRowColumnOperationsImpl(deps) {
47048
47101
  Math.max(0, getRowVisualWidth(nextRow) - 1)
47049
47102
  )
47050
47103
  ) : null;
47051
- const nextParagraph = (targetCell == null ? void 0 : targetCell.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
47104
+ const nextParagraph = resolveNextTableParagraph(tableBlock, targetCell);
47052
47105
  return commitTableMutation(
47053
47106
  current,
47054
47107
  targetBlocks,
@@ -47081,12 +47134,7 @@ function createTableRowColumnOperationsImpl(deps) {
47081
47134
  createEditorParagraph("")
47082
47135
  ]);
47083
47136
  if (current.trackChangesEnabled) {
47084
- insertedCell.style = {
47085
- revision: {
47086
- ...createTableRevisionMetadata(),
47087
- type: "insert"
47088
- }
47089
- };
47137
+ markTableRevision(insertedCell, "insert");
47090
47138
  }
47091
47139
  nextCells.push(insertedCell);
47092
47140
  inserted = true;
@@ -47117,12 +47165,7 @@ function createTableRowColumnOperationsImpl(deps) {
47117
47165
  createEditorParagraph("")
47118
47166
  ]);
47119
47167
  if (current.trackChangesEnabled) {
47120
- insertedCell.style = {
47121
- revision: {
47122
- ...createTableRevisionMetadata(),
47123
- type: "insert"
47124
- }
47125
- };
47168
+ markTableRevision(insertedCell, "insert");
47126
47169
  }
47127
47170
  nextCells.push(insertedCell);
47128
47171
  }
@@ -47130,7 +47173,7 @@ function createTableRowColumnOperationsImpl(deps) {
47130
47173
  }
47131
47174
  const targetRow2 = tableBlock.rows[location.rowIndex];
47132
47175
  const targetCell2 = targetRow2 ? findCellAtVisualColumn(targetRow2, insertVisualColumn) : null;
47133
- const nextParagraph2 = (targetCell2 == null ? void 0 : targetCell2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
47176
+ const nextParagraph2 = resolveNextTableParagraph(tableBlock, targetCell2);
47134
47177
  return commitTableMutation(
47135
47178
  current,
47136
47179
  targetBlocks,
@@ -47148,18 +47191,13 @@ function createTableRowColumnOperationsImpl(deps) {
47148
47191
  for (const row of tableBlock.rows) {
47149
47192
  const insertedCell = createEditorTableCell([createEditorParagraph("")]);
47150
47193
  if (current.trackChangesEnabled) {
47151
- insertedCell.style = {
47152
- revision: {
47153
- ...createTableRevisionMetadata(),
47154
- type: "insert"
47155
- }
47156
- };
47194
+ markTableRevision(insertedCell, "insert");
47157
47195
  }
47158
47196
  row.cells.splice(insertIndex, 0, insertedCell);
47159
47197
  }
47160
47198
  const targetRow = tableBlock.rows[location.rowIndex];
47161
47199
  const targetCell = targetRow == null ? void 0 : targetRow.cells[insertIndex];
47162
- const nextParagraph = (targetCell == null ? void 0 : targetCell.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
47200
+ const nextParagraph = resolveNextTableParagraph(tableBlock, targetCell);
47163
47201
  return commitTableMutation(
47164
47202
  current,
47165
47203
  targetBlocks,
@@ -47184,13 +47222,7 @@ function createTableRowColumnOperationsImpl(deps) {
47184
47222
  for (const row of tableBlock.rows) {
47185
47223
  const cell = findCellAtVisualColumn(row, visualColumn);
47186
47224
  if (cell) {
47187
- cell.style = {
47188
- ...cell.style ?? {},
47189
- revision: {
47190
- ...createTableRevisionMetadata(),
47191
- type: "delete"
47192
- }
47193
- };
47225
+ markTableRevision(cell, "delete");
47194
47226
  }
47195
47227
  }
47196
47228
  return commitTableMutation(current, targetBlocks, location.zone, null);
@@ -47231,7 +47263,7 @@ function createTableRowColumnOperationsImpl(deps) {
47231
47263
  Math.max(0, getRowVisualWidth(targetRow2) - 1)
47232
47264
  )
47233
47265
  );
47234
- const nextParagraph2 = (targetCell2 == null ? void 0 : targetCell2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
47266
+ const nextParagraph2 = resolveNextTableParagraph(tableBlock, targetCell2);
47235
47267
  return commitTableMutation(
47236
47268
  current,
47237
47269
  targetBlocks,
@@ -47247,7 +47279,7 @@ function createTableRowColumnOperationsImpl(deps) {
47247
47279
  }
47248
47280
  const targetRow = tableBlock.rows[location.rowIndex];
47249
47281
  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);
47282
+ const nextParagraph = resolveNextTableParagraph(tableBlock, targetCell);
47251
47283
  return commitTableMutation(
47252
47284
  current,
47253
47285
  targetBlocks,
@@ -49179,34 +49211,7 @@ function pxToPt(px) {
49179
49211
  function ptToPx(pt) {
49180
49212
  return pt * PIXELS_PER_POINT;
49181
49213
  }
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
- }
49214
+ const parseSizeToPt = parseUnitToPt;
49210
49215
  const CONTENT_MIN_WIDTH_GUARD_PX = 12;
49211
49216
  const CONTENT_MIN_HEIGHT_GUARD_PX = 4;
49212
49217
  const DEFAULT_CELL_PADDING_LEFT_RIGHT_PX = 7.2;
@@ -49963,6 +49968,15 @@ function findNextWordBoundary(text, offset) {
49963
49968
  }
49964
49969
  const REUSE_MOUSE_DOWN_HIT_MAX_AGE_MS = 600;
49965
49970
  const REUSE_MOUSE_DOWN_HIT_MAX_DISTANCE_PX = 8;
49971
+ function resolveZoneFirstParagraph(blocks, zone) {
49972
+ if (!blocks || blocks.length === 0) {
49973
+ const paragraph2 = createSectionBoundaryParagraph(zone);
49974
+ return { paragraph: paragraph2, blocks: [paragraph2] };
49975
+ }
49976
+ const firstBlock = blocks[0];
49977
+ const paragraph = firstBlock.type === "paragraph" ? firstBlock : getBlockParagraphs(firstBlock)[0] ?? null;
49978
+ return { paragraph, blocks };
49979
+ }
49966
49980
  function resolveTripleClickParagraphRange(state, paragraph, targetZone) {
49967
49981
  const zoneParagraphs = getDocumentParagraphs(state.document).filter(
49968
49982
  (candidate) => {
@@ -50043,21 +50057,13 @@ function createEditorSurfaceEventsImpl(deps) {
50043
50057
  let newFooter = section.footer;
50044
50058
  let zoneParagraph = null;
50045
50059
  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
- }
50060
+ const resolved = resolveZoneFirstParagraph(newHeader, "header");
50061
+ zoneParagraph = resolved.paragraph;
50062
+ newHeader = resolved.blocks;
50053
50063
  } 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
- }
50064
+ const resolved = resolveZoneFirstParagraph(newFooter, "footer");
50065
+ zoneParagraph = resolved.paragraph;
50066
+ newFooter = resolved.blocks;
50061
50067
  }
50062
50068
  if (newHeader !== section.header || newFooter !== section.footer) {
50063
50069
  const newSections = [...sections];
@@ -53015,224 +53021,6 @@ function connectEditorClientHost(controller, deps) {
53015
53021
  exportPdf: () => Promise.resolve(deps.docIO.handleExportPdf())
53016
53022
  });
53017
53023
  }
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
53024
  function createCommandBuilder(isCommandEnabled) {
53237
53025
  return (name, execute, state) => ({
53238
53026
  execute,
@@ -53894,16 +53682,211 @@ function createEssentialsPlugin(deps) {
53894
53682
  }
53895
53683
  };
53896
53684
  }
53897
- function createEditorEssentialsRuntimePlugin(options) {
53898
- const essentialsGate = {
53685
+ function buildEssentialsGate(options) {
53686
+ return {
53899
53687
  isCommandEnabled: (commandName) => !options.isReadOnly() && (commandName !== "insertFootnote" || options.commandsController.canInsertFootnoteCommand())
53900
53688
  };
53901
- const essentialsStyle = {
53689
+ }
53690
+ function buildEssentialsStyle(options) {
53691
+ return {
53902
53692
  state: () => options.styleController.toolbarStyleState()
53903
53693
  };
53904
- const essentialsSelection = {
53694
+ }
53695
+ function buildEssentialsSelection(options) {
53696
+ return {
53905
53697
  isCollapsed: () => isSelectionCollapsed(options.state().selection)
53906
53698
  };
53699
+ }
53700
+ function buildEssentialsHistory(options) {
53701
+ return {
53702
+ canUndo: () => options.undoStack().length > 0,
53703
+ canRedo: () => options.redoStack().length > 0,
53704
+ undo: () => (options.historyActions.performUndo(), true),
53705
+ redo: () => (options.historyActions.performRedo(), true)
53706
+ };
53707
+ }
53708
+ const DEFAULT_TOC_MAX_LEVEL = 3;
53709
+ const TOC_INSTRUCTION = ' TOC \\o "1-3" \\h \\z \\u ';
53710
+ const twipsToPx = (twips) => Math.round(twips / TWIPS_PER_INCH * PX_PER_INCH);
53711
+ function collectTocHeadings(state, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
53712
+ var _a2;
53713
+ const headings = [];
53714
+ for (const paragraph of getDocumentParagraphs(state.document)) {
53715
+ const level = getHeadingLevel((_a2 = paragraph.style) == null ? void 0 : _a2.styleId);
53716
+ if (level === null || level > maxLevel) continue;
53717
+ const text = getParagraphText(paragraph).trim();
53718
+ if (!text) continue;
53719
+ headings.push({ id: paragraph.id, level, text });
53720
+ }
53721
+ return headings;
53722
+ }
53723
+ function makeRun(partial) {
53724
+ const id = createEditorRun(partial.text).id;
53725
+ if (partial.fieldChar) {
53726
+ return {
53727
+ id,
53728
+ text: partial.text,
53729
+ kind: "fieldChar",
53730
+ fieldChar: partial.fieldChar
53731
+ };
53732
+ }
53733
+ if (partial.fieldInstruction !== void 0) {
53734
+ return {
53735
+ id,
53736
+ text: partial.text,
53737
+ kind: "fieldInstruction",
53738
+ fieldInstruction: partial.fieldInstruction
53739
+ };
53740
+ }
53741
+ return { id, text: partial.text, kind: "text" };
53742
+ }
53743
+ function makeParagraph(runs, style2) {
53744
+ const paragraph = createEditorParagraph("");
53745
+ paragraph.runs = runs;
53746
+ if (style2) paragraph.style = style2;
53747
+ return paragraph;
53748
+ }
53749
+ function buildEntryParagraph(heading, pageNumber, rightTabPositionPt) {
53750
+ const pageLabel = pageNumber !== void 0 ? String(pageNumber) : "";
53751
+ const run = makeRun({ text: `${heading.text} ${pageLabel}` });
53752
+ const style2 = {
53753
+ tabs: [{ position: rightTabPositionPt, type: "right", leader: "dot" }],
53754
+ spacingAfter: twipsToPx(40),
53755
+ indentLeft: twipsToPx((heading.level - 1) * 397)
53756
+ };
53757
+ return makeParagraph([run], style2);
53758
+ }
53759
+ function rightTabPositionForSection(section) {
53760
+ const { width, margins } = section.pageSettings;
53761
+ const contentWidthPx = Math.max(0, width - margins.left - margins.right);
53762
+ return roundTo(contentWidthPx * PT_PER_PX, 2);
53763
+ }
53764
+ function buildStartMarkerParagraph() {
53765
+ return makeParagraph([
53766
+ makeRun({ text: "", fieldChar: { kind: "begin" } }),
53767
+ makeRun({ text: "", fieldInstruction: TOC_INSTRUCTION }),
53768
+ makeRun({ text: "", fieldChar: { kind: "separate" } })
53769
+ ]);
53770
+ }
53771
+ function buildEndMarkerParagraph() {
53772
+ return makeParagraph([makeRun({ text: "", fieldChar: { kind: "end" } })]);
53773
+ }
53774
+ function buildTocBlocks(headings, resolvePage, rightTabPositionPt) {
53775
+ const entries = headings.map(
53776
+ (heading) => buildEntryParagraph(heading, resolvePage(heading.id), rightTabPositionPt)
53777
+ );
53778
+ return [buildStartMarkerParagraph(), ...entries, buildEndMarkerParagraph()];
53779
+ }
53780
+ function replaceSectionBlocks(state, sectionIndex, nextBlocks, selectionParagraph) {
53781
+ const sections = getDocumentSections(state.document);
53782
+ const section = sections[sectionIndex];
53783
+ if (!section) return state;
53784
+ const nextSections = [...sections];
53785
+ nextSections[sectionIndex] = { ...section, blocks: nextBlocks };
53786
+ return {
53787
+ ...state,
53788
+ document: { ...state.document, sections: nextSections },
53789
+ selection: withSelection(paragraphOffsetToPosition(selectionParagraph, 0))
53790
+ };
53791
+ }
53792
+ function insertTableOfContents(state, resolvePage = () => void 0, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
53793
+ const zone = getActiveZone(state);
53794
+ if (zone !== "main") return state;
53795
+ const sectionIndex = getActiveSectionIndex(state);
53796
+ const sections = getDocumentSections(state.document);
53797
+ const section = sections[sectionIndex];
53798
+ if (!section) return state;
53799
+ const headings = collectTocHeadings(state, maxLevel);
53800
+ const tocBlocks = buildTocBlocks(
53801
+ headings,
53802
+ resolvePage,
53803
+ rightTabPositionForSection(section)
53804
+ );
53805
+ const focus = clampPosition(state, state.selection.focus);
53806
+ const blockIndex = section.blocks.findIndex((block) => {
53807
+ if (block.id === focus.paragraphId) return true;
53808
+ if (block.type === "paragraph") return false;
53809
+ return getBlockParagraphs(block).some(
53810
+ (p) => p.id === focus.paragraphId
53811
+ );
53812
+ });
53813
+ const insertAt = blockIndex === -1 ? section.blocks.length : blockIndex + 1;
53814
+ const nextBlocks = [
53815
+ ...section.blocks.slice(0, insertAt),
53816
+ ...tocBlocks,
53817
+ ...section.blocks.slice(insertAt)
53818
+ ];
53819
+ return replaceSectionBlocks(state, sectionIndex, nextBlocks, tocBlocks[0]);
53820
+ }
53821
+ function findTocRegion(blocks) {
53822
+ let depth = 0;
53823
+ let instruction = "";
53824
+ let separateBlockIndex = -1;
53825
+ let beginBlockIndex = -1;
53826
+ let isToc = false;
53827
+ for (let i = 0; i < blocks.length; i += 1) {
53828
+ const block = blocks[i];
53829
+ if (block.type !== "paragraph") continue;
53830
+ for (const run of block.runs) {
53831
+ const fieldChar = getRunFieldChar(run);
53832
+ const fieldInstruction = getRunFieldInstruction(run);
53833
+ if ((fieldChar == null ? void 0 : fieldChar.kind) === "begin") {
53834
+ depth += 1;
53835
+ if (depth === 1) {
53836
+ beginBlockIndex = i;
53837
+ instruction = "";
53838
+ isToc = false;
53839
+ separateBlockIndex = -1;
53840
+ }
53841
+ } else if (depth === 1 && fieldInstruction !== void 0) {
53842
+ instruction += fieldInstruction;
53843
+ if (/\bTOC\b/i.test(instruction)) isToc = true;
53844
+ } else if ((fieldChar == null ? void 0 : fieldChar.kind) === "separate") {
53845
+ if (depth === 1) separateBlockIndex = i;
53846
+ } else if ((fieldChar == null ? void 0 : fieldChar.kind) === "end") {
53847
+ if (depth === 1) {
53848
+ if (isToc) {
53849
+ return {
53850
+ startBlockIndex: separateBlockIndex >= 0 ? separateBlockIndex : beginBlockIndex,
53851
+ endBlockIndex: i
53852
+ };
53853
+ }
53854
+ }
53855
+ depth = Math.max(0, depth - 1);
53856
+ }
53857
+ }
53858
+ }
53859
+ return null;
53860
+ }
53861
+ function updateTableOfContents(state, resolvePage = () => void 0, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
53862
+ const sectionIndex = getActiveSectionIndex(state);
53863
+ const sections = getDocumentSections(state.document);
53864
+ const section = sections[sectionIndex];
53865
+ if (!section) return state;
53866
+ const region = findTocRegion(section.blocks);
53867
+ if (!region) return state;
53868
+ const headings = collectTocHeadings(state, maxLevel);
53869
+ const entries = headings.map(
53870
+ (heading) => buildEntryParagraph(
53871
+ heading,
53872
+ resolvePage(heading.id),
53873
+ rightTabPositionForSection(section)
53874
+ )
53875
+ );
53876
+ const nextBlocks = [
53877
+ ...section.blocks.slice(0, region.startBlockIndex + 1),
53878
+ ...entries,
53879
+ ...section.blocks.slice(region.endBlockIndex)
53880
+ ];
53881
+ const selectionParagraph = entries[0] ?? section.blocks[region.startBlockIndex];
53882
+ return replaceSectionBlocks(
53883
+ state,
53884
+ sectionIndex,
53885
+ nextBlocks,
53886
+ selectionParagraph
53887
+ );
53888
+ }
53889
+ function buildEssentialsFormatting(options) {
53907
53890
  const stepFontSize = (direction) => {
53908
53891
  const currentPx = Number(
53909
53892
  options.styleController.toolbarStyleState().fontSize
@@ -53916,12 +53899,6 @@ function createEditorEssentialsRuntimePlugin(options) {
53916
53899
  );
53917
53900
  return true;
53918
53901
  };
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
53902
  const buildTocPageResolver = (state) => {
53926
53903
  const layout = projectDocumentLayout(state.document);
53927
53904
  const pageByParagraph = /* @__PURE__ */ new Map();
@@ -53935,7 +53912,7 @@ function createEditorEssentialsRuntimePlugin(options) {
53935
53912
  }
53936
53913
  return (headingId) => pageByParagraph.get(headingId);
53937
53914
  };
53938
- const essentialsFormatting = {
53915
+ return {
53939
53916
  selectAll: () => {
53940
53917
  const paragraphs = getDocumentParagraphs(options.state().document);
53941
53918
  if (paragraphs.length === 0) return false;
@@ -54054,7 +54031,46 @@ function createEditorEssentialsRuntimePlugin(options) {
54054
54031
  ), true),
54055
54032
  setUnderlineStyle: (value) => options.styleController.applyToolbarValueStyleCommand("underlineStyle", value)
54056
54033
  };
54057
- const essentialsDocument = {
54034
+ }
54035
+ const SHAPE_DEFAULT_WIDTH = 150;
54036
+ const SHAPE_DEFAULT_HEIGHT = 100;
54037
+ const SHAPE_DEFAULT_FILL = "#4472C4";
54038
+ const SHAPE_DEFAULT_BORDER_COLOR = "#2F528F";
54039
+ const SHAPE_DEFAULT_BORDER_WIDTH_PT = 1;
54040
+ function insertShapeAtSelection(state, preset) {
54041
+ const collapsedState = isSelectionCollapsed(state.selection) ? state : deleteSelectionRange(state);
54042
+ const { paragraph, index, offset } = getFocusParagraph(collapsedState);
54043
+ const textBox = {
54044
+ width: SHAPE_DEFAULT_WIDTH,
54045
+ height: SHAPE_DEFAULT_HEIGHT,
54046
+ blocks: [createEditorParagraph("")],
54047
+ shape: {
54048
+ preset,
54049
+ fill: SHAPE_DEFAULT_FILL,
54050
+ borderColor: SHAPE_DEFAULT_BORDER_COLOR,
54051
+ borderWidthPt: SHAPE_DEFAULT_BORDER_WIDTH_PT
54052
+ },
54053
+ floating: wrapPresetToFloating(void 0, "front")
54054
+ };
54055
+ const insertedRun = createEditorStyledRun(
54056
+ "",
54057
+ getStyleAtOffset(paragraph, offset),
54058
+ void 0,
54059
+ textBox
54060
+ );
54061
+ const nextParagraph = insertRunsAtOffset(paragraph, offset, [insertedRun]);
54062
+ const paragraphs = getParagraphs(collapsedState);
54063
+ const nextParagraphs = paragraphs.map(
54064
+ (candidate, candidateIndex) => candidateIndex === index ? nextParagraph : cloneParagraph(candidate)
54065
+ );
54066
+ return cloneStateWithParagraphs(
54067
+ collapsedState,
54068
+ nextParagraphs,
54069
+ withSelection(paragraphOffsetToPosition(nextParagraph, offset + 1))
54070
+ );
54071
+ }
54072
+ function buildEssentialsDocument(options) {
54073
+ return {
54058
54074
  documentStyles: () => {
54059
54075
  var _a2, _b2;
54060
54076
  const document2 = options.state().document;
@@ -54100,23 +54116,31 @@ function createEditorEssentialsRuntimePlugin(options) {
54100
54116
  (current) => insertShapeAtSelection(current, preset)
54101
54117
  )
54102
54118
  };
54103
- const essentialsLink = {
54119
+ }
54120
+ function buildEssentialsLink(options) {
54121
+ return {
54104
54122
  prompt: () => options.commandsController.promptForLink(),
54105
54123
  remove: () => options.commandsController.removeLinkCommand(),
54106
54124
  canPrompt: () => !isSelectionCollapsed(options.state().selection) || Boolean(options.styleController.toolbarStyleState().link)
54107
54125
  };
54108
- const essentialsImage = {
54126
+ }
54127
+ function buildEssentialsImage(options) {
54128
+ return {
54109
54129
  promptAlt: () => options.commandsController.promptForImageAlt(),
54110
54130
  promptCaption: () => options.commandsController.promptForImageCaption(),
54111
54131
  isSelected: () => Boolean(options.selectedImageRun())
54112
54132
  };
54113
- const essentialsBrowser = {
54133
+ }
54134
+ function buildEssentialsBrowser() {
54135
+ return {
54114
54136
  print: () => window.print(),
54115
54137
  copy: () => {
54116
54138
  document.execCommand("copy");
54117
54139
  }
54118
54140
  };
54119
- const essentialsParagraph = {
54141
+ }
54142
+ function buildEssentialsParagraph(options) {
54143
+ return {
54120
54144
  togglePageBreakBefore: () => options.commandsController.toggleParagraphFlagCommand("pageBreakBefore"),
54121
54145
  toggleKeepWithNext: () => options.commandsController.toggleParagraphFlagCommand("keepWithNext"),
54122
54146
  setSpacingAfter: (value) => options.commandsController.applyParagraphStyleCommand(
@@ -54190,21 +54214,23 @@ function createEditorEssentialsRuntimePlugin(options) {
54190
54214
  outdent: () => void options.commandsController.handleListTab("outdent"),
54191
54215
  indent: () => void options.commandsController.handleListTab("indent")
54192
54216
  };
54193
- const essentialsSection = {
54217
+ }
54218
+ function buildEssentialsSection(options) {
54219
+ const section = {
54194
54220
  isLandscape: () => {
54195
54221
  var _a2, _b2;
54196
54222
  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";
54223
+ const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54224
+ return ((_b2 = target == null ? void 0 : target.pageSettings) == null ? void 0 : _b2.orientation) === "landscape";
54199
54225
  },
54200
54226
  setOrientation: (orientation) => {
54201
54227
  var _a2;
54202
54228
  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;
54229
+ const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54230
+ if (!target) return;
54205
54231
  options.commandsController.applyUpdateSectionSettingsCommand(idx, {
54206
54232
  pageSettings: {
54207
- ...section.pageSettings,
54233
+ ...target.pageSettings,
54208
54234
  orientation
54209
54235
  }
54210
54236
  });
@@ -54212,259 +54238,259 @@ function createEditorEssentialsRuntimePlugin(options) {
54212
54238
  toggleOrientation: () => {
54213
54239
  var _a2, _b2;
54214
54240
  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
- );
54241
+ const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54242
+ if (!target) return;
54243
+ const current = ((_b2 = target.pageSettings) == null ? void 0 : _b2.orientation) ?? "portrait";
54244
+ section.setOrientation(current === "portrait" ? "landscape" : "portrait");
54221
54245
  },
54222
54246
  breakNextPage: () => options.commandsController.applyInsertSectionBreakCommand("nextPage"),
54223
54247
  breakContinuous: () => options.commandsController.applyInsertSectionBreakCommand("continuous"),
54224
54248
  getMargins: () => {
54225
54249
  var _a2, _b2;
54226
54250
  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;
54251
+ const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54252
+ return (_b2 = target == null ? void 0 : target.pageSettings) == null ? void 0 : _b2.margins;
54229
54253
  },
54230
54254
  setPageMargins: (margins) => {
54231
54255
  var _a2;
54232
54256
  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;
54257
+ const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54258
+ if (!(target == null ? void 0 : target.pageSettings)) return;
54235
54259
  options.commandsController.applyUpdateSectionSettingsCommand(idx, {
54236
54260
  pageSettings: {
54237
- ...section.pageSettings,
54261
+ ...target.pageSettings,
54238
54262
  margins: {
54239
- ...section.pageSettings.margins,
54263
+ ...target.pageSettings.margins,
54240
54264
  ...margins
54241
54265
  }
54242
54266
  }
54243
54267
  });
54244
54268
  }
54245
54269
  };
54246
- const buildEssentialsTable = () => {
54247
- const insideTable = () => Boolean(
54248
- findParagraphTableLocation(
54249
- options.state().document,
54250
- options.state().selection.focus.paragraphId,
54251
- getActiveSectionIndex(options.state())
54252
- )
54270
+ return section;
54271
+ }
54272
+ function buildEssentialsTable(options) {
54273
+ const insideTable = () => Boolean(
54274
+ findParagraphTableLocation(
54275
+ options.state().document,
54276
+ options.state().selection.focus.paragraphId,
54277
+ getActiveSectionIndex(options.state())
54278
+ )
54279
+ );
54280
+ const apply = (producer, mergeKey) => {
54281
+ options.applyTransactionalState(producer, { mergeKey });
54282
+ options.focusInput();
54283
+ };
54284
+ const RAW_TBL_LOOK_DEFAULTS = {
54285
+ firstRow: false,
54286
+ lastRow: false,
54287
+ firstCol: false,
54288
+ lastCol: false,
54289
+ noHBand: false,
54290
+ noVBand: false
54291
+ };
54292
+ const selectedTableIn = (state) => {
54293
+ const secIdx = getActiveSectionIndex(state);
54294
+ const loc = findParagraphTableLocation(
54295
+ state.document,
54296
+ state.selection.focus.paragraphId,
54297
+ secIdx
54253
54298
  );
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;
54299
+ if (!loc) return null;
54300
+ const section = getDocumentSections(state.document)[secIdx];
54301
+ if (!section) return null;
54302
+ const blocks = loc.zone === "header" ? section.header ?? [] : loc.zone === "footer" ? section.footer ?? [] : section.blocks;
54303
+ const table = blocks[loc.blockIndex];
54304
+ return table && table.type === "table" ? table : null;
54305
+ };
54306
+ const rawTblLookIn = (state) => {
54307
+ var _a2;
54308
+ const table = selectedTableIn(state);
54309
+ if (!table) return null;
54310
+ return { ...RAW_TBL_LOOK_DEFAULTS, ...((_a2 = table.style) == null ? void 0 : _a2.tblLook) ?? {} };
54311
+ };
54312
+ const selectionLabel = () => {
54313
+ const normalized = normalizeSelection(options.state());
54314
+ if (normalized.isCollapsed) return null;
54315
+ const secIdx = getActiveSectionIndex(options.state());
54316
+ const anchorLoc = findParagraphTableLocation(
54317
+ options.state().document,
54318
+ options.state().selection.anchor.paragraphId,
54319
+ secIdx
54320
+ );
54321
+ const focusLoc = findParagraphTableLocation(
54322
+ options.state().document,
54323
+ options.state().selection.focus.paragraphId,
54324
+ secIdx
54325
+ );
54326
+ if (!anchorLoc || !focusLoc || anchorLoc.blockIndex !== focusLoc.blockIndex || anchorLoc.rowIndex === focusLoc.rowIndex && anchorLoc.cellIndex === focusLoc.cellIndex) {
54327
+ return null;
54328
+ }
54329
+ const count = options.selectionBoxes().length;
54330
+ if (count === 0) return null;
54331
+ return `Table selection: ${count} cell${count === 1 ? "" : "s"}`;
54332
+ };
54333
+ return {
54334
+ insideTable,
54335
+ selectionLabel,
54336
+ getTblLook: () => {
54337
+ const raw = rawTblLookIn(options.state());
54338
+ if (!raw) return null;
54339
+ return {
54340
+ firstRow: raw.firstRow,
54341
+ lastRow: raw.lastRow,
54342
+ firstCol: raw.firstCol,
54343
+ lastCol: raw.lastCol,
54344
+ // Banding is stored as the negated "no band" flags in OOXML.
54345
+ bandedRows: !raw.noHBand,
54346
+ bandedCols: !raw.noVBand
54347
+ };
54348
+ },
54349
+ toggleTblLook: (flag) => apply((current) => {
54350
+ const raw = rawTblLookIn(current);
54351
+ if (!raw) return current;
54352
+ const next = { ...raw };
54353
+ switch (flag) {
54354
+ case "firstRow":
54355
+ next.firstRow = !raw.firstRow;
54356
+ break;
54357
+ case "lastRow":
54358
+ next.lastRow = !raw.lastRow;
54359
+ break;
54360
+ case "firstCol":
54361
+ next.firstCol = !raw.firstCol;
54362
+ break;
54363
+ case "lastCol":
54364
+ next.lastCol = !raw.lastCol;
54365
+ break;
54366
+ case "bandedRows":
54367
+ next.noHBand = !raw.noHBand;
54368
+ break;
54369
+ case "bandedCols":
54370
+ next.noVBand = !raw.noVBand;
54371
+ break;
54302
54372
  }
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
- };
54373
+ return setTableStyleValue(current, "tblLook", next);
54374
+ }, MERGE_KEYS.tableStyleOptions),
54375
+ getStyleId: () => {
54376
+ var _a2, _b2;
54377
+ return ((_b2 = (_a2 = selectedTableIn(options.state())) == null ? void 0 : _a2.style) == null ? void 0 : _b2.styleId) ?? null;
54378
+ },
54379
+ setStyleId: (styleId) => apply(
54380
+ (current) => setTableStyleValue(current, "styleId", styleId || null),
54381
+ MERGE_KEYS.tableStyleGallery
54382
+ ),
54383
+ getLayout: () => {
54384
+ var _a2, _b2;
54385
+ return ((_b2 = (_a2 = selectedTableIn(options.state())) == null ? void 0 : _a2.style) == null ? void 0 : _b2.layout) ?? null;
54386
+ },
54387
+ toggleAutoFit: () => apply((current) => {
54388
+ var _a2;
54389
+ const table = selectedTableIn(current);
54390
+ const nextLayout = ((_a2 = table == null ? void 0 : table.style) == null ? void 0 : _a2.layout) === "autofit" ? "fixed" : "autofit";
54391
+ return setTableStyleValue(current, "layout", nextLayout);
54392
+ }, MERGE_KEYS.tableDistribute),
54393
+ distributeColumns: () => apply(
54394
+ (current) => distributeSelectedTableColumns(current),
54395
+ MERGE_KEYS.tableDistribute
54396
+ ),
54397
+ distributeRows: () => apply(
54398
+ (current) => distributeSelectedTableRows(current),
54399
+ MERGE_KEYS.tableDistribute
54400
+ ),
54401
+ canMerge: () => options.tableOps.canMergeSelectedTable(options.state()),
54402
+ canSplit: () => options.tableOps.canSplitSelectedTable(options.state()),
54403
+ canEditColumn: () => options.tableOps.canEditSelectedTableColumn(options.state()),
54404
+ canEditRow: () => options.tableOps.canEditSelectedTableRow(options.state()),
54405
+ merge: () => apply(
54406
+ (current) => options.tableOps.mergeSelectedTable(current),
54407
+ MERGE_KEYS.mergeTable
54408
+ ),
54409
+ split: () => apply(
54410
+ (current) => options.tableOps.splitSelectedTable(current),
54411
+ MERGE_KEYS.splitTable
54412
+ ),
54413
+ insertColumnBefore: () => apply(
54414
+ (current) => options.tableOps.insertSelectedTableColumn(current, -1),
54415
+ MERGE_KEYS.insertTableColumn
54416
+ ),
54417
+ insertColumnAfter: () => apply(
54418
+ (current) => options.tableOps.insertSelectedTableColumn(current, 1),
54419
+ MERGE_KEYS.insertTableColumn
54420
+ ),
54421
+ deleteColumn: () => apply(
54422
+ (current) => options.tableOps.deleteSelectedTableColumn(current),
54423
+ MERGE_KEYS.deleteTableColumn
54424
+ ),
54425
+ insertRowBefore: () => apply(
54426
+ (current) => options.tableOps.insertSelectedTableRow(current, -1),
54427
+ MERGE_KEYS.insertTableRow
54428
+ ),
54429
+ insertRowAfter: () => apply(
54430
+ (current) => options.tableOps.insertSelectedTableRow(current, 1),
54431
+ MERGE_KEYS.insertTableRow
54432
+ ),
54433
+ deleteRow: () => apply(
54434
+ (current) => options.tableOps.deleteSelectedTableRow(current),
54435
+ MERGE_KEYS.deleteTableRow
54436
+ ),
54437
+ cellShading: (color) => apply(
54438
+ (current) => setTableCellStyleValue(current, "shading", color || null),
54439
+ MERGE_KEYS.tableShading
54440
+ ),
54441
+ cellBorders: () => apply(
54442
+ (current) => setTableCellBorders(current, {
54443
+ width: 1,
54444
+ type: "solid",
54445
+ color: "#64748b"
54446
+ }),
54447
+ MERGE_KEYS.tableBorders
54448
+ ),
54449
+ cellNoBorders: () => apply(
54450
+ (current) => setTableCellBorders(current, {
54451
+ width: 0,
54452
+ type: "none",
54453
+ color: "transparent"
54454
+ }),
54455
+ MERGE_KEYS.tableBorders
54456
+ ),
54457
+ width100: () => apply(
54458
+ (current) => setTableStyleValue(current, "width", "100%"),
54459
+ MERGE_KEYS.tableWidth
54460
+ ),
54461
+ alignLeft: () => apply(
54462
+ (current) => setTableCellStyleValue(current, "horizontalAlign", "left"),
54463
+ MERGE_KEYS.tableAlign
54464
+ ),
54465
+ alignCenter: () => apply(
54466
+ (current) => setTableCellStyleValue(current, "horizontalAlign", "center"),
54467
+ MERGE_KEYS.tableAlign
54468
+ ),
54469
+ alignRight: () => apply(
54470
+ (current) => setTableCellStyleValue(current, "horizontalAlign", "right"),
54471
+ MERGE_KEYS.tableAlign
54472
+ ),
54473
+ setCellWidth: (width) => apply(
54474
+ (current) => setTableCellWidth(current, width),
54475
+ MERGE_KEYS.tableCellWidth
54476
+ ),
54477
+ insert: (rows, cols) => options.tableOps.insertTableCommand(rows, cols)
54453
54478
  };
54454
- const essentialsTable = buildEssentialsTable();
54479
+ }
54480
+ function createEditorEssentialsRuntimePlugin(options) {
54455
54481
  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
54482
+ gate: buildEssentialsGate(options),
54483
+ style: buildEssentialsStyle(options),
54484
+ selection: buildEssentialsSelection(options),
54485
+ history: buildEssentialsHistory(options),
54486
+ formatting: buildEssentialsFormatting(options),
54487
+ document: buildEssentialsDocument(options),
54488
+ link: buildEssentialsLink(options),
54489
+ image: buildEssentialsImage(options),
54490
+ browser: buildEssentialsBrowser(),
54491
+ paragraph: buildEssentialsParagraph(options),
54492
+ section: buildEssentialsSection(options),
54493
+ table: buildEssentialsTable(options)
54468
54494
  });
54469
54495
  }
54470
54496
  const defaultMenuItems = [