@univerjs/ui 1.0.0-alpha.3 → 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.
- package/lib/cjs/index.js +671 -638
- package/lib/cjs/locale/ar-SA.js +11 -0
- package/lib/cjs/locale/ca-ES.js +11 -0
- package/lib/cjs/locale/de-DE.js +11 -0
- package/lib/cjs/locale/en-US.js +11 -0
- package/lib/cjs/locale/es-ES.js +11 -0
- package/lib/cjs/locale/fa-IR.js +11 -0
- package/lib/cjs/locale/fr-FR.js +11 -0
- package/lib/cjs/locale/id-ID.js +11 -0
- package/lib/cjs/locale/it-IT.js +11 -0
- package/lib/cjs/locale/ja-JP.js +11 -0
- package/lib/cjs/locale/ko-KR.js +11 -0
- package/lib/cjs/locale/pl-PL.js +11 -0
- package/lib/cjs/locale/pt-BR.js +11 -0
- package/lib/cjs/locale/ru-RU.js +11 -0
- package/lib/cjs/locale/sk-SK.js +11 -0
- package/lib/cjs/locale/vi-VN.js +11 -0
- package/lib/cjs/locale/zh-CN.js +11 -0
- package/lib/cjs/locale/zh-HK.js +11 -0
- package/lib/cjs/locale/zh-TW.js +11 -0
- package/lib/es/index.js +674 -643
- package/lib/es/locale/ar-SA.js +11 -0
- package/lib/es/locale/ca-ES.js +11 -0
- package/lib/es/locale/de-DE.js +11 -0
- package/lib/es/locale/en-US.js +11 -0
- package/lib/es/locale/es-ES.js +11 -0
- package/lib/es/locale/fa-IR.js +11 -0
- package/lib/es/locale/fr-FR.js +11 -0
- package/lib/es/locale/id-ID.js +11 -0
- package/lib/es/locale/it-IT.js +11 -0
- package/lib/es/locale/ja-JP.js +11 -0
- package/lib/es/locale/ko-KR.js +11 -0
- package/lib/es/locale/pl-PL.js +11 -0
- package/lib/es/locale/pt-BR.js +11 -0
- package/lib/es/locale/ru-RU.js +11 -0
- package/lib/es/locale/sk-SK.js +11 -0
- package/lib/es/locale/vi-VN.js +11 -0
- package/lib/es/locale/zh-CN.js +11 -0
- package/lib/es/locale/zh-HK.js +11 -0
- package/lib/es/locale/zh-TW.js +11 -0
- package/lib/index.js +674 -643
- package/lib/locale/ar-SA.js +11 -0
- package/lib/locale/ca-ES.js +11 -0
- package/lib/locale/de-DE.js +11 -0
- package/lib/locale/en-US.js +11 -0
- package/lib/locale/es-ES.js +11 -0
- package/lib/locale/fa-IR.js +11 -0
- package/lib/locale/fr-FR.js +11 -0
- package/lib/locale/id-ID.js +11 -0
- package/lib/locale/it-IT.js +11 -0
- package/lib/locale/ja-JP.js +11 -0
- package/lib/locale/ko-KR.js +11 -0
- package/lib/locale/pl-PL.js +11 -0
- package/lib/locale/pt-BR.js +11 -0
- package/lib/locale/ru-RU.js +11 -0
- package/lib/locale/sk-SK.js +11 -0
- package/lib/locale/vi-VN.js +11 -0
- package/lib/locale/zh-CN.js +11 -0
- package/lib/locale/zh-HK.js +11 -0
- package/lib/locale/zh-TW.js +11 -0
- package/lib/types/commands/operations/toggle-fullscreen.operation.d.ts +17 -0
- package/lib/types/controllers/ui/ui-desktop.controller.d.ts +1 -3
- package/lib/types/controllers/ui/ui-mobile.controller.d.ts +1 -3
- package/lib/types/index.d.ts +2 -1
- package/lib/types/locale/en-US.d.ts +13 -0
- package/lib/types/services/before-close/before-close.service.d.ts +3 -2
- package/lib/types/services/menu/menu.d.ts +3 -2
- package/lib/types/services/menu/types.d.ts +1 -0
- package/lib/types/services/popup/canvas-popup.service.d.ts +3 -0
- package/lib/types/views/components/dom/FloatDom.d.ts +1 -1
- package/lib/types/views/components/dom/Print.d.ts +1 -1
- package/lib/types/views/emoji-picker/emoji-picker-utils.d.ts +1 -1
- package/lib/types/views/index.d.ts +1 -1
- package/lib/types/views/slider/ZoomInput.d.ts +25 -0
- package/lib/types/views/slider/index.d.ts +1 -0
- package/lib/umd/index.js +13 -13
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +8 -8
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,
|
|
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 {
|
|
@@ -610,169 +785,18 @@ let MetaKeys = /* @__PURE__ */ function(MetaKeys) {
|
|
|
610
785
|
MetaKeys[MetaKeys["SHIFT"] = 1024] = "SHIFT";
|
|
611
786
|
/** Option key on MacOS. Alt key on other systems. */
|
|
612
787
|
MetaKeys[MetaKeys["ALT"] = 2048] = "ALT";
|
|
613
|
-
/** Command key on MacOS. Ctrl key on other systems. */
|
|
614
|
-
MetaKeys[MetaKeys["CTRL_COMMAND"] = 4096] = "CTRL_COMMAND";
|
|
615
|
-
/** Ctrl key for MacOS. Not valid on other systems. */
|
|
616
|
-
MetaKeys[MetaKeys["MAC_CTRL"] = 8192] = "MAC_CTRL";
|
|
617
|
-
return MetaKeys;
|
|
618
|
-
}({});
|
|
619
|
-
|
|
620
|
-
//#endregion
|
|
621
|
-
//#region src/common/lifecycle.ts
|
|
622
|
-
function fromGlobalEvent(type, listener, options) {
|
|
623
|
-
window.addEventListener(type, listener, options);
|
|
624
|
-
return toDisposable(() => window.removeEventListener(type, listener, options));
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
//#endregion
|
|
628
|
-
//#region src/utils/embed-boundary.ts
|
|
629
|
-
/**
|
|
630
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
631
|
-
*
|
|
632
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
633
|
-
* you may not use this file except in compliance with the License.
|
|
634
|
-
* You may obtain a copy of the License at
|
|
635
|
-
*
|
|
636
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
637
|
-
*
|
|
638
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
639
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
640
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
641
|
-
* See the License for the specific language governing permissions and
|
|
642
|
-
* limitations under the License.
|
|
643
|
-
*/
|
|
644
|
-
const EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
|
|
645
|
-
function getEmbedBoundaryOwner(target) {
|
|
646
|
-
var _ref, _getAttributeValue;
|
|
647
|
-
if (!hasClosest(target)) return;
|
|
648
|
-
const ownerElement = target.closest(`[${EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE}]`);
|
|
649
|
-
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;
|
|
650
|
-
}
|
|
651
|
-
function isEmbedBoundaryTarget(target) {
|
|
652
|
-
return hasClosest(target) && target.closest(`[${"data-embed-interaction-boundary-owner"}]`) != null;
|
|
653
|
-
}
|
|
654
|
-
function keepInteractionInsideSameEmbedBoundary(event) {
|
|
655
|
-
const owner = getEmbedBoundaryOwner(event.currentTarget);
|
|
656
|
-
if (!owner) return;
|
|
657
|
-
if (getEmbedBoundaryOwner(event.target) === owner) event.preventDefault();
|
|
658
|
-
}
|
|
659
|
-
function hasClosest(target) {
|
|
660
|
-
return !!target && typeof target.closest === "function";
|
|
661
|
-
}
|
|
662
|
-
function getAttributeValue(target, name) {
|
|
663
|
-
var _getAttribute$call;
|
|
664
|
-
const getAttribute = target === null || target === void 0 ? void 0 : target.getAttribute;
|
|
665
|
-
return typeof getAttribute === "function" ? (_getAttribute$call = getAttribute.call(target, name)) !== null && _getAttribute$call !== void 0 ? _getAttribute$call : void 0 : void 0;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
//#endregion
|
|
669
|
-
//#region src/services/layout/layout.service.ts
|
|
670
|
-
const FOCUSING_UNIVER = "FOCUSING_UNIVER";
|
|
671
|
-
const givingBackFocusElements = [
|
|
672
|
-
"app-layout",
|
|
673
|
-
"button",
|
|
674
|
-
"sheet-bar-append-button",
|
|
675
|
-
"render-canvas",
|
|
676
|
-
"workbench-layout"
|
|
677
|
-
];
|
|
678
|
-
const ILayoutService = createIdentifier("ui.layout-service");
|
|
679
|
-
let DesktopLayoutService = class DesktopLayoutService extends Disposable {
|
|
680
|
-
get isFocused() {
|
|
681
|
-
return this._isFocused;
|
|
682
|
-
}
|
|
683
|
-
constructor(_contextService, _univerInstanceService) {
|
|
684
|
-
super();
|
|
685
|
-
this._contextService = _contextService;
|
|
686
|
-
this._univerInstanceService = _univerInstanceService;
|
|
687
|
-
_defineProperty(this, "_rootContainerElement", null);
|
|
688
|
-
_defineProperty(this, "_isFocused", false);
|
|
689
|
-
_defineProperty(this, "_focusHandlers", /* @__PURE__ */ new Map());
|
|
690
|
-
_defineProperty(this, "_contentElements", []);
|
|
691
|
-
_defineProperty(this, "_allContainers", []);
|
|
692
|
-
this._initUniverFocusListener();
|
|
693
|
-
this._initEditorStatus();
|
|
694
|
-
}
|
|
695
|
-
get rootContainerElement() {
|
|
696
|
-
return this._rootContainerElement;
|
|
697
|
-
}
|
|
698
|
-
focus() {
|
|
699
|
-
const currentFocused = this._univerInstanceService.getFocusedUnit();
|
|
700
|
-
if (!currentFocused) return;
|
|
701
|
-
let handler;
|
|
702
|
-
if (currentFocused instanceof Workbook) handler = this._focusHandlers.get(UniverInstanceType.UNIVER_SHEET);
|
|
703
|
-
else if (currentFocused instanceof DocumentDataModel) handler = this._focusHandlers.get(UniverInstanceType.UNIVER_DOC);
|
|
704
|
-
else if ((currentFocused === null || currentFocused === void 0 ? void 0 : currentFocused.type) === UniverInstanceType.UNIVER_SLIDE) handler = this._focusHandlers.get(UniverInstanceType.UNIVER_SLIDE);
|
|
705
|
-
if (handler) handler(currentFocused.getUnitId());
|
|
706
|
-
}
|
|
707
|
-
registerFocusHandler(type, handler) {
|
|
708
|
-
if (this._focusHandlers.has(type)) throw new Error(`[DesktopLayoutService]: handler of type ${type} bas been registered!`);
|
|
709
|
-
this._focusHandlers.set(type, handler);
|
|
710
|
-
return toDisposable(() => this._focusHandlers.delete(type));
|
|
711
|
-
}
|
|
712
|
-
registerContentElement(container) {
|
|
713
|
-
if (this._contentElements.indexOf(container) === -1) {
|
|
714
|
-
this._contentElements.push(container);
|
|
715
|
-
return toDisposable(() => remove(this._contentElements, container));
|
|
716
|
-
}
|
|
717
|
-
throw new Error("[DesktopLayoutService]: content container already registered!");
|
|
718
|
-
}
|
|
719
|
-
getContentElement() {
|
|
720
|
-
return this._contentElements[0];
|
|
721
|
-
}
|
|
722
|
-
registerRootContainerElement(container) {
|
|
723
|
-
if (this._rootContainerElement) throw new Error("[DesktopLayoutService]: root container already registered!");
|
|
724
|
-
this._rootContainerElement = container;
|
|
725
|
-
const dis = this.registerContainerElement(container);
|
|
726
|
-
return toDisposable(() => {
|
|
727
|
-
this._rootContainerElement = null;
|
|
728
|
-
dis.dispose();
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
registerContainerElement(container) {
|
|
732
|
-
if (this._allContainers.indexOf(container) === -1) {
|
|
733
|
-
this._allContainers.push(container);
|
|
734
|
-
return toDisposable(() => remove(this._allContainers, container));
|
|
735
|
-
}
|
|
736
|
-
throw new Error("[LayoutService]: container already registered!");
|
|
737
|
-
}
|
|
738
|
-
checkElementInCurrentContainers(element) {
|
|
739
|
-
return this._allContainers.some((container) => container.contains(element));
|
|
740
|
-
}
|
|
741
|
-
checkContentIsFocused() {
|
|
742
|
-
return this._contentElements.some((contentEl) => contentEl === document.activeElement || contentEl.contains(document.activeElement));
|
|
743
|
-
}
|
|
744
|
-
_initUniverFocusListener() {
|
|
745
|
-
this.disposeWithMe(fromEvent(window, "focusin").subscribe((event) => {
|
|
746
|
-
var _this$_rootContainerE;
|
|
747
|
-
const target = event.target;
|
|
748
|
-
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)) {
|
|
749
|
-
queueMicrotask(() => {
|
|
750
|
-
const targetUnitId = getFocusUnitIdFromElement(target);
|
|
751
|
-
if (targetUnitId && this._univerInstanceService.getUnit(targetUnitId)) this._univerInstanceService.focusUnit(targetUnitId);
|
|
752
|
-
this.focus();
|
|
753
|
-
this._isFocused = true;
|
|
754
|
-
this._contextService.setContextValue(FOCUSING_UNIVER, this._isFocused);
|
|
755
|
-
this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());
|
|
756
|
-
});
|
|
757
|
-
return;
|
|
758
|
-
}
|
|
759
|
-
if (target && this.checkElementInCurrentContainers(target)) this._isFocused = true;
|
|
760
|
-
else this._isFocused = false;
|
|
761
|
-
this._contextService.setContextValue(FOCUSING_UNIVER, this._isFocused);
|
|
762
|
-
this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());
|
|
763
|
-
}));
|
|
764
|
-
}
|
|
765
|
-
_initEditorStatus() {
|
|
766
|
-
this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
DesktopLayoutService = __decorate([__decorateParam(0, IContextService), __decorateParam(1, IUniverInstanceService)], DesktopLayoutService);
|
|
770
|
-
function getFocusingUniverEditorStatus() {
|
|
771
|
-
var _document$activeEleme;
|
|
772
|
-
return ((_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.dataset.uComp) === "editor";
|
|
773
|
-
}
|
|
774
|
-
function getFocusUnitIdFromElement(target) {
|
|
775
|
-
return target.dataset.uUnitId;
|
|
788
|
+
/** Command key on MacOS. Ctrl key on other systems. */
|
|
789
|
+
MetaKeys[MetaKeys["CTRL_COMMAND"] = 4096] = "CTRL_COMMAND";
|
|
790
|
+
/** Ctrl key for MacOS. Not valid on other systems. */
|
|
791
|
+
MetaKeys[MetaKeys["MAC_CTRL"] = 8192] = "MAC_CTRL";
|
|
792
|
+
return MetaKeys;
|
|
793
|
+
}({});
|
|
794
|
+
|
|
795
|
+
//#endregion
|
|
796
|
+
//#region src/common/lifecycle.ts
|
|
797
|
+
function fromGlobalEvent(type, listener, options) {
|
|
798
|
+
window.addEventListener(type, listener, options);
|
|
799
|
+
return toDisposable(() => window.removeEventListener(type, listener, options));
|
|
776
800
|
}
|
|
777
801
|
|
|
778
802
|
//#endregion
|
|
@@ -998,6 +1022,7 @@ let SharedController = class SharedController extends Disposable {
|
|
|
998
1022
|
this._registerShortcuts();
|
|
999
1023
|
}
|
|
1000
1024
|
_registerCommands() {
|
|
1025
|
+
this.disposeWithMe(this._commandService.registerCommand(ToggleFullscreenOperation));
|
|
1001
1026
|
[
|
|
1002
1027
|
CutCommand,
|
|
1003
1028
|
CopyCommand,
|
|
@@ -1052,6 +1077,7 @@ let RibbonStartGroup = /* @__PURE__ */ function(RibbonStartGroup) {
|
|
|
1052
1077
|
}({});
|
|
1053
1078
|
let RibbonInsertGroup = /* @__PURE__ */ function(RibbonInsertGroup) {
|
|
1054
1079
|
RibbonInsertGroup["EDIT"] = "ribbon.insert.edit";
|
|
1080
|
+
RibbonInsertGroup["CELL"] = "ribbon.insert.cell";
|
|
1055
1081
|
RibbonInsertGroup["MEDIA"] = "ribbon.insert.media";
|
|
1056
1082
|
RibbonInsertGroup["OTHERS"] = "ribbon.insert.others";
|
|
1057
1083
|
return RibbonInsertGroup;
|
|
@@ -1131,7 +1157,8 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
|
|
|
1131
1157
|
title: "ui.ribbon.insert",
|
|
1132
1158
|
["ribbon.insert.edit"]: { order: 0 },
|
|
1133
1159
|
["ribbon.insert.media"]: { order: 1 },
|
|
1134
|
-
["ribbon.insert.
|
|
1160
|
+
["ribbon.insert.cell"]: { order: 2 },
|
|
1161
|
+
["ribbon.insert.others"]: { order: 3 }
|
|
1135
1162
|
},
|
|
1136
1163
|
["ribbon.formulas"]: {
|
|
1137
1164
|
order: 2,
|
|
@@ -1676,13 +1703,29 @@ function applyFloatDomLayout(wrapper, inner, layout) {
|
|
|
1676
1703
|
innerStyle.bottom = innerLayout.bottom === "auto" ? "auto" : `${innerLayout.bottom}px`;
|
|
1677
1704
|
}
|
|
1678
1705
|
const FloatDomSingle = memo((props) => {
|
|
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) {
|
|
1679
1723
|
var _layer$contentBox, _layer$contentBox2;
|
|
1680
|
-
const { layer, id } = props;
|
|
1724
|
+
const { layer, id, Component } = props;
|
|
1681
1725
|
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
1682
1726
|
const position = useObservable(useMemo(() => layer.position$.pipe(first()), [layer.position$]));
|
|
1683
1727
|
const domRef = useRef(null);
|
|
1684
1728
|
const innerDomRef = useRef(null);
|
|
1685
|
-
const Component = typeof layer.componentKey === "string" ? useDependency(ComponentManager).get(layer.componentKey) : layer.componentKey;
|
|
1686
1729
|
const layerProps = useMemo(() => ({
|
|
1687
1730
|
data: layer.data,
|
|
1688
1731
|
...layer.props,
|
|
@@ -1754,7 +1797,7 @@ const FloatDomSingle = memo((props) => {
|
|
|
1754
1797
|
children: component
|
|
1755
1798
|
})
|
|
1756
1799
|
});
|
|
1757
|
-
}
|
|
1800
|
+
}
|
|
1758
1801
|
const FloatDom = ({ unitId }) => {
|
|
1759
1802
|
var _layers$filter;
|
|
1760
1803
|
const instanceService = useDependency(IUniverInstanceService);
|
|
@@ -2023,7 +2066,6 @@ RectPopup.useContext = () => useContext(RectPopupContext);
|
|
|
2023
2066
|
//#endregion
|
|
2024
2067
|
//#region src/views/components/popup/CanvasPopup.tsx
|
|
2025
2068
|
const SingleCanvasPopup = ({ popup, children }) => {
|
|
2026
|
-
const [hidden, setHidden] = useState(false);
|
|
2027
2069
|
const anchorRect$ = useMemo(() => popup.anchorRect$.pipe(throttleTime(0, animationFrameScheduler), map((anchorRect) => {
|
|
2028
2070
|
var _popup$offset;
|
|
2029
2071
|
const { bottom, left, right, top } = anchorRect;
|
|
@@ -2044,26 +2086,21 @@ const SingleCanvasPopup = ({ popup, children }) => {
|
|
|
2044
2086
|
return (_popup$excludeRects$ = popup.excludeRects$) === null || _popup$excludeRects$ === void 0 ? void 0 : _popup$excludeRects$.pipe(throttleTime(0, animationFrameScheduler));
|
|
2045
2087
|
}, [popup.excludeRects$]), popup.excludeRects);
|
|
2046
2088
|
const { canvasElement, hideOnInvisible = true, hiddenType = "destroy" } = popup;
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
const
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
const
|
|
2053
|
-
const
|
|
2054
|
-
|
|
2055
|
-
const bufferX = Math.min(.5 * rectWidth, 10);
|
|
2056
|
-
return rectWithOffset.top >= hiddenRect.top - bufferY && rectWithOffset.bottom <= hiddenRect.bottom + bufferY && rectWithOffset.left >= hiddenRect.left - bufferX && rectWithOffset.right <= hiddenRect.right + bufferX;
|
|
2057
|
-
});
|
|
2058
|
-
if (rectWithOffset.bottom < top || rectWithOffset.top > bottom || rectWithOffset.right < left || rectWithOffset.left > right || isInHiddenRect) setHidden(true);
|
|
2059
|
-
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;
|
|
2060
2097
|
});
|
|
2061
|
-
return
|
|
2062
|
-
}, [
|
|
2063
|
-
canvasElement,
|
|
2064
|
-
hideOnInvisible,
|
|
2098
|
+
return rectWithOffset.bottom < top || rectWithOffset.top > bottom || rectWithOffset.right < left || rectWithOffset.left > right || isInHiddenRect;
|
|
2099
|
+
})) : null, false, false, [
|
|
2065
2100
|
anchorRect$,
|
|
2066
|
-
|
|
2101
|
+
canvasElement,
|
|
2102
|
+
hiddenRects$,
|
|
2103
|
+
hideOnInvisible
|
|
2067
2104
|
]);
|
|
2068
2105
|
if (hidden && hiddenType === "destroy") return null;
|
|
2069
2106
|
return /* @__PURE__ */ jsx(RectPopup, {
|
|
@@ -2306,7 +2343,8 @@ function ComponentContainer(props) {
|
|
|
2306
2343
|
*/
|
|
2307
2344
|
function useComponentsOfPart(part, injector) {
|
|
2308
2345
|
var _injector$get;
|
|
2309
|
-
const
|
|
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;
|
|
2310
2348
|
const changeInfo = useObservable(useMemo(() => uiPartsService.uiVisibleChange$.pipe(filter((ui) => ui.ui === part)), [part, uiPartsService]));
|
|
2311
2349
|
const updateCounterRef = useRef(0);
|
|
2312
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, [
|
|
@@ -2483,33 +2521,14 @@ function CustomLabel(props) {
|
|
|
2483
2521
|
const localeService = useDependency(LocaleService);
|
|
2484
2522
|
const componentManager = useDependency(ComponentManager);
|
|
2485
2523
|
const iconManager = useDependency(IconManager);
|
|
2486
|
-
const
|
|
2487
|
-
const
|
|
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 : "";
|
|
2488
2527
|
const nodes = [];
|
|
2489
2528
|
let index = 0;
|
|
2490
|
-
useEffect(() => {
|
|
2491
|
-
if (value$) {
|
|
2492
|
-
const subscription = value$.subscribe((v) => {
|
|
2493
|
-
setSubscribedValue(v);
|
|
2494
|
-
});
|
|
2495
|
-
return () => {
|
|
2496
|
-
subscription.unsubscribe();
|
|
2497
|
-
};
|
|
2498
|
-
}
|
|
2499
|
-
}, [value$]);
|
|
2500
2529
|
const realValue = useMemo(() => {
|
|
2501
2530
|
return value !== null && value !== void 0 ? value : subscribedValue;
|
|
2502
2531
|
}, [subscribedValue, value]);
|
|
2503
|
-
useEffect(() => {
|
|
2504
|
-
let subscription = null;
|
|
2505
|
-
if (isObservable(icon)) subscription = icon.subscribe((v) => {
|
|
2506
|
-
setRealIcon(v);
|
|
2507
|
-
});
|
|
2508
|
-
else setRealIcon(icon !== null && icon !== void 0 ? icon : "");
|
|
2509
|
-
return () => {
|
|
2510
|
-
subscription === null || subscription === void 0 || subscription.unsubscribe();
|
|
2511
|
-
};
|
|
2512
|
-
}, [icon]);
|
|
2513
2532
|
const isValid = useMemo(() => {
|
|
2514
2533
|
if (realValue && typeof realValue === "string") return new ColorKit(realValue).isValid;
|
|
2515
2534
|
return false;
|
|
@@ -2554,6 +2573,7 @@ function CustomLabel(props) {
|
|
|
2554
2573
|
* @returns The menu item's status
|
|
2555
2574
|
*/
|
|
2556
2575
|
function useToolbarItemStatus(menuItem) {
|
|
2576
|
+
var _selectionsValue$2;
|
|
2557
2577
|
const { disabled$, hidden$, activated$, value$ } = menuItem;
|
|
2558
2578
|
let selectionsValue$;
|
|
2559
2579
|
if (isMenuButtonSelectorItem(menuItem)) {
|
|
@@ -2563,37 +2583,18 @@ function useToolbarItemStatus(menuItem) {
|
|
|
2563
2583
|
selectionsValue$ = selections === null || selections === void 0 || (_selections$ = selections[0]) === null || _selections$ === void 0 ? void 0 : _selections$.value$;
|
|
2564
2584
|
}
|
|
2565
2585
|
}
|
|
2566
|
-
const
|
|
2567
|
-
const
|
|
2568
|
-
const
|
|
2569
|
-
const [hidden, setHidden] = useState(false);
|
|
2570
|
-
const [selectionsValue, setSelectionsValue] = useState();
|
|
2571
|
-
useEffect(() => {
|
|
2572
|
-
const subscriptions = [];
|
|
2573
|
-
disabled$ && subscriptions.push(disabled$.subscribe((disabled) => setDisabled(disabled)));
|
|
2574
|
-
hidden$ && subscriptions.push(hidden$.subscribe((hidden) => setHidden(hidden)));
|
|
2575
|
-
activated$ && subscriptions.push(activated$.subscribe((activated) => setActivated(activated)));
|
|
2576
|
-
value$ && subscriptions.push(value$.subscribe((value) => {
|
|
2577
|
-
setValue(value);
|
|
2578
|
-
}));
|
|
2579
|
-
selectionsValue$ && subscriptions.push(selectionsValue$.subscribe((value) => {
|
|
2580
|
-
setSelectionsValue(value);
|
|
2581
|
-
setValue(value);
|
|
2582
|
-
}));
|
|
2583
|
-
return () => subscriptions.forEach((subscription) => subscription.unsubscribe());
|
|
2584
|
-
}, [
|
|
2585
|
-
activated$,
|
|
2586
|
-
disabled$,
|
|
2587
|
-
hidden$,
|
|
2588
|
-
value$,
|
|
2589
|
-
selectionsValue$
|
|
2590
|
-
]);
|
|
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);
|
|
2591
2589
|
return {
|
|
2592
2590
|
disabled,
|
|
2593
|
-
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$])),
|
|
2594
2595
|
activated,
|
|
2595
2596
|
hidden,
|
|
2596
|
-
selectionsValue
|
|
2597
|
+
selectionsValue: useObservable((_selectionsValue$2 = selectionsValue$) !== null && _selectionsValue$2 !== void 0 ? _selectionsValue$2 : null)
|
|
2597
2598
|
};
|
|
2598
2599
|
}
|
|
2599
2600
|
function useToolbarShortcutDisplay({ id, commandId, shortcut }) {
|
|
@@ -2685,9 +2686,8 @@ function DropdownMenuLabel({ icon, value, option, onOptionSelect }) {
|
|
|
2685
2686
|
var _option$label;
|
|
2686
2687
|
const onChange = (v) => {
|
|
2687
2688
|
onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
commandId: option === null || option === void 0 ? void 0 : option.commandId
|
|
2689
|
+
...option,
|
|
2690
|
+
value: v
|
|
2691
2691
|
});
|
|
2692
2692
|
};
|
|
2693
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;
|
|
@@ -2717,21 +2717,21 @@ function getOptionKey(option) {
|
|
|
2717
2717
|
function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, onOptionSelect }) {
|
|
2718
2718
|
const { dropdownVisible, setDropdownVisible } = useContext(TooltipWrapperContext);
|
|
2719
2719
|
const menuManagerService = useDependency(IMenuManagerService);
|
|
2720
|
-
const
|
|
2721
|
-
const
|
|
2722
|
-
|
|
2723
|
-
const
|
|
2724
|
-
|
|
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]));
|
|
2725
2729
|
});
|
|
2726
|
-
return () =>
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
}, [
|
|
2731
|
-
menuId,
|
|
2732
|
-
menuManagerService,
|
|
2733
|
-
menuVersion
|
|
2734
|
-
]);
|
|
2730
|
+
return itemStates.length ? merge$1(...itemStates).pipe(scan((states, [key, hidden]) => ({
|
|
2731
|
+
...states,
|
|
2732
|
+
[key]: hidden
|
|
2733
|
+
}), {}), startWith({})) : of({});
|
|
2734
|
+
}, [menuItems]), {});
|
|
2735
2735
|
const filteredMenuItems = useMemo(() => {
|
|
2736
2736
|
return menuItems.filter((item) => {
|
|
2737
2737
|
var _item$key;
|
|
@@ -2749,39 +2749,6 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
2749
2749
|
onOptionSelect(option);
|
|
2750
2750
|
setDropdownVisible(false);
|
|
2751
2751
|
}
|
|
2752
|
-
useEffect(() => {
|
|
2753
|
-
const subscriptions = [];
|
|
2754
|
-
menuItems.forEach((item) => {
|
|
2755
|
-
if (!item.children) {
|
|
2756
|
-
var _item$item;
|
|
2757
|
-
if ((_item$item = item.item) === null || _item$item === void 0 ? void 0 : _item$item.hidden$) {
|
|
2758
|
-
const sub = item.item.hidden$.subscribe((hidden) => {
|
|
2759
|
-
setHiddenStates((prev) => ({
|
|
2760
|
-
...prev,
|
|
2761
|
-
[item.key]: hidden
|
|
2762
|
-
}));
|
|
2763
|
-
});
|
|
2764
|
-
subscriptions.push(sub);
|
|
2765
|
-
}
|
|
2766
|
-
} else {
|
|
2767
|
-
const sub = combineLatest(item.children.map((subItem) => {
|
|
2768
|
-
var _subItem$item$hidden$, _subItem$item;
|
|
2769
|
-
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);
|
|
2770
|
-
})).subscribe((hiddenValues) => {
|
|
2771
|
-
const isAllHidden = hiddenValues.every((hidden) => hidden === true);
|
|
2772
|
-
setHiddenStates((prev) => ({
|
|
2773
|
-
...prev,
|
|
2774
|
-
[item.key]: isAllHidden
|
|
2775
|
-
}));
|
|
2776
|
-
});
|
|
2777
|
-
subscriptions.push(sub);
|
|
2778
|
-
}
|
|
2779
|
-
});
|
|
2780
|
-
return () => {
|
|
2781
|
-
subscriptions.forEach((sub) => sub === null || sub === void 0 ? void 0 : sub.unsubscribe());
|
|
2782
|
-
setHiddenStates({});
|
|
2783
|
-
};
|
|
2784
|
-
}, [menuItems]);
|
|
2785
2752
|
if (slot) return /* @__PURE__ */ jsx(DropdownWrapper, {
|
|
2786
2753
|
disabled,
|
|
2787
2754
|
overlay: options.map((option) => /* @__PURE__ */ jsx(DropdownMenuLabel, {
|
|
@@ -3008,7 +2975,8 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
3008
2975
|
if (disabled) return;
|
|
3009
2976
|
let commandId = sId;
|
|
3010
2977
|
if (option.id) commandId = option.id;
|
|
3011
|
-
|
|
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 });
|
|
3012
2980
|
}
|
|
3013
2981
|
function handleSelectionsValueChange(value) {
|
|
3014
2982
|
if (disabled) return;
|
|
@@ -3016,7 +2984,10 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
3016
2984
|
}
|
|
3017
2985
|
function handleClick() {
|
|
3018
2986
|
if (disabled) return;
|
|
3019
|
-
if (menuType === 2)
|
|
2987
|
+
if (menuType === 2) {
|
|
2988
|
+
const commandParams = typeof params === "function" ? params() : params;
|
|
2989
|
+
executeCommand(bId, commandParams !== null && commandParams !== void 0 ? commandParams : { value });
|
|
2990
|
+
}
|
|
3020
2991
|
}
|
|
3021
2992
|
if (menuType === 2) return /* @__PURE__ */ jsxs("div", {
|
|
3022
2993
|
"data-u-command": id,
|
|
@@ -3081,7 +3052,6 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
3081
3052
|
function renderButtonType() {
|
|
3082
3053
|
var _label$name;
|
|
3083
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 : "");
|
|
3084
|
-
const commandValue = (value !== null && value !== void 0 ? value : typeof params === "function") ? params() : params;
|
|
3085
3055
|
return /* @__PURE__ */ jsx(ToolbarButton, {
|
|
3086
3056
|
"data-u-command": id,
|
|
3087
3057
|
className: "univer-text-sm",
|
|
@@ -3090,7 +3060,8 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
3090
3060
|
disabled,
|
|
3091
3061
|
onClick: () => {
|
|
3092
3062
|
var _props$commandId;
|
|
3093
|
-
|
|
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 });
|
|
3094
3065
|
},
|
|
3095
3066
|
onDoubleClick: () => props.subId && executeCommand(props.subId),
|
|
3096
3067
|
children: isCustomComponent ? /* @__PURE__ */ jsx(CustomLabel, {
|
|
@@ -3667,6 +3638,7 @@ function DesignTinyMenuGroup({ items, columns, sizeVariant = "default", layoutVa
|
|
|
3667
3638
|
//#endregion
|
|
3668
3639
|
//#region src/views/menu/desktop/TinyMenuGroup.tsx
|
|
3669
3640
|
const EMPTY_HIDDEN_ITEM_IDS = [];
|
|
3641
|
+
const EMPTY_TINY_MENU_CHILDREN = [];
|
|
3670
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", {
|
|
3671
3643
|
variants: {
|
|
3672
3644
|
disabled: {
|
|
@@ -3734,52 +3706,24 @@ function QuickTileMenuItem(props) {
|
|
|
3734
3706
|
});
|
|
3735
3707
|
}
|
|
3736
3708
|
function UITinyMenuGroup(props) {
|
|
3709
|
+
var _item$children;
|
|
3737
3710
|
const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, hoverSuppressed, columns, sizeVariant = "default", layoutVariant = "default", onOptionSelect } = props;
|
|
3738
|
-
const [activeItems, setActiveItems] = useState([]);
|
|
3739
|
-
const [hiddenItems, setHiddenItems] = useState([]);
|
|
3740
3711
|
const iconManager = useDependency(IconManager);
|
|
3741
3712
|
const localeService = useDependency(LocaleService);
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
});
|
|
3754
|
-
return () => {
|
|
3755
|
-
subscription.unsubscribe();
|
|
3756
|
-
observables.forEach((observable) => {
|
|
3757
|
-
observable.complete();
|
|
3758
|
-
});
|
|
3759
|
-
};
|
|
3760
|
-
}, [item]);
|
|
3761
|
-
useEffect(() => {
|
|
3762
|
-
const { children } = item;
|
|
3763
|
-
if (!children) return;
|
|
3764
|
-
const observables = children.map((child) => {
|
|
3765
|
-
var _child$item$hidden$, _child$item3;
|
|
3766
|
-
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);
|
|
3767
|
-
});
|
|
3768
|
-
const subscription = combineLatest(observables).subscribe((hiddenArr) => {
|
|
3769
|
-
const hiddenItems = [];
|
|
3770
|
-
for (let index = 0; index < hiddenArr.length; index++) if (hiddenArr[index]) hiddenItems.push(getTinyMenuChildStateKey(children[index]));
|
|
3771
|
-
setHiddenItems(hiddenItems);
|
|
3772
|
-
});
|
|
3773
|
-
return () => {
|
|
3774
|
-
subscription.unsubscribe();
|
|
3775
|
-
observables.forEach((observable) => {
|
|
3776
|
-
observable.complete();
|
|
3777
|
-
});
|
|
3778
|
-
};
|
|
3779
|
-
}, [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$, []);
|
|
3780
3724
|
const visibleChildren = useMemo(() => {
|
|
3781
|
-
var _item$
|
|
3782
|
-
return getVisibleTinyMenuChildren((_item$
|
|
3725
|
+
var _item$children2;
|
|
3726
|
+
return getVisibleTinyMenuChildren((_item$children2 = item.children) !== null && _item$children2 !== void 0 ? _item$children2 : [], [...hiddenItems, ...hiddenItemIds]);
|
|
3783
3727
|
}, [
|
|
3784
3728
|
hiddenItemIds,
|
|
3785
3729
|
hiddenItems,
|
|
@@ -3818,9 +3762,9 @@ function UITinyMenuGroup(props) {
|
|
|
3818
3762
|
});
|
|
3819
3763
|
}
|
|
3820
3764
|
function UIQuickTileMenuGroup(props) {
|
|
3821
|
-
var _item$
|
|
3765
|
+
var _item$children3;
|
|
3822
3766
|
const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, onOptionSelect } = props;
|
|
3823
|
-
if (!((_item$
|
|
3767
|
+
if (!((_item$children3 = item.children) === null || _item$children3 === void 0 ? void 0 : _item$children3.length)) return null;
|
|
3824
3768
|
return /* @__PURE__ */ jsx("div", {
|
|
3825
3769
|
className: "univer-item-center univer-grid univer-grid-cols-3 univer-gap-1.5 univer-py-1",
|
|
3826
3770
|
children: getVisibleTinyMenuChildren(item.children, hiddenItemIds).map((menuSchema) => /* @__PURE__ */ jsx(QuickTileMenuItem, {
|
|
@@ -4636,7 +4580,7 @@ function ContextMenuMenuItem(props) {
|
|
|
4636
4580
|
}), hasSubmenu && submenuVisible && (submenuPortalContainer ? createPortal(/* @__PURE__ */ jsx("div", {
|
|
4637
4581
|
ref: submenuElementRef,
|
|
4638
4582
|
dir: direction,
|
|
4639
|
-
|
|
4583
|
+
"data-u-context-menu-submenu": "true",
|
|
4640
4584
|
className: "univer-z-[1080] univer-w-max univer-max-w-[calc(100vw-16px)]",
|
|
4641
4585
|
style: {
|
|
4642
4586
|
position: "fixed",
|
|
@@ -4735,28 +4679,20 @@ function ContextMenuMenuItem(props) {
|
|
|
4735
4679
|
});
|
|
4736
4680
|
}
|
|
4737
4681
|
function useContextGroupHiddenStates$1(menuSchemas) {
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
if (!((_menuSchema$children3 = menuSchema.children) === null || _menuSchema$children3 === void 0 ? void 0 : _menuSchema$children3.length)) return null;
|
|
4743
|
-
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) => {
|
|
4744
4686
|
var _childSchema$item$hid, _childSchema$item;
|
|
4745
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);
|
|
4746
|
-
}))
|
|
4747
|
-
|
|
4748
|
-
setHiddenStates((state) => ({
|
|
4749
|
-
...state,
|
|
4750
|
-
[menuSchema.key]: isAllHidden
|
|
4751
|
-
}));
|
|
4752
|
-
});
|
|
4688
|
+
})) !== null && _menuSchema$children$ !== void 0 ? _menuSchema$children$ : [];
|
|
4689
|
+
return hiddenObservables.length ? [combineLatest(hiddenObservables).pipe(map((values) => [menuSchema.key, values.every(Boolean)]))] : [];
|
|
4753
4690
|
});
|
|
4754
|
-
return () => {
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
};
|
|
4758
|
-
}, [menuSchemas]);
|
|
4759
|
-
return hiddenStates;
|
|
4691
|
+
return groupStates.length ? merge$1(...groupStates).pipe(scan((states, [key, hidden]) => ({
|
|
4692
|
+
...states,
|
|
4693
|
+
[key]: hidden
|
|
4694
|
+
}), {}), startWith({})) : of({});
|
|
4695
|
+
}, [menuSchemas]), {});
|
|
4760
4696
|
}
|
|
4761
4697
|
|
|
4762
4698
|
//#endregion
|
|
@@ -4934,6 +4870,7 @@ function DesktopContextMenu() {
|
|
|
4934
4870
|
const MIN_SIDEBAR_WIDTH = 280;
|
|
4935
4871
|
const MAX_SIDEBAR_WIDTH = 800;
|
|
4936
4872
|
function Sidebar() {
|
|
4873
|
+
const localeService = useDependency(LocaleService);
|
|
4937
4874
|
const sidebarService = useDependency(ISidebarService);
|
|
4938
4875
|
const sidebarOptions = useObservable(sidebarService.sidebarOptions$);
|
|
4939
4876
|
const scrollRef = useRef(null);
|
|
@@ -5040,7 +4977,7 @@ function Sidebar() {
|
|
|
5040
4977
|
"data-u-comp": "sidebar",
|
|
5041
4978
|
role: "complementary",
|
|
5042
4979
|
"aria-expanded": !!(options === null || options === void 0 ? void 0 : options.visible),
|
|
5043
|
-
"aria-label": "
|
|
4980
|
+
"aria-label": localeService.t("ui.sidebar.panel"),
|
|
5044
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", {
|
|
5045
4982
|
"univer-w-96 univer-translate-x-0": options === null || options === void 0 ? void 0 : options.visible,
|
|
5046
4983
|
"univer-w-0 univer-translate-x-full": !(options === null || options === void 0 ? void 0 : options.visible)
|
|
@@ -5051,7 +4988,7 @@ function Sidebar() {
|
|
|
5051
4988
|
onMouseDown: handleResizeMouseDown,
|
|
5052
4989
|
role: "separator",
|
|
5053
4990
|
"aria-orientation": "vertical",
|
|
5054
|
-
"aria-label": "
|
|
4991
|
+
"aria-label": localeService.t("ui.sidebar.resize"),
|
|
5055
4992
|
tabIndex: 0,
|
|
5056
4993
|
onKeyDown: (e) => {
|
|
5057
4994
|
if (!sidebarRef.current) return;
|
|
@@ -5080,7 +5017,7 @@ function Sidebar() {
|
|
|
5080
5017
|
type: "button",
|
|
5081
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",
|
|
5082
5019
|
onClick: handleClose,
|
|
5083
|
-
"aria-label": "
|
|
5020
|
+
"aria-label": localeService.t("ui.sidebar.close"),
|
|
5084
5021
|
children: /* @__PURE__ */ jsx(CloseIcon, {})
|
|
5085
5022
|
})]
|
|
5086
5023
|
}),
|
|
@@ -5325,39 +5262,23 @@ function DesktopWorkbenchContent(props) {
|
|
|
5325
5262
|
sub.unsubscribe();
|
|
5326
5263
|
};
|
|
5327
5264
|
}, []);
|
|
5328
|
-
const
|
|
5265
|
+
const darkMode = useObservable(themeService.darkMode$, themeService.darkMode);
|
|
5329
5266
|
useLayoutEffect(() => {
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
else document.documentElement.classList.remove("univer-dark");
|
|
5334
|
-
});
|
|
5335
|
-
return () => {
|
|
5336
|
-
sub.unsubscribe();
|
|
5337
|
-
};
|
|
5338
|
-
}, []);
|
|
5267
|
+
if (darkMode) document.documentElement.classList.add("univer-dark");
|
|
5268
|
+
else document.documentElement.classList.remove("univer-dark");
|
|
5269
|
+
}, [darkMode]);
|
|
5339
5270
|
useEffect(() => {
|
|
5340
5271
|
if (contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
|
|
5341
5272
|
}, [onRendered]);
|
|
5342
|
-
const
|
|
5343
|
-
const
|
|
5273
|
+
const locale = useObservable(() => localeService.localeChanged$.pipe(map(() => localeService.getLocales())), localeService.getLocales(), false, [localeService]);
|
|
5274
|
+
const direction = useObservable(localeService.direction$, localeService.getDirection());
|
|
5344
5275
|
const portalContainer = useMemo(() => document.createElement("div"), []);
|
|
5345
5276
|
useEffect(() => {
|
|
5346
5277
|
document.body.appendChild(portalContainer);
|
|
5347
|
-
const subscriptions = [localeService.localeChanged$.subscribe(() => {
|
|
5348
|
-
setLocale(localeService.getLocales());
|
|
5349
|
-
}), localeService.direction$.subscribe(() => {
|
|
5350
|
-
setDirection(localeService.getDirection());
|
|
5351
|
-
})];
|
|
5352
5278
|
return () => {
|
|
5353
|
-
subscriptions.forEach((subscription) => subscription.unsubscribe());
|
|
5354
5279
|
document.body.removeChild(portalContainer);
|
|
5355
5280
|
};
|
|
5356
|
-
}, [
|
|
5357
|
-
localeService,
|
|
5358
|
-
mountContainer,
|
|
5359
|
-
portalContainer
|
|
5360
|
-
]);
|
|
5281
|
+
}, [mountContainer, portalContainer]);
|
|
5361
5282
|
useEffect(() => {
|
|
5362
5283
|
portalContainer.dir = direction;
|
|
5363
5284
|
}, [direction, portalContainer]);
|
|
@@ -5517,17 +5438,15 @@ var SingleUnitUIController = class extends Disposable {
|
|
|
5517
5438
|
//#endregion
|
|
5518
5439
|
//#region src/controllers/ui/ui-desktop.controller.ts
|
|
5519
5440
|
let DesktopUIController = class DesktopUIController extends SingleUnitUIController {
|
|
5520
|
-
constructor(_config, injector, lifecycleService, renderManagerService, layoutService, instanceService, menuManagerService, uiPartsService
|
|
5441
|
+
constructor(_config, injector, lifecycleService, renderManagerService, layoutService, instanceService, menuManagerService, uiPartsService) {
|
|
5521
5442
|
super(injector, instanceService, layoutService, lifecycleService, renderManagerService);
|
|
5522
5443
|
this._config = _config;
|
|
5523
|
-
this._componentManager = _componentManager;
|
|
5524
5444
|
menuManagerService.mergeMenu(menuSchema);
|
|
5525
5445
|
this._initBuiltinComponents(uiPartsService);
|
|
5526
5446
|
this._bootstrapWorkbench();
|
|
5527
5447
|
}
|
|
5528
5448
|
dispose() {
|
|
5529
5449
|
super.dispose();
|
|
5530
|
-
this._componentManager.dispose();
|
|
5531
5450
|
}
|
|
5532
5451
|
bootstrap(callback) {
|
|
5533
5452
|
return bootstrap$1(this._injector, this._config, callback);
|
|
@@ -5545,8 +5464,7 @@ DesktopUIController = __decorate([
|
|
|
5545
5464
|
__decorateParam(4, ILayoutService),
|
|
5546
5465
|
__decorateParam(5, IUniverInstanceService),
|
|
5547
5466
|
__decorateParam(6, IMenuManagerService),
|
|
5548
|
-
__decorateParam(7, IUIPartsService)
|
|
5549
|
-
__decorateParam(8, Inject(ComponentManager))
|
|
5467
|
+
__decorateParam(7, IUIPartsService)
|
|
5550
5468
|
], DesktopUIController);
|
|
5551
5469
|
function bootstrap$1(injector, options, callback) {
|
|
5552
5470
|
let mountContainer;
|
|
@@ -5579,7 +5497,7 @@ const IUIController = createIdentifier("univer.ui.ui-controller");
|
|
|
5579
5497
|
//#endregion
|
|
5580
5498
|
//#region package.json
|
|
5581
5499
|
var name = "@univerjs/ui";
|
|
5582
|
-
var version = "1.0.0-alpha.
|
|
5500
|
+
var version = "1.0.0-alpha.4";
|
|
5583
5501
|
|
|
5584
5502
|
//#endregion
|
|
5585
5503
|
//#region src/views/color-picker/interface.ts
|
|
@@ -20733,72 +20651,207 @@ function CategoryIcon(props) {
|
|
|
20733
20651
|
//#region src/services/font.service.ts
|
|
20734
20652
|
const IFontService = createIdentifier("univer.font-service");
|
|
20735
20653
|
const DEFAULT_FONT_LIST = [
|
|
20736
|
-
|
|
20737
|
-
|
|
20738
|
-
|
|
20739
|
-
|
|
20740
|
-
|
|
20741
|
-
|
|
20742
|
-
|
|
20743
|
-
|
|
20744
|
-
|
|
20745
|
-
|
|
20746
|
-
|
|
20747
|
-
|
|
20748
|
-
|
|
20749
|
-
|
|
20750
|
-
|
|
20751
|
-
|
|
20752
|
-
|
|
20753
|
-
|
|
20754
|
-
|
|
20755
|
-
|
|
20756
|
-
|
|
20757
|
-
|
|
20758
|
-
|
|
20759
|
-
|
|
20760
|
-
|
|
20761
|
-
|
|
20762
|
-
|
|
20763
|
-
|
|
20764
|
-
|
|
20765
|
-
|
|
20766
|
-
|
|
20767
|
-
|
|
20768
|
-
|
|
20769
|
-
|
|
20770
|
-
|
|
20771
|
-
|
|
20772
|
-
|
|
20773
|
-
|
|
20774
|
-
|
|
20775
|
-
|
|
20776
|
-
|
|
20777
|
-
|
|
20778
|
-
|
|
20779
|
-
|
|
20780
|
-
|
|
20781
|
-
|
|
20782
|
-
|
|
20783
|
-
|
|
20784
|
-
|
|
20785
|
-
|
|
20786
|
-
|
|
20787
|
-
|
|
20788
|
-
|
|
20789
|
-
|
|
20790
|
-
|
|
20791
|
-
|
|
20792
|
-
|
|
20793
|
-
|
|
20794
|
-
|
|
20795
|
-
|
|
20796
|
-
|
|
20797
|
-
|
|
20798
|
-
|
|
20799
|
-
|
|
20800
|
-
|
|
20801
|
-
|
|
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
|
+
}));
|
|
20802
20855
|
let FontService = class FontService {
|
|
20803
20856
|
constructor(_configService) {
|
|
20804
20857
|
this._configService = _configService;
|
|
@@ -20881,17 +20934,8 @@ FontService = __decorate([__decorateParam(0, IConfigService)], FontService);
|
|
|
20881
20934
|
//#region src/views/font-family/use-font-list.ts
|
|
20882
20935
|
function useFontList() {
|
|
20883
20936
|
const fontService = useDependency(IFontService);
|
|
20884
|
-
const [fonts, setFonts] = useState(() => fontService.getFonts());
|
|
20885
|
-
useEffect(() => {
|
|
20886
|
-
const subscription = fontService.fonts$.subscribe((fonts) => {
|
|
20887
|
-
setFonts(fonts);
|
|
20888
|
-
});
|
|
20889
|
-
return () => {
|
|
20890
|
-
subscription.unsubscribe();
|
|
20891
|
-
};
|
|
20892
|
-
}, [fontService]);
|
|
20893
20937
|
return {
|
|
20894
|
-
fonts,
|
|
20938
|
+
fonts: useObservable(fontService.fonts$, fontService.getFonts()),
|
|
20895
20939
|
fontService
|
|
20896
20940
|
};
|
|
20897
20941
|
}
|
|
@@ -21188,6 +21232,97 @@ const HeadingItem = (props) => {
|
|
|
21188
21232
|
};
|
|
21189
21233
|
const HEADING_ITEM_COMPONENT = "UI_COMPONENT_HEADING_ITEM";
|
|
21190
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
|
+
|
|
21191
21326
|
//#endregion
|
|
21192
21327
|
//#region src/views/slider/Slider.tsx
|
|
21193
21328
|
const SLIDER_WIDTH = 116;
|
|
@@ -21202,18 +21337,12 @@ function Slider(props) {
|
|
|
21202
21337
|
const { value, min = 0, max = 400, disabled = false, resetPoint = 100, shortcuts, onChange } = props;
|
|
21203
21338
|
const isRtl = useObservable(localeService.direction$, localeService.getDirection()) === "rtl";
|
|
21204
21339
|
const sliderInnerRailRef = useRef(null);
|
|
21205
|
-
const isEditingZoomRef = useRef(false);
|
|
21206
21340
|
const dragValueRef = useRef(value);
|
|
21207
21341
|
const pendingDragValueRef = useRef(null);
|
|
21208
21342
|
const lastCommittedDragValueRef = useRef(value);
|
|
21209
21343
|
const dragCommitTimerRef = useRef(null);
|
|
21210
|
-
const [zoomListVisible, setZoomListVisible] = useState(false);
|
|
21211
21344
|
const [isDragging, setIsDragging] = useState(false);
|
|
21212
21345
|
const [dragValue, setDragValue] = useState(value);
|
|
21213
|
-
const [zoomInputValue, setZoomInputValue] = useState(() => `${value}%`);
|
|
21214
|
-
useEffect(() => {
|
|
21215
|
-
if (!isEditingZoomRef.current) setZoomInputValue(`${value}%`);
|
|
21216
|
-
}, [value]);
|
|
21217
21346
|
useEffect(() => () => {
|
|
21218
21347
|
clearDragCommitTimer();
|
|
21219
21348
|
}, []);
|
|
@@ -21312,61 +21441,11 @@ function Slider(props) {
|
|
|
21312
21441
|
window.addEventListener("pointerup", onPointerUp);
|
|
21313
21442
|
window.addEventListener("pointerout", onPointerOut);
|
|
21314
21443
|
}
|
|
21315
|
-
function handleSelectZoomLevel(value) {
|
|
21316
|
-
if (disabled) return;
|
|
21317
|
-
setZoomListVisible(false);
|
|
21318
|
-
onChange && onChange(value);
|
|
21319
|
-
}
|
|
21320
|
-
function parseExactZoomInput(rawValue) {
|
|
21321
|
-
const normalizedValue = rawValue.trim().replace(/%$/, "").trim();
|
|
21322
|
-
if (normalizedValue === "") return null;
|
|
21323
|
-
const parsedValue = Number(normalizedValue);
|
|
21324
|
-
if (!Number.isFinite(parsedValue)) return null;
|
|
21325
|
-
return Math.round(clampValue(parsedValue));
|
|
21326
|
-
}
|
|
21327
|
-
function handleExactZoomFocus() {
|
|
21328
|
-
if (disabled) return;
|
|
21329
|
-
isEditingZoomRef.current = true;
|
|
21330
|
-
setZoomInputValue(String(value));
|
|
21331
|
-
}
|
|
21332
|
-
function commitExactZoomInput() {
|
|
21333
|
-
if (disabled) return;
|
|
21334
|
-
if (!isEditingZoomRef.current) return;
|
|
21335
|
-
const parsedValue = parseExactZoomInput(zoomInputValue);
|
|
21336
|
-
isEditingZoomRef.current = false;
|
|
21337
|
-
if (parsedValue == null) {
|
|
21338
|
-
setZoomInputValue(`${value}%`);
|
|
21339
|
-
return;
|
|
21340
|
-
}
|
|
21341
|
-
setZoomInputValue(`${parsedValue}%`);
|
|
21342
|
-
if (parsedValue !== value) onChange && onChange(parsedValue);
|
|
21343
|
-
}
|
|
21344
|
-
function handleExactZoomChange(value) {
|
|
21345
|
-
setZoomInputValue(value);
|
|
21346
|
-
}
|
|
21347
|
-
function handleInputKeyDown(e) {
|
|
21348
|
-
e.stopPropagation();
|
|
21349
|
-
if (e.key === "Enter") {
|
|
21350
|
-
e.preventDefault();
|
|
21351
|
-
commitExactZoomInput();
|
|
21352
|
-
e.currentTarget.blur();
|
|
21353
|
-
}
|
|
21354
|
-
}
|
|
21355
|
-
const items = [{
|
|
21356
|
-
type: "radio",
|
|
21357
|
-
value: value.toString(),
|
|
21358
|
-
options: shortcuts.map((item) => ({
|
|
21359
|
-
value: item.toString(),
|
|
21360
|
-
label: `${item}%`
|
|
21361
|
-
})),
|
|
21362
|
-
onSelect: (value) => handleSelectZoomLevel(+value)
|
|
21363
|
-
}];
|
|
21364
21444
|
const visualValue = isDragging ? dragValue : value;
|
|
21365
21445
|
const sliderOffset = Math.min(Math.max((_getSliderOffset = getSliderOffset(visualValue)) !== null && _getSliderOffset !== void 0 ? _getSliderOffset : 0, 0), 100);
|
|
21366
21446
|
const handleOffset = isRtl ? 100 - sliderOffset : sliderOffset;
|
|
21367
21447
|
const ReduceIcon = iconManager.get("ReduceIcon");
|
|
21368
21448
|
const IncreaseIcon = iconManager.get("IncreaseIcon");
|
|
21369
|
-
const MoreDownIcon = iconManager.get("MoreDownIcon");
|
|
21370
21449
|
return /* @__PURE__ */ jsxs("div", {
|
|
21371
21450
|
className: clsx("univer-flex univer-select-none univer-items-center univer-gap-1.5", { "univer-cursor-not-allowed": disabled }),
|
|
21372
21451
|
children: [
|
|
@@ -21424,33 +21503,13 @@ function Slider(props) {
|
|
|
21424
21503
|
onClick: () => handleStep(10),
|
|
21425
21504
|
children: /* @__PURE__ */ jsx(IncreaseIcon, { className: "univer-text-gray-500" })
|
|
21426
21505
|
}),
|
|
21427
|
-
/* @__PURE__ */
|
|
21428
|
-
|
|
21429
|
-
|
|
21430
|
-
|
|
21431
|
-
|
|
21432
|
-
|
|
21433
|
-
|
|
21434
|
-
disabled,
|
|
21435
|
-
type: "text",
|
|
21436
|
-
onChange: handleExactZoomChange,
|
|
21437
|
-
onFocus: handleExactZoomFocus,
|
|
21438
|
-
onBlur: commitExactZoomInput,
|
|
21439
|
-
onKeyDown: handleInputKeyDown
|
|
21440
|
-
}), /* @__PURE__ */ jsx(DropdownMenu, {
|
|
21441
|
-
align: "end",
|
|
21442
|
-
items,
|
|
21443
|
-
open: zoomListVisible,
|
|
21444
|
-
disabled,
|
|
21445
|
-
onOpenChange: setZoomListVisible,
|
|
21446
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
21447
|
-
className: "univer-h-6 univer-w-4 univer-rounded-none univer-p-0",
|
|
21448
|
-
size: "small",
|
|
21449
|
-
variant: "text",
|
|
21450
|
-
disabled,
|
|
21451
|
-
children: /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-size-3 univer-text-gray-500 dark:!univer-text-gray-300" })
|
|
21452
|
-
})
|
|
21453
|
-
})]
|
|
21506
|
+
/* @__PURE__ */ jsx(ZoomInput, {
|
|
21507
|
+
value,
|
|
21508
|
+
min,
|
|
21509
|
+
max,
|
|
21510
|
+
shortcuts,
|
|
21511
|
+
disabled,
|
|
21512
|
+
onChange
|
|
21454
21513
|
})
|
|
21455
21514
|
]
|
|
21456
21515
|
});
|
|
@@ -21483,11 +21542,13 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
21483
21542
|
}
|
|
21484
21543
|
_registerIcons() {
|
|
21485
21544
|
this.disposeWithMe(this._iconManager.register({
|
|
21545
|
+
ExpandIcon,
|
|
21486
21546
|
IncreaseIcon,
|
|
21487
21547
|
MoreDownIcon,
|
|
21488
21548
|
RedoIcon,
|
|
21489
21549
|
ReduceIcon,
|
|
21490
21550
|
ShortcutIcon,
|
|
21551
|
+
ShrinkIcon,
|
|
21491
21552
|
UndoIcon
|
|
21492
21553
|
}));
|
|
21493
21554
|
}
|
|
@@ -21578,7 +21639,7 @@ function MobileRibbon(props) {
|
|
|
21578
21639
|
type: "button",
|
|
21579
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 }),
|
|
21580
21641
|
disabled: activeIndex === 0,
|
|
21581
|
-
"aria-label": "
|
|
21642
|
+
"aria-label": localeService.t("ui.navigation.previous"),
|
|
21582
21643
|
onClick: () => selectTab(activeIndex - 1),
|
|
21583
21644
|
children: /* @__PURE__ */ jsx(MoreLeftIcon, { className: "univer-rotate-180 univer-text-sm" })
|
|
21584
21645
|
})
|
|
@@ -21615,7 +21676,7 @@ function MobileRibbon(props) {
|
|
|
21615
21676
|
dark:active:!univer-bg-gray-600
|
|
21616
21677
|
`, { "univer-opacity-40": activeIndex >= ribbon.length - 1 }),
|
|
21617
21678
|
disabled: activeIndex >= ribbon.length - 1,
|
|
21618
|
-
"aria-label": "
|
|
21679
|
+
"aria-label": localeService.t("ui.navigation.next"),
|
|
21619
21680
|
onClick: () => selectTab(activeIndex + 1),
|
|
21620
21681
|
children: /* @__PURE__ */ jsx(MoreRightIcon, { className: "univer-text-sm" })
|
|
21621
21682
|
}), hasHeaderMenu && /* @__PURE__ */ jsx("div", {
|
|
@@ -21635,7 +21696,7 @@ function MobileRibbon(props) {
|
|
|
21635
21696
|
dark:!univer-text-gray-300
|
|
21636
21697
|
`, { "univer-opacity-30": !canScrollLeft }),
|
|
21637
21698
|
disabled: !canScrollLeft,
|
|
21638
|
-
"aria-label": "
|
|
21699
|
+
"aria-label": localeService.t("ui.navigation.previous"),
|
|
21639
21700
|
onClick: () => scrollToolbar("left"),
|
|
21640
21701
|
children: /* @__PURE__ */ jsx(MoreLeftIcon, { className: "univer-text-sm" })
|
|
21641
21702
|
}),
|
|
@@ -21664,7 +21725,7 @@ function MobileRibbon(props) {
|
|
|
21664
21725
|
dark:!univer-text-gray-300
|
|
21665
21726
|
`, { "univer-opacity-30": !canScrollRight }),
|
|
21666
21727
|
disabled: !canScrollRight,
|
|
21667
|
-
"aria-label": "
|
|
21728
|
+
"aria-label": localeService.t("ui.navigation.next"),
|
|
21668
21729
|
onClick: () => scrollToolbar("right"),
|
|
21669
21730
|
children: /* @__PURE__ */ jsx(MoreRightIcon, { className: "univer-text-sm" })
|
|
21670
21731
|
})
|
|
@@ -21679,6 +21740,7 @@ function MobileMenu(props) {
|
|
|
21679
21740
|
var _viewStack;
|
|
21680
21741
|
const { menuType, onOptionSelect, schemas: providedSchemas, menuManagerService: providedMenuManagerService } = props;
|
|
21681
21742
|
const rootMenuManagerService = useDependency(IMenuManagerService);
|
|
21743
|
+
const localeService = useDependency(LocaleService);
|
|
21682
21744
|
const menuManagerService = providedMenuManagerService !== null && providedMenuManagerService !== void 0 ? providedMenuManagerService : rootMenuManagerService;
|
|
21683
21745
|
const [viewStack, setViewStack] = useState([]);
|
|
21684
21746
|
const menuSchemas = useMemo(() => {
|
|
@@ -21707,7 +21769,7 @@ function MobileMenu(props) {
|
|
|
21707
21769
|
children: [
|
|
21708
21770
|
/* @__PURE__ */ jsx("button", {
|
|
21709
21771
|
type: "button",
|
|
21710
|
-
"aria-label": "
|
|
21772
|
+
"aria-label": localeService.t("ui.navigation.back"),
|
|
21711
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",
|
|
21712
21774
|
onClick: closeView,
|
|
21713
21775
|
children: /* @__PURE__ */ jsx(MoreLeftIcon, { className: "univer-text-base" })
|
|
@@ -21943,30 +22005,20 @@ function getMenuSchemaTitle(schema, localeService) {
|
|
|
21943
22005
|
return schema.key;
|
|
21944
22006
|
}
|
|
21945
22007
|
function useContextGroupHiddenStates(menuSchemas) {
|
|
21946
|
-
|
|
21947
|
-
|
|
21948
|
-
const subscriptions = menuSchemas.map((menuSchema) => {
|
|
22008
|
+
return useObservable(useMemo(() => {
|
|
22009
|
+
const groupStates = menuSchemas.flatMap((menuSchema) => {
|
|
21949
22010
|
var _menuSchema$children;
|
|
21950
|
-
|
|
21951
|
-
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) => {
|
|
21952
22012
|
var _childSchema$item$hid, _childSchema$item;
|
|
21953
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);
|
|
21954
|
-
});
|
|
21955
|
-
|
|
21956
|
-
return combineLatest(hiddenObservables).subscribe((hiddenValues) => {
|
|
21957
|
-
const isAllHidden = hiddenValues.every((hidden) => hidden === true);
|
|
21958
|
-
setHiddenStates((state) => ({
|
|
21959
|
-
...state,
|
|
21960
|
-
[menuSchema.key]: isAllHidden
|
|
21961
|
-
}));
|
|
21962
|
-
});
|
|
22014
|
+
}) : [];
|
|
22015
|
+
return hiddenObservables.length ? [combineLatest(hiddenObservables).pipe(map((values) => [menuSchema.key, values.every(Boolean)]))] : [];
|
|
21963
22016
|
});
|
|
21964
|
-
return () => {
|
|
21965
|
-
|
|
21966
|
-
|
|
21967
|
-
};
|
|
21968
|
-
}, [menuSchemas]);
|
|
21969
|
-
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]), {});
|
|
21970
22022
|
}
|
|
21971
22023
|
function getLeafItemSchemas(schemas) {
|
|
21972
22024
|
return schemas.reduce((acc, schema) => {
|
|
@@ -22109,20 +22161,12 @@ function MobileWorkbench(props) {
|
|
|
22109
22161
|
const leftSidebarComponents = useComponentsOfPart("left-sidebar");
|
|
22110
22162
|
const globalComponents = useComponentsOfPart("global");
|
|
22111
22163
|
const toolbarComponents = useComponentsOfPart("toolbar");
|
|
22112
|
-
const
|
|
22113
|
-
useEffect(() => {
|
|
22114
|
-
const sub = themeService.darkMode$.subscribe((darkMode) => {
|
|
22115
|
-
setDarkMode(darkMode);
|
|
22116
|
-
});
|
|
22117
|
-
return () => {
|
|
22118
|
-
sub.unsubscribe();
|
|
22119
|
-
};
|
|
22120
|
-
}, []);
|
|
22164
|
+
const darkMode = useObservable(themeService.darkMode$, themeService.darkMode);
|
|
22121
22165
|
useEffect(() => {
|
|
22122
22166
|
if (contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
|
|
22123
22167
|
}, [onRendered]);
|
|
22124
|
-
const
|
|
22125
|
-
const
|
|
22168
|
+
const locale = useObservable(() => localeService.localeChanged$.pipe(map(() => localeService.getLocales())), localeService.getLocales(), false, [localeService]);
|
|
22169
|
+
const direction = useObservable(localeService.direction$, localeService.getDirection());
|
|
22126
22170
|
const portalContainer = useMemo(() => document.createElement("div"), []);
|
|
22127
22171
|
useLayoutEffect(() => {
|
|
22128
22172
|
const sub = themeService.currentTheme$.subscribe((theme) => {
|
|
@@ -22134,20 +22178,10 @@ function MobileWorkbench(props) {
|
|
|
22134
22178
|
}, []);
|
|
22135
22179
|
useEffect(() => {
|
|
22136
22180
|
document.body.appendChild(portalContainer);
|
|
22137
|
-
const subscriptions = [localeService.localeChanged$.subscribe(() => {
|
|
22138
|
-
setLocale(localeService.getLocales());
|
|
22139
|
-
}), localeService.direction$.subscribe(() => {
|
|
22140
|
-
setDirection(localeService.getDirection());
|
|
22141
|
-
})];
|
|
22142
22181
|
return () => {
|
|
22143
|
-
subscriptions.forEach((subscription) => subscription.unsubscribe());
|
|
22144
22182
|
document.body.removeChild(portalContainer);
|
|
22145
22183
|
};
|
|
22146
|
-
}, [
|
|
22147
|
-
localeService,
|
|
22148
|
-
mountContainer,
|
|
22149
|
-
portalContainer
|
|
22150
|
-
]);
|
|
22184
|
+
}, [mountContainer, portalContainer]);
|
|
22151
22185
|
useEffect(() => {
|
|
22152
22186
|
portalContainer.dir = direction;
|
|
22153
22187
|
}, [direction, portalContainer]);
|
|
@@ -22212,17 +22246,15 @@ function MobileWorkbench(props) {
|
|
|
22212
22246
|
//#endregion
|
|
22213
22247
|
//#region src/controllers/ui/ui-mobile.controller.ts
|
|
22214
22248
|
let MobileUIController = class MobileUIController extends SingleUnitUIController {
|
|
22215
|
-
constructor(_config, injector, lifecycleService, renderManagerService, layoutService, instanceService, menuManagerService, uiPartsService
|
|
22249
|
+
constructor(_config, injector, lifecycleService, renderManagerService, layoutService, instanceService, menuManagerService, uiPartsService) {
|
|
22216
22250
|
super(injector, instanceService, layoutService, lifecycleService, renderManagerService);
|
|
22217
22251
|
this._config = _config;
|
|
22218
|
-
this._componentManager = _componentManager;
|
|
22219
22252
|
menuManagerService.mergeMenu(menuSchema);
|
|
22220
22253
|
this._initBuiltinComponents(uiPartsService);
|
|
22221
22254
|
this._bootstrapWorkbench();
|
|
22222
22255
|
}
|
|
22223
22256
|
dispose() {
|
|
22224
22257
|
super.dispose();
|
|
22225
|
-
this._componentManager.dispose();
|
|
22226
22258
|
}
|
|
22227
22259
|
bootstrap(callback) {
|
|
22228
22260
|
return bootstrap(this._injector, this._config, callback);
|
|
@@ -22240,8 +22272,7 @@ MobileUIController = __decorate([
|
|
|
22240
22272
|
__decorateParam(4, ILayoutService),
|
|
22241
22273
|
__decorateParam(5, IUniverInstanceService),
|
|
22242
22274
|
__decorateParam(6, IMenuManagerService),
|
|
22243
|
-
__decorateParam(7, IUIPartsService)
|
|
22244
|
-
__decorateParam(8, Inject(ComponentManager))
|
|
22275
|
+
__decorateParam(7, IUIPartsService)
|
|
22245
22276
|
], MobileUIController);
|
|
22246
22277
|
function bootstrap(injector, options, callback) {
|
|
22247
22278
|
let mountContainer;
|
|
@@ -22275,9 +22306,10 @@ const INotificationService = createIdentifier("ui.notification.service");
|
|
|
22275
22306
|
//#region src/services/before-close/before-close.service.ts
|
|
22276
22307
|
const IBeforeCloseService = createIdentifier("univer.ui.before-close-service");
|
|
22277
22308
|
let DesktopBeforeCloseService = class DesktopBeforeCloseService extends Disposable {
|
|
22278
|
-
constructor(_notificationService) {
|
|
22309
|
+
constructor(_notificationService, _localeService) {
|
|
22279
22310
|
super();
|
|
22280
22311
|
this._notificationService = _notificationService;
|
|
22312
|
+
this._localeService = _localeService;
|
|
22281
22313
|
_defineProperty(this, "_beforeUnloadCallbacks", []);
|
|
22282
22314
|
_defineProperty(this, "_onCloseCallbacks", []);
|
|
22283
22315
|
_defineProperty(this, "_beforeUnloadHandler", void 0);
|
|
@@ -22288,7 +22320,7 @@ let DesktopBeforeCloseService = class DesktopBeforeCloseService extends Disposab
|
|
|
22288
22320
|
if (message) {
|
|
22289
22321
|
this._notificationService.show({
|
|
22290
22322
|
type: "error",
|
|
22291
|
-
title: "
|
|
22323
|
+
title: this._localeService.t("ui.beforeClose.title"),
|
|
22292
22324
|
content: message
|
|
22293
22325
|
});
|
|
22294
22326
|
if (typeof event === "undefined") event = window.event;
|
|
@@ -22325,7 +22357,7 @@ let DesktopBeforeCloseService = class DesktopBeforeCloseService extends Disposab
|
|
|
22325
22357
|
window.addEventListener("unload", this._unloadHandler);
|
|
22326
22358
|
}
|
|
22327
22359
|
};
|
|
22328
|
-
DesktopBeforeCloseService = __decorate([__decorateParam(0, INotificationService)], DesktopBeforeCloseService);
|
|
22360
|
+
DesktopBeforeCloseService = __decorate([__decorateParam(0, INotificationService), __decorateParam(1, Inject(LocaleService))], DesktopBeforeCloseService);
|
|
22329
22361
|
|
|
22330
22362
|
//#endregion
|
|
22331
22363
|
//#region src/utils/html.ts
|
|
@@ -22758,17 +22790,7 @@ const ContextConfirm = (props) => {
|
|
|
22758
22790
|
});
|
|
22759
22791
|
};
|
|
22760
22792
|
function ConfirmPart() {
|
|
22761
|
-
const
|
|
22762
|
-
const [confirmOptions, setConfirmOptions] = useState([]);
|
|
22763
|
-
useEffect(() => {
|
|
22764
|
-
const subscription = confirmService.confirmOptions$.subscribe((options) => {
|
|
22765
|
-
setConfirmOptions(options);
|
|
22766
|
-
});
|
|
22767
|
-
return () => {
|
|
22768
|
-
subscription.unsubscribe();
|
|
22769
|
-
};
|
|
22770
|
-
}, []);
|
|
22771
|
-
const props = confirmOptions.map((options) => {
|
|
22793
|
+
const props = useObservable(useDependency(IConfirmService).confirmOptions$, []).map((options) => {
|
|
22772
22794
|
const { children, title, ...restProps } = options;
|
|
22773
22795
|
const confirmProps = restProps;
|
|
22774
22796
|
for (const key of ["children", "title"]) {
|
|
@@ -22845,14 +22867,7 @@ const IDialogService = createIdentifier("univer.ui.dialog-service");
|
|
|
22845
22867
|
//#endregion
|
|
22846
22868
|
//#region src/views/components/dialog-part/DialogPart.tsx
|
|
22847
22869
|
function DialogPart() {
|
|
22848
|
-
const
|
|
22849
|
-
const [dialogOptions, setDialogOptions] = useState([]);
|
|
22850
|
-
useEffect(() => {
|
|
22851
|
-
const subscription = dialogService.getDialogs$().subscribe((options) => {
|
|
22852
|
-
setDialogOptions(options);
|
|
22853
|
-
});
|
|
22854
|
-
return () => subscription.unsubscribe();
|
|
22855
|
-
}, []);
|
|
22870
|
+
const dialogOptions = useObservable(useDependency(IDialogService).getDialogs$(), []);
|
|
22856
22871
|
const attrs = useMemo(() => dialogOptions.map((options) => {
|
|
22857
22872
|
const { children, title, footer, ...restProps } = options;
|
|
22858
22873
|
const dialogProps = restProps;
|
|
@@ -24257,15 +24272,31 @@ function extractFontFamily(styleStr) {
|
|
|
24257
24272
|
//#endregion
|
|
24258
24273
|
//#region src/views/components/dom/Print.tsx
|
|
24259
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) {
|
|
24260
24292
|
var _position$startY, _position$startX;
|
|
24261
|
-
const { layer, id, position } = props;
|
|
24293
|
+
const { layer, id, position, Component } = props;
|
|
24262
24294
|
const univerInstanceService = useDependency$1(IUniverInstanceService);
|
|
24263
24295
|
const domRef = useRef(null);
|
|
24264
24296
|
const innerDomRef = useRef(null);
|
|
24265
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)`);
|
|
24266
24298
|
const topRef = useRef((_position$startY = position === null || position === void 0 ? void 0 : position.startY) !== null && _position$startY !== void 0 ? _position$startY : 0);
|
|
24267
24299
|
const leftRef = useRef((_position$startX = position === null || position === void 0 ? void 0 : position.startX) !== null && _position$startX !== void 0 ? _position$startX : 0);
|
|
24268
|
-
const Component = typeof layer.componentKey === "string" ? useDependency$1(ComponentManager).get(layer.componentKey) : layer.componentKey;
|
|
24269
24300
|
const layerProps = useMemo(() => ({
|
|
24270
24301
|
data: layer.data,
|
|
24271
24302
|
...layer.props
|
|
@@ -24320,7 +24351,7 @@ const PrintFloatDomSingle = memo((props) => {
|
|
|
24320
24351
|
children: component
|
|
24321
24352
|
})
|
|
24322
24353
|
});
|
|
24323
|
-
}
|
|
24354
|
+
}
|
|
24324
24355
|
|
|
24325
24356
|
//#endregion
|
|
24326
24357
|
//#region src/views/progress-bar/ProgressBar.tsx
|
|
@@ -24405,4 +24436,4 @@ function ProgressBar(props) {
|
|
|
24405
24436
|
}
|
|
24406
24437
|
|
|
24407
24438
|
//#endregion
|
|
24408
|
-
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, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UIRuntimeScopeService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoShortcutItem, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, ZIndexManager, 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 };
|
|
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 };
|