@univerjs/sheets-ui 1.0.0-beta.0 → 1.0.0-beta.2

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 (107) hide show
  1. package/lib/cjs/facade.js +5 -5
  2. package/lib/cjs/index.js +1535 -1542
  3. package/lib/cjs/locale/ar-SA.js +14 -133
  4. package/lib/cjs/locale/ca-ES.js +16 -135
  5. package/lib/cjs/locale/de-DE.js +14 -133
  6. package/lib/cjs/locale/en-US.js +14 -133
  7. package/lib/cjs/locale/es-ES.js +14 -133
  8. package/lib/cjs/locale/fa-IR.js +14 -133
  9. package/lib/cjs/locale/fr-FR.js +14 -133
  10. package/lib/cjs/locale/id-ID.js +14 -133
  11. package/lib/cjs/locale/it-IT.js +14 -133
  12. package/lib/cjs/locale/ja-JP.js +14 -133
  13. package/lib/cjs/locale/ko-KR.js +14 -133
  14. package/lib/cjs/locale/pl-PL.js +14 -133
  15. package/lib/cjs/locale/pt-BR.js +14 -133
  16. package/lib/cjs/locale/ru-RU.js +14 -133
  17. package/lib/cjs/locale/sk-SK.js +16 -135
  18. package/lib/cjs/locale/vi-VN.js +14 -133
  19. package/lib/cjs/locale/zh-CN.js +14 -133
  20. package/lib/cjs/locale/zh-HK.js +14 -133
  21. package/lib/cjs/locale/zh-TW.js +14 -133
  22. package/lib/es/facade.js +6 -6
  23. package/lib/es/index.js +1543 -1551
  24. package/lib/es/locale/ar-SA.js +14 -133
  25. package/lib/es/locale/ca-ES.js +16 -135
  26. package/lib/es/locale/de-DE.js +14 -133
  27. package/lib/es/locale/en-US.js +14 -133
  28. package/lib/es/locale/es-ES.js +14 -133
  29. package/lib/es/locale/fa-IR.js +14 -133
  30. package/lib/es/locale/fr-FR.js +14 -133
  31. package/lib/es/locale/id-ID.js +14 -133
  32. package/lib/es/locale/it-IT.js +14 -133
  33. package/lib/es/locale/ja-JP.js +14 -133
  34. package/lib/es/locale/ko-KR.js +14 -133
  35. package/lib/es/locale/pl-PL.js +14 -133
  36. package/lib/es/locale/pt-BR.js +14 -133
  37. package/lib/es/locale/ru-RU.js +14 -133
  38. package/lib/es/locale/sk-SK.js +16 -135
  39. package/lib/es/locale/vi-VN.js +14 -133
  40. package/lib/es/locale/zh-CN.js +14 -133
  41. package/lib/es/locale/zh-HK.js +14 -133
  42. package/lib/es/locale/zh-TW.js +14 -133
  43. package/lib/facade.js +6 -6
  44. package/lib/index.css +54 -87
  45. package/lib/index.js +1543 -1551
  46. package/lib/locale/ar-SA.js +14 -133
  47. package/lib/locale/ca-ES.js +16 -135
  48. package/lib/locale/de-DE.js +14 -133
  49. package/lib/locale/en-US.js +14 -133
  50. package/lib/locale/es-ES.js +14 -133
  51. package/lib/locale/fa-IR.js +14 -133
  52. package/lib/locale/fr-FR.js +14 -133
  53. package/lib/locale/id-ID.js +14 -133
  54. package/lib/locale/it-IT.js +14 -133
  55. package/lib/locale/ja-JP.js +14 -133
  56. package/lib/locale/ko-KR.js +14 -133
  57. package/lib/locale/pl-PL.js +14 -133
  58. package/lib/locale/pt-BR.js +14 -133
  59. package/lib/locale/ru-RU.js +14 -133
  60. package/lib/locale/sk-SK.js +16 -135
  61. package/lib/locale/vi-VN.js +14 -133
  62. package/lib/locale/zh-CN.js +14 -133
  63. package/lib/locale/zh-HK.js +14 -133
  64. package/lib/locale/zh-TW.js +14 -133
  65. package/lib/types/controllers/editor/data-sync.controller.d.ts +4 -2
  66. package/lib/types/controllers/editor/editing.render-controller.d.ts +5 -2
  67. package/lib/types/controllers/force-string-alert-render.controller.d.ts +9 -4
  68. package/lib/types/controllers/render-controllers/contextmenu.render-controller.d.ts +4 -0
  69. package/lib/types/controllers/render-controllers/header-menu.render-controller.d.ts +4 -4
  70. package/lib/types/controllers/render-controllers/scroll.render-controller.d.ts +6 -0
  71. package/lib/types/controllers/utils/range-tools.d.ts +2 -0
  72. package/lib/types/embed-tab-anchor.d.ts +2 -1
  73. package/lib/types/index.d.ts +1 -1
  74. package/lib/types/locale/en-US.d.ts +1 -106
  75. package/lib/types/menu/header-menu-shape.d.ts +3 -3
  76. package/lib/types/services/cell-alert-manager.service.d.ts +6 -0
  77. package/lib/types/services/cell-popup-manager.service.d.ts +6 -7
  78. package/lib/types/services/editor-bridge.service.d.ts +3 -0
  79. package/lib/types/services/sheet-embed-integration.service.d.ts +5 -0
  80. package/lib/types/services/sheet-embed-runtime.service.d.ts +2 -1
  81. package/lib/types/views/CellPopup.d.ts +2 -1
  82. package/lib/types/views/hook.d.ts +0 -4
  83. package/lib/types/views/status-bar/CopyableStatisticItem.d.ts +0 -2
  84. package/lib/types/views/status-bar/StatusBar.d.ts +1 -1
  85. package/lib/umd/facade.js +1 -1
  86. package/lib/umd/index.js +14 -11
  87. package/lib/umd/locale/ar-SA.js +1 -1
  88. package/lib/umd/locale/ca-ES.js +1 -1
  89. package/lib/umd/locale/de-DE.js +1 -1
  90. package/lib/umd/locale/en-US.js +1 -1
  91. package/lib/umd/locale/es-ES.js +1 -1
  92. package/lib/umd/locale/fa-IR.js +1 -1
  93. package/lib/umd/locale/fr-FR.js +1 -1
  94. package/lib/umd/locale/id-ID.js +1 -1
  95. package/lib/umd/locale/it-IT.js +1 -1
  96. package/lib/umd/locale/ja-JP.js +1 -1
  97. package/lib/umd/locale/ko-KR.js +1 -1
  98. package/lib/umd/locale/pl-PL.js +1 -1
  99. package/lib/umd/locale/pt-BR.js +1 -1
  100. package/lib/umd/locale/ru-RU.js +1 -1
  101. package/lib/umd/locale/sk-SK.js +1 -1
  102. package/lib/umd/locale/vi-VN.js +1 -1
  103. package/lib/umd/locale/zh-CN.js +1 -1
  104. package/lib/umd/locale/zh-HK.js +1 -1
  105. package/lib/umd/locale/zh-TW.js +1 -1
  106. package/package.json +14 -14
  107. package/lib/types/services/sheet-loading-render.service.d.ts +0 -65
package/lib/index.js CHANGED
@@ -1,17 +1,17 @@
1
- import { BreakLineCommand, CoverContentCommand, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_VIEW_KEY, DOC_VERTICAL_PADDING, DeleteLeftCommand, DeleteRightCommand, DocSelectionRenderService, IEditorService, IMEInputCommand, MoveCursorOperation, MoveSelectionOperation, NodePositionConvertToCursor, ReplaceSnapshotCommand, SetInlineFormatBoldCommand, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, SetInlineFormatTextColorCommand, SetInlineFormatUnderlineCommand, UniverDocsUIPlugin, VIEWPORT_KEY, convertBodyToHtml, getCanvasOffsetByEngine, getLineBounding } from "@univerjs/docs-ui";
2
- import { AbsoluteRefType, BaselineOffset, BooleanNumber, BorderStyleTypes, CellModeEnum, CellValueType, ColorKit, CommandType, CustomRangeType, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DEFAULT_WORKSHEET_COLUMN_COUNT, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT, DEFAULT_WORKSHEET_COLUMN_WIDTH, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY, DEFAULT_WORKSHEET_ROW_COUNT, DEFAULT_WORKSHEET_ROW_HEIGHT, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DataStreamTreeTokenType, DependentOn, Direction, Disposable, DisposableCollection, DocumentFlavor, EDITOR_ACTIVATED, ErrorService, FOCUSING_COMMENT_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_EDITOR_INPUT_FORMULA, FOCUSING_EDITOR_STANDALONE, FOCUSING_FX_BAR_EDITOR, FOCUSING_SHAPE_TEXT_EDITOR, FOCUSING_SHEET, FOCUSING_UNIVER_EDITOR, FontItalic, FontWeight, HorizontalAlign, IAuthzIoService, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IPermissionService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LRUMap, LocaleService, LocaleType, LookUp, NilCommand, ObjectMatrix, Optional, Plugin, PresetListType, Quantity, RANGE_TYPE, Range, Rectangle, RxDisposable, SHEET_EDITOR_UNITS, ThemeService, Tools, UndoCommandId, UniverInstanceType, UserManagerService, VerticalAlign, Workbook, WrapStrategy, cloneCellDataMatrix, cloneCellDataWithSpanAndDisplay, cloneValue, composeStyles, convertCellToRange, createDocumentModelWithStyle, createIdentifier, createInterceptorKey, createParagraphId, createSectionId, dateKit, debounce, extractPureTextFromCell, fromEventSubject, generateRandomId, get, getEmptyCell, getIntersectRange, getNumfmtParseValueFilter, getReverseDirection, handleStyleToString, isDefaultFormat, isFormulaString, isInternalEditorID, isNotNullOrUndefined, isRealNum, isSafeUrl, isTextFormat, isValidRange, merge, mergeOverrideWithDependencies, nameCharacterCheck, numberToABC, numfmt, registerDependencies, sequenceExecute, set, skipParseTagNames, sortRules, splitIntoGrid, throttle, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
1
+ import { BreakLineCommand, CoverContentCommand, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_VIEW_KEY, DOC_VERTICAL_PADDING, DeleteLeftCommand, DeleteRightCommand, DocSelectionRenderService, IEditorService, IMEInputCommand, MoveCursorOperation, MoveSelectionOperation, NodePositionConvertToCursor, ReplaceSnapshotCommand, SetDocInputStyleCommand, SetInlineFormatBoldCommand, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, SetInlineFormatTextColorCommand, SetInlineFormatUnderlineCommand, UniverDocsUIPlugin, VIEWPORT_KEY, convertBodyToHtml, getCanvasOffsetByEngine, getLineBounding } from "@univerjs/docs-ui";
2
+ import { AbsoluteRefType, BaselineOffset, BooleanNumber, BorderStyleTypes, CellModeEnum, CellValueType, ColorKit, CommandType, CustomRangeType, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DEFAULT_WORKSHEET_COLUMN_COUNT, DEFAULT_WORKSHEET_COLUMN_WIDTH, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY, DEFAULT_WORKSHEET_ROW_COUNT, DEFAULT_WORKSHEET_ROW_HEIGHT, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DataStreamTreeTokenType, DependentOn, Direction, Disposable, DisposableCollection, DocumentFlavor, EDITOR_ACTIVATED, ErrorService, FOCUSING_COMMENT_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_EDITOR_INPUT_FORMULA, FOCUSING_EDITOR_STANDALONE, FOCUSING_FX_BAR_EDITOR, FOCUSING_SHAPE_TEXT_EDITOR, FOCUSING_SHEET, FOCUSING_UNIVER_EDITOR, FontItalic, FontWeight, HorizontalAlign, IAuthzIoService, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IPermissionService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LRUMap, LocaleService, LocaleType, LookUp, NilCommand, ObjectMatrix, Optional, Plugin, PresetListType, Quantity, RANGE_TYPE, Range, Rectangle, RxDisposable, SHEET_EDITOR_UNITS, ThemeService, Tools, UndoCommandId, UniverInstanceType, UserManagerService, VerticalAlign, Workbook, WrapStrategy, cloneCellDataMatrix, cloneCellDataWithSpanAndDisplay, cloneValue, composeStyles, convertCellToRange, createDocumentModelWithStyle, createIdentifier, createInterceptorKey, createParagraphId, createSectionId, dateKit, debounce, extractPureTextFromCell, fromEventSubject, generateRandomId, get, getEmptyCell, getIntersectRange, getNumfmtParseValueFilter, getReverseDirection, handleStyleToString, isDefaultFormat, isFormulaString, isNotNullOrUndefined, isRealNum, isSafeUrl, isTextFormat, isValidRange, merge, mergeOverrideWithDependencies, nameCharacterCheck, numberToABC, numfmt, registerDependencies, sequenceExecute, set, skipParseTagNames, sortRules, splitIntoGrid, throttle, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
3
3
  import { AUTO_FILL_APPLY_TYPE, AUTO_FILL_HOOK_TYPE, AddMergeUndoMutationFactory, AddRangeProtectionCommand, AddRangeProtectionMutation, AddWorksheetMergeAllCommand, AddWorksheetMergeCommand, AddWorksheetMergeHorizontalCommand, AddWorksheetMergeMutation, AddWorksheetMergeVerticalCommand, AddWorksheetProtectionCommand, AutoClearContentCommand, AutoFillCommand, AutoFillController, BEFORE_CELL_EDIT, BorderStyleManagerService, COMMAND_LISTENER_SKELETON_CHANGE, COMMAND_LISTENER_VALUE_CHANGE, CancelFrozenCommand, CancelMarkDirtyRowAutoHeightOperation, ClearSelectionAllCommand, ClearSelectionContentCommand, ClearSelectionFormatCommand, CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeleteRangeProtectionCommand, DeleteRangeProtectionMutation, DeleteWorksheetProtectionCommand, DeltaColumnWidthCommand, DeltaRowHeightCommand, EditStateEnum, IAutoFillService, IExclusiveRangeService, INTERCEPTOR_POINT, INumfmtService, IRefSelectionsService, InsertColBeforeCommand, InsertColCommand, InsertColMutation, InsertDefinedNameCommand, InsertMultiColsLeftCommand, InsertMultiColsRightCommand, InsertMultiRowsAboveCommand, InsertMultiRowsAfterCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowBeforeCommand, InsertRowCommand, InsertRowMutation, InsertSheetCommand, InsertSheetMutation, MAX_CELL_PER_SHEET_KEY, MERGE_CELL_INTERCEPTOR_CHECK, MarkDirtyRowAutoHeightOperation, MergeCellController, MoveColsCommand, MoveColsMutation, MoveRangeCommand, MoveRangeMutation, MoveRowsCommand, MoveRowsMutation, REF_SELECTIONS_ENABLED, RangeProtectionCache, RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint, RangeProtectionRuleModel, RefRangeService, RefSelectionsService, RefillCommand, RemoveColCommand, RemoveColMutation, RemoveDefinedNameCommand, RemoveMergeUndoMutationFactory, RemoveRowCommand, RemoveRowMutation, RemoveSheetCommand, RemoveSheetMutation, RemoveWorksheetMergeCommand, RemoveWorksheetMergeMutation, ResetBackgroundColorCommand, ResetTextColorCommand, SCOPE_WORKBOOK_VALUE_DEFINED_NAME, SELECTIONS_ENABLED, SELECTION_CONTROL_BORDER_BUFFER_COLOR, SELECTION_CONTROL_BORDER_BUFFER_WIDTH, SHEETS_PLUGIN_CONFIG_KEY, ScrollToCellOperation, SelectionMoveType, SetBackgroundColorCommand, SetBoldCommand, SetBorderBasicCommand, SetBorderCommand, SetColHiddenCommand, SetColHiddenMutation, SetColVisibleMutation, SetColWidthCommand, SetDefinedNameCommand, SetFontFamilyCommand, SetFontSizeCommand, SetFrozenCommand, SetFrozenMutation, SetFrozenMutationFactory, SetHorizontalTextAlignCommand, SetItalicCommand, SetProtectionCommand, SetRangeValuesCommand, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetRowHeightCommand, SetRowHiddenCommand, SetRowHiddenMutation, SetRowVisibleMutation, SetSelectedColsVisibleCommand, SetSelectedRowsVisibleCommand, SetSelectionsOperation, SetShrinkToFitCommand, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetStrikeThroughCommand, SetStyleCommand, SetTabColorCommand, SetTabColorMutation, SetTextColorCommand, SetTextRotationCommand, SetTextWrapCommand, SetUnderlineCommand, SetVerticalTextAlignCommand, SetWorksheetActivateCommand, SetWorksheetActiveOperation, SetWorksheetColWidthMutation, SetWorksheetColWidthMutationFactory, SetWorksheetHideCommand, SetWorksheetHideMutation, SetWorksheetNameCommand, SetWorksheetNameMutation, SetWorksheetOrderCommand, SetWorksheetOrderMutation, SetWorksheetPermissionPointsCommand, SetWorksheetRowAutoHeightMutation, SetWorksheetRowAutoHeightMutationFactory, SetWorksheetRowHeightMutation, SetWorksheetRowIsAutoHeightCommand, SetWorksheetRowIsAutoHeightMutation, SetWorksheetShowCommand, SheetCopyDownCommand, SheetCopyRightCommand, SheetInterceptorService, SheetPermissionCheckController, SheetPermissionInitController, SheetSkeletonService, SheetsSelectionsService, TextToNumberCommand, ToggleCellCheckboxCommand, ToggleGridlinesCommand, ToggleGridlinesMutation, UniverSheetsPlugin, ViewStateEnum, WorkbookCopyPermission, WorkbookCreateProtectPermission, WorkbookCreateSheetPermission, WorkbookDeleteColumnPermission, WorkbookDeleteRowPermission, WorkbookDeleteSheetPermission, WorkbookEditablePermission, WorkbookHideSheetPermission, WorkbookInsertColumnPermission, WorkbookInsertRowPermission, WorkbookManageCollaboratorPermission, WorkbookRenameSheetPermission, WorksheetCopyPermission, WorksheetDeleteColumnPermission, WorksheetDeleteProtectionPermission, WorksheetDeleteRowPermission, WorksheetEditPermission, WorksheetInsertColumnPermission, WorksheetInsertRowPermission, WorksheetManageCollaboratorPermission, WorksheetProtectionPointModel, WorksheetProtectionRuleModel, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission, WorksheetSetColumnStylePermission, WorksheetSetRowStylePermission, WorksheetViewPermission, adjustRangeOnMutation, alignToMergedCellsBorders, attachPrimaryWithCoord, attachRangeWithCoord, attachSelectionWithCoord, baseProtectionActions, convertPrimaryWithCoordToPrimary, convertSelectionDataToRange, countCells, defaultLargeSheetOperationConfig, deserializeListOptions, discreteRangeToRange, expandToContinuousRange, getAddMergeMutationRangeByType, getAllWorksheetPermissionPoint, getCellAtRowCol, getClearContentMutationParamsForRanges, getMoveRangeCommandMutations, getPrimaryForRange, getSelectionsService, getSheetCommandTarget, isCellImage, rangeToDiscreteRange, serializeListOptions, setEndForRange, validateDefinedName } from "@univerjs/sheets";
4
- import { AnchoredContextMenu, BuiltInUIPart, COLOR_PICKER_COMPONENT, ComponentContainer, ComponentManager, ContextMenuGroup, ContextMenuPosition, CopyCommand, CutCommand, DISABLE_AUTO_FOCUS_KEY, 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, HTML_CLIPBOARD_MIME_TYPE, ICanvasPopupService, IClipboardInterfaceService, IContextMenuService, IDialogService, ILayoutService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IShortcutService, ISidebarService, IUIPartsService, IconManager, KeyCode, MenuItemType, MetaKeys, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SheetPasteShortKeyCommandName, Slider, ToggleFullscreenOperation, ToolbarItem, UI_PLUGIN_CONFIG_KEY, UniverMobileUIPlugin, ZoomInput, connectInjector, getMenuHiddenObservable, handleStringToStyle, imageMimeTypeSet, sanitizeParsedHtml, textTrim, useComponentsOfPart, useConfigValue, useDependency, useEvent, useObservable, useSidebarClick, useVirtualList } from "@univerjs/ui";
5
- import { CURSOR_TYPE, DashedRect, DeviceInputEventType, Engine, FIX_ONE_PIXEL_BLUR_OFFSET, Group, IRenderManagerService, Layer, RENDER_CLASS_TYPE, RENDER_RAW_FORMULA_KEY, Rect, RegularPolygon, RenderUnit, SHEET_EXTENSION_PREFIX, SHEET_VIEWPORT_KEY, Scene, ScrollBar, ScrollTimer, ScrollTimerType, Shape, SheetExtension, Spreadsheet, SpreadsheetColumnHeader, SpreadsheetRowHeader, TRANSFORM_CHANGE_OBSERVABLE_TYPE, UniverRenderEnginePlugin, Vector2, Viewport, calculateCellImageRect, cancelRequestFrame, convertTextRotation, convertTransformToOffsetX, convertTransformToOffsetY, fixLineWidthByScale, getCurrentTypeOfRenderer, getNextWheelZoomRatio, ptToPixel, requestNewFrame, withCurrentTypeOfRenderer } from "@univerjs/engine-render";
6
- import { BehaviorSubject, EMPTY, Observable, Subject, Subscription, combineLatest, combineLatestWith, distinctUntilChanged, filter, firstValueFrom, from, fromEvent, map, merge as merge$1, of, shareReplay, skip, startWith, switchMap, take, takeUntil, throttleTime, timeout, withLatestFrom } from "rxjs";
7
- import { DocSelectionManagerService, DocSkeletonManagerService, InsertTextCommand, RichTextEditingMutation, SetTextSelectionsOperation, UniverDocsPlugin } from "@univerjs/docs";
4
+ import { AnchoredContextMenu, BuiltInUIPart, COLOR_PICKER_COMPONENT, ComponentContainer, ComponentManager, ContextMenuGroup, ContextMenuPosition, CopyCommand, CutCommand, DISABLE_AUTO_FOCUS_KEY, 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, HTML_CLIPBOARD_MIME_TYPE, ICanvasPopupService, IClipboardInterfaceService, IContextMenuService, IDialogService, ILayoutService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IShortcutService, ISidebarService, IUIPartsService, IWorkbenchService, IconManager, KeyCode, MenuItemType, MetaKeys, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SheetPasteShortKeyCommandName, Slider, ToggleFullscreenOperation, ToolbarItem, UI_PLUGIN_CONFIG_KEY, UniverMobileUIPlugin, ZoomInput, connectInjector, getMenuHiddenObservable, handleStringToStyle, imageMimeTypeSet, sanitizeParsedHtml, textTrim, useComponentsOfPart, useConfigValue, useDependency, useEvent, useObservable, useSidebarClick, useVirtualList } from "@univerjs/ui";
5
+ import { CURSOR_TYPE, DashedRect, DeviceInputEventType, FIX_ONE_PIXEL_BLUR_OFFSET, Group, IRenderManagerService, Layer, RENDER_CLASS_TYPE, RENDER_RAW_FORMULA_KEY, Rect, RegularPolygon, SHEET_EXTENSION_PREFIX, SHEET_VIEWPORT_KEY, ScrollBar, ScrollTimer, ScrollTimerType, Shape, SheetExtension, Spreadsheet, SpreadsheetColumnHeader, SpreadsheetRowHeader, TRANSFORM_CHANGE_OBSERVABLE_TYPE, UniverRenderEnginePlugin, Vector2, Viewport, calculateCellImageRect, cancelRequestFrame, convertTextRotation, convertTransformToOffsetX, convertTransformToOffsetY, fixLineWidthByScale, getCurrentTypeOfRenderer, getNextWheelZoomRatio, ptToPixel, requestNewFrame, withCurrentTypeOfRenderer } from "@univerjs/engine-render";
6
+ import { BehaviorSubject, EMPTY, Observable, Subject, Subscription, combineLatest, combineLatestWith, distinctUntilChanged, filter, from, fromEvent, map, merge as merge$1, of, shareReplay, skip, startWith, switchMap, takeUntil, throttleTime, withLatestFrom } from "rxjs";
7
+ import { DocSelectionManagerService, DocSkeletonManagerService, DocStateChangeManagerService, InsertTextCommand, RichTextEditingMutation, SetTextSelectionsOperation, UniverDocsPlugin } from "@univerjs/docs";
8
8
  import { ObjectScope, UnitAction, UnitObject, UnitRole } from "@univerjs/protocol";
9
9
  import { Avatar, Button, Calendar, CascaderList, ColorPicker, ConfigContext, Confirm, Dropdown, DropdownMenu, FormLayout, Input, InputNumber, MessageType, Radio, RadioGroup, Select, Separator, Switch, TimeInput, Tooltip, borderBottomClassName, borderClassName, borderRightClassName, borderTopClassName, clsx, scrollbarClassName } from "@univerjs/design";
10
- import { AddImageIcon, AdjustHeightDoubleIcon, AdjustWidthDoubleIcon, AlignBottomIcon, AlignTopIcon, AllBorderIcon, AutoHeightDoubleIcon, AutoWidthDoubleIcon, AutofillDoubleIcon, AutowrapIcon, BackSlashDoubleIcon, BoldIcon, BrushIcon, CancelFreezeIcon, CancelMergeIcon, CheckMarkIcon, ClearFormatDoubleIcon, CloseIcon, CodeIcon, ConvertIcon, ConvertToNumberIcon, CopyDoubleIcon, CutIcon, DeleteCellShiftLeftDoubleIcon, DeleteCellShiftUpDoubleIcon, DeleteColumnDoubleIcon, DeleteIcon, DeleteRowDoubleIcon, DownBorderDoubleIcon, DownIcon, DownloadImageIcon, ErrorIcon, EyeIcon, EyelashIcon, FontColorDoubleIcon, FontSizeIncreaseIcon, FontSizeReduceIcon, FreezeColumnIcon, FreezeRowIcon, FreezeToSelectedIcon, FxIcon, HideDoubleIcon, HideGridlinesIcon, HorizontalBorderDoubleIcon, HorizontalMergeIcon, HorizontallyIcon, IncreaseIcon, InfoIcon, InnerBorderDoubleIcon, InsertCellDownDoubleIcon, InsertCellShiftRightDoubleIcon, InsertDoubleIcon, InsertRowAboveDoubleIcon, InsertRowBelowDoubleIcon, ItalicIcon, LeftBorderDoubleIcon, LeftDoubleDiagonalDoubleIcon, LeftInsertColumnDoubleIcon, LeftJustifyingIcon, LeftRotationFortyFiveDegreesIcon, LeftRotationNinetyDegreesIcon, LeftTridiagonalDoubleIcon, LoadingMultiIcon, LockIcon, MergeAllIcon, MoreDownIcon, MoreLeftIcon, MoreRightIcon, NoBorderIcon, NoColorDoubleIcon, NoRotationIcon, OuterBorderDoubleIcon, OverflowIcon, PaintBucketDoubleIcon, PasteSpecialDoubleIcon, PenIcon, ProtectIcon, ReduceDoubleIcon, RightBorderDoubleIcon, RightDoubleDiagonalDoubleIcon, RightInsertColumnDoubleIcon, RightJustifyingIcon, RightRotationFortyFiveDegreesIcon, RightRotationNinetyDegreesIcon, ShrinkToFitIcon, SlashDoubleIcon, StrikethroughIcon, SubscriptIcon, SuperscriptIcon, TruncationIcon, UnderlineIcon, UpBorderDoubleIcon, VerticalBorderDoubleIcon, VerticalCenterIcon, VerticalIntegrationIcon, VerticalTextIcon, WarningIcon, WriteIcon } from "@univerjs/icons";
11
- import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
12
- import { FUNCTION_NAMES_MATH, FUNCTION_NAMES_STATISTICAL, FUNCTION_NAMES_TEXT, FormulaDataModel, IDefinedNamesService, IFunctionService, ISuperTableService, LexerTreeBuilder, NullValueObject, SetFormulaCalculationNotificationMutation, UniverFormulaEnginePlugin, deserializeRangeWithSheet, isReferenceStringWithEffectiveColumn, isReferenceStrings, matchToken, operatorToken, sequenceNodeType, serializeRange, serializeRangeWithSheet } from "@univerjs/engine-formula";
13
- import { ITelemetryService } from "@univerjs/telemetry";
10
+ import { AddImageIcon, AdjustHeightDoubleIcon, AdjustWidthDoubleIcon, AlignBottomIcon, AlignTopIcon, AllBorderIcon, AutoHeightDoubleIcon, AutoWidthDoubleIcon, AutofillDoubleIcon, AutowrapIcon, BackSlashDoubleIcon, BasesMultiIcon, BoardsMultiIcon, BoldIcon, BrushIcon, CancelFreezeIcon, CancelMergeIcon, CheckMarkIcon, ClearFormatDoubleIcon, CloseIcon, CodeIcon, ConvertIcon, ConvertToNumberIcon, CopyDoubleIcon, CutIcon, DeleteCellShiftLeftDoubleIcon, DeleteCellShiftUpDoubleIcon, DeleteColumnDoubleIcon, DeleteIcon, DeleteRowDoubleIcon, DocsMultiIcon, DownBorderDoubleIcon, DownIcon, DownloadImageIcon, ErrorIcon, EyeIcon, EyelashIcon, FontColorDoubleIcon, FontSizeIncreaseIcon, FontSizeReduceIcon, FreezeColumnIcon, FreezeRowIcon, FreezeToSelectedIcon, FxIcon, HideDoubleIcon, HideGridlinesIcon, HorizontalBorderDoubleIcon, HorizontalMergeIcon, HorizontallyIcon, IncreaseIcon, InfoIcon, InnerBorderDoubleIcon, InsertCellDownDoubleIcon, InsertCellShiftRightDoubleIcon, InsertDoubleIcon, InsertRowAboveDoubleIcon, InsertRowBelowDoubleIcon, ItalicIcon, LeftBorderDoubleIcon, LeftDoubleDiagonalDoubleIcon, LeftInsertColumnDoubleIcon, LeftJustifyingIcon, LeftRotationFortyFiveDegreesIcon, LeftRotationNinetyDegreesIcon, LeftTridiagonalDoubleIcon, LockIcon, MergeAllIcon, MoreDownIcon, MoreLeftIcon, MoreRightIcon, NoBorderIcon, NoColorDoubleIcon, NoRotationIcon, OuterBorderDoubleIcon, OverflowIcon, PaintBucketDoubleIcon, PasteSpecialDoubleIcon, PenIcon, ProtectIcon, ReduceDoubleIcon, RightBorderDoubleIcon, RightDoubleDiagonalDoubleIcon, RightInsertColumnDoubleIcon, RightJustifyingIcon, RightRotationFortyFiveDegreesIcon, RightRotationNinetyDegreesIcon, SheetsMultiIcon, ShrinkToFitIcon, SlashDoubleIcon, SlidesMultiIcon, StrikethroughIcon, SubscriptIcon, SuperscriptIcon, TruncationIcon, UnderlineIcon, UpBorderDoubleIcon, VerticalBorderDoubleIcon, VerticalCenterIcon, VerticalIntegrationIcon, VerticalTextIcon, WarningIcon, WriteIcon } from "@univerjs/icons";
11
+ import { useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState } from "react";
14
12
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
+ import { FUNCTION_NAMES_MATH, FUNCTION_NAMES_STATISTICAL, FUNCTION_NAMES_TEXT, FormulaDataModel, IDefinedNamesService, IFunctionService, ISuperTableService, LexerTreeBuilder, NullValueObject, SetFormulaCalculationNotificationMutation, UniverFormulaEnginePlugin, deserializeRangeWithSheet, isReferenceStringWithEffectiveColumn, isReferenceStrings, matchToken, operatorToken, quoteSheetName, sequenceNodeType, serializeRange, serializeRangeWithSheet } from "@univerjs/engine-formula";
14
+ import { ITelemetryService } from "@univerjs/telemetry";
15
15
  import { debounceTime, filter as filter$1, map as map$1, shareReplay as shareReplay$1, startWith as startWith$1, switchMap as switchMap$1 } from "rxjs/operators";
16
16
 
17
17
  //#region src/basics/editor/get-editor-object.ts
@@ -92,6 +92,40 @@ function whenEditorDidNotInputFormulaActivated(contextService) {
92
92
 
93
93
  //#endregion
94
94
  //#region src/controllers/utils/range-tools.ts
95
+ function groupConsecutive(values, start, end) {
96
+ const groups = [];
97
+ for (let index = start; index <= end; index++) {
98
+ const value = values[index];
99
+ const previous = groups[groups.length - 1];
100
+ if (previous && value === previous.end + 1) previous.end = value;
101
+ else groups.push({
102
+ start: value,
103
+ end: value
104
+ });
105
+ }
106
+ return groups;
107
+ }
108
+ function projectLine(values, start, end) {
109
+ let low = 0;
110
+ let high = values.length;
111
+ while (low < high) {
112
+ const middle = Math.floor((low + high) / 2);
113
+ if (values[middle] < start) low = middle + 1;
114
+ else high = middle;
115
+ }
116
+ const first = low;
117
+ if (first === values.length || values[first] > end) return null;
118
+ high = values.length;
119
+ while (low < high) {
120
+ const middle = Math.floor((low + high) / 2);
121
+ if (values[middle] <= end) low = middle + 1;
122
+ else high = middle;
123
+ }
124
+ return {
125
+ start: first,
126
+ end: low - 1
127
+ };
128
+ }
95
129
  function virtualizeDiscreteRanges(ranges) {
96
130
  let totalRows = [];
97
131
  let totalCols = [];
@@ -115,7 +149,27 @@ function virtualizeDiscreteRanges(ranges) {
115
149
  mapFunc: (row, col) => ({
116
150
  row: totalRows[row],
117
151
  col: totalCols[col]
118
- })
152
+ }),
153
+ mapRange: (range) => {
154
+ const rowGroups = groupConsecutive(totalRows, range.startRow, range.endRow);
155
+ const columnGroups = groupConsecutive(totalCols, range.startColumn, range.endColumn);
156
+ return rowGroups.flatMap((row) => columnGroups.map((column) => ({
157
+ startRow: row.start,
158
+ endRow: row.end,
159
+ startColumn: column.start,
160
+ endColumn: column.end
161
+ })));
162
+ },
163
+ projectRange: (range) => {
164
+ const row = projectLine(totalRows, range.startRow, range.endRow);
165
+ const column = projectLine(totalCols, range.startColumn, range.endColumn);
166
+ return row && column ? {
167
+ startRow: row.start,
168
+ endRow: row.end,
169
+ startColumn: column.start,
170
+ endColumn: column.end
171
+ } : null;
172
+ }
119
173
  };
120
174
  }
121
175
 
@@ -130,7 +184,7 @@ let SELECTION_SHAPE_DEPTH = /* @__PURE__ */ function(SELECTION_SHAPE_DEPTH) {
130
184
  }({});
131
185
  function genNormalSelectionStyle(themeService) {
132
186
  const primaryColor = themeService.getColorFromTheme("primary.600");
133
- const whiteColor = themeService.getColorFromTheme("white");
187
+ const gray0Color = themeService.getColorFromTheme("gray.0");
134
188
  const fill = new ColorKit(primaryColor).setAlpha(.07).toRgbString();
135
189
  return {
136
190
  strokeWidth: 1,
@@ -139,10 +193,10 @@ function genNormalSelectionStyle(themeService) {
139
193
  widgets: {},
140
194
  widgetSize: 6,
141
195
  widgetStrokeWidth: 1,
142
- widgetStroke: whiteColor,
196
+ widgetStroke: gray0Color,
143
197
  autofillSize: 6,
144
198
  autofillStrokeWidth: 1,
145
- autofillStroke: whiteColor,
199
+ autofillStroke: gray0Color,
146
200
  rowHeaderFill: fill,
147
201
  rowHeaderStroke: primaryColor,
148
202
  rowHeaderStrokeWidth: 1,
@@ -3069,6 +3123,7 @@ var HtmlToUSMService = class HtmlToUSMService {
3069
3123
  let value = numfmtMatch[1].trim();
3070
3124
  if (value.startsWith("\"") && value.endsWith("\"")) value = value.slice(1, -1);
3071
3125
  const decoded = decodeMsoNumberFormat(value);
3126
+ if (!numfmt.isValidFormat(decoded)) continue;
3072
3127
  selectors.split(",").forEach((sel) => {
3073
3128
  this._msoNumfmtMap.set(sel.trim(), decoded);
3074
3129
  });
@@ -4009,6 +4064,10 @@ const IMAGE_MIME_TO_EXTENSION = {
4009
4064
  [FILE__BMP_CLIPBOARD_MIME_TYPE]: "bmp"
4010
4065
  };
4011
4066
  const FORMULA_CLIPBOARD_MIME_TYPE = "web application/x-univer-sheets-formula";
4067
+ function wrapHtmlForExcel(html) {
4068
+ var _html$match;
4069
+ return `<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Excel.Sheet"><meta name="Generator" content="Univer"></head><body><!--StartFragment-->${((_html$match = html.match(/<table[\s\S]*<\/table>/)) === null || _html$match === void 0 ? void 0 : _html$match[0]) ?? html}<!--EndFragment--></body></html>`;
4070
+ }
4012
4071
  /**
4013
4072
  * This service provide hooks for sheet features to supplement content or modify behavior of clipboard.
4014
4073
  */
@@ -4103,7 +4162,7 @@ let SheetClipboardService = class SheetClipboardService extends Disposable {
4103
4162
  matrix: matrixFragment,
4104
4163
  copyType
4105
4164
  });
4106
- await this._clipboardInterfaceService.write(plain, html, formulaClipboardPayload ? { [FORMULA_CLIPBOARD_MIME_TYPE]: formulaClipboardPayload } : void 0);
4165
+ await this._clipboardInterfaceService.write(plain, wrapHtmlForExcel(html), formulaClipboardPayload ? { [FORMULA_CLIPBOARD_MIME_TYPE]: formulaClipboardPayload } : void 0);
4107
4166
  this._markSelectionService.removeAllShapes();
4108
4167
  const style = createCopyPasteSelectionStyle(this._themeService);
4109
4168
  this._copyMarkId = this._markSelectionService.addShape({
@@ -4123,7 +4182,9 @@ let SheetClipboardService = class SheetClipboardService extends Disposable {
4123
4182
  const imageIndex = types.findIndex((type) => imageMimeTypeSet.has(type));
4124
4183
  const shouldUseHTMLPaste = imageIndex === -1 || !htmlContainsImage(html);
4125
4184
  if (html && shouldUseHTMLPaste) {
4126
- if (this._platformService.isWindows && htmlIsFromExcel(html)) this._notificationService.show({
4185
+ const copyId = extractId(html);
4186
+ const isInternalCopy = Boolean(copyId && this._copyContentCache.get(copyId));
4187
+ if (this._platformService.isWindows && htmlIsFromExcel(html) && !isInternalCopy) this._notificationService.show({
4127
4188
  type: "warning",
4128
4189
  title: this._localeService.t("sheets-ui.clipboard.shortCutNotify.title"),
4129
4190
  content: this._localeService.t("sheets-ui.clipboard.shortCutNotify.useShortCutInstead")
@@ -7232,6 +7293,9 @@ let SheetsScrollRenderController = class SheetsScrollRenderController extends Di
7232
7293
  this._commandService = _commandService;
7233
7294
  this._renderManagerService = _renderManagerService;
7234
7295
  this._scrollManagerService = _scrollManagerService;
7296
+ _defineProperty(this, "_pendingWheelOffsetX", 0);
7297
+ _defineProperty(this, "_pendingWheelOffsetY", 0);
7298
+ _defineProperty(this, "_pendingWheelFrameId", null);
7235
7299
  this._initCommandListener();
7236
7300
  this._wheelEventListener();
7237
7301
  this._scrollBarEventListener();
@@ -7242,6 +7306,12 @@ let SheetsScrollRenderController = class SheetsScrollRenderController extends Di
7242
7306
  if (!scene) return;
7243
7307
  const viewMain = scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN);
7244
7308
  if (!viewMain) return;
7309
+ this.disposeWithMe(toDisposable(() => {
7310
+ if (this._pendingWheelFrameId != null) {
7311
+ cancelAnimationFrame(this._pendingWheelFrameId);
7312
+ this._pendingWheelFrameId = null;
7313
+ }
7314
+ }));
7245
7315
  this.disposeWithMe(scene.onMouseWheel$.subscribeEvent((evt, state) => {
7246
7316
  if (evt.ctrlKey || !this._contextService.getContextValue(FOCUSING_SHEET)) return;
7247
7317
  let offsetX = 0;
@@ -7257,14 +7327,15 @@ let SheetsScrollRenderController = class SheetsScrollRenderController extends Di
7257
7327
  if (absOffsetY >= absOffsetX * WHEEL_CROSS_AXIS_LOCK_RATIO) offsetX = 0;
7258
7328
  else if (absOffsetX >= absOffsetY * WHEEL_CROSS_AXIS_LOCK_RATIO) offsetY = 0;
7259
7329
  }
7260
- const targetViewportScrollX = viewMain.viewportScrollX + offsetX;
7261
- const targetViewportScrollY = viewMain.viewportScrollY + offsetY;
7262
- const { x: targetScrollX, y: targetScrollY } = viewMain.transViewportScroll2ScrollValue(targetViewportScrollX, targetViewportScrollY);
7263
- this._commandService.executeCommand(SetScrollRelativeCommand.id, {
7264
- offsetX,
7265
- offsetY
7330
+ this._pendingWheelOffsetX += offsetX;
7331
+ this._pendingWheelOffsetY += offsetY;
7332
+ if (this._pendingWheelFrameId == null) this._pendingWheelFrameId = requestAnimationFrame(() => {
7333
+ this._pendingWheelFrameId = null;
7334
+ this._flushPendingWheelScroll();
7266
7335
  });
7267
- this._context.scene.makeDirty(true);
7336
+ const targetViewportScrollX = viewMain.viewportScrollX + this._pendingWheelOffsetX;
7337
+ const targetViewportScrollY = viewMain.viewportScrollY + this._pendingWheelOffsetY;
7338
+ const { x: targetScrollX, y: targetScrollY } = viewMain.transViewportScroll2ScrollValue(targetViewportScrollX, targetViewportScrollY);
7268
7339
  const isLimitedStore = viewMain.limitedScroll(targetScrollX, targetScrollY);
7269
7340
  if (isLimitedStore && !isLimitedStore.isLimitedX && !isLimitedStore.isLimitedY) {
7270
7341
  evt.preventDefault();
@@ -7273,6 +7344,30 @@ let SheetsScrollRenderController = class SheetsScrollRenderController extends Di
7273
7344
  if (viewMain.isWheelPreventDefaultX && viewMain.isWheelPreventDefaultY) evt.preventDefault();
7274
7345
  }));
7275
7346
  }
7347
+ _flushPendingWheelScroll() {
7348
+ const offsetX = this._pendingWheelOffsetX;
7349
+ const offsetY = this._pendingWheelOffsetY;
7350
+ if (offsetX === 0 && offsetY === 0) return;
7351
+ this._pendingWheelOffsetX = 0;
7352
+ this._pendingWheelOffsetY = 0;
7353
+ const canUseScrollFastPath = this._canUseScrollFastPath();
7354
+ this._commandService.executeCommand(SetScrollRelativeCommand.id, {
7355
+ offsetX,
7356
+ offsetY
7357
+ });
7358
+ this._markSceneDirtyForScrolling(canUseScrollFastPath);
7359
+ }
7360
+ _canUseScrollFastPath() {
7361
+ var _this$_getSheetObject, _spreadsheet$getSkele;
7362
+ const { scene } = this._context;
7363
+ const spreadsheet = (_this$_getSheetObject = this._getSheetObject()) === null || _this$_getSheetObject === void 0 ? void 0 : _this$_getSheetObject.spreadsheet;
7364
+ return scene.getParent().classType === RENDER_CLASS_TYPE.ENGINE && !scene.isDirty() && spreadsheet != null && !spreadsheet.isDirty() && !spreadsheet.isForceDirty() && ((_spreadsheet$getSkele = spreadsheet.getSkeleton()) === null || _spreadsheet$getSkele === void 0 ? void 0 : _spreadsheet$getSkele.worksheet.getMergeData().length) === 0 && scene.getViewports().every((viewport) => !viewport.shouldIntoRender() || !viewport.isDirty && !viewport.isForceDirty) && scene.getLayers().every((layer) => layer.getObjectsByOrder().every((object) => !object.isDirty()));
7365
+ }
7366
+ _markSceneDirtyForScrolling(canUseScrollFastPath) {
7367
+ const { scene } = this._context;
7368
+ if (canUseScrollFastPath) scene.makeDirtyForScrolling();
7369
+ else scene.makeDirty(true);
7370
+ }
7276
7371
  _scrollBarEventListener() {
7277
7372
  const { scene } = this._context;
7278
7373
  if (scene == null) return;
@@ -7525,8 +7620,8 @@ let SheetsScrollRenderController = class SheetsScrollRenderController extends Di
7525
7620
  return getSelectionsService(this._injector);
7526
7621
  }
7527
7622
  _getViewportBounding() {
7528
- var _this$_getSheetObject, _this$_sheetSkeletonM5;
7529
- const scene = (_this$_getSheetObject = this._getSheetObject()) === null || _this$_getSheetObject === void 0 ? void 0 : _this$_getSheetObject.scene;
7623
+ var _this$_getSheetObject2, _this$_sheetSkeletonM5;
7624
+ const scene = (_this$_getSheetObject2 = this._getSheetObject()) === null || _this$_getSheetObject2 === void 0 ? void 0 : _this$_getSheetObject2.scene;
7530
7625
  if (scene == null) return;
7531
7626
  const viewport = scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN);
7532
7627
  if (viewport == null) return;
@@ -7536,10 +7631,10 @@ let SheetsScrollRenderController = class SheetsScrollRenderController extends Di
7536
7631
  return skeleton.getRangeByViewBound(vpInfo.viewBound);
7537
7632
  }
7538
7633
  _scrollToCell(row, column, forceTop = false, forceLeft = false) {
7539
- var _this$_getSheetObject2, _this$_sheetSkeletonM6;
7634
+ var _this$_getSheetObject3, _this$_sheetSkeletonM6;
7540
7635
  const { rowHeightAccumulation, columnWidthAccumulation } = this._sheetSkeletonManagerService.getCurrentSkeleton() ?? {};
7541
7636
  if (rowHeightAccumulation == null || columnWidthAccumulation == null) return false;
7542
- const scene = (_this$_getSheetObject2 = this._getSheetObject()) === null || _this$_getSheetObject2 === void 0 ? void 0 : _this$_getSheetObject2.scene;
7637
+ const scene = (_this$_getSheetObject3 = this._getSheetObject()) === null || _this$_getSheetObject3 === void 0 ? void 0 : _this$_getSheetObject3.scene;
7543
7638
  if (scene == null) return false;
7544
7639
  const viewport = scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN);
7545
7640
  if (viewport == null) return false;
@@ -8254,7 +8349,8 @@ let EditorBridgeService = class EditorBridgeService extends Disposable {
8254
8349
  sheetId,
8255
8350
  documentLayoutObject,
8256
8351
  editorUnitId: this._editorUnitId,
8257
- isInArrayFormulaRange: cell === null || cell === void 0 ? void 0 : cell.isInArrayFormulaRange
8352
+ isInArrayFormulaRange: cell === null || cell === void 0 ? void 0 : cell.isInArrayFormulaRange,
8353
+ isPercentFormat: cell === null || cell === void 0 ? void 0 : cell.isPercentFormat
8258
8354
  };
8259
8355
  }
8260
8356
  _getWorkbookForEditUnit(unitId) {
@@ -9240,867 +9336,192 @@ CellCustomRenderController = __decorate([
9240
9336
  ], CellCustomRenderController);
9241
9337
 
9242
9338
  //#endregion
9243
- //#region src/controllers/render-controllers/sheet.render-controller.ts
9244
- const FRAME_STACK_THRESHOLD = 60;
9245
- let SheetRenderController = class SheetRenderController extends RxDisposable {
9246
- constructor(_context, _configService, _sheetSkeletonManagerService, _sheetRenderService, _commandService, _telemetryService) {
9247
- super();
9248
- this._context = _context;
9249
- this._configService = _configService;
9250
- this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
9251
- this._sheetRenderService = _sheetRenderService;
9252
- this._commandService = _commandService;
9253
- this._telemetryService = _telemetryService;
9254
- _defineProperty(this, "_renderMetric$", new Subject());
9255
- _defineProperty(this, "renderMetric$", this._renderMetric$.asObservable());
9256
- _defineProperty(this, "_renderFrameTimeMetric", null);
9257
- _defineProperty(this, "_renderFrameTags", {});
9258
- _defineProperty(this, "_afterRenderMetric$", new Subject());
9259
- this._addNewRender();
9260
- this._initRenderMetricSubscriber();
9339
+ //#region src/views/hook.ts
9340
+ function useActiveWorkbook() {
9341
+ const univerInstanceService = useDependency(IUniverInstanceService);
9342
+ return useObservable(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), void 0, void 0, []) ?? null;
9343
+ }
9344
+ function useActiveWorksheet(workbook) {
9345
+ return useObservable(() => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? of(null), void 0, void 0, [workbook]);
9346
+ }
9347
+ function useWorkbooks() {
9348
+ const univerInstanceService = useDependency(IUniverInstanceService);
9349
+ return useObservable(() => {
9350
+ return merge$1([univerInstanceService.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET), univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET)]).pipe(map(() => univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET)), startWith(univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET)));
9351
+ }, [], void 0, [univerInstanceService]);
9352
+ }
9353
+
9354
+ //#endregion
9355
+ //#region src/views/clipboard/ClipboardPopupMenu.tsx
9356
+ const DEFAULT_PADDING = 2;
9357
+ const SheetPasteOptions = [
9358
+ {
9359
+ value: "DEFAULT_PASTE",
9360
+ label: "sheets-ui.rightClick.paste"
9361
+ },
9362
+ {
9363
+ value: "SPECIAL_PASTE_VALUE",
9364
+ label: "sheets-ui.rightClick.pasteValue"
9365
+ },
9366
+ {
9367
+ value: "SPECIAL_PASTE_FORMAT",
9368
+ label: "sheets-ui.rightClick.pasteFormat"
9369
+ },
9370
+ {
9371
+ value: "SPECIAL_PASTE_COL_WIDTH",
9372
+ label: "sheets-ui.rightClick.pasteColWidth"
9373
+ },
9374
+ {
9375
+ value: "SPECIAL_PASTE_BESIDES_BORDER",
9376
+ label: "sheets-ui.rightClick.pasteBesidesBorder"
9377
+ },
9378
+ {
9379
+ value: "SPECIAL_PASTE_FORMULA",
9380
+ label: "sheets-ui.rightClick.pasteFormula"
9261
9381
  }
9262
- _addNewRender() {
9263
- const { scene, engine, unit: workbook } = this._context;
9264
- this._addComponent(workbook);
9265
- this._initRerenderScheduler();
9266
- this._initCommandListener();
9267
- const worksheet = this._context.unit.getActiveSheet();
9268
- if (!worksheet) throw new Error("No active sheet found");
9269
- const sheetId = worksheet.getSheetId();
9270
- this._sheetSkeletonManagerService.setCurrent({ sheetId });
9271
- const frameFn = () => scene.render();
9272
- this.disposeWithMe(this._context.activated$.subscribe((activated) => {
9273
- if (activated) engine.runRenderLoop(frameFn);
9274
- else engine.stopRenderLoop(frameFn);
9275
- }));
9276
- }
9277
- _initRenderMetricSubscriber() {
9278
- const { engine } = this._context;
9279
- this.disposeWithMe(engine.beginFrame$.subscribe(() => {
9280
- this._renderFrameTimeMetric = null;
9281
- this._renderFrameTags = {};
9282
- }));
9283
- this.disposeWithMe(engine.endFrame$.subscribe(() => {
9284
- if (this._renderFrameTimeMetric && Object.keys(this._renderFrameTimeMetric).some((key) => key.startsWith(SHEET_EXTENSION_PREFIX))) this._afterRenderMetric$.next({
9285
- frameTimeMetric: this._renderFrameTimeMetric,
9286
- tags: this._renderFrameTags
9287
- });
9288
- }));
9289
- this.disposeWithMe(engine.renderFrameTimeMetric$.subscribe(([key, value]) => {
9290
- if (!this._renderFrameTimeMetric) this._renderFrameTimeMetric = {};
9291
- if (!this._renderFrameTimeMetric[key]) this._renderFrameTimeMetric[key] = [];
9292
- this._renderFrameTimeMetric[key].push(Math.round(value * 100) / 100);
9293
- }));
9294
- this.disposeWithMe(engine.renderFrameTags$.subscribe(([key, value]) => {
9295
- this._renderFrameTags[key] = value;
9296
- }));
9297
- const frameInfoList = [];
9298
- this.disposeWithMe(this._afterRenderMetric$.pipe(withLatestFrom(engine.endFrame$)).subscribe(([sceneRenderDetail, basicFrameTimeInfo]) => {
9299
- frameInfoList.push({
9300
- FPS: basicFrameTimeInfo.FPS,
9301
- elapsedTime: basicFrameTimeInfo.elapsedTime,
9302
- frameTime: Math.round(basicFrameTimeInfo.frameTime * 100) / 100,
9303
- ...sceneRenderDetail.frameTimeMetric,
9304
- ...sceneRenderDetail.tags
9305
- });
9306
- if (frameInfoList.length > FRAME_STACK_THRESHOLD) {
9307
- this._captureRenderMetric(frameInfoList);
9308
- frameInfoList.length = 0;
9309
- }
9310
- }));
9311
- }
9312
- /**
9313
- * Send render metric to telemetry service
9314
- * @param frameInfoList
9315
- */
9316
- _captureRenderMetric(frameInfoList) {
9317
- var _this$_telemetryServi;
9318
- const filteredFrameInfo = frameInfoList;
9319
- if (filteredFrameInfo.length === 0) return;
9320
- const sumValueForNumListFields = (data) => {
9321
- let totalSum = 0;
9322
- const sums = Object.entries(data).filter(([_, value]) => Array.isArray(value)).map(([key]) => key).reduce((acc, key) => {
9323
- acc[key] = data[key].reduce((sum, num) => sum + num, 0);
9324
- return acc;
9325
- }, {});
9326
- Object.keys(data).filter((key) => key.startsWith(SHEET_EXTENSION_PREFIX)).forEach((key) => {
9327
- totalSum += sums[key];
9328
- });
9329
- return {
9330
- ...sums,
9331
- extensionTotal: totalSum
9332
- };
9333
- };
9334
- const frameTimeListAfterSum = frameInfoList.map((info) => {
9335
- return {
9336
- ...info,
9337
- ...sumValueForNumListFields(info)
9338
- };
9339
- });
9340
- const getSummaryStats = (list) => {
9341
- return Object.entries(list[0]).filter(([key, _]) => !["elapsedTime"].includes(key)).filter(([_, value]) => typeof value === "number").map(([key]) => key).reduce((acc, key) => {
9342
- const values = list.map((obj) => obj[key]);
9343
- const max = Math.max(...values);
9344
- const min = Math.min(...values);
9345
- const avg = values.reduce((sum, val) => sum + val, 0) / values.length;
9346
- acc[key] = {
9347
- max: Math.round(max * 100) / 100,
9348
- min: Math.round(min * 100) / 100,
9349
- avg: Math.round(avg * 100) / 100
9350
- };
9351
- return acc;
9352
- }, {});
9353
- };
9354
- const summaryFrameStats = getSummaryStats(frameTimeListAfterSum);
9355
- const elapsedTimeToStart = filteredFrameInfo[filteredFrameInfo.length - 1].elapsedTime;
9356
- const telemetryData = {
9357
- sheetId: this._context.unit.getActiveSheet().getSheetId(),
9358
- unitId: this._context.unit.getUnitId(),
9359
- elapsedTimeToStart,
9360
- ...summaryFrameStats
9361
- };
9362
- this._renderMetric$.next(telemetryData);
9363
- (_this$_telemetryServi = this._telemetryService) === null || _this$_telemetryServi === void 0 || _this$_telemetryServi.capture("sheet_render_cost", telemetryData);
9364
- }
9365
- _addComponent(workbook) {
9366
- const { scene, components } = this._context;
9367
- const worksheet = workbook.getActiveSheet();
9368
- const spreadsheet = new Spreadsheet("__SpreadsheetRender__");
9369
- this._addViewport(worksheet);
9370
- const spreadsheetRowHeader = new SpreadsheetRowHeader("__SpreadsheetRowHeader__");
9371
- const spreadsheetColumnHeader = new SpreadsheetColumnHeader("__SpreadsheetColumnHeader__");
9372
- const SpreadsheetLeftTopPlaceholder = new Rect("__SpreadsheetLeftTopPlaceholder__", {
9373
- zIndex: 2,
9374
- left: -1,
9375
- top: -1,
9376
- fill: "rgb(248, 249, 250)",
9377
- stroke: "rgb(217, 217, 217)",
9378
- strokeWidth: 1
9379
- });
9380
- this._context.mainComponent = spreadsheet;
9381
- components.set("__SpreadsheetRender__", spreadsheet);
9382
- components.set("__SpreadsheetRowHeader__", spreadsheetRowHeader);
9383
- components.set("__SpreadsheetColumnHeader__", spreadsheetColumnHeader);
9384
- components.set("__SpreadsheetLeftTopPlaceholder__", SpreadsheetLeftTopPlaceholder);
9385
- scene.addObjects([spreadsheet], 0);
9386
- scene.addObjects([
9387
- spreadsheetRowHeader,
9388
- spreadsheetColumnHeader,
9389
- SpreadsheetLeftTopPlaceholder
9390
- ], 10);
9391
- scene.enableLayerCache(0, 10);
9392
- }
9393
- _initViewports(scene, rowHeader, columnHeader) {
9394
- const rowHeaderWidth = rowHeader.hidden ? 0 : rowHeader.width;
9395
- const columnHeaderHeight = columnHeader.hidden ? 0 : columnHeader.height;
9396
- const bufferEdgeX = 100;
9397
- const bufferEdgeY = 100;
9398
- const viewMain = new Viewport(SHEET_VIEWPORT_KEY.VIEW_MAIN, scene, {
9399
- left: rowHeaderWidth,
9400
- top: columnHeaderHeight,
9401
- bottom: 0,
9402
- right: 0,
9403
- isWheelPreventDefaultX: true,
9404
- allowCache: true,
9405
- bufferEdgeX,
9406
- bufferEdgeY
9407
- });
9408
- const viewMainLeftTop = new Viewport(SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP, scene, {
9409
- isWheelPreventDefaultX: true,
9410
- active: false,
9411
- allowCache: true,
9412
- bufferEdgeX: 0,
9413
- bufferEdgeY: 0
9414
- });
9415
- const viewMainLeft = new Viewport(SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT, scene, {
9416
- isWheelPreventDefaultX: true,
9417
- active: false,
9418
- allowCache: true,
9419
- bufferEdgeX: 0,
9420
- bufferEdgeY
9421
- });
9422
- const viewMainTop = new Viewport(SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP, scene, {
9423
- isWheelPreventDefaultX: true,
9424
- active: false,
9425
- allowCache: true,
9426
- bufferEdgeX,
9427
- bufferEdgeY: 0
9428
- });
9429
- const viewRowTop = new Viewport(SHEET_VIEWPORT_KEY.VIEW_ROW_TOP, scene, {
9430
- active: false,
9431
- isWheelPreventDefaultX: true
9432
- });
9433
- const viewRowBottom = new Viewport(SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM, scene, {
9434
- left: 0,
9435
- top: columnHeaderHeight,
9436
- bottom: 0,
9437
- width: rowHeaderWidth + 1,
9438
- isWheelPreventDefaultX: true
9439
- });
9440
- const viewColumnLeft = new Viewport(SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT, scene, {
9441
- active: false,
9442
- isWheelPreventDefaultX: true
9443
- });
9444
- const viewColumnRight = new Viewport(SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT, scene, {
9445
- left: rowHeaderWidth,
9446
- top: 0,
9447
- height: columnHeaderHeight + 1,
9448
- right: 0,
9449
- isWheelPreventDefaultX: true
9450
- });
9451
- return {
9452
- viewMain,
9453
- viewLeftTop: new Viewport(SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP, scene, {
9454
- left: 0,
9455
- top: 0,
9456
- width: rowHeaderWidth,
9457
- height: columnHeaderHeight,
9458
- isWheelPreventDefaultX: true
9459
- }),
9460
- viewMainLeftTop,
9461
- viewMainLeft,
9462
- viewMainTop,
9463
- viewColumnLeft,
9464
- viewRowTop,
9465
- viewRowBottom,
9466
- viewColumnRight
9467
- };
9468
- }
9469
- /**
9470
- *
9471
- * initViewport & wheel event
9472
- * +-----------------+--------------------+-------------------+
9473
- * | VIEW_LEFT_TOP | VIEW_COLUMN_LEFT | VIEW_COLUMN_RIGHT |
9474
- * +-----------------+--------------------+-------------------+
9475
- * | VIEW_ROW_TOP | VIEW_MAIN_LEFT_TOP | VIEW_MAIN_TOP |
9476
- * +-----------------+--------------------+-------------------+
9477
- * | VIEW_ROW_BOTTOM | VIEW_MAIN_LEFT | VIEW_MAIN |
9478
- * +-----------------+--------------------+-------------------+
9479
- */
9480
- _addViewport(worksheet) {
9481
- const scene = this._context.scene;
9482
- const { rowHeader, columnHeader } = worksheet.getConfig();
9483
- const { viewMain } = this._initViewports(scene, rowHeader, columnHeader);
9484
- const sheetsUIConfig = this._configService.getConfig(SHEETS_UI_PLUGIN_CONFIG_KEY);
9485
- new ScrollBar(viewMain, sheetsUIConfig === null || sheetsUIConfig === void 0 ? void 0 : sheetsUIConfig.scrollConfig);
9486
- scene.attachControl();
9487
- return viewMain;
9488
- }
9489
- _initRerenderScheduler() {
9490
- this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe((param) => {
9491
- if (!param) return null;
9492
- const { skeleton: spreadsheetSkeleton, sheetId } = param;
9493
- const workbook = this._context.unit;
9494
- const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(sheetId);
9495
- if (workbook == null || worksheet == null) return;
9496
- const { mainComponent, components } = this._context;
9497
- const spreadsheet = mainComponent;
9498
- const spreadsheetRowHeader = components.get("__SpreadsheetRowHeader__");
9499
- const spreadsheetColumnHeader = components.get("__SpreadsheetColumnHeader__");
9500
- const spreadsheetLeftTopPlaceholder = components.get("__SpreadsheetLeftTopPlaceholder__");
9501
- const leftTopPlaceholderSize = getLeftTopPlaceholderSize(spreadsheetSkeleton);
9502
- spreadsheet === null || spreadsheet === void 0 || spreadsheet.updateSkeleton(spreadsheetSkeleton);
9503
- spreadsheetRowHeader === null || spreadsheetRowHeader === void 0 || spreadsheetRowHeader.updateSkeleton(spreadsheetSkeleton);
9504
- spreadsheetColumnHeader === null || spreadsheetColumnHeader === void 0 || spreadsheetColumnHeader.updateSkeleton(spreadsheetSkeleton);
9505
- spreadsheetLeftTopPlaceholder === null || spreadsheetLeftTopPlaceholder === void 0 || spreadsheetLeftTopPlaceholder.transformByState({
9506
- width: leftTopPlaceholderSize.width,
9507
- height: leftTopPlaceholderSize.height
9508
- });
9509
- }));
9510
- }
9511
- _initCommandListener() {
9512
- this.disposeWithMe(this._commandService.onCommandExecuted((command, options) => {
9513
- const { unit: workbook } = this._context;
9514
- const { id: commandId } = command;
9515
- if (COMMAND_LISTENER_SKELETON_CHANGE.includes(commandId) || this._sheetRenderService.checkMutationShouldTriggerRerender(commandId)) {
9516
- const { unitId, subUnitId } = command.params;
9517
- const worksheet = workbook.getActiveSheet();
9518
- if (!worksheet) return;
9519
- const workbookId = this._context.unitId;
9520
- const worksheetId = worksheet.getSheetId();
9521
- if (unitId !== workbookId || subUnitId !== worksheetId) return;
9522
- this._sheetSkeletonManagerService.makeDirty({
9523
- sheetId: worksheetId,
9524
- commandId
9525
- }, true);
9526
- this._sheetSkeletonManagerService.setCurrent({
9527
- sheetId: worksheetId,
9528
- commandId
9529
- });
9530
- } else if (COMMAND_LISTENER_VALUE_CHANGE.includes(commandId)) this._sheetSkeletonManagerService.reCalculate();
9531
- if (command.type === CommandType.MUTATION) this._markUnitDirty(command, options);
9532
- }));
9533
- }
9534
- _markUnitDirty(command, options) {
9535
- if (command.id.substring(0, 3) === "doc") return;
9536
- const { mainComponent: spreadsheet, scene } = this._context;
9537
- if (command.id === SetFormulaCalculationNotificationMutation.id) {
9538
- if (command.params.stageInfo != null) return;
9539
- }
9540
- if (spreadsheet) spreadsheet.makeDirty();
9541
- scene.makeDirty();
9542
- if (!command.params) return;
9543
- const cmdParams = command.params;
9544
- const viewports = this._spreadsheetViewports(scene);
9545
- if (command.id === SetRangeValuesMutation.id && cmdParams.cellValue && !(options === null || options === void 0 ? void 0 : options.fromChangeset)) {
9546
- const dirtyRange = this._cellValueToRange(cmdParams.cellValue);
9547
- const dirtyBounds = this._rangeToBounds([dirtyRange]);
9548
- this._markViewportDirty(viewports, dirtyBounds);
9549
- spreadsheet.setDirtyArea(dirtyBounds);
9550
- }
9551
- if (command.id === MoveRangeMutation.id && cmdParams.from && cmdParams.to && !(options === null || options === void 0 ? void 0 : options.fromChangeset)) {
9552
- const fromRange = cmdParams.fromRange || this._cellValueToRange(cmdParams.from.value);
9553
- const toRange = cmdParams.toRange || this._cellValueToRange(cmdParams.to.value);
9554
- const dirtyBounds = this._rangeToBounds([fromRange, toRange]);
9555
- this._markViewportDirty(viewports, dirtyBounds);
9556
- spreadsheet.setDirtyArea(dirtyBounds);
9557
- }
9558
- }
9559
- /**
9560
- * cellValue data structure:
9561
- * {[row]: { [col]: value}}
9562
- * @param cellValue
9563
- * @returns IRange
9564
- */
9565
- _cellValueToRange(cellValue) {
9566
- const columns = [];
9567
- let minCol = 0;
9568
- let maxCol = 0;
9569
- let minRow = 0;
9570
- let maxRow = 0;
9571
- for (const [_row, columnObj] of Object.entries(cellValue)) {
9572
- for (const column in columnObj) {
9573
- columns.push(Number(column));
9574
- if (minCol > Number(column)) minCol = Number(column);
9575
- if (maxCol < Number(column)) maxCol = Number(column);
9576
- }
9577
- if (minRow > Number(_row)) minRow = Number(_row);
9578
- if (maxRow < Number(_row)) maxRow = Number(_row);
9579
- }
9580
- return {
9581
- startRow: minRow,
9582
- endRow: maxRow,
9583
- startColumn: minCol,
9584
- endColumn: maxCol
9585
- };
9586
- }
9587
- _rangeToBounds(ranges) {
9588
- const { rowHeightAccumulation, columnWidthAccumulation, rowHeaderWidth, columnHeaderHeight } = this._sheetSkeletonManagerService.getCurrentParam().skeleton;
9589
- const dirtyBounds = [];
9590
- for (const r of ranges) {
9591
- const { startRow, endRow, startColumn, endColumn } = r;
9592
- const top = startRow === 0 ? 0 : rowHeightAccumulation[startRow - 1] + columnHeaderHeight;
9593
- const bottom = rowHeightAccumulation[endRow] + columnHeaderHeight;
9594
- const left = startColumn === 0 ? 0 : columnWidthAccumulation[startColumn - 1] + rowHeaderWidth;
9595
- const right = columnWidthAccumulation[endColumn] + rowHeaderWidth;
9596
- dirtyBounds.push({
9597
- top,
9598
- left,
9599
- bottom,
9600
- right,
9601
- width: right - left,
9602
- height: bottom - top
9603
- });
9604
- }
9605
- return dirtyBounds;
9606
- }
9607
- _markViewportDirty(viewports, dirtyBounds) {
9608
- const activeViewports = viewports.filter((vp) => vp.isActive && vp.cacheBound);
9609
- for (const vp of activeViewports) for (const b of dirtyBounds) if (Rectangle.hasIntersectionBetweenTwoRect(vp.cacheBound, b)) vp.markDirty(true);
9610
- }
9611
- _spreadsheetViewports(scene) {
9612
- return scene.getViewports().filter((v) => [
9613
- "viewMain",
9614
- "viewMainLeftTop",
9615
- "viewMainTop",
9616
- "viewMainLeft"
9617
- ].includes(v.viewportKey));
9618
- }
9619
- };
9620
- SheetRenderController = __decorate([
9621
- __decorateParam(1, Inject(IConfigService)),
9622
- __decorateParam(2, Inject(SheetSkeletonManagerService)),
9623
- __decorateParam(3, Inject(SheetsRenderService)),
9624
- __decorateParam(4, ICommandService),
9625
- __decorateParam(5, Optional(ITelemetryService))
9626
- ], SheetRenderController);
9627
- function getLeftTopPlaceholderSize(skeleton) {
9628
- return {
9629
- width: skeleton.rowHeaderWidthAndMarginLeft ?? skeleton.rowHeaderWidth,
9630
- height: skeleton.columnHeaderHeightAndMarginTop ?? skeleton.columnHeaderHeight
9631
- };
9632
- }
9633
-
9634
- //#endregion
9635
- //#region src/controllers/render-controllers/skeleton.render-controller.ts
9636
- let SheetSkeletonRenderController = class SheetSkeletonRenderController extends Disposable {
9637
- constructor(_context, _sheetSkeletonManagerService, _renderManagerService) {
9638
- super();
9639
- this._context = _context;
9640
- this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
9641
- this._renderManagerService = _renderManagerService;
9642
- this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe((param) => {
9643
- this._updateSceneSize(param);
9644
- }));
9645
- }
9646
- _updateSceneSize(param) {
9647
- var _this$_renderManagerS;
9648
- if (param == null) return;
9649
- const { unitId } = this._context;
9650
- const { skeleton } = param;
9651
- const scene = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.scene;
9652
- if (skeleton == null || scene == null) return;
9653
- const { rowTotalHeight, columnTotalWidth, rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop } = skeleton;
9654
- if (!this._context.unit.getActiveSheet()) return;
9655
- scene === null || scene === void 0 || scene.transformByState({
9656
- width: rowHeaderWidthAndMarginLeft + columnTotalWidth,
9657
- height: columnHeaderHeightAndMarginTop + rowTotalHeight
9658
- });
9659
- scene.getMainViewport().setMargin(rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop);
9660
- }
9661
- };
9662
- SheetSkeletonRenderController = __decorate([__decorateParam(1, Inject(SheetSkeletonManagerService)), __decorateParam(2, IRenderManagerService)], SheetSkeletonRenderController);
9663
-
9664
- //#endregion
9665
- //#region src/services/sheet-loading-render.service.ts
9666
- const PREVIEW_UNIT_SUFFIX = "__snapshot_loading_preview__";
9667
- const PREVIEW_SCENE_PREFIX = "_UNIVER_SCENE_";
9668
- const PREVIEW_CANVAS_Z_INDEX = "9";
9669
- const ISheetLoadingRenderService = createIdentifier("sheets-ui.sheet-loading-render.service");
9670
- let SheetLoadingRenderService = class SheetLoadingRenderService extends Disposable {
9671
- constructor(_injector, _layoutService, _sheetInterceptorService, _renderManagerService) {
9672
- super();
9673
- this._injector = _injector;
9674
- this._layoutService = _layoutService;
9675
- this._sheetInterceptorService = _sheetInterceptorService;
9676
- this._renderManagerService = _renderManagerService;
9677
- _defineProperty(this, "workbook$", new BehaviorSubject(null));
9678
- _defineProperty(this, "loading$", new BehaviorSubject(false));
9679
- _defineProperty(this, "previewReady$", new BehaviorSubject(false));
9680
- _defineProperty(this, "_loadingRender", null);
9681
- _defineProperty(this, "_finalCanvasGuard", null);
9682
- _defineProperty(this, "_hiddenFinalCanvas", null);
9683
- _defineProperty(this, "_finalCanvasVisibility", "");
9684
- }
9685
- showSkeleton(workbookData, activeSheetId) {
9686
- var _this$_loadingRender;
9687
- const sourceUnitId = workbookData.id;
9688
- if (((_this$_loadingRender = this._loadingRender) === null || _this$_loadingRender === void 0 ? void 0 : _this$_loadingRender.sourceUnitId) !== sourceUnitId) {
9689
- this._disposeLoadingRender();
9690
- this.previewReady$.next(false);
9691
- this._loadingRender = {
9692
- sourceUnitId,
9693
- workbook: this._createLoadingWorkbook(workbookData, activeSheetId),
9694
- render: null
9695
- };
9696
- this.workbook$.next(this._loadingRender.workbook);
9697
- this.loading$.next(true);
9698
- this._guardFinalCanvas(sourceUnitId);
9699
- }
9700
- const worksheet = this._loadingRender.workbook.getSheetBySheetId(activeSheetId);
9701
- if (worksheet && this._loadingRender.workbook.getActiveSheet().getSheetId() !== activeSheetId) this._loadingRender.workbook.setActiveSheet(worksheet);
9702
- }
9703
- show(workbookData, activeSheetId, cellData) {
9704
- this.showSkeleton(workbookData, activeSheetId);
9705
- const loadingRender = this._loadingRender;
9706
- if (!loadingRender) return;
9707
- let shouldRender = false;
9708
- if (!loadingRender.render) {
9709
- const contentElement = this._layoutService.getContentElement();
9710
- if (!contentElement) return;
9711
- loadingRender.render = this._createLoadingRender(loadingRender.workbook, loadingRender.sourceUnitId, contentElement);
9712
- shouldRender = true;
9713
- }
9714
- const worksheet = loadingRender.workbook.getSheetBySheetId(activeSheetId);
9715
- if (!worksheet) return;
9716
- if (loadingRender.workbook.getActiveSheet().getSheetId() !== activeSheetId) {
9717
- loadingRender.workbook.setActiveSheet(worksheet);
9718
- loadingRender.render.with(SheetSkeletonManagerService).setCurrent({ sheetId: activeSheetId });
9719
- shouldRender = true;
9720
- }
9721
- if (cellData && cellData !== loadingRender.lastCellData) {
9722
- loadingRender.lastCellData = cellData;
9723
- const target = worksheet.getCellMatrix();
9724
- const getDisplayCell = this._sheetInterceptorService.fetchThroughInterceptors(INTERCEPTOR_POINT.CELL_CONTENT, InterceptorEffectEnum.Value | InterceptorEffectEnum.Style);
9725
- new ObjectMatrix(cellData).forValue((row, column, rawData) => {
9726
- const displayCell = getDisplayCell(rawData, {
9727
- unitId: loadingRender.sourceUnitId,
9728
- subUnitId: activeSheetId,
9729
- row,
9730
- col: column,
9731
- workbook: loadingRender.workbook,
9732
- worksheet,
9733
- rawData
9734
- });
9735
- target.setValue(row, column, displayCell);
9736
- });
9737
- const skeletonManager = loadingRender.render.with(SheetSkeletonManagerService);
9738
- skeletonManager.makeDirty({ sheetId: activeSheetId });
9739
- skeletonManager.reCalculate();
9740
- if (loadingRender.render.mainComponent instanceof Spreadsheet) loadingRender.render.mainComponent.makeForceDirty(true);
9741
- loadingRender.render.scene.makeDirty(true);
9742
- shouldRender = true;
9743
- }
9744
- if (shouldRender) loadingRender.render.scene.render();
9745
- if (!this.previewReady$.value) this.previewReady$.next(true);
9746
- }
9747
- async handoff(sourceUnitId, timeoutMs) {
9748
- var _this$_loadingRender2, _this$_finalCanvasGua;
9749
- if (((_this$_loadingRender2 = this._loadingRender) === null || _this$_loadingRender2 === void 0 ? void 0 : _this$_loadingRender2.sourceUnitId) !== sourceUnitId) return true;
9750
- if (!this._loadingRender.render) {
9751
- this.hide(sourceUnitId);
9752
- return true;
9753
- }
9754
- (_this$_finalCanvasGua = this._finalCanvasGuard) === null || _this$_finalCanvasGua === void 0 || _this$_finalCanvasGua.unsubscribe();
9755
- this._finalCanvasGuard = null;
9756
- try {
9757
- await firstValueFrom(this._getFinalRender$(sourceUnitId).pipe(take(1), switchMap((render) => this._waitForFinalCanvas(render).pipe(switchMap(() => {
9758
- this._hideFinalCanvas(render);
9759
- return this._requestFinalRender(render);
9760
- }))), timeout(timeoutMs)));
9761
- this.hide(sourceUnitId);
9762
- return true;
9763
- } catch {
9764
- return false;
9765
- }
9766
- }
9767
- hide(sourceUnitId) {
9768
- var _this$_loadingRender3;
9769
- if (((_this$_loadingRender3 = this._loadingRender) === null || _this$_loadingRender3 === void 0 ? void 0 : _this$_loadingRender3.sourceUnitId) !== sourceUnitId) return;
9770
- this._disposeLoadingRender();
9771
- }
9772
- dispose() {
9773
- this._disposeLoadingRender();
9774
- this.workbook$.complete();
9775
- this.loading$.complete();
9776
- this.previewReady$.complete();
9777
- super.dispose();
9778
- }
9779
- _createLoadingWorkbook(workbookData, activeSheetId) {
9780
- const previewUnitId = `${workbookData.id}${PREVIEW_UNIT_SUFFIX}`;
9781
- const workbook = this._injector.createInstance(Workbook, {
9782
- ...workbookData,
9783
- id: previewUnitId
9784
- });
9785
- const activeSheet = workbook.getSheetBySheetId(activeSheetId);
9786
- if (activeSheet) workbook.setActiveSheet(activeSheet);
9787
- return workbook;
9788
- }
9789
- _createLoadingRender(workbook, sourceUnitId, contentElement) {
9790
- const previewUnitId = workbook.getUnitId();
9791
- const { width, height } = contentElement.getBoundingClientRect();
9792
- const engine = this._injector.createInstance(Engine, previewUnitId, void 0);
9793
- const scene = new Scene(`${PREVIEW_SCENE_PREFIX}${previewUnitId}`, engine, {
9794
- width,
9795
- height
9796
- });
9797
- scene.disableObjectsEvent();
9798
- const render = this._injector.createInstance(RenderUnit, {
9799
- unit: workbook,
9800
- engine,
9801
- scene,
9802
- isMainScene: true
9803
- });
9804
- try {
9805
- render.addRenderDependencies([
9806
- [SheetSkeletonManagerService],
9807
- [SheetSkeletonRenderController],
9808
- [SheetRenderController]
9809
- ]);
9810
- const canvas = engine.getCanvas();
9811
- canvas.setId(`univer-sheet-loading-canvas_${sourceUnitId}`);
9812
- canvas.getCanvasEle().dataset.uUnitId = sourceUnitId;
9813
- canvas.getCanvasEle().style.pointerEvents = "none";
9814
- canvas.getCanvasEle().style.zIndex = PREVIEW_CANVAS_Z_INDEX;
9815
- engine.mount(contentElement);
9816
- return render;
9817
- } catch (error) {
9818
- this._disposeRender(render);
9819
- throw error;
9820
- }
9821
- }
9822
- _waitForFinalCanvas(render) {
9823
- return new Observable((subscriber) => {
9824
- let frameId;
9825
- const canvasElement = render.engine.getCanvasElement();
9826
- const checkMounted = () => {
9827
- const contentElement = this._layoutService.getContentElement();
9828
- if (contentElement && canvasElement.parentElement === contentElement && canvasElement.width > 0 && canvasElement.height > 0) {
9829
- subscriber.next();
9830
- subscriber.complete();
9831
- return;
9832
- }
9833
- frameId = window.requestAnimationFrame(checkMounted);
9834
- };
9835
- checkMounted();
9836
- return () => {
9837
- if (frameId !== void 0) window.cancelAnimationFrame(frameId);
9838
- };
9839
- });
9840
- }
9841
- _getFinalRender$(sourceUnitId) {
9842
- const existingRender = this._renderManagerService.getRenderUnitById(sourceUnitId);
9843
- return existingRender ? of(existingRender) : this._renderManagerService.created$.pipe(filter((render) => render.unitId === sourceUnitId));
9844
- }
9845
- _guardFinalCanvas(sourceUnitId) {
9846
- var _this$_finalCanvasGua2;
9847
- (_this$_finalCanvasGua2 = this._finalCanvasGuard) === null || _this$_finalCanvasGua2 === void 0 || _this$_finalCanvasGua2.unsubscribe();
9848
- this._finalCanvasGuard = this._getFinalRender$(sourceUnitId).pipe(take(1), switchMap((render) => this._waitForFinalCanvas(render).pipe(map(() => render)))).subscribe((render) => this._hideFinalCanvas(render));
9849
- }
9850
- _requestFinalRender(render) {
9851
- render.scene.makeDirty(true);
9852
- return from(render.scene.requestRender()).pipe(switchMap(() => this._waitForNextAnimationFrame()));
9853
- }
9854
- _hideFinalCanvas(render) {
9855
- const canvasElement = render.engine.getCanvasElement();
9856
- if (this._hiddenFinalCanvas === canvasElement) return;
9857
- this._restoreFinalCanvas();
9858
- this._hiddenFinalCanvas = canvasElement;
9859
- this._finalCanvasVisibility = canvasElement.style.visibility;
9860
- canvasElement.style.visibility = "hidden";
9861
- }
9862
- _restoreFinalCanvas() {
9863
- if (!this._hiddenFinalCanvas) return;
9864
- this._hiddenFinalCanvas.style.visibility = this._finalCanvasVisibility;
9865
- this._hiddenFinalCanvas = null;
9866
- this._finalCanvasVisibility = "";
9867
- }
9868
- _waitForNextAnimationFrame() {
9869
- return new Observable((subscriber) => {
9870
- const frameId = window.requestAnimationFrame(() => {
9871
- subscriber.next();
9872
- subscriber.complete();
9873
- });
9874
- return () => window.cancelAnimationFrame(frameId);
9875
- });
9876
- }
9877
- _disposeLoadingRender() {
9878
- var _this$_finalCanvasGua3;
9879
- (_this$_finalCanvasGua3 = this._finalCanvasGuard) === null || _this$_finalCanvasGua3 === void 0 || _this$_finalCanvasGua3.unsubscribe();
9880
- this._finalCanvasGuard = null;
9881
- this._restoreFinalCanvas();
9882
- const loadingRender = this._loadingRender;
9883
- this._loadingRender = null;
9884
- this.workbook$.next(null);
9885
- this.loading$.next(false);
9886
- this.previewReady$.next(false);
9887
- if (!loadingRender) return;
9888
- if (loadingRender.render) this._disposeRender(loadingRender.render);
9889
- loadingRender.workbook.dispose();
9890
- }
9891
- _disposeRender(render) {
9892
- render.components.forEach((component) => component.dispose());
9893
- render.scene.dispose();
9894
- render.dispose();
9895
- render.engine.dispose();
9896
- }
9897
- };
9898
- SheetLoadingRenderService = __decorate([
9899
- __decorateParam(0, Inject(Injector)),
9900
- __decorateParam(1, ILayoutService),
9901
- __decorateParam(2, Inject(SheetInterceptorService)),
9902
- __decorateParam(3, IRenderManagerService)
9903
- ], SheetLoadingRenderService);
9904
-
9905
- //#endregion
9906
- //#region src/views/hook.ts
9907
- const SheetLoadingWorkbookContext = createContext(null);
9908
- function useActiveWorkbook() {
9909
- const univerInstanceService = useDependency(IUniverInstanceService);
9910
- const loadingWorkbook = useContext(SheetLoadingWorkbookContext);
9911
- const workbook = useObservable(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), void 0, void 0, []);
9912
- return loadingWorkbook ?? workbook ?? null;
9913
- }
9914
- function useSheetLoadingWorkbook() {
9915
- return useObservable(useDependency(ISheetLoadingRenderService).workbook$) ?? null;
9916
- }
9917
- function useSheetLoading() {
9918
- return useObservable(useDependency(ISheetLoadingRenderService).loading$) ?? false;
9919
- }
9920
- function useSheetLoadingPreviewReady() {
9921
- return useObservable(useDependency(ISheetLoadingRenderService).previewReady$) ?? false;
9922
- }
9923
- function useActiveWorksheet(workbook) {
9924
- return useObservable(() => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? of(null), void 0, void 0, [workbook]);
9925
- }
9926
- function useWorkbooks() {
9927
- const univerInstanceService = useDependency(IUniverInstanceService);
9928
- return useObservable(() => {
9929
- return merge$1([univerInstanceService.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET), univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET)]).pipe(map(() => univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET)), startWith(univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET)));
9930
- }, [], void 0, [univerInstanceService]);
9931
- }
9932
-
9933
- //#endregion
9934
- //#region src/views/clipboard/ClipboardPopupMenu.tsx
9935
- const DEFAULT_PADDING = 2;
9936
- const SheetPasteOptions = [
9937
- {
9938
- value: "DEFAULT_PASTE",
9939
- label: "sheets-ui.rightClick.paste"
9940
- },
9941
- {
9942
- value: "SPECIAL_PASTE_VALUE",
9943
- label: "sheets-ui.rightClick.pasteValue"
9944
- },
9945
- {
9946
- value: "SPECIAL_PASTE_FORMAT",
9947
- label: "sheets-ui.rightClick.pasteFormat"
9948
- },
9949
- {
9950
- value: "SPECIAL_PASTE_COL_WIDTH",
9951
- label: "sheets-ui.rightClick.pasteColWidth"
9952
- },
9953
- {
9954
- value: "SPECIAL_PASTE_BESIDES_BORDER",
9955
- label: "sheets-ui.rightClick.pasteBesidesBorder"
9956
- },
9957
- {
9958
- value: "SPECIAL_PASTE_FORMULA",
9959
- label: "sheets-ui.rightClick.pasteFormula"
9960
- }
9961
- ];
9962
- const useMenuPosition = (range) => {
9963
- var _scene$getEngine;
9964
- const univerInstanceService = useDependency(IUniverInstanceService);
9965
- const renderManagerService = useDependency(IRenderManagerService);
9966
- const workbook = useActiveWorkbook();
9967
- if (!range || !workbook) return null;
9968
- const anchor = {
9969
- startRow: range.rows[0],
9970
- startCol: range.cols[0],
9971
- endRow: range.rows[range.rows.length - 1],
9972
- endCol: range.cols[range.cols.length - 1]
9973
- };
9974
- if (anchor.endRow < 0 || anchor.endCol < 0) return null;
9975
- const ru = renderManagerService.getRenderUnitById(workbook.getUnitId());
9976
- const sheetSkeletonManagerService = ru === null || ru === void 0 ? void 0 : ru.with(SheetSkeletonManagerService);
9977
- const sheetObject = getSheetObject(univerInstanceService, renderManagerService);
9978
- if (!sheetObject) return null;
9979
- const { scene } = sheetObject;
9980
- const skeleton = sheetSkeletonManagerService === null || sheetSkeletonManagerService === void 0 ? void 0 : sheetSkeletonManagerService.getCurrentSkeleton();
9981
- const viewport = getViewportByCell(anchor.endRow, anchor.endCol, scene, workbook.getActiveSheet());
9982
- if (!viewport) return null;
9983
- const scaleX = scene === null || scene === void 0 ? void 0 : scene.scaleX;
9984
- const scaleY = scene === null || scene === void 0 ? void 0 : scene.scaleY;
9985
- const scrollXY = scene === null || scene === void 0 ? void 0 : scene.getViewportScrollXY(viewport);
9986
- const canvas = (_scene$getEngine = scene.getEngine()) === null || _scene$getEngine === void 0 ? void 0 : _scene$getEngine.getCanvas();
9987
- if (!scaleX || !scene || !scaleX || !scaleY || !scrollXY) return null;
9988
- const endPosition = skeleton === null || skeleton === void 0 ? void 0 : skeleton.getNoMergeCellWithCoordByIndex(anchor.endRow, anchor.endCol);
9989
- const endX = (endPosition === null || endPosition === void 0 ? void 0 : endPosition.endX) ?? 0;
9990
- const endY = (endPosition === null || endPosition === void 0 ? void 0 : endPosition.endY) ?? 0;
9991
- const positionEndX = convertTransformToOffsetX(endX, scaleX, scrollXY) ?? -9999;
9992
- const positionEndY = convertTransformToOffsetY(endY, scaleY, scrollXY) ?? -9999;
9993
- const canvasWidth = canvas === null || canvas === void 0 ? void 0 : canvas.getWidth();
9994
- const canvasHeight = canvas === null || canvas === void 0 ? void 0 : canvas.getHeight();
9995
- if (!canvasWidth || !canvasHeight) return null;
9996
- const XInSideView = positionEndX + 50 <= canvasWidth;
9997
- const YInSideView = positionEndY + 50 <= canvasHeight;
9998
- let positionX = positionEndX;
9999
- let positionY = positionEndY;
10000
- if (!XInSideView) positionX = canvasWidth - 100;
10001
- if (!YInSideView) positionY = canvasHeight - 100;
10002
- return {
10003
- positionX,
10004
- positionY
10005
- };
10006
- };
10007
- const ClipboardPopupMenu = () => {
10008
- const clipboardService = useDependency(ISheetClipboardService);
10009
- const showMenu = useObservable(clipboardService.showMenu$, false);
10010
- const pasteOptionsCache = useObservable(clipboardService.pasteOptionsCache$, null);
10011
- const localeService = useDependency(LocaleService);
10012
- const commandService = useDependency(ICommandService);
10013
- const [menuHovered, setMenuHovered] = useState(false);
10014
- const [visible, setVisible] = useState(false);
10015
- const range = pasteOptionsCache === null || pasteOptionsCache === void 0 ? void 0 : pasteOptionsCache.target.pastedRange;
10016
- const relativePosition = useMenuPosition(range);
10017
- if (!relativePosition || !showMenu) return null;
10018
- if (relativePosition.positionX < 50 || relativePosition.positionY < 30) return null;
10019
- const showMore = menuHovered || visible;
10020
- const handleClick = (type) => {
10021
- setVisible(false);
10022
- commandService.executeCommand(SheetOptionalPasteCommand.id, { type });
10023
- };
10024
- return /* @__PURE__ */ jsx("div", {
10025
- className: "univer-absolute univer-inset-0 univer-z-10 univer-size-0",
10026
- children: /* @__PURE__ */ jsx("div", {
10027
- className: "univer-absolute",
10028
- style: {
10029
- left: relativePosition.positionX + DEFAULT_PADDING,
10030
- top: relativePosition.positionY + DEFAULT_PADDING
10031
- },
10032
- onMouseEnter: () => setMenuHovered(true),
10033
- onMouseLeave: () => setMenuHovered(false),
10034
- children: /* @__PURE__ */ jsx(DropdownMenu, {
10035
- align: "start",
10036
- items: SheetPasteOptions.map((item) => ({
10037
- type: "checkbox",
10038
- value: item.value,
10039
- label: localeService.t(item.label),
10040
- checked: (pasteOptionsCache === null || pasteOptionsCache === void 0 ? void 0 : pasteOptionsCache.pasteType) === PREDEFINED_HOOK_NAME_PASTE[item.value],
10041
- onSelect: () => handleClick(item.value)
10042
- })),
10043
- open: visible,
10044
- onOpenChange: setVisible,
10045
- children: /* @__PURE__ */ jsxs("div", {
10046
- className: clsx("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800", borderClassName, {
10047
- "univer-bg-gray-100 dark:!univer-bg-gray-800": visible,
10048
- "univer-bg-white dark:!univer-bg-gray-900": !visible
10049
- }),
10050
- children: [/* @__PURE__ */ jsx(PasteSpecialDoubleIcon, { className: "univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white" }), showMore && /* @__PURE__ */ jsx(MoreDownIcon, { className: "dark:!univer-text-white" })]
10051
- })
10052
- })
10053
- })
10054
- });
10055
- };
10056
-
10057
- //#endregion
10058
- //#region src/controllers/clipboard/const.ts
10059
- /**
10060
- * Copyright 2023-present DreamNum Co., Ltd.
10061
- *
10062
- * Licensed under the Apache License, Version 2.0 (the "License");
10063
- * you may not use this file except in compliance with the License.
10064
- * You may obtain a copy of the License at
10065
- *
10066
- * http://www.apache.org/licenses/LICENSE-2.0
10067
- *
10068
- * Unless required by applicable law or agreed to in writing, software
10069
- * distributed under the License is distributed on an "AS IS" BASIS,
10070
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10071
- * See the License for the specific language governing permissions and
10072
- * limitations under the License.
10073
- */
10074
- const RemovePasteMenuCommands = [
10075
- SetCellEditVisibleOperation.id,
10076
- SetRangeValuesCommand.id,
10077
- SetZoomRatioOperation.id,
10078
- MoveRangeMutation.id,
10079
- RemoveRowMutation.id,
10080
- RemoveColMutation.id,
10081
- InsertRowMutation.id,
10082
- InsertColMutation.id,
10083
- MoveRowsMutation.id,
10084
- MoveColsMutation.id,
10085
- SetWorksheetColWidthMutation.id,
10086
- SetWorksheetRowHeightMutation.id,
10087
- SetSelectionsOperation.id,
10088
- UndoCommandId
10089
- ];
10090
-
10091
- //#endregion
10092
- //#region src/services/editor/cell-editor-manager.service.ts
10093
- var CellEditorManagerService = class {
10094
- constructor() {
10095
- _defineProperty(this, "_state", null);
10096
- _defineProperty(this, "_rect", null);
10097
- _defineProperty(this, "_state$", new BehaviorSubject(null));
10098
- _defineProperty(this, "state$", this._state$.asObservable());
10099
- _defineProperty(this, "_rect$", new BehaviorSubject(null));
10100
- _defineProperty(this, "rect$", this._rect$.asObservable());
10101
- _defineProperty(this, "_focus", false);
10102
- _defineProperty(this, "_focus$", new BehaviorSubject(this._focus));
10103
- _defineProperty(this, "focus$", this._focus$.asObservable());
9382
+ ];
9383
+ const useMenuPosition = (range) => {
9384
+ var _scene$getEngine;
9385
+ const univerInstanceService = useDependency(IUniverInstanceService);
9386
+ const renderManagerService = useDependency(IRenderManagerService);
9387
+ const workbook = useActiveWorkbook();
9388
+ if (!range || !workbook) return null;
9389
+ const anchor = {
9390
+ startRow: range.rows[0],
9391
+ startCol: range.cols[0],
9392
+ endRow: range.rows[range.rows.length - 1],
9393
+ endCol: range.cols[range.cols.length - 1]
9394
+ };
9395
+ if (anchor.endRow < 0 || anchor.endCol < 0) return null;
9396
+ const ru = renderManagerService.getRenderUnitById(workbook.getUnitId());
9397
+ const sheetSkeletonManagerService = ru === null || ru === void 0 ? void 0 : ru.with(SheetSkeletonManagerService);
9398
+ const sheetObject = getSheetObject(univerInstanceService, renderManagerService);
9399
+ if (!sheetObject) return null;
9400
+ const { scene } = sheetObject;
9401
+ const skeleton = sheetSkeletonManagerService === null || sheetSkeletonManagerService === void 0 ? void 0 : sheetSkeletonManagerService.getCurrentSkeleton();
9402
+ const viewport = getViewportByCell(anchor.endRow, anchor.endCol, scene, workbook.getActiveSheet());
9403
+ if (!viewport) return null;
9404
+ const scaleX = scene === null || scene === void 0 ? void 0 : scene.scaleX;
9405
+ const scaleY = scene === null || scene === void 0 ? void 0 : scene.scaleY;
9406
+ const scrollXY = scene === null || scene === void 0 ? void 0 : scene.getViewportScrollXY(viewport);
9407
+ const canvas = (_scene$getEngine = scene.getEngine()) === null || _scene$getEngine === void 0 ? void 0 : _scene$getEngine.getCanvas();
9408
+ if (!scaleX || !scene || !scaleX || !scaleY || !scrollXY) return null;
9409
+ const endPosition = skeleton === null || skeleton === void 0 ? void 0 : skeleton.getNoMergeCellWithCoordByIndex(anchor.endRow, anchor.endCol);
9410
+ const endX = (endPosition === null || endPosition === void 0 ? void 0 : endPosition.endX) ?? 0;
9411
+ const endY = (endPosition === null || endPosition === void 0 ? void 0 : endPosition.endY) ?? 0;
9412
+ const positionEndX = convertTransformToOffsetX(endX, scaleX, scrollXY) ?? -9999;
9413
+ const positionEndY = convertTransformToOffsetY(endY, scaleY, scrollXY) ?? -9999;
9414
+ const canvasWidth = canvas === null || canvas === void 0 ? void 0 : canvas.getWidth();
9415
+ const canvasHeight = canvas === null || canvas === void 0 ? void 0 : canvas.getHeight();
9416
+ if (!canvasWidth || !canvasHeight) return null;
9417
+ const XInSideView = positionEndX + 50 <= canvasWidth;
9418
+ const YInSideView = positionEndY + 50 <= canvasHeight;
9419
+ let positionX = positionEndX;
9420
+ let positionY = positionEndY;
9421
+ if (!XInSideView) positionX = canvasWidth - 100;
9422
+ if (!YInSideView) positionY = canvasHeight - 100;
9423
+ return {
9424
+ positionX,
9425
+ positionY
9426
+ };
9427
+ };
9428
+ const ClipboardPopupMenu = () => {
9429
+ const clipboardService = useDependency(ISheetClipboardService);
9430
+ const showMenu = useObservable(clipboardService.showMenu$, false);
9431
+ const pasteOptionsCache = useObservable(clipboardService.pasteOptionsCache$, null);
9432
+ const localeService = useDependency(LocaleService);
9433
+ const commandService = useDependency(ICommandService);
9434
+ const [menuHovered, setMenuHovered] = useState(false);
9435
+ const [visible, setVisible] = useState(false);
9436
+ const range = pasteOptionsCache === null || pasteOptionsCache === void 0 ? void 0 : pasteOptionsCache.target.pastedRange;
9437
+ const relativePosition = useMenuPosition(range);
9438
+ if (!relativePosition || !showMenu) return null;
9439
+ if (relativePosition.positionX < 50 || relativePosition.positionY < 30) return null;
9440
+ const showMore = menuHovered || visible;
9441
+ const handleClick = (type) => {
9442
+ setVisible(false);
9443
+ commandService.executeCommand(SheetOptionalPasteCommand.id, { type });
9444
+ };
9445
+ return /* @__PURE__ */ jsx("div", {
9446
+ className: "univer-absolute univer-inset-0 univer-z-10 univer-size-0",
9447
+ children: /* @__PURE__ */ jsx("div", {
9448
+ className: "univer-absolute",
9449
+ style: {
9450
+ left: relativePosition.positionX + DEFAULT_PADDING,
9451
+ top: relativePosition.positionY + DEFAULT_PADDING
9452
+ },
9453
+ onMouseEnter: () => setMenuHovered(true),
9454
+ onMouseLeave: () => setMenuHovered(false),
9455
+ children: /* @__PURE__ */ jsx(DropdownMenu, {
9456
+ align: "start",
9457
+ items: SheetPasteOptions.map((item) => ({
9458
+ type: "checkbox",
9459
+ value: item.value,
9460
+ label: localeService.t(item.label),
9461
+ checked: (pasteOptionsCache === null || pasteOptionsCache === void 0 ? void 0 : pasteOptionsCache.pasteType) === PREDEFINED_HOOK_NAME_PASTE[item.value],
9462
+ onSelect: () => handleClick(item.value)
9463
+ })),
9464
+ open: visible,
9465
+ onOpenChange: setVisible,
9466
+ children: /* @__PURE__ */ jsxs("div", {
9467
+ className: clsx("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800", borderClassName, {
9468
+ "univer-bg-gray-100 dark:!univer-bg-gray-800": visible,
9469
+ "univer-bg-gray-0 dark:!univer-bg-gray-900": !visible
9470
+ }),
9471
+ children: [/* @__PURE__ */ jsx(PasteSpecialDoubleIcon, { className: "univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-gray-0" }), showMore && /* @__PURE__ */ jsx(MoreDownIcon, { className: "dark:!univer-text-gray-0" })]
9472
+ })
9473
+ })
9474
+ })
9475
+ });
9476
+ };
9477
+
9478
+ //#endregion
9479
+ //#region src/controllers/clipboard/const.ts
9480
+ /**
9481
+ * Copyright 2023-present DreamNum Co., Ltd.
9482
+ *
9483
+ * Licensed under the Apache License, Version 2.0 (the "License");
9484
+ * you may not use this file except in compliance with the License.
9485
+ * You may obtain a copy of the License at
9486
+ *
9487
+ * http://www.apache.org/licenses/LICENSE-2.0
9488
+ *
9489
+ * Unless required by applicable law or agreed to in writing, software
9490
+ * distributed under the License is distributed on an "AS IS" BASIS,
9491
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9492
+ * See the License for the specific language governing permissions and
9493
+ * limitations under the License.
9494
+ */
9495
+ const RemovePasteMenuCommands = [
9496
+ SetCellEditVisibleOperation.id,
9497
+ SetRangeValuesCommand.id,
9498
+ SetZoomRatioOperation.id,
9499
+ MoveRangeMutation.id,
9500
+ RemoveRowMutation.id,
9501
+ RemoveColMutation.id,
9502
+ InsertRowMutation.id,
9503
+ InsertColMutation.id,
9504
+ MoveRowsMutation.id,
9505
+ MoveColsMutation.id,
9506
+ SetWorksheetColWidthMutation.id,
9507
+ SetWorksheetRowHeightMutation.id,
9508
+ SetSelectionsOperation.id,
9509
+ UndoCommandId
9510
+ ];
9511
+
9512
+ //#endregion
9513
+ //#region src/services/editor/cell-editor-manager.service.ts
9514
+ var CellEditorManagerService = class {
9515
+ constructor() {
9516
+ _defineProperty(this, "_state", null);
9517
+ _defineProperty(this, "_rect", null);
9518
+ _defineProperty(this, "_state$", new BehaviorSubject(null));
9519
+ _defineProperty(this, "state$", this._state$.asObservable());
9520
+ _defineProperty(this, "_rect$", new BehaviorSubject(null));
9521
+ _defineProperty(this, "rect$", this._rect$.asObservable());
9522
+ _defineProperty(this, "_focus", false);
9523
+ _defineProperty(this, "_focus$", new BehaviorSubject(this._focus));
9524
+ _defineProperty(this, "focus$", this._focus$.asObservable());
10104
9525
  }
10105
9526
  dispose() {
10106
9527
  this._state$.complete();
@@ -10568,7 +9989,9 @@ let EditorBridgeRenderController = class EditorBridgeRenderController extends Rx
10568
9989
  if (!sheetObject) return;
10569
9990
  const { spreadsheet, spreadsheetColumnHeader, spreadsheetLeftTopPlaceholder, spreadsheetRowHeader } = sheetObject;
10570
9991
  d.add(spreadsheet.onDblclick$.subscribeEvent((evt) => {
9992
+ var _this$_editorBridgeSe;
10571
9993
  if (evt.button === 2) return;
9994
+ if (isCellImage((_this$_editorBridgeSe = this._editorBridgeService.getEditCellState()) === null || _this$_editorBridgeSe === void 0 || (_this$_editorBridgeSe = _this$_editorBridgeSe.documentLayoutObject.documentModel) === null || _this$_editorBridgeSe === void 0 ? void 0 : _this$_editorBridgeSe.getSnapshot())) return;
10572
9995
  this._commandService.executeCommand(SetCellEditVisibleOperation.id, {
10573
9996
  visible: true,
10574
9997
  eventType: DeviceInputEventType.Dblclick,
@@ -10599,25 +10022,25 @@ let EditorBridgeRenderController = class EditorBridgeRenderController extends Rx
10599
10022
  _initialKeyboardListener(d) {
10600
10023
  let disposable = null;
10601
10024
  const addEvent = (render) => {
10025
+ disposable === null || disposable === void 0 || disposable.dispose();
10026
+ disposable = null;
10602
10027
  const docSelectionRenderService = render.with(DocSelectionRenderService);
10603
- if (docSelectionRenderService) {
10604
- disposable = toDisposable(docSelectionRenderService.onInputBefore$.subscribe((config) => {
10605
- var _this$_embedRuntimeFo;
10606
- if (!this._isCurrentSheetFocused()) return;
10607
- const isFocusFormulaEditor = this._contextService.getContextValue(FOCUSING_FX_BAR_EDITOR);
10608
- const isFocusSheets = this._contextService.getContextValue(FOCUSING_SHEET) || ((_this$_embedRuntimeFo = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo === void 0 ? void 0 : _this$_embedRuntimeFo.isChildUnitInActiveSession(this._context.unitId)) === true;
10609
- const unitId = render.unitId;
10610
- if (this._editorBridgeService.isVisible().visible) return;
10611
- if (unitId && isFocusSheets && !isFocusFormulaEditor) this._showEditorByKeyboard(config);
10612
- }));
10613
- d.add(disposable);
10614
- }
10028
+ if (docSelectionRenderService) disposable = toDisposable(docSelectionRenderService.onInputBefore$.subscribe((config) => {
10029
+ var _this$_embedRuntimeFo;
10030
+ if (!this._isCurrentSheetFocused()) return;
10031
+ const isFocusFormulaEditor = this._contextService.getContextValue(FOCUSING_FX_BAR_EDITOR);
10032
+ const isFocusSheets = this._contextService.getContextValue(FOCUSING_SHEET) || ((_this$_embedRuntimeFo = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo === void 0 ? void 0 : _this$_embedRuntimeFo.isChildUnitInActiveSession(this._context.unitId)) === true;
10033
+ const unitId = render.unitId;
10034
+ if (this._editorBridgeService.isVisible().visible) return;
10035
+ if (unitId && isFocusSheets && !isFocusFormulaEditor) this._showEditorByKeyboard(config);
10036
+ }));
10615
10037
  };
10616
10038
  const render = this._renderManagerService.getRenderUnitById(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
10617
10039
  if (render) addEvent(render);
10618
- else this.disposeWithMe(this._renderManagerService.created$.pipe(filter((render) => render.unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY)).subscribe((render) => {
10040
+ d.add(this._renderManagerService.created$.pipe(filter((render) => render.unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY)).subscribe(addEvent));
10041
+ d.add(toDisposable(() => {
10619
10042
  disposable === null || disposable === void 0 || disposable.dispose();
10620
- addEvent(render);
10043
+ disposable = null;
10621
10044
  }));
10622
10045
  }
10623
10046
  _initSheetFocusListener(d) {
@@ -10664,9 +10087,9 @@ let EditorBridgeRenderController = class EditorBridgeRenderController extends Rx
10664
10087
  this._hideEditor();
10665
10088
  }
10666
10089
  _isEmbeddedFormulaEditorActive() {
10667
- var _this$_embedRuntimeFo2, _this$_editorBridgeSe;
10090
+ var _this$_embedRuntimeFo2, _this$_editorBridgeSe2;
10668
10091
  if (((_this$_embedRuntimeFo2 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo2 === void 0 ? void 0 : _this$_embedRuntimeFo2.isChildUnitInActiveSession(this._context.unitId)) !== true) return false;
10669
- const dataStream = (_this$_editorBridgeSe = this._editorBridgeService.getEditCellState()) === null || _this$_editorBridgeSe === void 0 || (_this$_editorBridgeSe = _this$_editorBridgeSe.documentLayoutObject.documentModel) === null || _this$_editorBridgeSe === void 0 || (_this$_editorBridgeSe = _this$_editorBridgeSe.getSnapshot().body) === null || _this$_editorBridgeSe === void 0 ? void 0 : _this$_editorBridgeSe.dataStream;
10092
+ const dataStream = (_this$_editorBridgeSe2 = this._editorBridgeService.getEditCellState()) === null || _this$_editorBridgeSe2 === void 0 || (_this$_editorBridgeSe2 = _this$_editorBridgeSe2.documentLayoutObject.documentModel) === null || _this$_editorBridgeSe2 === void 0 || (_this$_editorBridgeSe2 = _this$_editorBridgeSe2.getSnapshot().body) === null || _this$_editorBridgeSe2 === void 0 ? void 0 : _this$_editorBridgeSe2.dataStream;
10670
10093
  return typeof dataStream === "string" && dataStream.startsWith("=");
10671
10094
  }
10672
10095
  _isCurrentEmbedRuntimeEvent(evt) {
@@ -11366,8 +10789,29 @@ const isRangeSelector = (unitId) => {
11366
10789
  //#endregion
11367
10790
  //#region src/controllers/editor/editing.render-controller.ts
11368
10791
  const HIDDEN_EDITOR_POSITION$1 = -1e3;
10792
+ function getPercentOffset(editCellState, dataStream) {
10793
+ if (!editCellState.isPercentFormat || editCellState.isInArrayFormulaRange) return null;
10794
+ const percentSuffix = `%${DEFAULT_EMPTY_DOCUMENT_VALUE}`;
10795
+ return (dataStream === null || dataStream === void 0 ? void 0 : dataStream.endsWith(percentSuffix)) ? dataStream.length - percentSuffix.length : null;
10796
+ }
10797
+ function getPercentEditorSelection(editCellState, visibleParam, dataStream) {
10798
+ const percentOffset = getPercentOffset(editCellState, dataStream);
10799
+ if (percentOffset == null) return null;
10800
+ const { eventType, initialValue, keycode } = visibleParam;
10801
+ if (eventType === DeviceInputEventType.Dblclick || eventType === DeviceInputEventType.Keyboard && keycode === KeyCode.F2) return {
10802
+ startOffset: percentOffset,
10803
+ endOffset: percentOffset,
10804
+ collapsed: true
10805
+ };
10806
+ if (eventType !== DeviceInputEventType.Keyboard || keycode === KeyCode.BACKSPACE || keycode === KeyCode.DELETE || !/^\d/.test(initialValue ?? "")) return null;
10807
+ return {
10808
+ startOffset: 0,
10809
+ endOffset: percentOffset,
10810
+ collapsed: false
10811
+ };
10812
+ }
11369
10813
  let EditingRenderController = class EditingRenderController extends Disposable {
11370
- constructor(_undoRedoService, _contextService, _renderManagerService, _editorBridgeService, _cellEditorManagerService, _lexerTreeBuilder, _functionService, _textSelectionManagerService, _commandService, _localService, _editorService, _univerInstanceService, _sheetInterceptorService, _sheetCellEditorResizeService, _selectionManagerService, _configService) {
10814
+ constructor(_undoRedoService, _contextService, _renderManagerService, _editorBridgeService, _cellEditorManagerService, _lexerTreeBuilder, _functionService, _textSelectionManagerService, _commandService, _localService, _editorService, _univerInstanceService, _sheetInterceptorService, _sheetCellEditorResizeService, _selectionManagerService, _configService, _docStateChangeManagerService) {
11371
10815
  super();
11372
10816
  this._undoRedoService = _undoRedoService;
11373
10817
  this._contextService = _contextService;
@@ -11385,6 +10829,7 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11385
10829
  this._sheetCellEditorResizeService = _sheetCellEditorResizeService;
11386
10830
  this._selectionManagerService = _selectionManagerService;
11387
10831
  this._configService = _configService;
10832
+ this._docStateChangeManagerService = _docStateChangeManagerService;
11388
10833
  _defineProperty(this, "_cursorChange", 0);
11389
10834
  _defineProperty(this, "_editingUnit", "");
11390
10835
  _defineProperty(this, "_submitEmptyCellImageEdit", false);
@@ -11459,6 +10904,7 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11459
10904
  const docSelectionRenderManager = (_this$_renderManagerS2 = this._renderManagerService.getRenderUnitById(docUnitId)) === null || _this$_renderManagerS2 === void 0 ? void 0 : _this$_renderManagerS2.with(DocSelectionRenderService);
11460
10905
  if (!docSelectionRenderManager) return;
11461
10906
  docSelectionRenderManager.sync();
10907
+ this._cacheEmptyCellTextStyle();
11462
10908
  }));
11463
10909
  }
11464
10910
  _initSkeletonListener(d) {
@@ -11539,6 +10985,30 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11539
10985
  * Listen to document edits to refresh the size of the sheet editor, not for normal editor.
11540
10986
  */
11541
10987
  _commandExecutedListener(d) {
10988
+ d.add(this._commandService.beforeCommandExecuted((command) => {
10989
+ var _this$_getDocumentDat;
10990
+ if (command.id !== InsertTextCommand.id) return;
10991
+ const params = command.params;
10992
+ const visibleParam = this._editorBridgeService.isVisible();
10993
+ const editCellState = this._editorBridgeService.getEditLocation();
10994
+ if (params.unitId !== DOCS_NORMAL_EDITOR_UNIT_ID_KEY || !visibleParam.visible || editCellState == null) return;
10995
+ const dataStream = (_this$_getDocumentDat = this._getDocumentDataModel()) === null || _this$_getDocumentDat === void 0 || (_this$_getDocumentDat = _this$_getDocumentDat.getBody()) === null || _this$_getDocumentDat === void 0 ? void 0 : _this$_getDocumentDat.dataStream;
10996
+ if (dataStream == null) return;
10997
+ const percentOffset = getPercentOffset(editCellState, dataStream);
10998
+ if (percentOffset != null && !this._editorBridgeService.getEditorDirty() && visibleParam.eventType === DeviceInputEventType.Keyboard && /^\d/.test(visibleParam.initialValue ?? "") && /^\d/.test(params.body.dataStream)) {
10999
+ params.range = {
11000
+ startOffset: 0,
11001
+ endOffset: percentOffset,
11002
+ collapsed: false
11003
+ };
11004
+ return;
11005
+ }
11006
+ if (percentOffset != null && params.body.dataStream === "%" && params.range.collapsed && params.range.startOffset === percentOffset && params.range.endOffset === percentOffset) params.range = {
11007
+ ...params.range,
11008
+ endOffset: percentOffset + 1,
11009
+ collapsed: false
11010
+ };
11011
+ }));
11542
11012
  d.add(this._commandService.onCommandExecuted((command) => {
11543
11013
  if (command.id === RichTextEditingMutation.id) {
11544
11014
  const { unitId: commandUnitId } = command.params;
@@ -11571,12 +11041,13 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11571
11041
  }));
11572
11042
  }
11573
11043
  _handleEditorVisible(param) {
11574
- var _this$_sheetCellEdito4, _this$_renderManagerS5;
11044
+ var _this$_sheetCellEdito4, _documentDataModel$ge, _this$_renderManagerS5;
11575
11045
  const { eventType, keycode } = param;
11576
11046
  this._cursorChange = eventType === DeviceInputEventType.PointerDown || eventType === DeviceInputEventType.Dblclick ? 2 : 1;
11577
11047
  const editCellState = this._editorBridgeService.getEditLocation();
11578
11048
  if (editCellState == null) return;
11579
11049
  const { unitId, isInArrayFormulaRange = false } = editCellState;
11050
+ this._clearEditorHistory();
11580
11051
  this._commandService.syncExecuteCommand(ScrollToRangeOperation.id, {
11581
11052
  unitId,
11582
11053
  range: {
@@ -11616,35 +11087,51 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11616
11087
  subUnitId: DOCS_NORMAL_EDITOR_UNIT_ID_KEY
11617
11088
  });
11618
11089
  };
11090
+ const replaceSelection = (selection) => {
11091
+ this._textSelectionManagerService.replaceDocRanges([selection], {
11092
+ unitId: DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
11093
+ subUnitId: DOCS_NORMAL_EDITOR_UNIT_ID_KEY
11094
+ });
11095
+ };
11096
+ const percentSelection = getPercentEditorSelection(editCellState, param, (_documentDataModel$ge = documentDataModel.getBody()) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.dataStream);
11619
11097
  const cellImage = isCellImage(documentDataModel.getSnapshot());
11620
11098
  this._submitEmptyCellImageEdit = cellImage && eventType === DeviceInputEventType.Keyboard && keycode === KeyCode.BACKSPACE;
11621
11099
  if (cellImage) clearAndEdit();
11622
11100
  else if (eventType === DeviceInputEventType.Keyboard && keycode === KeyCode.F2) {
11623
- var _documentDataModel$ge;
11101
+ var _documentDataModel$ge2;
11624
11102
  document.makeDirty();
11625
11103
  this._textSelectionManagerService.replaceDocRanges([{
11626
11104
  startOffset: 0,
11627
11105
  endOffset: 0
11628
11106
  }]);
11629
- const endOffset = (((_documentDataModel$ge = documentDataModel.getBody()) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.dataStream.length) ?? 2) - 2;
11630
- this._textSelectionManagerService.replaceDocRanges([{
11107
+ const endOffset = (((_documentDataModel$ge2 = documentDataModel.getBody()) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.dataStream.length) ?? 2) - 2;
11108
+ if (percentSelection) replaceSelection(percentSelection);
11109
+ else this._textSelectionManagerService.replaceDocRanges([{
11631
11110
  startOffset: endOffset,
11632
11111
  endOffset
11633
11112
  }], {
11634
11113
  unitId: DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
11635
11114
  subUnitId: DOCS_NORMAL_EDITOR_UNIT_ID_KEY
11636
11115
  });
11637
- } else if (eventType === DeviceInputEventType.Keyboard || eventType === DeviceInputEventType.Dblclick && isInArrayFormulaRange) clearAndEdit();
11116
+ } else if (eventType === DeviceInputEventType.Keyboard || eventType === DeviceInputEventType.Dblclick && isInArrayFormulaRange) if (percentSelection) replaceSelection(percentSelection);
11117
+ else clearAndEdit();
11638
11118
  else if (eventType === DeviceInputEventType.Dblclick) {
11639
11119
  if (this._contextService.getContextValue(FOCUSING_EDITOR_INPUT_FORMULA)) return;
11640
11120
  const cursor = documentDataModel.getBody().dataStream.length - 2 || 0;
11641
- this._textSelectionManagerService.replaceDocRanges([{
11121
+ if (percentSelection) replaceSelection(percentSelection);
11122
+ else this._textSelectionManagerService.replaceDocRanges([{
11642
11123
  startOffset: cursor,
11643
11124
  endOffset: cursor
11644
11125
  }]);
11645
11126
  }
11646
11127
  (_this$_renderManagerS5 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS5 === void 0 || _this$_renderManagerS5.scene.resetCursor();
11647
11128
  }
11129
+ _cacheEmptyCellTextStyle() {
11130
+ var _this$_editorBridgeSe, _sourceBody$textRuns;
11131
+ const sourceBody = (_this$_editorBridgeSe = this._editorBridgeService.getEditLocation()) === null || _this$_editorBridgeSe === void 0 || (_this$_editorBridgeSe = _this$_editorBridgeSe.documentLayoutObject.documentModel) === null || _this$_editorBridgeSe === void 0 ? void 0 : _this$_editorBridgeSe.getBody();
11132
+ const textRun = (sourceBody === null || sourceBody === void 0 || (_sourceBody$textRuns = sourceBody.textRuns) === null || _sourceBody$textRuns === void 0 ? void 0 : _sourceBody$textRuns.length) === 1 ? sourceBody.textRuns[0] : null;
11133
+ if ((sourceBody === null || sourceBody === void 0 ? void 0 : sourceBody.dataStream) === DEFAULT_EMPTY_DOCUMENT_VALUE && (textRun === null || textRun === void 0 ? void 0 : textRun.st) === 0 && textRun.ed === 0) this._commandService.syncExecuteCommand(SetDocInputStyleCommand.id, { style: Tools.deepClone(textRun.ts) });
11134
+ }
11648
11135
  _refreshCurrentSelections(sheetId) {
11649
11136
  const selections = this._workbookSelections.getSelectionsOfWorksheet(sheetId);
11650
11137
  if (selections) {
@@ -11768,8 +11255,13 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11768
11255
  var _this$_getEditorSkele;
11769
11256
  (_this$_getEditorSkele = this._getEditorSkeleton(DOCS_NORMAL_EDITOR_UNIT_ID_KEY)) === null || _this$_getEditorSkele === void 0 || _this$_getEditorSkele.resetInitialWidth();
11770
11257
  }
11771
- this._undoRedoService.clearUndoRedo(editorUnitId);
11258
+ this._clearEditorHistory();
11259
+ }
11260
+ _clearEditorHistory() {
11261
+ this._undoRedoService.clearUndoRedo(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
11772
11262
  this._undoRedoService.clearUndoRedo(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
11263
+ this._docStateChangeManagerService.clearHistory(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
11264
+ this._docStateChangeManagerService.clearHistory(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
11773
11265
  }
11774
11266
  _moveSelection(keycode, currentUnitId, worksheetId) {
11775
11267
  if (keycode == null || !MOVE_SELECTION_KEYCODE_LIST.includes(keycode)) {
@@ -11873,7 +11365,8 @@ EditingRenderController = __decorate([
11873
11365
  __decorateParam(12, Inject(SheetInterceptorService)),
11874
11366
  __decorateParam(13, Inject(SheetCellEditorResizeService)),
11875
11367
  __decorateParam(14, Inject(SheetsSelectionsService)),
11876
- __decorateParam(15, IConfigService)
11368
+ __decorateParam(15, IConfigService),
11369
+ __decorateParam(16, Inject(DocStateChangeManagerService))
11877
11370
  ], EditingRenderController);
11878
11371
  function getCellDataByInput(cellData, snapshot, lexerTreeBuilder, localeService, functionService, styles) {
11879
11372
  var _styles$get;
@@ -14002,7 +13495,7 @@ let SheetPermissionCheckUIController = class SheetPermissionCheckUIController ex
14002
13495
  workbookTypes: [WorkbookEditablePermission],
14003
13496
  worksheetTypes: [WorksheetSetCellValuePermission, WorksheetEditPermission],
14004
13497
  rangeTypes: [RangeProtectionPermissionEditPoint]
14005
- });
13498
+ }, params.unitId);
14006
13499
  errorMsg = this._localeService.t("sheets-ui.permission.dialog.editErr");
14007
13500
  break;
14008
13501
  case ApplyFormatPainterCommand.id:
@@ -15753,9 +15246,9 @@ var HeaderUnhideRangeService = class {
15753
15246
 
15754
15247
  //#endregion
15755
15248
  //#region src/menu/header-menu-shape.ts
15756
- const HEADER_MENU_SHAPE_CIRCLE_FILL = "rgba(0, 0, 0, 0.15)";
15757
- const HEADER_MENU_SHAPE_TRIANGLE_FILL = "rgb(0, 0, 0)";
15758
- const HEADER_MENU_BACKGROUND_COLOR = "rgb(255, 255, 255, 1)";
15249
+ const HEADER_MENU_SHAPE_CIRCLE_FILL = "gray.200";
15250
+ const HEADER_MENU_SHAPE_TRIANGLE_FILL = "gray.900";
15251
+ const HEADER_MENU_BACKGROUND_COLOR = "gray.50";
15759
15252
  var HeaderMenuShape = class extends Shape {
15760
15253
  constructor(key, props) {
15761
15254
  super(key, props);
@@ -15776,309 +15269,701 @@ var HeaderMenuShape = class extends Shape {
15776
15269
  if (this._mode === 1) Rect.drawWith(ctx, {
15777
15270
  width: this._size,
15778
15271
  height: this._size,
15779
- radius: this._size,
15780
- fill: HEADER_MENU_SHAPE_CIRCLE_FILL
15272
+ radius: this._size,
15273
+ fill: HEADER_MENU_SHAPE_CIRCLE_FILL
15274
+ });
15275
+ const iconSize = this._size * .5 * this._iconRatio;
15276
+ const sixtyDegree = Math.PI / 180 * 60;
15277
+ const left = iconSize * Math.sin(sixtyDegree);
15278
+ const top = iconSize * Math.cos(sixtyDegree);
15279
+ RegularPolygon.drawWith(ctx, {
15280
+ pointsGroup: [[
15281
+ {
15282
+ x: -left + this._size / 2,
15283
+ y: -top + this._size / 2
15284
+ },
15285
+ {
15286
+ x: left + this._size / 2,
15287
+ y: -top + this._size / 2
15288
+ },
15289
+ {
15290
+ x: this._size / 2,
15291
+ y: iconSize + this._size / 2
15292
+ }
15293
+ ]],
15294
+ fill: HEADER_MENU_SHAPE_TRIANGLE_FILL
15295
+ });
15296
+ }
15297
+ };
15298
+
15299
+ //#endregion
15300
+ //#region src/views/header-unhide-shape.ts
15301
+ const UNHIDE_ICON_SIZE = 12;
15302
+ const UNHIDE_ARROW_RATIO = .4;
15303
+ var HeaderUnhideShape = class extends Shape {
15304
+ constructor(key, props, onClick) {
15305
+ super(key, props);
15306
+ _defineProperty(this, "_size", 12);
15307
+ _defineProperty(this, "_iconRatio", UNHIDE_ARROW_RATIO);
15308
+ _defineProperty(this, "_hovered", true);
15309
+ _defineProperty(this, "_hasPrevious", true);
15310
+ _defineProperty(this, "_hasNext", true);
15311
+ _defineProperty(this, "_unhideType", void 0);
15312
+ if (props) this.setShapeProps(props);
15313
+ this.onPointerEnter$.subscribeEvent(() => this.setShapeProps({ hovered: true }));
15314
+ this.onPointerLeave$.subscribeEvent(() => this.setShapeProps({ hovered: false }));
15315
+ this.onPointerDown$.subscribeEvent(() => onClick === null || onClick === void 0 ? void 0 : onClick());
15316
+ }
15317
+ setShapeProps(props) {
15318
+ if (props.type !== void 0) this._unhideType = props.type;
15319
+ if (props.hovered !== void 0) this._hovered = props.hovered;
15320
+ if (props.hasPrevious !== void 0) this._hasPrevious = props.hasPrevious;
15321
+ if (props.hasNext !== void 0) this._hasNext = props.hasNext;
15322
+ this.transformByState({
15323
+ width: this._size * (this._unhideType === 1 ? 2 : 1),
15324
+ height: this._size * (this._unhideType === 0 ? 2 : 1)
15325
+ });
15326
+ }
15327
+ _draw(ctx) {
15328
+ if (this._unhideType === 0) this._drawOnRow(ctx);
15329
+ else this._drawOnCol(ctx);
15330
+ }
15331
+ _drawOnRow(ctx) {
15332
+ if (this._hovered) if (!this._hasNext || !this._hasPrevious) Rect.drawWith(ctx, {
15333
+ width: this._size,
15334
+ height: this._size,
15335
+ stroke: HEADER_MENU_SHAPE_TRIANGLE_FILL,
15336
+ fill: HEADER_MENU_BACKGROUND_COLOR
15337
+ });
15338
+ else Rect.drawWith(ctx, {
15339
+ width: this._size,
15340
+ height: 2 * this._size,
15341
+ stroke: HEADER_MENU_SHAPE_TRIANGLE_FILL,
15342
+ fill: HEADER_MENU_BACKGROUND_COLOR
15343
+ });
15344
+ const iconSize = this._size * .5 * this._iconRatio;
15345
+ const sixtyDegree = Math.PI / 3;
15346
+ const top = iconSize * Math.cos(sixtyDegree);
15347
+ const left = iconSize * Math.sin(sixtyDegree);
15348
+ if (this._hasPrevious) RegularPolygon.drawWith(ctx, {
15349
+ pointsGroup: [[
15350
+ {
15351
+ x: this._size / 2,
15352
+ y: this._size / 2 - left
15353
+ },
15354
+ {
15355
+ x: this._size / 2 - left,
15356
+ y: this._size / 2 + top
15357
+ },
15358
+ {
15359
+ x: this._size / 2 + left,
15360
+ y: this._size / 2 + top
15361
+ }
15362
+ ]],
15363
+ fill: HEADER_MENU_SHAPE_TRIANGLE_FILL
15364
+ });
15365
+ if (this._hasNext) {
15366
+ const offset = this._hasPrevious ? 3 : 1;
15367
+ RegularPolygon.drawWith(ctx, {
15368
+ pointsGroup: [[
15369
+ {
15370
+ x: this._size / 2,
15371
+ y: this._size * offset / 2 + left
15372
+ },
15373
+ {
15374
+ x: this._size / 2 - left,
15375
+ y: this._size * offset / 2 - top
15376
+ },
15377
+ {
15378
+ x: this._size / 2 + left,
15379
+ y: this._size * offset / 2 - top
15380
+ }
15381
+ ]],
15382
+ fill: HEADER_MENU_SHAPE_TRIANGLE_FILL
15383
+ });
15384
+ }
15385
+ }
15386
+ /**
15387
+ *
15388
+ * @param ctx
15389
+ */
15390
+ _drawOnCol(ctx) {
15391
+ if (this._hovered) if (!this._hasNext || !this._hasPrevious) Rect.drawWith(ctx, {
15392
+ width: this._size,
15393
+ height: this._size,
15394
+ stroke: HEADER_MENU_SHAPE_TRIANGLE_FILL,
15395
+ fill: HEADER_MENU_BACKGROUND_COLOR
15396
+ });
15397
+ else Rect.drawWith(ctx, {
15398
+ width: 2 * this._size,
15399
+ height: this._size,
15400
+ stroke: HEADER_MENU_SHAPE_TRIANGLE_FILL,
15401
+ fill: HEADER_MENU_BACKGROUND_COLOR
15781
15402
  });
15782
15403
  const iconSize = this._size * .5 * this._iconRatio;
15783
- const sixtyDegree = Math.PI / 180 * 60;
15784
- const left = iconSize * Math.sin(sixtyDegree);
15404
+ const sixtyDegree = Math.PI / 3;
15785
15405
  const top = iconSize * Math.cos(sixtyDegree);
15786
- RegularPolygon.drawWith(ctx, {
15406
+ const left = iconSize * Math.sin(sixtyDegree);
15407
+ if (this._hasPrevious) RegularPolygon.drawWith(ctx, {
15787
15408
  pointsGroup: [[
15788
15409
  {
15789
- x: -left + this._size / 2,
15790
- y: -top + this._size / 2
15410
+ x: -top + this._size / 2,
15411
+ y: this._size / 2
15791
15412
  },
15792
15413
  {
15793
- x: left + this._size / 2,
15794
- y: -top + this._size / 2
15414
+ x: this._size / 2 + left,
15415
+ y: this._size / 2 - left
15795
15416
  },
15796
15417
  {
15797
- x: this._size / 2,
15798
- y: iconSize + this._size / 2
15418
+ x: this._size / 2 + left,
15419
+ y: this._size / 2 + left
15799
15420
  }
15800
15421
  ]],
15801
15422
  fill: HEADER_MENU_SHAPE_TRIANGLE_FILL
15802
15423
  });
15424
+ if (this._hasNext) {
15425
+ const offset = this._hasPrevious ? 3 : 1;
15426
+ RegularPolygon.drawWith(ctx, {
15427
+ pointsGroup: [[
15428
+ {
15429
+ x: top + this._size * offset / 2,
15430
+ y: this._size / 2
15431
+ },
15432
+ {
15433
+ x: -left + this._size * offset / 2,
15434
+ y: this._size / 2 - left
15435
+ },
15436
+ {
15437
+ x: -left + this._size * offset / 2,
15438
+ y: this._size / 2 + left
15439
+ }
15440
+ ]],
15441
+ fill: HEADER_MENU_SHAPE_TRIANGLE_FILL
15442
+ });
15443
+ }
15803
15444
  }
15804
15445
  };
15805
15446
 
15806
15447
  //#endregion
15807
- //#region src/views/header-unhide-shape.ts
15808
- const UNHIDE_ICON_SIZE = 12;
15809
- const UNHIDE_ARROW_RATIO = .4;
15810
- var HeaderUnhideShape = class extends Shape {
15811
- constructor(key, props, onClick) {
15812
- super(key, props);
15813
- _defineProperty(this, "_size", 12);
15814
- _defineProperty(this, "_iconRatio", UNHIDE_ARROW_RATIO);
15815
- _defineProperty(this, "_hovered", true);
15816
- _defineProperty(this, "_hasPrevious", true);
15817
- _defineProperty(this, "_hasNext", true);
15818
- _defineProperty(this, "_unhideType", void 0);
15819
- if (props) this.setShapeProps(props);
15820
- this.onPointerEnter$.subscribeEvent(() => this.setShapeProps({ hovered: true }));
15821
- this.onPointerLeave$.subscribeEvent(() => this.setShapeProps({ hovered: false }));
15822
- this.onPointerDown$.subscribeEvent(() => onClick === null || onClick === void 0 ? void 0 : onClick());
15448
+ //#region src/controllers/render-controllers/header-unhide.render-controller.ts
15449
+ const HEADER_UNHIDE_CONTROLLER_SHAPE = "__SpreadsheetHeaderUnhideSHAPEControllerShape__";
15450
+ const HEADER_UNHIDE_RANGE_VISIBLE_CHECK = createInterceptorKey("headerUnhideRangeVisibleCheck");
15451
+ let HeaderUnhideRenderController = class HeaderUnhideRenderController extends RxDisposable {
15452
+ get _workbook() {
15453
+ return this._context.unit;
15454
+ }
15455
+ constructor(_context, _sheetSkeletonManagerService, _headerUnhideRangeService, _commandService) {
15456
+ super();
15457
+ this._context = _context;
15458
+ this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
15459
+ this._headerUnhideRangeService = _headerUnhideRangeService;
15460
+ this._commandService = _commandService;
15461
+ _defineProperty(this, "_shapes", {
15462
+ cols: [],
15463
+ rows: []
15464
+ });
15465
+ _defineProperty(this, "interceptor", new InterceptorManager({ HEADER_UNHIDE_RANGE_VISIBLE_CHECK }));
15466
+ this._init();
15467
+ }
15468
+ dispose() {
15469
+ super.dispose();
15470
+ this._clearShapes();
15471
+ }
15472
+ _init() {
15473
+ let activeSheetId = "";
15474
+ this._context.unit.activeSheet$.pipe(takeUntil(this.dispose$)).subscribe((worksheet) => {
15475
+ this._clearShapes();
15476
+ if (!worksheet) {
15477
+ activeSheetId = "";
15478
+ return;
15479
+ }
15480
+ activeSheetId = worksheet.getSheetId();
15481
+ this._update(this._workbook, worksheet);
15482
+ });
15483
+ this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe((param) => {
15484
+ if (param) {
15485
+ const { unitId, sheetId } = param;
15486
+ if (unitId === this._workbook.getUnitId() && sheetId === activeSheetId) {
15487
+ const worksheet = this._workbook.getSheetBySheetId(sheetId);
15488
+ if (worksheet) this._update(this._workbook, worksheet);
15489
+ }
15490
+ }
15491
+ }));
15492
+ }
15493
+ _update(workbook, worksheet) {
15494
+ var _this$_sheetSkeletonM;
15495
+ const skeleton = (_this$_sheetSkeletonM = this._sheetSkeletonManagerService.getSkeletonParam(worksheet.getSheetId())) === null || _this$_sheetSkeletonM === void 0 ? void 0 : _this$_sheetSkeletonM.skeleton;
15496
+ if (!skeleton) return;
15497
+ const visibleCheck = this.interceptor.fetchThroughInterceptors(HEADER_UNHIDE_RANGE_VISIBLE_CHECK);
15498
+ const shouldRenderRange = (payload) => this._headerUnhideRangeService.shouldRenderRange(visibleCheck(true, payload) ?? true, payload);
15499
+ const hiddenRowRanges = worksheet.getHiddenRows().filter((range) => shouldRenderRange({
15500
+ axis: "row",
15501
+ range,
15502
+ workbook,
15503
+ worksheet
15504
+ }));
15505
+ const hiddenColRanges = worksheet.getHiddenCols().filter((range) => shouldRenderRange({
15506
+ axis: "column",
15507
+ range,
15508
+ workbook,
15509
+ worksheet
15510
+ }));
15511
+ const { scene } = this._getSheetObject();
15512
+ const rowCount = worksheet.getRowCount();
15513
+ const rowShapes = hiddenRowRanges.map((range) => {
15514
+ const { startRow, endRow } = range;
15515
+ const position = getCoordByCell(startRow, 0, scene, skeleton);
15516
+ const hasPrevious = startRow !== 0;
15517
+ const hasNext = endRow !== rowCount - 1;
15518
+ return new HeaderUnhideShape(HEADER_UNHIDE_CONTROLLER_SHAPE, {
15519
+ type: 0,
15520
+ hovered: false,
15521
+ hasPrevious,
15522
+ hasNext,
15523
+ top: position.startY - (hasPrevious ? 12 : 0),
15524
+ left: position.startX - 12
15525
+ }, () => this._commandService.executeCommand(SetSpecificRowsVisibleCommand.id, {
15526
+ unitId: workbook.getUnitId(),
15527
+ subUnitId: worksheet.getSheetId(),
15528
+ ranges: [range]
15529
+ }));
15530
+ });
15531
+ const colCount = worksheet.getColumnCount();
15532
+ const colShapes = hiddenColRanges.map((range) => {
15533
+ const { startColumn, endColumn } = range;
15534
+ const position = getCoordByCell(0, startColumn, scene, skeleton);
15535
+ const hasPrevious = startColumn !== 0;
15536
+ const hasNext = endColumn !== colCount - 1;
15537
+ return new HeaderUnhideShape(HEADER_UNHIDE_CONTROLLER_SHAPE, {
15538
+ type: 1,
15539
+ hovered: false,
15540
+ hasPrevious,
15541
+ hasNext,
15542
+ top: Math.max(skeleton.columnHeaderHeight, skeleton.columnHeaderHeightAndMarginTop) - 12,
15543
+ left: position.startX - (hasPrevious ? 12 : 0)
15544
+ }, () => this._commandService.executeCommand(SetSpecificColsVisibleCommand.id, {
15545
+ unitId: workbook.getUnitId(),
15546
+ subUnitId: worksheet.getSheetId(),
15547
+ ranges: [range]
15548
+ }));
15549
+ });
15550
+ scene.addObjects(colShapes, 12);
15551
+ scene.addObjects(rowShapes, 12);
15552
+ this._clearShapes();
15553
+ this._shapes = {
15554
+ cols: colShapes,
15555
+ rows: rowShapes
15556
+ };
15557
+ }
15558
+ _clearShapes() {
15559
+ this._shapes.cols.forEach((shape) => shape.dispose());
15560
+ this._shapes.rows.forEach((shape) => shape.dispose());
15561
+ this._shapes = {
15562
+ cols: [],
15563
+ rows: []
15564
+ };
15565
+ }
15566
+ _getSheetObject() {
15567
+ return getSheetObject(this._workbook, this._context);
15568
+ }
15569
+ };
15570
+ HeaderUnhideRenderController = __decorate([
15571
+ __decorateParam(1, Inject(SheetSkeletonManagerService)),
15572
+ __decorateParam(2, Inject(HeaderUnhideRangeService)),
15573
+ __decorateParam(3, ICommandService)
15574
+ ], HeaderUnhideRenderController);
15575
+
15576
+ //#endregion
15577
+ //#region src/controllers/render-controllers/sheet.render-controller.ts
15578
+ const FRAME_STACK_THRESHOLD = 60;
15579
+ let SheetRenderController = class SheetRenderController extends RxDisposable {
15580
+ constructor(_context, _configService, _sheetSkeletonManagerService, _sheetRenderService, _commandService, _telemetryService) {
15581
+ super();
15582
+ this._context = _context;
15583
+ this._configService = _configService;
15584
+ this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
15585
+ this._sheetRenderService = _sheetRenderService;
15586
+ this._commandService = _commandService;
15587
+ this._telemetryService = _telemetryService;
15588
+ _defineProperty(this, "_renderMetric$", new Subject());
15589
+ _defineProperty(this, "renderMetric$", this._renderMetric$.asObservable());
15590
+ _defineProperty(this, "_renderFrameTimeMetric", null);
15591
+ _defineProperty(this, "_renderFrameTags", {});
15592
+ _defineProperty(this, "_afterRenderMetric$", new Subject());
15593
+ this._addNewRender();
15594
+ this._initRenderMetricSubscriber();
15595
+ }
15596
+ _addNewRender() {
15597
+ const { scene, engine, unit: workbook } = this._context;
15598
+ this._addComponent(workbook);
15599
+ this._initRerenderScheduler();
15600
+ this._initCommandListener();
15601
+ const worksheet = this._context.unit.getActiveSheet();
15602
+ if (!worksheet) throw new Error("No active sheet found");
15603
+ const sheetId = worksheet.getSheetId();
15604
+ this._sheetSkeletonManagerService.setCurrent({ sheetId });
15605
+ const frameFn = () => scene.render();
15606
+ this.disposeWithMe(this._context.activated$.subscribe((activated) => {
15607
+ if (activated) engine.runRenderLoop(frameFn);
15608
+ else engine.stopRenderLoop(frameFn);
15609
+ }));
15610
+ }
15611
+ _initRenderMetricSubscriber() {
15612
+ const { engine } = this._context;
15613
+ this.disposeWithMe(engine.beginFrame$.subscribe(() => {
15614
+ this._renderFrameTimeMetric = null;
15615
+ this._renderFrameTags = {};
15616
+ }));
15617
+ this.disposeWithMe(engine.endFrame$.subscribe(() => {
15618
+ if (this._renderFrameTimeMetric && Object.keys(this._renderFrameTimeMetric).some((key) => key.startsWith(SHEET_EXTENSION_PREFIX))) this._afterRenderMetric$.next({
15619
+ frameTimeMetric: this._renderFrameTimeMetric,
15620
+ tags: this._renderFrameTags
15621
+ });
15622
+ }));
15623
+ this.disposeWithMe(engine.renderFrameTimeMetric$.subscribe(([key, value]) => {
15624
+ if (!this._renderFrameTimeMetric) this._renderFrameTimeMetric = {};
15625
+ if (!this._renderFrameTimeMetric[key]) this._renderFrameTimeMetric[key] = [];
15626
+ this._renderFrameTimeMetric[key].push(Math.round(value * 100) / 100);
15627
+ }));
15628
+ this.disposeWithMe(engine.renderFrameTags$.subscribe(([key, value]) => {
15629
+ this._renderFrameTags[key] = value;
15630
+ }));
15631
+ const frameInfoList = [];
15632
+ this.disposeWithMe(this._afterRenderMetric$.pipe(withLatestFrom(engine.endFrame$)).subscribe(([sceneRenderDetail, basicFrameTimeInfo]) => {
15633
+ frameInfoList.push({
15634
+ FPS: basicFrameTimeInfo.FPS,
15635
+ elapsedTime: basicFrameTimeInfo.elapsedTime,
15636
+ frameTime: Math.round(basicFrameTimeInfo.frameTime * 100) / 100,
15637
+ ...sceneRenderDetail.frameTimeMetric,
15638
+ ...sceneRenderDetail.tags
15639
+ });
15640
+ if (frameInfoList.length > FRAME_STACK_THRESHOLD) {
15641
+ this._captureRenderMetric(frameInfoList);
15642
+ frameInfoList.length = 0;
15643
+ }
15644
+ }));
15823
15645
  }
15824
- setShapeProps(props) {
15825
- if (props.type !== void 0) this._unhideType = props.type;
15826
- if (props.hovered !== void 0) this._hovered = props.hovered;
15827
- if (props.hasPrevious !== void 0) this._hasPrevious = props.hasPrevious;
15828
- if (props.hasNext !== void 0) this._hasNext = props.hasNext;
15829
- this.transformByState({
15830
- width: this._size * (this._unhideType === 1 ? 2 : 1),
15831
- height: this._size * (this._unhideType === 0 ? 2 : 1)
15646
+ /**
15647
+ * Send render metric to telemetry service
15648
+ * @param frameInfoList
15649
+ */
15650
+ _captureRenderMetric(frameInfoList) {
15651
+ var _this$_telemetryServi;
15652
+ const filteredFrameInfo = frameInfoList;
15653
+ if (filteredFrameInfo.length === 0) return;
15654
+ const sumValueForNumListFields = (data) => {
15655
+ let totalSum = 0;
15656
+ const sums = Object.entries(data).filter(([_, value]) => Array.isArray(value)).map(([key]) => key).reduce((acc, key) => {
15657
+ acc[key] = data[key].reduce((sum, num) => sum + num, 0);
15658
+ return acc;
15659
+ }, {});
15660
+ Object.keys(data).filter((key) => key.startsWith(SHEET_EXTENSION_PREFIX)).forEach((key) => {
15661
+ totalSum += sums[key];
15662
+ });
15663
+ return {
15664
+ ...sums,
15665
+ extensionTotal: totalSum
15666
+ };
15667
+ };
15668
+ const frameTimeListAfterSum = frameInfoList.map((info) => {
15669
+ return {
15670
+ ...info,
15671
+ ...sumValueForNumListFields(info)
15672
+ };
15832
15673
  });
15674
+ const getSummaryStats = (list) => {
15675
+ return Object.entries(list[0]).filter(([key, _]) => !["elapsedTime"].includes(key)).filter(([_, value]) => typeof value === "number").map(([key]) => key).reduce((acc, key) => {
15676
+ const values = list.map((obj) => obj[key]);
15677
+ const max = Math.max(...values);
15678
+ const min = Math.min(...values);
15679
+ const avg = values.reduce((sum, val) => sum + val, 0) / values.length;
15680
+ acc[key] = {
15681
+ max: Math.round(max * 100) / 100,
15682
+ min: Math.round(min * 100) / 100,
15683
+ avg: Math.round(avg * 100) / 100
15684
+ };
15685
+ return acc;
15686
+ }, {});
15687
+ };
15688
+ const summaryFrameStats = getSummaryStats(frameTimeListAfterSum);
15689
+ const elapsedTimeToStart = filteredFrameInfo[filteredFrameInfo.length - 1].elapsedTime;
15690
+ const telemetryData = {
15691
+ sheetId: this._context.unit.getActiveSheet().getSheetId(),
15692
+ unitId: this._context.unit.getUnitId(),
15693
+ elapsedTimeToStart,
15694
+ ...summaryFrameStats
15695
+ };
15696
+ this._renderMetric$.next(telemetryData);
15697
+ (_this$_telemetryServi = this._telemetryService) === null || _this$_telemetryServi === void 0 || _this$_telemetryServi.capture("sheet_render_cost", telemetryData);
15833
15698
  }
15834
- _draw(ctx) {
15835
- if (this._unhideType === 0) this._drawOnRow(ctx);
15836
- else this._drawOnCol(ctx);
15699
+ _addComponent(workbook) {
15700
+ const { scene, components } = this._context;
15701
+ const worksheet = workbook.getActiveSheet();
15702
+ const spreadsheet = new Spreadsheet("__SpreadsheetRender__");
15703
+ this._addViewport(worksheet);
15704
+ const spreadsheetRowHeader = new SpreadsheetRowHeader("__SpreadsheetRowHeader__");
15705
+ const spreadsheetColumnHeader = new SpreadsheetColumnHeader("__SpreadsheetColumnHeader__");
15706
+ const SpreadsheetLeftTopPlaceholder = new Rect("__SpreadsheetLeftTopPlaceholder__", {
15707
+ zIndex: 2,
15708
+ left: -1,
15709
+ top: -1,
15710
+ fill: "gray.50",
15711
+ stroke: "gray.200",
15712
+ strokeWidth: 1
15713
+ });
15714
+ this._context.mainComponent = spreadsheet;
15715
+ components.set("__SpreadsheetRender__", spreadsheet);
15716
+ components.set("__SpreadsheetRowHeader__", spreadsheetRowHeader);
15717
+ components.set("__SpreadsheetColumnHeader__", spreadsheetColumnHeader);
15718
+ components.set("__SpreadsheetLeftTopPlaceholder__", SpreadsheetLeftTopPlaceholder);
15719
+ scene.addObjects([spreadsheet], 0);
15720
+ scene.addObjects([
15721
+ spreadsheetRowHeader,
15722
+ spreadsheetColumnHeader,
15723
+ SpreadsheetLeftTopPlaceholder
15724
+ ], 10);
15725
+ scene.enableLayerCache(0, 10);
15837
15726
  }
15838
- _drawOnRow(ctx) {
15839
- if (this._hovered) if (!this._hasNext || !this._hasPrevious) Rect.drawWith(ctx, {
15840
- width: this._size,
15841
- height: this._size,
15842
- stroke: HEADER_MENU_SHAPE_TRIANGLE_FILL,
15843
- fill: HEADER_MENU_BACKGROUND_COLOR
15727
+ _initViewports(scene, rowHeader, columnHeader) {
15728
+ const rowHeaderWidth = rowHeader.hidden ? 0 : rowHeader.width;
15729
+ const columnHeaderHeight = columnHeader.hidden ? 0 : columnHeader.height;
15730
+ const bufferEdgeX = 100;
15731
+ const bufferEdgeY = 100;
15732
+ const viewMain = new Viewport(SHEET_VIEWPORT_KEY.VIEW_MAIN, scene, {
15733
+ left: rowHeaderWidth,
15734
+ top: columnHeaderHeight,
15735
+ bottom: 0,
15736
+ right: 0,
15737
+ isWheelPreventDefaultX: true,
15738
+ allowCache: true,
15739
+ bufferEdgeX,
15740
+ bufferEdgeY
15844
15741
  });
15845
- else Rect.drawWith(ctx, {
15846
- width: this._size,
15847
- height: 2 * this._size,
15848
- stroke: HEADER_MENU_SHAPE_TRIANGLE_FILL,
15849
- fill: HEADER_MENU_BACKGROUND_COLOR
15742
+ const viewMainLeftTop = new Viewport(SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP, scene, {
15743
+ isWheelPreventDefaultX: true,
15744
+ active: false,
15745
+ allowCache: true,
15746
+ bufferEdgeX: 0,
15747
+ bufferEdgeY: 0
15850
15748
  });
15851
- const iconSize = this._size * .5 * this._iconRatio;
15852
- const sixtyDegree = Math.PI / 3;
15853
- const top = iconSize * Math.cos(sixtyDegree);
15854
- const left = iconSize * Math.sin(sixtyDegree);
15855
- if (this._hasPrevious) RegularPolygon.drawWith(ctx, {
15856
- pointsGroup: [[
15857
- {
15858
- x: this._size / 2,
15859
- y: this._size / 2 - left
15860
- },
15861
- {
15862
- x: this._size / 2 - left,
15863
- y: this._size / 2 + top
15864
- },
15865
- {
15866
- x: this._size / 2 + left,
15867
- y: this._size / 2 + top
15868
- }
15869
- ]],
15870
- fill: HEADER_MENU_SHAPE_TRIANGLE_FILL
15749
+ const viewMainLeft = new Viewport(SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT, scene, {
15750
+ isWheelPreventDefaultX: true,
15751
+ active: false,
15752
+ allowCache: true,
15753
+ bufferEdgeX: 0,
15754
+ bufferEdgeY
15871
15755
  });
15872
- if (this._hasNext) {
15873
- const offset = this._hasPrevious ? 3 : 1;
15874
- RegularPolygon.drawWith(ctx, {
15875
- pointsGroup: [[
15876
- {
15877
- x: this._size / 2,
15878
- y: this._size * offset / 2 + left
15879
- },
15880
- {
15881
- x: this._size / 2 - left,
15882
- y: this._size * offset / 2 - top
15883
- },
15884
- {
15885
- x: this._size / 2 + left,
15886
- y: this._size * offset / 2 - top
15887
- }
15888
- ]],
15889
- fill: HEADER_MENU_SHAPE_TRIANGLE_FILL
15890
- });
15891
- }
15892
- }
15893
- /**
15894
- *
15895
- * @param ctx
15896
- */
15897
- _drawOnCol(ctx) {
15898
- if (this._hovered) if (!this._hasNext || !this._hasPrevious) Rect.drawWith(ctx, {
15899
- width: this._size,
15900
- height: this._size,
15901
- stroke: HEADER_MENU_SHAPE_TRIANGLE_FILL,
15902
- fill: HEADER_MENU_BACKGROUND_COLOR
15756
+ const viewMainTop = new Viewport(SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP, scene, {
15757
+ isWheelPreventDefaultX: true,
15758
+ active: false,
15759
+ allowCache: true,
15760
+ bufferEdgeX,
15761
+ bufferEdgeY: 0
15903
15762
  });
15904
- else Rect.drawWith(ctx, {
15905
- width: 2 * this._size,
15906
- height: this._size,
15907
- stroke: HEADER_MENU_SHAPE_TRIANGLE_FILL,
15908
- fill: HEADER_MENU_BACKGROUND_COLOR
15763
+ const viewRowTop = new Viewport(SHEET_VIEWPORT_KEY.VIEW_ROW_TOP, scene, {
15764
+ active: false,
15765
+ isWheelPreventDefaultX: true
15909
15766
  });
15910
- const iconSize = this._size * .5 * this._iconRatio;
15911
- const sixtyDegree = Math.PI / 3;
15912
- const top = iconSize * Math.cos(sixtyDegree);
15913
- const left = iconSize * Math.sin(sixtyDegree);
15914
- if (this._hasPrevious) RegularPolygon.drawWith(ctx, {
15915
- pointsGroup: [[
15916
- {
15917
- x: -top + this._size / 2,
15918
- y: this._size / 2
15919
- },
15920
- {
15921
- x: this._size / 2 + left,
15922
- y: this._size / 2 - left
15923
- },
15924
- {
15925
- x: this._size / 2 + left,
15926
- y: this._size / 2 + left
15927
- }
15928
- ]],
15929
- fill: HEADER_MENU_SHAPE_TRIANGLE_FILL
15767
+ const viewRowBottom = new Viewport(SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM, scene, {
15768
+ left: 0,
15769
+ top: columnHeaderHeight,
15770
+ bottom: 0,
15771
+ width: rowHeaderWidth + 1,
15772
+ isWheelPreventDefaultX: true
15930
15773
  });
15931
- if (this._hasNext) {
15932
- const offset = this._hasPrevious ? 3 : 1;
15933
- RegularPolygon.drawWith(ctx, {
15934
- pointsGroup: [[
15935
- {
15936
- x: top + this._size * offset / 2,
15937
- y: this._size / 2
15938
- },
15939
- {
15940
- x: -left + this._size * offset / 2,
15941
- y: this._size / 2 - left
15942
- },
15943
- {
15944
- x: -left + this._size * offset / 2,
15945
- y: this._size / 2 + left
15946
- }
15947
- ]],
15948
- fill: HEADER_MENU_SHAPE_TRIANGLE_FILL
15949
- });
15950
- }
15951
- }
15952
- };
15953
-
15954
- //#endregion
15955
- //#region src/controllers/render-controllers/header-unhide.render-controller.ts
15956
- const HEADER_UNHIDE_CONTROLLER_SHAPE = "__SpreadsheetHeaderUnhideSHAPEControllerShape__";
15957
- const HEADER_UNHIDE_RANGE_VISIBLE_CHECK = createInterceptorKey("headerUnhideRangeVisibleCheck");
15958
- let HeaderUnhideRenderController = class HeaderUnhideRenderController extends RxDisposable {
15959
- get _workbook() {
15960
- return this._context.unit;
15961
- }
15962
- constructor(_context, _sheetSkeletonManagerService, _headerUnhideRangeService, _commandService) {
15963
- super();
15964
- this._context = _context;
15965
- this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
15966
- this._headerUnhideRangeService = _headerUnhideRangeService;
15967
- this._commandService = _commandService;
15968
- _defineProperty(this, "_shapes", {
15969
- cols: [],
15970
- rows: []
15774
+ const viewColumnLeft = new Viewport(SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT, scene, {
15775
+ active: false,
15776
+ isWheelPreventDefaultX: true
15971
15777
  });
15972
- _defineProperty(this, "interceptor", new InterceptorManager({ HEADER_UNHIDE_RANGE_VISIBLE_CHECK }));
15973
- this._init();
15778
+ const viewColumnRight = new Viewport(SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT, scene, {
15779
+ left: rowHeaderWidth,
15780
+ top: 0,
15781
+ height: columnHeaderHeight + 1,
15782
+ right: 0,
15783
+ isWheelPreventDefaultX: true
15784
+ });
15785
+ return {
15786
+ viewMain,
15787
+ viewLeftTop: new Viewport(SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP, scene, {
15788
+ left: 0,
15789
+ top: 0,
15790
+ width: rowHeaderWidth,
15791
+ height: columnHeaderHeight,
15792
+ isWheelPreventDefaultX: true
15793
+ }),
15794
+ viewMainLeftTop,
15795
+ viewMainLeft,
15796
+ viewMainTop,
15797
+ viewColumnLeft,
15798
+ viewRowTop,
15799
+ viewRowBottom,
15800
+ viewColumnRight
15801
+ };
15974
15802
  }
15975
- dispose() {
15976
- super.dispose();
15977
- this._clearShapes();
15803
+ /**
15804
+ *
15805
+ * initViewport & wheel event
15806
+ * +-----------------+--------------------+-------------------+
15807
+ * | VIEW_LEFT_TOP | VIEW_COLUMN_LEFT | VIEW_COLUMN_RIGHT |
15808
+ * +-----------------+--------------------+-------------------+
15809
+ * | VIEW_ROW_TOP | VIEW_MAIN_LEFT_TOP | VIEW_MAIN_TOP |
15810
+ * +-----------------+--------------------+-------------------+
15811
+ * | VIEW_ROW_BOTTOM | VIEW_MAIN_LEFT | VIEW_MAIN |
15812
+ * +-----------------+--------------------+-------------------+
15813
+ */
15814
+ _addViewport(worksheet) {
15815
+ const scene = this._context.scene;
15816
+ const { rowHeader, columnHeader } = worksheet.getConfig();
15817
+ const { viewMain } = this._initViewports(scene, rowHeader, columnHeader);
15818
+ const sheetsUIConfig = this._configService.getConfig(SHEETS_UI_PLUGIN_CONFIG_KEY);
15819
+ new ScrollBar(viewMain, sheetsUIConfig === null || sheetsUIConfig === void 0 ? void 0 : sheetsUIConfig.scrollConfig);
15820
+ scene.attachControl();
15821
+ return viewMain;
15978
15822
  }
15979
- _init() {
15980
- let activeSheetId = "";
15981
- this._context.unit.activeSheet$.pipe(takeUntil(this.dispose$)).subscribe((worksheet) => {
15982
- this._clearShapes();
15983
- if (!worksheet) {
15984
- activeSheetId = "";
15985
- return;
15986
- }
15987
- activeSheetId = worksheet.getSheetId();
15988
- this._update(this._workbook, worksheet);
15989
- });
15823
+ _initRerenderScheduler() {
15990
15824
  this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe((param) => {
15991
- if (param) {
15992
- const { unitId, sheetId } = param;
15993
- if (unitId === this._workbook.getUnitId() && sheetId === activeSheetId) {
15994
- const worksheet = this._workbook.getSheetBySheetId(sheetId);
15995
- if (worksheet) this._update(this._workbook, worksheet);
15996
- }
15997
- }
15825
+ if (!param) return null;
15826
+ const { skeleton: spreadsheetSkeleton, sheetId } = param;
15827
+ const workbook = this._context.unit;
15828
+ const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(sheetId);
15829
+ if (workbook == null || worksheet == null) return;
15830
+ const { mainComponent, components } = this._context;
15831
+ const spreadsheet = mainComponent;
15832
+ const spreadsheetRowHeader = components.get("__SpreadsheetRowHeader__");
15833
+ const spreadsheetColumnHeader = components.get("__SpreadsheetColumnHeader__");
15834
+ const spreadsheetLeftTopPlaceholder = components.get("__SpreadsheetLeftTopPlaceholder__");
15835
+ const leftTopPlaceholderSize = getLeftTopPlaceholderSize(spreadsheetSkeleton);
15836
+ spreadsheet === null || spreadsheet === void 0 || spreadsheet.updateSkeleton(spreadsheetSkeleton);
15837
+ spreadsheetRowHeader === null || spreadsheetRowHeader === void 0 || spreadsheetRowHeader.updateSkeleton(spreadsheetSkeleton);
15838
+ spreadsheetColumnHeader === null || spreadsheetColumnHeader === void 0 || spreadsheetColumnHeader.updateSkeleton(spreadsheetSkeleton);
15839
+ spreadsheetLeftTopPlaceholder === null || spreadsheetLeftTopPlaceholder === void 0 || spreadsheetLeftTopPlaceholder.transformByState({
15840
+ width: leftTopPlaceholderSize.width,
15841
+ height: leftTopPlaceholderSize.height
15842
+ });
15998
15843
  }));
15999
15844
  }
16000
- _update(workbook, worksheet) {
16001
- var _this$_sheetSkeletonM;
16002
- const skeleton = (_this$_sheetSkeletonM = this._sheetSkeletonManagerService.getSkeletonParam(worksheet.getSheetId())) === null || _this$_sheetSkeletonM === void 0 ? void 0 : _this$_sheetSkeletonM.skeleton;
16003
- if (!skeleton) return;
16004
- const visibleCheck = this.interceptor.fetchThroughInterceptors(HEADER_UNHIDE_RANGE_VISIBLE_CHECK);
16005
- const shouldRenderRange = (payload) => this._headerUnhideRangeService.shouldRenderRange(visibleCheck(true, payload) ?? true, payload);
16006
- const hiddenRowRanges = worksheet.getHiddenRows().filter((range) => shouldRenderRange({
16007
- axis: "row",
16008
- range,
16009
- workbook,
16010
- worksheet
16011
- }));
16012
- const hiddenColRanges = worksheet.getHiddenCols().filter((range) => shouldRenderRange({
16013
- axis: "column",
16014
- range,
16015
- workbook,
16016
- worksheet
15845
+ _initCommandListener() {
15846
+ this.disposeWithMe(this._commandService.onCommandExecuted((command, options) => {
15847
+ const { unit: workbook } = this._context;
15848
+ const { id: commandId } = command;
15849
+ if (COMMAND_LISTENER_SKELETON_CHANGE.includes(commandId) || this._sheetRenderService.checkMutationShouldTriggerRerender(commandId)) {
15850
+ const { unitId, subUnitId } = command.params;
15851
+ const worksheet = workbook.getActiveSheet();
15852
+ if (!worksheet) return;
15853
+ const workbookId = this._context.unitId;
15854
+ const worksheetId = worksheet.getSheetId();
15855
+ if (unitId !== workbookId || subUnitId !== worksheetId) return;
15856
+ this._sheetSkeletonManagerService.makeDirty({
15857
+ sheetId: worksheetId,
15858
+ commandId
15859
+ }, true);
15860
+ this._sheetSkeletonManagerService.setCurrent({
15861
+ sheetId: worksheetId,
15862
+ commandId
15863
+ });
15864
+ } else if (COMMAND_LISTENER_VALUE_CHANGE.includes(commandId)) this._sheetSkeletonManagerService.reCalculate();
15865
+ if (command.type === CommandType.MUTATION) this._markUnitDirty(command, options);
16017
15866
  }));
16018
- const { scene } = this._getSheetObject();
16019
- const rowCount = worksheet.getRowCount();
16020
- const rowShapes = hiddenRowRanges.map((range) => {
16021
- const { startRow, endRow } = range;
16022
- const position = getCoordByCell(startRow, 0, scene, skeleton);
16023
- const hasPrevious = startRow !== 0;
16024
- const hasNext = endRow !== rowCount - 1;
16025
- return new HeaderUnhideShape(HEADER_UNHIDE_CONTROLLER_SHAPE, {
16026
- type: 0,
16027
- hovered: false,
16028
- hasPrevious,
16029
- hasNext,
16030
- top: position.startY - (hasPrevious ? 12 : 0),
16031
- left: position.startX - 12
16032
- }, () => this._commandService.executeCommand(SetSpecificRowsVisibleCommand.id, {
16033
- unitId: workbook.getUnitId(),
16034
- subUnitId: worksheet.getSheetId(),
16035
- ranges: [range]
16036
- }));
16037
- });
16038
- const colCount = worksheet.getColumnCount();
16039
- const colShapes = hiddenColRanges.map((range) => {
16040
- const { startColumn, endColumn } = range;
16041
- const position = getCoordByCell(0, startColumn, scene, skeleton);
16042
- const hasPrevious = startColumn !== 0;
16043
- const hasNext = endColumn !== colCount - 1;
16044
- return new HeaderUnhideShape(HEADER_UNHIDE_CONTROLLER_SHAPE, {
16045
- type: 1,
16046
- hovered: false,
16047
- hasPrevious,
16048
- hasNext,
16049
- top: Math.max(skeleton.columnHeaderHeight, skeleton.columnHeaderHeightAndMarginTop) - 12,
16050
- left: position.startX - (hasPrevious ? 12 : 0)
16051
- }, () => this._commandService.executeCommand(SetSpecificColsVisibleCommand.id, {
16052
- unitId: workbook.getUnitId(),
16053
- subUnitId: worksheet.getSheetId(),
16054
- ranges: [range]
16055
- }));
16056
- });
16057
- scene.addObjects(colShapes, 12);
16058
- scene.addObjects(rowShapes, 12);
16059
- this._clearShapes();
16060
- this._shapes = {
16061
- cols: colShapes,
16062
- rows: rowShapes
16063
- };
16064
15867
  }
16065
- _clearShapes() {
16066
- this._shapes.cols.forEach((shape) => shape.dispose());
16067
- this._shapes.rows.forEach((shape) => shape.dispose());
16068
- this._shapes = {
16069
- cols: [],
16070
- rows: []
15868
+ _markUnitDirty(command, options) {
15869
+ if (command.id.substring(0, 3) === "doc") return;
15870
+ const { mainComponent: spreadsheet, scene } = this._context;
15871
+ if (command.id === SetFormulaCalculationNotificationMutation.id) {
15872
+ if (command.params.stageInfo != null) return;
15873
+ }
15874
+ if (spreadsheet) spreadsheet.makeDirty();
15875
+ scene.makeDirty();
15876
+ if (!command.params) return;
15877
+ const cmdParams = command.params;
15878
+ const viewports = this._spreadsheetViewports(scene);
15879
+ if (command.id === SetRangeValuesMutation.id && cmdParams.cellValue && !(options === null || options === void 0 ? void 0 : options.fromChangeset)) {
15880
+ const dirtyRange = this._cellValueToRange(cmdParams.cellValue);
15881
+ const dirtyBounds = this._rangeToBounds([dirtyRange]);
15882
+ this._markViewportDirty(viewports, dirtyBounds);
15883
+ spreadsheet.setDirtyArea(dirtyBounds);
15884
+ }
15885
+ if (command.id === MoveRangeMutation.id && cmdParams.from && cmdParams.to && !(options === null || options === void 0 ? void 0 : options.fromChangeset)) {
15886
+ const fromRange = cmdParams.fromRange || this._cellValueToRange(cmdParams.from.value);
15887
+ const toRange = cmdParams.toRange || this._cellValueToRange(cmdParams.to.value);
15888
+ const dirtyBounds = this._rangeToBounds([fromRange, toRange]);
15889
+ this._markViewportDirty(viewports, dirtyBounds);
15890
+ spreadsheet.setDirtyArea(dirtyBounds);
15891
+ }
15892
+ }
15893
+ /**
15894
+ * cellValue data structure:
15895
+ * {[row]: { [col]: value}}
15896
+ * @param cellValue
15897
+ * @returns IRange
15898
+ */
15899
+ _cellValueToRange(cellValue) {
15900
+ const columns = [];
15901
+ let minCol = 0;
15902
+ let maxCol = 0;
15903
+ let minRow = 0;
15904
+ let maxRow = 0;
15905
+ for (const [_row, columnObj] of Object.entries(cellValue)) {
15906
+ for (const column in columnObj) {
15907
+ columns.push(Number(column));
15908
+ if (minCol > Number(column)) minCol = Number(column);
15909
+ if (maxCol < Number(column)) maxCol = Number(column);
15910
+ }
15911
+ if (minRow > Number(_row)) minRow = Number(_row);
15912
+ if (maxRow < Number(_row)) maxRow = Number(_row);
15913
+ }
15914
+ return {
15915
+ startRow: minRow,
15916
+ endRow: maxRow,
15917
+ startColumn: minCol,
15918
+ endColumn: maxCol
16071
15919
  };
16072
15920
  }
16073
- _getSheetObject() {
16074
- return getSheetObject(this._workbook, this._context);
15921
+ _rangeToBounds(ranges) {
15922
+ const { rowHeightAccumulation, columnWidthAccumulation, rowHeaderWidth, columnHeaderHeight } = this._sheetSkeletonManagerService.getCurrentParam().skeleton;
15923
+ const dirtyBounds = [];
15924
+ for (const r of ranges) {
15925
+ const { startRow, endRow, startColumn, endColumn } = r;
15926
+ const top = startRow === 0 ? 0 : rowHeightAccumulation[startRow - 1] + columnHeaderHeight;
15927
+ const bottom = rowHeightAccumulation[endRow] + columnHeaderHeight;
15928
+ const left = startColumn === 0 ? 0 : columnWidthAccumulation[startColumn - 1] + rowHeaderWidth;
15929
+ const right = columnWidthAccumulation[endColumn] + rowHeaderWidth;
15930
+ dirtyBounds.push({
15931
+ top,
15932
+ left,
15933
+ bottom,
15934
+ right,
15935
+ width: right - left,
15936
+ height: bottom - top
15937
+ });
15938
+ }
15939
+ return dirtyBounds;
15940
+ }
15941
+ _markViewportDirty(viewports, dirtyBounds) {
15942
+ const activeViewports = viewports.filter((vp) => vp.isActive && vp.cacheBound);
15943
+ for (const vp of activeViewports) for (const b of dirtyBounds) if (Rectangle.hasIntersectionBetweenTwoRect(vp.cacheBound, b)) vp.markDirty(true);
15944
+ }
15945
+ _spreadsheetViewports(scene) {
15946
+ return scene.getViewports().filter((v) => [
15947
+ "viewMain",
15948
+ "viewMainLeftTop",
15949
+ "viewMainTop",
15950
+ "viewMainLeft"
15951
+ ].includes(v.viewportKey));
16075
15952
  }
16076
15953
  };
16077
- HeaderUnhideRenderController = __decorate([
16078
- __decorateParam(1, Inject(SheetSkeletonManagerService)),
16079
- __decorateParam(2, Inject(HeaderUnhideRangeService)),
16080
- __decorateParam(3, ICommandService)
16081
- ], HeaderUnhideRenderController);
15954
+ SheetRenderController = __decorate([
15955
+ __decorateParam(1, Inject(IConfigService)),
15956
+ __decorateParam(2, Inject(SheetSkeletonManagerService)),
15957
+ __decorateParam(3, Inject(SheetsRenderService)),
15958
+ __decorateParam(4, ICommandService),
15959
+ __decorateParam(5, Optional(ITelemetryService))
15960
+ ], SheetRenderController);
15961
+ function getLeftTopPlaceholderSize(skeleton) {
15962
+ return {
15963
+ width: skeleton.rowHeaderWidthAndMarginLeft ?? skeleton.rowHeaderWidth,
15964
+ height: skeleton.columnHeaderHeightAndMarginTop ?? skeleton.columnHeaderHeight
15965
+ };
15966
+ }
16082
15967
 
16083
15968
  //#endregion
16084
15969
  //#region src/services/status-bar.service.ts
@@ -17357,6 +17242,7 @@ function ToggleGridlinesMenuFactory(accessor) {
17357
17242
  type: MenuItemType.BUTTON,
17358
17243
  tooltip: "sheets-ui.toolbar.toggleGridlines",
17359
17244
  icon: "HideGridlinesIcon",
17245
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
17360
17246
  activated$: new Observable((observer) => {
17361
17247
  const getValue = () => {
17362
17248
  const workbook = instanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
@@ -18103,7 +17989,7 @@ function TextColorSelectorMenuItemFactory(accessor) {
18103
17989
  selectable: false
18104
17990
  },
18105
17991
  value$: new Observable((subscriber) => {
18106
- const defaultValue = DEFAULT_STYLES.cl.rgb;
17992
+ const defaultValue = themeService.getColorFromTheme("gray.900");
18107
17993
  const { isAllValuesSame, value: currentValue } = selectionManagerService.getCellStylesProperty("cl");
18108
17994
  if (isAllValuesSame) subscriber.next((currentValue === null || currentValue === void 0 ? void 0 : currentValue.rgb) ?? defaultValue);
18109
17995
  else subscriber.next(defaultValue);
@@ -20179,7 +20065,7 @@ function getEmbedSheetsTabCustomData(snapshot) {
20179
20065
  function isEmbedSheetsTabCustomData(value) {
20180
20066
  if (!value || typeof value !== "object") return false;
20181
20067
  const candidate = value;
20182
- return candidate.version === 1 && typeof candidate.embedId === "string" && typeof candidate.hostAnchorId === "string";
20068
+ return candidate.version === 1 && typeof candidate.embedId === "string" && typeof candidate.hostAnchorId === "string" && (candidate.childType === void 0 || typeof candidate.childType === "number");
20183
20069
  }
20184
20070
 
20185
20071
  //#endregion
@@ -20188,10 +20074,6 @@ const ISheetEmbedRuntimeService = createIdentifier("sheet-ui.embed-runtime.servi
20188
20074
 
20189
20075
  //#endregion
20190
20076
  //#region src/views/auto-fill-popup-menu/AutoFillPopupMenu.tsx
20191
- const useUpdate = () => {
20192
- const [, setState] = useState({});
20193
- return useCallback(() => setState((prevState) => !prevState), []);
20194
- };
20195
20077
  function AutoFillPopupMenu() {
20196
20078
  const commandService = useDependency(ICommandService);
20197
20079
  const univerInstanceService = useDependency(IUniverInstanceService);
@@ -20221,7 +20103,8 @@ function AutoFillPopupMenu() {
20221
20103
  col: -1
20222
20104
  }, false, [autoFillService]);
20223
20105
  const selected = useObservable(autoFillService.applyType$, AUTO_FILL_APPLY_TYPE.SERIES);
20224
- const [isHovered, setHovered] = useState(false);
20106
+ const [isHovered, setIsHovered] = useState(false);
20107
+ const [, forceUpdate] = useReducer((version) => version + 1, 0);
20225
20108
  const workbook = useActiveWorkbook();
20226
20109
  const sheetSkeletonManagerService = useMemo(() => {
20227
20110
  if (workbook) {
@@ -20231,14 +20114,13 @@ function AutoFillPopupMenu() {
20231
20114
  return null;
20232
20115
  }, [workbook, renderManagerService]);
20233
20116
  const handleMouseEnter = () => {
20234
- setHovered(true);
20117
+ setIsHovered(true);
20235
20118
  };
20236
20119
  const handleMouseLeave = () => {
20237
- setHovered(false);
20120
+ setIsHovered(false);
20238
20121
  };
20239
- const forceUpdate = useUpdate();
20240
20122
  useEffect(() => {
20241
- return commandService.onCommandExecuted((command, options) => {
20123
+ return commandService.onCommandExecuted((command) => {
20242
20124
  if (command.id === SetScrollOperation.id) forceUpdate();
20243
20125
  }).dispose;
20244
20126
  }, [forceUpdate, commandService]);
@@ -20283,7 +20165,11 @@ function AutoFillPopupMenu() {
20283
20165
  const showMore = visible || isHovered;
20284
20166
  const availableMenu = menu.filter((item) => !item.disable);
20285
20167
  return /* @__PURE__ */ jsx("div", {
20286
- className: "univer-absolute univer-inset-0 univer-z-10 univer-size-0",
20168
+ className: "univer-absolute univer-z-10 univer-size-0",
20169
+ style: {
20170
+ left: 0,
20171
+ top: 0
20172
+ },
20287
20173
  children: /* @__PURE__ */ jsx("div", {
20288
20174
  className: "univer-absolute",
20289
20175
  style: {
@@ -20308,9 +20194,9 @@ function AutoFillPopupMenu() {
20308
20194
  children: /* @__PURE__ */ jsxs("div", {
20309
20195
  className: clsx("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800", borderClassName, {
20310
20196
  "univer-bg-gray-100 dark:!univer-bg-gray-800": visible,
20311
- "univer-bg-white dark:!univer-bg-gray-900": !visible
20197
+ "univer-bg-gray-0 dark:!univer-bg-gray-900": !visible
20312
20198
  }),
20313
- children: [/* @__PURE__ */ jsx(AutofillDoubleIcon, { className: "univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white" }), showMore && /* @__PURE__ */ jsx(MoreDownIcon, { className: "dark:!univer-text-white" })]
20199
+ children: [/* @__PURE__ */ jsx(AutofillDoubleIcon, { className: "univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-gray-0" }), showMore && /* @__PURE__ */ jsx(MoreDownIcon, { className: "dark:!univer-text-gray-0" })]
20314
20200
  })
20315
20201
  })
20316
20202
  })
@@ -20457,7 +20343,7 @@ const EDITOR_DEFAULT_POSITION = {
20457
20343
  left: HIDDEN_EDITOR_POSITION
20458
20344
  };
20459
20345
  const CELL_EDITOR_DARK_SURFACE_THEME_COLOR = "gray.800";
20460
- const CELL_EDITOR_LIGHT_SURFACE_THEME_COLOR = "white";
20346
+ const CELL_EDITOR_LIGHT_SURFACE_THEME_COLOR = "gray.0";
20461
20347
  /**
20462
20348
  * @returns the host background color for the cell editor.
20463
20349
  */
@@ -20516,6 +20402,7 @@ function isEmbedRuntimeEditorOrPopup(target) {
20516
20402
  * @returns the rendered cell editor container.
20517
20403
  */
20518
20404
  function EditorContainer() {
20405
+ var _workbook$getSheetByS;
20519
20406
  const [state, setState] = useState({ ...EDITOR_DEFAULT_POSITION });
20520
20407
  const cellEditorManagerService = useDependency(ICellEditorManagerService);
20521
20408
  const injector = useDependency(Injector);
@@ -20534,9 +20421,12 @@ function EditorContainer() {
20534
20421
  const disableAutoFocus = useObservable(() => contextService.subscribeContextValue$(DISABLE_AUTO_FOCUS_KEY), false, void 0, [contextService, DISABLE_AUTO_FOCUS_KEY]);
20535
20422
  const FormulaEditor = componentManager.get(EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY);
20536
20423
  const editState = useObservable(editorBridgeService.currentEditCellState$);
20424
+ const workbook = editState ? instanceService.getUnit(editState.unitId, UniverInstanceType.UNIVER_SHEET) ?? null : null;
20425
+ const activeSheet = useActiveWorksheet(workbook);
20537
20426
  const darkMode = useObservable(themeService.darkMode$, themeService.darkMode);
20538
20427
  const [showEditCellAddress, setShowEditCellAddress] = useState(false);
20539
- const editCellAddress = editState ? `${numberToABC(editState.column)}${editState.row + 1}` : null;
20428
+ const editSheetName = editState ? workbook === null || workbook === void 0 || (_workbook$getSheetByS = workbook.getSheetBySheetId(editState.sheetId)) === null || _workbook$getSheetByS === void 0 ? void 0 : _workbook$getSheetByS.getName() : null;
20429
+ const editCellAddress = editState ? `${activeSheet && editSheetName && activeSheet.getSheetId() !== editState.sheetId ? `'${quoteSheetName(editSheetName)}'!` : ""}${numberToABC(editState.column)}${editState.row + 1}` : null;
20540
20430
  const editorBorderColor = genNormalSelectionStyle(themeService).stroke;
20541
20431
  const focusCoordinator = injector.has(ISheetEmbedRuntimeFocusCoordinator) ? injector.get(ISheetEmbedRuntimeFocusCoordinator) : void 0;
20542
20432
  const resolveRuntimeFocusState = () => {
@@ -20856,7 +20746,7 @@ function EditorContainer() {
20856
20746
  className: "univer-pointer-events-none univer-absolute univer-left-0 univer-top-0 univer-z-10 univer-whitespace-nowrap univer-rounded-t univer-px-1.5 univer-text-xs univer-leading-5",
20857
20747
  style: {
20858
20748
  backgroundColor: editorBorderColor,
20859
- color: themeService.getColorFromTheme("white"),
20749
+ color: themeService.getColorFromTheme("gray.0"),
20860
20750
  transform: "translateY(-100%)"
20861
20751
  },
20862
20752
  children: editCellAddress
@@ -21093,7 +20983,13 @@ function DefinedName({ disable }) {
21093
20983
  return () => {
21094
20984
  subscription.unsubscribe();
21095
20985
  };
21096
- }, []);
20986
+ }, [
20987
+ definedNamesService,
20988
+ lexerTreeBuilder,
20989
+ selectionManagerService,
20990
+ unitId,
20991
+ workbook
20992
+ ]);
21097
20993
  const handleDefinedNamesList = debounce((value) => {
21098
20994
  const hasMatch = definedNames.find((i) => i.name.toLowerCase().includes(value.toLowerCase()));
21099
20995
  if (hasMatch && !open) setOpen(true);
@@ -21195,7 +21091,7 @@ function DefinedName({ disable }) {
21195
21091
  className: "univer-relative univer-box-border univer-flex univer-h-full univer-w-24 univer-border-r-gray-200 univer-py-1.5 univer-transition-all",
21196
21092
  children: [/* @__PURE__ */ jsx("input", {
21197
21093
  ref: inputRef,
21198
- className: clsx("univer-box-border univer-size-full univer-appearance-none univer-pl-1.5 univer-pr-5 univer-text-gray-900 focus:univer-outline-none rtl:univer-pl-5 rtl:univer-pr-1.5 dark:!univer-border-r-gray-700 dark:!univer-bg-gray-900 dark:!univer-text-white", borderRightClassName, { "univer-cursor-not-allowed": disable }),
21094
+ className: clsx("univer-box-border univer-size-full univer-appearance-none univer-bg-transparent univer-pl-1.5 univer-pr-5 univer-text-gray-900 focus:univer-outline-none dark:!univer-border-r-gray-700 dark:!univer-text-gray-0", borderRightClassName, { "univer-cursor-not-allowed": disable }),
21199
21095
  type: "text",
21200
21096
  value: inputValue,
21201
21097
  onChange: handleChangeSelection,
@@ -21214,7 +21110,7 @@ function DefinedName({ disable }) {
21214
21110
  onOpenChange: setOpen,
21215
21111
  onOpenAutoFocus: (e) => e.preventDefault(),
21216
21112
  children: /* @__PURE__ */ jsx("a", {
21217
- className: clsx("univer-absolute univer-right-0 univer-top-0 univer-flex univer-h-full univer-cursor-pointer univer-items-center univer-justify-center univer-px-1 univer-transition-colors univer-duration-200 hover:univer-bg-gray-100 rtl:univer-left-0 rtl:univer-right-auto dark:!univer-text-white dark:hover:!univer-bg-gray-800", { "univer-cursor-not-allowed univer-text-gray-300 hover:univer-bg-transparent dark:!univer-text-gray-700": disable }),
21113
+ className: clsx("univer-absolute univer-right-0 univer-top-0 univer-flex univer-h-full univer-cursor-pointer univer-items-center univer-justify-center univer-px-1 univer-transition-colors univer-duration-200 hover:univer-bg-gray-100 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-800", { "univer-cursor-not-allowed univer-text-gray-300 hover:univer-bg-transparent dark:!univer-text-gray-700": disable }),
21218
21114
  children: /* @__PURE__ */ jsx(MoreDownIcon, {})
21219
21115
  })
21220
21116
  })]
@@ -21349,7 +21245,7 @@ function FormulaBar(props) {
21349
21245
  const workbookEditDisable = !((workbookEditablePermission === null || workbookEditablePermission === void 0 ? void 0 : workbookEditablePermission.value) ?? true);
21350
21246
  const editorActivationDisable = editDisable || workbookEditDisable;
21351
21247
  const disabled = editDisable || imageDisable;
21352
- const shouldSkipFocus = useRef(false);
21248
+ const shouldSkipFocusRef = useRef(false);
21353
21249
  const handlePointerDown = () => {
21354
21250
  try {
21355
21251
  contextService.setContextValue(FOCUSING_FX_BAR_EDITOR, true);
@@ -21364,25 +21260,26 @@ function FormulaBar(props) {
21364
21260
  unitId: editState.unitId
21365
21261
  })) {
21366
21262
  contextService.setContextValue(FOCUSING_FX_BAR_EDITOR, false);
21367
- shouldSkipFocus.current = true;
21263
+ shouldSkipFocusRef.current = true;
21368
21264
  }
21369
21265
  }
21370
21266
  } catch (e) {
21371
21267
  contextService.setContextValue(FOCUSING_FX_BAR_EDITOR, false);
21372
- shouldSkipFocus.current = true;
21268
+ shouldSkipFocusRef.current = true;
21373
21269
  throw e;
21374
21270
  }
21375
21271
  };
21376
21272
  const handlePointerUp = () => {
21377
- if (shouldSkipFocus.current) setTimeout(() => {
21273
+ if (shouldSkipFocusRef.current) setTimeout(() => {
21378
21274
  editorService.blur(true);
21379
21275
  }, 30);
21380
- shouldSkipFocus.current = false;
21276
+ shouldSkipFocusRef.current = false;
21381
21277
  };
21382
21278
  const hideEditor = isCellImage(editState === null || editState === void 0 || (_editState$documentLa = editState.documentLayoutObject.documentModel) === null || _editState$documentLa === void 0 ? void 0 : _editState$documentLa.getSnapshot()) || viewDisable;
21383
21279
  return /* @__PURE__ */ jsxs("div", {
21280
+ dir: "ltr",
21384
21281
  "data-u-comp": "formula-bar",
21385
- className: clsx("univer-box-border univer-flex univer-bg-white univer-transition-[height] univer-ease-linear dark:!univer-bg-gray-800", borderBottomClassName, className, {
21282
+ className: clsx("univer-box-border univer-flex univer-bg-gray-0 univer-text-gray-900 univer-transition-[height] univer-ease-linear dark:!univer-bg-gray-800", borderBottomClassName, className, {
21386
21283
  "univer-h-7": arrowDirection === 0,
21387
21284
  "univer-h-20": arrowDirection === 1,
21388
21285
  "univer-pointer-events-none": editDisable
@@ -21400,17 +21297,17 @@ function FormulaBar(props) {
21400
21297
  className: clsx("univer-relative univer-box-border univer-flex univer-h-full univer-w-20 univer-items-center univer-justify-center univer-text-xs", borderRightClassName),
21401
21298
  children: [
21402
21299
  /* @__PURE__ */ jsx("span", {
21403
- className: clsx("univer-flex univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base dark:!univer-text-white", { "univer-cursor-pointer univer-text-red-600 hover:univer-bg-gray-100 dark:!univer-text-green-400 dark:hover:!univer-bg-gray-700": iconActivated }),
21300
+ className: clsx("univer-flex univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base dark:!univer-text-gray-0", { "univer-cursor-pointer univer-text-red-600 hover:univer-bg-gray-100 dark:!univer-text-green-400 dark:hover:!univer-bg-gray-700": iconActivated }),
21404
21301
  onClick: handleCloseBtnClick,
21405
21302
  children: /* @__PURE__ */ jsx(CloseIcon, {})
21406
21303
  }),
21407
21304
  /* @__PURE__ */ jsx("span", {
21408
- className: clsx("univer-flex univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base dark:!univer-text-white", { "univer-cursor-pointer univer-text-green-600 hover:univer-bg-gray-100 dark:!univer-text-red-400 dark:hover:!univer-bg-gray-700": iconActivated }),
21305
+ className: clsx("univer-flex univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base dark:!univer-text-gray-0", { "univer-cursor-pointer univer-text-green-600 hover:univer-bg-gray-100 dark:!univer-text-red-400 dark:hover:!univer-bg-gray-700": iconActivated }),
21409
21306
  onClick: handleConfirmBtnClick,
21410
21307
  children: /* @__PURE__ */ jsx(CheckMarkIcon, {})
21411
21308
  }),
21412
21309
  /* @__PURE__ */ jsx("span", {
21413
- className: "univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base hover:univer-bg-gray-100 dark:!univer-text-white dark:hover:!univer-bg-gray-700",
21310
+ className: "univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base hover:univer-bg-gray-100 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-700",
21414
21311
  onClick: handlerFxBtnClick,
21415
21312
  children: /* @__PURE__ */ jsx(FxIcon, {})
21416
21313
  })
@@ -21420,7 +21317,7 @@ function FormulaBar(props) {
21420
21317
  className: "univer-flex univer-w-full univer-flex-1 univer-overflow-hidden univer-pl-3",
21421
21318
  children: [/* @__PURE__ */ jsxs("div", {
21422
21319
  ref,
21423
- className: "univer-relative univer-flex-1 univer-bg-white dark:!univer-bg-gray-800",
21320
+ className: "univer-relative univer-flex-1 univer-bg-gray-0 dark:!univer-bg-gray-800",
21424
21321
  onPointerDown: handlePointerDown,
21425
21322
  onPointerUp: handlePointerUp,
21426
21323
  style: { pointerEvents: hideEditor ? "none" : "auto" },
@@ -21445,7 +21342,7 @@ function FormulaBar(props) {
21445
21342
  },
21446
21343
  autoScrollbar: false,
21447
21344
  disableContextMenu: false
21448
- }), hideEditor && /* @__PURE__ */ jsx("div", { className: "univer-pointer-events-none univer-relative univer-left-0 univer-top-0 univer-z-[100] univer-size-full univer-cursor-not-allowed univer-bg-white dark:!univer-bg-gray-800" })]
21345
+ }), hideEditor && /* @__PURE__ */ jsx("div", { className: "univer-pointer-events-none univer-relative univer-left-0 univer-top-0 univer-z-[100] univer-size-full univer-cursor-not-allowed univer-bg-gray-0 dark:!univer-bg-gray-800" })]
21449
21346
  }), /* @__PURE__ */ jsx("div", {
21450
21347
  className: clsx("univer-flex univer-h-full univer-w-5 univer-cursor-pointer univer-items-center univer-justify-center univer-text-xs univer-text-gray-700 dark:!univer-text-gray-200", { "univer-cursor-not-allowed univer-text-gray-200 dark:!univer-text-gray-700": editDisable }),
21451
21348
  onClick: handleArrowClick,
@@ -21586,7 +21483,7 @@ function SheetBarItem(props) {
21586
21483
  const themeService = useDependency(ThemeService);
21587
21484
  const getTextColor = (color) => {
21588
21485
  const darkTextColor = themeService.getColorFromTheme("gray.900");
21589
- const lightTextColor = themeService.getColorFromTheme("white");
21486
+ const lightTextColor = themeService.getColorFromTheme("gray.0");
21590
21487
  return new ColorKit(color).isDark() ? lightTextColor : darkTextColor;
21591
21488
  };
21592
21489
  const currentSelected = Boolean(selected);
@@ -21600,8 +21497,8 @@ function SheetBarItem(props) {
21600
21497
  onKeyDown,
21601
21498
  onClick,
21602
21499
  className: clsx("univer-mx-1 univer-box-border univer-flex univer-flex-grow univer-cursor-pointer univer-select-none univer-flex-row univer-items-center univer-rounded univer-text-xs univer-transition-[colors,box-shadow] focus-visible:univer-ring-2 focus-visible:univer-ring-primary-500", {
21603
- "dark:!univer-text-white": !color || color && !textColor,
21604
- "univer-justify-center univer-bg-white univer-font-bold univer-text-primary-700 univer-shadow": currentSelected,
21500
+ "dark:!univer-text-gray-0": !color || color && !textColor,
21501
+ "univer-justify-center univer-bg-gray-0 univer-font-bold univer-text-primary-700 univer-shadow": currentSelected,
21605
21502
  "dark:!univer-bg-gray-700": currentSelected && !color,
21606
21503
  "univer-font-medium univer-text-gray-900 hover:univer-bg-gray-100": !currentSelected,
21607
21504
  "dark:hover:!univer-bg-gray-700": !currentSelected && !color
@@ -22528,6 +22425,32 @@ const SCROLL_SHADOW_NONE = "";
22528
22425
  const SCROLL_SHADOW_LEFT = "inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2)";
22529
22426
  const SCROLL_SHADOW_RIGHT = "inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)";
22530
22427
  const SCROLL_SHADOW_BOTH = "inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2), inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)";
22428
+ function EmbedSheetTabProductIcon({ childType }) {
22429
+ const className = "univer-size-4 univer-shrink-0";
22430
+ switch (childType) {
22431
+ case UniverInstanceType.UNIVER_SHEET: return /* @__PURE__ */ jsx(SheetsMultiIcon, {
22432
+ "aria-hidden": true,
22433
+ className
22434
+ });
22435
+ case UniverInstanceType.UNIVER_DOC: return /* @__PURE__ */ jsx(DocsMultiIcon, {
22436
+ "aria-hidden": true,
22437
+ className
22438
+ });
22439
+ case UniverInstanceType.UNIVER_SLIDE: return /* @__PURE__ */ jsx(SlidesMultiIcon, {
22440
+ "aria-hidden": true,
22441
+ className
22442
+ });
22443
+ case UniverInstanceType.UNIVER_BASE: return /* @__PURE__ */ jsx(BasesMultiIcon, {
22444
+ "aria-hidden": true,
22445
+ className
22446
+ });
22447
+ case UniverInstanceType.UNIVER_BOARD: return /* @__PURE__ */ jsx(BoardsMultiIcon, {
22448
+ "aria-hidden": true,
22449
+ className
22450
+ });
22451
+ default: return null;
22452
+ }
22453
+ }
22531
22454
  function getScrollShadow(state) {
22532
22455
  const { leftEnd, rightEnd } = state;
22533
22456
  if (leftEnd && rightEnd) return SCROLL_SHADOW_NONE;
@@ -22548,6 +22471,7 @@ function shouldRefreshSheetTabs(commandInfo) {
22548
22471
  }
22549
22472
  }
22550
22473
  function SheetBarTabs() {
22474
+ const injector = useDependency(Injector);
22551
22475
  const [sheetList, setSheetList] = useState([]);
22552
22476
  const [activeSheetId, setActiveSheetId] = useState("");
22553
22477
  const [scrollShadow, setScrollShadow] = useState("");
@@ -22669,19 +22593,28 @@ function SheetBarTabs() {
22669
22593
  const updateSheetItems = useCallback(() => {
22670
22594
  const activeSheet = workbook.getActiveSheet();
22671
22595
  const currentSubUnitId = (activeSheet === null || activeSheet === void 0 ? void 0 : activeSheet.getSheetId()) ?? "";
22596
+ const embedRuntimeService = injector.has(ISheetEmbedRuntimeService) ? injector.get(ISheetEmbedRuntimeService) : void 0;
22672
22597
  const sheetListItems = workbook.getSheets().filter((sheet) => !sheet.isSheetHidden()).map((sheet, index) => {
22598
+ var _embedRuntimeService$;
22673
22599
  const worksheetRule = worksheetProtectionRuleModel.getRule(workbook.getUnitId(), sheet.getSheetId());
22674
22600
  const hasSelectionRule = rangeProtectionRuleModel.getSubunitRuleList(workbook.getUnitId(), sheet.getSheetId()).length > 0;
22675
22601
  const hasProtection = Boolean((worksheetRule === null || worksheetRule === void 0 ? void 0 : worksheetRule.permissionId) || hasSelectionRule);
22602
+ const embedData = getEmbedSheetsTabCustomData(sheet.getConfig());
22603
+ const embedChildType = (embedData === null || embedData === void 0 ? void 0 : embedData.childType) ?? (embedData ? embedRuntimeService === null || embedRuntimeService === void 0 || (_embedRuntimeService$ = embedRuntimeService.getSheetTabChildType) === null || _embedRuntimeService$ === void 0 ? void 0 : _embedRuntimeService$.call(embedRuntimeService, {
22604
+ hostUnitId: workbook.getUnitId(),
22605
+ hostAnchorId: embedData.hostAnchorId,
22606
+ embedId: embedData.embedId
22607
+ }) : void 0);
22676
22608
  return {
22677
22609
  sheetId: sheet.getSheetId(),
22678
- label: hasProtection ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(LockIcon, { className: "univer-shrink-0" }), /* @__PURE__ */ jsx("span", {
22679
- className: "univer-truncate univer-outline-none",
22680
- children: sheet.getName()
22681
- })] }) : /* @__PURE__ */ jsx("span", {
22682
- className: "univer-truncate univer-outline-none",
22683
- children: sheet.getName()
22684
- }),
22610
+ label: /* @__PURE__ */ jsxs(Fragment, { children: [
22611
+ embedChildType != null && /* @__PURE__ */ jsx(EmbedSheetTabProductIcon, { childType: embedChildType }),
22612
+ hasProtection && /* @__PURE__ */ jsx(LockIcon, { className: "univer-shrink-0" }),
22613
+ /* @__PURE__ */ jsx("span", {
22614
+ className: "univer-truncate univer-outline-none",
22615
+ children: sheet.getName()
22616
+ })
22617
+ ] }),
22685
22618
  index,
22686
22619
  selected: activeSheet === sheet,
22687
22620
  color: sheet.getTabColor() ?? void 0
@@ -22690,6 +22623,7 @@ function SheetBarTabs() {
22690
22623
  setSheetList(sheetListItems);
22691
22624
  setActiveSheetId(currentSubUnitId);
22692
22625
  }, [
22626
+ injector,
22693
22627
  rangeProtectionRuleModel,
22694
22628
  workbook,
22695
22629
  worksheetProtectionRuleModel
@@ -23157,120 +23091,98 @@ const functionDisplayNames = {
23157
23091
  [FUNCTION_NAMES_STATISTICAL.COUNTA]: "sheets-ui.statusbar.countA",
23158
23092
  [FUNCTION_NAMES_TEXT.CONCATENATE]: "concatenate"
23159
23093
  };
23160
- const CopyableStatisticItem = (item) => {
23161
- const localeService = useDependency(LocaleService);
23162
- const messageService = useDependency(IMessageService);
23163
- const clipboardService = useDependency(IClipboardInterfaceService);
23164
- const formateValue = formatNumber(item);
23165
- const copyToClipboard = async () => {
23166
- await clipboardService.writeText(item.value.toString());
23167
- messageService.show({
23168
- type: MessageType.Success,
23169
- content: localeService.t("sheets-ui.statusbar.copied")
23170
- });
23171
- };
23172
- return /* @__PURE__ */ jsx(Tooltip, {
23173
- title: localeService.t("sheets-ui.statusbar.clickToCopy"),
23174
- placement: "top",
23175
- children: /* @__PURE__ */ jsx("div", {
23176
- className: "univer-flex univer-cursor-pointer univer-truncate univer-text-center univer-text-xs univer-text-gray-400",
23177
- onClick: copyToClipboard,
23178
- children: /* @__PURE__ */ jsx("span", { children: `${localeService.t((functionDisplayNames === null || functionDisplayNames === void 0 ? void 0 : functionDisplayNames[item.name]) || item.name)}: ${formateValue}` })
23179
- }, item.name)
23180
- });
23181
- };
23182
23094
  function formatNumber(item) {
23183
23095
  const { pattern, value: num } = item;
23184
23096
  if (typeof num !== "number") return 0;
23185
- if (num >= 1e8) return num.toExponential(2);
23186
23097
  if (pattern && allowPatternFunctions.includes(item.name)) return numfmt.format(pattern, num, { throws: false });
23187
23098
  return num.toLocaleString();
23188
23099
  }
23189
23100
 
23190
23101
  //#endregion
23191
23102
  //#region src/views/status-bar/StatusBar.tsx
23192
- const SINGLE_MODE_WIDTH = 800;
23193
- const ROW_COUNT_THRESHOLD = 3;
23194
23103
  const StatusBar = () => {
23195
- const [isSingle, setIsSingle] = useState(window.innerWidth < SINGLE_MODE_WIDTH);
23104
+ const localeService = useDependency(LocaleService);
23196
23105
  const statusBarService = useDependency(IStatusBarService);
23197
- const items = statusBarService.getFunctions().map((item, index) => ({
23106
+ const [selectedFunction, setSelectedFunction] = useState(FUNCTION_NAMES_MATH.SUM);
23107
+ const [open, setOpen] = useState(false);
23108
+ const [statistics, setStatistics] = useState(() => statusBarService.getFunctions().map((item) => ({
23198
23109
  name: item.func,
23199
23110
  value: 0,
23200
23111
  show: true,
23201
- disable: false,
23112
+ disable: true,
23202
23113
  pattern: null
23203
- }));
23204
- const useStatistics = (initialItems, statusBarService, isSingle) => {
23205
- const [statistics, setStatistics] = useState(initialItems);
23206
- const [show, setShow] = useState(true);
23207
- const filteredStatistics = useMemo(() => statistics.filter((item) => item.show && !item.disable), [statistics]);
23208
- const firstItem = useMemo(() => filteredStatistics.find((item) => item.show && !item.disable), [filteredStatistics]);
23209
- const showList = useMemo(() => isSingle && firstItem ? [firstItem] : filteredStatistics, [
23210
- isSingle,
23211
- firstItem,
23212
- filteredStatistics
23213
- ]);
23214
- const updateStatistics = useCallback((state) => {
23215
- const items = state === null || state === void 0 ? void 0 : state.values;
23216
- if (!(items === null || items === void 0 ? void 0 : items.length)) {
23217
- setShow(false);
23218
- return;
23219
- }
23220
- setShow(true);
23221
- setStatistics((prevStats) => prevStats.map((stat) => {
23222
- var _items$find;
23114
+ })));
23115
+ useEffect(() => {
23116
+ const subscription = statusBarService.state$.subscribe((state) => {
23117
+ const values = (state === null || state === void 0 ? void 0 : state.values) ?? [];
23118
+ setStatistics((previousStatistics) => previousStatistics.map((statistic) => {
23119
+ const value = values.find((item) => item.func === statistic.name);
23223
23120
  return {
23224
- ...stat,
23225
- value: ((_items$find = items.find((i) => i.func === stat.name)) === null || _items$find === void 0 ? void 0 : _items$find.value) ?? stat.value,
23226
- disable: !items.some((i) => i.func === stat.name),
23121
+ ...statistic,
23122
+ value: (value === null || value === void 0 ? void 0 : value.value) ?? statistic.value,
23123
+ disable: !value,
23227
23124
  pattern: (state === null || state === void 0 ? void 0 : state.pattern) ?? null
23228
23125
  };
23229
23126
  }));
23230
- }, []);
23231
- useEffect(() => {
23232
- const subscription = statusBarService.state$.subscribe(updateStatistics);
23233
- return () => subscription.unsubscribe();
23234
- }, [statusBarService, updateStatistics]);
23235
- return {
23236
- statistics,
23237
- showList,
23238
- show
23239
- };
23127
+ });
23128
+ return () => subscription.unsubscribe();
23129
+ }, [statusBarService]);
23130
+ const availableStatistics = statistics.filter((item) => item.show && !item.disable);
23131
+ const selectedStatistic = availableStatistics.find((item) => item.name === selectedFunction) ?? availableStatistics.find((item) => item.name === FUNCTION_NAMES_MATH.SUM) ?? availableStatistics[0];
23132
+ if (!selectedStatistic) return null;
23133
+ const formatStatistic = (item) => {
23134
+ const localeKey = functionDisplayNames[item.name] || item.name;
23135
+ return `${localeService.t(localeKey)}: ${formatNumber(item)}`;
23240
23136
  };
23241
- const { showList, show } = useStatistics(items, statusBarService, isSingle);
23242
- const handleResize = debounce(() => {
23243
- const newSingleState = window.innerWidth < SINGLE_MODE_WIDTH;
23244
- if (isSingle !== newSingleState) setIsSingle(newSingleState);
23245
- }, 100);
23246
- useEffect(() => {
23247
- window.addEventListener("resize", handleResize);
23248
- return () => {
23249
- window.removeEventListener("resize", handleResize);
23250
- };
23251
- }, [isSingle]);
23252
- const getStatisticLayout = (showList, rowCountThreshold, CopyableStatisticItem) => {
23253
- if (showList.length > rowCountThreshold) return showList.reduce((acc, _, index) => {
23254
- if (index % 2 === 0) acc.push(showList.slice(index, index + 2));
23255
- return acc;
23256
- }, []).map((item, index) => /* @__PURE__ */ jsxs("div", {
23257
- className: "univer-grid univer-h-full univer-items-center",
23258
- children: [item[0] && /* @__PURE__ */ jsx(CopyableStatisticItem, { ...item[0] }, item[0].name), item[1] && /* @__PURE__ */ jsx(CopyableStatisticItem, { ...item[1] }, item[1].name)]
23259
- }, `stat-col-${index}`));
23260
- return showList.map((item) => /* @__PURE__ */ jsx("div", {
23261
- className: "univer-grid univer-h-full univer-items-center",
23262
- children: /* @__PURE__ */ jsx(CopyableStatisticItem, { ...item })
23263
- }, item.name));
23137
+ const handleSelect = (name) => {
23138
+ setSelectedFunction(name);
23139
+ setOpen(false);
23264
23140
  };
23265
- const renderContent = getStatisticLayout(showList, ROW_COUNT_THRESHOLD, CopyableStatisticItem);
23266
- return show && /* @__PURE__ */ jsx("div", {
23267
- className: clsx("univer-relative univer-box-border univer-flex univer-h-full univer-items-center univer-overflow-hidden univer-px-2 after:univer-absolute after:univer-right-0 after:univer-top-1/2 after:univer-block after:univer-h-4 after:univer-w-px after:-univer-translate-y-1/2 after:univer-bg-gray-200 after:univer-content-[\"\"]", {
23268
- "univer-max-w-32": isSingle,
23269
- "univer-max-w-fit": !isSingle
23270
- }),
23271
- children: /* @__PURE__ */ jsx("div", {
23272
- className: "univer-flex univer-h-full univer-gap-x-2",
23273
- children: renderContent
23141
+ return /* @__PURE__ */ jsx("div", {
23142
+ className: "univer-relative univer-box-border univer-flex univer-h-full univer-min-w-0 univer-max-w-64 univer-items-center univer-overflow-hidden univer-px-2 after:univer-absolute after:univer-right-0 after:univer-top-1/2 after:univer-block after:univer-h-4 after:univer-w-px after:-univer-translate-y-1/2 after:univer-bg-gray-200 after:univer-content-[\"\"]",
23143
+ children: /* @__PURE__ */ jsx(Dropdown, {
23144
+ align: "end",
23145
+ side: "top",
23146
+ open,
23147
+ onOpenChange: setOpen,
23148
+ overlay: /* @__PURE__ */ jsx("div", {
23149
+ "data-u-comp": "status-bar-statistic-menu",
23150
+ className: "univer-grid univer-w-max univer-max-w-[calc(100vw-16px)] univer-gap-0.5 univer-p-1.5",
23151
+ children: availableStatistics.map((item) => {
23152
+ const text = formatStatistic(item);
23153
+ const selected = item.name === selectedStatistic.name;
23154
+ return /* @__PURE__ */ jsxs("button", {
23155
+ type: "button",
23156
+ className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded univer-border-none univer-bg-transparent univer-px-2 univer-py-1.5 univer-text-left univer-text-xs univer-text-gray-900 hover:univer-bg-gray-100 dark:!univer-text-gray-200 dark:hover:!univer-bg-gray-800", { "univer-bg-gray-100 dark:!univer-bg-gray-800": selected }),
23157
+ "aria-pressed": selected,
23158
+ onClick: () => handleSelect(item.name),
23159
+ children: [/* @__PURE__ */ jsx("span", {
23160
+ className: "univer-w-3 univer-shrink-0",
23161
+ children: selected && /* @__PURE__ */ jsx(CheckMarkIcon, {})
23162
+ }), /* @__PURE__ */ jsx(Tooltip, {
23163
+ title: text,
23164
+ placement: "top",
23165
+ children: /* @__PURE__ */ jsx("span", {
23166
+ className: "univer-min-w-0 univer-flex-1 univer-truncate",
23167
+ children: text
23168
+ })
23169
+ })]
23170
+ }, item.name);
23171
+ })
23172
+ }),
23173
+ children: /* @__PURE__ */ jsxs("button", {
23174
+ type: "button",
23175
+ "data-u-comp": "status-bar-statistic-picker",
23176
+ className: "univer-flex univer-min-w-0 univer-max-w-full univer-cursor-pointer univer-items-center univer-gap-1 univer-border-none univer-bg-transparent univer-p-0 univer-text-xs univer-text-gray-400",
23177
+ children: [/* @__PURE__ */ jsx(Tooltip, {
23178
+ title: formatStatistic(selectedStatistic),
23179
+ placement: "top",
23180
+ children: /* @__PURE__ */ jsx("span", {
23181
+ className: "univer-min-w-0 univer-flex-1 univer-truncate",
23182
+ children: formatStatistic(selectedStatistic)
23183
+ })
23184
+ }), /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-shrink-0" })]
23185
+ })
23274
23186
  })
23275
23187
  });
23276
23188
  };
@@ -23282,68 +23194,49 @@ function RenderSheetFooter() {
23282
23194
  const config = useConfigValue(SHEETS_UI_PLUGIN_CONFIG_KEY);
23283
23195
  const menuManagerService = useDependency(IMenuManagerService);
23284
23196
  const showFooter = (config === null || config === void 0 ? void 0 : config.footer) ?? true;
23285
- const activeWorkbook = useActiveWorkbook();
23286
- const workbook = useSheetLoadingWorkbook() ?? activeWorkbook;
23287
- const isLoading = useSheetLoading();
23197
+ const workbook = useRootWorkbenchWorkbook();
23288
23198
  const activeWorkbookEmbeddedRender = useActiveWorkbookIsEmbeddedRender(workbook);
23289
- const focusedUnitType = useFocusedUnitType();
23199
+ const rootUnitType = useWorkbenchRootUnitType();
23290
23200
  const activeEmbedTab = useActiveSheetEmbedTabData(workbook);
23291
23201
  if (!workbook || !showFooter) return null;
23292
23202
  if (activeWorkbookEmbeddedRender) return null;
23293
- if (!activeEmbedTab && focusedUnitType != null && focusedUnitType !== UniverInstanceType.UNIVER_SHEET) return null;
23203
+ if (rootUnitType !== UniverInstanceType.UNIVER_SHEET) return null;
23294
23204
  const footerMenus = menuManagerService.getMenuByPositionKey(ContextMenuPosition.FOOTER_MENU);
23295
23205
  const { sheetBar = true, statisticBar = true, menus = true, zoomSlider = true } = (config === null || config === void 0 ? void 0 : config.footer) || {};
23296
23206
  const showStatisticBar = activeEmbedTab ? false : statisticBar;
23297
23207
  const showMenus = activeEmbedTab ? false : menus;
23298
23208
  const showZoomSlider = activeEmbedTab ? false : zoomSlider;
23299
23209
  if (!sheetBar && !showStatisticBar && !showMenus && !showZoomSlider) return null;
23300
- return /* @__PURE__ */ jsx(SheetLoadingWorkbookContext.Provider, {
23301
- value: workbook,
23302
- children: /* @__PURE__ */ jsxs("section", {
23303
- className: clsx("univer-box-border univer-grid univer-w-full univer-grid-flow-col univer-grid-cols-[1fr,auto,auto,auto] univer-items-center univer-justify-between univer-bg-white univer-px-5 univer-text-gray-900 dark:!univer-bg-gray-900 dark:!univer-text-gray-200", { "univer-pointer-events-none": isLoading }),
23304
- "data-range-selector": true,
23305
- "aria-disabled": isLoading,
23306
- style: { height: 36 },
23307
- children: [
23308
- sheetBar && /* @__PURE__ */ jsx(SheetBar, {}),
23309
- showStatisticBar && /* @__PURE__ */ jsx(StatusBar, {}),
23310
- showMenus && footerMenus.length > 0 && /* @__PURE__ */ jsx("div", {
23311
- className: "univer-box-border univer-flex univer-gap-2 univer-px-2",
23312
- children: footerMenus.map((item) => {
23313
- var _item$children;
23314
- return (_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.map((child) => (child === null || child === void 0 ? void 0 : child.item) && /* @__PURE__ */ jsx(ToolbarItem, { ...child.item }, child.key));
23315
- })
23316
- }),
23317
- showZoomSlider && /* @__PURE__ */ jsx(SheetZoomSlider, {})
23318
- ]
23319
- })
23210
+ return /* @__PURE__ */ jsxs("section", {
23211
+ className: "univer-box-border univer-grid univer-w-full univer-grid-flow-col univer-grid-cols-[1fr,auto,auto,auto] univer-items-center univer-justify-between univer-bg-gray-0 univer-px-5 univer-text-gray-900 dark:!univer-bg-gray-900 dark:!univer-text-gray-200",
23212
+ "data-range-selector": true,
23213
+ style: { height: 36 },
23214
+ children: [
23215
+ sheetBar && /* @__PURE__ */ jsx(SheetBar, {}),
23216
+ showStatisticBar && /* @__PURE__ */ jsx(StatusBar, {}),
23217
+ showMenus && footerMenus.length > 0 && /* @__PURE__ */ jsx("div", {
23218
+ className: "univer-box-border univer-flex univer-gap-2 univer-px-2",
23219
+ children: footerMenus.map((item) => {
23220
+ var _item$children;
23221
+ return (_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.map((child) => (child === null || child === void 0 ? void 0 : child.item) && /* @__PURE__ */ jsx(ToolbarItem, { ...child.item }, child.key));
23222
+ })
23223
+ }),
23224
+ showZoomSlider && /* @__PURE__ */ jsx(SheetZoomSlider, {})
23225
+ ]
23320
23226
  });
23321
23227
  }
23322
23228
  function RenderSheetHeader() {
23323
23229
  const config = useConfigValue(SHEETS_UI_PLUGIN_CONFIG_KEY);
23324
- const activeWorkbook = useActiveWorkbook();
23325
- const workbook = useSheetLoadingWorkbook() ?? activeWorkbook;
23326
- const isLoading = useSheetLoading();
23230
+ const workbook = useRootWorkbenchWorkbook();
23327
23231
  const hasWorkbook = !!workbook;
23328
23232
  const activeWorkbookEmbeddedRender = useActiveWorkbookIsEmbeddedRender(workbook);
23329
- const focusedUnitType = useFocusedUnitType();
23233
+ const rootUnitType = useWorkbenchRootUnitType();
23330
23234
  const activeEmbedTab = useActiveSheetEmbedTabData(workbook);
23331
23235
  if (!hasWorkbook) return null;
23332
23236
  if (activeWorkbookEmbeddedRender) return null;
23333
23237
  if (activeEmbedTab) return null;
23334
- if (focusedUnitType != null && focusedUnitType !== UniverInstanceType.UNIVER_SHEET) return /* @__PURE__ */ jsx("div", {
23335
- "aria-hidden": true,
23336
- className: "univer-h-7 univer-border-b univer-border-gray-200 univer-bg-white dark:!univer-border-gray-700 dark:!univer-bg-gray-900",
23337
- "data-u-comp": "formula-bar-placeholder"
23338
- });
23339
- if ((config === null || config === void 0 ? void 0 : config.formulaBar) !== false) return /* @__PURE__ */ jsx(SheetLoadingWorkbookContext.Provider, {
23340
- value: workbook,
23341
- children: /* @__PURE__ */ jsx("div", {
23342
- "aria-disabled": isLoading,
23343
- className: clsx({ "univer-pointer-events-none": isLoading }),
23344
- children: /* @__PURE__ */ jsx(FormulaBar, {})
23345
- })
23346
- });
23238
+ if (rootUnitType !== UniverInstanceType.UNIVER_SHEET) return null;
23239
+ if ((config === null || config === void 0 ? void 0 : config.formulaBar) !== false) return /* @__PURE__ */ jsx(FormulaBar, {});
23347
23240
  return null;
23348
23241
  }
23349
23242
  /**
@@ -23351,18 +23244,16 @@ function RenderSheetHeader() {
23351
23244
  */
23352
23245
  function RenderSheetContent() {
23353
23246
  const config = useConfigValue(SHEETS_UI_PLUGIN_CONFIG_KEY);
23354
- const isLoading = useSheetLoading();
23355
- const isPreviewReady = useSheetLoadingPreviewReady();
23356
23247
  const componentManager = useDependency(ComponentManager);
23357
- const activeWorkbook = useActiveWorkbook();
23358
- const workbook = useSheetLoadingWorkbook() ?? activeWorkbook;
23248
+ const workbook = useRootWorkbenchWorkbook();
23359
23249
  const activeEmbedTab = useActiveSheetEmbedTabData(workbook);
23360
23250
  const injector = useDependency(Injector);
23361
23251
  const activeWorkbookEmbeddedRender = useActiveWorkbookIsEmbeddedRender(workbook);
23252
+ const rootWorkbenchOwnsSheet = useWorkbenchRootUnitType() === UniverInstanceType.UNIVER_SHEET;
23362
23253
  const ShapeTextEditorContainer = componentManager.get("SheetShapeTextEditorContainer") ?? componentManager.get("ShapeTextEditorContainer");
23363
23254
  useEffect(() => {
23364
23255
  var _tryGetSheetEmbedRunt;
23365
- if (!workbook || isLoading || activeEmbedTab || activeWorkbookEmbeddedRender) return;
23256
+ if (!workbook || activeEmbedTab || activeWorkbookEmbeddedRender || !rootWorkbenchOwnsSheet) return;
23366
23257
  const instanceService = injector.get(IUniverInstanceService);
23367
23258
  instanceService.setCurrentUnitForType(workbook.getUnitId());
23368
23259
  instanceService.focusUnit(workbook.getUnitId());
@@ -23371,11 +23262,11 @@ function RenderSheetContent() {
23371
23262
  activeEmbedTab,
23372
23263
  activeWorkbookEmbeddedRender,
23373
23264
  injector,
23374
- isLoading,
23265
+ rootWorkbenchOwnsSheet,
23375
23266
  workbook
23376
23267
  ]);
23377
23268
  if (!workbook) return null;
23378
- if (isLoading) return isPreviewReady ? null : /* @__PURE__ */ jsx(SheetLoadingSkeleton, {});
23269
+ if (!rootWorkbenchOwnsSheet) return null;
23379
23270
  if (activeWorkbookEmbeddedRender) return null;
23380
23271
  if (activeEmbedTab && workbook) return /* @__PURE__ */ jsx(RenderSheetEmbedTabHost, {
23381
23272
  workbook,
@@ -23387,42 +23278,6 @@ function RenderSheetContent() {
23387
23278
  /* @__PURE__ */ jsx(AutoFillPopupMenu, {})
23388
23279
  ] });
23389
23280
  }
23390
- function SheetLoadingSkeleton() {
23391
- return /* @__PURE__ */ jsxs("div", {
23392
- "data-u-comp": "sheet-loading-skeleton",
23393
- "aria-busy": true,
23394
- className: "univer-absolute univer-inset-0 univer-z-10 univer-overflow-hidden univer-bg-white dark:!univer-bg-gray-900",
23395
- children: [
23396
- /* @__PURE__ */ jsx("div", {
23397
- className: "univer-absolute univer-right-0 univer-top-0 univer-border-b univer-border-gray-200 univer-bg-gray-50 dark:!univer-border-gray-700 dark:!univer-bg-gray-800",
23398
- style: {
23399
- left: DEFAULT_WORKSHEET_ROW_TITLE_WIDTH,
23400
- height: DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT
23401
- }
23402
- }),
23403
- /* @__PURE__ */ jsx("div", {
23404
- className: "univer-absolute univer-bottom-0 univer-left-0 univer-border-r univer-border-gray-200 univer-bg-gray-50 dark:!univer-border-gray-700 dark:!univer-bg-gray-800",
23405
- style: {
23406
- top: DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT,
23407
- width: DEFAULT_WORKSHEET_ROW_TITLE_WIDTH
23408
- }
23409
- }),
23410
- /* @__PURE__ */ jsx("div", {
23411
- className: "univer-absolute univer-bottom-0 univer-right-0 univer-animate-pulse univer-text-gray-200 dark:!univer-text-gray-700",
23412
- style: {
23413
- top: DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT,
23414
- left: DEFAULT_WORKSHEET_ROW_TITLE_WIDTH,
23415
- backgroundImage: "linear-gradient(to right, currentColor 1px, transparent 1px), linear-gradient(to bottom, currentColor 1px, transparent 1px)",
23416
- backgroundSize: `${DEFAULT_WORKSHEET_COLUMN_WIDTH}px ${DEFAULT_WORKSHEET_ROW_HEIGHT}px`
23417
- }
23418
- }),
23419
- /* @__PURE__ */ jsx(LoadingMultiIcon, {
23420
- "aria-hidden": true,
23421
- className: "univer-absolute univer-left-1/2 univer-top-1/2 univer-size-6 -univer-translate-x-1/2 -univer-translate-y-1/2 univer-animate-spin univer-text-violet-500"
23422
- })
23423
- ]
23424
- });
23425
- }
23426
23281
  function RenderSheetEmbedTabHost(props) {
23427
23282
  const { workbook, worksheet } = props;
23428
23283
  const injector = useDependency(Injector);
@@ -23454,26 +23309,45 @@ function RenderSheetEmbedTabHost(props) {
23454
23309
  ]);
23455
23310
  return /* @__PURE__ */ jsx("div", {
23456
23311
  "data-embed-sheets-sheet-tab-host": hostAnchorId,
23457
- className: "univer-absolute univer-inset-0 univer-z-40 univer-bg-white dark:!univer-bg-gray-900"
23312
+ className: "univer-absolute univer-inset-0 univer-z-40 univer-bg-gray-0 dark:!univer-bg-gray-900"
23458
23313
  });
23459
23314
  }
23460
23315
  function useActiveWorkbookIsEmbeddedRender(workbook) {
23461
23316
  const univerInstanceService = useDependency(IUniverInstanceService);
23317
+ const renderManagerService = useDependency(IRenderManagerService);
23318
+ const injector = useDependency(Injector);
23319
+ const runtimeFocusCoordinator = injector.has(ISheetEmbedRuntimeFocusCoordinator) ? injector.get(ISheetEmbedRuntimeFocusCoordinator) : void 0;
23462
23320
  return useMemo(() => {
23463
- var _univerInstanceServic;
23321
+ var _renderManagerService, _univerInstanceServic;
23464
23322
  if (!workbook) return false;
23465
- return ((_univerInstanceServic = univerInstanceService.getUnitCreateOptions(workbook.getUnitId())) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.embeddedRender) === true;
23466
- }, [univerInstanceService, workbook]);
23323
+ return (runtimeFocusCoordinator === null || runtimeFocusCoordinator === void 0 ? void 0 : runtimeFocusCoordinator.resolveRuntimeScopeByChildUnitId(workbook.getUnitId())) != null || ((_renderManagerService = renderManagerService.getRenderUnitById(workbook.getUnitId())) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.isMainScene) === false || ((_univerInstanceServic = univerInstanceService.getUnitCreateOptions(workbook.getUnitId())) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.embeddedRender) === true;
23324
+ }, [
23325
+ useObservable(() => merge$1(renderManagerService.created$, renderManagerService.disposed$, (runtimeFocusCoordinator === null || runtimeFocusCoordinator === void 0 ? void 0 : runtimeFocusCoordinator.runtimeSessionChanged$) ?? EMPTY), null, false, [renderManagerService, runtimeFocusCoordinator]),
23326
+ renderManagerService,
23327
+ runtimeFocusCoordinator,
23328
+ univerInstanceService,
23329
+ workbook
23330
+ ]);
23467
23331
  }
23468
- function useFocusedUnitType() {
23469
- const univerInstanceService = useDependency(IUniverInstanceService);
23470
- const focusedUnitId = useObservable(() => univerInstanceService.focused$, null, false, [univerInstanceService]);
23332
+ function useRootWorkbenchWorkbook() {
23333
+ const activeWorkbook = useActiveWorkbook();
23334
+ const injector = useDependency(Injector);
23335
+ const instanceService = useDependency(IUniverInstanceService);
23336
+ const runtimeFocusCoordinator = injector.has(ISheetEmbedRuntimeFocusCoordinator) ? injector.get(ISheetEmbedRuntimeFocusCoordinator) : void 0;
23471
23337
  return useMemo(() => {
23472
- if (!focusedUnitId) return null;
23473
- if (isInternalEditorID(focusedUnitId) && univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) return UniverInstanceType.UNIVER_SHEET;
23474
- const focusedUnit = univerInstanceService.getUnit(focusedUnitId);
23475
- return (focusedUnit === null || focusedUnit === void 0 ? void 0 : focusedUnit.type) ?? null;
23476
- }, [focusedUnitId, univerInstanceService]);
23338
+ if (!activeWorkbook || !runtimeFocusCoordinator) return activeWorkbook;
23339
+ const runtimeScope = runtimeFocusCoordinator.resolveRuntimeScopeByChildUnitId(activeWorkbook.getUnitId());
23340
+ if (!(runtimeScope === null || runtimeScope === void 0 ? void 0 : runtimeScope.hostUnitId)) return activeWorkbook;
23341
+ return instanceService.getUnit(runtimeScope.hostUnitId, UniverInstanceType.UNIVER_SHEET) ?? activeWorkbook;
23342
+ }, [
23343
+ activeWorkbook,
23344
+ instanceService,
23345
+ runtimeFocusCoordinator,
23346
+ useObservable(() => (runtimeFocusCoordinator === null || runtimeFocusCoordinator === void 0 ? void 0 : runtimeFocusCoordinator.runtimeSessionChanged$) ?? EMPTY, null, false, [runtimeFocusCoordinator])
23347
+ ]);
23348
+ }
23349
+ function useWorkbenchRootUnitType() {
23350
+ return useObservable(useDependency(IWorkbenchService).rootUnitType$, null, true);
23477
23351
  }
23478
23352
  function useActiveSheetEmbedTabData(workbook) {
23479
23353
  const worksheet = useActiveWorksheet(workbook);
@@ -24098,7 +23972,7 @@ const useHighlightRange = (ranges = []) => {
24098
23972
  //#endregion
24099
23973
  //#region package.json
24100
23974
  var name = "@univerjs/sheets-ui";
24101
- var version = "1.0.0-beta.0";
23975
+ var version = "1.0.0-beta.2";
24102
23976
 
24103
23977
  //#endregion
24104
23978
  //#region src/views/cell-popup/config.ts
@@ -24268,6 +24142,8 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends Di
24268
24142
  disposable.add(this._commandService.onCommandExecuted((commandInfo) => {
24269
24143
  if (shouldUpdatePosition(commandInfo.id)) position$.next(calc());
24270
24144
  }));
24145
+ const viewMain = currentRender.scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN);
24146
+ if (viewMain) disposable.add(viewMain.onScrollAfter$.subscribeEvent(() => position$.next(calc())));
24271
24147
  return {
24272
24148
  position,
24273
24149
  position$,
@@ -24314,6 +24190,10 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends Di
24314
24190
  };
24315
24191
  const { position, position$, disposable } = this._createPositionObserver(bound, currentRender, skeleton, worksheet);
24316
24192
  const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
24193
+ const canvasElement = currentRender.engine.getCanvasElement();
24194
+ const scaleAdjust = canvasElement.getBoundingClientRect().width / pxToNum(canvasElement.style.width);
24195
+ const { scaleX, scaleY } = currentRender.scene.getAncestorScale();
24196
+ const viewMain = currentRender.scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN);
24317
24197
  const id = this._globalPopupManagerService.addPopup({
24318
24198
  ...popup,
24319
24199
  unitId,
@@ -24321,7 +24201,11 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends Di
24321
24201
  connectorInjector: popupInjector,
24322
24202
  anchorRect: position,
24323
24203
  anchorRect$: position$,
24324
- canvasElement: currentRender.engine.getCanvasElement()
24204
+ canvasElement,
24205
+ boundaryInsets: popup.constrainToCanvas ? {
24206
+ left: ((viewMain === null || viewMain === void 0 ? void 0 : viewMain.left) ?? skeleton.rowHeaderWidth * scaleX) * scaleAdjust,
24207
+ top: ((viewMain === null || viewMain === void 0 ? void 0 : viewMain.top) ?? skeleton.columnHeaderHeight * scaleY) * scaleAdjust
24208
+ } : popup.boundaryInsets
24325
24209
  });
24326
24210
  const disposableCollection = new DisposableCollection();
24327
24211
  disposableCollection.add(disposable);
@@ -24734,6 +24618,11 @@ function shouldUpdatePosition(commandId) {
24734
24618
 
24735
24619
  //#endregion
24736
24620
  //#region src/services/cell-popup-manager.service.ts
24621
+ const CELL_POPUP_DIRECTIONS = [
24622
+ "horizontal",
24623
+ "vertical",
24624
+ "left-center"
24625
+ ];
24737
24626
  let CellPopupManagerService = class CellPopupManagerService extends Disposable {
24738
24627
  constructor(_sheetCanvasPopManagerService) {
24739
24628
  super();
@@ -24789,7 +24678,7 @@ let CellPopupManagerService = class CellPopupManagerService extends Disposable {
24789
24678
  direction
24790
24679
  },
24791
24680
  noPushMinimumGap: true,
24792
- autoRelayout: false,
24681
+ autoRelayout: popup.autoRelayout ?? false,
24793
24682
  zIndex: 90
24794
24683
  }, unitId, subUnitId);
24795
24684
  subUnitMap.setValue(row, col, {
@@ -24817,31 +24706,21 @@ let CellPopupManagerService = class CellPopupManagerService extends Disposable {
24817
24706
  const subUnitMap = this._ensureCellPopupMap(unitId, subUnitId);
24818
24707
  const cache = subUnitMap.getValue(row, col);
24819
24708
  if (!cache) return;
24820
- if (cache.horizontal) {
24821
- var _cache$horizontal$dis;
24822
- (_cache$horizontal$dis = cache.horizontal.disposable) === null || _cache$horizontal$dis === void 0 || _cache$horizontal$dis.dispose();
24823
- cache.horizontal = void 0;
24824
- this._change$.next({
24825
- unitId,
24826
- subUnitId,
24827
- row,
24828
- col,
24829
- direction: "horizontal"
24830
- });
24831
- }
24832
- if (cache.vertical) {
24833
- var _cache$vertical$dispo;
24834
- (_cache$vertical$dispo = cache.vertical.disposable) === null || _cache$vertical$dispo === void 0 || _cache$vertical$dispo.dispose();
24835
- cache.vertical = void 0;
24709
+ CELL_POPUP_DIRECTIONS.forEach((direction) => {
24710
+ var _directionCache$dispo2;
24711
+ const directionCache = cache[direction];
24712
+ if (!directionCache) return;
24713
+ (_directionCache$dispo2 = directionCache.disposable) === null || _directionCache$dispo2 === void 0 || _directionCache$dispo2.dispose();
24714
+ cache[direction] = void 0;
24836
24715
  this._change$.next({
24837
24716
  unitId,
24838
24717
  subUnitId,
24839
24718
  row,
24840
24719
  col,
24841
- direction: "vertical"
24720
+ direction
24842
24721
  });
24843
- }
24844
- if (!cache.horizontal && !cache.vertical) subUnitMap.realDeleteValue(row, col);
24722
+ });
24723
+ if (CELL_POPUP_DIRECTIONS.every((direction) => !cache[direction])) subUnitMap.realDeleteValue(row, col);
24845
24724
  }
24846
24725
  hidePopupsForUnit(unitId, subUnitId) {
24847
24726
  const unitMap = this._cellPopupMap.get(unitId);
@@ -25560,12 +25439,12 @@ function BorderPanel(props) {
25560
25439
  })
25561
25440
  }),
25562
25441
  children: /* @__PURE__ */ jsxs("button", {
25563
- className: "univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded univer-border-none univer-bg-transparent univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
25442
+ className: "univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded univer-border-none univer-bg-transparent univer-p-1 univer-text-gray-900 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
25564
25443
  type: "button",
25565
25444
  children: [/* @__PURE__ */ jsx(PaintBucketDoubleIcon, {
25566
- className: "univer-fill-primary-600 dark:!univer-text-white",
25445
+ className: "univer-fill-primary-600 dark:!univer-text-gray-0",
25567
25446
  extend: { colorChannel1: (value === null || value === void 0 ? void 0 : value.color) ?? "" }
25568
- }), /* @__PURE__ */ jsx(MoreDownIcon, { className: "dark:!univer-text-white" })]
25447
+ }), /* @__PURE__ */ jsx(MoreDownIcon, { className: "dark:!univer-text-gray-0" })]
25569
25448
  })
25570
25449
  }) }), /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Dropdown, {
25571
25450
  overlay: /* @__PURE__ */ jsx("section", {
@@ -25576,19 +25455,19 @@ function BorderPanel(props) {
25576
25455
  className: "univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-px-1 univer-py-3 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
25577
25456
  onClick: () => handleClick(item.value, "style"),
25578
25457
  children: [item.value === type && /* @__PURE__ */ jsx(CheckMarkIcon, { className: "univer-absolute univer-left-3 univer-text-primary-600" }), /* @__PURE__ */ jsx(BorderLine, {
25579
- className: "univer-ml-6 univer-fill-gray-900 dark:!univer-fill-white",
25458
+ className: "univer-ml-6 univer-fill-gray-900 dark:!univer-fill-gray-0",
25580
25459
  type: item.value
25581
25460
  })]
25582
25461
  }, item.value))
25583
25462
  })
25584
25463
  }),
25585
25464
  children: /* @__PURE__ */ jsxs("button", {
25586
- className: "univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded univer-border-none univer-bg-transparent univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
25465
+ className: "univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded univer-border-none univer-bg-transparent univer-p-1 univer-text-gray-900 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
25587
25466
  type: "button",
25588
25467
  children: [/* @__PURE__ */ jsx(BorderLine, {
25589
- className: "univer-fill-gray-900 dark:!univer-fill-white",
25468
+ className: "univer-fill-gray-900 dark:!univer-fill-gray-0",
25590
25469
  type: type ?? BorderStyleTypes.THIN
25591
- }), /* @__PURE__ */ jsx(MoreDownIcon, { className: "dark:!univer-text-white" })]
25470
+ }), /* @__PURE__ */ jsx(MoreDownIcon, { className: "dark:!univer-text-gray-0" })]
25592
25471
  })
25593
25472
  }) })]
25594
25473
  })
@@ -25620,6 +25499,7 @@ let CellAlertManagerService = class CellAlertManagerService extends Disposable {
25620
25499
  });
25621
25500
  }
25622
25501
  showAlert(alert) {
25502
+ var _alert$menu, _alert$menu2, _alert$menu3;
25623
25503
  let lastPopup = this._currentAlert.get(alert.key);
25624
25504
  if (lastPopup) lastPopup.dispose.dispose();
25625
25505
  if (lastPopup) lastPopup.dispose.dispose();
@@ -25640,7 +25520,9 @@ let CellAlertManagerService = class CellAlertManagerService extends Disposable {
25640
25520
  col
25641
25521
  }, {
25642
25522
  componentKey: CELL_ALERT_KEY,
25643
- direction: "horizontal",
25523
+ direction: ((_alert$menu = alert.menu) === null || _alert$menu === void 0 ? void 0 : _alert$menu.length) ? "left-center" : "horizontal",
25524
+ autoRelayout: Boolean((_alert$menu2 = alert.menu) === null || _alert$menu2 === void 0 ? void 0 : _alert$menu2.length),
25525
+ showOnSelectionMoving: Boolean((_alert$menu3 = alert.menu) === null || _alert$menu3 === void 0 ? void 0 : _alert$menu3.length),
25644
25526
  extraProps: { alert },
25645
25527
  priority: 1
25646
25528
  });
@@ -25680,18 +25562,53 @@ CellAlertManagerService = __decorate([__decorateParam(0, IRenderManagerService),
25680
25562
  */
25681
25563
  function CellAlert({ popup }) {
25682
25564
  var _popup$extraProps;
25565
+ const [visible, setVisible] = useState(false);
25566
+ const [isHovered, setIsHovered] = useState(false);
25683
25567
  const alert = (_popup$extraProps = popup.extraProps) === null || _popup$extraProps === void 0 ? void 0 : _popup$extraProps.alert;
25684
25568
  if (!alert) return null;
25685
- const { type, title, message } = alert;
25569
+ const { type, title, message, menu } = alert;
25570
+ if (menu === null || menu === void 0 ? void 0 : menu.length) {
25571
+ const accessibleLabel = [title, message].filter((value) => typeof value === "string").join(": ");
25572
+ const showMore = visible || isHovered;
25573
+ return /* @__PURE__ */ jsx("div", {
25574
+ onMouseEnter: () => setIsHovered(true),
25575
+ onMouseLeave: () => setIsHovered(false),
25576
+ children: /* @__PURE__ */ jsx(DropdownMenu, {
25577
+ align: "start",
25578
+ open: visible,
25579
+ onOpenChange: setVisible,
25580
+ items: [
25581
+ {
25582
+ type: "custom",
25583
+ className: "univer-px-2 univer-py-1.5 univer-font-medium univer-text-gray-900 dark:!univer-text-gray-0",
25584
+ children: message
25585
+ },
25586
+ { type: "separator" },
25587
+ ...menu.map((item) => ({
25588
+ type: "item",
25589
+ children: item.label,
25590
+ disabled: item.disabled,
25591
+ onSelect: item.onSelect
25592
+ }))
25593
+ ],
25594
+ children: /* @__PURE__ */ jsxs("button", {
25595
+ type: "button",
25596
+ "aria-label": accessibleLabel || void 0,
25597
+ className: "univer-flex univer-items-center univer-gap-1 univer-rounded univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-p-1 univer-shadow hover:univer-bg-gray-100 dark:!univer-border-gray-600 dark:!univer-bg-gray-900 dark:hover:!univer-bg-gray-800",
25598
+ children: [/* @__PURE__ */ jsx(WarningIcon, { className: "univer-text-yellow-500" }), showMore && /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-text-gray-600 dark:!univer-text-gray-300" })]
25599
+ })
25600
+ })
25601
+ });
25602
+ }
25686
25603
  const iconMap = {
25687
- [2]: /* @__PURE__ */ jsx(ErrorIcon, { className: "univer-mr-1.5 univer-text-red-500" }),
25688
- [0]: /* @__PURE__ */ jsx(InfoIcon, { className: "univer-mr-1.5 univer-text-blue-500" }),
25689
- [1]: /* @__PURE__ */ jsx(WarningIcon, { className: "univer-mr-1.5 univer-text-yellow-500" })
25604
+ [2]: /* @__PURE__ */ jsx(ErrorIcon, { className: "univer-text-red-500" }),
25605
+ [0]: /* @__PURE__ */ jsx(InfoIcon, { className: "univer-text-blue-500" }),
25606
+ [1]: /* @__PURE__ */ jsx(WarningIcon, { className: "univer-text-yellow-500" })
25690
25607
  };
25691
25608
  return /* @__PURE__ */ jsxs("div", {
25692
- className: "univer-z-[100] univer-box-border univer-w-[156px] univer-rounded-lg univer-bg-white univer-px-2 univer-py-1 univer-text-gray-900 univer-shadow dark:!univer-bg-black dark:!univer-text-white",
25609
+ className: "univer-z-[100] univer-box-border univer-w-[156px] univer-rounded-lg univer-bg-gray-0 univer-px-2 univer-py-1 univer-text-gray-900 univer-shadow dark:!univer-bg-gray-1000 dark:!univer-text-gray-0",
25693
25610
  children: [/* @__PURE__ */ jsxs("div", {
25694
- className: "univer-mb-1.5 univer-flex univer-h-5 univer-flex-row univer-items-center univer-text-sm univer-font-medium",
25611
+ className: "univer-mb-1.5 univer-flex univer-h-5 univer-flex-row univer-items-center univer-gap-x-1.5 univer-text-sm univer-font-medium",
25695
25612
  children: [type ? iconMap[type] : null, title]
25696
25613
  }), /* @__PURE__ */ jsx("div", {
25697
25614
  className: "univer-text-sm",
@@ -25721,7 +25638,10 @@ const CellPopup = (props) => {
25721
25638
  const componentManager = useDependency(ComponentManager);
25722
25639
  return /* @__PURE__ */ jsx("div", {
25723
25640
  "data-u-comp": "sheets-ui-cell-popup",
25724
- className: "univer-ml-px univer-flex univer-flex-col",
25641
+ className: `
25642
+ ${direction === "left-center" ? "univer-mr-px" : "univer-ml-px"}
25643
+ univer-flex univer-flex-col
25644
+ `,
25725
25645
  children: popups.map((popup) => {
25726
25646
  const Component = componentManager.get(popup.componentKey);
25727
25647
  return Component ? /* @__PURE__ */ jsx(Component, { popup }, popup.id ?? popup.componentKey) : null;
@@ -25863,7 +25783,7 @@ function DefinedNameInputContent(props) {
25863
25783
  className: "univer-relative univer-h-8 univer-select-none",
25864
25784
  children: /* @__PURE__ */ jsx(FormulaEditor, {
25865
25785
  ref: formulaEditorRef,
25866
- className: clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent", borderClassName),
25786
+ className: clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-gray-0 univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-0 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent", borderClassName),
25867
25787
  initValue: formulaOrRefStringValue,
25868
25788
  unitId,
25869
25789
  subUnitId,
@@ -26099,7 +26019,7 @@ const DefinedNameContainer = () => {
26099
26019
  children: [/* @__PURE__ */ jsxs("div", {
26100
26020
  title: definedName.comment,
26101
26021
  children: [/* @__PURE__ */ jsxs("div", {
26102
- className: "univer-my-1 univer-max-h-[100px] univer-max-w-[190px] univer-truncate univer-text-sm univer-font-medium univer-text-gray-900 dark:!univer-text-white",
26022
+ className: "univer-my-1 univer-max-h-[100px] univer-max-w-[190px] univer-truncate univer-text-sm univer-font-medium univer-text-gray-900 dark:!univer-text-gray-0",
26103
26023
  children: [definedName.name, /* @__PURE__ */ jsx("span", {
26104
26024
  className: "univer-text-xxs univer-ml-1 univer-text-gray-400",
26105
26025
  children: definedName.localSheetId === SCOPE_WORKBOOK_VALUE_DEFINED_NAME || definedName.localSheetId == null ? "" : getSheetNameBySheetId(definedName.localSheetId)
@@ -26206,7 +26126,7 @@ function DateDropdown(props) {
26206
26126
  if (await (onChange === null || onChange === void 0 ? void 0 : onChange(date))) hideFn();
26207
26127
  };
26208
26128
  return /* @__PURE__ */ jsxs("div", {
26209
- className: "univer-rounded univer-bg-white univer-p-2 univer-shadow-lg dark:!univer-bg-black",
26129
+ className: "univer-rounded univer-bg-gray-0 univer-p-2 univer-shadow-lg dark:!univer-bg-gray-1000",
26210
26130
  children: [patternType === "time" ? /* @__PURE__ */ jsx(TimeInput, {
26211
26131
  value: date.toDate(),
26212
26132
  onValueChange: (newValue) => {
@@ -26259,6 +26179,8 @@ function getListDropdownValue(value, multiple) {
26259
26179
  function SelectList(props) {
26260
26180
  const { value, onChange, multiple, options, onEdit, style, location, showEdit: showEditOnDropdown, showSearch: showSearchOnDropdown } = props;
26261
26181
  const localeService = useDependency(LocaleService);
26182
+ const themeService = useDependency(ThemeService);
26183
+ useObservable(themeService.currentTheme$);
26262
26184
  const { row, col, unitId, subUnitId } = location;
26263
26185
  const searchRef = useRef(null);
26264
26186
  useEffect(() => {
@@ -26297,14 +26219,14 @@ function SelectList(props) {
26297
26219
  ]);
26298
26220
  return /* @__PURE__ */ jsxs("div", {
26299
26221
  "data-u-comp": "sheets-dropdown-list",
26300
- className: clsx("univer-box-border univer-rounded-lg univer-bg-white univer-py-1 univer-text-gray-900 univer-shadow dark:!univer-bg-black dark:!univer-text-white", borderClassName),
26222
+ className: clsx("univer-box-border univer-rounded-lg univer-bg-gray-0 univer-py-1 univer-text-gray-900 univer-shadow dark:!univer-bg-gray-1000 dark:!univer-text-gray-0", borderClassName),
26301
26223
  style,
26302
26224
  children: [
26303
26225
  showSearchOnDropdown && /* @__PURE__ */ jsx("div", {
26304
26226
  className: "univer-box-border univer-flex univer-w-full univer-px-2",
26305
26227
  children: /* @__PURE__ */ jsx("input", {
26306
26228
  ref: searchRef,
26307
- className: clsx("univer-w-full univer-rounded-md univer-px-2 univer-py-1 univer-text-sm focus:univer-border-primary-500 focus:univer-outline-none dark:!univer-bg-black dark:!univer-text-white", borderClassName),
26229
+ className: clsx("univer-w-full univer-rounded-md univer-bg-gray-0 univer-px-2 univer-py-1 univer-text-sm univer-text-gray-900 focus:univer-border-primary-500 focus:univer-outline-none dark:!univer-bg-gray-1000 dark:!univer-text-gray-0", borderClassName),
26308
26230
  type: "text",
26309
26231
  value: lowerFilter,
26310
26232
  autoFocus: true,
@@ -26318,6 +26240,7 @@ function SelectList(props) {
26318
26240
  /* @__PURE__ */ jsx("div", {
26319
26241
  className: clsx("univer-flex univer-max-h-52 univer-flex-col univer-gap-1 univer-overflow-y-auto univer-px-2 univer-py-1", scrollbarClassName),
26320
26242
  children: filteredOptions.map((item, i) => {
26243
+ var _item$color;
26321
26244
  const selected = value.indexOf(item.value) > -1;
26322
26245
  const handleClick = () => {
26323
26246
  let set;
@@ -26330,16 +26253,18 @@ function SelectList(props) {
26330
26253
  onChange(newValue);
26331
26254
  };
26332
26255
  const index = item.label.toLocaleLowerCase().indexOf(lowerFilter);
26333
- const isDark = new ColorKit(item.color).isDark();
26256
+ const isThemeColor = Boolean(((_item$color = item.color) === null || _item$color === void 0 ? void 0 : _item$color.includes(".")) && themeService.isValidThemeColor(item.color));
26257
+ const backgroundColor = isThemeColor ? themeService.getColorFromTheme(item.color) : item.color;
26258
+ const isDark = new ColorKit(backgroundColor).isDark();
26334
26259
  return /* @__PURE__ */ jsxs("div", {
26335
26260
  className: "univer-flex univer-cursor-pointer univer-flex-row univer-items-center univer-justify-between univer-rounded-md univer-px-1.5 univer-py-1 hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700",
26336
26261
  onClick: handleClick,
26337
26262
  children: [/* @__PURE__ */ jsx("div", {
26338
26263
  className: clsx("univer-inline-flex univer-h-4 univer-w-fit univer-items-center univer-truncate univer-rounded-full univer-px-1.5 univer-text-xs", {
26339
- "univer-text-gray-900": !isDark,
26340
- "univer-text-white": isDark
26264
+ "univer-text-gray-900": isThemeColor || !isDark,
26265
+ "univer-text-gray-0": !isThemeColor && isDark
26341
26266
  }),
26342
- style: { background: item.color },
26267
+ style: { background: backgroundColor },
26343
26268
  children: lowerFilter && item.label.toLowerCase().includes(lowerFilter) ? /* @__PURE__ */ jsxs(Fragment, { children: [
26344
26269
  /* @__PURE__ */ jsx("span", { children: item.label.substring(0, index) }),
26345
26270
  /* @__PURE__ */ jsx("span", {
@@ -26409,7 +26334,7 @@ const Spin = ({ loading, children }) => {
26409
26334
  return /* @__PURE__ */ jsxs("div", {
26410
26335
  className: "univer-relative univer-size-full",
26411
26336
  children: [loading && /* @__PURE__ */ jsx("div", {
26412
- className: "univer-absolute -univer-bottom-0.5 -univer-left-0.5 -univer-right-0.5 -univer-top-0.5 univer-z-10 univer-flex univer-items-center univer-justify-center univer-bg-white univer-backdrop-blur dark:!univer-bg-black",
26337
+ className: "univer-absolute -univer-bottom-0.5 -univer-left-0.5 -univer-right-0.5 -univer-top-0.5 univer-z-10 univer-flex univer-items-center univer-justify-center univer-bg-gray-0 univer-backdrop-blur dark:!univer-bg-gray-1000",
26413
26338
  children: /* @__PURE__ */ jsx("div", { className: "univer-size-10 univer-animate-spin univer-rounded-full univer-border-4 univer-border-solid univer-border-gray-100 univer-border-t-primary-500" })
26414
26339
  }), /* @__PURE__ */ jsx("div", {
26415
26340
  className: loading ? "univer-pointer-events-none univer-blur-sm" : "",
@@ -27017,7 +26942,7 @@ const PermissionDetailUserPart = (props) => {
27017
26942
  src: (_item$subject2 = item.subject) === null || _item$subject2 === void 0 ? void 0 : _item$subject2.avatar
27018
26943
  }),
27019
26944
  /* @__PURE__ */ jsx("span", {
27020
- className: "univer-ml-1.5 univer-w-[130px] univer-truncate univer-text-gray-900 dark:!univer-text-white",
26945
+ className: "univer-ml-1.5 univer-w-[130px] univer-truncate univer-text-gray-900 dark:!univer-text-gray-0",
27021
26946
  children: (_item$subject3 = item.subject) === null || _item$subject3 === void 0 ? void 0 : _item$subject3.name
27022
26947
  }),
27023
26948
  /* @__PURE__ */ jsx(Select, {
@@ -27384,11 +27309,11 @@ function SheetPermissionPanelListContent() {
27384
27309
  }) })
27385
27310
  }),
27386
27311
  /* @__PURE__ */ jsx("span", {
27387
- className: "univer-h-4 univer-flex-grow univer-text-xs univer-text-gray-900 dark:!univer-text-white",
27312
+ className: "univer-h-4 univer-flex-grow univer-text-xs univer-text-gray-900 dark:!univer-text-gray-0",
27388
27313
  children: localeService.t("sheets-ui.permission.panel.created")
27389
27314
  }),
27390
27315
  /* @__PURE__ */ jsx("span", {
27391
- className: "univer-h-4 univer-text-xs univer-text-gray-900 dark:!univer-text-white",
27316
+ className: "univer-h-4 univer-text-xs univer-text-gray-900 dark:!univer-text-gray-0",
27392
27317
  children: editPermission ? `${localeService.t("sheets-ui.permission.panel.iCanEdit")}` : `${localeService.t("sheets-ui.permission.panel.iCanNotEdit")}`
27393
27318
  })
27394
27319
  ]
@@ -27396,10 +27321,10 @@ function SheetPermissionPanelListContent() {
27396
27321
  /* @__PURE__ */ jsxs("div", {
27397
27322
  className: "univer-mt-2 univer-flex univer-items-center",
27398
27323
  children: [/* @__PURE__ */ jsx("span", {
27399
- className: "univer-h-4 univer-flex-grow univer-text-xs univer-text-gray-900 dark:!univer-text-white",
27324
+ className: "univer-h-4 univer-flex-grow univer-text-xs univer-text-gray-900 dark:!univer-text-gray-0",
27400
27325
  children: localeService.t("sheets-ui.permission.panel.viewPermission")
27401
27326
  }), /* @__PURE__ */ jsx("span", {
27402
- className: "univer-h-4 univer-text-xs univer-text-gray-900 dark:!univer-text-white",
27327
+ className: "univer-h-4 univer-text-xs univer-text-gray-900 dark:!univer-text-gray-0",
27403
27328
  children: viewPermission ? `${localeService.t("sheets-ui.permission.panel.iCanView")}` : `${localeService.t("sheets-ui.permission.panel.iCanNotView")}`
27404
27329
  })]
27405
27330
  }),
@@ -27841,7 +27766,7 @@ const formulaEditorStyle = {
27841
27766
  }
27842
27767
  };
27843
27768
  let EditorDataSyncController = class EditorDataSyncController extends Disposable {
27844
- constructor(_univerInstanceService, _renderManagerService, _editorBridgeService, _commandService, _rangeProtectionRuleModel, _worksheetProtectionRuleModel, _formulaEditorController, _formulaEditorManagerService, _contextService) {
27769
+ constructor(_univerInstanceService, _renderManagerService, _editorBridgeService, _commandService, _rangeProtectionRuleModel, _worksheetProtectionRuleModel, _formulaEditorController, _formulaEditorManagerService, _contextService, _themeService) {
27845
27770
  super();
27846
27771
  this._univerInstanceService = _univerInstanceService;
27847
27772
  this._renderManagerService = _renderManagerService;
@@ -27852,12 +27777,14 @@ let EditorDataSyncController = class EditorDataSyncController extends Disposable
27852
27777
  this._formulaEditorController = _formulaEditorController;
27853
27778
  this._formulaEditorManagerService = _formulaEditorManagerService;
27854
27779
  this._contextService = _contextService;
27780
+ this._themeService = _themeService;
27855
27781
  this._initialize();
27856
27782
  }
27857
27783
  _initialize() {
27858
27784
  this._syncFormulaEditorContent();
27859
27785
  this._commandExecutedListener();
27860
27786
  this._syncFormulaRefRenderStyleOnFocusChange();
27787
+ this._syncFormulaBarTextColorOnThemeChange();
27861
27788
  }
27862
27789
  _getEditorViewModel(unitId) {
27863
27790
  var _this$_renderManagerS;
@@ -27981,6 +27908,11 @@ let EditorDataSyncController = class EditorDataSyncController extends Disposable
27981
27908
  this._refreshRenderStyleConfig(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
27982
27909
  }));
27983
27910
  }
27911
+ _syncFormulaBarTextColorOnThemeChange() {
27912
+ this.disposeWithMe(this._themeService.currentTheme$.pipe(skip(1)).subscribe(() => {
27913
+ this._refreshRenderStyleConfig(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
27914
+ }));
27915
+ }
27984
27916
  _refreshRenderStyleConfig(unitId) {
27985
27917
  var _currentRender$mainCo3;
27986
27918
  const currentRender = this._renderManagerService.getRenderUnitById(unitId);
@@ -27995,11 +27927,15 @@ let EditorDataSyncController = class EditorDataSyncController extends Disposable
27995
27927
  if (unitId === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY) this._formulaEditorController.autoScroll();
27996
27928
  }
27997
27929
  _checkAndSetRenderStyleConfig(documentDataModel) {
27998
- var _snapshot$body;
27930
+ var _snapshot$documentSty, _snapshot$body;
27999
27931
  const snapshot = documentDataModel.getSnapshot();
28000
27932
  if (snapshot.id !== DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY && snapshot.id !== DOCS_NORMAL_EDITOR_UNIT_ID_KEY) return;
28001
27933
  const isFormulaBar = snapshot.id === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;
28002
- if (isFormulaBar) snapshot.documentStyle = formulaEditorStyle;
27934
+ const previousPageWidth = (_snapshot$documentSty = snapshot.documentStyle) === null || _snapshot$documentSty === void 0 || (_snapshot$documentSty = _snapshot$documentSty.pageSize) === null || _snapshot$documentSty === void 0 ? void 0 : _snapshot$documentSty.width;
27935
+ if (isFormulaBar) snapshot.documentStyle = {
27936
+ ...formulaEditorStyle,
27937
+ textStyle: { cl: { rgb: this._themeService.getColorFromTheme("gray.900") } }
27938
+ };
28003
27939
  else snapshot.documentStyle ??= {};
28004
27940
  let renderConfig = snapshot.documentStyle.renderConfig;
28005
27941
  if (renderConfig == null) {
@@ -28008,8 +27944,8 @@ let EditorDataSyncController = class EditorDataSyncController extends Disposable
28008
27944
  }
28009
27945
  const position = isFormulaBar ? this._formulaEditorManagerService.getPosition() : null;
28010
27946
  if (isFormulaBar && position) {
28011
- const width = position.width;
28012
- snapshot.documentStyle.pageSize = {
27947
+ const width = position.width > 0 ? position.width : previousPageWidth;
27948
+ if (width != null && width > 0) snapshot.documentStyle.pageSize = {
28013
27949
  width,
28014
27950
  height: Infinity
28015
27951
  };
@@ -28036,84 +27972,97 @@ EditorDataSyncController = __decorate([
28036
27972
  __decorateParam(5, Inject(WorksheetProtectionRuleModel)),
28037
27973
  __decorateParam(6, Inject(FormulaEditorController)),
28038
27974
  __decorateParam(7, IFormulaEditorManagerService),
28039
- __decorateParam(8, IContextService)
27975
+ __decorateParam(8, IContextService),
27976
+ __decorateParam(9, Inject(ThemeService))
28040
27977
  ], EditorDataSyncController);
28041
27978
 
28042
27979
  //#endregion
28043
27980
  //#region src/controllers/force-string-alert-render.controller.ts
28044
27981
  const ALERT_KEY = "SHEET_FORCE_STRING_ALERT";
28045
27982
  let ForceStringAlertRenderController = class ForceStringAlertRenderController extends Disposable {
28046
- constructor(_context, _hoverManagerService, _cellAlertManagerService, _localeService, _configService) {
27983
+ constructor(_context, _selectionManagerService, _cellAlertManagerService, _localeService, _configService, _commandService, _univerInstanceService) {
28047
27984
  super();
28048
27985
  this._context = _context;
28049
- this._hoverManagerService = _hoverManagerService;
27986
+ this._selectionManagerService = _selectionManagerService;
28050
27987
  this._cellAlertManagerService = _cellAlertManagerService;
28051
27988
  this._localeService = _localeService;
28052
27989
  this._configService = _configService;
27990
+ this._commandService = _commandService;
27991
+ this._univerInstanceService = _univerInstanceService;
28053
27992
  this._init();
28054
27993
  }
28055
27994
  _init() {
28056
27995
  this._initCellAlertPopup();
28057
27996
  }
28058
27997
  _initCellAlertPopup() {
28059
- this.disposeWithMe(this._hoverManagerService.currentCell$.subscribe((cellPos) => {
28060
- if (cellPos) {
28061
- const location = cellPos.location;
28062
- const workbook = this._context.unit;
28063
- const worksheet = workbook.getActiveSheet();
28064
- if (!worksheet) return this._hideAlert();
28065
- const cellData = worksheet.getCell(location.row, location.col);
28066
- if (!cellData || cellData.v === null || cellData.v === void 0) return this._hideAlert();
28067
- let numfmtValue;
28068
- if (cellData === null || cellData === void 0 ? void 0 : cellData.s) {
28069
- const style = workbook.getStyles().get(cellData.s);
28070
- if (style === null || style === void 0 ? void 0 : style.n) numfmtValue = style.n;
28071
- }
28072
- if (isTextFormat(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern)) {
28073
- this._hideAlert();
28074
- return;
28075
- }
28076
- /**
28077
- * If the cell type is string or force string, and the value is a pure number or a string that can be converted to a number, show the force string alert.
28078
- * '123 -> yes
28079
- * '20% -> yes
28080
- * '1,234.56 -> yes
28081
- * 'abc -> no
28082
- * '2025-09-17 -> no
28083
- */
28084
- if ((cellData.t === CellValueType.FORCE_STRING || cellData.t === CellValueType.STRING) && (isRealNum(cellData.v) || typeof cellData.v === "string" && getNumfmtParseValueFilter(cellData.v))) {
28085
- var _this$_configService$, _currentAlert$alert;
28086
- if ((_this$_configService$ = this._configService.getConfig("sheets-ui.config")) === null || _this$_configService$ === void 0 ? void 0 : _this$_configService$.disableForceStringAlert) return;
28087
- const currentAlert = this._cellAlertManagerService.currentAlert.get(ALERT_KEY);
28088
- const currentLoc = currentAlert === null || currentAlert === void 0 || (_currentAlert$alert = currentAlert.alert) === null || _currentAlert$alert === void 0 ? void 0 : _currentAlert$alert.location;
28089
- if (currentLoc && currentLoc.row === cellPos.location.row && currentLoc.col === cellPos.location.col && currentLoc.subUnitId === cellPos.location.subUnitId && currentLoc.unitId === cellPos.location.unitId) {
28090
- this._hideAlert();
28091
- return;
28092
- }
28093
- this._cellAlertManagerService.showAlert({
28094
- type: 2,
28095
- title: this._localeService.t("sheets-ui.info.error"),
28096
- message: this._localeService.t("sheets-ui.info.forceStringInfo"),
28097
- location,
28098
- width: 200,
28099
- height: 74,
28100
- key: ALERT_KEY
28101
- });
28102
- return;
27998
+ this.disposeWithMe(this._selectionManagerService.selectionChanged$.subscribe((selections) => this._updateAlert(selections)));
27999
+ this.disposeWithMe(this._context.unit.activeSheet$.subscribe(() => this._updateAlert(this._selectionManagerService.getCurrentSelections())));
28000
+ this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).subscribe(() => this._updateAlert(this._selectionManagerService.getCurrentSelections())));
28001
+ }
28002
+ _isCurrentSheet(worksheet) {
28003
+ const selectionParam = this._selectionManagerService.currentSelectionParam;
28004
+ return Boolean(worksheet && (selectionParam === null || selectionParam === void 0 ? void 0 : selectionParam.unitId) === this._context.unit.getUnitId() && selectionParam.sheetId === worksheet.getSheetId());
28005
+ }
28006
+ _updateAlert(selections) {
28007
+ var _this$_configService$, _cellStyle$n;
28008
+ this._hideAlert();
28009
+ const workbook = this._context.unit;
28010
+ const worksheet = workbook.getActiveSheet();
28011
+ if (!this._isCurrentSheet(worksheet)) return;
28012
+ if ((selections === null || selections === void 0 ? void 0 : selections.length) !== 1) return;
28013
+ if ((_this$_configService$ = this._configService.getConfig("sheets-ui.config")) === null || _this$_configService$ === void 0 ? void 0 : _this$_configService$.disableForceStringAlert) return;
28014
+ const selection = selections[0];
28015
+ const primary = selection.primary;
28016
+ if (!primary) return;
28017
+ const row = primary.actualRow;
28018
+ const col = primary.actualColumn;
28019
+ const cellData = worksheet.getCell(row, col);
28020
+ if (!cellData || cellData.v === null || cellData.v === void 0) return;
28021
+ const cellStyle = workbook.getStyles().get(cellData.s);
28022
+ if (isTextFormat(cellStyle === null || cellStyle === void 0 || (_cellStyle$n = cellStyle.n) === null || _cellStyle$n === void 0 ? void 0 : _cellStyle$n.pattern)) return;
28023
+ if (cellData.t !== CellValueType.FORCE_STRING && cellData.t !== CellValueType.STRING || !isRealNum(cellData.v) && !(typeof cellData.v === "string" && getNumfmtParseValueFilter(cellData.v))) return;
28024
+ const unitId = workbook.getUnitId();
28025
+ const subUnitId = worksheet.getSheetId();
28026
+ const range = { ...selection.range };
28027
+ this._cellAlertManagerService.showAlert({
28028
+ type: 1,
28029
+ title: this._localeService.t("sheets-ui.info.error"),
28030
+ message: this._localeService.t("sheets-ui.info.forceStringInfo"),
28031
+ location: {
28032
+ unitId,
28033
+ subUnitId,
28034
+ row,
28035
+ col
28036
+ },
28037
+ width: 200,
28038
+ height: 74,
28039
+ key: this._alertKey,
28040
+ menu: [{
28041
+ label: this._localeService.t("sheets-ui.info.convertToNumber"),
28042
+ onSelect: () => {
28043
+ if (this._commandService.syncExecuteCommand(TextToNumberCommand.id, {
28044
+ unitId,
28045
+ subUnitId,
28046
+ ranges: [range]
28047
+ })) this._hideAlert();
28103
28048
  }
28104
- }
28105
- this._hideAlert();
28106
- }));
28049
+ }]
28050
+ });
28051
+ }
28052
+ get _alertKey() {
28053
+ return `${ALERT_KEY}:${this._context.unit.getUnitId()}`;
28107
28054
  }
28108
28055
  _hideAlert() {
28109
- this._cellAlertManagerService.removeAlert(ALERT_KEY);
28056
+ this._cellAlertManagerService.removeAlert(this._alertKey);
28110
28057
  }
28111
28058
  };
28112
28059
  ForceStringAlertRenderController = __decorate([
28113
- __decorateParam(1, Inject(HoverManagerService)),
28060
+ __decorateParam(1, Inject(SheetsSelectionsService)),
28114
28061
  __decorateParam(2, Inject(CellAlertManagerService)),
28115
28062
  __decorateParam(3, Inject(LocaleService)),
28116
- __decorateParam(4, IConfigService)
28063
+ __decorateParam(4, IConfigService),
28064
+ __decorateParam(5, ICommandService),
28065
+ __decorateParam(6, IUniverInstanceService)
28117
28066
  ], ForceStringAlertRenderController);
28118
28067
 
28119
28068
  //#endregion
@@ -28543,7 +28492,7 @@ function MobileSheetBarImpl(props) {
28543
28492
  tabMapRef.current.set(sheet.sheetId, element);
28544
28493
  },
28545
28494
  className: clsx("univer-relative univer-box-border univer-flex univer-h-full univer-max-w-36 univer-shrink-0 univer-cursor-pointer univer-select-none univer-items-center univer-justify-center univer-truncate univer-px-1 univer-py-0.5 univer-text-sm univer-font-medium univer-leading-6 univer-transition-all", borderRightClassName, {
28546
- "univer-bg-white univer-text-blue-600 dark:!univer-bg-gray-700 dark:!univer-text-blue-400": sheet.sheetId === activeKey,
28495
+ "univer-bg-gray-0 univer-text-blue-600 dark:!univer-bg-gray-700 dark:!univer-text-blue-400": sheet.sheetId === activeKey,
28547
28496
  "univer-text-gray-600 hover:univer-bg-gray-50 active:univer-bg-gray-100 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700": sheet.sheetId !== activeKey
28548
28497
  }),
28549
28498
  role: "tab",
@@ -29359,35 +29308,37 @@ FormatPainterRenderController = __decorate([
29359
29308
  //#region src/controllers/render-controllers/header-menu.render-controller.ts
29360
29309
  const HEADER_MENU_CONTROLLER_SHAPE = "__SpreadsheetHeaderMenuSHAPEControllerShape__";
29361
29310
  const HEADER_MENU_CONTROLLER_MENU = "__SpreadsheetHeaderMenuMAINControllerShape__";
29362
- const HEADER_MENU_CONTROLLER_SHAPE_COLOR = "rgba(0, 0, 0, 0.1)";
29311
+ const HEADER_MENU_CONTROLLER_SHAPE_ALPHA = .1;
29363
29312
  let HeaderMenuRenderController = class HeaderMenuRenderController extends Disposable {
29364
- constructor(_context, _sheetSkeletonManagerService, _contextMenuService, _commandService, _selectionManagerService) {
29313
+ constructor(_context, _sheetSkeletonManagerService, _contextMenuService, _commandService, _selectionManagerService, _themeService) {
29365
29314
  super();
29366
29315
  this._context = _context;
29367
29316
  this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
29368
29317
  this._contextMenuService = _contextMenuService;
29369
29318
  this._commandService = _commandService;
29370
29319
  this._selectionManagerService = _selectionManagerService;
29320
+ this._themeService = _themeService;
29371
29321
  _defineProperty(this, "_hoverRect", void 0);
29372
29322
  _defineProperty(this, "_hoverMenu", void 0);
29373
29323
  _defineProperty(this, "_currentColumn", Number.POSITIVE_INFINITY);
29374
- _defineProperty(this, "_headerPointerSubs", void 0);
29375
- _defineProperty(this, "_colHeaderPointerSubs", void 0);
29324
+ _defineProperty(this, "_headerPointerSubs", new Subscription());
29376
29325
  this._initialize();
29377
29326
  }
29378
29327
  dispose() {
29379
- var _this$_hoverRect, _this$_hoverMenu, _this$_headerPointerS;
29328
+ var _this$_hoverRect, _this$_hoverMenu;
29329
+ super.dispose();
29380
29330
  (_this$_hoverRect = this._hoverRect) === null || _this$_hoverRect === void 0 || _this$_hoverRect.dispose();
29381
29331
  (_this$_hoverMenu = this._hoverMenu) === null || _this$_hoverMenu === void 0 || _this$_hoverMenu.dispose();
29382
- (_this$_headerPointerS = this._headerPointerSubs) === null || _this$_headerPointerS === void 0 || _this$_headerPointerS.unsubscribe();
29383
- this._headerPointerSubs = null;
29332
+ this._headerPointerSubs.unsubscribe();
29384
29333
  }
29385
29334
  _initialize() {
29386
29335
  const scene = this._context.scene;
29387
- this._hoverRect = new Rect(HEADER_MENU_CONTROLLER_SHAPE, {
29388
- fill: HEADER_MENU_CONTROLLER_SHAPE_COLOR,
29389
- evented: false
29390
- });
29336
+ this._hoverRect = new Rect(HEADER_MENU_CONTROLLER_SHAPE, { evented: false });
29337
+ this.disposeWithMe(this._themeService.currentTheme$.subscribe(() => {
29338
+ var _this$_hoverRect2;
29339
+ const color = this._themeService.getColorFromTheme("gray.900");
29340
+ (_this$_hoverRect2 = this._hoverRect) === null || _this$_hoverRect2 === void 0 || _this$_hoverRect2.setProps({ fill: new ColorKit(color).setAlpha(HEADER_MENU_CONTROLLER_SHAPE_ALPHA).toRgbString() });
29341
+ }));
29391
29342
  this._hoverMenu = new HeaderMenuShape(HEADER_MENU_CONTROLLER_MENU, {
29392
29343
  zIndex: 100,
29393
29344
  visible: false
@@ -29398,7 +29349,6 @@ let HeaderMenuRenderController = class HeaderMenuRenderController extends Dispos
29398
29349
  this._initialHoverMenu();
29399
29350
  }
29400
29351
  _initialHover(initialType = 0) {
29401
- var _this$_headerPointerS2, _this$_headerPointerS3, _this$_headerPointerS4;
29402
29352
  const spreadsheetColumnHeader = this._context.components.get("__SpreadsheetColumnHeader__");
29403
29353
  const spreadsheetRowHeader = this._context.components.get("__SpreadsheetRowHeader__");
29404
29354
  const eventBindingObject = initialType === 0 ? spreadsheetRowHeader : spreadsheetColumnHeader;
@@ -29409,17 +29359,17 @@ let HeaderMenuRenderController = class HeaderMenuRenderController extends Dispos
29409
29359
  const { rowBaseWidth, rowGutterWidth, columnBaseHeight, columnGutterHeight } = getHeaderBaseLayout(skeleton);
29410
29360
  const { startX, startY, endX, endY, column } = getCoordByOffset(evt.offsetX, evt.offsetY, this._context.scene, skeleton);
29411
29361
  if (initialType === 0) {
29412
- var _this$_hoverRect2;
29413
- (_this$_hoverRect2 = this._hoverRect) === null || _this$_hoverRect2 === void 0 || _this$_hoverRect2.transformByState({
29362
+ var _this$_hoverRect3;
29363
+ (_this$_hoverRect3 = this._hoverRect) === null || _this$_hoverRect3 === void 0 || _this$_hoverRect3.transformByState({
29414
29364
  width: rowBaseWidth,
29415
29365
  height: endY - startY,
29416
29366
  left: rowGutterWidth,
29417
29367
  top: startY
29418
29368
  });
29419
29369
  } else {
29420
- var _this$_hoverRect3;
29370
+ var _this$_hoverRect4;
29421
29371
  this._currentColumn = column;
29422
- (_this$_hoverRect3 = this._hoverRect) === null || _this$_hoverRect3 === void 0 || _this$_hoverRect3.transformByState({
29372
+ (_this$_hoverRect4 = this._hoverRect) === null || _this$_hoverRect4 === void 0 || _this$_hoverRect4.transformByState({
29423
29373
  width: endX - startX,
29424
29374
  height: columnBaseHeight,
29425
29375
  left: startX,
@@ -29440,21 +29390,20 @@ let HeaderMenuRenderController = class HeaderMenuRenderController extends Dispos
29440
29390
  }
29441
29391
  };
29442
29392
  const pointerEnterHandler = () => {
29443
- var _this$_hoverRect4;
29444
- (_this$_hoverRect4 = this._hoverRect) === null || _this$_hoverRect4 === void 0 || _this$_hoverRect4.show();
29393
+ var _this$_hoverRect5;
29394
+ (_this$_hoverRect5 = this._hoverRect) === null || _this$_hoverRect5 === void 0 || _this$_hoverRect5.show();
29445
29395
  };
29446
29396
  const pointerLeaveHandler = () => {
29447
- var _this$_hoverRect5, _this$_hoverMenu2;
29448
- (_this$_hoverRect5 = this._hoverRect) === null || _this$_hoverRect5 === void 0 || _this$_hoverRect5.hide();
29397
+ var _this$_hoverRect6, _this$_hoverMenu2;
29398
+ (_this$_hoverRect6 = this._hoverRect) === null || _this$_hoverRect6 === void 0 || _this$_hoverRect6.hide();
29449
29399
  (_this$_hoverMenu2 = this._hoverMenu) === null || _this$_hoverMenu2 === void 0 || _this$_hoverMenu2.hide();
29450
29400
  };
29451
- this._headerPointerSubs = new Subscription();
29452
29401
  const headerPointerMoveSub = eventBindingObject.onPointerMove$.subscribeEvent(pointerMoveHandler);
29453
29402
  const headerPointerEnterSub = eventBindingObject.onPointerEnter$.subscribeEvent(pointerEnterHandler);
29454
29403
  const headerPointerLeaveSub = eventBindingObject.onPointerLeave$.subscribeEvent(pointerLeaveHandler);
29455
- (_this$_headerPointerS2 = this._headerPointerSubs) === null || _this$_headerPointerS2 === void 0 || _this$_headerPointerS2.add(headerPointerMoveSub);
29456
- (_this$_headerPointerS3 = this._headerPointerSubs) === null || _this$_headerPointerS3 === void 0 || _this$_headerPointerS3.add(headerPointerEnterSub);
29457
- (_this$_headerPointerS4 = this._headerPointerSubs) === null || _this$_headerPointerS4 === void 0 || _this$_headerPointerS4.add(headerPointerLeaveSub);
29404
+ this._headerPointerSubs.add(headerPointerMoveSub);
29405
+ this._headerPointerSubs.add(headerPointerEnterSub);
29406
+ this._headerPointerSubs.add(headerPointerLeaveSub);
29458
29407
  }
29459
29408
  _initialHoverMenu() {
29460
29409
  if (this._hoverMenu == null) return;
@@ -29525,7 +29474,8 @@ HeaderMenuRenderController = __decorate([
29525
29474
  __decorateParam(1, Inject(SheetSkeletonManagerService)),
29526
29475
  __decorateParam(2, IContextMenuService),
29527
29476
  __decorateParam(3, ICommandService),
29528
- __decorateParam(4, Inject(SheetsSelectionsService))
29477
+ __decorateParam(4, Inject(SheetsSelectionsService)),
29478
+ __decorateParam(5, Inject(ThemeService))
29529
29479
  ], HeaderMenuRenderController);
29530
29480
  function getHeaderBaseLayout(skeleton) {
29531
29481
  var _skeleton$worksheet$g, _skeleton$worksheet, _config$rowHeader, _config$columnHeader;
@@ -30837,6 +30787,36 @@ MobileSheetsScrollRenderController = __decorate([
30837
30787
  __decorateParam(7, IContextService)
30838
30788
  ], MobileSheetsScrollRenderController);
30839
30789
 
30790
+ //#endregion
30791
+ //#region src/controllers/render-controllers/skeleton.render-controller.ts
30792
+ let SheetSkeletonRenderController = class SheetSkeletonRenderController extends Disposable {
30793
+ constructor(_context, _sheetSkeletonManagerService, _renderManagerService) {
30794
+ super();
30795
+ this._context = _context;
30796
+ this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
30797
+ this._renderManagerService = _renderManagerService;
30798
+ this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe((param) => {
30799
+ this._updateSceneSize(param);
30800
+ }));
30801
+ }
30802
+ _updateSceneSize(param) {
30803
+ var _this$_renderManagerS;
30804
+ if (param == null) return;
30805
+ const { unitId } = this._context;
30806
+ const { skeleton } = param;
30807
+ const scene = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.scene;
30808
+ if (skeleton == null || scene == null) return;
30809
+ const { rowTotalHeight, columnTotalWidth, rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop } = skeleton;
30810
+ if (!this._context.unit.getActiveSheet()) return;
30811
+ scene === null || scene === void 0 || scene.transformByState({
30812
+ width: rowHeaderWidthAndMarginLeft + columnTotalWidth,
30813
+ height: columnHeaderHeightAndMarginTop + rowTotalHeight
30814
+ });
30815
+ scene.getMainViewport().setMargin(rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop);
30816
+ }
30817
+ };
30818
+ SheetSkeletonRenderController = __decorate([__decorateParam(1, Inject(SheetSkeletonManagerService)), __decorateParam(2, IRenderManagerService)], SheetSkeletonRenderController);
30819
+
30840
30820
  //#endregion
30841
30821
  //#region src/services/auto-height.service.ts
30842
30822
  const IAutoHeightService = createIdentifier("sheets-ui.services.auto-height");
@@ -31742,7 +31722,6 @@ let UniverSheetsMobileUIPlugin = class UniverSheetsMobileUIPlugin extends Plugin
31742
31722
  [SelectAllService],
31743
31723
  [ISheetCellDropdownManagerService, { useClass: SheetCellDropdownManagerService }],
31744
31724
  [SheetCellEditorResizeService],
31745
- [ISheetLoadingRenderService, { useClass: SheetLoadingRenderService }],
31746
31725
  [AutoHeightController],
31747
31726
  [AutoWidthController],
31748
31727
  [FormulaEditorController],
@@ -31877,6 +31856,7 @@ let SheetContextMenuRenderController = class SheetContextMenuRenderController ex
31877
31856
  this._selectionRenderService = _selectionRenderService;
31878
31857
  this._injector = _injector;
31879
31858
  this._init();
31859
+ this._initEmbedRuntimeSessionListener();
31880
31860
  }
31881
31861
  _init() {
31882
31862
  var _this$_context;
@@ -31924,6 +31904,13 @@ let SheetContextMenuRenderController = class SheetContextMenuRenderController ex
31924
31904
  });
31925
31905
  this.disposeWithMe(colHeaderObserver);
31926
31906
  }
31907
+ _initEmbedRuntimeSessionListener() {
31908
+ const runtimeFocusCoordinator = this._getSheetEmbedRuntimeFocusCoordinator();
31909
+ if (!runtimeFocusCoordinator) return;
31910
+ this.disposeWithMe(runtimeFocusCoordinator.runtimeSessionChanged$.subscribe(() => {
31911
+ if (shouldHideSheetHostContextMenuForEmbedSession(this._context.unitId, runtimeFocusCoordinator.resolveActiveChildSessionRuntimeScope())) this._contextMenuService.hideContextMenu();
31912
+ }));
31913
+ }
31927
31914
  _shouldSuppressHostContextMenu() {
31928
31915
  var _this$_getSheetHostCh, _this$_getSheetHostCh2;
31929
31916
  return shouldSuppressSheetContextMenuForEmbedOverride(this._context.unitId, (_this$_getSheetHostCh = this._getSheetHostChromeOverrideService()) === null || _this$_getSheetHostCh === void 0 || (_this$_getSheetHostCh2 = _this$_getSheetHostCh.getOverride) === null || _this$_getSheetHostCh2 === void 0 ? void 0 : _this$_getSheetHostCh2.call(_this$_getSheetHostCh));
@@ -31931,6 +31918,9 @@ let SheetContextMenuRenderController = class SheetContextMenuRenderController ex
31931
31918
  _getSheetHostChromeOverrideService() {
31932
31919
  return this._injector.has(ISheetHostChromeOverrideService) ? this._injector.get(ISheetHostChromeOverrideService) : void 0;
31933
31920
  }
31921
+ _getSheetEmbedRuntimeFocusCoordinator() {
31922
+ return this._injector.has(ISheetEmbedRuntimeFocusCoordinator) ? this._injector.get(ISheetEmbedRuntimeFocusCoordinator) : void 0;
31923
+ }
31934
31924
  };
31935
31925
  SheetContextMenuRenderController = __decorate([
31936
31926
  __decorateParam(1, IContextMenuService),
@@ -31938,6 +31928,9 @@ SheetContextMenuRenderController = __decorate([
31938
31928
  __decorateParam(3, ISheetSelectionRenderService),
31939
31929
  __decorateParam(4, Inject(Injector))
31940
31930
  ], SheetContextMenuRenderController);
31931
+ function shouldHideSheetHostContextMenuForEmbedSession(hostUnitId, activeScope) {
31932
+ return (activeScope === null || activeScope === void 0 ? void 0 : activeScope.hostUnitId) === hostUnitId && activeScope.sessionMode !== "host-passive";
31933
+ }
31941
31934
  function shouldSuppressSheetContextMenuForEmbedOverride(hostUnitId, override) {
31942
31935
  return override != null && override.hostUnitId === hostUnitId && override.entry === "sheets-sheet-tab";
31943
31936
  }
@@ -32360,7 +32353,6 @@ let UniverSheetsUIPlugin = class UniverSheetsUIPlugin extends Plugin {
32360
32353
  [SelectAllService],
32361
32354
  [ISheetCellDropdownManagerService, { useClass: SheetCellDropdownManagerService }],
32362
32355
  [SheetCellEditorResizeService],
32363
- [ISheetLoadingRenderService, { useClass: SheetLoadingRenderService }],
32364
32356
  [AutoHeightController],
32365
32357
  [AutoWidthController],
32366
32358
  [FormulaEditorController],
@@ -32483,4 +32475,4 @@ UniverSheetsUIPlugin = __decorate([
32483
32475
  ], UniverSheetsUIPlugin);
32484
32476
 
32485
32477
  //#endregion
32486
- export { AddRangeProtectionFromContextMenuCommand, AddRangeProtectionFromSheetBarCommand, AddRangeProtectionFromToolbarCommand, ApplyFormatPainterCommand, AutoFillPopupMenu, AutoFillUIController, AutoHeightController, AutoWidthController, BORDER_LINE_CHILDREN, BORDER_SIZE_CHILDREN, BaseSelectionRenderService, BorderLine, COPY_SPECIAL_MENU_ID, COPY_TYPE, CellAlertManagerService, CellAlertType, CellCustomRenderController, CellEditorManagerService, CellPopupManagerService, ChangeSheetProtectionFromSheetBarCommand, ChangeZoomRatioCommand, DeleteRangeMoveLeftConfirmCommand, DeleteRangeMoveUpConfirmCommand, DeleteRangeProtectionFromContextMenuCommand, DeleteWorksheetProtectionFormSheetBarCommand, DragManagerService, DragRenderController, EMBEDDING_FORMULA_EDITOR, EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, EditingRenderController, EditorBridgeService, EditorContainer, ExpandSelectionCommand, FORMULA_CLIPBOARD_MIME_TYPE, FormatPainterStatus, FormulaBar, FormulaEditorController, HEADER_UNHIDE_RANGE_VISIBLE_CHECK, HeaderFreezeRenderController, HeaderMoveRenderController, HeaderResizeRenderController, HeaderUnhideRangeAxis, HeaderUnhideRangeService, HeaderUnhideRenderController, HideColConfirmCommand, HideRowConfirmCommand, HoverManagerService, HoverRenderController, ICellEditorManagerService, IEditorBridgeService, IFormatPainterService, IFormulaEditorManagerService, IMarkSelectionService, IRepeatLastActionService, ISheetCellDropdownManagerService, ISheetClipboardService, ISheetEmbedFloatingGeometryService, ISheetEmbedInteractionBoundaryService, ISheetEmbedRuntimeFocusCoordinator, ISheetEmbedRuntimeService, ISheetHostChromeOverrideService, ISheetLoadingRenderService, ISheetSelectionRenderService, IStatusBarService, InsertRangeMoveDownConfirmCommand, InsertRangeMoveRightConfirmCommand, JumpOver, MarkSelectionService, MoveSelectionCommand, MoveSelectionEnterAndTabCommand, PASTE_SPECIAL_MENU_ID, PREDEFINED_HOOK_NAME, PREDEFINED_HOOK_NAME_COPY, PREDEFINED_HOOK_NAME_PASTE, RANGE_SELECTOR_COMPONENT_KEY, RANGE_SELECTOR_SYMBOLS, RemoveColConfirmCommand, RemoveRowConfirmCommand, RemoveSheetConfirmCommand, RenameSheetOperation, RepeatLastActionPermission, ResetRangeTextColorCommand, ResetScrollCommand, SELECTION_SHAPE_DEPTH, SHEETS_UI_PLUGIN_CONFIG_KEY, SHEET_EMBED_CHILD_TYPE_ATTRIBUTE, SHEET_EMBED_CHILD_UNIT_ID_ATTRIBUTE, SHEET_EMBED_FLOAT_DOM_ATTRIBUTE, SHEET_EMBED_HOST_UNIT_ID_ATTRIBUTE, SHEET_EMBED_ID_ATTRIBUTE, SHEET_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, SHEET_EMBED_RUNTIME_FOCUS_ROLE_ATTRIBUTE, SHEET_FOOTER_BAR_HEIGHT, SHEET_UI_PLUGIN_NAME, SHEET_VIEW_KEY, ScrollCommand, ScrollToCellCommand, ScrollToRangeOperation, SelectAllCommand, SelectionControl, SelectionControl as SelectionShape, SelectionShapeExtension, SetActivateCellEditOperation, SetCellEditVisibleArrowOperation, SetCellEditVisibleOperation, SetCellEditVisibleWithF2Operation, SetColumnFrozenCommand, SetColumnHeaderHeightCommand, SetFirstColumnFrozenCommand, SetFirstRowFrozenCommand, SetFormatPainterOperation, SetInfiniteFormatPainterCommand, SetOnceFormatPainterCommand, SetRangeBoldCommand, SetRangeFontDecreaseCommand, SetRangeFontFamilyCommand, SetRangeFontIncreaseCommand, SetRangeFontSizeCommand, SetRangeItalicCommand, SetRangeProtectionFromContextMenuCommand, SetRangeStrickThroughCommand, SetRangeSubscriptCommand, SetRangeSuperscriptCommand, SetRangeTextColorCommand, SetRangeUnderlineCommand, SetRowFrozenCommand, SetRowHeaderWidthCommand, SetScrollOperation, SetScrollRelativeCommand, SetSelectionFrozenCommand, SetWorksheetColAutoWidthCommand, SetZoomRatioCommand, SetZoomRatioOperation, SheetBar, SheetCanvasPopManagerService, SheetCellDropdownManagerService, SheetCellEditorResizeService, SheetClipboardController, SheetClipboardService, SheetCopyCommand, SheetCutCommand, SheetMenuPosition, SheetPasteBesidesBorderCommand, SheetPasteColWidthCommand, SheetPasteCommand, SheetPasteFormatCommand, SheetPasteShortKeyCommand, SheetPasteValueCommand, SheetPermissionCheckUIController, SheetPermissionOpenDialogOperation, SheetPermissionOpenPanelOperation, SheetPermissionRenderManagerService, SheetPermissionUserManagerService, SheetPrintInterceptorService, SheetPrintingResourceCollector, SheetRenderController, SheetScrollManagerService, SheetSelectionRenderService, SheetSkeletonManagerService, SheetUIController, SheetsRenderService, SheetsScrollRenderController, menuSchema as SheetsUIMenuSchema, SheetsUIPart, ShowMenuListCommand, SidebarDefinedNameOperation, StatusBarController, StatusBarService, UNIVER_SHEET_PERMISSION_USER_PART, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, ViewSheetPermissionFromContextMenuCommand, ViewSheetPermissionFromSheetBarCommand, calculateDocSkeletonRects, matchedSelectionByRowColIndex as checkInHeaderRanges, deriveStateFromActiveSheet$, functionDisplayNames, genNormalSelectionStyle, genSelectionByRange, selectionDataForSelectAll as getAllSelection, getCellRealRange, getCoordByCell, getCoordByOffset, getCurrentExclusiveRangeInterest$, getCurrentRangeDisable$, getCustomRangePosition, getEditingCustomRangePosition, getEditorObject, getMatrixPlainText, getObservableWithExclusiveRange$, getRepeatRange, getSheetObject, getTopLeftSelectionOfCurrSheet, getTransformCoord, getViewportByCell, isEmbeddingFormulaEditor, isRangeSelector, menuClipboardDisabledObservable, mergeSetRangeValues, resolveActiveSheetEmbedRuntimeDomScope, resolveSheetEmbedRuntimeDomScope, useActiveWorkbook, useActiveWorksheet, useHighlightRange, useKeyEventConfig, useWorkbooks, virtualizeDiscreteRanges, whenFormulaEditorActivated, whenSheetEditorActivated, whenSheetEditorFocused };
32478
+ export { AddRangeProtectionFromContextMenuCommand, AddRangeProtectionFromSheetBarCommand, AddRangeProtectionFromToolbarCommand, ApplyFormatPainterCommand, AutoFillPopupMenu, AutoFillUIController, AutoHeightController, AutoWidthController, BORDER_LINE_CHILDREN, BORDER_SIZE_CHILDREN, BaseSelectionRenderService, BorderLine, COPY_SPECIAL_MENU_ID, COPY_TYPE, CellAlertManagerService, CellAlertType, CellCustomRenderController, CellEditorManagerService, CellPopupManagerService, ChangeSheetProtectionFromSheetBarCommand, ChangeZoomRatioCommand, DeleteRangeMoveLeftConfirmCommand, DeleteRangeMoveUpConfirmCommand, DeleteRangeProtectionFromContextMenuCommand, DeleteWorksheetProtectionFormSheetBarCommand, DragManagerService, DragRenderController, EMBEDDING_FORMULA_EDITOR, EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, EditingRenderController, EditorBridgeService, EditorContainer, ExpandSelectionCommand, FORMULA_CLIPBOARD_MIME_TYPE, FormatPainterStatus, FormulaBar, FormulaEditorController, HEADER_UNHIDE_RANGE_VISIBLE_CHECK, HeaderFreezeRenderController, HeaderMoveRenderController, HeaderResizeRenderController, HeaderUnhideRangeAxis, HeaderUnhideRangeService, HeaderUnhideRenderController, HideColConfirmCommand, HideRowConfirmCommand, HoverManagerService, HoverRenderController, ICellEditorManagerService, IEditorBridgeService, IFormatPainterService, IFormulaEditorManagerService, IMarkSelectionService, IRepeatLastActionService, ISheetBarService, ISheetCellDropdownManagerService, ISheetClipboardService, ISheetEmbedFloatingGeometryService, ISheetEmbedInteractionBoundaryService, ISheetEmbedRuntimeFocusCoordinator, ISheetEmbedRuntimeService, ISheetHostChromeOverrideService, ISheetSelectionRenderService, IStatusBarService, InsertRangeMoveDownConfirmCommand, InsertRangeMoveRightConfirmCommand, JumpOver, MarkSelectionService, MoveSelectionCommand, MoveSelectionEnterAndTabCommand, PASTE_SPECIAL_MENU_ID, PREDEFINED_HOOK_NAME, PREDEFINED_HOOK_NAME_COPY, PREDEFINED_HOOK_NAME_PASTE, RANGE_SELECTOR_COMPONENT_KEY, RANGE_SELECTOR_SYMBOLS, RemoveColConfirmCommand, RemoveRowConfirmCommand, RemoveSheetConfirmCommand, RenameSheetOperation, RepeatLastActionPermission, ResetRangeTextColorCommand, ResetScrollCommand, SELECTION_SHAPE_DEPTH, SHEETS_UI_PLUGIN_CONFIG_KEY, SHEET_EMBED_CHILD_TYPE_ATTRIBUTE, SHEET_EMBED_CHILD_UNIT_ID_ATTRIBUTE, SHEET_EMBED_FLOAT_DOM_ATTRIBUTE, SHEET_EMBED_HOST_UNIT_ID_ATTRIBUTE, SHEET_EMBED_ID_ATTRIBUTE, SHEET_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, SHEET_EMBED_RUNTIME_FOCUS_ROLE_ATTRIBUTE, SHEET_FOOTER_BAR_HEIGHT, SHEET_UI_PLUGIN_NAME, SHEET_VIEW_KEY, ScrollCommand, ScrollToCellCommand, ScrollToRangeOperation, SelectAllCommand, SelectionControl, SelectionControl as SelectionShape, SelectionShapeExtension, SetActivateCellEditOperation, SetCellEditVisibleArrowOperation, SetCellEditVisibleOperation, SetCellEditVisibleWithF2Operation, SetColumnFrozenCommand, SetColumnHeaderHeightCommand, SetFirstColumnFrozenCommand, SetFirstRowFrozenCommand, SetFormatPainterOperation, SetInfiniteFormatPainterCommand, SetOnceFormatPainterCommand, SetRangeBoldCommand, SetRangeFontDecreaseCommand, SetRangeFontFamilyCommand, SetRangeFontIncreaseCommand, SetRangeFontSizeCommand, SetRangeItalicCommand, SetRangeProtectionFromContextMenuCommand, SetRangeStrickThroughCommand, SetRangeSubscriptCommand, SetRangeSuperscriptCommand, SetRangeTextColorCommand, SetRangeUnderlineCommand, SetRowFrozenCommand, SetRowHeaderWidthCommand, SetScrollOperation, SetScrollRelativeCommand, SetSelectionFrozenCommand, SetWorksheetColAutoWidthCommand, SetZoomRatioCommand, SetZoomRatioOperation, SheetBar, SheetBarService, SheetCanvasPopManagerService, SheetCellDropdownManagerService, SheetCellEditorResizeService, SheetClipboardController, SheetClipboardService, SheetCopyCommand, SheetCutCommand, SheetMenuPosition, SheetPasteBesidesBorderCommand, SheetPasteColWidthCommand, SheetPasteCommand, SheetPasteFormatCommand, SheetPasteShortKeyCommand, SheetPasteValueCommand, SheetPermissionCheckUIController, SheetPermissionOpenDialogOperation, SheetPermissionOpenPanelOperation, SheetPermissionRenderManagerService, SheetPermissionUserManagerService, SheetPrintInterceptorService, SheetPrintingResourceCollector, SheetRenderController, SheetScrollManagerService, SheetSelectionRenderService, SheetSkeletonManagerService, SheetUIController, SheetsRenderService, SheetsScrollRenderController, menuSchema as SheetsUIMenuSchema, SheetsUIPart, ShowMenuListCommand, SidebarDefinedNameOperation, StatusBarController, StatusBarService, UNIVER_SHEET_PERMISSION_USER_PART, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, ViewSheetPermissionFromContextMenuCommand, ViewSheetPermissionFromSheetBarCommand, calculateDocSkeletonRects, matchedSelectionByRowColIndex as checkInHeaderRanges, deriveStateFromActiveSheet$, functionDisplayNames, genNormalSelectionStyle, genSelectionByRange, selectionDataForSelectAll as getAllSelection, getCellRealRange, getCoordByCell, getCoordByOffset, getCurrentExclusiveRangeInterest$, getCurrentRangeDisable$, getCustomRangePosition, getEditingCustomRangePosition, getEditorObject, getMatrixPlainText, getObservableWithExclusiveRange$, getRepeatRange, getSheetObject, getTopLeftSelectionOfCurrSheet, getTransformCoord, getViewportByCell, isEmbeddingFormulaEditor, isRangeSelector, menuClipboardDisabledObservable, mergeSetRangeValues, resolveActiveSheetEmbedRuntimeDomScope, resolveSheetEmbedRuntimeDomScope, useActiveWorkbook, useActiveWorksheet, useHighlightRange, useKeyEventConfig, useWorkbooks, virtualizeDiscreteRanges, whenFormulaEditorActivated, whenSheetEditorActivated, whenSheetEditorFocused };