@univerjs/docs-ui 1.1.0 → 1.3.0

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 (102) hide show
  1. package/README.md +45 -0
  2. package/lib/cjs/index.js +822 -243
  3. package/lib/cjs/locale/ar-SA.js +4 -0
  4. package/lib/cjs/locale/ca-ES.js +4 -0
  5. package/lib/cjs/locale/de-DE.js +4 -0
  6. package/lib/cjs/locale/en-US.js +4 -0
  7. package/lib/cjs/locale/es-ES.js +4 -0
  8. package/lib/cjs/locale/fa-IR.js +4 -0
  9. package/lib/cjs/locale/fr-FR.js +4 -0
  10. package/lib/cjs/locale/id-ID.js +4 -0
  11. package/lib/cjs/locale/it-IT.js +4 -0
  12. package/lib/cjs/locale/ja-JP.js +4 -0
  13. package/lib/cjs/locale/ko-KR.js +4 -0
  14. package/lib/cjs/locale/pl-PL.js +4 -0
  15. package/lib/cjs/locale/pt-BR.js +4 -0
  16. package/lib/cjs/locale/ru-RU.js +4 -0
  17. package/lib/cjs/locale/sk-SK.js +4 -0
  18. package/lib/cjs/locale/vi-VN.js +4 -0
  19. package/lib/cjs/locale/zh-CN.js +4 -0
  20. package/lib/cjs/locale/zh-HK.js +4 -0
  21. package/lib/cjs/locale/zh-TW.js +4 -0
  22. package/lib/es/index.js +826 -248
  23. package/lib/es/locale/ar-SA.js +4 -0
  24. package/lib/es/locale/ca-ES.js +4 -0
  25. package/lib/es/locale/de-DE.js +4 -0
  26. package/lib/es/locale/en-US.js +4 -0
  27. package/lib/es/locale/es-ES.js +4 -0
  28. package/lib/es/locale/fa-IR.js +4 -0
  29. package/lib/es/locale/fr-FR.js +4 -0
  30. package/lib/es/locale/id-ID.js +4 -0
  31. package/lib/es/locale/it-IT.js +4 -0
  32. package/lib/es/locale/ja-JP.js +4 -0
  33. package/lib/es/locale/ko-KR.js +4 -0
  34. package/lib/es/locale/pl-PL.js +4 -0
  35. package/lib/es/locale/pt-BR.js +4 -0
  36. package/lib/es/locale/ru-RU.js +4 -0
  37. package/lib/es/locale/sk-SK.js +4 -0
  38. package/lib/es/locale/vi-VN.js +4 -0
  39. package/lib/es/locale/zh-CN.js +4 -0
  40. package/lib/es/locale/zh-HK.js +4 -0
  41. package/lib/es/locale/zh-TW.js +4 -0
  42. package/lib/index.css +40 -78
  43. package/lib/index.js +826 -248
  44. package/lib/locale/ar-SA.js +4 -0
  45. package/lib/locale/ca-ES.js +4 -0
  46. package/lib/locale/de-DE.js +4 -0
  47. package/lib/locale/en-US.js +4 -0
  48. package/lib/locale/es-ES.js +4 -0
  49. package/lib/locale/fa-IR.js +4 -0
  50. package/lib/locale/fr-FR.js +4 -0
  51. package/lib/locale/id-ID.js +4 -0
  52. package/lib/locale/it-IT.js +4 -0
  53. package/lib/locale/ja-JP.js +4 -0
  54. package/lib/locale/ko-KR.js +4 -0
  55. package/lib/locale/pl-PL.js +4 -0
  56. package/lib/locale/pt-BR.js +4 -0
  57. package/lib/locale/ru-RU.js +4 -0
  58. package/lib/locale/sk-SK.js +4 -0
  59. package/lib/locale/vi-VN.js +4 -0
  60. package/lib/locale/zh-CN.js +4 -0
  61. package/lib/locale/zh-HK.js +4 -0
  62. package/lib/locale/zh-TW.js +4 -0
  63. package/lib/types/config/config.d.ts +5 -0
  64. package/lib/types/index.d.ts +1 -0
  65. package/lib/types/locale/en-US.d.ts +4 -0
  66. package/lib/types/menu/menu.d.ts +1 -1
  67. package/lib/types/menu/mobile-schema.d.ts +41 -2
  68. package/lib/types/plugin.d.ts +1 -1
  69. package/lib/types/services/clipboard/clipboard.service.d.ts +1 -1
  70. package/lib/types/services/doc-heading-collapse.service.d.ts +38 -0
  71. package/lib/types/services/doc-paragraph-menu.service.d.ts +5 -3
  72. package/lib/types/services/doc-popup-manager.service.d.ts +4 -1
  73. package/lib/types/services/mobile/doc-selection-render.service.d.ts +1 -0
  74. package/lib/types/services/selection/doc-selection-render.service.d.ts +2 -1
  75. package/lib/types/views/EditorColorPicker.d.ts +20 -0
  76. package/lib/types/views/ParagraphMenu.d.ts +2 -2
  77. package/lib/types/views/doc-side-menu-layout.d.ts +17 -0
  78. package/lib/types/views/heading-collapse-shape.d.ts +38 -0
  79. package/lib/types/views/paragraph-menu/paragraph-menu-position.d.ts +21 -0
  80. package/lib/types/views/paragraph-setting/hook/utils.d.ts +2 -0
  81. package/lib/types/views/rich-text-editor/hooks/editor-undo-redo-keyboard.d.ts +5 -1
  82. package/lib/umd/index.js +16 -17
  83. package/lib/umd/locale/ar-SA.js +1 -1
  84. package/lib/umd/locale/ca-ES.js +1 -1
  85. package/lib/umd/locale/de-DE.js +1 -1
  86. package/lib/umd/locale/en-US.js +1 -1
  87. package/lib/umd/locale/es-ES.js +1 -1
  88. package/lib/umd/locale/fa-IR.js +1 -1
  89. package/lib/umd/locale/fr-FR.js +1 -1
  90. package/lib/umd/locale/id-ID.js +1 -1
  91. package/lib/umd/locale/it-IT.js +1 -1
  92. package/lib/umd/locale/ja-JP.js +1 -1
  93. package/lib/umd/locale/ko-KR.js +1 -1
  94. package/lib/umd/locale/pl-PL.js +1 -1
  95. package/lib/umd/locale/pt-BR.js +1 -1
  96. package/lib/umd/locale/ru-RU.js +1 -1
  97. package/lib/umd/locale/sk-SK.js +1 -1
  98. package/lib/umd/locale/vi-VN.js +1 -1
  99. package/lib/umd/locale/zh-CN.js +1 -1
  100. package/lib/umd/locale/zh-HK.js +1 -1
  101. package/lib/umd/locale/zh-TW.js +1 -1
  102. package/package.json +12 -12
package/lib/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { BaselineOffset, BlockType, BooleanNumber, BuildTextUtils, COLORS, ColorKit, ColumnSeparatorType, CommandType, CustomDecorationType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOC_RANGE_TYPE, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, DeleteDirection, DependentOn, Direction, Disposable, DisposableCollection, DocumentBlockRangeType, DocumentBlockType, DocumentFlavor, DrawingTypeEnum, EDITOR_ACTIVATED, ErrorService, FOCUSING_COMMENT_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_DOC, FOCUSING_EDITOR_STANDALONE, FOCUSING_FX_BAR_EDITOR, FOCUSING_SHAPE_TEXT_EDITOR, FOCUSING_UNIVER_EDITOR, HorizontalAlign, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IPermissionService, IUndoRedoService, IUniverInstanceService, ImageSourceType, Inject, Injector, InterceptorManager, JSON1, JSONX, LOCALE_META, LRUMap, ListGlyphType, LocaleService, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MemoryCursor, ModernDocumentWidthMode, NAMED_STYLE_MAP, NamedStyleType, ObjectPermissionService, ObjectRelativeFromH, ObjectRelativeFromV, Optional, PAGE_SIZE, PAPER_TYPES, PRESERVE_INSERTED_PARAGRAPH_IDS, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, PresetListType, QuickListTypeMap, RANGE_DIRECTION, Rectangle, RedoCommand, RegionService, RichTextBuilder, RxDisposable, SHEET_EDITOR_UNITS, SectionType, SliceBodyType, SpacingRule, TableAlignmentType, TableRowHeightRule, TableSizeType, TableTextWrapType, TextX, TextXActionType, ThemeService, Tools, UndoCommand, UniverInstanceType, UpdateDocsAttributeType, VerticalAlign, checkForSubstrings, cloneBodyWithFreshParagraphIds, containsInteriorInsertionOffset, createIdentifier, createInterceptorKey, createInternalEditorID, createParagraphId, createSectionId, debounce, fromEventSubject, generateRandomId, getBlockRangeInterval, getBodySlice, getBodySliceForTextXAction, getColorStyle, getCustomBlockIdsInSelections, getParagraphContentStartOffset, getParagraphContentStartOffsets, getPlainText, getRichTextEditPath, getSectionHeaderFooterReferenceKey, getTableRangeInterval, getTextRunSlice, isCommentEditorID, isInternalEditorID, isSafeUrl, merge, mergeOverrideWithDependencies, normalizeBody, remove, resolveDocumentParagraphStyle, resolveSectionHeaderFooterReference, resolveSectionHeaderFooterReferences, sequenceExecuteAsync, skipParseTagNames, toDisposable, touchDependencies, validateDocBodyStructure } from "@univerjs/core";
2
- import { CreateHeaderFooterCommand, DeleteTextCommand, DocBlockMoveValidatorService, DocContentInsertService, DocHistoryAction, DocInterceptorService, DocLayoutExecutorService, DocLayoutExecutorState, DocLayoutSessionStatus, DocSelectionManagerService, DocSkeletonManagerService, DocStateChangeManagerService, DocStateEmitService, HeaderFooterType, IDocStateChangeInterceptorService, InsertDocumentColumnBreakCommand, InsertDocumentSectionBreakCommand, InsertTextCommand, RichTextEditingMutation, SetDocumentPermissionCommand, SetSectionHeaderFooterLinkCommand, SetTextSelectionsOperation, UniverDocsPlugin, UpdateDocumentSectionCommand, UpdateTextCommand, buildDocTransform, canEditDocumentTargets, consumeContentInsertRange, createSectionColumnProperties, generateParagraphs, getDocumentEditTargetObjectIds, getDocumentParagraphPermissionObjectId, getDocumentPermissionValue, getDocumentSectionPermissionObjectId, getTopLevelSectionBreaks, isSheetLikeDocsCustomBlockChildType, resolveDocsCustomBlockSize, shouldUseInlineTextSelectionForDocsCustomBlockDrawing, transformDocumentTextRanges } from "@univerjs/docs";
2
+ import { CreateHeaderFooterCommand, DeleteTextCommand, DocBlockMoveValidatorService, DocContentInsertService, DocHistoryAction, DocInterceptorService, DocLayoutExecutorService, DocLayoutExecutorState, DocLayoutSessionStatus, DocSelectionManagerService, DocSkeletonManagerService, DocStateChangeManagerService, DocStateEmitService, HeaderFooterType, IDocStateChangeInterceptorService, InsertDocumentColumnBreakCommand, InsertDocumentSectionBreakCommand, InsertTextCommand, RichTextEditingMutation, SetDocumentPermissionCommand, SetHeadingCollapsedCommand, SetSectionHeaderFooterLinkCommand, SetTextSelectionsOperation, UniverDocsPlugin, UpdateDocumentSectionCommand, UpdateTextCommand, buildDocTransform, canEditDocumentTargets, consumeContentInsertRange, createSectionColumnProperties, generateParagraphs, getDocumentEditTargetObjectIds, getDocumentParagraphPermissionObjectId, getDocumentPermissionValue, getDocumentSectionPermissionObjectId, getTopLevelSectionBreaks, isSheetLikeDocsCustomBlockChildType, resolveDocsCustomBlockSize, shouldUseInlineTextSelectionForDocsCustomBlockDrawing, transformDocumentTextRanges } from "@univerjs/docs";
3
3
  import * as EngineRender from "@univerjs/engine-render";
4
- import { BaseObject, CURSOR_TYPE, DRAWING_OBJECT_UPPER_LAYER_INDEX, DeviceInputEventType, DocBackground, DocumentEditArea, DocumentSkeletonPageType, Documents, GlyphType, IRenderManagerService, Layer, LineType, Liquid, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, PageLayoutType, Path, RENDER_CLASS_TYPE, Rect, RegularPolygon, ScrollBar, ScrollTimer, Shape, TRANSFORM_CHANGE_OBSERVABLE_TYPE, UniverRenderEnginePlugin, Vector2, Viewport, compareDocumentSkeletonNestedPagePathOrder, documentSkeletonLineIterator, documentSkeletonTableIterator, getColor, getDocsTableRenderViewport, getDocsTableViewportLeft, getDocumentSkeletonColumnPagePathInfo, getDocumentSkeletonNestedPageOffset, getLastColumn, getNextWheelZoomRatio, getNumberUnitValue, getOffsetRectForDom, getPageFromPath, getParagraphByGlyph, getSystemHighlightColor, getTableIdAndSliceIndex, getTopmostDocsTableHit, hasListGlyph, isFirstGlyph, isIndentByGlyph, parseDataStreamToTree, pixelToPt, ptToPixel, pxToNum, registerDocumentLayoutPresentation } from "@univerjs/engine-render";
4
+ import { BaseObject, CURSOR_TYPE, DRAWING_OBJECT_UPPER_LAYER_INDEX, DeviceInputEventType, DocBackground, DocumentEditArea, DocumentSkeletonPageType, DocumentViewModel, Documents, GlyphType, IRenderManagerService, Layer, LineType, Liquid, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, PageLayoutType, Path, RENDER_CLASS_TYPE, Rect, RegularPolygon, ScrollBar, ScrollTimer, Shape, TRANSFORM_CHANGE_OBSERVABLE_TYPE, UniverRenderEnginePlugin, Vector2, Viewport, compareDocumentSkeletonNestedPagePathOrder, documentSkeletonLineIterator, documentSkeletonTableIterator, getColor, getDocsTableRenderViewport, getDocsTableViewportLeft, getDocumentSkeletonColumnPagePathInfo, getDocumentSkeletonNestedPageOffset, getLastColumn, getNextWheelZoomRatio, getNumberUnitValue, getOffsetRectForDom, getPageFromPath, getParagraphByGlyph, getSystemHighlightColor, getTableIdAndSliceIndex, getTopmostDocsTableHit, hasListGlyph, isFirstGlyph, isIndentByGlyph, parseDataStreamToTree, pixelToPt, ptToPixel, pxToNum, registerDocumentLayoutPresentation } from "@univerjs/engine-render";
5
5
  import { Button, Checkbox, Dialog, Dropdown, DropdownMenu, InputNumber, MessageType, MobileColorPicker, MobileDropdown, MobileSelect, Popup, Select, Separator, Tooltip, borderClassName, clsx, resetButtonClassName, scrollbarClassName, selectClassName, useMobileKeyboardViewportLayout } from "@univerjs/design";
6
- import { BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, ComponentManager, ContextMenuGroup, ContextMenuPanel, ContextMenuPosition, CopyCommand, CutCommand, EMOJI_PICKER_COMPONENT, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FormatPainterSessionService, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, ICanvasPopupService, IClipboardInterfaceService, IContextMenuService, ILayoutService, IMenuManagerService, IMessageService, IRibbonService, IShortcutService, ISidebarService, IUIPartsService, IWorkbenchService, IconManager, KeyCode, MOBILE_UI_MODE, MenuItemType, MenuManagerPosition, MetaKeys, MobileDrawer, MobileKeyboardInsetContext, MobileMenu, MobileZoomIndicator, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, RectPopup, RibbonInsertGroup, RibbonStartGroup, RibbonViewGroup, SYMBOL_PICKER_COMPONENT, Slider, ToggleFullscreenOperation, ToolbarButton, ToolbarItem, UniverMobileUIPlugin, bindFormatPainterCanvas, connectInjector, getMenuHiddenObservable, getMobileCanvasPanDelta, imageMimeTypeSet, objectPermissionMenuItemFactory, openObjectPermissionDialog, openObjectPermissionPanel, preventBrowserZoomInContainers, useConfigValue, useDependency, useEvent, useInjector, useMobileCanvasPanel, useMobileCanvasViewport, useObservable } from "@univerjs/ui";
6
+ import { BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, ComponentManager, ContextMenuGroup, ContextMenuPanel, ContextMenuPosition, CopyCommand, CutCommand, DISABLE_AUTO_FOCUS_KEY, EMOJI_PICKER_COMPONENT, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FormatPainterSessionService, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, ICanvasPopupService, IClipboardInterfaceService, IContextMenuService, ILayoutService, IMenuManagerService, IMessageService, IRibbonService, IShortcutService, ISidebarService, IUIPartsService, IWorkbenchService, IconManager, KeyCode, MOBILE_UI_MODE, MenuItemType, MenuManagerPosition, MetaKeys, MobileDrawer, MobileKeyboardInsetContext, MobileMenu, MobileZoomIndicator, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, RectPopup, RibbonInsertGroup, RibbonStartGroup, RibbonViewGroup, SYMBOL_PICKER_COMPONENT, Slider, ToggleFullscreenOperation, ToolbarButton, ToolbarItem, UniverMobileUIPlugin, bindFormatPainterCanvas, connectInjector, getMenuHiddenObservable, getMobileCanvasPanDelta, imageMimeTypeSet, objectPermissionMenuItemFactory, openObjectPermissionDialog, openObjectPermissionPanel, preventBrowserZoomInContainers, useConfigValue, useDependency, useEvent, useInjector, useMobileCanvasPanel, useMobileCanvasViewport, useObservable } from "@univerjs/ui";
7
7
  import { UnitAction, UnitObject } from "@univerjs/protocol";
8
- import { BehaviorSubject, EMPTY, Observable, Subject, animationFrameScheduler, auditTime, combineLatest, debounceTime, distinctUntilChanged, filter, first, fromEvent, map, merge as merge$1, observeOn, of, shareReplay, startWith, switchMap, take, takeUntil, tap, throttleTime } from "rxjs";
8
+ import { BehaviorSubject, EMPTY, Observable, Subject, Subscription, animationFrameScheduler, auditTime, combineLatest, debounceTime, distinctUntilChanged, filter, fromEvent, map, merge as merge$1, observeOn, of, shareReplay, skip, startWith, switchMap, take, takeUntil, tap, throttleTime } from "rxjs";
9
9
  import { bufferTime, filter as filter$1, map as map$1 } from "rxjs/operators";
10
10
  import { createElement, forwardRef, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState } from "react";
11
11
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -493,15 +493,34 @@ const BreakLineCommand = {
493
493
  const { horizontalLine, insertionMode = "split-paragraph" } = params ?? {};
494
494
  const { segmentId } = activeTextRange;
495
495
  const docDataModel = (params === null || params === void 0 ? void 0 : params.unitId) ? univerInstanceService.getUnit(params.unitId, UniverInstanceType.UNIVER_DOC) : univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
496
- const originBody = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId ?? "")) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
496
+ let originBody = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId ?? "")) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
497
497
  if (docDataModel == null || originBody == null) return false;
498
498
  const unitId = docDataModel.getUnitId();
499
499
  const { startOffset, endOffset } = activeTextRange;
500
500
  const paragraphs = originBody.paragraphs ?? [];
501
501
  const isBareStructuralGap = isTopLevelStructuralGap(originBody.dataStream, startOffset) && originBody.dataStream[startOffset] !== DataStreamTreeTokenType.PARAGRAPH;
502
502
  const insertsAtStructuralGap = insertionMode === "insert-gap" || isBareStructuralGap;
503
- const prevParagraph = insertsAtStructuralGap ? void 0 : paragraphs.find((p) => p.startIndex >= startOffset);
503
+ let prevParagraph = insertsAtStructuralGap ? void 0 : paragraphs.find((p) => p.startIndex >= startOffset);
504
504
  if (!prevParagraph && !insertsAtStructuralGap) return false;
505
+ if (!segmentId && (prevParagraph === null || prevParagraph === void 0 ? void 0 : prevParagraph.headingCollapsed) && docDataModel.getSnapshot().documentStyle.documentFlavor === DocumentFlavor.MODERN) {
506
+ const paragraphId = prevParagraph.paragraphId;
507
+ const viewModel = new DocumentViewModel(docDataModel);
508
+ try {
509
+ if (viewModel.getHeadingSections().some((section) => section.paragraphId === paragraphId)) {
510
+ var _originBody$paragraph;
511
+ if (!commandService.syncExecuteCommand(SetHeadingCollapsedCommand.id, {
512
+ unitId,
513
+ paragraphId,
514
+ collapsed: false
515
+ })) return false;
516
+ originBody = docDataModel.getBody();
517
+ prevParagraph = originBody === null || originBody === void 0 || (_originBody$paragraph = originBody.paragraphs) === null || _originBody$paragraph === void 0 ? void 0 : _originBody$paragraph.find((paragraph) => paragraph.startIndex >= startOffset);
518
+ if (!originBody || !prevParagraph) return false;
519
+ }
520
+ } finally {
521
+ viewModel.dispose();
522
+ }
523
+ }
505
524
  const isAtParagraphEnd = startOffset === (prevParagraph === null || prevParagraph === void 0 ? void 0 : prevParagraph.startIndex);
506
525
  const prevParagraphIndex = prevParagraph === null || prevParagraph === void 0 ? void 0 : prevParagraph.startIndex;
507
526
  const defaultTextStyle = docMenuStyleService.getDefaultStyle();
@@ -2839,7 +2858,7 @@ function getTextRangeFromCharIndex(startOffset, endOffset, scene, document, skel
2839
2858
  function getRectRangeFromCharIndex(startOffset, endOffset, scene, document, skeleton, style, segmentId, segmentPage) {
2840
2859
  const startNodePosition = skeleton.findNodePositionByCharIndex(startOffset, true, segmentId, segmentPage);
2841
2860
  const endNodePosition = skeleton.findNodePositionByCharIndex(endOffset, true, segmentId, segmentPage);
2842
- if (startNodePosition == null || endNodePosition == null) return;
2861
+ if (startNodePosition == null || endNodePosition == null || startNodePosition.path.indexOf("cells") === -1 || endNodePosition.path.indexOf("cells") === -1) return;
2843
2862
  return new RectRange(scene, document, skeleton, startNodePosition, endNodePosition, style, segmentId, segmentPage);
2844
2863
  }
2845
2864
  function getRangeListFromCharIndex(startOffset, endOffset, scene, document, skeleton, style, segmentId, segmentPage) {
@@ -3225,7 +3244,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
3225
3244
  get canFocusing() {
3226
3245
  const ownerDocument = this._getOwnerDocument();
3227
3246
  const activeElement = ownerDocument.activeElement;
3228
- return !this._shouldPreserveExternalFocus() && !this._isAnotherEditorFocused() && (this.isFocusing || activeElement === ownerDocument.body || activeElement === null || activeElement instanceof HTMLElement && this._containsCurrentEmbedRuntimeElement(activeElement));
3247
+ return !this._isInUnfocusedFrame() && !this._shouldPreserveExternalFocus() && !this._isAnotherEditorFocused() && (this.isFocusing || activeElement === ownerDocument.body || activeElement === null || activeElement instanceof HTMLElement && this._containsCurrentEmbedRuntimeElement(activeElement));
3229
3248
  }
3230
3249
  cancelPointerSelection() {
3231
3250
  if (!this._onPointerEvent) return;
@@ -3956,7 +3975,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
3956
3975
  const activeRangeInstance = this._getActiveRangeInstance();
3957
3976
  const anchor = activeRangeInstance === null || activeRangeInstance === void 0 ? void 0 : activeRangeInstance.getAnchor();
3958
3977
  if (!anchor || anchor && !anchor.visible || this.activeViewPort == null) {
3959
- if (preserveFocus || this._shouldPreserveExternalFocus() || !forceFocus && this._isAnotherEditorFocused()) return;
3978
+ if (preserveFocus || this._shouldPreserveExternalFocus() || !forceFocus && (this._isInUnfocusedFrame() || this._isAnotherEditorFocused())) return;
3960
3979
  this.focus();
3961
3980
  return;
3962
3981
  }
@@ -4234,6 +4253,11 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
4234
4253
  if (activeElement instanceof HTMLElement && this._containsCurrentLayoutElement(activeElement)) return false;
4235
4254
  return ((_this$_embedInteracti2 = this._embedInteractionBoundaryService) === null || _this$_embedInteracti2 === void 0 || (_this$_embedInteracti3 = _this$_embedInteracti2.hasRecentInteractionFor) === null || _this$_embedInteracti3 === void 0 ? void 0 : _this$_embedInteracti3.call(_this$_embedInteracti2, currentEmbedOwner, ownerDocument)) === true;
4236
4255
  }
4256
+ _isInUnfocusedFrame() {
4257
+ const ownerDocument = this._getOwnerDocument();
4258
+ const ownerWindow = ownerDocument.defaultView;
4259
+ return ownerWindow != null && ownerWindow.parent !== ownerWindow && !ownerDocument.hasFocus();
4260
+ }
4237
4261
  _isAnotherEditorFocused() {
4238
4262
  const activeElement = this._getOwnerDocument().activeElement;
4239
4263
  return activeElement instanceof HTMLElement && activeElement !== this._input && activeElement.dataset.uComp === this._input.dataset.uComp;
@@ -6233,6 +6257,14 @@ const DeleteLeftCommand = {
6233
6257
  const { segmentId, style, segmentPage } = activeRange;
6234
6258
  const body = (_docDataModel$getSelf3 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf3 === void 0 ? void 0 : _docDataModel$getSelf3.getBody();
6235
6259
  if (body == null) return false;
6260
+ if (activeRange.collapsed && !segmentId) {
6261
+ const hidden = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel().getCollapsedHeadingAtOffset(activeRange.startOffset - 1);
6262
+ if (hidden) return commandService.executeCommand(SetHeadingCollapsedCommand.id, {
6263
+ unitId,
6264
+ paragraphId: hidden.paragraphId,
6265
+ collapsed: false
6266
+ });
6267
+ }
6236
6268
  const originalLength = body.dataStream.length;
6237
6269
  const typingStyle = captureDeletedTypingStyle(accessor, docDataModel, body, activeRange);
6238
6270
  const actualRange = activeRange;
@@ -6391,6 +6423,14 @@ const DeleteRightCommand = {
6391
6423
  const { segmentId, style, segmentPage } = activeRange;
6392
6424
  const body = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf5 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf5 === void 0 ? void 0 : _docDataModel$getSelf5.getBody();
6393
6425
  if (!docDataModel || !body) return false;
6426
+ if (activeRange.collapsed && !segmentId) {
6427
+ const hidden = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel().getCollapsedHeadingAtOffset(activeRange.startOffset + 1);
6428
+ if (hidden) return commandService.executeCommand(SetHeadingCollapsedCommand.id, {
6429
+ unitId: docDataModel.getUnitId(),
6430
+ paragraphId: hidden.paragraphId,
6431
+ collapsed: false
6432
+ });
6433
+ }
6394
6434
  const actualRange = activeRange;
6395
6435
  const { startOffset, endOffset, collapsed } = actualRange;
6396
6436
  if (collapsed && shouldResetEmptyCenteredParagraphAlignment(accessor, docDataModel)) {
@@ -8752,13 +8792,21 @@ let DocClipboardService = class DocClipboardService extends Disposable {
8752
8792
  this.dismissPasteOptions();
8753
8793
  const unitId = payload.unitId ?? this._getCurrentDocumentUnitId();
8754
8794
  if (!unitId || !this._canEditTargets(unitId)) return false;
8755
- if (!cachedSource && !payload.html && !payload.text && !payload.internalJson && !payload.files.length) return false;
8795
+ const isCommentEditor = isCommentEditorID(unitId);
8796
+ if (!cachedSource && !payload.html && !payload.text && !payload.internalJson && (isCommentEditor || !payload.files.length)) return false;
8756
8797
  const generation = this._pasteGeneration;
8757
- const mode = unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY ? "text" : payload.mode ?? "source";
8798
+ const mode = isCommentEditor || unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY ? "text" : payload.mode ?? "source";
8758
8799
  const style = this._getPasteStyle(unitId);
8759
- const source = await this._preparePaste(payload, mode, cachedSource);
8800
+ const source = await (isCommentEditor && payload.text !== void 0 ? { body: { dataStream: payload.text } } : this._preparePaste(payload, mode, cachedSource));
8760
8801
  if (generation !== this._pasteGeneration || !this._canEditTargets(unitId)) return false;
8761
- let doc = applyDocPasteMode(source, mode, style, payload.text);
8802
+ let doc;
8803
+ if (isCommentEditor) {
8804
+ const text = payload.text ?? getClipboardPlainText(source);
8805
+ if (!text) return false;
8806
+ const body = BuildTextUtils.transform.fromPlainText(text);
8807
+ delete body.customRanges;
8808
+ doc = { body };
8809
+ } else doc = applyDocPasteMode(source, mode, style, payload.text);
8762
8810
  if (unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY) {
8763
8811
  doc = {
8764
8812
  ...source,
@@ -8962,12 +9010,11 @@ let DocClipboardService = class DocClipboardService extends Disposable {
8962
9010
  }
8963
9011
  }
8964
9012
  async _setClipboardData(documentList, needCache = true, plainTextList) {
8965
- var _documentList$0$body;
8966
9013
  const copyId = generateRandomId(6);
8967
- const text = (plainTextList ? plainTextList.join("\n") : documentList.length > 1 ? documentList.map((doc) => {
9014
+ const text = (plainTextList ?? documentList.map((doc) => {
8968
9015
  var _doc$body3;
8969
9016
  return ((_doc$body3 = doc.body) === null || _doc$body3 === void 0 ? void 0 : _doc$body3.dataStream) || "";
8970
- }).join("\n") : ((_documentList$0$body = documentList[0].body) === null || _documentList$0$body === void 0 ? void 0 : _documentList$0$body.dataStream) || "").replaceAll(DataStreamTreeTokenType.TABLE_START, "").replaceAll(DataStreamTreeTokenType.TABLE_END, "").replaceAll(DataStreamTreeTokenType.TABLE_ROW_START, "").replaceAll(DataStreamTreeTokenType.TABLE_ROW_END, "").replaceAll(DataStreamTreeTokenType.TABLE_CELL_START, "").replaceAll(DataStreamTreeTokenType.TABLE_CELL_END, "").replaceAll(DataStreamTreeTokenType.BLOCK_START, "").replaceAll(DataStreamTreeTokenType.BLOCK_END, "").replaceAll("\r\n", " ").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "");
9017
+ })).join("\n").replaceAll(DataStreamTreeTokenType.TABLE_START, "").replaceAll(DataStreamTreeTokenType.TABLE_END, "").replaceAll(DataStreamTreeTokenType.TABLE_ROW_START, "").replaceAll(DataStreamTreeTokenType.TABLE_ROW_END, "").replaceAll(DataStreamTreeTokenType.TABLE_CELL_START, "").replaceAll(DataStreamTreeTokenType.TABLE_CELL_END, "").replaceAll(DataStreamTreeTokenType.BLOCK_START, "").replaceAll(DataStreamTreeTokenType.BLOCK_END, "").replaceAll("\r\n", " ").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "");
8971
9018
  let html = this._umdToHtml.convert(documentList);
8972
9019
  let internalJson = "";
8973
9020
  let internalDocData = null;
@@ -9025,7 +9072,6 @@ let DocClipboardService = class DocClipboardService extends Disposable {
9025
9072
  const snapshot = docDataModel.getSnapshot();
9026
9073
  if (body == null) return;
9027
9074
  for (const range of allRanges) {
9028
- var _docDataModel$getSelf2, _docBody$tables;
9029
9075
  const { startOffset, endOffset, collapsed, rangeType } = range;
9030
9076
  if (collapsed || startOffset == null || endOffset == null) continue;
9031
9077
  if (rangeType === DOC_RANGE_TYPE.RECT) {
@@ -9035,20 +9081,9 @@ let DocClipboardService = class DocClipboardService extends Disposable {
9035
9081
  plainTextResults.push(bodySlice.dataStream);
9036
9082
  continue;
9037
9083
  }
9038
- const deleteRange = {
9039
- startOffset,
9040
- endOffset,
9041
- collapsed
9042
- };
9043
- const docBody = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.sliceBody(deleteRange.startOffset, deleteRange.endOffset, sliceType);
9044
- if (docBody == null) continue;
9045
- if ((_docBody$tables = docBody.tables) === null || _docBody$tables === void 0 ? void 0 : _docBody$tables.length) {
9046
- var _body$tables2;
9047
- const completeTableIds = new Set((_body$tables2 = body.tables) === null || _body$tables2 === void 0 ? void 0 : _body$tables2.filter((table) => table.startIndex >= startOffset && table.endIndex <= endOffset).map((table) => table.tableId));
9048
- docBody.tables = docBody.tables.filter((table) => completeTableIds.has(table.tableId));
9049
- }
9084
+ const docBody = getBodySliceForTextXAction(body, startOffset, endOffset, false, sliceType);
9050
9085
  results.push(docBody);
9051
- plainTextResults.push((copyContentHook === null || copyContentHook === void 0 ? void 0 : copyContentHook(deleteRange.startOffset, deleteRange.endOffset, {
9086
+ plainTextResults.push((copyContentHook === null || copyContentHook === void 0 ? void 0 : copyContentHook(startOffset, endOffset, {
9052
9087
  body,
9053
9088
  segmentId,
9054
9089
  unitId: docDataModel.getUnitId()
@@ -11722,7 +11757,6 @@ const DEFAULT_DOC_FIT_TO_WIDTH_OPTIONS = {
11722
11757
  align: "center"
11723
11758
  };
11724
11759
  const defaultPluginConfig = {
11725
- toc: false,
11726
11760
  footer: true,
11727
11761
  wordCount: true,
11728
11762
  placeholder: true,
@@ -12939,7 +12973,7 @@ let DocPageLayoutService = class DocPageLayoutService extends Disposable {
12939
12973
  sceneWidth = docsWidth + horizontalMargin * 2;
12940
12974
  scrollToX = 0;
12941
12975
  }
12942
- if (engineHeight > docsHeight) sceneHeight = (engineHeight - pageMarginTop * 2) / viewScale;
12976
+ if (engineHeight > (docsHeight + pageMarginTop * 2) * viewScale) sceneHeight = (engineHeight - pageMarginTop * 2) / viewScale;
12943
12977
  else sceneHeight = docsHeight + pageMarginTop * 2;
12944
12978
  sceneHeight = this.resolveSceneHeight(sceneHeight);
12945
12979
  scene.transformByState({
@@ -13653,9 +13687,13 @@ let DocRenderController = class DocRenderController extends RxDisposable {
13653
13687
  const interactionAnchor = priorityAnchorBelongsToMutation ? options.anchor : options.priorityAnchor ?? options.anchor;
13654
13688
  let interactionViewportAnchor = priorityAnchorBelongsToMutation ? null : this._captureViewportAnchor(skeleton, options.priorityAnchor, options.invalidation);
13655
13689
  const foregroundEndOffset = this._resolveContinuousForegroundEndOffset(skeleton, options.invalidation);
13690
+ const viewport = this._context.scene.getViewport("viewMain");
13691
+ const docsComponent = this._context.mainComponent;
13692
+ const minimumPublicationHeight = this._context.unit.documentStyle.documentFlavor === DocumentFlavor.MODERN && viewport != null && docsComponent instanceof Documents ? Math.max(0, viewport.calcViewportInfo().viewBound.bottom - docsComponent.getOffsetConfig().docsTop) : void 0;
13656
13693
  this._layoutCoordinator.schedule(skeleton, {
13657
13694
  ...options,
13658
13695
  anchor: interactionAnchor,
13696
+ ...minimumPublicationHeight != null && Number.isFinite(minimumPublicationHeight) && minimumPublicationHeight > 0 ? { minimumPublicationHeight } : {},
13659
13697
  ...foregroundEndOffset == null ? {} : { foregroundEndOffset },
13660
13698
  preserveInteractionWindow: interactionAnchor != null && interactionAnchor !== options.anchor,
13661
13699
  reuseUnaffectedTail: false
@@ -15015,7 +15053,8 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends Dispos
15015
15053
  const updatePosition = () => {
15016
15054
  try {
15017
15055
  const newPosition = calc();
15018
- if (newPosition) position$.next(newPosition);
15056
+ const previous = position$.value;
15057
+ if (newPosition && (newPosition.left !== previous.left || newPosition.right !== previous.right || newPosition.top !== previous.top || newPosition.bottom !== previous.bottom)) position$.next(newPosition);
15019
15058
  } catch {}
15020
15059
  };
15021
15060
  disposable.add(this._commandService.onCommandExecuted((commandInfo) => {
@@ -15071,6 +15110,7 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends Dispos
15071
15110
  disposable.add(currentRender.scene.onTransformChange$.subscribeEvent(() => {
15072
15111
  updatePositions();
15073
15112
  }));
15113
+ if (currentRender.mainComponent) disposable.add(currentRender.mainComponent.onTransformChange$.subscribeEvent(updatePositions));
15074
15114
  return {
15075
15115
  positions,
15076
15116
  positions$,
@@ -15082,14 +15122,18 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends Dispos
15082
15122
  if (!currentRender) throw new Error(`Current render not found, unitId: ${unitId}`);
15083
15123
  const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
15084
15124
  const popupManagerService = this._resolvePopupManagerService(popupInjector);
15085
- const { position, position$, disposable } = this._createRectPositionObserver(rect, currentRender);
15125
+ const { position, position$, disposable, updatePosition } = this._createRectPositionObserver(rect, currentRender);
15126
+ if (popup.positionChanges$) disposable.add(popup.positionChanges$.subscribe(updatePosition));
15086
15127
  const id = popupManagerService.addPopup({
15087
15128
  ...popup,
15088
15129
  unitId,
15089
15130
  subUnitId: "default",
15090
15131
  connectorInjector: popupInjector,
15091
15132
  anchorRect: position,
15092
- anchorRect$: position$,
15133
+ anchorRect$: position$.pipe(throttleTime(0, animationFrameScheduler, {
15134
+ leading: true,
15135
+ trailing: true
15136
+ })),
15093
15137
  canvasElement: currentRender.engine.getCanvasElement()
15094
15138
  });
15095
15139
  const popupActivity = popup.requiresStableLayout === false ? null : this._beginPopupActivity(unitId);
@@ -15121,7 +15165,10 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends Dispos
15121
15165
  subUnitId: "default",
15122
15166
  connectorInjector: popupInjector,
15123
15167
  anchorRect: position,
15124
- anchorRect$: position$,
15168
+ anchorRect$: position$.pipe(throttleTime(0, animationFrameScheduler, {
15169
+ leading: true,
15170
+ trailing: true
15171
+ })),
15125
15172
  canvasElement: currentRender.engine.getCanvasElement()
15126
15173
  });
15127
15174
  const popupActivity = popup.requiresStableLayout === false ? null : this._beginPopupActivity(unitId);
@@ -15163,7 +15210,11 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends Dispos
15163
15210
  }
15164
15211
  return direction.includes("top") ? bounds[0] : bounds[bounds.length - 1];
15165
15212
  };
15166
- const position$ = bounds$.pipe(filter((bounds) => bounds.length > 0), map(getAnchor));
15213
+ const popupBounds$ = bounds$.pipe(throttleTime(0, animationFrameScheduler, {
15214
+ leading: true,
15215
+ trailing: true
15216
+ }));
15217
+ const position$ = popupBounds$.pipe(filter((bounds) => bounds.length > 0), map(getAnchor));
15167
15218
  let id;
15168
15219
  let popupActivity = null;
15169
15220
  const removePopup = () => {
@@ -15188,7 +15239,7 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends Dispos
15188
15239
  anchorRect: getAnchor(bounds),
15189
15240
  anchorRect$: position$,
15190
15241
  excludeRects: bounds,
15191
- excludeRects$: bounds$,
15242
+ excludeRects$: popupBounds$,
15192
15243
  direction: [
15193
15244
  "top",
15194
15245
  "bottom",
@@ -15497,6 +15548,12 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
15497
15548
  }));
15498
15549
  }
15499
15550
  _initResetDirty() {
15551
+ this.disposeWithMe(this._documents.onTransformChange$.subscribeEvent(() => {
15552
+ this._customRangeDirty = true;
15553
+ this._bulletDirty = true;
15554
+ this._paragraphDirty = true;
15555
+ this._tableBoundsDirty = true;
15556
+ }));
15500
15557
  this.disposeWithMe(this._skeleton.dirty$.subscribe(() => {
15501
15558
  this._customRangeDirty = true;
15502
15559
  this._bulletDirty = true;
@@ -15988,6 +16045,9 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
15988
16045
  return (_this$_tableCellBound2 = this._tableCellBounds.get(tableId)) === null || _this$_tableCellBound2 === void 0 ? void 0 : _this$_tableCellBound2.find((bound) => bound.rowIndex === rowIndex && bound.colIndex === colIndex && (pageIndex == null || bound.pageIndex === pageIndex));
15989
16046
  }
15990
16047
  findParagraphBoundByIndex(index) {
16048
+ this._buildParagraphBounds();
16049
+ const paragraph = this._paragraphBounds.get(index);
16050
+ if (paragraph) return paragraph;
15991
16051
  this._buildTableBounds();
15992
16052
  this._buildTableCellsForDocumentRange(index, index);
15993
16053
  let tableParagraph = this._tableParagraphBoundsByIndex.get(index);
@@ -15999,9 +16059,6 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
15999
16059
  if (tableParagraph) return tableParagraph;
16000
16060
  }
16001
16061
  if (tableParagraph) return tableParagraph;
16002
- this._buildParagraphBounds();
16003
- const paragraph = this._paragraphBounds.get(index);
16004
- if (paragraph) return paragraph;
16005
16062
  }
16006
16063
  findParagraphBoundsInRange(startIndex, endIndex) {
16007
16064
  this._buildTableBounds();
@@ -16639,6 +16696,28 @@ const DocOpenPageSettingCommand = {
16639
16696
  }
16640
16697
  };
16641
16698
 
16699
+ //#endregion
16700
+ //#region src/views/EditorColorPicker.tsx
16701
+ function EditorColorPicker(props) {
16702
+ const containerRef = useRef(null);
16703
+ const ColorPickerComponent = useDependency(ComponentManager).get(COLOR_PICKER_COMPONENT);
16704
+ useEffect(() => {
16705
+ const container = containerRef.current;
16706
+ const view = container === null || container === void 0 ? void 0 : container.ownerDocument.defaultView;
16707
+ if (!container || !view) return;
16708
+ const preserveComposition = (event) => {
16709
+ if (event.isComposing && (event.key === "Enter" || event.key === "Escape") && event.target instanceof view.HTMLInputElement && container.contains(event.target)) event.stopPropagation();
16710
+ };
16711
+ view.addEventListener("keydown", preserveComposition, true);
16712
+ return () => view.removeEventListener("keydown", preserveComposition, true);
16713
+ }, []);
16714
+ return /* @__PURE__ */ jsx("div", {
16715
+ ref: containerRef,
16716
+ children: /* @__PURE__ */ jsx(ColorPickerComponent, { ...props })
16717
+ });
16718
+ }
16719
+ EditorColorPicker.componentKey = "docs.editor-color-picker";
16720
+
16642
16721
  //#endregion
16643
16722
  //#region src/views/const.ts
16644
16723
  /**
@@ -17442,7 +17521,7 @@ function TextColorSelectorMenuItemFactory(accessor) {
17442
17521
  type: MenuItemType.BUTTON_SELECTOR,
17443
17522
  selections: [{
17444
17523
  label: {
17445
- name: COLOR_PICKER_COMPONENT,
17524
+ name: EditorColorPicker.componentKey,
17446
17525
  hoverable: false,
17447
17526
  selectable: false
17448
17527
  },
@@ -17871,7 +17950,7 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
17871
17950
  icon: "PaintBucketDoubleIcon",
17872
17951
  selections: [{
17873
17952
  label: {
17874
- name: COLOR_PICKER_COMPONENT,
17953
+ name: EditorColorPicker.componentKey,
17875
17954
  hoverable: false,
17876
17955
  selectable: false
17877
17956
  },
@@ -20717,10 +20796,30 @@ function DocFooter() {
20717
20796
  return /* @__PURE__ */ jsx(DocFooterContent, {});
20718
20797
  }
20719
20798
 
20799
+ //#endregion
20800
+ //#region src/views/doc-side-menu-layout.ts
20801
+ function isDocSideMenuTableOverlapping(outline, table, viewport) {
20802
+ if (table.bottom <= outline.top || table.top >= outline.bottom) return false;
20803
+ let left = table.left;
20804
+ let right = table.right;
20805
+ if (viewport && (viewport.leadingInsetLeft ?? 0) + viewport.contentWidth + (viewport.trailingInsetRight ?? 0) > viewport.viewportWidth) {
20806
+ const clipLeft = viewport.viewportLeft ?? table.left - (viewport.leadingInsetLeft ?? 0);
20807
+ left = Math.max(clipLeft, table.left - viewport.scrollLeft);
20808
+ right = Math.min(clipLeft + viewport.viewportWidth, table.left + viewport.contentWidth - viewport.scrollLeft);
20809
+ }
20810
+ return right > left && left < outline.right && right > outline.left;
20811
+ }
20812
+
20720
20813
  //#endregion
20721
20814
  //#region src/views/SideMenu.tsx
20722
20815
  const SideMenu = forwardRef((props, ref) => {
20723
- const { label, menus, onClick, className, style, mode, maxHeight, activeId, open, onOpenChange, maxWidth, wrapperClass, wrapperStyle, iconClass, iconStyle } = props;
20816
+ const { label, menus, onClick, className, style, mode = "side-bar", maxHeight, activeId, open: controlledOpen, onOpenChange, maxWidth, wrapperClass, wrapperStyle, iconClass, iconStyle } = props;
20817
+ const [expanded, setExpanded] = useState(mode === "side-bar");
20818
+ const open = controlledOpen ?? expanded;
20819
+ const handleOpenChange = useCallback((nextOpen) => {
20820
+ if (controlledOpen === void 0) setExpanded(nextOpen);
20821
+ onOpenChange === null || onOpenChange === void 0 || onOpenChange(nextOpen);
20822
+ }, [controlledOpen, onOpenChange]);
20724
20823
  const panelId = useId();
20725
20824
  const wrapperRef = useRef(null);
20726
20825
  const containerRef = useRef(null);
@@ -20748,13 +20847,13 @@ const SideMenu = forwardRef((props, ref) => {
20748
20847
  if (!open || mode !== "float") return;
20749
20848
  const handlePointerDown = (event) => {
20750
20849
  var _wrapperRef$current;
20751
- if (event.target instanceof Node && !((_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.contains(event.target))) onOpenChange === null || onOpenChange === void 0 || onOpenChange(false);
20850
+ if (event.target instanceof Node && !((_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.contains(event.target))) handleOpenChange(false);
20752
20851
  };
20753
20852
  document.addEventListener("pointerdown", handlePointerDown);
20754
20853
  return () => document.removeEventListener("pointerdown", handlePointerDown);
20755
20854
  }, [
20855
+ handleOpenChange,
20756
20856
  mode,
20757
- onOpenChange,
20758
20857
  open
20759
20858
  ]);
20760
20859
  const handleKeyDown = (event) => {
@@ -20763,7 +20862,7 @@ const SideMenu = forwardRef((props, ref) => {
20763
20862
  var _toggleRef$current;
20764
20863
  event.preventDefault();
20765
20864
  event.stopPropagation();
20766
- onOpenChange === null || onOpenChange === void 0 || onOpenChange(false);
20865
+ handleOpenChange(false);
20767
20866
  (_toggleRef$current = toggleRef.current) === null || _toggleRef$current === void 0 || _toggleRef$current.focus();
20768
20867
  return;
20769
20868
  }
@@ -20792,51 +20891,47 @@ const SideMenu = forwardRef((props, ref) => {
20792
20891
  };
20793
20892
  return /* @__PURE__ */ jsxs("div", {
20794
20893
  ref: wrapperRef,
20795
- className: clsx("univer-relative univer-ml-3", wrapperClass),
20894
+ className: clsx("univer-relative univer-ms-4", wrapperClass),
20796
20895
  style: {
20797
- width,
20896
+ width: open ? width : 32,
20798
20897
  ...wrapperStyle
20799
20898
  },
20800
20899
  onKeyDown: handleKeyDown,
20801
- children: [/* @__PURE__ */ jsx("button", {
20900
+ children: [/* @__PURE__ */ jsx(Button, {
20802
20901
  ref: toggleRef,
20803
20902
  type: "button",
20903
+ variant: "ghost",
20904
+ size: "icon",
20804
20905
  "aria-label": label,
20805
20906
  "aria-expanded": !!open,
20806
20907
  "aria-controls": open ? panelId : void 0,
20807
20908
  title: label,
20808
- onClick: () => onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(!open),
20809
- className: clsx("univer-absolute univer-top-1.5 univer-z-10 univer-flex univer-size-8 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-md univer-border-0 univer-bg-gray-0 univer-text-gray-500 univer-transition-colors hover:univer-bg-gray-100 hover:univer-text-gray-900 focus-visible:univer-outline focus-visible:univer-outline-2 focus-visible:univer-outline-primary-600 dark:univer-bg-gray-900 dark:univer-text-gray-400 dark:hover:univer-bg-gray-800", !open && "univer-shadow-sm", iconClass),
20810
- style: {
20811
- left: open ? width - 40 : 0,
20812
- ...iconStyle
20813
- },
20814
- children: open ? /* @__PURE__ */ jsx(MoreLeftIcon, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(CatalogueIcon, { "aria-hidden": "true" })
20815
- }), open && /* @__PURE__ */ jsxs("nav", {
20909
+ onClick: () => handleOpenChange(!open),
20910
+ className: clsx("univer-absolute univer-start-0 univer-top-0 univer-z-10 !univer-text-gray-500 hover:!univer-text-gray-900 focus-visible:univer-outline focus-visible:univer-outline-2 focus-visible:univer-outline-primary-600 dark:!univer-text-gray-400 dark:hover:!univer-text-gray-100", iconClass),
20911
+ style: iconStyle,
20912
+ children: open ? /* @__PURE__ */ jsx(MoreLeftIcon, {
20913
+ "aria-hidden": "true",
20914
+ className: "!univer-size-6"
20915
+ }) : /* @__PURE__ */ jsx(CatalogueIcon, {
20916
+ "aria-hidden": "true",
20917
+ className: "!univer-size-5"
20918
+ })
20919
+ }), open && /* @__PURE__ */ jsx("nav", {
20816
20920
  id: panelId,
20817
20921
  "aria-label": label,
20818
- className: clsx("univer-box-border univer-flex univer-w-full univer-flex-col univer-overflow-hidden univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-text-gray-700 dark:univer-border-gray-700 dark:univer-bg-gray-900 dark:univer-text-gray-200", mode === "float" ? "univer-shadow-md" : "univer-shadow-sm", className),
20922
+ className: clsx("univer-box-border univer-flex univer-w-full univer-flex-col univer-overflow-hidden univer-pt-10", mode === "float" && "univer-bg-gray-0 dark:univer-bg-gray-900", className),
20819
20923
  style: {
20820
20924
  maxHeight,
20821
20925
  ...style
20822
20926
  },
20823
- children: [/* @__PURE__ */ jsxs("div", {
20824
- className: "univer-flex univer-h-11 univer-shrink-0 univer-items-center univer-gap-2 univer-px-3 univer-pr-12 univer-text-xs univer-font-medium univer-text-gray-500 dark:univer-text-gray-400",
20825
- children: [/* @__PURE__ */ jsx(CatalogueIcon, {
20826
- "aria-hidden": "true",
20827
- className: "univer-shrink-0 univer-text-sm"
20828
- }), /* @__PURE__ */ jsx("span", {
20829
- className: "univer-truncate",
20830
- children: label
20831
- })]
20832
- }), /* @__PURE__ */ jsx("div", {
20927
+ children: /* @__PURE__ */ jsx("div", {
20833
20928
  ref: containerRef,
20834
- className: clsx("univer-relative univer-min-h-0 univer-overflow-y-auto univer-overscroll-contain univer-px-2 univer-pb-2", scrollbarClassName),
20929
+ className: clsx("univer-relative univer-min-h-0 univer-overflow-y-auto univer-overscroll-contain univer-pb-2", scrollbarClassName),
20835
20930
  children: /* @__PURE__ */ jsx("ol", {
20836
20931
  className: "univer-m-0 univer-list-none univer-p-0",
20837
20932
  children: menus === null || menus === void 0 ? void 0 : menus.map((menu) => /* @__PURE__ */ jsx("li", {
20838
- className: menu.isTitle ? "univer-mb-1 univer-pb-1" : void 0,
20839
- children: /* @__PURE__ */ jsxs("button", {
20933
+ className: menu.isTitle ? "univer-mb-2" : void 0,
20934
+ children: /* @__PURE__ */ jsx("button", {
20840
20935
  ref: (element) => {
20841
20936
  if (element) itemsRef.current.set(menu.id, element);
20842
20937
  else itemsRef.current.delete(menu.id);
@@ -20844,39 +20939,28 @@ const SideMenu = forwardRef((props, ref) => {
20844
20939
  type: "button",
20845
20940
  "aria-current": menu.id === activeId ? "location" : void 0,
20846
20941
  title: menu.text,
20847
- className: clsx("univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded univer-border-0 univer-bg-transparent univer-py-1.5 univer-pr-2 univer-text-left univer-text-sm univer-leading-5 univer-transition-colors hover:univer-bg-gray-100 focus-visible:univer-outline focus-visible:univer-outline-2 focus-visible:-univer-outline-offset-2 focus-visible:univer-outline-primary-600 dark:hover:univer-bg-gray-800", menu.isTitle ? "univer-font-semibold" : "univer-font-normal", {
20848
- "univer-bg-primary-50 univer-text-primary-700 hover:univer-bg-primary-50 dark:univer-bg-gray-700 dark:univer-text-primary-200 dark:hover:univer-bg-gray-700": menu.id === activeId,
20849
- "univer-text-gray-900 dark:univer-text-gray-100": menu.isTitle && menu.id !== activeId,
20850
- "univer-text-gray-600 dark:univer-text-gray-300": !menu.isTitle && menu.id !== activeId
20942
+ className: clsx("univer-box-border univer-flex univer-min-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-border-0 univer-bg-transparent univer-py-1.5 univer-pe-2 univer-text-start univer-text-sm univer-leading-5 univer-transition-colors focus-visible:univer-outline focus-visible:univer-outline-2 focus-visible:-univer-outline-offset-2 focus-visible:univer-outline-primary-600", menu.isTitle ? "univer-font-medium" : "univer-font-normal", {
20943
+ "univer-text-primary-600 dark:univer-text-primary-400": menu.id === activeId,
20944
+ "univer-text-gray-600 hover:univer-text-gray-900 dark:univer-text-gray-300 dark:hover:univer-text-gray-100": menu.isTitle && menu.id !== activeId,
20945
+ "univer-text-gray-500 hover:univer-text-gray-900 dark:univer-text-gray-400 dark:hover:univer-text-gray-100": !menu.isTitle && menu.id !== activeId
20851
20946
  }),
20852
- style: { paddingLeft: 10 + Math.max(0, menu.level - 1) * 12 },
20947
+ style: { paddingInlineStart: menu.isTitle ? 0 : 12 + Math.max(0, menu.level - 1) * 12 },
20853
20948
  onClick: () => {
20854
20949
  onClick === null || onClick === void 0 || onClick(menu);
20855
20950
  if (mode === "float") {
20856
20951
  var _toggleRef$current2;
20857
- onOpenChange === null || onOpenChange === void 0 || onOpenChange(false);
20952
+ handleOpenChange(false);
20858
20953
  (_toggleRef$current2 = toggleRef.current) === null || _toggleRef$current2 === void 0 || _toggleRef$current2.focus();
20859
20954
  }
20860
20955
  },
20861
- children: [
20862
- menu.level > 1 && /* @__PURE__ */ jsx("span", {
20863
- "aria-hidden": "true",
20864
- className: "univer-absolute univer-bottom-0 univer-top-0 univer-w-px univer-bg-gray-200 dark:univer-bg-gray-700",
20865
- style: { left: 14 + Math.max(0, menu.level - 2) * 12 }
20866
- }),
20867
- menu.id === activeId && /* @__PURE__ */ jsx("span", {
20868
- "aria-hidden": "true",
20869
- className: "univer-absolute univer-bottom-2 univer-left-0 univer-top-2 univer-w-0.5 univer-rounded-full univer-bg-primary-600 dark:univer-bg-primary-400"
20870
- }),
20871
- /* @__PURE__ */ jsx("span", {
20872
- className: menu.isTitle ? "univer-line-clamp-2 univer-break-words" : "univer-truncate",
20873
- children: menu.text
20874
- })
20875
- ]
20956
+ children: /* @__PURE__ */ jsx("span", {
20957
+ className: menu.isTitle ? "univer-line-clamp-2 univer-break-words" : "univer-truncate",
20958
+ children: menu.text
20959
+ })
20876
20960
  })
20877
20961
  }, menu.id))
20878
20962
  })
20879
- })]
20963
+ })
20880
20964
  })]
20881
20965
  });
20882
20966
  });
@@ -20898,52 +20982,77 @@ function findActiveHeading(boundMap, paragraphMap, scrollTop, bottom) {
20898
20982
  if (!boundMap) return;
20899
20983
  const paragraphBounds = Array.from(boundMap.values());
20900
20984
  const paragraphIndex = paragraphBounds.findIndex((p) => p.paragraphStart !== p.paragraphEnd && p.rect.top < bottom && p.rect.bottom > scrollTop);
20901
- if (paragraphIndex === -1) return void 0;
20902
- const lastParagraphIndex = paragraphBounds === null || paragraphBounds === void 0 ? void 0 : paragraphBounds.findLastIndex((p) => p.paragraphStart !== p.paragraphEnd && p.rect.top < bottom && p.rect.bottom > scrollTop);
20985
+ if (paragraphIndex === -1) return;
20986
+ let lastParagraphIndex = paragraphBounds.length - 1;
20987
+ while (lastParagraphIndex > paragraphIndex) {
20988
+ const bound = paragraphBounds[lastParagraphIndex];
20989
+ if (bound.paragraphStart !== bound.paragraphEnd && bound.rect.top < bottom && bound.rect.bottom > scrollTop) break;
20990
+ lastParagraphIndex--;
20991
+ }
20903
20992
  for (let i = paragraphIndex; i <= lastParagraphIndex; i++) {
20904
- var _paragraph$paragraphS;
20905
20993
  const bound = paragraphBounds[i];
20906
20994
  const paragraph = paragraphMap.get(bound.startIndex);
20907
- if (paragraph === null || paragraph === void 0 || (_paragraph$paragraphS = paragraph.paragraphStyle) === null || _paragraph$paragraphS === void 0 ? void 0 : _paragraph$paragraphS.headingId) return paragraph.paragraphStyle.headingId;
20995
+ if (paragraph) return paragraph.paragraphId;
20908
20996
  }
20909
20997
  for (let i = paragraphIndex; i >= 0; i--) {
20910
- var _paragraph$paragraphS2;
20911
20998
  const bound = paragraphBounds[i];
20912
20999
  const paragraph = paragraphMap.get(bound.startIndex);
20913
- if (paragraph === null || paragraph === void 0 || (_paragraph$paragraphS2 = paragraph.paragraphStyle) === null || _paragraph$paragraphS2 === void 0 ? void 0 : _paragraph$paragraphS2.headingId) return paragraph.paragraphStyle.headingId;
21000
+ if (paragraph) return paragraph.paragraphId;
20914
21001
  }
20915
21002
  }
20916
21003
  const TITLE_ID = "__title";
20917
21004
  function DocSideMenu() {
20918
21005
  const config = useConfigValue(DOCS_UI_PLUGIN_CONFIG_KEY);
20919
21006
  const workbenchService = useDependency(IWorkbenchService);
20920
- if (useObservable(workbenchService.rootUnitType$, null, true) === UniverInstanceType.UNIVER_DOC && (config === null || config === void 0 ? void 0 : config.toc)) return /* @__PURE__ */ jsx(DocSideMenuContent, {});
21007
+ if (useObservable(workbenchService.rootUnitType$, null, true) === UniverInstanceType.UNIVER_DOC && (config === null || config === void 0 ? void 0 : config.toc) !== false) return /* @__PURE__ */ jsx(DocSideMenuContent, { toc: config === null || config === void 0 ? void 0 : config.toc });
20921
21008
  return null;
20922
21009
  }
20923
- function DocSideMenuContent() {
20924
- var _documentData$body, _documentData$body3;
21010
+ function DocSideMenuContent({ toc }) {
21011
+ var _currentDoc$getSnapsh, _documentData$body, _documentData$body3, _menus$find;
20925
21012
  const instanceService = useDependency(IUniverInstanceService);
20926
21013
  const localeService = useDependency(LocaleService);
20927
21014
  const currentDoc = useObservable(() => instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC), void 0, false, [instanceService]);
21015
+ const enabled = toc ?? (currentDoc === null || currentDoc === void 0 || (_currentDoc$getSnapsh = currentDoc.getSnapshot().documentStyle) === null || _currentDoc$getSnapsh === void 0 ? void 0 : _currentDoc$getSnapsh.documentFlavor) === DocumentFlavor.MODERN;
20928
21016
  const renderManagerService = useDependency(IRenderManagerService);
20929
21017
  const documentData = useObservable(currentDoc ? () => currentDoc.change$.pipe(debounceTime(100), map(() => currentDoc.getSnapshot())) : null, currentDoc === null || currentDoc === void 0 ? void 0 : currentDoc.getSnapshot(), false, [currentDoc]);
20930
21018
  const fullDataStream = (documentData === null || documentData === void 0 || (_documentData$body = documentData.body) === null || _documentData$body === void 0 ? void 0 : _documentData$body.dataStream) ?? "";
20931
21019
  const [activeId, setActiveId] = useState(void 0);
21020
+ const [outlineHeight, setOutlineHeight] = useState(0);
21021
+ const containerRef = useRef(null);
20932
21022
  const unitId = (currentDoc === null || currentDoc === void 0 ? void 0 : currentDoc.getUnitId()) ?? "";
20933
21023
  const renderer = renderManagerService.getRenderUnitById(unitId);
20934
21024
  const title = documentData === null || documentData === void 0 ? void 0 : documentData.title;
20935
21025
  const docEventManagerService = renderer === null || renderer === void 0 ? void 0 : renderer.with(DocEventManagerService);
20936
- const paragraphBounds = docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.paragraphBounds;
21026
+ const viewport = renderer === null || renderer === void 0 ? void 0 : renderer.scene.getViewport("viewMain");
20937
21027
  const readLayout = () => {
20938
21028
  var _renderer$mainCompone;
21029
+ const scaleX = (renderer === null || renderer === void 0 ? void 0 : renderer.scene.scaleX) ?? 1;
21030
+ const scaleY = (renderer === null || renderer === void 0 ? void 0 : renderer.scene.scaleY) ?? 1;
21031
+ const scrollX = (viewport === null || viewport === void 0 ? void 0 : viewport.viewportScrollX) ?? 0;
21032
+ const scrollY = (viewport === null || viewport === void 0 ? void 0 : viewport.viewportScrollY) ?? 0;
21033
+ const canvasHeight = (renderer === null || renderer === void 0 ? void 0 : renderer.engine.height) ?? 0;
21034
+ const left = (((renderer === null || renderer === void 0 || (_renderer$mainCompone = renderer.mainComponent) === null || _renderer$mainCompone === void 0 ? void 0 : _renderer$mainCompone.left) ?? 0) - scrollX) * scaleX;
21035
+ const outlineRect = {
21036
+ left: scrollX + 16 / scaleX,
21037
+ right: scrollX + 272 / scaleX,
21038
+ top: scrollY + 16 / scaleY,
21039
+ bottom: scrollY + Math.min(canvasHeight - 16, 16 + outlineHeight) / scaleY
21040
+ };
21041
+ const overlapsTable = left >= 288 && outlineHeight > 0 && Array.from((docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.tableBounds.values()) ?? []).some(({ tableId, rect }) => isDocSideMenuTableOverlapping(outlineRect, rect, getDocsTableRenderViewport(unitId, getTableIdAndSliceIndex(tableId).tableId)));
20939
21042
  return {
20940
- left: (renderer === null || renderer === void 0 || (_renderer$mainCompone = renderer.mainComponent) === null || _renderer$mainCompone === void 0 ? void 0 : _renderer$mainCompone.left) ?? 0,
20941
- canvasHeight: (renderer === null || renderer === void 0 ? void 0 : renderer.engine.height) ?? 0,
21043
+ left,
21044
+ canvasHeight,
20942
21045
  canvasWidth: (renderer === null || renderer === void 0 ? void 0 : renderer.engine.width) ?? 0,
20943
- scaleY: (renderer === null || renderer === void 0 ? void 0 : renderer.scene.scaleY) ?? 1
21046
+ scaleY,
21047
+ overlapsTable
20944
21048
  };
20945
21049
  };
20946
- const { left, canvasHeight, canvasWidth, scaleY } = useObservable((renderer === null || renderer === void 0 ? void 0 : renderer.engine.onTransformChange$) ? () => merge$1(fromEventSubject(renderer.engine.onTransformChange$), ...renderer.mainComponent ? [fromEventSubject(renderer.mainComponent.onTransformChange$)] : []).pipe(auditTime(33), map(readLayout), startWith(readLayout())) : null, readLayout(), false, [renderer]);
21050
+ const layout = useObservable((renderer === null || renderer === void 0 ? void 0 : renderer.engine.onTransformChange$) ? () => merge$1(fromEventSubject(renderer.engine.onTransformChange$), fromEventSubject(renderer.scene.onTransformChange$), ...renderer.mainComponent instanceof Documents ? [renderer.mainComponent.pageRender$] : [], ...viewport ? [fromEventSubject(viewport.onScrollAfter$)] : [], ...renderer.mainComponent ? [fromEventSubject(renderer.mainComponent.onTransformChange$)] : []).pipe(auditTime(33), map(readLayout), startWith(readLayout()), distinctUntilChanged((previous, current) => previous.left === current.left && previous.canvasHeight === current.canvasHeight && previous.canvasWidth === current.canvasWidth && previous.scaleY === current.scaleY && previous.overlapsTable === current.overlapsTable)) : null, readLayout(), false, [
21051
+ renderer,
21052
+ viewport,
21053
+ outlineHeight
21054
+ ]);
21055
+ const { left, canvasHeight, canvasWidth, scaleY } = layout;
20947
21056
  const paragraphs = useMemo(() => {
20948
21057
  var _documentData$body2;
20949
21058
  return (documentData === null || documentData === void 0 || (_documentData$body2 = documentData.body) === null || _documentData$body2 === void 0 ? void 0 : _documentData$body2.paragraphs) ?? [];
@@ -20952,22 +21061,26 @@ function DocSideMenuContent() {
20952
21061
  dataStream: fullDataStream,
20953
21062
  paragraphs
20954
21063
  }), [fullDataStream, paragraphs]);
21064
+ const headingParagraphs = useMemo(() => paragraphs.filter((p) => {
21065
+ var _p$paragraphStyle;
21066
+ return ((_p$paragraphStyle = p.paragraphStyle) === null || _p$paragraphStyle === void 0 ? void 0 : _p$paragraphStyle.namedStyleType) !== void 0 && p.paragraphStyle.namedStyleType !== NamedStyleType.SUBTITLE && p.paragraphStyle.namedStyleType !== NamedStyleType.NORMAL_TEXT;
21067
+ }).map((p) => p.paragraphId ? p : {
21068
+ ...p,
21069
+ paragraphId: `__paragraph_${p.startIndex}`
21070
+ }), [paragraphs]);
20955
21071
  const paragraphMap = useMemo(() => {
20956
21072
  const map = /* @__PURE__ */ new Map();
20957
- paragraphs.forEach((p) => {
21073
+ headingParagraphs.forEach((p) => {
20958
21074
  map.set(p.startIndex, p);
20959
21075
  });
20960
21076
  return map;
20961
- }, [paragraphs]);
20962
- const mode = left < 240 ? "float" : "side-bar";
20963
- const paragraphMenus = paragraphs === null || paragraphs === void 0 ? void 0 : paragraphs.filter((p) => {
20964
- var _p$paragraphStyle;
20965
- return ((_p$paragraphStyle = p.paragraphStyle) === null || _p$paragraphStyle === void 0 ? void 0 : _p$paragraphStyle.namedStyleType) !== void 0 && p.paragraphStyle.namedStyleType !== NamedStyleType.SUBTITLE && p.paragraphStyle.namedStyleType !== NamedStyleType.NORMAL_TEXT;
20966
- }).map((p) => {
21077
+ }, [headingParagraphs]);
21078
+ const mode = left < 288 || layout.overlapsTable ? "float" : "side-bar";
21079
+ const paragraphMenus = headingParagraphs.map((p) => {
20967
21080
  var _p$paragraphStyle2;
20968
21081
  const level = transformNamedStyleTypeToLevel(p.paragraphStyle.namedStyleType);
20969
21082
  return {
20970
- id: p.paragraphStyle.headingId,
21083
+ id: p.paragraphId,
20971
21084
  text: getPlainText(fullDataStream.slice(paragraphStarts.get(p.startIndex), p.startIndex)),
20972
21085
  level,
20973
21086
  isTitle: ((_p$paragraphStyle2 = p.paragraphStyle) === null || _p$paragraphStyle2 === void 0 ? void 0 : _p$paragraphStyle2.namedStyleType) === NamedStyleType.TITLE
@@ -20976,7 +21089,7 @@ function DocSideMenuContent() {
20976
21089
  const handleScroll = useEvent((params) => {
20977
21090
  const scrollTop = params.viewportScrollY;
20978
21091
  const bottom = scrollTop + canvasHeight / scaleY;
20979
- const activeId = findActiveHeading(paragraphBounds, paragraphMap, scrollTop, bottom);
21092
+ const activeId = findActiveHeading(docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.paragraphBounds, paragraphMap, scrollTop, bottom);
20980
21093
  if (activeId) setActiveId(activeId);
20981
21094
  });
20982
21095
  const menus = (paragraphMenus === null || paragraphMenus === void 0 ? void 0 : paragraphMenus.find((p) => p.isTitle)) ? paragraphMenus : [...title ? [{
@@ -20985,7 +21098,32 @@ function DocSideMenuContent() {
20985
21098
  level: 1,
20986
21099
  isTitle: true
20987
21100
  }] : [], ...paragraphMenus ?? []].filter(Boolean);
20988
- const [open, setOpen] = useState(true);
21101
+ const outlineTitle = (_menus$find = menus.find((menu) => menu.isTitle)) === null || _menus$find === void 0 ? void 0 : _menus$find.text;
21102
+ useLayoutEffect(() => {
21103
+ setOutlineHeight(0);
21104
+ }, [
21105
+ unitId,
21106
+ menus.length,
21107
+ outlineTitle
21108
+ ]);
21109
+ useLayoutEffect(() => {
21110
+ const container = containerRef.current;
21111
+ const menu = container === null || container === void 0 ? void 0 : container.firstElementChild;
21112
+ if (!container || !menu) return;
21113
+ const measureOutline = () => {
21114
+ var _container$querySelec;
21115
+ const height = (_container$querySelec = container.querySelector("nav")) === null || _container$querySelec === void 0 ? void 0 : _container$querySelec.getBoundingClientRect().height;
21116
+ if (height) setOutlineHeight(height);
21117
+ };
21118
+ const observer = new ResizeObserver(measureOutline);
21119
+ observer.observe(menu);
21120
+ return () => observer.disconnect();
21121
+ }, [
21122
+ mode,
21123
+ unitId,
21124
+ menus.length,
21125
+ enabled
21126
+ ]);
20989
21127
  useEffect(() => {
20990
21128
  const viewport = renderer === null || renderer === void 0 ? void 0 : renderer.scene.getViewport("viewMain");
20991
21129
  if (!viewport) return;
@@ -21002,31 +21140,27 @@ function DocSideMenuContent() {
21002
21140
  setActiveId(menu.id);
21003
21141
  return;
21004
21142
  }
21005
- const paragraph = paragraphs.find((p) => {
21006
- var _p$paragraphStyle3;
21007
- return ((_p$paragraphStyle3 = p.paragraphStyle) === null || _p$paragraphStyle3 === void 0 ? void 0 : _p$paragraphStyle3.headingId) === menu.id;
21008
- });
21143
+ const paragraph = headingParagraphs.find((p) => p.paragraphId === menu.id);
21009
21144
  if (!paragraph) return;
21010
- const bound = paragraphBounds === null || paragraphBounds === void 0 ? void 0 : paragraphBounds.get(paragraph.startIndex);
21145
+ const bound = docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.paragraphBounds.get(paragraph.startIndex);
21011
21146
  if (!bound) return;
21012
21147
  viewport.scrollToViewportPos({ viewportScrollY: bound.rect.top });
21013
21148
  setActiveId(menu.id);
21014
21149
  });
21015
- if (!currentDoc || isInternalEditorID(unitId) || !(menus === null || menus === void 0 ? void 0 : menus.length)) return null;
21150
+ if (!enabled || !currentDoc || isInternalEditorID(unitId) || !(menus === null || menus === void 0 ? void 0 : menus.length)) return null;
21016
21151
  return /* @__PURE__ */ jsx("div", {
21152
+ ref: containerRef,
21017
21153
  className: "univer-absolute univer-bottom-0 univer-left-0 univer-top-0 univer-z-[100] univer-w-[0px]",
21018
21154
  children: /* @__PURE__ */ jsx(SideMenu, {
21019
21155
  label: localeService.t("docs-ui.outline.title"),
21020
21156
  menus,
21021
- open,
21022
- onOpenChange: setOpen,
21023
21157
  mode,
21024
21158
  maxWidth: Math.max(0, Math.floor(mode === "float" ? canvasWidth : left) - 24),
21025
21159
  wrapperClass: "univer-mt-4",
21026
21160
  activeId,
21027
21161
  onClick: handleClick,
21028
21162
  maxHeight: Math.max(0, canvasHeight - 32)
21029
- })
21163
+ }, mode)
21030
21164
  });
21031
21165
  }
21032
21166
 
@@ -21404,7 +21538,7 @@ function resolveDocsCustomBlockRenderViewport(params) {
21404
21538
  //#endregion
21405
21539
  //#region package.json
21406
21540
  var name = "@univerjs/docs-ui";
21407
- var version = "1.1.0";
21541
+ var version = "1.3.0";
21408
21542
 
21409
21543
  //#endregion
21410
21544
  //#region src/commands/commands/doc-paragraph-setting.command.ts
@@ -22266,7 +22400,7 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
22266
22400
  }
22267
22401
  _deferUnmaterializedCursorMove(doc, skeleton, offset, segmentId, resume) {
22268
22402
  var _skeleton$getSkeleton, _render$getInjector, _doc$getBody;
22269
- if (segmentId !== "") return false;
22403
+ if (segmentId !== "" || skeleton.getViewModel().getCollapsedHeadingAtOffset(offset)) return false;
22270
22404
  const pageIndex = skeleton.findBodyPageIndexByCharIndex(offset);
22271
22405
  const page = (_skeleton$getSkeleton = skeleton.getSkeletonData()) === null || _skeleton$getSkeleton === void 0 ? void 0 : _skeleton$getSkeleton.pages[pageIndex];
22272
22406
  if (pageIndex >= 0 && !(page === null || page === void 0 ? void 0 : page.isMaterializationPlaceholder)) return false;
@@ -22375,6 +22509,13 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
22375
22509
  const visited = /* @__PURE__ */ new Set();
22376
22510
  while (current >= 0 && current < dataStream.length && !visited.has(current)) {
22377
22511
  visited.add(current);
22512
+ if (!segmentId) {
22513
+ const hidden = skeleton.getViewModel().getCollapsedHeadingAtOffset(current);
22514
+ if (hidden) {
22515
+ current = step < 0 ? hidden.paragraphIndex : hidden.endOffset;
22516
+ continue;
22517
+ }
22518
+ }
22378
22519
  const normalizedCursor = this._normalizeCursorOffset(dataStream, customRanges, current, direction);
22379
22520
  if (normalizedCursor < 0 || normalizedCursor >= dataStream.length) return;
22380
22521
  if (this._isRenderableCursorOffset(skeleton, dataStream, normalizedCursor, segmentId, segmentPage)) return normalizedCursor;
@@ -24656,6 +24797,7 @@ let MobileComponentsController = class MobileComponentsController extends Dispos
24656
24797
  }));
24657
24798
  }
24658
24799
  _registerComponents() {
24800
+ this.disposeWithMe(this._componentManager.register(EditorColorPicker.componentKey, EditorColorPicker));
24659
24801
  this.disposeWithMe(this._componentManager.register(COMPONENT_DOC_HEADER_FOOTER_PANEL, MobileHeaderFooterPanel));
24660
24802
  this.disposeWithMe(this._componentManager.register("doc_ui_paragraph-setting-panel", MobileParagraphSettings));
24661
24803
  this.disposeWithMe(this._componentManager.register(DOC_SECTION_SETTING_COMPONENT, MobileSectionSettings));
@@ -25188,8 +25330,10 @@ let DocMobileUIController = class DocMobileUIController extends Disposable {
25188
25330
  this.disposeWithMe(this._uiPartsService.registerComponent(BuiltInUIPart.HEADER_MENU, () => connectInjector(MobileDocEditDoneButton, this._injector)));
25189
25331
  }
25190
25332
  _initMenus() {
25333
+ const { [ContextMenuPosition.MAIN_AREA]: mainAreaMenu, ...rootMenus } = mobileMenuSchema;
25191
25334
  this._menuManagerService.mergeMenu(menuSchema);
25192
- this._menuManagerService.appendRootMenu(mobileMenuSchema);
25335
+ this._menuManagerService.mergeMenu({ [ContextMenuPosition.MAIN_AREA]: mainAreaMenu });
25336
+ this._menuManagerService.appendRootMenu(rootMenus);
25193
25337
  }
25194
25338
  _initFocusHandler() {
25195
25339
  this.disposeWithMe(this._layoutService.registerFocusHandler(UniverInstanceType.UNIVER_DOC, () => {}));
@@ -25997,6 +26141,9 @@ let DocResizeRenderController = class DocResizeRenderController extends Disposab
25997
26141
  this._initResize();
25998
26142
  }
25999
26143
  _initResize() {
26144
+ this.disposeWithMe(this._context.activated$.pipe(observeOn(animationFrameScheduler)).subscribe((activated) => {
26145
+ if (activated) this._refreshLayoutAndSelection();
26146
+ }));
26000
26147
  this.disposeWithMe(fromEventSubject(this._context.engine.onTransformChange$).pipe(throttleTime(0, animationFrameScheduler)).subscribe(() => this._refreshLayoutAndSelection()));
26001
26148
  this.disposeWithMe(this._sidebarService.sidebarOptions$.pipe(observeOn(animationFrameScheduler)).subscribe(() => this._refreshLayoutAndSelection()));
26002
26149
  }
@@ -27254,7 +27401,7 @@ let DocFloatMenuService = class DocFloatMenuService extends Disposable {
27254
27401
  this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe((selection) => {
27255
27402
  const { unitId, textRanges } = selection;
27256
27403
  if (unitId !== this._context.unitId) return;
27257
- if (this._suppressed || this._embedSuppressed || this._contextService.getContextValue(FOCUSING_COMMON_DRAWINGS)) {
27404
+ if (selection.isEditing || this._suppressed || this._embedSuppressed || this._contextService.getContextValue(FOCUSING_COMMON_DRAWINGS)) {
27258
27405
  this._hideFloatMenu();
27259
27406
  return;
27260
27407
  }
@@ -27541,6 +27688,10 @@ let MobileDocSelectionRenderService = class MobileDocSelectionRenderService exte
27541
27688
  this.disposeWithMe(this.textSelectionInner$.subscribe(() => this._syncMobileSelectionVisuals()));
27542
27689
  this._initMobileKeyboardViewport();
27543
27690
  }
27691
+ focus() {
27692
+ if ((this._context.unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY || this._context.unitId === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY) && this.isFocusing) return;
27693
+ super.focus();
27694
+ }
27544
27695
  cancelPointerSelection() {
27545
27696
  this._handleDragDisposables.dispose();
27546
27697
  super.cancelPointerSelection();
@@ -27581,10 +27732,11 @@ let MobileDocSelectionRenderService = class MobileDocSelectionRenderService exte
27581
27732
  }
27582
27733
  _syncMobileSelectionVisuals() {
27583
27734
  const activeRange = this._getActiveRangeInstance();
27735
+ const isInternalEditor = isInternalEditorID(this._context.unitId);
27584
27736
  this._selectionVisuals.hide();
27585
27737
  for (const range of this._rangeList) {
27586
27738
  const caret = range.getAnchor();
27587
- if (this.isEditing && range === activeRange) caret === null || caret === void 0 || caret.show();
27739
+ if ((this.isEditing || isInternalEditor) && range === activeRange) caret === null || caret === void 0 || caret.show();
27588
27740
  else caret === null || caret === void 0 || caret.hide();
27589
27741
  }
27590
27742
  if (!activeRange || activeRange.collapsed || this.isEditing) return;
@@ -27618,6 +27770,10 @@ let MobileDocSelectionRenderService = class MobileDocSelectionRenderService exte
27618
27770
  });
27619
27771
  }
27620
27772
  _handleInputBlur(event) {
27773
+ if (isInternalEditorID(this._context.unitId)) {
27774
+ super._handleInputBlur(event);
27775
+ return;
27776
+ }
27621
27777
  if (this.isEditing) {
27622
27778
  this._pendingBlurEvent = event;
27623
27779
  return;
@@ -28365,6 +28521,20 @@ const LIST_ICON_MAP = {
28365
28521
  [PresetListType.CHECK_LIST]: "TodoListDoubleIcon",
28366
28522
  [PresetListType.CHECK_LIST_CHECKED]: "TodoListDoubleIcon"
28367
28523
  };
28524
+ const PASSIVE_PARAGRAPH_MENU_KEYS = /* @__PURE__ */ new Set([
28525
+ "ArrowLeft",
28526
+ "ArrowRight",
28527
+ "ArrowUp",
28528
+ "ArrowDown",
28529
+ "Home",
28530
+ "End",
28531
+ "PageUp",
28532
+ "PageDown",
28533
+ "Shift",
28534
+ "Control",
28535
+ "Alt",
28536
+ "Meta"
28537
+ ]);
28368
28538
  let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28369
28539
  get activeParagraph() {
28370
28540
  var _this$_paragraphMenu;
@@ -28380,8 +28550,10 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28380
28550
  }
28381
28551
  setBlockMenuDragging(isDragging) {
28382
28552
  this._isBlockMenuDragging = isDragging;
28383
- if (isDragging) this._dragInteraction ??= this._docLayoutInteractionService.beginInteraction();
28384
- else {
28553
+ if (isDragging) {
28554
+ this._cancelParagraphMenuHide();
28555
+ this._dragInteraction ??= this._docLayoutInteractionService.beginInteraction();
28556
+ } else {
28385
28557
  var _this$_dragInteractio;
28386
28558
  (_this$_dragInteractio = this._dragInteraction) === null || _this$_dragInteractio === void 0 || _this$_dragInteractio.dispose();
28387
28559
  this._dragInteraction = null;
@@ -28403,6 +28575,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28403
28575
  this._docLayoutInteractionService = _docLayoutInteractionService;
28404
28576
  this._contextService = _contextService;
28405
28577
  _defineProperty(this, "_paragraphMenu", null);
28578
+ _defineProperty(this, "_paragraphMenuHideTimer", null);
28406
28579
  _defineProperty(this, "_activeTarget$", new BehaviorSubject(null));
28407
28580
  _defineProperty(this, "activeTarget$", this._activeTarget$.asObservable());
28408
28581
  _defineProperty(this, "_focusedTableMenu", null);
@@ -28428,13 +28601,6 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28428
28601
  if (this._focusedTableMenu && !this._canEditDocument(this._focusedTableMenu.target.menuRange)) this.hideFocusedTableMenu();
28429
28602
  }));
28430
28603
  }
28431
- _isCursorInActiveParagraph() {
28432
- if (!this._paragraphMenu) return false;
28433
- const activeTextRange = this._docSelectionManagerService.getActiveTextRange();
28434
- if (!(activeTextRange === null || activeTextRange === void 0 ? void 0 : activeTextRange.collapsed)) return false;
28435
- if (!(activeTextRange === null || activeTextRange === void 0 ? void 0 : activeTextRange.collapsed) || activeTextRange.startOffset < this._paragraphMenu.paragraph.paragraphStart || activeTextRange.startOffset > this._paragraphMenu.paragraph.paragraphEnd) return false;
28436
- return true;
28437
- }
28438
28604
  _getExpandedSelectionState(ranges) {
28439
28605
  return ranges.reduce((state, range) => {
28440
28606
  if (range.rangeType === DOC_RANGE_TYPE.RECT) {
@@ -28464,6 +28630,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28464
28630
  }
28465
28631
  setParagraphMenuActive(active, focusedTable = false) {
28466
28632
  var _this$_paragraphMenu3, _this$_focusedTableMe2;
28633
+ if (active && !focusedTable) this._cancelParagraphMenuHide();
28467
28634
  const menu = focusedTable ? this._focusedTableMenu : this._paragraphMenu;
28468
28635
  if (menu) menu.active = active;
28469
28636
  if (((_this$_paragraphMenu3 = this._paragraphMenu) === null || _this$_paragraphMenu3 === void 0 ? void 0 : _this$_paragraphMenu3.active) || ((_this$_focusedTableMe2 = this._focusedTableMenu) === null || _this$_focusedTableMe2 === void 0 ? void 0 : _this$_focusedTableMe2.active)) this._menuInteraction ??= this._docLayoutInteractionService.beginInteraction();
@@ -28478,10 +28645,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28478
28645
  var _this$_focusedTableMe3;
28479
28646
  if (this._isBlockMenuDragging) return;
28480
28647
  if ((_this$_focusedTableMe3 = this._focusedTableMenu) === null || _this$_focusedTableMe3 === void 0 ? void 0 : _this$_focusedTableMe3.active) return;
28481
- if (this._docSelectionRenderService.isOnPointerEvent) {
28482
- this.hideParagraphMenu(true);
28483
- return;
28484
- }
28648
+ if (this._docSelectionRenderService.isOnPointerEvent) return;
28485
28649
  const selectionState = this._getExpandedSelectionState(this._docSelectionManagerService.getDocRanges());
28486
28650
  if (selectionState.hasExpandedTextRange) {
28487
28651
  this.hideParagraphMenu(true);
@@ -28508,6 +28672,8 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28508
28672
  this.showTableMenu(tableBound);
28509
28673
  return;
28510
28674
  }
28675
+ this._scheduleParagraphMenuHide();
28676
+ return;
28511
28677
  }
28512
28678
  this.hideParagraphMenu(true);
28513
28679
  };
@@ -28522,6 +28688,9 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28522
28688
  handleHoverTarget(p ?? left, table);
28523
28689
  }));
28524
28690
  this.disposeWithMe(this._docSelectionRenderService.onSelectionStart$.subscribe(() => {
28691
+ this._cancelParagraphMenuHide();
28692
+ }));
28693
+ this.disposeWithMe(this._docSelectionRenderService.movingSelection$.subscribe(() => {
28525
28694
  this.hideParagraphMenu(true);
28526
28695
  }));
28527
28696
  this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe(({ textRanges, rectRanges }) => {
@@ -28531,13 +28700,13 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28531
28700
  }));
28532
28701
  let lastScrollY = 0;
28533
28702
  this.disposeWithMe(this._context.scene.getViewport("viewMain").onScrollAfter$.subscribeEvent((e) => {
28534
- var _this$_paragraphMenu7;
28703
+ var _this$_paragraphMenu7, _this$_paragraphMenu8;
28535
28704
  if (lastScrollY === e.scrollY) return;
28536
28705
  lastScrollY = e.scrollY;
28537
28706
  this._focusedTableMenuDismiss$.next();
28538
28707
  if ((_this$_paragraphMenu7 = this._paragraphMenu) === null || _this$_paragraphMenu7 === void 0 ? void 0 : _this$_paragraphMenu7.blockRange) return;
28539
28708
  if (this._isBlockMenuDragging) return;
28540
- this.hideParagraphMenu(true);
28709
+ if ((_this$_paragraphMenu8 = this._paragraphMenu) === null || _this$_paragraphMenu8 === void 0 ? void 0 : _this$_paragraphMenu8.active) this.hideParagraphMenu(true);
28541
28710
  }));
28542
28711
  this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(() => {
28543
28712
  if (this._isBlockMenuDragging) return;
@@ -28547,6 +28716,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28547
28716
  if (this._isBlockMenuDragging) return;
28548
28717
  if (this._handleSlashMenuKeydown(config)) return;
28549
28718
  this._focusedTableMenuDismiss$.next();
28719
+ if (PASSIVE_PARAGRAPH_MENU_KEYS.has(config.event.key)) return;
28550
28720
  this.hideParagraphMenu(true);
28551
28721
  }));
28552
28722
  this.disposeWithMe(this._docSelectionRenderService.onInputBefore$.subscribe((config) => {
@@ -28602,10 +28772,10 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28602
28772
  return null;
28603
28773
  }
28604
28774
  _getSlashMenuParagraph(config) {
28605
- var _this$_paragraphMenu8;
28775
+ var _this$_paragraphMenu9;
28606
28776
  const activeRange = this._getCollapsedTextRange(config);
28607
28777
  const offset = activeRange === null || activeRange === void 0 ? void 0 : activeRange.startOffset;
28608
- const activeParagraph = ((_this$_paragraphMenu8 = this._paragraphMenu) === null || _this$_paragraphMenu8 === void 0 ? void 0 : _this$_paragraphMenu8.paragraph) ?? null;
28778
+ const activeParagraph = ((_this$_paragraphMenu9 = this._paragraphMenu) === null || _this$_paragraphMenu9 === void 0 ? void 0 : _this$_paragraphMenu9.paragraph) ?? null;
28609
28779
  if (activeParagraph && offset != null && offset >= activeParagraph.paragraphStart && offset <= activeParagraph.paragraphEnd) return activeParagraph;
28610
28780
  if (activeParagraph && offset == null) return activeParagraph;
28611
28781
  if (offset == null) return null;
@@ -28626,7 +28796,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28626
28796
  }
28627
28797
  }
28628
28798
  showParagraphMenu(paragraph) {
28629
- var _this$_paragraphMenu9;
28799
+ var _this$_paragraphMenu10;
28630
28800
  if (this._hasExpandedSelection()) {
28631
28801
  this.hideParagraphMenu(true);
28632
28802
  return;
@@ -28636,43 +28806,27 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28636
28806
  this.hideParagraphMenu(true);
28637
28807
  return;
28638
28808
  }
28639
- if (((_this$_paragraphMenu9 = this._paragraphMenu) === null || _this$_paragraphMenu9 === void 0 ? void 0 : _this$_paragraphMenu9.target.key) === target.key) return;
28640
- this.hideParagraphMenu(true);
28809
+ this._cancelParagraphMenuHide();
28810
+ if (((_this$_paragraphMenu10 = this._paragraphMenu) === null || _this$_paragraphMenu10 === void 0 ? void 0 : _this$_paragraphMenu10.target.key) === target.key) return;
28641
28811
  const targetParagraph = target.paragraph ?? paragraph;
28642
28812
  const blockRange = target.blockRange;
28643
28813
  const getFirstLine = () => {
28814
+ var _this$_context$unit$g;
28644
28815
  const latestParagraphBound = this._docEventManagerService.findParagraphBoundByIndex(targetParagraph.startIndex) ?? targetParagraph;
28645
28816
  const baseAnchor = blockRange ? getBlockRangeAnchorRect(this._docEventManagerService, blockRange, paragraph) : latestParagraphBound.firstLine ?? paragraph.firstLine;
28646
- if (!target.cellRange) return baseAnchor;
28647
- return getTableCellParagraphAnchorRect(this._docEventManagerService, latestParagraphBound, baseAnchor);
28648
- };
28649
- const disposable = this._docPopupManagerService.attachPopupToRect(getFirstLine, {
28650
- componentKey: DOC_PARAGRAPH_MENU_COMPONENT_KEY,
28651
- constrainToCanvas: true,
28652
- requiresStableLayout: false,
28653
- direction: "left-center",
28654
- onClickOutside: () => {
28655
- if (this._isSlashMenuActive) {
28656
- this.hideParagraphMenu(true);
28657
- return;
28658
- }
28659
- this._docSelectionManagerService.textSelection$.pipe(first()).subscribe(() => {
28660
- if (!this._isCursorInActiveParagraph()) this.hideParagraphMenu(true);
28661
- });
28662
- },
28663
- zIndex: 101
28664
- }, this._context.unitId);
28665
- this._paragraphMenu = {
28666
- paragraph: targetParagraph,
28667
- target,
28668
- blockRange,
28669
- disposable,
28670
- active: false
28817
+ const menuAnchor = ((_this$_context$unit$g = this._context.unit.getSnapshot().documentStyle) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.documentFlavor) === DocumentFlavor.MODERN && this._docSkeletonManagerService.getViewModel().getHeadingSections().some((heading) => heading.paragraphIndex === targetParagraph.startIndex && heading.startOffset < heading.endOffset) ? {
28818
+ ...baseAnchor,
28819
+ left: baseAnchor.left - 24,
28820
+ right: baseAnchor.right - 24
28821
+ } : baseAnchor;
28822
+ if (!target.cellRange) return menuAnchor;
28823
+ return getTableCellParagraphAnchorRect(this._docEventManagerService, latestParagraphBound, menuAnchor);
28671
28824
  };
28672
- this._activeTarget$.next(target);
28825
+ this._showHoverMenu(targetParagraph, target, getFirstLine);
28673
28826
  }
28674
28827
  showTableMenu(tableBound, focused = false) {
28675
- var _this$_focusedTableMe4, _body$tables, _this$_paragraphMenu10;
28828
+ var _this$_focusedTableMe4, _body$tables, _this$_paragraphMenu11;
28829
+ if (!focused) this._cancelParagraphMenuHide();
28676
28830
  if (!focused && ((_this$_focusedTableMe4 = this._focusedTableMenu) === null || _this$_focusedTableMe4 === void 0 || (_this$_focusedTableMe4 = _this$_focusedTableMe4.target.table) === null || _this$_focusedTableMe4 === void 0 ? void 0 : _this$_focusedTableMe4.tableId) === tableBound.tableId) return;
28677
28831
  if (!focused && this._hasExpandedTextSelection()) {
28678
28832
  this.hideParagraphMenu(true);
@@ -28710,7 +28864,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28710
28864
  return;
28711
28865
  }
28712
28866
  if (!focused && this._shouldKeepCurrentCellMenuForTable(table)) return;
28713
- if (!focused && ((_this$_paragraphMenu10 = this._paragraphMenu) === null || _this$_paragraphMenu10 === void 0 ? void 0 : _this$_paragraphMenu10.target.key) === target.key) return;
28867
+ if (!focused && ((_this$_paragraphMenu11 = this._paragraphMenu) === null || _this$_paragraphMenu11 === void 0 ? void 0 : _this$_paragraphMenu11.target.key) === target.key) return;
28714
28868
  const anchorRect = getTableAnchorRect(tableBound);
28715
28869
  const paragraph = {
28716
28870
  rect: tableBound.rect,
@@ -28726,31 +28880,47 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28726
28880
  this._showFocusedTableMenu(tableBound, target);
28727
28881
  return;
28728
28882
  }
28729
- this._showHoverTableMenu(tableBound, target, paragraph);
28730
- }
28731
- _showHoverTableMenu(tableBound, target, paragraph) {
28732
- this.hideParagraphMenu(true);
28733
28883
  const getFirstLine = () => getTableAnchorRect(this._docEventManagerService.tableBounds.get(tableBound.tableId) ?? tableBound);
28734
- const disposable = this._docPopupManagerService.attachPopupToRect(getFirstLine, {
28735
- componentKey: DOC_TABLE_BLOCK_MENU_COMPONENT_KEY,
28884
+ this._showHoverMenu(paragraph, target, getFirstLine);
28885
+ }
28886
+ _showHoverMenu(paragraph, target, getAnchor) {
28887
+ const menu = this._paragraphMenu;
28888
+ if ((menu === null || menu === void 0 ? void 0 : menu.active) && menu.target.kind === DocumentBlockType.TABLE !== (target.kind === DocumentBlockType.TABLE)) this.hideParagraphMenu(true);
28889
+ if (this._paragraphMenu) {
28890
+ this._paragraphMenu.paragraph = paragraph;
28891
+ this._paragraphMenu.target = target;
28892
+ this._paragraphMenu.blockRange = target.blockRange;
28893
+ this._paragraphMenu.getAnchor = getAnchor;
28894
+ this._activeTarget$.next(target);
28895
+ return;
28896
+ }
28897
+ const disposable = this._docPopupManagerService.attachPopupToRect(() => {
28898
+ var _this$_paragraphMenu12;
28899
+ return ((_this$_paragraphMenu12 = this._paragraphMenu) === null || _this$_paragraphMenu12 === void 0 ? void 0 : _this$_paragraphMenu12.getAnchor()) ?? getAnchor();
28900
+ }, {
28901
+ direction: target.kind === DocumentBlockType.TABLE ? "top-right" : "left-center",
28902
+ offset: target.kind === DocumentBlockType.TABLE ? [0, 0] : [8, 0],
28903
+ componentKey: DOC_PARAGRAPH_MENU_COMPONENT_KEY,
28904
+ positionChanges$: this.activeTarget$,
28736
28905
  constrainToCanvas: true,
28737
28906
  requiresStableLayout: false,
28738
- direction: "top-right",
28739
28907
  onClickOutside: () => {
28740
- this.hideParagraphMenu(true);
28908
+ if (this._isSlashMenuActive) this.hideParagraphMenu(true);
28741
28909
  },
28742
28910
  zIndex: 101
28743
28911
  }, this._context.unitId);
28744
28912
  this._paragraphMenu = {
28745
28913
  paragraph,
28746
28914
  target,
28915
+ blockRange: target.blockRange,
28747
28916
  disposable,
28748
- active: false
28917
+ active: false,
28918
+ getAnchor
28749
28919
  };
28750
28920
  this._activeTarget$.next(target);
28751
28921
  }
28752
28922
  _showFocusedTableMenu(tableBound, target) {
28753
- var _this$_focusedTableMe5, _this$_paragraphMenu11;
28923
+ var _this$_focusedTableMe5, _this$_paragraphMenu13;
28754
28924
  if (((_this$_focusedTableMe5 = this._focusedTableMenu) === null || _this$_focusedTableMe5 === void 0 ? void 0 : _this$_focusedTableMe5.target.key) === target.key) {
28755
28925
  this._focusedTableMenu.target = target;
28756
28926
  this._focusedTableMenu.bound = tableBound;
@@ -28758,7 +28928,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28758
28928
  return;
28759
28929
  }
28760
28930
  this.hideFocusedTableMenu();
28761
- if (((_this$_paragraphMenu11 = this._paragraphMenu) === null || _this$_paragraphMenu11 === void 0 ? void 0 : _this$_paragraphMenu11.target.key) === target.key) this.hideParagraphMenu(true);
28931
+ if (((_this$_paragraphMenu13 = this._paragraphMenu) === null || _this$_paragraphMenu13 === void 0 ? void 0 : _this$_paragraphMenu13.target.key) === target.key) this.hideParagraphMenu(true);
28762
28932
  const getFocusedAnchor = () => {
28763
28933
  var _this$_focusedTableMe6;
28764
28934
  return getTableAnchorRect(this._docEventManagerService.tableBounds.get(tableBound.tableId) ?? ((_this$_focusedTableMe6 = this._focusedTableMenu) === null || _this$_focusedTableMe6 === void 0 ? void 0 : _this$_focusedTableMe6.bound) ?? tableBound);
@@ -28781,8 +28951,8 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28781
28951
  this._focusedTableTarget$.next(target);
28782
28952
  }
28783
28953
  _shouldKeepCurrentCellMenuForTable(table) {
28784
- var _this$_paragraphMenu12;
28785
- const target = (_this$_paragraphMenu12 = this._paragraphMenu) === null || _this$_paragraphMenu12 === void 0 ? void 0 : _this$_paragraphMenu12.target;
28954
+ var _this$_paragraphMenu14;
28955
+ const target = (_this$_paragraphMenu14 = this._paragraphMenu) === null || _this$_paragraphMenu14 === void 0 ? void 0 : _this$_paragraphMenu14.target;
28786
28956
  if (!target || target.kind === DocumentBlockType.TABLE || !target.cellRange) return false;
28787
28957
  return target.cellRange.startOffset >= table.startIndex && target.cellRange.startOffset <= table.endIndex;
28788
28958
  }
@@ -28822,7 +28992,21 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28822
28992
  }
28823
28993
  };
28824
28994
  }
28995
+ _cancelParagraphMenuHide() {
28996
+ if (this._paragraphMenuHideTimer != null) {
28997
+ clearTimeout(this._paragraphMenuHideTimer);
28998
+ this._paragraphMenuHideTimer = null;
28999
+ }
29000
+ }
29001
+ _scheduleParagraphMenuHide() {
29002
+ if (!this._paragraphMenu || this._paragraphMenu.active || this._paragraphMenuHideTimer != null) return;
29003
+ this._paragraphMenuHideTimer = setTimeout(() => {
29004
+ this._paragraphMenuHideTimer = null;
29005
+ this.hideParagraphMenu();
29006
+ }, 200);
29007
+ }
28825
29008
  hideParagraphMenu(force = false) {
29009
+ this._cancelParagraphMenuHide();
28826
29010
  if (this._isBlockMenuDragging) return;
28827
29011
  if (this._paragraphMenu && (this._paragraphMenu.disposable.canDispose() || force)) {
28828
29012
  this._paragraphMenu.disposable.dispose();
@@ -28848,6 +29032,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
28848
29032
  this._isBlockMenuDragging = false;
28849
29033
  this.hideFocusedTableMenu();
28850
29034
  this.hideParagraphMenu(true);
29035
+ this._activeTarget$.complete();
28851
29036
  this._focusedTableTarget$.complete();
28852
29037
  this._focusedTableMenuDismiss$.complete();
28853
29038
  (_this$_menuInteractio2 = this._menuInteraction) === null || _this$_menuInteractio2 === void 0 || _this$_menuInteractio2.dispose();
@@ -29126,6 +29311,74 @@ function getBlockRangeAnchorRect(docEventManagerService, blockRange, fallbackPar
29126
29311
  };
29127
29312
  }
29128
29313
 
29314
+ //#endregion
29315
+ //#region src/views/paragraph-menu/paragraph-menu-position.ts
29316
+ function observeParagraphMenuPosition(element, popup, targets$) {
29317
+ let anchor;
29318
+ let table = false;
29319
+ let previousPosition;
29320
+ let disposed = false;
29321
+ const previousTransition = element.style.transition;
29322
+ const updatePosition = () => {
29323
+ var _window$matchMedia, _window;
29324
+ if (disposed || !anchor || element.style.visibility === "hidden") return;
29325
+ const gap = table ? 0 : 8;
29326
+ const boundary = popup.canvasElement.getBoundingClientRect();
29327
+ const containerLeft = Math.max(boundary.left, 0);
29328
+ const containerTop = Math.max(boundary.top, 0);
29329
+ const position = RectPopup.calcPopupPosition({
29330
+ position: {
29331
+ ...anchor,
29332
+ left: anchor.left - gap,
29333
+ right: anchor.right + gap
29334
+ },
29335
+ width: element.clientWidth,
29336
+ height: element.clientHeight,
29337
+ direction: table ? "top-right" : "left-center",
29338
+ containerLeft,
29339
+ containerTop,
29340
+ containerWidth: Math.max(0, Math.min(boundary.right, window.innerWidth) - containerLeft),
29341
+ containerHeight: Math.max(0, Math.min(boundary.bottom, window.innerHeight) - containerTop),
29342
+ boundaryInsets: popup.boundaryInsets,
29343
+ noPushMinimumGap: popup.noPushMinimumGap
29344
+ });
29345
+ if ((previousPosition === null || previousPosition === void 0 ? void 0 : previousPosition.top) === position.top && previousPosition.left === position.left && element.style.top === previousPosition.styleTop && element.style.left === previousPosition.styleLeft) return;
29346
+ element.style.transition = previousPosition && !((_window$matchMedia = (_window = window).matchMedia) === null || _window$matchMedia === void 0 ? void 0 : _window$matchMedia.call(_window, "(prefers-reduced-motion: reduce)").matches) ? "top 100ms ease-out, left 100ms ease-out" : "";
29347
+ element.style.top = `${position.top}px`;
29348
+ element.style.left = `${position.left}px`;
29349
+ previousPosition = {
29350
+ ...position,
29351
+ styleTop: element.style.top,
29352
+ styleLeft: element.style.left
29353
+ };
29354
+ };
29355
+ const mutationObserver = new MutationObserver(updatePosition);
29356
+ mutationObserver.observe(element, {
29357
+ attributes: true,
29358
+ attributeFilter: ["style"]
29359
+ });
29360
+ const resizeObserver = new ResizeObserver(updatePosition);
29361
+ resizeObserver.observe(element);
29362
+ resizeObserver.observe(popup.canvasElement);
29363
+ const subscription = new Subscription();
29364
+ subscription.add(targets$.subscribe((target) => {
29365
+ table = (target === null || target === void 0 ? void 0 : target.kind) === DocumentBlockType.TABLE;
29366
+ updatePosition();
29367
+ }));
29368
+ subscription.add(popup.anchorRect$.subscribe((rect) => {
29369
+ anchor = rect;
29370
+ updatePosition();
29371
+ }));
29372
+ return () => {
29373
+ if (disposed) return;
29374
+ disposed = true;
29375
+ subscription.unsubscribe();
29376
+ mutationObserver.disconnect();
29377
+ resizeObserver.disconnect();
29378
+ element.style.transition = previousTransition;
29379
+ };
29380
+ }
29381
+
29129
29382
  //#endregion
29130
29383
  //#region src/views/ParagraphMenu.tsx
29131
29384
  function getParagraphMenuPopupDirection(anchorLeft, menuWidth = 212, viewportPadding = 8, options = {}) {
@@ -29139,26 +29392,9 @@ const PARAGRAPH_MENU_HOVER_OPEN_DELAY = 800;
29139
29392
  const PARAGRAPH_MENU_HOVER_HIDE_DELAY = 240;
29140
29393
  const PARAGRAPH_MENU_HOVER_BRIDGE_EDGE_OVERLAP = 12;
29141
29394
  const PARAGRAPH_MENU_HOVER_BRIDGE_VERTICAL_PADDING = 8;
29142
- function getParagraphMenuIconSizeClass(iconKey) {
29143
- return iconKey === "TextTypeIcon" ? "univer-size-3" : "univer-size-4";
29144
- }
29145
29395
  function shouldExecuteParagraphMenuMove(validatorService, context) {
29146
29396
  return validatorService.canMoveBlock(context);
29147
29397
  }
29148
- function getParagraphMenuTriggerIconKey(namedStyleType) {
29149
- switch (namedStyleType) {
29150
- case NamedStyleType.HEADING_1: return "H1Icon";
29151
- case NamedStyleType.HEADING_2: return "H2Icon";
29152
- case NamedStyleType.HEADING_3: return "H3Icon";
29153
- case NamedStyleType.HEADING_4: return "H4Icon";
29154
- case NamedStyleType.HEADING_5: return "H5Icon";
29155
- case NamedStyleType.TITLE: return "TitleTypeIcon";
29156
- case NamedStyleType.SUBTITLE: return "SubtitleTypeIcon";
29157
- case NamedStyleType.NORMAL_TEXT:
29158
- case NamedStyleType.NAMED_STYLE_TYPE_UNSPECIFIED:
29159
- default: return "TextTypeIcon";
29160
- }
29161
- }
29162
29398
  function createParagraphMenuHoverOpenScheduler(openMenu, delay = 800) {
29163
29399
  let openTimer = null;
29164
29400
  const cancel = () => {
@@ -29297,9 +29533,6 @@ const PARAGRAPH_MENU_RESTORE_SELECTION_COMMAND_IDS = /* @__PURE__ */ new Set([
29297
29533
  SetInlineFormatTextBackgroundColorCommand.id,
29298
29534
  ResetInlineFormatTextBackgroundColorCommand.id
29299
29535
  ]);
29300
- function shouldRestoreParagraphMenuSelectionAfterCommand(commandId) {
29301
- return !!commandId && PARAGRAPH_MENU_RESTORE_SELECTION_COMMAND_IDS.has(commandId);
29302
- }
29303
29536
  function getParagraphMenuCommand(params, targetRange) {
29304
29537
  const commandId = params.commandId ?? params.id ?? (typeof params.label === "string" ? params.label : void 0);
29305
29538
  if (commandId && targetRange && commandId in HEADING_COMMAND_VALUES) return {
@@ -29341,28 +29574,11 @@ function getParagraphMenuCommandParams(commandId, commandParams, target, unitId)
29341
29574
  blockRange: target.blockRange
29342
29575
  };
29343
29576
  }
29344
- function getParagraphMenuType(target, emptyMode) {
29345
- if ((target === null || target === void 0 ? void 0 : target.kind) === "table") return DOC_TABLE_BLOCK_MENU_ID;
29346
- if (emptyMode) return DOC_PARAGRAPH_T_INSERT_MENU_ID;
29347
- if ((target === null || target === void 0 ? void 0 : target.icon) === "ReduceIcon") return DOC_PARAGRAPH_T_DIVIDER_MENU_ID;
29348
- return DOC_PARAGRAPH_T_EDIT_MENU_ID;
29349
- }
29350
- function getParagraphMenuActiveItemIds(target, namedStyleType) {
29351
- if ((target === null || target === void 0 ? void 0 : target.kind) === "blockRange") {
29352
- var _target$blockRange;
29353
- const commandId = getParagraphMenuBlockRangeCommandId((_target$blockRange = target.blockRange) === null || _target$blockRange === void 0 ? void 0 : _target$blockRange.blockType);
29354
- return commandId && PARAGRAPH_MENU_BLOCK_RANGE_COMMAND_IDS.has(commandId) ? [commandId] : [];
29355
- }
29356
- const activeIds = [getParagraphMenuActiveHeadingCommandId(namedStyleType)];
29357
- const listCommandId = (target === null || target === void 0 ? void 0 : target.icon) ? LIST_ICON_TO_COMMAND_ID[target.icon] : void 0;
29358
- if (listCommandId) activeIds.push(listCommandId);
29359
- return activeIds;
29360
- }
29361
29577
  function getParagraphMenuHiddenItemIds(menuType, target, namedStyleType) {
29362
- var _target$blockRange2;
29578
+ var _target$blockRange;
29363
29579
  if (menuType === "doc.menu.paragraph-t.insert") return [];
29364
29580
  const hiddenIds = [...getParagraphMenuHiddenHeadingCommandIds(namedStyleType)];
29365
- const blockType = (target === null || target === void 0 ? void 0 : target.kind) === "blockRange" ? (_target$blockRange2 = target.blockRange) === null || _target$blockRange2 === void 0 ? void 0 : _target$blockRange2.blockType : void 0;
29581
+ const blockType = (target === null || target === void 0 ? void 0 : target.kind) === "blockRange" ? (_target$blockRange = target.blockRange) === null || _target$blockRange === void 0 ? void 0 : _target$blockRange.blockType : void 0;
29366
29582
  if ((target === null || target === void 0 ? void 0 : target.kind) !== "blockRange") hiddenIds.push(DocPasteCommand.id);
29367
29583
  if (blockType === DocumentBlockRangeType.CALLOUT) hiddenIds.push(getParagraphMenuBlockRangeCommandId(DocumentBlockRangeType.CODE), getParagraphMenuBlockRangeCommandId(DocumentBlockRangeType.QUOTE));
29368
29584
  else if (blockType === DocumentBlockRangeType.QUOTE || blockType === DocumentBlockRangeType.CODE) hiddenIds.push(getParagraphMenuBlockRangeCommandId(DocumentBlockRangeType.CALLOUT));
@@ -29626,6 +29842,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29626
29842
  const doc = univerInstanceService.getUnit(popup.unitId, UniverInstanceType.UNIVER_DOC);
29627
29843
  const docParagraphMenuService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocParagraphMenuService);
29628
29844
  const docEventManagerService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocEventManagerService);
29845
+ const docSelectionRenderService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocSelectionRenderService);
29629
29846
  const isFocusedTableMenu = ((_popup$extraProps = popup.extraProps) === null || _popup$extraProps === void 0 ? void 0 : _popup$extraProps.focusedTableMenu) === true;
29630
29847
  const activeTarget = useObservable(isFocusedTableMenu ? docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.focusedTableTarget$ : docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget$);
29631
29848
  const slashMenuRequest = useObservable(docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.slashMenuRequest$);
@@ -29639,7 +29856,8 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29639
29856
  docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(active, isFocusedTableMenu);
29640
29857
  };
29641
29858
  const rawActiveTarget = getActiveTarget();
29642
- const currentActiveTarget = (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table" === tableBlockOnly ? rawActiveTarget : null;
29859
+ const isTableMenu = tableBlockOnly || (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table";
29860
+ const currentActiveTarget = (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table" === isTableMenu ? rawActiveTarget : null;
29643
29861
  const activeParagraphBound = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.paragraph) ?? (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeParagraph) ?? paragraph ?? paragraphLeft;
29644
29862
  const startIndex = activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.startIndex;
29645
29863
  const dataStream = (doc === null || doc === void 0 || (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.dataStream) ?? "";
@@ -29649,10 +29867,38 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29649
29867
  }, [doc, startIndex]);
29650
29868
  const isEmptyParagraph = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.emptyMode) ?? isEmptyParagraphMenuTarget(dataStream, activeParagraphBound);
29651
29869
  const namedStyleType = paragraphObj === null || paragraphObj === void 0 || (_paragraphObj$paragra = paragraphObj.paragraphStyle) === null || _paragraphObj$paragra === void 0 ? void 0 : _paragraphObj$paragra.namedStyleType;
29652
- const targetIconKey = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.icon) ?? getParagraphMenuTriggerIconKey(namedStyleType);
29870
+ const getParagraphMenuTriggerIconKey = () => {
29871
+ switch (namedStyleType) {
29872
+ case NamedStyleType.HEADING_1: return "H1Icon";
29873
+ case NamedStyleType.HEADING_2: return "H2Icon";
29874
+ case NamedStyleType.HEADING_3: return "H3Icon";
29875
+ case NamedStyleType.HEADING_4: return "H4Icon";
29876
+ case NamedStyleType.HEADING_5: return "H5Icon";
29877
+ case NamedStyleType.TITLE: return "TitleTypeIcon";
29878
+ case NamedStyleType.SUBTITLE: return "SubtitleTypeIcon";
29879
+ default: return "TextTypeIcon";
29880
+ }
29881
+ };
29882
+ const isModernHeading = (doc === null || doc === void 0 ? void 0 : doc.getDocumentStyle().documentFlavor) === DocumentFlavor.MODERN && startIndex != null && (renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocSkeletonManagerService).getViewModel().getHeadingSections().some((heading) => heading.paragraphIndex === startIndex && heading.startOffset < heading.endOffset));
29883
+ const targetIconKey = isEmptyParagraph ? "IncreaseIcon" : (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.icon) ?? getParagraphMenuTriggerIconKey();
29653
29884
  const TargetIcon = iconManager.get(targetIconKey);
29654
- const paragraphMenuType = useMemo(() => getParagraphMenuType(currentActiveTarget, isEmptyParagraph), [currentActiveTarget, isEmptyParagraph]);
29655
- const paragraphMenuActiveItemIds = useMemo(() => getParagraphMenuActiveItemIds(currentActiveTarget, namedStyleType), [currentActiveTarget, namedStyleType]);
29885
+ const paragraphMenuType = useMemo(() => {
29886
+ if ((currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.kind) === "table") return DOC_TABLE_BLOCK_MENU_ID;
29887
+ if (isEmptyParagraph) return DOC_PARAGRAPH_T_INSERT_MENU_ID;
29888
+ if ((currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.icon) === "ReduceIcon") return DOC_PARAGRAPH_T_DIVIDER_MENU_ID;
29889
+ return DOC_PARAGRAPH_T_EDIT_MENU_ID;
29890
+ }, [currentActiveTarget, isEmptyParagraph]);
29891
+ const paragraphMenuActiveItemIds = useMemo(() => {
29892
+ if ((currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.kind) === "blockRange") {
29893
+ var _currentActiveTarget$;
29894
+ const commandId = getParagraphMenuBlockRangeCommandId((_currentActiveTarget$ = currentActiveTarget.blockRange) === null || _currentActiveTarget$ === void 0 ? void 0 : _currentActiveTarget$.blockType);
29895
+ return commandId && PARAGRAPH_MENU_BLOCK_RANGE_COMMAND_IDS.has(commandId) ? [commandId] : [];
29896
+ }
29897
+ const activeIds = [getParagraphMenuActiveHeadingCommandId(namedStyleType)];
29898
+ const listCommandId = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.icon) ? LIST_ICON_TO_COMMAND_ID[currentActiveTarget.icon] : void 0;
29899
+ if (listCommandId) activeIds.push(listCommandId);
29900
+ return activeIds;
29901
+ }, [currentActiveTarget, namedStyleType]);
29656
29902
  const paragraphMenuHiddenItemIds = useMemo(() => (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.kind) === "table" ? [] : getParagraphMenuHiddenItemIds(paragraphMenuType, currentActiveTarget, namedStyleType), [
29657
29903
  currentActiveTarget,
29658
29904
  namedStyleType,
@@ -29692,6 +29938,17 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29692
29938
  if (activeElement === focusedElement || !focusedElement.isConnected && activeElement === body) layoutService.focus();
29693
29939
  }, [layoutService]);
29694
29940
  useLayoutEffect(() => restoreMenuFocus, [restoreMenuFocus]);
29941
+ useLayoutEffect(() => {
29942
+ var _anchorRef$current3;
29943
+ if (isFocusedTableMenu || !docParagraphMenuService) return;
29944
+ const popupElement = (_anchorRef$current3 = anchorRef.current) === null || _anchorRef$current3 === void 0 ? void 0 : _anchorRef$current3.closest("[data-u-comp=\"rect-popup\"]");
29945
+ if (!popupElement) return;
29946
+ return observeParagraphMenuPosition(popupElement, popup, docParagraphMenuService.activeTarget$);
29947
+ }, [
29948
+ docParagraphMenuService,
29949
+ isFocusedTableMenu,
29950
+ popup
29951
+ ]);
29695
29952
  const handleHideMenu = useCallback(() => {
29696
29953
  hoverOpenSchedulerRef.current.cancel();
29697
29954
  restoreMenuFocus();
@@ -29704,6 +29961,16 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29704
29961
  isFocusedTableMenu,
29705
29962
  restoreMenuFocus
29706
29963
  ]);
29964
+ useEffect(() => {
29965
+ if (!visible || isFocusedTableMenu || !docSelectionRenderService) return;
29966
+ const subscription = docSelectionRenderService.onSelectionStart$.pipe(skip(1)).subscribe(handleHideMenu);
29967
+ return () => subscription.unsubscribe();
29968
+ }, [
29969
+ docSelectionRenderService,
29970
+ handleHideMenu,
29971
+ isFocusedTableMenu,
29972
+ visible
29973
+ ]);
29707
29974
  useEffect(() => {
29708
29975
  if (!isFocusedTableMenu || !docParagraphMenuService) return;
29709
29976
  const subscription = docParagraphMenuService.focusedTableMenuDismiss$.subscribe(handleHideMenu);
@@ -29743,7 +30010,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29743
30010
  };
29744
30011
  const handleOpenMenu = (mode = "pointer") => {
29745
30012
  clearHideTimer();
29746
- if (openMode === "slash") return;
30013
+ if (openMode === "slash" || isDraggingRef.current) return;
29747
30014
  const latestTarget = getActiveTarget();
29748
30015
  setMenuInteractionActive(true);
29749
30016
  const targetRange = latestTarget ? {
@@ -29898,7 +30165,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29898
30165
  finishParagraphMenuCommand(docParagraphMenuService, handleHideMenu);
29899
30166
  return;
29900
30167
  }
29901
- const previousTextRanges = shouldRestoreParagraphMenuSelectionAfterCommand(commandId) ? getCurrentTextRangesSnapshot() : null;
30168
+ const previousTextRanges = commandId && PARAGRAPH_MENU_RESTORE_SELECTION_COMMAND_IDS.has(commandId) ? getCurrentTextRangesSnapshot() : null;
29902
30169
  if (commandId && shouldUseInsertBelowRange(commandId, option) && (latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.moveRange)) docContentInsertService.setInsertRange({
29903
30170
  unitId: popup.unitId,
29904
30171
  startOffset: latestTarget.moveRange.endOffset,
@@ -29930,21 +30197,24 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29930
30197
  docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(false, isFocusedTableMenu);
29931
30198
  }, [docParagraphMenuService, isFocusedTableMenu]);
29932
30199
  useEffect(() => {
29933
- if (tableBlockOnly || !slashMenuRequest || handledSlashRequestNonceRef.current >= slashMenuRequest.nonce) return;
30200
+ if (isTableMenu || !slashMenuRequest || handledSlashRequestNonceRef.current >= slashMenuRequest.nonce) return;
29934
30201
  handledSlashRequestNonceRef.current = slashMenuRequest.nonce;
29935
30202
  hoverOpenSchedulerRef.current.cancel();
29936
30203
  clearHideTimer();
29937
30204
  isMouseOver.current = false;
29938
30205
  handleOpenSlashMenu(slashMenuRequest);
29939
- }, [slashMenuRequest, tableBlockOnly]);
30206
+ }, [slashMenuRequest, isTableMenu]);
29940
30207
  if (!currentActiveTarget) return null;
29941
30208
  return /* @__PURE__ */ jsxs(Fragment, { children: [
29942
30209
  /* @__PURE__ */ jsxs("div", {
29943
30210
  "data-u-comp": "paragraph-menu",
29944
- "data-u-table-menu": tableBlockOnly ? "true" : void 0,
30211
+ "data-u-table-menu": isTableMenu ? "true" : void 0,
29945
30212
  "data-u-focused-table-menu": isFocusedTableMenu ? "true" : void 0,
29946
30213
  ref: anchorRef,
29947
- className: clsx("univer-mr-1 univer-inline-flex univer-h-7 univer-cursor-pointer univer-items-center univer-gap-1 univer-rounded-md univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-px-2 univer-py-0 univer-shadow-sm univer-transition-colors hover:univer-bg-gray-50 hover:univer-shadow-md dark:!univer-border-gray-600 dark:!univer-bg-gray-900 dark:hover:!univer-bg-gray-800", { "univer-bg-gray-100 univer-shadow-md dark:!univer-bg-gray-800": visible }),
30214
+ className: clsx("univer-inline-flex univer-h-7 univer-cursor-pointer univer-select-none univer-items-center univer-gap-1 univer-rounded-md univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-px-2 univer-py-0 univer-shadow-sm univer-transition-colors hover:univer-bg-gray-50 hover:univer-shadow-md dark:!univer-border-gray-600 dark:!univer-bg-gray-900 dark:hover:!univer-bg-gray-800", {
30215
+ "univer-mr-1": !isModernHeading,
30216
+ "univer-bg-gray-100 univer-shadow-md dark:!univer-bg-gray-800": visible
30217
+ }),
29948
30218
  onMouseEnter: (e) => {
29949
30219
  var _popup$onPointerEnter;
29950
30220
  (_popup$onPointerEnter = popup.onPointerEnter) === null || _popup$onPointerEnter === void 0 || _popup$onPointerEnter.call(popup, e);
@@ -29963,7 +30233,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29963
30233
  isMouseOver.current = true;
29964
30234
  hoverOpenSchedulerRef.current.openNow();
29965
30235
  },
29966
- children: [/* @__PURE__ */ jsx(TargetIcon, { className: clsx(getParagraphMenuIconSizeClass(targetIconKey), "univer-shrink-0 univer-text-gray-700 dark:!univer-text-gray-0") }), (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.draggable) && /* @__PURE__ */ jsx("button", {
30236
+ children: [/* @__PURE__ */ jsx(TargetIcon, { className: clsx(targetIconKey === "TextTypeIcon" ? "univer-size-3" : "univer-size-4", "univer-shrink-0 univer-text-gray-700 dark:!univer-text-gray-0") }), !isEmptyParagraph && (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.draggable) && /* @__PURE__ */ jsx("button", {
29967
30237
  type: "button",
29968
30238
  className: "univer-group univer-flex univer-h-4 univer-w-2.5 univer-cursor-grab univer-items-center univer-justify-center univer-border-none univer-bg-transparent univer-p-0 active:univer-cursor-grabbing",
29969
30239
  "aria-label": localeService.t("docs-ui.doc.blockMenu.dragBlock"),
@@ -29980,6 +30250,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29980
30250
  isMouseOver.current = true;
29981
30251
  isDraggingRef.current = true;
29982
30252
  docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setBlockMenuDragging(true);
30253
+ handleHideMenu();
29983
30254
  dragRangeRef.current = moveRange;
29984
30255
  dragTargetOffsetRef.current = null;
29985
30256
  setDropRect(null);
@@ -30039,7 +30310,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
30039
30310
  }),
30040
30311
  visible && hoverBridgeStyle && /* @__PURE__ */ jsx("div", {
30041
30312
  "aria-hidden": "true",
30042
- className: "univer-fixed univer-z-[1019] univer-bg-transparent",
30313
+ className: "univer-fixed univer-z-[1019] univer-select-none univer-bg-transparent",
30043
30314
  style: hoverBridgeStyle,
30044
30315
  onMouseEnter: (e) => {
30045
30316
  var _popup$onPointerEnter2;
@@ -30058,6 +30329,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
30058
30329
  anchorRect$,
30059
30330
  direction: menuDirection,
30060
30331
  children: /* @__PURE__ */ jsx("section", {
30332
+ className: "univer-select-none",
30061
30333
  onFocusCapture: (event) => {
30062
30334
  focusedMenuElementRef.current = event.target;
30063
30335
  },
@@ -30317,6 +30589,7 @@ let ComponentsController = class ComponentsController extends Disposable {
30317
30589
  [DOC_PARAGRAPH_MENU_COMPONENT_KEY, ParagraphMenu],
30318
30590
  [DOC_TABLE_BLOCK_MENU_COMPONENT_KEY, TableBlockMenu],
30319
30591
  [FLOAT_MENU_COMPONENT_KEY, FloatToolbar],
30592
+ [EditorColorPicker.componentKey, EditorColorPicker],
30320
30593
  [PAGE_SETTING_COMPONENT_ID, PageSettings],
30321
30594
  [DOC_LAYOUT_RECOVERY_COMPONENT, DocLayoutRecovery]
30322
30595
  ].forEach(([key, comp]) => {
@@ -30804,6 +31077,289 @@ let DocContextualRibbonService = class DocContextualRibbonService extends Dispos
30804
31077
  };
30805
31078
  DocContextualRibbonService = __decorate([__decorateParam(0, IRibbonService)], DocContextualRibbonService);
30806
31079
 
31080
+ //#endregion
31081
+ //#region src/views/heading-collapse-shape.ts
31082
+ var HeadingCollapseShape = class extends Shape {
31083
+ constructor(key, colors, activate) {
31084
+ super(key, {
31085
+ width: 24,
31086
+ height: 28,
31087
+ debounceParentDirty: false
31088
+ });
31089
+ _defineProperty(this, "_collapsed", false);
31090
+ _defineProperty(this, "_label", "");
31091
+ _defineProperty(this, "_colors", void 0);
31092
+ _defineProperty(this, "_hovered", false);
31093
+ _defineProperty(this, "_tooltipVisible", false);
31094
+ _defineProperty(this, "_tooltipTimer", null);
31095
+ _defineProperty(this, "_pressed", false);
31096
+ this._colors = colors;
31097
+ this.cursor = CURSOR_TYPE.POINTER;
31098
+ this.disposeWithMe(this.onPointerEnter$.subscribeEvent((event) => {
31099
+ if (this._hovered || event.buttons) return;
31100
+ this._hovered = true;
31101
+ this._tooltipTimer = setTimeout(() => {
31102
+ this._tooltipTimer = null;
31103
+ this._tooltipVisible = true;
31104
+ this.makeDirty(true);
31105
+ }, 500);
31106
+ this.makeDirty(true);
31107
+ }));
31108
+ this.disposeWithMe(this.onPointerLeave$.subscribeEvent(() => this.resetHover()));
31109
+ this.disposeWithMe(this.onPointerDown$.subscribeEvent((event, state) => {
31110
+ state.stopPropagation();
31111
+ event.preventDefault();
31112
+ this._pressed = event.button === 0;
31113
+ }));
31114
+ this.disposeWithMe(this.onPointerUp$.subscribeEvent((event, state) => {
31115
+ state.stopPropagation();
31116
+ event.preventDefault();
31117
+ const activateButton = this._pressed && event.button === 0;
31118
+ this._pressed = false;
31119
+ this._hideTooltip();
31120
+ if (activateButton) activate();
31121
+ }));
31122
+ this.disposeWithMe(this.onClick$.subscribeEvent((_event, state) => state.stopPropagation()));
31123
+ this.disposeWithMe(this.onDblclick$.subscribeEvent((_event, state) => state.stopPropagation()));
31124
+ }
31125
+ update(collapsed, label, colors) {
31126
+ if (collapsed === this._collapsed && label === this._label && colors === this._colors) return;
31127
+ this._collapsed = collapsed;
31128
+ this._label = label;
31129
+ this._colors = colors;
31130
+ this.makeDirty(true);
31131
+ }
31132
+ resetHover() {
31133
+ this._hideTooltip();
31134
+ this._pressed = false;
31135
+ if (this._hovered) {
31136
+ this._hovered = false;
31137
+ this.makeDirty(true);
31138
+ }
31139
+ }
31140
+ _hideTooltip() {
31141
+ if (this._tooltipTimer !== null) {
31142
+ clearTimeout(this._tooltipTimer);
31143
+ this._tooltipTimer = null;
31144
+ }
31145
+ if (this._tooltipVisible) {
31146
+ this._tooltipVisible = false;
31147
+ this.makeDirty(true);
31148
+ }
31149
+ }
31150
+ _draw(ctx, bounds) {
31151
+ ctx.fillStyle = this._hovered ? this._colors.hover : this._colors.normal;
31152
+ ctx.beginPath();
31153
+ if (this._collapsed) {
31154
+ ctx.moveTo(9, 8);
31155
+ ctx.lineTo(16, 14);
31156
+ ctx.lineTo(9, 20);
31157
+ } else {
31158
+ ctx.moveTo(6, 11);
31159
+ ctx.lineTo(18, 11);
31160
+ ctx.lineTo(12, 18);
31161
+ }
31162
+ ctx.closePath();
31163
+ ctx.fill();
31164
+ if (!this._tooltipVisible) return;
31165
+ ctx.save();
31166
+ ctx.font = "12px sans-serif";
31167
+ const width = ctx.measureText(this._label).width + 20;
31168
+ const viewport = bounds === null || bounds === void 0 ? void 0 : bounds.viewBound;
31169
+ const centeredLeft = (this.width - width) / 2;
31170
+ const left = viewport ? Math.max(viewport.left - this.left, Math.min(centeredLeft, viewport.right - this.left - width)) : centeredLeft;
31171
+ const below = viewport != null && this.top - 36 < viewport.top;
31172
+ ctx.translate(left, below ? this.height + 8 : -36);
31173
+ Rect.drawWith(ctx, {
31174
+ width,
31175
+ height: 28,
31176
+ radius: 6,
31177
+ fill: this._colors.tooltipBackground
31178
+ });
31179
+ ctx.fillStyle = this._colors.tooltipBackground;
31180
+ ctx.beginPath();
31181
+ const arrow = this.width / 2 - left;
31182
+ const arrowBase = below ? 0 : 28;
31183
+ ctx.moveTo(arrow - 4, arrowBase);
31184
+ ctx.lineTo(arrow, below ? -4 : 32);
31185
+ ctx.lineTo(arrow + 4, arrowBase);
31186
+ ctx.fill();
31187
+ ctx.fillStyle = this._colors.tooltipText;
31188
+ ctx.textAlign = "center";
31189
+ ctx.textBaseline = "middle";
31190
+ ctx.fillText(this._label, width / 2, 14);
31191
+ ctx.restore();
31192
+ }
31193
+ dispose() {
31194
+ this.resetHover();
31195
+ super.dispose();
31196
+ }
31197
+ };
31198
+
31199
+ //#endregion
31200
+ //#region src/services/doc-heading-collapse.service.ts
31201
+ let DocHeadingCollapseService = class DocHeadingCollapseService extends Disposable {
31202
+ constructor(_context, _skeletonManager, _eventManager, _selections, _commandService, _layoutService, themeService, localeService) {
31203
+ super();
31204
+ this._context = _context;
31205
+ this._skeletonManager = _skeletonManager;
31206
+ this._eventManager = _eventManager;
31207
+ this._selections = _selections;
31208
+ this._commandService = _commandService;
31209
+ this._layoutService = _layoutService;
31210
+ _defineProperty(this, "_buttons", /* @__PURE__ */ new Map());
31211
+ _defineProperty(this, "_colors", void 0);
31212
+ _defineProperty(this, "_expandLabel", "");
31213
+ _defineProperty(this, "_collapseLabel", "");
31214
+ this._colors = this._getColors(themeService);
31215
+ if (isInternalEditorID(_context.unitId)) return;
31216
+ this.disposeWithMe(themeService.currentTheme$.subscribe(() => {
31217
+ this._colors = this._getColors(themeService);
31218
+ this._update();
31219
+ }));
31220
+ this.disposeWithMe(localeService.currentLocale$.subscribe(() => {
31221
+ this._expandLabel = localeService.t("docs-ui.heading.expand");
31222
+ this._collapseLabel = localeService.t("docs-ui.heading.collapse");
31223
+ this._update();
31224
+ }));
31225
+ this.disposeWithMe(_context.scene.beforeRender$.subscribe(() => this._update()));
31226
+ this.disposeWithMe(this._skeletonManager.currentSkeleton$.subscribe(() => this._update()));
31227
+ this.disposeWithMe(this._skeletonManager.getSkeleton().dirty$.subscribe(() => this._update()));
31228
+ const resetHover = () => this._buttons.forEach((button) => button.resetHover());
31229
+ const viewport = _context.scene.getViewport("viewMain");
31230
+ if (viewport) {
31231
+ let scrollX = viewport.viewportScrollX;
31232
+ let scrollY = viewport.viewportScrollY;
31233
+ this.disposeWithMe(viewport.onScrollAfter$.subscribeEvent((event) => {
31234
+ if (event.viewportScrollX !== scrollX || event.viewportScrollY !== scrollY) {
31235
+ resetHover();
31236
+ scrollX = event.viewportScrollX;
31237
+ scrollY = event.viewportScrollY;
31238
+ }
31239
+ }));
31240
+ }
31241
+ this.disposeWithMe(_context.scene.onPointerCancel$.subscribeEvent(resetHover));
31242
+ this.disposeWithMe(_context.scene.onTransformChange$.subscribeEvent(({ value, preValue }) => {
31243
+ if (value.scaleX != null && value.scaleX !== preValue.scaleX || value.scaleY != null && value.scaleY !== preValue.scaleY) resetHover();
31244
+ }));
31245
+ this.disposeWithMe(_context.scene.onPointerLeave$.subscribeEvent(resetHover));
31246
+ this.disposeWithMe(this._selections.textSelection$.subscribe(({ unitId }) => {
31247
+ if (unitId === _context.unitId) this._normalizeSelection();
31248
+ }));
31249
+ }
31250
+ _getColors(themeService) {
31251
+ return {
31252
+ normal: themeService.getColorFromTheme("gray.900"),
31253
+ hover: themeService.getColorFromTheme("primary.600"),
31254
+ tooltipBackground: themeService.getColorFromTheme("gray.700"),
31255
+ tooltipText: themeService.getColorFromTheme("gray.0")
31256
+ };
31257
+ }
31258
+ _normalizeSelection() {
31259
+ const target = {
31260
+ unitId: this._context.unitId,
31261
+ subUnitId: this._context.unitId
31262
+ };
31263
+ const info = this._selections.getSelectionInfo(target);
31264
+ if (!info || info.segmentId) return;
31265
+ const viewModel = this._skeletonManager.getViewModel();
31266
+ const hiddenRect = info.rectRanges.find((range) => !range.segmentId && range.startOffset != null && viewModel.getCollapsedHeadingAtOffset(range.startOffset));
31267
+ if ((hiddenRect === null || hiddenRect === void 0 ? void 0 : hiddenRect.startOffset) != null) {
31268
+ const offset = viewModel.getCollapsedHeadingAtOffset(hiddenRect.startOffset).paragraphIndex;
31269
+ const textRanges = [{
31270
+ startOffset: offset,
31271
+ endOffset: offset,
31272
+ collapsed: true,
31273
+ isActive: true
31274
+ }];
31275
+ this._selections.replaceSelectionInfoWithoutRefresh({
31276
+ ...info,
31277
+ textRanges,
31278
+ rectRanges: []
31279
+ }, target);
31280
+ this._selections.replaceDocRanges(textRanges, target, false, { forceFocus: false });
31281
+ return;
31282
+ }
31283
+ let changed = false;
31284
+ const textRanges = info.textRanges.map((range) => {
31285
+ var _viewModel$getCollaps, _viewModel$getCollaps2;
31286
+ if (range.segmentId) return range;
31287
+ const startOffset = ((_viewModel$getCollaps = viewModel.getCollapsedHeadingAtOffset(range.startOffset)) === null || _viewModel$getCollaps === void 0 ? void 0 : _viewModel$getCollaps.paragraphIndex) ?? range.startOffset;
31288
+ const endOffset = ((_viewModel$getCollaps2 = viewModel.getCollapsedHeadingAtOffset(range.endOffset)) === null || _viewModel$getCollaps2 === void 0 ? void 0 : _viewModel$getCollaps2.paragraphIndex) ?? range.endOffset;
31289
+ if (startOffset === range.startOffset && endOffset === range.endOffset) return range;
31290
+ changed = true;
31291
+ return {
31292
+ ...range,
31293
+ startOffset,
31294
+ endOffset,
31295
+ collapsed: startOffset === endOffset,
31296
+ startNodePosition: void 0,
31297
+ endNodePosition: void 0
31298
+ };
31299
+ });
31300
+ if (changed) {
31301
+ this._selections.replaceSelectionInfoWithoutRefresh({
31302
+ ...info,
31303
+ textRanges
31304
+ }, target);
31305
+ this._selections.replaceDocRanges([...textRanges, ...info.rectRanges], target, false, { forceFocus: false });
31306
+ }
31307
+ }
31308
+ _update() {
31309
+ this._normalizeSelection();
31310
+ const active = /* @__PURE__ */ new Set();
31311
+ const viewModel = this._skeletonManager.getViewModel();
31312
+ if (this._context.unit.getSnapshot().documentStyle.documentFlavor === DocumentFlavor.MODERN) for (const heading of viewModel.getHeadingSections()) {
31313
+ if (heading.startOffset >= heading.endOffset || viewModel.getCollapsedHeadingAtOffset(heading.paragraphIndex)) continue;
31314
+ const bound = this._eventManager.findParagraphBoundByIndex(heading.paragraphIndex);
31315
+ if (!bound || bound.segmentId) continue;
31316
+ active.add(heading.paragraphId);
31317
+ let button = this._buttons.get(heading.paragraphId);
31318
+ if (!button) {
31319
+ button = new HeadingCollapseShape(`__DocHeadingCollapse__${heading.paragraphId}`, this._colors, () => {
31320
+ var _this$_context$unit$g;
31321
+ const paragraph = (_this$_context$unit$g = this._context.unit.getBody()) === null || _this$_context$unit$g === void 0 || (_this$_context$unit$g = _this$_context$unit$g.paragraphs) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.find((item) => item.paragraphId === heading.paragraphId);
31322
+ if (paragraph && this._commandService.syncExecuteCommand(SetHeadingCollapsedCommand.id, {
31323
+ unitId: this._context.unitId,
31324
+ paragraphId: heading.paragraphId,
31325
+ collapsed: paragraph.headingCollapsed !== true
31326
+ })) this._layoutService.focus(this._context.unitId);
31327
+ });
31328
+ this._buttons.set(heading.paragraphId, button);
31329
+ this._context.scene.addObject(button, 3);
31330
+ }
31331
+ const left = bound.firstLine.left - button.width;
31332
+ const top = (bound.firstLine.top + bound.firstLine.bottom - button.height) / 2;
31333
+ if (button.left !== left || button.top !== top) {
31334
+ button.resetHover();
31335
+ button.transformByState({
31336
+ left,
31337
+ top
31338
+ });
31339
+ }
31340
+ button.update(heading.collapsed, heading.collapsed ? this._expandLabel : this._collapseLabel, this._colors);
31341
+ }
31342
+ for (const [id, button] of this._buttons) if (!active.has(id)) {
31343
+ button.dispose();
31344
+ this._buttons.delete(id);
31345
+ }
31346
+ }
31347
+ dispose() {
31348
+ super.dispose();
31349
+ this._buttons.forEach((button) => button.dispose());
31350
+ this._buttons.clear();
31351
+ }
31352
+ };
31353
+ DocHeadingCollapseService = __decorate([
31354
+ __decorateParam(1, Inject(DocSkeletonManagerService)),
31355
+ __decorateParam(2, Inject(DocEventManagerService)),
31356
+ __decorateParam(3, Inject(DocSelectionManagerService)),
31357
+ __decorateParam(4, ICommandService),
31358
+ __decorateParam(5, ILayoutService),
31359
+ __decorateParam(6, Inject(ThemeService)),
31360
+ __decorateParam(7, Inject(LocaleService))
31361
+ ], DocHeadingCollapseService);
31362
+
30807
31363
  //#endregion
30808
31364
  //#region src/shortcuts/core-editing.shortcut.ts
30809
31365
  const BreakLineShortcut = {
@@ -31228,6 +31784,7 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends Plugin {
31228
31784
  [DocFloatMenuService],
31229
31785
  [DocPasteOptionsRenderController],
31230
31786
  [DocParagraphMenuService],
31787
+ [DocHeadingCollapseService],
31231
31788
  [DocHeaderFooterController],
31232
31789
  [DocHeaderFooterRibbonController],
31233
31790
  [DocResizeRenderController],
@@ -31623,18 +32180,30 @@ function isSheetFormulaEditor(editorUnitId, univerInstanceService) {
31623
32180
  }
31624
32181
  function executeEditorUndoRedoCommand(options) {
31625
32182
  var _univerInstanceServic;
31626
- const { commandId, commandService, editorUnitId, univerInstanceService } = options;
32183
+ const { commandId, commandService, contextService, editorUnitId, preserveHostFocus, univerInstanceService } = options;
31627
32184
  const shouldUseSheetEditorContext = editorUnitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY || editorUnitId === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;
31628
32185
  if (isSheetFormulaEditor(editorUnitId, univerInstanceService)) return;
31629
32186
  const previousFocusedUnitId = ((_univerInstanceServic = univerInstanceService.getFocusedUnit()) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getUnitId()) ?? null;
31630
32187
  const shouldRestoreFocus = !shouldUseSheetEditorContext && previousFocusedUnitId !== null && previousFocusedUnitId !== editorUnitId;
31631
32188
  if (!shouldUseSheetEditorContext && previousFocusedUnitId !== editorUnitId) univerInstanceService.focusUnit(editorUnitId);
31632
32189
  commandService.executeCommand(commandId).finally(() => {
31633
- if (shouldRestoreFocus) univerInstanceService.focusUnit(previousFocusedUnitId);
32190
+ var _univerInstanceServic2;
32191
+ if (!shouldRestoreFocus || ((_univerInstanceServic2 = univerInstanceService.getFocusedUnit()) === null || _univerInstanceServic2 === void 0 ? void 0 : _univerInstanceServic2.getUnitId()) !== editorUnitId) return;
32192
+ if (!preserveHostFocus || !contextService) {
32193
+ univerInstanceService.focusUnit(previousFocusedUnitId);
32194
+ return;
32195
+ }
32196
+ const previousDisableAutoFocus = contextService.getContextValue(DISABLE_AUTO_FOCUS_KEY);
32197
+ contextService.setContextValue(DISABLE_AUTO_FOCUS_KEY, true);
32198
+ try {
32199
+ univerInstanceService.focusUnit(previousFocusedUnitId);
32200
+ } finally {
32201
+ contextService.setContextValue(DISABLE_AUTO_FOCUS_KEY, previousDisableAutoFocus);
32202
+ }
31634
32203
  });
31635
32204
  }
31636
32205
  function createEditorUndoRedoKeyboardConfig(options) {
31637
- const { commandService, editorUnitId, handler, keyCodes = [], univerInstanceService } = options;
32206
+ const { commandService, contextService, editorUnitId, handler, keyCodes = [], preserveHostFocus, univerInstanceService } = options;
31638
32207
  const ctrlCommand = MetaKeys.CTRL_COMMAND;
31639
32208
  const ctrlCommandShift = MetaKeys.CTRL_COMMAND | MetaKeys.SHIFT;
31640
32209
  return {
@@ -31659,7 +32228,9 @@ function createEditorUndoRedoKeyboardConfig(options) {
31659
32228
  executeEditorUndoRedoCommand({
31660
32229
  commandId: UndoCommand.id,
31661
32230
  commandService,
32231
+ contextService,
31662
32232
  editorUnitId,
32233
+ preserveHostFocus,
31663
32234
  univerInstanceService
31664
32235
  });
31665
32236
  return;
@@ -31668,7 +32239,9 @@ function createEditorUndoRedoKeyboardConfig(options) {
31668
32239
  executeEditorUndoRedoCommand({
31669
32240
  commandId: RedoCommand.id,
31670
32241
  commandService,
32242
+ contextService,
31671
32243
  editorUnitId,
32244
+ preserveHostFocus,
31672
32245
  univerInstanceService
31673
32246
  });
31674
32247
  return;
@@ -32114,6 +32687,7 @@ const useResize = (editor, isSingle = true, autoScrollbar, autoScroll, layoutSiz
32114
32687
  const RichTextEditor = (props) => {
32115
32688
  const { className, autoFocus, onFocusChange: _onFocusChange, initialValue, onClickOutside: _onClickOutside, preserveHostFocus, cancelDefaultResizeListener, documentLayoutSize, autoScroll = true, autoScrollbar = true, emitSelectionWhileDragging, keyboardEventsOnSelection = false, keyboardEventConfig, layoutSize, pixelRatio, moveCursor = true, style, isSingle, editorId: propsEditorId, onHeightChange, onChange: _onChange, defaultHeight = 32, maxHeight = 32, icon, editorRef, placeholder, noStyle, canvasStyle, renderConfig } = props;
32116
32689
  const commandService = useDependency(ICommandService);
32690
+ const contextService = useDependency(IContextService);
32117
32691
  const univerInstanceService = useDependency(IUniverInstanceService);
32118
32692
  const localeService = useDependency(LocaleService);
32119
32693
  const onFocusChange = useEvent(_onFocusChange);
@@ -32181,14 +32755,18 @@ const RichTextEditor = (props) => {
32181
32755
  useEditorClickOutside(editorId, sheetEmbeddingRef, onClickOutside);
32182
32756
  const resolvedKeyboardEventConfig = useMemo(() => createEditorUndoRedoKeyboardConfig({
32183
32757
  commandService,
32758
+ contextService,
32184
32759
  univerInstanceService,
32185
32760
  editorUnitId: editorId,
32761
+ preserveHostFocus,
32186
32762
  keyCodes: keyboardEventConfig === null || keyboardEventConfig === void 0 ? void 0 : keyboardEventConfig.keyCodes,
32187
32763
  handler: keyboardEventConfig === null || keyboardEventConfig === void 0 ? void 0 : keyboardEventConfig.handler
32188
32764
  }), [
32189
32765
  commandService,
32766
+ contextService,
32190
32767
  editorId,
32191
32768
  keyboardEventConfig,
32769
+ preserveHostFocus,
32192
32770
  univerInstanceService
32193
32771
  ]);
32194
32772
  useLeftAndRightArrow(isFocusing && moveCursor, false, editor);
@@ -32338,4 +32916,4 @@ function MobileRichTextEditor(props) {
32338
32916
  }
32339
32917
 
32340
32918
  //#endregion
32341
- export { AfterSpaceCommand, AlignCenterCommand, AlignJustifyCommand, AlignLeftCommand, AlignMenuItemFactory, AlignOperationCommand, AlignRightCommand, BackgroundColorSelectorMenuItemFactory, BoldMenuItemFactory, BreakLineCommand, BulletListCommand, BulletListTypePicker, ChangeListNestingLevelCommand, ChangeListNestingLevelType, ChangeListTypeCommand, CheckListCommand, CoverContentCommand, CreateDocTableCommand, CutContentCommand, DEFAULT_DOC_FIT_TO_WIDTH_OPTIONS, DOCS_COMPONENT_BACKGROUND_LAYER_INDEX, DOCS_COMPONENT_DEFAULT_Z_INDEX, DOCS_COMPONENT_HEADER_LAYER_INDEX, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_UI_PLUGIN_CONFIG_KEY, DOCS_VIEW_KEY, DOC_CONTENT_INSERT_MENU_ID, DOC_CUSTOM_RANGE_CHROME_BACKGROUND_ALPHA, DOC_CUSTOM_RANGE_CHROME_RADIUS, DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, DOC_PARAGRAPH_T_ALIGN_MENU_ID, DOC_PARAGRAPH_T_COLORS_MENU_ID, DOC_PARAGRAPH_T_DIVIDER_MENU_ID, DOC_PARAGRAPH_T_EDIT_MENU_ID, DOC_PARAGRAPH_T_INSERT_BELOW_MENU_ID, DOC_PARAGRAPH_T_INSERT_MENU_ID, DOC_TABLE_BLOCK_MENU_ID, DOC_VERTICAL_PADDING, DeleteCurrentParagraphCommand, DeleteCustomBlockCommand, DeleteLeftCommand, DeleteRightCommand, DocAutoFormatService, DocBackScrollRenderController, DocCanvasPopManagerService, DocClipboardPasteAdapterService, DocContextualRibbonService, DocCopyCommand, DocCreateTableOperation, DocCutCommand, DocEventManagerService, DocFloatMenuService, DocHtmlExportService, DocIMEInputManagerService, DocLayoutInteractionService, DocMobileElementMenuService, DocPageLayoutService, DocParagraphMenuService, DocParagraphPlaceholderRenderController, DocPasteCommand, DocPrintInterceptorService, DocRenderController, DocSelectAllCommand, DocSelectionRenderService, DocTableDeleteColumnsCommand, DocTableDeleteRowsCommand, DocTableDeleteTableCommand, DocTableInsertColumnCommand, DocTableInsertColumnLeftCommand, DocTableInsertColumnRightCommand, DocTableInsertRowAboveCommand, DocTableInsertRowBellowCommand, DocTableInsertRowCommand, DocTableTabCommand, DocUIController, DocViewScaleService, DocsRenderService, menuSchema as DocsUIMenuSchema, EMPTY_PARAGRAPH_MENU_ID, Editor, EditorService, EnterCommand, FLOAT_TEXT_STYLE_MENU_ID, FLOAT_TOOLBAR_MENU_POSITION, FloatTextStyleMenuItemFactory, FontFamilySelectorMenuItemFactory, FontSizeSelectorMenuItemFactory, HorizontalLineCommand, IDocClipboardPasteAdapterService, IDocClipboardService, IDocEmbedInteractionBoundaryService, IDocEmbedRuntimeFocusCoordinator, IEditorService, IMEInputCommand, INSERT_BELLOW_MENU_ID, InnerPasteCommand, InsertCustomRangeCommand, ItalicMenuItemFactory, ListOperationCommand, MOBILE_DOC_ELEMENT_MENU, MergeTwoParagraphCommand, MobileDocElementMenu, MobileRichTextEditor, MobileRichTextToolbar, MoveCursorOperation, MoveDocBlockCommand, MoveSelectionOperation, NORMAL_TEXT_SELECTION_PLUGIN_NAME, NodePositionConvertToCursor, NodePositionConvertToRectRange, OrderListCommand, OrderListTypePicker, ParagraphMenuInsertBelowSubmenuItemFactory, ParagraphSettingMenuFactory, LarkPastePlugin as PastePluginLark, UniverPastePlugin as PastePluginUniver, WordPastePlugin as PastePluginWord, QuickListCommand, RectRange, ReplaceSelectionCommand, ReplaceSnapshotCommand, ReplaceTextRunsCommand, ResetInlineFormatTextBackgroundColorCommand, ResetInlineFormatTextColorCommand, RichTextEditor, SetDocInputStyleCommand, SetDocZoomRatioCommand, SetDocZoomRatioOperation, SetInlineFormatBoldCommand, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, SetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextColorCommand, SetInlineFormatTextFillCommand, SetInlineFormatUnderlineCommand, SetParagraphNamedStyleCommand, StrikeThroughMenuItemFactory, SwitchDocModeCommand, TEXT_RANGE_LAYER_INDEX, TabCommand, TextColorSelectorMenuItemFactory, TextRange, ToggleCheckListCommand, UnderlineMenuItemFactory, UniverDocsMobileUIPlugin, UniverDocsUIPlugin, VIEWPORT_KEY, addCustomDecorationBySelectionFactory, addCustomDecorationFactory, buildMoveDocBlockActions, calcDocFitToWidthScale, calcDocRangePositions, captureTextFormat, collectDocsTableLikeEmbedChildUnitIds, convertBodyToHtml, convertClipboardHtmlToDocumentData, convertClipboardRtfToPlainText, convertPositionsToRectRanges, createDefaultDocsTableLikeCustomBlockBleedViewport, createDocsCustomBlockSizeRefreshScheduler, createEditorUndoRedoKeyboardConfig, deleteCustomDecorationFactory, disableMenuWhenHeaderFooterEditing, disableMenuWithoutDocumentUnitPermission, drawDocCustomRangeChrome, executeEditorUndoRedoCommand, findDocRangeNodePositions, genTableSource, generateParagraphs, getAnchorBounding, getCanvasOffsetByEngine, getCommandSkeleton, getCursorWhenDelete, getCutActionsFromDocRanges, getDocBlockRangeMenuId, getDocObjectById, getEditorRuntimeConfig, getEmptyTableCell, getEmptyTableRow, getLineBounding, getListMarkerFallbackBound, getListParagraphContextMenuHit, getOneTextSelectionRange, getStyleInTextRange, getTableColumn, getTextRangeFromCharIndex, hasParagraphInTable, hideMenuWhenSelectionInBlockRange, isInSameTableCell, isTextRangeInAnyBlockRange, isValidRectRange, neoGetDocObject, normalizeDocFitToWidthOptions, registerEditorRuntimeConfig, removeClipboardHtmlImages, resolveDocCustomRangeChromeTheme, resolveDocFitBaseWidth, resolveDocViewScale, resolveDocsCustomBlockRenderViewport, resolveDocsTableLikeCustomBlockBleedViewport, resolveDocsTableLikeCustomBlockContentHeight, resolveDocsTableLikeCustomBlockContentWidth, scrollDocsTableLikeCustomBlockLive, shouldRefreshDocsCustomBlockSizeForCommand, useEditor, useEditorClickOutside, useIsFocusing, useKeyboardEvent, useLeftAndRightArrow, useOnChange, useResize, whenDocAndEditorFocused };
32919
+ export { AfterSpaceCommand, AlignCenterCommand, AlignJustifyCommand, AlignLeftCommand, AlignMenuItemFactory, AlignOperationCommand, AlignRightCommand, BackgroundColorSelectorMenuItemFactory, BoldMenuItemFactory, BreakLineCommand, BulletListCommand, BulletListTypePicker, ChangeListNestingLevelCommand, ChangeListNestingLevelType, ChangeListTypeCommand, CheckListCommand, CoverContentCommand, CreateDocTableCommand, CutContentCommand, DEFAULT_DOC_FIT_TO_WIDTH_OPTIONS, DOCS_COMPONENT_BACKGROUND_LAYER_INDEX, DOCS_COMPONENT_DEFAULT_Z_INDEX, DOCS_COMPONENT_HEADER_LAYER_INDEX, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_UI_PLUGIN_CONFIG_KEY, DOCS_VIEW_KEY, DOC_CONTENT_INSERT_MENU_ID, DOC_CUSTOM_RANGE_CHROME_BACKGROUND_ALPHA, DOC_CUSTOM_RANGE_CHROME_RADIUS, DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, DOC_PARAGRAPH_T_ALIGN_MENU_ID, DOC_PARAGRAPH_T_COLORS_MENU_ID, DOC_PARAGRAPH_T_DIVIDER_MENU_ID, DOC_PARAGRAPH_T_EDIT_MENU_ID, DOC_PARAGRAPH_T_INSERT_BELOW_MENU_ID, DOC_PARAGRAPH_T_INSERT_MENU_ID, DOC_TABLE_BLOCK_MENU_ID, DOC_VERTICAL_PADDING, DeleteCurrentParagraphCommand, DeleteCustomBlockCommand, DeleteLeftCommand, DeleteRightCommand, DocAutoFormatService, DocBackScrollRenderController, DocCanvasPopManagerService, DocClipboardPasteAdapterService, DocContextualRibbonService, DocCopyCommand, DocCreateTableOperation, DocCutCommand, DocEventManagerService, DocFloatMenuService, DocHtmlExportService, DocIMEInputManagerService, DocLayoutInteractionService, DocMobileElementMenuService, DocPageLayoutService, DocParagraphMenuService, DocParagraphPlaceholderRenderController, DocPasteCommand, DocPrintInterceptorService, DocRenderController, DocSelectAllCommand, DocSelectionRenderService, DocTableDeleteColumnsCommand, DocTableDeleteRowsCommand, DocTableDeleteTableCommand, DocTableInsertColumnCommand, DocTableInsertColumnLeftCommand, DocTableInsertColumnRightCommand, DocTableInsertRowAboveCommand, DocTableInsertRowBellowCommand, DocTableInsertRowCommand, DocTableTabCommand, DocUIController, DocViewScaleService, DocsRenderService, menuSchema as DocsUIMenuSchema, EMPTY_PARAGRAPH_MENU_ID, Editor, EditorColorPicker, EditorService, EnterCommand, FLOAT_TEXT_STYLE_MENU_ID, FLOAT_TOOLBAR_MENU_POSITION, FloatTextStyleMenuItemFactory, FontFamilySelectorMenuItemFactory, FontSizeSelectorMenuItemFactory, HorizontalLineCommand, IDocClipboardPasteAdapterService, IDocClipboardService, IDocEmbedInteractionBoundaryService, IDocEmbedRuntimeFocusCoordinator, IEditorService, IMEInputCommand, INSERT_BELLOW_MENU_ID, InnerPasteCommand, InsertCustomRangeCommand, ItalicMenuItemFactory, ListOperationCommand, MOBILE_DOC_ELEMENT_MENU, MergeTwoParagraphCommand, MobileDocElementMenu, MobileRichTextEditor, MobileRichTextToolbar, MoveCursorOperation, MoveDocBlockCommand, MoveSelectionOperation, NORMAL_TEXT_SELECTION_PLUGIN_NAME, NodePositionConvertToCursor, NodePositionConvertToRectRange, OrderListCommand, OrderListTypePicker, ParagraphMenuInsertBelowSubmenuItemFactory, ParagraphSettingMenuFactory, LarkPastePlugin as PastePluginLark, UniverPastePlugin as PastePluginUniver, WordPastePlugin as PastePluginWord, QuickListCommand, RectRange, ReplaceSelectionCommand, ReplaceSnapshotCommand, ReplaceTextRunsCommand, ResetInlineFormatTextBackgroundColorCommand, ResetInlineFormatTextColorCommand, RichTextEditor, SetDocInputStyleCommand, SetDocZoomRatioCommand, SetDocZoomRatioOperation, SetInlineFormatBoldCommand, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, SetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextColorCommand, SetInlineFormatTextFillCommand, SetInlineFormatUnderlineCommand, SetParagraphNamedStyleCommand, StrikeThroughMenuItemFactory, SwitchDocModeCommand, TEXT_RANGE_LAYER_INDEX, TabCommand, TextColorSelectorMenuItemFactory, TextRange, ToggleCheckListCommand, UnderlineMenuItemFactory, UniverDocsMobileUIPlugin, UniverDocsUIPlugin, VIEWPORT_KEY, addCustomDecorationBySelectionFactory, addCustomDecorationFactory, buildMoveDocBlockActions, calcDocFitToWidthScale, calcDocRangePositions, captureTextFormat, collectDocsTableLikeEmbedChildUnitIds, convertBodyToHtml, convertClipboardHtmlToDocumentData, convertClipboardRtfToPlainText, convertPositionsToRectRanges, createDefaultDocsTableLikeCustomBlockBleedViewport, createDocsCustomBlockSizeRefreshScheduler, createEditorUndoRedoKeyboardConfig, deleteCustomDecorationFactory, disableMenuWhenHeaderFooterEditing, disableMenuWithoutDocumentUnitPermission, drawDocCustomRangeChrome, executeEditorUndoRedoCommand, findDocRangeNodePositions, genTableSource, generateParagraphs, getAnchorBounding, getCanvasOffsetByEngine, getCommandSkeleton, getCursorWhenDelete, getCutActionsFromDocRanges, getDocBlockRangeMenuId, getDocObjectById, getEditorRuntimeConfig, getEmptyTableCell, getEmptyTableRow, getLineBounding, getListMarkerFallbackBound, getListParagraphContextMenuHit, getOneTextSelectionRange, getStyleInTextRange, getTableColumn, getTextRangeFromCharIndex, hasParagraphInTable, hideMenuWhenSelectionInBlockRange, isInSameTableCell, isTextRangeInAnyBlockRange, isValidRectRange, neoGetDocObject, normalizeDocFitToWidthOptions, registerEditorRuntimeConfig, removeClipboardHtmlImages, resolveDocCustomRangeChromeTheme, resolveDocFitBaseWidth, resolveDocViewScale, resolveDocsCustomBlockRenderViewport, resolveDocsTableLikeCustomBlockBleedViewport, resolveDocsTableLikeCustomBlockContentHeight, resolveDocsTableLikeCustomBlockContentWidth, scrollDocsTableLikeCustomBlockLive, shouldRefreshDocsCustomBlockSizeForCommand, useEditor, useEditorClickOutside, useIsFocusing, useKeyboardEvent, useLeftAndRightArrow, useOnChange, useResize, whenDocAndEditorFocused };