@univerjs/docs-ui 1.0.3 → 1.1.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 (109) hide show
  1. package/lib/cjs/index.js +1600 -475
  2. package/lib/cjs/locale/ar-SA.js +14 -0
  3. package/lib/cjs/locale/ca-ES.js +14 -0
  4. package/lib/cjs/locale/de-DE.js +14 -0
  5. package/lib/cjs/locale/en-US.js +14 -0
  6. package/lib/cjs/locale/es-ES.js +14 -0
  7. package/lib/cjs/locale/fa-IR.js +14 -0
  8. package/lib/cjs/locale/fr-FR.js +14 -0
  9. package/lib/cjs/locale/id-ID.js +14 -0
  10. package/lib/cjs/locale/it-IT.js +14 -0
  11. package/lib/cjs/locale/ja-JP.js +14 -0
  12. package/lib/cjs/locale/ko-KR.js +14 -0
  13. package/lib/cjs/locale/pl-PL.js +14 -0
  14. package/lib/cjs/locale/pt-BR.js +14 -0
  15. package/lib/cjs/locale/ru-RU.js +14 -0
  16. package/lib/cjs/locale/sk-SK.js +14 -0
  17. package/lib/cjs/locale/vi-VN.js +14 -0
  18. package/lib/cjs/locale/zh-CN.js +14 -0
  19. package/lib/cjs/locale/zh-HK.js +14 -0
  20. package/lib/cjs/locale/zh-TW.js +14 -0
  21. package/lib/es/index.js +1585 -466
  22. package/lib/es/locale/ar-SA.js +14 -0
  23. package/lib/es/locale/ca-ES.js +14 -0
  24. package/lib/es/locale/de-DE.js +14 -0
  25. package/lib/es/locale/en-US.js +14 -0
  26. package/lib/es/locale/es-ES.js +14 -0
  27. package/lib/es/locale/fa-IR.js +14 -0
  28. package/lib/es/locale/fr-FR.js +14 -0
  29. package/lib/es/locale/id-ID.js +14 -0
  30. package/lib/es/locale/it-IT.js +14 -0
  31. package/lib/es/locale/ja-JP.js +14 -0
  32. package/lib/es/locale/ko-KR.js +14 -0
  33. package/lib/es/locale/pl-PL.js +14 -0
  34. package/lib/es/locale/pt-BR.js +14 -0
  35. package/lib/es/locale/ru-RU.js +14 -0
  36. package/lib/es/locale/sk-SK.js +14 -0
  37. package/lib/es/locale/vi-VN.js +14 -0
  38. package/lib/es/locale/zh-CN.js +14 -0
  39. package/lib/es/locale/zh-HK.js +14 -0
  40. package/lib/es/locale/zh-TW.js +14 -0
  41. package/lib/index.css +26 -4
  42. package/lib/index.js +1585 -466
  43. package/lib/locale/ar-SA.js +14 -0
  44. package/lib/locale/ca-ES.js +14 -0
  45. package/lib/locale/de-DE.js +14 -0
  46. package/lib/locale/en-US.js +14 -0
  47. package/lib/locale/es-ES.js +14 -0
  48. package/lib/locale/fa-IR.js +14 -0
  49. package/lib/locale/fr-FR.js +14 -0
  50. package/lib/locale/id-ID.js +14 -0
  51. package/lib/locale/it-IT.js +14 -0
  52. package/lib/locale/ja-JP.js +14 -0
  53. package/lib/locale/ko-KR.js +14 -0
  54. package/lib/locale/pl-PL.js +14 -0
  55. package/lib/locale/pt-BR.js +14 -0
  56. package/lib/locale/ru-RU.js +14 -0
  57. package/lib/locale/sk-SK.js +14 -0
  58. package/lib/locale/vi-VN.js +14 -0
  59. package/lib/locale/zh-CN.js +14 -0
  60. package/lib/locale/zh-HK.js +14 -0
  61. package/lib/locale/zh-TW.js +14 -0
  62. package/lib/types/commands/commands/doc-delete.command.d.ts +5 -2
  63. package/lib/types/commands/commands/doc-header-footer.command.d.ts +2 -0
  64. package/lib/types/commands/commands/insert-header-footer-field.command.d.ts +28 -0
  65. package/lib/types/commands/commands/refresh-header-footer-fields.command.d.ts +22 -0
  66. package/lib/types/commands/operations/doc-header-footer-ribbon.operation.d.ts +19 -0
  67. package/lib/types/controllers/doc-header-footer-ribbon.controller.d.ts +31 -0
  68. package/lib/types/controllers/render-controllers/doc-field.render-controller.d.ts +31 -0
  69. package/lib/types/controllers/ui.controller.d.ts +1 -0
  70. package/lib/types/index.d.ts +1 -0
  71. package/lib/types/locale/en-US.d.ts +14 -0
  72. package/lib/types/menu/display.menu.d.ts +21 -0
  73. package/lib/types/menu/header-footer-ribbon.d.ts +17 -0
  74. package/lib/types/services/clipboard/clipboard.service.d.ts +4 -0
  75. package/lib/types/services/doc-event-manager.service.d.ts +1 -0
  76. package/lib/types/services/doc-paragraph-menu.service.d.ts +11 -2
  77. package/lib/types/services/doc-zoom.d.ts +4 -1
  78. package/lib/types/services/selection/doc-selection-render.service.d.ts +2 -0
  79. package/lib/types/services/selection/word-boundary.d.ts +1 -0
  80. package/lib/types/shortcuts/core-editing.shortcut.d.ts +4 -0
  81. package/lib/types/shortcuts/format.shortcut.d.ts +1 -0
  82. package/lib/types/shortcuts/utils.d.ts +1 -0
  83. package/lib/types/utils/date-time-field.d.ts +22 -0
  84. package/lib/types/views/header-footer/panel/DocHeaderFooterFields.d.ts +19 -0
  85. package/lib/types/views/header-footer/panel/DocHeaderFooterRibbonControl.d.ts +20 -0
  86. package/lib/types/views/header-footer/panel/component-name.d.ts +2 -0
  87. package/lib/types/views/header-footer/panel/use-header-footer-options.d.ts +2 -2
  88. package/lib/umd/facade.js +1 -1
  89. package/lib/umd/index.js +16 -15
  90. package/lib/umd/locale/ar-SA.js +1 -1
  91. package/lib/umd/locale/ca-ES.js +1 -1
  92. package/lib/umd/locale/de-DE.js +1 -1
  93. package/lib/umd/locale/en-US.js +1 -1
  94. package/lib/umd/locale/es-ES.js +1 -1
  95. package/lib/umd/locale/fa-IR.js +1 -1
  96. package/lib/umd/locale/fr-FR.js +1 -1
  97. package/lib/umd/locale/id-ID.js +1 -1
  98. package/lib/umd/locale/it-IT.js +1 -1
  99. package/lib/umd/locale/ja-JP.js +1 -1
  100. package/lib/umd/locale/ko-KR.js +1 -1
  101. package/lib/umd/locale/pl-PL.js +1 -1
  102. package/lib/umd/locale/pt-BR.js +1 -1
  103. package/lib/umd/locale/ru-RU.js +1 -1
  104. package/lib/umd/locale/sk-SK.js +1 -1
  105. package/lib/umd/locale/vi-VN.js +1 -1
  106. package/lib/umd/locale/zh-CN.js +1 -1
  107. package/lib/umd/locale/zh-HK.js +1 -1
  108. package/lib/umd/locale/zh-TW.js +1 -1
  109. package/package.json +13 -13
package/lib/es/index.js CHANGED
@@ -1,15 +1,15 @@
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_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 } from "@univerjs/docs";
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";
3
3
  import * as EngineRender from "@univerjs/engine-render";
4
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";
5
- import { Button, Checkbox, Dropdown, DropdownMenu, InputNumber, MessageType, MobileSelect, Popup, Select, Separator, Tooltip, borderClassName, clsx, resetButtonClassName, scrollbarClassName, 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, SYMBOL_PICKER_COMPONENT, Slider, ToolbarButton, ToolbarItem, UniverMobileUIPlugin, bindFormatPainterCanvas, connectInjector, getMenuHiddenObservable, getMobileCanvasPanDelta, imageMimeTypeSet, objectPermissionMenuItemFactory, openObjectPermissionDialog, openObjectPermissionPanel, preventBrowserZoomInContainers, useConfigValue, useDependency, useEvent, useInjector, useMobileCanvasPanel, useMobileCanvasViewport, useObservable } from "@univerjs/ui";
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";
7
7
  import { UnitAction, UnitObject } from "@univerjs/protocol";
8
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";
9
9
  import { bufferTime, filter as filter$1, map as map$1 } from "rxjs/operators";
10
- import { createElement, forwardRef, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
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";
12
- import { AddImageIcon, AlignTextBothIcon, BoldIcon, CatalogueIcon, CheckMarkIcon, CloseIcon, ColorWheelMultiIcon, ColumnIcon, CopyDoubleIcon, CutIcon, DeleteColumnDoubleIcon, DeleteIcon, DeleteRowDoubleIcon, DeleteTableDoubleIcon, DocPasteOptionsIcon, DocSettingIcon, DownIcon, FontColorDoubleIcon, GridIcon, H1Icon, H2Icon, H3Icon, H4Icon, H5Icon, HeaderFooterIcon, HorizontallyIcon, InsertDoubleIcon, InsertRowAboveDoubleIcon, InsertRowBelowDoubleIcon, ItalicIcon, KeyboardIcon, LeftInsertColumnDoubleIcon, LeftJustifyingIcon, LineIndentDecreaseIcon, LineIndentIncreaseIcon, LoadingMultiIcon, MenuIcon, MoreHorizontalIcon, MoreLeftIcon, MoreRightIcon, NoColorDoubleIcon, OrderIcon, PaintBucketDoubleIcon, ParagraphSettingIcon, PasteSpecialDoubleIcon, QuickAddIcon, ReduceDoubleIcon, ReduceIcon, RightInsertColumnDoubleIcon, RightJustifyingIcon, SectionSettingIcon, ShapeIcon, SmileIcon, StatisticalFunctionIcon, StrikethroughIcon, SubscriptIcon, SubtitleTypeIcon, SuperscriptIcon, SymbolsIcon, TextColorSwatchDoubleIcon, TextIcon, TextTypeIcon, TitleTypeIcon, TodoListDoubleIcon, UnderlineIcon, UnorderIcon, WriteIcon } from "@univerjs/icons";
12
+ import { AddImageIcon, AlignTextBothIcon, BoldIcon, CalendarIcon, CatalogueIcon, CheckMarkIcon, CloseIcon, ColorWheelMultiIcon, ColumnIcon, CopyDoubleIcon, CutIcon, DeleteColumnDoubleIcon, DeleteIcon, DeleteRowDoubleIcon, DeleteTableDoubleIcon, DocPasteOptionsIcon, DocSettingIcon, DownIcon, FontColorDoubleIcon, GridIcon, H1Icon, H2Icon, H3Icon, H4Icon, H5Icon, HeaderFooterIcon, HorizontallyIcon, InsertBelowDoubleIcon, InsertDoubleIcon, InsertRowAboveDoubleIcon, InsertRowBelowDoubleIcon, ItalicIcon, KeyboardIcon, LeftInsertColumnDoubleIcon, LeftJustifyingIcon, LineIndentDecreaseIcon, LineIndentIncreaseIcon, LoadingMultiIcon, MenuIcon, MoreDownIcon, MoreHorizontalIcon, MoreLeftIcon, MoreRightIcon, NoColorDoubleIcon, NumberIcon, OrderIcon, PaintBucketDoubleIcon, ParagraphSettingIcon, PasteSpecialDoubleIcon, QuickAddIcon, ReduceDoubleIcon, ReduceIcon, RightInsertColumnDoubleIcon, RightJustifyingIcon, SectionSettingIcon, ShapeIcon, SmileIcon, StatisticalFunctionIcon, StrikethroughIcon, SubscriptIcon, SubtitleTypeIcon, SuperscriptIcon, SymbolsIcon, TextColorSwatchDoubleIcon, TextIcon, TextTypeIcon, TitleTypeIcon, TodoListDoubleIcon, UnderlineIcon, UnorderIcon, WriteIcon, ZoomInIcon } from "@univerjs/icons";
13
13
  import { getDrawingShapeKeyByDrawingSearch } from "@univerjs/drawing";
14
14
 
15
15
  //#region src/basics/docs-view-key.ts
@@ -242,7 +242,7 @@ function getCustomDecorationAtPosition(customDecorations, position) {
242
242
  }
243
243
 
244
244
  //#endregion
245
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
245
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
246
246
  function _typeof(o) {
247
247
  "@babel/helpers - typeof";
248
248
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -253,7 +253,7 @@ function _typeof(o) {
253
253
  }
254
254
 
255
255
  //#endregion
256
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
256
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
257
257
  function toPrimitive(t, r) {
258
258
  if ("object" != _typeof(t) || !t) return t;
259
259
  var e = t[Symbol.toPrimitive];
@@ -266,14 +266,14 @@ function toPrimitive(t, r) {
266
266
  }
267
267
 
268
268
  //#endregion
269
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
269
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
270
270
  function toPropertyKey(t) {
271
271
  var i = toPrimitive(t, "string");
272
272
  return "symbol" == _typeof(i) ? i : i + "";
273
273
  }
274
274
 
275
275
  //#endregion
276
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
276
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
277
277
  function _defineProperty(e, r, t) {
278
278
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
279
279
  value: t,
@@ -284,7 +284,7 @@ function _defineProperty(e, r, t) {
284
284
  }
285
285
 
286
286
  //#endregion
287
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
287
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
288
288
  function __decorateParam(paramIndex, decorator) {
289
289
  return function(target, key) {
290
290
  decorator(target, key, paramIndex);
@@ -292,7 +292,7 @@ function __decorateParam(paramIndex, decorator) {
292
292
  }
293
293
 
294
294
  //#endregion
295
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
295
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
296
296
  function __decorate(decorators, target, key, desc) {
297
297
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
298
298
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -408,8 +408,8 @@ let DocMenuStyleService = class DocMenuStyleService extends Disposable {
408
408
  }));
409
409
  }
410
410
  _listenDocRangeChange() {
411
- this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(() => {
412
- this._clearStyleCache();
411
+ this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(({ options }) => {
412
+ if (!(options === null || options === void 0 ? void 0 : options.preserveInputStyle)) this._clearStyleCache();
413
413
  }));
414
414
  }
415
415
  getStyleCache() {
@@ -1643,10 +1643,10 @@ var NodePositionConvertToCursor = class {
1643
1643
  let segmentPage = page;
1644
1644
  if (pageType === DocumentSkeletonPageType.HEADER) {
1645
1645
  var _skeHeaders$get;
1646
- segmentPage = (_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(pageWidth);
1646
+ segmentPage = (_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(page.headerLayoutKey ?? pageWidth);
1647
1647
  } else if (pageType === DocumentSkeletonPageType.FOOTER) {
1648
1648
  var _skeFooters$get;
1649
- segmentPage = (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(pageWidth);
1649
+ segmentPage = (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(page.footerLayoutKey ?? pageWidth);
1650
1650
  } else if (pageType === DocumentSkeletonPageType.NOTE) {
1651
1651
  var _getPageFromPath3, _page$notes;
1652
1652
  const noteId = (_getPageFromPath3 = getPageFromPath(skeletonData, path)) === null || _getPageFromPath3 === void 0 ? void 0 : _getPageFromPath3.segmentId;
@@ -1813,8 +1813,8 @@ function getCellPageFromSegmentPath(skeletonData, rootPage, path) {
1813
1813
  if (path[0] === "pages") return null;
1814
1814
  const segmentPages = [];
1815
1815
  const { headerId, footerId, pageWidth } = rootPage;
1816
- const headerPage = headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(pageWidth);
1817
- const footerPage = footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(pageWidth);
1816
+ const headerPage = headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(rootPage.headerLayoutKey ?? pageWidth);
1817
+ const footerPage = footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(rootPage.footerLayoutKey ?? pageWidth);
1818
1818
  if (headerPage != null) segmentPages.push(headerPage);
1819
1819
  if (footerPage != null) segmentPages.push(footerPage);
1820
1820
  for (const segmentPage of segmentPages) {
@@ -2229,7 +2229,7 @@ function getCellPageFromPositionPath(skeletonData, position) {
2229
2229
  const rootPage = skeletonData.pages[segmentPage];
2230
2230
  if (rootPage == null) return null;
2231
2231
  const { headerId, footerId, pageWidth } = rootPage;
2232
- const segmentPages = [headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(pageWidth), footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(pageWidth)];
2232
+ const segmentPages = [headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(rootPage.headerLayoutKey ?? pageWidth), footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(rootPage.footerLayoutKey ?? pageWidth)];
2233
2233
  for (const segmentPage of segmentPages) {
2234
2234
  if (segmentPage == null) continue;
2235
2235
  const page = getPageFromPath({
@@ -3169,6 +3169,20 @@ function getWordBoundaryByIndex(content, nodeIndex, paragraphStartOffset) {
3169
3169
  endOffset: paragraphStartOffset + range.end
3170
3170
  };
3171
3171
  }
3172
+ function getWordSelectionByIndex(content, nodeIndex, paragraphStartOffset, isBack) {
3173
+ var _segments;
3174
+ const text = content.replace(/[\r\n]+$/, "");
3175
+ if (!text.length || nodeIndex < 0) return null;
3176
+ const index = Math.min(nodeIndex, text.length - 1);
3177
+ const segments = Array.from(new Intl.Segmenter(void 0, { granularity: "word" }).segment(text));
3178
+ const segmentIndex = segments.findIndex((segment) => segment.index <= index && index < segment.index + segment.segment.length);
3179
+ const segment = segments[segmentIndex];
3180
+ const whitespace = /^\s+$/.test(segment.segment);
3181
+ return {
3182
+ startOffset: paragraphStartOffset + (whitespace ? ((_segments = segments[segmentIndex - 1]) === null || _segments === void 0 ? void 0 : _segments.index) ?? segment.index : segment.index),
3183
+ endOffset: paragraphStartOffset + (whitespace ? Math.min(nodeIndex + (isBack ? 0 : 1), text.length) : segment.index + segment.segment.length)
3184
+ };
3185
+ }
3172
3186
  function getNextWordBoundaryOffset(content, nodeIndex, paragraphStartOffset, direction) {
3173
3187
  if (nodeIndex < 0) return null;
3174
3188
  const ranges = getWordRanges(content);
@@ -3198,6 +3212,12 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
3198
3212
  get isFocusing() {
3199
3213
  return this._input === this._getOwnerDocument().activeElement;
3200
3214
  }
3215
+ get inputElement() {
3216
+ return this._input;
3217
+ }
3218
+ get selectionContainer() {
3219
+ return this._container;
3220
+ }
3201
3221
  get isEditing() {
3202
3222
  var _this$_textSelectionI;
3203
3223
  return ((_this$_textSelectionI = this._textSelectionInner$.value) === null || _this$_textSelectionI === void 0 ? void 0 : _this$_textSelectionI.isEditing) === true;
@@ -3331,15 +3351,13 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
3331
3351
  this._selectionStyle = style;
3332
3352
  }
3333
3353
  replaceDocRanges(ranges, isEditing = true, options) {
3334
- var _this$_context$unit$g;
3335
3354
  if (this._onPointerEvent) {
3336
3355
  this._pendingSelection = null;
3337
3356
  return false;
3338
3357
  }
3339
3358
  this._syncNoteSegment(ranges[0]);
3340
- const isBodyOrNote = this._currentSegmentId === "" || ((_this$_context$unit$g = this._context.unit.getSnapshot().notes) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g[this._currentSegmentId]) != null;
3341
3359
  let currentLogicalSelection = null;
3342
- if (isBodyOrNote && ranges.length > 0) {
3360
+ if (ranges.length > 0) {
3343
3361
  const { unitId } = this._context;
3344
3362
  const selection = this._docSelectionManagerService.getSelectionInfo({
3345
3363
  unitId,
@@ -3412,7 +3430,12 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
3412
3430
  this._addRectRanges(rectRanges);
3413
3431
  };
3414
3432
  for (const range of ranges) {
3415
- const { startOffset, endOffset, rangeType, startNodePosition, endNodePosition } = range;
3433
+ const { rangeType } = range;
3434
+ let { startOffset, endOffset, startNodePosition, endNodePosition } = range;
3435
+ if (rangeType !== DOC_RANGE_TYPE.RECT && range.direction === RANGE_DIRECTION.BACKWARD && startOffset < endOffset) {
3436
+ [startOffset, endOffset] = [endOffset, startOffset];
3437
+ [startNodePosition, endNodePosition] = [endNodePosition, startNodePosition];
3438
+ }
3416
3439
  const rangeStyle = range.style ?? style;
3417
3440
  if (rangeType !== DOC_RANGE_TYPE.RECT && startOffset === endOffset) {
3418
3441
  const textRange = cursorConvertToTextRange(scene, {
@@ -3430,7 +3453,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
3430
3453
  if (startNodePosition && endNodePosition) textRange = getTextRangeFromCharIndex(startNodePosition.isBack ? startOffset : startOffset - 1, endNodePosition.isBack ? endOffset : endOffset - 1, scene, document, docSkeleton, rangeStyle, segmentId, segmentPage, startNodePosition.isBack, endNodePosition.isBack);
3431
3454
  else textRange = getTextRangeFromCharIndex(startOffset, endOffset, scene, document, docSkeleton, rangeStyle, segmentId, segmentPage);
3432
3455
  if (textRange) this._addTextRange(textRange);
3433
- } catch (_e) {
3456
+ } catch {
3434
3457
  generalAddRange(startOffset, endOffset, rangeStyle);
3435
3458
  }
3436
3459
  else generalAddRange(startOffset, endOffset, rangeStyle);
@@ -3520,7 +3543,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
3520
3543
  if (paragraphInfo == null) return;
3521
3544
  const { content, st, nodeIndex } = paragraphInfo;
3522
3545
  if (nodeIndex === -1) return;
3523
- const wordBoundary = getWordBoundaryByIndex(content, nodeIndex, st);
3546
+ const wordBoundary = this._context.unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY || this._context.unitId === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY ? getWordSelectionByIndex(content, nodeIndex, st, startNode.ratioX < .5) : getWordBoundaryByIndex(content, nodeIndex, st);
3524
3547
  if (wordBoundary != null) {
3525
3548
  this.removeAllRanges();
3526
3549
  const textRanges = [{
@@ -4109,10 +4132,26 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
4109
4132
  }));
4110
4133
  }
4111
4134
  _refreshMissingInputRange(config) {
4135
+ var _this$_context$unit$g;
4112
4136
  if (config.activeRange == null) {
4113
4137
  config.activeRange = this._getActiveRange();
4114
4138
  config.rangeList = this._getAllTextRanges();
4115
4139
  }
4140
+ const { unitId } = this._context;
4141
+ if (config.activeRange != null || unitId !== DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY || ((_this$_context$unit$g = this._context.unit.getBody()) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.dataStream) !== "\r\n") return;
4142
+ const selection = this._docSelectionManagerService.getSelectionInfo({
4143
+ unitId,
4144
+ subUnitId: unitId
4145
+ });
4146
+ if (selection == null || selection.textRanges.length !== 1 || selection.rectRanges.length > 0) return;
4147
+ const caret = selection.textRanges[0];
4148
+ if (!caret.isActive || caret.startOffset !== 0 || caret.endOffset !== 0) return;
4149
+ config.activeRange = {
4150
+ ...caret,
4151
+ segmentId: selection.segmentId,
4152
+ segmentPage: selection.segmentPage
4153
+ };
4154
+ config.rangeList = [config.activeRange];
4116
4155
  }
4117
4156
  _handleInputFocus(event) {
4118
4157
  this._eventHandle(event, (config) => {
@@ -5657,7 +5696,7 @@ const CutContentCommand = {
5657
5696
  id: "doc.command.inner-cut",
5658
5697
  type: CommandType.COMMAND,
5659
5698
  handler: (accessor, params) => {
5660
- var _selectionInfo$option3;
5699
+ var _selectionInfo$option3, _docDataModel$getSelf7;
5661
5700
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
5662
5701
  const commandService = accessor.get(ICommandService);
5663
5702
  const univerInstanceService = accessor.get(IUniverInstanceService);
@@ -5677,12 +5716,19 @@ const CutContentCommand = {
5677
5716
  const docSkeletonManagerService = getCommandSkeleton(accessor, unitId);
5678
5717
  if (docSkeletonManagerService == null) return false;
5679
5718
  const viewModel = docSkeletonManagerService.getViewModel();
5719
+ const body = (_docDataModel$getSelf7 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf7 === void 0 ? void 0 : _docDataModel$getSelf7.getBody();
5720
+ const clearsBody = wholeBodySelected || body != null && isWholeBodySelected(selections, rectRanges, body);
5680
5721
  const doMutation = {
5681
5722
  id: RichTextEditingMutation.id,
5682
5723
  params: {
5683
5724
  unitId,
5684
5725
  actions: [],
5685
- textRanges,
5726
+ textRanges: clearsBody ? [{
5727
+ ...textRanges[0],
5728
+ startOffset: 0,
5729
+ endOffset: 0,
5730
+ collapsed: true
5731
+ }] : textRanges,
5686
5732
  trigger: CutContentCommand.id
5687
5733
  }
5688
5734
  };
@@ -5699,6 +5745,31 @@ function isHorizontalLineParagraph(dataStream, paragraph) {
5699
5745
  return Array.from(dataStream).every((token) => token === DataStreamTreeTokenType.PARAGRAPH || token === DataStreamTreeTokenType.SECTION_BREAK) && (paragraphStyle === null || paragraphStyle === void 0 ? void 0 : paragraphStyle.borderBottom) != null && paragraphStyle.borderTop == null && paragraphStyle.borderLeft == null && paragraphStyle.borderRight == null && paragraphStyle.borderBetween == null;
5700
5746
  }
5701
5747
 
5748
+ //#endregion
5749
+ //#region src/commands/operations/doc-cursor.operation.ts
5750
+ /**
5751
+ * The operation to move cursor in the current document.
5752
+ */
5753
+ const MoveCursorOperation = {
5754
+ id: "doc.operation.move-cursor",
5755
+ type: CommandType.OPERATION,
5756
+ handler: (accessor, params) => {
5757
+ if (!params) return false;
5758
+ return true;
5759
+ }
5760
+ };
5761
+ /**
5762
+ * The operation to move selection in the current document.
5763
+ */
5764
+ const MoveSelectionOperation = {
5765
+ id: "doc.operation.move-selection",
5766
+ type: CommandType.OPERATION,
5767
+ handler: (accessor, params) => {
5768
+ if (!params) return false;
5769
+ return true;
5770
+ }
5771
+ };
5772
+
5702
5773
  //#endregion
5703
5774
  //#region src/commands/commands/format-painter.command.ts
5704
5775
  function captureTextFormat(body, range, defaultStyle = {}, lists = {}, document = { documentStyle: {} }) {
@@ -6112,11 +6183,25 @@ function isDeleteOffsetInsideBlockRange(body, offset) {
6112
6183
  return interval.startOffset < offset && offset < interval.endOffset - 1;
6113
6184
  })) ?? false;
6114
6185
  }
6186
+ function selectDeleteBoundary(accessor, direction, granularity) {
6187
+ var _selections$getActive, _selections$getRectRa;
6188
+ const selections = accessor.get(DocSelectionManagerService);
6189
+ if (((_selections$getActive = selections.getActiveTextRange()) === null || _selections$getActive === void 0 ? void 0 : _selections$getActive.collapsed) && !((_selections$getRectRa = selections.getRectRanges()) === null || _selections$getRectRa === void 0 ? void 0 : _selections$getRectRa.length)) {
6190
+ var _selections$getActive2;
6191
+ accessor.get(ICommandService).syncExecuteCommand(MoveSelectionOperation.id, {
6192
+ direction,
6193
+ granularity
6194
+ });
6195
+ return ((_selections$getActive2 = selections.getActiveTextRange()) === null || _selections$getActive2 === void 0 ? void 0 : _selections$getActive2.collapsed) === false;
6196
+ }
6197
+ return true;
6198
+ }
6115
6199
  const DeleteLeftCommand = {
6116
6200
  id: "doc.command.delete-left",
6117
6201
  type: CommandType.COMMAND,
6118
- handler: async (accessor) => {
6202
+ handler: async (accessor, params) => {
6119
6203
  var _docDataModel$getSelf3, _docDataModel$getSelf4;
6204
+ if ((params === null || params === void 0 ? void 0 : params.granularity) && !selectDeleteBoundary(accessor, Direction.LEFT, params.granularity)) return true;
6120
6205
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
6121
6206
  const univerInstanceService = accessor.get(IUniverInstanceService);
6122
6207
  const commandService = accessor.get(ICommandService);
@@ -6276,8 +6361,9 @@ const DeleteLeftCommand = {
6276
6361
  const DeleteRightCommand = {
6277
6362
  id: "doc.command.delete-right",
6278
6363
  type: CommandType.COMMAND,
6279
- handler: async (accessor) => {
6364
+ handler: async (accessor, params) => {
6280
6365
  var _docDataModel$getSelf5;
6366
+ if ((params === null || params === void 0 ? void 0 : params.granularity) && !selectDeleteBoundary(accessor, Direction.RIGHT, params.granularity)) return true;
6281
6367
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
6282
6368
  const docDataModel = accessor.get(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
6283
6369
  if (!docDataModel) return false;
@@ -8452,23 +8538,39 @@ function getTableClipboardBodySlice(body, range) {
8452
8538
  return getTableCellContentClipboardBodySlice(body, startOffset, endOffset);
8453
8539
  }
8454
8540
  function getTableCellContentClipboardBodySlice(body, start, end) {
8455
- var _bodySlice$textRuns, _bodySlice$tables, _bodySlice$paragraphs;
8541
+ var _bodySlice$textRuns, _bodySlice$docxExport;
8456
8542
  const bodySlice = getBodySlice(body, start, end + 2);
8457
- bodySlice.dataStream = DataStreamTreeTokenType.TABLE_START + DataStreamTreeTokenType.TABLE_ROW_START + DataStreamTreeTokenType.TABLE_CELL_START + bodySlice.dataStream + DataStreamTreeTokenType.TABLE_CELL_END + DataStreamTreeTokenType.TABLE_ROW_END + DataStreamTreeTokenType.TABLE_END;
8543
+ const prefix = DataStreamTreeTokenType.TABLE_START + DataStreamTreeTokenType.TABLE_ROW_START + DataStreamTreeTokenType.TABLE_CELL_START;
8544
+ bodySlice.dataStream = prefix + bodySlice.dataStream + DataStreamTreeTokenType.TABLE_CELL_END + DataStreamTreeTokenType.TABLE_ROW_END + DataStreamTreeTokenType.TABLE_END;
8545
+ const offset = prefix.length;
8458
8546
  (_bodySlice$textRuns = bodySlice.textRuns) === null || _bodySlice$textRuns === void 0 || _bodySlice$textRuns.forEach((textRun) => {
8459
- const { st, ed } = textRun;
8460
- textRun.st = st + 3;
8461
- textRun.ed = ed + 3;
8462
- });
8463
- (_bodySlice$tables = bodySlice.tables) === null || _bodySlice$tables === void 0 || _bodySlice$tables.forEach((table) => {
8464
- const { startIndex, endIndex } = table;
8465
- table.startIndex = startIndex + 3;
8466
- table.endIndex = endIndex + 3;
8547
+ textRun.st += offset;
8548
+ textRun.ed += offset;
8467
8549
  });
8468
- (_bodySlice$paragraphs = bodySlice.paragraphs) === null || _bodySlice$paragraphs === void 0 || _bodySlice$paragraphs.forEach((paragraph) => {
8469
- const { startIndex } = paragraph;
8470
- paragraph.startIndex = startIndex + 3;
8550
+ [
8551
+ bodySlice.paragraphs,
8552
+ bodySlice.sectionBreaks,
8553
+ bodySlice.customBlocks,
8554
+ bodySlice.docxRawCustomBlocks,
8555
+ bodySlice.docxRawBlocks
8556
+ ].forEach((items) => items === null || items === void 0 ? void 0 : items.forEach((item) => {
8557
+ item.startIndex += offset;
8558
+ }));
8559
+ [
8560
+ bodySlice.tables,
8561
+ bodySlice.columnGroups,
8562
+ bodySlice.blockRanges,
8563
+ bodySlice.customRanges,
8564
+ bodySlice.customDecorations
8565
+ ].forEach((ranges) => ranges === null || ranges === void 0 ? void 0 : ranges.forEach((range) => {
8566
+ range.startIndex += offset;
8567
+ range.endIndex += offset;
8568
+ }));
8569
+ (_bodySlice$docxExport = bodySlice.docxExportExcludedRanges) === null || _bodySlice$docxExport === void 0 || _bodySlice$docxExport.forEach((range) => {
8570
+ range.start += offset;
8571
+ range.end += offset;
8471
8572
  });
8573
+ if (bodySlice.renderedPageBreaks) bodySlice.renderedPageBreaks = bodySlice.renderedPageBreaks.map((index) => index + offset);
8472
8574
  return bodySlice;
8473
8575
  }
8474
8576
  const IDocClipboardService = createIdentifier("doc.clipboard-service");
@@ -8498,7 +8600,11 @@ let DocClipboardService = class DocClipboardService extends Disposable {
8498
8600
  _defineProperty(this, "_umdToHtml", void 0);
8499
8601
  this._umdToHtml = new UDMToHtmlService(docHtmlExportService);
8500
8602
  this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
8501
- if (!this._applyingPaste && command.type === CommandType.MUTATION) this.dismissPasteOptions();
8603
+ var _command$params, _this$_pasteOptions$$;
8604
+ if (this._applyingPaste || command.type !== CommandType.MUTATION) return;
8605
+ const unitId = (_command$params = command.params) === null || _command$params === void 0 ? void 0 : _command$params.unitId;
8606
+ const pasteUnitId = ((_this$_pasteOptions$$ = this._pasteOptions$.value) === null || _this$_pasteOptions$$ === void 0 ? void 0 : _this$_pasteOptions$$.unitId) ?? this._getCurrentDocumentUnitId();
8607
+ if (!unitId || unitId === pasteUnitId) this.dismissPasteOptions();
8502
8608
  }));
8503
8609
  const invalidateSelection = () => {
8504
8610
  const key = this._getPasteSelectionKey();
@@ -8572,6 +8678,12 @@ let DocClipboardService = class DocClipboardService extends Disposable {
8572
8678
  mode
8573
8679
  });
8574
8680
  }
8681
+ isPasteOptionsEnabled(unitId) {
8682
+ return !isInternalEditorID(unitId) || this._clipboardHooks.some((hook) => {
8683
+ var _hook$supportsPasteOp;
8684
+ return (_hook$supportsPasteOp = hook.supportsPasteOptions) === null || _hook$supportsPasteOp === void 0 ? void 0 : _hook$supportsPasteOp.call(hook, unitId);
8685
+ });
8686
+ }
8575
8687
  setNextPasteMode(mode) {
8576
8688
  this._nextPasteMode = mode;
8577
8689
  }
@@ -8662,7 +8774,7 @@ let DocClipboardService = class DocClipboardService extends Disposable {
8662
8774
  try {
8663
8775
  this._stateChangeManager.flushPendingChanges(unitId);
8664
8776
  const result = this._paste(doc, unitId);
8665
- if (result && !isInternalEditorID(unitId)) this._savePasteSession(payload, mode === "text" ? cachedSource : source, style, mode, unitId);
8777
+ if (result && this.isPasteOptionsEnabled(unitId)) this._savePasteSession(payload, mode === "text" ? cachedSource : source, style, mode, unitId);
8666
8778
  return result;
8667
8779
  } finally {
8668
8780
  this._applyingPaste = false;
@@ -8886,7 +8998,11 @@ let DocClipboardService = class DocClipboardService extends Disposable {
8886
8998
  this._clipboardHooks.push(hook);
8887
8999
  return toDisposable(() => {
8888
9000
  const index = this._clipboardHooks.indexOf(hook);
8889
- if (index > -1) this._clipboardHooks.splice(index, 1);
9001
+ if (index > -1) {
9002
+ this._clipboardHooks.splice(index, 1);
9003
+ const state = this._pasteOptions$.value;
9004
+ if (state && !this.isPasteOptionsEnabled(state.unitId)) this.dismissPasteOptions();
9005
+ }
8890
9006
  });
8891
9007
  }
8892
9008
  _applyCopyDocDataHooks(doc, sourceDocuments) {
@@ -11592,31 +11708,6 @@ const DocCreateTableOperation = {
11592
11708
  }
11593
11709
  };
11594
11710
 
11595
- //#endregion
11596
- //#region src/commands/operations/doc-cursor.operation.ts
11597
- /**
11598
- * The operation to move cursor in the current document.
11599
- */
11600
- const MoveCursorOperation = {
11601
- id: "doc.operation.move-cursor",
11602
- type: CommandType.OPERATION,
11603
- handler: (accessor, params) => {
11604
- if (!params) return false;
11605
- return true;
11606
- }
11607
- };
11608
- /**
11609
- * The operation to move selection in the current document.
11610
- */
11611
- const MoveSelectionOperation = {
11612
- id: "doc.operation.move-selection",
11613
- type: CommandType.OPERATION,
11614
- handler: (accessor, params) => {
11615
- if (!params) return false;
11616
- return true;
11617
- }
11618
- };
11619
-
11620
11711
  //#endregion
11621
11712
  //#region src/config/config.ts
11622
11713
  const DOCS_UI_PLUGIN_CONFIG_KEY = "docs-ui.config";
@@ -12061,6 +12152,7 @@ function getLineFontFamily(line) {
12061
12152
  function drawParagraphPlaceholders(ctx, placeholders, color = PLACEHOLDER_COLOR) {
12062
12153
  ctx.save();
12063
12154
  ctx.fillStyle = color;
12155
+ ctx.globalAlpha *= .5;
12064
12156
  ctx.textBaseline = "alphabetic";
12065
12157
  for (const placeholder of placeholders) {
12066
12158
  const clipLeft = placeholder.clipLeft ?? placeholder.x;
@@ -12684,12 +12776,35 @@ var DocLayoutInteractionService = class extends Disposable {
12684
12776
  //#region src/services/doc-zoom.ts
12685
12777
  const DEFAULT_DOC_ZOOM_RATIO = 1;
12686
12778
  const DEFAULT_MODERN_DOC_ZOOM_RATIO = 1;
12779
+ const DOC_ZOOM_SHORTCUTS = [
12780
+ 50,
12781
+ 80,
12782
+ 100,
12783
+ 130,
12784
+ 150,
12785
+ 170,
12786
+ 200,
12787
+ 400
12788
+ ];
12687
12789
  function getDocEffectiveZoomRatio(documentModel) {
12688
12790
  var _documentModel$getSet, _documentModel$getSna;
12689
12791
  const zoomRatio = (_documentModel$getSet = documentModel.getSettings()) === null || _documentModel$getSet === void 0 ? void 0 : _documentModel$getSet.zoomRatio;
12690
12792
  if (zoomRatio != null) return zoomRatio;
12691
12793
  return ((_documentModel$getSna = documentModel.getSnapshot().documentStyle) === null || _documentModel$getSna === void 0 ? void 0 : _documentModel$getSna.documentFlavor) === DocumentFlavor.MODERN ? 1 : DEFAULT_DOC_ZOOM_RATIO;
12692
12794
  }
12795
+ function getDocZoomRatio$(commandService, instanceService) {
12796
+ return instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC).pipe(switchMap((documentModel) => {
12797
+ if (!documentModel) return of(100);
12798
+ return new Observable((subscriber) => {
12799
+ const update = () => subscriber.next(Math.round(getDocEffectiveZoomRatio(documentModel) * 100));
12800
+ const disposable = commandService.onCommandExecuted((command) => {
12801
+ if (command.id === SetDocZoomRatioOperation.id && command.params.unitId === documentModel.getUnitId()) update();
12802
+ });
12803
+ update();
12804
+ return () => disposable.dispose();
12805
+ });
12806
+ }), distinctUntilChanged());
12807
+ }
12693
12808
 
12694
12809
  //#endregion
12695
12810
  //#region src/services/doc-view-scale.ts
@@ -13339,11 +13454,13 @@ function doesDocMutationRequireLayout(actions, drawings) {
13339
13454
  if (!sawComponent || !drawingOnly) return true;
13340
13455
  if (transitions.size === 0) return false;
13341
13456
  for (const [drawingId, transition] of transitions) {
13342
- var _drawings$drawingId;
13343
- const currentLayoutType = drawings === null || drawings === void 0 || (_drawings$drawingId = drawings[drawingId]) === null || _drawings$drawingId === void 0 ? void 0 : _drawings$drawingId.layoutType;
13457
+ var _currentDrawing$docTr, _currentDrawing$docTr2;
13458
+ const currentDrawing = drawings === null || drawings === void 0 ? void 0 : drawings[drawingId];
13459
+ const currentLayoutType = currentDrawing === null || currentDrawing === void 0 ? void 0 : currentDrawing.layoutType;
13344
13460
  const before = transition.before ?? currentLayoutType;
13345
13461
  const after = transition.after ?? currentLayoutType;
13346
13462
  if (before == null || after == null || before !== PositionedObjectLayoutType.WRAP_NONE || after !== PositionedObjectLayoutType.WRAP_NONE) return true;
13463
+ if ((currentDrawing === null || currentDrawing === void 0 || (_currentDrawing$docTr = currentDrawing.docTransform) === null || _currentDrawing$docTr === void 0 ? void 0 : _currentDrawing$docTr.positionH.relativeFrom) !== ObjectRelativeFromH.PAGE || (currentDrawing === null || currentDrawing === void 0 || (_currentDrawing$docTr2 = currentDrawing.docTransform) === null || _currentDrawing$docTr2 === void 0 ? void 0 : _currentDrawing$docTr2.positionV.relativeFrom) !== ObjectRelativeFromV.PAGE) return true;
13347
13464
  }
13348
13465
  return false;
13349
13466
  }
@@ -14323,6 +14440,8 @@ function getHeaderFooterTarget(viewModel, editArea, segmentPage, page) {
14323
14440
  * limitations under the License.
14324
14441
  */
14325
14442
  const COMPONENT_DOC_HEADER_FOOTER_PANEL = "COMPONENT_DOC_HEADER_FOOTER_PANEL";
14443
+ const DOC_HEADER_FOOTER_RIBBON_TAB = "docs-ui.ribbon.header-footer";
14444
+ const DOC_HEADER_FOOTER_RIBBON_CONTROL = "DocHeaderFooterRibbonControl";
14326
14445
 
14327
14446
  //#endregion
14328
14447
  //#region src/commands/operations/doc-header-footer-panel.operation.ts
@@ -14380,8 +14499,8 @@ const CoreHeaderFooterCommand = {
14380
14499
  let resolvedCreateType = createType;
14381
14500
  if (headerFooterProps != null) Object.keys(headerFooterProps).forEach((key) => {
14382
14501
  const value = headerFooterProps[key];
14383
- if (resolvedCreateType == null && key === "useFirstPageHeaderFooter" && value === BooleanNumber.TRUE && !headerFooterConfig.firstPageHeaderId) resolvedCreateType = editArea === DocumentEditArea.HEADER ? HeaderFooterType.FIRST_PAGE_HEADER : HeaderFooterType.FIRST_PAGE_FOOTER;
14384
- else if (resolvedCreateType == null && key === "evenAndOddHeaders" && value === BooleanNumber.TRUE && !headerFooterConfig.evenPageHeaderId) resolvedCreateType = editArea === DocumentEditArea.HEADER ? HeaderFooterType.EVEN_PAGE_HEADER : HeaderFooterType.EVEN_PAGE_FOOTER;
14502
+ if (resolvedCreateType == null && key === "useFirstPageHeaderFooter" && value === BooleanNumber.TRUE && !(editArea === DocumentEditArea.HEADER ? headerFooterConfig.firstPageHeaderId : headerFooterConfig.firstPageFooterId)) resolvedCreateType = editArea === DocumentEditArea.HEADER ? HeaderFooterType.FIRST_PAGE_HEADER : HeaderFooterType.FIRST_PAGE_FOOTER;
14503
+ else if (resolvedCreateType == null && key === "evenAndOddHeaders" && value === BooleanNumber.TRUE && !(editArea === DocumentEditArea.HEADER ? headerFooterConfig.evenPageHeaderId : headerFooterConfig.evenPageFooterId)) resolvedCreateType = editArea === DocumentEditArea.HEADER ? HeaderFooterType.EVEN_PAGE_HEADER : HeaderFooterType.EVEN_PAGE_FOOTER;
14385
14504
  });
14386
14505
  return commandService.syncExecuteCommand(CreateHeaderFooterCommand.id, {
14387
14506
  unitId,
@@ -14396,8 +14515,8 @@ const CoreHeaderFooterCommand = {
14396
14515
  const OpenHeaderFooterPanelCommand = {
14397
14516
  id: "doc.command.open-header-footer-panel",
14398
14517
  type: CommandType.COMMAND,
14399
- handler: async (accessor, _params) => {
14400
- var _skeleton$getSkeleton;
14518
+ handler: async (accessor, params) => {
14519
+ var _skeleton$getSkeleton, _docDataModel$getSelf;
14401
14520
  const commandService = accessor.get(ICommandService);
14402
14521
  const instanceService = accessor.get(IUniverInstanceService);
14403
14522
  const renderManagerService = accessor.get(IRenderManagerService);
@@ -14414,8 +14533,9 @@ const OpenHeaderFooterPanelCommand = {
14414
14533
  const currentPage = selectionRenderService.getSegmentPage();
14415
14534
  const pageNumber = currentPage >= 0 && currentPage < pages.length ? currentPage : 0;
14416
14535
  const page = pages[pageNumber];
14417
- viewModel.setEditArea(DocumentEditArea.HEADER);
14418
- const { createType, headerFooterId, sectionId } = getHeaderFooterTarget(viewModel, DocumentEditArea.HEADER, pageNumber, page);
14536
+ const editArea = (params === null || params === void 0 ? void 0 : params.editArea) ?? DocumentEditArea.HEADER;
14537
+ viewModel.setEditArea(editArea);
14538
+ const { createType, headerFooterId, sectionId } = getHeaderFooterTarget(viewModel, editArea, pageNumber, page);
14419
14539
  selectionRenderService.setSegmentPage(pageNumber);
14420
14540
  if (createType != null) {
14421
14541
  const segmentId = generateRandomId(6);
@@ -14432,6 +14552,21 @@ const OpenHeaderFooterPanelCommand = {
14432
14552
  return false;
14433
14553
  }
14434
14554
  } else if (headerFooterId != null) selectionRenderService.setSegment(headerFooterId);
14555
+ const segmentId = selectionRenderService.getSegment();
14556
+ const segmentSnapshot = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getSnapshot();
14557
+ if (!segmentSnapshot) return false;
14558
+ const offset = findFirstCursorOffset(segmentSnapshot);
14559
+ accessor.get(DocSelectionManagerService).replaceDocRanges([{
14560
+ startOffset: offset,
14561
+ endOffset: offset,
14562
+ collapsed: true,
14563
+ segmentId,
14564
+ segmentPage: pageNumber
14565
+ }], {
14566
+ unitId,
14567
+ subUnitId: unitId
14568
+ });
14569
+ selectionRenderService.focus();
14435
14570
  return commandService.executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "open" });
14436
14571
  }
14437
14572
  };
@@ -14474,7 +14609,254 @@ const CloseHeaderFooterCommand = {
14474
14609
  endOffset: offset
14475
14610
  }]);
14476
14611
  });
14477
- commandService.executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "close" });
14612
+ await commandService.executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "close" });
14613
+ return true;
14614
+ }
14615
+ };
14616
+
14617
+ //#endregion
14618
+ //#region src/utils/date-time-field.ts
14619
+ function createDateTimeField(format, locale, date) {
14620
+ const options = format === "time" ? {
14621
+ hour: "2-digit",
14622
+ minute: "2-digit",
14623
+ second: "2-digit",
14624
+ hourCycle: "h23"
14625
+ } : {
14626
+ year: "numeric",
14627
+ month: format === "long" ? "long" : "2-digit",
14628
+ day: "2-digit"
14629
+ };
14630
+ const formatter = new Intl.DateTimeFormat(locale, {
14631
+ ...options,
14632
+ calendar: "gregory",
14633
+ numberingSystem: "latn"
14634
+ });
14635
+ const parts = formatter.formatToParts(date);
14636
+ const tokens = {
14637
+ year: "yyyy",
14638
+ month: format === "long" ? "MMMM" : "MM",
14639
+ day: "dd",
14640
+ hour: "HH",
14641
+ minute: "mm",
14642
+ second: "ss"
14643
+ };
14644
+ const mask = parts.map((part) => tokens[part.type] ?? `'${part.value.replace(/'/g, "''")}'`).join("");
14645
+ const fieldType = format === "time" ? "TIME" : "DATE";
14646
+ return {
14647
+ fieldType,
14648
+ instruction: `${fieldType} \\@ "${mask}"`,
14649
+ cachedResult: formatter.format(date)
14650
+ };
14651
+ }
14652
+ function resolveDateTimeField(instruction, locale, date) {
14653
+ try {
14654
+ Intl.getCanonicalLocales(locale);
14655
+ } catch {
14656
+ return;
14657
+ }
14658
+ for (const format of [
14659
+ "short",
14660
+ "long",
14661
+ "time"
14662
+ ]) {
14663
+ const field = createDateTimeField(format, locale, date);
14664
+ if (field.instruction === instruction) return field.cachedResult;
14665
+ }
14666
+ }
14667
+
14668
+ //#endregion
14669
+ //#region src/commands/commands/insert-header-footer-field.command.ts
14670
+ const InsertHeaderFooterFieldCommand = {
14671
+ id: "doc.command.insert-header-footer-field",
14672
+ type: CommandType.COMMAND,
14673
+ handler(accessor, params) {
14674
+ var _snapshot$headers, _snapshot$footers, _model$getSelfOrHeade, _body$customRanges;
14675
+ if (!params || ![
14676
+ "PAGE",
14677
+ "NUMPAGES",
14678
+ "DATE",
14679
+ "TIME"
14680
+ ].includes(params.fieldType)) return false;
14681
+ const model = accessor.get(IUniverInstanceService).getUnit(params.unitId, UniverInstanceType.UNIVER_DOC);
14682
+ const active = accessor.get(DocSelectionManagerService).getActiveTextRange();
14683
+ const selection = params.selection ?? active;
14684
+ const segmentId = params.segmentId ?? (active === null || active === void 0 ? void 0 : active.segmentId);
14685
+ const snapshot = model === null || model === void 0 ? void 0 : model.getSnapshot();
14686
+ if (!model || (snapshot === null || snapshot === void 0 ? void 0 : snapshot.disabled) || !selection || !segmentId || !(snapshot === null || snapshot === void 0 || (_snapshot$headers = snapshot.headers) === null || _snapshot$headers === void 0 ? void 0 : _snapshot$headers[segmentId]) && !(snapshot === null || snapshot === void 0 || (_snapshot$footers = snapshot.footers) === null || _snapshot$footers === void 0 ? void 0 : _snapshot$footers[segmentId])) return false;
14687
+ const body = (_model$getSelfOrHeade = model.getSelfOrHeaderFooterModel(segmentId)) === null || _model$getSelfOrHeade === void 0 ? void 0 : _model$getSelfOrHeade.getBody();
14688
+ if (!body || params.expectedDataStream != null && params.expectedDataStream !== body.dataStream || !Number.isInteger(selection.startOffset) || !Number.isInteger(selection.endOffset) || selection.startOffset < 0 || selection.endOffset < selection.startOffset || selection.endOffset > body.dataStream.length - 2) return false;
14689
+ if (!canEditDocumentTargets(accessor.get(IPermissionService), params.unitId, getDocumentEditTargetObjectIds(model, segmentId, selection))) return false;
14690
+ if ((_body$customRanges = body.customRanges) === null || _body$customRanges === void 0 ? void 0 : _body$customRanges.some((range) => {
14691
+ var _range$properties;
14692
+ return range.rangeType === CustomRangeType.FIELD && ((_range$properties = range.properties) === null || _range$properties === void 0 ? void 0 : _range$properties.locked) === BooleanNumber.TRUE && selection.startOffset <= range.endIndex && selection.endOffset > range.startIndex;
14693
+ })) return false;
14694
+ const locale = LOCALE_META[accessor.get(LocaleService).getCurrentLocale()].tag;
14695
+ let properties;
14696
+ if (params.fieldType === "DATE" || params.fieldType === "TIME") {
14697
+ const format = params.format ?? (params.fieldType === "TIME" ? "time" : "short");
14698
+ if (![
14699
+ "short",
14700
+ "long",
14701
+ "time"
14702
+ ].includes(format)) return false;
14703
+ properties = createDateTimeField(format, locale, /* @__PURE__ */ new Date());
14704
+ } else {
14705
+ var _accessor$get$getRend, _skeleton$getSkeleton;
14706
+ const skeleton = (_accessor$get$getRend = accessor.get(IRenderManagerService).getRenderUnitById(params.unitId)) === null || _accessor$get$getRend === void 0 ? void 0 : _accessor$get$getRend.with(DocSkeletonManagerService).getSkeleton();
14707
+ const pages = skeleton === null || skeleton === void 0 || (_skeleton$getSkeleton = skeleton.getSkeletonData()) === null || _skeleton$getSkeleton === void 0 ? void 0 : _skeleton$getSkeleton.pages;
14708
+ if (!(pages === null || pages === void 0 ? void 0 : pages.length)) return false;
14709
+ const pageIndex = params.segmentPage ?? (active === null || active === void 0 ? void 0 : active.segmentPage) ?? 0;
14710
+ const page = pages[Math.max(0, pageIndex)];
14711
+ if (!page) return false;
14712
+ properties = {
14713
+ fieldType: params.fieldType,
14714
+ instruction: params.fieldType,
14715
+ cachedResult: String(params.fieldType === "PAGE" ? page.pageNumber : (skeleton === null || skeleton === void 0 ? void 0 : skeleton.getCompletedPageCount()) ?? "…")
14716
+ };
14717
+ }
14718
+ const automatic = params.automatic !== false || params.fieldType === "PAGE" || params.fieldType === "NUMPAGES";
14719
+ const dataStream = automatic ? `${DataStreamTreeTokenType.CUSTOM_RANGE_START}${properties.cachedResult}${DataStreamTreeTokenType.CUSTOM_RANGE_END}` : properties.cachedResult;
14720
+ const style = accessor.get(DocMenuStyleService);
14721
+ const textRun = getTextRunForSelection(body, selection, style.getDefaultStyle(), style.getStyleCache(), false);
14722
+ return accessor.get(ICommandService).syncExecuteCommand(InsertTextCommand.id, {
14723
+ unitId: params.unitId,
14724
+ segmentId,
14725
+ range: selection,
14726
+ debounce: false,
14727
+ body: {
14728
+ dataStream,
14729
+ textRuns: [{
14730
+ ...textRun,
14731
+ ts: {
14732
+ ...textRun.ts,
14733
+ lang: locale
14734
+ },
14735
+ st: 0,
14736
+ ed: dataStream.length
14737
+ }],
14738
+ customRanges: automatic ? [{
14739
+ startIndex: 0,
14740
+ endIndex: dataStream.length - 1,
14741
+ rangeId: generateRandomId(),
14742
+ rangeType: CustomRangeType.FIELD,
14743
+ wholeEntity: false,
14744
+ properties: {
14745
+ ...properties,
14746
+ sourceKind: "complex"
14747
+ }
14748
+ }] : []
14749
+ },
14750
+ textRanges: [{
14751
+ ...selection,
14752
+ segmentId,
14753
+ segmentPage: params.segmentPage ?? (active === null || active === void 0 ? void 0 : active.segmentPage),
14754
+ startOffset: selection.startOffset + dataStream.length,
14755
+ endOffset: selection.startOffset + dataStream.length,
14756
+ collapsed: true
14757
+ }]
14758
+ });
14759
+ }
14760
+ };
14761
+
14762
+ //#endregion
14763
+ //#region src/commands/commands/refresh-header-footer-fields.command.ts
14764
+ const RefreshHeaderFooterFieldsCommand = {
14765
+ id: "doc.command.refresh-header-footer-fields",
14766
+ type: CommandType.COMMAND,
14767
+ handler(accessor, params) {
14768
+ if (!params) return false;
14769
+ const model = accessor.get(IUniverInstanceService).getUnit(params.unitId, UniverInstanceType.UNIVER_DOC);
14770
+ const snapshot = model === null || model === void 0 ? void 0 : model.getSnapshot();
14771
+ if (!model || !snapshot || snapshot.disabled) return false;
14772
+ const permissions = accessor.get(IPermissionService);
14773
+ const locale = LOCALE_META[accessor.get(LocaleService).getCurrentLocale()].tag;
14774
+ const now = /* @__PURE__ */ new Date();
14775
+ const selections = accessor.get(DocSelectionManagerService).getTextRanges({
14776
+ unitId: params.unitId,
14777
+ subUnitId: params.unitId
14778
+ }) ?? [];
14779
+ let actions = null;
14780
+ for (const [segmentId, segment] of Object.entries({
14781
+ "": { body: snapshot.body },
14782
+ ...snapshot.headers,
14783
+ ...snapshot.footers
14784
+ })) {
14785
+ if (!segment.body) continue;
14786
+ const textX = refreshDateTimeFields(segment.body, locale, now, (field) => (!params.selectionOnly || selections.some((selection) => (selection.segmentId ?? "") === segmentId && selection.startOffset <= field.endIndex && selection.endOffset > field.startIndex)) && canEditDocumentTargets(permissions, params.unitId, getDocumentEditTargetObjectIds(model, segmentId, {
14787
+ startOffset: field.startIndex,
14788
+ endOffset: field.endIndex + 1
14789
+ })));
14790
+ if (textX.length) actions = JSONX.compose(actions, JSONX.getInstance().editOp(textX, getRichTextEditPath(model, segmentId)));
14791
+ }
14792
+ if (JSONX.isNoop(actions)) return true;
14793
+ if (!params.onOpen) accessor.get(DocStateChangeManagerService).flushPendingChanges(params.unitId);
14794
+ return Boolean(accessor.get(ICommandService).syncExecuteCommand(RichTextEditingMutation.id, {
14795
+ unitId: params.unitId,
14796
+ actions,
14797
+ textRanges: transformDocumentTextRanges(actions, [...selections]),
14798
+ noHistory: params.onOpen === true,
14799
+ debounce: false,
14800
+ trigger: RefreshHeaderFooterFieldsCommand.id
14801
+ }));
14802
+ }
14803
+ };
14804
+ const UpdateSelectedDocFieldsCommand = {
14805
+ id: "doc.command.update-selected-fields",
14806
+ type: CommandType.COMMAND,
14807
+ handler(accessor) {
14808
+ const model = accessor.get(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
14809
+ if (!model) return false;
14810
+ return accessor.get(ICommandService).syncExecuteCommand(RefreshHeaderFooterFieldsCommand.id, {
14811
+ unitId: model.getUnitId(),
14812
+ selectionOnly: true
14813
+ });
14814
+ }
14815
+ };
14816
+ function refreshDateTimeFields(body, locale, date, canEdit) {
14817
+ const textX = new TextX();
14818
+ let cursor = 0;
14819
+ const ranges = [...body.customRanges ?? []].sort((a, b) => a.startIndex - b.startIndex);
14820
+ for (const field of ranges) {
14821
+ var _body$textRuns, _run$ts;
14822
+ const properties = field.properties;
14823
+ if (field.rangeType !== CustomRangeType.FIELD || (properties === null || properties === void 0 ? void 0 : properties.locked) === BooleanNumber.TRUE || (properties === null || properties === void 0 ? void 0 : properties.fieldType) !== "DATE" && (properties === null || properties === void 0 ? void 0 : properties.fieldType) !== "TIME" || !canEdit(field) || ranges.some((range) => range !== field && range.startIndex > field.startIndex && range.endIndex < field.endIndex)) continue;
14824
+ const start = field.startIndex;
14825
+ const run = (_body$textRuns = body.textRuns) === null || _body$textRuns === void 0 ? void 0 : _body$textRuns.find((run) => run.st <= start + 1 && run.ed > start + 1);
14826
+ const value = resolveDateTimeField(properties.instruction, (run === null || run === void 0 || (_run$ts = run.ts) === null || _run$ts === void 0 ? void 0 : _run$ts.lang) ?? locale, date);
14827
+ if (value == null || start < cursor || body.dataStream.slice(start + 1, field.endIndex) === value && properties.cachedResult === value) continue;
14828
+ const dataStream = `${DataStreamTreeTokenType.CUSTOM_RANGE_START}${value}${DataStreamTreeTokenType.CUSTOM_RANGE_END}`;
14829
+ textX.retain(start - cursor).delete(field.endIndex - start + 1).insert(dataStream.length, {
14830
+ dataStream,
14831
+ textRuns: run ? [{
14832
+ ...run,
14833
+ st: 0,
14834
+ ed: dataStream.length
14835
+ }] : [],
14836
+ customRanges: [{
14837
+ ...field,
14838
+ startIndex: 0,
14839
+ endIndex: dataStream.length - 1,
14840
+ properties: {
14841
+ ...properties,
14842
+ cachedResult: value
14843
+ }
14844
+ }]
14845
+ });
14846
+ cursor = field.endIndex + 1;
14847
+ }
14848
+ return textX.serialize();
14849
+ }
14850
+
14851
+ //#endregion
14852
+ //#region src/commands/operations/doc-header-footer-ribbon.operation.ts
14853
+ const DocHeaderFooterRibbonOperation = {
14854
+ id: SidebarDocHeaderFooterPanelOperation.id,
14855
+ type: SidebarDocHeaderFooterPanelOperation.type,
14856
+ handler(accessor, params) {
14857
+ const ribbon = accessor.get(IRibbonService);
14858
+ if ((params === null || params === void 0 ? void 0 : params.value) === "open") ribbon.showContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB, { activate: true });
14859
+ else ribbon.hideContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB);
14478
14860
  return true;
14479
14861
  }
14480
14862
  };
@@ -15103,8 +15485,12 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
15103
15485
  }
15104
15486
  _initPointer() {
15105
15487
  let preCursor = CURSOR_TYPE.TEXT;
15488
+ let pointing = false;
15106
15489
  this.disposeWithMe(this.hoverCustomRanges$.subscribe((ranges) => {
15107
- if (ranges.length) {
15490
+ const nextPointing = ranges.some(({ range }) => range.rangeType !== CustomRangeType.FIELD);
15491
+ if (nextPointing === pointing) return;
15492
+ pointing = nextPointing;
15493
+ if (pointing) {
15108
15494
  preCursor = this._context.scene.getCursor();
15109
15495
  this._context.scene.setCursor(CURSOR_TYPE.POINTER);
15110
15496
  } else this._context.scene.setCursor(preCursor);
@@ -15227,6 +15613,10 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
15227
15613
  this._buildBulletBounds();
15228
15614
  return [...this._bulletBounds];
15229
15615
  }
15616
+ getCustomRangeBounds() {
15617
+ this._buildCustomRangeBounds();
15618
+ return [...this._customRangeBounds];
15619
+ }
15230
15620
  getListContextMenuBulletByOffset(offsetX, offsetY) {
15231
15621
  const point = transformOffset2Bound(offsetX, offsetY, this._context.scene);
15232
15622
  return this._calcActiveBullet(point) ?? this._calcActiveListParagraph(point);
@@ -15772,133 +16162,51 @@ const OpenDocPermissionPanelOperation = {
15772
16162
  };
15773
16163
 
15774
16164
  //#endregion
15775
- //#region src/controllers/doc-paragraph-setting.controller.ts
15776
- /**
15777
- * Copyright 2023-present DreamNum Co., Ltd.
15778
- *
15779
- * Licensed under the Apache License, Version 2.0 (the "License");
15780
- * you may not use this file except in compliance with the License.
15781
- * You may obtain a copy of the License at
15782
- *
15783
- * http://www.apache.org/licenses/LICENSE-2.0
15784
- *
15785
- * Unless required by applicable law or agreed to in writing, software
15786
- * distributed under the License is distributed on an "AS IS" BASIS,
15787
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15788
- * See the License for the specific language governing permissions and
15789
- * limitations under the License.
15790
- */
15791
- const paragraphSettingIndexKey$1 = "doc_ui_paragraph-setting-panel";
15792
- let DocParagraphSettingController = class DocParagraphSettingController extends Disposable {
15793
- constructor(_commandService, _sidebarService) {
15794
- super();
15795
- this._commandService = _commandService;
15796
- this._sidebarService = _sidebarService;
15797
- _defineProperty(this, "_id", void 0);
15798
- }
15799
- openPanel() {
15800
- const props = {
15801
- header: { title: "docs-ui.doc.slider.paragraphSetting" },
15802
- id: this._id,
15803
- children: { label: paragraphSettingIndexKey$1 },
15804
- width: 300
15805
- };
15806
- this._sidebarService.open(props);
15807
- }
15808
- closePanel() {
15809
- this._sidebarService.close(this._id);
15810
- }
15811
- };
15812
- DocParagraphSettingController = __decorate([__decorateParam(0, ICommandService), __decorateParam(1, Inject(ISidebarService))], DocParagraphSettingController);
15813
-
15814
- //#endregion
15815
- //#region src/commands/operations/doc-paragraph-setting-panel.operation.ts
15816
- const DocParagraphSettingPanelOperation = {
15817
- id: "sidebar.operation.doc-paragraph-setting-panel",
15818
- type: CommandType.OPERATION,
15819
- handler: (accessor) => {
15820
- accessor.get(DocParagraphSettingController).openPanel();
15821
- return true;
15822
- }
15823
- };
15824
-
15825
- //#endregion
15826
- //#region src/views/section-setting/component-name.ts
15827
- /**
15828
- * Copyright 2023-present DreamNum Co., Ltd.
15829
- *
15830
- * Licensed under the Apache License, Version 2.0 (the "License");
15831
- * you may not use this file except in compliance with the License.
15832
- * You may obtain a copy of the License at
15833
- *
15834
- * http://www.apache.org/licenses/LICENSE-2.0
15835
- *
15836
- * Unless required by applicable law or agreed to in writing, software
15837
- * distributed under the License is distributed on an "AS IS" BASIS,
15838
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15839
- * See the License for the specific language governing permissions and
15840
- * limitations under the License.
15841
- */
15842
- const DOC_SECTION_SETTING_COMPONENT = "doc_ui_section-setting-panel";
15843
-
15844
- //#endregion
15845
- //#region src/controllers/doc-section-setting.controller.ts
15846
- /**
15847
- * Copyright 2023-present DreamNum Co., Ltd.
15848
- *
15849
- * Licensed under the Apache License, Version 2.0 (the "License");
15850
- * you may not use this file except in compliance with the License.
15851
- * You may obtain a copy of the License at
15852
- *
15853
- * http://www.apache.org/licenses/LICENSE-2.0
15854
- *
15855
- * Unless required by applicable law or agreed to in writing, software
15856
- * distributed under the License is distributed on an "AS IS" BASIS,
15857
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15858
- * See the License for the specific language governing permissions and
15859
- * limitations under the License.
15860
- */
15861
- let DocSectionSettingController = class DocSectionSettingController extends Disposable {
15862
- constructor(_sidebarService, _selectionManager) {
15863
- super();
15864
- this._sidebarService = _sidebarService;
15865
- this._selectionManager = _selectionManager;
15866
- _defineProperty(this, "_panelId", "DocSectionSetting");
15867
- }
15868
- openPanel() {
15869
- this._sidebarService.open({
15870
- header: { title: "docs-ui.doc.slider.sectionSetting" },
15871
- id: this._panelId,
15872
- children: { label: DOC_SECTION_SETTING_COMPONENT },
15873
- width: 300
16165
+ //#region src/commands/commands/insert-special-character.command.ts
16166
+ const InsertSpecialCharacterCommand = {
16167
+ id: "doc.command.insert-special-character",
16168
+ type: CommandType.COMMAND,
16169
+ handler: (accessor, params) => {
16170
+ var _docDataModel$getSelf, _getEditorRuntimeConf;
16171
+ if (!(params === null || params === void 0 ? void 0 : params.value)) return false;
16172
+ const commandService = accessor.get(ICommandService);
16173
+ const docSelectionManagerService = accessor.get(DocSelectionManagerService);
16174
+ const univerInstanceService = accessor.get(IUniverInstanceService);
16175
+ const docMenuStyleService = accessor.get(DocMenuStyleService);
16176
+ const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
16177
+ const activeRange = docSelectionManagerService.getActiveTextRange();
16178
+ if (!docDataModel || !activeRange) return false;
16179
+ const { segmentId } = activeRange;
16180
+ const originBody = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
16181
+ if (!originBody) return false;
16182
+ const { value } = params;
16183
+ const curTextRun = getTextRunForSelection(originBody, activeRange, docMenuStyleService.getDefaultStyle(), docMenuStyleService.getStyleCache(), false, ((_getEditorRuntimeConf = getEditorRuntimeConfig(docDataModel)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.inheritParagraphStartStyle) === true);
16184
+ const curCustomRange = getCustomRangeAtPosition(originBody.customRanges ?? [], activeRange.endOffset);
16185
+ const curCustomDecorations = getCustomDecorationAtPosition(originBody.customDecorations ?? [], activeRange.endOffset);
16186
+ return commandService.executeCommand(InsertTextCommand.id, {
16187
+ unitId: docDataModel.getUnitId(),
16188
+ body: {
16189
+ dataStream: value,
16190
+ textRuns: [{
16191
+ ...curTextRun,
16192
+ st: 0,
16193
+ ed: value.length
16194
+ }],
16195
+ customRanges: curCustomRange ? [{
16196
+ ...curCustomRange,
16197
+ startIndex: 0,
16198
+ endIndex: value.length - 1
16199
+ }] : [],
16200
+ customDecorations: curCustomDecorations.map((customDecoration) => ({
16201
+ ...customDecoration,
16202
+ startIndex: 0,
16203
+ endIndex: value.length - 1
16204
+ }))
16205
+ },
16206
+ range: activeRange,
16207
+ segmentId
15874
16208
  });
15875
16209
  }
15876
- closePanel() {
15877
- this._sidebarService.close(this._panelId);
15878
- }
15879
- navigateToSectionEnd(unitId, sectionStart, sectionEnd) {
15880
- const params = {
15881
- unitId,
15882
- subUnitId: unitId
15883
- };
15884
- const cursorOffset = Math.max(sectionStart, sectionEnd - 1);
15885
- this._selectionManager.replaceDocRanges([{
15886
- startOffset: cursorOffset,
15887
- endOffset: cursorOffset
15888
- }], params, true, { shouldFocus: false });
15889
- }
15890
- };
15891
- DocSectionSettingController = __decorate([__decorateParam(0, Inject(ISidebarService)), __decorateParam(1, Inject(DocSelectionManagerService))], DocSectionSettingController);
15892
-
15893
- //#endregion
15894
- //#region src/commands/operations/doc-section-setting-panel.operation.ts
15895
- const DocSectionSettingPanelOperation = {
15896
- id: "sidebar.operation.doc-section-setting-panel",
15897
- type: CommandType.OPERATION,
15898
- handler: (accessor) => {
15899
- accessor.get(DocSectionSettingController).openPanel();
15900
- return true;
15901
- }
15902
16210
  };
15903
16211
 
15904
16212
  //#endregion
@@ -16331,54 +16639,6 @@ const DocOpenPageSettingCommand = {
16331
16639
  }
16332
16640
  };
16333
16641
 
16334
- //#endregion
16335
- //#region src/commands/commands/insert-special-character.command.ts
16336
- const InsertSpecialCharacterCommand = {
16337
- id: "doc.command.insert-special-character",
16338
- type: CommandType.COMMAND,
16339
- handler: (accessor, params) => {
16340
- var _docDataModel$getSelf, _getEditorRuntimeConf;
16341
- if (!(params === null || params === void 0 ? void 0 : params.value)) return false;
16342
- const commandService = accessor.get(ICommandService);
16343
- const docSelectionManagerService = accessor.get(DocSelectionManagerService);
16344
- const univerInstanceService = accessor.get(IUniverInstanceService);
16345
- const docMenuStyleService = accessor.get(DocMenuStyleService);
16346
- const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
16347
- const activeRange = docSelectionManagerService.getActiveTextRange();
16348
- if (!docDataModel || !activeRange) return false;
16349
- const { segmentId } = activeRange;
16350
- const originBody = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
16351
- if (!originBody) return false;
16352
- const { value } = params;
16353
- const curTextRun = getTextRunForSelection(originBody, activeRange, docMenuStyleService.getDefaultStyle(), docMenuStyleService.getStyleCache(), false, ((_getEditorRuntimeConf = getEditorRuntimeConfig(docDataModel)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.inheritParagraphStartStyle) === true);
16354
- const curCustomRange = getCustomRangeAtPosition(originBody.customRanges ?? [], activeRange.endOffset);
16355
- const curCustomDecorations = getCustomDecorationAtPosition(originBody.customDecorations ?? [], activeRange.endOffset);
16356
- return commandService.executeCommand(InsertTextCommand.id, {
16357
- unitId: docDataModel.getUnitId(),
16358
- body: {
16359
- dataStream: value,
16360
- textRuns: [{
16361
- ...curTextRun,
16362
- st: 0,
16363
- ed: value.length
16364
- }],
16365
- customRanges: curCustomRange ? [{
16366
- ...curCustomRange,
16367
- startIndex: 0,
16368
- endIndex: value.length - 1
16369
- }] : [],
16370
- customDecorations: curCustomDecorations.map((customDecoration) => ({
16371
- ...customDecoration,
16372
- startIndex: 0,
16373
- endIndex: value.length - 1
16374
- }))
16375
- },
16376
- range: activeRange,
16377
- segmentId
16378
- });
16379
- }
16380
- };
16381
-
16382
16642
  //#endregion
16383
16643
  //#region src/views/const.ts
16384
16644
  /**
@@ -17735,6 +17995,210 @@ function PageSettingMenuItemFactory(accessor) {
17735
17995
  };
17736
17996
  }
17737
17997
 
17998
+ //#endregion
17999
+ //#region src/menu/header-footer-ribbon.ts
18000
+ const headerFooterRibbonSchema = {
18001
+ [ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.FORMAT]: { [UpdateSelectedDocFieldsCommand.id]: {
18002
+ order: 1,
18003
+ menuItemFactory: (accessor) => {
18004
+ const instances = accessor.get(IUniverInstanceService);
18005
+ const selections = accessor.get(DocSelectionManagerService);
18006
+ return {
18007
+ id: UpdateSelectedDocFieldsCommand.id,
18008
+ type: MenuItemType.BUTTON,
18009
+ title: "docs-ui.headerFooter.refreshFields",
18010
+ disabled$: disableMenuWithoutDocumentUnitPermission(accessor, UnitAction.Edit),
18011
+ hidden$: combineLatest([instances.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC), selections.textSelection$.pipe(startWith(null))]).pipe(map(([model]) => !model || !(selections.getTextRanges({
18012
+ unitId: model.getUnitId(),
18013
+ subUnitId: model.getUnitId()
18014
+ }) ?? []).some((selection) => {
18015
+ var _model$getSelfOrHeade;
18016
+ return (_model$getSelfOrHeade = model.getSelfOrHeaderFooterModel(selection.segmentId)) === null || _model$getSelfOrHeade === void 0 || (_model$getSelfOrHeade = _model$getSelfOrHeade.getBody()) === null || _model$getSelfOrHeade === void 0 || (_model$getSelfOrHeade = _model$getSelfOrHeade.customRanges) === null || _model$getSelfOrHeade === void 0 ? void 0 : _model$getSelfOrHeade.some((field) => field.rangeType === CustomRangeType.FIELD && selection.startOffset <= field.endIndex && selection.endOffset > field.startIndex);
18017
+ })))
18018
+ };
18019
+ }
18020
+ } } },
18021
+ [MenuManagerPosition.RIBBON]: { [DOC_HEADER_FOOTER_RIBBON_TAB]: {
18022
+ order: 90,
18023
+ title: "docs-ui.toolbar.headerFooter",
18024
+ contextual: true,
18025
+ ...Object.fromEntries([
18026
+ "insertion",
18027
+ "navigation",
18028
+ "options",
18029
+ "position"
18030
+ ].map((kind, order) => [`${DOC_HEADER_FOOTER_RIBBON_TAB}.${kind}`, {
18031
+ order,
18032
+ [`${DOC_HEADER_FOOTER_RIBBON_CONTROL}.${kind}`]: {
18033
+ order: 0,
18034
+ gridLayout: {
18035
+ row: 1,
18036
+ column: 1,
18037
+ rowSpan: 2
18038
+ },
18039
+ menuItemFactory: () => ({
18040
+ id: `${DOC_HEADER_FOOTER_RIBBON_CONTROL}.${kind}`,
18041
+ type: MenuItemType.BUTTON,
18042
+ label: {
18043
+ name: DOC_HEADER_FOOTER_RIBBON_CONTROL,
18044
+ hoverable: false,
18045
+ props: { kind }
18046
+ }
18047
+ })
18048
+ }
18049
+ }])),
18050
+ "docs-ui.headerFooter.close": {
18051
+ order: 5,
18052
+ [CloseHeaderFooterCommand.id]: {
18053
+ order: 0,
18054
+ gridLayout: {
18055
+ row: 1,
18056
+ column: 1,
18057
+ rowSpan: 2,
18058
+ showLabel: true
18059
+ },
18060
+ menuItemFactory: () => ({
18061
+ id: CloseHeaderFooterCommand.id,
18062
+ type: MenuItemType.BUTTON,
18063
+ icon: "CloseIcon",
18064
+ title: "docs-ui.headerFooter.closeHeaderFooter",
18065
+ tooltip: "docs-ui.headerFooter.closeHeaderFooter"
18066
+ })
18067
+ }
18068
+ }
18069
+ } }
18070
+ };
18071
+
18072
+ //#endregion
18073
+ //#region src/controllers/doc-paragraph-setting.controller.ts
18074
+ /**
18075
+ * Copyright 2023-present DreamNum Co., Ltd.
18076
+ *
18077
+ * Licensed under the Apache License, Version 2.0 (the "License");
18078
+ * you may not use this file except in compliance with the License.
18079
+ * You may obtain a copy of the License at
18080
+ *
18081
+ * http://www.apache.org/licenses/LICENSE-2.0
18082
+ *
18083
+ * Unless required by applicable law or agreed to in writing, software
18084
+ * distributed under the License is distributed on an "AS IS" BASIS,
18085
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18086
+ * See the License for the specific language governing permissions and
18087
+ * limitations under the License.
18088
+ */
18089
+ const paragraphSettingIndexKey$1 = "doc_ui_paragraph-setting-panel";
18090
+ let DocParagraphSettingController = class DocParagraphSettingController extends Disposable {
18091
+ constructor(_commandService, _sidebarService) {
18092
+ super();
18093
+ this._commandService = _commandService;
18094
+ this._sidebarService = _sidebarService;
18095
+ _defineProperty(this, "_id", void 0);
18096
+ }
18097
+ openPanel() {
18098
+ const props = {
18099
+ header: { title: "docs-ui.doc.slider.paragraphSetting" },
18100
+ id: this._id,
18101
+ children: { label: paragraphSettingIndexKey$1 },
18102
+ width: 300
18103
+ };
18104
+ this._sidebarService.open(props);
18105
+ }
18106
+ closePanel() {
18107
+ this._sidebarService.close(this._id);
18108
+ }
18109
+ };
18110
+ DocParagraphSettingController = __decorate([__decorateParam(0, ICommandService), __decorateParam(1, Inject(ISidebarService))], DocParagraphSettingController);
18111
+
18112
+ //#endregion
18113
+ //#region src/commands/operations/doc-paragraph-setting-panel.operation.ts
18114
+ const DocParagraphSettingPanelOperation = {
18115
+ id: "sidebar.operation.doc-paragraph-setting-panel",
18116
+ type: CommandType.OPERATION,
18117
+ handler: (accessor) => {
18118
+ accessor.get(DocParagraphSettingController).openPanel();
18119
+ return true;
18120
+ }
18121
+ };
18122
+
18123
+ //#endregion
18124
+ //#region src/views/section-setting/component-name.ts
18125
+ /**
18126
+ * Copyright 2023-present DreamNum Co., Ltd.
18127
+ *
18128
+ * Licensed under the Apache License, Version 2.0 (the "License");
18129
+ * you may not use this file except in compliance with the License.
18130
+ * You may obtain a copy of the License at
18131
+ *
18132
+ * http://www.apache.org/licenses/LICENSE-2.0
18133
+ *
18134
+ * Unless required by applicable law or agreed to in writing, software
18135
+ * distributed under the License is distributed on an "AS IS" BASIS,
18136
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18137
+ * See the License for the specific language governing permissions and
18138
+ * limitations under the License.
18139
+ */
18140
+ const DOC_SECTION_SETTING_COMPONENT = "doc_ui_section-setting-panel";
18141
+
18142
+ //#endregion
18143
+ //#region src/controllers/doc-section-setting.controller.ts
18144
+ /**
18145
+ * Copyright 2023-present DreamNum Co., Ltd.
18146
+ *
18147
+ * Licensed under the Apache License, Version 2.0 (the "License");
18148
+ * you may not use this file except in compliance with the License.
18149
+ * You may obtain a copy of the License at
18150
+ *
18151
+ * http://www.apache.org/licenses/LICENSE-2.0
18152
+ *
18153
+ * Unless required by applicable law or agreed to in writing, software
18154
+ * distributed under the License is distributed on an "AS IS" BASIS,
18155
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18156
+ * See the License for the specific language governing permissions and
18157
+ * limitations under the License.
18158
+ */
18159
+ let DocSectionSettingController = class DocSectionSettingController extends Disposable {
18160
+ constructor(_sidebarService, _selectionManager) {
18161
+ super();
18162
+ this._sidebarService = _sidebarService;
18163
+ this._selectionManager = _selectionManager;
18164
+ _defineProperty(this, "_panelId", "DocSectionSetting");
18165
+ }
18166
+ openPanel() {
18167
+ this._sidebarService.open({
18168
+ header: { title: "docs-ui.doc.slider.sectionSetting" },
18169
+ id: this._panelId,
18170
+ children: { label: DOC_SECTION_SETTING_COMPONENT },
18171
+ width: 300
18172
+ });
18173
+ }
18174
+ closePanel() {
18175
+ this._sidebarService.close(this._panelId);
18176
+ }
18177
+ navigateToSectionEnd(unitId, sectionStart, sectionEnd) {
18178
+ const params = {
18179
+ unitId,
18180
+ subUnitId: unitId
18181
+ };
18182
+ const cursorOffset = Math.max(sectionStart, sectionEnd - 1);
18183
+ this._selectionManager.replaceDocRanges([{
18184
+ startOffset: cursorOffset,
18185
+ endOffset: cursorOffset
18186
+ }], params, true, { shouldFocus: false });
18187
+ }
18188
+ };
18189
+ DocSectionSettingController = __decorate([__decorateParam(0, Inject(ISidebarService)), __decorateParam(1, Inject(DocSelectionManagerService))], DocSectionSettingController);
18190
+
18191
+ //#endregion
18192
+ //#region src/commands/operations/doc-section-setting-panel.operation.ts
18193
+ const DocSectionSettingPanelOperation = {
18194
+ id: "sidebar.operation.doc-section-setting-panel",
18195
+ type: CommandType.OPERATION,
18196
+ handler: (accessor) => {
18197
+ accessor.get(DocSectionSettingController).openPanel();
18198
+ return true;
18199
+ }
18200
+ };
18201
+
17738
18202
  //#endregion
17739
18203
  //#region src/menu/context-menu.ts
17740
18204
  const getDisableOnCollapsedObservable = (accessor) => {
@@ -18018,6 +18482,46 @@ function PasteRibbonMenuFactory(accessor) {
18018
18482
  };
18019
18483
  }
18020
18484
 
18485
+ //#endregion
18486
+ //#region src/menu/display.menu.ts
18487
+ const DOC_ZOOM_RATIO_MENU_ID = "doc.menu.zoom-ratio";
18488
+ function DocZoomRatioMenuItemFactory(accessor) {
18489
+ const commandService = accessor.get(ICommandService);
18490
+ const instanceService = accessor.get(IUniverInstanceService);
18491
+ return {
18492
+ id: DOC_ZOOM_RATIO_MENU_ID,
18493
+ type: MenuItemType.SELECTOR,
18494
+ icon: "ZoomInIcon",
18495
+ tooltip: "docs-ui.toolbar.zoom",
18496
+ selectionsCommandId: SetDocZoomRatioOperation.id,
18497
+ selections: DOC_ZOOM_SHORTCUTS.map((value) => ({
18498
+ value,
18499
+ label: `${value}%`,
18500
+ params: () => {
18501
+ var _instanceService$getC;
18502
+ return {
18503
+ unitId: (_instanceService$getC = instanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC)) === null || _instanceService$getC === void 0 ? void 0 : _instanceService$getC.getUnitId(),
18504
+ zoomRatio: value / 100
18505
+ };
18506
+ }
18507
+ })),
18508
+ value$: getDocZoomRatio$(commandService, instanceService),
18509
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
18510
+ };
18511
+ }
18512
+ function DocFullscreenMenuItemFactory(accessor) {
18513
+ const root = accessor.get(ILayoutService).rootContainerElement;
18514
+ const fullscreen$ = root ? merge$1(of(null), fromEvent(root.ownerDocument, "fullscreenchange")).pipe(map(() => root.ownerDocument.fullscreenElement === root), distinctUntilChanged()) : of(false);
18515
+ return {
18516
+ id: ToggleFullscreenOperation.id,
18517
+ type: MenuItemType.BUTTON,
18518
+ tooltip: "docs-ui.toolbar.fullscreen",
18519
+ icon: fullscreen$.pipe(map((fullscreen) => fullscreen ? "ShrinkIcon" : "ExpandIcon")),
18520
+ activated$: fullscreen$,
18521
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
18522
+ };
18523
+ }
18524
+
18021
18525
  //#endregion
18022
18526
  //#region src/views/paragraph-menu/theme-color.ts
18023
18527
  function getHighlightBackgroundColor(themeService, index) {
@@ -18426,7 +18930,7 @@ function ParagraphMenuInsertBelowSubmenuItemFactory(accessor) {
18426
18930
  return {
18427
18931
  id: DOC_PARAGRAPH_T_INSERT_BELOW_MENU_ID,
18428
18932
  type: MenuItemType.SUBITEMS,
18429
- icon: "TextTypeIcon",
18933
+ icon: "InsertBelowDoubleIcon",
18430
18934
  title: "docs-ui.rightClick.insertBellow",
18431
18935
  tooltip: "docs-ui.rightClick.insertBellow",
18432
18936
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
@@ -18644,7 +19148,8 @@ const menuSchema = {
18644
19148
  order: 0,
18645
19149
  gridLayout: {
18646
19150
  row: 2,
18647
- column: 1
19151
+ column: 1,
19152
+ width: 44
18648
19153
  },
18649
19154
  menuItemFactory: BoldMenuItemFactory
18650
19155
  },
@@ -18652,7 +19157,8 @@ const menuSchema = {
18652
19157
  order: 1,
18653
19158
  gridLayout: {
18654
19159
  row: 2,
18655
- column: 2
19160
+ column: 2,
19161
+ width: 44
18656
19162
  },
18657
19163
  menuItemFactory: ItalicMenuItemFactory
18658
19164
  },
@@ -18660,7 +19166,8 @@ const menuSchema = {
18660
19166
  order: 2,
18661
19167
  gridLayout: {
18662
19168
  row: 2,
18663
- column: 3
19169
+ column: 3,
19170
+ width: 44
18664
19171
  },
18665
19172
  menuItemFactory: UnderlineMenuItemFactory
18666
19173
  },
@@ -18668,7 +19175,8 @@ const menuSchema = {
18668
19175
  order: 3,
18669
19176
  gridLayout: {
18670
19177
  row: 2,
18671
- column: 4
19178
+ column: 4,
19179
+ width: 44
18672
19180
  },
18673
19181
  menuItemFactory: StrikeThroughMenuItemFactory
18674
19182
  },
@@ -18676,7 +19184,8 @@ const menuSchema = {
18676
19184
  order: 4,
18677
19185
  gridLayout: {
18678
19186
  row: 2,
18679
- column: 5
19187
+ column: 6,
19188
+ width: 44
18680
19189
  },
18681
19190
  menuItemFactory: SubscriptMenuItemFactory
18682
19191
  },
@@ -18684,7 +19193,8 @@ const menuSchema = {
18684
19193
  order: 5,
18685
19194
  gridLayout: {
18686
19195
  row: 2,
18687
- column: 6
19196
+ column: 5,
19197
+ width: 44
18688
19198
  },
18689
19199
  menuItemFactory: SuperscriptMenuItemFactory
18690
19200
  },
@@ -18694,7 +19204,7 @@ const menuSchema = {
18694
19204
  row: 1,
18695
19205
  column: 1,
18696
19206
  columnSpan: 2,
18697
- width: 100
19207
+ width: 96
18698
19208
  },
18699
19209
  menuItemFactory: HeadingSelectorMenuItemFactory
18700
19210
  },
@@ -18703,7 +19213,8 @@ const menuSchema = {
18703
19213
  gridLayout: {
18704
19214
  row: 1,
18705
19215
  column: 7,
18706
- width: 64
19216
+ columnSpan: 2,
19217
+ width: 96
18707
19218
  },
18708
19219
  menuItemFactory: FontSizeSelectorMenuItemFactory
18709
19220
  },
@@ -18713,7 +19224,7 @@ const menuSchema = {
18713
19224
  row: 1,
18714
19225
  column: 3,
18715
19226
  columnSpan: 4,
18716
- width: 160
19227
+ width: 200
18717
19228
  },
18718
19229
  menuItemFactory: FontFamilySelectorMenuItemFactory
18719
19230
  },
@@ -18721,7 +19232,8 @@ const menuSchema = {
18721
19232
  order: 8,
18722
19233
  gridLayout: {
18723
19234
  row: 2,
18724
- column: 7
19235
+ column: 8,
19236
+ width: 44
18725
19237
  },
18726
19238
  menuItemFactory: TextColorSelectorMenuItemFactory,
18727
19239
  [ResetInlineFormatTextColorCommand.id]: {
@@ -18733,7 +19245,8 @@ const menuSchema = {
18733
19245
  order: 9,
18734
19246
  gridLayout: {
18735
19247
  row: 2,
18736
- column: 8
19248
+ column: 7,
19249
+ width: 44
18737
19250
  },
18738
19251
  menuItemFactory: BackgroundColorSelectorMenuItemFactory,
18739
19252
  [ResetInlineFormatTextBackgroundColorCommand.id]: {
@@ -18784,16 +19297,6 @@ const menuSchema = {
18784
19297
  showLabel: true
18785
19298
  },
18786
19299
  menuItemFactory: HeaderFooterMenuItemFactory
18787
- },
18788
- [DocOpenPageSettingCommand.id]: {
18789
- order: 12,
18790
- gridLayout: {
18791
- row: 1,
18792
- column: 4,
18793
- rowSpan: 2,
18794
- showLabel: true
18795
- },
18796
- menuItemFactory: PageSettingMenuItemFactory
18797
19300
  }
18798
19301
  },
18799
19302
  [RibbonInsertGroup.MEDIA]: {
@@ -18859,13 +19362,41 @@ const menuSchema = {
18859
19362
  },
18860
19363
  menuItemFactory: EmojiPickerMenuItemFactory
18861
19364
  },
18862
- [DOC_INSERT_SYMBOL_MENU_ID]: {
18863
- order: 6,
19365
+ [DOC_INSERT_SYMBOL_MENU_ID]: {
19366
+ order: 6,
19367
+ gridLayout: {
19368
+ row: 2,
19369
+ column: 3
19370
+ },
19371
+ menuItemFactory: SymbolPickerMenuItemFactory
19372
+ }
19373
+ },
19374
+ [RibbonViewGroup.DISPLAY]: {
19375
+ [DocOpenPageSettingCommand.id]: {
19376
+ order: 0,
19377
+ gridLayout: {
19378
+ row: 1,
19379
+ column: 1,
19380
+ rowSpan: 2,
19381
+ showLabel: true
19382
+ },
19383
+ menuItemFactory: PageSettingMenuItemFactory
19384
+ },
19385
+ [DOC_ZOOM_RATIO_MENU_ID]: {
19386
+ order: 1,
19387
+ gridLayout: {
19388
+ row: 1,
19389
+ column: 2
19390
+ },
19391
+ menuItemFactory: DocZoomRatioMenuItemFactory
19392
+ },
19393
+ [ToggleFullscreenOperation.id]: {
19394
+ order: 2,
18864
19395
  gridLayout: {
18865
19396
  row: 2,
18866
- column: 3
19397
+ column: 2
18867
19398
  },
18868
- menuItemFactory: SymbolPickerMenuItemFactory
19399
+ menuItemFactory: DocFullscreenMenuItemFactory
18869
19400
  }
18870
19401
  },
18871
19402
  [ContextMenuPosition.MAIN_AREA]: {
@@ -19492,6 +20023,9 @@ const menuSchema = {
19492
20023
 
19493
20024
  //#endregion
19494
20025
  //#region src/shortcuts/utils.ts
20026
+ function whenTextEditorFocused(contextService) {
20027
+ return contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && !contextService.getContextValue(FOCUSING_COMMON_DRAWINGS) && (contextService.getContextValue(FOCUSING_DOC) || contextService.getContextValue(EDITOR_ACTIVATED) || contextService.getContextValue(FOCUSING_FX_BAR_EDITOR));
20028
+ }
19495
20029
  function whenDocAndEditorFocused(contextService) {
19496
20030
  return contextService.getContextValue(FOCUSING_DOC) && contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && !contextService.getContextValue(FOCUSING_COMMON_DRAWINGS);
19497
20031
  }
@@ -19506,6 +20040,11 @@ const TabShortCut = {
19506
20040
  binding: KeyCode.TAB,
19507
20041
  preconditions: whenDocAndEditorFocused
19508
20042
  };
20043
+ const UpdateDocFieldsShortcut = {
20044
+ id: UpdateSelectedDocFieldsCommand.id,
20045
+ binding: KeyCode.F9,
20046
+ preconditions: whenDocAndEditorFocused
20047
+ };
19509
20048
  const ShiftTabShortCut = {
19510
20049
  id: TabCommand.id,
19511
20050
  binding: KeyCode.TAB | MetaKeys.SHIFT,
@@ -19578,45 +20117,23 @@ const BulletListShortCut = {
19578
20117
 
19579
20118
  //#endregion
19580
20119
  //#region src/views/count-bar/ZoomSlider.tsx
19581
- const ZOOM_MAP = [
19582
- 50,
19583
- 80,
19584
- 100,
19585
- 130,
19586
- 150,
19587
- 170,
19588
- 200,
19589
- 400
19590
- ];
19591
20120
  const DOC_ZOOM_RANGE = [10, 400];
19592
20121
  function ZoomSlider() {
19593
20122
  const commandService = useDependency(ICommandService);
19594
20123
  const univerInstanceService = useDependency(IUniverInstanceService);
19595
- const documentDataModel = useObservable(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC).pipe(filter((documentDataModel) => documentDataModel != null)), null, false, [univerInstanceService]);
19596
- const getCurrentZoom = useCallback((docModel = documentDataModel) => {
19597
- if (!docModel) return 100;
19598
- return Math.round(getDocEffectiveZoomRatio(docModel) * 100);
19599
- }, [documentDataModel]);
19600
- const [zoom, setZoom] = useState(100);
19601
- useEffect(() => setZoom(getCurrentZoom(documentDataModel)), [documentDataModel, getCurrentZoom]);
19602
- useEffect(() => {
19603
- return commandService.onCommandExecuted((commandInfo) => {
19604
- if (commandInfo.id === SetDocZoomRatioOperation.id) setZoom(getCurrentZoom());
19605
- }).dispose;
19606
- }, [commandService, getCurrentZoom]);
20124
+ const zoom = useObservable(() => getDocZoomRatio$(commandService, univerInstanceService), 100, void 0, [commandService, univerInstanceService]);
19607
20125
  function handleChange(value) {
19608
- setZoom(value);
20126
+ const documentDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
19609
20127
  if (documentDataModel == null) return;
19610
- const zoomRatio = value / 100;
19611
- commandService.executeCommand(SetDocZoomRatioOperation.id, {
20128
+ return commandService.executeCommand(SetDocZoomRatioOperation.id, {
19612
20129
  unitId: documentDataModel.getUnitId(),
19613
- zoomRatio
20130
+ zoomRatio: value / 100
19614
20131
  });
19615
20132
  }
19616
20133
  return /* @__PURE__ */ jsx(Slider, {
19617
20134
  min: DOC_ZOOM_RANGE[0],
19618
20135
  value: zoom,
19619
- shortcuts: ZOOM_MAP,
20136
+ shortcuts: DOC_ZOOM_SHORTCUTS,
19620
20137
  onChange: handleChange
19621
20138
  });
19622
20139
  }
@@ -20515,21 +21032,6 @@ function DocSideMenuContent() {
20515
21032
 
20516
21033
  //#endregion
20517
21034
  //#region src/controllers/ui.controller.ts
20518
- /**
20519
- * Copyright 2023-present DreamNum Co., Ltd.
20520
- *
20521
- * Licensed under the Apache License, Version 2.0 (the "License");
20522
- * you may not use this file except in compliance with the License.
20523
- * You may obtain a copy of the License at
20524
- *
20525
- * http://www.apache.org/licenses/LICENSE-2.0
20526
- *
20527
- * Unless required by applicable law or agreed to in writing, software
20528
- * distributed under the License is distributed on an "AS IS" BASIS,
20529
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20530
- * See the License for the specific language governing permissions and
20531
- * limitations under the License.
20532
- */
20533
21035
  let DocUIController = class DocUIController extends Disposable {
20534
21036
  constructor(_injector, _commandService, _layoutService, _menuManagerService, _uiPartsService, _univerInstanceService, _shortcutService, _configService, _embedInteractionBoundaryService, _embedRuntimeFocusCoordinator) {
20535
21037
  super();
@@ -20551,6 +21053,7 @@ let DocUIController = class DocUIController extends Disposable {
20551
21053
  _initMenus() {
20552
21054
  this._menuManagerService.appendRootMenu(floatToolbarMenuSchema);
20553
21055
  this._menuManagerService.mergeMenu(menuSchema);
21056
+ this._menuManagerService.mergeMenu(headerFooterRibbonSchema);
20554
21057
  }
20555
21058
  _initShortCut() {
20556
21059
  [
@@ -20566,7 +21069,8 @@ let DocUIController = class DocUIController extends Disposable {
20566
21069
  AlignLeftShortCut,
20567
21070
  OrderListShortCut,
20568
21071
  BulletListShortCut,
20569
- TabShortCut
21072
+ TabShortCut,
21073
+ UpdateDocFieldsShortcut
20570
21074
  ].forEach((shortcut) => {
20571
21075
  this.disposeWithMe(this._shortcutService.registerShortcut(shortcut));
20572
21076
  });
@@ -20575,6 +21079,7 @@ let DocUIController = class DocUIController extends Disposable {
20575
21079
  this._initMenus();
20576
21080
  this._initFocusHandler();
20577
21081
  this._initCommands();
21082
+ this._initDateTimeFields();
20578
21083
  this._initUiParts();
20579
21084
  this._initShortCut();
20580
21085
  }
@@ -20583,10 +21088,25 @@ let DocUIController = class DocUIController extends Disposable {
20583
21088
  OpenDocPermissionPanelOperation,
20584
21089
  OpenDocParagraphPermissionOperation,
20585
21090
  CoreHeaderFooterCommand,
21091
+ InsertHeaderFooterFieldCommand,
21092
+ RefreshHeaderFooterFieldsCommand,
21093
+ UpdateSelectedDocFieldsCommand,
20586
21094
  OpenHeaderFooterPanelCommand,
20587
- SidebarDocHeaderFooterPanelOperation
21095
+ DocHeaderFooterRibbonOperation
20588
21096
  ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
20589
21097
  }
21098
+ _initDateTimeFields() {
21099
+ const refreshed = /* @__PURE__ */ new WeakSet();
21100
+ this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC).subscribe((model) => {
21101
+ if (model && !refreshed.has(model)) {
21102
+ refreshed.add(model);
21103
+ this._commandService.syncExecuteCommand(RefreshHeaderFooterFieldsCommand.id, {
21104
+ unitId: model.getUnitId(),
21105
+ onOpen: true
21106
+ });
21107
+ }
21108
+ }));
21109
+ }
20590
21110
  _initFocusHandler() {
20591
21111
  this.disposeWithMe(this._layoutService.registerFocusHandler(UniverInstanceType.UNIVER_DOC, (unitId) => {
20592
21112
  if (this._shouldPreserveEmbedFocus(unitId)) return;
@@ -20884,7 +21404,7 @@ function resolveDocsCustomBlockRenderViewport(params) {
20884
21404
  //#endregion
20885
21405
  //#region package.json
20886
21406
  var name = "@univerjs/docs-ui";
20887
- var version = "1.0.3";
21407
+ var version = "1.1.0";
20888
21408
 
20889
21409
  //#endregion
20890
21410
  //#region src/commands/commands/doc-paragraph-setting.command.ts
@@ -21131,8 +21651,8 @@ var HeaderFooterContentCover = class extends BaseObject {
21131
21651
  right: pageLeft + page.pageWidth,
21132
21652
  bottom: pageTop + page.pageHeight
21133
21653
  });
21134
- const header = (_data$skeHeaders$get = data.skeHeaders.get(page.headerId)) === null || _data$skeHeaders$get === void 0 ? void 0 : _data$skeHeaders$get.get(page.pageWidth);
21135
- const footer = (_data$skeFooters$get = data.skeFooters.get(page.footerId)) === null || _data$skeFooters$get === void 0 ? void 0 : _data$skeFooters$get.get(page.pageWidth);
21654
+ const header = (_data$skeHeaders$get = data.skeHeaders.get(page.headerId)) === null || _data$skeHeaders$get === void 0 ? void 0 : _data$skeHeaders$get.get(page.headerLayoutKey ?? page.pageWidth);
21655
+ const footer = (_data$skeFooters$get = data.skeFooters.get(page.footerId)) === null || _data$skeFooters$get === void 0 ? void 0 : _data$skeFooters$get.get(page.footerLayoutKey ?? page.pageWidth);
21136
21656
  const local = [];
21137
21657
  if (header) this._collectTextAndTables(header, pageLeft + page.marginLeft, pageTop + header.marginTop, local);
21138
21658
  if (footer) this._collectTextAndTables(footer, pageLeft + page.marginLeft, pageTop + page.pageHeight - footer.height - footer.marginBottom, local);
@@ -21590,7 +22110,7 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
21590
22110
  const body = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(normalizedSegmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
21591
22111
  if (body == null) return;
21592
22112
  const dataStreamLength = body.dataStream.length ?? Number.POSITIVE_INFINITY;
21593
- const customRanges = docDataModel.getCustomRanges() ?? [];
22113
+ const customRanges = body.customRanges ?? [];
21594
22114
  if (granularity !== "character") {
21595
22115
  const nextOffset = this._getCursorOffsetByGranularity(skeleton, focusOffset, direction, granularity, normalizedSegmentId, normalizedSegmentPage, dataStreamLength, body.dataStream);
21596
22116
  if (nextOffset == null || nextOffset === focusOffset) return;
@@ -21662,7 +22182,7 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
21662
22182
  const body = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(normalizedSegmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.getBody();
21663
22183
  if (body == null) return;
21664
22184
  const dataStreamLength = body.dataStream.length ?? Number.POSITIVE_INFINITY;
21665
- const customRanges = docDataModel.getCustomRanges() ?? [];
22185
+ const customRanges = body.customRanges ?? [];
21666
22186
  if (granularity !== "character") {
21667
22187
  let cursorOffset;
21668
22188
  if (!activeRange.collapsed || allRanges.length > 1) {
@@ -22285,26 +22805,33 @@ function DocPasteOptions() {
22285
22805
  const commandService = useDependency(ICommandService);
22286
22806
  const localeService = useDependency(LocaleService);
22287
22807
  const layoutService = useDependency(ILayoutService);
22808
+ const editorService = useDependency(IEditorService);
22288
22809
  const state = useObservable(clipboard.pasteOptions$, null);
22289
22810
  const [busy, setBusy] = useState(false);
22290
22811
  const [open, setOpen] = useState(false);
22812
+ const focusEditor = () => {
22813
+ const editor = state && clipboard.isPasteOptionsEnabled(state.unitId) && editorService.getEditor(state.unitId);
22814
+ if (editor) editor.focus();
22815
+ else layoutService.focus();
22816
+ };
22291
22817
  const changeMode = async (value) => {
22292
22818
  setBusy(true);
22293
22819
  try {
22294
22820
  await commandService.executeCommand(DocChangePasteModeCommand.id, { value });
22295
22821
  } finally {
22296
22822
  setBusy(false);
22297
- layoutService.focus();
22823
+ focusEditor();
22298
22824
  }
22299
22825
  };
22300
22826
  if (!state) return null;
22301
22827
  return /* @__PURE__ */ jsx(DropdownMenu, {
22828
+ "data-u-editor-interaction-boundary": "true",
22302
22829
  align: "start",
22303
22830
  open,
22304
22831
  onOpenChange: setOpen,
22305
22832
  onCloseAutoFocus: (event) => {
22306
22833
  event.preventDefault();
22307
- layoutService.focus();
22834
+ focusEditor();
22308
22835
  },
22309
22836
  onEscapeKeyDown: () => clipboard.dismissPasteOptions(),
22310
22837
  items: DOC_PASTE_OPTIONS.map((option) => ({
@@ -22316,6 +22843,7 @@ function DocPasteOptions() {
22316
22843
  onSelect: () => changeMode(option.value)
22317
22844
  })),
22318
22845
  children: /* @__PURE__ */ jsxs(Button, {
22846
+ "data-u-editor-interaction-boundary": "true",
22319
22847
  size: "small",
22320
22848
  disabled: busy,
22321
22849
  "aria-label": localeService.t("docs-ui.pasteOptions.title"),
@@ -22324,7 +22852,7 @@ function DocPasteOptions() {
22324
22852
  onKeyDown: (event) => {
22325
22853
  if (event.key === "Escape") {
22326
22854
  clipboard.dismissPasteOptions();
22327
- layoutService.focus();
22855
+ focusEditor();
22328
22856
  }
22329
22857
  },
22330
22858
  className: "univer-shadow-sm",
@@ -22583,28 +23111,37 @@ function useHeaderFooterOptions(unitId) {
22583
23111
  page
22584
23112
  };
22585
23113
  };
22586
- const [options, setOptions] = useState(() => {
22587
- var _getCurrentSectionCon;
22588
- const config = (_getCurrentSectionCon = getCurrentSectionContext()) === null || _getCurrentSectionCon === void 0 ? void 0 : _getCurrentSectionCon.config;
22589
- return {
22590
- marginHeader: (config === null || config === void 0 ? void 0 : config.marginHeader) ?? 0,
22591
- marginFooter: (config === null || config === void 0 ? void 0 : config.marginFooter) ?? 0,
22592
- useFirstPageHeaderFooter: (config === null || config === void 0 ? void 0 : config.useFirstPageHeaderFooter) ?? BooleanNumber.FALSE,
22593
- evenAndOddHeaders: (config === null || config === void 0 ? void 0 : config.evenAndOddHeaders) ?? BooleanNumber.FALSE
23114
+ const [, refresh] = useReducer((revision) => revision + 1, 0);
23115
+ useEffect(() => {
23116
+ const commandListener = commandService.onCommandExecuted((command) => {
23117
+ var _command$params;
23118
+ if (command.id === RichTextEditingMutation.id && ((_command$params = command.params) === null || _command$params === void 0 ? void 0 : _command$params.unitId) === unitId) refresh();
23119
+ });
23120
+ const segmentListener = docSelectionRenderService.segmentContext$.subscribe(() => refresh());
23121
+ return () => {
23122
+ commandListener.dispose();
23123
+ segmentListener.unsubscribe();
22594
23124
  };
22595
- });
23125
+ }, [
23126
+ commandService,
23127
+ docSelectionRenderService,
23128
+ unitId
23129
+ ]);
22596
23130
  const sectionContext = getCurrentSectionContext();
23131
+ const config = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config;
23132
+ const options = {
23133
+ marginHeader: (config === null || config === void 0 ? void 0 : config.marginHeader) ?? 0,
23134
+ marginFooter: (config === null || config === void 0 ? void 0 : config.marginFooter) ?? 0,
23135
+ useFirstPageHeaderFooter: (config === null || config === void 0 ? void 0 : config.useFirstPageHeaderFooter) ?? BooleanNumber.FALSE,
23136
+ evenAndOddHeaders: (config === null || config === void 0 ? void 0 : config.evenAndOddHeaders) ?? BooleanNumber.FALSE
23137
+ };
22597
23138
  const headerFooterKind = ((_renderManagerService2 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService2 === void 0 || (_renderManagerService2 = _renderManagerService2.with(DocSkeletonManagerService)) === null || _renderManagerService2 === void 0 || (_renderManagerService2 = _renderManagerService2.getViewModel()) === null || _renderManagerService2 === void 0 ? void 0 : _renderManagerService2.getEditArea()) === DocumentEditArea.FOOTER ? "footer" : "header";
22598
23139
  const variant = getHeaderFooterVariant((sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config) ?? {}, docSelectionRenderService.getSegmentPage(), sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page);
22599
23140
  const referenceKey = getSectionHeaderFooterReferenceKey(headerFooterKind, variant);
22600
23141
  const canLinkToPrevious = ((sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionIndex) ?? -1) > 0;
22601
- const [linkedToPrevious, setLinkedToPrevious] = useState(canLinkToPrevious && !(sectionContext === null || sectionContext === void 0 || (_sectionContext$secti = sectionContext.section) === null || _sectionContext$secti === void 0 ? void 0 : _sectionContext$secti[referenceKey]));
22602
- const handleCheckboxChange = (val, type) => {
23142
+ const linkedToPrevious = canLinkToPrevious && !(sectionContext === null || sectionContext === void 0 || (_sectionContext$secti = sectionContext.section) === null || _sectionContext$secti === void 0 ? void 0 : _sectionContext$secti[referenceKey]);
23143
+ const handleCheckboxChange = async (val, type) => {
22603
23144
  var _renderManagerService3;
22604
- setOptions((prev) => ({
22605
- ...prev,
22606
- [type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE
22607
- }));
22608
23145
  const sectionContext = getCurrentSectionContext();
22609
23146
  const documentStyle = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config;
22610
23147
  const docSkeletonManagerService = (_renderManagerService3 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService3 === void 0 ? void 0 : _renderManagerService3.with(DocSkeletonManagerService);
@@ -22629,7 +23166,7 @@ function useHeaderFooterOptions(unitId) {
22629
23166
  if (needCreateHeaderFooter) {
22630
23167
  const segmentId = generateRandomId(6);
22631
23168
  if (needChangeSegmentId) docSelectionRenderService.setSegment(segmentId);
22632
- commandService.executeCommand(CoreHeaderFooterCommandId, {
23169
+ await commandService.executeCommand(CoreHeaderFooterCommandId, {
22633
23170
  unitId,
22634
23171
  segmentId,
22635
23172
  headerFooterProps: { [type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE },
@@ -22643,7 +23180,7 @@ function useHeaderFooterOptions(unitId) {
22643
23180
  [type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE
22644
23181
  }, editArea, segmentPageIndex, sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page);
22645
23182
  if (needFocusSegmentId && needFocusSegmentId !== prevSegmentId) docSelectionRenderService.setSegment(needFocusSegmentId);
22646
- commandService.executeCommand(CoreHeaderFooterCommandId, {
23183
+ await commandService.executeCommand(CoreHeaderFooterCommandId, {
22647
23184
  unitId,
22648
23185
  headerFooterProps: { [type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE },
22649
23186
  sectionId: sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionId
@@ -22652,21 +23189,16 @@ function useHeaderFooterOptions(unitId) {
22652
23189
  layoutService.focus();
22653
23190
  };
22654
23191
  const handleMarginChange = async (val, type) => {
22655
- var _getCurrentSectionCon2;
22656
- setOptions((prev) => ({
22657
- ...prev,
22658
- [type]: val
22659
- }));
23192
+ var _getCurrentSectionCon;
22660
23193
  await commandService.executeCommand(CoreHeaderFooterCommandId, {
22661
23194
  unitId,
22662
23195
  headerFooterProps: { [type]: val },
22663
- sectionId: (_getCurrentSectionCon2 = getCurrentSectionContext()) === null || _getCurrentSectionCon2 === void 0 ? void 0 : _getCurrentSectionCon2.sectionId
23196
+ sectionId: (_getCurrentSectionCon = getCurrentSectionContext()) === null || _getCurrentSectionCon === void 0 ? void 0 : _getCurrentSectionCon.sectionId
22664
23197
  });
22665
- docSelectionRenderService.removeAllRanges();
22666
23198
  docSelectionRenderService.blur();
22667
23199
  };
22668
23200
  const closeHeaderFooter = () => {
22669
- commandService.executeCommand(CloseHeaderFooterCommand.id, { unitId });
23201
+ return commandService.executeCommand(CloseHeaderFooterCommand.id, { unitId });
22670
23202
  };
22671
23203
  const handleLinkToPreviousChange = async (linked) => {
22672
23204
  var _renderManagerService4;
@@ -22685,7 +23217,6 @@ function useHeaderFooterOptions(unitId) {
22685
23217
  linkedToPrevious: linked,
22686
23218
  ...linked ? {} : { segmentId }
22687
23219
  })) return;
22688
- setLinkedToPrevious(linked);
22689
23220
  docSelectionRenderService.setSegment(linked ? previousSegmentId ?? "" : segmentId);
22690
23221
  layoutService.focus();
22691
23222
  };
@@ -24061,6 +24592,7 @@ let MobileComponentsController = class MobileComponentsController extends Dispos
24061
24592
  H5Icon,
24062
24593
  HeaderFooterIcon,
24063
24594
  HorizontallyIcon,
24595
+ InsertBelowDoubleIcon,
24064
24596
  InsertDoubleIcon,
24065
24597
  InsertRowAboveDoubleIcon,
24066
24598
  InsertRowBelowDoubleIcon,
@@ -24093,6 +24625,7 @@ let MobileComponentsController = class MobileComponentsController extends Dispos
24093
24625
  TodoListDoubleIcon,
24094
24626
  UnderlineIcon,
24095
24627
  UnorderIcon,
24628
+ ZoomInIcon,
24096
24629
  DefaultTextColorIcon,
24097
24630
  HeaderTextColorIcon,
24098
24631
  MoreRightIcon,
@@ -25387,9 +25920,9 @@ let DocPasteOptionsRenderController = class DocPasteOptionsRenderController exte
25387
25920
  this._context = _context;
25388
25921
  this._clipboard = _clipboard;
25389
25922
  _defineProperty(this, "_popup", void 0);
25390
- if (isInternalEditorID(_context.unitId)) return;
25391
25923
  const mobile = contextService.getContextValue(MOBILE_UI_MODE) === true;
25392
25924
  this.disposeWithMe(selection.onKeydown$.subscribe(({ event }) => {
25925
+ if (!this._clipboard.isPasteOptionsEnabled(this._context.unitId)) return;
25393
25926
  const key = event;
25394
25927
  if ((key.ctrlKey || key.metaKey) && key.shiftKey && key.key.toLowerCase() === "v") this._clipboard.setNextPasteMode("text");
25395
25928
  else if (![
@@ -25402,12 +25935,17 @@ let DocPasteOptionsRenderController = class DocPasteOptionsRenderController exte
25402
25935
  this._clipboard.dismissPasteOptions();
25403
25936
  }
25404
25937
  }));
25405
- this.disposeWithMe(selection.onInputBefore$.subscribe(() => this._clipboard.dismissPasteOptions()));
25938
+ this.disposeWithMe(selection.onInputBefore$.subscribe(() => {
25939
+ if (this._clipboard.isPasteOptionsEnabled(this._context.unitId)) this._clipboard.dismissPasteOptions();
25940
+ }));
25406
25941
  this.disposeWithMe(selection.onPointerDown$.subscribe(() => {
25942
+ if (!this._clipboard.isPasteOptionsEnabled(this._context.unitId)) return;
25407
25943
  this._clipboard.setNextPasteMode("source");
25408
25944
  if (!mobile) this._clipboard.dismissPasteOptions();
25409
25945
  }));
25410
- this.disposeWithMe(selection.onBlur$.subscribe(() => this._clipboard.setNextPasteMode("source")));
25946
+ this.disposeWithMe(selection.onBlur$.subscribe(() => {
25947
+ if (this._clipboard.isPasteOptionsEnabled(this._context.unitId)) this._clipboard.setNextPasteMode("source");
25948
+ }));
25411
25949
  this.disposeWithMe(this._clipboard.pasteOptions$.subscribe((state) => {
25412
25950
  var _this$_popup;
25413
25951
  (_this$_popup = this._popup) === null || _this$_popup === void 0 || _this$_popup.dispose();
@@ -25427,7 +25965,7 @@ let DocPasteOptionsRenderController = class DocPasteOptionsRenderController exte
25427
25965
  this.disposeWithMe(() => {
25428
25966
  var _this$_popup2;
25429
25967
  (_this$_popup2 = this._popup) === null || _this$_popup2 === void 0 || _this$_popup2.dispose();
25430
- this._clipboard.dismissPasteOptions();
25968
+ if (this._popup) this._clipboard.dismissPasteOptions();
25431
25969
  });
25432
25970
  }
25433
25971
  };
@@ -26464,8 +27002,8 @@ var DocPrintInterceptorService = class extends Disposable {
26464
27002
  const page = data.pages[pageIndex];
26465
27003
  if (!page) return drawingIds;
26466
27004
  collectPageDrawingIds(page, drawingIds);
26467
- const header = (_data$skeHeaders$get = data.skeHeaders.get(page.headerId)) === null || _data$skeHeaders$get === void 0 ? void 0 : _data$skeHeaders$get.get(page.pageWidth);
26468
- const footer = (_data$skeFooters$get = data.skeFooters.get(page.footerId)) === null || _data$skeFooters$get === void 0 ? void 0 : _data$skeFooters$get.get(page.pageWidth);
27005
+ const header = (_data$skeHeaders$get = data.skeHeaders.get(page.headerId)) === null || _data$skeHeaders$get === void 0 ? void 0 : _data$skeHeaders$get.get(page.headerLayoutKey ?? page.pageWidth);
27006
+ const footer = (_data$skeFooters$get = data.skeFooters.get(page.footerId)) === null || _data$skeFooters$get === void 0 ? void 0 : _data$skeFooters$get.get(page.footerLayoutKey ?? page.pageWidth);
26469
27007
  if (header) collectPageDrawingIds(header, drawingIds);
26470
27008
  if (footer) collectPageDrawingIds(footer, drawingIds);
26471
27009
  return drawingIds;
@@ -27466,6 +28004,319 @@ UniverDocsMobileUIPlugin = __decorate([
27466
28004
  __decorateParam(4, IConfigService)
27467
28005
  ], UniverDocsMobileUIPlugin);
27468
28006
 
28007
+ //#endregion
28008
+ //#region src/views/header-footer/panel/DocHeaderFooterFields.tsx
28009
+ function DocHeaderFooterFields({ unitId, disabled }) {
28010
+ const localeService = useDependency(LocaleService);
28011
+ useObservable(localeService.currentLocale$);
28012
+ const commands = useDependency(ICommandService);
28013
+ const layout = useDependency(ILayoutService);
28014
+ const shortcuts = useDependency(IShortcutService);
28015
+ const selections = useDependency(DocSelectionManagerService);
28016
+ const instances = useDependency(IUniverInstanceService);
28017
+ const [target, setTarget] = useState(null);
28018
+ const [format, setFormat] = useState("short");
28019
+ const [automatic, setAutomatic] = useState(true);
28020
+ const [error, setError] = useState(false);
28021
+ const [previewDate, setPreviewDate] = useState(() => /* @__PURE__ */ new Date());
28022
+ const locale = LOCALE_META[localeService.getCurrentLocale()].tag;
28023
+ const dialogOpen = target !== null;
28024
+ const dialogFocusRef = useRef(null);
28025
+ useEffect(() => {
28026
+ var _instances$getFocused;
28027
+ if (dialogOpen) return;
28028
+ const focus = dialogFocusRef.current;
28029
+ dialogFocusRef.current = null;
28030
+ if ((focus === null || focus === void 0 ? void 0 : focus.unitId) === unitId && instances.getUnit(unitId) && ((_instances$getFocused = instances.getFocusedUnit()) === null || _instances$getFocused === void 0 ? void 0 : _instances$getFocused.getUnitId()) === focus.focusedUnitId) layout.focus(unitId);
28031
+ }, [
28032
+ dialogOpen,
28033
+ instances,
28034
+ layout,
28035
+ unitId
28036
+ ]);
28037
+ useEffect(() => {
28038
+ if (!dialogOpen) return;
28039
+ const escape = shortcuts.forceEscape();
28040
+ return () => escape.dispose();
28041
+ }, [dialogOpen, shortcuts]);
28042
+ function restoreFocus(event) {
28043
+ event.preventDefault();
28044
+ layout.focus(unitId);
28045
+ }
28046
+ function openDateTime() {
28047
+ var _instances$getUnit, _instances$getFocused2;
28048
+ const selection = selections.getActiveTextRange();
28049
+ const body = (_instances$getUnit = instances.getUnit(unitId)) === null || _instances$getUnit === void 0 || (_instances$getUnit = _instances$getUnit.getSelfOrHeaderFooterModel(selection === null || selection === void 0 ? void 0 : selection.segmentId)) === null || _instances$getUnit === void 0 ? void 0 : _instances$getUnit.getBody();
28050
+ if (!(selection === null || selection === void 0 ? void 0 : selection.segmentId) || !body) return;
28051
+ dialogFocusRef.current = {
28052
+ unitId,
28053
+ focusedUnitId: (_instances$getFocused2 = instances.getFocusedUnit()) === null || _instances$getFocused2 === void 0 ? void 0 : _instances$getFocused2.getUnitId()
28054
+ };
28055
+ setTarget({
28056
+ unitId,
28057
+ selection: { ...selection },
28058
+ segmentId: selection.segmentId,
28059
+ segmentPage: selection.segmentPage,
28060
+ expectedDataStream: body.dataStream
28061
+ });
28062
+ setPreviewDate(/* @__PURE__ */ new Date());
28063
+ setError(false);
28064
+ }
28065
+ async function insertDateTime() {
28066
+ if (!target) return;
28067
+ if (await commands.executeCommand(InsertHeaderFooterFieldCommand.id, {
28068
+ ...target,
28069
+ fieldType: format === "time" ? "TIME" : "DATE",
28070
+ format,
28071
+ automatic
28072
+ })) setTarget(null);
28073
+ else setError(true);
28074
+ }
28075
+ return /* @__PURE__ */ jsxs("div", {
28076
+ className: "univer-flex univer-flex-col univer-gap-1 univer-text-xs",
28077
+ children: [
28078
+ /* @__PURE__ */ jsx(DropdownMenu, {
28079
+ onCloseAutoFocus: restoreFocus,
28080
+ disabled,
28081
+ items: [
28082
+ {
28083
+ type: "item",
28084
+ children: localeService.t("docs-ui.headerFooter.currentPage"),
28085
+ onSelect: () => commands.executeCommand(InsertHeaderFooterFieldCommand.id, {
28086
+ unitId,
28087
+ fieldType: "PAGE"
28088
+ })
28089
+ },
28090
+ {
28091
+ type: "item",
28092
+ children: localeService.t("docs-ui.headerFooter.totalPages"),
28093
+ onSelect: () => commands.executeCommand(InsertHeaderFooterFieldCommand.id, {
28094
+ unitId,
28095
+ fieldType: "NUMPAGES"
28096
+ })
28097
+ },
28098
+ { type: "separator" },
28099
+ {
28100
+ type: "item",
28101
+ children: localeService.t("docs-ui.headerFooter.refreshFields"),
28102
+ onSelect: () => commands.executeCommand(RefreshHeaderFooterFieldsCommand.id, { unitId })
28103
+ }
28104
+ ],
28105
+ children: /* @__PURE__ */ jsxs(Button, {
28106
+ className: "univer-justify-start",
28107
+ "data-u-command": InsertHeaderFooterFieldCommand.id,
28108
+ size: "small",
28109
+ variant: "text",
28110
+ disabled,
28111
+ onMouseDown: (event) => event.preventDefault(),
28112
+ children: [
28113
+ /* @__PURE__ */ jsx(NumberIcon, { "aria-hidden": "true" }),
28114
+ /* @__PURE__ */ jsx("span", {
28115
+ className: "univer-flex-1 univer-text-start",
28116
+ children: localeService.t("docs-ui.headerFooter.pageNumber")
28117
+ }),
28118
+ /* @__PURE__ */ jsx(MoreDownIcon, { "aria-hidden": "true" })
28119
+ ]
28120
+ })
28121
+ }),
28122
+ /* @__PURE__ */ jsxs(Button, {
28123
+ className: "univer-justify-start",
28124
+ "data-u-command": InsertHeaderFooterFieldCommand.id,
28125
+ size: "small",
28126
+ variant: "text",
28127
+ disabled,
28128
+ onMouseDown: (event) => event.preventDefault(),
28129
+ onClick: openDateTime,
28130
+ children: [/* @__PURE__ */ jsx(CalendarIcon, { "aria-hidden": "true" }), localeService.t("docs-ui.headerFooter.dateTime")]
28131
+ }),
28132
+ /* @__PURE__ */ jsx(Dialog, {
28133
+ open: dialogOpen,
28134
+ width: 360,
28135
+ title: localeService.t("docs-ui.headerFooter.dateTime"),
28136
+ showOk: true,
28137
+ showCancel: true,
28138
+ onClose: () => setTarget(null),
28139
+ onCancel: () => setTarget(null),
28140
+ onOk: insertDateTime,
28141
+ children: /* @__PURE__ */ jsxs("div", {
28142
+ className: "univer-flex univer-flex-col univer-gap-4",
28143
+ children: [
28144
+ /* @__PURE__ */ jsx(DropdownMenu, {
28145
+ align: "start",
28146
+ className: "univer-w-[--radix-popper-anchor-width]",
28147
+ items: [{
28148
+ type: "radio",
28149
+ value: format,
28150
+ hideIndicator: true,
28151
+ onSelect: (value) => setFormat(value),
28152
+ options: [
28153
+ "short",
28154
+ "long",
28155
+ "time"
28156
+ ].map((value) => ({
28157
+ value,
28158
+ label: createDateTimeField(value, locale, previewDate).cachedResult
28159
+ }))
28160
+ }],
28161
+ children: /* @__PURE__ */ jsxs(Button, {
28162
+ "aria-label": localeService.t("docs-ui.headerFooter.dateTime"),
28163
+ className: selectClassName,
28164
+ "data-u-comp": "select",
28165
+ children: [/* @__PURE__ */ jsx("span", {
28166
+ className: "univer-flex-1 univer-truncate univer-text-start",
28167
+ children: createDateTimeField(format, locale, previewDate).cachedResult
28168
+ }), /* @__PURE__ */ jsx(MoreDownIcon, { "aria-hidden": "true" })]
28169
+ })
28170
+ }),
28171
+ /* @__PURE__ */ jsx(Checkbox, {
28172
+ checked: automatic,
28173
+ onChange: (value) => setAutomatic(Boolean(value)),
28174
+ children: localeService.t("docs-ui.headerFooter.updateAutomatically")
28175
+ }),
28176
+ error && /* @__PURE__ */ jsx("p", {
28177
+ role: "alert",
28178
+ children: localeService.t("docs-ui.headerFooter.insertFailed")
28179
+ })
28180
+ ]
28181
+ })
28182
+ })
28183
+ ]
28184
+ });
28185
+ }
28186
+
28187
+ //#endregion
28188
+ //#region src/views/header-footer/panel/DocHeaderFooterRibbonControl.tsx
28189
+ function DocHeaderFooterRibbonControl(props) {
28190
+ const instances = useDependency(IUniverInstanceService);
28191
+ const localeService = useDependency(LocaleService);
28192
+ useObservable(localeService.currentLocale$);
28193
+ const document = useObservable(() => instances.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC), void 0, false, [instances]);
28194
+ const containerRef = useRef(null);
28195
+ const [compact, setCompact] = useState(false);
28196
+ const { kind } = props;
28197
+ useEffect(() => {
28198
+ var _containerRef$current;
28199
+ const toolbar = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.closest("[role=\"toolbar\"]");
28200
+ if (!toolbar || kind === "insertion") return;
28201
+ const thresholds = {
28202
+ position: 1100,
28203
+ options: 900,
28204
+ navigation: 650
28205
+ };
28206
+ const resize = () => setCompact(toolbar.getBoundingClientRect().width < thresholds[kind]);
28207
+ const observer = new ResizeObserver(resize);
28208
+ observer.observe(toolbar);
28209
+ return () => observer.disconnect();
28210
+ }, [kind, document]);
28211
+ if (!document) return null;
28212
+ const content = /* @__PURE__ */ jsx(HeaderFooterRibbonControl, {
28213
+ ...props,
28214
+ unitId: document.getUnitId()
28215
+ }, document.getUnitId());
28216
+ return /* @__PURE__ */ jsx("div", {
28217
+ ref: containerRef,
28218
+ "data-u-command": OpenHeaderFooterPanelCommand.id,
28219
+ className: "univer-flex univer-items-center univer-whitespace-nowrap",
28220
+ children: compact && kind !== "insertion" ? /* @__PURE__ */ jsx(DropdownMenu, {
28221
+ items: [{
28222
+ type: "custom",
28223
+ className: "univer-p-2",
28224
+ children: content
28225
+ }],
28226
+ children: /* @__PURE__ */ jsx(Button, {
28227
+ "data-u-command": OpenHeaderFooterPanelCommand.id,
28228
+ size: "small",
28229
+ variant: "text",
28230
+ onMouseDown: (event) => event.preventDefault(),
28231
+ children: localeService.t(`docs-ui.headerFooter.${kind}`)
28232
+ })
28233
+ }) : content
28234
+ });
28235
+ }
28236
+ function HeaderFooterRibbonControl({ kind, unitId }) {
28237
+ var _instances$getUnit, _renders$getRenderUni;
28238
+ const localeService = useDependency(LocaleService);
28239
+ const commandService = useDependency(ICommandService);
28240
+ const renders = useDependency(IRenderManagerService);
28241
+ const permissionService = useDependency(IPermissionService);
28242
+ useObservable(permissionService.permissionPointUpdate$);
28243
+ const instances = useDependency(IUniverInstanceService);
28244
+ const disabled = Boolean((_instances$getUnit = instances.getUnit(unitId)) === null || _instances$getUnit === void 0 ? void 0 : _instances$getUnit.getSnapshot().disabled) || !getDocumentPermissionValue(permissionService, unitId, unitId, UnitAction.Edit);
28245
+ const { canLinkToPrevious, linkedToPrevious, options, handleLinkToPreviousChange, handleCheckboxChange, handleMarginChange } = useHeaderFooterOptions(unitId);
28246
+ const area = (_renders$getRenderUni = renders.getRenderUnitById(unitId)) === null || _renders$getRenderUni === void 0 ? void 0 : _renders$getRenderUni.with(DocSkeletonManagerService).getViewModel().getEditArea();
28247
+ if (kind === "insertion") return /* @__PURE__ */ jsx(DocHeaderFooterFields, {
28248
+ unitId,
28249
+ disabled
28250
+ });
28251
+ if (kind === "navigation") return /* @__PURE__ */ jsxs("div", {
28252
+ className: "univer-grid univer-grid-cols-[auto_auto] univer-items-center univer-gap-x-2 univer-gap-y-1 univer-text-start univer-text-xs",
28253
+ children: [
28254
+ /* @__PURE__ */ jsx(Button, {
28255
+ "data-u-command": OpenHeaderFooterPanelCommand.id,
28256
+ size: "small",
28257
+ variant: "text",
28258
+ disabled: disabled || area === DocumentEditArea.HEADER,
28259
+ onMouseDown: (event) => event.preventDefault(),
28260
+ onClick: () => commandService.executeCommand(OpenHeaderFooterPanelCommand.id, { editArea: DocumentEditArea.HEADER }),
28261
+ children: localeService.t("docs-ui.headerFooter.goToHeader")
28262
+ }),
28263
+ /* @__PURE__ */ jsx(Checkbox, {
28264
+ disabled: disabled || !canLinkToPrevious,
28265
+ checked: linkedToPrevious,
28266
+ onChange: (value) => handleLinkToPreviousChange(Boolean(value)),
28267
+ children: localeService.t("docs-ui.headerFooter.linkToPrevious")
28268
+ }),
28269
+ /* @__PURE__ */ jsx(Button, {
28270
+ "data-u-command": OpenHeaderFooterPanelCommand.id,
28271
+ size: "small",
28272
+ variant: "text",
28273
+ disabled: disabled || area === DocumentEditArea.FOOTER,
28274
+ onMouseDown: (event) => event.preventDefault(),
28275
+ onClick: () => commandService.executeCommand(OpenHeaderFooterPanelCommand.id, { editArea: DocumentEditArea.FOOTER }),
28276
+ children: localeService.t("docs-ui.headerFooter.goToFooter")
28277
+ })
28278
+ ]
28279
+ });
28280
+ if (kind === "options") return /* @__PURE__ */ jsxs("div", {
28281
+ className: "univer-flex univer-flex-col univer-gap-2 univer-text-start univer-text-xs",
28282
+ children: [/* @__PURE__ */ jsx(Checkbox, {
28283
+ disabled,
28284
+ checked: options.useFirstPageHeaderFooter === BooleanNumber.TRUE,
28285
+ onChange: (value) => handleCheckboxChange(Boolean(value), "useFirstPageHeaderFooter"),
28286
+ children: localeService.t("docs-ui.headerFooter.firstPageCheckBox")
28287
+ }), /* @__PURE__ */ jsx(Checkbox, {
28288
+ disabled,
28289
+ checked: options.evenAndOddHeaders === BooleanNumber.TRUE,
28290
+ onChange: (value) => handleCheckboxChange(Boolean(value), "evenAndOddHeaders"),
28291
+ children: localeService.t("docs-ui.headerFooter.oddEvenCheckBox")
28292
+ })]
28293
+ });
28294
+ return /* @__PURE__ */ jsxs("div", {
28295
+ className: "univer-flex univer-flex-col univer-gap-1 univer-text-start univer-text-xs",
28296
+ children: [/* @__PURE__ */ jsxs("label", {
28297
+ className: "univer-grid univer-grid-cols-[1fr_5rem] univer-items-center univer-gap-x-2",
28298
+ children: [/* @__PURE__ */ jsx("span", { children: localeService.t("docs-ui.headerFooter.headerTopMargin") }), /* @__PURE__ */ jsx(InputNumber, {
28299
+ disabled,
28300
+ min: 0,
28301
+ max: 200,
28302
+ precision: 1,
28303
+ value: options.marginHeader,
28304
+ onChange: (value) => handleMarginChange(value ?? 0, "marginHeader")
28305
+ })]
28306
+ }), /* @__PURE__ */ jsxs("label", {
28307
+ className: "univer-grid univer-grid-cols-[1fr_5rem] univer-items-center univer-gap-x-2",
28308
+ children: [/* @__PURE__ */ jsx("span", { children: localeService.t("docs-ui.headerFooter.footerBottomMargin") }), /* @__PURE__ */ jsx(InputNumber, {
28309
+ disabled,
28310
+ min: 0,
28311
+ max: 200,
28312
+ precision: 1,
28313
+ value: options.marginFooter,
28314
+ onChange: (value) => handleMarginChange(value ?? 0, "marginFooter")
28315
+ })]
28316
+ })]
28317
+ });
28318
+ }
28319
+
27469
28320
  //#endregion
27470
28321
  //#region src/views/paragraph-menu/component-keys.ts
27471
28322
  /**
@@ -27523,6 +28374,10 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
27523
28374
  var _this$_paragraphMenu2;
27524
28375
  return ((_this$_paragraphMenu2 = this._paragraphMenu) === null || _this$_paragraphMenu2 === void 0 ? void 0 : _this$_paragraphMenu2.target) ?? null;
27525
28376
  }
28377
+ get focusedTableTarget() {
28378
+ var _this$_focusedTableMe;
28379
+ return ((_this$_focusedTableMe = this._focusedTableMenu) === null || _this$_focusedTableMe === void 0 ? void 0 : _this$_focusedTableMe.target) ?? null;
28380
+ }
27526
28381
  setBlockMenuDragging(isDragging) {
27527
28382
  this._isBlockMenuDragging = isDragging;
27528
28383
  if (isDragging) this._dragInteraction ??= this._docLayoutInteractionService.beginInteraction();
@@ -27550,6 +28405,11 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
27550
28405
  _defineProperty(this, "_paragraphMenu", null);
27551
28406
  _defineProperty(this, "_activeTarget$", new BehaviorSubject(null));
27552
28407
  _defineProperty(this, "activeTarget$", this._activeTarget$.asObservable());
28408
+ _defineProperty(this, "_focusedTableMenu", null);
28409
+ _defineProperty(this, "_focusedTableTarget$", new BehaviorSubject(null));
28410
+ _defineProperty(this, "focusedTableTarget$", this._focusedTableTarget$.asObservable());
28411
+ _defineProperty(this, "_focusedTableMenuDismiss$", new Subject());
28412
+ _defineProperty(this, "focusedTableMenuDismiss$", this._focusedTableMenuDismiss$.asObservable());
27553
28413
  _defineProperty(this, "_slashMenuRequest$", new BehaviorSubject(null));
27554
28414
  _defineProperty(this, "slashMenuRequest$", this._slashMenuRequest$.asObservable());
27555
28415
  _defineProperty(this, "_isBlockMenuDragging", false);
@@ -27565,6 +28425,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
27565
28425
  this._isBlockMenuDragging = false;
27566
28426
  this.hideParagraphMenu(true);
27567
28427
  }
28428
+ if (this._focusedTableMenu && !this._canEditDocument(this._focusedTableMenu.target.menuRange)) this.hideFocusedTableMenu();
27568
28429
  }));
27569
28430
  }
27570
28431
  _isCursorInActiveParagraph() {
@@ -27601,9 +28462,11 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
27601
28462
  _hasExpandedSelection() {
27602
28463
  return this._hasExpandedSelectionRanges(this._docSelectionManagerService.getDocRanges());
27603
28464
  }
27604
- setParagraphMenuActive(active) {
27605
- if (this._paragraphMenu) this._paragraphMenu.active = active;
27606
- if (active && this._paragraphMenu) this._menuInteraction ??= this._docLayoutInteractionService.beginInteraction();
28465
+ setParagraphMenuActive(active, focusedTable = false) {
28466
+ var _this$_paragraphMenu3, _this$_focusedTableMe2;
28467
+ const menu = focusedTable ? this._focusedTableMenu : this._paragraphMenu;
28468
+ if (menu) menu.active = active;
28469
+ 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();
27607
28470
  else {
27608
28471
  var _this$_menuInteractio;
27609
28472
  (_this$_menuInteractio = this._menuInteraction) === null || _this$_menuInteractio === void 0 || _this$_menuInteractio.dispose();
@@ -27612,7 +28475,9 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
27612
28475
  }
27613
28476
  _init() {
27614
28477
  const handleHoverTarget = (paragraph, tableBound) => {
28478
+ var _this$_focusedTableMe3;
27615
28479
  if (this._isBlockMenuDragging) return;
28480
+ if ((_this$_focusedTableMe3 = this._focusedTableMenu) === null || _this$_focusedTableMe3 === void 0 ? void 0 : _this$_focusedTableMe3.active) return;
27616
28481
  if (this._docSelectionRenderService.isOnPointerEvent) {
27617
28482
  this.hideParagraphMenu(true);
27618
28483
  return;
@@ -27623,18 +28488,18 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
27623
28488
  return;
27624
28489
  }
27625
28490
  if (selectionState.hasRectRange) {
27626
- var _this$_paragraphMenu3;
28491
+ var _this$_paragraphMenu4;
27627
28492
  if (tableBound) {
27628
28493
  this.showTableMenu(tableBound);
27629
28494
  return;
27630
28495
  }
27631
- if (((_this$_paragraphMenu3 = this._paragraphMenu) === null || _this$_paragraphMenu3 === void 0 ? void 0 : _this$_paragraphMenu3.target.kind) === DocumentBlockType.TABLE) return;
28496
+ if (((_this$_paragraphMenu4 = this._paragraphMenu) === null || _this$_paragraphMenu4 === void 0 ? void 0 : _this$_paragraphMenu4.target.kind) === DocumentBlockType.TABLE) return;
27632
28497
  this.hideParagraphMenu(true);
27633
28498
  return;
27634
28499
  }
27635
28500
  if (this._docSkeletonManagerService.getViewModel().getEditArea() === DocumentEditArea.BODY && !this._floatMenuService.floatMenu && !this._context.unit.getDisabled() && this._canEditDocument()) {
27636
- var _this$_paragraphMenu4;
27637
- if ((_this$_paragraphMenu4 = this._paragraphMenu) === null || _this$_paragraphMenu4 === void 0 ? void 0 : _this$_paragraphMenu4.active) return;
28501
+ var _this$_paragraphMenu5;
28502
+ if ((_this$_paragraphMenu5 = this._paragraphMenu) === null || _this$_paragraphMenu5 === void 0 ? void 0 : _this$_paragraphMenu5.active) return;
27638
28503
  if (paragraph) {
27639
28504
  this.showParagraphMenu(paragraph);
27640
28505
  return;
@@ -27660,16 +28525,17 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
27660
28525
  this.hideParagraphMenu(true);
27661
28526
  }));
27662
28527
  this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe(({ textRanges, rectRanges }) => {
27663
- var _this$_paragraphMenu5;
28528
+ var _this$_paragraphMenu6;
27664
28529
  const selectionState = this._getExpandedSelectionState([...textRanges, ...rectRanges]);
27665
- if (selectionState.hasExpandedTextRange || selectionState.hasRectRange && ((_this$_paragraphMenu5 = this._paragraphMenu) === null || _this$_paragraphMenu5 === void 0 ? void 0 : _this$_paragraphMenu5.target.kind) !== DocumentBlockType.TABLE) this.hideParagraphMenu(true);
28530
+ if (selectionState.hasExpandedTextRange || selectionState.hasRectRange && ((_this$_paragraphMenu6 = this._paragraphMenu) === null || _this$_paragraphMenu6 === void 0 ? void 0 : _this$_paragraphMenu6.target.kind) !== DocumentBlockType.TABLE) this.hideParagraphMenu(true);
27666
28531
  }));
27667
28532
  let lastScrollY = 0;
27668
28533
  this.disposeWithMe(this._context.scene.getViewport("viewMain").onScrollAfter$.subscribeEvent((e) => {
27669
- var _this$_paragraphMenu6;
28534
+ var _this$_paragraphMenu7;
27670
28535
  if (lastScrollY === e.scrollY) return;
27671
28536
  lastScrollY = e.scrollY;
27672
- if ((_this$_paragraphMenu6 = this._paragraphMenu) === null || _this$_paragraphMenu6 === void 0 ? void 0 : _this$_paragraphMenu6.blockRange) return;
28537
+ this._focusedTableMenuDismiss$.next();
28538
+ if ((_this$_paragraphMenu7 = this._paragraphMenu) === null || _this$_paragraphMenu7 === void 0 ? void 0 : _this$_paragraphMenu7.blockRange) return;
27673
28539
  if (this._isBlockMenuDragging) return;
27674
28540
  this.hideParagraphMenu(true);
27675
28541
  }));
@@ -27680,6 +28546,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
27680
28546
  this.disposeWithMe(this._docSelectionRenderService.onKeydown$.subscribe((config) => {
27681
28547
  if (this._isBlockMenuDragging) return;
27682
28548
  if (this._handleSlashMenuKeydown(config)) return;
28549
+ this._focusedTableMenuDismiss$.next();
27683
28550
  this.hideParagraphMenu(true);
27684
28551
  }));
27685
28552
  this.disposeWithMe(this._docSelectionRenderService.onInputBefore$.subscribe((config) => {
@@ -27735,10 +28602,10 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
27735
28602
  return null;
27736
28603
  }
27737
28604
  _getSlashMenuParagraph(config) {
27738
- var _this$_paragraphMenu7;
28605
+ var _this$_paragraphMenu8;
27739
28606
  const activeRange = this._getCollapsedTextRange(config);
27740
28607
  const offset = activeRange === null || activeRange === void 0 ? void 0 : activeRange.startOffset;
27741
- const activeParagraph = ((_this$_paragraphMenu7 = this._paragraphMenu) === null || _this$_paragraphMenu7 === void 0 ? void 0 : _this$_paragraphMenu7.paragraph) ?? null;
28608
+ const activeParagraph = ((_this$_paragraphMenu8 = this._paragraphMenu) === null || _this$_paragraphMenu8 === void 0 ? void 0 : _this$_paragraphMenu8.paragraph) ?? null;
27742
28609
  if (activeParagraph && offset != null && offset >= activeParagraph.paragraphStart && offset <= activeParagraph.paragraphEnd) return activeParagraph;
27743
28610
  if (activeParagraph && offset == null) return activeParagraph;
27744
28611
  if (offset == null) return null;
@@ -27759,7 +28626,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
27759
28626
  }
27760
28627
  }
27761
28628
  showParagraphMenu(paragraph) {
27762
- var _this$_paragraphMenu8;
28629
+ var _this$_paragraphMenu9;
27763
28630
  if (this._hasExpandedSelection()) {
27764
28631
  this.hideParagraphMenu(true);
27765
28632
  return;
@@ -27769,7 +28636,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
27769
28636
  this.hideParagraphMenu(true);
27770
28637
  return;
27771
28638
  }
27772
- if (((_this$_paragraphMenu8 = this._paragraphMenu) === null || _this$_paragraphMenu8 === void 0 ? void 0 : _this$_paragraphMenu8.target.key) === target.key) return;
28639
+ if (((_this$_paragraphMenu9 = this._paragraphMenu) === null || _this$_paragraphMenu9 === void 0 ? void 0 : _this$_paragraphMenu9.target.key) === target.key) return;
27773
28640
  this.hideParagraphMenu(true);
27774
28641
  const targetParagraph = target.paragraph ?? paragraph;
27775
28642
  const blockRange = target.blockRange;
@@ -27804,15 +28671,19 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
27804
28671
  };
27805
28672
  this._activeTarget$.next(target);
27806
28673
  }
27807
- showTableMenu(tableBound) {
27808
- var _body$tables, _this$_paragraphMenu9;
27809
- if (this._hasExpandedTextSelection()) {
28674
+ showTableMenu(tableBound, focused = false) {
28675
+ var _this$_focusedTableMe4, _body$tables, _this$_paragraphMenu10;
28676
+ 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
+ if (!focused && this._hasExpandedTextSelection()) {
27810
28678
  this.hideParagraphMenu(true);
27811
28679
  return;
27812
28680
  }
27813
28681
  const body = this._context.unit.getBody();
27814
28682
  const table = body === null || body === void 0 || (_body$tables = body.tables) === null || _body$tables === void 0 ? void 0 : _body$tables.find((item) => item.tableId === tableBound.tableId);
27815
- if (!table) return;
28683
+ if (!table) {
28684
+ if (focused) this.hideFocusedTableMenu();
28685
+ return;
28686
+ }
27816
28687
  const target = {
27817
28688
  kind: DocumentBlockType.TABLE,
27818
28689
  key: `${DocumentBlockType.TABLE}:${table.tableId}`,
@@ -27825,17 +28696,21 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
27825
28696
  },
27826
28697
  moveRange: {
27827
28698
  startOffset: table.startIndex,
27828
- endOffset: table.endIndex
28699
+ endOffset: table.endIndex + ((body === null || body === void 0 ? void 0 : body.dataStream[table.endIndex]) === "\r" ? 1 : 0)
27829
28700
  },
27830
28701
  emptyMode: false,
27831
28702
  draggable: true
27832
28703
  };
27833
28704
  if (!this._canEditDocument(target.menuRange)) {
28705
+ if (focused) {
28706
+ this.hideFocusedTableMenu();
28707
+ return;
28708
+ }
27834
28709
  this.hideParagraphMenu(true);
27835
28710
  return;
27836
28711
  }
27837
- if (this._shouldKeepCurrentCellMenuForTable(table)) return;
27838
- if (((_this$_paragraphMenu9 = this._paragraphMenu) === null || _this$_paragraphMenu9 === void 0 ? void 0 : _this$_paragraphMenu9.target.key) === target.key) return;
28712
+ 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;
27839
28714
  const anchorRect = getTableAnchorRect(tableBound);
27840
28715
  const paragraph = {
27841
28716
  rect: tableBound.rect,
@@ -27846,8 +28721,16 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
27846
28721
  pageIndex: tableBound.pageIndex,
27847
28722
  firstLine: anchorRect
27848
28723
  };
28724
+ if (focused) {
28725
+ target.paragraph = paragraph;
28726
+ this._showFocusedTableMenu(tableBound, target);
28727
+ return;
28728
+ }
28729
+ this._showHoverTableMenu(tableBound, target, paragraph);
28730
+ }
28731
+ _showHoverTableMenu(tableBound, target, paragraph) {
27849
28732
  this.hideParagraphMenu(true);
27850
- const getFirstLine = () => getTableAnchorRect(this._docEventManagerService.tableBounds.get(table.tableId) ?? tableBound);
28733
+ const getFirstLine = () => getTableAnchorRect(this._docEventManagerService.tableBounds.get(tableBound.tableId) ?? tableBound);
27851
28734
  const disposable = this._docPopupManagerService.attachPopupToRect(getFirstLine, {
27852
28735
  componentKey: DOC_TABLE_BLOCK_MENU_COMPONENT_KEY,
27853
28736
  constrainToCanvas: true,
@@ -27866,9 +28749,40 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
27866
28749
  };
27867
28750
  this._activeTarget$.next(target);
27868
28751
  }
28752
+ _showFocusedTableMenu(tableBound, target) {
28753
+ var _this$_focusedTableMe5, _this$_paragraphMenu11;
28754
+ if (((_this$_focusedTableMe5 = this._focusedTableMenu) === null || _this$_focusedTableMe5 === void 0 ? void 0 : _this$_focusedTableMe5.target.key) === target.key) {
28755
+ this._focusedTableMenu.target = target;
28756
+ this._focusedTableMenu.bound = tableBound;
28757
+ this._focusedTableTarget$.next(target);
28758
+ return;
28759
+ }
28760
+ this.hideFocusedTableMenu();
28761
+ if (((_this$_paragraphMenu11 = this._paragraphMenu) === null || _this$_paragraphMenu11 === void 0 ? void 0 : _this$_paragraphMenu11.target.key) === target.key) this.hideParagraphMenu(true);
28762
+ const getFocusedAnchor = () => {
28763
+ var _this$_focusedTableMe6;
28764
+ return getTableAnchorRect(this._docEventManagerService.tableBounds.get(tableBound.tableId) ?? ((_this$_focusedTableMe6 = this._focusedTableMenu) === null || _this$_focusedTableMe6 === void 0 ? void 0 : _this$_focusedTableMe6.bound) ?? tableBound);
28765
+ };
28766
+ const disposable = this._docPopupManagerService.attachPopupToRect(getFocusedAnchor, {
28767
+ componentKey: DOC_TABLE_BLOCK_MENU_COMPONENT_KEY,
28768
+ extraProps: { focusedTableMenu: true },
28769
+ constrainToCanvas: true,
28770
+ requiresStableLayout: false,
28771
+ direction: "top-right",
28772
+ onClickOutside: () => this._focusedTableMenuDismiss$.next(),
28773
+ zIndex: 102
28774
+ }, this._context.unitId);
28775
+ this._focusedTableMenu = {
28776
+ target,
28777
+ bound: tableBound,
28778
+ disposable,
28779
+ active: false
28780
+ };
28781
+ this._focusedTableTarget$.next(target);
28782
+ }
27869
28783
  _shouldKeepCurrentCellMenuForTable(table) {
27870
- var _this$_paragraphMenu10;
27871
- const target = (_this$_paragraphMenu10 = this._paragraphMenu) === null || _this$_paragraphMenu10 === void 0 ? void 0 : _this$_paragraphMenu10.target;
28784
+ var _this$_paragraphMenu12;
28785
+ const target = (_this$_paragraphMenu12 = this._paragraphMenu) === null || _this$_paragraphMenu12 === void 0 ? void 0 : _this$_paragraphMenu12.target;
27872
28786
  if (!target || target.kind === DocumentBlockType.TABLE || !target.cellRange) return false;
27873
28787
  return target.cellRange.startOffset >= table.startIndex && target.cellRange.startOffset <= table.endIndex;
27874
28788
  }
@@ -27911,22 +28825,32 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
27911
28825
  hideParagraphMenu(force = false) {
27912
28826
  if (this._isBlockMenuDragging) return;
27913
28827
  if (this._paragraphMenu && (this._paragraphMenu.disposable.canDispose() || force)) {
27914
- var _this$_menuInteractio2;
27915
28828
  this._paragraphMenu.disposable.dispose();
27916
28829
  this._paragraphMenu = null;
27917
- (_this$_menuInteractio2 = this._menuInteraction) === null || _this$_menuInteractio2 === void 0 || _this$_menuInteractio2.dispose();
27918
- this._menuInteraction = null;
28830
+ this.setParagraphMenuActive(false);
27919
28831
  this._isSlashMenuActive = false;
27920
28832
  this._slashMenuRequest$.next(null);
27921
28833
  this._activeTarget$.next(null);
27922
28834
  }
27923
28835
  }
28836
+ hideFocusedTableMenu() {
28837
+ var _this$_focusedTableMe7;
28838
+ (_this$_focusedTableMe7 = this._focusedTableMenu) === null || _this$_focusedTableMe7 === void 0 || _this$_focusedTableMe7.disposable.dispose();
28839
+ this._focusedTableMenu = null;
28840
+ this._focusedTableTarget$.next(null);
28841
+ this.setParagraphMenuActive(false, true);
28842
+ }
27924
28843
  _canEditDocument(range, segmentId = "") {
27925
28844
  return canEditDocumentTargets(this._permissionService, this._context.unitId, range ? getDocumentEditTargetObjectIds(this._context.unit, segmentId, range) : []);
27926
28845
  }
27927
28846
  dispose() {
27928
- var _this$_menuInteractio3, _this$_dragInteractio2;
27929
- (_this$_menuInteractio3 = this._menuInteraction) === null || _this$_menuInteractio3 === void 0 || _this$_menuInteractio3.dispose();
28847
+ var _this$_menuInteractio2, _this$_dragInteractio2;
28848
+ this._isBlockMenuDragging = false;
28849
+ this.hideFocusedTableMenu();
28850
+ this.hideParagraphMenu(true);
28851
+ this._focusedTableTarget$.complete();
28852
+ this._focusedTableMenuDismiss$.complete();
28853
+ (_this$_menuInteractio2 = this._menuInteraction) === null || _this$_menuInteractio2 === void 0 || _this$_menuInteractio2.dispose();
27930
28854
  this._menuInteraction = null;
27931
28855
  (_this$_dragInteractio2 = this._dragInteraction) === null || _this$_dragInteractio2 === void 0 || _this$_dragInteractio2.dispose();
27932
28856
  this._dragInteraction = null;
@@ -28258,9 +29182,6 @@ function createParagraphMenuHoverOpenScheduler(openMenu, delay = 800) {
28258
29182
  }
28259
29183
  };
28260
29184
  }
28261
- function setParagraphMenuInteractionActive(docParagraphMenuService, active) {
28262
- docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(active);
28263
- }
28264
29185
  function isEmptyParagraphMenuTarget(dataStream, paragraph) {
28265
29186
  if (!paragraph) return false;
28266
29187
  return dataStream.slice(paragraph.paragraphStart, paragraph.paragraphEnd).replace(/[\r\n]/g, "") === "";
@@ -28670,7 +29591,7 @@ function getBlockRangeClipboardTargetRange(commandId, target, paragraph) {
28670
29591
  return null;
28671
29592
  }
28672
29593
  function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
28673
- var _doc$getBody, _paragraphObj$paragra;
29594
+ var _popup$extraProps, _doc$getBody, _paragraphObj$paragra;
28674
29595
  const [visible, setVisible] = useState(false);
28675
29596
  const [openMode, setOpenMode] = useState("pointer");
28676
29597
  const [anchorRect, setAnchorRect] = useState(null);
@@ -28679,10 +29600,12 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
28679
29600
  const targetRangeRef = useRef(null);
28680
29601
  const dragTargetOffsetRef = useRef(null);
28681
29602
  const dragRangeRef = useRef(null);
29603
+ const dragCleanupRef = useRef(null);
28682
29604
  const isDraggingRef = useRef(false);
28683
29605
  const openMenuRef = useRef(() => void 0);
28684
29606
  const hoverOpenSchedulerRef = useRef(createParagraphMenuHoverOpenScheduler(() => openMenuRef.current()));
28685
29607
  const commandService = useDependency(ICommandService);
29608
+ const logService = useDependency(ILogService);
28686
29609
  const localeService = useDependency(LocaleService);
28687
29610
  const themeService = useDependency(ThemeService);
28688
29611
  const docSelectionManagerService = useDependency(DocSelectionManagerService);
@@ -28703,12 +29626,20 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
28703
29626
  const doc = univerInstanceService.getUnit(popup.unitId, UniverInstanceType.UNIVER_DOC);
28704
29627
  const docParagraphMenuService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocParagraphMenuService);
28705
29628
  const docEventManagerService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocEventManagerService);
28706
- const activeTarget = useObservable(docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget$);
29629
+ const isFocusedTableMenu = ((_popup$extraProps = popup.extraProps) === null || _popup$extraProps === void 0 ? void 0 : _popup$extraProps.focusedTableMenu) === true;
29630
+ const activeTarget = useObservable(isFocusedTableMenu ? docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.focusedTableTarget$ : docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget$);
28707
29631
  const slashMenuRequest = useObservable(docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.slashMenuRequest$);
28708
29632
  const paragraph = useObservable(docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.hoverParagraph$);
28709
29633
  const paragraphLeft = useObservable(docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.hoverParagraphLeft$);
28710
- const rawActiveTarget = activeTarget ?? (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget);
28711
- const currentActiveTarget = tableBlockOnly ? (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table" ? rawActiveTarget : null : (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table" ? null : rawActiveTarget;
29634
+ const getActiveTarget = () => {
29635
+ if (isFocusedTableMenu) return (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.focusedTableTarget) ?? activeTarget;
29636
+ return (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
29637
+ };
29638
+ const setMenuInteractionActive = (active) => {
29639
+ docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(active, isFocusedTableMenu);
29640
+ };
29641
+ const rawActiveTarget = getActiveTarget();
29642
+ const currentActiveTarget = (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table" === tableBlockOnly ? rawActiveTarget : null;
28712
29643
  const activeParagraphBound = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.paragraph) ?? (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeParagraph) ?? paragraph ?? paragraphLeft;
28713
29644
  const startIndex = activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.startIndex;
28714
29645
  const dataStream = (doc === null || doc === void 0 || (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.dataStream) ?? "";
@@ -28761,13 +29692,41 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
28761
29692
  if (activeElement === focusedElement || !focusedElement.isConnected && activeElement === body) layoutService.focus();
28762
29693
  }, [layoutService]);
28763
29694
  useLayoutEffect(() => restoreMenuFocus, [restoreMenuFocus]);
28764
- const handleHideMenu = () => {
29695
+ const handleHideMenu = useCallback(() => {
29696
+ hoverOpenSchedulerRef.current.cancel();
28765
29697
  restoreMenuFocus();
28766
29698
  setVisible(false);
28767
29699
  setOpenMode("pointer");
28768
29700
  targetRangeRef.current = null;
28769
- setParagraphMenuInteractionActive(docParagraphMenuService, false);
28770
- };
29701
+ docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(false, isFocusedTableMenu);
29702
+ }, [
29703
+ docParagraphMenuService,
29704
+ isFocusedTableMenu,
29705
+ restoreMenuFocus
29706
+ ]);
29707
+ useEffect(() => {
29708
+ if (!isFocusedTableMenu || !docParagraphMenuService) return;
29709
+ const subscription = docParagraphMenuService.focusedTableMenuDismiss$.subscribe(handleHideMenu);
29710
+ const ownerDocument = popup.canvasElement.ownerDocument;
29711
+ const handleKeydown = (event) => {
29712
+ if (event.key === "Escape") {
29713
+ event.preventDefault();
29714
+ event.stopPropagation();
29715
+ handleHideMenu();
29716
+ }
29717
+ };
29718
+ if (visible) ownerDocument.addEventListener("keydown", handleKeydown, true);
29719
+ return () => {
29720
+ subscription.unsubscribe();
29721
+ ownerDocument.removeEventListener("keydown", handleKeydown, true);
29722
+ };
29723
+ }, [
29724
+ docParagraphMenuService,
29725
+ isFocusedTableMenu,
29726
+ handleHideMenu,
29727
+ popup.canvasElement,
29728
+ visible
29729
+ ]);
28771
29730
  const clearHideTimer = () => {
28772
29731
  if (hideTimerRef.current != null) {
28773
29732
  window.clearTimeout(hideTimerRef.current);
@@ -28785,8 +29744,8 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
28785
29744
  const handleOpenMenu = (mode = "pointer") => {
28786
29745
  clearHideTimer();
28787
29746
  if (openMode === "slash") return;
28788
- const latestTarget = (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
28789
- setParagraphMenuInteractionActive(docParagraphMenuService, true);
29747
+ const latestTarget = getActiveTarget();
29748
+ setMenuInteractionActive(true);
28790
29749
  const targetRange = latestTarget ? {
28791
29750
  ...latestTarget.menuRange,
28792
29751
  segmentId: activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.segmentId
@@ -28834,7 +29793,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
28834
29793
  return commandService.executeCommand(resolved.commandId, resolved.params);
28835
29794
  };
28836
29795
  const unwrapActiveBlockRange = async () => {
28837
- const latestTarget = (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
29796
+ const latestTarget = getActiveTarget();
28838
29797
  if (!latestTarget || latestTarget.kind !== "blockRange" || !latestTarget.blockRange || !(doc === null || doc === void 0 ? void 0 : doc.getBody())) return null;
28839
29798
  const previousBody = doc.getBody();
28840
29799
  const { body, range } = unwrapBlockRangeBody(previousBody, latestTarget.blockRange);
@@ -28857,7 +29816,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
28857
29816
  return nextRange;
28858
29817
  };
28859
29818
  const executeParagraphMenuOption = async (option) => {
28860
- const latestTarget = (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
29819
+ const latestTarget = getActiveTarget();
28861
29820
  const targetRange = getTargetSelectionRange(latestTarget, activeParagraphBound ?? void 0);
28862
29821
  const blockRange = getBlockSelectionRange(latestTarget, activeParagraphBound ?? void 0);
28863
29822
  const formattingRange = getParagraphFormattingRange(latestTarget, activeParagraphBound ?? void 0);
@@ -28961,31 +29920,35 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
28961
29920
  const hoverBridgeStyle = visible && (menuDirection === "left" || menuDirection === "right") ? getParagraphMenuHoverBridgeStyle(anchorRect, menuDirection) : void 0;
28962
29921
  const resolvedParagraphMenuType = openMode === "slash" ? DOC_PARAGRAPH_T_INSERT_MENU_ID : paragraphMenuType;
28963
29922
  useEffect(() => () => {
29923
+ var _dragCleanupRef$curre;
29924
+ (_dragCleanupRef$curre = dragCleanupRef.current) === null || _dragCleanupRef$curre === void 0 || _dragCleanupRef$curre.call(dragCleanupRef);
28964
29925
  if (hideTimerRef.current != null) {
28965
29926
  window.clearTimeout(hideTimerRef.current);
28966
29927
  hideTimerRef.current = null;
28967
29928
  }
28968
29929
  hoverOpenSchedulerRef.current.cancel();
28969
- setParagraphMenuInteractionActive(docParagraphMenuService, false);
28970
- }, []);
29930
+ docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(false, isFocusedTableMenu);
29931
+ }, [docParagraphMenuService, isFocusedTableMenu]);
28971
29932
  useEffect(() => {
28972
- if (!slashMenuRequest || handledSlashRequestNonceRef.current >= slashMenuRequest.nonce) return;
29933
+ if (tableBlockOnly || !slashMenuRequest || handledSlashRequestNonceRef.current >= slashMenuRequest.nonce) return;
28973
29934
  handledSlashRequestNonceRef.current = slashMenuRequest.nonce;
28974
29935
  hoverOpenSchedulerRef.current.cancel();
28975
29936
  clearHideTimer();
28976
29937
  isMouseOver.current = false;
28977
29938
  handleOpenSlashMenu(slashMenuRequest);
28978
- }, [slashMenuRequest]);
29939
+ }, [slashMenuRequest, tableBlockOnly]);
28979
29940
  if (!currentActiveTarget) return null;
28980
29941
  return /* @__PURE__ */ jsxs(Fragment, { children: [
28981
29942
  /* @__PURE__ */ jsxs("div", {
28982
29943
  "data-u-comp": "paragraph-menu",
29944
+ "data-u-table-menu": tableBlockOnly ? "true" : void 0,
29945
+ "data-u-focused-table-menu": isFocusedTableMenu ? "true" : void 0,
28983
29946
  ref: anchorRef,
28984
- 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-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-700 dark:!univer-bg-gray-900 dark:hover:!univer-bg-gray-800", { "univer-bg-gray-100 univer-shadow-md dark:!univer-bg-gray-800": visible }),
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 }),
28985
29948
  onMouseEnter: (e) => {
28986
29949
  var _popup$onPointerEnter;
28987
29950
  (_popup$onPointerEnter = popup.onPointerEnter) === null || _popup$onPointerEnter === void 0 || _popup$onPointerEnter.call(popup, e);
28988
- setParagraphMenuInteractionActive(docParagraphMenuService, true);
29951
+ setMenuInteractionActive(true);
28989
29952
  isMouseOver.current = true;
28990
29953
  scheduleOpenMenu();
28991
29954
  },
@@ -29007,7 +29970,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29007
29970
  title: localeService.t("docs-ui.doc.blockMenu.dragBlock"),
29008
29971
  onPointerDown: (event) => {
29009
29972
  var _event$currentTarget$, _event$currentTarget;
29010
- const latestTarget = (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
29973
+ const latestTarget = getActiveTarget();
29011
29974
  const moveRange = latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.moveRange;
29012
29975
  if (!moveRange || !(latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.draggable)) return;
29013
29976
  event.preventDefault();
@@ -29035,6 +29998,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29035
29998
  window.removeEventListener("pointerup", handlePointerUp);
29036
29999
  window.removeEventListener("pointercancel", handlePointerCancel);
29037
30000
  window.removeEventListener("blur", handleWindowBlur);
30001
+ dragCleanupRef.current = null;
29038
30002
  const range = dragRangeRef.current;
29039
30003
  const targetOffset = dragTargetOffsetRef.current;
29040
30004
  dragRangeRef.current = null;
@@ -29050,7 +30014,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29050
30014
  unitId: popup.unitId,
29051
30015
  sourceRange: range,
29052
30016
  targetOffset
29053
- });
30017
+ }).catch((error) => logService.error(error));
29054
30018
  };
29055
30019
  const handlePointerUp = (upEvent) => {
29056
30020
  if (upEvent.pointerId !== pointerId) return;
@@ -29064,6 +30028,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29064
30028
  const handleWindowBlur = () => {
29065
30029
  finishDrag(false);
29066
30030
  };
30031
+ dragCleanupRef.current = () => finishDrag(false);
29067
30032
  window.addEventListener("pointermove", handlePointerMove);
29068
30033
  window.addEventListener("pointerup", handlePointerUp);
29069
30034
  window.addEventListener("pointercancel", handlePointerCancel);
@@ -29079,7 +30044,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29079
30044
  onMouseEnter: (e) => {
29080
30045
  var _popup$onPointerEnter2;
29081
30046
  (_popup$onPointerEnter2 = popup.onPointerEnter) === null || _popup$onPointerEnter2 === void 0 || _popup$onPointerEnter2.call(popup, e);
29082
- setParagraphMenuInteractionActive(docParagraphMenuService, true);
30047
+ setMenuInteractionActive(true);
29083
30048
  isMouseOver.current = true;
29084
30049
  clearHideTimer();
29085
30050
  },
@@ -29102,7 +30067,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29102
30067
  onMouseEnter: (e) => {
29103
30068
  var _popup$onPointerEnter3;
29104
30069
  (_popup$onPointerEnter3 = popup.onPointerEnter) === null || _popup$onPointerEnter3 === void 0 || _popup$onPointerEnter3.call(popup, e);
29105
- setParagraphMenuInteractionActive(docParagraphMenuService, true);
30070
+ setMenuInteractionActive(true);
29106
30071
  isMouseOver.current = true;
29107
30072
  clearHideTimer();
29108
30073
  },
@@ -29120,7 +30085,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29120
30085
  autoFocusTarget: openMode === "slash" ? "container" : void 0,
29121
30086
  suppressHoverUntilPointerMove: openMode === "slash",
29122
30087
  onMenuPointerEnter: () => {
29123
- setParagraphMenuInteractionActive(docParagraphMenuService, true);
30088
+ setMenuInteractionActive(true);
29124
30089
  isMouseOver.current = true;
29125
30090
  clearHideTimer();
29126
30091
  },
@@ -29134,7 +30099,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29134
30099
  onOptionSelect: async (params) => {
29135
30100
  const targetRange = targetRangeRef.current ?? getParagraphMenuTargetRange(activeParagraphBound);
29136
30101
  const { commandId, params: commandParams } = getParagraphMenuCommand(params, targetRange);
29137
- const latestTarget = (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
30102
+ const latestTarget = getActiveTarget();
29138
30103
  if ((latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.kind) === "table" && commandId && targetRange) {
29139
30104
  univerInstanceService.focusUnit(popup.unitId);
29140
30105
  const tableRange = {
@@ -29261,6 +30226,7 @@ let ComponentsController = class ComponentsController extends Disposable {
29261
30226
  BoldIcon,
29262
30227
  CopyDoubleIcon,
29263
30228
  ColumnIcon,
30229
+ CloseIcon,
29264
30230
  CutIcon,
29265
30231
  DeleteColumnDoubleIcon,
29266
30232
  DeleteIcon,
@@ -29276,6 +30242,7 @@ let ComponentsController = class ComponentsController extends Disposable {
29276
30242
  H5Icon,
29277
30243
  HeaderFooterIcon,
29278
30244
  HorizontallyIcon,
30245
+ InsertBelowDoubleIcon,
29279
30246
  InsertDoubleIcon,
29280
30247
  InsertRowAboveDoubleIcon,
29281
30248
  InsertRowBelowDoubleIcon,
@@ -29309,6 +30276,7 @@ let ComponentsController = class ComponentsController extends Disposable {
29309
30276
  TodoListDoubleIcon,
29310
30277
  UnderlineIcon,
29311
30278
  UnorderIcon,
30279
+ ZoomInIcon,
29312
30280
  DefaultTextColorIcon,
29313
30281
  HeaderTextColorIcon,
29314
30282
  MoreRightIcon,
@@ -29339,7 +30307,8 @@ let ComponentsController = class ComponentsController extends Disposable {
29339
30307
  }));
29340
30308
  }
29341
30309
  _registerComponents() {
29342
- if (!this._componentManager.get("COMPONENT_DOC_HEADER_FOOTER_PANEL")) this.disposeWithMe(this._componentManager.register(COMPONENT_DOC_HEADER_FOOTER_PANEL, DocHeaderFooterPanel));
30310
+ this.disposeWithMe(this._componentManager.register(DOC_HEADER_FOOTER_RIBBON_CONTROL, DocHeaderFooterRibbonControl));
30311
+ if (!this._componentManager.hasDefault("COMPONENT_DOC_HEADER_FOOTER_PANEL")) this.disposeWithMe(this._componentManager.register(COMPONENT_DOC_HEADER_FOOTER_PANEL, DocHeaderFooterPanel));
29343
30312
  this.disposeWithMe(this._componentManager.register(paragraphSettingIndexKey, ParagraphSettingIndex));
29344
30313
  this.disposeWithMe(this._componentManager.register(DOC_SECTION_SETTING_COMPONENT, SectionSettingIndex));
29345
30314
  [
@@ -29357,6 +30326,43 @@ let ComponentsController = class ComponentsController extends Disposable {
29357
30326
  };
29358
30327
  ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
29359
30328
 
30329
+ //#endregion
30330
+ //#region src/controllers/doc-header-footer-ribbon.controller.ts
30331
+ let DocHeaderFooterRibbonController = class DocHeaderFooterRibbonController extends Disposable {
30332
+ constructor(_context, skeletonManager, _instanceService, _ribbonService, _renderManager) {
30333
+ super();
30334
+ this._context = _context;
30335
+ this._instanceService = _instanceService;
30336
+ this._ribbonService = _ribbonService;
30337
+ this._renderManager = _renderManager;
30338
+ _defineProperty(this, "_visible", false);
30339
+ this.disposeWithMe(combineLatest([skeletonManager.getViewModel().editAreaChange$, this._instanceService.focused$]).pipe(map(([area, focused]) => focused === this._context.unitId && this._context.unit.getDocumentStyle().documentFlavor === DocumentFlavor.TRADITIONAL && (area === DocumentEditArea.HEADER || area === DocumentEditArea.FOOTER)), distinctUntilChanged()).subscribe((visible) => {
30340
+ if (visible === this._visible) return;
30341
+ this._visible = visible;
30342
+ if (visible) this._ribbonService.showContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB, { activate: true });
30343
+ else if (!this._focusedDocumentEditsHeaderFooter()) this._ribbonService.hideContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB);
30344
+ }));
30345
+ }
30346
+ _focusedDocumentEditsHeaderFooter() {
30347
+ var _this$_renderManager$;
30348
+ const focused = this._instanceService.getFocusedUnit();
30349
+ if (!focused || focused.type !== UniverInstanceType.UNIVER_DOC || focused.getUnitId() === this._context.unitId) return false;
30350
+ const manager = (_this$_renderManager$ = this._renderManager.getRenderUnitById(focused.getUnitId())) === null || _this$_renderManager$ === void 0 ? void 0 : _this$_renderManager$.with(DocSkeletonManagerService);
30351
+ const area = manager === null || manager === void 0 ? void 0 : manager.getViewModel().getEditArea();
30352
+ return (area === DocumentEditArea.HEADER || area === DocumentEditArea.FOOTER) && (manager === null || manager === void 0 ? void 0 : manager.getViewModel().getDataModel().getDocumentStyle().documentFlavor) === DocumentFlavor.TRADITIONAL;
30353
+ }
30354
+ dispose() {
30355
+ if (this._visible && !this._focusedDocumentEditsHeaderFooter()) this._ribbonService.hideContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB);
30356
+ super.dispose();
30357
+ }
30358
+ };
30359
+ DocHeaderFooterRibbonController = __decorate([
30360
+ __decorateParam(1, Inject(DocSkeletonManagerService)),
30361
+ __decorateParam(2, IUniverInstanceService),
30362
+ __decorateParam(3, IRibbonService),
30363
+ __decorateParam(4, IRenderManagerService)
30364
+ ], DocHeaderFooterRibbonController);
30365
+
29360
30366
  //#endregion
29361
30367
  //#region src/controllers/format-painter.controller.ts
29362
30368
  let DocFormatPainterController = class DocFormatPainterController extends Disposable {
@@ -29424,6 +30430,83 @@ DocFormatPainterController = __decorate([
29424
30430
  __decorateParam(7, ICommandService)
29425
30431
  ], DocFormatPainterController);
29426
30432
 
30433
+ //#endregion
30434
+ //#region src/controllers/render-controllers/doc-field.render-controller.ts
30435
+ let DocFieldRenderController = class DocFieldRenderController extends Disposable {
30436
+ constructor(_context, _events, _selections, theme, _instances) {
30437
+ super();
30438
+ this._context = _context;
30439
+ this._events = _events;
30440
+ this._selections = _selections;
30441
+ this._instances = _instances;
30442
+ _defineProperty(this, "_hovered", /* @__PURE__ */ new Set());
30443
+ _defineProperty(this, "_shade", "");
30444
+ const documents = this._context.mainComponent;
30445
+ this.disposeWithMe(theme.currentTheme$.subscribe(() => {
30446
+ this._shade = theme.getColorFromTheme("gray.200");
30447
+ documents.makeDirty(true);
30448
+ }));
30449
+ this.disposeWithMe(this._events.hoverCustomRanges$.subscribe((ranges) => {
30450
+ this._hovered = new Set(ranges.filter(({ range }) => range.rangeType === CustomRangeType.FIELD).map(({ range, segmentId, segmentPageIndex }) => `${segmentId ?? ""}:${segmentPageIndex}:${range.rangeId}`));
30451
+ documents.makeDirty(true);
30452
+ }));
30453
+ this.disposeWithMe(this._selections.textSelection$.subscribe(({ unitId }) => {
30454
+ if (unitId === this._context.unitId) documents.makeDirty(true);
30455
+ }));
30456
+ this.disposeWithMe(this._instances.focused$.subscribe(() => documents.makeDirty(true)));
30457
+ this.disposeWithMe(documents.getSkeleton().getViewModel().editAreaChange$.subscribe(() => documents.makeDirty(true)));
30458
+ this.disposeWithMe(documents.pageRender$.subscribe((config) => this._drawFields(config)));
30459
+ }
30460
+ _drawFields({ page, pageLeft, pageTop, ctx }) {
30461
+ var _this$_instances$getF;
30462
+ if (((_this$_instances$getF = this._instances.getFocusedUnit()) === null || _this$_instances$getF === void 0 ? void 0 : _this$_instances$getF.getUnitId()) !== this._context.unitId) return;
30463
+ const active = this._getActiveFields();
30464
+ if (!active.size) return;
30465
+ const documents = this._context.mainComponent;
30466
+ const skeleton = documents.getSkeleton();
30467
+ const pageIndex = skeleton.getSkeletonData().pages.indexOf(page);
30468
+ const { docsLeft, docsTop } = documents.getOffsetConfig();
30469
+ const area = skeleton.getViewModel().getEditArea();
30470
+ const snapshot = this._context.unit.getSnapshot();
30471
+ const activeSegments = area === DocumentEditArea.HEADER ? snapshot.headers : snapshot.footers;
30472
+ ctx.save();
30473
+ ctx.beginPath();
30474
+ ctx.rect(pageLeft, pageTop, page.pageWidth, page.pageHeight);
30475
+ ctx.clip();
30476
+ ctx.fillStyle = this._shade;
30477
+ ctx.globalAlpha *= .45;
30478
+ for (const { customRange: field, segmentId, segmentPageIndex, rects } of this._events.getCustomRangeBounds()) {
30479
+ if (field.rangeType !== CustomRangeType.FIELD) continue;
30480
+ if (segmentId) {
30481
+ if (area === DocumentEditArea.BODY || segmentPageIndex !== pageIndex || !(activeSegments === null || activeSegments === void 0 ? void 0 : activeSegments[segmentId])) continue;
30482
+ } else if (area !== DocumentEditArea.BODY) continue;
30483
+ if (!active.has(`${segmentId ?? ""}:${segmentPageIndex}:${field.rangeId}`)) continue;
30484
+ for (const rect of rects) ctx.fillRect(rect.left - docsLeft, rect.top - docsTop, rect.right - rect.left, rect.bottom - rect.top);
30485
+ }
30486
+ ctx.restore();
30487
+ }
30488
+ _getActiveFields() {
30489
+ const active = new Set(this._hovered);
30490
+ const selections = this._selections.getTextRanges({
30491
+ unitId: this._context.unitId,
30492
+ subUnitId: this._context.unitId
30493
+ }) ?? [];
30494
+ for (const selection of selections) {
30495
+ var _this$_context$unit$g;
30496
+ const segmentId = selection.segmentId ?? "";
30497
+ const fields = ((_this$_context$unit$g = this._context.unit.getSelfOrHeaderFooterModel(segmentId)) === null || _this$_context$unit$g === void 0 || (_this$_context$unit$g = _this$_context$unit$g.getBody()) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.customRanges) ?? [];
30498
+ for (const field of fields) if (field.rangeType === CustomRangeType.FIELD && selection.startOffset <= field.endIndex && selection.endOffset > field.startIndex) active.add(`${segmentId}:${segmentId ? selection.segmentPage : -1}:${field.rangeId}`);
30499
+ }
30500
+ return active;
30501
+ }
30502
+ };
30503
+ DocFieldRenderController = __decorate([
30504
+ __decorateParam(1, Inject(DocEventManagerService)),
30505
+ __decorateParam(2, Inject(DocSelectionManagerService)),
30506
+ __decorateParam(3, Inject(ThemeService)),
30507
+ __decorateParam(4, IUniverInstanceService)
30508
+ ], DocFieldRenderController);
30509
+
29427
30510
  //#endregion
29428
30511
  //#region src/controllers/render-controllers/doc-selection-render.controller.ts
29429
30512
  let DocSelectionRenderController = class DocSelectionRenderController extends Disposable {
@@ -29748,6 +30831,32 @@ const CloseHeaderFooterShortcut = {
29748
30831
  preconditions: whenDocAndEditorFocused,
29749
30832
  binding: KeyCode.ESC
29750
30833
  };
30834
+ const DeleteWordLeftShortcut = {
30835
+ id: DeleteLeftCommand.id,
30836
+ preconditions: whenTextEditorFocused,
30837
+ binding: KeyCode.BACKSPACE | MetaKeys.CTRL_COMMAND,
30838
+ mac: KeyCode.BACKSPACE | MetaKeys.ALT,
30839
+ staticParameters: { granularity: "word" }
30840
+ };
30841
+ const DeleteWordRightShortcut = {
30842
+ id: DeleteRightCommand.id,
30843
+ preconditions: whenTextEditorFocused,
30844
+ mac: KeyCode.DELETE | MetaKeys.ALT,
30845
+ staticParameters: { granularity: "word" }
30846
+ };
30847
+ const DeleteLineStartShortcut = {
30848
+ id: DeleteLeftCommand.id,
30849
+ preconditions: whenTextEditorFocused,
30850
+ mac: KeyCode.BACKSPACE | MetaKeys.CTRL_COMMAND,
30851
+ staticParameters: { granularity: "line" }
30852
+ };
30853
+ const DeleteLineEndShortcut = {
30854
+ id: DeleteRightCommand.id,
30855
+ preconditions: whenTextEditorFocused,
30856
+ binding: KeyCode.DELETE | MetaKeys.CTRL_COMMAND,
30857
+ mac: KeyCode.DELETE | MetaKeys.MAC_CTRL,
30858
+ staticParameters: { granularity: "line" }
30859
+ };
29751
30860
 
29752
30861
  //#endregion
29753
30862
  //#region src/shortcuts/cursor.shortcut.ts
@@ -29758,7 +30867,7 @@ function moveCursorShortcut(direction, granularity, binding, mac = binding, win
29758
30867
  mac,
29759
30868
  win,
29760
30869
  linux,
29761
- preconditions: whenDocAndEditorFocused,
30870
+ preconditions: whenTextEditorFocused,
29762
30871
  staticParameters: {
29763
30872
  direction,
29764
30873
  granularity
@@ -29772,7 +30881,7 @@ function moveSelectionShortcut(direction, granularity, binding, mac = binding, w
29772
30881
  mac,
29773
30882
  win,
29774
30883
  linux,
29775
- preconditions: whenDocAndEditorFocused,
30884
+ preconditions: whenTextEditorFocused,
29776
30885
  staticParameters: {
29777
30886
  direction,
29778
30887
  granularity
@@ -30035,6 +31144,10 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends Plugin {
30035
31144
  MoveSelectionWordRightShortcut,
30036
31145
  SelectAllShortcut,
30037
31146
  DeleteLeftShortcut,
31147
+ DeleteWordLeftShortcut,
31148
+ DeleteWordRightShortcut,
31149
+ DeleteLineStartShortcut,
31150
+ DeleteLineEndShortcut,
30038
31151
  DeleteRightShortcut,
30039
31152
  CloseHeaderFooterShortcut,
30040
31153
  BreakLineShortcut,
@@ -30111,10 +31224,12 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends Plugin {
30111
31224
  _initRenderModules() {
30112
31225
  [
30113
31226
  [DocEventManagerService],
31227
+ [DocFieldRenderController],
30114
31228
  [DocFloatMenuService],
30115
31229
  [DocPasteOptionsRenderController],
30116
31230
  [DocParagraphMenuService],
30117
31231
  [DocHeaderFooterController],
31232
+ [DocHeaderFooterRibbonController],
30118
31233
  [DocResizeRenderController],
30119
31234
  [DocParagraphPlaceholderRenderController],
30120
31235
  [DocContextMenuRenderController],
@@ -30317,6 +31432,35 @@ const mobileButtonClassName = `
30317
31432
  `;
30318
31433
  const activeButtonClassName = "univer-bg-primary-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-400";
30319
31434
  function MobileRichTextToolbar({ editorId, className }) {
31435
+ function resolveToolbarState(editor, defaultTextColor) {
31436
+ var _style$ul, _style$st, _style$cl;
31437
+ const body = editor === null || editor === void 0 ? void 0 : editor.getDocumentData().body;
31438
+ const ranges = (editor === null || editor === void 0 ? void 0 : editor.getSelectionRanges()) ?? [];
31439
+ const range = ranges.find((item) => item.isActive) ?? ranges[0];
31440
+ if (!body || !range) return {
31441
+ bold: false,
31442
+ italic: false,
31443
+ underline: false,
31444
+ strike: false,
31445
+ color: defaultTextColor,
31446
+ bulletList: false,
31447
+ orderList: false
31448
+ };
31449
+ const style = getStyleInTextRange(body, range, {});
31450
+ const listTypes = BuildTextUtils.range.getParagraphsInRanges([range], body.paragraphs ?? [], body.dataStream).map((paragraph) => {
31451
+ var _paragraph$bullet;
31452
+ return (_paragraph$bullet = paragraph.bullet) === null || _paragraph$bullet === void 0 ? void 0 : _paragraph$bullet.listType;
31453
+ }).filter((listType) => typeof listType === "string");
31454
+ return {
31455
+ bold: style.bl === BooleanNumber.TRUE,
31456
+ italic: style.it === BooleanNumber.TRUE,
31457
+ underline: ((_style$ul = style.ul) === null || _style$ul === void 0 ? void 0 : _style$ul.s) === BooleanNumber.TRUE,
31458
+ strike: ((_style$st = style.st) === null || _style$st === void 0 ? void 0 : _style$st.s) === BooleanNumber.TRUE,
31459
+ color: ((_style$cl = style.cl) === null || _style$cl === void 0 ? void 0 : _style$cl.rgb) ?? defaultTextColor,
31460
+ bulletList: Boolean(listTypes.length && listTypes.every((listType) => listType.startsWith(PresetListType.BULLET_LIST))),
31461
+ orderList: Boolean(listTypes.length && listTypes.every((listType) => listType.startsWith(PresetListType.ORDER_LIST)))
31462
+ };
31463
+ }
30320
31464
  const commandService = useDependency(ICommandService);
30321
31465
  const editorService = useDependency(IEditorService);
30322
31466
  const localeService = useDependency(LocaleService);
@@ -30330,12 +31474,11 @@ function MobileRichTextToolbar({ editorId, className }) {
30330
31474
  return () => cancelAnimationFrame(frame);
30331
31475
  }, [editorId, editorService]);
30332
31476
  useEffect(() => {
30333
- if (!editor) return void 0;
31477
+ if (!editor) return;
30334
31478
  const subscription = merge$1(editor.input$, editor.selectionChange$).subscribe(() => setRevision((value) => value + 1));
30335
31479
  return () => subscription.unsubscribe();
30336
31480
  }, [editor]);
30337
- const defaultTextColor = themeService.getColorFromTheme("gray.900");
30338
- const state = resolveToolbarState(editor, defaultTextColor);
31481
+ const state = resolveToolbarState(editor, themeService.getColorFromTheme("gray.900"));
30339
31482
  const colors = COLOR_TOKENS.map((token) => themeService.getColorFromTheme(token));
30340
31483
  async function execute(commandId, params) {
30341
31484
  const activeEditor = editorService.getEditor(editorId);
@@ -30434,18 +31577,23 @@ function MobileRichTextToolbar({ editorId, className }) {
30434
31577
  style: { backgroundColor: color },
30435
31578
  onClick: () => execute(SetInlineFormatTextColorCommand.id, { value: color })
30436
31579
  }, color)),
30437
- /* @__PURE__ */ jsxs("label", {
30438
- "aria-label": localeService.t("docs-ui.toolbar.textColor.main"),
30439
- className: clsx(resetButtonClassName, "univer-relative univer-flex univer-size-7 univer-items-center univer-justify-center univer-justify-self-center univer-overflow-hidden univer-rounded-md univer-border-2 univer-border-solid univer-border-transparent active:univer-scale-95"),
30440
- children: [/* @__PURE__ */ jsx(ColorWheelMultiIcon, { className: "univer-size-6" }), /* @__PURE__ */ jsx("input", {
31580
+ /* @__PURE__ */ jsx(MobileDropdown, {
31581
+ overlay: /* @__PURE__ */ jsx("div", {
31582
+ className: "univer-px-4 univer-pb-2",
31583
+ onPointerDown: (event) => event.stopPropagation(),
31584
+ children: /* @__PURE__ */ jsx(MobileColorPicker, {
31585
+ value: state.color,
31586
+ onChange: (color) => execute(SetInlineFormatTextColorCommand.id, { value: color })
31587
+ })
31588
+ }),
31589
+ children: /* @__PURE__ */ jsx(Button, {
31590
+ type: "button",
31591
+ variant: "text",
31592
+ size: "icon",
30441
31593
  "aria-label": localeService.t("docs-ui.toolbar.textColor.main"),
30442
- className: "univer-absolute univer-inset-0 univer-size-full univer-cursor-pointer univer-opacity-0",
30443
- type: "color",
30444
- defaultValue: defaultTextColor,
30445
- onChange: (event) => {
30446
- execute(SetInlineFormatTextColorCommand.id, { value: event.target.value });
30447
- }
30448
- })]
31594
+ className: "univer-size-7 univer-justify-self-center",
31595
+ children: /* @__PURE__ */ jsx(ColorWheelMultiIcon, { className: "!univer-size-6" })
31596
+ })
30449
31597
  })
30450
31598
  ]
30451
31599
  })
@@ -30464,35 +31612,6 @@ function FormatButton(props) {
30464
31612
  })
30465
31613
  });
30466
31614
  }
30467
- function resolveToolbarState(editor, defaultTextColor) {
30468
- var _style$ul, _style$st, _style$cl;
30469
- const body = editor === null || editor === void 0 ? void 0 : editor.getDocumentData().body;
30470
- const ranges = (editor === null || editor === void 0 ? void 0 : editor.getSelectionRanges()) ?? [];
30471
- const range = ranges.find((item) => item.isActive) ?? ranges[0];
30472
- if (!body || !range) return {
30473
- bold: false,
30474
- italic: false,
30475
- underline: false,
30476
- strike: false,
30477
- color: defaultTextColor,
30478
- bulletList: false,
30479
- orderList: false
30480
- };
30481
- const style = getStyleInTextRange(body, range, {});
30482
- const listTypes = BuildTextUtils.range.getParagraphsInRanges([range], body.paragraphs ?? [], body.dataStream).map((paragraph) => {
30483
- var _paragraph$bullet;
30484
- return (_paragraph$bullet = paragraph.bullet) === null || _paragraph$bullet === void 0 ? void 0 : _paragraph$bullet.listType;
30485
- }).filter((listType) => typeof listType === "string");
30486
- return {
30487
- bold: style.bl === BooleanNumber.TRUE,
30488
- italic: style.it === BooleanNumber.TRUE,
30489
- underline: ((_style$ul = style.ul) === null || _style$ul === void 0 ? void 0 : _style$ul.s) === BooleanNumber.TRUE,
30490
- strike: ((_style$st = style.st) === null || _style$st === void 0 ? void 0 : _style$st.s) === BooleanNumber.TRUE,
30491
- color: ((_style$cl = style.cl) === null || _style$cl === void 0 ? void 0 : _style$cl.rgb) ?? defaultTextColor,
30492
- bulletList: Boolean(listTypes.length && listTypes.every((listType) => listType.startsWith(PresetListType.BULLET_LIST))),
30493
- orderList: Boolean(listTypes.length && listTypes.every((listType) => listType.startsWith(PresetListType.ORDER_LIST)))
30494
- };
30495
- }
30496
31615
 
30497
31616
  //#endregion
30498
31617
  //#region src/views/rich-text-editor/hooks/editor-undo-redo-keyboard.ts
@@ -31219,4 +32338,4 @@ function MobileRichTextEditor(props) {
31219
32338
  }
31220
32339
 
31221
32340
  //#endregion
31222
- 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, 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 };
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 };