@univerjs/ui 1.0.0-alpha.6 → 1.0.0-alpha.8
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/facade.js +9 -41
- package/lib/cjs/index.js +1434 -470
- package/lib/cjs/locale/ar-SA.js +12 -0
- package/lib/cjs/locale/ca-ES.js +12 -0
- package/lib/cjs/locale/de-DE.js +12 -0
- package/lib/cjs/locale/en-US.js +12 -0
- package/lib/cjs/locale/es-ES.js +12 -0
- package/lib/cjs/locale/fa-IR.js +12 -0
- package/lib/cjs/locale/fr-FR.js +12 -0
- package/lib/cjs/locale/id-ID.js +12 -0
- package/lib/cjs/locale/it-IT.js +12 -0
- package/lib/cjs/locale/ja-JP.js +12 -0
- package/lib/cjs/locale/ko-KR.js +12 -0
- package/lib/cjs/locale/pl-PL.js +12 -0
- package/lib/cjs/locale/pt-BR.js +12 -0
- package/lib/cjs/locale/ru-RU.js +12 -0
- package/lib/cjs/locale/sk-SK.js +12 -0
- package/lib/cjs/locale/vi-VN.js +12 -0
- package/lib/cjs/locale/zh-CN.js +12 -0
- package/lib/cjs/locale/zh-HK.js +12 -0
- package/lib/cjs/locale/zh-TW.js +12 -0
- package/lib/es/facade.js +11 -43
- package/lib/es/index.js +1431 -475
- package/lib/es/locale/ar-SA.js +12 -0
- package/lib/es/locale/ca-ES.js +12 -0
- package/lib/es/locale/de-DE.js +12 -0
- package/lib/es/locale/en-US.js +12 -0
- package/lib/es/locale/es-ES.js +12 -0
- package/lib/es/locale/fa-IR.js +12 -0
- package/lib/es/locale/fr-FR.js +12 -0
- package/lib/es/locale/id-ID.js +12 -0
- package/lib/es/locale/it-IT.js +12 -0
- package/lib/es/locale/ja-JP.js +12 -0
- package/lib/es/locale/ko-KR.js +12 -0
- package/lib/es/locale/pl-PL.js +12 -0
- package/lib/es/locale/pt-BR.js +12 -0
- package/lib/es/locale/ru-RU.js +12 -0
- package/lib/es/locale/sk-SK.js +12 -0
- package/lib/es/locale/vi-VN.js +12 -0
- package/lib/es/locale/zh-CN.js +12 -0
- package/lib/es/locale/zh-HK.js +12 -0
- package/lib/es/locale/zh-TW.js +12 -0
- package/lib/facade.js +11 -43
- package/lib/index.css +224 -6
- package/lib/index.js +1431 -475
- package/lib/locale/ar-SA.js +12 -0
- package/lib/locale/ca-ES.js +12 -0
- package/lib/locale/de-DE.js +12 -0
- package/lib/locale/en-US.js +12 -0
- package/lib/locale/es-ES.js +12 -0
- package/lib/locale/fa-IR.js +12 -0
- package/lib/locale/fr-FR.js +12 -0
- package/lib/locale/id-ID.js +12 -0
- package/lib/locale/it-IT.js +12 -0
- package/lib/locale/ja-JP.js +12 -0
- package/lib/locale/ko-KR.js +12 -0
- package/lib/locale/pl-PL.js +12 -0
- package/lib/locale/pt-BR.js +12 -0
- package/lib/locale/ru-RU.js +12 -0
- package/lib/locale/sk-SK.js +12 -0
- package/lib/locale/vi-VN.js +12 -0
- package/lib/locale/zh-CN.js +12 -0
- package/lib/locale/zh-HK.js +12 -0
- package/lib/locale/zh-TW.js +12 -0
- package/lib/types/commands/operations/open-feature-search.operation.d.ts +17 -0
- package/lib/types/controllers/feature-search/feature-search.controller.d.ts +20 -0
- package/lib/types/controllers/ui/ui.controller.d.ts +1 -1
- package/lib/types/facade/f-univer.d.ts +0 -8
- package/lib/types/facade/index.d.ts +0 -2
- package/lib/types/index.d.ts +4 -4
- package/lib/types/locale/en-US.d.ts +12 -0
- package/lib/types/menu/feature-search.menu.d.ts +18 -0
- package/lib/types/{controllers/menus/menus.d.ts → menu/history.menu.d.ts} +2 -2
- package/lib/types/{controllers/shortcut-display/menu.d.ts → menu/shortcut-panel.menu.d.ts} +2 -2
- package/lib/types/services/contextmenu/contextmenu-host.service.d.ts +5 -1
- package/lib/types/services/menu/menu-manager.service.d.ts +11 -0
- package/lib/types/services/menu/types.d.ts +1 -0
- package/lib/types/services/parts/parts.service.d.ts +3 -0
- package/lib/types/services/shortcut/shortcut.service.d.ts +21 -1
- package/lib/types/services/workbench/workbench.service.d.ts +30 -0
- package/lib/types/utils/embed-boundary.d.ts +2 -0
- package/lib/types/views/components/feature-search/FeatureSearch.d.ts +29 -0
- package/lib/types/views/components/ribbon/RibbonGrid.d.ts +23 -0
- package/lib/types/views/components/ribbon/ToolbarItem.d.ts +10 -1
- package/lib/types/views/components/ribbon/ribbon-grid-layout.d.ts +27 -0
- package/lib/types/views/components/ribbon/ribbon-menu/RibbonGridMenu.d.ts +21 -0
- package/lib/types/views/components/sidebar/Sidebar.d.ts +0 -2
- package/lib/types/views/components/workbench-skeleton/WorkbenchSkeleton.d.ts +22 -0
- package/lib/types/views/custom-label/CustomLabel.d.ts +1 -0
- package/lib/types/views/emoji-picker/EmojiPicker.d.ts +7 -3
- package/lib/types/views/emoji-picker/emoji-picker-utils.d.ts +1 -1
- package/lib/types/views/emoji-picker/index.d.ts +0 -1
- package/lib/types/views/index.d.ts +1 -0
- package/lib/types/views/symbol-picker/SymbolPicker.d.ts +31 -0
- package/lib/types/views/symbol-picker/index.d.ts +18 -0
- package/lib/types/views/symbol-picker/symbols.d.ts +23 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +16 -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/types/facade/f-hooks.d.ts +0 -63
package/lib/es/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
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";
|
|
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, Quantity, RedoCommand, SHEET_EDITOR_UNITS, ThemeService, Tools, UndoCommand, UniverInstanceType, Workbook, createIdentifier, dedupeBy, generateRandomId, getBorderStyleType, isInternalEditorID, isRealNum, merge, mergeOverrideWithDependencies, registerDependencies, remove, throttle, toDisposable, touchDependencies } from "@univerjs/core";
|
|
2
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
|
-
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,
|
|
4
|
+
import { Button, ColorPicker, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, 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, scrollbarClassName, toast, unmount } from "@univerjs/design";
|
|
5
5
|
import { IRenderManagerService, UniverRenderEnginePlugin, ptToPx } from "@univerjs/engine-render";
|
|
6
|
-
import { distinctUntilChanged as distinctUntilChanged$1, map as map$1, scan as scan$1, startWith as startWith$1 } from "rxjs/operators";
|
|
6
|
+
import { distinctUntilChanged as distinctUntilChanged$1, map as map$1, scan as scan$1, startWith as startWith$1, switchMap as switchMap$1 } from "rxjs/operators";
|
|
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, 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";
|
|
10
|
+
import { ActivityIcon, CheckMarkIcon, CloseIcon, DatabaseIcon, ExpandIcon, EyeIcon, FeatureSearchIcon, FoodsIcon, FunctionIcon, HomeIcon, IncreaseIcon, InfoIcon, InsertIcon, KeyboardIcon, MoreDownIcon, MoreLeftIcon, MoreRightIcon, MoreVerticalIcon, NatureIcon, ObjectsIcon, PeopleIcon, PlacesIcon, RandomIcon, RecentIcon, RedoIcon, ReduceIcon, SearchIcon, ShortcutIcon, ShrinkIcon, SymbolsIcon, UndoIcon } from "@univerjs/icons";
|
|
11
11
|
|
|
12
12
|
//#region src/utils/embed-boundary.ts
|
|
13
13
|
/**
|
|
@@ -26,6 +26,7 @@ import { ActivityIcon, CheckMarkIcon, CloseIcon, DatabaseIcon, ExpandIcon, EyeIc
|
|
|
26
26
|
* limitations under the License.
|
|
27
27
|
*/
|
|
28
28
|
const EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
|
|
29
|
+
const EMBED_CHILD_UNIT_ID_ATTRIBUTE = "data-embed-child-unit-id";
|
|
29
30
|
function getEmbedBoundaryOwner(target) {
|
|
30
31
|
var _ref, _getAttributeValue;
|
|
31
32
|
if (!hasClosest(target)) return;
|
|
@@ -35,6 +36,12 @@ function getEmbedBoundaryOwner(target) {
|
|
|
35
36
|
function isEmbedBoundaryTarget(target) {
|
|
36
37
|
return hasClosest(target) && target.closest(`[${"data-embed-interaction-boundary-owner"}]`) != null;
|
|
37
38
|
}
|
|
39
|
+
function getEmbedChildUnitId(target) {
|
|
40
|
+
var _ref2, _getAttributeValue2;
|
|
41
|
+
if (!hasClosest(target)) return;
|
|
42
|
+
const childRuntime = target.closest(`[${EMBED_CHILD_UNIT_ID_ATTRIBUTE}]`);
|
|
43
|
+
return (_ref2 = (_getAttributeValue2 = getAttributeValue(target, "data-embed-child-unit-id")) !== null && _getAttributeValue2 !== void 0 ? _getAttributeValue2 : getAttributeValue(childRuntime, "data-embed-child-unit-id")) !== null && _ref2 !== void 0 ? _ref2 : void 0;
|
|
44
|
+
}
|
|
38
45
|
function keepInteractionInsideSameEmbedBoundary(event) {
|
|
39
46
|
const owner = getEmbedBoundaryOwner(event.currentTarget);
|
|
40
47
|
if (!owner) return;
|
|
@@ -50,7 +57,7 @@ function getAttributeValue(target, name) {
|
|
|
50
57
|
}
|
|
51
58
|
|
|
52
59
|
//#endregion
|
|
53
|
-
//#region \0@oxc-project+runtime@0.
|
|
60
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
54
61
|
function _typeof(o) {
|
|
55
62
|
"@babel/helpers - typeof";
|
|
56
63
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -61,7 +68,7 @@ function _typeof(o) {
|
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
//#endregion
|
|
64
|
-
//#region \0@oxc-project+runtime@0.
|
|
71
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
65
72
|
function toPrimitive(t, r) {
|
|
66
73
|
if ("object" != _typeof(t) || !t) return t;
|
|
67
74
|
var e = t[Symbol.toPrimitive];
|
|
@@ -74,14 +81,14 @@ function toPrimitive(t, r) {
|
|
|
74
81
|
}
|
|
75
82
|
|
|
76
83
|
//#endregion
|
|
77
|
-
//#region \0@oxc-project+runtime@0.
|
|
84
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
78
85
|
function toPropertyKey(t) {
|
|
79
86
|
var i = toPrimitive(t, "string");
|
|
80
87
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
//#endregion
|
|
84
|
-
//#region \0@oxc-project+runtime@0.
|
|
91
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
85
92
|
function _defineProperty(e, r, t) {
|
|
86
93
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
87
94
|
value: t,
|
|
@@ -92,7 +99,7 @@ function _defineProperty(e, r, t) {
|
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
//#endregion
|
|
95
|
-
//#region \0@oxc-project+runtime@0.
|
|
102
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
96
103
|
function __decorateParam(paramIndex, decorator) {
|
|
97
104
|
return function(target, key) {
|
|
98
105
|
decorator(target, key, paramIndex);
|
|
@@ -100,7 +107,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
100
107
|
}
|
|
101
108
|
|
|
102
109
|
//#endregion
|
|
103
|
-
//#region \0@oxc-project+runtime@0.
|
|
110
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
104
111
|
function __decorate(decorators, target, key, desc) {
|
|
105
112
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
106
113
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -457,12 +464,13 @@ var ZIndexManager = class {
|
|
|
457
464
|
//#region src/common/menu-hidden-observable.ts
|
|
458
465
|
function getMenuHiddenObservable(accessor, targetUniverType, matchUnitId, needHideUnitId) {
|
|
459
466
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
467
|
+
const getUnitType = (unitId) => SHEET_EDITOR_UNITS.includes(unitId) ? UniverInstanceType.UNIVER_SHEET : univerInstanceService.getUnitType(unitId);
|
|
460
468
|
return new Observable((subscriber) => {
|
|
461
469
|
const subscription = univerInstanceService.focused$.subscribe((unitId) => {
|
|
462
470
|
if (unitId == null) return subscriber.next(true);
|
|
463
471
|
if (matchUnitId && matchUnitId !== unitId) return subscriber.next(true);
|
|
464
472
|
if (needHideUnitId && (Array.isArray(needHideUnitId) ? needHideUnitId.includes(unitId) : needHideUnitId === unitId)) return subscriber.next(true);
|
|
465
|
-
const univerType =
|
|
473
|
+
const univerType = getUnitType(unitId);
|
|
466
474
|
subscriber.next(univerType !== targetUniverType);
|
|
467
475
|
});
|
|
468
476
|
const focusedUniverInstance = univerInstanceService.getFocusedUnit();
|
|
@@ -470,7 +478,7 @@ function getMenuHiddenObservable(accessor, targetUniverType, matchUnitId, needHi
|
|
|
470
478
|
const currentUnit = univerInstanceService.getCurrentUnitOfType(targetUniverType);
|
|
471
479
|
subscriber.next(currentUnit == null);
|
|
472
480
|
} else {
|
|
473
|
-
const univerType =
|
|
481
|
+
const univerType = getUnitType(focusedUniverInstance.getUnitId());
|
|
474
482
|
subscriber.next(univerType !== targetUniverType);
|
|
475
483
|
}
|
|
476
484
|
return () => subscription.unsubscribe();
|
|
@@ -829,18 +837,47 @@ var PlatformService = class {
|
|
|
829
837
|
}
|
|
830
838
|
};
|
|
831
839
|
|
|
840
|
+
//#endregion
|
|
841
|
+
//#region src/services/runtime-scope/ui-runtime-scope.service.ts
|
|
842
|
+
const IUIRuntimeScopeService = createIdentifier("ui.runtime-scope.service");
|
|
843
|
+
var UIRuntimeScopeService = class extends Disposable {
|
|
844
|
+
constructor(..._args) {
|
|
845
|
+
super(..._args);
|
|
846
|
+
_defineProperty(this, "_scopes", /* @__PURE__ */ new Map());
|
|
847
|
+
}
|
|
848
|
+
register(scope) {
|
|
849
|
+
this._scopes.set(scope.unitId, scope);
|
|
850
|
+
return toDisposable(() => {
|
|
851
|
+
if (this._scopes.get(scope.unitId) === scope) this._scopes.delete(scope.unitId);
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
get(unitId) {
|
|
855
|
+
return unitId ? this._scopes.get(unitId) : void 0;
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
|
|
832
859
|
//#endregion
|
|
833
860
|
//#region src/services/shortcut/shortcut.service.ts
|
|
834
861
|
/**
|
|
862
|
+
* Defines whether a Univer shortcut should yield to the browser's native behavior
|
|
863
|
+
* when the keyboard event originates from an editable text element.
|
|
864
|
+
*/
|
|
865
|
+
let NativeTextEditorShortcutBehavior = /* @__PURE__ */ function(NativeTextEditorShortcutBehavior) {
|
|
866
|
+
NativeTextEditorShortcutBehavior[NativeTextEditorShortcutBehavior["ALLOW_NATIVE"] = 0] = "ALLOW_NATIVE";
|
|
867
|
+
NativeTextEditorShortcutBehavior[NativeTextEditorShortcutBehavior["OVERRIDE_NATIVE"] = 1] = "OVERRIDE_NATIVE";
|
|
868
|
+
return NativeTextEditorShortcutBehavior;
|
|
869
|
+
}({});
|
|
870
|
+
/**
|
|
835
871
|
* The dependency injection identifier of the {@link IShortcutService}.
|
|
836
872
|
*/
|
|
837
873
|
const IShortcutService = createIdentifier("ui.shortcut.service");
|
|
838
874
|
let ShortcutService = class ShortcutService extends Disposable {
|
|
839
|
-
constructor(_commandService, _platformService, _contextService, _layoutService) {
|
|
875
|
+
constructor(_commandService, _platformService, _contextService, _runtimeScopeService, _layoutService) {
|
|
840
876
|
super();
|
|
841
877
|
this._commandService = _commandService;
|
|
842
878
|
this._platformService = _platformService;
|
|
843
879
|
this._contextService = _contextService;
|
|
880
|
+
this._runtimeScopeService = _runtimeScopeService;
|
|
844
881
|
this._layoutService = _layoutService;
|
|
845
882
|
_defineProperty(this, "_shortCutMapping", /* @__PURE__ */ new Map());
|
|
846
883
|
_defineProperty(this, "_commandIDMapping", /* @__PURE__ */ new Map());
|
|
@@ -910,25 +947,29 @@ let ShortcutService = class ShortcutService extends Disposable {
|
|
|
910
947
|
_resolveKeyboardEvent(e) {
|
|
911
948
|
const candidate = this.dispatch(e);
|
|
912
949
|
if (candidate) {
|
|
913
|
-
|
|
950
|
+
var _this$_getRuntimeServ, _this$_getRuntimeServ2;
|
|
951
|
+
(_this$_getRuntimeServ = (_this$_getRuntimeServ2 = this._getRuntimeService(e, ICommandService)) === null || _this$_getRuntimeServ2 === void 0 ? void 0 : _this$_getRuntimeServ2.executeCommand(candidate.id, candidate.staticParameters)) !== null && _this$_getRuntimeServ !== void 0 || this._commandService.executeCommand(candidate.id, candidate.staticParameters);
|
|
914
952
|
e.preventDefault();
|
|
915
953
|
}
|
|
916
954
|
}
|
|
917
955
|
dispatch(e) {
|
|
956
|
+
var _this$_getRuntimeServ3;
|
|
918
957
|
if (this._forceEscaped || this._forceDisabled) return;
|
|
919
958
|
if (this._layoutService && !this._layoutService.checkElementInCurrentContainers(e.target)) return;
|
|
920
959
|
const binding = this._deriveBindingFromEvent(e);
|
|
921
960
|
if (binding === null) return;
|
|
922
|
-
if (this._shouldLetEmbedTextEditorHandleNativeShortcut(e, binding)) return;
|
|
923
961
|
const shortcuts = this._shortCutMapping.get(binding);
|
|
924
962
|
if (shortcuts === void 0) return;
|
|
925
|
-
|
|
963
|
+
const contextService = (_this$_getRuntimeServ3 = this._getRuntimeService(e, IContextService)) !== null && _this$_getRuntimeServ3 !== void 0 ? _this$_getRuntimeServ3 : this._contextService;
|
|
964
|
+
const candidateShortcut = Array.from(shortcuts).sort((s1, s2) => {
|
|
926
965
|
var _s2$priority, _s1$priority;
|
|
927
966
|
return ((_s2$priority = s2.priority) !== null && _s2$priority !== void 0 ? _s2$priority : 0) - ((_s1$priority = s1.priority) !== null && _s1$priority !== void 0 ? _s1$priority : 0);
|
|
928
967
|
}).find((s) => {
|
|
929
|
-
var _s$preconditions, _s$preconditions2;
|
|
930
|
-
return (_s$preconditions = (_s$preconditions2 = s.preconditions) === null || _s$preconditions2 === void 0 ? void 0 : _s$preconditions2.call(s,
|
|
968
|
+
var _s$eventPreconditions, _s$eventPreconditions2, _s$preconditions, _s$preconditions2;
|
|
969
|
+
return ((_s$eventPreconditions = (_s$eventPreconditions2 = s.eventPreconditions) === null || _s$eventPreconditions2 === void 0 ? void 0 : _s$eventPreconditions2.call(s, e)) !== null && _s$eventPreconditions !== void 0 ? _s$eventPreconditions : true) && ((_s$preconditions = (_s$preconditions2 = s.preconditions) === null || _s$preconditions2 === void 0 ? void 0 : _s$preconditions2.call(s, contextService)) !== null && _s$preconditions !== void 0 ? _s$preconditions : true);
|
|
931
970
|
});
|
|
971
|
+
if (this._shouldLetEmbedTextEditorHandleNativeShortcut(e, binding) && (candidateShortcut === null || candidateShortcut === void 0 ? void 0 : candidateShortcut.nativeTextEditorBehavior) !== 1) return;
|
|
972
|
+
return candidateShortcut;
|
|
932
973
|
}
|
|
933
974
|
_getBindingFromItem(item) {
|
|
934
975
|
if (this._platformService.isMac && item.mac) return item.mac;
|
|
@@ -951,12 +992,18 @@ let ShortcutService = class ShortcutService extends Disposable {
|
|
|
951
992
|
if (!(target instanceof HTMLElement)) return false;
|
|
952
993
|
return (target.isContentEditable || target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) && isEmbedBoundaryTarget(target);
|
|
953
994
|
}
|
|
995
|
+
_getRuntimeService(event, identifier) {
|
|
996
|
+
const childUnitId = getEmbedChildUnitId(event.target);
|
|
997
|
+
const runtimeScope = this._runtimeScopeService.get(childUnitId);
|
|
998
|
+
return (runtimeScope === null || runtimeScope === void 0 ? void 0 : runtimeScope.has(identifier)) ? runtimeScope.get(identifier) : void 0;
|
|
999
|
+
}
|
|
954
1000
|
};
|
|
955
1001
|
ShortcutService = __decorate([
|
|
956
1002
|
__decorateParam(0, ICommandService),
|
|
957
1003
|
__decorateParam(1, IPlatformService),
|
|
958
1004
|
__decorateParam(2, IContextService),
|
|
959
|
-
__decorateParam(3,
|
|
1005
|
+
__decorateParam(3, IUIRuntimeScopeService),
|
|
1006
|
+
__decorateParam(4, Optional(ILayoutService))
|
|
960
1007
|
], ShortcutService);
|
|
961
1008
|
|
|
962
1009
|
//#endregion
|
|
@@ -1072,6 +1119,7 @@ let RibbonStartGroup = /* @__PURE__ */ function(RibbonStartGroup) {
|
|
|
1072
1119
|
RibbonStartGroup["HISTORY"] = "ribbon.start.history";
|
|
1073
1120
|
RibbonStartGroup["FORMAT"] = "ribbon.start.format";
|
|
1074
1121
|
RibbonStartGroup["LAYOUT"] = "ribbon.start.layout";
|
|
1122
|
+
RibbonStartGroup["NUMBER"] = "ribbon.start.number";
|
|
1075
1123
|
RibbonStartGroup["OTHERS"] = "ribbon.start.others";
|
|
1076
1124
|
return RibbonStartGroup;
|
|
1077
1125
|
}({});
|
|
@@ -1150,7 +1198,8 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
|
|
|
1150
1198
|
["ribbon.start.history"]: { order: 0 },
|
|
1151
1199
|
["ribbon.start.format"]: { order: 1 },
|
|
1152
1200
|
["ribbon.start.layout"]: { order: 2 },
|
|
1153
|
-
["ribbon.start.
|
|
1201
|
+
["ribbon.start.number"]: { order: 3 },
|
|
1202
|
+
["ribbon.start.others"]: { order: 4 }
|
|
1154
1203
|
},
|
|
1155
1204
|
["ribbon.insert"]: {
|
|
1156
1205
|
order: 1,
|
|
@@ -1298,7 +1347,8 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
|
|
|
1298
1347
|
quickLayout: value.quickLayout,
|
|
1299
1348
|
quickColumns: value.quickColumns,
|
|
1300
1349
|
quickLayoutVariant: value.quickLayoutVariant,
|
|
1301
|
-
tiny: value.tiny
|
|
1350
|
+
tiny: value.tiny,
|
|
1351
|
+
gridLayout: value.gridLayout
|
|
1302
1352
|
};
|
|
1303
1353
|
if (value.menuItemFactory) {
|
|
1304
1354
|
const item = this._injector.invoke(value.menuItemFactory);
|
|
@@ -1409,6 +1459,10 @@ ShortcutPanelController = __decorate([
|
|
|
1409
1459
|
__decorateParam(2, ICommandService)
|
|
1410
1460
|
], ShortcutPanelController);
|
|
1411
1461
|
|
|
1462
|
+
//#endregion
|
|
1463
|
+
//#region src/services/dialog/dialog.service.ts
|
|
1464
|
+
const IDialogService = createIdentifier("univer.ui.dialog-service");
|
|
1465
|
+
|
|
1412
1466
|
//#endregion
|
|
1413
1467
|
//#region src/services/menu/menu.ts
|
|
1414
1468
|
let MenuItemType = /* @__PURE__ */ function(MenuItemType) {
|
|
@@ -1427,7 +1481,372 @@ function isMenuButtonSelectorItem(v) {
|
|
|
1427
1481
|
}
|
|
1428
1482
|
|
|
1429
1483
|
//#endregion
|
|
1430
|
-
//#region src/
|
|
1484
|
+
//#region src/services/ribbon/ribbon.service.ts
|
|
1485
|
+
const IRibbonService = createIdentifier("univer.ribbon-service");
|
|
1486
|
+
function isSameHiddenMap(previous, current) {
|
|
1487
|
+
return previous.length === current.length && previous.every((hidden, index) => hidden === current[index]);
|
|
1488
|
+
}
|
|
1489
|
+
let DesktopRibbonService = class DesktopRibbonService extends Disposable {
|
|
1490
|
+
constructor(_menuManagerService, _univerInstanceService) {
|
|
1491
|
+
super();
|
|
1492
|
+
this._menuManagerService = _menuManagerService;
|
|
1493
|
+
this._univerInstanceService = _univerInstanceService;
|
|
1494
|
+
_defineProperty(this, "_ribbon$", new BehaviorSubject([]));
|
|
1495
|
+
_defineProperty(this, "ribbon$", this._ribbon$.asObservable());
|
|
1496
|
+
_defineProperty(this, "_activatedTab$", new BehaviorSubject("ribbon.start"));
|
|
1497
|
+
_defineProperty(this, "activatedTab$", this._activatedTab$.asObservable());
|
|
1498
|
+
_defineProperty(this, "_collapsedIds$", new BehaviorSubject([]));
|
|
1499
|
+
_defineProperty(this, "collapsedIds$", this._collapsedIds$.asObservable());
|
|
1500
|
+
_defineProperty(this, "_fakeToolbarVisible$", new BehaviorSubject(false));
|
|
1501
|
+
_defineProperty(this, "fakeToolbarVisible$", this._fakeToolbarVisible$.asObservable());
|
|
1502
|
+
_defineProperty(this, "_visibleContextualTabs", /* @__PURE__ */ new Set());
|
|
1503
|
+
_defineProperty(this, "_contextualTabs", /* @__PURE__ */ new Set());
|
|
1504
|
+
_defineProperty(this, "_lastNonContextualActivatedTab", "ribbon.start");
|
|
1505
|
+
_defineProperty(this, "_hiddenSubscription", null);
|
|
1506
|
+
this._initRibbonSubscription();
|
|
1507
|
+
}
|
|
1508
|
+
setActivatedTab(tab) {
|
|
1509
|
+
if (!this._isContextualTab(tab)) this._lastNonContextualActivatedTab = tab;
|
|
1510
|
+
this._activatedTab$.next(tab);
|
|
1511
|
+
}
|
|
1512
|
+
showContextualTab(tab, options) {
|
|
1513
|
+
this._visibleContextualTabs.add(tab);
|
|
1514
|
+
this._updateRibbon();
|
|
1515
|
+
if (options === null || options === void 0 ? void 0 : options.activate) this.setActivatedTab(tab);
|
|
1516
|
+
}
|
|
1517
|
+
hideContextualTab(tab) {
|
|
1518
|
+
if (!this._visibleContextualTabs.delete(tab)) return;
|
|
1519
|
+
this._updateRibbon();
|
|
1520
|
+
}
|
|
1521
|
+
hideAllContextualTabs() {
|
|
1522
|
+
if (this._visibleContextualTabs.size === 0) return;
|
|
1523
|
+
this._visibleContextualTabs.clear();
|
|
1524
|
+
this._updateRibbon();
|
|
1525
|
+
}
|
|
1526
|
+
setCollapsedIds(ids) {
|
|
1527
|
+
this._collapsedIds$.next(ids);
|
|
1528
|
+
}
|
|
1529
|
+
setFakeToolbarVisible(visible) {
|
|
1530
|
+
this._fakeToolbarVisible$.next(visible);
|
|
1531
|
+
}
|
|
1532
|
+
_initRibbonSubscription() {
|
|
1533
|
+
this.disposeWithMe(combineLatest([this._menuManagerService.menuChanged$.pipe(startWith$1(void 0)), this._univerInstanceService.focused$.pipe(startWith$1(void 0), distinctUntilChanged$1())]).subscribe(() => {
|
|
1534
|
+
this._updateRibbon();
|
|
1535
|
+
}));
|
|
1536
|
+
}
|
|
1537
|
+
_updateRibbon() {
|
|
1538
|
+
var _this$_hiddenSubscrip;
|
|
1539
|
+
const ribbon = this._filterContextualTabs(this._menuManagerService.getMenuByPositionKey("ribbon"));
|
|
1540
|
+
const hiddenObservableMap = [];
|
|
1541
|
+
const hiddenKeyMap = [];
|
|
1542
|
+
for (const group of ribbon) if (group.children) {
|
|
1543
|
+
for (const item of group.children) if (item.children) for (const child of item.children) {
|
|
1544
|
+
var _child$item;
|
|
1545
|
+
if ((_child$item = child.item) === null || _child$item === void 0 ? void 0 : _child$item.hidden$) {
|
|
1546
|
+
hiddenObservableMap.push(child.item.hidden$);
|
|
1547
|
+
hiddenKeyMap.push(child.key);
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
(_this$_hiddenSubscrip = this._hiddenSubscription) === null || _this$_hiddenSubscrip === void 0 || _this$_hiddenSubscrip.unsubscribe();
|
|
1552
|
+
this._hiddenSubscription = null;
|
|
1553
|
+
if (hiddenObservableMap.length === 0) {
|
|
1554
|
+
this._setRibbon(ribbon);
|
|
1555
|
+
return;
|
|
1556
|
+
}
|
|
1557
|
+
this._hiddenSubscription = combineLatest(hiddenObservableMap.map((hidden$) => hidden$.pipe(startWith$1(false)))).pipe(distinctUntilChanged$1(isSameHiddenMap)).subscribe((hiddenMap) => {
|
|
1558
|
+
const newRibbon = [];
|
|
1559
|
+
const hiddenPathMap = hiddenMap.map((hidden, index) => {
|
|
1560
|
+
if (hidden) return hiddenKeyMap[index];
|
|
1561
|
+
return null;
|
|
1562
|
+
}).filter((item) => !!item);
|
|
1563
|
+
for (const group of ribbon) {
|
|
1564
|
+
var _group$children, _newGroup$children2;
|
|
1565
|
+
const newGroup = {
|
|
1566
|
+
...group,
|
|
1567
|
+
children: []
|
|
1568
|
+
};
|
|
1569
|
+
if ((_group$children = group.children) === null || _group$children === void 0 ? void 0 : _group$children.length) for (const item of group.children) {
|
|
1570
|
+
var _item$children;
|
|
1571
|
+
const newItem = {
|
|
1572
|
+
...item,
|
|
1573
|
+
children: []
|
|
1574
|
+
};
|
|
1575
|
+
let shouldAddItem = true;
|
|
1576
|
+
if ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) {
|
|
1577
|
+
var _newItem$children2;
|
|
1578
|
+
for (const child of item.children) if (!hiddenPathMap.includes(child.key)) {
|
|
1579
|
+
var _newItem$children;
|
|
1580
|
+
(_newItem$children = newItem.children) === null || _newItem$children === void 0 || _newItem$children.push(child);
|
|
1581
|
+
}
|
|
1582
|
+
if ((_newItem$children2 = newItem.children) === null || _newItem$children2 === void 0 ? void 0 : _newItem$children2.every((child) => {
|
|
1583
|
+
var _child$children;
|
|
1584
|
+
return ((_child$children = child.children) === null || _child$children === void 0 ? void 0 : _child$children.length) === 0;
|
|
1585
|
+
})) shouldAddItem = false;
|
|
1586
|
+
}
|
|
1587
|
+
if (shouldAddItem) {
|
|
1588
|
+
var _newGroup$children;
|
|
1589
|
+
(_newGroup$children = newGroup.children) === null || _newGroup$children === void 0 || _newGroup$children.push(newItem);
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
if (((_newGroup$children2 = newGroup.children) === null || _newGroup$children2 === void 0 ? void 0 : _newGroup$children2.length) && newGroup.children.every((item) => {
|
|
1593
|
+
var _item$children2;
|
|
1594
|
+
return (_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.length;
|
|
1595
|
+
})) newRibbon.push(newGroup);
|
|
1596
|
+
}
|
|
1597
|
+
this._setRibbon(newRibbon);
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1600
|
+
_filterContextualTabs(ribbon) {
|
|
1601
|
+
this._contextualTabs.clear();
|
|
1602
|
+
ribbon.forEach((group) => {
|
|
1603
|
+
if (group.contextual) this._contextualTabs.add(group.key);
|
|
1604
|
+
});
|
|
1605
|
+
return ribbon.filter((group) => !group.contextual || this._visibleContextualTabs.has(group.key));
|
|
1606
|
+
}
|
|
1607
|
+
_setRibbon(ribbon) {
|
|
1608
|
+
const activatedTab = this._activatedTab$.getValue();
|
|
1609
|
+
const activeGroup = ribbon.find((group) => group.key === activatedTab);
|
|
1610
|
+
if (!activeGroup && this._contextualTabs.has(activatedTab)) {
|
|
1611
|
+
var _ref, _ribbon$find;
|
|
1612
|
+
const fallbackTab = (_ref = (_ribbon$find = ribbon.find((group) => group.key === this._lastNonContextualActivatedTab && !group.contextual)) !== null && _ribbon$find !== void 0 ? _ribbon$find : ribbon.find((group) => group.key === "ribbon.start")) !== null && _ref !== void 0 ? _ref : ribbon[0];
|
|
1613
|
+
if (fallbackTab) this._activatedTab$.next(fallbackTab.key);
|
|
1614
|
+
} else if (!activeGroup && ribbon.some((group) => group.key === "ribbon.start")) {
|
|
1615
|
+
const fallbackTab = ribbon.find((group) => group.key === "ribbon.start");
|
|
1616
|
+
this._activatedTab$.next(fallbackTab.key);
|
|
1617
|
+
if (!fallbackTab.contextual) this._lastNonContextualActivatedTab = fallbackTab.key;
|
|
1618
|
+
} else if (activeGroup && !activeGroup.contextual) this._lastNonContextualActivatedTab = activeGroup.key;
|
|
1619
|
+
this._ribbon$.next(ribbon);
|
|
1620
|
+
}
|
|
1621
|
+
_isContextualTab(tab) {
|
|
1622
|
+
return this._contextualTabs.has(tab) || this._ribbon$.getValue().some((group) => group.key === tab && group.contextual);
|
|
1623
|
+
}
|
|
1624
|
+
dispose() {
|
|
1625
|
+
var _this$_hiddenSubscrip2;
|
|
1626
|
+
(_this$_hiddenSubscrip2 = this._hiddenSubscription) === null || _this$_hiddenSubscrip2 === void 0 || _this$_hiddenSubscrip2.unsubscribe();
|
|
1627
|
+
this._hiddenSubscription = null;
|
|
1628
|
+
this._ribbon$.next([]);
|
|
1629
|
+
this._ribbon$.complete();
|
|
1630
|
+
this._activatedTab$.complete();
|
|
1631
|
+
this._collapsedIds$.complete();
|
|
1632
|
+
this._fakeToolbarVisible$.complete();
|
|
1633
|
+
super.dispose();
|
|
1634
|
+
}
|
|
1635
|
+
};
|
|
1636
|
+
DesktopRibbonService = __decorate([__decorateParam(0, IMenuManagerService), __decorateParam(1, IUniverInstanceService)], DesktopRibbonService);
|
|
1637
|
+
|
|
1638
|
+
//#endregion
|
|
1639
|
+
//#region src/utils/di.ts
|
|
1640
|
+
function unwrap(o) {
|
|
1641
|
+
if (typeof o === "function") return o();
|
|
1642
|
+
return o;
|
|
1643
|
+
}
|
|
1644
|
+
function useObservableRef(observable, defaultValue) {
|
|
1645
|
+
const ref = useRef(defaultValue);
|
|
1646
|
+
useEffect(() => {
|
|
1647
|
+
if (observable) {
|
|
1648
|
+
const sub = unwrap(observable).subscribe((value) => {
|
|
1649
|
+
ref.current = value;
|
|
1650
|
+
});
|
|
1651
|
+
return () => sub.unsubscribe();
|
|
1652
|
+
}
|
|
1653
|
+
}, [observable]);
|
|
1654
|
+
return ref;
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
//#endregion
|
|
1658
|
+
//#region src/views/components/feature-search/FeatureSearch.tsx
|
|
1659
|
+
const FEATURE_SEARCH_COMPONENT = "FeatureSearch";
|
|
1660
|
+
const FEATURE_SEARCH_DIALOG_ID = "FEATURE_SEARCH_DIALOG";
|
|
1661
|
+
function resolveParams(item, value) {
|
|
1662
|
+
const params = typeof item.params === "function" ? item.params() : item.params;
|
|
1663
|
+
return params !== null && params !== void 0 ? params : value === void 0 ? void 0 : { value };
|
|
1664
|
+
}
|
|
1665
|
+
function resolveOptionParams(option) {
|
|
1666
|
+
const params = typeof option.params === "function" ? option.params(option.value) : option.params;
|
|
1667
|
+
return params !== null && params !== void 0 ? params : option.value === void 0 ? void 0 : { value: option.value };
|
|
1668
|
+
}
|
|
1669
|
+
function deduplicate(items) {
|
|
1670
|
+
return items.filter((item, index) => items.findIndex((candidate) => candidate.commandId === item.commandId && Tools.diffValue(candidate.params, item.params)) === index);
|
|
1671
|
+
}
|
|
1672
|
+
function FeatureSearch() {
|
|
1673
|
+
const menuManagerService = useDependency(IMenuManagerService);
|
|
1674
|
+
const localeService = useDependency(LocaleService);
|
|
1675
|
+
const commandService = useDependency(ICommandService);
|
|
1676
|
+
const dialogService = useDependency(IDialogService);
|
|
1677
|
+
const layoutService = useDependency(ILayoutService);
|
|
1678
|
+
const ribbonService = useDependency(IRibbonService);
|
|
1679
|
+
const items = useObservable(useMemo(() => {
|
|
1680
|
+
function getItemTitle(item) {
|
|
1681
|
+
var _ref, _item$title;
|
|
1682
|
+
const titleKey = (_ref = (_item$title = item.title) !== null && _item$title !== void 0 ? _item$title : item.tooltip) !== null && _ref !== void 0 ? _ref : item.description;
|
|
1683
|
+
return titleKey ? localeService.t(titleKey) : "";
|
|
1684
|
+
}
|
|
1685
|
+
function collectCandidates(schemas, path, keyPath, ancestors = [], parentTitle) {
|
|
1686
|
+
return schemas.flatMap((schema, index) => {
|
|
1687
|
+
var _schema$title;
|
|
1688
|
+
const schemaTitle = localeService.t((_schema$title = schema.title) !== null && _schema$title !== void 0 ? _schema$title : "");
|
|
1689
|
+
const schemaPath = schemaTitle ? [...path, schemaTitle] : path;
|
|
1690
|
+
const schemaKeyPath = [...keyPath, `${schema.key}:${index}`];
|
|
1691
|
+
const result = [];
|
|
1692
|
+
if (schema.item) result.push({
|
|
1693
|
+
key: `${schemaKeyPath.join("/")}:item`,
|
|
1694
|
+
item: schema.item,
|
|
1695
|
+
path: schemaPath,
|
|
1696
|
+
ancestors,
|
|
1697
|
+
parentTitle
|
|
1698
|
+
});
|
|
1699
|
+
if (schema.headerActionItem) result.push({
|
|
1700
|
+
key: `${schemaKeyPath.join("/")}:header`,
|
|
1701
|
+
item: schema.headerActionItem,
|
|
1702
|
+
path: schemaPath,
|
|
1703
|
+
ancestors,
|
|
1704
|
+
parentTitle
|
|
1705
|
+
});
|
|
1706
|
+
if (schema.children) result.push(...collectCandidates(schema.children, schemaPath, schemaKeyPath, schema.item ? [...ancestors, schema.item] : ancestors, schema.item ? getItemTitle(schema.item) : parentTitle));
|
|
1707
|
+
return result;
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
function observeCandidate(candidate) {
|
|
1711
|
+
var _item$hidden$$pipe, _item$hidden$, _item$disabled$$pipe, _item$disabled$, _item$value$$pipe, _item$value$;
|
|
1712
|
+
const { item } = candidate;
|
|
1713
|
+
const hasOptions = item.type === 1 || item.type === 2;
|
|
1714
|
+
const selections = hasOptions ? item.selections : void 0;
|
|
1715
|
+
const selections$ = isObservable(selections) ? selections.pipe(startWith$1([])) : of(selections !== null && selections !== void 0 ? selections : []);
|
|
1716
|
+
return combineLatest([
|
|
1717
|
+
candidate.ancestors.length ? combineLatest(candidate.ancestors.map((ancestor) => {
|
|
1718
|
+
var _ancestor$hidden$$pip, _ancestor$hidden$;
|
|
1719
|
+
return (_ancestor$hidden$$pip = (_ancestor$hidden$ = ancestor.hidden$) === null || _ancestor$hidden$ === void 0 ? void 0 : _ancestor$hidden$.pipe(startWith$1(true))) !== null && _ancestor$hidden$$pip !== void 0 ? _ancestor$hidden$$pip : of(false);
|
|
1720
|
+
})).pipe(map$1((states) => states.some(Boolean))) : of(false),
|
|
1721
|
+
candidate.ancestors.length ? combineLatest(candidate.ancestors.map((ancestor) => {
|
|
1722
|
+
var _ancestor$disabled$$p, _ancestor$disabled$;
|
|
1723
|
+
return (_ancestor$disabled$$p = (_ancestor$disabled$ = ancestor.disabled$) === null || _ancestor$disabled$ === void 0 ? void 0 : _ancestor$disabled$.pipe(startWith$1(true))) !== null && _ancestor$disabled$$p !== void 0 ? _ancestor$disabled$$p : of(false);
|
|
1724
|
+
})).pipe(map$1((states) => states.some(Boolean))) : of(false),
|
|
1725
|
+
(_item$hidden$$pipe = (_item$hidden$ = item.hidden$) === null || _item$hidden$ === void 0 ? void 0 : _item$hidden$.pipe(startWith$1(true))) !== null && _item$hidden$$pipe !== void 0 ? _item$hidden$$pipe : of(false),
|
|
1726
|
+
(_item$disabled$$pipe = (_item$disabled$ = item.disabled$) === null || _item$disabled$ === void 0 ? void 0 : _item$disabled$.pipe(startWith$1(true))) !== null && _item$disabled$$pipe !== void 0 ? _item$disabled$$pipe : of(false),
|
|
1727
|
+
(_item$value$$pipe = (_item$value$ = item.value$) === null || _item$value$ === void 0 ? void 0 : _item$value$.pipe(startWith$1(void 0))) !== null && _item$value$$pipe !== void 0 ? _item$value$$pipe : of(void 0),
|
|
1728
|
+
selections$
|
|
1729
|
+
]).pipe(map$1(([ancestorHidden, ancestorDisabled, hidden, disabled, value, options]) => {
|
|
1730
|
+
if (ancestorHidden || ancestorDisabled || hidden || disabled) return [];
|
|
1731
|
+
const title = getItemTitle(item);
|
|
1732
|
+
const path = candidate.path.join(" / ");
|
|
1733
|
+
const result = [];
|
|
1734
|
+
if (title && item.type !== 1 && item.type !== 3) {
|
|
1735
|
+
var _item$description, _item$commandId;
|
|
1736
|
+
result.push({
|
|
1737
|
+
key: candidate.key,
|
|
1738
|
+
title,
|
|
1739
|
+
parentTitle: candidate.parentTitle,
|
|
1740
|
+
description: localeService.t((_item$description = item.description) !== null && _item$description !== void 0 ? _item$description : ""),
|
|
1741
|
+
path,
|
|
1742
|
+
commandId: (_item$commandId = item.commandId) !== null && _item$commandId !== void 0 ? _item$commandId : item.id,
|
|
1743
|
+
params: resolveParams(item, value),
|
|
1744
|
+
getParams: () => resolveParams(item, value)
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1747
|
+
if (hasOptions) options.forEach((option, index) => {
|
|
1748
|
+
var _ref2, _ref3, _ref4, _option$commandId, _ref5, _ref6, _option$id;
|
|
1749
|
+
if (option.disabled || typeof option.label !== "string") return;
|
|
1750
|
+
const commandId = (_ref2 = (_ref3 = (_ref4 = (_option$commandId = option.commandId) !== null && _option$commandId !== void 0 ? _option$commandId : option.id) !== null && _ref4 !== void 0 ? _ref4 : item.selectionsCommandId) !== null && _ref3 !== void 0 ? _ref3 : item.commandId) !== null && _ref2 !== void 0 ? _ref2 : item.id;
|
|
1751
|
+
result.push({
|
|
1752
|
+
key: `${candidate.key}:option:${(_ref5 = (_ref6 = (_option$id = option.id) !== null && _option$id !== void 0 ? _option$id : option.commandId) !== null && _ref6 !== void 0 ? _ref6 : option.value) !== null && _ref5 !== void 0 ? _ref5 : index}`,
|
|
1753
|
+
title: localeService.t(option.label),
|
|
1754
|
+
parentTitle: title,
|
|
1755
|
+
description: "",
|
|
1756
|
+
path,
|
|
1757
|
+
commandId,
|
|
1758
|
+
params: resolveOptionParams(option),
|
|
1759
|
+
getParams: () => resolveOptionParams(option)
|
|
1760
|
+
});
|
|
1761
|
+
});
|
|
1762
|
+
return result;
|
|
1763
|
+
}));
|
|
1764
|
+
}
|
|
1765
|
+
return combineLatest([ribbonService.ribbon$, merge$1(of(void 0), menuManagerService.menuChanged$, localeService.localeChanged$)]).pipe(switchMap$1(([ribbon]) => {
|
|
1766
|
+
const candidates = [...collectCandidates(ribbon, [localeService.t("ui.featureSearch.ribbon")], ["ribbon"]), ...collectCandidates(menuManagerService.getMenuByPositionKey("contextMenu"), [localeService.t("ui.featureSearch.contextMenu")], ["contextMenu"])];
|
|
1767
|
+
if (candidates.length === 0) return of([]);
|
|
1768
|
+
return combineLatest(candidates.map(observeCandidate)).pipe(map$1((items) => deduplicate(items.flat())));
|
|
1769
|
+
}));
|
|
1770
|
+
}, [
|
|
1771
|
+
localeService,
|
|
1772
|
+
menuManagerService,
|
|
1773
|
+
ribbonService
|
|
1774
|
+
]), []);
|
|
1775
|
+
async function execute(item) {
|
|
1776
|
+
layoutService.focus();
|
|
1777
|
+
if (await commandService.executeCommand(item.commandId, item.getParams())) dialogService.close(FEATURE_SEARCH_DIALOG_ID);
|
|
1778
|
+
}
|
|
1779
|
+
return /* @__PURE__ */ jsxs(Command, {
|
|
1780
|
+
label: localeService.t("ui.featureSearch.title"),
|
|
1781
|
+
loop: true,
|
|
1782
|
+
children: [/* @__PURE__ */ jsx(CommandInput, {
|
|
1783
|
+
autoFocus: true,
|
|
1784
|
+
placeholder: localeService.t("ui.featureSearch.placeholder")
|
|
1785
|
+
}), /* @__PURE__ */ jsxs(CommandList, { children: [/* @__PURE__ */ jsx(CommandEmpty, { children: localeService.t("ui.featureSearch.empty") }), /* @__PURE__ */ jsx(CommandGroup, { children: items.map((item) => {
|
|
1786
|
+
var _item$parentTitle;
|
|
1787
|
+
return /* @__PURE__ */ jsxs(CommandItem, {
|
|
1788
|
+
value: item.key,
|
|
1789
|
+
keywords: [
|
|
1790
|
+
(_item$parentTitle = item.parentTitle) !== null && _item$parentTitle !== void 0 ? _item$parentTitle : "",
|
|
1791
|
+
item.title,
|
|
1792
|
+
item.description,
|
|
1793
|
+
item.path
|
|
1794
|
+
],
|
|
1795
|
+
onSelect: () => execute(item),
|
|
1796
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
1797
|
+
className: "univer-flex univer-min-w-0 univer-flex-1 univer-items-center univer-gap-1",
|
|
1798
|
+
children: [item.parentTitle && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
1799
|
+
className: "univer-shrink-0",
|
|
1800
|
+
children: item.parentTitle
|
|
1801
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1802
|
+
className: "univer-text-gray-400",
|
|
1803
|
+
children: "/"
|
|
1804
|
+
})] }), /* @__PURE__ */ jsx("span", {
|
|
1805
|
+
className: "univer-truncate",
|
|
1806
|
+
children: item.title
|
|
1807
|
+
})]
|
|
1808
|
+
}), item.path && /* @__PURE__ */ jsx("span", {
|
|
1809
|
+
className: "univer-max-w-1/2 univer-truncate univer-text-xs univer-text-gray-400",
|
|
1810
|
+
children: item.path
|
|
1811
|
+
})]
|
|
1812
|
+
}, item.key);
|
|
1813
|
+
}) })] })]
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1817
|
+
//#endregion
|
|
1818
|
+
//#region src/commands/operations/open-feature-search.operation.ts
|
|
1819
|
+
const OpenFeatureSearchOperation = {
|
|
1820
|
+
id: "ui.operation.open-feature-search",
|
|
1821
|
+
type: CommandType.OPERATION,
|
|
1822
|
+
handler: (accessor) => {
|
|
1823
|
+
const dialogService = accessor.get(IDialogService);
|
|
1824
|
+
const localeService = accessor.get(LocaleService);
|
|
1825
|
+
dialogService.open({
|
|
1826
|
+
id: FEATURE_SEARCH_DIALOG_ID,
|
|
1827
|
+
width: 560,
|
|
1828
|
+
title: { title: localeService.t("ui.featureSearch.title") },
|
|
1829
|
+
children: { label: FEATURE_SEARCH_COMPONENT },
|
|
1830
|
+
onClose: () => dialogService.close(FEATURE_SEARCH_DIALOG_ID)
|
|
1831
|
+
});
|
|
1832
|
+
return true;
|
|
1833
|
+
}
|
|
1834
|
+
};
|
|
1835
|
+
|
|
1836
|
+
//#endregion
|
|
1837
|
+
//#region src/menu/feature-search.menu.ts
|
|
1838
|
+
function FeatureSearchMenuItemFactory() {
|
|
1839
|
+
return {
|
|
1840
|
+
id: OpenFeatureSearchOperation.id,
|
|
1841
|
+
title: "ui.featureSearch.title",
|
|
1842
|
+
tooltip: "ui.featureSearch.title",
|
|
1843
|
+
icon: "FeatureSearchIcon",
|
|
1844
|
+
type: 0
|
|
1845
|
+
};
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
//#endregion
|
|
1849
|
+
//#region src/menu/history.menu.ts
|
|
1431
1850
|
const undoRedoDisableFactory$ = (accessor, isUndo) => {
|
|
1432
1851
|
const undoRedoService = accessor.get(IUndoRedoService);
|
|
1433
1852
|
const contextService = accessor.get(IContextService);
|
|
@@ -1460,13 +1879,13 @@ function RedoMenuItemFactory(accessor) {
|
|
|
1460
1879
|
}
|
|
1461
1880
|
|
|
1462
1881
|
//#endregion
|
|
1463
|
-
//#region src/
|
|
1882
|
+
//#region src/menu/shortcut-panel.menu.ts
|
|
1464
1883
|
function ShortcutPanelMenuItemFactory() {
|
|
1465
1884
|
return {
|
|
1466
1885
|
id: ToggleShortcutPanelOperation.id,
|
|
1467
1886
|
title: "ui.toggle-shortcut-panel",
|
|
1468
1887
|
tooltip: "ui.toggle-shortcut-panel",
|
|
1469
|
-
icon: "
|
|
1888
|
+
icon: "KeyboardIcon",
|
|
1470
1889
|
type: 0
|
|
1471
1890
|
};
|
|
1472
1891
|
}
|
|
@@ -1477,17 +1896,33 @@ const menuSchema = {
|
|
|
1477
1896
|
["ribbon.start.history"]: {
|
|
1478
1897
|
[UndoCommand.id]: {
|
|
1479
1898
|
order: 0,
|
|
1899
|
+
gridLayout: {
|
|
1900
|
+
row: 1,
|
|
1901
|
+
column: 1,
|
|
1902
|
+
iconSize: 18
|
|
1903
|
+
},
|
|
1480
1904
|
menuItemFactory: UndoMenuItemFactory
|
|
1481
1905
|
},
|
|
1482
1906
|
[RedoCommand.id]: {
|
|
1483
1907
|
order: 1,
|
|
1908
|
+
gridLayout: {
|
|
1909
|
+
row: 2,
|
|
1910
|
+
column: 1,
|
|
1911
|
+
iconSize: 18
|
|
1912
|
+
},
|
|
1484
1913
|
menuItemFactory: RedoMenuItemFactory
|
|
1485
1914
|
}
|
|
1486
1915
|
},
|
|
1487
|
-
["ribbon.start.others"]: {
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1916
|
+
["ribbon.start.others"]: {
|
|
1917
|
+
[ToggleShortcutPanelOperation.id]: {
|
|
1918
|
+
order: 1,
|
|
1919
|
+
menuItemFactory: ShortcutPanelMenuItemFactory
|
|
1920
|
+
},
|
|
1921
|
+
[OpenFeatureSearchOperation.id]: {
|
|
1922
|
+
order: 2,
|
|
1923
|
+
menuItemFactory: FeatureSearchMenuItemFactory
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1491
1926
|
};
|
|
1492
1927
|
|
|
1493
1928
|
//#endregion
|
|
@@ -1513,6 +1948,7 @@ var UIPartsService = class extends Disposable {
|
|
|
1513
1948
|
constructor(..._args) {
|
|
1514
1949
|
super(..._args);
|
|
1515
1950
|
_defineProperty(this, "_componentsByPart", /* @__PURE__ */ new Map());
|
|
1951
|
+
_defineProperty(this, "_disabledUIParts", /* @__PURE__ */ new Map());
|
|
1516
1952
|
_defineProperty(this, "_componentRegistered$", new Subject());
|
|
1517
1953
|
_defineProperty(this, "componentRegistered$", this._componentRegistered$.asObservable());
|
|
1518
1954
|
_defineProperty(this, "_uiVisible", /* @__PURE__ */ new Map());
|
|
@@ -1522,21 +1958,56 @@ var UIPartsService = class extends Disposable {
|
|
|
1522
1958
|
dispose() {
|
|
1523
1959
|
super.dispose();
|
|
1524
1960
|
this._componentsByPart.clear();
|
|
1961
|
+
this._disabledUIParts.clear();
|
|
1525
1962
|
this._uiVisible.clear();
|
|
1526
1963
|
this._componentRegistered$.complete();
|
|
1527
1964
|
this._uiVisibleChange$.complete();
|
|
1528
1965
|
}
|
|
1529
1966
|
setUIVisible(part, visible) {
|
|
1967
|
+
const wasVisible = this.isUIVisible(part);
|
|
1530
1968
|
this._uiVisible.set(part, visible);
|
|
1531
|
-
this.
|
|
1969
|
+
const isVisible = this.isUIVisible(part);
|
|
1970
|
+
if (wasVisible !== isVisible) this._uiVisibleChange$.next({
|
|
1532
1971
|
ui: part,
|
|
1533
|
-
visible
|
|
1972
|
+
visible: isVisible
|
|
1534
1973
|
});
|
|
1535
1974
|
}
|
|
1536
1975
|
isUIVisible(part) {
|
|
1537
|
-
var _this$_uiVisible$get;
|
|
1538
|
-
return (_this$_uiVisible$get = this._uiVisible.get(part)) !== null && _this$_uiVisible$get !== void 0 ? _this$_uiVisible$get : true;
|
|
1539
|
-
}
|
|
1976
|
+
var _this$_uiVisible$get, _this$_disabledUIPart;
|
|
1977
|
+
return ((_this$_uiVisible$get = this._uiVisible.get(part)) !== null && _this$_uiVisible$get !== void 0 ? _this$_uiVisible$get : true) && !((_this$_disabledUIPart = this._disabledUIParts.get(part)) === null || _this$_disabledUIPart === void 0 ? void 0 : _this$_disabledUIPart.size);
|
|
1978
|
+
}
|
|
1979
|
+
registerDisabledUIParts(parts, disabled$) {
|
|
1980
|
+
const uniqueParts = [...new Set(parts)];
|
|
1981
|
+
const registration = Symbol("disabled-ui-parts");
|
|
1982
|
+
let disabled = false;
|
|
1983
|
+
const update = (nextDisabled) => {
|
|
1984
|
+
if (disabled === nextDisabled) return;
|
|
1985
|
+
disabled = nextDisabled;
|
|
1986
|
+
uniqueParts.forEach((part) => {
|
|
1987
|
+
var _this$_disabledUIPart2;
|
|
1988
|
+
const wasVisible = this.isUIVisible(part);
|
|
1989
|
+
const registrations = (_this$_disabledUIPart2 = this._disabledUIParts.get(part)) !== null && _this$_disabledUIPart2 !== void 0 ? _this$_disabledUIPart2 : /* @__PURE__ */ new Set();
|
|
1990
|
+
if (disabled) {
|
|
1991
|
+
registrations.add(registration);
|
|
1992
|
+
this._disabledUIParts.set(part, registrations);
|
|
1993
|
+
} else {
|
|
1994
|
+
registrations.delete(registration);
|
|
1995
|
+
if (registrations.size === 0) this._disabledUIParts.delete(part);
|
|
1996
|
+
}
|
|
1997
|
+
const isVisible = this.isUIVisible(part);
|
|
1998
|
+
if (wasVisible !== isVisible) this._uiVisibleChange$.next({
|
|
1999
|
+
ui: part,
|
|
2000
|
+
visible: isVisible
|
|
2001
|
+
});
|
|
2002
|
+
});
|
|
2003
|
+
};
|
|
2004
|
+
const subscription = disabled$.subscribe(update);
|
|
2005
|
+
const disposable = toDisposable(() => {
|
|
2006
|
+
subscription.unsubscribe();
|
|
2007
|
+
update(false);
|
|
2008
|
+
});
|
|
2009
|
+
return this.disposeWithMe(disposable);
|
|
2010
|
+
}
|
|
1540
2011
|
registerComponent(part, componentFactory) {
|
|
1541
2012
|
const componentType = componentFactory();
|
|
1542
2013
|
const components = (this._componentsByPart.get(part) || this._componentsByPart.set(part, /* @__PURE__ */ new Set()).get(part)).add(componentType);
|
|
@@ -1552,25 +2023,6 @@ var UIPartsService = class extends Disposable {
|
|
|
1552
2023
|
}
|
|
1553
2024
|
};
|
|
1554
2025
|
|
|
1555
|
-
//#endregion
|
|
1556
|
-
//#region src/utils/di.ts
|
|
1557
|
-
function unwrap(o) {
|
|
1558
|
-
if (typeof o === "function") return o();
|
|
1559
|
-
return o;
|
|
1560
|
-
}
|
|
1561
|
-
function useObservableRef(observable, defaultValue) {
|
|
1562
|
-
const ref = useRef(defaultValue);
|
|
1563
|
-
useEffect(() => {
|
|
1564
|
-
if (observable) {
|
|
1565
|
-
const sub = unwrap(observable).subscribe((value) => {
|
|
1566
|
-
ref.current = value;
|
|
1567
|
-
});
|
|
1568
|
-
return () => sub.unsubscribe();
|
|
1569
|
-
}
|
|
1570
|
-
}, [observable]);
|
|
1571
|
-
return ref;
|
|
1572
|
-
}
|
|
1573
|
-
|
|
1574
2026
|
//#endregion
|
|
1575
2027
|
//#region src/services/dom/canvas-dom-layer.service.ts
|
|
1576
2028
|
function shouldForwardFloatDomEvents(layer) {
|
|
@@ -2167,160 +2619,6 @@ var RibbonOverrideService = class extends Disposable {
|
|
|
2167
2619
|
}
|
|
2168
2620
|
};
|
|
2169
2621
|
|
|
2170
|
-
//#endregion
|
|
2171
|
-
//#region src/services/ribbon/ribbon.service.ts
|
|
2172
|
-
const IRibbonService = createIdentifier("univer.ribbon-service");
|
|
2173
|
-
function isSameHiddenMap(previous, current) {
|
|
2174
|
-
return previous.length === current.length && previous.every((hidden, index) => hidden === current[index]);
|
|
2175
|
-
}
|
|
2176
|
-
let DesktopRibbonService = class DesktopRibbonService extends Disposable {
|
|
2177
|
-
constructor(_menuManagerService, _univerInstanceService) {
|
|
2178
|
-
super();
|
|
2179
|
-
this._menuManagerService = _menuManagerService;
|
|
2180
|
-
this._univerInstanceService = _univerInstanceService;
|
|
2181
|
-
_defineProperty(this, "_ribbon$", new BehaviorSubject([]));
|
|
2182
|
-
_defineProperty(this, "ribbon$", this._ribbon$.asObservable());
|
|
2183
|
-
_defineProperty(this, "_activatedTab$", new BehaviorSubject("ribbon.start"));
|
|
2184
|
-
_defineProperty(this, "activatedTab$", this._activatedTab$.asObservable());
|
|
2185
|
-
_defineProperty(this, "_collapsedIds$", new BehaviorSubject([]));
|
|
2186
|
-
_defineProperty(this, "collapsedIds$", this._collapsedIds$.asObservable());
|
|
2187
|
-
_defineProperty(this, "_fakeToolbarVisible$", new BehaviorSubject(false));
|
|
2188
|
-
_defineProperty(this, "fakeToolbarVisible$", this._fakeToolbarVisible$.asObservable());
|
|
2189
|
-
_defineProperty(this, "_visibleContextualTabs", /* @__PURE__ */ new Set());
|
|
2190
|
-
_defineProperty(this, "_contextualTabs", /* @__PURE__ */ new Set());
|
|
2191
|
-
_defineProperty(this, "_lastNonContextualActivatedTab", "ribbon.start");
|
|
2192
|
-
_defineProperty(this, "_hiddenSubscription", null);
|
|
2193
|
-
this._initRibbonSubscription();
|
|
2194
|
-
}
|
|
2195
|
-
setActivatedTab(tab) {
|
|
2196
|
-
if (!this._isContextualTab(tab)) this._lastNonContextualActivatedTab = tab;
|
|
2197
|
-
this._activatedTab$.next(tab);
|
|
2198
|
-
}
|
|
2199
|
-
showContextualTab(tab, options) {
|
|
2200
|
-
this._visibleContextualTabs.add(tab);
|
|
2201
|
-
this._updateRibbon();
|
|
2202
|
-
if (options === null || options === void 0 ? void 0 : options.activate) this.setActivatedTab(tab);
|
|
2203
|
-
}
|
|
2204
|
-
hideContextualTab(tab) {
|
|
2205
|
-
if (!this._visibleContextualTabs.delete(tab)) return;
|
|
2206
|
-
this._updateRibbon();
|
|
2207
|
-
}
|
|
2208
|
-
hideAllContextualTabs() {
|
|
2209
|
-
if (this._visibleContextualTabs.size === 0) return;
|
|
2210
|
-
this._visibleContextualTabs.clear();
|
|
2211
|
-
this._updateRibbon();
|
|
2212
|
-
}
|
|
2213
|
-
setCollapsedIds(ids) {
|
|
2214
|
-
this._collapsedIds$.next(ids);
|
|
2215
|
-
}
|
|
2216
|
-
setFakeToolbarVisible(visible) {
|
|
2217
|
-
this._fakeToolbarVisible$.next(visible);
|
|
2218
|
-
}
|
|
2219
|
-
_initRibbonSubscription() {
|
|
2220
|
-
this.disposeWithMe(combineLatest([this._menuManagerService.menuChanged$.pipe(startWith$1(void 0)), this._univerInstanceService.focused$.pipe(startWith$1(void 0), distinctUntilChanged$1())]).subscribe(() => {
|
|
2221
|
-
this._updateRibbon();
|
|
2222
|
-
}));
|
|
2223
|
-
}
|
|
2224
|
-
_updateRibbon() {
|
|
2225
|
-
var _this$_hiddenSubscrip;
|
|
2226
|
-
const ribbon = this._filterContextualTabs(this._menuManagerService.getMenuByPositionKey("ribbon"));
|
|
2227
|
-
const hiddenObservableMap = [];
|
|
2228
|
-
const hiddenKeyMap = [];
|
|
2229
|
-
for (const group of ribbon) if (group.children) {
|
|
2230
|
-
for (const item of group.children) if (item.children) for (const child of item.children) {
|
|
2231
|
-
var _child$item;
|
|
2232
|
-
if ((_child$item = child.item) === null || _child$item === void 0 ? void 0 : _child$item.hidden$) {
|
|
2233
|
-
hiddenObservableMap.push(child.item.hidden$);
|
|
2234
|
-
hiddenKeyMap.push(child.key);
|
|
2235
|
-
}
|
|
2236
|
-
}
|
|
2237
|
-
}
|
|
2238
|
-
if (hiddenObservableMap.length === 0) {
|
|
2239
|
-
this._setRibbon(ribbon);
|
|
2240
|
-
return;
|
|
2241
|
-
}
|
|
2242
|
-
(_this$_hiddenSubscrip = this._hiddenSubscription) === null || _this$_hiddenSubscrip === void 0 || _this$_hiddenSubscrip.unsubscribe();
|
|
2243
|
-
this._hiddenSubscription = combineLatest(hiddenObservableMap).pipe(startWith$1(new Array(hiddenObservableMap.length).fill(false)), distinctUntilChanged$1(isSameHiddenMap)).subscribe((hiddenMap) => {
|
|
2244
|
-
const newRibbon = [];
|
|
2245
|
-
const hiddenPathMap = hiddenMap.map((hidden, index) => {
|
|
2246
|
-
if (hidden) return hiddenKeyMap[index];
|
|
2247
|
-
return null;
|
|
2248
|
-
}).filter((item) => !!item);
|
|
2249
|
-
for (const group of ribbon) {
|
|
2250
|
-
var _group$children, _newGroup$children2;
|
|
2251
|
-
const newGroup = {
|
|
2252
|
-
...group,
|
|
2253
|
-
children: []
|
|
2254
|
-
};
|
|
2255
|
-
if ((_group$children = group.children) === null || _group$children === void 0 ? void 0 : _group$children.length) for (const item of group.children) {
|
|
2256
|
-
var _item$children;
|
|
2257
|
-
const newItem = {
|
|
2258
|
-
...item,
|
|
2259
|
-
children: []
|
|
2260
|
-
};
|
|
2261
|
-
let shouldAddItem = true;
|
|
2262
|
-
if ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) {
|
|
2263
|
-
var _newItem$children2;
|
|
2264
|
-
for (const child of item.children) if (!hiddenPathMap.includes(child.key)) {
|
|
2265
|
-
var _newItem$children;
|
|
2266
|
-
(_newItem$children = newItem.children) === null || _newItem$children === void 0 || _newItem$children.push(child);
|
|
2267
|
-
}
|
|
2268
|
-
if ((_newItem$children2 = newItem.children) === null || _newItem$children2 === void 0 ? void 0 : _newItem$children2.every((child) => {
|
|
2269
|
-
var _child$children;
|
|
2270
|
-
return ((_child$children = child.children) === null || _child$children === void 0 ? void 0 : _child$children.length) === 0;
|
|
2271
|
-
})) shouldAddItem = false;
|
|
2272
|
-
}
|
|
2273
|
-
if (shouldAddItem) {
|
|
2274
|
-
var _newGroup$children;
|
|
2275
|
-
(_newGroup$children = newGroup.children) === null || _newGroup$children === void 0 || _newGroup$children.push(newItem);
|
|
2276
|
-
}
|
|
2277
|
-
}
|
|
2278
|
-
if (((_newGroup$children2 = newGroup.children) === null || _newGroup$children2 === void 0 ? void 0 : _newGroup$children2.length) && newGroup.children.every((item) => {
|
|
2279
|
-
var _item$children2;
|
|
2280
|
-
return (_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.length;
|
|
2281
|
-
})) newRibbon.push(newGroup);
|
|
2282
|
-
}
|
|
2283
|
-
this._setRibbon(newRibbon);
|
|
2284
|
-
});
|
|
2285
|
-
}
|
|
2286
|
-
_filterContextualTabs(ribbon) {
|
|
2287
|
-
this._contextualTabs.clear();
|
|
2288
|
-
ribbon.forEach((group) => {
|
|
2289
|
-
if (group.contextual) this._contextualTabs.add(group.key);
|
|
2290
|
-
});
|
|
2291
|
-
return ribbon.filter((group) => !group.contextual || this._visibleContextualTabs.has(group.key));
|
|
2292
|
-
}
|
|
2293
|
-
_setRibbon(ribbon) {
|
|
2294
|
-
const activatedTab = this._activatedTab$.getValue();
|
|
2295
|
-
const activeGroup = ribbon.find((group) => group.key === activatedTab);
|
|
2296
|
-
if (!activeGroup && this._contextualTabs.has(activatedTab)) {
|
|
2297
|
-
var _ref, _ribbon$find;
|
|
2298
|
-
const fallbackTab = (_ref = (_ribbon$find = ribbon.find((group) => group.key === this._lastNonContextualActivatedTab && !group.contextual)) !== null && _ribbon$find !== void 0 ? _ribbon$find : ribbon.find((group) => group.key === "ribbon.start")) !== null && _ref !== void 0 ? _ref : ribbon[0];
|
|
2299
|
-
if (fallbackTab) this._activatedTab$.next(fallbackTab.key);
|
|
2300
|
-
} else if (!activeGroup && ribbon.some((group) => group.key === "ribbon.start")) {
|
|
2301
|
-
const fallbackTab = ribbon.find((group) => group.key === "ribbon.start");
|
|
2302
|
-
this._activatedTab$.next(fallbackTab.key);
|
|
2303
|
-
if (!fallbackTab.contextual) this._lastNonContextualActivatedTab = fallbackTab.key;
|
|
2304
|
-
} else if (activeGroup && !activeGroup.contextual) this._lastNonContextualActivatedTab = activeGroup.key;
|
|
2305
|
-
this._ribbon$.next(ribbon);
|
|
2306
|
-
}
|
|
2307
|
-
_isContextualTab(tab) {
|
|
2308
|
-
return this._contextualTabs.has(tab) || this._ribbon$.getValue().some((group) => group.key === tab && group.contextual);
|
|
2309
|
-
}
|
|
2310
|
-
dispose() {
|
|
2311
|
-
var _this$_hiddenSubscrip2;
|
|
2312
|
-
(_this$_hiddenSubscrip2 = this._hiddenSubscription) === null || _this$_hiddenSubscrip2 === void 0 || _this$_hiddenSubscrip2.unsubscribe();
|
|
2313
|
-
this._hiddenSubscription = null;
|
|
2314
|
-
this._ribbon$.next([]);
|
|
2315
|
-
this._ribbon$.complete();
|
|
2316
|
-
this._activatedTab$.complete();
|
|
2317
|
-
this._collapsedIds$.complete();
|
|
2318
|
-
this._fakeToolbarVisible$.complete();
|
|
2319
|
-
super.dispose();
|
|
2320
|
-
}
|
|
2321
|
-
};
|
|
2322
|
-
DesktopRibbonService = __decorate([__decorateParam(0, IMenuManagerService), __decorateParam(1, IUniverInstanceService)], DesktopRibbonService);
|
|
2323
|
-
|
|
2324
2622
|
//#endregion
|
|
2325
2623
|
//#region src/views/components/ComponentContainer.tsx
|
|
2326
2624
|
function ComponentContainer(props) {
|
|
@@ -2435,79 +2733,113 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
|
2435
2733
|
}
|
|
2436
2734
|
|
|
2437
2735
|
//#endregion
|
|
2438
|
-
//#region src/views/components/ribbon/
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
univer-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2736
|
+
//#region src/views/components/ribbon/ribbon-menu/RibbonGridMenu.tsx
|
|
2737
|
+
function RibbonGridMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
2738
|
+
const localeService = useDependency(LocaleService);
|
|
2739
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2740
|
+
"data-testid": "ribbon-grid-menu",
|
|
2741
|
+
"data-u-comp": "ribbon-grid-menu",
|
|
2742
|
+
className: "univer-flex univer-h-full univer-items-end univer-justify-start univer-overflow-x-auto univer-bg-gray-50 univer-px-2 dark:!univer-bg-gray-900",
|
|
2743
|
+
role: "tablist",
|
|
2744
|
+
children: ribbon.map((group) => {
|
|
2745
|
+
const isActive = activatedTab === group.key;
|
|
2746
|
+
const title = localeService.t(group.title || group.key);
|
|
2747
|
+
return /* @__PURE__ */ jsx("button", {
|
|
2748
|
+
type: "button",
|
|
2749
|
+
role: "tab",
|
|
2750
|
+
"aria-selected": isActive,
|
|
2751
|
+
title,
|
|
2752
|
+
onClick: () => onSelectTab(group),
|
|
2753
|
+
className: clsx("univer-relative univer-flex univer-h-9 univer-cursor-pointer univer-items-center univer-whitespace-nowrap univer-border-0 univer-border-b-[3px] univer-bg-transparent univer-px-3 univer-text-base univer-font-semibold univer-text-gray-700 univer-transition-colors hover:univer-text-gray-900 focus-visible:univer-outline-none focus-visible:univer-ring-2 focus-visible:univer-ring-inset focus-visible:univer-ring-primary-500 dark:!univer-text-gray-200 dark:hover:!univer-text-white", isActive ? "univer-border-primary-600 univer-text-primary-700 dark:!univer-text-primary-300" : "univer-border-transparent"),
|
|
2754
|
+
children: title
|
|
2755
|
+
}, group.key);
|
|
2756
|
+
})
|
|
2757
|
+
});
|
|
2758
|
+
}
|
|
2759
|
+
|
|
2760
|
+
//#endregion
|
|
2761
|
+
//#region src/views/components/ribbon/ribbon-grid-layout.ts
|
|
2762
|
+
const RIBBON_GRID_ROWS = 2;
|
|
2763
|
+
function placeRibbonGridItems(items) {
|
|
2764
|
+
const occupied = /* @__PURE__ */ new Set();
|
|
2765
|
+
const placements = /* @__PURE__ */ new Map();
|
|
2766
|
+
const fallbackItems = [];
|
|
2767
|
+
for (const item of items) {
|
|
2768
|
+
var _layout$rowSpan, _layout$columnSpan, _layout$showLabel;
|
|
2769
|
+
const layout = item.gridLayout;
|
|
2770
|
+
if (!layout) {
|
|
2771
|
+
fallbackItems.push({ item });
|
|
2772
|
+
continue;
|
|
2471
2773
|
}
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
/**
|
|
2479
|
-
* Button Component
|
|
2480
|
-
*/
|
|
2481
|
-
function ToolbarButton(props) {
|
|
2482
|
-
const { children, className, style, disabled = false, active = false, noIcon, onClick, onDoubleClick, ...restProps } = props;
|
|
2483
|
-
const handleClick = (e) => {
|
|
2484
|
-
if (disabled) {
|
|
2485
|
-
e.preventDefault();
|
|
2486
|
-
return;
|
|
2774
|
+
const rowSpan = (_layout$rowSpan = layout.rowSpan) !== null && _layout$rowSpan !== void 0 ? _layout$rowSpan : 1;
|
|
2775
|
+
const columnSpan = (_layout$columnSpan = layout.columnSpan) !== null && _layout$columnSpan !== void 0 ? _layout$columnSpan : 1;
|
|
2776
|
+
const cells = getCells(layout.row, layout.column, rowSpan, columnSpan);
|
|
2777
|
+
if (!isValidGridGeometry(layout, rowSpan, cells)) {
|
|
2778
|
+
fallbackItems.push({ item });
|
|
2779
|
+
continue;
|
|
2487
2780
|
}
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2781
|
+
const placement = {
|
|
2782
|
+
item,
|
|
2783
|
+
row: layout.row,
|
|
2784
|
+
column: layout.column,
|
|
2785
|
+
rowSpan,
|
|
2786
|
+
columnSpan,
|
|
2787
|
+
showLabel: (_layout$showLabel = layout.showLabel) !== null && _layout$showLabel !== void 0 ? _layout$showLabel : false,
|
|
2788
|
+
width: layout.width,
|
|
2789
|
+
iconSize: layout.iconSize
|
|
2790
|
+
};
|
|
2791
|
+
if (cells.some((cell) => occupied.has(cell))) {
|
|
2792
|
+
fallbackItems.push({
|
|
2793
|
+
item,
|
|
2794
|
+
layout: placement
|
|
2795
|
+
});
|
|
2796
|
+
continue;
|
|
2494
2797
|
}
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2798
|
+
cells.forEach((cell) => occupied.add(cell));
|
|
2799
|
+
placements.set(item, placement);
|
|
2800
|
+
}
|
|
2801
|
+
for (const { item, layout } of fallbackItems) {
|
|
2802
|
+
var _layout$rowSpan2, _layout$columnSpan2, _layout$showLabel2;
|
|
2803
|
+
const rowSpan = (_layout$rowSpan2 = layout === null || layout === void 0 ? void 0 : layout.rowSpan) !== null && _layout$rowSpan2 !== void 0 ? _layout$rowSpan2 : 1;
|
|
2804
|
+
const columnSpan = (_layout$columnSpan2 = layout === null || layout === void 0 ? void 0 : layout.columnSpan) !== null && _layout$columnSpan2 !== void 0 ? _layout$columnSpan2 : 1;
|
|
2805
|
+
const { row, column, cells } = findFirstAvailableCells(occupied, rowSpan, columnSpan);
|
|
2806
|
+
cells.forEach((cell) => occupied.add(cell));
|
|
2807
|
+
placements.set(item, {
|
|
2808
|
+
item,
|
|
2809
|
+
row,
|
|
2810
|
+
column,
|
|
2811
|
+
rowSpan,
|
|
2812
|
+
columnSpan,
|
|
2813
|
+
showLabel: (_layout$showLabel2 = layout === null || layout === void 0 ? void 0 : layout.showLabel) !== null && _layout$showLabel2 !== void 0 ? _layout$showLabel2 : false,
|
|
2814
|
+
width: layout === null || layout === void 0 ? void 0 : layout.width,
|
|
2815
|
+
iconSize: layout === null || layout === void 0 ? void 0 : layout.iconSize
|
|
2816
|
+
});
|
|
2817
|
+
}
|
|
2818
|
+
return items.map((item) => placements.get(item));
|
|
2819
|
+
}
|
|
2820
|
+
function isValidGridGeometry(layout, rowSpan, cells) {
|
|
2821
|
+
return cells.length > 0 && layout.row + rowSpan - 1 <= RIBBON_GRID_ROWS && (layout.width === void 0 || Number.isFinite(layout.width) && layout.width > 0) && (layout.iconSize === void 0 || Number.isFinite(layout.iconSize) && layout.iconSize > 0);
|
|
2822
|
+
}
|
|
2823
|
+
function findFirstAvailableCells(occupied, rowSpan, columnSpan) {
|
|
2824
|
+
for (let column = 1;; column++) for (let row = 1; row + rowSpan - 1 <= RIBBON_GRID_ROWS; row++) {
|
|
2825
|
+
const cells = getCells(row, column, rowSpan, columnSpan);
|
|
2826
|
+
if (cells.every((cell) => !occupied.has(cell))) return {
|
|
2827
|
+
row,
|
|
2828
|
+
column,
|
|
2829
|
+
cells
|
|
2830
|
+
};
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
function getCells(row, column, rowSpan, columnSpan) {
|
|
2834
|
+
if (![
|
|
2835
|
+
row,
|
|
2836
|
+
column,
|
|
2837
|
+
rowSpan,
|
|
2838
|
+
columnSpan
|
|
2839
|
+
].every(Number.isInteger) || Math.min(row, column, rowSpan, columnSpan) < 1) return [];
|
|
2840
|
+
const cells = [];
|
|
2841
|
+
for (let currentRow = row; currentRow < row + rowSpan; currentRow++) for (let currentColumn = column; currentColumn < column + columnSpan; currentColumn++) cells.push(`${currentRow}:${currentColumn}`);
|
|
2842
|
+
return cells;
|
|
2511
2843
|
}
|
|
2512
2844
|
|
|
2513
2845
|
//#endregion
|
|
@@ -2517,7 +2849,7 @@ function ToolbarButton(props) {
|
|
|
2517
2849
|
* @param props
|
|
2518
2850
|
*/
|
|
2519
2851
|
function CustomLabel(props) {
|
|
2520
|
-
const { className, title, icon, label, value, value$ } = props;
|
|
2852
|
+
const { className, iconSize, title, icon, label, value, value$ } = props;
|
|
2521
2853
|
const localeService = useDependency(LocaleService);
|
|
2522
2854
|
const componentManager = useDependency(ComponentManager);
|
|
2523
2855
|
const iconManager = useDependency(IconManager);
|
|
@@ -2537,6 +2869,10 @@ function CustomLabel(props) {
|
|
|
2537
2869
|
const Icon = iconManager.get(realIcon);
|
|
2538
2870
|
if (Icon) nodes.push(/* @__PURE__ */ jsx(Icon, {
|
|
2539
2871
|
className: "univer-text-base",
|
|
2872
|
+
style: iconSize ? {
|
|
2873
|
+
width: iconSize,
|
|
2874
|
+
height: iconSize
|
|
2875
|
+
} : void 0,
|
|
2540
2876
|
extend: { colorChannel1: isValid ? String(realValue) : "var(--univer-primary-600)" }
|
|
2541
2877
|
}, index++));
|
|
2542
2878
|
}
|
|
@@ -2607,6 +2943,82 @@ function useToolbarShortcutDisplay({ id, commandId, shortcut }) {
|
|
|
2607
2943
|
]), null, true);
|
|
2608
2944
|
}
|
|
2609
2945
|
|
|
2946
|
+
//#endregion
|
|
2947
|
+
//#region src/views/components/ribbon/ToolbarButton.tsx
|
|
2948
|
+
/**
|
|
2949
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
2950
|
+
*
|
|
2951
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2952
|
+
* you may not use this file except in compliance with the License.
|
|
2953
|
+
* You may obtain a copy of the License at
|
|
2954
|
+
*
|
|
2955
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2956
|
+
*
|
|
2957
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2958
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2959
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2960
|
+
* See the License for the specific language governing permissions and
|
|
2961
|
+
* limitations under the License.
|
|
2962
|
+
*/
|
|
2963
|
+
const toolbarButtonClassName = `
|
|
2964
|
+
univer-box-border univer-flex univer-h-6 univer-min-w-6 univer-cursor-pointer univer-items-center
|
|
2965
|
+
univer-justify-center univer-rounded univer-border-none univer-bg-transparent univer-p-0
|
|
2966
|
+
univer-text-gray-900 univer-outline-none univer-transition-colors univer-animate-in univer-fade-in
|
|
2967
|
+
dark:!univer-text-white dark:hover:!univer-bg-gray-700 dark:disabled:!univer-text-gray-600
|
|
2968
|
+
disabled:univer-cursor-not-allowed disabled:univer-text-gray-300 disabled:hover:univer-bg-transparent
|
|
2969
|
+
hover:univer-bg-gray-100 whitespace-nowrap univer-w-max
|
|
2970
|
+
`;
|
|
2971
|
+
const toolbarButtonVariants = cva(toolbarButtonClassName, {
|
|
2972
|
+
variants: {
|
|
2973
|
+
noIcon: {
|
|
2974
|
+
true: "univer-px-2",
|
|
2975
|
+
false: ""
|
|
2976
|
+
},
|
|
2977
|
+
active: {
|
|
2978
|
+
true: "!univer-bg-gray-200 dark:!univer-bg-gray-500",
|
|
2979
|
+
false: ""
|
|
2980
|
+
}
|
|
2981
|
+
},
|
|
2982
|
+
defaultVariants: {
|
|
2983
|
+
noIcon: false,
|
|
2984
|
+
active: false
|
|
2985
|
+
}
|
|
2986
|
+
});
|
|
2987
|
+
/**
|
|
2988
|
+
* Button Component
|
|
2989
|
+
*/
|
|
2990
|
+
function ToolbarButton(props) {
|
|
2991
|
+
const { children, className, style, disabled = false, active = false, noIcon, onClick, onDoubleClick, ...restProps } = props;
|
|
2992
|
+
const handleClick = (e) => {
|
|
2993
|
+
if (disabled) {
|
|
2994
|
+
e.preventDefault();
|
|
2995
|
+
return;
|
|
2996
|
+
}
|
|
2997
|
+
onClick && onClick(e);
|
|
2998
|
+
};
|
|
2999
|
+
const handleDoubleClick = (e) => {
|
|
3000
|
+
if (disabled) {
|
|
3001
|
+
e.preventDefault();
|
|
3002
|
+
return;
|
|
3003
|
+
}
|
|
3004
|
+
onDoubleClick && onDoubleClick(e);
|
|
3005
|
+
};
|
|
3006
|
+
return /* @__PURE__ */ jsx("button", {
|
|
3007
|
+
type: "button",
|
|
3008
|
+
className: toolbarButtonVariants({
|
|
3009
|
+
noIcon,
|
|
3010
|
+
active,
|
|
3011
|
+
className
|
|
3012
|
+
}),
|
|
3013
|
+
style,
|
|
3014
|
+
disabled,
|
|
3015
|
+
onClick: handleClick,
|
|
3016
|
+
onDoubleClick: handleDoubleClick,
|
|
3017
|
+
...restProps,
|
|
3018
|
+
children
|
|
3019
|
+
});
|
|
3020
|
+
}
|
|
3021
|
+
|
|
2610
3022
|
//#endregion
|
|
2611
3023
|
//#region src/views/components/ribbon/TooltipButtonWrapper.tsx
|
|
2612
3024
|
const TooltipWrapperContext = createContext({
|
|
@@ -2663,12 +3075,31 @@ const TooltipWrapper = forwardRef((props, ref) => {
|
|
|
2663
3075
|
function DropdownWrapper(props) {
|
|
2664
3076
|
const { children, overlay, disabled, align = "start" } = props;
|
|
2665
3077
|
const { dropdownVisible, setDropdownVisible } = useContext(TooltipWrapperContext);
|
|
3078
|
+
const triggerRef = useRef(null);
|
|
3079
|
+
const overlayRef = useRef(null);
|
|
3080
|
+
useEffect(() => {
|
|
3081
|
+
if (disabled) setDropdownVisible(false);
|
|
3082
|
+
}, [disabled, setDropdownVisible]);
|
|
3083
|
+
useEffect(() => {
|
|
3084
|
+
var _triggerRef$current;
|
|
3085
|
+
const ownerDocument = (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.ownerDocument;
|
|
3086
|
+
if (!dropdownVisible || !ownerDocument) return;
|
|
3087
|
+
const handlePointerDown = (event) => {
|
|
3088
|
+
var _triggerRef$current2, _overlayRef$current;
|
|
3089
|
+
const target = event.target;
|
|
3090
|
+
if (!target || ((_triggerRef$current2 = triggerRef.current) === null || _triggerRef$current2 === void 0 ? void 0 : _triggerRef$current2.contains(target)) || ((_overlayRef$current = overlayRef.current) === null || _overlayRef$current === void 0 ? void 0 : _overlayRef$current.contains(target))) return;
|
|
3091
|
+
setDropdownVisible(false);
|
|
3092
|
+
};
|
|
3093
|
+
ownerDocument.addEventListener("pointerdown", handlePointerDown, true);
|
|
3094
|
+
return () => ownerDocument.removeEventListener("pointerdown", handlePointerDown, true);
|
|
3095
|
+
}, [dropdownVisible, setDropdownVisible]);
|
|
2666
3096
|
function handleVisibleChange(visible) {
|
|
2667
3097
|
setDropdownVisible(visible);
|
|
2668
3098
|
}
|
|
2669
3099
|
return /* @__PURE__ */ jsx(Dropdown, {
|
|
2670
3100
|
align,
|
|
2671
3101
|
overlay: /* @__PURE__ */ jsx("div", {
|
|
3102
|
+
ref: overlayRef,
|
|
2672
3103
|
className: "univer-grid univer-gap-2",
|
|
2673
3104
|
children: overlay
|
|
2674
3105
|
}),
|
|
@@ -2676,6 +3107,7 @@ function DropdownWrapper(props) {
|
|
|
2676
3107
|
open: dropdownVisible,
|
|
2677
3108
|
onOpenChange: handleVisibleChange,
|
|
2678
3109
|
children: /* @__PURE__ */ jsx("div", {
|
|
3110
|
+
ref: triggerRef,
|
|
2679
3111
|
className: "univer-h-full",
|
|
2680
3112
|
onClick: (e) => e.stopPropagation(),
|
|
2681
3113
|
children
|
|
@@ -2716,6 +3148,9 @@ function getOptionKey(option) {
|
|
|
2716
3148
|
}
|
|
2717
3149
|
function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, onOptionSelect }) {
|
|
2718
3150
|
const { dropdownVisible, setDropdownVisible } = useContext(TooltipWrapperContext);
|
|
3151
|
+
useEffect(() => {
|
|
3152
|
+
if (disabled) setDropdownVisible(false);
|
|
3153
|
+
}, [disabled, setDropdownVisible]);
|
|
2719
3154
|
const menuManagerService = useDependency(IMenuManagerService);
|
|
2720
3155
|
const resolveMenuItems = () => menuId ? menuManagerService.getMenuByPositionKey(menuId) : [];
|
|
2721
3156
|
const menuItems = useObservable(() => menuManagerService.menuChanged$.pipe(map(resolveMenuItems), startWith(resolveMenuItems())), resolveMenuItems(), false, [menuId, menuManagerService]);
|
|
@@ -2736,7 +3171,8 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
2736
3171
|
return menuItems.filter((item) => {
|
|
2737
3172
|
var _item$key;
|
|
2738
3173
|
if (!item.children) return !hiddenStates[item.key];
|
|
2739
|
-
|
|
3174
|
+
const itemKey = ((_item$key = item.key) === null || _item$key === void 0 ? void 0 : _item$key.toString()) || "";
|
|
3175
|
+
return !hiddenStates[itemKey];
|
|
2740
3176
|
});
|
|
2741
3177
|
}, [menuItems, hiddenStates]);
|
|
2742
3178
|
function handleVisibleChange(visible) {
|
|
@@ -2759,11 +3195,16 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
2759
3195
|
children
|
|
2760
3196
|
});
|
|
2761
3197
|
if (options === null || options === void 0 ? void 0 : options.length) {
|
|
3198
|
+
var _options$0$label;
|
|
3199
|
+
const isSingleCustomPanel = options.length === 1 && typeof options[0].label === "object" && ((_options$0$label = options[0].label) === null || _options$0$label === void 0 ? void 0 : _options$0$label.hoverable) === false;
|
|
2762
3200
|
const items = options.map((option) => {
|
|
2763
|
-
var _option$label3;
|
|
3201
|
+
var _option$label3, _option$label4;
|
|
2764
3202
|
return {
|
|
2765
3203
|
type: "item",
|
|
2766
|
-
className: clsx({
|
|
3204
|
+
className: clsx({
|
|
3205
|
+
"focus:univer-bg-white": typeof option.label !== "string" && ((_option$label3 = option.label) === null || _option$label3 === void 0 ? void 0 : _option$label3.hoverable) === false,
|
|
3206
|
+
"!univer-p-0": typeof option.label !== "string" && ((_option$label4 = option.label) === null || _option$label4 === void 0 ? void 0 : _option$label4.hoverable) === false
|
|
3207
|
+
}),
|
|
2767
3208
|
children: /* @__PURE__ */ jsx(DropdownMenuLabel, {
|
|
2768
3209
|
icon: option.icon,
|
|
2769
3210
|
value,
|
|
@@ -2802,6 +3243,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
2802
3243
|
}
|
|
2803
3244
|
return /* @__PURE__ */ jsx(DropdownMenu, {
|
|
2804
3245
|
align: "start",
|
|
3246
|
+
className: clsx({ "!univer-p-0": isSingleCustomPanel }),
|
|
2805
3247
|
items,
|
|
2806
3248
|
disabled,
|
|
2807
3249
|
open: dropdownVisible,
|
|
@@ -2939,7 +3381,8 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
2939
3381
|
layoutService.focus();
|
|
2940
3382
|
commandService.executeCommand(commandId, params);
|
|
2941
3383
|
};
|
|
2942
|
-
const { tooltip, shortcut, icon, title, label, id, commandId, type, slot, params } = props;
|
|
3384
|
+
const { tooltip, shortcut, icon, title, label, id, commandId, type, slot, params, grid, large, showLabel, iconSize, iconColor, fullWidth } = props;
|
|
3385
|
+
const gridLabel = title !== null && title !== void 0 ? title : tooltip;
|
|
2943
3386
|
const shortcutDisplay = useToolbarShortcutDisplay({
|
|
2944
3387
|
id,
|
|
2945
3388
|
commandId,
|
|
@@ -2971,6 +3414,7 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
2971
3414
|
const selectionsCommandId = props.selectionsCommandId;
|
|
2972
3415
|
const bId = commandId !== null && commandId !== void 0 ? commandId : id;
|
|
2973
3416
|
const sId = (_ref = selectionsCommandId !== null && selectionsCommandId !== void 0 ? selectionsCommandId : commandId) !== null && _ref !== void 0 ? _ref : id;
|
|
3417
|
+
const titleToDisplay = grid ? showLabel ? gridLabel : large ? void 0 : title : title;
|
|
2974
3418
|
function handleSelect(option) {
|
|
2975
3419
|
if (disabled) return;
|
|
2976
3420
|
let commandId = sId;
|
|
@@ -2992,17 +3436,24 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
2992
3436
|
if (menuType === 2) return /* @__PURE__ */ jsxs("div", {
|
|
2993
3437
|
"data-u-command": id,
|
|
2994
3438
|
"data-disabled": disabled,
|
|
2995
|
-
className: toolbarButtonSelectorRootVariants({ disabled }),
|
|
3439
|
+
className: clsx(toolbarButtonSelectorRootVariants({ disabled }), {
|
|
3440
|
+
"univer-box-border univer-h-full univer-min-w-14 univer-flex-col !univer-pr-0": grid && large,
|
|
3441
|
+
"univer-box-border univer-h-full": grid && !large
|
|
3442
|
+
}),
|
|
2996
3443
|
children: [/* @__PURE__ */ jsx("div", {
|
|
2997
|
-
className: toolbarButtonSelectorMainVariants({
|
|
3444
|
+
className: clsx(toolbarButtonSelectorMainVariants({
|
|
2998
3445
|
active: activated,
|
|
2999
3446
|
disabled
|
|
3447
|
+
}), {
|
|
3448
|
+
"univer-h-full univer-w-full univer-flex-col univer-justify-center univer-rounded univer-px-1 univer-pb-4 [&>svg]:univer-size-8": grid && large,
|
|
3449
|
+
"[&>svg]:univer-size-4": grid && !large
|
|
3000
3450
|
}),
|
|
3001
3451
|
onClick: handleClick,
|
|
3002
3452
|
children: /* @__PURE__ */ jsx(CustomLabel, {
|
|
3003
3453
|
icon: iconToDisplay,
|
|
3004
|
-
|
|
3005
|
-
|
|
3454
|
+
iconSize,
|
|
3455
|
+
title: titleToDisplay,
|
|
3456
|
+
value: iconColor !== null && iconColor !== void 0 ? iconColor : value,
|
|
3006
3457
|
label,
|
|
3007
3458
|
onChange: handleSelectionsValueChange
|
|
3008
3459
|
})
|
|
@@ -3014,9 +3465,12 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
3014
3465
|
disabled,
|
|
3015
3466
|
onOptionSelect: handleSelect,
|
|
3016
3467
|
children: /* @__PURE__ */ jsx("div", {
|
|
3017
|
-
className: toolbarButtonSelectorTriggerVariants({
|
|
3468
|
+
className: clsx(toolbarButtonSelectorTriggerVariants({
|
|
3018
3469
|
disabled,
|
|
3019
3470
|
active: activated
|
|
3471
|
+
}), {
|
|
3472
|
+
"!univer-top-auto univer-bottom-0 univer-h-4 univer-w-full univer-rounded-b univer-rounded-t-none": grid && large,
|
|
3473
|
+
"univer-h-full": grid && !large
|
|
3020
3474
|
}),
|
|
3021
3475
|
"data-disabled": disabled,
|
|
3022
3476
|
children: /* @__PURE__ */ jsx(MoreDownIcon, {})
|
|
@@ -3030,31 +3484,70 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
3030
3484
|
options,
|
|
3031
3485
|
disabled,
|
|
3032
3486
|
onOptionSelect: handleSelect,
|
|
3033
|
-
children: /* @__PURE__ */
|
|
3487
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
3034
3488
|
"data-u-command": id,
|
|
3035
|
-
className: toolbarSelectorRootVariants({
|
|
3489
|
+
className: clsx(toolbarSelectorRootVariants({
|
|
3036
3490
|
disabled,
|
|
3037
3491
|
active: activated
|
|
3038
|
-
}),
|
|
3039
|
-
|
|
3492
|
+
}), {
|
|
3493
|
+
"univer-box-border univer-h-full univer-min-w-14 univer-flex-col univer-justify-center univer-gap-1 univer-px-1.5 univer-py-1 univer-text-xs [&>svg]:univer-size-8": grid && large,
|
|
3494
|
+
"univer-box-border univer-h-full": grid && !large,
|
|
3495
|
+
"univer-bg-white dark:!univer-bg-gray-800": grid && !large && !icon,
|
|
3496
|
+
"[&>svg]:univer-size-4": grid && !large
|
|
3497
|
+
}, grid && !large && !icon && borderClassName),
|
|
3498
|
+
children: grid && large ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CustomLabel, {
|
|
3040
3499
|
icon: iconToDisplay,
|
|
3041
|
-
|
|
3500
|
+
iconSize
|
|
3501
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
3502
|
+
className: clsx(toolbarSelectorTriggerVariants({ disabled }), "univer-h-4 univer-justify-center univer-gap-0.5"),
|
|
3503
|
+
children: [/* @__PURE__ */ jsx(CustomLabel, {
|
|
3504
|
+
title: titleToDisplay,
|
|
3505
|
+
value,
|
|
3506
|
+
label,
|
|
3507
|
+
onChange: handleSelectionsValueChange
|
|
3508
|
+
}), /* @__PURE__ */ jsx(MoreDownIcon, {})]
|
|
3509
|
+
})] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CustomLabel, {
|
|
3510
|
+
icon: iconToDisplay,
|
|
3511
|
+
iconSize,
|
|
3512
|
+
title: titleToDisplay,
|
|
3042
3513
|
value,
|
|
3043
3514
|
label,
|
|
3044
3515
|
onChange: handleSelectionsValueChange
|
|
3045
3516
|
}), /* @__PURE__ */ jsx("div", {
|
|
3046
|
-
className: toolbarSelectorTriggerVariants({ disabled }),
|
|
3517
|
+
className: clsx(toolbarSelectorTriggerVariants({ disabled }), { "univer-ml-auto rtl:univer-ml-0 rtl:univer-mr-auto": grid && !large && !icon }),
|
|
3047
3518
|
children: /* @__PURE__ */ jsx(MoreDownIcon, {})
|
|
3048
|
-
})]
|
|
3519
|
+
})] })
|
|
3049
3520
|
})
|
|
3050
3521
|
});
|
|
3051
3522
|
}
|
|
3052
3523
|
function renderButtonType() {
|
|
3053
3524
|
var _label$name;
|
|
3054
3525
|
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 : "");
|
|
3526
|
+
const buttonClassName = clsx(grid && !large && "univer-h-full univer-min-w-8 [&>svg]:univer-size-4", grid && large ? "univer-h-full univer-min-w-14 univer-flex-col univer-gap-1 univer-px-1.5 univer-py-1 univer-text-xs [&>svg]:univer-size-8" : showLabel ? "univer-gap-1 univer-px-1.5 univer-text-sm" : "univer-text-sm", grid && fullWidth && isCustomComponent && "!univer-px-0");
|
|
3527
|
+
const buttonStyle = grid && large ? {
|
|
3528
|
+
textAlign: "center",
|
|
3529
|
+
whiteSpace: "normal"
|
|
3530
|
+
} : void 0;
|
|
3531
|
+
if (isCustomComponent) return /* @__PURE__ */ jsx("span", {
|
|
3532
|
+
"data-u-command": id,
|
|
3533
|
+
className: toolbarButtonVariants({
|
|
3534
|
+
noIcon: !icon,
|
|
3535
|
+
active: activated,
|
|
3536
|
+
className: buttonClassName
|
|
3537
|
+
}),
|
|
3538
|
+
style: buttonStyle,
|
|
3539
|
+
"aria-disabled": disabled,
|
|
3540
|
+
children: /* @__PURE__ */ jsx(CustomLabel, {
|
|
3541
|
+
className: grid && fullWidth ? "!univer-w-full" : void 0,
|
|
3542
|
+
title: grid && showLabel ? gridLabel : title,
|
|
3543
|
+
value,
|
|
3544
|
+
label
|
|
3545
|
+
})
|
|
3546
|
+
});
|
|
3055
3547
|
return /* @__PURE__ */ jsx(ToolbarButton, {
|
|
3056
3548
|
"data-u-command": id,
|
|
3057
|
-
className:
|
|
3549
|
+
className: buttonClassName,
|
|
3550
|
+
style: buttonStyle,
|
|
3058
3551
|
noIcon: !icon,
|
|
3059
3552
|
active: activated,
|
|
3060
3553
|
disabled,
|
|
@@ -3064,11 +3557,11 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
3064
3557
|
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 });
|
|
3065
3558
|
},
|
|
3066
3559
|
onDoubleClick: () => props.subId && executeCommand(props.subId),
|
|
3067
|
-
children:
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
}) :
|
|
3560
|
+
children: icon ? /* @__PURE__ */ jsx(CustomLabel, {
|
|
3561
|
+
icon,
|
|
3562
|
+
iconSize,
|
|
3563
|
+
title: grid && (large || showLabel) ? gridLabel : void 0
|
|
3564
|
+
}) : /* @__PURE__ */ jsx(CustomLabel, { title })
|
|
3072
3565
|
});
|
|
3073
3566
|
}
|
|
3074
3567
|
function renderItem() {
|
|
@@ -3089,6 +3582,51 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
3089
3582
|
});
|
|
3090
3583
|
});
|
|
3091
3584
|
|
|
3585
|
+
//#endregion
|
|
3586
|
+
//#region src/views/components/ribbon/RibbonGrid.tsx
|
|
3587
|
+
function RibbonGrid({ groups, title, className, ...props }) {
|
|
3588
|
+
const localeService = useDependency(LocaleService);
|
|
3589
|
+
return /* @__PURE__ */ jsx("div", {
|
|
3590
|
+
...props,
|
|
3591
|
+
"data-testid": "ribbon-grid-toolbar",
|
|
3592
|
+
"data-u-comp": "ribbon-grid-toolbar",
|
|
3593
|
+
className: clsx("univer-box-border univer-flex univer-h-[88px] univer-overflow-x-auto univer-overflow-y-hidden univer-bg-gray-50 univer-px-2 univer-text-sm dark:!univer-bg-gray-900", borderBottomClassName, scrollbarClassName, className),
|
|
3594
|
+
role: "toolbar",
|
|
3595
|
+
"aria-label": localeService.t(title),
|
|
3596
|
+
children: /* @__PURE__ */ jsx(ToolbarDropdownProvider, { children: groups.map((group) => {
|
|
3597
|
+
var _group$children;
|
|
3598
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3599
|
+
"data-u-comp": "ribbon-grid-group",
|
|
3600
|
+
className: "univer-relative univer-box-border univer-flex univer-min-w-16 univer-shrink-0 univer-flex-col univer-px-2",
|
|
3601
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
3602
|
+
"data-testid": "ribbon-grid-group-grid",
|
|
3603
|
+
className: "univer-grid univer-min-h-0 univer-flex-1 univer-grid-flow-col univer-grid-rows-2 univer-content-center univer-gap-x-1 univer-gap-y-2 univer-py-2 [&>div>span>span]:univer-h-full",
|
|
3604
|
+
children: placeRibbonGridItems((_group$children = group.children) !== null && _group$children !== void 0 ? _group$children : []).map((placement) => placement.item.item && /* @__PURE__ */ jsx("div", {
|
|
3605
|
+
className: clsx("univer-flex univer-items-stretch [&>span>button]:univer-h-full [&>span]:univer-h-full", placement.width && "[&>span>span]:univer-w-full [&>span]:univer-w-full [&_[data-u-command]]:univer-w-full"),
|
|
3606
|
+
style: {
|
|
3607
|
+
gridRow: `${placement.row} / span ${placement.rowSpan}`,
|
|
3608
|
+
gridColumn: `${placement.column} / span ${placement.columnSpan}`,
|
|
3609
|
+
width: placement.width
|
|
3610
|
+
},
|
|
3611
|
+
children: /* @__PURE__ */ jsx(ToolbarItem, {
|
|
3612
|
+
...placement.item.item,
|
|
3613
|
+
grid: true,
|
|
3614
|
+
large: placement.rowSpan > 1,
|
|
3615
|
+
showLabel: placement.showLabel,
|
|
3616
|
+
iconSize: placement.iconSize,
|
|
3617
|
+
fullWidth: placement.width !== void 0
|
|
3618
|
+
})
|
|
3619
|
+
}, placement.item.key))
|
|
3620
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
3621
|
+
"data-testid": "ribbon-grid-group-divider",
|
|
3622
|
+
className: clsx("univer-pointer-events-none univer-absolute univer-bottom-1.5 univer-right-0 univer-top-3.5 !univer-border-gray-300 univer-opacity-50 rtl:univer-left-0 rtl:univer-right-auto", borderRightClassName),
|
|
3623
|
+
"aria-hidden": "true"
|
|
3624
|
+
})]
|
|
3625
|
+
}, group.key);
|
|
3626
|
+
}) })
|
|
3627
|
+
});
|
|
3628
|
+
}
|
|
3629
|
+
|
|
3092
3630
|
//#endregion
|
|
3093
3631
|
//#region src/views/components/ribbon/Ribbon.tsx
|
|
3094
3632
|
function Ribbon(props) {
|
|
@@ -3159,7 +3697,7 @@ function Ribbon(props) {
|
|
|
3159
3697
|
activatedTab
|
|
3160
3698
|
]);
|
|
3161
3699
|
useEffect(() => {
|
|
3162
|
-
if (hideToolbar) {
|
|
3700
|
+
if (hideToolbar || ribbonType === "grid") {
|
|
3163
3701
|
toolbarItemRefs.current = {};
|
|
3164
3702
|
ribbonService.setCollapsedIds([]);
|
|
3165
3703
|
ribbonService.setFakeToolbarVisible(false);
|
|
@@ -3199,7 +3737,8 @@ function Ribbon(props) {
|
|
|
3199
3737
|
hideToolbar,
|
|
3200
3738
|
ribbon,
|
|
3201
3739
|
activatedTab,
|
|
3202
|
-
ribbonService
|
|
3740
|
+
ribbonService,
|
|
3741
|
+
ribbonType
|
|
3203
3742
|
]);
|
|
3204
3743
|
const fakeToolbar = useMemo(() => {
|
|
3205
3744
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -3237,7 +3776,7 @@ function Ribbon(props) {
|
|
|
3237
3776
|
...embedRibbonOverrideAttributes,
|
|
3238
3777
|
className: clsx("univer-relative univer-select-none", headerClassName, {
|
|
3239
3778
|
"univer-hidden": toolbarOnly,
|
|
3240
|
-
"univer-h-9": !toolbarOnly && (ribbonType === "classic" || headerMenuComponents && headerMenuComponents.size > 0)
|
|
3779
|
+
"univer-h-9": !toolbarOnly && (ribbonType === "classic" || ribbonType === "grid" || headerMenuComponents && headerMenuComponents.size > 0)
|
|
3241
3780
|
}),
|
|
3242
3781
|
children: [
|
|
3243
3782
|
!toolbarOnly && (ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.placeholderTitle) && ribbon.length === 0 && /* @__PURE__ */ jsx("div", {
|
|
@@ -3252,13 +3791,23 @@ function Ribbon(props) {
|
|
|
3252
3791
|
activatedTab,
|
|
3253
3792
|
onSelectTab: handleSelectTab
|
|
3254
3793
|
}),
|
|
3794
|
+
!toolbarOnly && ribbonType === "grid" && ribbon.length >= 1 && /* @__PURE__ */ jsx(RibbonGridMenu, {
|
|
3795
|
+
ribbon,
|
|
3796
|
+
activatedTab,
|
|
3797
|
+
onSelectTab: handleSelectTab
|
|
3798
|
+
}),
|
|
3255
3799
|
headerMenu && headerMenuComponents && headerMenuComponents.size > 0 && /* @__PURE__ */ jsx("div", {
|
|
3256
3800
|
className: "univer-absolute univer-right-2 univer-top-0 univer-flex univer-h-full univer-flex-row univer-items-center univer-gap-2 rtl:univer-left-2 rtl:univer-right-auto [&>*]:univer-inline-flex [&>*]:univer-h-6 [&>*]:univer-items-center [&>*]:univer-rounded [&>*]:univer-px-1 [&>*]:univer-transition-colors hover:[&>*]:univer-bg-gray-100",
|
|
3257
3801
|
children: /* @__PURE__ */ jsx(ComponentContainer, { components: headerMenuComponents })
|
|
3258
3802
|
})
|
|
3259
3803
|
]
|
|
3260
3804
|
}),
|
|
3261
|
-
!hideToolbar && /* @__PURE__ */
|
|
3805
|
+
!hideToolbar && ribbonType === "grid" && /* @__PURE__ */ jsx(RibbonGrid, {
|
|
3806
|
+
...embedRibbonOverrideAttributes,
|
|
3807
|
+
groups: activeGroup.allGroups,
|
|
3808
|
+
title: activatedTabTitle
|
|
3809
|
+
}),
|
|
3810
|
+
!hideToolbar && ribbonType !== "grid" && /* @__PURE__ */ jsxs("div", {
|
|
3262
3811
|
...embedRibbonOverrideAttributes,
|
|
3263
3812
|
className: clsx("univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3 univer-text-sm", {
|
|
3264
3813
|
"univer-grid-cols-[1fr] univer-justify-center": ribbonType === "classic" || ribbon.length === 1,
|
|
@@ -3310,7 +3859,7 @@ function Ribbon(props) {
|
|
|
3310
3859
|
})] }, activatedTab)
|
|
3311
3860
|
})]
|
|
3312
3861
|
}),
|
|
3313
|
-
fakeToolbar
|
|
3862
|
+
ribbonType !== "grid" && fakeToolbar
|
|
3314
3863
|
] })
|
|
3315
3864
|
});
|
|
3316
3865
|
}
|
|
@@ -3372,6 +3921,33 @@ var ThemeSwitcherService = class extends Disposable {
|
|
|
3372
3921
|
}
|
|
3373
3922
|
};
|
|
3374
3923
|
|
|
3924
|
+
//#endregion
|
|
3925
|
+
//#region src/services/workbench/workbench.service.ts
|
|
3926
|
+
const IWorkbenchService = createIdentifier("univer.ui.workbench.service");
|
|
3927
|
+
var WorkbenchService = class extends Disposable {
|
|
3928
|
+
constructor(..._args) {
|
|
3929
|
+
super(..._args);
|
|
3930
|
+
_defineProperty(this, "_tokens", /* @__PURE__ */ new Set());
|
|
3931
|
+
_defineProperty(this, "_skeletonVisible$", new BehaviorSubject(false));
|
|
3932
|
+
_defineProperty(this, "skeletonVisible$", this._skeletonVisible$.asObservable());
|
|
3933
|
+
}
|
|
3934
|
+
acquireSkeleton() {
|
|
3935
|
+
const token = Symbol("workbench-skeleton");
|
|
3936
|
+
this._tokens.add(token);
|
|
3937
|
+
if (this._tokens.size === 1) this._skeletonVisible$.next(true);
|
|
3938
|
+
const disposable = toDisposable(() => {
|
|
3939
|
+
if (!this._tokens.delete(token) || this._tokens.size > 0) return;
|
|
3940
|
+
this._skeletonVisible$.next(false);
|
|
3941
|
+
});
|
|
3942
|
+
return this.disposeWithMe(disposable);
|
|
3943
|
+
}
|
|
3944
|
+
dispose() {
|
|
3945
|
+
super.dispose();
|
|
3946
|
+
this._tokens.clear();
|
|
3947
|
+
this._skeletonVisible$.complete();
|
|
3948
|
+
}
|
|
3949
|
+
};
|
|
3950
|
+
|
|
3375
3951
|
//#endregion
|
|
3376
3952
|
//#region src/services/contextmenu/contextmenu.service.ts
|
|
3377
3953
|
const IContextMenuService = createIdentifier("ui.contextmenu.service");
|
|
@@ -3408,25 +3984,6 @@ var ContextMenuService = class extends Disposable {
|
|
|
3408
3984
|
}
|
|
3409
3985
|
};
|
|
3410
3986
|
|
|
3411
|
-
//#endregion
|
|
3412
|
-
//#region src/services/runtime-scope/ui-runtime-scope.service.ts
|
|
3413
|
-
const IUIRuntimeScopeService = createIdentifier("ui.runtime-scope.service");
|
|
3414
|
-
var UIRuntimeScopeService = class extends Disposable {
|
|
3415
|
-
constructor(..._args) {
|
|
3416
|
-
super(..._args);
|
|
3417
|
-
_defineProperty(this, "_scopes", /* @__PURE__ */ new Map());
|
|
3418
|
-
}
|
|
3419
|
-
register(scope) {
|
|
3420
|
-
this._scopes.set(scope.unitId, scope);
|
|
3421
|
-
return toDisposable(() => {
|
|
3422
|
-
if (this._scopes.get(scope.unitId) === scope) this._scopes.delete(scope.unitId);
|
|
3423
|
-
});
|
|
3424
|
-
}
|
|
3425
|
-
get(unitId) {
|
|
3426
|
-
return unitId ? this._scopes.get(unitId) : void 0;
|
|
3427
|
-
}
|
|
3428
|
-
};
|
|
3429
|
-
|
|
3430
3987
|
//#endregion
|
|
3431
3988
|
//#region src/services/contextmenu/contextmenu-host.service.ts
|
|
3432
3989
|
const IContextMenuHostService = createIdentifier("ui.contextmenu.host.service");
|
|
@@ -3434,31 +3991,37 @@ var ContextMenuHostService = class extends Disposable {
|
|
|
3434
3991
|
constructor(..._args) {
|
|
3435
3992
|
super(..._args);
|
|
3436
3993
|
_defineProperty(this, "_menuMap", /* @__PURE__ */ new Map());
|
|
3437
|
-
_defineProperty(this, "_activeMenuId", null);
|
|
3994
|
+
_defineProperty(this, "_activeMenuId$", new BehaviorSubject(null));
|
|
3995
|
+
_defineProperty(this, "activeMenuId$", this._activeMenuId$.asObservable());
|
|
3438
3996
|
}
|
|
3439
3997
|
get activeMenuId() {
|
|
3440
|
-
return this._activeMenuId;
|
|
3998
|
+
return this._activeMenuId$.value;
|
|
3441
3999
|
}
|
|
3442
4000
|
registerMenu(menuId, hide) {
|
|
3443
4001
|
this._menuMap.set(menuId, hide);
|
|
3444
4002
|
return toDisposable(() => {
|
|
3445
4003
|
this._menuMap.delete(menuId);
|
|
3446
|
-
if (this.
|
|
4004
|
+
if (this.activeMenuId === menuId) this._activeMenuId$.next(null);
|
|
3447
4005
|
});
|
|
3448
4006
|
}
|
|
3449
4007
|
activateMenu(menuId) {
|
|
3450
4008
|
this.hideActiveMenu(menuId);
|
|
3451
|
-
this._activeMenuId
|
|
4009
|
+
this._activeMenuId$.next(menuId);
|
|
3452
4010
|
}
|
|
3453
4011
|
deactivateMenu(menuId) {
|
|
3454
|
-
if (this.
|
|
4012
|
+
if (this.activeMenuId === menuId) this._activeMenuId$.next(null);
|
|
3455
4013
|
}
|
|
3456
4014
|
hideActiveMenu(exceptMenuId) {
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
4015
|
+
const activeMenuId = this.activeMenuId;
|
|
4016
|
+
if (!activeMenuId || activeMenuId === exceptMenuId) return;
|
|
4017
|
+
const hide = this._menuMap.get(activeMenuId);
|
|
4018
|
+
this._activeMenuId$.next(null);
|
|
3460
4019
|
hide === null || hide === void 0 || hide();
|
|
3461
4020
|
}
|
|
4021
|
+
dispose() {
|
|
4022
|
+
this._activeMenuId$.complete();
|
|
4023
|
+
super.dispose();
|
|
4024
|
+
}
|
|
3462
4025
|
};
|
|
3463
4026
|
|
|
3464
4027
|
//#endregion
|
|
@@ -3495,10 +4058,10 @@ function useScrollYOverContainer(element, container) {
|
|
|
3495
4058
|
useEffect(() => {
|
|
3496
4059
|
if (!isBrowser() || !element || !container) return;
|
|
3497
4060
|
updater();
|
|
3498
|
-
const resizeObserver =
|
|
4061
|
+
const resizeObserver = new ResizeObserver(updater);
|
|
3499
4062
|
resizeObserver.observe(element);
|
|
3500
4063
|
return () => {
|
|
3501
|
-
resizeObserver.
|
|
4064
|
+
resizeObserver.disconnect();
|
|
3502
4065
|
};
|
|
3503
4066
|
}, [element, container]);
|
|
3504
4067
|
}
|
|
@@ -3677,11 +4240,12 @@ function QuickTileMenuItem(props) {
|
|
|
3677
4240
|
const activated = useObservable(menuItem === null || menuItem === void 0 ? void 0 : menuItem.activated$, false);
|
|
3678
4241
|
if (!menuItem || hidden) return null;
|
|
3679
4242
|
const Icon = menuItem.icon ? iconManager.get(menuItem.icon) : null;
|
|
4243
|
+
const active = resolveMenuItemActiveState(menuItem.id, activated, activeItemIds);
|
|
3680
4244
|
return /* @__PURE__ */ jsxs("button", {
|
|
3681
4245
|
type: "button",
|
|
3682
4246
|
className: quickTileMenuButtonVariants({
|
|
3683
4247
|
disabled,
|
|
3684
|
-
active
|
|
4248
|
+
active
|
|
3685
4249
|
}),
|
|
3686
4250
|
disabled,
|
|
3687
4251
|
onClick: () => {
|
|
@@ -4432,6 +4996,9 @@ function ContextMenuMenuItem(props) {
|
|
|
4432
4996
|
setInputValue(value);
|
|
4433
4997
|
}, [value]);
|
|
4434
4998
|
useEffect(() => () => clearSubmenuCloseTimer(), [clearSubmenuCloseTimer]);
|
|
4999
|
+
useEffect(() => {
|
|
5000
|
+
if (disabled) closeSubmenu();
|
|
5001
|
+
}, [closeSubmenu, disabled]);
|
|
4435
5002
|
useEffect(() => {
|
|
4436
5003
|
if (!submenuVisible) {
|
|
4437
5004
|
setSubmenuPositionReady(false);
|
|
@@ -4451,9 +5018,10 @@ function ContextMenuMenuItem(props) {
|
|
|
4451
5018
|
const left = useLeft ? leftLeft : rightLeft;
|
|
4452
5019
|
setSubmenuPlacement(useLeft ? "left" : "right");
|
|
4453
5020
|
const maxTop = window.innerHeight - menuViewportPadding - submenuRect.height;
|
|
5021
|
+
const top = maxTop < menuViewportPadding ? menuViewportPadding : Math.min(Math.max(menuItemRect.top, menuViewportPadding), maxTop);
|
|
4454
5022
|
setSubmenuPosition({
|
|
4455
5023
|
left,
|
|
4456
|
-
top
|
|
5024
|
+
top
|
|
4457
5025
|
});
|
|
4458
5026
|
setSubmenuPositionReady(true);
|
|
4459
5027
|
};
|
|
@@ -4474,7 +5042,8 @@ function ContextMenuMenuItem(props) {
|
|
|
4474
5042
|
const hiddenById = menuItem.id != null && hiddenItemIds.includes(menuItem.id) || hiddenItemIds.includes(menuKey);
|
|
4475
5043
|
if (hidden || hiddenById) return null;
|
|
4476
5044
|
const onChange = (v) => {
|
|
4477
|
-
|
|
5045
|
+
const newValue = isRealNum(v) && typeof v === "string" ? Number.parseInt(v) : v;
|
|
5046
|
+
setInputValue(newValue);
|
|
4478
5047
|
};
|
|
4479
5048
|
const onSubmenuOptionSelect = (option) => {
|
|
4480
5049
|
onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect(option);
|
|
@@ -5015,7 +5584,7 @@ function Sidebar() {
|
|
|
5015
5584
|
children: [options === null || options === void 0 ? void 0 : options.header, /* @__PURE__ */ jsx("button", {
|
|
5016
5585
|
ref: closeButtonRef,
|
|
5017
5586
|
type: "button",
|
|
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",
|
|
5587
|
+
className: "focus:univer-ring-primary-500/50 univer-flex univer-size-6 univer-cursor-pointer univer-appearance-none univer-items-center univer-justify-center 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",
|
|
5019
5588
|
onClick: handleClose,
|
|
5020
5589
|
"aria-label": localeService.t("ui.sidebar.close"),
|
|
5021
5590
|
children: /* @__PURE__ */ jsx(CloseIcon, {})
|
|
@@ -5023,7 +5592,6 @@ function Sidebar() {
|
|
|
5023
5592
|
}),
|
|
5024
5593
|
/* @__PURE__ */ jsx("section", {
|
|
5025
5594
|
className: "univer-box-border univer-cursor-default univer-px-4",
|
|
5026
|
-
style: options === null || options === void 0 ? void 0 : options.bodyStyle,
|
|
5027
5595
|
children: options === null || options === void 0 ? void 0 : options.children
|
|
5028
5596
|
}),
|
|
5029
5597
|
(options === null || options === void 0 ? void 0 : options.footer) && /* @__PURE__ */ jsx("footer", {
|
|
@@ -5035,6 +5603,95 @@ function Sidebar() {
|
|
|
5035
5603
|
});
|
|
5036
5604
|
}
|
|
5037
5605
|
|
|
5606
|
+
//#endregion
|
|
5607
|
+
//#region src/views/components/workbench-skeleton/WorkbenchSkeleton.tsx
|
|
5608
|
+
function WorkbenchSkeleton({ darkMode, direction, overlay = false }) {
|
|
5609
|
+
const shimmerClassName = `
|
|
5610
|
+
univer-animate-pulse univer-bg-gray-100 motion-reduce:univer-animate-none
|
|
5611
|
+
dark:!univer-bg-gray-700
|
|
5612
|
+
`;
|
|
5613
|
+
const shimmerStyle = { animationDuration: "1.2s" };
|
|
5614
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
5615
|
+
"aria-busy": "true",
|
|
5616
|
+
className: clsx("univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-overflow-hidden univer-bg-gray-50 dark:!univer-bg-gray-900", {
|
|
5617
|
+
"univer-absolute univer-inset-0 univer-z-50": overlay,
|
|
5618
|
+
"univer-dark": darkMode
|
|
5619
|
+
}),
|
|
5620
|
+
dir: direction,
|
|
5621
|
+
children: [
|
|
5622
|
+
/* @__PURE__ */ jsxs("header", {
|
|
5623
|
+
"data-u-comp": "workbench-skeleton-toolbar",
|
|
5624
|
+
className: "univer-flex univer-h-11 univer-shrink-0 univer-items-center univer-gap-2 univer-border-0 univer-border-b univer-border-solid univer-border-gray-200 univer-bg-white univer-px-4 dark:!univer-border-gray-700 dark:!univer-bg-gray-800",
|
|
5625
|
+
children: [
|
|
5626
|
+
/* @__PURE__ */ jsx("div", {
|
|
5627
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5628
|
+
className: clsx(shimmerClassName, "univer-h-4 univer-w-24 univer-rounded"),
|
|
5629
|
+
style: shimmerStyle
|
|
5630
|
+
}),
|
|
5631
|
+
/* @__PURE__ */ jsx("div", {
|
|
5632
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5633
|
+
className: clsx(shimmerClassName, "univer-ml-2 univer-size-6 univer-rounded"),
|
|
5634
|
+
style: shimmerStyle
|
|
5635
|
+
}),
|
|
5636
|
+
/* @__PURE__ */ jsx("div", {
|
|
5637
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5638
|
+
className: clsx(shimmerClassName, "univer-size-6 univer-rounded"),
|
|
5639
|
+
style: shimmerStyle
|
|
5640
|
+
})
|
|
5641
|
+
]
|
|
5642
|
+
}),
|
|
5643
|
+
/* @__PURE__ */ jsxs("main", {
|
|
5644
|
+
"data-u-comp": "workbench-skeleton-content",
|
|
5645
|
+
className: "univer-flex univer-min-h-0 univer-min-w-0 univer-flex-1 univer-flex-col univer-gap-4 univer-p-4",
|
|
5646
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
5647
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5648
|
+
className: clsx(shimmerClassName, "univer-h-4 univer-w-1/3 univer-rounded"),
|
|
5649
|
+
style: shimmerStyle
|
|
5650
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
5651
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5652
|
+
className: clsx(shimmerClassName, "univer-flex-1 univer-rounded-md"),
|
|
5653
|
+
style: shimmerStyle
|
|
5654
|
+
})]
|
|
5655
|
+
}),
|
|
5656
|
+
/* @__PURE__ */ jsxs("footer", {
|
|
5657
|
+
"data-u-comp": "workbench-skeleton-footer",
|
|
5658
|
+
className: "univer-flex univer-h-10 univer-shrink-0 univer-items-center univer-justify-between univer-border-0 univer-border-t univer-border-solid univer-border-gray-200 univer-bg-white univer-px-4 dark:!univer-border-gray-700 dark:!univer-bg-gray-800",
|
|
5659
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
5660
|
+
className: "univer-flex univer-items-center univer-gap-2",
|
|
5661
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
5662
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5663
|
+
className: clsx(shimmerClassName, "univer-size-5 univer-rounded"),
|
|
5664
|
+
style: shimmerStyle
|
|
5665
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
5666
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5667
|
+
className: clsx(shimmerClassName, "univer-h-5 univer-w-14 univer-rounded"),
|
|
5668
|
+
style: shimmerStyle
|
|
5669
|
+
})]
|
|
5670
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
5671
|
+
className: "univer-flex univer-items-center univer-gap-2",
|
|
5672
|
+
children: [
|
|
5673
|
+
/* @__PURE__ */ jsx("div", {
|
|
5674
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5675
|
+
className: clsx(shimmerClassName, "univer-size-5 univer-rounded"),
|
|
5676
|
+
style: shimmerStyle
|
|
5677
|
+
}),
|
|
5678
|
+
/* @__PURE__ */ jsx("div", {
|
|
5679
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5680
|
+
className: clsx(shimmerClassName, "univer-h-2 univer-w-24 univer-rounded-full"),
|
|
5681
|
+
style: shimmerStyle
|
|
5682
|
+
}),
|
|
5683
|
+
/* @__PURE__ */ jsx("div", {
|
|
5684
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5685
|
+
className: clsx(shimmerClassName, "univer-size-5 univer-rounded"),
|
|
5686
|
+
style: shimmerStyle
|
|
5687
|
+
})
|
|
5688
|
+
]
|
|
5689
|
+
})]
|
|
5690
|
+
})
|
|
5691
|
+
]
|
|
5692
|
+
});
|
|
5693
|
+
}
|
|
5694
|
+
|
|
5038
5695
|
//#endregion
|
|
5039
5696
|
//#region src/views/hooks/update-effect.ts
|
|
5040
5697
|
/**
|
|
@@ -5241,6 +5898,8 @@ function DesktopWorkbenchContent(props) {
|
|
|
5241
5898
|
var _uiConfig$popupRootId;
|
|
5242
5899
|
const { header = true, toolbar = true, footer = true, headerMenu = true, contextMenu = true, ribbonType = "classic", mountContainer, onRendered } = props;
|
|
5243
5900
|
const localeService = useDependency(LocaleService);
|
|
5901
|
+
const lifecycleService = useDependency(LifecycleService);
|
|
5902
|
+
const workbenchService = useDependency(IWorkbenchService);
|
|
5244
5903
|
const themeService = useDependency(ThemeService);
|
|
5245
5904
|
const themeSwitcherService = useDependency(ThemeSwitcherService);
|
|
5246
5905
|
const contentRef = useRef(null);
|
|
@@ -5253,6 +5912,9 @@ function DesktopWorkbenchContent(props) {
|
|
|
5253
5912
|
const leftSidebarComponents = useComponentsOfPart("left-sidebar");
|
|
5254
5913
|
const globalComponents = useComponentsOfPart("global");
|
|
5255
5914
|
const toolbarComponents = useComponentsOfPart("toolbar");
|
|
5915
|
+
const lifecycleStage = useObservable(lifecycleService.lifecycle$, lifecycleService.stage);
|
|
5916
|
+
const externalSkeletonVisible = useObservable(workbenchService.skeletonVisible$, void 0, true);
|
|
5917
|
+
const ready = lifecycleStage >= LifecycleStages.Ready;
|
|
5256
5918
|
const popupRootId = (_uiConfig$popupRootId = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.popupRootId) !== null && _uiConfig$popupRootId !== void 0 ? _uiConfig$popupRootId : "univer-popup-portal";
|
|
5257
5919
|
useLayoutEffect(() => {
|
|
5258
5920
|
const sub = themeService.currentTheme$.subscribe((theme) => {
|
|
@@ -5268,8 +5930,8 @@ function DesktopWorkbenchContent(props) {
|
|
|
5268
5930
|
else document.documentElement.classList.remove("univer-dark");
|
|
5269
5931
|
}, [darkMode]);
|
|
5270
5932
|
useEffect(() => {
|
|
5271
|
-
if (contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
|
|
5272
|
-
}, [onRendered]);
|
|
5933
|
+
if (ready && contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
|
|
5934
|
+
}, [ready, onRendered]);
|
|
5273
5935
|
const locale = useObservable(() => localeService.localeChanged$.pipe(map(() => localeService.getLocales())), localeService.getLocales(), false, [localeService]);
|
|
5274
5936
|
const direction = useObservable(localeService.direction$, localeService.getDirection());
|
|
5275
5937
|
const portalContainer = useMemo(() => document.createElement("div"), []);
|
|
@@ -5287,61 +5949,68 @@ function DesktopWorkbenchContent(props) {
|
|
|
5287
5949
|
direction,
|
|
5288
5950
|
mountContainer: portalContainer,
|
|
5289
5951
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
5290
|
-
"
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
className: "univer-
|
|
5317
|
-
children: [
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
className: "univer-relative univer-overflow-hidden dark:!univer-bg-gray-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5952
|
+
className: "univer-relative univer-h-full univer-min-h-0",
|
|
5953
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
5954
|
+
"data-u-comp": "workbench-layout",
|
|
5955
|
+
className: clsx("univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800", { "univer-dark": darkMode }),
|
|
5956
|
+
tabIndex: -1,
|
|
5957
|
+
onBlur: (e) => e.stopPropagation(),
|
|
5958
|
+
onContextMenu: (e) => e.preventDefault(),
|
|
5959
|
+
dir: direction,
|
|
5960
|
+
children: [
|
|
5961
|
+
/* @__PURE__ */ jsx("div", {
|
|
5962
|
+
className: "univer-relative univer-flex univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800",
|
|
5963
|
+
children: /* @__PURE__ */ jsx(ComponentContainer, { components: customHeaderComponents }, "custom-header")
|
|
5964
|
+
}),
|
|
5965
|
+
header && toolbar && /* @__PURE__ */ jsx("header", {
|
|
5966
|
+
"data-u-comp": "headerbar",
|
|
5967
|
+
className: "univer-relative univer-z-10 univer-w-full univer-overflow-hidden",
|
|
5968
|
+
children: /* @__PURE__ */ jsx(ComponentContainer, {
|
|
5969
|
+
components: toolbarComponents,
|
|
5970
|
+
sharedProps: {
|
|
5971
|
+
ribbonType,
|
|
5972
|
+
headerMenuComponents,
|
|
5973
|
+
headerMenu
|
|
5974
|
+
}
|
|
5975
|
+
}, "toolbar")
|
|
5976
|
+
}),
|
|
5977
|
+
/* @__PURE__ */ jsxs("section", {
|
|
5978
|
+
className: "univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col",
|
|
5979
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
5980
|
+
className: "univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden",
|
|
5981
|
+
children: [
|
|
5982
|
+
/* @__PURE__ */ jsx("aside", {
|
|
5983
|
+
"data-u-comp": "left-sidebar",
|
|
5984
|
+
className: "univer-h-full",
|
|
5985
|
+
children: /* @__PURE__ */ jsx(ComponentContainer, { components: leftSidebarComponents }, "left-sidebar")
|
|
5986
|
+
}),
|
|
5987
|
+
/* @__PURE__ */ jsxs("section", {
|
|
5988
|
+
className: clsx("univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white dark:!univer-bg-gray-800", borderBottomClassName),
|
|
5989
|
+
children: [/* @__PURE__ */ jsx("header", { children: header && /* @__PURE__ */ jsx(ComponentContainer, { components: headerComponents }, "header") }), /* @__PURE__ */ jsx("section", {
|
|
5990
|
+
className: "univer-relative univer-overflow-hidden dark:!univer-bg-gray-900",
|
|
5991
|
+
ref: contentRef,
|
|
5992
|
+
"data-range-selector": true,
|
|
5993
|
+
onContextMenu: (e) => e.preventDefault(),
|
|
5994
|
+
children: /* @__PURE__ */ jsx(ComponentContainer, { components: contentComponents }, "content")
|
|
5995
|
+
})]
|
|
5996
|
+
}),
|
|
5997
|
+
/* @__PURE__ */ jsx("aside", {
|
|
5998
|
+
"data-u-comp": "right-sidebar",
|
|
5999
|
+
className: "univer-z-[100] univer-h-full",
|
|
6000
|
+
children: /* @__PURE__ */ jsx(Sidebar, {})
|
|
6001
|
+
})
|
|
6002
|
+
]
|
|
6003
|
+
}), footer && /* @__PURE__ */ jsx("footer", { children: /* @__PURE__ */ jsx(ComponentContainer, {
|
|
6004
|
+
components: footerComponents,
|
|
6005
|
+
sharedProps: { contextMenu }
|
|
6006
|
+
}, "footer") })]
|
|
6007
|
+
})
|
|
6008
|
+
]
|
|
6009
|
+
}), (!ready || externalSkeletonVisible) && /* @__PURE__ */ jsx(WorkbenchSkeleton, {
|
|
6010
|
+
darkMode,
|
|
6011
|
+
direction,
|
|
6012
|
+
overlay: true
|
|
6013
|
+
})]
|
|
5345
6014
|
}), /* @__PURE__ */ jsxs("div", {
|
|
5346
6015
|
dir: direction,
|
|
5347
6016
|
children: [
|
|
@@ -5386,6 +6055,9 @@ var SingleUnitUIController = class extends Disposable {
|
|
|
5386
6055
|
delete this._renderManagerService;
|
|
5387
6056
|
}
|
|
5388
6057
|
_bootstrapWorkbench() {
|
|
6058
|
+
var _this$_injector$get;
|
|
6059
|
+
const initialSkeleton = (_this$_injector$get = this._injector.get(IWorkbenchService, Quantity.OPTIONAL)) === null || _this$_injector$get === void 0 ? void 0 : _this$_injector$get.acquireSkeleton();
|
|
6060
|
+
if (initialSkeleton) this.disposeWithMe(initialSkeleton);
|
|
5389
6061
|
this.disposeWithMe(this.bootstrap(async (contentElement, containerElement) => {
|
|
5390
6062
|
if (this._layoutService) {
|
|
5391
6063
|
this.disposeWithMe(this._layoutService.registerRootContainerElement(containerElement));
|
|
@@ -5396,6 +6068,7 @@ var SingleUnitUIController = class extends Disposable {
|
|
|
5396
6068
|
this._renderTimeout = window.setTimeout(() => {
|
|
5397
6069
|
const allRenders = this._renderManagerService.getRenderAll();
|
|
5398
6070
|
for (const [key] of allRenders) if (this._changeRenderUnit(key, contentElement)) break;
|
|
6071
|
+
requestAnimationFrame(() => requestAnimationFrame(() => initialSkeleton === null || initialSkeleton === void 0 ? void 0 : initialSkeleton.dispose()));
|
|
5399
6072
|
this.disposeWithMe(this._instanceService.focused$.subscribe((unit) => {
|
|
5400
6073
|
if (unit) this._changeRenderUnit(unit, contentElement);
|
|
5401
6074
|
}));
|
|
@@ -5423,9 +6096,9 @@ var SingleUnitUIController = class extends Disposable {
|
|
|
5423
6096
|
var _this$_instanceServic2;
|
|
5424
6097
|
if (this._currentRenderId === rendererId) return false;
|
|
5425
6098
|
if ((_this$_instanceServic2 = this._instanceService.getUnitCreateOptions(rendererId)) === null || _this$_instanceServic2 === void 0 ? void 0 : _this$_instanceServic2.embeddedRender) return false;
|
|
5426
|
-
const renderer = this._renderManagerService.
|
|
6099
|
+
const renderer = this._renderManagerService.getRenderUnitById(rendererId);
|
|
5427
6100
|
if (!renderer || !renderer.unitId || isInternalEditorID(renderer.unitId)) return false;
|
|
5428
|
-
const currentRenderer = this._currentRenderId ? this._renderManagerService.
|
|
6101
|
+
const currentRenderer = this._currentRenderId ? this._renderManagerService.getRenderUnitById(this._currentRenderId) : null;
|
|
5429
6102
|
currentRenderer === null || currentRenderer === void 0 || currentRenderer.deactivate();
|
|
5430
6103
|
currentRenderer === null || currentRenderer === void 0 || currentRenderer.engine.unmount();
|
|
5431
6104
|
renderer.engine.mount(contentElement);
|
|
@@ -5497,7 +6170,7 @@ const IUIController = createIdentifier("univer.ui.ui-controller");
|
|
|
5497
6170
|
//#endregion
|
|
5498
6171
|
//#region package.json
|
|
5499
6172
|
var name = "@univerjs/ui";
|
|
5500
|
-
var version = "1.0.0-alpha.
|
|
6173
|
+
var version = "1.0.0-alpha.8";
|
|
5501
6174
|
|
|
5502
6175
|
//#endregion
|
|
5503
6176
|
//#region src/views/color-picker/interface.ts
|
|
@@ -5591,7 +6264,7 @@ function ShortcutPanel() {
|
|
|
5591
6264
|
if (!shortcutGroups.has(group)) shortcutGroups.set(group, []);
|
|
5592
6265
|
shortcutGroups.get(group).push(shortcutItem);
|
|
5593
6266
|
}
|
|
5594
|
-
|
|
6267
|
+
const toRender = Array.from(shortcutGroups.entries()).map(([name, items]) => {
|
|
5595
6268
|
const groupSequence = name.split("_")[0];
|
|
5596
6269
|
const localeKey = groupTitles.get(name);
|
|
5597
6270
|
return {
|
|
@@ -5599,7 +6272,8 @@ function ShortcutPanel() {
|
|
|
5599
6272
|
name: localeService.t(localeKey),
|
|
5600
6273
|
items: dedupeBy(items, (item) => item.title + item.shortcut)
|
|
5601
6274
|
};
|
|
5602
|
-
}).sort((a, b) => a.sequence - b.sequence)
|
|
6275
|
+
}).sort((a, b) => a.sequence - b.sequence);
|
|
6276
|
+
setShortcutItems(toRender);
|
|
5603
6277
|
}, [
|
|
5604
6278
|
shortcutService,
|
|
5605
6279
|
localeService,
|
|
@@ -20499,11 +21173,12 @@ function EmojiPicker(props) {
|
|
|
20499
21173
|
};
|
|
20500
21174
|
}, [localStorageService, recentStorageKey]);
|
|
20501
21175
|
const handleSelect = (item, options) => {
|
|
20502
|
-
var _extraProps$onSelect;
|
|
21176
|
+
var _props$onChange, _extraProps$onSelect;
|
|
20503
21177
|
const nextRecents = promoteRecentEmoji(recents, item);
|
|
20504
21178
|
setActiveEmoji(item.emoji);
|
|
20505
21179
|
setRecents(nextRecents);
|
|
20506
21180
|
writeRecents(localStorageService, recentStorageKey, nextRecents);
|
|
21181
|
+
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, item.emoji);
|
|
20507
21182
|
extraProps === null || extraProps === void 0 || (_extraProps$onSelect = extraProps.onSelect) === null || _extraProps$onSelect === void 0 || _extraProps$onSelect.call(extraProps, item.emoji, options);
|
|
20508
21183
|
};
|
|
20509
21184
|
const handleRandom = () => {
|
|
@@ -20523,7 +21198,7 @@ function EmojiPicker(props) {
|
|
|
20523
21198
|
};
|
|
20524
21199
|
return /* @__PURE__ */ jsxs("section", {
|
|
20525
21200
|
"data-u-comp": EMOJI_PICKER_COMPONENT,
|
|
20526
|
-
className: "univer-flex univer-h-[340px] univer-w-[420px] univer-flex-col univer-overflow-hidden univer-rounded-[10px] univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-900",
|
|
21201
|
+
className: clsx("univer-flex univer-h-[340px] univer-w-[420px] univer-flex-col univer-overflow-hidden", !props.embedded && "univer-rounded-[10px] univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-900"),
|
|
20527
21202
|
children: [
|
|
20528
21203
|
/* @__PURE__ */ jsxs("div", {
|
|
20529
21204
|
className: "univer-flex univer-items-center univer-gap-1 univer-px-3 univer-pb-2 univer-pt-3",
|
|
@@ -20545,7 +21220,7 @@ function EmojiPicker(props) {
|
|
|
20545
21220
|
}),
|
|
20546
21221
|
/* @__PURE__ */ jsx("div", {
|
|
20547
21222
|
ref: scrollRef,
|
|
20548
|
-
className: "univer-relative univer-min-h-0 univer-flex-1 univer-overflow-y-auto univer-px-3",
|
|
21223
|
+
className: clsx("univer-relative univer-min-h-0 univer-flex-1 univer-overflow-y-auto univer-px-3", scrollbarClassName),
|
|
20549
21224
|
onScroll: handleScroll,
|
|
20550
21225
|
children: renderedSections.length ? /* @__PURE__ */ jsx("div", {
|
|
20551
21226
|
className: "univer-flex univer-flex-col univer-gap-1.5 univer-pb-2",
|
|
@@ -21296,8 +21971,8 @@ function ZoomInput(props) {
|
|
|
21296
21971
|
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
21972
|
onClick: (e) => e.stopPropagation(),
|
|
21298
21973
|
children: [/* @__PURE__ */ jsx(Input, {
|
|
21299
|
-
className: "univer-box-border univer-h-6 univer-w-
|
|
21300
|
-
inputClass: "univer-w-
|
|
21974
|
+
className: "univer-box-border univer-h-6 univer-min-w-0 univer-flex-1 univer-border-none univer-bg-transparent [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-full [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-px-1 [&_input]:univer-text-center [&_input]:univer-text-xs [&_input]:univer-tabular-nums",
|
|
21975
|
+
inputClass: "univer-w-full",
|
|
21301
21976
|
size: "mini",
|
|
21302
21977
|
value: inputValue,
|
|
21303
21978
|
disabled,
|
|
@@ -21515,6 +22190,234 @@ function Slider(props) {
|
|
|
21515
22190
|
});
|
|
21516
22191
|
}
|
|
21517
22192
|
|
|
22193
|
+
//#endregion
|
|
22194
|
+
//#region src/views/symbol-picker/symbols.ts
|
|
22195
|
+
const SYMBOL_CATEGORIES = [
|
|
22196
|
+
{
|
|
22197
|
+
key: "mathematics",
|
|
22198
|
+
titleKey: "ui.symbolPicker.mathematics",
|
|
22199
|
+
symbols: [
|
|
22200
|
+
"+",
|
|
22201
|
+
"−",
|
|
22202
|
+
"×",
|
|
22203
|
+
"÷",
|
|
22204
|
+
"≠",
|
|
22205
|
+
"≈",
|
|
22206
|
+
"<",
|
|
22207
|
+
">",
|
|
22208
|
+
"≤",
|
|
22209
|
+
"≥",
|
|
22210
|
+
"≪",
|
|
22211
|
+
"≫",
|
|
22212
|
+
"≡",
|
|
22213
|
+
"±",
|
|
22214
|
+
"%",
|
|
22215
|
+
"‰",
|
|
22216
|
+
"‱",
|
|
22217
|
+
"½",
|
|
22218
|
+
"⅓",
|
|
22219
|
+
"⅔",
|
|
22220
|
+
"¼",
|
|
22221
|
+
"¾",
|
|
22222
|
+
"¹",
|
|
22223
|
+
"²",
|
|
22224
|
+
"³",
|
|
22225
|
+
"ⁿ",
|
|
22226
|
+
"₁",
|
|
22227
|
+
"₂",
|
|
22228
|
+
"₃",
|
|
22229
|
+
"|a|",
|
|
22230
|
+
"∟",
|
|
22231
|
+
"∠",
|
|
22232
|
+
"⊿",
|
|
22233
|
+
"△",
|
|
22234
|
+
"∥",
|
|
22235
|
+
"⊥",
|
|
22236
|
+
"∫",
|
|
22237
|
+
"∬",
|
|
22238
|
+
"∭",
|
|
22239
|
+
"∮",
|
|
22240
|
+
"∯",
|
|
22241
|
+
"∰",
|
|
22242
|
+
"∝",
|
|
22243
|
+
"∞",
|
|
22244
|
+
"∼",
|
|
22245
|
+
"≌",
|
|
22246
|
+
"∈",
|
|
22247
|
+
"∉",
|
|
22248
|
+
"⊆",
|
|
22249
|
+
"⊂",
|
|
22250
|
+
"∅",
|
|
22251
|
+
"∩",
|
|
22252
|
+
"∪",
|
|
22253
|
+
"∧",
|
|
22254
|
+
"∨",
|
|
22255
|
+
"⋅",
|
|
22256
|
+
"⋮",
|
|
22257
|
+
"⋰",
|
|
22258
|
+
"⋱",
|
|
22259
|
+
"⋯",
|
|
22260
|
+
"∏",
|
|
22261
|
+
"∑",
|
|
22262
|
+
"∃",
|
|
22263
|
+
"∄",
|
|
22264
|
+
"∀",
|
|
22265
|
+
"∂",
|
|
22266
|
+
"∆",
|
|
22267
|
+
"⊙",
|
|
22268
|
+
"⊕",
|
|
22269
|
+
"%"
|
|
22270
|
+
]
|
|
22271
|
+
},
|
|
22272
|
+
{
|
|
22273
|
+
key: "greek",
|
|
22274
|
+
titleKey: "ui.symbolPicker.greek",
|
|
22275
|
+
symbols: [
|
|
22276
|
+
"α",
|
|
22277
|
+
"β",
|
|
22278
|
+
"γ",
|
|
22279
|
+
"δ",
|
|
22280
|
+
"ε",
|
|
22281
|
+
"ζ",
|
|
22282
|
+
"η",
|
|
22283
|
+
"θ",
|
|
22284
|
+
"ι",
|
|
22285
|
+
"κ",
|
|
22286
|
+
"λ",
|
|
22287
|
+
"μ",
|
|
22288
|
+
"ν",
|
|
22289
|
+
"ξ",
|
|
22290
|
+
"ο",
|
|
22291
|
+
"π",
|
|
22292
|
+
"ρ",
|
|
22293
|
+
"σ",
|
|
22294
|
+
"τ",
|
|
22295
|
+
"υ",
|
|
22296
|
+
"φ",
|
|
22297
|
+
"χ",
|
|
22298
|
+
"ψ",
|
|
22299
|
+
"ω",
|
|
22300
|
+
"Α",
|
|
22301
|
+
"Β",
|
|
22302
|
+
"Γ",
|
|
22303
|
+
"Δ",
|
|
22304
|
+
"Ε",
|
|
22305
|
+
"Ζ",
|
|
22306
|
+
"Η",
|
|
22307
|
+
"Θ",
|
|
22308
|
+
"Ι",
|
|
22309
|
+
"Κ",
|
|
22310
|
+
"Λ",
|
|
22311
|
+
"Μ",
|
|
22312
|
+
"Ν",
|
|
22313
|
+
"Ξ",
|
|
22314
|
+
"Ο",
|
|
22315
|
+
"Π",
|
|
22316
|
+
"Ρ",
|
|
22317
|
+
"Σ",
|
|
22318
|
+
"Τ",
|
|
22319
|
+
"Υ",
|
|
22320
|
+
"Φ",
|
|
22321
|
+
"Χ",
|
|
22322
|
+
"Ψ",
|
|
22323
|
+
"Ω"
|
|
22324
|
+
]
|
|
22325
|
+
},
|
|
22326
|
+
{
|
|
22327
|
+
key: "common",
|
|
22328
|
+
titleKey: "ui.symbolPicker.common",
|
|
22329
|
+
symbols: [
|
|
22330
|
+
"kg",
|
|
22331
|
+
"mm",
|
|
22332
|
+
"cm",
|
|
22333
|
+
"m²",
|
|
22334
|
+
"°C",
|
|
22335
|
+
"°",
|
|
22336
|
+
"§",
|
|
22337
|
+
"◎",
|
|
22338
|
+
"©",
|
|
22339
|
+
"®",
|
|
22340
|
+
"{",
|
|
22341
|
+
"⌜",
|
|
22342
|
+
"〚",
|
|
22343
|
+
"№",
|
|
22344
|
+
"$",
|
|
22345
|
+
"¥",
|
|
22346
|
+
"@",
|
|
22347
|
+
"&",
|
|
22348
|
+
"*",
|
|
22349
|
+
"|",
|
|
22350
|
+
"#",
|
|
22351
|
+
"※",
|
|
22352
|
+
"√",
|
|
22353
|
+
"×",
|
|
22354
|
+
"…",
|
|
22355
|
+
"①",
|
|
22356
|
+
"②",
|
|
22357
|
+
"③",
|
|
22358
|
+
"↑",
|
|
22359
|
+
"↓",
|
|
22360
|
+
"←",
|
|
22361
|
+
"→"
|
|
22362
|
+
]
|
|
22363
|
+
}
|
|
22364
|
+
];
|
|
22365
|
+
|
|
22366
|
+
//#endregion
|
|
22367
|
+
//#region src/views/symbol-picker/SymbolPicker.tsx
|
|
22368
|
+
const SYMBOL_PICKER_COMPONENT = "ui.symbol-picker";
|
|
22369
|
+
function SymbolPicker(props) {
|
|
22370
|
+
var _props$popup;
|
|
22371
|
+
const extraProps = (_props$popup = props.popup) === null || _props$popup === void 0 ? void 0 : _props$popup.extraProps;
|
|
22372
|
+
const localeService = useDependency(LocaleService);
|
|
22373
|
+
useObservable(localeService.currentLocale$, localeService.getCurrentLocale());
|
|
22374
|
+
const [activeSymbol, setActiveSymbol] = useState(extraProps === null || extraProps === void 0 ? void 0 : extraProps.activeSymbol);
|
|
22375
|
+
const handleSelect = (symbol) => {
|
|
22376
|
+
var _props$onChange, _extraProps$onSelect;
|
|
22377
|
+
setActiveSymbol(symbol);
|
|
22378
|
+
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, symbol);
|
|
22379
|
+
extraProps === null || extraProps === void 0 || (_extraProps$onSelect = extraProps.onSelect) === null || _extraProps$onSelect === void 0 || _extraProps$onSelect.call(extraProps, symbol, { keepOpen: true });
|
|
22380
|
+
};
|
|
22381
|
+
return /* @__PURE__ */ jsx("section", {
|
|
22382
|
+
"data-u-comp": SYMBOL_PICKER_COMPONENT,
|
|
22383
|
+
className: clsx("univer-flex univer-h-[340px] univer-w-[420px] univer-flex-col univer-overflow-hidden", !props.embedded && "univer-rounded-[10px] univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-900", props.className),
|
|
22384
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
22385
|
+
className: clsx("univer-min-h-0 univer-flex-1 univer-overflow-y-auto univer-p-4", scrollbarClassName),
|
|
22386
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
22387
|
+
className: "univer-flex univer-flex-col univer-gap-5",
|
|
22388
|
+
children: SYMBOL_CATEGORIES.map((category) => /* @__PURE__ */ jsx(SymbolSection, {
|
|
22389
|
+
activeSymbol,
|
|
22390
|
+
category,
|
|
22391
|
+
onSelect: handleSelect
|
|
22392
|
+
}, category.key))
|
|
22393
|
+
})
|
|
22394
|
+
})
|
|
22395
|
+
});
|
|
22396
|
+
}
|
|
22397
|
+
function SymbolSection(props) {
|
|
22398
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
22399
|
+
className: "univer-flex univer-flex-col univer-gap-2",
|
|
22400
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
22401
|
+
className: "univer-text-sm univer-font-semibold univer-text-gray-900 dark:!univer-text-gray-100",
|
|
22402
|
+
children: useDependency(LocaleService).t(props.category.titleKey)
|
|
22403
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
22404
|
+
className: "univer-grid univer-grid-cols-10 univer-gap-1",
|
|
22405
|
+
children: props.category.symbols.map((symbol, index) => {
|
|
22406
|
+
const active = props.activeSymbol === symbol;
|
|
22407
|
+
return /* @__PURE__ */ jsx("button", {
|
|
22408
|
+
type: "button",
|
|
22409
|
+
"aria-label": symbol,
|
|
22410
|
+
"aria-pressed": active,
|
|
22411
|
+
title: symbol,
|
|
22412
|
+
className: clsx("univer-flex univer-size-8 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-lg univer-border-0 univer-bg-transparent univer-p-0 univer-text-lg univer-text-gray-900 dark:!univer-text-gray-100", active ? "univer-bg-primary-50 univer-shadow-sm dark:!univer-bg-gray-800 dark:!univer-shadow-sm" : "hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800"),
|
|
22413
|
+
onClick: () => props.onSelect(symbol),
|
|
22414
|
+
children: symbol
|
|
22415
|
+
}, `${props.category.key}-${symbol}-${index}`);
|
|
22416
|
+
})
|
|
22417
|
+
})]
|
|
22418
|
+
});
|
|
22419
|
+
}
|
|
22420
|
+
|
|
21518
22421
|
//#endregion
|
|
21519
22422
|
//#region src/controllers/components.controller.ts
|
|
21520
22423
|
/**
|
|
@@ -21544,9 +22447,11 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
21544
22447
|
this.disposeWithMe(this._iconManager.register({
|
|
21545
22448
|
ExpandIcon,
|
|
21546
22449
|
IncreaseIcon,
|
|
22450
|
+
KeyboardIcon,
|
|
21547
22451
|
MoreDownIcon,
|
|
21548
22452
|
RedoIcon,
|
|
21549
22453
|
ReduceIcon,
|
|
22454
|
+
FeatureSearchIcon,
|
|
21550
22455
|
ShortcutIcon,
|
|
21551
22456
|
ShrinkIcon,
|
|
21552
22457
|
UndoIcon
|
|
@@ -21560,7 +22465,9 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
21560
22465
|
[FONT_FAMILY_ITEM_COMPONENT, FontFamilyItem],
|
|
21561
22466
|
[FONT_SIZE_COMPONENT, FontSize],
|
|
21562
22467
|
[COLOR_PICKER_COMPONENT, ColorPicker],
|
|
21563
|
-
[EMOJI_PICKER_COMPONENT, EmojiPicker]
|
|
22468
|
+
[EMOJI_PICKER_COMPONENT, EmojiPicker],
|
|
22469
|
+
[SYMBOL_PICKER_COMPONENT, SymbolPicker],
|
|
22470
|
+
[FEATURE_SEARCH_COMPONENT, FeatureSearch]
|
|
21564
22471
|
].forEach(([key, comp]) => {
|
|
21565
22472
|
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
21566
22473
|
});
|
|
@@ -21569,6 +22476,24 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
21569
22476
|
};
|
|
21570
22477
|
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
21571
22478
|
|
|
22479
|
+
//#endregion
|
|
22480
|
+
//#region src/controllers/feature-search/feature-search.controller.ts
|
|
22481
|
+
const FeatureSearchShortcut = {
|
|
22482
|
+
id: OpenFeatureSearchOperation.id,
|
|
22483
|
+
binding: 4096 | 1024 | 80,
|
|
22484
|
+
description: "ui.featureSearch.title",
|
|
22485
|
+
group: "10_global-shortcut",
|
|
22486
|
+
groupTitle: "ui.global-shortcut"
|
|
22487
|
+
};
|
|
22488
|
+
let FeatureSearchController = class FeatureSearchController extends Disposable {
|
|
22489
|
+
constructor(commandService, shortcutService) {
|
|
22490
|
+
super();
|
|
22491
|
+
this.disposeWithMe(commandService.registerCommand(OpenFeatureSearchOperation));
|
|
22492
|
+
this.disposeWithMe(shortcutService.registerShortcut(FeatureSearchShortcut));
|
|
22493
|
+
}
|
|
22494
|
+
};
|
|
22495
|
+
FeatureSearchController = __decorate([__decorateParam(0, ICommandService), __decorateParam(1, IShortcutService)], FeatureSearchController);
|
|
22496
|
+
|
|
21572
22497
|
//#endregion
|
|
21573
22498
|
//#region src/views/components/ribbon/MobileRibbon.tsx
|
|
21574
22499
|
const toolbarScrollOffset = 168;
|
|
@@ -21792,7 +22717,8 @@ function MobileMenu(props) {
|
|
|
21792
22717
|
menuManagerService,
|
|
21793
22718
|
menuType,
|
|
21794
22719
|
onExecute: onOptionSelect,
|
|
21795
|
-
onOpenView: openView
|
|
22720
|
+
onOpenView: openView,
|
|
22721
|
+
inheritedDisabled$: currentView === null || currentView === void 0 ? void 0 : currentView.disabled$
|
|
21796
22722
|
})
|
|
21797
22723
|
}), (currentView === null || currentView === void 0 ? void 0 : currentView.kind) === "options" && /* @__PURE__ */ jsx("div", {
|
|
21798
22724
|
className: "univer-overflow-hidden univer-rounded-2xl univer-bg-white",
|
|
@@ -21801,6 +22727,7 @@ function MobileMenu(props) {
|
|
|
21801
22727
|
menuItem: currentView.menuItem,
|
|
21802
22728
|
options: currentView.options,
|
|
21803
22729
|
currentValue: currentView.currentValue,
|
|
22730
|
+
inheritedDisabled$: currentView.disabled$,
|
|
21804
22731
|
onExecute: onOptionSelect
|
|
21805
22732
|
})
|
|
21806
22733
|
})]
|
|
@@ -21808,7 +22735,7 @@ function MobileMenu(props) {
|
|
|
21808
22735
|
});
|
|
21809
22736
|
}
|
|
21810
22737
|
function MobileSchemaList(props) {
|
|
21811
|
-
const { schemas, menuManagerService, menuType, onExecute, onOpenView } = props;
|
|
22738
|
+
const { schemas, menuManagerService, menuType, onExecute, onOpenView, inheritedDisabled$ } = props;
|
|
21812
22739
|
const localeService = useDependency(LocaleService);
|
|
21813
22740
|
const hiddenGroupStates = useContextGroupHiddenStates(schemas);
|
|
21814
22741
|
const visibleSchemas = useMemo(() => {
|
|
@@ -21826,6 +22753,7 @@ function MobileSchemaList(props) {
|
|
|
21826
22753
|
menuType,
|
|
21827
22754
|
onExecute,
|
|
21828
22755
|
onOpenView,
|
|
22756
|
+
inheritedDisabled$,
|
|
21829
22757
|
bordered: index !== visibleSchemas.length - 1
|
|
21830
22758
|
}, schema.key);
|
|
21831
22759
|
if (!((_schema$children2 = schema.children) === null || _schema$children2 === void 0 ? void 0 : _schema$children2.length)) return null;
|
|
@@ -21840,18 +22768,20 @@ function MobileSchemaList(props) {
|
|
|
21840
22768
|
menuType,
|
|
21841
22769
|
onExecute,
|
|
21842
22770
|
onOpenView,
|
|
22771
|
+
inheritedDisabled$,
|
|
21843
22772
|
bordered: childIndex !== schema.children.length - 1
|
|
21844
22773
|
}, childSchema.key))]
|
|
21845
22774
|
}, schema.key);
|
|
21846
22775
|
}) });
|
|
21847
22776
|
}
|
|
21848
22777
|
function MobileSchemaRow(props) {
|
|
21849
|
-
const { schema, menuManagerService, menuType, onExecute, onOpenView, bordered } = props;
|
|
22778
|
+
const { schema, menuManagerService, menuType, onExecute, onOpenView, inheritedDisabled$, bordered } = props;
|
|
21850
22779
|
const interaction = useMobileSchemaInteraction({
|
|
21851
22780
|
schema,
|
|
21852
22781
|
menuManagerService,
|
|
21853
22782
|
menuType,
|
|
21854
|
-
onOpenView
|
|
22783
|
+
onOpenView,
|
|
22784
|
+
inheritedDisabled$
|
|
21855
22785
|
});
|
|
21856
22786
|
if (!interaction || interaction.hidden) return null;
|
|
21857
22787
|
const { menuItem, disabled, value, currentValueText, hasSubmenu, onPress } = interaction;
|
|
@@ -21879,7 +22809,8 @@ function MobileSchemaRow(props) {
|
|
|
21879
22809
|
});
|
|
21880
22810
|
}
|
|
21881
22811
|
function MobileSelectionOptionsView(props) {
|
|
21882
|
-
const { options, menuKey, menuItem, currentValue, onExecute } = props;
|
|
22812
|
+
const { options, menuKey, menuItem, currentValue, inheritedDisabled$, onExecute } = props;
|
|
22813
|
+
const inheritedDisabled = useObservable(inheritedDisabled$, false);
|
|
21883
22814
|
return /* @__PURE__ */ jsx(Fragment$1, { children: options.map((option, index) => {
|
|
21884
22815
|
var _option$value;
|
|
21885
22816
|
return /* @__PURE__ */ jsx(MobileSelectionOptionRow, {
|
|
@@ -21887,6 +22818,7 @@ function MobileSelectionOptionsView(props) {
|
|
|
21887
22818
|
menuKey,
|
|
21888
22819
|
menuItem,
|
|
21889
22820
|
currentValue,
|
|
22821
|
+
disabled: inheritedDisabled,
|
|
21890
22822
|
bordered: index !== options.length - 1,
|
|
21891
22823
|
onExecute
|
|
21892
22824
|
}, `${menuKey}-${String((_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : index)}`);
|
|
@@ -21894,15 +22826,17 @@ function MobileSelectionOptionsView(props) {
|
|
|
21894
22826
|
}
|
|
21895
22827
|
function MobileSelectionOptionRow(props) {
|
|
21896
22828
|
var _option$value2;
|
|
21897
|
-
const { option, menuKey, menuItem, currentValue, bordered, onExecute } = props;
|
|
22829
|
+
const { option, menuKey, menuItem, currentValue, disabled, bordered, onExecute } = props;
|
|
21898
22830
|
const optionValue = useObservable(option.value$);
|
|
21899
22831
|
const displayValue = (_option$value2 = option.value) !== null && _option$value2 !== void 0 ? _option$value2 : optionValue;
|
|
21900
22832
|
const selected = displayValue === currentValue;
|
|
22833
|
+
const optionDisabled = disabled || Boolean(option.disabled);
|
|
21901
22834
|
return /* @__PURE__ */ jsxs("button", {
|
|
21902
22835
|
type: "button",
|
|
21903
22836
|
className: clsx("univer-relative univer-flex univer-min-h-[56px] univer-w-full univer-appearance-none univer-items-center univer-gap-3 univer-border-0 univer-bg-white univer-px-4 univer-py-3 univer-text-left univer-transition-colors enabled:hover:univer-bg-gray-50 enabled:active:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-opacity-40", bordered && borderBottomClassName),
|
|
21904
|
-
disabled:
|
|
22837
|
+
disabled: optionDisabled,
|
|
21905
22838
|
onClick: () => {
|
|
22839
|
+
if (optionDisabled) return;
|
|
21906
22840
|
onExecute === null || onExecute === void 0 || onExecute({
|
|
21907
22841
|
...option,
|
|
21908
22842
|
value: displayValue,
|
|
@@ -21924,11 +22858,15 @@ function MobileSelectionOptionRow(props) {
|
|
|
21924
22858
|
}
|
|
21925
22859
|
function useMobileSchemaInteraction(props) {
|
|
21926
22860
|
var _schema$children3;
|
|
21927
|
-
const { schema, menuManagerService, menuType, onOpenView } = props;
|
|
22861
|
+
const { schema, menuManagerService, menuType, onOpenView, inheritedDisabled$ } = props;
|
|
21928
22862
|
const localeService = useDependency(LocaleService);
|
|
21929
22863
|
const menuItem = schema.item;
|
|
21930
22864
|
const selectorItem = menuItem;
|
|
21931
|
-
const disabled =
|
|
22865
|
+
const disabled$ = useMemo(() => {
|
|
22866
|
+
const sources = [inheritedDisabled$, menuItem === null || menuItem === void 0 ? void 0 : menuItem.disabled$].filter((source) => Boolean(source));
|
|
22867
|
+
return sources.length ? combineLatest(sources.map((source) => source.pipe(startWith$1(false)))).pipe(map((states) => states.some(Boolean))) : void 0;
|
|
22868
|
+
}, [inheritedDisabled$, menuItem === null || menuItem === void 0 ? void 0 : menuItem.disabled$]);
|
|
22869
|
+
const disabled = useObservable(disabled$, false);
|
|
21932
22870
|
const hidden = useObservable(menuItem === null || menuItem === void 0 ? void 0 : menuItem.hidden$, false);
|
|
21933
22871
|
const value = useObservable(menuItem === null || menuItem === void 0 ? void 0 : menuItem.value$);
|
|
21934
22872
|
const selectionsFromObservable = useObservable(selectorItem && isObservable(selectorItem.selections) ? selectorItem.selections : void 0);
|
|
@@ -21950,11 +22888,13 @@ function useMobileSchemaInteraction(props) {
|
|
|
21950
22888
|
const hasSubmenu = schemaChildren.length > 0 || selections.length > 0 || subMenuItems.length > 0;
|
|
21951
22889
|
const currentValueText = typeof value === "string" || typeof value === "number" ? String(value) : "";
|
|
21952
22890
|
const onPress = (onExecute) => {
|
|
22891
|
+
if (disabled) return;
|
|
21953
22892
|
if (schemaChildren.length > 0) {
|
|
21954
22893
|
onOpenView({
|
|
21955
22894
|
kind: "schema",
|
|
21956
22895
|
title: getMenuSchemaTitle(schema, localeService),
|
|
21957
|
-
schemas: schemaChildren
|
|
22896
|
+
schemas: schemaChildren,
|
|
22897
|
+
disabled$
|
|
21958
22898
|
});
|
|
21959
22899
|
return;
|
|
21960
22900
|
}
|
|
@@ -21965,7 +22905,8 @@ function useMobileSchemaInteraction(props) {
|
|
|
21965
22905
|
options: selections,
|
|
21966
22906
|
menuItem: selectorItem,
|
|
21967
22907
|
menuKey: schema.key,
|
|
21968
|
-
currentValue: value
|
|
22908
|
+
currentValue: value,
|
|
22909
|
+
disabled$
|
|
21969
22910
|
});
|
|
21970
22911
|
return;
|
|
21971
22912
|
}
|
|
@@ -21973,7 +22914,8 @@ function useMobileSchemaInteraction(props) {
|
|
|
21973
22914
|
onOpenView({
|
|
21974
22915
|
kind: "schema",
|
|
21975
22916
|
title: getMenuSchemaTitle(schema, localeService),
|
|
21976
|
-
schemas: subMenuItems
|
|
22917
|
+
schemas: subMenuItems,
|
|
22918
|
+
disabled$
|
|
21977
22919
|
});
|
|
21978
22920
|
return;
|
|
21979
22921
|
}
|
|
@@ -22151,6 +23093,8 @@ function mountMobileWorkbench(injector, options, mountContainer, onRendered) {
|
|
|
22151
23093
|
function MobileWorkbench(props) {
|
|
22152
23094
|
const { header = true, toolbar = true, footer = true, headerMenu = true, ribbonType = "classic", contextMenu = true, mountContainer, onRendered } = props;
|
|
22153
23095
|
const localeService = useDependency(LocaleService);
|
|
23096
|
+
const lifecycleService = useDependency(LifecycleService);
|
|
23097
|
+
const workbenchService = useDependency(IWorkbenchService);
|
|
22154
23098
|
const themeService = useDependency(ThemeService);
|
|
22155
23099
|
const themeSwitcherService = useDependency(ThemeSwitcherService);
|
|
22156
23100
|
const contentRef = useRef(null);
|
|
@@ -22162,9 +23106,12 @@ function MobileWorkbench(props) {
|
|
|
22162
23106
|
const globalComponents = useComponentsOfPart("global");
|
|
22163
23107
|
const toolbarComponents = useComponentsOfPart("toolbar");
|
|
22164
23108
|
const darkMode = useObservable(themeService.darkMode$, themeService.darkMode);
|
|
23109
|
+
const lifecycleStage = useObservable(lifecycleService.lifecycle$, lifecycleService.stage);
|
|
23110
|
+
const externalSkeletonVisible = useObservable(workbenchService.skeletonVisible$, void 0, true);
|
|
23111
|
+
const ready = lifecycleStage >= LifecycleStages.Ready;
|
|
22165
23112
|
useEffect(() => {
|
|
22166
|
-
if (contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
|
|
22167
|
-
}, [onRendered]);
|
|
23113
|
+
if (ready && contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
|
|
23114
|
+
}, [ready, onRendered]);
|
|
22168
23115
|
const locale = useObservable(() => localeService.localeChanged$.pipe(map(() => localeService.getLocales())), localeService.getLocales(), false, [localeService]);
|
|
22169
23116
|
const direction = useObservable(localeService.direction$, localeService.getDirection());
|
|
22170
23117
|
const portalContainer = useMemo(() => document.createElement("div"), []);
|
|
@@ -22190,51 +23137,58 @@ function MobileWorkbench(props) {
|
|
|
22190
23137
|
direction,
|
|
22191
23138
|
mountContainer: portalContainer,
|
|
22192
23139
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
22193
|
-
"
|
|
22194
|
-
|
|
22195
|
-
|
|
22196
|
-
|
|
22197
|
-
|
|
22198
|
-
|
|
22199
|
-
|
|
22200
|
-
|
|
22201
|
-
|
|
22202
|
-
|
|
22203
|
-
|
|
22204
|
-
|
|
22205
|
-
|
|
22206
|
-
|
|
22207
|
-
|
|
22208
|
-
|
|
22209
|
-
|
|
22210
|
-
|
|
22211
|
-
|
|
22212
|
-
|
|
22213
|
-
className: "univer-
|
|
22214
|
-
children: [
|
|
22215
|
-
|
|
22216
|
-
|
|
22217
|
-
|
|
22218
|
-
|
|
22219
|
-
|
|
22220
|
-
|
|
22221
|
-
|
|
22222
|
-
className: "univer-
|
|
22223
|
-
children:
|
|
22224
|
-
|
|
22225
|
-
|
|
22226
|
-
|
|
22227
|
-
|
|
22228
|
-
|
|
22229
|
-
|
|
22230
|
-
|
|
22231
|
-
|
|
22232
|
-
|
|
22233
|
-
|
|
22234
|
-
|
|
22235
|
-
|
|
22236
|
-
|
|
22237
|
-
|
|
23140
|
+
className: "univer-relative univer-h-full univer-min-h-0",
|
|
23141
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
23142
|
+
"data-u-comp": "app-layout",
|
|
23143
|
+
className: clsx("univer-relative univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800", { "univer-dark": darkMode }),
|
|
23144
|
+
tabIndex: -1,
|
|
23145
|
+
onBlur: (e) => e.stopPropagation(),
|
|
23146
|
+
onContextMenu: (e) => e.preventDefault(),
|
|
23147
|
+
dir: direction,
|
|
23148
|
+
children: [header && toolbar && /* @__PURE__ */ jsx("header", {
|
|
23149
|
+
"data-u-comp": "headerbar",
|
|
23150
|
+
className: "univer-relative univer-z-10 univer-w-full univer-overflow-hidden",
|
|
23151
|
+
children: /* @__PURE__ */ jsx(ComponentContainer, {
|
|
23152
|
+
components: toolbarComponents,
|
|
23153
|
+
sharedProps: {
|
|
23154
|
+
ribbonType,
|
|
23155
|
+
headerMenuComponents,
|
|
23156
|
+
headerMenu
|
|
23157
|
+
}
|
|
23158
|
+
}, "toolbar")
|
|
23159
|
+
}), /* @__PURE__ */ jsxs("section", {
|
|
23160
|
+
className: "univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col",
|
|
23161
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
23162
|
+
className: "univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden",
|
|
23163
|
+
children: [
|
|
23164
|
+
/* @__PURE__ */ jsx("aside", {
|
|
23165
|
+
className: "univer-h-full",
|
|
23166
|
+
children: /* @__PURE__ */ jsx(ComponentContainer, { components: leftSidebarComponents }, "left-sidebar")
|
|
23167
|
+
}),
|
|
23168
|
+
/* @__PURE__ */ jsxs("section", {
|
|
23169
|
+
className: clsx("univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white dark:!univer-bg-gray-800", borderBottomClassName),
|
|
23170
|
+
children: [/* @__PURE__ */ jsx("header", {
|
|
23171
|
+
className: "univer-w-screen",
|
|
23172
|
+
children: header && /* @__PURE__ */ jsx(ComponentContainer, { components: headerComponents }, "header")
|
|
23173
|
+
}), /* @__PURE__ */ jsx("section", {
|
|
23174
|
+
ref: contentRef,
|
|
23175
|
+
className: "univer-relative univer-overflow-hidden",
|
|
23176
|
+
"data-range-selector": true,
|
|
23177
|
+
onContextMenu: (e) => e.preventDefault(),
|
|
23178
|
+
children: /* @__PURE__ */ jsx(ComponentContainer, { components: contentComponents }, "content")
|
|
23179
|
+
})]
|
|
23180
|
+
}),
|
|
23181
|
+
/* @__PURE__ */ jsx("aside", {
|
|
23182
|
+
className: "univer-h-full",
|
|
23183
|
+
children: /* @__PURE__ */ jsx(Sidebar, {})
|
|
23184
|
+
})
|
|
23185
|
+
]
|
|
23186
|
+
}), footer && /* @__PURE__ */ jsx("footer", { children: /* @__PURE__ */ jsx(ComponentContainer, { components: footerComponents }, "footer") })]
|
|
23187
|
+
})]
|
|
23188
|
+
}), (!ready || externalSkeletonVisible) && /* @__PURE__ */ jsx(WorkbenchSkeleton, {
|
|
23189
|
+
darkMode,
|
|
23190
|
+
direction,
|
|
23191
|
+
overlay: true
|
|
22238
23192
|
})]
|
|
22239
23193
|
}), /* @__PURE__ */ jsxs("div", {
|
|
22240
23194
|
dir: direction,
|
|
@@ -22528,7 +23482,7 @@ let BrowserClipboardService = class BrowserClipboardService extends Disposable {
|
|
|
22528
23482
|
this._notificationService = _notificationService;
|
|
22529
23483
|
}
|
|
22530
23484
|
async write(text, html, customData) {
|
|
22531
|
-
if (!this.supportClipboard) return this._legacyCopyHtml(text, html);
|
|
23485
|
+
if (!this.supportClipboard || typeof ClipboardItem === "undefined" || typeof navigator.clipboard.write !== "function") return this._legacyCopyHtml(text, html);
|
|
22532
23486
|
try {
|
|
22533
23487
|
return await navigator.clipboard.write([new ClipboardItem({
|
|
22534
23488
|
[PLAIN_TEXT_CLIPBOARD_MIME_TYPE]: new Blob([text], { type: PLAIN_TEXT_CLIPBOARD_MIME_TYPE }),
|
|
@@ -22860,10 +23814,6 @@ let DesktopConfirmService = class DesktopConfirmService extends Disposable {
|
|
|
22860
23814
|
};
|
|
22861
23815
|
DesktopConfirmService = __decorate([__decorateParam(0, Inject(Injector)), __decorateParam(1, IUIPartsService)], DesktopConfirmService);
|
|
22862
23816
|
|
|
22863
|
-
//#endregion
|
|
22864
|
-
//#region src/services/dialog/dialog.service.ts
|
|
22865
|
-
const IDialogService = createIdentifier("univer.ui.dialog-service");
|
|
22866
|
-
|
|
22867
23817
|
//#endregion
|
|
22868
23818
|
//#region src/views/components/dialog-part/DialogPart.tsx
|
|
22869
23819
|
function DialogPart() {
|
|
@@ -23452,6 +24402,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends Plugin {
|
|
|
23452
24402
|
[IconManager],
|
|
23453
24403
|
[ComponentsController],
|
|
23454
24404
|
[ThemeSwitcherService],
|
|
24405
|
+
[IWorkbenchService, { useClass: WorkbenchService }],
|
|
23455
24406
|
[ZIndexManager],
|
|
23456
24407
|
[ShortcutPanelService],
|
|
23457
24408
|
[IUIPartsService, { useClass: UIPartsService }],
|
|
@@ -23507,6 +24458,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends Plugin {
|
|
|
23507
24458
|
}],
|
|
23508
24459
|
[SharedController],
|
|
23509
24460
|
[ErrorController],
|
|
24461
|
+
[FeatureSearchController],
|
|
23510
24462
|
[ShortcutPanelController]
|
|
23511
24463
|
], this._config.override));
|
|
23512
24464
|
touchDependencies(this._injector, [
|
|
@@ -23516,7 +24468,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends Plugin {
|
|
|
23516
24468
|
]);
|
|
23517
24469
|
}
|
|
23518
24470
|
onReady() {
|
|
23519
|
-
touchDependencies(this._injector, [[SharedController]]);
|
|
24471
|
+
touchDependencies(this._injector, [[SharedController], [FeatureSearchController]]);
|
|
23520
24472
|
}
|
|
23521
24473
|
onSteady() {
|
|
23522
24474
|
touchDependencies(this._injector, [[ShortcutPanelController]]);
|
|
@@ -23556,6 +24508,7 @@ let UniverUIPlugin = class UniverUIPlugin extends Plugin {
|
|
|
23556
24508
|
[ZIndexManager],
|
|
23557
24509
|
[ShortcutPanelService],
|
|
23558
24510
|
[IUIPartsService, { useClass: UIPartsService }],
|
|
24511
|
+
[IWorkbenchService, { useClass: WorkbenchService }],
|
|
23559
24512
|
[ILayoutService, { useClass: DesktopLayoutService }],
|
|
23560
24513
|
[IRibbonService, { useClass: DesktopRibbonService }],
|
|
23561
24514
|
[IRibbonOverrideService, { useClass: RibbonOverrideService }],
|
|
@@ -23609,6 +24562,7 @@ let UniverUIPlugin = class UniverUIPlugin extends Plugin {
|
|
|
23609
24562
|
}],
|
|
23610
24563
|
[SharedController],
|
|
23611
24564
|
[ErrorController],
|
|
24565
|
+
[FeatureSearchController],
|
|
23612
24566
|
[ShortcutPanelController]
|
|
23613
24567
|
], this._config.override));
|
|
23614
24568
|
touchDependencies(this._injector, [
|
|
@@ -23618,7 +24572,7 @@ let UniverUIPlugin = class UniverUIPlugin extends Plugin {
|
|
|
23618
24572
|
]);
|
|
23619
24573
|
}
|
|
23620
24574
|
onReady() {
|
|
23621
|
-
touchDependencies(this._injector, [[SharedController]]);
|
|
24575
|
+
touchDependencies(this._injector, [[SharedController], [FeatureSearchController]]);
|
|
23622
24576
|
}
|
|
23623
24577
|
onSteady() {
|
|
23624
24578
|
touchDependencies(this._injector, [[ShortcutPanelController]]);
|
|
@@ -23784,8 +24738,10 @@ function handleStringToStyle($dom, cssStyle = "") {
|
|
|
23784
24738
|
else styleList.bl = 0;
|
|
23785
24739
|
else if (key === "font-style") if (value === "italic") styleList.it = 1;
|
|
23786
24740
|
else styleList.it = 0;
|
|
23787
|
-
else if (key === "font-family")
|
|
23788
|
-
|
|
24741
|
+
else if (key === "font-family") {
|
|
24742
|
+
const fontFamily = extractFontFamily(textTrim(originStr));
|
|
24743
|
+
styleList.ff = fontFamily;
|
|
24744
|
+
} else if (key === "font-size") {
|
|
23789
24745
|
let fs = Number.parseInt(value);
|
|
23790
24746
|
if (cssText.indexOf("vertical-align") > -1 && (cssText.indexOf("sub") > -1 || cssText.indexOf("sup") > -1)) fs *= 2;
|
|
23791
24747
|
if (value.indexOf("px") !== -1) fs = getPtFontSizeByPx(Number.parseInt(value, 10));
|
|
@@ -24436,4 +25392,4 @@ function ProgressBar(props) {
|
|
|
24436
25392
|
}
|
|
24437
25393
|
|
|
24438
25394
|
//#endregion
|
|
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 };
|
|
25395
|
+
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_CHILD_UNIT_ID_ATTRIBUTE, 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, IWorkbenchService, IconManager, KeyCode, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileContextMenu, MockMessageService, NativeTextEditorShortcutBehavior, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonOverrideService, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SYMBOL_CATEGORIES, SYMBOL_PICKER_COMPONENT, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, SymbolPicker, ThemeSwitcherService, ToggleFullscreenOperation, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UIRuntimeScopeService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoShortcutItem, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, WorkbenchService, ZIndexManager, ZoomInput, connectDependencies, connectInjector, getAllEmojis, getDefaultRecentEmojis, getEmbedBoundaryOwner, getEmbedChildUnitId, 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 };
|