@univerjs/ui 1.0.0-alpha.2 → 1.0.0-alpha.4

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 (115) hide show
  1. package/lib/cjs/facade.js +2 -0
  2. package/lib/cjs/index.js +1174 -798
  3. package/lib/cjs/locale/ar-SA.js +11 -0
  4. package/lib/cjs/locale/ca-ES.js +11 -0
  5. package/lib/cjs/locale/de-DE.js +11 -0
  6. package/lib/cjs/locale/en-US.js +11 -0
  7. package/lib/cjs/locale/es-ES.js +11 -0
  8. package/lib/cjs/locale/fa-IR.js +11 -0
  9. package/lib/cjs/locale/fr-FR.js +11 -0
  10. package/lib/cjs/locale/id-ID.js +11 -0
  11. package/lib/cjs/locale/it-IT.js +11 -0
  12. package/lib/cjs/locale/ja-JP.js +11 -0
  13. package/lib/cjs/locale/ko-KR.js +11 -0
  14. package/lib/cjs/locale/pl-PL.js +11 -0
  15. package/lib/cjs/locale/pt-BR.js +11 -0
  16. package/lib/cjs/locale/ru-RU.js +11 -0
  17. package/lib/cjs/locale/sk-SK.js +11 -0
  18. package/lib/cjs/locale/vi-VN.js +11 -0
  19. package/lib/cjs/locale/zh-CN.js +11 -0
  20. package/lib/cjs/locale/zh-HK.js +11 -0
  21. package/lib/cjs/locale/zh-TW.js +11 -0
  22. package/lib/es/facade.js +2 -0
  23. package/lib/es/index.js +1168 -803
  24. package/lib/es/locale/ar-SA.js +11 -0
  25. package/lib/es/locale/ca-ES.js +11 -0
  26. package/lib/es/locale/de-DE.js +11 -0
  27. package/lib/es/locale/en-US.js +11 -0
  28. package/lib/es/locale/es-ES.js +11 -0
  29. package/lib/es/locale/fa-IR.js +11 -0
  30. package/lib/es/locale/fr-FR.js +11 -0
  31. package/lib/es/locale/id-ID.js +11 -0
  32. package/lib/es/locale/it-IT.js +11 -0
  33. package/lib/es/locale/ja-JP.js +11 -0
  34. package/lib/es/locale/ko-KR.js +11 -0
  35. package/lib/es/locale/pl-PL.js +11 -0
  36. package/lib/es/locale/pt-BR.js +11 -0
  37. package/lib/es/locale/ru-RU.js +11 -0
  38. package/lib/es/locale/sk-SK.js +11 -0
  39. package/lib/es/locale/vi-VN.js +11 -0
  40. package/lib/es/locale/zh-CN.js +11 -0
  41. package/lib/es/locale/zh-HK.js +11 -0
  42. package/lib/es/locale/zh-TW.js +11 -0
  43. package/lib/facade.js +2 -0
  44. package/lib/index.css +5 -12
  45. package/lib/index.js +1168 -803
  46. package/lib/locale/ar-SA.js +11 -0
  47. package/lib/locale/ca-ES.js +11 -0
  48. package/lib/locale/de-DE.js +11 -0
  49. package/lib/locale/en-US.js +11 -0
  50. package/lib/locale/es-ES.js +11 -0
  51. package/lib/locale/fa-IR.js +11 -0
  52. package/lib/locale/fr-FR.js +11 -0
  53. package/lib/locale/id-ID.js +11 -0
  54. package/lib/locale/it-IT.js +11 -0
  55. package/lib/locale/ja-JP.js +11 -0
  56. package/lib/locale/ko-KR.js +11 -0
  57. package/lib/locale/pl-PL.js +11 -0
  58. package/lib/locale/pt-BR.js +11 -0
  59. package/lib/locale/ru-RU.js +11 -0
  60. package/lib/locale/sk-SK.js +11 -0
  61. package/lib/locale/vi-VN.js +11 -0
  62. package/lib/locale/zh-CN.js +11 -0
  63. package/lib/locale/zh-HK.js +11 -0
  64. package/lib/locale/zh-TW.js +11 -0
  65. package/lib/types/commands/operations/toggle-fullscreen.operation.d.ts +17 -0
  66. package/lib/types/controllers/ui/ui-desktop.controller.d.ts +1 -3
  67. package/lib/types/controllers/ui/ui-mobile.controller.d.ts +1 -3
  68. package/lib/types/facade/f-menu-builder.d.ts +2 -0
  69. package/lib/types/index.d.ts +8 -3
  70. package/lib/types/locale/en-US.d.ts +13 -0
  71. package/lib/types/services/before-close/before-close.service.d.ts +3 -2
  72. package/lib/types/services/contextmenu/contextmenu.service.d.ts +6 -3
  73. package/lib/types/services/dom/canvas-dom-layer.service.d.ts +52 -1
  74. package/lib/types/services/menu/menu-manager.service.d.ts +1 -0
  75. package/lib/types/services/menu/menu.d.ts +3 -2
  76. package/lib/types/services/menu/types.d.ts +1 -0
  77. package/lib/types/services/popup/canvas-popup.service.d.ts +5 -1
  78. package/lib/types/services/ribbon/ribbon-override.service.d.ts +42 -0
  79. package/lib/types/services/runtime-scope/ui-runtime-scope.service.d.ts +32 -0
  80. package/lib/types/services/shortcut/shortcut.service.d.ts +2 -1
  81. package/lib/types/utils/embed-boundary.d.ts +23 -0
  82. package/lib/types/utils/index.d.ts +1 -0
  83. package/lib/types/views/components/context-menu/AnchoredContextMenu.d.ts +4 -0
  84. package/lib/types/views/components/context-menu/ContextMenuPanel.d.ts +4 -0
  85. package/lib/types/views/components/dom/FloatDom.d.ts +12 -1
  86. package/lib/types/views/components/dom/Print.d.ts +1 -1
  87. package/lib/types/views/components/dom/float-dom-layout.d.ts +35 -0
  88. package/lib/types/views/components/ribbon/Ribbon.d.ts +2 -0
  89. package/lib/types/views/components/ribbon/TooltipButtonWrapper.d.ts +6 -1
  90. package/lib/types/views/emoji-picker/emoji-picker-utils.d.ts +1 -1
  91. package/lib/types/views/index.d.ts +1 -1
  92. package/lib/types/views/menu/mobile/MobileMenu.d.ts +2 -0
  93. package/lib/types/views/slider/ZoomInput.d.ts +25 -0
  94. package/lib/types/views/slider/index.d.ts +1 -0
  95. package/lib/umd/index.js +15 -22
  96. package/lib/umd/locale/ar-SA.js +1 -1
  97. package/lib/umd/locale/ca-ES.js +1 -1
  98. package/lib/umd/locale/de-DE.js +1 -1
  99. package/lib/umd/locale/en-US.js +1 -1
  100. package/lib/umd/locale/es-ES.js +1 -1
  101. package/lib/umd/locale/fa-IR.js +1 -1
  102. package/lib/umd/locale/fr-FR.js +1 -1
  103. package/lib/umd/locale/id-ID.js +1 -1
  104. package/lib/umd/locale/it-IT.js +1 -1
  105. package/lib/umd/locale/ja-JP.js +1 -1
  106. package/lib/umd/locale/ko-KR.js +1 -1
  107. package/lib/umd/locale/pl-PL.js +1 -1
  108. package/lib/umd/locale/pt-BR.js +1 -1
  109. package/lib/umd/locale/ru-RU.js +1 -1
  110. package/lib/umd/locale/sk-SK.js +1 -1
  111. package/lib/umd/locale/vi-VN.js +1 -1
  112. package/lib/umd/locale/zh-CN.js +1 -1
  113. package/lib/umd/locale/zh-HK.js +1 -1
  114. package/lib/umd/locale/zh-TW.js +1 -1
  115. package/package.json +9 -9
package/lib/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { BaselineOffset, BorderStyleTypes, ColorKit, CommandType, DependentOn, Disposable, DocumentDataModel, DocumentFlavor, EDITOR_ACTIVATED, ErrorService, FOCUSING_FX_BAR_EDITOR, FOCUSING_UNIVER_EDITOR, ICommandService, IConfigService, IConfirmService, IContextService, ILocalStorageService, ILogService, IUndoRedoService, IUniverInstanceService, Inject, Injector, LifecycleService, LifecycleStages, LifecycleUnreachableError, LocaleService, NAMED_STYLE_MAP, NamedStyleType, Optional, Plugin, RedoCommand, ThemeService, Tools, UndoCommand, UniverInstanceType, Workbook, convertObservableToBehaviorSubject, createIdentifier, dedupeBy, generateRandomId, getBorderStyleType, isInternalEditorID, isRealNum, merge, mergeOverrideWithDependencies, registerDependencies, remove, throttle, toDisposable, touchDependencies } from "@univerjs/core";
2
- import { BehaviorSubject, Observable, Subject, animationFrameScheduler, combineLatest, debounceTime, distinctUntilChanged, filter, first, fromEvent, isObservable, map, merge as merge$1, of, scan, startWith, switchMap, throttleTime } from "rxjs";
1
+ import { BaselineOffset, BorderStyleTypes, ColorKit, CommandType, DependentOn, Disposable, DocumentDataModel, DocumentFlavor, EDITOR_ACTIVATED, ErrorService, FOCUSING_FX_BAR_EDITOR, FOCUSING_UNIVER_EDITOR, ICommandService, IConfigService, IConfirmService, IContextService, ILocalStorageService, ILogService, IUndoRedoService, IUniverInstanceService, Inject, Injector, LifecycleService, LifecycleStages, LifecycleUnreachableError, LocaleService, NAMED_STYLE_MAP, NamedStyleType, Optional, Plugin, RedoCommand, ThemeService, Tools, UndoCommand, UniverInstanceType, Workbook, createIdentifier, dedupeBy, generateRandomId, getBorderStyleType, isInternalEditorID, isRealNum, merge, mergeOverrideWithDependencies, registerDependencies, remove, throttle, toDisposable, touchDependencies } from "@univerjs/core";
2
+ import { BehaviorSubject, EMPTY, Observable, Subject, animationFrameScheduler, combineLatest, debounceTime, distinctUntilChanged, filter, first, fromEvent, isObservable, map, merge as merge$1, of, scan, startWith, switchMap, throttleTime } from "rxjs";
3
3
  import { Fragment, cloneElement, createContext, createElement, forwardRef, memo, useCallback, useContext, useDeferredValue, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
4
4
  import { Button, ColorPicker, ConfigContext, ConfigProvider, Confirm, Dialog, Dropdown, DropdownMenu, Gallery, HoverCard, Input, InputNumber, KBD, MessageType, Messager, Popup, Toaster, Tooltip, borderBottomClassName, borderClassName, borderLeftBottomClassName, borderRightClassName, borderTopClassName, clsx, cva, divideXClassName, divideYClassName, isBrowser, message, removeMessage, render, resetButtonClassName, resizeObserverCtor, scrollbarClassName, toast, unmount } from "@univerjs/design";
5
5
  import { IRenderManagerService, UniverRenderEnginePlugin, ptToPx } from "@univerjs/engine-render";
@@ -7,8 +7,49 @@ import { distinctUntilChanged as distinctUntilChanged$1, map as map$1, scan as s
7
7
  import { RediConsumer, RediContext, RediProvider, WithDependency, connectDependencies, connectInjector, useDependency, useDependency as useDependency$1, useInjector, useObservable, useUpdateBinder } from "@wendellhu/redi/react-bindings";
8
8
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { createPortal } from "react-dom";
10
- import { ActivityIcon, CheckMarkIcon, CloseIcon, DatabaseIcon, EyeIcon, FoodsIcon, FunctionIcon, HomeIcon, IncreaseIcon, InfoIcon, InsertIcon, MoreDownIcon, MoreLeftIcon, MoreRightIcon, MoreVerticalIcon, NatureIcon, ObjectsIcon, PeopleIcon, PlacesIcon, RandomIcon, RecentIcon, RedoIcon, ReduceIcon, SearchIcon, ShortcutIcon, SymbolsIcon, UndoIcon } from "@univerjs/icons";
10
+ import { ActivityIcon, CheckMarkIcon, CloseIcon, DatabaseIcon, ExpandIcon, EyeIcon, FoodsIcon, FunctionIcon, HomeIcon, IncreaseIcon, InfoIcon, InsertIcon, MoreDownIcon, MoreLeftIcon, MoreRightIcon, MoreVerticalIcon, NatureIcon, ObjectsIcon, PeopleIcon, PlacesIcon, RandomIcon, RecentIcon, RedoIcon, ReduceIcon, SearchIcon, ShortcutIcon, ShrinkIcon, SymbolsIcon, UndoIcon } from "@univerjs/icons";
11
11
 
12
+ //#region src/utils/embed-boundary.ts
13
+ /**
14
+ * Copyright 2023-present DreamNum Co., Ltd.
15
+ *
16
+ * Licensed under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this file except in compliance with the License.
18
+ * You may obtain a copy of the License at
19
+ *
20
+ * http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software
23
+ * distributed under the License is distributed on an "AS IS" BASIS,
24
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
+ * See the License for the specific language governing permissions and
26
+ * limitations under the License.
27
+ */
28
+ const EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
29
+ function getEmbedBoundaryOwner(target) {
30
+ var _ref, _getAttributeValue;
31
+ if (!hasClosest(target)) return;
32
+ const ownerElement = target.closest(`[${EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE}]`);
33
+ return (_ref = (_getAttributeValue = getAttributeValue(target, "data-embed-interaction-boundary-owner")) !== null && _getAttributeValue !== void 0 ? _getAttributeValue : getAttributeValue(ownerElement, "data-embed-interaction-boundary-owner")) !== null && _ref !== void 0 ? _ref : void 0;
34
+ }
35
+ function isEmbedBoundaryTarget(target) {
36
+ return hasClosest(target) && target.closest(`[${"data-embed-interaction-boundary-owner"}]`) != null;
37
+ }
38
+ function keepInteractionInsideSameEmbedBoundary(event) {
39
+ const owner = getEmbedBoundaryOwner(event.currentTarget);
40
+ if (!owner) return;
41
+ if (getEmbedBoundaryOwner(event.target) === owner) event.preventDefault();
42
+ }
43
+ function hasClosest(target) {
44
+ return !!target && typeof target.closest === "function";
45
+ }
46
+ function getAttributeValue(target, name) {
47
+ var _getAttribute$call;
48
+ const getAttribute = target === null || target === void 0 ? void 0 : target.getAttribute;
49
+ return typeof getAttribute === "function" ? (_getAttribute$call = getAttribute.call(target, name)) !== null && _getAttribute$call !== void 0 ? _getAttribute$call : void 0 : void 0;
50
+ }
51
+
52
+ //#endregion
12
53
  //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
13
54
  function _typeof(o) {
14
55
  "@babel/helpers - typeof";
@@ -50,6 +91,157 @@ function _defineProperty(e, r, t) {
50
91
  }) : e[r] = t, e;
51
92
  }
52
93
 
94
+ //#endregion
95
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
96
+ function __decorateParam(paramIndex, decorator) {
97
+ return function(target, key) {
98
+ decorator(target, key, paramIndex);
99
+ };
100
+ }
101
+
102
+ //#endregion
103
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
104
+ function __decorate(decorators, target, key, desc) {
105
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
106
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
107
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
108
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
109
+ }
110
+
111
+ //#endregion
112
+ //#region src/services/layout/layout.service.ts
113
+ const FOCUSING_UNIVER = "FOCUSING_UNIVER";
114
+ const givingBackFocusElements = [
115
+ "app-layout",
116
+ "button",
117
+ "sheet-bar-append-button",
118
+ "render-canvas",
119
+ "workbench-layout"
120
+ ];
121
+ const ILayoutService = createIdentifier("ui.layout-service");
122
+ let DesktopLayoutService = class DesktopLayoutService extends Disposable {
123
+ get isFocused() {
124
+ return this._isFocused;
125
+ }
126
+ constructor(_contextService, _univerInstanceService) {
127
+ super();
128
+ this._contextService = _contextService;
129
+ this._univerInstanceService = _univerInstanceService;
130
+ _defineProperty(this, "_rootContainerElement", null);
131
+ _defineProperty(this, "_isFocused", false);
132
+ _defineProperty(this, "_focusHandlers", /* @__PURE__ */ new Map());
133
+ _defineProperty(this, "_contentElements", []);
134
+ _defineProperty(this, "_allContainers", []);
135
+ this._initUniverFocusListener();
136
+ this._initEditorStatus();
137
+ }
138
+ get rootContainerElement() {
139
+ return this._rootContainerElement;
140
+ }
141
+ focus() {
142
+ const currentFocused = this._univerInstanceService.getFocusedUnit();
143
+ if (!currentFocused) return;
144
+ let handler;
145
+ if (currentFocused instanceof Workbook) handler = this._focusHandlers.get(UniverInstanceType.UNIVER_SHEET);
146
+ else if (currentFocused instanceof DocumentDataModel) handler = this._focusHandlers.get(UniverInstanceType.UNIVER_DOC);
147
+ else if ((currentFocused === null || currentFocused === void 0 ? void 0 : currentFocused.type) === UniverInstanceType.UNIVER_SLIDE) handler = this._focusHandlers.get(UniverInstanceType.UNIVER_SLIDE);
148
+ if (handler) handler(currentFocused.getUnitId());
149
+ }
150
+ registerFocusHandler(type, handler) {
151
+ if (this._focusHandlers.has(type)) throw new Error(`[DesktopLayoutService]: handler of type ${type} bas been registered!`);
152
+ this._focusHandlers.set(type, handler);
153
+ return toDisposable(() => this._focusHandlers.delete(type));
154
+ }
155
+ registerContentElement(container) {
156
+ if (this._contentElements.indexOf(container) === -1) {
157
+ this._contentElements.push(container);
158
+ return toDisposable(() => remove(this._contentElements, container));
159
+ }
160
+ throw new Error("[DesktopLayoutService]: content container already registered!");
161
+ }
162
+ getContentElement() {
163
+ return this._contentElements[0];
164
+ }
165
+ registerRootContainerElement(container) {
166
+ if (this._rootContainerElement) throw new Error("[DesktopLayoutService]: root container already registered!");
167
+ this._rootContainerElement = container;
168
+ const dis = this.registerContainerElement(container);
169
+ return toDisposable(() => {
170
+ this._rootContainerElement = null;
171
+ dis.dispose();
172
+ });
173
+ }
174
+ registerContainerElement(container) {
175
+ if (this._allContainers.indexOf(container) === -1) {
176
+ this._allContainers.push(container);
177
+ return toDisposable(() => remove(this._allContainers, container));
178
+ }
179
+ throw new Error("[LayoutService]: container already registered!");
180
+ }
181
+ checkElementInCurrentContainers(element) {
182
+ return this._allContainers.some((container) => container.contains(element));
183
+ }
184
+ checkContentIsFocused() {
185
+ return this._contentElements.some((contentEl) => contentEl === document.activeElement || contentEl.contains(document.activeElement));
186
+ }
187
+ _initUniverFocusListener() {
188
+ this.disposeWithMe(fromEvent(window, "focusin").subscribe((event) => {
189
+ var _this$_rootContainerE;
190
+ const target = event.target;
191
+ if (((_this$_rootContainerE = this._rootContainerElement) === null || _this$_rootContainerE === void 0 ? void 0 : _this$_rootContainerE.contains(target)) && givingBackFocusElements.some((item) => target.dataset.uComp === item) && !isEmbedBoundaryTarget(target)) {
192
+ queueMicrotask(() => {
193
+ const targetUnitId = getFocusUnitIdFromElement(target);
194
+ if (targetUnitId && this._univerInstanceService.getUnit(targetUnitId)) this._univerInstanceService.focusUnit(targetUnitId);
195
+ this.focus();
196
+ this._isFocused = true;
197
+ this._contextService.setContextValue(FOCUSING_UNIVER, this._isFocused);
198
+ this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());
199
+ });
200
+ return;
201
+ }
202
+ if (target && this.checkElementInCurrentContainers(target)) this._isFocused = true;
203
+ else this._isFocused = false;
204
+ this._contextService.setContextValue(FOCUSING_UNIVER, this._isFocused);
205
+ this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());
206
+ }));
207
+ }
208
+ _initEditorStatus() {
209
+ this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());
210
+ }
211
+ };
212
+ DesktopLayoutService = __decorate([__decorateParam(0, IContextService), __decorateParam(1, IUniverInstanceService)], DesktopLayoutService);
213
+ function getFocusingUniverEditorStatus() {
214
+ var _document$activeEleme;
215
+ return ((_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.dataset.uComp) === "editor";
216
+ }
217
+ function getFocusUnitIdFromElement(target) {
218
+ return target.dataset.uUnitId;
219
+ }
220
+
221
+ //#endregion
222
+ //#region src/commands/operations/toggle-fullscreen.operation.ts
223
+ const ToggleFullscreenOperation = {
224
+ id: "base-ui.operation.toggle-fullscreen",
225
+ type: CommandType.OPERATION,
226
+ handler: (accessor) => {
227
+ const root = accessor.get(ILayoutService).rootContainerElement;
228
+ if (!root) return false;
229
+ const document = root.ownerDocument;
230
+ try {
231
+ if (document.fullscreenElement) {
232
+ if (!document.exitFullscreen) return false;
233
+ document.exitFullscreen().catch(() => {});
234
+ } else {
235
+ if (!root.requestFullscreen) return false;
236
+ root.requestFullscreen().catch(() => {});
237
+ }
238
+ return true;
239
+ } catch {
240
+ return false;
241
+ }
242
+ }
243
+ };
244
+
53
245
  //#endregion
54
246
  //#region src/services/shortcut/shortcut-panel.service.ts
55
247
  /**
@@ -117,23 +309,6 @@ const ToggleShortcutPanelOperation = {
117
309
  }
118
310
  };
119
311
 
120
- //#endregion
121
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
122
- function __decorateParam(paramIndex, decorator) {
123
- return function(target, key) {
124
- decorator(target, key, paramIndex);
125
- };
126
- }
127
-
128
- //#endregion
129
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
130
- function __decorate(decorators, target, key, desc) {
131
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
132
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
133
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
134
- return c > 3 && r && Object.defineProperty(target, key, r), r;
135
- }
136
-
137
312
  //#endregion
138
313
  //#region src/common/component-manager.ts
139
314
  let ComponentManager = class ComponentManager extends Disposable {
@@ -624,106 +799,6 @@ function fromGlobalEvent(type, listener, options) {
624
799
  return toDisposable(() => window.removeEventListener(type, listener, options));
625
800
  }
626
801
 
627
- //#endregion
628
- //#region src/services/layout/layout.service.ts
629
- const FOCUSING_UNIVER = "FOCUSING_UNIVER";
630
- const givingBackFocusElements = [
631
- "app-layout",
632
- "button",
633
- "sheet-bar-append-button",
634
- "render-canvas",
635
- "workbench-layout"
636
- ];
637
- const ILayoutService = createIdentifier("ui.layout-service");
638
- let DesktopLayoutService = class DesktopLayoutService extends Disposable {
639
- get isFocused() {
640
- return this._isFocused;
641
- }
642
- constructor(_contextService, _univerInstanceService) {
643
- super();
644
- this._contextService = _contextService;
645
- this._univerInstanceService = _univerInstanceService;
646
- _defineProperty(this, "_rootContainerElement", null);
647
- _defineProperty(this, "_isFocused", false);
648
- _defineProperty(this, "_focusHandlers", /* @__PURE__ */ new Map());
649
- _defineProperty(this, "_contentElements", []);
650
- _defineProperty(this, "_allContainers", []);
651
- this._initUniverFocusListener();
652
- this._initEditorStatus();
653
- }
654
- get rootContainerElement() {
655
- return this._rootContainerElement;
656
- }
657
- focus() {
658
- const currentFocused = this._univerInstanceService.getFocusedUnit();
659
- if (!currentFocused) return;
660
- let handler;
661
- if (currentFocused instanceof Workbook) handler = this._focusHandlers.get(UniverInstanceType.UNIVER_SHEET);
662
- else if (currentFocused instanceof DocumentDataModel) handler = this._focusHandlers.get(UniverInstanceType.UNIVER_DOC);
663
- else if ((currentFocused === null || currentFocused === void 0 ? void 0 : currentFocused.type) === UniverInstanceType.UNIVER_SLIDE) handler = this._focusHandlers.get(UniverInstanceType.UNIVER_SLIDE);
664
- if (handler) handler(currentFocused.getUnitId());
665
- }
666
- registerFocusHandler(type, handler) {
667
- if (this._focusHandlers.has(type)) throw new Error(`[DesktopLayoutService]: handler of type ${type} bas been registered!`);
668
- this._focusHandlers.set(type, handler);
669
- return toDisposable(() => this._focusHandlers.delete(type));
670
- }
671
- registerContentElement(container) {
672
- if (this._contentElements.indexOf(container) === -1) {
673
- this._contentElements.push(container);
674
- return toDisposable(() => remove(this._contentElements, container));
675
- }
676
- throw new Error("[DesktopLayoutService]: content container already registered!");
677
- }
678
- getContentElement() {
679
- return this._contentElements[0];
680
- }
681
- registerRootContainerElement(container) {
682
- if (this._rootContainerElement) throw new Error("[DesktopLayoutService]: root container already registered!");
683
- this._rootContainerElement = container;
684
- const dis = this.registerContainerElement(container);
685
- return toDisposable(() => {
686
- this._rootContainerElement = null;
687
- dis.dispose();
688
- });
689
- }
690
- registerContainerElement(container) {
691
- if (this._allContainers.indexOf(container) === -1) {
692
- this._allContainers.push(container);
693
- return toDisposable(() => remove(this._allContainers, container));
694
- }
695
- throw new Error("[LayoutService]: container already registered!");
696
- }
697
- checkElementInCurrentContainers(element) {
698
- return this._allContainers.some((container) => container.contains(element));
699
- }
700
- checkContentIsFocused() {
701
- return this._contentElements.some((contentEl) => contentEl === document.activeElement || contentEl.contains(document.activeElement));
702
- }
703
- _initUniverFocusListener() {
704
- this.disposeWithMe(fromEvent(window, "focusin").subscribe((event) => {
705
- var _this$_rootContainerE;
706
- const target = event.target;
707
- if (((_this$_rootContainerE = this._rootContainerElement) === null || _this$_rootContainerE === void 0 ? void 0 : _this$_rootContainerE.contains(target)) && givingBackFocusElements.some((item) => target.dataset.uComp === item)) {
708
- queueMicrotask(() => this.focus());
709
- return;
710
- }
711
- if (target && this.checkElementInCurrentContainers(target)) this._isFocused = true;
712
- else this._isFocused = false;
713
- this._contextService.setContextValue(FOCUSING_UNIVER, this._isFocused);
714
- this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());
715
- }));
716
- }
717
- _initEditorStatus() {
718
- this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());
719
- }
720
- };
721
- DesktopLayoutService = __decorate([__decorateParam(0, IContextService), __decorateParam(1, IUniverInstanceService)], DesktopLayoutService);
722
- function getFocusingUniverEditorStatus() {
723
- var _document$activeEleme;
724
- return ((_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.dataset.uComp) === "editor";
725
- }
726
-
727
802
  //#endregion
728
803
  //#region src/services/platform/platform.service.ts
729
804
  /**
@@ -844,6 +919,7 @@ let ShortcutService = class ShortcutService extends Disposable {
844
919
  if (this._layoutService && !this._layoutService.checkElementInCurrentContainers(e.target)) return;
845
920
  const binding = this._deriveBindingFromEvent(e);
846
921
  if (binding === null) return;
922
+ if (this._shouldLetEmbedTextEditorHandleNativeShortcut(e, binding)) return;
847
923
  const shortcuts = this._shortCutMapping.get(binding);
848
924
  if (shortcuts === void 0) return;
849
925
  return Array.from(shortcuts).sort((s1, s2) => {
@@ -869,6 +945,12 @@ let ShortcutService = class ShortcutService extends Disposable {
869
945
  if (this._platformService.isMac && e.ctrlKey) binding |= 8192;
870
946
  return binding;
871
947
  }
948
+ _shouldLetEmbedTextEditorHandleNativeShortcut(e, binding) {
949
+ if (binding !== (65 | 4096)) return false;
950
+ const target = e.target;
951
+ if (!(target instanceof HTMLElement)) return false;
952
+ return (target.isContentEditable || target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) && isEmbedBoundaryTarget(target);
953
+ }
872
954
  };
873
955
  ShortcutService = __decorate([
874
956
  __decorateParam(0, ICommandService),
@@ -940,6 +1022,7 @@ let SharedController = class SharedController extends Disposable {
940
1022
  this._registerShortcuts();
941
1023
  }
942
1024
  _registerCommands() {
1025
+ this.disposeWithMe(this._commandService.registerCommand(ToggleFullscreenOperation));
943
1026
  [
944
1027
  CutCommand,
945
1028
  CopyCommand,
@@ -994,6 +1077,7 @@ let RibbonStartGroup = /* @__PURE__ */ function(RibbonStartGroup) {
994
1077
  }({});
995
1078
  let RibbonInsertGroup = /* @__PURE__ */ function(RibbonInsertGroup) {
996
1079
  RibbonInsertGroup["EDIT"] = "ribbon.insert.edit";
1080
+ RibbonInsertGroup["CELL"] = "ribbon.insert.cell";
997
1081
  RibbonInsertGroup["MEDIA"] = "ribbon.insert.media";
998
1082
  RibbonInsertGroup["OTHERS"] = "ribbon.insert.others";
999
1083
  return RibbonInsertGroup;
@@ -1050,8 +1134,9 @@ let ContextMenuGroup = /* @__PURE__ */ function(ContextMenuGroup) {
1050
1134
 
1051
1135
  //#endregion
1052
1136
  //#region src/services/menu/menu-manager.service.ts
1137
+ var _MenuManagerService;
1053
1138
  const IMenuManagerService = createIdentifier("univer.menu-manager-service");
1054
- let MenuManagerService = class MenuManagerService extends Disposable {
1139
+ let MenuManagerService = _MenuManagerService = class MenuManagerService extends Disposable {
1055
1140
  constructor(_injector, _configService) {
1056
1141
  super();
1057
1142
  this._injector = _injector;
@@ -1072,7 +1157,8 @@ let MenuManagerService = class MenuManagerService extends Disposable {
1072
1157
  title: "ui.ribbon.insert",
1073
1158
  ["ribbon.insert.edit"]: { order: 0 },
1074
1159
  ["ribbon.insert.media"]: { order: 1 },
1075
- ["ribbon.insert.others"]: { order: 2 }
1160
+ ["ribbon.insert.cell"]: { order: 2 },
1161
+ ["ribbon.insert.others"]: { order: 3 }
1076
1162
  },
1077
1163
  ["ribbon.formulas"]: {
1078
1164
  order: 2,
@@ -1185,6 +1271,21 @@ let MenuManagerService = class MenuManagerService extends Disposable {
1185
1271
  this._menu = merge({}, this._menu, source);
1186
1272
  this.menuChanged$.next();
1187
1273
  }
1274
+ createScoped(injector) {
1275
+ const root = this;
1276
+ const createScopedBuilder = () => {
1277
+ const service = new _MenuManagerService(injector, root._configService);
1278
+ service._menu = root._menu;
1279
+ return service;
1280
+ };
1281
+ return {
1282
+ menuChanged$: root.menuChanged$,
1283
+ mergeMenu: (source, target) => root.mergeMenu(source, target),
1284
+ appendRootMenu: (source) => root.appendRootMenu(source),
1285
+ getMenuByPositionKey: (position) => createScopedBuilder().getMenuByPositionKey(position),
1286
+ getFlatMenuByPositionKey: (position) => createScopedBuilder().getFlatMenuByPositionKey(position)
1287
+ };
1288
+ }
1188
1289
  _buildMenuSchema(data) {
1189
1290
  const result = [];
1190
1291
  for (const [key, value] of Object.entries(data)) {
@@ -1224,6 +1325,7 @@ let MenuManagerService = class MenuManagerService extends Disposable {
1224
1325
  * @returns Menu schema array or empty array if not found
1225
1326
  */
1226
1327
  getMenuByPositionKey(key) {
1328
+ var _findKey;
1227
1329
  const findKey = (obj) => {
1228
1330
  if (key in obj) return this._buildMenuSchema(obj[key]);
1229
1331
  for (const k in obj) {
@@ -1234,7 +1336,7 @@ let MenuManagerService = class MenuManagerService extends Disposable {
1234
1336
  }
1235
1337
  }
1236
1338
  };
1237
- return findKey(this._menu);
1339
+ return (_findKey = findKey(this._menu)) !== null && _findKey !== void 0 ? _findKey : [];
1238
1340
  }
1239
1341
  /**
1240
1342
  * Get flat menu schema by position key
@@ -1256,7 +1358,7 @@ let MenuManagerService = class MenuManagerService extends Disposable {
1256
1358
  return flatMenuItems(menu);
1257
1359
  }
1258
1360
  };
1259
- MenuManagerService = __decorate([__decorateParam(0, Inject(Injector)), __decorateParam(1, IConfigService)], MenuManagerService);
1361
+ MenuManagerService = _MenuManagerService = __decorate([__decorateParam(0, Inject(Injector)), __decorateParam(1, IConfigService)], MenuManagerService);
1260
1362
  function normalizeMenuOrder(order) {
1261
1363
  return order !== null && order !== void 0 ? order : 0;
1262
1364
  }
@@ -1333,11 +1435,14 @@ const undoRedoDisableFactory$ = (accessor, isUndo) => {
1333
1435
  return undoDisable || contextService.getContextValue(EDITOR_ACTIVATED) || contextService.getContextValue(FOCUSING_FX_BAR_EDITOR);
1334
1436
  }));
1335
1437
  };
1438
+ const rtlIconFactory$ = (accessor, ltrIcon, rtlIcon) => {
1439
+ return accessor.get(LocaleService).direction$.pipe(map$1((direction) => direction === "rtl" ? rtlIcon : ltrIcon));
1440
+ };
1336
1441
  function UndoMenuItemFactory(accessor) {
1337
1442
  return {
1338
1443
  id: UndoCommand.id,
1339
1444
  type: 0,
1340
- icon: "UndoIcon",
1445
+ icon: rtlIconFactory$(accessor, "UndoIcon", "RedoIcon"),
1341
1446
  title: "ui.shortcut.undo",
1342
1447
  tooltip: "ui.shortcut.undo",
1343
1448
  disabled$: undoRedoDisableFactory$(accessor, true)
@@ -1347,7 +1452,7 @@ function RedoMenuItemFactory(accessor) {
1347
1452
  return {
1348
1453
  id: RedoCommand.id,
1349
1454
  type: 0,
1350
- icon: "RedoIcon",
1455
+ icon: rtlIconFactory$(accessor, "RedoIcon", "UndoIcon"),
1351
1456
  title: "ui.shortcut.redo",
1352
1457
  tooltip: "ui.shortcut.redo",
1353
1458
  disabled$: undoRedoDisableFactory$(accessor, false)
@@ -1468,8 +1573,15 @@ function useObservableRef(observable, defaultValue) {
1468
1573
 
1469
1574
  //#endregion
1470
1575
  //#region src/services/dom/canvas-dom-layer.service.ts
1471
- var CanvasFloatDomService = class {
1472
- constructor() {
1576
+ function shouldForwardFloatDomEvents(layer) {
1577
+ return layer.eventPassThrough !== false;
1578
+ }
1579
+ function shouldRenderFloatDomLayer(layer, currentUnitId) {
1580
+ return layer.unitId === currentUnitId || layer.preserveOnFocusChange === true;
1581
+ }
1582
+ var CanvasFloatDomService = class extends Disposable {
1583
+ constructor(..._args) {
1584
+ super(..._args);
1473
1585
  _defineProperty(this, "_domLayerMap", /* @__PURE__ */ new Map());
1474
1586
  _defineProperty(this, "_domLayers$", new BehaviorSubject([]));
1475
1587
  _defineProperty(this, "domLayers$", this._domLayers$.asObservable());
@@ -1500,68 +1612,147 @@ var CanvasFloatDomService = class {
1500
1612
  this._domLayerMap.clear();
1501
1613
  this._notice();
1502
1614
  }
1615
+ dispose() {
1616
+ this._domLayerMap.clear();
1617
+ this._domLayers$.next([]);
1618
+ this._domLayers$.complete();
1619
+ super.dispose();
1620
+ }
1621
+ };
1622
+ var CanvasFloatDomPreviewService = class extends Disposable {
1623
+ constructor(..._args2) {
1624
+ super(..._args2);
1625
+ _defineProperty(this, "previewUpdated$", new Subject());
1626
+ _defineProperty(this, "previewRequested$", new Subject());
1627
+ _defineProperty(this, "_previewMap", /* @__PURE__ */ new Map());
1628
+ _defineProperty(this, "_requestMap", /* @__PURE__ */ new Map());
1629
+ }
1630
+ getPreview(id) {
1631
+ return this._previewMap.get(id);
1632
+ }
1633
+ getPendingRequests() {
1634
+ return Array.from(this._requestMap.values());
1635
+ }
1636
+ setPreview(preview) {
1637
+ this._previewMap.set(preview.id, preview);
1638
+ this._requestMap.delete(preview.id);
1639
+ this.previewUpdated$.next(preview);
1640
+ }
1641
+ removePreview(id) {
1642
+ this._previewMap.delete(id);
1643
+ this._requestMap.delete(id);
1644
+ }
1645
+ requestPreview(request) {
1646
+ this._requestMap.set(request.id, request);
1647
+ this.previewRequested$.next(request);
1648
+ }
1649
+ dispose() {
1650
+ this._previewMap.clear();
1651
+ this._requestMap.clear();
1652
+ this.previewUpdated$.complete();
1653
+ this.previewRequested$.complete();
1654
+ super.dispose();
1655
+ }
1503
1656
  };
1504
1657
 
1658
+ //#endregion
1659
+ //#region src/views/components/dom/float-dom-layout.ts
1660
+ const LEGACY_WRAPPER_INSET = 2;
1661
+ const LEGACY_CONTENT_INSET = 4;
1662
+ function resolveFloatDomLayout(position, contentBox) {
1663
+ var _contentBox$wrapperIn, _contentBox$contentIn, _position$opacity;
1664
+ const wrapperInset = (_contentBox$wrapperIn = contentBox === null || contentBox === void 0 ? void 0 : contentBox.wrapperInset) !== null && _contentBox$wrapperIn !== void 0 ? _contentBox$wrapperIn : LEGACY_WRAPPER_INSET;
1665
+ const contentInset = (_contentBox$contentIn = contentBox === null || contentBox === void 0 ? void 0 : contentBox.contentInset) !== null && _contentBox$contentIn !== void 0 ? _contentBox$contentIn : LEGACY_CONTENT_INSET;
1666
+ return {
1667
+ wrapper: {
1668
+ top: position.startY,
1669
+ left: position.startX,
1670
+ width: Math.max(position.endX - position.startX - wrapperInset, 0),
1671
+ height: Math.max(position.endY - position.startY - wrapperInset, 0),
1672
+ transform: `rotate(${position.rotate}deg)`,
1673
+ opacity: (_position$opacity = position.opacity) !== null && _position$opacity !== void 0 ? _position$opacity : 1
1674
+ },
1675
+ inner: {
1676
+ width: position.width - contentInset,
1677
+ height: position.height - contentInset,
1678
+ left: position.absolute.left ? 0 : "auto",
1679
+ top: position.absolute.top ? 0 : "auto",
1680
+ right: position.absolute.left ? "auto" : 0,
1681
+ bottom: position.absolute.top ? "auto" : 0
1682
+ }
1683
+ };
1684
+ }
1685
+
1505
1686
  //#endregion
1506
1687
  //#region src/views/components/dom/FloatDom.tsx
1688
+ function applyFloatDomLayout(wrapper, inner, layout) {
1689
+ const { wrapper: wrapperLayout, inner: innerLayout } = layout;
1690
+ const wrapperStyle = wrapper.style;
1691
+ wrapperStyle.top = `${wrapperLayout.top}px`;
1692
+ wrapperStyle.left = `${wrapperLayout.left}px`;
1693
+ wrapperStyle.width = `${wrapperLayout.width}px`;
1694
+ wrapperStyle.height = `${wrapperLayout.height}px`;
1695
+ wrapperStyle.transform = wrapperLayout.transform;
1696
+ wrapperStyle.opacity = `${wrapperLayout.opacity}`;
1697
+ const innerStyle = inner.style;
1698
+ innerStyle.width = `${innerLayout.width}px`;
1699
+ innerStyle.height = `${innerLayout.height}px`;
1700
+ innerStyle.left = innerLayout.left === "auto" ? "auto" : `${innerLayout.left}px`;
1701
+ innerStyle.top = innerLayout.top === "auto" ? "auto" : `${innerLayout.top}px`;
1702
+ innerStyle.right = innerLayout.right === "auto" ? "auto" : `${innerLayout.right}px`;
1703
+ innerStyle.bottom = innerLayout.bottom === "auto" ? "auto" : `${innerLayout.bottom}px`;
1704
+ }
1507
1705
  const FloatDomSingle = memo((props) => {
1508
- var _position$startY, _position$startX;
1509
- const { layer, id } = props;
1510
- const size$ = useMemo(() => layer.position$.pipe(distinctUntilChanged((prev, curr) => prev.absolute.left === curr.absolute.left && prev.absolute.top === curr.absolute.top && prev.endX - prev.startX === curr.endX - curr.startX && prev.endY - prev.startY === curr.endY - curr.startY)), [layer.position$]);
1706
+ const { layer } = props;
1707
+ return typeof layer.componentKey === "string" ? /* @__PURE__ */ jsx(RegisteredFloatDomSingle, {
1708
+ ...props,
1709
+ componentKey: layer.componentKey
1710
+ }) : /* @__PURE__ */ jsx(FloatDomSingleContent, {
1711
+ ...props,
1712
+ Component: layer.componentKey
1713
+ });
1714
+ });
1715
+ function RegisteredFloatDomSingle(props) {
1716
+ const componentManager = useDependency(ComponentManager);
1717
+ return /* @__PURE__ */ jsx(FloatDomSingleContent, {
1718
+ ...props,
1719
+ Component: componentManager.get(props.componentKey)
1720
+ });
1721
+ }
1722
+ function FloatDomSingleContent(props) {
1723
+ var _layer$contentBox, _layer$contentBox2;
1724
+ const { layer, id, Component } = props;
1511
1725
  const univerInstanceService = useDependency(IUniverInstanceService);
1512
1726
  const position = useObservable(useMemo(() => layer.position$.pipe(first()), [layer.position$]));
1513
1727
  const domRef = useRef(null);
1514
1728
  const innerDomRef = useRef(null);
1515
- const transformRef = useRef(`transform: rotate(${position === null || position === void 0 ? void 0 : position.rotate}deg) translate(${position === null || position === void 0 ? void 0 : position.startX}px, ${position === null || position === void 0 ? void 0 : position.startY}px)`);
1516
- const topRef = useRef((_position$startY = position === null || position === void 0 ? void 0 : position.startY) !== null && _position$startY !== void 0 ? _position$startY : 0);
1517
- const leftRef = useRef((_position$startX = position === null || position === void 0 ? void 0 : position.startX) !== null && _position$startX !== void 0 ? _position$startX : 0);
1518
- const innerStyle = useRef({});
1519
- const Component = typeof layer.componentKey === "string" ? useDependency(ComponentManager).get(layer.componentKey) : layer.componentKey;
1520
1729
  const layerProps = useMemo(() => ({
1521
1730
  data: layer.data,
1522
- ...layer.props
1523
- }), [layer.data, layer.props]);
1731
+ ...layer.props,
1732
+ hostFloatDomLayout$: layer.position$
1733
+ }), [
1734
+ layer.data,
1735
+ layer.position$,
1736
+ layer.props
1737
+ ]);
1738
+ const floatDomOverflow = resolveFloatDomOverflow(layerProps);
1739
+ const wrapperInset = (_layer$contentBox = layer.contentBox) === null || _layer$contentBox === void 0 ? void 0 : _layer$contentBox.wrapperInset;
1740
+ const contentInset = (_layer$contentBox2 = layer.contentBox) === null || _layer$contentBox2 === void 0 ? void 0 : _layer$contentBox2.contentInset;
1524
1741
  useEffect(() => {
1525
1742
  const subscription = layer.position$.subscribe((position) => {
1526
- transformRef.current = `rotate(${position.rotate}deg)`;
1527
- topRef.current = position.startY;
1528
- leftRef.current = position.startX;
1529
- if (domRef.current) {
1530
- var _position$opacity;
1531
- domRef.current.style.transform = transformRef.current;
1532
- domRef.current.style.top = `${topRef.current}px`;
1533
- domRef.current.style.left = `${leftRef.current}px`;
1534
- domRef.current.style.opacity = `${(_position$opacity = position.opacity) !== null && _position$opacity !== void 0 ? _position$opacity : 1}`;
1535
- }
1536
- });
1537
- const sizeSubscription = size$.subscribe((size) => {
1538
- if (domRef.current) {
1539
- domRef.current.style.width = `${Math.max(size.endX - size.startX - 2, 0)}px`;
1540
- domRef.current.style.height = `${Math.max(size.endY - size.startY - 2, 0)}px`;
1541
- }
1542
- if (innerDomRef.current) {
1543
- const style = {
1544
- width: `${size.width - 4}px`,
1545
- height: `${size.height - 4}px`,
1546
- left: `${size.absolute.left ? 0 : "auto"}`,
1547
- top: `${size.absolute.top ? 0 : "auto"}`,
1548
- right: `${size.absolute.left ? "auto" : 0}`,
1549
- bottom: `${size.absolute.top ? "auto" : 0}`
1550
- };
1551
- innerDomRef.current.style.width = style.width;
1552
- innerDomRef.current.style.height = style.height;
1553
- innerDomRef.current.style.left = style.left;
1554
- innerDomRef.current.style.top = style.top;
1555
- innerDomRef.current.style.right = style.right;
1556
- innerDomRef.current.style.bottom = style.bottom;
1557
- innerStyle.current = style;
1558
- }
1743
+ if (domRef.current && innerDomRef.current) applyFloatDomLayout(domRef.current, innerDomRef.current, resolveFloatDomLayout(position, {
1744
+ wrapperInset,
1745
+ contentInset
1746
+ }));
1559
1747
  });
1560
1748
  return () => {
1561
1749
  subscription.unsubscribe();
1562
- sizeSubscription.unsubscribe();
1563
1750
  };
1564
- }, [layer.position$, size$]);
1751
+ }, [
1752
+ contentInset,
1753
+ layer.position$,
1754
+ wrapperInset
1755
+ ]);
1565
1756
  const instance = univerInstanceService.getUnit(layer.unitId);
1566
1757
  const docDisabled = instance instanceof DocumentDataModel ? instance.getDisabled() : void 0;
1567
1758
  const component = useMemo(() => Component ? /* @__PURE__ */ jsx(Component, {
@@ -1575,47 +1766,44 @@ const FloatDomSingle = memo((props) => {
1575
1766
  }
1576
1767
  }) : null, [Component, layerProps]);
1577
1768
  if (!position) return null;
1769
+ const layout = resolveFloatDomLayout(position, layer.contentBox);
1578
1770
  return /* @__PURE__ */ jsx("div", {
1579
1771
  ref: domRef,
1580
- className: "univer-z-10",
1772
+ className: "univer-absolute univer-z-10 univer-origin-center",
1581
1773
  style: {
1582
- position: "absolute",
1583
- top: topRef.current,
1584
- left: leftRef.current,
1585
- width: Math.max(position.endX - position.startX - 2, 0),
1586
- height: Math.max(position.endY - position.startY - 2, 0),
1587
- transform: transformRef.current,
1588
- overflow: "hidden",
1589
- transformOrigin: "center center"
1774
+ ...layout.wrapper,
1775
+ overflow: floatDomOverflow.outerOverflow
1590
1776
  },
1591
1777
  onPointerMove: (e) => {
1592
- layer.onPointerMove(e.nativeEvent);
1778
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerMove(e.nativeEvent);
1593
1779
  },
1594
1780
  onPointerDown: (e) => {
1595
- layer.onPointerDown(e.nativeEvent);
1781
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerDown(e.nativeEvent);
1596
1782
  },
1597
1783
  onPointerUp: (e) => {
1598
- layer.onPointerUp(e.nativeEvent);
1784
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerUp(e.nativeEvent);
1599
1785
  },
1600
1786
  onWheel: (e) => {
1601
- layer.onWheel(e.nativeEvent);
1787
+ if (shouldForwardFloatDomEvents(layer)) layer.onWheel(e.nativeEvent);
1602
1788
  },
1603
1789
  children: /* @__PURE__ */ jsx("div", {
1604
1790
  id,
1605
1791
  ref: innerDomRef,
1606
1792
  className: "univer-absolute univer-overflow-hidden",
1607
- style: { ...innerStyle.current },
1793
+ style: {
1794
+ ...layout.inner,
1795
+ overflow: floatDomOverflow.innerOverflow
1796
+ },
1608
1797
  children: component
1609
1798
  })
1610
1799
  });
1611
- });
1800
+ }
1612
1801
  const FloatDom = ({ unitId }) => {
1613
1802
  var _layers$filter;
1614
1803
  const instanceService = useDependency(IUniverInstanceService);
1615
1804
  const layers = useObservable(useDependency(CanvasFloatDomService).domLayers$);
1616
- const focusUnit = useObservable(instanceService.focused$);
1617
- const currentUnitId = unitId || focusUnit;
1618
- return layers === null || layers === void 0 || (_layers$filter = layers.filter((layer) => layer[1].unitId === currentUnitId)) === null || _layers$filter === void 0 ? void 0 : _layers$filter.map((layer) => {
1805
+ const currentUnitId = resolveFloatDomCurrentUnitId(unitId, useObservable(instanceService.focused$));
1806
+ return layers === null || layers === void 0 || (_layers$filter = layers.filter((layer) => shouldRenderFloatDomLayer(layer[1], currentUnitId))) === null || _layers$filter === void 0 ? void 0 : _layers$filter.map((layer) => {
1619
1807
  var _layer$1$domId;
1620
1808
  return /* @__PURE__ */ jsx(FloatDomSingle, {
1621
1809
  id: (_layer$1$domId = layer[1].domId) !== null && _layer$1$domId !== void 0 ? _layer$1$domId : layer[0],
@@ -1623,6 +1811,27 @@ const FloatDom = ({ unitId }) => {
1623
1811
  }, layer[0]);
1624
1812
  });
1625
1813
  };
1814
+ function resolveFloatDomCurrentUnitId(unitId, focusedUnit) {
1815
+ if (typeof unitId === "string") return unitId;
1816
+ if (typeof focusedUnit === "string") return focusedUnit;
1817
+ if (focusedUnit != null && typeof focusedUnit === "object" && "getUnitId" in focusedUnit && typeof focusedUnit.getUnitId === "function") {
1818
+ const focusedUnitId = focusedUnit.getUnitId();
1819
+ return typeof focusedUnitId === "string" ? focusedUnitId : null;
1820
+ }
1821
+ return null;
1822
+ }
1823
+ function resolveFloatDomOverflow(props) {
1824
+ var _viewport$bleedWidth;
1825
+ const viewport = props.customBlockRenderViewport;
1826
+ if (!(Number.isFinite(viewport === null || viewport === void 0 ? void 0 : viewport.bleedWidth) && ((_viewport$bleedWidth = viewport === null || viewport === void 0 ? void 0 : viewport.bleedWidth) !== null && _viewport$bleedWidth !== void 0 ? _viewport$bleedWidth : 0) > 0)) return {
1827
+ outerOverflow: "hidden",
1828
+ innerOverflow: "hidden"
1829
+ };
1830
+ return {
1831
+ outerOverflow: "visible",
1832
+ innerOverflow: "visible"
1833
+ };
1834
+ }
1626
1835
 
1627
1836
  //#endregion
1628
1837
  //#region src/services/popup/canvas-popup.service.ts
@@ -1857,7 +2066,6 @@ RectPopup.useContext = () => useContext(RectPopupContext);
1857
2066
  //#endregion
1858
2067
  //#region src/views/components/popup/CanvasPopup.tsx
1859
2068
  const SingleCanvasPopup = ({ popup, children }) => {
1860
- const [hidden, setHidden] = useState(false);
1861
2069
  const anchorRect$ = useMemo(() => popup.anchorRect$.pipe(throttleTime(0, animationFrameScheduler), map((anchorRect) => {
1862
2070
  var _popup$offset;
1863
2071
  const { bottom, left, right, top } = anchorRect;
@@ -1878,26 +2086,21 @@ const SingleCanvasPopup = ({ popup, children }) => {
1878
2086
  return (_popup$excludeRects$ = popup.excludeRects$) === null || _popup$excludeRects$ === void 0 ? void 0 : _popup$excludeRects$.pipe(throttleTime(0, animationFrameScheduler));
1879
2087
  }, [popup.excludeRects$]), popup.excludeRects);
1880
2088
  const { canvasElement, hideOnInvisible = true, hiddenType = "destroy" } = popup;
1881
- useEffect(() => {
1882
- if (!hideOnInvisible) return;
1883
- const anchorRectSub = combineLatest([anchorRect$, hiddenRects$]).subscribe(([rectWithOffset, hiddenRects]) => {
1884
- const { top, left, bottom, right } = canvasElement.getBoundingClientRect();
1885
- const rectHeight = rectWithOffset.bottom - rectWithOffset.top;
1886
- const rectWidth = rectWithOffset.right - rectWithOffset.left;
1887
- const isInHiddenRect = hiddenRects.some((hiddenRect) => {
1888
- const bufferY = Math.min(.5 * rectHeight, 10);
1889
- const bufferX = Math.min(.5 * rectWidth, 10);
1890
- return rectWithOffset.top >= hiddenRect.top - bufferY && rectWithOffset.bottom <= hiddenRect.bottom + bufferY && rectWithOffset.left >= hiddenRect.left - bufferX && rectWithOffset.right <= hiddenRect.right + bufferX;
1891
- });
1892
- if (rectWithOffset.bottom < top || rectWithOffset.top > bottom || rectWithOffset.right < left || rectWithOffset.left > right || isInHiddenRect) setHidden(true);
1893
- else setHidden(false);
2089
+ const hidden = useObservable(hideOnInvisible ? () => combineLatest([anchorRect$, hiddenRects$]).pipe(map(([rectWithOffset, hiddenRects]) => {
2090
+ const { top, left, bottom, right } = canvasElement.getBoundingClientRect();
2091
+ const rectHeight = rectWithOffset.bottom - rectWithOffset.top;
2092
+ const rectWidth = rectWithOffset.right - rectWithOffset.left;
2093
+ const isInHiddenRect = hiddenRects.some((hiddenRect) => {
2094
+ const bufferY = Math.min(.5 * rectHeight, 10);
2095
+ const bufferX = Math.min(.5 * rectWidth, 10);
2096
+ return rectWithOffset.top >= hiddenRect.top - bufferY && rectWithOffset.bottom <= hiddenRect.bottom + bufferY && rectWithOffset.left >= hiddenRect.left - bufferX && rectWithOffset.right <= hiddenRect.right + bufferX;
1894
2097
  });
1895
- return () => anchorRectSub.unsubscribe();
1896
- }, [
1897
- canvasElement,
1898
- hideOnInvisible,
2098
+ return rectWithOffset.bottom < top || rectWithOffset.top > bottom || rectWithOffset.right < left || rectWithOffset.left > right || isInHiddenRect;
2099
+ })) : null, false, false, [
1899
2100
  anchorRect$,
1900
- hiddenRects$
2101
+ canvasElement,
2102
+ hiddenRects$,
2103
+ hideOnInvisible
1901
2104
  ]);
1902
2105
  if (hidden && hiddenType === "destroy") return null;
1903
2106
  return /* @__PURE__ */ jsx(RectPopup, {
@@ -1929,13 +2132,41 @@ function CanvasPopup() {
1929
2132
  return useObservable(popupService.popups$, void 0, true).map((item) => {
1930
2133
  const [key, popup] = item;
1931
2134
  const Component = componentManager.get(popup.componentKey);
2135
+ const PopupComponent = Component && popup.connectorInjector ? connectInjector(Component, popup.connectorInjector) : Component;
1932
2136
  return /* @__PURE__ */ jsx(SingleCanvasPopup, {
1933
2137
  popup,
1934
- children: Component ? /* @__PURE__ */ jsx(Component, { popup }) : null
2138
+ children: PopupComponent && /* @__PURE__ */ jsx(PopupComponent, { popup })
1935
2139
  }, key);
1936
2140
  });
1937
2141
  }
1938
2142
 
2143
+ //#endregion
2144
+ //#region src/services/ribbon/ribbon-override.service.ts
2145
+ const IRibbonOverrideService = createIdentifier("univer.ribbon-override-service");
2146
+ var RibbonOverrideService = class extends Disposable {
2147
+ constructor(..._args) {
2148
+ super(..._args);
2149
+ _defineProperty(this, "_override$", new BehaviorSubject(null));
2150
+ _defineProperty(this, "override$", this._override$.asObservable());
2151
+ }
2152
+ getOverride() {
2153
+ return this._override$.getValue();
2154
+ }
2155
+ activate(override) {
2156
+ this._override$.next(override);
2157
+ }
2158
+ clear(id) {
2159
+ const current = this.getOverride();
2160
+ if (!current) return;
2161
+ if (!id || current.id === id) this._override$.next(null);
2162
+ }
2163
+ dispose() {
2164
+ this._override$.next(null);
2165
+ this._override$.complete();
2166
+ super.dispose();
2167
+ }
2168
+ };
2169
+
1939
2170
  //#endregion
1940
2171
  //#region src/services/ribbon/ribbon.service.ts
1941
2172
  const IRibbonService = createIdentifier("univer.ribbon-service");
@@ -2112,7 +2343,8 @@ function ComponentContainer(props) {
2112
2343
  */
2113
2344
  function useComponentsOfPart(part, injector) {
2114
2345
  var _injector$get;
2115
- const uiPartsService = (_injector$get = injector === null || injector === void 0 ? void 0 : injector.get(IUIPartsService)) !== null && _injector$get !== void 0 ? _injector$get : useDependency(IUIPartsService);
2346
+ const injectedUIPartsService = useDependency(IUIPartsService);
2347
+ const uiPartsService = (_injector$get = injector === null || injector === void 0 ? void 0 : injector.get(IUIPartsService)) !== null && _injector$get !== void 0 ? _injector$get : injectedUIPartsService;
2116
2348
  const changeInfo = useObservable(useMemo(() => uiPartsService.uiVisibleChange$.pipe(filter((ui) => ui.ui === part)), [part, uiPartsService]));
2117
2349
  const updateCounterRef = useRef(0);
2118
2350
  return useMemo(() => uiPartsService.isUIVisible(part) ? uiPartsService.getComponents(part) : /* @__PURE__ */ new Set(), [useObservable(() => uiPartsService.componentRegistered$.pipe(filter((key) => key === part), debounceTime(200), map(() => updateCounterRef.current += 1), startWith(updateCounterRef.current += 1)), void 0, void 0, [
@@ -2289,33 +2521,14 @@ function CustomLabel(props) {
2289
2521
  const localeService = useDependency(LocaleService);
2290
2522
  const componentManager = useDependency(ComponentManager);
2291
2523
  const iconManager = useDependency(IconManager);
2292
- const [subscribedValue, setSubscribedValue] = useState(value);
2293
- const [realIcon, setRealIcon] = useState("");
2524
+ const subscribedValue = useObservable(value$ !== null && value$ !== void 0 ? value$ : null, value);
2525
+ const subscribedIcon = useObservable(isObservable(icon) ? icon : null, "");
2526
+ const realIcon = isObservable(icon) ? subscribedIcon : icon !== null && icon !== void 0 ? icon : "";
2294
2527
  const nodes = [];
2295
2528
  let index = 0;
2296
- useEffect(() => {
2297
- if (value$) {
2298
- const subscription = value$.subscribe((v) => {
2299
- setSubscribedValue(v);
2300
- });
2301
- return () => {
2302
- subscription.unsubscribe();
2303
- };
2304
- }
2305
- }, [value$]);
2306
2529
  const realValue = useMemo(() => {
2307
2530
  return value !== null && value !== void 0 ? value : subscribedValue;
2308
2531
  }, [subscribedValue, value]);
2309
- useEffect(() => {
2310
- let subscription = null;
2311
- if (isObservable(icon)) subscription = icon.subscribe((v) => {
2312
- setRealIcon(v);
2313
- });
2314
- else setRealIcon(icon !== null && icon !== void 0 ? icon : "");
2315
- return () => {
2316
- subscription === null || subscription === void 0 || subscription.unsubscribe();
2317
- };
2318
- }, [icon]);
2319
2532
  const isValid = useMemo(() => {
2320
2533
  if (realValue && typeof realValue === "string") return new ColorKit(realValue).isValid;
2321
2534
  return false;
@@ -2360,6 +2573,7 @@ function CustomLabel(props) {
2360
2573
  * @returns The menu item's status
2361
2574
  */
2362
2575
  function useToolbarItemStatus(menuItem) {
2576
+ var _selectionsValue$2;
2363
2577
  const { disabled$, hidden$, activated$, value$ } = menuItem;
2364
2578
  let selectionsValue$;
2365
2579
  if (isMenuButtonSelectorItem(menuItem)) {
@@ -2369,37 +2583,18 @@ function useToolbarItemStatus(menuItem) {
2369
2583
  selectionsValue$ = selections === null || selections === void 0 || (_selections$ = selections[0]) === null || _selections$ === void 0 ? void 0 : _selections$.value$;
2370
2584
  }
2371
2585
  }
2372
- const [value, setValue] = useState();
2373
- const [disabled, setDisabled] = useState(false);
2374
- const [activated, setActivated] = useState(false);
2375
- const [hidden, setHidden] = useState(false);
2376
- const [selectionsValue, setSelectionsValue] = useState();
2377
- useEffect(() => {
2378
- const subscriptions = [];
2379
- disabled$ && subscriptions.push(disabled$.subscribe((disabled) => setDisabled(disabled)));
2380
- hidden$ && subscriptions.push(hidden$.subscribe((hidden) => setHidden(hidden)));
2381
- activated$ && subscriptions.push(activated$.subscribe((activated) => setActivated(activated)));
2382
- value$ && subscriptions.push(value$.subscribe((value) => {
2383
- setValue(value);
2384
- }));
2385
- selectionsValue$ && subscriptions.push(selectionsValue$.subscribe((value) => {
2386
- setSelectionsValue(value);
2387
- setValue(value);
2388
- }));
2389
- return () => subscriptions.forEach((subscription) => subscription.unsubscribe());
2390
- }, [
2391
- activated$,
2392
- disabled$,
2393
- hidden$,
2394
- value$,
2395
- selectionsValue$
2396
- ]);
2586
+ const disabled = useObservable(disabled$ !== null && disabled$ !== void 0 ? disabled$ : null, false);
2587
+ const activated = useObservable(activated$ !== null && activated$ !== void 0 ? activated$ : null, false);
2588
+ const hidden = useObservable(hidden$ !== null && hidden$ !== void 0 ? hidden$ : null, false);
2397
2589
  return {
2398
2590
  disabled,
2399
- value,
2591
+ value: useObservable(useMemo(() => {
2592
+ var _selectionsValue$;
2593
+ return merge$1(value$ !== null && value$ !== void 0 ? value$ : EMPTY, (_selectionsValue$ = selectionsValue$) !== null && _selectionsValue$ !== void 0 ? _selectionsValue$ : EMPTY);
2594
+ }, [selectionsValue$, value$])),
2400
2595
  activated,
2401
2596
  hidden,
2402
- selectionsValue
2597
+ selectionsValue: useObservable((_selectionsValue$2 = selectionsValue$) !== null && _selectionsValue$2 !== void 0 ? _selectionsValue$2 : null)
2403
2598
  };
2404
2599
  }
2405
2600
  function useToolbarShortcutDisplay({ id, commandId, shortcut }) {
@@ -2418,39 +2613,52 @@ const TooltipWrapperContext = createContext({
2418
2613
  dropdownVisible: false,
2419
2614
  setDropdownVisible: (_visible) => {}
2420
2615
  });
2616
+ const ToolbarDropdownContext = createContext(null);
2617
+ function ToolbarDropdownProvider(props) {
2618
+ const [openDropdownKey, setOpenDropdownKey] = useState(null);
2619
+ const contextValue = useMemo(() => ({
2620
+ openDropdownKey,
2621
+ setOpenDropdownKey
2622
+ }), [openDropdownKey]);
2623
+ return /* @__PURE__ */ jsx(ToolbarDropdownContext.Provider, {
2624
+ value: contextValue,
2625
+ children: props.children
2626
+ });
2627
+ }
2421
2628
  const TooltipWrapper = forwardRef((props, ref) => {
2422
- const { children, ...tooltipProps } = props;
2629
+ const { children, dropdownKey, ...tooltipProps } = props;
2423
2630
  const spanRef = useRef(null);
2424
2631
  const [tooltipVisible, setTooltipVisible] = useState(false);
2425
- const [dropdownVisible, setDropdownVisible] = useState(false);
2632
+ const [localDropdownVisible, setLocalDropdownVisible] = useState(false);
2633
+ const toolbarDropdownContext = useContext(ToolbarDropdownContext);
2634
+ const dropdownVisible = dropdownKey && toolbarDropdownContext ? toolbarDropdownContext.openDropdownKey === dropdownKey : localDropdownVisible;
2426
2635
  function handleChangeTooltipVisible(visible) {
2427
2636
  if (dropdownVisible) setTooltipVisible(false);
2428
2637
  else setTooltipVisible(visible);
2429
2638
  }
2430
- function handleChangeDropdownVisible(visible) {
2431
- setDropdownVisible(visible);
2639
+ const handleChangeDropdownVisible = useCallback((visible) => {
2640
+ if (dropdownKey && toolbarDropdownContext) toolbarDropdownContext.setOpenDropdownKey(visible ? dropdownKey : null);
2641
+ else setLocalDropdownVisible(visible);
2432
2642
  setTooltipVisible(false);
2433
- }
2643
+ }, [dropdownKey, toolbarDropdownContext]);
2434
2644
  const contextValue = useMemo(() => ({
2435
2645
  dropdownVisible,
2436
2646
  setDropdownVisible: handleChangeDropdownVisible
2437
- }), [dropdownVisible]);
2647
+ }), [dropdownVisible, handleChangeDropdownVisible]);
2438
2648
  useImperativeHandle(ref, () => ({ el: spanRef.current }));
2649
+ const content = /* @__PURE__ */ jsx("span", {
2650
+ ref: spanRef,
2651
+ children: /* @__PURE__ */ jsx(TooltipWrapperContext.Provider, {
2652
+ value: contextValue,
2653
+ children
2654
+ })
2655
+ });
2439
2656
  return tooltipProps.title ? /* @__PURE__ */ jsx(Tooltip, {
2440
2657
  visible: tooltipVisible,
2441
2658
  onVisibleChange: handleChangeTooltipVisible,
2442
2659
  ...tooltipProps,
2443
- children: /* @__PURE__ */ jsx("span", {
2444
- ref: spanRef,
2445
- children: /* @__PURE__ */ jsx(TooltipWrapperContext.Provider, {
2446
- value: contextValue,
2447
- children
2448
- })
2449
- })
2450
- }) : /* @__PURE__ */ jsx("span", {
2451
- ref: spanRef,
2452
- children
2453
- });
2660
+ children: content
2661
+ }) : content;
2454
2662
  });
2455
2663
  function DropdownWrapper(props) {
2456
2664
  const { children, overlay, disabled, align = "start" } = props;
@@ -2478,9 +2686,8 @@ function DropdownMenuLabel({ icon, value, option, onOptionSelect }) {
2478
2686
  var _option$label;
2479
2687
  const onChange = (v) => {
2480
2688
  onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
2481
- value: v,
2482
- label: option === null || option === void 0 ? void 0 : option.label,
2483
- commandId: option === null || option === void 0 ? void 0 : option.commandId
2689
+ ...option,
2690
+ value: v
2484
2691
  });
2485
2692
  };
2486
2693
  const hasCheckMark = typeof option.label === "string" || typeof option.label === "object" && ((_option$label = option.label) === null || _option$label === void 0 ? void 0 : _option$label.selectable) !== false;
@@ -2503,24 +2710,28 @@ function DropdownMenuLabel({ icon, value, option, onOptionSelect }) {
2503
2710
  })]
2504
2711
  });
2505
2712
  }
2713
+ function getOptionKey(option) {
2714
+ var _ref, _ref2, _option$id, _option$label2;
2715
+ return String((_ref = (_ref2 = (_option$id = option.id) !== null && _option$id !== void 0 ? _option$id : option.commandId) !== null && _ref2 !== void 0 ? _ref2 : option.value) !== null && _ref !== void 0 ? _ref : typeof option.label === "string" ? option.label : (_option$label2 = option.label) === null || _option$label2 === void 0 ? void 0 : _option$label2.name);
2716
+ }
2506
2717
  function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, onOptionSelect }) {
2507
2718
  const { dropdownVisible, setDropdownVisible } = useContext(TooltipWrapperContext);
2508
2719
  const menuManagerService = useDependency(IMenuManagerService);
2509
- const [hiddenStates, setHiddenStates] = useState({});
2510
- const [menuVersion, setMenuVersion] = useState(0);
2511
- useEffect(() => {
2512
- const subscription = menuManagerService.menuChanged$.subscribe(() => {
2513
- setMenuVersion((version) => version + 1);
2720
+ const resolveMenuItems = () => menuId ? menuManagerService.getMenuByPositionKey(menuId) : [];
2721
+ const menuItems = useObservable(() => menuManagerService.menuChanged$.pipe(map(resolveMenuItems), startWith(resolveMenuItems())), resolveMenuItems(), false, [menuId, menuManagerService]);
2722
+ const hiddenStates = useObservable(useMemo(() => {
2723
+ const itemStates = menuItems.map((item) => {
2724
+ var _item$item$hidden$, _item$item;
2725
+ return (item.children ? combineLatest(item.children.map((subItem) => {
2726
+ var _subItem$item$hidden$, _subItem$item;
2727
+ return (_subItem$item$hidden$ = (_subItem$item = subItem.item) === null || _subItem$item === void 0 ? void 0 : _subItem$item.hidden$) !== null && _subItem$item$hidden$ !== void 0 ? _subItem$item$hidden$ : of(false);
2728
+ })).pipe(map((hiddenValues) => hiddenValues.every(Boolean))) : (_item$item$hidden$ = (_item$item = item.item) === null || _item$item === void 0 ? void 0 : _item$item.hidden$) !== null && _item$item$hidden$ !== void 0 ? _item$item$hidden$ : of(false)).pipe(map((hidden) => [String(item.key), hidden]));
2514
2729
  });
2515
- return () => subscription.unsubscribe();
2516
- }, [menuManagerService]);
2517
- const menuItems = useMemo(() => {
2518
- return menuId ? menuManagerService.getMenuByPositionKey(menuId) : [];
2519
- }, [
2520
- menuId,
2521
- menuManagerService,
2522
- menuVersion
2523
- ]);
2730
+ return itemStates.length ? merge$1(...itemStates).pipe(scan((states, [key, hidden]) => ({
2731
+ ...states,
2732
+ [key]: hidden
2733
+ }), {}), startWith({})) : of({});
2734
+ }, [menuItems]), {});
2524
2735
  const filteredMenuItems = useMemo(() => {
2525
2736
  return menuItems.filter((item) => {
2526
2737
  var _item$key;
@@ -2531,58 +2742,28 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
2531
2742
  function handleVisibleChange(visible) {
2532
2743
  setDropdownVisible(visible);
2533
2744
  }
2745
+ function handleEmbedBoundaryFocusOutside(event) {
2746
+ keepInteractionInsideSameEmbedBoundary(event);
2747
+ }
2534
2748
  function handleOptionSelect(option) {
2535
2749
  onOptionSelect(option);
2536
2750
  setDropdownVisible(false);
2537
2751
  }
2538
- useEffect(() => {
2539
- const subscriptions = [];
2540
- menuItems.forEach((item) => {
2541
- if (!item.children) {
2542
- var _item$item;
2543
- if ((_item$item = item.item) === null || _item$item === void 0 ? void 0 : _item$item.hidden$) {
2544
- const sub = item.item.hidden$.subscribe((hidden) => {
2545
- setHiddenStates((prev) => ({
2546
- ...prev,
2547
- [item.key]: hidden
2548
- }));
2549
- });
2550
- subscriptions.push(sub);
2551
- }
2552
- } else {
2553
- const sub = combineLatest(item.children.map((subItem) => {
2554
- var _subItem$item$hidden$, _subItem$item;
2555
- return (_subItem$item$hidden$ = (_subItem$item = subItem.item) === null || _subItem$item === void 0 ? void 0 : _subItem$item.hidden$) !== null && _subItem$item$hidden$ !== void 0 ? _subItem$item$hidden$ : of(false);
2556
- })).subscribe((hiddenValues) => {
2557
- const isAllHidden = hiddenValues.every((hidden) => hidden === true);
2558
- setHiddenStates((prev) => ({
2559
- ...prev,
2560
- [item.key]: isAllHidden
2561
- }));
2562
- });
2563
- subscriptions.push(sub);
2564
- }
2565
- });
2566
- return () => {
2567
- subscriptions.forEach((sub) => sub === null || sub === void 0 ? void 0 : sub.unsubscribe());
2568
- setHiddenStates({});
2569
- };
2570
- }, [menuItems]);
2571
2752
  if (slot) return /* @__PURE__ */ jsx(DropdownWrapper, {
2572
2753
  disabled,
2573
- overlay: options.map((option, index) => /* @__PURE__ */ jsx(DropdownMenuLabel, {
2754
+ overlay: options.map((option) => /* @__PURE__ */ jsx(DropdownMenuLabel, {
2574
2755
  value,
2575
2756
  option,
2576
2757
  onOptionSelect: handleOptionSelect
2577
- }, index)),
2758
+ }, getOptionKey(option))),
2578
2759
  children
2579
2760
  });
2580
2761
  if (options === null || options === void 0 ? void 0 : options.length) {
2581
2762
  const items = options.map((option) => {
2582
- var _option$label2;
2763
+ var _option$label3;
2583
2764
  return {
2584
2765
  type: "item",
2585
- className: clsx({ "focus:univer-bg-white": typeof option.label !== "string" && ((_option$label2 = option.label) === null || _option$label2 === void 0 ? void 0 : _option$label2.hoverable) === false }),
2766
+ className: clsx({ "focus:univer-bg-white": typeof option.label !== "string" && ((_option$label3 = option.label) === null || _option$label3 === void 0 ? void 0 : _option$label3.hoverable) === false }),
2586
2767
  children: /* @__PURE__ */ jsx(DropdownMenuLabel, {
2587
2768
  icon: option.icon,
2588
2769
  value,
@@ -2625,6 +2806,8 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
2625
2806
  disabled,
2626
2807
  open: dropdownVisible,
2627
2808
  onOpenChange: handleVisibleChange,
2809
+ onFocusOutside: handleEmbedBoundaryFocusOutside,
2810
+ onInteractOutside: handleEmbedBoundaryFocusOutside,
2628
2811
  children
2629
2812
  });
2630
2813
  } else {
@@ -2659,6 +2842,8 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
2659
2842
  disabled,
2660
2843
  open: dropdownVisible,
2661
2844
  onOpenChange: handleVisibleChange,
2845
+ onFocusOutside: handleEmbedBoundaryFocusOutside,
2846
+ onInteractOutside: handleEmbedBoundaryFocusOutside,
2662
2847
  children
2663
2848
  });
2664
2849
  }
@@ -2790,7 +2975,8 @@ const ToolbarItem = forwardRef((props, ref) => {
2790
2975
  if (disabled) return;
2791
2976
  let commandId = sId;
2792
2977
  if (option.id) commandId = option.id;
2793
- executeCommand(commandId, { value: option.value });
2978
+ const commandParams = typeof option.params === "function" ? option.params(option.value) : option.params;
2979
+ executeCommand(commandId, commandParams !== null && commandParams !== void 0 ? commandParams : { value: option.value });
2794
2980
  }
2795
2981
  function handleSelectionsValueChange(value) {
2796
2982
  if (disabled) return;
@@ -2798,7 +2984,10 @@ const ToolbarItem = forwardRef((props, ref) => {
2798
2984
  }
2799
2985
  function handleClick() {
2800
2986
  if (disabled) return;
2801
- if (menuType === 2) executeCommand(bId, { value });
2987
+ if (menuType === 2) {
2988
+ const commandParams = typeof params === "function" ? params() : params;
2989
+ executeCommand(bId, commandParams !== null && commandParams !== void 0 ? commandParams : { value });
2990
+ }
2802
2991
  }
2803
2992
  if (menuType === 2) return /* @__PURE__ */ jsxs("div", {
2804
2993
  "data-u-command": id,
@@ -2863,7 +3052,6 @@ const ToolbarItem = forwardRef((props, ref) => {
2863
3052
  function renderButtonType() {
2864
3053
  var _label$name;
2865
3054
  const isCustomComponent = componentManager.get(typeof label === "string" ? label : (_label$name = label === null || label === void 0 ? void 0 : label.name) !== null && _label$name !== void 0 ? _label$name : "");
2866
- const commandValue = (value !== null && value !== void 0 ? value : typeof params === "function") ? params() : params;
2867
3055
  return /* @__PURE__ */ jsx(ToolbarButton, {
2868
3056
  "data-u-command": id,
2869
3057
  className: "univer-text-sm",
@@ -2872,7 +3060,8 @@ const ToolbarItem = forwardRef((props, ref) => {
2872
3060
  disabled,
2873
3061
  onClick: () => {
2874
3062
  var _props$commandId;
2875
- return executeCommand((_props$commandId = props.commandId) !== null && _props$commandId !== void 0 ? _props$commandId : props.id, commandValue);
3063
+ const commandParams = typeof params === "function" ? params() : params;
3064
+ executeCommand((_props$commandId = props.commandId) !== null && _props$commandId !== void 0 ? _props$commandId : props.id, commandParams !== null && commandParams !== void 0 ? commandParams : typeof value === "undefined" ? void 0 : { value });
2876
3065
  },
2877
3066
  onDoubleClick: () => props.subId && executeCommand(props.subId),
2878
3067
  children: isCustomComponent ? /* @__PURE__ */ jsx(CustomLabel, {
@@ -2895,6 +3084,7 @@ const ToolbarItem = forwardRef((props, ref) => {
2895
3084
  ref,
2896
3085
  title: tooltipTitle,
2897
3086
  placement: "bottom",
3087
+ dropdownKey: id,
2898
3088
  children: renderItem()
2899
3089
  });
2900
3090
  });
@@ -2902,15 +3092,20 @@ const ToolbarItem = forwardRef((props, ref) => {
2902
3092
  //#endregion
2903
3093
  //#region src/views/components/ribbon/Ribbon.tsx
2904
3094
  function Ribbon(props) {
2905
- const { ribbonType, headerMenuComponents, headerMenu = true } = props;
2906
- const ribbonService = useDependency(IRibbonService);
3095
+ var _ribbonOverride$ribbo;
3096
+ const { ribbonType, headerMenuComponents, headerMenu = true, toolbarOnly = false, headerClassName } = props;
3097
+ const defaultRibbonService = useDependency(IRibbonService);
3098
+ const ribbonOverrideService = useDependency(IRibbonOverrideService);
2907
3099
  const localeService = useDependency(LocaleService);
3100
+ const ribbonOverride = useObservable(ribbonOverrideService.override$, ribbonOverrideService.getOverride());
3101
+ const ribbonService = (_ribbonOverride$ribbo = ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.ribbonService) !== null && _ribbonOverride$ribbo !== void 0 ? _ribbonOverride$ribbo : defaultRibbonService;
2908
3102
  const containerRef = useRef(null);
2909
3103
  const toolbarItemRefs = useRef({});
2910
3104
  const ribbonData = useObservable(ribbonService.ribbon$, []);
2911
3105
  const activatedTab = useObservable(ribbonService.activatedTab$, "ribbon.start");
2912
3106
  const collapsedIds = useObservable(ribbonService.collapsedIds$, []);
2913
3107
  const fakeToolbarVisible = useObservable(ribbonService.fakeToolbarVisible$, false);
3108
+ const hideToolbar = (ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.hideToolbar) === true;
2914
3109
  const ribbon = useMemo(() => {
2915
3110
  if (ribbonType === "simple") {
2916
3111
  const simpleRibbon = [{
@@ -2936,7 +3131,7 @@ function Ribbon(props) {
2936
3131
  const handleSelectTab = useCallback((group) => {
2937
3132
  toolbarItemRefs.current = {};
2938
3133
  ribbonService.setActivatedTab(group.key);
2939
- }, []);
3134
+ }, [ribbonService]);
2940
3135
  const activeGroup = useMemo(() => {
2941
3136
  var _ribbon$find$children, _ribbon$find2;
2942
3137
  const allGroups = (_ribbon$find$children = (_ribbon$find2 = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find2 === void 0 ? void 0 : _ribbon$find2.children) !== null && _ribbon$find$children !== void 0 ? _ribbon$find$children : [];
@@ -2964,6 +3159,13 @@ function Ribbon(props) {
2964
3159
  activatedTab
2965
3160
  ]);
2966
3161
  useEffect(() => {
3162
+ if (hideToolbar) {
3163
+ toolbarItemRefs.current = {};
3164
+ ribbonService.setCollapsedIds([]);
3165
+ ribbonService.setFakeToolbarVisible(false);
3166
+ return;
3167
+ }
3168
+ if (!containerRef.current) return;
2967
3169
  let timer = null;
2968
3170
  const observer = new ResizeObserver(throttle((entries) => {
2969
3171
  for (const entry of entries) {
@@ -2993,7 +3195,12 @@ function Ribbon(props) {
2993
3195
  timer && cancelAnimationFrame(timer);
2994
3196
  observer.disconnect();
2995
3197
  };
2996
- }, [ribbon, activatedTab]);
3198
+ }, [
3199
+ hideToolbar,
3200
+ ribbon,
3201
+ activatedTab,
3202
+ ribbonService
3203
+ ]);
2997
3204
  const fakeToolbar = useMemo(() => {
2998
3205
  return /* @__PURE__ */ jsx("div", {
2999
3206
  "aria-hidden": "true",
@@ -3016,77 +3223,119 @@ function Ribbon(props) {
3016
3223
  }, child.key)))
3017
3224
  }) }, groupItem.key);
3018
3225
  })
3019
- });
3020
- }, [activeGroup.allGroups, fakeToolbarVisible]);
3021
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3022
- /* @__PURE__ */ jsxs("div", {
3023
- "data-u-comp": "ribbon-header-menu",
3024
- className: clsx("univer-relative univer-select-none", { "univer-h-9": ribbonType === "classic" || headerMenuComponents && headerMenuComponents.size > 0 }),
3025
- children: [ribbonType === "classic" && ribbon.length >= 1 && /* @__PURE__ */ jsx(ClassicMenu, {
3026
- ribbon,
3027
- activatedTab,
3028
- onSelectTab: handleSelectTab
3029
- }), headerMenu && headerMenuComponents && headerMenuComponents.size > 0 && /* @__PURE__ */ jsx("div", {
3030
- className: "univer-absolute univer-right-2 univer-top-0 univer-flex univer-h-full univer-flex-row univer-items-center univer-gap-2 rtl:univer-left-2 rtl:univer-right-auto [&>*]:univer-inline-flex [&>*]:univer-h-6 [&>*]:univer-items-center [&>*]:univer-rounded [&>*]:univer-px-1 [&>*]:univer-transition-colors hover:[&>*]:univer-bg-gray-100",
3031
- children: /* @__PURE__ */ jsx(ComponentContainer, { components: headerMenuComponents })
3032
- })]
3033
- }),
3034
- /* @__PURE__ */ jsxs("div", {
3035
- className: clsx("univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3 univer-text-sm", {
3036
- "univer-grid-cols-[1fr] univer-justify-center": ribbonType === "classic" || ribbon.length === 1,
3037
- "univer-grid-cols-[auto,1fr]": ribbon.length > 1 && ribbonType !== "classic"
3038
- }, borderBottomClassName),
3039
- children: [ribbonType === "collapsed" && ribbon.length >= 1 && /* @__PURE__ */ jsx(DefaultMenu, {
3040
- ribbon,
3041
- activatedTab,
3042
- onSelectTab: handleSelectTab
3043
- }), /* @__PURE__ */ jsxs("div", {
3044
- "data-u-comp": "ribbon-toolbar",
3045
- ref: containerRef,
3046
- className: clsx("univer-flex univer-overflow-hidden rtl:univer-divide-x-reverse", divideXClassName, { "univer-justify-center": ribbonType === "classic" }),
3047
- role: "toolbar",
3048
- "aria-label": localeService.t(activatedTabTitle),
3049
- children: [activeGroup.visibleGroups.map((groupItem) => {
3050
- var _groupItem$children3, _groupItem$children4;
3051
- return (((_groupItem$children3 = groupItem.children) === null || _groupItem$children3 === void 0 ? void 0 : _groupItem$children3.length) || groupItem.item) && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", {
3052
- className: "univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2 empty:univer-hidden",
3053
- children: groupItem.children && ((_groupItem$children4 = groupItem.children) === null || _groupItem$children4 === void 0 ? void 0 : _groupItem$children4.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, { ...child.item }, child.key)))
3054
- }) }, groupItem.key);
3055
- }), collapsedIds.length > 0 && /* @__PURE__ */ jsx("div", {
3056
- "data-u-comp": "ribbon-toolbar-more",
3057
- className: "univer-pl-2 rtl:univer-pr-2",
3058
- children: /* @__PURE__ */ jsx(Dropdown, {
3059
- collisionPadding: {
3060
- right: 12,
3061
- left: 12
3062
- },
3063
- onOpenAutoFocus: (e) => e.preventDefault(),
3064
- overlay: /* @__PURE__ */ jsx("div", {
3065
- className: "univer-box-border univer-grid univer-max-w-[--radix-popper-available-width] univer-gap-2 univer-p-2",
3066
- children: activeGroup.hiddenGroups.map((groupItem) => {
3067
- var _groupItem$children5;
3068
- return /* @__PURE__ */ jsx("div", {
3069
- className: "univer-flex univer-items-center univer-gap-2",
3070
- children: /* @__PURE__ */ jsx("div", {
3071
- className: "univer-flex univer-flex-wrap univer-gap-2",
3072
- children: groupItem.children ? (_groupItem$children5 = groupItem.children) === null || _groupItem$children5 === void 0 ? void 0 : _groupItem$children5.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, { ...child.item }, child.key)) : groupItem.item && /* @__PURE__ */ jsx(ToolbarItem, { ...groupItem.item }, groupItem.key)
3073
- })
3074
- }, groupItem.key);
3075
- })
3076
- }),
3077
- children: /* @__PURE__ */ jsx("button", {
3078
- type: "button",
3079
- className: toolbarButtonClassName,
3080
- "aria-label": localeService.t("ui.ribbon.more"),
3081
- "aria-haspopup": "true",
3082
- children: /* @__PURE__ */ jsx(MoreVerticalIcon, {})
3226
+ });
3227
+ }, [activeGroup.allGroups, fakeToolbarVisible]);
3228
+ const embedRibbonOverrideAttributes = ribbonOverride ? {
3229
+ "data-embed-ribbon-override": "true",
3230
+ "data-embed-id": ribbonOverride.id
3231
+ } : {};
3232
+ return /* @__PURE__ */ jsx(RibbonOverrideRuntimeProvider, {
3233
+ override: ribbonOverride,
3234
+ children: /* @__PURE__ */ jsxs(Fragment$1, { children: [
3235
+ /* @__PURE__ */ jsxs("div", {
3236
+ "data-u-comp": "ribbon-header-menu",
3237
+ ...embedRibbonOverrideAttributes,
3238
+ className: clsx("univer-relative univer-select-none", headerClassName, {
3239
+ "univer-hidden": toolbarOnly,
3240
+ "univer-h-9": !toolbarOnly && (ribbonType === "classic" || headerMenuComponents && headerMenuComponents.size > 0)
3241
+ }),
3242
+ children: [
3243
+ !toolbarOnly && (ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.placeholderTitle) && ribbon.length === 0 && /* @__PURE__ */ jsx("div", {
3244
+ className: clsx("univer-flex univer-h-9 univer-items-end univer-px-3", { "univer-justify-center": hideToolbar }),
3245
+ children: /* @__PURE__ */ jsx("span", {
3246
+ className: "univer-relative univer-inline-flex univer-h-8 univer-items-center univer-justify-center univer-rounded-t univer-bg-primary-50 univer-px-3 univer-text-sm univer-font-medium univer-text-primary-600",
3247
+ children: ribbonOverride.placeholderTitle
3083
3248
  })
3249
+ }),
3250
+ !toolbarOnly && ribbonType === "classic" && ribbon.length >= 1 && /* @__PURE__ */ jsx(ClassicMenu, {
3251
+ ribbon,
3252
+ activatedTab,
3253
+ onSelectTab: handleSelectTab
3254
+ }),
3255
+ headerMenu && headerMenuComponents && headerMenuComponents.size > 0 && /* @__PURE__ */ jsx("div", {
3256
+ className: "univer-absolute univer-right-2 univer-top-0 univer-flex univer-h-full univer-flex-row univer-items-center univer-gap-2 rtl:univer-left-2 rtl:univer-right-auto [&>*]:univer-inline-flex [&>*]:univer-h-6 [&>*]:univer-items-center [&>*]:univer-rounded [&>*]:univer-px-1 [&>*]:univer-transition-colors hover:[&>*]:univer-bg-gray-100",
3257
+ children: /* @__PURE__ */ jsx(ComponentContainer, { components: headerMenuComponents })
3084
3258
  })
3259
+ ]
3260
+ }),
3261
+ !hideToolbar && /* @__PURE__ */ jsxs("div", {
3262
+ ...embedRibbonOverrideAttributes,
3263
+ className: clsx("univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3 univer-text-sm", {
3264
+ "univer-grid-cols-[1fr] univer-justify-center": ribbonType === "classic" || ribbon.length === 1,
3265
+ "univer-grid-cols-[auto,1fr]": ribbon.length > 1 && ribbonType !== "classic"
3266
+ }, borderBottomClassName),
3267
+ children: [ribbonType === "collapsed" && ribbon.length >= 1 && /* @__PURE__ */ jsx(DefaultMenu, {
3268
+ ribbon,
3269
+ activatedTab,
3270
+ onSelectTab: handleSelectTab
3271
+ }), /* @__PURE__ */ jsx("div", {
3272
+ "data-u-comp": "ribbon-toolbar",
3273
+ ref: containerRef,
3274
+ className: clsx("univer-flex univer-overflow-hidden", divideXClassName, { "univer-justify-center": ribbonType === "classic" }),
3275
+ role: "toolbar",
3276
+ "aria-label": localeService.t(activatedTabTitle),
3277
+ children: /* @__PURE__ */ jsxs(ToolbarDropdownProvider, { children: [activeGroup.visibleGroups.map((groupItem) => {
3278
+ var _groupItem$children3, _groupItem$children4;
3279
+ return (((_groupItem$children3 = groupItem.children) === null || _groupItem$children3 === void 0 ? void 0 : _groupItem$children3.length) || groupItem.item) && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", {
3280
+ className: "univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2 empty:univer-hidden",
3281
+ children: groupItem.children && ((_groupItem$children4 = groupItem.children) === null || _groupItem$children4 === void 0 ? void 0 : _groupItem$children4.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, { ...child.item }, child.key)))
3282
+ }) }, groupItem.key);
3283
+ }), collapsedIds.length > 0 && /* @__PURE__ */ jsx("div", {
3284
+ className: "univer-pl-2 rtl:univer-pr-2",
3285
+ children: /* @__PURE__ */ jsx(Dropdown, {
3286
+ collisionPadding: {
3287
+ right: 12,
3288
+ left: 12
3289
+ },
3290
+ onOpenAutoFocus: (e) => e.preventDefault(),
3291
+ overlay: /* @__PURE__ */ jsx("div", {
3292
+ className: "univer-box-border univer-grid univer-max-w-[--radix-popper-available-width] univer-gap-2 univer-p-2",
3293
+ children: activeGroup.hiddenGroups.map((groupItem) => {
3294
+ var _groupItem$children5;
3295
+ return /* @__PURE__ */ jsx("div", {
3296
+ className: "univer-flex univer-items-center univer-gap-2",
3297
+ children: /* @__PURE__ */ jsx("div", {
3298
+ className: "univer-flex univer-flex-wrap univer-gap-2",
3299
+ children: groupItem.children ? (_groupItem$children5 = groupItem.children) === null || _groupItem$children5 === void 0 ? void 0 : _groupItem$children5.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, { ...child.item }, child.key)) : groupItem.item && /* @__PURE__ */ jsx(ToolbarItem, { ...groupItem.item }, groupItem.key)
3300
+ })
3301
+ }, groupItem.key);
3302
+ })
3303
+ }),
3304
+ children: /* @__PURE__ */ jsx("button", {
3305
+ type: "button",
3306
+ className: toolbarButtonClassName,
3307
+ children: /* @__PURE__ */ jsx(MoreVerticalIcon, {})
3308
+ })
3309
+ })
3310
+ })] }, activatedTab)
3085
3311
  })]
3086
- })]
3087
- }),
3088
- fakeToolbar
3089
- ] });
3312
+ }),
3313
+ fakeToolbar
3314
+ ] })
3315
+ });
3316
+ }
3317
+ function RibbonOverrideRuntimeProvider(props) {
3318
+ var _override$portalConta;
3319
+ const { override, children } = props;
3320
+ const config = useContext(ConfigContext);
3321
+ const injector = override === null || override === void 0 ? void 0 : override.injector;
3322
+ const ConnectedRibbonOverrideConfigProvider = useMemo(() => injector ? connectInjector(RibbonOverrideConfigProvider, injector) : null, [injector]);
3323
+ if (!override || !ConnectedRibbonOverrideConfigProvider) return children;
3324
+ return /* @__PURE__ */ jsx(ConnectedRibbonOverrideConfigProvider, {
3325
+ locale: config.locale,
3326
+ direction: config.direction,
3327
+ mountContainer: (_override$portalConta = override.portalContainer) !== null && _override$portalConta !== void 0 ? _override$portalConta : config.mountContainer,
3328
+ children
3329
+ });
3330
+ }
3331
+ function RibbonOverrideConfigProvider(props) {
3332
+ const { children, locale, direction, mountContainer } = props;
3333
+ return /* @__PURE__ */ jsx(ConfigProvider, {
3334
+ locale,
3335
+ direction,
3336
+ mountContainer,
3337
+ children
3338
+ });
3090
3339
  }
3091
3340
 
3092
3341
  //#endregion
@@ -3142,11 +3391,11 @@ var ContextMenuService = class extends Disposable {
3142
3391
  enable() {
3143
3392
  this.disabled = false;
3144
3393
  }
3145
- triggerContextMenu(event, menuType) {
3394
+ triggerContextMenu(event, menuType, context) {
3146
3395
  var _this$_currentHandler3;
3147
3396
  event.stopPropagation();
3148
3397
  if (this.disabled) return;
3149
- (_this$_currentHandler3 = this._currentHandler) === null || _this$_currentHandler3 === void 0 || _this$_currentHandler3.handleContextMenu(event, menuType);
3398
+ (_this$_currentHandler3 = this._currentHandler) === null || _this$_currentHandler3 === void 0 || _this$_currentHandler3.handleContextMenu(event, menuType, context);
3150
3399
  }
3151
3400
  hideContextMenu() {
3152
3401
  var _this$_currentHandler4;
@@ -3159,6 +3408,25 @@ var ContextMenuService = class extends Disposable {
3159
3408
  }
3160
3409
  };
3161
3410
 
3411
+ //#endregion
3412
+ //#region src/services/runtime-scope/ui-runtime-scope.service.ts
3413
+ const IUIRuntimeScopeService = createIdentifier("ui.runtime-scope.service");
3414
+ var UIRuntimeScopeService = class extends Disposable {
3415
+ constructor(..._args) {
3416
+ super(..._args);
3417
+ _defineProperty(this, "_scopes", /* @__PURE__ */ new Map());
3418
+ }
3419
+ register(scope) {
3420
+ this._scopes.set(scope.unitId, scope);
3421
+ return toDisposable(() => {
3422
+ if (this._scopes.get(scope.unitId) === scope) this._scopes.delete(scope.unitId);
3423
+ });
3424
+ }
3425
+ get(unitId) {
3426
+ return unitId ? this._scopes.get(unitId) : void 0;
3427
+ }
3428
+ };
3429
+
3162
3430
  //#endregion
3163
3431
  //#region src/services/contextmenu/contextmenu-host.service.ts
3164
3432
  const IContextMenuHostService = createIdentifier("ui.contextmenu.host.service");
@@ -3370,6 +3638,7 @@ function DesignTinyMenuGroup({ items, columns, sizeVariant = "default", layoutVa
3370
3638
  //#endregion
3371
3639
  //#region src/views/menu/desktop/TinyMenuGroup.tsx
3372
3640
  const EMPTY_HIDDEN_ITEM_IDS = [];
3641
+ const EMPTY_TINY_MENU_CHILDREN = [];
3373
3642
  const quickTileMenuButtonVariants = cva("univer-relative univer-box-border univer-flex univer-size-12 univer-w-full univer-appearance-none univer-flex-col univer-items-center univer-justify-center univer-gap-0.5 univer-rounded-lg univer-border-none univer-bg-white univer-p-0 univer-font-medium univer-text-gray-700 univer-outline-none univer-transition-all focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600 focus-visible:univer-ring-offset-0 dark:!univer-bg-gray-700 dark:!univer-text-gray-100", {
3374
3643
  variants: {
3375
3644
  disabled: {
@@ -3437,52 +3706,24 @@ function QuickTileMenuItem(props) {
3437
3706
  });
3438
3707
  }
3439
3708
  function UITinyMenuGroup(props) {
3709
+ var _item$children;
3440
3710
  const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, hoverSuppressed, columns, sizeVariant = "default", layoutVariant = "default", onOptionSelect } = props;
3441
- const [activeItems, setActiveItems] = useState([]);
3442
- const [hiddenItems, setHiddenItems] = useState([]);
3443
3711
  const iconManager = useDependency(IconManager);
3444
3712
  const localeService = useDependency(LocaleService);
3445
- useEffect(() => {
3446
- const { children } = item;
3447
- if (!children) return;
3448
- const observables = children.map((child) => {
3449
- var _child$item$activated, _child$item2;
3450
- return convertObservableToBehaviorSubject((_child$item$activated = (_child$item2 = child.item) === null || _child$item2 === void 0 ? void 0 : _child$item2.activated$) !== null && _child$item$activated !== void 0 ? _child$item$activated : of(false), false);
3451
- });
3452
- const subscription = combineLatest(observables).subscribe((activedArr) => {
3453
- const activeItems = [];
3454
- for (let index = 0; index < activedArr.length; index++) if (activedArr[index]) activeItems.push(getTinyMenuChildStateKey(children[index]));
3455
- setActiveItems(activeItems);
3456
- });
3457
- return () => {
3458
- subscription.unsubscribe();
3459
- observables.forEach((observable) => {
3460
- observable.complete();
3461
- });
3462
- };
3463
- }, [item]);
3464
- useEffect(() => {
3465
- const { children } = item;
3466
- if (!children) return;
3467
- const observables = children.map((child) => {
3468
- var _child$item$hidden$, _child$item3;
3469
- return convertObservableToBehaviorSubject((_child$item$hidden$ = (_child$item3 = child.item) === null || _child$item3 === void 0 ? void 0 : _child$item3.hidden$) !== null && _child$item$hidden$ !== void 0 ? _child$item$hidden$ : of(false), false);
3470
- });
3471
- const subscription = combineLatest(observables).subscribe((hiddenArr) => {
3472
- const hiddenItems = [];
3473
- for (let index = 0; index < hiddenArr.length; index++) if (hiddenArr[index]) hiddenItems.push(getTinyMenuChildStateKey(children[index]));
3474
- setHiddenItems(hiddenItems);
3475
- });
3476
- return () => {
3477
- subscription.unsubscribe();
3478
- observables.forEach((observable) => {
3479
- observable.complete();
3480
- });
3481
- };
3482
- }, [item]);
3713
+ const children = (_item$children = item.children) !== null && _item$children !== void 0 ? _item$children : EMPTY_TINY_MENU_CHILDREN;
3714
+ const activeItems$ = useMemo(() => children.length ? combineLatest(children.map((child) => {
3715
+ var _child$item$activated, _child$item2;
3716
+ return ((_child$item$activated = (_child$item2 = child.item) === null || _child$item2 === void 0 ? void 0 : _child$item2.activated$) !== null && _child$item$activated !== void 0 ? _child$item$activated : of(false)).pipe(startWith(false));
3717
+ })).pipe(map((states) => children.flatMap((child, index) => states[index] ? [getTinyMenuChildStateKey(child)] : []))) : of([]), [children]);
3718
+ const hiddenItems$ = useMemo(() => children.length ? combineLatest(children.map((child) => {
3719
+ var _child$item$hidden$, _child$item3;
3720
+ return ((_child$item$hidden$ = (_child$item3 = child.item) === null || _child$item3 === void 0 ? void 0 : _child$item3.hidden$) !== null && _child$item$hidden$ !== void 0 ? _child$item$hidden$ : of(false)).pipe(startWith(false));
3721
+ })).pipe(map((states) => children.flatMap((child, index) => states[index] ? [getTinyMenuChildStateKey(child)] : []))) : of([]), [children]);
3722
+ const activeItems = useObservable(activeItems$, []);
3723
+ const hiddenItems = useObservable(hiddenItems$, []);
3483
3724
  const visibleChildren = useMemo(() => {
3484
- var _item$children;
3485
- return getVisibleTinyMenuChildren((_item$children = item.children) !== null && _item$children !== void 0 ? _item$children : [], [...hiddenItems, ...hiddenItemIds]);
3725
+ var _item$children2;
3726
+ return getVisibleTinyMenuChildren((_item$children2 = item.children) !== null && _item$children2 !== void 0 ? _item$children2 : [], [...hiddenItems, ...hiddenItemIds]);
3486
3727
  }, [
3487
3728
  hiddenItemIds,
3488
3729
  hiddenItems,
@@ -3521,9 +3762,9 @@ function UITinyMenuGroup(props) {
3521
3762
  });
3522
3763
  }
3523
3764
  function UIQuickTileMenuGroup(props) {
3524
- var _item$children2;
3765
+ var _item$children3;
3525
3766
  const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, onOptionSelect } = props;
3526
- if (!((_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.length)) return null;
3767
+ if (!((_item$children3 = item.children) === null || _item$children3 === void 0 ? void 0 : _item$children3.length)) return null;
3527
3768
  return /* @__PURE__ */ jsx("div", {
3528
3769
  className: "univer-item-center univer-grid univer-grid-cols-3 univer-gap-1.5 univer-py-1",
3529
3770
  children: getVisibleTinyMenuChildren(item.children, hiddenItemIds).map((menuSchema) => /* @__PURE__ */ jsx(QuickTileMenuItem, {
@@ -3863,9 +4104,11 @@ function getContextMenuSubmenuPanelClassName(sizeVariant) {
3863
4104
  }
3864
4105
  function ContextMenuPanel(props) {
3865
4106
  var _layoutService$rootCo, _layoutService$rootCo2;
3866
- const { menuType, menuSessionVersion = 0, className, activeItemIds, hiddenItemIds, sizeVariant = "default", autoFocus, autoFocusTarget = "first-item", suppressHoverUntilPointerMove = false, onCancel, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
3867
- const menuManagerService = useDependency(IMenuManagerService);
3868
- const layoutService = useDependency(ILayoutService);
4107
+ const { menuType, menuManagerService: providedMenuManagerService, layoutService: providedLayoutService, menuSessionVersion = 0, className, activeItemIds, hiddenItemIds, sizeVariant = "default", autoFocus, autoFocusTarget = "first-item", suppressHoverUntilPointerMove = false, onCancel, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
4108
+ const rootMenuManagerService = useDependency(IMenuManagerService);
4109
+ const rootLayoutService = useDependency(ILayoutService);
4110
+ const menuManagerService = providedMenuManagerService !== null && providedMenuManagerService !== void 0 ? providedMenuManagerService : rootMenuManagerService;
4111
+ const layoutService = providedLayoutService !== null && providedLayoutService !== void 0 ? providedLayoutService : rootLayoutService;
3869
4112
  const [menuElement, setMenuElement] = useState(null);
3870
4113
  const [maxMenuHeight, setMaxMenuHeight] = useState(() => {
3871
4114
  if (typeof window === "undefined") return 240;
@@ -3968,6 +4211,7 @@ function ContextMenuPanel(props) {
3968
4211
  onWheel: (event) => event.stopPropagation(),
3969
4212
  children: /* @__PURE__ */ jsx(ContextMenuMenu, {
3970
4213
  menuSchemas: menuItems,
4214
+ menuManagerService,
3971
4215
  menuSessionVersion,
3972
4216
  submenuPortalContainer,
3973
4217
  rootMenuElement: menuElement,
@@ -3983,7 +4227,7 @@ function ContextMenuPanel(props) {
3983
4227
  });
3984
4228
  }
3985
4229
  function ContextMenuMenu(props) {
3986
- const { menuSchemas, menuSessionVersion, submenuPortalContainer, rootMenuElement, activeItemIds, hiddenItemIds, hoverSuppressed, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect, maxMenuHeight } = props;
4230
+ const { menuSchemas, menuManagerService, menuSessionVersion, submenuPortalContainer, rootMenuElement, activeItemIds, hiddenItemIds, hoverSuppressed, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect, maxMenuHeight } = props;
3987
4231
  const localeService = useDependency(LocaleService);
3988
4232
  const hiddenGroupStates = useContextGroupHiddenStates$1(menuSchemas);
3989
4233
  const [activeSubmenuKey, setActiveSubmenuKey] = useState(null);
@@ -4029,6 +4273,7 @@ function ContextMenuMenu(props) {
4029
4273
  if (menuSchema.item) return /* @__PURE__ */ jsx(ContextMenuMenuItem, {
4030
4274
  menuKey: menuSchema.key,
4031
4275
  menuItem: menuSchema.item,
4276
+ menuManagerService,
4032
4277
  menuSessionVersion,
4033
4278
  submenuPortalContainer,
4034
4279
  rootMenuElement,
@@ -4049,6 +4294,7 @@ function ContextMenuMenu(props) {
4049
4294
  children: menuSchema.children.map((childSchema) => childSchema.item && /* @__PURE__ */ jsx(ContextMenuMenuItem, {
4050
4295
  menuKey: childSchema.key,
4051
4296
  menuItem: childSchema.item,
4297
+ menuManagerService,
4052
4298
  menuSessionVersion,
4053
4299
  submenuPortalContainer,
4054
4300
  rootMenuElement,
@@ -4070,6 +4316,7 @@ function ContextMenuMenu(props) {
4070
4316
  children: [titleNode, menuSchema.children.map((childSchema) => childSchema.item && /* @__PURE__ */ jsx(ContextMenuMenuItem, {
4071
4317
  menuKey: childSchema.key,
4072
4318
  menuItem: childSchema.item,
4319
+ menuManagerService,
4073
4320
  menuSessionVersion,
4074
4321
  submenuPortalContainer,
4075
4322
  rootMenuElement,
@@ -4098,6 +4345,7 @@ function ContextMenuMenu(props) {
4098
4345
  children: [titleContent, /* @__PURE__ */ jsx(ContextMenuMenuItem, {
4099
4346
  menuKey: `${menuSchema.key}-header-action`,
4100
4347
  menuItem: menuSchema.headerActionItem,
4348
+ menuManagerService,
4101
4349
  menuSessionVersion,
4102
4350
  submenuPortalContainer,
4103
4351
  rootMenuElement,
@@ -4118,10 +4366,9 @@ function ContextMenuMenu(props) {
4118
4366
  }
4119
4367
  }
4120
4368
  function ContextMenuMenuItem(props) {
4121
- const { menuKey, menuItem, menuSessionVersion, submenuPortalContainer, rootMenuElement, maxMenuHeight, activeSubmenuKey, setActiveSubmenuKey, activeItemIds, hiddenItemIds = [], hoverSuppressed = false, compact = false, headerAction = false, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
4369
+ const { menuKey, menuItem, menuManagerService, menuSessionVersion, submenuPortalContainer, rootMenuElement, maxMenuHeight, activeSubmenuKey, setActiveSubmenuKey, activeItemIds, hiddenItemIds = [], hoverSuppressed = false, compact = false, headerAction = false, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
4122
4370
  const localeService = useDependency(LocaleService);
4123
4371
  const direction = useObservable(localeService.direction$);
4124
- const menuManagerService = useDependency(IMenuManagerService);
4125
4372
  const disabled = useObservable(menuItem.disabled$, false);
4126
4373
  const activated = useObservable(menuItem.activated$, false);
4127
4374
  const hidden = useObservable(menuItem.hidden$, false);
@@ -4253,6 +4500,7 @@ function ContextMenuMenuItem(props) {
4253
4500
  });
4254
4501
  const canExecuteItem = menuItem.type === 0 || menuItem.type === 2;
4255
4502
  const renderAsContainer = isNonSelectableLabel(menuItem.label);
4503
+ const SubmenuAffordanceIcon = direction === "rtl" ? MoreLeftIcon : MoreRightIcon;
4256
4504
  const interactiveItemClassName = clsx(itemClassName, isNonHoverableLabel(menuItem.label) && "hover:univer-bg-transparent dark:hover:!univer-bg-transparent");
4257
4505
  return /* @__PURE__ */ jsxs("div", {
4258
4506
  ref: menuItemElementRef,
@@ -4281,7 +4529,7 @@ function ContextMenuMenuItem(props) {
4281
4529
  children: [renderAsContainer ? /* @__PURE__ */ jsxs("div", {
4282
4530
  className: interactiveItemClassName,
4283
4531
  "aria-disabled": disabled,
4284
- children: [contentNode, hasSubmenu && /* @__PURE__ */ jsx(MoreRightIcon, { className: `
4532
+ children: [contentNode, hasSubmenu && /* @__PURE__ */ jsx(SubmenuAffordanceIcon, { className: `
4285
4533
  ${sizeVariant === "paragraph-t" ? "univer-size-4" : "univer-size-3.5"}
4286
4534
  univer-text-gray-400
4287
4535
  dark:!univer-text-gray-200
@@ -4324,7 +4572,7 @@ function ContextMenuMenuItem(props) {
4324
4572
  label: menuKey
4325
4573
  });
4326
4574
  },
4327
- children: [contentNode, hasSubmenu && !compact && /* @__PURE__ */ jsx(MoreRightIcon, { className: `
4575
+ children: [contentNode, hasSubmenu && !compact && /* @__PURE__ */ jsx(SubmenuAffordanceIcon, { className: `
4328
4576
  ${sizeVariant === "paragraph-t" ? "univer-size-4" : "univer-size-3.5"}
4329
4577
  univer-text-gray-400
4330
4578
  dark:!univer-text-gray-200
@@ -4332,7 +4580,7 @@ function ContextMenuMenuItem(props) {
4332
4580
  }), hasSubmenu && submenuVisible && (submenuPortalContainer ? createPortal(/* @__PURE__ */ jsx("div", {
4333
4581
  ref: submenuElementRef,
4334
4582
  dir: direction,
4335
- ["data-u-context-menu-submenu"]: "true",
4583
+ "data-u-context-menu-submenu": "true",
4336
4584
  className: "univer-z-[1080] univer-w-max univer-max-w-[calc(100vw-16px)]",
4337
4585
  style: {
4338
4586
  position: "fixed",
@@ -4371,7 +4619,7 @@ function ContextMenuMenuItem(props) {
4371
4619
  const optionSelected = typeof inputValue !== "undefined" && String(inputValue) === String(option.value);
4372
4620
  const optionSelectable = !isNonSelectableLabel(option.label);
4373
4621
  const optionHoverable = !isNonHoverableLabel(option.label);
4374
- const optionClassName = clsx(sizeVariant === "paragraph-t" ? "univer-relative univer-box-border univer-flex univer-min-h-10 univer-w-full univer-items-center univer-rounded-lg univer-border-none univer-bg-transparent univer-px-3 univer-text-left univer-text-base dark:!univer-text-white" : "univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-items-center univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm dark:!univer-text-white", option.disabled ? "univer-cursor-not-allowed univer-opacity-60" : optionHoverable && "univer-cursor-pointer hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-600");
4622
+ const optionClassName = clsx(optionSelectable ? sizeVariant === "paragraph-t" ? "univer-relative univer-box-border univer-flex univer-min-h-10 univer-w-full univer-items-center univer-rounded-lg univer-border-none univer-bg-transparent univer-px-3 univer-text-left univer-text-base dark:!univer-text-white" : "univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-items-center univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm dark:!univer-text-white" : "univer-relative univer-box-border univer-block univer-w-full univer-border-none univer-bg-transparent univer-p-0", option.disabled ? "univer-cursor-not-allowed univer-opacity-60" : optionHoverable && "univer-cursor-pointer hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-600");
4375
4623
  const optionContentNode = /* @__PURE__ */ jsxs(Fragment$1, { children: [optionSelectable && optionSelected && /* @__PURE__ */ jsx(CheckMarkIcon, { className: clsx("univer-absolute univer-left-0 univer-text-primary-600", sizeVariant === "paragraph-t" ? "univer-size-5" : "univer-size-4") }), /* @__PURE__ */ jsx("span", {
4376
4624
  className: clsx(getContextMenuContentClassName(sizeVariant), optionSelectable && optionSelected && "univer-pl-4"),
4377
4625
  children: /* @__PURE__ */ jsx(CustomLabel, {
@@ -4413,6 +4661,7 @@ function ContextMenuMenuItem(props) {
4413
4661
  })
4414
4662
  }), hasSubItemSubmenu && /* @__PURE__ */ jsx(ContextMenuMenu, {
4415
4663
  menuSchemas: subMenuItems,
4664
+ menuManagerService,
4416
4665
  menuSessionVersion,
4417
4666
  submenuPortalContainer,
4418
4667
  rootMenuElement,
@@ -4430,34 +4679,26 @@ function ContextMenuMenuItem(props) {
4430
4679
  });
4431
4680
  }
4432
4681
  function useContextGroupHiddenStates$1(menuSchemas) {
4433
- const [hiddenStates, setHiddenStates] = useState({});
4434
- useEffect(() => {
4435
- const subscriptions = menuSchemas.map((menuSchema) => {
4436
- var _menuSchema$children3;
4437
- if (!((_menuSchema$children3 = menuSchema.children) === null || _menuSchema$children3 === void 0 ? void 0 : _menuSchema$children3.length)) return null;
4438
- return combineLatest(menuSchema.children.map((childSchema) => {
4682
+ return useObservable(useMemo(() => {
4683
+ const groupStates = menuSchemas.flatMap((menuSchema) => {
4684
+ var _menuSchema$children$, _menuSchema$children3;
4685
+ const hiddenObservables = (_menuSchema$children$ = (_menuSchema$children3 = menuSchema.children) === null || _menuSchema$children3 === void 0 ? void 0 : _menuSchema$children3.map((childSchema) => {
4439
4686
  var _childSchema$item$hid, _childSchema$item;
4440
4687
  return (_childSchema$item$hid = (_childSchema$item = childSchema.item) === null || _childSchema$item === void 0 ? void 0 : _childSchema$item.hidden$) !== null && _childSchema$item$hid !== void 0 ? _childSchema$item$hid : of(false);
4441
- })).subscribe((hiddenValues) => {
4442
- const isAllHidden = hiddenValues.every((hidden) => hidden === true);
4443
- setHiddenStates((state) => ({
4444
- ...state,
4445
- [menuSchema.key]: isAllHidden
4446
- }));
4447
- });
4688
+ })) !== null && _menuSchema$children$ !== void 0 ? _menuSchema$children$ : [];
4689
+ return hiddenObservables.length ? [combineLatest(hiddenObservables).pipe(map((values) => [menuSchema.key, values.every(Boolean)]))] : [];
4448
4690
  });
4449
- return () => {
4450
- subscriptions.forEach((subscription) => subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe());
4451
- setHiddenStates({});
4452
- };
4453
- }, [menuSchemas]);
4454
- return hiddenStates;
4691
+ return groupStates.length ? merge$1(...groupStates).pipe(scan((states, [key, hidden]) => ({
4692
+ ...states,
4693
+ [key]: hidden
4694
+ }), {}), startWith({})) : of({});
4695
+ }, [menuSchemas]), {});
4455
4696
  }
4456
4697
 
4457
4698
  //#endregion
4458
4699
  //#region src/views/components/context-menu/AnchoredContextMenu.tsx
4459
4700
  function AnchoredContextMenu(props) {
4460
- const { hostId, visible, anchorRect, menuType, anchorVertical = "bottom", menuOffset = 0, onRequestClose, onOptionSelect } = props;
4701
+ const { hostId, visible, anchorRect, menuType, anchorVertical = "bottom", menuOffset = 0, menuManagerService, layoutService, onRequestClose, onOptionSelect } = props;
4461
4702
  const contentRef = useRef(null);
4462
4703
  const contextMenuHostService = useDependency(IContextMenuHostService);
4463
4704
  const onRequestCloseRef = useRef(onRequestClose);
@@ -4546,6 +4787,8 @@ function AnchoredContextMenu(props) {
4546
4787
  ref: contentRef,
4547
4788
  children: menuType && /* @__PURE__ */ jsx(ContextMenuPanel, {
4548
4789
  menuType,
4790
+ menuManagerService,
4791
+ layoutService,
4549
4792
  menuSessionVersion: menuSessionVersionRef.current,
4550
4793
  onOptionSelect
4551
4794
  })
@@ -4560,10 +4803,13 @@ function DesktopContextMenu() {
4560
4803
  const [visible, setVisible] = useState(false);
4561
4804
  const [menuType, setMenuType] = useState("");
4562
4805
  const [anchorRect, setAnchorRect] = useState(null);
4806
+ const [menuContext, setMenuContext] = useState();
4563
4807
  const visibleRef = useRef(visible);
4564
4808
  const contextMenuService = useDependency(IContextMenuService);
4565
4809
  const commandService = useDependency(ICommandService);
4566
- const injector = useInjector();
4810
+ const layoutService = useDependency(ILayoutService);
4811
+ const menuManagerService = useDependency(IMenuManagerService);
4812
+ const runtimeScopeService = useDependency(IUIRuntimeScopeService);
4567
4813
  visibleRef.current = visible;
4568
4814
  useEffect(() => {
4569
4815
  const disposables = contextMenuService.registerContextMenuHandler({
@@ -4580,10 +4826,11 @@ function DesktopContextMenu() {
4580
4826
  };
4581
4827
  }, [contextMenuService]);
4582
4828
  /** A function to open context menu with given position and menu type. */
4583
- function handleContextMenu(event, menuType) {
4829
+ function handleContextMenu(event, menuType, context) {
4584
4830
  setVisible(false);
4585
4831
  requestAnimationFrame(() => {
4586
4832
  setMenuType(menuType);
4833
+ setMenuContext(context);
4587
4834
  setAnchorRect({
4588
4835
  left: event.clientX,
4589
4836
  top: event.clientY,
@@ -4595,18 +4842,24 @@ function DesktopContextMenu() {
4595
4842
  function handleClose() {
4596
4843
  setVisible(false);
4597
4844
  }
4845
+ const activeScope = runtimeScopeService.get(menuContext === null || menuContext === void 0 ? void 0 : menuContext.unitId);
4846
+ const activeMenuManagerService = (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(IMenuManagerService)) ? activeScope.get(IMenuManagerService) : menuManagerService;
4847
+ const activeCommandService = (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(ICommandService)) ? activeScope.get(ICommandService) : commandService;
4848
+ const activeLayoutService = (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(ILayoutService)) ? activeScope.get(ILayoutService) : layoutService;
4598
4849
  return /* @__PURE__ */ jsx(AnchoredContextMenu, {
4599
4850
  hostId: DESKTOP_CONTEXT_MENU_HOST_ID,
4600
4851
  visible,
4601
4852
  anchorRect,
4602
4853
  menuType,
4854
+ menuManagerService: activeMenuManagerService,
4855
+ layoutService: activeLayoutService,
4603
4856
  onRequestClose: handleClose,
4604
4857
  onOptionSelect: (params) => {
4605
4858
  const { label: id, commandId, value } = params;
4606
4859
  const rawParams = typeof params.params === "function" ? params.params() : params.params;
4607
4860
  const commandParams = typeof rawParams === "undefined" ? { value } : rawParams;
4608
- if (commandService) commandService.executeCommand(commandId !== null && commandId !== void 0 ? commandId : id, commandParams);
4609
- injector.get(ILayoutService).focus();
4861
+ if (activeCommandService) activeCommandService.executeCommand(commandId !== null && commandId !== void 0 ? commandId : id, commandParams);
4862
+ activeLayoutService.focus();
4610
4863
  handleClose();
4611
4864
  }
4612
4865
  });
@@ -4617,6 +4870,7 @@ function DesktopContextMenu() {
4617
4870
  const MIN_SIDEBAR_WIDTH = 280;
4618
4871
  const MAX_SIDEBAR_WIDTH = 800;
4619
4872
  function Sidebar() {
4873
+ const localeService = useDependency(LocaleService);
4620
4874
  const sidebarService = useDependency(ISidebarService);
4621
4875
  const sidebarOptions = useObservable(sidebarService.sidebarOptions$);
4622
4876
  const scrollRef = useRef(null);
@@ -4723,7 +4977,7 @@ function Sidebar() {
4723
4977
  "data-u-comp": "sidebar",
4724
4978
  role: "complementary",
4725
4979
  "aria-expanded": !!(options === null || options === void 0 ? void 0 : options.visible),
4726
- "aria-label": "Sidebar panel",
4980
+ "aria-label": localeService.t("ui.sidebar.panel"),
4727
4981
  className: clsx("univer-relative univer-h-full univer-flex-shrink-0 univer-bg-white univer-text-gray-900 dark:!univer-bg-gray-900 dark:!univer-text-white", {
4728
4982
  "univer-w-96 univer-translate-x-0": options === null || options === void 0 ? void 0 : options.visible,
4729
4983
  "univer-w-0 univer-translate-x-full": !(options === null || options === void 0 ? void 0 : options.visible)
@@ -4734,7 +4988,7 @@ function Sidebar() {
4734
4988
  onMouseDown: handleResizeMouseDown,
4735
4989
  role: "separator",
4736
4990
  "aria-orientation": "vertical",
4737
- "aria-label": "Resize sidebar",
4991
+ "aria-label": localeService.t("ui.sidebar.resize"),
4738
4992
  tabIndex: 0,
4739
4993
  onKeyDown: (e) => {
4740
4994
  if (!sidebarRef.current) return;
@@ -4763,7 +5017,7 @@ function Sidebar() {
4763
5017
  type: "button",
4764
5018
  className: "focus:univer-ring-primary-500/50 univer-cursor-pointer univer-appearance-none univer-rounded-sm univer-border-none univer-bg-transparent univer-p-0 univer-text-gray-500 focus:univer-outline-none focus:univer-ring-2 dark:!univer-text-gray-300",
4765
5019
  onClick: handleClose,
4766
- "aria-label": "Close sidebar",
5020
+ "aria-label": localeService.t("ui.sidebar.close"),
4767
5021
  children: /* @__PURE__ */ jsx(CloseIcon, {})
4768
5022
  })]
4769
5023
  }),
@@ -5008,39 +5262,23 @@ function DesktopWorkbenchContent(props) {
5008
5262
  sub.unsubscribe();
5009
5263
  };
5010
5264
  }, []);
5011
- const [darkMode, setDarkMode] = useState(false);
5265
+ const darkMode = useObservable(themeService.darkMode$, themeService.darkMode);
5012
5266
  useLayoutEffect(() => {
5013
- const sub = themeService.darkMode$.subscribe((darkMode) => {
5014
- setDarkMode(darkMode);
5015
- if (darkMode) document.documentElement.classList.add("univer-dark");
5016
- else document.documentElement.classList.remove("univer-dark");
5017
- });
5018
- return () => {
5019
- sub.unsubscribe();
5020
- };
5021
- }, []);
5267
+ if (darkMode) document.documentElement.classList.add("univer-dark");
5268
+ else document.documentElement.classList.remove("univer-dark");
5269
+ }, [darkMode]);
5022
5270
  useEffect(() => {
5023
5271
  if (contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
5024
5272
  }, [onRendered]);
5025
- const [locale, setLocale] = useState(localeService.getLocales());
5026
- const [direction, setDirection] = useState(localeService.getDirection());
5273
+ const locale = useObservable(() => localeService.localeChanged$.pipe(map(() => localeService.getLocales())), localeService.getLocales(), false, [localeService]);
5274
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
5027
5275
  const portalContainer = useMemo(() => document.createElement("div"), []);
5028
5276
  useEffect(() => {
5029
5277
  document.body.appendChild(portalContainer);
5030
- const subscriptions = [localeService.localeChanged$.subscribe(() => {
5031
- setLocale(localeService.getLocales());
5032
- }), localeService.direction$.subscribe(() => {
5033
- setDirection(localeService.getDirection());
5034
- })];
5035
5278
  return () => {
5036
- subscriptions.forEach((subscription) => subscription.unsubscribe());
5037
5279
  document.body.removeChild(portalContainer);
5038
5280
  };
5039
- }, [
5040
- localeService,
5041
- mountContainer,
5042
- portalContainer
5043
- ]);
5281
+ }, [mountContainer, portalContainer]);
5044
5282
  useEffect(() => {
5045
5283
  portalContainer.dir = direction;
5046
5284
  }, [direction, portalContainer]);
@@ -5182,7 +5420,9 @@ var SingleUnitUIController = class extends Disposable {
5182
5420
  }));
5183
5421
  }
5184
5422
  _changeRenderUnit(rendererId, contentElement) {
5423
+ var _this$_instanceServic2;
5185
5424
  if (this._currentRenderId === rendererId) return false;
5425
+ if ((_this$_instanceServic2 = this._instanceService.getUnitCreateOptions(rendererId)) === null || _this$_instanceServic2 === void 0 ? void 0 : _this$_instanceServic2.embeddedRender) return false;
5186
5426
  const renderer = this._renderManagerService.getRenderById(rendererId);
5187
5427
  if (!renderer || !renderer.unitId || isInternalEditorID(renderer.unitId)) return false;
5188
5428
  const currentRenderer = this._currentRenderId ? this._renderManagerService.getRenderById(this._currentRenderId) : null;
@@ -5198,17 +5438,15 @@ var SingleUnitUIController = class extends Disposable {
5198
5438
  //#endregion
5199
5439
  //#region src/controllers/ui/ui-desktop.controller.ts
5200
5440
  let DesktopUIController = class DesktopUIController extends SingleUnitUIController {
5201
- constructor(_config, injector, lifecycleService, renderManagerService, layoutService, instanceService, menuManagerService, uiPartsService, _componentManager) {
5441
+ constructor(_config, injector, lifecycleService, renderManagerService, layoutService, instanceService, menuManagerService, uiPartsService) {
5202
5442
  super(injector, instanceService, layoutService, lifecycleService, renderManagerService);
5203
5443
  this._config = _config;
5204
- this._componentManager = _componentManager;
5205
5444
  menuManagerService.mergeMenu(menuSchema);
5206
5445
  this._initBuiltinComponents(uiPartsService);
5207
5446
  this._bootstrapWorkbench();
5208
5447
  }
5209
5448
  dispose() {
5210
5449
  super.dispose();
5211
- this._componentManager.dispose();
5212
5450
  }
5213
5451
  bootstrap(callback) {
5214
5452
  return bootstrap$1(this._injector, this._config, callback);
@@ -5226,8 +5464,7 @@ DesktopUIController = __decorate([
5226
5464
  __decorateParam(4, ILayoutService),
5227
5465
  __decorateParam(5, IUniverInstanceService),
5228
5466
  __decorateParam(6, IMenuManagerService),
5229
- __decorateParam(7, IUIPartsService),
5230
- __decorateParam(8, Inject(ComponentManager))
5467
+ __decorateParam(7, IUIPartsService)
5231
5468
  ], DesktopUIController);
5232
5469
  function bootstrap$1(injector, options, callback) {
5233
5470
  let mountContainer;
@@ -5260,7 +5497,7 @@ const IUIController = createIdentifier("univer.ui.ui-controller");
5260
5497
  //#endregion
5261
5498
  //#region package.json
5262
5499
  var name = "@univerjs/ui";
5263
- var version = "1.0.0-alpha.2";
5500
+ var version = "1.0.0-alpha.4";
5264
5501
 
5265
5502
  //#endregion
5266
5503
  //#region src/views/color-picker/interface.ts
@@ -20290,15 +20527,13 @@ function EmojiPicker(props) {
20290
20527
  children: [
20291
20528
  /* @__PURE__ */ jsxs("div", {
20292
20529
  className: "univer-flex univer-items-center univer-gap-1 univer-px-3 univer-pb-2 univer-pt-3",
20293
- children: [/* @__PURE__ */ jsxs("label", {
20294
- className: "univer-flex univer-h-8 univer-flex-1 univer-items-center univer-gap-1 univer-rounded-lg univer-border univer-border-solid univer-border-primary-500 univer-px-2 univer-text-gray-500 dark:!univer-border-primary-600 dark:!univer-text-gray-400",
20295
- children: [/* @__PURE__ */ jsx(SearchIcon, {}), /* @__PURE__ */ jsx(Input, {
20296
- "aria-label": localeService.t("ui.emojiPicker.search"),
20297
- placeholder: localeService.t("ui.emojiPicker.search"),
20298
- className: "univer-min-w-0 univer-flex-1",
20299
- value: query,
20300
- onChange: setQuery
20301
- })]
20530
+ children: [/* @__PURE__ */ jsx(Input, {
20531
+ "aria-label": localeService.t("ui.emojiPicker.search"),
20532
+ placeholder: localeService.t("ui.emojiPicker.search"),
20533
+ className: "univer-min-w-0 univer-flex-1",
20534
+ value: query,
20535
+ onChange: setQuery,
20536
+ slot: /* @__PURE__ */ jsx(SearchIcon, { className: "univer-size-4 univer-text-gray-500 dark:!univer-text-gray-400" })
20302
20537
  }), /* @__PURE__ */ jsx("button", {
20303
20538
  type: "button",
20304
20539
  "aria-label": localeService.t("ui.emojiPicker.random"),
@@ -20332,12 +20567,12 @@ function EmojiPicker(props) {
20332
20567
  className: clsx("univer-flex univer-h-10 univer-shrink-0 univer-items-center univer-border-gray-200 univer-px-2.5 dark:!univer-border-gray-600 [&_svg]:univer-size-5", borderTopClassName),
20333
20568
  children: [/* @__PURE__ */ jsx(CategoryButton, {
20334
20569
  selected: !isSearching && activeTab === "recent",
20335
- title: localeService.t("ui.emojiPicker.recents"),
20570
+ titleKey: "ui.emojiPicker.recents",
20336
20571
  onClick: () => scrollToSection("recent"),
20337
20572
  children: /* @__PURE__ */ jsx(RecentIcon, {})
20338
20573
  }), EMOJI_CATEGORIES.map((category) => /* @__PURE__ */ jsx(CategoryButton, {
20339
20574
  selected: !isSearching && activeTab === category.key,
20340
- title: localeService.t(category.titleKey),
20575
+ titleKey: category.titleKey,
20341
20576
  onClick: () => scrollToSection(category.key),
20342
20577
  children: /* @__PURE__ */ jsx(CategoryIcon, { category: category.key })
20343
20578
  }, category.key))]
@@ -20378,11 +20613,12 @@ function EmojiGrid(props) {
20378
20613
  });
20379
20614
  }
20380
20615
  function CategoryButton(props) {
20616
+ const localeService = useDependency(LocaleService);
20381
20617
  return /* @__PURE__ */ jsx("button", {
20382
20618
  type: "button",
20383
- "aria-label": props.title,
20619
+ "aria-label": localeService.t(props.titleKey),
20384
20620
  "aria-selected": props.selected,
20385
- title: props.title,
20621
+ title: localeService.t(props.titleKey),
20386
20622
  className: clsx("univer-flex univer-h-[30px] univer-flex-1 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-lg univer-border-0 univer-bg-transparent univer-p-0 univer-text-gray-500 dark:!univer-text-gray-400", props.selected ? "univer-bg-primary-50 univer-text-primary-500 dark:!univer-bg-gray-800 dark:!univer-text-primary-400" : "hover:univer-bg-gray-50 hover:univer-text-gray-700 dark:hover:!univer-bg-gray-800 dark:hover:!univer-text-gray-300"),
20387
20623
  onClick: props.onClick,
20388
20624
  children: props.children
@@ -20415,72 +20651,207 @@ function CategoryIcon(props) {
20415
20651
  //#region src/services/font.service.ts
20416
20652
  const IFontService = createIdentifier("univer.font-service");
20417
20653
  const DEFAULT_FONT_LIST = [
20418
- {
20419
- value: "Arial",
20420
- label: "ui.fontFamily.arial",
20421
- category: "sans-serif"
20422
- },
20423
- {
20424
- value: "Times New Roman",
20425
- label: "ui.fontFamily.times-new-roman",
20426
- category: "serif"
20427
- },
20428
- {
20429
- value: "Tahoma",
20430
- label: "ui.fontFamily.tahoma",
20431
- category: "sans-serif"
20432
- },
20433
- {
20434
- value: "Verdana",
20435
- label: "ui.fontFamily.verdana",
20436
- category: "sans-serif"
20437
- },
20438
- {
20439
- value: "Microsoft YaHei",
20440
- label: "ui.fontFamily.microsoft-yahei",
20441
- category: "sans-serif"
20442
- },
20443
- {
20444
- value: "SimSun",
20445
- label: "ui.fontFamily.simsun",
20446
- category: "serif"
20447
- },
20448
- {
20449
- value: "SimHei",
20450
- label: "ui.fontFamily.simhei",
20451
- category: "sans-serif"
20452
- },
20453
- {
20454
- value: "Kaiti",
20455
- label: "ui.fontFamily.kaiti",
20456
- category: "serif"
20457
- },
20458
- {
20459
- value: "FangSong",
20460
- label: "ui.fontFamily.fangsong",
20461
- category: "serif"
20462
- },
20463
- {
20464
- value: "NSimSun",
20465
- label: "ui.fontFamily.nsimsun",
20466
- category: "serif"
20467
- },
20468
- {
20469
- value: "STXinwei",
20470
- label: "ui.fontFamily.stxinwei",
20471
- category: "serif"
20472
- },
20473
- {
20474
- value: "STXingkai",
20475
- label: "ui.fontFamily.stxingkai",
20476
- category: "serif"
20477
- },
20478
- {
20479
- value: "STLiti",
20480
- label: "ui.fontFamily.stliti",
20481
- category: "serif"
20482
- }
20483
- ];
20654
+ "宋体",
20655
+ "Arial",
20656
+ "Baskerville",
20657
+ "Comic Sans MS",
20658
+ "Courier New",
20659
+ "Helvetica",
20660
+ "Times New Roman",
20661
+ "Verdana",
20662
+ "Apple LiGothic",
20663
+ "Apple LiSung",
20664
+ "Hei",
20665
+ "Kai",
20666
+ "LiHei Pro",
20667
+ "LiSong Pro",
20668
+ "STFangsong",
20669
+ "STHeiti",
20670
+ "STKaiti",
20671
+ "STSong",
20672
+ "报隶-繁",
20673
+ "报隶-简",
20674
+ "冬青黑体简体中文",
20675
+ "黑体-繁",
20676
+ "黑体-简",
20677
+ "华文仿宋",
20678
+ "华文楷体",
20679
+ "华文宋体",
20680
+ "楷体-繁",
20681
+ "楷体-简",
20682
+ "兰亭黑-繁",
20683
+ "兰亭黑-简",
20684
+ "隶变-繁",
20685
+ "隶变-简",
20686
+ "凌慧体-繁",
20687
+ "凌慧体-简",
20688
+ "翩翩体-繁",
20689
+ "翩翩体-简",
20690
+ "苹方-繁",
20691
+ "苹方-港",
20692
+ "苹方-简",
20693
+ "手札体-繁",
20694
+ "手札体-简",
20695
+ "宋体-繁",
20696
+ "宋体-简",
20697
+ "娃娃体-繁",
20698
+ "娃娃体-简",
20699
+ "魏碑-繁",
20700
+ "魏碑-简",
20701
+ "行楷-繁",
20702
+ "行楷-简",
20703
+ "雅痞-繁",
20704
+ "雅痞-简",
20705
+ "圆体-繁",
20706
+ "圆体-简",
20707
+ "Arial Black",
20708
+ "Big Caslon",
20709
+ "Courier",
20710
+ "Didot",
20711
+ "Futura",
20712
+ "Georgia",
20713
+ "Helvetica Neue",
20714
+ "Optima",
20715
+ "Times",
20716
+ "Tahoma",
20717
+ "BIZ UDGothic",
20718
+ "BIZ UDMincho",
20719
+ "Hiragino Maru Gothic Pro",
20720
+ "Hiragino Maru Gothic ProN",
20721
+ "Hiragino Mincho Pro",
20722
+ "Hiragino Mincho ProN",
20723
+ "Hiragino Sans",
20724
+ "Klee",
20725
+ "Osaka",
20726
+ "Toppan Bunkyu Gothic",
20727
+ "Toppan Bunkyu Midashi Gothic",
20728
+ "Toppan Bunkyu Midashi Mincho",
20729
+ "Toppan Bunkyu Mincho",
20730
+ "Tsukushi A Round Gothic",
20731
+ "Tsukushi B Round Gothic",
20732
+ "YuKyokasho",
20733
+ "YuKyokasho Yoko",
20734
+ "YuMincho +36p Kana",
20735
+ "American Typewriter",
20736
+ "Andale Mono",
20737
+ "Apple Chancery",
20738
+ "Apple SD Gothic Neo",
20739
+ "Apple Symbols",
20740
+ "AppleGothic",
20741
+ "AppleMyungjo",
20742
+ "Arial Unicode MS",
20743
+ "Athelas",
20744
+ "Avenir",
20745
+ "Avenir Next",
20746
+ "Avenir Next Condensed",
20747
+ "Ayuthaya",
20748
+ "Bangla MN",
20749
+ "Bangla Sangam MN",
20750
+ "Bauhaus 93",
20751
+ "Bodoni 72",
20752
+ "Bodoni 72 Oldstyle",
20753
+ "Bodoni 72 Smallcaps",
20754
+ "Bodoni Ornaments",
20755
+ "Bookshelf Symbol 7",
20756
+ "Bradley Hand",
20757
+ "Chalkboard",
20758
+ "Chalkboard SE",
20759
+ "Chalkduster",
20760
+ "Charter",
20761
+ "Cochin",
20762
+ "Copperplate",
20763
+ "Devanagari Sangam MN",
20764
+ "Din Alternate",
20765
+ "Euphemia UCAS",
20766
+ "Galvji",
20767
+ "Geneva",
20768
+ "Gill Sans",
20769
+ "Gujarati Sangam MN",
20770
+ "GungSeo",
20771
+ "Gurmukhi MN",
20772
+ "Gurmukhi Sangam MN",
20773
+ "HeadLineA",
20774
+ "Herculanum",
20775
+ "Hiragino Kaku Gothic Pro",
20776
+ "Hiragino Kaku Gothic ProN",
20777
+ "Hiragino Kaku Gothic Std",
20778
+ "Hiragino Kaku Gothic StdN",
20779
+ "Hoefler Text",
20780
+ "Impact",
20781
+ "InaiMathi",
20782
+ "Iowan Old Style",
20783
+ "Kannada MN",
20784
+ "Kannada Sangam MN",
20785
+ "Kefa",
20786
+ "Khmer MN",
20787
+ "Khmer Sangam MN",
20788
+ "Kohinoor Bangla",
20789
+ "Kohinoor Devanagari",
20790
+ "Kohinoor Telugu",
20791
+ "Krungthep",
20792
+ "Lao MN",
20793
+ "Lao Sangam MN",
20794
+ "Lucida Grande",
20795
+ "Luminari",
20796
+ "Malayalam MN",
20797
+ "Malayalam Sangam MN",
20798
+ "Marion",
20799
+ "Marker Felt",
20800
+ "Menlo",
20801
+ "Microsoft Sans Serif",
20802
+ "Modern No. 20",
20803
+ "Monaco",
20804
+ "Mukta Mahee",
20805
+ "Nanum Brush Script",
20806
+ "Nanum Gothic",
20807
+ "Nanum Myeongjo",
20808
+ "Nanum Pen Script",
20809
+ "Noteworthy",
20810
+ "Oriya MN",
20811
+ "Oriya Sangam MN",
20812
+ "Palatino",
20813
+ "Papyrus",
20814
+ "PCMyungjo",
20815
+ "Phosphate",
20816
+ "PilGi",
20817
+ "Plantagenet Cherokee",
20818
+ "PT Mono",
20819
+ "PT Sans",
20820
+ "PT Sans Caption",
20821
+ "PT Serif",
20822
+ "PT Serif Caption",
20823
+ "Rockwell",
20824
+ "Sathu",
20825
+ "Savoye LET",
20826
+ "Seravek",
20827
+ "Shree Devanagari 714",
20828
+ "SignPainter",
20829
+ "Silom",
20830
+ "Sinhala MN",
20831
+ "Sinhala Sangam MN",
20832
+ "Skia",
20833
+ "Snell Roundhand",
20834
+ "STIXGeneral",
20835
+ "Sukhumvit Set",
20836
+ "Superclarendon",
20837
+ "Tamil MN",
20838
+ "Tamil Sangam MN",
20839
+ "Telugu MN",
20840
+ "Telugu Sangam MN",
20841
+ "Trattatello",
20842
+ "Trebuchet MS",
20843
+ "Webdings",
20844
+ "Wingdings",
20845
+ "Wingdings 2",
20846
+ "Wingdings 3",
20847
+ "YuGothic",
20848
+ "YuGothic Light",
20849
+ "YuGothic Medium",
20850
+ "Zapfino"
20851
+ ].map((value) => ({
20852
+ value,
20853
+ label: value
20854
+ }));
20484
20855
  let FontService = class FontService {
20485
20856
  constructor(_configService) {
20486
20857
  this._configService = _configService;
@@ -20563,17 +20934,8 @@ FontService = __decorate([__decorateParam(0, IConfigService)], FontService);
20563
20934
  //#region src/views/font-family/use-font-list.ts
20564
20935
  function useFontList() {
20565
20936
  const fontService = useDependency(IFontService);
20566
- const [fonts, setFonts] = useState(() => fontService.getFonts());
20567
- useEffect(() => {
20568
- const subscription = fontService.fonts$.subscribe((fonts) => {
20569
- setFonts(fonts);
20570
- });
20571
- return () => {
20572
- subscription.unsubscribe();
20573
- };
20574
- }, [fontService]);
20575
20937
  return {
20576
- fonts,
20938
+ fonts: useObservable(fontService.fonts$, fontService.getFonts()),
20577
20939
  fontService
20578
20940
  };
20579
20941
  }
@@ -20652,11 +21014,13 @@ const FontFamily = ({ className, disabled: disabledProp, value, disabled$, onCha
20652
21014
  const FONT_FAMILY_ITEM_COMPONENT = "UI_FONT_FAMILY_ITEM_COMPONENT";
20653
21015
  const FontFamilyItem = ({ value, onChange }) => {
20654
21016
  const localeService = useDependency(LocaleService);
21017
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
20655
21018
  const { fonts, fontService } = useFontList();
20656
21019
  function handleSelectFont(nextValue) {
20657
21020
  onChange(nextValue);
20658
21021
  }
20659
21022
  return /* @__PURE__ */ jsx("ul", {
21023
+ dir: direction,
20660
21024
  className: "univer-m-0 univer-list-none univer-p-0 univer-text-sm",
20661
21025
  style: { fontFamily: value },
20662
21026
  children: fonts.map((font) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("button", {
@@ -20676,6 +21040,8 @@ const FontFamilyItem = ({ value, onChange }) => {
20676
21040
  //#region src/views/font-family/FontFamilyDropdown.tsx
20677
21041
  function FontFamilyDropdown(props) {
20678
21042
  const { value, onChange, ariaLabel, className, disabled: disabledProp, disabled$, inputClassName, popupClassName, popupDataComponent, title, onMouseDown, onPointerDown } = props;
21043
+ const localeService = useDependency(LocaleService);
21044
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
20679
21045
  const disabledObservableValue = useObservable(disabled$);
20680
21046
  const disabled = Boolean(disabledProp || disabledObservableValue);
20681
21047
  const [open, setOpen] = useState(false);
@@ -20689,6 +21055,7 @@ function FontFamilyDropdown(props) {
20689
21055
  open,
20690
21056
  onOpenChange: setOpen,
20691
21057
  overlay: /* @__PURE__ */ jsx("div", {
21058
+ dir: direction,
20692
21059
  className: clsx("univer-max-h-72 univer-min-w-44 univer-overflow-y-auto univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-p-1 univer-shadow-lg dark:!univer-border-gray-700 dark:!univer-bg-gray-900", popupClassName),
20693
21060
  ...popupDataAttributes,
20694
21061
  children: /* @__PURE__ */ jsx(FontFamilyItem, {
@@ -20700,6 +21067,7 @@ function FontFamilyDropdown(props) {
20700
21067
  "aria-disabled": disabled,
20701
21068
  "aria-expanded": open,
20702
21069
  "aria-label": ariaLabel,
21070
+ dir: direction,
20703
21071
  className: clsx("univer-flex univer-h-6 univer-min-w-0 univer-cursor-default univer-items-center univer-justify-between univer-gap-1 univer-rounded-md univer-px-1.5 univer-text-sm univer-text-gray-900 hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700", { "univer-cursor-not-allowed univer-opacity-60": disabled }, className),
20704
21072
  role: "combobox",
20705
21073
  tabIndex: disabled ? -1 : 0,
@@ -20864,6 +21232,97 @@ const HeadingItem = (props) => {
20864
21232
  };
20865
21233
  const HEADING_ITEM_COMPONENT = "UI_COMPONENT_HEADING_ITEM";
20866
21234
 
21235
+ //#endregion
21236
+ //#region src/views/slider/ZoomInput.tsx
21237
+ function ZoomInput(props) {
21238
+ const iconManager = useDependency(IconManager);
21239
+ const { value = 100, min = 0, max = 400, shortcuts, disabled = false, className, onChange } = props;
21240
+ const isEditingRef = useRef(false);
21241
+ const [listVisible, setListVisible] = useState(false);
21242
+ const [inputValue, setInputValue] = useState(() => `${value}%`);
21243
+ useEffect(() => {
21244
+ if (!isEditingRef.current) setInputValue(`${value}%`);
21245
+ }, [value]);
21246
+ function clampValue(value) {
21247
+ return Math.min(Math.max(value, min), max);
21248
+ }
21249
+ function handleSelect(value) {
21250
+ if (disabled) return;
21251
+ setListVisible(false);
21252
+ onChange === null || onChange === void 0 || onChange(value);
21253
+ }
21254
+ function parseInput(rawValue) {
21255
+ const normalizedValue = rawValue.trim().replace(/%$/, "").trim();
21256
+ if (normalizedValue === "") return null;
21257
+ const parsedValue = Number(normalizedValue);
21258
+ if (!Number.isFinite(parsedValue)) return null;
21259
+ return Math.round(clampValue(parsedValue));
21260
+ }
21261
+ function handleFocus() {
21262
+ if (disabled) return;
21263
+ isEditingRef.current = true;
21264
+ setInputValue(String(value));
21265
+ }
21266
+ function commitInput() {
21267
+ if (disabled || !isEditingRef.current) return;
21268
+ const parsedValue = parseInput(inputValue);
21269
+ isEditingRef.current = false;
21270
+ if (parsedValue == null) {
21271
+ setInputValue(`${value}%`);
21272
+ return;
21273
+ }
21274
+ setInputValue(`${parsedValue}%`);
21275
+ if (parsedValue !== value) onChange === null || onChange === void 0 || onChange(parsedValue);
21276
+ }
21277
+ function handleKeyDown(e) {
21278
+ e.stopPropagation();
21279
+ if (e.key === "Enter") {
21280
+ e.preventDefault();
21281
+ commitInput();
21282
+ e.currentTarget.blur();
21283
+ }
21284
+ }
21285
+ const items = [{
21286
+ type: "radio",
21287
+ value: value.toString(),
21288
+ options: shortcuts.map((item) => ({
21289
+ value: item.toString(),
21290
+ label: `${item}%`
21291
+ })),
21292
+ onSelect: (value) => handleSelect(+value)
21293
+ }];
21294
+ const MoreDownIcon = iconManager.get("MoreDownIcon");
21295
+ return /* @__PURE__ */ jsxs("div", {
21296
+ className: clsx("univer-flex univer-h-6 univer-w-[68px] univer-flex-shrink-0 univer-items-center univer-overflow-hidden univer-rounded-md univer-border univer-border-gray-200 univer-bg-white dark:!univer-border-gray-600 dark:!univer-bg-gray-800", className, { "univer-opacity-60": disabled }),
21297
+ onClick: (e) => e.stopPropagation(),
21298
+ children: [/* @__PURE__ */ jsx(Input, {
21299
+ className: "univer-box-border univer-h-6 univer-w-[52px] univer-border-none univer-bg-transparent [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-[52px] [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-px-1 [&_input]:univer-text-center [&_input]:univer-text-xs [&_input]:univer-tabular-nums",
21300
+ inputClass: "univer-w-[52px]",
21301
+ size: "mini",
21302
+ value: inputValue,
21303
+ disabled,
21304
+ type: "text",
21305
+ onChange: setInputValue,
21306
+ onFocus: handleFocus,
21307
+ onBlur: commitInput,
21308
+ onKeyDown: handleKeyDown
21309
+ }), /* @__PURE__ */ jsx(DropdownMenu, {
21310
+ align: "end",
21311
+ items,
21312
+ open: listVisible,
21313
+ disabled,
21314
+ onOpenChange: setListVisible,
21315
+ children: /* @__PURE__ */ jsx(Button, {
21316
+ className: "univer-h-6 univer-w-4 univer-rounded-none univer-p-0",
21317
+ size: "small",
21318
+ variant: "text",
21319
+ disabled,
21320
+ children: /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-size-3 univer-text-gray-500 dark:!univer-text-gray-300" })
21321
+ })
21322
+ })]
21323
+ });
21324
+ }
21325
+
20867
21326
  //#endregion
20868
21327
  //#region src/views/slider/Slider.tsx
20869
21328
  const SLIDER_WIDTH = 116;
@@ -20878,18 +21337,12 @@ function Slider(props) {
20878
21337
  const { value, min = 0, max = 400, disabled = false, resetPoint = 100, shortcuts, onChange } = props;
20879
21338
  const isRtl = useObservable(localeService.direction$, localeService.getDirection()) === "rtl";
20880
21339
  const sliderInnerRailRef = useRef(null);
20881
- const isEditingZoomRef = useRef(false);
20882
21340
  const dragValueRef = useRef(value);
20883
21341
  const pendingDragValueRef = useRef(null);
20884
21342
  const lastCommittedDragValueRef = useRef(value);
20885
21343
  const dragCommitTimerRef = useRef(null);
20886
- const [zoomListVisible, setZoomListVisible] = useState(false);
20887
21344
  const [isDragging, setIsDragging] = useState(false);
20888
21345
  const [dragValue, setDragValue] = useState(value);
20889
- const [zoomInputValue, setZoomInputValue] = useState(() => `${value}%`);
20890
- useEffect(() => {
20891
- if (!isEditingZoomRef.current) setZoomInputValue(`${value}%`);
20892
- }, [value]);
20893
21346
  useEffect(() => () => {
20894
21347
  clearDragCommitTimer();
20895
21348
  }, []);
@@ -20988,61 +21441,11 @@ function Slider(props) {
20988
21441
  window.addEventListener("pointerup", onPointerUp);
20989
21442
  window.addEventListener("pointerout", onPointerOut);
20990
21443
  }
20991
- function handleSelectZoomLevel(value) {
20992
- if (disabled) return;
20993
- setZoomListVisible(false);
20994
- onChange && onChange(value);
20995
- }
20996
- function parseExactZoomInput(rawValue) {
20997
- const normalizedValue = rawValue.trim().replace(/%$/, "").trim();
20998
- if (normalizedValue === "") return null;
20999
- const parsedValue = Number(normalizedValue);
21000
- if (!Number.isFinite(parsedValue)) return null;
21001
- return Math.round(clampValue(parsedValue));
21002
- }
21003
- function handleExactZoomFocus() {
21004
- if (disabled) return;
21005
- isEditingZoomRef.current = true;
21006
- setZoomInputValue(String(value));
21007
- }
21008
- function commitExactZoomInput() {
21009
- if (disabled) return;
21010
- if (!isEditingZoomRef.current) return;
21011
- const parsedValue = parseExactZoomInput(zoomInputValue);
21012
- isEditingZoomRef.current = false;
21013
- if (parsedValue == null) {
21014
- setZoomInputValue(`${value}%`);
21015
- return;
21016
- }
21017
- setZoomInputValue(`${parsedValue}%`);
21018
- if (parsedValue !== value) onChange && onChange(parsedValue);
21019
- }
21020
- function handleExactZoomChange(value) {
21021
- setZoomInputValue(value);
21022
- }
21023
- function handleInputKeyDown(e) {
21024
- e.stopPropagation();
21025
- if (e.key === "Enter") {
21026
- e.preventDefault();
21027
- commitExactZoomInput();
21028
- e.currentTarget.blur();
21029
- }
21030
- }
21031
- const items = [{
21032
- type: "radio",
21033
- value: value.toString(),
21034
- options: shortcuts.map((item) => ({
21035
- value: item.toString(),
21036
- label: `${item}%`
21037
- })),
21038
- onSelect: (value) => handleSelectZoomLevel(+value)
21039
- }];
21040
21444
  const visualValue = isDragging ? dragValue : value;
21041
21445
  const sliderOffset = Math.min(Math.max((_getSliderOffset = getSliderOffset(visualValue)) !== null && _getSliderOffset !== void 0 ? _getSliderOffset : 0, 0), 100);
21042
21446
  const handleOffset = isRtl ? 100 - sliderOffset : sliderOffset;
21043
21447
  const ReduceIcon = iconManager.get("ReduceIcon");
21044
21448
  const IncreaseIcon = iconManager.get("IncreaseIcon");
21045
- const MoreDownIcon = iconManager.get("MoreDownIcon");
21046
21449
  return /* @__PURE__ */ jsxs("div", {
21047
21450
  className: clsx("univer-flex univer-select-none univer-items-center univer-gap-1.5", { "univer-cursor-not-allowed": disabled }),
21048
21451
  children: [
@@ -21100,33 +21503,13 @@ function Slider(props) {
21100
21503
  onClick: () => handleStep(10),
21101
21504
  children: /* @__PURE__ */ jsx(IncreaseIcon, { className: "univer-text-gray-500" })
21102
21505
  }),
21103
- /* @__PURE__ */ jsxs("div", {
21104
- className: clsx("univer-flex univer-h-6 univer-w-[68px] univer-flex-shrink-0 univer-items-center univer-overflow-hidden univer-rounded-md univer-border univer-border-gray-200 univer-bg-white dark:!univer-border-gray-600 dark:!univer-bg-gray-800", { "univer-opacity-60": disabled }),
21105
- children: [/* @__PURE__ */ jsx(Input, {
21106
- className: "univer-box-border univer-h-6 univer-w-[52px] univer-border-none univer-bg-transparent [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-[52px] [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-px-1 [&_input]:univer-text-center [&_input]:univer-text-xs [&_input]:univer-tabular-nums",
21107
- inputClass: "univer-w-[52px]",
21108
- size: "mini",
21109
- value: zoomInputValue,
21110
- disabled,
21111
- type: "text",
21112
- onChange: handleExactZoomChange,
21113
- onFocus: handleExactZoomFocus,
21114
- onBlur: commitExactZoomInput,
21115
- onKeyDown: handleInputKeyDown
21116
- }), /* @__PURE__ */ jsx(DropdownMenu, {
21117
- align: "end",
21118
- items,
21119
- open: zoomListVisible,
21120
- disabled,
21121
- onOpenChange: setZoomListVisible,
21122
- children: /* @__PURE__ */ jsx(Button, {
21123
- className: "univer-h-6 univer-w-4 univer-rounded-none univer-p-0",
21124
- size: "small",
21125
- variant: "text",
21126
- disabled,
21127
- children: /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-size-3 univer-text-gray-500 dark:!univer-text-gray-300" })
21128
- })
21129
- })]
21506
+ /* @__PURE__ */ jsx(ZoomInput, {
21507
+ value,
21508
+ min,
21509
+ max,
21510
+ shortcuts,
21511
+ disabled,
21512
+ onChange
21130
21513
  })
21131
21514
  ]
21132
21515
  });
@@ -21159,11 +21542,13 @@ let ComponentsController = class ComponentsController extends Disposable {
21159
21542
  }
21160
21543
  _registerIcons() {
21161
21544
  this.disposeWithMe(this._iconManager.register({
21545
+ ExpandIcon,
21162
21546
  IncreaseIcon,
21163
21547
  MoreDownIcon,
21164
21548
  RedoIcon,
21165
21549
  ReduceIcon,
21166
21550
  ShortcutIcon,
21551
+ ShrinkIcon,
21167
21552
  UndoIcon
21168
21553
  }));
21169
21554
  }
@@ -21187,14 +21572,6 @@ ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)),
21187
21572
  //#endregion
21188
21573
  //#region src/views/components/ribbon/MobileRibbon.tsx
21189
21574
  const toolbarScrollOffset = 168;
21190
- const nestedControlResetClassName = `
21191
- [&_button]:!univer-m-0 [&_button]:!univer-appearance-none [&_button]:!univer-border-0
21192
- [&_button]:!univer-bg-transparent [&_button]:!univer-p-0 [&_button]:!univer-leading-none
21193
- [&_button]:!univer-outline-none
21194
- [&_input]:!univer-m-0 [&_input]:!univer-appearance-none [&_input]:!univer-border-0
21195
- [&_input]:!univer-bg-transparent [&_input]:!univer-p-0 [&_input]:!univer-leading-none
21196
- [&_input]:!univer-outline-none
21197
- `;
21198
21575
  function MobileRibbon(props) {
21199
21576
  var _activeGroup$children;
21200
21577
  const { headerMenuComponents, headerMenu = true } = props;
@@ -21262,7 +21639,7 @@ function MobileRibbon(props) {
21262
21639
  type: "button",
21263
21640
  className: clsx(resetButtonClassName, "univer-size-7 univer-rounded-md univer-text-gray-500 univer-transition-colors hover:univer-bg-gray-100 active:univer-bg-gray-200 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700 dark:active:!univer-bg-gray-600", { "univer-opacity-40": activeIndex === 0 }),
21264
21641
  disabled: activeIndex === 0,
21265
- "aria-label": "Previous",
21642
+ "aria-label": localeService.t("ui.navigation.previous"),
21266
21643
  onClick: () => selectTab(activeIndex - 1),
21267
21644
  children: /* @__PURE__ */ jsx(MoreLeftIcon, { className: "univer-rotate-180 univer-text-sm" })
21268
21645
  })
@@ -21299,7 +21676,7 @@ function MobileRibbon(props) {
21299
21676
  dark:active:!univer-bg-gray-600
21300
21677
  `, { "univer-opacity-40": activeIndex >= ribbon.length - 1 }),
21301
21678
  disabled: activeIndex >= ribbon.length - 1,
21302
- "aria-label": "Next",
21679
+ "aria-label": localeService.t("ui.navigation.next"),
21303
21680
  onClick: () => selectTab(activeIndex + 1),
21304
21681
  children: /* @__PURE__ */ jsx(MoreRightIcon, { className: "univer-text-sm" })
21305
21682
  }), hasHeaderMenu && /* @__PURE__ */ jsx("div", {
@@ -21319,7 +21696,7 @@ function MobileRibbon(props) {
21319
21696
  dark:!univer-text-gray-300
21320
21697
  `, { "univer-opacity-30": !canScrollLeft }),
21321
21698
  disabled: !canScrollLeft,
21322
- "aria-label": "Previous",
21699
+ "aria-label": localeService.t("ui.navigation.previous"),
21323
21700
  onClick: () => scrollToolbar("left"),
21324
21701
  children: /* @__PURE__ */ jsx(MoreLeftIcon, { className: "univer-text-sm" })
21325
21702
  }),
@@ -21334,7 +21711,7 @@ function MobileRibbon(props) {
21334
21711
  return /* @__PURE__ */ jsx("div", {
21335
21712
  className: clsx("univer-flex univer-shrink-0 univer-items-center univer-gap-0.5 univer-pr-1.5 rtl:univer-pl-1.5 rtl:univer-pr-0", { [borderRightClassName]: groupIndex !== activeGroups.length - 1 }),
21336
21713
  children: groupItems.map((child) => child.item && /* @__PURE__ */ jsx("div", {
21337
- className: clsx("[&_button]:!univer-font-inherit univer-flex univer-h-8 univer-shrink-0 univer-items-center univer-rounded-md [&_*]:univer-box-border [&_.univer-custom-label]:univer-text-sm [&_.univer-custom-label]:univer-leading-none [&_.univer-toolbar-button-selector-main]:!univer-h-8 [&_.univer-toolbar-button-selector-main]:!univer-rounded-none [&_.univer-toolbar-button-selector-main]:!univer-rounded-l-md [&_.univer-toolbar-button-selector-main]:!univer-px-1.5 [&_.univer-toolbar-button-selector-root]:!univer-h-8 [&_.univer-toolbar-button-selector-root]:univer-overflow-hidden [&_.univer-toolbar-button-selector-root]:!univer-rounded-md [&_.univer-toolbar-button-selector-root]:!univer-pr-0 [&_.univer-toolbar-button-selector-trigger]:!univer-static [&_.univer-toolbar-button-selector-trigger]:!univer-h-8 [&_.univer-toolbar-button-selector-trigger]:!univer-w-6 [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-none [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-r-md [&_.univer-toolbar-selector-root]:!univer-h-8 [&_.univer-toolbar-selector-root]:!univer-gap-1 [&_.univer-toolbar-selector-root]:!univer-rounded-md [&_.univer-toolbar-selector-root]:!univer-px-1.5 [&_.univer-toolbar-selector-trigger]:!univer-pl-0.5 [&_.univer-tooltip]:univer-inline-flex [&_.univer-tooltip]:univer-h-full [&_.univer-tooltip]:univer-items-center [&_[data-u-command]]:!univer-h-8 [&_[data-u-command]]:!univer-min-h-8 [&_[data-u-command]]:!univer-rounded-md [&_[data-u-command]]:!univer-px-1.5 [&_button]:!univer-h-8 [&_button]:!univer-min-w-8 [&_button]:!univer-rounded-md [&_button]:!univer-px-1.5", nestedControlResetClassName),
21714
+ className: clsx("[&_button]:!univer-font-inherit univer-flex univer-h-8 univer-shrink-0 univer-items-center univer-rounded-md [&_*]:univer-box-border [&_.univer-custom-label]:univer-text-sm [&_.univer-custom-label]:univer-leading-none [&_.univer-toolbar-button-selector-main]:!univer-h-8 [&_.univer-toolbar-button-selector-main]:!univer-rounded-none [&_.univer-toolbar-button-selector-main]:!univer-rounded-l-md [&_.univer-toolbar-button-selector-main]:!univer-px-1.5 [&_.univer-toolbar-button-selector-root]:!univer-h-8 [&_.univer-toolbar-button-selector-root]:univer-overflow-hidden [&_.univer-toolbar-button-selector-root]:!univer-rounded-md [&_.univer-toolbar-button-selector-root]:!univer-pr-0 [&_.univer-toolbar-button-selector-trigger]:!univer-static [&_.univer-toolbar-button-selector-trigger]:!univer-h-8 [&_.univer-toolbar-button-selector-trigger]:!univer-w-6 [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-none [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-r-md [&_.univer-toolbar-selector-root]:!univer-h-8 [&_.univer-toolbar-selector-root]:!univer-gap-1 [&_.univer-toolbar-selector-root]:!univer-rounded-md [&_.univer-toolbar-selector-root]:!univer-px-1.5 [&_.univer-toolbar-selector-trigger]:!univer-pl-0.5 [&_.univer-tooltip]:univer-inline-flex [&_.univer-tooltip]:univer-h-full [&_.univer-tooltip]:univer-items-center [&_[data-u-command]]:!univer-h-8 [&_[data-u-command]]:!univer-min-h-8 [&_[data-u-command]]:!univer-rounded-md [&_[data-u-command]]:!univer-px-1.5 [&_button]:!univer-m-0 [&_button]:!univer-h-8 [&_button]:!univer-min-w-8 [&_button]:!univer-appearance-none [&_button]:!univer-rounded-md [&_button]:!univer-border-0 [&_button]:!univer-bg-transparent [&_button]:!univer-p-0 [&_button]:!univer-px-1.5 [&_button]:!univer-leading-none [&_button]:!univer-outline-none [&_input]:!univer-m-0 [&_input]:!univer-appearance-none [&_input]:!univer-border-0 [&_input]:!univer-bg-transparent [&_input]:!univer-p-0 [&_input]:!univer-leading-none [&_input]:!univer-outline-none"),
21338
21715
  children: /* @__PURE__ */ jsx(ToolbarItem, { ...child.item })
21339
21716
  }, child.key))
21340
21717
  }, groupItem.key);
@@ -21348,7 +21725,7 @@ function MobileRibbon(props) {
21348
21725
  dark:!univer-text-gray-300
21349
21726
  `, { "univer-opacity-30": !canScrollRight }),
21350
21727
  disabled: !canScrollRight,
21351
- "aria-label": "Next",
21728
+ "aria-label": localeService.t("ui.navigation.next"),
21352
21729
  onClick: () => scrollToolbar("right"),
21353
21730
  children: /* @__PURE__ */ jsx(MoreRightIcon, { className: "univer-text-sm" })
21354
21731
  })
@@ -21361,8 +21738,10 @@ function MobileRibbon(props) {
21361
21738
  //#region src/views/menu/mobile/MobileMenu.tsx
21362
21739
  function MobileMenu(props) {
21363
21740
  var _viewStack;
21364
- const { menuType, onOptionSelect, schemas: providedSchemas } = props;
21365
- const menuManagerService = useDependency(IMenuManagerService);
21741
+ const { menuType, onOptionSelect, schemas: providedSchemas, menuManagerService: providedMenuManagerService } = props;
21742
+ const rootMenuManagerService = useDependency(IMenuManagerService);
21743
+ const localeService = useDependency(LocaleService);
21744
+ const menuManagerService = providedMenuManagerService !== null && providedMenuManagerService !== void 0 ? providedMenuManagerService : rootMenuManagerService;
21366
21745
  const [viewStack, setViewStack] = useState([]);
21367
21746
  const menuSchemas = useMemo(() => {
21368
21747
  if (providedSchemas) return providedSchemas;
@@ -21390,7 +21769,7 @@ function MobileMenu(props) {
21390
21769
  children: [
21391
21770
  /* @__PURE__ */ jsx("button", {
21392
21771
  type: "button",
21393
- "aria-label": "Back",
21772
+ "aria-label": localeService.t("ui.navigation.back"),
21394
21773
  className: "univer-flex univer-size-8 univer-appearance-none univer-items-center univer-justify-center univer-rounded-full univer-border-0 univer-bg-transparent univer-p-0 univer-text-gray-700 hover:univer-bg-gray-100 active:univer-bg-gray-200",
21395
21774
  onClick: closeView,
21396
21775
  children: /* @__PURE__ */ jsx(MoreLeftIcon, { className: "univer-text-base" })
@@ -21410,6 +21789,7 @@ function MobileMenu(props) {
21410
21789
  className: "univer-overflow-hidden univer-rounded-2xl univer-bg-white",
21411
21790
  children: /* @__PURE__ */ jsx(MobileSchemaList, {
21412
21791
  schemas: (currentView === null || currentView === void 0 ? void 0 : currentView.kind) === "schema" ? currentView.schemas : menuSchemas,
21792
+ menuManagerService,
21413
21793
  menuType,
21414
21794
  onExecute: onOptionSelect,
21415
21795
  onOpenView: openView
@@ -21428,7 +21808,7 @@ function MobileMenu(props) {
21428
21808
  });
21429
21809
  }
21430
21810
  function MobileSchemaList(props) {
21431
- const { schemas, menuType, onExecute, onOpenView } = props;
21811
+ const { schemas, menuManagerService, menuType, onExecute, onOpenView } = props;
21432
21812
  const localeService = useDependency(LocaleService);
21433
21813
  const hiddenGroupStates = useContextGroupHiddenStates(schemas);
21434
21814
  const visibleSchemas = useMemo(() => {
@@ -21442,6 +21822,7 @@ function MobileSchemaList(props) {
21442
21822
  var _schema$children2;
21443
21823
  if (schema.item) return /* @__PURE__ */ jsx(MobileSchemaRow, {
21444
21824
  schema,
21825
+ menuManagerService,
21445
21826
  menuType,
21446
21827
  onExecute,
21447
21828
  onOpenView,
@@ -21455,6 +21836,7 @@ function MobileSchemaList(props) {
21455
21836
  children: localeService.t(schema.title)
21456
21837
  }), schema.children.map((childSchema, childIndex) => /* @__PURE__ */ jsx(MobileSchemaRow, {
21457
21838
  schema: childSchema,
21839
+ menuManagerService,
21458
21840
  menuType,
21459
21841
  onExecute,
21460
21842
  onOpenView,
@@ -21464,9 +21846,10 @@ function MobileSchemaList(props) {
21464
21846
  }) });
21465
21847
  }
21466
21848
  function MobileSchemaRow(props) {
21467
- const { schema, menuType, onExecute, onOpenView, bordered } = props;
21849
+ const { schema, menuManagerService, menuType, onExecute, onOpenView, bordered } = props;
21468
21850
  const interaction = useMobileSchemaInteraction({
21469
21851
  schema,
21852
+ menuManagerService,
21470
21853
  menuType,
21471
21854
  onOpenView
21472
21855
  });
@@ -21541,8 +21924,7 @@ function MobileSelectionOptionRow(props) {
21541
21924
  }
21542
21925
  function useMobileSchemaInteraction(props) {
21543
21926
  var _schema$children3;
21544
- const { schema, menuType, onOpenView } = props;
21545
- const menuManagerService = useDependency(IMenuManagerService);
21927
+ const { schema, menuManagerService, menuType, onOpenView } = props;
21546
21928
  const localeService = useDependency(LocaleService);
21547
21929
  const menuItem = schema.item;
21548
21930
  const selectorItem = menuItem;
@@ -21623,30 +22005,20 @@ function getMenuSchemaTitle(schema, localeService) {
21623
22005
  return schema.key;
21624
22006
  }
21625
22007
  function useContextGroupHiddenStates(menuSchemas) {
21626
- const [hiddenStates, setHiddenStates] = useState({});
21627
- useEffect(() => {
21628
- const subscriptions = menuSchemas.map((menuSchema) => {
22008
+ return useObservable(useMemo(() => {
22009
+ const groupStates = menuSchemas.flatMap((menuSchema) => {
21629
22010
  var _menuSchema$children;
21630
- if (!((_menuSchema$children = menuSchema.children) === null || _menuSchema$children === void 0 ? void 0 : _menuSchema$children.length)) return null;
21631
- const hiddenObservables = getLeafItemSchemas(menuSchema.children).map((childSchema) => {
22011
+ const hiddenObservables = ((_menuSchema$children = menuSchema.children) === null || _menuSchema$children === void 0 ? void 0 : _menuSchema$children.length) ? getLeafItemSchemas(menuSchema.children).map((childSchema) => {
21632
22012
  var _childSchema$item$hid, _childSchema$item;
21633
22013
  return (_childSchema$item$hid = (_childSchema$item = childSchema.item) === null || _childSchema$item === void 0 ? void 0 : _childSchema$item.hidden$) !== null && _childSchema$item$hid !== void 0 ? _childSchema$item$hid : of(false);
21634
- });
21635
- if (!hiddenObservables.length) return null;
21636
- return combineLatest(hiddenObservables).subscribe((hiddenValues) => {
21637
- const isAllHidden = hiddenValues.every((hidden) => hidden === true);
21638
- setHiddenStates((state) => ({
21639
- ...state,
21640
- [menuSchema.key]: isAllHidden
21641
- }));
21642
- });
22014
+ }) : [];
22015
+ return hiddenObservables.length ? [combineLatest(hiddenObservables).pipe(map((values) => [menuSchema.key, values.every(Boolean)]))] : [];
21643
22016
  });
21644
- return () => {
21645
- subscriptions.forEach((subscription) => subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe());
21646
- setHiddenStates({});
21647
- };
21648
- }, [menuSchemas]);
21649
- return hiddenStates;
22017
+ return groupStates.length ? merge$1(...groupStates).pipe(scan$1((states, [key, hidden]) => ({
22018
+ ...states,
22019
+ [key]: hidden
22020
+ }), {}), startWith$1({})) : of({});
22021
+ }, [menuSchemas]), {});
21650
22022
  }
21651
22023
  function getLeafItemSchemas(schemas) {
21652
22024
  return schemas.reduce((acc, schema) => {
@@ -21663,11 +22035,14 @@ const MOBILE_CONTEXT_MENU_HOST_ID = "mobile-context-menu";
21663
22035
  function MobileContextMenu() {
21664
22036
  const [visible, setVisible] = useState(false);
21665
22037
  const [menuType, setMenuType] = useState("");
22038
+ const [menuContext, setMenuContext] = useState();
21666
22039
  const visibleRef = useRef(visible);
21667
22040
  const contextMenuHostService = useDependency(IContextMenuHostService);
21668
22041
  const contextMenuService = useDependency(IContextMenuService);
21669
22042
  const commandService = useDependency(ICommandService);
21670
22043
  const layoutService = useDependency(ILayoutService);
22044
+ const menuManagerService = useDependency(IMenuManagerService);
22045
+ const runtimeScopeService = useDependency(IUIRuntimeScopeService);
21671
22046
  const localeService = useDependency(LocaleService);
21672
22047
  const direction = useObservable(localeService.direction$);
21673
22048
  const { mountContainer } = useContext(ConfigContext);
@@ -21691,9 +22066,10 @@ function MobileContextMenu() {
21691
22066
  contextMenuHostService.deactivateMenu(MOBILE_CONTEXT_MENU_HOST_ID);
21692
22067
  };
21693
22068
  }, [contextMenuHostService, contextMenuService]);
21694
- function handleContextMenu(_event, nextMenuType) {
22069
+ function handleContextMenu(_event, nextMenuType, context) {
21695
22070
  contextMenuHostService.activateMenu(MOBILE_CONTEXT_MENU_HOST_ID);
21696
22071
  setMenuType(nextMenuType);
22072
+ setMenuContext(context);
21697
22073
  setVisible(true);
21698
22074
  }
21699
22075
  function handleClose() {
@@ -21708,6 +22084,23 @@ function MobileContextMenu() {
21708
22084
  }
21709
22085
  }, [localeService, menuType]);
21710
22086
  if (!mountContainer || !visible) return null;
22087
+ const activeScope = runtimeScopeService.get(menuContext === null || menuContext === void 0 ? void 0 : menuContext.unitId);
22088
+ const activeCommandService = (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(ICommandService)) ? activeScope.get(ICommandService) : commandService;
22089
+ const activeLayoutService = (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(ILayoutService)) ? activeScope.get(ILayoutService) : layoutService;
22090
+ const menu = /* @__PURE__ */ jsx(MobileMenu, {
22091
+ menuType,
22092
+ menuManagerService: (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(IMenuManagerService)) ? activeScope.get(IMenuManagerService) : menuManagerService,
22093
+ onOptionSelect: (params) => {
22094
+ var _ref, _params$commandId;
22095
+ const commandId = (_ref = (_params$commandId = params.commandId) !== null && _params$commandId !== void 0 ? _params$commandId : params.id) !== null && _ref !== void 0 ? _ref : params.label;
22096
+ const fallbackParams = typeof params.params === "function" ? params.params() : params.params;
22097
+ const commandParams = typeof params.value === "undefined" ? fallbackParams : { value: params.value };
22098
+ if (!commandId) return;
22099
+ activeLayoutService.focus();
22100
+ activeCommandService.executeCommand(commandId, commandParams);
22101
+ handleClose();
22102
+ }
22103
+ });
21711
22104
  return createPortal(/* @__PURE__ */ jsxs("div", {
21712
22105
  dir: direction,
21713
22106
  className: "univer-fixed univer-inset-0 univer-z-[1080] univer-flex univer-items-end",
@@ -21741,19 +22134,7 @@ function MobileContextMenu() {
21741
22134
  children: /* @__PURE__ */ jsx(CloseIcon, { className: "univer-size-4 univer-text-current" })
21742
22135
  })]
21743
22136
  })]
21744
- }), menuType && /* @__PURE__ */ jsx(MobileMenu, {
21745
- menuType,
21746
- onOptionSelect: (params) => {
21747
- var _ref, _params$commandId;
21748
- const commandId = (_ref = (_params$commandId = params.commandId) !== null && _params$commandId !== void 0 ? _params$commandId : params.id) !== null && _ref !== void 0 ? _ref : params.label;
21749
- const fallbackParams = typeof params.params === "function" ? params.params() : params.params;
21750
- const commandParams = typeof params.value === "undefined" ? fallbackParams : { value: params.value };
21751
- if (!commandId) return;
21752
- layoutService.focus();
21753
- commandService.executeCommand(commandId, commandParams);
21754
- handleClose();
21755
- }
21756
- })]
22137
+ }), menuType && menu]
21757
22138
  })]
21758
22139
  }), mountContainer);
21759
22140
  }
@@ -21780,20 +22161,12 @@ function MobileWorkbench(props) {
21780
22161
  const leftSidebarComponents = useComponentsOfPart("left-sidebar");
21781
22162
  const globalComponents = useComponentsOfPart("global");
21782
22163
  const toolbarComponents = useComponentsOfPart("toolbar");
21783
- const [darkMode, setDarkMode] = useState(false);
21784
- useEffect(() => {
21785
- const sub = themeService.darkMode$.subscribe((darkMode) => {
21786
- setDarkMode(darkMode);
21787
- });
21788
- return () => {
21789
- sub.unsubscribe();
21790
- };
21791
- }, []);
22164
+ const darkMode = useObservable(themeService.darkMode$, themeService.darkMode);
21792
22165
  useEffect(() => {
21793
22166
  if (contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
21794
22167
  }, [onRendered]);
21795
- const [locale, setLocale] = useState(localeService.getLocales());
21796
- const [direction, setDirection] = useState(localeService.getDirection());
22168
+ const locale = useObservable(() => localeService.localeChanged$.pipe(map(() => localeService.getLocales())), localeService.getLocales(), false, [localeService]);
22169
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
21797
22170
  const portalContainer = useMemo(() => document.createElement("div"), []);
21798
22171
  useLayoutEffect(() => {
21799
22172
  const sub = themeService.currentTheme$.subscribe((theme) => {
@@ -21805,20 +22178,10 @@ function MobileWorkbench(props) {
21805
22178
  }, []);
21806
22179
  useEffect(() => {
21807
22180
  document.body.appendChild(portalContainer);
21808
- const subscriptions = [localeService.localeChanged$.subscribe(() => {
21809
- setLocale(localeService.getLocales());
21810
- }), localeService.direction$.subscribe(() => {
21811
- setDirection(localeService.getDirection());
21812
- })];
21813
22181
  return () => {
21814
- subscriptions.forEach((subscription) => subscription.unsubscribe());
21815
22182
  document.body.removeChild(portalContainer);
21816
22183
  };
21817
- }, [
21818
- localeService,
21819
- mountContainer,
21820
- portalContainer
21821
- ]);
22184
+ }, [mountContainer, portalContainer]);
21822
22185
  useEffect(() => {
21823
22186
  portalContainer.dir = direction;
21824
22187
  }, [direction, portalContainer]);
@@ -21883,17 +22246,15 @@ function MobileWorkbench(props) {
21883
22246
  //#endregion
21884
22247
  //#region src/controllers/ui/ui-mobile.controller.ts
21885
22248
  let MobileUIController = class MobileUIController extends SingleUnitUIController {
21886
- constructor(_config, injector, lifecycleService, renderManagerService, layoutService, instanceService, menuManagerService, uiPartsService, _componentManager) {
22249
+ constructor(_config, injector, lifecycleService, renderManagerService, layoutService, instanceService, menuManagerService, uiPartsService) {
21887
22250
  super(injector, instanceService, layoutService, lifecycleService, renderManagerService);
21888
22251
  this._config = _config;
21889
- this._componentManager = _componentManager;
21890
22252
  menuManagerService.mergeMenu(menuSchema);
21891
22253
  this._initBuiltinComponents(uiPartsService);
21892
22254
  this._bootstrapWorkbench();
21893
22255
  }
21894
22256
  dispose() {
21895
22257
  super.dispose();
21896
- this._componentManager.dispose();
21897
22258
  }
21898
22259
  bootstrap(callback) {
21899
22260
  return bootstrap(this._injector, this._config, callback);
@@ -21911,8 +22272,7 @@ MobileUIController = __decorate([
21911
22272
  __decorateParam(4, ILayoutService),
21912
22273
  __decorateParam(5, IUniverInstanceService),
21913
22274
  __decorateParam(6, IMenuManagerService),
21914
- __decorateParam(7, IUIPartsService),
21915
- __decorateParam(8, Inject(ComponentManager))
22275
+ __decorateParam(7, IUIPartsService)
21916
22276
  ], MobileUIController);
21917
22277
  function bootstrap(injector, options, callback) {
21918
22278
  let mountContainer;
@@ -21946,9 +22306,10 @@ const INotificationService = createIdentifier("ui.notification.service");
21946
22306
  //#region src/services/before-close/before-close.service.ts
21947
22307
  const IBeforeCloseService = createIdentifier("univer.ui.before-close-service");
21948
22308
  let DesktopBeforeCloseService = class DesktopBeforeCloseService extends Disposable {
21949
- constructor(_notificationService) {
22309
+ constructor(_notificationService, _localeService) {
21950
22310
  super();
21951
22311
  this._notificationService = _notificationService;
22312
+ this._localeService = _localeService;
21952
22313
  _defineProperty(this, "_beforeUnloadCallbacks", []);
21953
22314
  _defineProperty(this, "_onCloseCallbacks", []);
21954
22315
  _defineProperty(this, "_beforeUnloadHandler", void 0);
@@ -21959,7 +22320,7 @@ let DesktopBeforeCloseService = class DesktopBeforeCloseService extends Disposab
21959
22320
  if (message) {
21960
22321
  this._notificationService.show({
21961
22322
  type: "error",
21962
- title: "Some changes are not saved",
22323
+ title: this._localeService.t("ui.beforeClose.title"),
21963
22324
  content: message
21964
22325
  });
21965
22326
  if (typeof event === "undefined") event = window.event;
@@ -21996,7 +22357,7 @@ let DesktopBeforeCloseService = class DesktopBeforeCloseService extends Disposab
21996
22357
  window.addEventListener("unload", this._unloadHandler);
21997
22358
  }
21998
22359
  };
21999
- DesktopBeforeCloseService = __decorate([__decorateParam(0, INotificationService)], DesktopBeforeCloseService);
22360
+ DesktopBeforeCloseService = __decorate([__decorateParam(0, INotificationService), __decorateParam(1, Inject(LocaleService))], DesktopBeforeCloseService);
22000
22361
 
22001
22362
  //#endregion
22002
22363
  //#region src/utils/html.ts
@@ -22429,17 +22790,7 @@ const ContextConfirm = (props) => {
22429
22790
  });
22430
22791
  };
22431
22792
  function ConfirmPart() {
22432
- const confirmService = useDependency(IConfirmService);
22433
- const [confirmOptions, setConfirmOptions] = useState([]);
22434
- useEffect(() => {
22435
- const subscription = confirmService.confirmOptions$.subscribe((options) => {
22436
- setConfirmOptions(options);
22437
- });
22438
- return () => {
22439
- subscription.unsubscribe();
22440
- };
22441
- }, []);
22442
- const props = confirmOptions.map((options) => {
22793
+ const props = useObservable(useDependency(IConfirmService).confirmOptions$, []).map((options) => {
22443
22794
  const { children, title, ...restProps } = options;
22444
22795
  const confirmProps = restProps;
22445
22796
  for (const key of ["children", "title"]) {
@@ -22516,14 +22867,7 @@ const IDialogService = createIdentifier("univer.ui.dialog-service");
22516
22867
  //#endregion
22517
22868
  //#region src/views/components/dialog-part/DialogPart.tsx
22518
22869
  function DialogPart() {
22519
- const dialogService = useDependency(IDialogService);
22520
- const [dialogOptions, setDialogOptions] = useState([]);
22521
- useEffect(() => {
22522
- const subscription = dialogService.getDialogs$().subscribe((options) => {
22523
- setDialogOptions(options);
22524
- });
22525
- return () => subscription.unsubscribe();
22526
- }, []);
22870
+ const dialogOptions = useObservable(useDependency(IDialogService).getDialogs$(), []);
22527
22871
  const attrs = useMemo(() => dialogOptions.map((options) => {
22528
22872
  const { children, title, footer, ...restProps } = options;
22529
22873
  const dialogProps = restProps;
@@ -23118,6 +23462,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends Plugin {
23118
23462
  [IMenuManagerService, { useClass: MenuManagerService }],
23119
23463
  [IContextMenuHostService, { useClass: ContextMenuHostService }],
23120
23464
  [IContextMenuService, { useClass: ContextMenuService }],
23465
+ [IUIRuntimeScopeService, { useClass: UIRuntimeScopeService }],
23121
23466
  [IClipboardInterfaceService, {
23122
23467
  useClass: BrowserClipboardService,
23123
23468
  lazy: true
@@ -23155,6 +23500,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends Plugin {
23155
23500
  [ICanvasPopupService, { useClass: CanvasPopupService }],
23156
23501
  [IFontService, { useClass: FontService }],
23157
23502
  [CanvasFloatDomService],
23503
+ [CanvasFloatDomPreviewService],
23158
23504
  [IUIController, {
23159
23505
  useFactory: (injector) => injector.createInstance(MobileUIController, this._config),
23160
23506
  deps: [Injector]
@@ -23212,11 +23558,13 @@ let UniverUIPlugin = class UniverUIPlugin extends Plugin {
23212
23558
  [IUIPartsService, { useClass: UIPartsService }],
23213
23559
  [ILayoutService, { useClass: DesktopLayoutService }],
23214
23560
  [IRibbonService, { useClass: DesktopRibbonService }],
23561
+ [IRibbonOverrideService, { useClass: RibbonOverrideService }],
23215
23562
  [IShortcutService, { useClass: ShortcutService }],
23216
23563
  [IPlatformService, { useClass: PlatformService }],
23217
23564
  [IMenuManagerService, { useClass: MenuManagerService }],
23218
23565
  [IContextMenuHostService, { useClass: ContextMenuHostService }],
23219
23566
  [IContextMenuService, { useClass: ContextMenuService }],
23567
+ [IUIRuntimeScopeService, { useClass: UIRuntimeScopeService }],
23220
23568
  [IClipboardInterfaceService, {
23221
23569
  useClass: BrowserClipboardService,
23222
23570
  lazy: true
@@ -23254,6 +23602,7 @@ let UniverUIPlugin = class UniverUIPlugin extends Plugin {
23254
23602
  [ICanvasPopupService, { useClass: CanvasPopupService }],
23255
23603
  [IFontService, { useClass: FontService }],
23256
23604
  [CanvasFloatDomService],
23605
+ [CanvasFloatDomPreviewService],
23257
23606
  [IUIController, {
23258
23607
  useFactory: (injector) => injector.createInstance(DesktopUIController, this._config),
23259
23608
  deps: [Injector]
@@ -23923,15 +24272,31 @@ function extractFontFamily(styleStr) {
23923
24272
  //#endregion
23924
24273
  //#region src/views/components/dom/Print.tsx
23925
24274
  const PrintFloatDomSingle = memo((props) => {
24275
+ const { layer } = props;
24276
+ return typeof layer.componentKey === "string" ? /* @__PURE__ */ jsx(RegisteredPrintFloatDomSingle, {
24277
+ ...props,
24278
+ componentKey: layer.componentKey
24279
+ }) : /* @__PURE__ */ jsx(PrintFloatDomSingleContent, {
24280
+ ...props,
24281
+ Component: layer.componentKey
24282
+ });
24283
+ });
24284
+ function RegisteredPrintFloatDomSingle(props) {
24285
+ const componentManager = useDependency$1(ComponentManager);
24286
+ return /* @__PURE__ */ jsx(PrintFloatDomSingleContent, {
24287
+ ...props,
24288
+ Component: componentManager.get(props.componentKey)
24289
+ });
24290
+ }
24291
+ function PrintFloatDomSingleContent(props) {
23926
24292
  var _position$startY, _position$startX;
23927
- const { layer, id, position } = props;
24293
+ const { layer, id, position, Component } = props;
23928
24294
  const univerInstanceService = useDependency$1(IUniverInstanceService);
23929
24295
  const domRef = useRef(null);
23930
24296
  const innerDomRef = useRef(null);
23931
24297
  const transformRef = useRef(`transform: rotate(${position === null || position === void 0 ? void 0 : position.rotate}deg) translate(${position === null || position === void 0 ? void 0 : position.startX}px, ${position === null || position === void 0 ? void 0 : position.startY}px)`);
23932
24298
  const topRef = useRef((_position$startY = position === null || position === void 0 ? void 0 : position.startY) !== null && _position$startY !== void 0 ? _position$startY : 0);
23933
24299
  const leftRef = useRef((_position$startX = position === null || position === void 0 ? void 0 : position.startX) !== null && _position$startX !== void 0 ? _position$startX : 0);
23934
- const Component = typeof layer.componentKey === "string" ? useDependency$1(ComponentManager).get(layer.componentKey) : layer.componentKey;
23935
24300
  const layerProps = useMemo(() => ({
23936
24301
  data: layer.data,
23937
24302
  ...layer.props
@@ -23967,16 +24332,16 @@ const PrintFloatDomSingle = memo((props) => {
23967
24332
  transform: transformRef.current
23968
24333
  },
23969
24334
  onPointerMove: (e) => {
23970
- layer.onPointerMove(e.nativeEvent);
24335
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerMove(e.nativeEvent);
23971
24336
  },
23972
24337
  onPointerDown: (e) => {
23973
- layer.onPointerDown(e.nativeEvent);
24338
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerDown(e.nativeEvent);
23974
24339
  },
23975
24340
  onPointerUp: (e) => {
23976
- layer.onPointerUp(e.nativeEvent);
24341
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerUp(e.nativeEvent);
23977
24342
  },
23978
24343
  onWheel: (e) => {
23979
- layer.onWheel(e.nativeEvent);
24344
+ if (shouldForwardFloatDomEvents(layer)) layer.onWheel(e.nativeEvent);
23980
24345
  },
23981
24346
  children: /* @__PURE__ */ jsx("div", {
23982
24347
  ref: innerDomRef,
@@ -23986,7 +24351,7 @@ const PrintFloatDomSingle = memo((props) => {
23986
24351
  children: component
23987
24352
  })
23988
24353
  });
23989
- });
24354
+ }
23990
24355
 
23991
24356
  //#endregion
23992
24357
  //#region src/views/progress-bar/ProgressBar.tsx
@@ -24071,4 +24436,4 @@ function ProgressBar(props) {
24071
24436
  }
24072
24437
 
24073
24438
  //#endregion
24074
- export { AnchoredContextMenu, BrowserClipboardService, BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, CanvasFloatDomService, CanvasPopup, CanvasPopupService, CommonLabel, ComponentContainer, ComponentManager, DesktopContextMenu as ContextMenu, ContextMenuGroup, ContextMenuHostService, ContextMenuPanel, ContextMenuPosition, ContextMenuService, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DISABLE_AUTO_FOCUS_KEY, DesktopBeforeCloseService, DesktopConfirmService, DesktopDialogService, DesktopGalleryService, DesktopLayoutService, DesktopLocalFileService, DesktopLocalStorageService, DesktopMessageService, DesktopNotificationService, DesktopRibbonService, DesktopSidebarService, DesktopUIController, EMOJI_CATEGORIES, EMOJI_PICKER_COMPONENT, EMOJI_RECENT_LIMIT, EmojiPicker, ErrorController, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE_SVG_XML_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, FloatDom, FloatDomSingle, FontFamily, FontFamilyDropdown, FontFamilyItem, FontService, FontSize, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, HeadingItem, IBeforeCloseService, ICanvasPopupService, IClipboardInterfaceService, IContextMenuHostService, IContextMenuService, IDialogService, IFontService, IGalleryService, ILayoutService, ILeftSidebarService, ILocalFileService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonService, IShortcutService, ISidebarService, IUIController, IUIPartsService, IconManager, KeyCode, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileContextMenu, MockMessageService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, ThemeSwitcherService, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoShortcutItem, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, ZIndexManager, connectDependencies, connectInjector, getAllEmojis, getDefaultRecentEmojis, getEmojiLocaleData, getHeaderFooterMenuHiddenObservable, getLocalizedEmojiTitle, getMenuHiddenObservable, getRandomEmoji, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, imageMimeTypeSet, mergeMenuConfigs, parseHtmlDocument, parseHtmlFragment, parseStoredRecentEmojis, promoteRecentEmoji, sanitizeParsedHtml, searchEmojis, splitSpanText, supportClipboardAPI, textTrim, useClickOutSide, useComponentsOfPart, useConfigValue, useDebounceFn, useDependency, useEvent, useInjector, useObservable, useObservableRef, useScrollYOverContainer, useSidebarClick, useToolbarItemStatus, useUpdateBinder, useUpdateEffect, useVirtualList };
24439
+ export { AnchoredContextMenu, BrowserClipboardService, BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, CanvasFloatDomPreviewService, CanvasFloatDomService, CanvasPopup, CanvasPopupService, CommonLabel, ComponentContainer, ComponentManager, DesktopContextMenu as ContextMenu, ContextMenuGroup, ContextMenuHostService, ContextMenuPanel, ContextMenuPosition, ContextMenuService, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DISABLE_AUTO_FOCUS_KEY, DesktopBeforeCloseService, DesktopConfirmService, DesktopDialogService, DesktopGalleryService, DesktopLayoutService, DesktopLocalFileService, DesktopLocalStorageService, DesktopMessageService, DesktopNotificationService, DesktopRibbonService, DesktopSidebarService, DesktopUIController, EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, EMOJI_CATEGORIES, EMOJI_PICKER_COMPONENT, EMOJI_RECENT_LIMIT, EmojiPicker, ErrorController, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE_SVG_XML_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, FloatDom, FloatDomSingle, FontFamily, FontFamilyDropdown, FontFamilyItem, FontService, FontSize, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, HeadingItem, IBeforeCloseService, ICanvasPopupService, IClipboardInterfaceService, IContextMenuHostService, IContextMenuService, IDialogService, IFontService, IGalleryService, ILayoutService, ILeftSidebarService, ILocalFileService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonOverrideService, IRibbonService, IShortcutService, ISidebarService, IUIController, IUIPartsService, IUIRuntimeScopeService, IconManager, KeyCode, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileContextMenu, MockMessageService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonOverrideService, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, ThemeSwitcherService, ToggleFullscreenOperation, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UIRuntimeScopeService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoShortcutItem, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, ZIndexManager, ZoomInput, connectDependencies, connectInjector, getAllEmojis, getDefaultRecentEmojis, getEmbedBoundaryOwner, getEmojiLocaleData, getHeaderFooterMenuHiddenObservable, getLocalizedEmojiTitle, getMenuHiddenObservable, getRandomEmoji, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, imageMimeTypeSet, isEmbedBoundaryTarget, keepInteractionInsideSameEmbedBoundary, mergeMenuConfigs, parseHtmlDocument, parseHtmlFragment, parseStoredRecentEmojis, promoteRecentEmoji, sanitizeParsedHtml, searchEmojis, splitSpanText, supportClipboardAPI, textTrim, useClickOutSide, useComponentsOfPart, useConfigValue, useDebounceFn, useDependency, useEvent, useInjector, useObservable, useObservableRef, useScrollYOverContainer, useSidebarClick, useToolbarItemStatus, useUpdateBinder, useUpdateEffect, useVirtualList };