@univerjs/sheets-ui 1.0.0-alpha.2 → 1.0.0-alpha.3

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 (113) hide show
  1. package/lib/cjs/facade.js +47 -37
  2. package/lib/cjs/index.js +1161 -272
  3. package/lib/cjs/locale/ar-SA.js +5 -0
  4. package/lib/cjs/locale/ca-ES.js +5 -0
  5. package/lib/cjs/locale/de-DE.js +5 -0
  6. package/lib/cjs/locale/en-US.js +5 -0
  7. package/lib/cjs/locale/es-ES.js +6 -1
  8. package/lib/cjs/locale/fa-IR.js +5 -0
  9. package/lib/cjs/locale/fr-FR.js +5 -0
  10. package/lib/cjs/locale/id-ID.js +5 -0
  11. package/lib/cjs/locale/it-IT.js +5 -0
  12. package/lib/cjs/locale/ja-JP.js +5 -0
  13. package/lib/cjs/locale/ko-KR.js +5 -0
  14. package/lib/cjs/locale/pl-PL.js +5 -0
  15. package/lib/cjs/locale/pt-BR.js +5 -0
  16. package/lib/cjs/locale/ru-RU.js +5 -0
  17. package/lib/cjs/locale/sk-SK.js +5 -0
  18. package/lib/cjs/locale/vi-VN.js +5 -0
  19. package/lib/cjs/locale/zh-CN.js +5 -0
  20. package/lib/cjs/locale/zh-HK.js +5 -0
  21. package/lib/cjs/locale/zh-TW.js +5 -0
  22. package/lib/es/facade.js +47 -37
  23. package/lib/es/index.js +1140 -247
  24. package/lib/es/locale/ar-SA.js +5 -0
  25. package/lib/es/locale/ca-ES.js +5 -0
  26. package/lib/es/locale/de-DE.js +5 -0
  27. package/lib/es/locale/en-US.js +5 -0
  28. package/lib/es/locale/es-ES.js +6 -1
  29. package/lib/es/locale/fa-IR.js +5 -0
  30. package/lib/es/locale/fr-FR.js +5 -0
  31. package/lib/es/locale/id-ID.js +5 -0
  32. package/lib/es/locale/it-IT.js +5 -0
  33. package/lib/es/locale/ja-JP.js +5 -0
  34. package/lib/es/locale/ko-KR.js +5 -0
  35. package/lib/es/locale/pl-PL.js +5 -0
  36. package/lib/es/locale/pt-BR.js +5 -0
  37. package/lib/es/locale/ru-RU.js +5 -0
  38. package/lib/es/locale/sk-SK.js +5 -0
  39. package/lib/es/locale/vi-VN.js +5 -0
  40. package/lib/es/locale/zh-CN.js +5 -0
  41. package/lib/es/locale/zh-HK.js +5 -0
  42. package/lib/es/locale/zh-TW.js +5 -0
  43. package/lib/facade.js +47 -37
  44. package/lib/index.css +4 -0
  45. package/lib/index.js +1140 -247
  46. package/lib/locale/ar-SA.js +5 -0
  47. package/lib/locale/ca-ES.js +5 -0
  48. package/lib/locale/de-DE.js +5 -0
  49. package/lib/locale/en-US.js +5 -0
  50. package/lib/locale/es-ES.js +6 -1
  51. package/lib/locale/fa-IR.js +5 -0
  52. package/lib/locale/fr-FR.js +5 -0
  53. package/lib/locale/id-ID.js +5 -0
  54. package/lib/locale/it-IT.js +5 -0
  55. package/lib/locale/ja-JP.js +5 -0
  56. package/lib/locale/ko-KR.js +5 -0
  57. package/lib/locale/pl-PL.js +5 -0
  58. package/lib/locale/pt-BR.js +5 -0
  59. package/lib/locale/ru-RU.js +5 -0
  60. package/lib/locale/sk-SK.js +5 -0
  61. package/lib/locale/vi-VN.js +5 -0
  62. package/lib/locale/zh-CN.js +5 -0
  63. package/lib/locale/zh-HK.js +5 -0
  64. package/lib/locale/zh-TW.js +5 -0
  65. package/lib/types/commands/commands/set-scroll.command.d.ts +3 -0
  66. package/lib/types/controllers/editor/editing.render-controller.d.ts +1 -0
  67. package/lib/types/controllers/editor/formula-editor.controller.d.ts +1 -0
  68. package/lib/types/controllers/render-controllers/contextmenu.render-controller.d.ts +7 -2
  69. package/lib/types/controllers/render-controllers/editor-bridge.render-controller.d.ts +7 -1
  70. package/lib/types/controllers/render-controllers/header-unhide.render-controller.d.ts +0 -1
  71. package/lib/types/embed-tab-anchor.d.ts +23 -0
  72. package/lib/types/facade/f-univer.d.ts +1 -0
  73. package/lib/types/index.d.ts +16 -3
  74. package/lib/types/locale/en-US.d.ts +5 -0
  75. package/lib/types/services/canvas-pop-manager.service.d.ts +9 -0
  76. package/lib/types/services/cell-popup-manager.service.d.ts +1 -0
  77. package/lib/types/services/editor/cell-editor-resize.service.d.ts +4 -1
  78. package/lib/types/services/editor-bridge.service.d.ts +2 -0
  79. package/lib/types/services/print-interceptor.service.d.ts +8 -0
  80. package/lib/types/services/selection/base-selection-render.service.d.ts +1 -0
  81. package/lib/types/services/sheet-embed-integration.service.d.ts +126 -0
  82. package/lib/types/services/sheet-embed-runtime.service.d.ts +26 -0
  83. package/lib/types/services/sheet-host-chrome-override.service.d.ts +25 -0
  84. package/lib/types/services/sheet-skeleton-manager.service.d.ts +2 -0
  85. package/lib/types/views/border-panel/interface.d.ts +63 -2
  86. package/lib/types/views/editor-container/EditorContainer.d.ts +7 -5
  87. package/lib/types/{menu/mobile-menu.d.ts → views/editor-container/EditorContainer.spec.d.ts} +1 -1
  88. package/lib/types/views/editor-container/focus-editor.d.ts +25 -0
  89. package/lib/types/views/sheet-bar/sheet-bar-tabs/SheetBarItem.d.ts +2 -1
  90. package/lib/types/views/sheet-bar/sheet-bar-tabs/utils/sheet-tab-drag-sort.d.ts +1 -0
  91. package/lib/types/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.d.ts +2 -1
  92. package/lib/umd/facade.js +1 -1
  93. package/lib/umd/index.js +12 -12
  94. package/lib/umd/locale/ar-SA.js +1 -1
  95. package/lib/umd/locale/ca-ES.js +1 -1
  96. package/lib/umd/locale/de-DE.js +1 -1
  97. package/lib/umd/locale/en-US.js +1 -1
  98. package/lib/umd/locale/es-ES.js +1 -1
  99. package/lib/umd/locale/fa-IR.js +1 -1
  100. package/lib/umd/locale/fr-FR.js +1 -1
  101. package/lib/umd/locale/id-ID.js +1 -1
  102. package/lib/umd/locale/it-IT.js +1 -1
  103. package/lib/umd/locale/ja-JP.js +1 -1
  104. package/lib/umd/locale/ko-KR.js +1 -1
  105. package/lib/umd/locale/pl-PL.js +1 -1
  106. package/lib/umd/locale/pt-BR.js +1 -1
  107. package/lib/umd/locale/ru-RU.js +1 -1
  108. package/lib/umd/locale/sk-SK.js +1 -1
  109. package/lib/umd/locale/vi-VN.js +1 -1
  110. package/lib/umd/locale/zh-CN.js +1 -1
  111. package/lib/umd/locale/zh-HK.js +1 -1
  112. package/lib/umd/locale/zh-TW.js +1 -1
  113. package/package.json +15 -15
package/lib/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
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, 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_BUT_HIDDEN, 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, NilCommand, ObjectMatrix, Optional, Plugin, PresetListType, Quantity, RANGE_TYPE, Range, Rectangle, RxDisposable, ThemeService, Tools, UndoCommandId, UniverInstanceType, UserManagerService, VerticalAlign, Workbook, WrapStrategy, cloneCellDataMatrix, cloneCellDataWithSpanAndDisplay, cloneValue, composeStyles, convertCellToRange, createIdentifier, createInterceptorKey, createParagraphId, dateKit, debounce, extractPureTextFromCell, fromEventSubject, generateRandomId, get, getEmptyCell, getNumfmtParseValueFilter, getReverseDirection, handleStyleToString, isDefaultFormat, isFormulaString, isNotNullOrUndefined, isRealNum, isSafeUrl, isTextFormat, isValidRange, merge, mergeOverrideWithDependencies, nameCharacterCheck, numfmt, registerDependencies, sequenceExecute, set, skipParseTagNames, sortRules, splitIntoGrid, throttle, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
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_BUT_HIDDEN, 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, ThemeService, Tools, UndoCommandId, UniverInstanceType, UserManagerService, VerticalAlign, Workbook, WrapStrategy, cloneCellDataMatrix, cloneCellDataWithSpanAndDisplay, cloneValue, composeStyles, convertCellToRange, createIdentifier, createInterceptorKey, createParagraphId, createSectionId, dateKit, debounce, extractPureTextFromCell, fromEventSubject, generateRandomId, get, getEmptyCell, getNumfmtParseValueFilter, getReverseDirection, handleStyleToString, isDefaultFormat, isFormulaString, isInternalEditorID, isNotNullOrUndefined, isRealNum, isSafeUrl, isTextFormat, isValidRange, merge, mergeOverrideWithDependencies, nameCharacterCheck, numfmt, registerDependencies, sequenceExecute, set, skipParseTagNames, sortRules, splitIntoGrid, throttle, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
3
3
  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, RibbonDataGroup, RibbonPosition, RibbonStartGroup, SheetPasteShortKeyCommandName, Slider, ToolbarItem, UI_PLUGIN_CONFIG_KEY, UniverMobileUIPlugin, connectInjector, getMenuHiddenObservable, handleStringToStyle, imageMimeTypeSet, sanitizeParsedHtml, textTrim, useComponentsOfPart, useConfigValue, useDependency, useEvent, useObservable, useSidebarClick, useVirtualList } from "@univerjs/ui";
4
4
  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, Vector2, Viewport, cancelRequestFrame, convertTextRotation, convertTransformToOffsetX, convertTransformToOffsetY, fixLineWidthByScale, getCurrentTypeOfRenderer, getNextWheelZoomRatio, ptToPixel, requestNewFrame, withCurrentTypeOfRenderer } from "@univerjs/engine-render";
5
5
  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, 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, rangeToDiscreteRange, serializeListOptions, setEndForRange, validateDefinedName } from "@univerjs/sheets";
@@ -7,7 +7,7 @@ import { BehaviorSubject, EMPTY, Observable, Subject, Subscription, combineLates
7
7
  import { DocSelectionManagerService, DocSkeletonManagerService, InsertTextCommand, RichTextEditingMutation, SetTextSelectionsOperation } 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, CopyDoubleIcon, CutIcon, DeleteCellShiftLeftDoubleIcon, DeleteCellShiftUpDoubleIcon, DeleteColumnDoubleIcon, DeleteIcon, DeleteRowDoubleIcon, DownBorderDoubleIcon, DownloadImageIcon, DropdownIcon, ErrorIcon, EyeIcon, EyelashIcon, FontColorDoubleIcon, FontSizeIncreaseIcon, FontSizeReduceIcon, FreezeColumnIcon, FreezeRowIcon, FreezeToSelectedIcon, FxIcon, HideDoubleIcon, HideGridlinesDoubleIcon, 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, PipingIcon, ProtectIcon, ReduceDoubleIcon, RightBorderDoubleIcon, RightDoubleDiagonalDoubleIcon, RightInsertColumnDoubleIcon, RightJustifyingIcon, RightRotationFortyFiveDegreesIcon, RightRotationNinetyDegreesIcon, SlashDoubleIcon, StrikethroughIcon, SubscriptIcon, SuperscriptIcon, TruncationIcon, UnderlineIcon, UpBorderDoubleIcon, VerticalBorderDoubleIcon, VerticalCenterIcon, VerticalIntegrationIcon, VerticalTextIcon, WarningIcon, WriteIcon } from "@univerjs/icons";
10
+ import { AddImageIcon, AdjustHeightDoubleIcon, AdjustWidthDoubleIcon, AlignBottomIcon, AlignTopIcon, AllBorderIcon, AutoHeightDoubleIcon, AutoWidthDoubleIcon, AutofillDoubleIcon, AutowrapIcon, BackSlashDoubleIcon, BoldIcon, BrushIcon, CancelFreezeIcon, CancelMergeIcon, CheckMarkIcon, ClearFormatDoubleIcon, CloseIcon, CodeIcon, ConvertIcon, CopyDoubleIcon, CutIcon, DeleteCellShiftLeftDoubleIcon, DeleteCellShiftUpDoubleIcon, DeleteColumnDoubleIcon, DeleteIcon, DeleteRowDoubleIcon, DownBorderDoubleIcon, DownIcon, DownloadImageIcon, ErrorIcon, EyeIcon, EyelashIcon, FontColorDoubleIcon, FontSizeIncreaseIcon, FontSizeReduceIcon, FreezeColumnIcon, FreezeRowIcon, FreezeToSelectedIcon, FxIcon, HideDoubleIcon, HideGridlinesDoubleIcon, 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, PipingIcon, ProtectIcon, ReduceDoubleIcon, RightBorderDoubleIcon, RightDoubleDiagonalDoubleIcon, RightInsertColumnDoubleIcon, RightJustifyingIcon, RightRotationFortyFiveDegreesIcon, RightRotationNinetyDegreesIcon, SlashDoubleIcon, StrikethroughIcon, SubscriptIcon, SuperscriptIcon, TruncationIcon, UnderlineIcon, UpBorderDoubleIcon, VerticalBorderDoubleIcon, VerticalCenterIcon, VerticalIntegrationIcon, VerticalTextIcon, WarningIcon, WriteIcon } from "@univerjs/icons";
11
11
  import { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
12
12
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
13
  import { FUNCTION_NAMES_MATH, FUNCTION_NAMES_STATISTICAL, FUNCTION_NAMES_TEXT, FormulaDataModel, IDefinedNamesService, IFunctionService, ISuperTableService, LexerTreeBuilder, NullValueObject, SetFormulaCalculationNotificationMutation, deserializeRangeWithSheet, isReferenceStringWithEffectiveColumn, isReferenceStrings, matchToken, operatorToken, sequenceNodeType, serializeRange, serializeRangeWithSheet } from "@univerjs/engine-formula";
@@ -460,6 +460,19 @@ var BaseSelectionRenderService = class extends Disposable {
460
460
  this._initSelectionThemeFromThemeService();
461
461
  this._initMoving();
462
462
  }
463
+ dispose() {
464
+ var _this$_escapeShortcut;
465
+ if (this._disposed) return;
466
+ this._clearUpdatingListeners();
467
+ this._reset();
468
+ (_this$_escapeShortcut = this._escapeShortcutDisposable) === null || _this$_escapeShortcut === void 0 || _this$_escapeShortcut.dispose();
469
+ this._escapeShortcutDisposable = null;
470
+ this._controlFillConfig$.complete();
471
+ this._selectionMoveEnd$.complete();
472
+ this._selectionMoving$.complete();
473
+ this._selectionMoveStart$.complete();
474
+ super.dispose();
475
+ }
463
476
  /**
464
477
  * If true, the selector will respond to the range of merged cells and automatically extend the selected range. If false, it will ignore the merged cells.
465
478
  */
@@ -636,10 +649,10 @@ var BaseSelectionRenderService = class extends Disposable {
636
649
  }
637
650
  }
638
651
  endSelection() {
639
- var _this$_escapeShortcut;
652
+ var _this$_escapeShortcut2;
640
653
  this._clearUpdatingListeners();
641
654
  this._selectionMoveEnd$.next(this.getSelectionDataWithStyle());
642
- (_this$_escapeShortcut = this._escapeShortcutDisposable) === null || _this$_escapeShortcut === void 0 || _this$_escapeShortcut.dispose();
655
+ (_this$_escapeShortcut2 = this._escapeShortcutDisposable) === null || _this$_escapeShortcut2 === void 0 || _this$_escapeShortcut2.dispose();
643
656
  this._escapeShortcutDisposable = null;
644
657
  }
645
658
  /**
@@ -1087,10 +1100,7 @@ let SheetSkeletonManagerService = class SheetSkeletonManagerService extends Disp
1087
1100
  render.scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM).setViewportSize({ top: size });
1088
1101
  render.scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_ROW_TOP).setViewportSize({ top: size });
1089
1102
  render.scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).setViewportSize({ height: size });
1090
- const selectionService = render === null || render === void 0 ? void 0 : render.with(SheetsSelectionsService);
1091
- const selectionRenderService = render === null || render === void 0 ? void 0 : render.with(ISheetSelectionRenderService);
1092
- const currSelections = selectionService.getCurrentSelections();
1093
- selectionRenderService.resetSelectionsByModelData(currSelections);
1103
+ this._resetSelectionsIfAvailable(render);
1094
1104
  const sheetSkeletonManagerParam = this._sheetSkeletonService.getSkeletonParam(render.unitId, sheetId);
1095
1105
  if (sheetSkeletonManagerParam) {
1096
1106
  sheetSkeletonManagerParam.commandId = SetColumnHeaderHeightCommand.id;
@@ -1111,16 +1121,28 @@ let SheetSkeletonManagerService = class SheetSkeletonManagerService extends Disp
1111
1121
  const prevLeft = render.scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).left || 0;
1112
1122
  render.scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).setViewportSize({ left: prevLeft + deltaX });
1113
1123
  render.scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).setViewportSize({ width: size });
1114
- const selectionService = render === null || render === void 0 ? void 0 : render.with(SheetsSelectionsService);
1115
- const selectionRenderService = render === null || render === void 0 ? void 0 : render.with(ISheetSelectionRenderService);
1116
- const currSelections = selectionService.getCurrentSelections();
1117
- selectionRenderService.resetSelectionsByModelData(currSelections);
1124
+ this._resetSelectionsIfAvailable(render);
1118
1125
  const sheetSkeletonManagerParam = this._sheetSkeletonService.getSkeletonParam(render.unitId, sheetId);
1119
1126
  if (sheetSkeletonManagerParam) {
1120
1127
  sheetSkeletonManagerParam.commandId = SetRowHeaderWidthCommand.id;
1121
1128
  this._currentSkeleton$.next(sheetSkeletonManagerParam);
1122
1129
  }
1123
1130
  }
1131
+ _resetSelectionsIfAvailable(render) {
1132
+ const selectionService = this._tryGetRenderDependency(render, SheetsSelectionsService);
1133
+ const selectionRenderService = this._tryGetRenderDependency(render, ISheetSelectionRenderService);
1134
+ if (!selectionService || !selectionRenderService) return;
1135
+ const currSelections = selectionService.getCurrentSelections();
1136
+ selectionRenderService.resetSelectionsByModelData(currSelections);
1137
+ }
1138
+ _tryGetRenderDependency(render, dependency) {
1139
+ try {
1140
+ return render.with(dependency);
1141
+ } catch (error) {
1142
+ if (error instanceof Error && (error.message.includes("DependencyNotFoundError") || error.message.includes("Cannot find"))) return null;
1143
+ throw error;
1144
+ }
1145
+ }
1124
1146
  };
1125
1147
  SheetSkeletonManagerService = __decorate([__decorateParam(1, Inject(SheetSkeletonService))], SheetSkeletonManagerService);
1126
1148
 
@@ -1230,7 +1252,7 @@ var SelectionShapeExtension = class {
1230
1252
  ].forEach((control) => {
1231
1253
  control.onPointerEnter$.subscribeEvent(() => {
1232
1254
  var _this$_injector$get;
1233
- if (((_this$_injector$get = this._injector.get(ISheetSelectionRenderService, Quantity.OPTIONAL)) === null || _this$_injector$get === void 0 ? void 0 : _this$_injector$get.interceptor.fetchThroughInterceptors(RANGE_MOVE_PERMISSION_CHECK)(false, null)) === false) return;
1255
+ if (((_this$_injector$get = this._injector.get(ISheetSelectionRenderService, Quantity.OPTIONAL, LookUp.SELF)) === null || _this$_injector$get === void 0 ? void 0 : _this$_injector$get.interceptor.fetchThroughInterceptors(RANGE_MOVE_PERMISSION_CHECK)(false, null)) === false) return;
1234
1256
  control.setCursor(CURSOR_TYPE.MOVE);
1235
1257
  });
1236
1258
  control.onPointerLeave$.subscribeEvent(() => {
@@ -1335,7 +1357,7 @@ var SelectionShapeExtension = class {
1335
1357
  var _this$_injector$get2;
1336
1358
  if (this._disabled) return;
1337
1359
  const { offsetX: moveOffsetX, offsetY: moveOffsetY } = moveEvt;
1338
- if (((_this$_injector$get2 = this._injector.get(ISheetSelectionRenderService, Quantity.OPTIONAL)) === null || _this$_injector$get2 === void 0 ? void 0 : _this$_injector$get2.interceptor.fetchThroughInterceptors(RANGE_MOVE_PERMISSION_CHECK)(false, null)) === false) return;
1360
+ if (((_this$_injector$get2 = this._injector.get(ISheetSelectionRenderService, Quantity.OPTIONAL, LookUp.SELF)) === null || _this$_injector$get2 === void 0 ? void 0 : _this$_injector$get2.interceptor.fetchThroughInterceptors(RANGE_MOVE_PERMISSION_CHECK)(false, null)) === false) return;
1339
1361
  const { x: newMoveOffsetX, y: newMoveOffsetY } = scene.getCoordRelativeToViewport(Vector2.FromArray([moveOffsetX, moveOffsetY]));
1340
1362
  this._controlMoving(newMoveOffsetX, newMoveOffsetY);
1341
1363
  scene.setCursor(CURSOR_TYPE.MOVE);
@@ -1500,7 +1522,7 @@ var SelectionShapeExtension = class {
1500
1522
  _initialAutoFill() {
1501
1523
  const { fillControl } = this._control;
1502
1524
  fillControl.onPointerEnter$.subscribeEvent((evt) => {
1503
- if (!this._injector.get(ISheetSelectionRenderService).interceptor.fetchThroughInterceptors(RANGE_FILL_PERMISSION_CHECK)(false, {
1525
+ if (!this._injector.get(ISheetSelectionRenderService, LookUp.SELF).interceptor.fetchThroughInterceptors(RANGE_FILL_PERMISSION_CHECK)(false, {
1504
1526
  x: evt.offsetX,
1505
1527
  y: evt.offsetY,
1506
1528
  skeleton: this._skeleton,
@@ -1631,7 +1653,7 @@ var SelectionShapeExtension = class {
1631
1653
  var _this$_activeViewport;
1632
1654
  const { offsetX: moveOffsetX, offsetY: moveOffsetY } = moveEvt;
1633
1655
  const currentViewport = scene.getActiveViewportByCoord(Vector2.FromArray([moveOffsetX, moveOffsetY]));
1634
- if (!this._injector.get(ISheetSelectionRenderService).interceptor.fetchThroughInterceptors(RANGE_FILL_PERMISSION_CHECK)(false, {
1656
+ if (!this._injector.get(ISheetSelectionRenderService, LookUp.SELF).interceptor.fetchThroughInterceptors(RANGE_FILL_PERMISSION_CHECK)(false, {
1635
1657
  x: evt.offsetX,
1636
1658
  y: evt.offsetY,
1637
1659
  skeleton: this._skeleton,
@@ -7300,12 +7322,14 @@ let SheetsScrollRenderController = class SheetsScrollRenderController extends Di
7300
7322
  this.disposeWithMe(viewportMain.onScrollByBar$.subscribeEvent((param) => {
7301
7323
  var _this$_sheetSkeletonM3;
7302
7324
  const skeleton = (_this$_sheetSkeletonM3 = this._sheetSkeletonManagerService.getCurrentParam()) === null || _this$_sheetSkeletonM3 === void 0 ? void 0 : _this$_sheetSkeletonM3.skeleton;
7303
- if (skeleton == null || param.isTrigger === false) return;
7325
+ if (skeleton == null || param.isTrigger === false || param.isBarDragging && !param.isBarDragEnd) return;
7304
7326
  const sheetObject = this._getSheetObject();
7305
7327
  if (skeleton == null || sheetObject == null) return;
7306
7328
  const { viewportScrollX = 0, viewportScrollY = 0 } = param;
7307
7329
  const { row, column, rowOffset, columnOffset } = skeleton.getOffsetRelativeToRowCol(viewportScrollX, viewportScrollY);
7308
7330
  this._commandService.executeCommand(ScrollCommand.id, {
7331
+ unitId: this._context.unitId,
7332
+ sheetId: skeleton.getLocation()[1],
7309
7333
  sheetViewStartRow: row,
7310
7334
  sheetViewStartColumn: column,
7311
7335
  offsetX: columnOffset,
@@ -7393,8 +7417,11 @@ let SheetsScrollRenderController = class SheetsScrollRenderController extends Di
7393
7417
  * @returns {boolean} - true if scroll is successful
7394
7418
  */
7395
7419
  scrollToCell(row, column, duration) {
7396
- const { ySplit: freezeYSplit, xSplit: freezeXSplit } = this._context.unit.getActiveSheet().getFreeze();
7420
+ const worksheet = this._context.unit.getActiveSheet();
7421
+ const { ySplit: freezeYSplit, xSplit: freezeXSplit } = worksheet.getFreeze();
7397
7422
  return this._commandService.syncExecuteCommand(ScrollCommand.id, {
7423
+ unitId: this._context.unitId,
7424
+ sheetId: worksheet.getSheetId(),
7398
7425
  sheetViewStartRow: row - freezeYSplit,
7399
7426
  sheetViewStartColumn: column - freezeXSplit,
7400
7427
  offsetX: 0,
@@ -7567,6 +7594,8 @@ let SheetsScrollRenderController = class SheetsScrollRenderController extends Di
7567
7594
  startSheetViewRow = startSheetViewRow - hiddenRows.length;
7568
7595
  }
7569
7596
  return this._commandService.syncExecuteCommand(ScrollCommand.id, {
7597
+ unitId: this._context.unitId,
7598
+ sheetId: worksheet.getSheetId(),
7570
7599
  sheetViewStartRow: Math.max(0, startSheetViewRow - freezedRowCount),
7571
7600
  sheetViewStartColumn: Math.max(0, startSheetViewColumn - freezedColCount),
7572
7601
  offsetX,
@@ -7655,10 +7684,12 @@ const ScrollCommand = {
7655
7684
  if (!params) return false;
7656
7685
  const univerInstanceService = accessor.get(IUniverInstanceService);
7657
7686
  const renderManagerSrv = accessor.get(IRenderManagerService);
7658
- const target = getSheetCommandTarget(univerInstanceService);
7687
+ const target = params.unitId ? getScrollCommandTargetByParams(univerInstanceService, params) : getSheetCommandTarget(univerInstanceService);
7659
7688
  if (!target) return false;
7660
7689
  const { workbook, worksheet, unitId } = target;
7661
- const currentScroll = renderManagerSrv.getRenderById(unitId).with(SheetScrollManagerService).getCurrentScrollState();
7690
+ const renderUnit = renderManagerSrv.getRenderById(unitId);
7691
+ if (!renderUnit) return false;
7692
+ const currentScroll = renderUnit.with(SheetScrollManagerService).getCurrentScrollState();
7662
7693
  if (!worksheet) return false;
7663
7694
  const { sheetViewStartRow, sheetViewStartColumn, offsetX, offsetY, duration } = params;
7664
7695
  const { sheetViewStartColumn: currentColumn, sheetViewStartRow: currentRow, offsetX: currentOffsetX, offsetY: currentOffsetY } = currentScroll || {};
@@ -7674,6 +7705,18 @@ const ScrollCommand = {
7674
7705
  });
7675
7706
  }
7676
7707
  };
7708
+ function getScrollCommandTargetByParams(univerInstanceService, params) {
7709
+ if (!params.unitId) return null;
7710
+ const workbook = univerInstanceService.getUnit(params.unitId, UniverInstanceType.UNIVER_SHEET);
7711
+ const worksheet = params.sheetId ? workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(params.sheetId) : workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
7712
+ if (!workbook || !worksheet) return null;
7713
+ return {
7714
+ workbook,
7715
+ worksheet,
7716
+ unitId: params.unitId,
7717
+ subUnitId: worksheet.getSheetId()
7718
+ };
7719
+ }
7677
7720
  /**
7678
7721
  * The command is used to scroll to the specific cell if the target cell is not in the viewport.
7679
7722
  */
@@ -7869,7 +7912,7 @@ let EditorBridgeService = class EditorBridgeService extends Disposable {
7869
7912
  refreshEditCellPosition(resetSizeOnly) {
7870
7913
  if (!this._currentEditCell || !this._currentEditCellState) return;
7871
7914
  const { unitId, sheetId, primary, scene, engine } = this._currentEditCell;
7872
- const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
7915
+ const workbook = this._getWorkbookForEditUnit(unitId);
7873
7916
  if (!workbook || workbook.getUnitId() !== unitId) return;
7874
7917
  const worksheet = workbook.getActiveSheet();
7875
7918
  if (!worksheet || worksheet.getSheetId() !== sheetId) return;
@@ -7968,7 +8011,7 @@ let EditorBridgeService = class EditorBridgeService extends Disposable {
7968
8011
  var _documentLayoutObject, _documentLayoutObject2;
7969
8012
  if (!this._currentEditCell) return;
7970
8013
  const { unitId, sheetId, primary, scene, engine } = this._currentEditCell;
7971
- const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
8014
+ const workbook = this._getWorkbookForEditUnit(unitId);
7972
8015
  if (!workbook || workbook.getUnitId() !== unitId) return;
7973
8016
  const worksheet = workbook.getActiveSheet();
7974
8017
  if (!worksheet || worksheet.getSheetId() !== sheetId) return;
@@ -8046,6 +8089,10 @@ let EditorBridgeService = class EditorBridgeService extends Disposable {
8046
8089
  isInArrayFormulaRange: cell === null || cell === void 0 ? void 0 : cell.isInArrayFormulaRange
8047
8090
  };
8048
8091
  }
8092
+ _getWorkbookForEditUnit(unitId) {
8093
+ var _this$_univerInstance;
8094
+ return (_this$_univerInstance = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) !== null && _this$_univerInstance !== void 0 ? _this$_univerInstance : this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
8095
+ }
8049
8096
  getCurrentEditorId() {
8050
8097
  return this._editorUnitId;
8051
8098
  }
@@ -8424,9 +8471,15 @@ const ScrollToRangeOperation = {
8424
8471
  id: "sheet.operation.scroll-to-range",
8425
8472
  type: CommandType.OPERATION,
8426
8473
  handler: (accessor, params) => {
8474
+ var _params$unitId, _instanceService$getC;
8427
8475
  if (!params) return false;
8428
8476
  const instanceService = accessor.get(IUniverInstanceService);
8429
- return accessor.get(IRenderManagerService).getRenderById(instanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET).getUnitId()).with(SheetsScrollRenderController).scrollToRange(params.range, params.forceTop, params.forceLeft);
8477
+ const renderManagerService = accessor.get(IRenderManagerService);
8478
+ const unitId = (_params$unitId = params.unitId) !== null && _params$unitId !== void 0 ? _params$unitId : (_instanceService$getC = instanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _instanceService$getC === void 0 ? void 0 : _instanceService$getC.getUnitId();
8479
+ if (!unitId) return false;
8480
+ const renderUnit = renderManagerService.getRenderById(unitId);
8481
+ if (!renderUnit) return false;
8482
+ return renderUnit.with(SheetsScrollRenderController).scrollToRange(params.range, params.forceTop, params.forceLeft);
8430
8483
  }
8431
8484
  };
8432
8485
 
@@ -8738,18 +8791,19 @@ let SheetsRenderService = class SheetsRenderService extends RxDisposable {
8738
8791
  }
8739
8792
  _initWorkbookListener() {
8740
8793
  this._instanceSrv.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((event) => this._createRenderer(event.unit, event.options));
8741
- this._instanceSrv.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => this._createRenderer(workbook));
8794
+ this._instanceSrv.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => {
8795
+ var _this$_instanceSrv$ge;
8796
+ return this._createRenderer(workbook, (_this$_instanceSrv$ge = this._instanceSrv.getUnitCreateOptions(workbook.getUnitId())) !== null && _this$_instanceSrv$ge !== void 0 ? _this$_instanceSrv$ge : void 0);
8797
+ });
8742
8798
  this._instanceSrv.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._disposeRenderer(workbook));
8743
8799
  }
8744
8800
  _createRenderer(workbook, createUnitOptions) {
8801
+ if (createUnitOptions === null || createUnitOptions === void 0 ? void 0 : createUnitOptions.skipAutoRender) return;
8745
8802
  const unitId = workbook.getUnitId();
8746
- this._renderManagerService.created$.subscribe((renderer) => {
8747
- if (renderer.unitId === unitId) {
8748
- renderer.engine.getCanvas().setId(`${SHEET_MAIN_CANVAS_ID}_${unitId}`);
8749
- renderer.engine.getCanvas().getContext().setId(`${SHEET_MAIN_CANVAS_ID}_${unitId}`);
8750
- }
8751
- });
8752
- this._renderManagerService.createRender(unitId, createUnitOptions);
8803
+ const canvas = this._renderManagerService.createRender(unitId, createUnitOptions).engine.getCanvas();
8804
+ canvas.setId(`${SHEET_MAIN_CANVAS_ID}_${unitId}`);
8805
+ canvas.getCanvasEle().dataset.uUnitId = unitId;
8806
+ canvas.getContext().setId(`${SHEET_MAIN_CANVAS_ID}_${unitId}`);
8753
8807
  }
8754
8808
  _disposeRenderer(workbook) {
8755
8809
  const unitId = workbook.getUnitId();
@@ -8844,11 +8898,28 @@ let AutoFillUIController = class AutoFillUIController extends Disposable {
8844
8898
  }
8845
8899
  _initSelectionControlFillChanged() {
8846
8900
  const disposableCollection = new DisposableCollection();
8901
+ let pendingRetry = false;
8902
+ let retryCount = 0;
8903
+ const scheduleUpdateListener = (listener) => {
8904
+ if (pendingRetry) return;
8905
+ pendingRetry = true;
8906
+ setTimeout(() => {
8907
+ pendingRetry = false;
8908
+ listener();
8909
+ }, 0);
8910
+ };
8847
8911
  const updateListener = () => {
8848
8912
  disposableCollection.dispose();
8849
8913
  const currentRenderer = getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService);
8850
8914
  if (!currentRenderer) return;
8851
- currentRenderer.with(ISheetSelectionRenderService).getSelectionControls().forEach((controlSelection) => {
8915
+ const selectionRenderService = getResolvedSelectionRenderService(currentRenderer);
8916
+ if (!selectionRenderService) {
8917
+ retryCount += 1;
8918
+ if (retryCount <= 3) scheduleUpdateListener(updateListener);
8919
+ return;
8920
+ }
8921
+ retryCount = 0;
8922
+ selectionRenderService.getSelectionControls().forEach((controlSelection) => {
8852
8923
  disposableCollection.add(controlSelection.selectionFilled$.subscribe((filled) => {
8853
8924
  if (filled == null || filled.startColumn === -1 || filled.startRow === -1 || filled.endColumn === -1 || filled.endRow === -1) return;
8854
8925
  const source = {
@@ -8886,11 +8957,11 @@ let AutoFillUIController = class AutoFillUIController extends Disposable {
8886
8957
  }));
8887
8958
  });
8888
8959
  };
8889
- updateListener();
8960
+ scheduleUpdateListener(updateListener);
8890
8961
  this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
8891
- if (command.id === SetSelectionsOperation.id) updateListener();
8962
+ if (command.id === SetSelectionsOperation.id) scheduleUpdateListener(updateListener);
8892
8963
  }));
8893
- this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).subscribe(() => updateListener()));
8964
+ this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).subscribe(() => scheduleUpdateListener(updateListener)));
8894
8965
  }
8895
8966
  _handleDbClickFill(source) {
8896
8967
  const selection = this._detectFillRange(source);
@@ -8940,6 +9011,13 @@ AutoFillUIController = __decorate([
8940
9011
  __decorateParam(5, IRenderManagerService),
8941
9012
  __decorateParam(6, Inject(SheetsRenderService))
8942
9013
  ], AutoFillUIController);
9014
+ function getResolvedSelectionRenderService(renderer) {
9015
+ var _getInjector, _resolvedDependencyCo;
9016
+ const injector = (_getInjector = renderer.getInjector) === null || _getInjector === void 0 ? void 0 : _getInjector.call(renderer);
9017
+ const resolvedDependencies = injector === null || injector === void 0 || (_resolvedDependencyCo = injector.resolvedDependencyCollection) === null || _resolvedDependencyCo === void 0 ? void 0 : _resolvedDependencyCo.resolvedDependencies;
9018
+ if (!resolvedDependencies) return;
9019
+ for (const [identifier, values] of resolvedDependencies) if (identifier.decoratorName === ISheetSelectionRenderService.decoratorName) return values.length === 1 ? values[0] : void 0;
9020
+ }
8943
9021
 
8944
9022
  //#endregion
8945
9023
  //#region src/controllers/auto-height.controller.ts
@@ -9392,12 +9470,60 @@ var CellEditorManagerService = class {
9392
9470
  };
9393
9471
  const ICellEditorManagerService = createIdentifier("univer.sheet-cell-editor-manager.service");
9394
9472
 
9473
+ //#endregion
9474
+ //#region src/services/sheet-embed-integration.service.ts
9475
+ const SHEET_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
9476
+ const SHEET_EMBED_RUNTIME_FOCUS_ROLE_ATTRIBUTE = "data-embed-runtime-focus-role";
9477
+ const SHEET_EMBED_FLOAT_DOM_ATTRIBUTE = "data-embed-float-dom";
9478
+ const SHEET_EMBED_ID_ATTRIBUTE = "data-embed-id";
9479
+ const SHEET_EMBED_HOST_UNIT_ID_ATTRIBUTE = "data-embed-host-unit-id";
9480
+ const SHEET_EMBED_CHILD_UNIT_ID_ATTRIBUTE = "data-embed-child-unit-id";
9481
+ const SHEET_EMBED_CHILD_TYPE_ATTRIBUTE = "data-embed-child-type";
9482
+ const ISheetEmbedInteractionBoundaryService = createIdentifier("sheets-ui.embed-interaction-boundary.service");
9483
+ const ISheetEmbedRuntimeFocusCoordinator = createIdentifier("sheets-ui.embed-runtime-focus-coordinator");
9484
+ const ISheetEmbedFloatingGeometryService = createIdentifier("sheets-ui.embed-floating-geometry.service");
9485
+ function resolveSheetEmbedRuntimeDomScope(element) {
9486
+ var _element$closest$getA, _element$closest, _container$getAttribu, _container$getAttribu2, _container$getAttribu3;
9487
+ if (!element) return;
9488
+ const embedId = (_element$closest$getA = (_element$closest = element.closest(`[${"data-embed-interaction-boundary-owner"}]`)) === null || _element$closest === void 0 ? void 0 : _element$closest.getAttribute("data-embed-interaction-boundary-owner")) !== null && _element$closest$getA !== void 0 ? _element$closest$getA : void 0;
9489
+ const container = resolveSheetEmbedFloatDomContainer(element, embedId);
9490
+ const resolvedEmbedId = (_container$getAttribu = container === null || container === void 0 ? void 0 : container.getAttribute("data-embed-id")) !== null && _container$getAttribu !== void 0 ? _container$getAttribu : embedId;
9491
+ if (!resolvedEmbedId) return;
9492
+ return {
9493
+ embedId: resolvedEmbedId,
9494
+ hostUnitId: (_container$getAttribu2 = container === null || container === void 0 ? void 0 : container.getAttribute("data-embed-host-unit-id")) !== null && _container$getAttribu2 !== void 0 ? _container$getAttribu2 : void 0,
9495
+ childUnitId: (_container$getAttribu3 = container === null || container === void 0 ? void 0 : container.getAttribute("data-embed-child-unit-id")) !== null && _container$getAttribu3 !== void 0 ? _container$getAttribu3 : void 0,
9496
+ childType: readChildType(container)
9497
+ };
9498
+ }
9499
+ function resolveActiveSheetEmbedRuntimeDomScope(ownerDocument = document) {
9500
+ const activeContainer = ownerDocument.querySelector(`[${SHEET_EMBED_FLOAT_DOM_ATTRIBUTE}="true"][data-embed-float-stage="stage2"]`);
9501
+ if (!activeContainer) return;
9502
+ return resolveSheetEmbedRuntimeDomScope(activeContainer);
9503
+ }
9504
+ function resolveSheetEmbedFloatDomContainer(element, embedId) {
9505
+ var _element$ownerDocumen, _ownerDocument$queryS;
9506
+ const ownContainer = element === null || element === void 0 ? void 0 : element.closest(`[${SHEET_EMBED_FLOAT_DOM_ATTRIBUTE}="true"]`);
9507
+ if (ownContainer && (!embedId || ownContainer.getAttribute("data-embed-id") === embedId)) return ownContainer;
9508
+ const ownerDocument = (_element$ownerDocumen = element === null || element === void 0 ? void 0 : element.ownerDocument) !== null && _element$ownerDocumen !== void 0 ? _element$ownerDocumen : typeof document === "undefined" ? void 0 : document;
9509
+ if (!ownerDocument || !embedId) return ownContainer !== null && ownContainer !== void 0 ? ownContainer : void 0;
9510
+ return (_ownerDocument$queryS = ownerDocument.querySelector(`[${"data-embed-float-dom"}="true"][${"data-embed-id"}="${escapeAttributeValue(embedId)}"]`)) !== null && _ownerDocument$queryS !== void 0 ? _ownerDocument$queryS : void 0;
9511
+ }
9512
+ function escapeAttributeValue(value) {
9513
+ return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
9514
+ }
9515
+ function readChildType(container) {
9516
+ const value = container === null || container === void 0 ? void 0 : container.getAttribute(SHEET_EMBED_CHILD_TYPE_ATTRIBUTE);
9517
+ if (value == null || value === "") return;
9518
+ return Number(value);
9519
+ }
9520
+
9395
9521
  //#endregion
9396
9522
  //#region src/services/editor/cell-editor-resize.service.ts
9397
9523
  const EDITOR_INPUT_SELF_EXTEND_GAP = 5;
9398
9524
  const EDITOR_BORDER_SIZE = 2;
9399
9525
  let SheetCellEditorResizeService = class SheetCellEditorResizeService extends Disposable {
9400
- constructor(_layoutService, _cellEditorManagerService, _editorBridgeService, _renderManagerService, _univerInstanceService, _configService) {
9526
+ constructor(_layoutService, _cellEditorManagerService, _editorBridgeService, _renderManagerService, _univerInstanceService, _configService, _embedFloatingGeometryService) {
9401
9527
  super();
9402
9528
  this._layoutService = _layoutService;
9403
9529
  this._cellEditorManagerService = _cellEditorManagerService;
@@ -9405,6 +9531,7 @@ let SheetCellEditorResizeService = class SheetCellEditorResizeService extends Di
9405
9531
  this._renderManagerService = _renderManagerService;
9406
9532
  this._univerInstanceService = _univerInstanceService;
9407
9533
  this._configService = _configService;
9534
+ this._embedFloatingGeometryService = _embedFloatingGeometryService;
9408
9535
  }
9409
9536
  get _currentRenderer() {
9410
9537
  return getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService);
@@ -9417,9 +9544,8 @@ let SheetCellEditorResizeService = class SheetCellEditorResizeService extends Di
9417
9544
  return this._renderManagerService.getRenderById(this._editingUnitId);
9418
9545
  }
9419
9546
  get _renderer() {
9420
- var _this$_univerInstance;
9421
- const currentUnitId = (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId();
9422
- return this._editingUnitId === currentUnitId ? this._editingRenderer : this._currentRenderer;
9547
+ var _this$_editingRendere;
9548
+ return (_this$_editingRendere = this._editingRenderer) !== null && _this$_editingRendere !== void 0 ? _this$_editingRendere : this._currentRenderer;
9423
9549
  }
9424
9550
  get _sheetSkeletonManagerService() {
9425
9551
  var _this$_renderer;
@@ -9523,13 +9649,14 @@ let SheetCellEditorResizeService = class SheetCellEditorResizeService extends Di
9523
9649
  const { startX, startY, endX } = position;
9524
9650
  const enginWidth = engine.width;
9525
9651
  const maxHeight = height - startY - EDITOR_BORDER_SIZE * 2;
9652
+ const cellWidth = endX - startX;
9526
9653
  let maxWidth = width - startX;
9527
9654
  if (horizontalAlign === HorizontalAlign.CENTER) {
9528
9655
  const rightGap = enginWidth - endX;
9529
- const leftGap = startX;
9530
- maxWidth = endX - startX + Math.min(leftGap, rightGap) * 2;
9656
+ maxWidth = cellWidth + Math.min(startX, rightGap) * 2;
9531
9657
  } else if (horizontalAlign === HorizontalAlign.RIGHT) maxWidth = endX;
9532
9658
  maxWidth = maxWidth - EDITOR_BORDER_SIZE * 2;
9659
+ maxWidth = Math.max(maxWidth, cellWidth);
9533
9660
  return {
9534
9661
  height: maxHeight,
9535
9662
  width: maxWidth,
@@ -9586,7 +9713,7 @@ let SheetCellEditorResizeService = class SheetCellEditorResizeService extends Di
9586
9713
  docEngine.resizeBySize(fixLineWidthByScale(editorWidth, precisionScaleX), fixLineWidthByScale(physicHeight, precisionScaleY));
9587
9714
  callback === null || callback === void 0 || callback();
9588
9715
  }, 0);
9589
- const contentBoundingRect = this._layoutService.getContentElement().getBoundingClientRect();
9716
+ const contentBoundingRect = this._getEditorContentElement().getBoundingClientRect();
9590
9717
  const canvasBoundingRect = canvasElement.getBoundingClientRect();
9591
9718
  startX = startX * scaleAdjust + (canvasBoundingRect.left - contentBoundingRect.left);
9592
9719
  startY = startY * scaleAdjust + (canvasBoundingRect.top - contentBoundingRect.top);
@@ -9601,6 +9728,10 @@ let SheetCellEditorResizeService = class SheetCellEditorResizeService extends Di
9601
9728
  show: true
9602
9729
  });
9603
9730
  }
9731
+ _getEditorContentElement() {
9732
+ var _this$_embedFloatingG, _this$_embedFloatingG2;
9733
+ return (_this$_embedFloatingG = (_this$_embedFloatingG2 = this._embedFloatingGeometryService) === null || _this$_embedFloatingG2 === void 0 || (_this$_embedFloatingG2 = _this$_embedFloatingG2.getRegistrationByChildUnitId(this._editingUnitId)) === null || _this$_embedFloatingG2 === void 0 ? void 0 : _this$_embedFloatingG2.contentRoot) !== null && _this$_embedFloatingG !== void 0 ? _this$_embedFloatingG : this._layoutService.getContentElement();
9734
+ }
9604
9735
  /**
9605
9736
  * Since the document does not support cell background color, an additional rect needs to be added.
9606
9737
  */
@@ -9663,13 +9794,14 @@ SheetCellEditorResizeService = __decorate([
9663
9794
  __decorateParam(2, IEditorBridgeService),
9664
9795
  __decorateParam(3, IRenderManagerService),
9665
9796
  __decorateParam(4, IUniverInstanceService),
9666
- __decorateParam(5, IConfigService)
9797
+ __decorateParam(5, IConfigService),
9798
+ __decorateParam(6, Optional(ISheetEmbedFloatingGeometryService))
9667
9799
  ], SheetCellEditorResizeService);
9668
9800
 
9669
9801
  //#endregion
9670
9802
  //#region src/controllers/render-controllers/editor-bridge.render-controller.ts
9671
9803
  let EditorBridgeRenderController = class EditorBridgeRenderController extends RxDisposable {
9672
- constructor(_context, _instanceSrv, _commandService, _editorBridgeService, _selectionManagerService, _contextService, _renderManagerService, _sheetSkeletonManagerService) {
9804
+ constructor(_context, _instanceSrv, _commandService, _editorBridgeService, _selectionManagerService, _contextService, _renderManagerService, _sheetSkeletonManagerService, _embedRuntimeFocusCoordinator) {
9673
9805
  super();
9674
9806
  this._context = _context;
9675
9807
  this._instanceSrv = _instanceSrv;
@@ -9679,10 +9811,13 @@ let EditorBridgeRenderController = class EditorBridgeRenderController extends Rx
9679
9811
  this._contextService = _contextService;
9680
9812
  this._renderManagerService = _renderManagerService;
9681
9813
  this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
9814
+ this._embedRuntimeFocusCoordinator = _embedRuntimeFocusCoordinator;
9682
9815
  _defineProperty(this, "_d", void 0);
9683
9816
  this.disposeWithMe(this._instanceSrv.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).subscribe((workbook) => {
9684
- if (workbook && workbook.getUnitId() === this._context.unitId) this._d = this._init();
9685
- else this._disposeCurrent();
9817
+ if (workbook && workbook.getUnitId() === this._context.unitId) {
9818
+ if (this._d) return;
9819
+ this._d = this._init();
9820
+ } else this._disposeCurrent();
9686
9821
  }));
9687
9822
  }
9688
9823
  _init() {
@@ -9691,6 +9826,7 @@ let EditorBridgeRenderController = class EditorBridgeRenderController extends Rx
9691
9826
  this._initEventListener(d);
9692
9827
  this._commandExecutedListener(d);
9693
9828
  this._initialKeyboardListener(d);
9829
+ this._initSheetFocusListener(d);
9694
9830
  return d;
9695
9831
  }
9696
9832
  _disposeCurrent() {
@@ -9707,7 +9843,9 @@ let EditorBridgeRenderController = class EditorBridgeRenderController extends Rx
9707
9843
  const primary = params === null || params === void 0 || (_params = params[params.length - 1]) === null || _params === void 0 ? void 0 : _params.primary;
9708
9844
  if (primary) {
9709
9845
  var _this$_context$unit$g, _this$_sheetSkeletonM;
9710
- const { scene, engine } = this._getSheetObject();
9846
+ const sheetObject = this._getSheetObject();
9847
+ if (!sheetObject) return;
9848
+ const { scene, engine } = sheetObject;
9711
9849
  const unitId = this._context.unitId;
9712
9850
  const sheetId = (_this$_context$unit$g = this._context.unit.getActiveSheet()) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.getSheetId();
9713
9851
  if (!sheetId) return;
@@ -9722,6 +9860,7 @@ let EditorBridgeRenderController = class EditorBridgeRenderController extends Rx
9722
9860
  endColumn: mergeInfo.mergeInfo.endColumn,
9723
9861
  isMergedMainCell: mergeInfo.isMergedMainCell
9724
9862
  } : primary;
9863
+ if (isSameEditCell(this._editorBridgeService.getEditLocation(), unitId, sheetId, newPrimary)) return;
9725
9864
  this._commandService.executeCommand(SetActivateCellEditOperation.id, {
9726
9865
  scene,
9727
9866
  engine,
@@ -9739,7 +9878,9 @@ let EditorBridgeRenderController = class EditorBridgeRenderController extends Rx
9739
9878
  }
9740
9879
  }
9741
9880
  _initEventListener(d) {
9742
- const { spreadsheet, spreadsheetColumnHeader, spreadsheetLeftTopPlaceholder, spreadsheetRowHeader } = this._getSheetObject();
9881
+ const sheetObject = this._getSheetObject();
9882
+ if (!sheetObject) return;
9883
+ const { spreadsheet, spreadsheetColumnHeader, spreadsheetLeftTopPlaceholder, spreadsheetRowHeader } = sheetObject;
9743
9884
  d.add(spreadsheet.onDblclick$.subscribeEvent((evt) => {
9744
9885
  if (evt.button === 2) return;
9745
9886
  this._commandService.executeCommand(SetCellEditVisibleOperation.id, {
@@ -9749,19 +9890,19 @@ let EditorBridgeRenderController = class EditorBridgeRenderController extends Rx
9749
9890
  });
9750
9891
  }));
9751
9892
  d.add(spreadsheet.onPointerDown$.subscribeEvent({
9752
- next: this._tryHideEditor.bind(this),
9893
+ next: (payload) => this._tryHideEditor(resolvePointerEventPayload(payload)),
9753
9894
  priority: -1
9754
9895
  }));
9755
9896
  d.add(spreadsheetColumnHeader.onPointerDown$.subscribeEvent({
9756
- next: this._tryHideEditor.bind(this),
9897
+ next: (payload) => this._tryHideEditor(resolvePointerEventPayload(payload)),
9757
9898
  priority: -1
9758
9899
  }));
9759
9900
  d.add(spreadsheetLeftTopPlaceholder.onPointerDown$.subscribeEvent({
9760
- next: this._tryHideEditor.bind(this),
9901
+ next: (payload) => this._tryHideEditor(resolvePointerEventPayload(payload)),
9761
9902
  priority: -1
9762
9903
  }));
9763
9904
  d.add(spreadsheetRowHeader.onPointerDown$.subscribeEvent({
9764
- next: this._tryHideEditor.bind(this),
9905
+ next: (payload) => this._tryHideEditor(resolvePointerEventPayload(payload)),
9765
9906
  priority: -1
9766
9907
  }));
9767
9908
  }
@@ -9775,9 +9916,10 @@ let EditorBridgeRenderController = class EditorBridgeRenderController extends Rx
9775
9916
  const docSelectionRenderService = render.with(DocSelectionRenderService);
9776
9917
  if (docSelectionRenderService) {
9777
9918
  disposable = toDisposable(docSelectionRenderService.onInputBefore$.subscribe((config) => {
9919
+ var _this$_embedRuntimeFo;
9778
9920
  if (!this._isCurrentSheetFocused()) return;
9779
9921
  const isFocusFormulaEditor = this._contextService.getContextValue(FOCUSING_FX_BAR_EDITOR);
9780
- const isFocusSheets = this._contextService.getContextValue(FOCUSING_SHEET);
9922
+ 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;
9781
9923
  const unitId = render.unitId;
9782
9924
  if (this._editorBridgeService.isVisible().visible) return;
9783
9925
  if (unitId && isFocusSheets && !isFocusFormulaEditor) this._showEditorByKeyboard(config);
@@ -9792,6 +9934,17 @@ let EditorBridgeRenderController = class EditorBridgeRenderController extends Rx
9792
9934
  addEvent(render);
9793
9935
  }));
9794
9936
  }
9937
+ _initSheetFocusListener(d) {
9938
+ d.add(this._contextService.subscribeContextValue$(FOCUSING_SHEET).subscribe((isFocusingSheet) => {
9939
+ if (!isFocusingSheet || !this._isCurrentSheetFocused() || this._contextService.getContextValue(FOCUSING_FX_BAR_EDITOR) || this._editorBridgeService.isVisible().visible) return;
9940
+ this._focusCellEditorInput();
9941
+ }));
9942
+ }
9943
+ _focusCellEditorInput() {
9944
+ const render = this._renderManagerService.getRenderById(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
9945
+ const docSelectionRenderService = render === null || render === void 0 ? void 0 : render.with(DocSelectionRenderService);
9946
+ if (!(docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing)) docSelectionRenderService === null || docSelectionRenderService === void 0 || docSelectionRenderService.focus();
9947
+ }
9795
9948
  _commandExecutedListener(d) {
9796
9949
  const refreshCommandSet = /* @__PURE__ */ new Set([ClearSelectionFormatCommand.id, SetZoomRatioCommand.id]);
9797
9950
  d.add(this._commandService.onCommandExecuted((command) => {
@@ -9806,19 +9959,35 @@ let EditorBridgeRenderController = class EditorBridgeRenderController extends Rx
9806
9959
  }));
9807
9960
  }
9808
9961
  _showEditorByKeyboard(config) {
9962
+ var _ref, _config$content;
9809
9963
  const event = config === null || config === void 0 ? void 0 : config.event;
9810
9964
  if (config == null || !event.data && event.inputType !== "InsertParagraph") return;
9965
+ const initialValue = (_ref = (_config$content = config.content) !== null && _config$content !== void 0 ? _config$content : event.data) !== null && _ref !== void 0 ? _ref : "";
9811
9966
  this._commandService.syncExecuteCommand(SetCellEditVisibleOperation.id, {
9812
9967
  visible: true,
9813
9968
  eventType: DeviceInputEventType.Keyboard,
9814
9969
  keycode: event.which,
9970
+ initialValue,
9815
9971
  unitId: this._context.unitId
9816
9972
  });
9817
9973
  }
9818
- _tryHideEditor() {
9974
+ _tryHideEditor(evt) {
9819
9975
  if (this._editorBridgeService.isForceKeepVisible()) return;
9976
+ if (!evt && this._isEmbeddedFormulaEditorActive()) return;
9977
+ if (this._isEmbeddedFormulaEditorActive() && this._isCurrentEmbedRuntimeEvent(evt)) return;
9978
+ if (isEmbedCellEditorInteraction(evt)) return;
9820
9979
  this._hideEditor();
9821
9980
  }
9981
+ _isEmbeddedFormulaEditorActive() {
9982
+ var _this$_embedRuntimeFo2, _this$_editorBridgeSe;
9983
+ if (((_this$_embedRuntimeFo2 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo2 === void 0 ? void 0 : _this$_embedRuntimeFo2.isChildUnitInActiveSession(this._context.unitId)) !== true) return false;
9984
+ 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;
9985
+ return typeof dataStream === "string" && dataStream.startsWith("=");
9986
+ }
9987
+ _isCurrentEmbedRuntimeEvent(evt) {
9988
+ var _this$_embedRuntimeFo3;
9989
+ return ((_this$_embedRuntimeFo3 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo3 === void 0 ? void 0 : _this$_embedRuntimeFo3.isChildUnitRuntimeEvent(this._context.unitId, evt === null || evt === void 0 ? void 0 : evt.target, evt instanceof Event ? evt : evt)) === true;
9990
+ }
9822
9991
  _hideEditor() {
9823
9992
  if (this._editorBridgeService.isVisible().visible !== true) return;
9824
9993
  this._commandService.syncExecuteCommand(SetCellEditVisibleOperation.id, {
@@ -9828,11 +9997,12 @@ let EditorBridgeRenderController = class EditorBridgeRenderController extends Rx
9828
9997
  });
9829
9998
  }
9830
9999
  _getSheetObject() {
10000
+ if (!this._context.unit) return null;
9831
10001
  return getSheetObject(this._context.unit, this._context);
9832
10002
  }
9833
10003
  _isCurrentSheetFocused() {
9834
- var _this$_instanceSrv$ge;
9835
- return ((_this$_instanceSrv$ge = this._instanceSrv.getFocusedUnit()) === null || _this$_instanceSrv$ge === void 0 ? void 0 : _this$_instanceSrv$ge.getUnitId()) === this._context.unitId;
10004
+ var _this$_instanceSrv$ge, _this$_embedRuntimeFo4;
10005
+ return ((_this$_instanceSrv$ge = this._instanceSrv.getFocusedUnit()) === null || _this$_instanceSrv$ge === void 0 ? void 0 : _this$_instanceSrv$ge.getUnitId()) === this._context.unitId || ((_this$_embedRuntimeFo4 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo4 === void 0 ? void 0 : _this$_embedRuntimeFo4.isChildUnitInActiveSession(this._context.unitId)) === true;
9836
10006
  }
9837
10007
  };
9838
10008
  EditorBridgeRenderController = __decorate([
@@ -9842,8 +10012,46 @@ EditorBridgeRenderController = __decorate([
9842
10012
  __decorateParam(4, Inject(SheetsSelectionsService)),
9843
10013
  __decorateParam(5, IContextService),
9844
10014
  __decorateParam(6, IRenderManagerService),
9845
- __decorateParam(7, Inject(SheetSkeletonManagerService))
10015
+ __decorateParam(7, Inject(SheetSkeletonManagerService)),
10016
+ __decorateParam(8, Optional(ISheetEmbedRuntimeFocusCoordinator))
9846
10017
  ], EditorBridgeRenderController);
10018
+ function resolvePointerEventPayload(payload) {
10019
+ return Array.isArray(payload) ? payload[0] : payload;
10020
+ }
10021
+ function isEmbedCellEditorInteraction(evt) {
10022
+ return isEmbedCellEditorInteractionTarget(evt === null || evt === void 0 ? void 0 : evt.target) || isEmbedCellEditorInteractionPoint(resolvePointerEventPoint(evt));
10023
+ }
10024
+ function isEmbedCellEditorInteractionTarget(target) {
10025
+ if (typeof HTMLElement === "undefined" || !(target instanceof HTMLElement)) return false;
10026
+ return target.closest(`[${"data-embed-runtime-focus-role"}="child-editor"]`) != null || target.closest("[data-u-comp=\"editor\"]") != null || target.closest("[id^=\"__editor___INTERNAL_EDITOR__\"]") != null || target.closest("[id^=\"univer-doc-selection-container-__INTERNAL_EDITOR__\"]") != null;
10027
+ }
10028
+ function resolvePointerEventPoint(evt) {
10029
+ if (!evt) return;
10030
+ return {
10031
+ clientX: "clientX" in evt ? evt.clientX : void 0,
10032
+ clientY: "clientY" in evt ? evt.clientY : void 0,
10033
+ x: "x" in evt ? evt.x : void 0,
10034
+ y: "y" in evt ? evt.y : void 0
10035
+ };
10036
+ }
10037
+ function isEmbedCellEditorInteractionPoint(evt) {
10038
+ if (typeof document === "undefined") return false;
10039
+ const clientX = Number.isFinite(evt === null || evt === void 0 ? void 0 : evt.clientX) ? evt === null || evt === void 0 ? void 0 : evt.clientX : evt === null || evt === void 0 ? void 0 : evt.x;
10040
+ const clientY = Number.isFinite(evt === null || evt === void 0 ? void 0 : evt.clientY) ? evt === null || evt === void 0 ? void 0 : evt.clientY : evt === null || evt === void 0 ? void 0 : evt.y;
10041
+ if (!Number.isFinite(clientX) || !Number.isFinite(clientY)) return false;
10042
+ return [...document.querySelectorAll([
10043
+ `[${SHEET_EMBED_RUNTIME_FOCUS_ROLE_ATTRIBUTE}="child-editor"]`,
10044
+ "[data-u-comp=\"editor\"]",
10045
+ "[id^=\"__editor___INTERNAL_EDITOR__\"]",
10046
+ "[id^=\"univer-doc-selection-container-__INTERNAL_EDITOR__\"]"
10047
+ ].join(","))].some((element) => {
10048
+ const rect = element.getBoundingClientRect();
10049
+ return rect.width > 0 && rect.height > 0 && clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom;
10050
+ });
10051
+ }
10052
+ function isSameEditCell(current, unitId, sheetId, primary) {
10053
+ return (current === null || current === void 0 ? void 0 : current.unitId) === unitId && current.sheetId === sheetId && current.row === primary.startRow && current.column === primary.startColumn;
10054
+ }
9847
10055
 
9848
10056
  //#endregion
9849
10057
  //#region src/services/repeat-last-action.service.ts
@@ -10560,10 +10768,11 @@ let EditingRenderController = class EditingRenderController extends Disposable {
10560
10768
  }
10561
10769
  _initialCursorSync(d) {
10562
10770
  d.add(this._cellEditorManagerService.focus$.pipe(filter((f) => !!f)).subscribe(() => {
10563
- var _this$_renderManagerS2;
10564
- const currentDoc = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
10565
- if (!currentDoc) return;
10566
- const docSelectionRenderManager = (_this$_renderManagerS2 = this._renderManagerService.getRenderById(currentDoc === null || currentDoc === void 0 ? void 0 : currentDoc.getUnitId())) === null || _this$_renderManagerS2 === void 0 ? void 0 : _this$_renderManagerS2.with(DocSelectionRenderService);
10771
+ var _this$_univerInstance, _this$_renderManagerS2;
10772
+ const editorId = this._contextService.getContextValue(FOCUSING_FX_BAR_EDITOR) ? DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY : this._editorBridgeService.getCurrentEditorId();
10773
+ const docUnitId = editorId !== null && editorId !== void 0 ? editorId : (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId();
10774
+ if (!docUnitId) return;
10775
+ const docSelectionRenderManager = (_this$_renderManagerS2 = this._renderManagerService.getRenderById(docUnitId)) === null || _this$_renderManagerS2 === void 0 ? void 0 : _this$_renderManagerS2.with(DocSelectionRenderService);
10567
10776
  if (!docSelectionRenderManager) return;
10568
10777
  docSelectionRenderManager.sync();
10569
10778
  }));
@@ -10684,14 +10893,17 @@ let EditingRenderController = class EditingRenderController extends Disposable {
10684
10893
  this._cursorChange = eventType === DeviceInputEventType.PointerDown || eventType === DeviceInputEventType.Dblclick ? 2 : 1;
10685
10894
  const editCellState = this._editorBridgeService.getEditLocation();
10686
10895
  if (editCellState == null) return;
10687
- this._commandService.syncExecuteCommand(ScrollToRangeOperation.id, { range: {
10688
- startRow: editCellState.row,
10689
- startColumn: editCellState.column,
10690
- endRow: editCellState.row,
10691
- endColumn: editCellState.column
10692
- } });
10693
- this._editorBridgeService.refreshEditCellPosition(false);
10694
10896
  const { unitId, isInArrayFormulaRange = false } = editCellState;
10897
+ this._commandService.syncExecuteCommand(ScrollToRangeOperation.id, {
10898
+ unitId,
10899
+ range: {
10900
+ startRow: editCellState.row,
10901
+ startColumn: editCellState.column,
10902
+ endRow: editCellState.row,
10903
+ endColumn: editCellState.column
10904
+ }
10905
+ });
10906
+ this._editorBridgeService.refreshEditCellPosition(false);
10695
10907
  const editorObject = this._getEditorObject();
10696
10908
  if (editorObject == null) return;
10697
10909
  const { document, scene } = editorObject;
@@ -11077,8 +11289,9 @@ function getCellStyleBySnapshot(snapshot) {
11077
11289
  return null;
11078
11290
  }
11079
11291
  function emptyBody(body, removeStyle = false) {
11292
+ var _body$textRuns;
11080
11293
  body.dataStream = DEFAULT_EMPTY_DOCUMENT_VALUE;
11081
- if (body.textRuns != null) if (body.textRuns.length === 1 && !removeStyle) {
11294
+ if ((_body$textRuns = body.textRuns) === null || _body$textRuns === void 0 ? void 0 : _body$textRuns.length) if (body.textRuns.length === 1 && !removeStyle) {
11082
11295
  body.textRuns[0].st = 0;
11083
11296
  body.textRuns[0].ed = 1;
11084
11297
  } else body.textRuns = void 0;
@@ -11445,7 +11658,10 @@ function generateBody(text) {
11445
11658
  return {
11446
11659
  dataStream,
11447
11660
  paragraphs,
11448
- sectionBreaks: [{ startIndex: dataStream.indexOf("\n") }]
11661
+ sectionBreaks: [{
11662
+ sectionId: createSectionId(/* @__PURE__ */ new Set()),
11663
+ startIndex: dataStream.indexOf("\n")
11664
+ }]
11449
11665
  };
11450
11666
  }
11451
11667
 
@@ -12181,11 +12397,18 @@ let FormulaEditorController = class FormulaEditorController extends RxDisposable
12181
12397
  });
12182
12398
  this._create(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
12183
12399
  this.disposeWithMe(this._editorService.focus$.subscribe(() => {
12184
- var _this$_editorService$;
12185
- if (((_this$_editorService$ = this._editorService.getFocusEditor()) === null || _this$_editorService$ === void 0 ? void 0 : _this$_editorService$.getEditorId()) !== DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY) this._contextService.setContextValue(FOCUSING_FX_BAR_EDITOR, false);
12186
- else this._contextService.setContextValue(FOCUSING_FX_BAR_EDITOR, true);
12400
+ this._syncFxBarFocusContext();
12187
12401
  }));
12188
12402
  }
12403
+ _syncFxBarFocusContext() {
12404
+ var _this$_editorService$;
12405
+ if (((_this$_editorService$ = this._editorService.getFocusEditor()) === null || _this$_editorService$ === void 0 ? void 0 : _this$_editorService$.getEditorId()) === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY) {
12406
+ this._contextService.setContextValue(FOCUSING_FX_BAR_EDITOR, true);
12407
+ return;
12408
+ }
12409
+ if (this._contextService.getContextValue(FOCUSING_FX_BAR_EDITOR) && this._contextService.getContextValue(EDITOR_ACTIVATED)) return;
12410
+ this._contextService.setContextValue(FOCUSING_FX_BAR_EDITOR, false);
12411
+ }
12189
12412
  _handleContentChange() {
12190
12413
  this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
12191
12414
  if (commandInfo.id === RichTextEditingMutation.id) {
@@ -16050,6 +16273,56 @@ const BORDER_LINE_CHILDREN = [
16050
16273
  value: "mltr_bctr"
16051
16274
  }
16052
16275
  ];
16276
+ const BORDER_SIZE_CHILDREN = [
16277
+ {
16278
+ label: BorderStyleTypes.THIN,
16279
+ value: BorderStyleTypes.THIN
16280
+ },
16281
+ {
16282
+ label: BorderStyleTypes.HAIR,
16283
+ value: BorderStyleTypes.HAIR
16284
+ },
16285
+ {
16286
+ label: BorderStyleTypes.DOTTED,
16287
+ value: BorderStyleTypes.DOTTED
16288
+ },
16289
+ {
16290
+ label: BorderStyleTypes.DASHED,
16291
+ value: BorderStyleTypes.DASHED
16292
+ },
16293
+ {
16294
+ label: BorderStyleTypes.DASH_DOT,
16295
+ value: BorderStyleTypes.DASH_DOT
16296
+ },
16297
+ {
16298
+ label: BorderStyleTypes.DASH_DOT_DOT,
16299
+ value: BorderStyleTypes.DASH_DOT_DOT
16300
+ },
16301
+ {
16302
+ label: BorderStyleTypes.MEDIUM,
16303
+ value: BorderStyleTypes.MEDIUM
16304
+ },
16305
+ {
16306
+ label: BorderStyleTypes.MEDIUM_DASHED,
16307
+ value: BorderStyleTypes.MEDIUM_DASHED
16308
+ },
16309
+ {
16310
+ label: BorderStyleTypes.MEDIUM_DASH_DOT,
16311
+ value: BorderStyleTypes.MEDIUM_DASH_DOT
16312
+ },
16313
+ {
16314
+ label: BorderStyleTypes.MEDIUM_DASH_DOT_DOT,
16315
+ value: BorderStyleTypes.MEDIUM_DASH_DOT_DOT
16316
+ },
16317
+ {
16318
+ label: BorderStyleTypes.THICK,
16319
+ value: BorderStyleTypes.THICK
16320
+ },
16321
+ {
16322
+ label: BorderStyleTypes.DOUBLE,
16323
+ value: BorderStyleTypes.DOUBLE
16324
+ }
16325
+ ];
16053
16326
 
16054
16327
  //#endregion
16055
16328
  //#region src/menu/menu-util.ts
@@ -16810,6 +17083,9 @@ const MenuItemInput = (props) => {
16810
17083
  function handlePressEnter() {
16811
17084
  if (inputValue) onChange(inputValue);
16812
17085
  }
17086
+ function handleKeyDown(event) {
17087
+ event.stopPropagation();
17088
+ }
16813
17089
  return /* @__PURE__ */ jsxs("div", {
16814
17090
  className: "univer-inline-flex univer-items-center univer-gap-1",
16815
17091
  children: [
@@ -16825,6 +17101,7 @@ const MenuItemInput = (props) => {
16825
17101
  max,
16826
17102
  disabled,
16827
17103
  onPressEnter: handlePressEnter,
17104
+ onKeyDown: handleKeyDown,
16828
17105
  onChange: handleChange
16829
17106
  })
16830
17107
  }),
@@ -19381,6 +19658,25 @@ const menuSchema = {
19381
19658
  } } }
19382
19659
  };
19383
19660
 
19661
+ //#endregion
19662
+ //#region src/embed-tab-anchor.ts
19663
+ const EMBED_SHEETS_TAB_CUSTOM_KEY = "UNIVER_EMBED_SHEETS_TAB";
19664
+ function getEmbedSheetsTabCustomData(snapshot) {
19665
+ var _snapshot$custom;
19666
+ const value = (_snapshot$custom = snapshot.custom) === null || _snapshot$custom === void 0 ? void 0 : _snapshot$custom[EMBED_SHEETS_TAB_CUSTOM_KEY];
19667
+ if (!isEmbedSheetsTabCustomData(value)) return;
19668
+ return value;
19669
+ }
19670
+ function isEmbedSheetsTabCustomData(value) {
19671
+ if (!value || typeof value !== "object") return false;
19672
+ const candidate = value;
19673
+ return candidate.version === 1 && typeof candidate.embedId === "string" && typeof candidate.hostAnchorId === "string";
19674
+ }
19675
+
19676
+ //#endregion
19677
+ //#region src/services/sheet-embed-runtime.service.ts
19678
+ const ISheetEmbedRuntimeService = createIdentifier("sheet-ui.embed-runtime.service");
19679
+
19384
19680
  //#endregion
19385
19681
  //#region src/views/auto-fill-popup-menu/AutoFillPopupMenu.tsx
19386
19682
  const useUpdate = () => {
@@ -19530,6 +19826,93 @@ function AutoFillPopupMenu() {
19530
19826
  });
19531
19827
  }
19532
19828
 
19829
+ //#endregion
19830
+ //#region src/views/editor-container/focus-editor.ts
19831
+ const SHEET_CELL_EDITOR_ELEMENT_ID = `__editor_${DOCS_NORMAL_EDITOR_UNIT_ID_KEY}`;
19832
+ const SHEET_CELL_EDITOR_SELECTION_CONTAINER_ID = `univer-doc-selection-container-${DOCS_NORMAL_EDITOR_UNIT_ID_KEY}`;
19833
+ function focusSheetCellEditorElement(ownerDocument = document) {
19834
+ const element = ownerDocument.getElementById(SHEET_CELL_EDITOR_ELEMENT_ID);
19835
+ if (element == null || ownerDocument.activeElement === element) return false;
19836
+ if (!element.hasAttribute("tabindex")) element.tabIndex = -1;
19837
+ element.focus({ preventScroll: true });
19838
+ return ownerDocument.activeElement === element;
19839
+ }
19840
+ function registerSheetCellEditorRuntimePortal(options) {
19841
+ var _options$ownerDocumen;
19842
+ const ownerDocument = (_options$ownerDocumen = options.ownerDocument) !== null && _options$ownerDocumen !== void 0 ? _options$ownerDocumen : typeof document === "undefined" ? void 0 : document;
19843
+ if (!ownerDocument) return toDisposable(() => {});
19844
+ const collection = new DisposableCollection();
19845
+ const view = ownerDocument.defaultView;
19846
+ let disposed = false;
19847
+ let registeredPortalRoot = null;
19848
+ let portalRegistration;
19849
+ const frameHandles = [];
19850
+ let observer;
19851
+ const tryRegister = () => {
19852
+ if (disposed) return;
19853
+ const portalRoot = resolveSheetCellEditorPortalRoot(ownerDocument);
19854
+ if (portalRoot === registeredPortalRoot) return;
19855
+ portalRegistration === null || portalRegistration === void 0 || portalRegistration.dispose();
19856
+ portalRegistration = void 0;
19857
+ registeredPortalRoot = null;
19858
+ if (!portalRoot) return;
19859
+ const rootRegistration = new DisposableCollection();
19860
+ registeredPortalRoot = portalRoot;
19861
+ if (options.interactionBoundaryService) rootRegistration.add(options.interactionBoundaryService.registerOwnedElement(options.embedId, portalRoot));
19862
+ if (options.focusCoordinator) {
19863
+ rootRegistration.add(options.focusCoordinator.registerElement({
19864
+ embedId: options.embedId,
19865
+ role: "child-editor",
19866
+ element: portalRoot
19867
+ }));
19868
+ const editorElement = ownerDocument.getElementById(SHEET_CELL_EDITOR_ELEMENT_ID);
19869
+ if (editorElement && editorElement !== portalRoot) rootRegistration.add(options.focusCoordinator.registerElement({
19870
+ embedId: options.embedId,
19871
+ role: "child-editor",
19872
+ element: editorElement
19873
+ }));
19874
+ }
19875
+ portalRegistration = rootRegistration;
19876
+ };
19877
+ const scheduleRetry = (remaining) => {
19878
+ if (remaining <= 0 || !(view === null || view === void 0 ? void 0 : view.requestAnimationFrame)) return;
19879
+ const handle = view.requestAnimationFrame(() => {
19880
+ const index = frameHandles.indexOf(handle);
19881
+ if (index >= 0) frameHandles.splice(index, 1);
19882
+ tryRegister();
19883
+ if (!registeredPortalRoot) scheduleRetry(remaining - 1);
19884
+ });
19885
+ frameHandles.push(handle);
19886
+ };
19887
+ tryRegister();
19888
+ if (!registeredPortalRoot) scheduleRetry(2);
19889
+ if ((view === null || view === void 0 ? void 0 : view.MutationObserver) && ownerDocument.body) {
19890
+ observer = new view.MutationObserver(() => tryRegister());
19891
+ observer.observe(ownerDocument.body, {
19892
+ childList: true,
19893
+ subtree: true
19894
+ });
19895
+ }
19896
+ collection.add(toDisposable(() => {
19897
+ disposed = true;
19898
+ frameHandles.forEach((handle) => {
19899
+ var _view$cancelAnimation;
19900
+ return view === null || view === void 0 || (_view$cancelAnimation = view.cancelAnimationFrame) === null || _view$cancelAnimation === void 0 ? void 0 : _view$cancelAnimation.call(view, handle);
19901
+ });
19902
+ frameHandles.length = 0;
19903
+ observer === null || observer === void 0 || observer.disconnect();
19904
+ observer = void 0;
19905
+ portalRegistration === null || portalRegistration === void 0 || portalRegistration.dispose();
19906
+ portalRegistration = void 0;
19907
+ registeredPortalRoot = null;
19908
+ }));
19909
+ return collection;
19910
+ }
19911
+ function resolveSheetCellEditorPortalRoot(ownerDocument = document) {
19912
+ var _ref;
19913
+ return (_ref = ownerDocument.getElementById(SHEET_CELL_EDITOR_SELECTION_CONTAINER_ID)) !== null && _ref !== void 0 ? _ref : ownerDocument.getElementById(SHEET_CELL_EDITOR_ELEMENT_ID);
19914
+ }
19915
+
19533
19916
  //#endregion
19534
19917
  //#region src/views/editor-container/hooks.ts
19535
19918
  /**
@@ -19599,19 +19982,65 @@ function isTransparentColor(color) {
19599
19982
  const normalizedColor = color.trim().toLowerCase().replace(/\s+/g, "");
19600
19983
  return normalizedColor === "transparent" || normalizedColor === "rgba(0,0,0,0)";
19601
19984
  }
19985
+ function shouldRefocusCellEditorAfterPointerDown(options) {
19986
+ const { root, target, activeElement, isEditorFocusing } = options;
19987
+ if (!root || !(target instanceof HTMLElement) || !(activeElement instanceof HTMLElement)) return true;
19988
+ const owner = root.closest(`[${SHEET_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE}]`);
19989
+ const embedId = owner === null || owner === void 0 ? void 0 : owner.getAttribute(SHEET_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE);
19990
+ if (!embedId) return true;
19991
+ const targetInOwner = target.closest(`[${SHEET_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE}="${embedId}"]`) != null;
19992
+ const activeOwnerElement = activeElement.closest(`[${SHEET_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE}="${embedId}"]`);
19993
+ if (targetInOwner && activeOwnerElement && isEmbedRuntimeInteractiveElement(activeElement)) return false;
19994
+ if (!isEditorFocusing) return true;
19995
+ return target.closest(`[${"data-embed-interaction-boundary-owner"}="${embedId}"]`) == null || activeOwnerElement == null;
19996
+ }
19997
+ function isEmbedRuntimeInteractiveElement(element) {
19998
+ const role = element.getAttribute(SHEET_EMBED_RUNTIME_FOCUS_ROLE_ATTRIBUTE);
19999
+ return role === "child-editor" || role === "child-popup" || role === "floating-menu";
20000
+ }
20001
+ function shouldPreserveEmbedPopupFocus(embedId, ownerDocument) {
20002
+ var _activeElement$getAtt, _activeElement$closes;
20003
+ if (!embedId) return false;
20004
+ const activeElement = ownerDocument.activeElement;
20005
+ if (!(activeElement instanceof HTMLElement)) return false;
20006
+ if (!activeElement.closest(`[${"data-embed-interaction-boundary-owner"}="${embedId}"]`)) return false;
20007
+ const role = (_activeElement$getAtt = activeElement.getAttribute("data-embed-runtime-focus-role")) !== null && _activeElement$getAtt !== void 0 ? _activeElement$getAtt : (_activeElement$closes = activeElement.closest(`[${"data-embed-runtime-focus-role"}]`)) === null || _activeElement$closes === void 0 ? void 0 : _activeElement$closes.getAttribute(SHEET_EMBED_RUNTIME_FOCUS_ROLE_ATTRIBUTE);
20008
+ return role === "child-popup" || role === "floating-menu";
20009
+ }
20010
+ function shouldPreserveEmbedInteractiveFocus(embedId, ownerDocument) {
20011
+ var _activeElement$getAtt2, _activeElement$closes2;
20012
+ if (!embedId) return false;
20013
+ const activeElement = ownerDocument.activeElement;
20014
+ if (!(activeElement instanceof HTMLElement)) return false;
20015
+ if (!activeElement.closest(`[${"data-embed-interaction-boundary-owner"}="${embedId}"]`)) return false;
20016
+ const role = (_activeElement$getAtt2 = activeElement.getAttribute("data-embed-runtime-focus-role")) !== null && _activeElement$getAtt2 !== void 0 ? _activeElement$getAtt2 : (_activeElement$closes2 = activeElement.closest(`[${"data-embed-runtime-focus-role"}]`)) === null || _activeElement$closes2 === void 0 ? void 0 : _activeElement$closes2.getAttribute(SHEET_EMBED_RUNTIME_FOCUS_ROLE_ATTRIBUTE);
20017
+ return role == null && activeElement.tagName !== "CANVAS" || role === "child-editor" || role === "child-popup" || role === "floating-menu";
20018
+ }
20019
+ function isEmbedRuntimeEditorOrPopup(target) {
20020
+ var _target$getAttribute, _target$closest;
20021
+ if (!(target instanceof HTMLElement)) return false;
20022
+ const role = (_target$getAttribute = target.getAttribute("data-embed-runtime-focus-role")) !== null && _target$getAttribute !== void 0 ? _target$getAttribute : (_target$closest = target.closest(`[${"data-embed-runtime-focus-role"}]`)) === null || _target$closest === void 0 ? void 0 : _target$closest.getAttribute(SHEET_EMBED_RUNTIME_FOCUS_ROLE_ATTRIBUTE);
20023
+ return role === "child-editor" || role === "child-popup" || role === "floating-menu";
20024
+ }
19602
20025
  /**
19603
20026
  * Cell editor container.
19604
20027
  * @returns the rendered cell editor container.
19605
20028
  */
19606
- const EditorContainer = () => {
20029
+ function EditorContainer() {
19607
20030
  const [state, setState] = useState({ ...EDITOR_DEFAULT_POSITION });
19608
20031
  const cellEditorManagerService = useDependency(ICellEditorManagerService);
20032
+ const injector = useDependency(Injector);
19609
20033
  const editorService = useDependency(IEditorService);
20034
+ const instanceService = useDependency(IUniverInstanceService);
19610
20035
  const contextService = useDependency(IContextService);
19611
20036
  const themeService = useDependency(ThemeService);
19612
20037
  const componentManager = useDependency(ComponentManager);
19613
20038
  const editorBridgeService = useDependency(IEditorBridgeService);
20039
+ const cellEditorResizeService = useDependency(SheetCellEditorResizeService);
20040
+ const rootRef = useRef(null);
20041
+ const pointerRefocusTimerRef = useRef(void 0);
19614
20042
  const visible = useObservable(editorBridgeService.visible$);
20043
+ const [runtimeFocusRevision, setRuntimeFocusRevision] = useState(0);
19615
20044
  const commandService = useDependency(ICommandService);
19616
20045
  const disableAutoFocus = useObservable(() => contextService.subscribeContextValue$(DISABLE_AUTO_FOCUS_KEY), false, void 0, [contextService, DISABLE_AUTO_FOCUS_KEY]);
19617
20046
  const FormulaEditor = componentManager.get(EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY);
@@ -19644,17 +20073,54 @@ const EditorContainer = () => {
19644
20073
  sub.unsubscribe();
19645
20074
  };
19646
20075
  }, []);
20076
+ useEffect(() => {
20077
+ if (!injector.has(ISheetEmbedFloatingGeometryService)) return;
20078
+ const subscription = injector.get(ISheetEmbedFloatingGeometryService).geometryInvalidated$.subscribe(() => {
20079
+ cellEditorResizeService.resizeCellEditor();
20080
+ });
20081
+ return () => subscription.unsubscribe();
20082
+ }, [cellEditorResizeService, injector]);
20083
+ useEffect(() => {
20084
+ if (!injector.has(ISheetEmbedRuntimeFocusCoordinator)) return;
20085
+ const subscription = injector.get(ISheetEmbedRuntimeFocusCoordinator).runtimeSessionChanged$.subscribe(() => {
20086
+ setRuntimeFocusRevision((revision) => revision + 1);
20087
+ });
20088
+ return () => subscription.unsubscribe();
20089
+ }, [injector]);
19647
20090
  useEffect(() => {
19648
20091
  if (!disableAutoFocus) cellEditorManagerService.setFocus(true);
19649
20092
  }, [disableAutoFocus, state]);
19650
20093
  useEffect(() => {
20094
+ var _rootRef$current$owne, _rootRef$current, _ownerDocument$defaul;
19651
20095
  if (!(visible === null || visible === void 0 ? void 0 : visible.visible)) return;
20096
+ cellEditorResizeService.fitTextSize();
20097
+ if (contextService.getContextValue(FOCUSING_FX_BAR_EDITOR)) return;
20098
+ const ownerDocument = (_rootRef$current$owne = (_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.ownerDocument) !== null && _rootRef$current$owne !== void 0 ? _rootRef$current$owne : document;
20099
+ const ownerWindow = (_ownerDocument$defaul = ownerDocument.defaultView) !== null && _ownerDocument$defaul !== void 0 ? _ownerDocument$defaul : window;
19652
20100
  let focusRetryFrame = 0;
19653
20101
  let finalFocusRetryFrame = 0;
20102
+ let delayedFocusTimer;
20103
+ const focusCellEditorElement = () => {
20104
+ var _resolveSheetEmbedRun;
20105
+ const scope = rootRef.current ? (_resolveSheetEmbedRun = resolveSheetEmbedRuntimeDomScope(rootRef.current)) !== null && _resolveSheetEmbedRun !== void 0 ? _resolveSheetEmbedRun : resolveActiveSheetEmbedRuntimeDomScope(ownerDocument) : resolveActiveSheetEmbedRuntimeDomScope(ownerDocument);
20106
+ if (shouldPreserveEmbedInteractiveFocus(scope === null || scope === void 0 ? void 0 : scope.embedId, ownerDocument)) return;
20107
+ focusSheetCellEditorElement(ownerDocument);
20108
+ if (delayedFocusTimer != null) ownerWindow.clearTimeout(delayedFocusTimer);
20109
+ delayedFocusTimer = ownerWindow.setTimeout(() => {
20110
+ delayedFocusTimer = void 0;
20111
+ if (shouldPreserveEmbedInteractiveFocus(scope === null || scope === void 0 ? void 0 : scope.embedId, ownerDocument)) return;
20112
+ focusSheetCellEditorElement(ownerDocument);
20113
+ }, 0);
20114
+ };
19654
20115
  const focusEditor = () => {
20116
+ var _resolveSheetEmbedRun2;
20117
+ if (contextService.getContextValue(FOCUSING_FX_BAR_EDITOR)) return;
20118
+ const scope = rootRef.current ? (_resolveSheetEmbedRun2 = resolveSheetEmbedRuntimeDomScope(rootRef.current)) !== null && _resolveSheetEmbedRun2 !== void 0 ? _resolveSheetEmbedRun2 : resolveActiveSheetEmbedRuntimeDomScope(ownerDocument) : resolveActiveSheetEmbedRuntimeDomScope(ownerDocument);
20119
+ if (shouldPreserveEmbedPopupFocus(scope === null || scope === void 0 ? void 0 : scope.embedId, ownerDocument)) return;
19655
20120
  const editor = editorService.getEditor(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
19656
20121
  const docSelectionRenderService = editor === null || editor === void 0 ? void 0 : editor.render.with(DocSelectionRenderService);
19657
20122
  if (!(docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing)) docSelectionRenderService === null || docSelectionRenderService === void 0 || docSelectionRenderService.focus();
20123
+ focusCellEditorElement();
19658
20124
  };
19659
20125
  focusEditor();
19660
20126
  focusRetryFrame = requestAnimationFrame(() => {
@@ -19664,8 +20130,185 @@ const EditorContainer = () => {
19664
20130
  return () => {
19665
20131
  cancelAnimationFrame(focusRetryFrame);
19666
20132
  cancelAnimationFrame(finalFocusRetryFrame);
20133
+ if (delayedFocusTimer != null) ownerWindow.clearTimeout(delayedFocusTimer);
19667
20134
  };
19668
- }, [editorService, visible === null || visible === void 0 ? void 0 : visible.visible]);
20135
+ }, [
20136
+ cellEditorResizeService,
20137
+ editorService,
20138
+ visible === null || visible === void 0 ? void 0 : visible.visible
20139
+ ]);
20140
+ useEffect(() => {
20141
+ var _instanceService$getF, _ref;
20142
+ if (!(visible === null || visible === void 0 ? void 0 : visible.visible) || !rootRef.current || !injector.has(ISheetEmbedRuntimeFocusCoordinator)) return;
20143
+ const focusCoordinator = injector.get(ISheetEmbedRuntimeFocusCoordinator);
20144
+ const focusedUnitId = (_instanceService$getF = instanceService.getFocusedUnit()) === null || _instanceService$getF === void 0 ? void 0 : _instanceService$getF.getUnitId();
20145
+ const rootRuntimeScope = resolveSheetEmbedRuntimeDomScope(rootRef.current);
20146
+ const unitRuntimeScope = [
20147
+ editState === null || editState === void 0 ? void 0 : editState.unitId,
20148
+ visible.unitId,
20149
+ focusedUnitId
20150
+ ].map((unitId) => focusCoordinator.resolveRuntimeScopeByChildUnitId(unitId)).find((resolvedScope) => resolvedScope != null);
20151
+ if (rootRuntimeScope && unitRuntimeScope && rootRuntimeScope.embedId !== unitRuntimeScope.embedId) return;
20152
+ const activeSessionScope = focusCoordinator.resolveActiveChildSessionRuntimeScope();
20153
+ const explicitRuntimeScope = unitRuntimeScope !== null && unitRuntimeScope !== void 0 ? unitRuntimeScope : rootRuntimeScope;
20154
+ if (activeSessionScope && rootRuntimeScope && !unitRuntimeScope && rootRuntimeScope.embedId !== activeSessionScope.embedId) return;
20155
+ const scope = (_ref = explicitRuntimeScope !== null && explicitRuntimeScope !== void 0 ? explicitRuntimeScope : activeSessionScope) !== null && _ref !== void 0 ? _ref : resolveActiveSheetEmbedRuntimeDomScope(rootRef.current.ownerDocument);
20156
+ if (!scope) return;
20157
+ const collection = new DisposableCollection();
20158
+ const interactionBoundaryService = injector.has(ISheetEmbedInteractionBoundaryService) ? injector.get(ISheetEmbedInteractionBoundaryService) : void 0;
20159
+ const editorRoot = rootRef.current;
20160
+ collection.add(focusCoordinator.acquireLease({
20161
+ embedId: scope.embedId,
20162
+ role: "child-editor",
20163
+ owner: "sheet-cell-editor",
20164
+ hostUnitId: scope.hostUnitId,
20165
+ childUnitId: scope.childUnitId,
20166
+ associatedChildUnitIds: [DOCS_NORMAL_EDITOR_UNIT_ID_KEY]
20167
+ }));
20168
+ if (interactionBoundaryService) collection.add(interactionBoundaryService.registerOwnedElement(scope.embedId, editorRoot));
20169
+ collection.add(focusCoordinator.registerElement({
20170
+ embedId: scope.embedId,
20171
+ role: "child-editor",
20172
+ element: editorRoot
20173
+ }));
20174
+ collection.add(registerSheetCellEditorRuntimePortal({
20175
+ embedId: scope.embedId,
20176
+ ownerDocument: rootRef.current.ownerDocument,
20177
+ interactionBoundaryService,
20178
+ focusCoordinator
20179
+ }));
20180
+ if (scope.childType === UniverInstanceType.UNIVER_SHEET && scope.childUnitId) {
20181
+ const ownerDocument = rootRef.current.ownerDocument;
20182
+ let pointerRetryFrame = 0;
20183
+ const focusEditor = () => {
20184
+ if (contextService.getContextValue(FOCUSING_FX_BAR_EDITOR) || shouldPreserveEmbedPopupFocus(scope.embedId, ownerDocument)) return;
20185
+ const editor = editorService.getEditor(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
20186
+ const docSelectionRenderService = editor === null || editor === void 0 ? void 0 : editor.render.with(DocSelectionRenderService);
20187
+ if (!(docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing)) docSelectionRenderService === null || docSelectionRenderService === void 0 || docSelectionRenderService.focus();
20188
+ focusSheetCellEditorElement(ownerDocument);
20189
+ };
20190
+ const refocusEditorAfterRuntimePointer = (event) => {
20191
+ if (!focusCoordinator.isChildUnitRuntimeEvent(scope.childUnitId, event.target, event) || isEmbedRuntimeEditorOrPopup(event.target)) return;
20192
+ cancelAnimationFrame(pointerRetryFrame);
20193
+ pointerRetryFrame = requestAnimationFrame(focusEditor);
20194
+ };
20195
+ ownerDocument.addEventListener("pointerdown", refocusEditorAfterRuntimePointer, true);
20196
+ ownerDocument.addEventListener("pointerup", refocusEditorAfterRuntimePointer, true);
20197
+ ownerDocument.addEventListener("click", refocusEditorAfterRuntimePointer, true);
20198
+ collection.add(toDisposable(() => {
20199
+ cancelAnimationFrame(pointerRetryFrame);
20200
+ ownerDocument.removeEventListener("pointerdown", refocusEditorAfterRuntimePointer, true);
20201
+ ownerDocument.removeEventListener("pointerup", refocusEditorAfterRuntimePointer, true);
20202
+ ownerDocument.removeEventListener("click", refocusEditorAfterRuntimePointer, true);
20203
+ }));
20204
+ }
20205
+ return () => collection.dispose();
20206
+ }, [
20207
+ contextService,
20208
+ editState === null || editState === void 0 ? void 0 : editState.unitId,
20209
+ editorService,
20210
+ injector,
20211
+ instanceService,
20212
+ runtimeFocusRevision,
20213
+ visible === null || visible === void 0 ? void 0 : visible.unitId,
20214
+ visible === null || visible === void 0 ? void 0 : visible.visible
20215
+ ]);
20216
+ useEffect(() => {
20217
+ var _rootRef$current$owne2, _rootRef$current2, _ownerDocument$defaul2;
20218
+ if ((visible === null || visible === void 0 ? void 0 : visible.visible) || !injector.has(ISheetEmbedRuntimeFocusCoordinator)) return;
20219
+ const focusCoordinator = injector.get(ISheetEmbedRuntimeFocusCoordinator);
20220
+ const activeSessionScope = focusCoordinator.resolveActiveChildSessionRuntimeScope();
20221
+ const childUnitId = activeSessionScope === null || activeSessionScope === void 0 ? void 0 : activeSessionScope.childUnitId;
20222
+ if (!activeSessionScope || activeSessionScope.childType !== UniverInstanceType.UNIVER_SHEET || !childUnitId || !instanceService.getUnit(childUnitId, UniverInstanceType.UNIVER_SHEET)) return;
20223
+ const ownerDocument = (_rootRef$current$owne2 = (_rootRef$current2 = rootRef.current) === null || _rootRef$current2 === void 0 ? void 0 : _rootRef$current2.ownerDocument) !== null && _rootRef$current$owne2 !== void 0 ? _rootRef$current$owne2 : document;
20224
+ const interactionBoundaryService = injector.has(ISheetEmbedInteractionBoundaryService) ? injector.get(ISheetEmbedInteractionBoundaryService) : void 0;
20225
+ const portalRegistration = registerSheetCellEditorRuntimePortal({
20226
+ embedId: activeSessionScope.embedId,
20227
+ ownerDocument,
20228
+ interactionBoundaryService,
20229
+ focusCoordinator
20230
+ });
20231
+ const ownerWindow = (_ownerDocument$defaul2 = ownerDocument.defaultView) !== null && _ownerDocument$defaul2 !== void 0 ? _ownerDocument$defaul2 : window;
20232
+ let delayedFocusTimer;
20233
+ const focusCellEditorElement = () => {
20234
+ if (shouldPreserveEmbedInteractiveFocus(activeSessionScope.embedId, ownerDocument)) return;
20235
+ focusSheetCellEditorElement(ownerDocument);
20236
+ if (delayedFocusTimer != null) ownerWindow.clearTimeout(delayedFocusTimer);
20237
+ delayedFocusTimer = ownerWindow.setTimeout(() => {
20238
+ delayedFocusTimer = void 0;
20239
+ if (shouldPreserveEmbedInteractiveFocus(activeSessionScope.embedId, ownerDocument)) return;
20240
+ focusSheetCellEditorElement(ownerDocument);
20241
+ }, 0);
20242
+ };
20243
+ const focusHiddenEditor = () => {
20244
+ if (shouldPreserveEmbedPopupFocus(activeSessionScope.embedId, ownerDocument)) return;
20245
+ const editor = editorService.getEditor(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
20246
+ const docSelectionRenderService = editor === null || editor === void 0 ? void 0 : editor.render.with(DocSelectionRenderService);
20247
+ if (!(docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing)) docSelectionRenderService === null || docSelectionRenderService === void 0 || docSelectionRenderService.focus();
20248
+ focusCellEditorElement();
20249
+ };
20250
+ let retryFrame = 0;
20251
+ let finalRetryFrame = 0;
20252
+ let pointerRetryFrame = 0;
20253
+ focusHiddenEditor();
20254
+ retryFrame = requestAnimationFrame(() => {
20255
+ focusHiddenEditor();
20256
+ finalRetryFrame = requestAnimationFrame(focusHiddenEditor);
20257
+ });
20258
+ const refocusHiddenEditorAfterRuntimePointer = (event) => {
20259
+ if (!focusCoordinator.isChildUnitRuntimeEvent(childUnitId, event.target, event) || isEmbedRuntimeEditorOrPopup(event.target)) return;
20260
+ cancelAnimationFrame(pointerRetryFrame);
20261
+ pointerRetryFrame = requestAnimationFrame(focusHiddenEditor);
20262
+ };
20263
+ ownerDocument.addEventListener("pointerdown", refocusHiddenEditorAfterRuntimePointer, true);
20264
+ ownerDocument.addEventListener("pointerup", refocusHiddenEditorAfterRuntimePointer, true);
20265
+ ownerDocument.addEventListener("click", refocusHiddenEditorAfterRuntimePointer, true);
20266
+ return () => {
20267
+ cancelAnimationFrame(retryFrame);
20268
+ cancelAnimationFrame(finalRetryFrame);
20269
+ cancelAnimationFrame(pointerRetryFrame);
20270
+ if (delayedFocusTimer != null) ownerWindow.clearTimeout(delayedFocusTimer);
20271
+ ownerDocument.removeEventListener("pointerdown", refocusHiddenEditorAfterRuntimePointer, true);
20272
+ ownerDocument.removeEventListener("pointerup", refocusHiddenEditorAfterRuntimePointer, true);
20273
+ ownerDocument.removeEventListener("click", refocusHiddenEditorAfterRuntimePointer, true);
20274
+ portalRegistration.dispose();
20275
+ };
20276
+ }, [
20277
+ editorService,
20278
+ injector,
20279
+ instanceService,
20280
+ runtimeFocusRevision,
20281
+ visible === null || visible === void 0 ? void 0 : visible.visible
20282
+ ]);
20283
+ useEffect(() => {
20284
+ return () => {
20285
+ var _rootRef$current3;
20286
+ const ownerWindow = (_rootRef$current3 = rootRef.current) === null || _rootRef$current3 === void 0 ? void 0 : _rootRef$current3.ownerDocument.defaultView;
20287
+ if (ownerWindow && pointerRefocusTimerRef.current != null) ownerWindow.clearTimeout(pointerRefocusTimerRef.current);
20288
+ };
20289
+ }, []);
20290
+ const refocusEditorAfterPointerDown = useEvent((event) => {
20291
+ var _rootRef$current$owne3, _rootRef$current4, _ownerDocument$defaul3;
20292
+ if (!(visible === null || visible === void 0 ? void 0 : visible.visible)) return;
20293
+ const ownerDocument = (_rootRef$current$owne3 = (_rootRef$current4 = rootRef.current) === null || _rootRef$current4 === void 0 ? void 0 : _rootRef$current4.ownerDocument) !== null && _rootRef$current$owne3 !== void 0 ? _rootRef$current$owne3 : document;
20294
+ const ownerWindow = (_ownerDocument$defaul3 = ownerDocument.defaultView) !== null && _ownerDocument$defaul3 !== void 0 ? _ownerDocument$defaul3 : window;
20295
+ const editor = editorService.getEditor(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
20296
+ const docSelectionRenderService = editor === null || editor === void 0 ? void 0 : editor.render.with(DocSelectionRenderService);
20297
+ const pointerTarget = event.target;
20298
+ const activeElementAtPointerDown = ownerDocument.activeElement;
20299
+ if (!shouldRefocusCellEditorAfterPointerDown({
20300
+ root: rootRef.current,
20301
+ target: pointerTarget,
20302
+ activeElement: activeElementAtPointerDown,
20303
+ isEditorFocusing: docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing
20304
+ })) return;
20305
+ if (pointerRefocusTimerRef.current != null) ownerWindow.clearTimeout(pointerRefocusTimerRef.current);
20306
+ pointerRefocusTimerRef.current = ownerWindow.setTimeout(() => {
20307
+ pointerRefocusTimerRef.current = void 0;
20308
+ if (!(docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing)) docSelectionRenderService === null || docSelectionRenderService === void 0 || docSelectionRenderService.focus();
20309
+ focusSheetCellEditorElement(ownerDocument);
20310
+ }, 0);
20311
+ });
19669
20312
  useSidebarClick(useEvent(() => {
19670
20313
  if (editorBridgeService.isVisible().visible) commandService.executeCommand(SetCellEditVisibleOperation.id, {
19671
20314
  visible: false,
@@ -19684,7 +20327,10 @@ const EditorContainer = () => {
19684
20327
  });
19685
20328
  });
19686
20329
  return /* @__PURE__ */ jsx("div", {
20330
+ ref: rootRef,
20331
+ "data-u-comp": "editor",
19687
20332
  className: "univer-absolute univer-z-10 univer-flex",
20333
+ onPointerDownCapture: refocusEditorAfterPointerDown,
19688
20334
  style: {
19689
20335
  left: state.left,
19690
20336
  top: state.top,
@@ -19709,17 +20355,15 @@ const EditorContainer = () => {
19709
20355
  resetSelectionOnBlur: false,
19710
20356
  isSingle: false,
19711
20357
  autoScrollbar: false,
19712
- onFormulaSelectingChange: (isSelecting, isFocusing) => {
19713
- if (!isFocusing) return;
20358
+ onFormulaSelectingChange: (isSelecting) => {
19714
20359
  if (isSelecting) editorBridgeService.enableForceKeepVisible();
19715
20360
  else editorBridgeService.disableForceKeepVisible();
19716
20361
  },
19717
- disableSelectionOnClick: true,
19718
20362
  disableContextMenu: false,
19719
20363
  canvasStyle: { backgroundColor: "transparent" }
19720
20364
  })
19721
20365
  });
19722
- };
20366
+ }
19723
20367
 
19724
20368
  //#endregion
19725
20369
  //#region src/services/utils/defined-name-utils.ts
@@ -20209,9 +20853,9 @@ function FormulaBar(props) {
20209
20853
  const shouldSkipFocus = useRef(false);
20210
20854
  const handlePointerDown = () => {
20211
20855
  try {
20856
+ contextService.setContextValue(FOCUSING_FX_BAR_EDITOR, true);
20212
20857
  if (editorBridgeService.isVisible().visible === false) {
20213
20858
  if (editorActivationDisable) {
20214
- contextService.setContextValue(FOCUSING_FX_BAR_EDITOR, true);
20215
20859
  editorService.focus(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
20216
20860
  return;
20217
20861
  }
@@ -20220,12 +20864,12 @@ function FormulaBar(props) {
20220
20864
  eventType: DeviceInputEventType.PointerDown,
20221
20865
  unitId: editState.unitId
20222
20866
  })) {
20867
+ contextService.setContextValue(FOCUSING_FX_BAR_EDITOR, false);
20223
20868
  shouldSkipFocus.current = true;
20224
- return;
20225
20869
  }
20226
20870
  }
20227
- contextService.setContextValue(FOCUSING_FX_BAR_EDITOR, true);
20228
20871
  } catch (e) {
20872
+ contextService.setContextValue(FOCUSING_FX_BAR_EDITOR, false);
20229
20873
  shouldSkipFocus.current = true;
20230
20874
  throw e;
20231
20875
  }
@@ -20306,7 +20950,7 @@ function FormulaBar(props) {
20306
20950
  }), /* @__PURE__ */ jsx("div", {
20307
20951
  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 }),
20308
20952
  onClick: handleArrowClick,
20309
- children: /* @__PURE__ */ jsx(DropdownIcon, { className: clsx({ "univer-rotate-180": arrowDirection === 1 }) })
20953
+ children: /* @__PURE__ */ jsx(DownIcon, { className: clsx({ "univer-rotate-180": arrowDirection === 1 }) })
20310
20954
  })]
20311
20955
  })]
20312
20956
  }),
@@ -20438,7 +21082,7 @@ function SheetBarMenu() {
20438
21082
  //#endregion
20439
21083
  //#region src/views/sheet-bar/sheet-bar-tabs/SheetBarItem.tsx
20440
21084
  function SheetBarItem(props) {
20441
- const { sheetId, label, color, selected, className, onKeyDown, tabIndex } = props;
21085
+ const { sheetId, label, color, selected, className, onKeyDown, onClick, tabIndex } = props;
20442
21086
  const themeService = useDependency(ThemeService);
20443
21087
  const getTextColor = (color) => {
20444
21088
  const darkTextColor = themeService.getColorFromTheme("gray.900");
@@ -20454,6 +21098,7 @@ function SheetBarItem(props) {
20454
21098
  "aria-selected": currentSelected,
20455
21099
  tabIndex: tabIndex !== null && tabIndex !== void 0 ? tabIndex : currentSelected ? 0 : -1,
20456
21100
  onKeyDown,
21101
+ onClick,
20457
21102
  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", {
20458
21103
  "dark:!univer-text-white": !color || color && !textColor,
20459
21104
  "univer-justify-center univer-bg-white univer-font-bold univer-text-primary-700 univer-shadow": currentSelected,
@@ -20496,6 +21141,49 @@ function SheetBarTabsContextMenu(props) {
20496
21141
  })] });
20497
21142
  }
20498
21143
 
21144
+ //#endregion
21145
+ //#region src/views/sheet-bar/sheet-bar-tabs/utils/sheet-tab-drag-sort.ts
21146
+ function getMidline(item) {
21147
+ return item.left + item.width / 2;
21148
+ }
21149
+ function calculateSheetTabDragSort(items, activeIndex, dragOffsetX) {
21150
+ const itemOffsets = items.map(() => 0);
21151
+ const activeItem = items[activeIndex];
21152
+ if (!activeItem) return {
21153
+ targetIndex: activeIndex,
21154
+ itemOffsets
21155
+ };
21156
+ itemOffsets[activeIndex] = dragOffsetX;
21157
+ const activeLeft = activeItem.left + dragOffsetX;
21158
+ const activeRight = activeLeft + activeItem.width;
21159
+ let targetIndex = activeIndex;
21160
+ if (dragOffsetX > 0) {
21161
+ for (let index = activeIndex + 1; index < items.length; index++) if (activeRight > getMidline(items[index])) {
21162
+ itemOffsets[index] = -activeItem.width;
21163
+ targetIndex = index;
21164
+ }
21165
+ } else if (dragOffsetX < 0) {
21166
+ for (let index = activeIndex - 1; index >= 0; index--) if (activeLeft < getMidline(items[index])) {
21167
+ itemOffsets[index] = activeItem.width;
21168
+ targetIndex = index;
21169
+ }
21170
+ }
21171
+ return {
21172
+ targetIndex,
21173
+ itemOffsets
21174
+ };
21175
+ }
21176
+ function reorderItems(items, fromIndex, toIndex) {
21177
+ if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length) return [...items];
21178
+ const nextItems = [...items];
21179
+ const [movedItem] = nextItems.splice(fromIndex, 1);
21180
+ nextItems.splice(toIndex, 0, movedItem);
21181
+ return nextItems;
21182
+ }
21183
+ function getSheetTabTargetOrder(sheetOrder, visibleSheetIds, targetIndex) {
21184
+ return sheetOrder.indexOf(visibleSheetIds[targetIndex]);
21185
+ }
21186
+
20499
21187
  //#endregion
20500
21188
  //#region src/views/sheet-bar/sheet-bar-tabs/utils/animate.ts
20501
21189
  /**
@@ -20608,46 +21296,6 @@ var Animate = class {
20608
21296
  }
20609
21297
  };
20610
21298
 
20611
- //#endregion
20612
- //#region src/views/sheet-bar/sheet-bar-tabs/utils/sheet-tab-drag-sort.ts
20613
- function getMidline(item) {
20614
- return item.left + item.width / 2;
20615
- }
20616
- function calculateSheetTabDragSort(items, activeIndex, dragOffsetX) {
20617
- const itemOffsets = items.map(() => 0);
20618
- const activeItem = items[activeIndex];
20619
- if (!activeItem) return {
20620
- targetIndex: activeIndex,
20621
- itemOffsets
20622
- };
20623
- itemOffsets[activeIndex] = dragOffsetX;
20624
- const activeLeft = activeItem.left + dragOffsetX;
20625
- const activeRight = activeLeft + activeItem.width;
20626
- let targetIndex = activeIndex;
20627
- if (dragOffsetX > 0) {
20628
- for (let index = activeIndex + 1; index < items.length; index++) if (activeRight > getMidline(items[index])) {
20629
- itemOffsets[index] = -activeItem.width;
20630
- targetIndex = index;
20631
- }
20632
- } else if (dragOffsetX < 0) {
20633
- for (let index = activeIndex - 1; index >= 0; index--) if (activeLeft < getMidline(items[index])) {
20634
- itemOffsets[index] = activeItem.width;
20635
- targetIndex = index;
20636
- }
20637
- }
20638
- return {
20639
- targetIndex,
20640
- itemOffsets
20641
- };
20642
- }
20643
- function reorderItems(items, fromIndex, toIndex) {
20644
- if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length) return [...items];
20645
- const nextItems = [...items];
20646
- const [movedItem] = nextItems.splice(fromIndex, 1);
20647
- nextItems.splice(toIndex, 0, movedItem);
20648
- return nextItems;
20649
- }
20650
-
20651
21299
  //#endregion
20652
21300
  //#region src/views/sheet-bar/sheet-bar-tabs/utils/sheet-tab-name-editor.ts
20653
21301
  const MAX_SHEET_NAME_LENGTH = 31;
@@ -20817,7 +21465,7 @@ var SlideTabItem = class SlideTabItem {
20817
21465
  startSheetTabNameEditor({
20818
21466
  slideTabItem: this._slideTabItem,
20819
21467
  canStart: () => this._slideTabBar.getConfig().onNameChangeCheck(),
20820
- checkName: (name) => this._slideTabBar.getConfig().onNameCheckAlert(name),
21468
+ checkName: (name) => this._slideTabBar.getConfig().onNameCheckAlert(name, this.getId()),
20821
21469
  setEditMode: (editing) => {
20822
21470
  this._editMode = editing;
20823
21471
  },
@@ -20826,8 +21474,12 @@ var SlideTabItem = class SlideTabItem {
20826
21474
  this._slideTabBar.updateItems();
20827
21475
  },
20828
21476
  onCommit: (name, focusEvent) => {
20829
- this._slideTabBar.getConfig().onChangeName(this.getId(), name);
20830
- if (callback) callback(focusEvent);
21477
+ try {
21478
+ this._slideTabBar.getConfig().onChangeName(this.getId(), name);
21479
+ if (callback) callback(focusEvent);
21480
+ } finally {
21481
+ this._slideTabBar.addListener();
21482
+ }
20831
21483
  }
20832
21484
  });
20833
21485
  }
@@ -20836,7 +21488,7 @@ var SlideTabItem = class SlideTabItem {
20836
21488
  const input = this._slideTabItem.querySelector("span");
20837
21489
  if (!input) return false;
20838
21490
  const text = (_input$textContent = input.textContent) !== null && _input$textContent !== void 0 ? _input$textContent : "";
20839
- return this._slideTabBar.getConfig().onNameCheckAlert(text);
21491
+ return this._slideTabBar.getConfig().onNameCheckAlert(text, this.getId());
20840
21492
  }
20841
21493
  animate() {
20842
21494
  return {
@@ -20989,6 +21641,7 @@ var SlideTabBar = class SlideTabBar {
20989
21641
  _defineProperty(this, "_downAction", void 0);
20990
21642
  _defineProperty(this, "_wheelAction", void 0);
20991
21643
  _defineProperty(this, "_scrollIncremental", 0);
21644
+ _defineProperty(this, "_dragStartScrollX", 0);
20992
21645
  _defineProperty(this, "_compareDirection", 0);
20993
21646
  _defineProperty(this, "_autoScrollTime", null);
20994
21647
  _defineProperty(this, "_slideScrollbar", void 0);
@@ -21021,7 +21674,6 @@ var SlideTabBar = class SlideTabBar {
21021
21674
  var _this$_activeTabItem2, _this$_activeTabItem3;
21022
21675
  (_this$_activeTabItem2 = this._activeTabItem) === null || _this$_activeTabItem2 === void 0 || _this$_activeTabItem2.removeEventListener("pointermove", this._moveAction);
21023
21676
  (_this$_activeTabItem3 = this._activeTabItem) === null || _this$_activeTabItem3 === void 0 || _this$_activeTabItem3.removeEventListener("pointerup", this._upAction);
21024
- this.removeListener();
21025
21677
  this._config.onChangeTab(downEvent, slideItemId);
21026
21678
  return;
21027
21679
  }
@@ -21029,6 +21681,7 @@ var SlideTabBar = class SlideTabBar {
21029
21681
  this._downActionX = downEvent.pageX;
21030
21682
  this._moveActionX = 0;
21031
21683
  this._scrollIncremental = 0;
21684
+ this._dragStartScrollX = this._slideScrollbar.getScrollX();
21032
21685
  this._activeTabItem = this._slideTabItems[slideItemIndex];
21033
21686
  if (!this._activeTabItem) {
21034
21687
  console.error("Not found active slide-tab-item in sheet bar");
@@ -21065,23 +21718,29 @@ var SlideTabBar = class SlideTabBar {
21065
21718
  }, SlideTabBar.LongPressDelay);
21066
21719
  };
21067
21720
  this._upAction = (upEvent) => {
21068
- var _this$_activeTabItem8, _this$_activeTabItem9, _this$_activeTabItem10, _this$_activeTabItem11;
21069
- if ((_this$_activeTabItem8 = this._activeTabItem) === null || _this$_activeTabItem8 === void 0 ? void 0 : _this$_activeTabItem8.isEditMode()) return;
21721
+ var _this$_activeTabItem8, _this$_activeTabItem9, _this$_activeTabItem10;
21070
21722
  if (this._longPressTimer) {
21071
21723
  clearTimeout(this._longPressTimer);
21072
21724
  this._longPressTimer = null;
21073
21725
  }
21074
21726
  if (!this._activeTabItem) return;
21727
+ if (this._activeTabItem.isEditMode()) {
21728
+ const activeSlideItemElement = this._activeTabItem.getSlideTabItem();
21729
+ const pointerId = upEvent.pointerId;
21730
+ if (pointerId != null && activeSlideItemElement.hasPointerCapture(pointerId)) activeSlideItemElement.releasePointerCapture(pointerId);
21731
+ this._activeTabItem.removeEventListener("pointerup", this._upAction);
21732
+ return;
21733
+ }
21075
21734
  const isFromScroll = this._autoScrollTime !== null;
21076
21735
  this._closeAutoScroll();
21077
21736
  this._activeTabItem.disableFixed();
21078
21737
  this.updateItems();
21079
- const activeSlideItemElement = (_this$_activeTabItem9 = this._activeTabItem) === null || _this$_activeTabItem9 === void 0 ? void 0 : _this$_activeTabItem9.getSlideTabItem();
21738
+ const activeSlideItemElement = (_this$_activeTabItem8 = this._activeTabItem) === null || _this$_activeTabItem8 === void 0 ? void 0 : _this$_activeTabItem8.getSlideTabItem();
21080
21739
  if (!activeSlideItemElement) return;
21081
21740
  activeSlideItemElement.style.cursor = "";
21082
21741
  activeSlideItemElement.releasePointerCapture(upEvent.pointerId);
21083
- (_this$_activeTabItem10 = this._activeTabItem) === null || _this$_activeTabItem10 === void 0 || _this$_activeTabItem10.removeEventListener("pointermove", this._moveAction);
21084
- (_this$_activeTabItem11 = this._activeTabItem) === null || _this$_activeTabItem11 === void 0 || _this$_activeTabItem11.removeEventListener("pointerup", this._upAction);
21742
+ (_this$_activeTabItem9 = this._activeTabItem) === null || _this$_activeTabItem9 === void 0 || _this$_activeTabItem9.removeEventListener("pointermove", this._moveAction);
21743
+ (_this$_activeTabItem10 = this._activeTabItem) === null || _this$_activeTabItem10 === void 0 || _this$_activeTabItem10.removeEventListener("pointerup", this._upAction);
21085
21744
  if (this._config.onSlideEnd && this._activeTabItemIndex !== this._compareIndex && isFromScroll) {
21086
21745
  this.removeListener();
21087
21746
  this._config.onSlideEnd(upEvent, this._compareIndex || 0);
@@ -21089,6 +21748,7 @@ var SlideTabBar = class SlideTabBar {
21089
21748
  this._scrollIncremental = 0;
21090
21749
  this._downActionX = 0;
21091
21750
  this._moveActionX = 0;
21751
+ this._dragStartScrollX = this._slideScrollbar.getScrollX();
21092
21752
  this._compareIndex = 0;
21093
21753
  };
21094
21754
  this._moveAction = (moveEvent) => {
@@ -21125,9 +21785,9 @@ var SlideTabBar = class SlideTabBar {
21125
21785
  * @param currentIndex
21126
21786
  */
21127
21787
  update(currentIndex) {
21788
+ this.removeListener();
21128
21789
  this._config.currentIndex = currentIndex;
21129
21790
  this._initConfig();
21130
- this.removeListener();
21131
21791
  this.addListener();
21132
21792
  this.scrollToItem(currentIndex);
21133
21793
  }
@@ -21264,13 +21924,13 @@ var SlideTabBar = class SlideTabBar {
21264
21924
  return scrollX;
21265
21925
  }
21266
21926
  calculateActiveTabItemScrollX() {
21267
- var _this$_activeTabItem12;
21927
+ var _this$_activeTabItem11;
21268
21928
  let scrollX = 0;
21269
21929
  const padding = 4;
21270
21930
  const containerRect = this._slideTabBar.getBoundingClientRect();
21271
21931
  const containerLeftPosition = containerRect.left;
21272
21932
  const containerRightPosition = containerRect.left + containerRect.width;
21273
- const itemReact = (_this$_activeTabItem12 = this._activeTabItem) === null || _this$_activeTabItem12 === void 0 ? void 0 : _this$_activeTabItem12.getSlideTabItem().getBoundingClientRect();
21933
+ const itemReact = (_this$_activeTabItem11 = this._activeTabItem) === null || _this$_activeTabItem11 === void 0 ? void 0 : _this$_activeTabItem11.getSlideTabItem().getBoundingClientRect();
21274
21934
  if (!itemReact) return 0;
21275
21935
  const itemLeft = itemReact.left;
21276
21936
  const itemWidth = itemReact.width;
@@ -21282,6 +21942,7 @@ var SlideTabBar = class SlideTabBar {
21282
21942
  this.removeListener();
21283
21943
  this._downActionX = 0;
21284
21944
  this._moveActionX = 0;
21945
+ this._dragStartScrollX = this._slideScrollbar.getScrollX();
21285
21946
  this._compareDirection = 0;
21286
21947
  this._compareIndex = 0;
21287
21948
  this._slideTabItems = [];
@@ -21335,17 +21996,18 @@ var SlideTabBar = class SlideTabBar {
21335
21996
  }
21336
21997
  _updateDragSortState() {
21337
21998
  if (!this._activeTabItem) return;
21999
+ const dragSortOffsetX = this._moveActionX + this._slideScrollbar.getScrollX() - this._dragStartScrollX;
21338
22000
  const dragSortResult = calculateSheetTabDragSort(this._slideTabItems.map((item) => ({
21339
22001
  id: item.getId(),
21340
22002
  left: item.getMidLine() - item.getWidth() / 2,
21341
22003
  width: item.getWidth()
21342
- })), this._activeTabItemIndex, this._moveActionX);
22004
+ })), this._activeTabItemIndex, dragSortOffsetX);
21343
22005
  this._compareIndex = dragSortResult.targetIndex;
21344
22006
  dragSortResult.itemOffsets.forEach((offset, index) => {
21345
22007
  const item = this._slideTabItems[index];
21346
22008
  if (!item) return;
21347
22009
  if (item.equals(this._activeTabItem)) {
21348
- this._compareDirection = item.translateX(offset);
22010
+ this._compareDirection = item.translateX(this._moveActionX);
21349
22011
  return;
21350
22012
  }
21351
22013
  item.animate().translateX(offset);
@@ -21399,7 +22061,9 @@ function SheetBarTabs() {
21399
22061
  const [contextMenuAnchorRect, setContextMenuAnchorRect] = useState(null);
21400
22062
  const slideTabBarRef = useRef(null);
21401
22063
  const slideTabBarContainerRef = useRef(null);
22064
+ const activeSheetIdRef = useRef(activeSheetId);
21402
22065
  const commandService = useDependency(ICommandService);
22066
+ const renderManagerService = useDependency(IRenderManagerService);
21403
22067
  const sheetBarService = useDependency(ISheetBarService);
21404
22068
  const localeService = useDependency(LocaleService);
21405
22069
  const confirmService = useDependency(IConfirmService);
@@ -21408,6 +22072,7 @@ function SheetBarTabs() {
21408
22072
  const rangeProtectionRuleModel = useDependency(RangeProtectionRuleModel);
21409
22073
  const permissionService = useDependency(IPermissionService);
21410
22074
  const workbook = useActiveWorkbook();
22075
+ const workbookRef = useRef(workbook);
21411
22076
  const resetOrder = useObservable(worksheetProtectionRuleModel.resetOrder$);
21412
22077
  const config = useConfigValue(UI_PLUGIN_CONFIG_KEY);
21413
22078
  const showContextMenu = (_config$contextMenu = config === null || config === void 0 ? void 0 : config.contextMenu) !== null && _config$contextMenu !== void 0 ? _config$contextMenu : true;
@@ -21461,9 +22126,9 @@ function SheetBarTabs() {
21461
22126
  openSheetNameErrorDialog("sheetNameSpecCharAlert", localeService.t("sheets-ui.sheetConfig.sheetNameSpecCharError"));
21462
22127
  return true;
21463
22128
  }, [localeService, openSheetNameErrorDialog]);
21464
- const nameRepeatCheck = useCallback((name) => {
21465
- var _workbook$getActiveSh;
21466
- if (((_workbook$getActiveSh = workbook.getActiveSheet()) === null || _workbook$getActiveSh === void 0 ? void 0 : _workbook$getActiveSh.getName()) === name) return false;
22129
+ const nameRepeatCheck = useCallback((name, subUnitId) => {
22130
+ var _workbook$getSheetByS, _workbook$getActiveSh;
22131
+ if ((subUnitId ? (_workbook$getSheetByS = workbook.getSheetBySheetId(subUnitId)) === null || _workbook$getSheetByS === void 0 ? void 0 : _workbook$getSheetByS.getName() : (_workbook$getActiveSh = workbook.getActiveSheet()) === null || _workbook$getActiveSh === void 0 ? void 0 : _workbook$getActiveSh.getName()) === name) return false;
21467
22132
  if (!workbook.checkSheetName(name)) return false;
21468
22133
  const id = "sheetNameRepeatAlert";
21469
22134
  confirmService.open({
@@ -21554,6 +22219,34 @@ function SheetBarTabs() {
21554
22219
  rightEnd: slideTabBar.isRightEnd()
21555
22220
  });
21556
22221
  }, [sheetBarService]);
22222
+ useEffect(() => {
22223
+ activeSheetIdRef.current = activeSheetId;
22224
+ }, [activeSheetId]);
22225
+ useEffect(() => {
22226
+ workbookRef.current = workbook;
22227
+ }, [workbook]);
22228
+ const syncActiveSheetRender = useCallback((subUnitId) => {
22229
+ const render = renderManagerService.getRenderById(workbookRef.current.getUnitId());
22230
+ try {
22231
+ render === null || render === void 0 || render.with(SheetSkeletonManagerService).setCurrent({ sheetId: subUnitId });
22232
+ render === null || render === void 0 || render.scene.makeDirty(true);
22233
+ render === null || render === void 0 || render.scene.render();
22234
+ } catch {}
22235
+ }, [renderManagerService]);
22236
+ const activateSheetTab = useCallback((subUnitId) => {
22237
+ if (!subUnitId || subUnitId === activeSheetIdRef.current) return;
22238
+ commandService.executeCommand(SetWorksheetActiveOperation.id, {
22239
+ subUnitId,
22240
+ unitId: workbookRef.current.getUnitId()
22241
+ }).then((result) => {
22242
+ if (result !== false) return;
22243
+ const worksheet = workbookRef.current.getSheetBySheetId(subUnitId);
22244
+ if (worksheet) {
22245
+ workbookRef.current.setActiveSheet(worksheet);
22246
+ syncActiveSheetRender(subUnitId);
22247
+ }
22248
+ });
22249
+ }, [commandService, syncActiveSheetRender]);
21557
22250
  const observeResize = useCallback((slideTabBar) => {
21558
22251
  var _slideTabBarContainer;
21559
22252
  const slideTabBarContainer = (_slideTabBarContainer = slideTabBarContainerRef.current) === null || _slideTabBarContainer === void 0 ? void 0 : _slideTabBarContainer.querySelector("[data-u-comp=slide-tab-bar]");
@@ -21662,8 +22355,8 @@ function SheetBarTabs() {
21662
22355
  slideTabBarContainer: slideTabBarContainerRef.current,
21663
22356
  currentIndex: 0,
21664
22357
  onChangeName: (subUnitId, worksheetName) => {
21665
- var _workbook$getSheetByS;
21666
- if (((_workbook$getSheetByS = workbook.getSheetBySheetId(subUnitId)) === null || _workbook$getSheetByS === void 0 ? void 0 : _workbook$getSheetByS.getName()) === worksheetName) {
22358
+ var _workbook$getSheetByS2;
22359
+ if (((_workbook$getSheetByS2 = workbook.getSheetBySheetId(subUnitId)) === null || _workbook$getSheetByS2 === void 0 ? void 0 : _workbook$getSheetByS2.getName()) === worksheetName) {
21667
22360
  updateSheetItems();
21668
22361
  return;
21669
22362
  }
@@ -21673,7 +22366,8 @@ function SheetBarTabs() {
21673
22366
  });
21674
22367
  },
21675
22368
  onSlideEnd: async (event, order) => {
21676
- await commandService.executeCommand(SetWorksheetOrderCommand.id, { order });
22369
+ const targetOrder = getSheetTabTargetOrder(workbook.getSheetOrders(), workbook.getUnhiddenWorksheets(), order);
22370
+ await commandService.executeCommand(SetWorksheetOrderCommand.id, { order: targetOrder });
21677
22371
  },
21678
22372
  onChangeTab: (_event, subUnitId) => {
21679
22373
  commandService.executeCommand(SetWorksheetActiveOperation.id, {
@@ -21684,8 +22378,8 @@ function SheetBarTabs() {
21684
22378
  onScroll: (state) => {
21685
22379
  sheetBarService.setScroll(state);
21686
22380
  },
21687
- onNameCheckAlert: (name) => {
21688
- return nameEmptyCheck(name) || sheetNameSpecCharCheck(name) || nameRepeatCheck(name);
22381
+ onNameCheckAlert: (name, subUnitId) => {
22382
+ return nameEmptyCheck(name) || sheetNameSpecCharCheck(name) || nameRepeatCheck(name, subUnitId);
21689
22383
  },
21690
22384
  onNameChangeCheck: canRenameActiveSheet
21691
22385
  });
@@ -21719,6 +22413,9 @@ function SheetBarTabs() {
21719
22413
  const renameSubscription = sheetBarService.renameId$.subscribe(() => {
21720
22414
  setTabEditor();
21721
22415
  });
22416
+ const activeSheetSubscription = workbook.activeSheet$.subscribe(() => {
22417
+ updateSheetItems();
22418
+ });
21722
22419
  return () => {
21723
22420
  commandDisposable.dispose();
21724
22421
  slideTabBar.destroy();
@@ -21726,6 +22423,7 @@ function SheetBarTabs() {
21726
22423
  scrollSubscription.unsubscribe();
21727
22424
  scrollXSubscription.unsubscribe();
21728
22425
  renameSubscription.unsubscribe();
22426
+ activeSheetSubscription.unsubscribe();
21729
22427
  disconnectResizeObserver === null || disconnectResizeObserver === void 0 || disconnectResizeObserver();
21730
22428
  };
21731
22429
  }, [
@@ -21744,6 +22442,19 @@ function SheetBarTabs() {
21744
22442
  const currentIndex = sheetList.findIndex((item) => item.sheetId === activeSheetId);
21745
22443
  (_slideTabBarRef$curre5 = slideTabBarRef.current) === null || _slideTabBarRef$curre5 === void 0 || _slideTabBarRef$curre5.update(currentIndex >= 0 ? currentIndex : 0);
21746
22444
  }, [activeSheetId, sheetList]);
22445
+ useEffect(() => {
22446
+ const handlePointerDownCapture = (event) => {
22447
+ var _tabElement$getAttrib;
22448
+ const container = slideTabBarContainerRef.current;
22449
+ const target = event.target;
22450
+ if (!container || !(target instanceof Element)) return;
22451
+ const tabElement = target.closest("[data-u-comp=slide-tab-item]");
22452
+ if (!tabElement || !container.contains(tabElement)) return;
22453
+ activateSheetTab((_tabElement$getAttrib = tabElement.getAttribute("data-id")) !== null && _tabElement$getAttrib !== void 0 ? _tabElement$getAttrib : void 0);
22454
+ };
22455
+ document.addEventListener("pointerdown", handlePointerDownCapture, true);
22456
+ return () => document.removeEventListener("pointerdown", handlePointerDownCapture, true);
22457
+ }, [activateSheetTab]);
21747
22458
  useEffect(() => {
21748
22459
  const subscription = merge$1(worksheetProtectionRuleModel.ruleChange$, rangeProtectionRuleModel.ruleChange$).subscribe(() => {
21749
22460
  updateSheetItems();
@@ -22091,31 +22802,52 @@ function RenderSheetFooter() {
22091
22802
  const config = useConfigValue(SHEETS_UI_PLUGIN_CONFIG_KEY);
22092
22803
  const menuManagerService = useDependency(IMenuManagerService);
22093
22804
  const showFooter = (_config$footer = config === null || config === void 0 ? void 0 : config.footer) !== null && _config$footer !== void 0 ? _config$footer : true;
22094
- if (!useActiveWorkbook() || !showFooter) return null;
22805
+ const workbook = useActiveWorkbook();
22806
+ const activeWorkbookEmbeddedRender = useActiveWorkbookIsEmbeddedRender(workbook);
22807
+ const focusedUnitType = useFocusedUnitType();
22808
+ const activeEmbedTab = useActiveSheetEmbedTabData(workbook);
22809
+ if (!workbook || !showFooter) return null;
22810
+ if (activeWorkbookEmbeddedRender) return null;
22811
+ if (!activeEmbedTab && focusedUnitType != null && focusedUnitType !== UniverInstanceType.UNIVER_SHEET) return null;
22095
22812
  const footerMenus = menuManagerService.getMenuByPositionKey(ContextMenuPosition.FOOTER_MENU);
22096
22813
  const { sheetBar = true, statisticBar = true, menus = true, zoomSlider = true } = (config === null || config === void 0 ? void 0 : config.footer) || {};
22097
- if (!sheetBar && !statisticBar && !menus && !zoomSlider) return null;
22814
+ const showStatisticBar = activeEmbedTab ? false : statisticBar;
22815
+ const showMenus = activeEmbedTab ? false : menus;
22816
+ const showZoomSlider = activeEmbedTab ? false : zoomSlider;
22817
+ if (!sheetBar && !showStatisticBar && !showMenus && !showZoomSlider) return null;
22098
22818
  return /* @__PURE__ */ jsxs("section", {
22099
22819
  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-white univer-px-5 univer-text-gray-900 dark:!univer-bg-gray-900 dark:!univer-text-gray-200",
22100
22820
  style: { height: 36 },
22101
22821
  "data-range-selector": true,
22102
22822
  children: [
22103
22823
  sheetBar && /* @__PURE__ */ jsx(SheetBar, {}),
22104
- statisticBar && /* @__PURE__ */ jsx(StatusBar, {}),
22105
- menus && footerMenus.length > 0 && /* @__PURE__ */ jsx("div", {
22824
+ showStatisticBar && /* @__PURE__ */ jsx(StatusBar, {}),
22825
+ showMenus && footerMenus.length > 0 && /* @__PURE__ */ jsx("div", {
22106
22826
  className: "univer-box-border univer-flex univer-gap-2 univer-px-2",
22107
22827
  children: footerMenus.map((item) => {
22108
22828
  var _item$children;
22109
22829
  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));
22110
22830
  })
22111
22831
  }),
22112
- zoomSlider && /* @__PURE__ */ jsx(SheetZoomSlider, {})
22832
+ showZoomSlider && /* @__PURE__ */ jsx(SheetZoomSlider, {})
22113
22833
  ]
22114
22834
  });
22115
22835
  }
22116
22836
  function RenderSheetHeader() {
22117
22837
  const config = useConfigValue(SHEETS_UI_PLUGIN_CONFIG_KEY);
22118
- if (!useHasWorkbook()) return null;
22838
+ const workbook = useActiveWorkbook();
22839
+ const hasWorkbook = !!workbook;
22840
+ const activeWorkbookEmbeddedRender = useActiveWorkbookIsEmbeddedRender(workbook);
22841
+ const focusedUnitType = useFocusedUnitType();
22842
+ const activeEmbedTab = useActiveSheetEmbedTabData(workbook);
22843
+ if (!hasWorkbook) return null;
22844
+ if (activeWorkbookEmbeddedRender) return null;
22845
+ if (activeEmbedTab) return null;
22846
+ if (focusedUnitType != null && focusedUnitType !== UniverInstanceType.UNIVER_SHEET) return /* @__PURE__ */ jsx("div", {
22847
+ "aria-hidden": true,
22848
+ className: "univer-h-7 univer-border-b univer-border-gray-200 univer-bg-white dark:!univer-border-gray-700 dark:!univer-bg-gray-900",
22849
+ "data-u-comp": "formula-bar-placeholder"
22850
+ });
22119
22851
  if ((config === null || config === void 0 ? void 0 : config.formulaBar) !== false) return /* @__PURE__ */ jsx(FormulaBar, {});
22120
22852
  return null;
22121
22853
  }
@@ -22123,19 +22855,108 @@ function RenderSheetHeader() {
22123
22855
  * @deprecated We should not write into this component anymore.
22124
22856
  */
22125
22857
  function RenderSheetContent() {
22858
+ var _componentManager$get;
22126
22859
  const config = useConfigValue(SHEETS_UI_PLUGIN_CONFIG_KEY);
22127
22860
  const hasWorkbook = useHasWorkbook();
22128
- const ShapeTextEditorContainer = useDependency(ComponentManager).get("ShapeTextEditorContainer");
22861
+ const componentManager = useDependency(ComponentManager);
22862
+ const workbook = useActiveWorkbook();
22863
+ const activeEmbedTab = useActiveSheetEmbedTabData(workbook);
22864
+ const injector = useDependency(Injector);
22865
+ const activeWorkbookEmbeddedRender = useActiveWorkbookIsEmbeddedRender(workbook);
22866
+ const ShapeTextEditorContainer = (_componentManager$get = componentManager.get("SheetShapeTextEditorContainer")) !== null && _componentManager$get !== void 0 ? _componentManager$get : componentManager.get("ShapeTextEditorContainer");
22867
+ useEffect(() => {
22868
+ var _tryGetSheetEmbedRunt;
22869
+ if (!workbook || activeEmbedTab || activeWorkbookEmbeddedRender) return;
22870
+ const instanceService = injector.get(IUniverInstanceService);
22871
+ instanceService.setCurrentUnitForType(workbook.getUnitId());
22872
+ instanceService.focusUnit(workbook.getUnitId());
22873
+ (_tryGetSheetEmbedRunt = tryGetSheetEmbedRuntimeService(injector)) === null || _tryGetSheetEmbedRunt === void 0 || _tryGetSheetEmbedRunt.clearTab();
22874
+ }, [
22875
+ activeEmbedTab,
22876
+ activeWorkbookEmbeddedRender,
22877
+ injector,
22878
+ workbook
22879
+ ]);
22129
22880
  if (!hasWorkbook) return null;
22881
+ if (activeWorkbookEmbeddedRender) return null;
22882
+ if (activeEmbedTab && workbook) return /* @__PURE__ */ jsx(RenderSheetEmbedTabHost, {
22883
+ workbook,
22884
+ worksheet: activeEmbedTab.worksheet
22885
+ });
22130
22886
  return /* @__PURE__ */ jsxs(Fragment, { children: [
22131
22887
  ShapeTextEditorContainer && /* @__PURE__ */ jsx(ShapeTextEditorContainer, {}),
22132
22888
  !(config === null || config === void 0 ? void 0 : config.disableEdit) && /* @__PURE__ */ jsx(EditorContainer, {}),
22133
22889
  /* @__PURE__ */ jsx(AutoFillPopupMenu, {})
22134
22890
  ] });
22135
22891
  }
22892
+ function RenderSheetEmbedTabHost(props) {
22893
+ const { workbook, worksheet } = props;
22894
+ const injector = useDependency(Injector);
22895
+ const embedData = getEmbedSheetsTabCustomData(worksheet.getConfig());
22896
+ const hostUnitId = workbook.getUnitId();
22897
+ const hostAnchorId = embedData === null || embedData === void 0 ? void 0 : embedData.hostAnchorId;
22898
+ const embedId = embedData === null || embedData === void 0 ? void 0 : embedData.embedId;
22899
+ useEffect(() => {
22900
+ if (!embedId || !hostAnchorId) return;
22901
+ const embedRuntimeService = tryGetSheetEmbedRuntimeService(injector);
22902
+ if (!embedRuntimeService) return;
22903
+ try {
22904
+ const disposable = embedRuntimeService.mountSheetTab({
22905
+ hostUnitId,
22906
+ hostAnchorId,
22907
+ embedId
22908
+ });
22909
+ return () => {
22910
+ disposable === null || disposable === void 0 || disposable.dispose();
22911
+ };
22912
+ } catch (error) {
22913
+ console.warn("[sheets-ui] failed to mount embedded sheet-tab block", error);
22914
+ }
22915
+ }, [
22916
+ embedId,
22917
+ hostAnchorId,
22918
+ hostUnitId,
22919
+ injector
22920
+ ]);
22921
+ return /* @__PURE__ */ jsx("div", {
22922
+ "data-embed-sheets-sheet-tab-host": hostAnchorId,
22923
+ className: "univer-absolute univer-inset-0 univer-z-40 univer-bg-white dark:!univer-bg-gray-900"
22924
+ });
22925
+ }
22136
22926
  function useHasWorkbook() {
22137
22927
  const univerInstanceService = useDependency(IUniverInstanceService);
22138
- return useMemo(() => univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).length > 0, [univerInstanceService, !!useObservable(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), null, false, [])]);
22928
+ const workbook = useObservable(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), null, false, []);
22929
+ return useMemo(() => !!workbook, [workbook]);
22930
+ }
22931
+ function useActiveWorkbookIsEmbeddedRender(workbook) {
22932
+ const univerInstanceService = useDependency(IUniverInstanceService);
22933
+ return useMemo(() => {
22934
+ var _univerInstanceServic;
22935
+ if (!workbook) return false;
22936
+ return ((_univerInstanceServic = univerInstanceService.getUnitCreateOptions(workbook.getUnitId())) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.embeddedRender) === true;
22937
+ }, [univerInstanceService, workbook]);
22938
+ }
22939
+ function useFocusedUnitType() {
22940
+ const univerInstanceService = useDependency(IUniverInstanceService);
22941
+ const focusedUnitId = useObservable(() => univerInstanceService.focused$, null, false, [univerInstanceService]);
22942
+ return useMemo(() => {
22943
+ var _focusedUnit$type;
22944
+ if (!focusedUnitId) return null;
22945
+ if (isInternalEditorID(focusedUnitId) && univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) return UniverInstanceType.UNIVER_SHEET;
22946
+ const focusedUnit = univerInstanceService.getUnit(focusedUnitId);
22947
+ return (_focusedUnit$type = focusedUnit === null || focusedUnit === void 0 ? void 0 : focusedUnit.type) !== null && _focusedUnit$type !== void 0 ? _focusedUnit$type : null;
22948
+ }, [focusedUnitId, univerInstanceService]);
22949
+ }
22950
+ function useActiveSheetEmbedTabData(workbook) {
22951
+ const worksheet = useActiveWorksheet(workbook);
22952
+ return worksheet && getEmbedSheetsTabCustomData(worksheet.getConfig()) ? { worksheet } : void 0;
22953
+ }
22954
+ function tryGetSheetEmbedRuntimeService(injector) {
22955
+ try {
22956
+ return injector.get(ISheetEmbedRuntimeService);
22957
+ } catch {
22958
+ return;
22959
+ }
22139
22960
  }
22140
22961
 
22141
22962
  //#endregion
@@ -22706,10 +23527,8 @@ let SheetUIController = class SheetUIController extends Disposable {
22706
23527
  }
22707
23528
  _initFocusHandler() {
22708
23529
  this.disposeWithMe(this._layoutService.registerFocusHandler(UniverInstanceType.UNIVER_SHEET, (_unitId) => {
22709
- const renderManagerService = this._injector.get(IRenderManagerService);
22710
- const instanceService = this._injector.get(IUniverInstanceService);
22711
- const currentEditorRender = getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC, instanceService, renderManagerService);
22712
- const docSelectionRenderService = currentEditorRender === null || currentEditorRender === void 0 ? void 0 : currentEditorRender.with(DocSelectionRenderService);
23530
+ const cellEditorRender = this._injector.get(IRenderManagerService).getRenderById(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
23531
+ const docSelectionRenderService = cellEditorRender === null || cellEditorRender === void 0 ? void 0 : cellEditorRender.with(DocSelectionRenderService);
22713
23532
  docSelectionRenderService === null || docSelectionRenderService === void 0 || docSelectionRenderService.focus();
22714
23533
  }));
22715
23534
  }
@@ -22750,7 +23569,7 @@ const useHighlightRange = (ranges = []) => {
22750
23569
  //#endregion
22751
23570
  //#region package.json
22752
23571
  var name = "@univerjs/sheets-ui";
22753
- var version = "1.0.0-alpha.2";
23572
+ var version = "1.0.0-alpha.3";
22754
23573
 
22755
23574
  //#endregion
22756
23575
  //#region src/controllers/cell-alert.controller.ts
@@ -22796,6 +23615,7 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends Di
22796
23615
  this._selectionManagerService = _selectionManagerService;
22797
23616
  _defineProperty(this, "_popupMenuFeatureMap", /* @__PURE__ */ new Map());
22798
23617
  _defineProperty(this, "_popupMenuOffsetMap", /* @__PURE__ */ new Map());
23618
+ _defineProperty(this, "_popupDisposables", /* @__PURE__ */ new Set());
22799
23619
  _defineProperty(this, "_isSelectionMoving", false);
22800
23620
  this._initMoving();
22801
23621
  }
@@ -22844,6 +23664,8 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends Di
22844
23664
  if (callback) return callback(unitId, subUnitId, drawingId, drawingType);
22845
23665
  }
22846
23666
  dispose() {
23667
+ Array.from(this._popupDisposables).forEach((disposable) => disposable.dispose());
23668
+ this._popupDisposables.clear();
22847
23669
  super.dispose();
22848
23670
  this._popupMenuFeatureMap.clear();
22849
23671
  this._popupMenuOffsetMap.clear();
@@ -22974,20 +23796,25 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends Di
22974
23796
  bottom: top + height
22975
23797
  };
22976
23798
  const { position, position$, disposable } = this._createPositionObserver(bound, currentRender, skeleton, worksheet);
23799
+ const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
22977
23800
  const id = this._globalPopupManagerService.addPopup({
22978
23801
  ...popup,
22979
23802
  unitId,
22980
23803
  subUnitId,
23804
+ connectorInjector: popupInjector,
22981
23805
  anchorRect: position,
22982
23806
  anchorRect$: position$,
22983
23807
  canvasElement: currentRender.engine.getCanvasElement()
22984
23808
  });
23809
+ const disposableCollection = new DisposableCollection();
23810
+ disposableCollection.add(disposable);
23811
+ disposableCollection.add(toDisposable(() => {
23812
+ this._globalPopupManagerService.removePopup(id);
23813
+ position$.complete();
23814
+ }));
23815
+ const trackedDisposable = this._trackPopupDisposable(disposableCollection);
22985
23816
  return {
22986
- dispose: () => {
22987
- this._globalPopupManagerService.removePopup(id);
22988
- position$.complete();
22989
- disposable.dispose();
22990
- },
23817
+ dispose: () => trackedDisposable.dispose(),
22991
23818
  canDispose: () => this._globalPopupManagerService.activePopupId !== id
22992
23819
  };
22993
23820
  }
@@ -23011,28 +23838,42 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends Di
23011
23838
  skeleton,
23012
23839
  currentRender
23013
23840
  });
23841
+ const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
23014
23842
  const id = this._globalPopupManagerService.addPopup({
23015
23843
  ...popup,
23016
23844
  unitId,
23017
23845
  subUnitId,
23846
+ connectorInjector: popupInjector,
23018
23847
  anchorRect: position,
23019
23848
  anchorRect$: position$,
23020
23849
  hiddenRects$: rects$,
23021
23850
  canvasElement: currentRender.engine.getCanvasElement()
23022
23851
  });
23852
+ const disposableCollection = new DisposableCollection();
23853
+ disposableCollection.add(disposable);
23854
+ disposableCollection.add(rectsObserverDisposable);
23855
+ disposableCollection.add(toDisposable(() => {
23856
+ this._globalPopupManagerService.removePopup(id);
23857
+ position$.complete();
23858
+ workbook = null;
23859
+ worksheet = null;
23860
+ }));
23861
+ const trackedDisposable = this._trackPopupDisposable(disposableCollection);
23023
23862
  return {
23024
- dispose: () => {
23025
- this._globalPopupManagerService.removePopup(id);
23026
- position$.complete();
23027
- disposable.dispose();
23028
- rectsObserverDisposable.dispose();
23029
- workbook = null;
23030
- worksheet = null;
23031
- },
23863
+ dispose: () => trackedDisposable.dispose(),
23032
23864
  canDispose: () => this._globalPopupManagerService.activePopupId !== id
23033
23865
  };
23034
23866
  }
23035
23867
  attachPopupToAbsolutePosition(bound, popup, _unitId, _subUnitId) {
23868
+ const position$ = new BehaviorSubject(bound);
23869
+ const disposable = this._attachAbsolutePopup(bound, position$.asObservable(), popup, _unitId, _subUnitId, () => position$.complete());
23870
+ if (!disposable) position$.complete();
23871
+ return disposable;
23872
+ }
23873
+ attachPopupToDynamicAbsolutePosition(bound, anchorRect$, popup, _unitId, _subUnitId) {
23874
+ return this._attachAbsolutePopup(bound, anchorRect$, popup, _unitId, _subUnitId);
23875
+ }
23876
+ _attachAbsolutePopup(bound, anchorRect$, popup, _unitId, _subUnitId, onDispose) {
23036
23877
  var _this$_renderManagerS3;
23037
23878
  const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
23038
23879
  const worksheet = workbook.getActiveSheet();
@@ -23044,20 +23885,24 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends Di
23044
23885
  const currentRender = this._renderManagerService.getRenderById(unitId);
23045
23886
  if (!currentRender || !skeleton) return null;
23046
23887
  if (this._isSelectionMoving && !popup.showOnSelectionMoving) return;
23047
- const position$ = new BehaviorSubject(bound);
23888
+ const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
23048
23889
  const id = this._globalPopupManagerService.addPopup({
23049
23890
  ...popup,
23050
23891
  unitId,
23051
23892
  subUnitId,
23893
+ connectorInjector: popupInjector,
23052
23894
  anchorRect: bound,
23053
- anchorRect$: position$.asObservable(),
23895
+ anchorRect$,
23054
23896
  canvasElement: currentRender.engine.getCanvasElement()
23055
23897
  });
23898
+ const disposableCollection = new DisposableCollection();
23899
+ disposableCollection.add(toDisposable(() => {
23900
+ this._globalPopupManagerService.removePopup(id);
23901
+ onDispose === null || onDispose === void 0 || onDispose();
23902
+ }));
23903
+ const trackedDisposable = this._trackPopupDisposable(disposableCollection);
23056
23904
  return {
23057
- dispose: () => {
23058
- this._globalPopupManagerService.removePopup(id);
23059
- position$.complete();
23060
- },
23905
+ dispose: () => trackedDisposable.dispose(),
23061
23906
  canDispose: () => this._globalPopupManagerService.activePopupId !== id
23062
23907
  };
23063
23908
  }
@@ -23094,10 +23939,12 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends Di
23094
23939
  skeleton,
23095
23940
  currentRender
23096
23941
  });
23942
+ const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
23097
23943
  const id = this._globalPopupManagerService.addPopup({
23098
23944
  ...popup,
23099
23945
  unitId,
23100
23946
  subUnitId,
23947
+ connectorInjector: popupInjector,
23101
23948
  anchorRect: position,
23102
23949
  anchorRect$: position$,
23103
23950
  canvasElement: currentRender.engine.getCanvasElement(),
@@ -23116,13 +23963,14 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends Di
23116
23963
  startColumn: col,
23117
23964
  endColumn: col
23118
23965
  };
23966
+ const trackedDisposable = this._trackPopupDisposable(disposableCollection);
23119
23967
  disposableCollection.add(this._refRangeService.watchRange(unitId, subUnitId, watchedRange, (_, after) => {
23120
- if (!after) disposableCollection.dispose();
23968
+ if (!after) trackedDisposable.dispose();
23121
23969
  else updateRowCol(after.startRow, after.startColumn);
23122
23970
  }));
23123
23971
  return {
23124
23972
  dispose() {
23125
- disposableCollection.dispose();
23973
+ trackedDisposable.dispose();
23126
23974
  worksheet = null;
23127
23975
  workbook = null;
23128
23976
  },
@@ -23160,10 +24008,12 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends Di
23160
24008
  skeleton,
23161
24009
  currentRender
23162
24010
  });
24011
+ const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
23163
24012
  const id = this._globalPopupManagerService.addPopup({
23164
24013
  ...popup,
23165
24014
  unitId,
23166
24015
  subUnitId,
24016
+ connectorInjector: popupInjector,
23167
24017
  anchorRect: position,
23168
24018
  anchorRect$: position$,
23169
24019
  canvasElement: currentRender.engine.getCanvasElement(),
@@ -23178,17 +24028,34 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends Di
23178
24028
  }));
23179
24029
  disposableCollection.add(rectsObserverDisposable);
23180
24030
  const watchedRange = { ...range };
24031
+ const trackedDisposable = this._trackPopupDisposable(disposableCollection);
23181
24032
  disposableCollection.add(this._refRangeService.watchRange(unitId, subUnitId, watchedRange, (_, after) => {
23182
- if (!after) disposableCollection.dispose();
24033
+ if (!after) trackedDisposable.dispose();
23183
24034
  else updateRange(after);
23184
24035
  }));
23185
24036
  return {
23186
24037
  dispose() {
23187
- disposableCollection.dispose();
24038
+ trackedDisposable.dispose();
23188
24039
  },
23189
24040
  canDispose: () => this._globalPopupManagerService.activePopupId !== id
23190
24041
  };
23191
24042
  }
24043
+ _resolveEmbeddedPopupInjector(unitId, currentRender) {
24044
+ var _this$_univerInstance, _currentRender$getInj;
24045
+ return ((_this$_univerInstance = this._univerInstanceService.getUnitCreateOptions(unitId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.embeddedRender) === true ? (_currentRender$getInj = currentRender.getInjector) === null || _currentRender$getInj === void 0 ? void 0 : _currentRender$getInj.call(currentRender) : void 0;
24046
+ }
24047
+ _trackPopupDisposable(disposable) {
24048
+ let disposed = false;
24049
+ const trackedDisposables = this._popupDisposables;
24050
+ const trackedDisposable = { dispose: () => {
24051
+ if (disposed) return;
24052
+ disposed = true;
24053
+ trackedDisposables.delete(trackedDisposable);
24054
+ disposable.dispose();
24055
+ } };
24056
+ trackedDisposables.add(trackedDisposable);
24057
+ return { dispose: () => trackedDisposable.dispose() };
24058
+ }
23192
24059
  /**
23193
24060
  *
23194
24061
  * @param initialRow
@@ -23204,7 +24071,10 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends Di
23204
24071
  const position$ = new BehaviorSubject(position);
23205
24072
  const updatePosition = () => position$.next(this._calcCellPositionByCell(row, col, currentRender, skeleton, activeViewport));
23206
24073
  const disposable = new DisposableCollection();
23207
- disposable.add(currentRender.engine.clientRect$.subscribe(() => updatePosition()));
24074
+ disposable.add(currentRender.engine.clientRect$.subscribe({
24075
+ next: () => updatePosition(),
24076
+ error: () => {}
24077
+ }));
23208
24078
  disposable.add(fromEventSubject(currentRender.engine.onTransformChange$).pipe(throttleTime(16)).subscribe(() => updatePosition()));
23209
24079
  disposable.add(this._commandService.onCommandExecuted((commandInfo) => {
23210
24080
  if (commandInfo.id === SetWorksheetRowAutoHeightMutation.id) {
@@ -23281,7 +24151,10 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends Di
23281
24151
  rightBottomPos$.next(rightBottomCoord);
23282
24152
  };
23283
24153
  const disposable = new DisposableCollection();
23284
- disposable.add(currentRender.engine.clientRect$.subscribe(() => updatePosition()));
24154
+ disposable.add(currentRender.engine.clientRect$.subscribe({
24155
+ next: () => updatePosition(),
24156
+ error: () => {}
24157
+ }));
23285
24158
  disposable.add(this._commandService.onCommandExecuted((commandInfo) => {
23286
24159
  if (commandInfo.id === SetWorksheetRowAutoHeightMutation.id) {
23287
24160
  if (commandInfo.params.rowsAutoHeightInfo.findIndex((item) => item.row === startRow) > -1) {
@@ -23453,6 +24326,23 @@ let CellPopupManagerService = class CellPopupManagerService extends Disposable {
23453
24326
  }
23454
24327
  if (!cache.horizontal && !cache.vertical) subUnitMap.realDeleteValue(row, col);
23455
24328
  }
24329
+ hidePopupsForUnit(unitId, subUnitId) {
24330
+ const unitMap = this._cellPopupMap.get(unitId);
24331
+ if (!unitMap) return;
24332
+ const targets = [];
24333
+ (subUnitId ? [[subUnitId, unitMap.get(subUnitId)]] : [...unitMap.entries()]).forEach(([currentSubUnitId, subUnitMap]) => {
24334
+ subUnitMap === null || subUnitMap === void 0 || subUnitMap.forValue((row, col) => {
24335
+ targets.push({
24336
+ subUnitId: currentSubUnitId,
24337
+ row,
24338
+ col
24339
+ });
24340
+ });
24341
+ });
24342
+ targets.forEach((target) => this.hidePopup(unitId, target.subUnitId, target.row, target.col));
24343
+ if (subUnitId) unitMap.delete(subUnitId);
24344
+ else this._cellPopupMap.delete(unitId);
24345
+ }
23456
24346
  };
23457
24347
  CellPopupManagerService = __decorate([__decorateParam(0, Inject(SheetCanvasPopManagerService))], CellPopupManagerService);
23458
24348
 
@@ -24091,56 +24981,6 @@ function BorderLine(props) {
24091
24981
 
24092
24982
  //#endregion
24093
24983
  //#region src/views/border-panel/BorderPanel.tsx
24094
- const BORDER_SIZE_CHILDREN = [
24095
- {
24096
- label: BorderStyleTypes.THIN,
24097
- value: BorderStyleTypes.THIN
24098
- },
24099
- {
24100
- label: BorderStyleTypes.HAIR,
24101
- value: BorderStyleTypes.HAIR
24102
- },
24103
- {
24104
- label: BorderStyleTypes.DOTTED,
24105
- value: BorderStyleTypes.DOTTED
24106
- },
24107
- {
24108
- label: BorderStyleTypes.DASHED,
24109
- value: BorderStyleTypes.DASHED
24110
- },
24111
- {
24112
- label: BorderStyleTypes.DASH_DOT,
24113
- value: BorderStyleTypes.DASH_DOT
24114
- },
24115
- {
24116
- label: BorderStyleTypes.DASH_DOT_DOT,
24117
- value: BorderStyleTypes.DASH_DOT_DOT
24118
- },
24119
- {
24120
- label: BorderStyleTypes.MEDIUM,
24121
- value: BorderStyleTypes.MEDIUM
24122
- },
24123
- {
24124
- label: BorderStyleTypes.MEDIUM_DASHED,
24125
- value: BorderStyleTypes.MEDIUM_DASHED
24126
- },
24127
- {
24128
- label: BorderStyleTypes.MEDIUM_DASH_DOT,
24129
- value: BorderStyleTypes.MEDIUM_DASH_DOT
24130
- },
24131
- {
24132
- label: BorderStyleTypes.MEDIUM_DASH_DOT_DOT,
24133
- value: BorderStyleTypes.MEDIUM_DASH_DOT_DOT
24134
- },
24135
- {
24136
- label: BorderStyleTypes.THICK,
24137
- value: BorderStyleTypes.THICK
24138
- },
24139
- {
24140
- label: BorderStyleTypes.DOUBLE,
24141
- value: BorderStyleTypes.DOUBLE
24142
- }
24143
- ];
24144
24984
  function getBorderColor(borderData) {
24145
24985
  if (!borderData) return;
24146
24986
  for (const key in borderData) {
@@ -28626,7 +29466,7 @@ let MobileSheetsScrollRenderController = class MobileSheetsScrollRenderControlle
28626
29466
  this.disposeWithMe(viewportMain.onScrollByBar$.subscribeEvent((param) => {
28627
29467
  var _this$_sheetSkeletonM4;
28628
29468
  const skeleton = (_this$_sheetSkeletonM4 = this._sheetSkeletonManagerService.getCurrentParam()) === null || _this$_sheetSkeletonM4 === void 0 ? void 0 : _this$_sheetSkeletonM4.skeleton;
28629
- if (skeleton == null || param.isTrigger === false) return;
29469
+ if (skeleton == null || param.isTrigger === false || param.isBarDragging && !param.isBarDragEnd) return;
28630
29470
  const sheetObject = this._getSheetObject();
28631
29471
  if (skeleton == null || sheetObject == null) return;
28632
29472
  const { viewportScrollX = 0, viewportScrollY = 0 } = param;
@@ -29501,7 +30341,7 @@ function getListDropdownValue(value, multiple) {
29501
30341
  //#endregion
29502
30342
  //#region src/views/dropdown/ListDropDown.tsx
29503
30343
  function SelectList(props) {
29504
- const { value, onChange, multiple, options, title, onEdit, style, location, showEdit: showEditOnDropdown, showSearch: showSearchOnDropdown } = props;
30344
+ const { value, onChange, multiple, options, onEdit, style, location, showEdit: showEditOnDropdown, showSearch: showSearchOnDropdown } = props;
29505
30345
  const localeService = useDependency(LocaleService);
29506
30346
  const { row, col, unitId, subUnitId } = location;
29507
30347
  const searchRef = useRef(null);
@@ -29557,7 +30397,7 @@ function SelectList(props) {
29557
30397
  }),
29558
30398
  /* @__PURE__ */ jsx("div", {
29559
30399
  className: "univer-px-3.5 univer-py-1 univer-pt-2 univer-text-xs",
29560
- children: title
30400
+ children: localeService.t(multiple ? "sheets-ui.data-validation.listMultiple.dropdown" : "sheets-ui.data-validation.list.dropdown")
29561
30401
  }),
29562
30402
  /* @__PURE__ */ jsx("div", {
29563
30403
  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),
@@ -29616,7 +30456,6 @@ function ListDropDown(props) {
29616
30456
  const { location, hideFn, onChange, onEdit, options, defaultValue, multiple, showSearch, showEdit } = extraProps;
29617
30457
  const { worksheet } = location;
29618
30458
  if (!worksheet) return null;
29619
- const localeService = useDependency(LocaleService);
29620
30459
  const [localValue, setLocalValue] = useState(defaultValue);
29621
30460
  const cellWidth = ((_anchorRect$right = anchorRect === null || anchorRect === void 0 ? void 0 : anchorRect.right) !== null && _anchorRect$right !== void 0 ? _anchorRect$right : 0) - ((_anchorRect$left = anchorRect === null || anchorRect === void 0 ? void 0 : anchorRect.left) !== null && _anchorRect$left !== void 0 ? _anchorRect$left : 0);
29622
30461
  return /* @__PURE__ */ jsx(SelectList, {
@@ -29624,7 +30463,6 @@ function ListDropDown(props) {
29624
30463
  minWidth: cellWidth,
29625
30464
  maxWidth: Math.max(cellWidth, 200)
29626
30465
  },
29627
- title: multiple ? localeService.t("sheets-ui.data-validation.listMultiple.dropdown") : localeService.t("sheets-ui.data-validation.list.dropdown"),
29628
30466
  value: getListDropdownValue(localValue, multiple),
29629
30467
  multiple,
29630
30468
  onChange: async (newValue) => {
@@ -29700,6 +30538,28 @@ SheetCellDropdownManagerService = __decorate([
29700
30538
 
29701
30539
  //#endregion
29702
30540
  //#region src/services/print-interceptor.service.ts
30541
+ /** Tracks asynchronous resources registered by all interceptors for one print page. */
30542
+ var SheetPrintingResourceCollector = class {
30543
+ constructor() {
30544
+ _defineProperty(this, "_pending", /* @__PURE__ */ new Set());
30545
+ }
30546
+ add(resource) {
30547
+ const tracked = Promise.resolve(resource).catch(() => void 0).finally(() => this._pending.delete(tracked));
30548
+ this._pending.add(tracked);
30549
+ }
30550
+ async wait(timeout = 1e4) {
30551
+ const deadline = Date.now() + timeout;
30552
+ while (this._pending.size > 0) {
30553
+ const remaining = deadline - Date.now();
30554
+ if (remaining <= 0) return;
30555
+ let timeoutId;
30556
+ await Promise.race([Promise.allSettled(Array.from(this._pending)), new Promise((resolve) => {
30557
+ timeoutId = setTimeout(resolve, remaining);
30558
+ })]);
30559
+ if (timeoutId !== void 0) clearTimeout(timeoutId);
30560
+ }
30561
+ }
30562
+ };
29703
30563
  const PRINTING_RANGE = createInterceptorKey("PRINTING_RANGE");
29704
30564
  const PRINTING_COMPONENT_COLLECT = createInterceptorKey("PRINTING_COMPONENT_COLLECT");
29705
30565
  const PRINTING_DOM_COLLECT = createInterceptorKey("PRINTING_DOM_COLLECT");
@@ -30506,7 +31366,12 @@ let UniverSheetsMobileUIPlugin = class UniverSheetsMobileUIPlugin extends Plugin
30506
31366
  }
30507
31367
  _initAutoFocus() {
30508
31368
  const univerInstanceService = this._univerInstanceService;
30509
- this.disposeWithMe(univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(filter$1((v) => !!v)).subscribe((workbook) => univerInstanceService.focusUnit(workbook.getUnitId())));
31369
+ this.disposeWithMe(univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(filter$1((v) => !!v)).subscribe((workbook) => {
31370
+ const unitId = workbook.getUnitId();
31371
+ const createOptions = univerInstanceService.getUnitCreateOptions(unitId);
31372
+ if ((createOptions === null || createOptions === void 0 ? void 0 : createOptions.makeCurrent) === false) return;
31373
+ univerInstanceService.focusUnit(unitId);
31374
+ }));
30510
31375
  }
30511
31376
  };
30512
31377
  _defineProperty(UniverSheetsMobileUIPlugin, "pluginName", "SHEET_UI_PLUGIN");
@@ -30521,15 +31386,20 @@ UniverSheetsMobileUIPlugin = __decorate([
30521
31386
  __decorateParam(4, IUniverInstanceService)
30522
31387
  ], UniverSheetsMobileUIPlugin);
30523
31388
 
31389
+ //#endregion
31390
+ //#region src/services/sheet-host-chrome-override.service.ts
31391
+ const ISheetHostChromeOverrideService = createIdentifier("sheet-ui.host-chrome-override.service");
31392
+
30524
31393
  //#endregion
30525
31394
  //#region src/controllers/render-controllers/contextmenu.render-controller.ts
30526
31395
  let SheetContextMenuRenderController = class SheetContextMenuRenderController extends Disposable {
30527
- constructor(_context, _contextMenuService, _selectionManagerService, _selectionRenderService) {
31396
+ constructor(_context, _contextMenuService, _selectionManagerService, _selectionRenderService, _injector) {
30528
31397
  super();
30529
31398
  this._context = _context;
30530
31399
  this._contextMenuService = _contextMenuService;
30531
31400
  this._selectionManagerService = _selectionManagerService;
30532
31401
  this._selectionRenderService = _selectionRenderService;
31402
+ this._injector = _injector;
30533
31403
  this._init();
30534
31404
  }
30535
31405
  _init() {
@@ -30552,6 +31422,7 @@ let SheetContextMenuRenderController = class SheetContextMenuRenderController ex
30552
31422
  }
30553
31423
  };
30554
31424
  const triggerMenu = (position) => {
31425
+ if (this._shouldSuppressHostContextMenu()) return;
30555
31426
  this._contextMenuService.triggerContextMenu(event, position);
30556
31427
  };
30557
31428
  if (!isPointerInRange()) triggerMenu(ContextMenuPosition.MAIN_AREA);
@@ -30563,20 +31434,37 @@ let SheetContextMenuRenderController = class SheetContextMenuRenderController ex
30563
31434
  this.disposeWithMe(spreadsheetSubscription);
30564
31435
  const spreadsheetColumnHeader = this._context.components.get("__SpreadsheetColumnHeader__");
30565
31436
  const rowHeaderSub = this._context.components.get("__SpreadsheetRowHeader__").onPointerDown$.subscribeEvent((event) => {
30566
- if (event.button === 2) this._contextMenuService.triggerContextMenu(event, ContextMenuPosition.ROW_HEADER);
31437
+ if (event.button === 2) {
31438
+ if (this._shouldSuppressHostContextMenu()) return;
31439
+ this._contextMenuService.triggerContextMenu(event, ContextMenuPosition.ROW_HEADER);
31440
+ }
30567
31441
  });
30568
31442
  this.disposeWithMe(rowHeaderSub);
30569
31443
  const colHeaderObserver = spreadsheetColumnHeader.onPointerDown$.subscribeEvent((event) => {
30570
- if (event.button === 2) this._contextMenuService.triggerContextMenu(event, ContextMenuPosition.COL_HEADER);
31444
+ if (event.button === 2) {
31445
+ if (this._shouldSuppressHostContextMenu()) return;
31446
+ this._contextMenuService.triggerContextMenu(event, ContextMenuPosition.COL_HEADER);
31447
+ }
30571
31448
  });
30572
31449
  this.disposeWithMe(colHeaderObserver);
30573
31450
  }
31451
+ _shouldSuppressHostContextMenu() {
31452
+ var _this$_getSheetHostCh, _this$_getSheetHostCh2;
31453
+ 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));
31454
+ }
31455
+ _getSheetHostChromeOverrideService() {
31456
+ return this._injector.has(ISheetHostChromeOverrideService) ? this._injector.get(ISheetHostChromeOverrideService) : void 0;
31457
+ }
30574
31458
  };
30575
31459
  SheetContextMenuRenderController = __decorate([
30576
31460
  __decorateParam(1, IContextMenuService),
30577
31461
  __decorateParam(2, Inject(SheetsSelectionsService)),
30578
- __decorateParam(3, ISheetSelectionRenderService)
31462
+ __decorateParam(3, ISheetSelectionRenderService),
31463
+ __decorateParam(4, Inject(Injector))
30579
31464
  ], SheetContextMenuRenderController);
31465
+ function shouldSuppressSheetContextMenuForEmbedOverride(hostUnitId, override) {
31466
+ return override != null && override.hostUnitId === hostUnitId && override.entry === "sheets-sheet-tab";
31467
+ }
30580
31468
 
30581
31469
  //#endregion
30582
31470
  //#region src/controllers/repeat-last-action.controller.ts
@@ -31100,7 +31988,12 @@ let UniverSheetsUIPlugin = class UniverSheetsUIPlugin extends Plugin {
31100
31988
  }
31101
31989
  _initAutoFocus() {
31102
31990
  const univerInstanceService = this._univerInstanceService;
31103
- this.disposeWithMe(univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(filter$1((v) => !!v)).subscribe((workbook) => univerInstanceService.focusUnit(workbook.getUnitId())));
31991
+ this.disposeWithMe(univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(filter$1((v) => !!v)).subscribe((workbook) => {
31992
+ const unitId = workbook.getUnitId();
31993
+ const createOptions = univerInstanceService.getUnitCreateOptions(unitId);
31994
+ if ((createOptions === null || createOptions === void 0 ? void 0 : createOptions.makeCurrent) === false) return;
31995
+ univerInstanceService.focusUnit(unitId);
31996
+ }));
31104
31997
  }
31105
31998
  };
31106
31999
  _defineProperty(UniverSheetsUIPlugin, "pluginName", "SHEET_UI_PLUGIN");
@@ -31116,4 +32009,4 @@ UniverSheetsUIPlugin = __decorate([
31116
32009
  ], UniverSheetsUIPlugin);
31117
32010
 
31118
32011
  //#endregion
31119
- export { AddRangeProtectionFromContextMenuCommand, AddRangeProtectionFromSheetBarCommand, AddRangeProtectionFromToolbarCommand, ApplyFormatPainterCommand, AutoFillUIController, AutoHeightController, AutoWidthController, BaseSelectionRenderService, 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, ExpandSelectionCommand, FORMULA_CLIPBOARD_MIME_TYPE, FormatPainterStatus, FormulaEditorController, HEADER_UNHIDE_RANGE_VISIBLE_CHECK, HeaderFreezeRenderController, HeaderMoveRenderController, HeaderResizeRenderController, HeaderUnhideRangeAxis, HeaderUnhideRangeService, HeaderUnhideRenderController, HideColConfirmCommand, HideRowConfirmCommand, HoverManagerService, HoverRenderController, ICellEditorManagerService, IEditorBridgeService, IFormatPainterService, IFormulaEditorManagerService, IMarkSelectionService, IRepeatLastActionService, ISheetCellDropdownManagerService, ISheetClipboardService, 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, 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, SheetCanvasPopManagerService, SheetCellDropdownManagerService, SheetCellEditorResizeService, SheetClipboardController, SheetClipboardService, SheetCopyCommand, SheetCutCommand, SheetMenuPosition, SheetPasteBesidesBorderCommand, SheetPasteColWidthCommand, SheetPasteCommand, SheetPasteFormatCommand, SheetPasteShortKeyCommand, SheetPasteValueCommand, SheetPermissionCheckUIController, SheetPermissionOpenDialogOperation, SheetPermissionOpenPanelOperation, SheetPermissionRenderManagerService, SheetPermissionUserManagerService, SheetPrintInterceptorService, 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, useActiveWorkbook, useActiveWorksheet, useHighlightRange, useKeyEventConfig, useWorkbooks, virtualizeDiscreteRanges, whenFormulaEditorActivated, whenSheetEditorActivated, whenSheetEditorFocused };
32012
+ 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, 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 };