@univerjs/ui 1.0.0-alpha.5 → 1.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1092 -349
- 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/index.js +1092 -354
- 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/index.css +176 -6
- package/lib/index.js +1092 -354
- 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/index.d.ts +2 -3
- 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/shortcut/shortcut.service.d.ts +4 -1
- 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/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/index.js +13 -13
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +7 -7
package/lib/cjs/index.js
CHANGED
|
@@ -27,6 +27,7 @@ let _univerjs_icons = require("@univerjs/icons");
|
|
|
27
27
|
* limitations under the License.
|
|
28
28
|
*/
|
|
29
29
|
const EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
|
|
30
|
+
const EMBED_CHILD_UNIT_ID_ATTRIBUTE = "data-embed-child-unit-id";
|
|
30
31
|
function getEmbedBoundaryOwner(target) {
|
|
31
32
|
var _ref, _getAttributeValue;
|
|
32
33
|
if (!hasClosest(target)) return;
|
|
@@ -36,6 +37,12 @@ function getEmbedBoundaryOwner(target) {
|
|
|
36
37
|
function isEmbedBoundaryTarget(target) {
|
|
37
38
|
return hasClosest(target) && target.closest(`[${"data-embed-interaction-boundary-owner"}]`) != null;
|
|
38
39
|
}
|
|
40
|
+
function getEmbedChildUnitId(target) {
|
|
41
|
+
var _ref2, _getAttributeValue2;
|
|
42
|
+
if (!hasClosest(target)) return;
|
|
43
|
+
const childRuntime = target.closest(`[${EMBED_CHILD_UNIT_ID_ATTRIBUTE}]`);
|
|
44
|
+
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;
|
|
45
|
+
}
|
|
39
46
|
function keepInteractionInsideSameEmbedBoundary(event) {
|
|
40
47
|
const owner = getEmbedBoundaryOwner(event.currentTarget);
|
|
41
48
|
if (!owner) return;
|
|
@@ -458,12 +465,13 @@ var ZIndexManager = class {
|
|
|
458
465
|
//#region src/common/menu-hidden-observable.ts
|
|
459
466
|
function getMenuHiddenObservable(accessor, targetUniverType, matchUnitId, needHideUnitId) {
|
|
460
467
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
468
|
+
const getUnitType = (unitId) => _univerjs_core.SHEET_EDITOR_UNITS.includes(unitId) ? _univerjs_core.UniverInstanceType.UNIVER_SHEET : univerInstanceService.getUnitType(unitId);
|
|
461
469
|
return new rxjs.Observable((subscriber) => {
|
|
462
470
|
const subscription = univerInstanceService.focused$.subscribe((unitId) => {
|
|
463
471
|
if (unitId == null) return subscriber.next(true);
|
|
464
472
|
if (matchUnitId && matchUnitId !== unitId) return subscriber.next(true);
|
|
465
473
|
if (needHideUnitId && (Array.isArray(needHideUnitId) ? needHideUnitId.includes(unitId) : needHideUnitId === unitId)) return subscriber.next(true);
|
|
466
|
-
const univerType =
|
|
474
|
+
const univerType = getUnitType(unitId);
|
|
467
475
|
subscriber.next(univerType !== targetUniverType);
|
|
468
476
|
});
|
|
469
477
|
const focusedUniverInstance = univerInstanceService.getFocusedUnit();
|
|
@@ -471,7 +479,7 @@ function getMenuHiddenObservable(accessor, targetUniverType, matchUnitId, needHi
|
|
|
471
479
|
const currentUnit = univerInstanceService.getCurrentUnitOfType(targetUniverType);
|
|
472
480
|
subscriber.next(currentUnit == null);
|
|
473
481
|
} else {
|
|
474
|
-
const univerType =
|
|
482
|
+
const univerType = getUnitType(focusedUniverInstance.getUnitId());
|
|
475
483
|
subscriber.next(univerType !== targetUniverType);
|
|
476
484
|
}
|
|
477
485
|
return () => subscription.unsubscribe();
|
|
@@ -830,6 +838,25 @@ var PlatformService = class {
|
|
|
830
838
|
}
|
|
831
839
|
};
|
|
832
840
|
|
|
841
|
+
//#endregion
|
|
842
|
+
//#region src/services/runtime-scope/ui-runtime-scope.service.ts
|
|
843
|
+
const IUIRuntimeScopeService = (0, _univerjs_core.createIdentifier)("ui.runtime-scope.service");
|
|
844
|
+
var UIRuntimeScopeService = class extends _univerjs_core.Disposable {
|
|
845
|
+
constructor(..._args) {
|
|
846
|
+
super(..._args);
|
|
847
|
+
_defineProperty(this, "_scopes", /* @__PURE__ */ new Map());
|
|
848
|
+
}
|
|
849
|
+
register(scope) {
|
|
850
|
+
this._scopes.set(scope.unitId, scope);
|
|
851
|
+
return (0, _univerjs_core.toDisposable)(() => {
|
|
852
|
+
if (this._scopes.get(scope.unitId) === scope) this._scopes.delete(scope.unitId);
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
get(unitId) {
|
|
856
|
+
return unitId ? this._scopes.get(unitId) : void 0;
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
|
|
833
860
|
//#endregion
|
|
834
861
|
//#region src/services/shortcut/shortcut.service.ts
|
|
835
862
|
/**
|
|
@@ -837,11 +864,12 @@ var PlatformService = class {
|
|
|
837
864
|
*/
|
|
838
865
|
const IShortcutService = (0, _univerjs_core.createIdentifier)("ui.shortcut.service");
|
|
839
866
|
let ShortcutService = class ShortcutService extends _univerjs_core.Disposable {
|
|
840
|
-
constructor(_commandService, _platformService, _contextService, _layoutService) {
|
|
867
|
+
constructor(_commandService, _platformService, _contextService, _runtimeScopeService, _layoutService) {
|
|
841
868
|
super();
|
|
842
869
|
this._commandService = _commandService;
|
|
843
870
|
this._platformService = _platformService;
|
|
844
871
|
this._contextService = _contextService;
|
|
872
|
+
this._runtimeScopeService = _runtimeScopeService;
|
|
845
873
|
this._layoutService = _layoutService;
|
|
846
874
|
_defineProperty(this, "_shortCutMapping", /* @__PURE__ */ new Map());
|
|
847
875
|
_defineProperty(this, "_commandIDMapping", /* @__PURE__ */ new Map());
|
|
@@ -911,11 +939,13 @@ let ShortcutService = class ShortcutService extends _univerjs_core.Disposable {
|
|
|
911
939
|
_resolveKeyboardEvent(e) {
|
|
912
940
|
const candidate = this.dispatch(e);
|
|
913
941
|
if (candidate) {
|
|
914
|
-
|
|
942
|
+
var _this$_getRuntimeServ, _this$_getRuntimeServ2;
|
|
943
|
+
(_this$_getRuntimeServ = (_this$_getRuntimeServ2 = this._getRuntimeService(e, _univerjs_core.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);
|
|
915
944
|
e.preventDefault();
|
|
916
945
|
}
|
|
917
946
|
}
|
|
918
947
|
dispatch(e) {
|
|
948
|
+
var _this$_getRuntimeServ3;
|
|
919
949
|
if (this._forceEscaped || this._forceDisabled) return;
|
|
920
950
|
if (this._layoutService && !this._layoutService.checkElementInCurrentContainers(e.target)) return;
|
|
921
951
|
const binding = this._deriveBindingFromEvent(e);
|
|
@@ -923,12 +953,13 @@ let ShortcutService = class ShortcutService extends _univerjs_core.Disposable {
|
|
|
923
953
|
if (this._shouldLetEmbedTextEditorHandleNativeShortcut(e, binding)) return;
|
|
924
954
|
const shortcuts = this._shortCutMapping.get(binding);
|
|
925
955
|
if (shortcuts === void 0) return;
|
|
956
|
+
const contextService = (_this$_getRuntimeServ3 = this._getRuntimeService(e, _univerjs_core.IContextService)) !== null && _this$_getRuntimeServ3 !== void 0 ? _this$_getRuntimeServ3 : this._contextService;
|
|
926
957
|
return Array.from(shortcuts).sort((s1, s2) => {
|
|
927
958
|
var _s2$priority, _s1$priority;
|
|
928
959
|
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);
|
|
929
960
|
}).find((s) => {
|
|
930
961
|
var _s$preconditions, _s$preconditions2;
|
|
931
|
-
return (_s$preconditions = (_s$preconditions2 = s.preconditions) === null || _s$preconditions2 === void 0 ? void 0 : _s$preconditions2.call(s,
|
|
962
|
+
return (_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;
|
|
932
963
|
});
|
|
933
964
|
}
|
|
934
965
|
_getBindingFromItem(item) {
|
|
@@ -952,12 +983,18 @@ let ShortcutService = class ShortcutService extends _univerjs_core.Disposable {
|
|
|
952
983
|
if (!(target instanceof HTMLElement)) return false;
|
|
953
984
|
return (target.isContentEditable || target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) && isEmbedBoundaryTarget(target);
|
|
954
985
|
}
|
|
986
|
+
_getRuntimeService(event, identifier) {
|
|
987
|
+
const childUnitId = getEmbedChildUnitId(event.target);
|
|
988
|
+
const runtimeScope = this._runtimeScopeService.get(childUnitId);
|
|
989
|
+
return (runtimeScope === null || runtimeScope === void 0 ? void 0 : runtimeScope.has(identifier)) ? runtimeScope.get(identifier) : void 0;
|
|
990
|
+
}
|
|
955
991
|
};
|
|
956
992
|
ShortcutService = __decorate([
|
|
957
993
|
__decorateParam(0, _univerjs_core.ICommandService),
|
|
958
994
|
__decorateParam(1, IPlatformService),
|
|
959
995
|
__decorateParam(2, _univerjs_core.IContextService),
|
|
960
|
-
__decorateParam(3,
|
|
996
|
+
__decorateParam(3, IUIRuntimeScopeService),
|
|
997
|
+
__decorateParam(4, (0, _univerjs_core.Optional)(ILayoutService))
|
|
961
998
|
], ShortcutService);
|
|
962
999
|
|
|
963
1000
|
//#endregion
|
|
@@ -1073,6 +1110,7 @@ let RibbonStartGroup = /* @__PURE__ */ function(RibbonStartGroup) {
|
|
|
1073
1110
|
RibbonStartGroup["HISTORY"] = "ribbon.start.history";
|
|
1074
1111
|
RibbonStartGroup["FORMAT"] = "ribbon.start.format";
|
|
1075
1112
|
RibbonStartGroup["LAYOUT"] = "ribbon.start.layout";
|
|
1113
|
+
RibbonStartGroup["NUMBER"] = "ribbon.start.number";
|
|
1076
1114
|
RibbonStartGroup["OTHERS"] = "ribbon.start.others";
|
|
1077
1115
|
return RibbonStartGroup;
|
|
1078
1116
|
}({});
|
|
@@ -1151,7 +1189,8 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
|
|
|
1151
1189
|
["ribbon.start.history"]: { order: 0 },
|
|
1152
1190
|
["ribbon.start.format"]: { order: 1 },
|
|
1153
1191
|
["ribbon.start.layout"]: { order: 2 },
|
|
1154
|
-
["ribbon.start.
|
|
1192
|
+
["ribbon.start.number"]: { order: 3 },
|
|
1193
|
+
["ribbon.start.others"]: { order: 4 }
|
|
1155
1194
|
},
|
|
1156
1195
|
["ribbon.insert"]: {
|
|
1157
1196
|
order: 1,
|
|
@@ -1299,7 +1338,8 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
|
|
|
1299
1338
|
quickLayout: value.quickLayout,
|
|
1300
1339
|
quickColumns: value.quickColumns,
|
|
1301
1340
|
quickLayoutVariant: value.quickLayoutVariant,
|
|
1302
|
-
tiny: value.tiny
|
|
1341
|
+
tiny: value.tiny,
|
|
1342
|
+
gridLayout: value.gridLayout
|
|
1303
1343
|
};
|
|
1304
1344
|
if (value.menuItemFactory) {
|
|
1305
1345
|
const item = this._injector.invoke(value.menuItemFactory);
|
|
@@ -1410,6 +1450,10 @@ ShortcutPanelController = __decorate([
|
|
|
1410
1450
|
__decorateParam(2, _univerjs_core.ICommandService)
|
|
1411
1451
|
], ShortcutPanelController);
|
|
1412
1452
|
|
|
1453
|
+
//#endregion
|
|
1454
|
+
//#region src/services/dialog/dialog.service.ts
|
|
1455
|
+
const IDialogService = (0, _univerjs_core.createIdentifier)("univer.ui.dialog-service");
|
|
1456
|
+
|
|
1413
1457
|
//#endregion
|
|
1414
1458
|
//#region src/services/menu/menu.ts
|
|
1415
1459
|
let MenuItemType = /* @__PURE__ */ function(MenuItemType) {
|
|
@@ -1428,7 +1472,372 @@ function isMenuButtonSelectorItem(v) {
|
|
|
1428
1472
|
}
|
|
1429
1473
|
|
|
1430
1474
|
//#endregion
|
|
1431
|
-
//#region src/
|
|
1475
|
+
//#region src/services/ribbon/ribbon.service.ts
|
|
1476
|
+
const IRibbonService = (0, _univerjs_core.createIdentifier)("univer.ribbon-service");
|
|
1477
|
+
function isSameHiddenMap(previous, current) {
|
|
1478
|
+
return previous.length === current.length && previous.every((hidden, index) => hidden === current[index]);
|
|
1479
|
+
}
|
|
1480
|
+
let DesktopRibbonService = class DesktopRibbonService extends _univerjs_core.Disposable {
|
|
1481
|
+
constructor(_menuManagerService, _univerInstanceService) {
|
|
1482
|
+
super();
|
|
1483
|
+
this._menuManagerService = _menuManagerService;
|
|
1484
|
+
this._univerInstanceService = _univerInstanceService;
|
|
1485
|
+
_defineProperty(this, "_ribbon$", new rxjs.BehaviorSubject([]));
|
|
1486
|
+
_defineProperty(this, "ribbon$", this._ribbon$.asObservable());
|
|
1487
|
+
_defineProperty(this, "_activatedTab$", new rxjs.BehaviorSubject("ribbon.start"));
|
|
1488
|
+
_defineProperty(this, "activatedTab$", this._activatedTab$.asObservable());
|
|
1489
|
+
_defineProperty(this, "_collapsedIds$", new rxjs.BehaviorSubject([]));
|
|
1490
|
+
_defineProperty(this, "collapsedIds$", this._collapsedIds$.asObservable());
|
|
1491
|
+
_defineProperty(this, "_fakeToolbarVisible$", new rxjs.BehaviorSubject(false));
|
|
1492
|
+
_defineProperty(this, "fakeToolbarVisible$", this._fakeToolbarVisible$.asObservable());
|
|
1493
|
+
_defineProperty(this, "_visibleContextualTabs", /* @__PURE__ */ new Set());
|
|
1494
|
+
_defineProperty(this, "_contextualTabs", /* @__PURE__ */ new Set());
|
|
1495
|
+
_defineProperty(this, "_lastNonContextualActivatedTab", "ribbon.start");
|
|
1496
|
+
_defineProperty(this, "_hiddenSubscription", null);
|
|
1497
|
+
this._initRibbonSubscription();
|
|
1498
|
+
}
|
|
1499
|
+
setActivatedTab(tab) {
|
|
1500
|
+
if (!this._isContextualTab(tab)) this._lastNonContextualActivatedTab = tab;
|
|
1501
|
+
this._activatedTab$.next(tab);
|
|
1502
|
+
}
|
|
1503
|
+
showContextualTab(tab, options) {
|
|
1504
|
+
this._visibleContextualTabs.add(tab);
|
|
1505
|
+
this._updateRibbon();
|
|
1506
|
+
if (options === null || options === void 0 ? void 0 : options.activate) this.setActivatedTab(tab);
|
|
1507
|
+
}
|
|
1508
|
+
hideContextualTab(tab) {
|
|
1509
|
+
if (!this._visibleContextualTabs.delete(tab)) return;
|
|
1510
|
+
this._updateRibbon();
|
|
1511
|
+
}
|
|
1512
|
+
hideAllContextualTabs() {
|
|
1513
|
+
if (this._visibleContextualTabs.size === 0) return;
|
|
1514
|
+
this._visibleContextualTabs.clear();
|
|
1515
|
+
this._updateRibbon();
|
|
1516
|
+
}
|
|
1517
|
+
setCollapsedIds(ids) {
|
|
1518
|
+
this._collapsedIds$.next(ids);
|
|
1519
|
+
}
|
|
1520
|
+
setFakeToolbarVisible(visible) {
|
|
1521
|
+
this._fakeToolbarVisible$.next(visible);
|
|
1522
|
+
}
|
|
1523
|
+
_initRibbonSubscription() {
|
|
1524
|
+
this.disposeWithMe((0, rxjs.combineLatest)([this._menuManagerService.menuChanged$.pipe((0, rxjs_operators.startWith)(void 0)), this._univerInstanceService.focused$.pipe((0, rxjs_operators.startWith)(void 0), (0, rxjs_operators.distinctUntilChanged)())]).subscribe(() => {
|
|
1525
|
+
this._updateRibbon();
|
|
1526
|
+
}));
|
|
1527
|
+
}
|
|
1528
|
+
_updateRibbon() {
|
|
1529
|
+
var _this$_hiddenSubscrip;
|
|
1530
|
+
const ribbon = this._filterContextualTabs(this._menuManagerService.getMenuByPositionKey("ribbon"));
|
|
1531
|
+
const hiddenObservableMap = [];
|
|
1532
|
+
const hiddenKeyMap = [];
|
|
1533
|
+
for (const group of ribbon) if (group.children) {
|
|
1534
|
+
for (const item of group.children) if (item.children) for (const child of item.children) {
|
|
1535
|
+
var _child$item;
|
|
1536
|
+
if ((_child$item = child.item) === null || _child$item === void 0 ? void 0 : _child$item.hidden$) {
|
|
1537
|
+
hiddenObservableMap.push(child.item.hidden$);
|
|
1538
|
+
hiddenKeyMap.push(child.key);
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
(_this$_hiddenSubscrip = this._hiddenSubscription) === null || _this$_hiddenSubscrip === void 0 || _this$_hiddenSubscrip.unsubscribe();
|
|
1543
|
+
this._hiddenSubscription = null;
|
|
1544
|
+
if (hiddenObservableMap.length === 0) {
|
|
1545
|
+
this._setRibbon(ribbon);
|
|
1546
|
+
return;
|
|
1547
|
+
}
|
|
1548
|
+
this._hiddenSubscription = (0, rxjs.combineLatest)(hiddenObservableMap.map((hidden$) => hidden$.pipe((0, rxjs_operators.startWith)(false)))).pipe((0, rxjs_operators.distinctUntilChanged)(isSameHiddenMap)).subscribe((hiddenMap) => {
|
|
1549
|
+
const newRibbon = [];
|
|
1550
|
+
const hiddenPathMap = hiddenMap.map((hidden, index) => {
|
|
1551
|
+
if (hidden) return hiddenKeyMap[index];
|
|
1552
|
+
return null;
|
|
1553
|
+
}).filter((item) => !!item);
|
|
1554
|
+
for (const group of ribbon) {
|
|
1555
|
+
var _group$children, _newGroup$children2;
|
|
1556
|
+
const newGroup = {
|
|
1557
|
+
...group,
|
|
1558
|
+
children: []
|
|
1559
|
+
};
|
|
1560
|
+
if ((_group$children = group.children) === null || _group$children === void 0 ? void 0 : _group$children.length) for (const item of group.children) {
|
|
1561
|
+
var _item$children;
|
|
1562
|
+
const newItem = {
|
|
1563
|
+
...item,
|
|
1564
|
+
children: []
|
|
1565
|
+
};
|
|
1566
|
+
let shouldAddItem = true;
|
|
1567
|
+
if ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) {
|
|
1568
|
+
var _newItem$children2;
|
|
1569
|
+
for (const child of item.children) if (!hiddenPathMap.includes(child.key)) {
|
|
1570
|
+
var _newItem$children;
|
|
1571
|
+
(_newItem$children = newItem.children) === null || _newItem$children === void 0 || _newItem$children.push(child);
|
|
1572
|
+
}
|
|
1573
|
+
if ((_newItem$children2 = newItem.children) === null || _newItem$children2 === void 0 ? void 0 : _newItem$children2.every((child) => {
|
|
1574
|
+
var _child$children;
|
|
1575
|
+
return ((_child$children = child.children) === null || _child$children === void 0 ? void 0 : _child$children.length) === 0;
|
|
1576
|
+
})) shouldAddItem = false;
|
|
1577
|
+
}
|
|
1578
|
+
if (shouldAddItem) {
|
|
1579
|
+
var _newGroup$children;
|
|
1580
|
+
(_newGroup$children = newGroup.children) === null || _newGroup$children === void 0 || _newGroup$children.push(newItem);
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
if (((_newGroup$children2 = newGroup.children) === null || _newGroup$children2 === void 0 ? void 0 : _newGroup$children2.length) && newGroup.children.every((item) => {
|
|
1584
|
+
var _item$children2;
|
|
1585
|
+
return (_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.length;
|
|
1586
|
+
})) newRibbon.push(newGroup);
|
|
1587
|
+
}
|
|
1588
|
+
this._setRibbon(newRibbon);
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
_filterContextualTabs(ribbon) {
|
|
1592
|
+
this._contextualTabs.clear();
|
|
1593
|
+
ribbon.forEach((group) => {
|
|
1594
|
+
if (group.contextual) this._contextualTabs.add(group.key);
|
|
1595
|
+
});
|
|
1596
|
+
return ribbon.filter((group) => !group.contextual || this._visibleContextualTabs.has(group.key));
|
|
1597
|
+
}
|
|
1598
|
+
_setRibbon(ribbon) {
|
|
1599
|
+
const activatedTab = this._activatedTab$.getValue();
|
|
1600
|
+
const activeGroup = ribbon.find((group) => group.key === activatedTab);
|
|
1601
|
+
if (!activeGroup && this._contextualTabs.has(activatedTab)) {
|
|
1602
|
+
var _ref, _ribbon$find;
|
|
1603
|
+
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];
|
|
1604
|
+
if (fallbackTab) this._activatedTab$.next(fallbackTab.key);
|
|
1605
|
+
} else if (!activeGroup && ribbon.some((group) => group.key === "ribbon.start")) {
|
|
1606
|
+
const fallbackTab = ribbon.find((group) => group.key === "ribbon.start");
|
|
1607
|
+
this._activatedTab$.next(fallbackTab.key);
|
|
1608
|
+
if (!fallbackTab.contextual) this._lastNonContextualActivatedTab = fallbackTab.key;
|
|
1609
|
+
} else if (activeGroup && !activeGroup.contextual) this._lastNonContextualActivatedTab = activeGroup.key;
|
|
1610
|
+
this._ribbon$.next(ribbon);
|
|
1611
|
+
}
|
|
1612
|
+
_isContextualTab(tab) {
|
|
1613
|
+
return this._contextualTabs.has(tab) || this._ribbon$.getValue().some((group) => group.key === tab && group.contextual);
|
|
1614
|
+
}
|
|
1615
|
+
dispose() {
|
|
1616
|
+
var _this$_hiddenSubscrip2;
|
|
1617
|
+
(_this$_hiddenSubscrip2 = this._hiddenSubscription) === null || _this$_hiddenSubscrip2 === void 0 || _this$_hiddenSubscrip2.unsubscribe();
|
|
1618
|
+
this._hiddenSubscription = null;
|
|
1619
|
+
this._ribbon$.next([]);
|
|
1620
|
+
this._ribbon$.complete();
|
|
1621
|
+
this._activatedTab$.complete();
|
|
1622
|
+
this._collapsedIds$.complete();
|
|
1623
|
+
this._fakeToolbarVisible$.complete();
|
|
1624
|
+
super.dispose();
|
|
1625
|
+
}
|
|
1626
|
+
};
|
|
1627
|
+
DesktopRibbonService = __decorate([__decorateParam(0, IMenuManagerService), __decorateParam(1, _univerjs_core.IUniverInstanceService)], DesktopRibbonService);
|
|
1628
|
+
|
|
1629
|
+
//#endregion
|
|
1630
|
+
//#region src/utils/di.ts
|
|
1631
|
+
function unwrap(o) {
|
|
1632
|
+
if (typeof o === "function") return o();
|
|
1633
|
+
return o;
|
|
1634
|
+
}
|
|
1635
|
+
function useObservableRef(observable, defaultValue) {
|
|
1636
|
+
const ref = (0, react.useRef)(defaultValue);
|
|
1637
|
+
(0, react.useEffect)(() => {
|
|
1638
|
+
if (observable) {
|
|
1639
|
+
const sub = unwrap(observable).subscribe((value) => {
|
|
1640
|
+
ref.current = value;
|
|
1641
|
+
});
|
|
1642
|
+
return () => sub.unsubscribe();
|
|
1643
|
+
}
|
|
1644
|
+
}, [observable]);
|
|
1645
|
+
return ref;
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
//#endregion
|
|
1649
|
+
//#region src/views/components/feature-search/FeatureSearch.tsx
|
|
1650
|
+
const FEATURE_SEARCH_COMPONENT = "FeatureSearch";
|
|
1651
|
+
const FEATURE_SEARCH_DIALOG_ID = "FEATURE_SEARCH_DIALOG";
|
|
1652
|
+
function resolveParams(item, value) {
|
|
1653
|
+
const params = typeof item.params === "function" ? item.params() : item.params;
|
|
1654
|
+
return params !== null && params !== void 0 ? params : value === void 0 ? void 0 : { value };
|
|
1655
|
+
}
|
|
1656
|
+
function resolveOptionParams(option) {
|
|
1657
|
+
const params = typeof option.params === "function" ? option.params(option.value) : option.params;
|
|
1658
|
+
return params !== null && params !== void 0 ? params : option.value === void 0 ? void 0 : { value: option.value };
|
|
1659
|
+
}
|
|
1660
|
+
function deduplicate(items) {
|
|
1661
|
+
return items.filter((item, index) => items.findIndex((candidate) => candidate.commandId === item.commandId && _univerjs_core.Tools.diffValue(candidate.params, item.params)) === index);
|
|
1662
|
+
}
|
|
1663
|
+
function FeatureSearch() {
|
|
1664
|
+
const menuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
|
|
1665
|
+
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
1666
|
+
const commandService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ICommandService);
|
|
1667
|
+
const dialogService = (0, _wendellhu_redi_react_bindings.useDependency)(IDialogService);
|
|
1668
|
+
const layoutService = (0, _wendellhu_redi_react_bindings.useDependency)(ILayoutService);
|
|
1669
|
+
const ribbonService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonService);
|
|
1670
|
+
const items = (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => {
|
|
1671
|
+
function getItemTitle(item) {
|
|
1672
|
+
var _ref, _item$title;
|
|
1673
|
+
const titleKey = (_ref = (_item$title = item.title) !== null && _item$title !== void 0 ? _item$title : item.tooltip) !== null && _ref !== void 0 ? _ref : item.description;
|
|
1674
|
+
return titleKey ? localeService.t(titleKey) : "";
|
|
1675
|
+
}
|
|
1676
|
+
function collectCandidates(schemas, path, keyPath, ancestors = [], parentTitle) {
|
|
1677
|
+
return schemas.flatMap((schema, index) => {
|
|
1678
|
+
var _schema$title;
|
|
1679
|
+
const schemaTitle = localeService.t((_schema$title = schema.title) !== null && _schema$title !== void 0 ? _schema$title : "");
|
|
1680
|
+
const schemaPath = schemaTitle ? [...path, schemaTitle] : path;
|
|
1681
|
+
const schemaKeyPath = [...keyPath, `${schema.key}:${index}`];
|
|
1682
|
+
const result = [];
|
|
1683
|
+
if (schema.item) result.push({
|
|
1684
|
+
key: `${schemaKeyPath.join("/")}:item`,
|
|
1685
|
+
item: schema.item,
|
|
1686
|
+
path: schemaPath,
|
|
1687
|
+
ancestors,
|
|
1688
|
+
parentTitle
|
|
1689
|
+
});
|
|
1690
|
+
if (schema.headerActionItem) result.push({
|
|
1691
|
+
key: `${schemaKeyPath.join("/")}:header`,
|
|
1692
|
+
item: schema.headerActionItem,
|
|
1693
|
+
path: schemaPath,
|
|
1694
|
+
ancestors,
|
|
1695
|
+
parentTitle
|
|
1696
|
+
});
|
|
1697
|
+
if (schema.children) result.push(...collectCandidates(schema.children, schemaPath, schemaKeyPath, schema.item ? [...ancestors, schema.item] : ancestors, schema.item ? getItemTitle(schema.item) : parentTitle));
|
|
1698
|
+
return result;
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
function observeCandidate(candidate) {
|
|
1702
|
+
var _item$hidden$$pipe, _item$hidden$, _item$disabled$$pipe, _item$disabled$, _item$value$$pipe, _item$value$;
|
|
1703
|
+
const { item } = candidate;
|
|
1704
|
+
const hasOptions = item.type === 1 || item.type === 2;
|
|
1705
|
+
const selections = hasOptions ? item.selections : void 0;
|
|
1706
|
+
const selections$ = (0, rxjs.isObservable)(selections) ? selections.pipe((0, rxjs_operators.startWith)([])) : (0, rxjs.of)(selections !== null && selections !== void 0 ? selections : []);
|
|
1707
|
+
return (0, rxjs.combineLatest)([
|
|
1708
|
+
candidate.ancestors.length ? (0, rxjs.combineLatest)(candidate.ancestors.map((ancestor) => {
|
|
1709
|
+
var _ancestor$hidden$$pip, _ancestor$hidden$;
|
|
1710
|
+
return (_ancestor$hidden$$pip = (_ancestor$hidden$ = ancestor.hidden$) === null || _ancestor$hidden$ === void 0 ? void 0 : _ancestor$hidden$.pipe((0, rxjs_operators.startWith)(true))) !== null && _ancestor$hidden$$pip !== void 0 ? _ancestor$hidden$$pip : (0, rxjs.of)(false);
|
|
1711
|
+
})).pipe((0, rxjs_operators.map)((states) => states.some(Boolean))) : (0, rxjs.of)(false),
|
|
1712
|
+
candidate.ancestors.length ? (0, rxjs.combineLatest)(candidate.ancestors.map((ancestor) => {
|
|
1713
|
+
var _ancestor$disabled$$p, _ancestor$disabled$;
|
|
1714
|
+
return (_ancestor$disabled$$p = (_ancestor$disabled$ = ancestor.disabled$) === null || _ancestor$disabled$ === void 0 ? void 0 : _ancestor$disabled$.pipe((0, rxjs_operators.startWith)(true))) !== null && _ancestor$disabled$$p !== void 0 ? _ancestor$disabled$$p : (0, rxjs.of)(false);
|
|
1715
|
+
})).pipe((0, rxjs_operators.map)((states) => states.some(Boolean))) : (0, rxjs.of)(false),
|
|
1716
|
+
(_item$hidden$$pipe = (_item$hidden$ = item.hidden$) === null || _item$hidden$ === void 0 ? void 0 : _item$hidden$.pipe((0, rxjs_operators.startWith)(true))) !== null && _item$hidden$$pipe !== void 0 ? _item$hidden$$pipe : (0, rxjs.of)(false),
|
|
1717
|
+
(_item$disabled$$pipe = (_item$disabled$ = item.disabled$) === null || _item$disabled$ === void 0 ? void 0 : _item$disabled$.pipe((0, rxjs_operators.startWith)(true))) !== null && _item$disabled$$pipe !== void 0 ? _item$disabled$$pipe : (0, rxjs.of)(false),
|
|
1718
|
+
(_item$value$$pipe = (_item$value$ = item.value$) === null || _item$value$ === void 0 ? void 0 : _item$value$.pipe((0, rxjs_operators.startWith)(void 0))) !== null && _item$value$$pipe !== void 0 ? _item$value$$pipe : (0, rxjs.of)(void 0),
|
|
1719
|
+
selections$
|
|
1720
|
+
]).pipe((0, rxjs_operators.map)(([ancestorHidden, ancestorDisabled, hidden, disabled, value, options]) => {
|
|
1721
|
+
if (ancestorHidden || ancestorDisabled || hidden || disabled) return [];
|
|
1722
|
+
const title = getItemTitle(item);
|
|
1723
|
+
const path = candidate.path.join(" / ");
|
|
1724
|
+
const result = [];
|
|
1725
|
+
if (title && item.type !== 1 && item.type !== 3) {
|
|
1726
|
+
var _item$description, _item$commandId;
|
|
1727
|
+
result.push({
|
|
1728
|
+
key: candidate.key,
|
|
1729
|
+
title,
|
|
1730
|
+
parentTitle: candidate.parentTitle,
|
|
1731
|
+
description: localeService.t((_item$description = item.description) !== null && _item$description !== void 0 ? _item$description : ""),
|
|
1732
|
+
path,
|
|
1733
|
+
commandId: (_item$commandId = item.commandId) !== null && _item$commandId !== void 0 ? _item$commandId : item.id,
|
|
1734
|
+
params: resolveParams(item, value),
|
|
1735
|
+
getParams: () => resolveParams(item, value)
|
|
1736
|
+
});
|
|
1737
|
+
}
|
|
1738
|
+
if (hasOptions) options.forEach((option, index) => {
|
|
1739
|
+
var _ref2, _ref3, _ref4, _option$commandId, _ref5, _ref6, _option$id;
|
|
1740
|
+
if (option.disabled || typeof option.label !== "string") return;
|
|
1741
|
+
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;
|
|
1742
|
+
result.push({
|
|
1743
|
+
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}`,
|
|
1744
|
+
title: localeService.t(option.label),
|
|
1745
|
+
parentTitle: title,
|
|
1746
|
+
description: "",
|
|
1747
|
+
path,
|
|
1748
|
+
commandId,
|
|
1749
|
+
params: resolveOptionParams(option),
|
|
1750
|
+
getParams: () => resolveOptionParams(option)
|
|
1751
|
+
});
|
|
1752
|
+
});
|
|
1753
|
+
return result;
|
|
1754
|
+
}));
|
|
1755
|
+
}
|
|
1756
|
+
return (0, rxjs.combineLatest)([ribbonService.ribbon$, (0, rxjs.merge)((0, rxjs.of)(void 0), menuManagerService.menuChanged$, localeService.localeChanged$)]).pipe((0, rxjs_operators.switchMap)(([ribbon]) => {
|
|
1757
|
+
const candidates = [...collectCandidates(ribbon, [localeService.t("ui.featureSearch.ribbon")], ["ribbon"]), ...collectCandidates(menuManagerService.getMenuByPositionKey("contextMenu"), [localeService.t("ui.featureSearch.contextMenu")], ["contextMenu"])];
|
|
1758
|
+
if (candidates.length === 0) return (0, rxjs.of)([]);
|
|
1759
|
+
return (0, rxjs.combineLatest)(candidates.map(observeCandidate)).pipe((0, rxjs_operators.map)((items) => deduplicate(items.flat())));
|
|
1760
|
+
}));
|
|
1761
|
+
}, [
|
|
1762
|
+
localeService,
|
|
1763
|
+
menuManagerService,
|
|
1764
|
+
ribbonService
|
|
1765
|
+
]), []);
|
|
1766
|
+
async function execute(item) {
|
|
1767
|
+
layoutService.focus();
|
|
1768
|
+
if (await commandService.executeCommand(item.commandId, item.getParams())) dialogService.close(FEATURE_SEARCH_DIALOG_ID);
|
|
1769
|
+
}
|
|
1770
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Command, {
|
|
1771
|
+
label: localeService.t("ui.featureSearch.title"),
|
|
1772
|
+
loop: true,
|
|
1773
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.CommandInput, {
|
|
1774
|
+
autoFocus: true,
|
|
1775
|
+
placeholder: localeService.t("ui.featureSearch.placeholder")
|
|
1776
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.CommandList, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.CommandEmpty, { children: localeService.t("ui.featureSearch.empty") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.CommandGroup, { children: items.map((item) => {
|
|
1777
|
+
var _item$parentTitle;
|
|
1778
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.CommandItem, {
|
|
1779
|
+
value: item.key,
|
|
1780
|
+
keywords: [
|
|
1781
|
+
(_item$parentTitle = item.parentTitle) !== null && _item$parentTitle !== void 0 ? _item$parentTitle : "",
|
|
1782
|
+
item.title,
|
|
1783
|
+
item.description,
|
|
1784
|
+
item.path
|
|
1785
|
+
],
|
|
1786
|
+
onSelect: () => execute(item),
|
|
1787
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1788
|
+
className: "univer-flex univer-min-w-0 univer-flex-1 univer-items-center univer-gap-1",
|
|
1789
|
+
children: [item.parentTitle && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1790
|
+
className: "univer-shrink-0",
|
|
1791
|
+
children: item.parentTitle
|
|
1792
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1793
|
+
className: "univer-text-gray-400",
|
|
1794
|
+
children: "/"
|
|
1795
|
+
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1796
|
+
className: "univer-truncate",
|
|
1797
|
+
children: item.title
|
|
1798
|
+
})]
|
|
1799
|
+
}), item.path && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1800
|
+
className: "univer-max-w-1/2 univer-truncate univer-text-xs univer-text-gray-400",
|
|
1801
|
+
children: item.path
|
|
1802
|
+
})]
|
|
1803
|
+
}, item.key);
|
|
1804
|
+
}) })] })]
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
//#endregion
|
|
1809
|
+
//#region src/commands/operations/open-feature-search.operation.ts
|
|
1810
|
+
const OpenFeatureSearchOperation = {
|
|
1811
|
+
id: "ui.operation.open-feature-search",
|
|
1812
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
1813
|
+
handler: (accessor) => {
|
|
1814
|
+
const dialogService = accessor.get(IDialogService);
|
|
1815
|
+
const localeService = accessor.get(_univerjs_core.LocaleService);
|
|
1816
|
+
dialogService.open({
|
|
1817
|
+
id: FEATURE_SEARCH_DIALOG_ID,
|
|
1818
|
+
width: 560,
|
|
1819
|
+
title: { title: localeService.t("ui.featureSearch.title") },
|
|
1820
|
+
children: { label: FEATURE_SEARCH_COMPONENT },
|
|
1821
|
+
onClose: () => dialogService.close(FEATURE_SEARCH_DIALOG_ID)
|
|
1822
|
+
});
|
|
1823
|
+
return true;
|
|
1824
|
+
}
|
|
1825
|
+
};
|
|
1826
|
+
|
|
1827
|
+
//#endregion
|
|
1828
|
+
//#region src/menu/feature-search.menu.ts
|
|
1829
|
+
function FeatureSearchMenuItemFactory() {
|
|
1830
|
+
return {
|
|
1831
|
+
id: OpenFeatureSearchOperation.id,
|
|
1832
|
+
title: "ui.featureSearch.title",
|
|
1833
|
+
tooltip: "ui.featureSearch.title",
|
|
1834
|
+
icon: "FeatureSearchIcon",
|
|
1835
|
+
type: 0
|
|
1836
|
+
};
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
//#endregion
|
|
1840
|
+
//#region src/menu/history.menu.ts
|
|
1432
1841
|
const undoRedoDisableFactory$ = (accessor, isUndo) => {
|
|
1433
1842
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
1434
1843
|
const contextService = accessor.get(_univerjs_core.IContextService);
|
|
@@ -1461,13 +1870,13 @@ function RedoMenuItemFactory(accessor) {
|
|
|
1461
1870
|
}
|
|
1462
1871
|
|
|
1463
1872
|
//#endregion
|
|
1464
|
-
//#region src/
|
|
1873
|
+
//#region src/menu/shortcut-panel.menu.ts
|
|
1465
1874
|
function ShortcutPanelMenuItemFactory() {
|
|
1466
1875
|
return {
|
|
1467
1876
|
id: ToggleShortcutPanelOperation.id,
|
|
1468
1877
|
title: "ui.toggle-shortcut-panel",
|
|
1469
1878
|
tooltip: "ui.toggle-shortcut-panel",
|
|
1470
|
-
icon: "
|
|
1879
|
+
icon: "KeyboardIcon",
|
|
1471
1880
|
type: 0
|
|
1472
1881
|
};
|
|
1473
1882
|
}
|
|
@@ -1478,17 +1887,33 @@ const menuSchema = {
|
|
|
1478
1887
|
["ribbon.start.history"]: {
|
|
1479
1888
|
[_univerjs_core.UndoCommand.id]: {
|
|
1480
1889
|
order: 0,
|
|
1890
|
+
gridLayout: {
|
|
1891
|
+
row: 1,
|
|
1892
|
+
column: 1,
|
|
1893
|
+
iconSize: 18
|
|
1894
|
+
},
|
|
1481
1895
|
menuItemFactory: UndoMenuItemFactory
|
|
1482
1896
|
},
|
|
1483
1897
|
[_univerjs_core.RedoCommand.id]: {
|
|
1484
1898
|
order: 1,
|
|
1899
|
+
gridLayout: {
|
|
1900
|
+
row: 2,
|
|
1901
|
+
column: 1,
|
|
1902
|
+
iconSize: 18
|
|
1903
|
+
},
|
|
1485
1904
|
menuItemFactory: RedoMenuItemFactory
|
|
1486
1905
|
}
|
|
1487
1906
|
},
|
|
1488
|
-
["ribbon.start.others"]: {
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1907
|
+
["ribbon.start.others"]: {
|
|
1908
|
+
[ToggleShortcutPanelOperation.id]: {
|
|
1909
|
+
order: 1,
|
|
1910
|
+
menuItemFactory: ShortcutPanelMenuItemFactory
|
|
1911
|
+
},
|
|
1912
|
+
[OpenFeatureSearchOperation.id]: {
|
|
1913
|
+
order: 2,
|
|
1914
|
+
menuItemFactory: FeatureSearchMenuItemFactory
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1492
1917
|
};
|
|
1493
1918
|
|
|
1494
1919
|
//#endregion
|
|
@@ -1553,25 +1978,6 @@ var UIPartsService = class extends _univerjs_core.Disposable {
|
|
|
1553
1978
|
}
|
|
1554
1979
|
};
|
|
1555
1980
|
|
|
1556
|
-
//#endregion
|
|
1557
|
-
//#region src/utils/di.ts
|
|
1558
|
-
function unwrap(o) {
|
|
1559
|
-
if (typeof o === "function") return o();
|
|
1560
|
-
return o;
|
|
1561
|
-
}
|
|
1562
|
-
function useObservableRef(observable, defaultValue) {
|
|
1563
|
-
const ref = (0, react.useRef)(defaultValue);
|
|
1564
|
-
(0, react.useEffect)(() => {
|
|
1565
|
-
if (observable) {
|
|
1566
|
-
const sub = unwrap(observable).subscribe((value) => {
|
|
1567
|
-
ref.current = value;
|
|
1568
|
-
});
|
|
1569
|
-
return () => sub.unsubscribe();
|
|
1570
|
-
}
|
|
1571
|
-
}, [observable]);
|
|
1572
|
-
return ref;
|
|
1573
|
-
}
|
|
1574
|
-
|
|
1575
1981
|
//#endregion
|
|
1576
1982
|
//#region src/services/dom/canvas-dom-layer.service.ts
|
|
1577
1983
|
function shouldForwardFloatDomEvents(layer) {
|
|
@@ -2168,160 +2574,6 @@ var RibbonOverrideService = class extends _univerjs_core.Disposable {
|
|
|
2168
2574
|
}
|
|
2169
2575
|
};
|
|
2170
2576
|
|
|
2171
|
-
//#endregion
|
|
2172
|
-
//#region src/services/ribbon/ribbon.service.ts
|
|
2173
|
-
const IRibbonService = (0, _univerjs_core.createIdentifier)("univer.ribbon-service");
|
|
2174
|
-
function isSameHiddenMap(previous, current) {
|
|
2175
|
-
return previous.length === current.length && previous.every((hidden, index) => hidden === current[index]);
|
|
2176
|
-
}
|
|
2177
|
-
let DesktopRibbonService = class DesktopRibbonService extends _univerjs_core.Disposable {
|
|
2178
|
-
constructor(_menuManagerService, _univerInstanceService) {
|
|
2179
|
-
super();
|
|
2180
|
-
this._menuManagerService = _menuManagerService;
|
|
2181
|
-
this._univerInstanceService = _univerInstanceService;
|
|
2182
|
-
_defineProperty(this, "_ribbon$", new rxjs.BehaviorSubject([]));
|
|
2183
|
-
_defineProperty(this, "ribbon$", this._ribbon$.asObservable());
|
|
2184
|
-
_defineProperty(this, "_activatedTab$", new rxjs.BehaviorSubject("ribbon.start"));
|
|
2185
|
-
_defineProperty(this, "activatedTab$", this._activatedTab$.asObservable());
|
|
2186
|
-
_defineProperty(this, "_collapsedIds$", new rxjs.BehaviorSubject([]));
|
|
2187
|
-
_defineProperty(this, "collapsedIds$", this._collapsedIds$.asObservable());
|
|
2188
|
-
_defineProperty(this, "_fakeToolbarVisible$", new rxjs.BehaviorSubject(false));
|
|
2189
|
-
_defineProperty(this, "fakeToolbarVisible$", this._fakeToolbarVisible$.asObservable());
|
|
2190
|
-
_defineProperty(this, "_visibleContextualTabs", /* @__PURE__ */ new Set());
|
|
2191
|
-
_defineProperty(this, "_contextualTabs", /* @__PURE__ */ new Set());
|
|
2192
|
-
_defineProperty(this, "_lastNonContextualActivatedTab", "ribbon.start");
|
|
2193
|
-
_defineProperty(this, "_hiddenSubscription", null);
|
|
2194
|
-
this._initRibbonSubscription();
|
|
2195
|
-
}
|
|
2196
|
-
setActivatedTab(tab) {
|
|
2197
|
-
if (!this._isContextualTab(tab)) this._lastNonContextualActivatedTab = tab;
|
|
2198
|
-
this._activatedTab$.next(tab);
|
|
2199
|
-
}
|
|
2200
|
-
showContextualTab(tab, options) {
|
|
2201
|
-
this._visibleContextualTabs.add(tab);
|
|
2202
|
-
this._updateRibbon();
|
|
2203
|
-
if (options === null || options === void 0 ? void 0 : options.activate) this.setActivatedTab(tab);
|
|
2204
|
-
}
|
|
2205
|
-
hideContextualTab(tab) {
|
|
2206
|
-
if (!this._visibleContextualTabs.delete(tab)) return;
|
|
2207
|
-
this._updateRibbon();
|
|
2208
|
-
}
|
|
2209
|
-
hideAllContextualTabs() {
|
|
2210
|
-
if (this._visibleContextualTabs.size === 0) return;
|
|
2211
|
-
this._visibleContextualTabs.clear();
|
|
2212
|
-
this._updateRibbon();
|
|
2213
|
-
}
|
|
2214
|
-
setCollapsedIds(ids) {
|
|
2215
|
-
this._collapsedIds$.next(ids);
|
|
2216
|
-
}
|
|
2217
|
-
setFakeToolbarVisible(visible) {
|
|
2218
|
-
this._fakeToolbarVisible$.next(visible);
|
|
2219
|
-
}
|
|
2220
|
-
_initRibbonSubscription() {
|
|
2221
|
-
this.disposeWithMe((0, rxjs.combineLatest)([this._menuManagerService.menuChanged$.pipe((0, rxjs_operators.startWith)(void 0)), this._univerInstanceService.focused$.pipe((0, rxjs_operators.startWith)(void 0), (0, rxjs_operators.distinctUntilChanged)())]).subscribe(() => {
|
|
2222
|
-
this._updateRibbon();
|
|
2223
|
-
}));
|
|
2224
|
-
}
|
|
2225
|
-
_updateRibbon() {
|
|
2226
|
-
var _this$_hiddenSubscrip;
|
|
2227
|
-
const ribbon = this._filterContextualTabs(this._menuManagerService.getMenuByPositionKey("ribbon"));
|
|
2228
|
-
const hiddenObservableMap = [];
|
|
2229
|
-
const hiddenKeyMap = [];
|
|
2230
|
-
for (const group of ribbon) if (group.children) {
|
|
2231
|
-
for (const item of group.children) if (item.children) for (const child of item.children) {
|
|
2232
|
-
var _child$item;
|
|
2233
|
-
if ((_child$item = child.item) === null || _child$item === void 0 ? void 0 : _child$item.hidden$) {
|
|
2234
|
-
hiddenObservableMap.push(child.item.hidden$);
|
|
2235
|
-
hiddenKeyMap.push(child.key);
|
|
2236
|
-
}
|
|
2237
|
-
}
|
|
2238
|
-
}
|
|
2239
|
-
if (hiddenObservableMap.length === 0) {
|
|
2240
|
-
this._setRibbon(ribbon);
|
|
2241
|
-
return;
|
|
2242
|
-
}
|
|
2243
|
-
(_this$_hiddenSubscrip = this._hiddenSubscription) === null || _this$_hiddenSubscrip === void 0 || _this$_hiddenSubscrip.unsubscribe();
|
|
2244
|
-
this._hiddenSubscription = (0, rxjs.combineLatest)(hiddenObservableMap).pipe((0, rxjs_operators.startWith)(new Array(hiddenObservableMap.length).fill(false)), (0, rxjs_operators.distinctUntilChanged)(isSameHiddenMap)).subscribe((hiddenMap) => {
|
|
2245
|
-
const newRibbon = [];
|
|
2246
|
-
const hiddenPathMap = hiddenMap.map((hidden, index) => {
|
|
2247
|
-
if (hidden) return hiddenKeyMap[index];
|
|
2248
|
-
return null;
|
|
2249
|
-
}).filter((item) => !!item);
|
|
2250
|
-
for (const group of ribbon) {
|
|
2251
|
-
var _group$children, _newGroup$children2;
|
|
2252
|
-
const newGroup = {
|
|
2253
|
-
...group,
|
|
2254
|
-
children: []
|
|
2255
|
-
};
|
|
2256
|
-
if ((_group$children = group.children) === null || _group$children === void 0 ? void 0 : _group$children.length) for (const item of group.children) {
|
|
2257
|
-
var _item$children;
|
|
2258
|
-
const newItem = {
|
|
2259
|
-
...item,
|
|
2260
|
-
children: []
|
|
2261
|
-
};
|
|
2262
|
-
let shouldAddItem = true;
|
|
2263
|
-
if ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) {
|
|
2264
|
-
var _newItem$children2;
|
|
2265
|
-
for (const child of item.children) if (!hiddenPathMap.includes(child.key)) {
|
|
2266
|
-
var _newItem$children;
|
|
2267
|
-
(_newItem$children = newItem.children) === null || _newItem$children === void 0 || _newItem$children.push(child);
|
|
2268
|
-
}
|
|
2269
|
-
if ((_newItem$children2 = newItem.children) === null || _newItem$children2 === void 0 ? void 0 : _newItem$children2.every((child) => {
|
|
2270
|
-
var _child$children;
|
|
2271
|
-
return ((_child$children = child.children) === null || _child$children === void 0 ? void 0 : _child$children.length) === 0;
|
|
2272
|
-
})) shouldAddItem = false;
|
|
2273
|
-
}
|
|
2274
|
-
if (shouldAddItem) {
|
|
2275
|
-
var _newGroup$children;
|
|
2276
|
-
(_newGroup$children = newGroup.children) === null || _newGroup$children === void 0 || _newGroup$children.push(newItem);
|
|
2277
|
-
}
|
|
2278
|
-
}
|
|
2279
|
-
if (((_newGroup$children2 = newGroup.children) === null || _newGroup$children2 === void 0 ? void 0 : _newGroup$children2.length) && newGroup.children.every((item) => {
|
|
2280
|
-
var _item$children2;
|
|
2281
|
-
return (_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.length;
|
|
2282
|
-
})) newRibbon.push(newGroup);
|
|
2283
|
-
}
|
|
2284
|
-
this._setRibbon(newRibbon);
|
|
2285
|
-
});
|
|
2286
|
-
}
|
|
2287
|
-
_filterContextualTabs(ribbon) {
|
|
2288
|
-
this._contextualTabs.clear();
|
|
2289
|
-
ribbon.forEach((group) => {
|
|
2290
|
-
if (group.contextual) this._contextualTabs.add(group.key);
|
|
2291
|
-
});
|
|
2292
|
-
return ribbon.filter((group) => !group.contextual || this._visibleContextualTabs.has(group.key));
|
|
2293
|
-
}
|
|
2294
|
-
_setRibbon(ribbon) {
|
|
2295
|
-
const activatedTab = this._activatedTab$.getValue();
|
|
2296
|
-
const activeGroup = ribbon.find((group) => group.key === activatedTab);
|
|
2297
|
-
if (!activeGroup && this._contextualTabs.has(activatedTab)) {
|
|
2298
|
-
var _ref, _ribbon$find;
|
|
2299
|
-
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];
|
|
2300
|
-
if (fallbackTab) this._activatedTab$.next(fallbackTab.key);
|
|
2301
|
-
} else if (!activeGroup && ribbon.some((group) => group.key === "ribbon.start")) {
|
|
2302
|
-
const fallbackTab = ribbon.find((group) => group.key === "ribbon.start");
|
|
2303
|
-
this._activatedTab$.next(fallbackTab.key);
|
|
2304
|
-
if (!fallbackTab.contextual) this._lastNonContextualActivatedTab = fallbackTab.key;
|
|
2305
|
-
} else if (activeGroup && !activeGroup.contextual) this._lastNonContextualActivatedTab = activeGroup.key;
|
|
2306
|
-
this._ribbon$.next(ribbon);
|
|
2307
|
-
}
|
|
2308
|
-
_isContextualTab(tab) {
|
|
2309
|
-
return this._contextualTabs.has(tab) || this._ribbon$.getValue().some((group) => group.key === tab && group.contextual);
|
|
2310
|
-
}
|
|
2311
|
-
dispose() {
|
|
2312
|
-
var _this$_hiddenSubscrip2;
|
|
2313
|
-
(_this$_hiddenSubscrip2 = this._hiddenSubscription) === null || _this$_hiddenSubscrip2 === void 0 || _this$_hiddenSubscrip2.unsubscribe();
|
|
2314
|
-
this._hiddenSubscription = null;
|
|
2315
|
-
this._ribbon$.next([]);
|
|
2316
|
-
this._ribbon$.complete();
|
|
2317
|
-
this._activatedTab$.complete();
|
|
2318
|
-
this._collapsedIds$.complete();
|
|
2319
|
-
this._fakeToolbarVisible$.complete();
|
|
2320
|
-
super.dispose();
|
|
2321
|
-
}
|
|
2322
|
-
};
|
|
2323
|
-
DesktopRibbonService = __decorate([__decorateParam(0, IMenuManagerService), __decorateParam(1, _univerjs_core.IUniverInstanceService)], DesktopRibbonService);
|
|
2324
|
-
|
|
2325
2577
|
//#endregion
|
|
2326
2578
|
//#region src/views/components/ComponentContainer.tsx
|
|
2327
2579
|
function ComponentContainer(props) {
|
|
@@ -2427,88 +2679,103 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
|
2427
2679
|
})
|
|
2428
2680
|
}),
|
|
2429
2681
|
onOpenChange: setGroupSelectorVisible,
|
|
2430
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
|
|
2431
|
-
className: "univer-mr-2 univer-flex univer-h-7 univer-cursor-pointer univer-items-center univer-gap-1.5 univer-whitespace-nowrap !univer-rounded-full univer-bg-gray-700 univer-pl-3 univer-pr-2 univer-text-sm univer-text-white dark:!univer-bg-gray-200 dark:!univer-text-gray-800",
|
|
2432
|
-
onClick: () => setGroupSelectorVisible(true),
|
|
2433
|
-
children: [localeService.t(activatedTabTitle), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "univer-text-gray-200 dark:!univer-text-gray-500" })]
|
|
2434
|
-
})
|
|
2435
|
-
});
|
|
2436
|
-
}
|
|
2437
|
-
|
|
2438
|
-
//#endregion
|
|
2439
|
-
//#region src/views/components/ribbon/
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
univer-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2682
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
|
|
2683
|
+
className: "univer-mr-2 univer-flex univer-h-7 univer-cursor-pointer univer-items-center univer-gap-1.5 univer-whitespace-nowrap !univer-rounded-full univer-bg-gray-700 univer-pl-3 univer-pr-2 univer-text-sm univer-text-white dark:!univer-bg-gray-200 dark:!univer-text-gray-800",
|
|
2684
|
+
onClick: () => setGroupSelectorVisible(true),
|
|
2685
|
+
children: [localeService.t(activatedTabTitle), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "univer-text-gray-200 dark:!univer-text-gray-500" })]
|
|
2686
|
+
})
|
|
2687
|
+
});
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
//#endregion
|
|
2691
|
+
//#region src/views/components/ribbon/ribbon-menu/RibbonGridMenu.tsx
|
|
2692
|
+
function RibbonGridMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
2693
|
+
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
2694
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2695
|
+
"data-testid": "ribbon-grid-menu",
|
|
2696
|
+
"data-u-comp": "ribbon-grid-menu",
|
|
2697
|
+
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",
|
|
2698
|
+
role: "tablist",
|
|
2699
|
+
children: ribbon.map((group) => {
|
|
2700
|
+
const isActive = activatedTab === group.key;
|
|
2701
|
+
const title = localeService.t(group.title || group.key);
|
|
2702
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2703
|
+
type: "button",
|
|
2704
|
+
role: "tab",
|
|
2705
|
+
"aria-selected": isActive,
|
|
2706
|
+
title,
|
|
2707
|
+
onClick: () => onSelectTab(group),
|
|
2708
|
+
className: (0, _univerjs_design.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"),
|
|
2709
|
+
children: title
|
|
2710
|
+
}, group.key);
|
|
2711
|
+
})
|
|
2712
|
+
});
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
//#endregion
|
|
2716
|
+
//#region src/views/components/ribbon/ribbon-grid-layout.ts
|
|
2717
|
+
const RIBBON_GRID_ROWS = 2;
|
|
2718
|
+
function placeRibbonGridItems(items) {
|
|
2719
|
+
const occupied = /* @__PURE__ */ new Set();
|
|
2720
|
+
const placements = /* @__PURE__ */ new Map();
|
|
2721
|
+
const fallbackItems = [];
|
|
2722
|
+
let maxExplicitColumn = 0;
|
|
2723
|
+
for (const item of items) {
|
|
2724
|
+
var _layout$rowSpan, _layout$columnSpan, _layout$showLabel;
|
|
2725
|
+
const layout = item.gridLayout;
|
|
2726
|
+
if (!layout) {
|
|
2727
|
+
fallbackItems.push(item);
|
|
2728
|
+
continue;
|
|
2472
2729
|
}
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
/**
|
|
2480
|
-
* Button Component
|
|
2481
|
-
*/
|
|
2482
|
-
function ToolbarButton(props) {
|
|
2483
|
-
const { children, className, style, disabled = false, active = false, noIcon, onClick, onDoubleClick, ...restProps } = props;
|
|
2484
|
-
const handleClick = (e) => {
|
|
2485
|
-
if (disabled) {
|
|
2486
|
-
e.preventDefault();
|
|
2487
|
-
return;
|
|
2730
|
+
const rowSpan = (_layout$rowSpan = layout.rowSpan) !== null && _layout$rowSpan !== void 0 ? _layout$rowSpan : 1;
|
|
2731
|
+
const columnSpan = (_layout$columnSpan = layout.columnSpan) !== null && _layout$columnSpan !== void 0 ? _layout$columnSpan : 1;
|
|
2732
|
+
const cells = getCells(layout.row, layout.column, rowSpan, columnSpan);
|
|
2733
|
+
if (!(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) && cells.every((cell) => !occupied.has(cell)))) {
|
|
2734
|
+
fallbackItems.push(item);
|
|
2735
|
+
continue;
|
|
2488
2736
|
}
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2737
|
+
cells.forEach((cell) => occupied.add(cell));
|
|
2738
|
+
maxExplicitColumn = Math.max(maxExplicitColumn, layout.column + columnSpan - 1);
|
|
2739
|
+
placements.set(item, {
|
|
2740
|
+
item,
|
|
2741
|
+
row: layout.row,
|
|
2742
|
+
column: layout.column,
|
|
2743
|
+
rowSpan,
|
|
2744
|
+
columnSpan,
|
|
2745
|
+
showLabel: (_layout$showLabel = layout.showLabel) !== null && _layout$showLabel !== void 0 ? _layout$showLabel : false,
|
|
2746
|
+
width: layout.width,
|
|
2747
|
+
iconSize: layout.iconSize
|
|
2748
|
+
});
|
|
2749
|
+
}
|
|
2750
|
+
let fallbackRow = 1;
|
|
2751
|
+
let fallbackColumn = maxExplicitColumn + 1;
|
|
2752
|
+
for (const item of fallbackItems) {
|
|
2753
|
+
placements.set(item, {
|
|
2754
|
+
item,
|
|
2755
|
+
row: fallbackRow,
|
|
2756
|
+
column: fallbackColumn,
|
|
2757
|
+
rowSpan: 1,
|
|
2758
|
+
columnSpan: 1,
|
|
2759
|
+
showLabel: false
|
|
2760
|
+
});
|
|
2761
|
+
fallbackRow += 1;
|
|
2762
|
+
if (fallbackRow > RIBBON_GRID_ROWS) {
|
|
2763
|
+
fallbackRow = 1;
|
|
2764
|
+
fallbackColumn += 1;
|
|
2495
2765
|
}
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
...restProps,
|
|
2510
|
-
children
|
|
2511
|
-
});
|
|
2766
|
+
}
|
|
2767
|
+
return items.map((item) => placements.get(item));
|
|
2768
|
+
}
|
|
2769
|
+
function getCells(row, column, rowSpan, columnSpan) {
|
|
2770
|
+
if (![
|
|
2771
|
+
row,
|
|
2772
|
+
column,
|
|
2773
|
+
rowSpan,
|
|
2774
|
+
columnSpan
|
|
2775
|
+
].every(Number.isInteger) || Math.min(row, column, rowSpan, columnSpan) < 1) return [];
|
|
2776
|
+
const cells = [];
|
|
2777
|
+
for (let currentRow = row; currentRow < row + rowSpan; currentRow++) for (let currentColumn = column; currentColumn < column + columnSpan; currentColumn++) cells.push(`${currentRow}:${currentColumn}`);
|
|
2778
|
+
return cells;
|
|
2512
2779
|
}
|
|
2513
2780
|
|
|
2514
2781
|
//#endregion
|
|
@@ -2518,7 +2785,7 @@ function ToolbarButton(props) {
|
|
|
2518
2785
|
* @param props
|
|
2519
2786
|
*/
|
|
2520
2787
|
function CustomLabel(props) {
|
|
2521
|
-
const { className, title, icon, label, value, value$ } = props;
|
|
2788
|
+
const { className, iconSize, title, icon, label, value, value$ } = props;
|
|
2522
2789
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
2523
2790
|
const componentManager = (0, _wendellhu_redi_react_bindings.useDependency)(ComponentManager);
|
|
2524
2791
|
const iconManager = (0, _wendellhu_redi_react_bindings.useDependency)(IconManager);
|
|
@@ -2538,6 +2805,10 @@ function CustomLabel(props) {
|
|
|
2538
2805
|
const Icon = iconManager.get(realIcon);
|
|
2539
2806
|
if (Icon) nodes.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
2540
2807
|
className: "univer-text-base",
|
|
2808
|
+
style: iconSize ? {
|
|
2809
|
+
width: iconSize,
|
|
2810
|
+
height: iconSize
|
|
2811
|
+
} : void 0,
|
|
2541
2812
|
extend: { colorChannel1: isValid ? String(realValue) : "var(--univer-primary-600)" }
|
|
2542
2813
|
}, index++));
|
|
2543
2814
|
}
|
|
@@ -2608,6 +2879,82 @@ function useToolbarShortcutDisplay({ id, commandId, shortcut }) {
|
|
|
2608
2879
|
]), null, true);
|
|
2609
2880
|
}
|
|
2610
2881
|
|
|
2882
|
+
//#endregion
|
|
2883
|
+
//#region src/views/components/ribbon/ToolbarButton.tsx
|
|
2884
|
+
/**
|
|
2885
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
2886
|
+
*
|
|
2887
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2888
|
+
* you may not use this file except in compliance with the License.
|
|
2889
|
+
* You may obtain a copy of the License at
|
|
2890
|
+
*
|
|
2891
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2892
|
+
*
|
|
2893
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2894
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2895
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2896
|
+
* See the License for the specific language governing permissions and
|
|
2897
|
+
* limitations under the License.
|
|
2898
|
+
*/
|
|
2899
|
+
const toolbarButtonClassName = `
|
|
2900
|
+
univer-box-border univer-flex univer-h-6 univer-min-w-6 univer-cursor-pointer univer-items-center
|
|
2901
|
+
univer-justify-center univer-rounded univer-border-none univer-bg-transparent univer-p-0
|
|
2902
|
+
univer-text-gray-900 univer-outline-none univer-transition-colors univer-animate-in univer-fade-in
|
|
2903
|
+
dark:!univer-text-white dark:hover:!univer-bg-gray-700 dark:disabled:!univer-text-gray-600
|
|
2904
|
+
disabled:univer-cursor-not-allowed disabled:univer-text-gray-300 disabled:hover:univer-bg-transparent
|
|
2905
|
+
hover:univer-bg-gray-100 whitespace-nowrap univer-w-max
|
|
2906
|
+
`;
|
|
2907
|
+
const toolbarButtonVariants = (0, _univerjs_design.cva)(toolbarButtonClassName, {
|
|
2908
|
+
variants: {
|
|
2909
|
+
noIcon: {
|
|
2910
|
+
true: "univer-px-2",
|
|
2911
|
+
false: ""
|
|
2912
|
+
},
|
|
2913
|
+
active: {
|
|
2914
|
+
true: "!univer-bg-gray-200 dark:!univer-bg-gray-500",
|
|
2915
|
+
false: ""
|
|
2916
|
+
}
|
|
2917
|
+
},
|
|
2918
|
+
defaultVariants: {
|
|
2919
|
+
noIcon: false,
|
|
2920
|
+
active: false
|
|
2921
|
+
}
|
|
2922
|
+
});
|
|
2923
|
+
/**
|
|
2924
|
+
* Button Component
|
|
2925
|
+
*/
|
|
2926
|
+
function ToolbarButton(props) {
|
|
2927
|
+
const { children, className, style, disabled = false, active = false, noIcon, onClick, onDoubleClick, ...restProps } = props;
|
|
2928
|
+
const handleClick = (e) => {
|
|
2929
|
+
if (disabled) {
|
|
2930
|
+
e.preventDefault();
|
|
2931
|
+
return;
|
|
2932
|
+
}
|
|
2933
|
+
onClick && onClick(e);
|
|
2934
|
+
};
|
|
2935
|
+
const handleDoubleClick = (e) => {
|
|
2936
|
+
if (disabled) {
|
|
2937
|
+
e.preventDefault();
|
|
2938
|
+
return;
|
|
2939
|
+
}
|
|
2940
|
+
onDoubleClick && onDoubleClick(e);
|
|
2941
|
+
};
|
|
2942
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2943
|
+
type: "button",
|
|
2944
|
+
className: toolbarButtonVariants({
|
|
2945
|
+
noIcon,
|
|
2946
|
+
active,
|
|
2947
|
+
className
|
|
2948
|
+
}),
|
|
2949
|
+
style,
|
|
2950
|
+
disabled,
|
|
2951
|
+
onClick: handleClick,
|
|
2952
|
+
onDoubleClick: handleDoubleClick,
|
|
2953
|
+
...restProps,
|
|
2954
|
+
children
|
|
2955
|
+
});
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2611
2958
|
//#endregion
|
|
2612
2959
|
//#region src/views/components/ribbon/TooltipButtonWrapper.tsx
|
|
2613
2960
|
const TooltipWrapperContext = (0, react.createContext)({
|
|
@@ -2664,12 +3011,31 @@ const TooltipWrapper = (0, react.forwardRef)((props, ref) => {
|
|
|
2664
3011
|
function DropdownWrapper(props) {
|
|
2665
3012
|
const { children, overlay, disabled, align = "start" } = props;
|
|
2666
3013
|
const { dropdownVisible, setDropdownVisible } = (0, react.useContext)(TooltipWrapperContext);
|
|
3014
|
+
const triggerRef = (0, react.useRef)(null);
|
|
3015
|
+
const overlayRef = (0, react.useRef)(null);
|
|
3016
|
+
(0, react.useEffect)(() => {
|
|
3017
|
+
if (disabled) setDropdownVisible(false);
|
|
3018
|
+
}, [disabled, setDropdownVisible]);
|
|
3019
|
+
(0, react.useEffect)(() => {
|
|
3020
|
+
var _triggerRef$current;
|
|
3021
|
+
const ownerDocument = (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.ownerDocument;
|
|
3022
|
+
if (!dropdownVisible || !ownerDocument) return;
|
|
3023
|
+
const handlePointerDown = (event) => {
|
|
3024
|
+
var _triggerRef$current2, _overlayRef$current;
|
|
3025
|
+
const target = event.target;
|
|
3026
|
+
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;
|
|
3027
|
+
setDropdownVisible(false);
|
|
3028
|
+
};
|
|
3029
|
+
ownerDocument.addEventListener("pointerdown", handlePointerDown, true);
|
|
3030
|
+
return () => ownerDocument.removeEventListener("pointerdown", handlePointerDown, true);
|
|
3031
|
+
}, [dropdownVisible, setDropdownVisible]);
|
|
2667
3032
|
function handleVisibleChange(visible) {
|
|
2668
3033
|
setDropdownVisible(visible);
|
|
2669
3034
|
}
|
|
2670
3035
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
|
|
2671
3036
|
align,
|
|
2672
3037
|
overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3038
|
+
ref: overlayRef,
|
|
2673
3039
|
className: "univer-grid univer-gap-2",
|
|
2674
3040
|
children: overlay
|
|
2675
3041
|
}),
|
|
@@ -2677,6 +3043,7 @@ function DropdownWrapper(props) {
|
|
|
2677
3043
|
open: dropdownVisible,
|
|
2678
3044
|
onOpenChange: handleVisibleChange,
|
|
2679
3045
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3046
|
+
ref: triggerRef,
|
|
2680
3047
|
className: "univer-h-full",
|
|
2681
3048
|
onClick: (e) => e.stopPropagation(),
|
|
2682
3049
|
children
|
|
@@ -2717,6 +3084,9 @@ function getOptionKey(option) {
|
|
|
2717
3084
|
}
|
|
2718
3085
|
function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, onOptionSelect }) {
|
|
2719
3086
|
const { dropdownVisible, setDropdownVisible } = (0, react.useContext)(TooltipWrapperContext);
|
|
3087
|
+
(0, react.useEffect)(() => {
|
|
3088
|
+
if (disabled) setDropdownVisible(false);
|
|
3089
|
+
}, [disabled, setDropdownVisible]);
|
|
2720
3090
|
const menuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
|
|
2721
3091
|
const resolveMenuItems = () => menuId ? menuManagerService.getMenuByPositionKey(menuId) : [];
|
|
2722
3092
|
const menuItems = (0, _wendellhu_redi_react_bindings.useObservable)(() => menuManagerService.menuChanged$.pipe((0, rxjs.map)(resolveMenuItems), (0, rxjs.startWith)(resolveMenuItems())), resolveMenuItems(), false, [menuId, menuManagerService]);
|
|
@@ -2760,11 +3130,16 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
2760
3130
|
children
|
|
2761
3131
|
});
|
|
2762
3132
|
if (options === null || options === void 0 ? void 0 : options.length) {
|
|
3133
|
+
var _options$0$label;
|
|
3134
|
+
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;
|
|
2763
3135
|
const items = options.map((option) => {
|
|
2764
|
-
var _option$label3;
|
|
3136
|
+
var _option$label3, _option$label4;
|
|
2765
3137
|
return {
|
|
2766
3138
|
type: "item",
|
|
2767
|
-
className: (0, _univerjs_design.clsx)({
|
|
3139
|
+
className: (0, _univerjs_design.clsx)({
|
|
3140
|
+
"focus:univer-bg-white": typeof option.label !== "string" && ((_option$label3 = option.label) === null || _option$label3 === void 0 ? void 0 : _option$label3.hoverable) === false,
|
|
3141
|
+
"!univer-p-0": typeof option.label !== "string" && ((_option$label4 = option.label) === null || _option$label4 === void 0 ? void 0 : _option$label4.hoverable) === false
|
|
3142
|
+
}),
|
|
2768
3143
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuLabel, {
|
|
2769
3144
|
icon: option.icon,
|
|
2770
3145
|
value,
|
|
@@ -2803,6 +3178,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
2803
3178
|
}
|
|
2804
3179
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
|
|
2805
3180
|
align: "start",
|
|
3181
|
+
className: (0, _univerjs_design.clsx)({ "!univer-p-0": isSingleCustomPanel }),
|
|
2806
3182
|
items,
|
|
2807
3183
|
disabled,
|
|
2808
3184
|
open: dropdownVisible,
|
|
@@ -2940,7 +3316,8 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
2940
3316
|
layoutService.focus();
|
|
2941
3317
|
commandService.executeCommand(commandId, params);
|
|
2942
3318
|
};
|
|
2943
|
-
const { tooltip, shortcut, icon, title, label, id, commandId, type, slot, params } = props;
|
|
3319
|
+
const { tooltip, shortcut, icon, title, label, id, commandId, type, slot, params, grid, large, showLabel, iconSize, iconColor, fullWidth } = props;
|
|
3320
|
+
const gridLabel = title !== null && title !== void 0 ? title : tooltip;
|
|
2944
3321
|
const shortcutDisplay = useToolbarShortcutDisplay({
|
|
2945
3322
|
id,
|
|
2946
3323
|
commandId,
|
|
@@ -2972,6 +3349,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
2972
3349
|
const selectionsCommandId = props.selectionsCommandId;
|
|
2973
3350
|
const bId = commandId !== null && commandId !== void 0 ? commandId : id;
|
|
2974
3351
|
const sId = (_ref = selectionsCommandId !== null && selectionsCommandId !== void 0 ? selectionsCommandId : commandId) !== null && _ref !== void 0 ? _ref : id;
|
|
3352
|
+
const titleToDisplay = grid ? showLabel ? gridLabel : large ? void 0 : title : title;
|
|
2975
3353
|
function handleSelect(option) {
|
|
2976
3354
|
if (disabled) return;
|
|
2977
3355
|
let commandId = sId;
|
|
@@ -2993,17 +3371,24 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
2993
3371
|
if (menuType === 2) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2994
3372
|
"data-u-command": id,
|
|
2995
3373
|
"data-disabled": disabled,
|
|
2996
|
-
className: toolbarButtonSelectorRootVariants({ disabled }),
|
|
3374
|
+
className: (0, _univerjs_design.clsx)(toolbarButtonSelectorRootVariants({ disabled }), {
|
|
3375
|
+
"univer-box-border univer-h-full univer-min-w-14 univer-flex-col !univer-pr-0": grid && large,
|
|
3376
|
+
"univer-box-border univer-h-full": grid && !large
|
|
3377
|
+
}),
|
|
2997
3378
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2998
|
-
className: toolbarButtonSelectorMainVariants({
|
|
3379
|
+
className: (0, _univerjs_design.clsx)(toolbarButtonSelectorMainVariants({
|
|
2999
3380
|
active: activated,
|
|
3000
3381
|
disabled
|
|
3382
|
+
}), {
|
|
3383
|
+
"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,
|
|
3384
|
+
"[&>svg]:univer-size-4": grid && !large
|
|
3001
3385
|
}),
|
|
3002
3386
|
onClick: handleClick,
|
|
3003
3387
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
|
|
3004
3388
|
icon: iconToDisplay,
|
|
3005
|
-
|
|
3006
|
-
|
|
3389
|
+
iconSize,
|
|
3390
|
+
title: titleToDisplay,
|
|
3391
|
+
value: iconColor !== null && iconColor !== void 0 ? iconColor : value,
|
|
3007
3392
|
label,
|
|
3008
3393
|
onChange: handleSelectionsValueChange
|
|
3009
3394
|
})
|
|
@@ -3015,9 +3400,12 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3015
3400
|
disabled,
|
|
3016
3401
|
onOptionSelect: handleSelect,
|
|
3017
3402
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3018
|
-
className: toolbarButtonSelectorTriggerVariants({
|
|
3403
|
+
className: (0, _univerjs_design.clsx)(toolbarButtonSelectorTriggerVariants({
|
|
3019
3404
|
disabled,
|
|
3020
3405
|
active: activated
|
|
3406
|
+
}), {
|
|
3407
|
+
"!univer-top-auto univer-bottom-0 univer-h-4 univer-w-full univer-rounded-b univer-rounded-t-none": grid && large,
|
|
3408
|
+
"univer-h-full": grid && !large
|
|
3021
3409
|
}),
|
|
3022
3410
|
"data-disabled": disabled,
|
|
3023
3411
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {})
|
|
@@ -3031,31 +3419,70 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3031
3419
|
options,
|
|
3032
3420
|
disabled,
|
|
3033
3421
|
onOptionSelect: handleSelect,
|
|
3034
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.
|
|
3422
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3035
3423
|
"data-u-command": id,
|
|
3036
|
-
className: toolbarSelectorRootVariants({
|
|
3424
|
+
className: (0, _univerjs_design.clsx)(toolbarSelectorRootVariants({
|
|
3037
3425
|
disabled,
|
|
3038
3426
|
active: activated
|
|
3039
|
-
}),
|
|
3040
|
-
|
|
3427
|
+
}), {
|
|
3428
|
+
"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,
|
|
3429
|
+
"univer-box-border univer-h-full": grid && !large,
|
|
3430
|
+
"univer-bg-white dark:!univer-bg-gray-800": grid && !large && !icon,
|
|
3431
|
+
"[&>svg]:univer-size-4": grid && !large
|
|
3432
|
+
}, grid && !large && !icon && _univerjs_design.borderClassName),
|
|
3433
|
+
children: grid && large ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
|
|
3434
|
+
icon: iconToDisplay,
|
|
3435
|
+
iconSize
|
|
3436
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3437
|
+
className: (0, _univerjs_design.clsx)(toolbarSelectorTriggerVariants({ disabled }), "univer-h-4 univer-justify-center univer-gap-0.5"),
|
|
3438
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
|
|
3439
|
+
title: titleToDisplay,
|
|
3440
|
+
value,
|
|
3441
|
+
label,
|
|
3442
|
+
onChange: handleSelectionsValueChange
|
|
3443
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {})]
|
|
3444
|
+
})] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
|
|
3041
3445
|
icon: iconToDisplay,
|
|
3042
|
-
|
|
3446
|
+
iconSize,
|
|
3447
|
+
title: titleToDisplay,
|
|
3043
3448
|
value,
|
|
3044
3449
|
label,
|
|
3045
3450
|
onChange: handleSelectionsValueChange
|
|
3046
3451
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3047
|
-
className: toolbarSelectorTriggerVariants({ disabled }),
|
|
3452
|
+
className: (0, _univerjs_design.clsx)(toolbarSelectorTriggerVariants({ disabled }), { "univer-ml-auto rtl:univer-ml-0 rtl:univer-mr-auto": grid && !large && !icon }),
|
|
3048
3453
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {})
|
|
3049
|
-
})]
|
|
3454
|
+
})] })
|
|
3050
3455
|
})
|
|
3051
3456
|
});
|
|
3052
3457
|
}
|
|
3053
3458
|
function renderButtonType() {
|
|
3054
3459
|
var _label$name;
|
|
3055
3460
|
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 : "");
|
|
3461
|
+
const buttonClassName = (0, _univerjs_design.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");
|
|
3462
|
+
const buttonStyle = grid && large ? {
|
|
3463
|
+
textAlign: "center",
|
|
3464
|
+
whiteSpace: "normal"
|
|
3465
|
+
} : void 0;
|
|
3466
|
+
if (isCustomComponent) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3467
|
+
"data-u-command": id,
|
|
3468
|
+
className: toolbarButtonVariants({
|
|
3469
|
+
noIcon: !icon,
|
|
3470
|
+
active: activated,
|
|
3471
|
+
className: buttonClassName
|
|
3472
|
+
}),
|
|
3473
|
+
style: buttonStyle,
|
|
3474
|
+
"aria-disabled": disabled,
|
|
3475
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
|
|
3476
|
+
className: grid && fullWidth ? "!univer-w-full" : void 0,
|
|
3477
|
+
title: grid && showLabel ? gridLabel : title,
|
|
3478
|
+
value,
|
|
3479
|
+
label
|
|
3480
|
+
})
|
|
3481
|
+
});
|
|
3056
3482
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
3057
3483
|
"data-u-command": id,
|
|
3058
|
-
className:
|
|
3484
|
+
className: buttonClassName,
|
|
3485
|
+
style: buttonStyle,
|
|
3059
3486
|
noIcon: !icon,
|
|
3060
3487
|
active: activated,
|
|
3061
3488
|
disabled,
|
|
@@ -3065,11 +3492,11 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3065
3492
|
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 });
|
|
3066
3493
|
},
|
|
3067
3494
|
onDoubleClick: () => props.subId && executeCommand(props.subId),
|
|
3068
|
-
children:
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
}) :
|
|
3495
|
+
children: icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
|
|
3496
|
+
icon,
|
|
3497
|
+
iconSize,
|
|
3498
|
+
title: grid && (large || showLabel) ? gridLabel : void 0
|
|
3499
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, { title })
|
|
3073
3500
|
});
|
|
3074
3501
|
}
|
|
3075
3502
|
function renderItem() {
|
|
@@ -3090,6 +3517,51 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3090
3517
|
});
|
|
3091
3518
|
});
|
|
3092
3519
|
|
|
3520
|
+
//#endregion
|
|
3521
|
+
//#region src/views/components/ribbon/RibbonGrid.tsx
|
|
3522
|
+
function RibbonGrid({ groups, title, className, ...props }) {
|
|
3523
|
+
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
3524
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3525
|
+
...props,
|
|
3526
|
+
"data-testid": "ribbon-grid-toolbar",
|
|
3527
|
+
"data-u-comp": "ribbon-grid-toolbar",
|
|
3528
|
+
className: (0, _univerjs_design.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", _univerjs_design.borderBottomClassName, _univerjs_design.scrollbarClassName, className),
|
|
3529
|
+
role: "toolbar",
|
|
3530
|
+
"aria-label": localeService.t(title),
|
|
3531
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarDropdownProvider, { children: groups.map((group) => {
|
|
3532
|
+
var _group$children;
|
|
3533
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3534
|
+
"data-u-comp": "ribbon-grid-group",
|
|
3535
|
+
className: "univer-relative univer-box-border univer-flex univer-min-w-16 univer-shrink-0 univer-flex-col univer-px-2",
|
|
3536
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3537
|
+
"data-testid": "ribbon-grid-group-grid",
|
|
3538
|
+
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",
|
|
3539
|
+
children: placeRibbonGridItems((_group$children = group.children) !== null && _group$children !== void 0 ? _group$children : []).map((placement) => placement.item.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3540
|
+
className: (0, _univerjs_design.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"),
|
|
3541
|
+
style: {
|
|
3542
|
+
gridRow: `${placement.row} / span ${placement.rowSpan}`,
|
|
3543
|
+
gridColumn: `${placement.column} / span ${placement.columnSpan}`,
|
|
3544
|
+
width: placement.width
|
|
3545
|
+
},
|
|
3546
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, {
|
|
3547
|
+
...placement.item.item,
|
|
3548
|
+
grid: true,
|
|
3549
|
+
large: placement.rowSpan > 1,
|
|
3550
|
+
showLabel: placement.showLabel,
|
|
3551
|
+
iconSize: placement.iconSize,
|
|
3552
|
+
fullWidth: placement.width !== void 0
|
|
3553
|
+
})
|
|
3554
|
+
}, placement.item.key))
|
|
3555
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3556
|
+
"data-testid": "ribbon-grid-group-divider",
|
|
3557
|
+
className: (0, _univerjs_design.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", _univerjs_design.borderRightClassName),
|
|
3558
|
+
"aria-hidden": "true"
|
|
3559
|
+
})]
|
|
3560
|
+
}, group.key);
|
|
3561
|
+
}) })
|
|
3562
|
+
});
|
|
3563
|
+
}
|
|
3564
|
+
|
|
3093
3565
|
//#endregion
|
|
3094
3566
|
//#region src/views/components/ribbon/Ribbon.tsx
|
|
3095
3567
|
function Ribbon(props) {
|
|
@@ -3160,7 +3632,7 @@ function Ribbon(props) {
|
|
|
3160
3632
|
activatedTab
|
|
3161
3633
|
]);
|
|
3162
3634
|
(0, react.useEffect)(() => {
|
|
3163
|
-
if (hideToolbar) {
|
|
3635
|
+
if (hideToolbar || ribbonType === "grid") {
|
|
3164
3636
|
toolbarItemRefs.current = {};
|
|
3165
3637
|
ribbonService.setCollapsedIds([]);
|
|
3166
3638
|
ribbonService.setFakeToolbarVisible(false);
|
|
@@ -3200,7 +3672,8 @@ function Ribbon(props) {
|
|
|
3200
3672
|
hideToolbar,
|
|
3201
3673
|
ribbon,
|
|
3202
3674
|
activatedTab,
|
|
3203
|
-
ribbonService
|
|
3675
|
+
ribbonService,
|
|
3676
|
+
ribbonType
|
|
3204
3677
|
]);
|
|
3205
3678
|
const fakeToolbar = (0, react.useMemo)(() => {
|
|
3206
3679
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -3238,7 +3711,7 @@ function Ribbon(props) {
|
|
|
3238
3711
|
...embedRibbonOverrideAttributes,
|
|
3239
3712
|
className: (0, _univerjs_design.clsx)("univer-relative univer-select-none", headerClassName, {
|
|
3240
3713
|
"univer-hidden": toolbarOnly,
|
|
3241
|
-
"univer-h-9": !toolbarOnly && (ribbonType === "classic" || headerMenuComponents && headerMenuComponents.size > 0)
|
|
3714
|
+
"univer-h-9": !toolbarOnly && (ribbonType === "classic" || ribbonType === "grid" || headerMenuComponents && headerMenuComponents.size > 0)
|
|
3242
3715
|
}),
|
|
3243
3716
|
children: [
|
|
3244
3717
|
!toolbarOnly && (ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.placeholderTitle) && ribbon.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -3253,13 +3726,23 @@ function Ribbon(props) {
|
|
|
3253
3726
|
activatedTab,
|
|
3254
3727
|
onSelectTab: handleSelectTab
|
|
3255
3728
|
}),
|
|
3729
|
+
!toolbarOnly && ribbonType === "grid" && ribbon.length >= 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RibbonGridMenu, {
|
|
3730
|
+
ribbon,
|
|
3731
|
+
activatedTab,
|
|
3732
|
+
onSelectTab: handleSelectTab
|
|
3733
|
+
}),
|
|
3256
3734
|
headerMenu && headerMenuComponents && headerMenuComponents.size > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3257
3735
|
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",
|
|
3258
3736
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, { components: headerMenuComponents })
|
|
3259
3737
|
})
|
|
3260
3738
|
]
|
|
3261
3739
|
}),
|
|
3262
|
-
!hideToolbar && /* @__PURE__ */ (0, react_jsx_runtime.
|
|
3740
|
+
!hideToolbar && ribbonType === "grid" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RibbonGrid, {
|
|
3741
|
+
...embedRibbonOverrideAttributes,
|
|
3742
|
+
groups: activeGroup.allGroups,
|
|
3743
|
+
title: activatedTabTitle
|
|
3744
|
+
}),
|
|
3745
|
+
!hideToolbar && ribbonType !== "grid" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3263
3746
|
...embedRibbonOverrideAttributes,
|
|
3264
3747
|
className: (0, _univerjs_design.clsx)("univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3 univer-text-sm", {
|
|
3265
3748
|
"univer-grid-cols-[1fr] univer-justify-center": ribbonType === "classic" || ribbon.length === 1,
|
|
@@ -3311,7 +3794,7 @@ function Ribbon(props) {
|
|
|
3311
3794
|
})] }, activatedTab)
|
|
3312
3795
|
})]
|
|
3313
3796
|
}),
|
|
3314
|
-
fakeToolbar
|
|
3797
|
+
ribbonType !== "grid" && fakeToolbar
|
|
3315
3798
|
] })
|
|
3316
3799
|
});
|
|
3317
3800
|
}
|
|
@@ -3409,25 +3892,6 @@ var ContextMenuService = class extends _univerjs_core.Disposable {
|
|
|
3409
3892
|
}
|
|
3410
3893
|
};
|
|
3411
3894
|
|
|
3412
|
-
//#endregion
|
|
3413
|
-
//#region src/services/runtime-scope/ui-runtime-scope.service.ts
|
|
3414
|
-
const IUIRuntimeScopeService = (0, _univerjs_core.createIdentifier)("ui.runtime-scope.service");
|
|
3415
|
-
var UIRuntimeScopeService = class extends _univerjs_core.Disposable {
|
|
3416
|
-
constructor(..._args) {
|
|
3417
|
-
super(..._args);
|
|
3418
|
-
_defineProperty(this, "_scopes", /* @__PURE__ */ new Map());
|
|
3419
|
-
}
|
|
3420
|
-
register(scope) {
|
|
3421
|
-
this._scopes.set(scope.unitId, scope);
|
|
3422
|
-
return (0, _univerjs_core.toDisposable)(() => {
|
|
3423
|
-
if (this._scopes.get(scope.unitId) === scope) this._scopes.delete(scope.unitId);
|
|
3424
|
-
});
|
|
3425
|
-
}
|
|
3426
|
-
get(unitId) {
|
|
3427
|
-
return unitId ? this._scopes.get(unitId) : void 0;
|
|
3428
|
-
}
|
|
3429
|
-
};
|
|
3430
|
-
|
|
3431
3895
|
//#endregion
|
|
3432
3896
|
//#region src/services/contextmenu/contextmenu-host.service.ts
|
|
3433
3897
|
const IContextMenuHostService = (0, _univerjs_core.createIdentifier)("ui.contextmenu.host.service");
|
|
@@ -3435,31 +3899,37 @@ var ContextMenuHostService = class extends _univerjs_core.Disposable {
|
|
|
3435
3899
|
constructor(..._args) {
|
|
3436
3900
|
super(..._args);
|
|
3437
3901
|
_defineProperty(this, "_menuMap", /* @__PURE__ */ new Map());
|
|
3438
|
-
_defineProperty(this, "_activeMenuId", null);
|
|
3902
|
+
_defineProperty(this, "_activeMenuId$", new rxjs.BehaviorSubject(null));
|
|
3903
|
+
_defineProperty(this, "activeMenuId$", this._activeMenuId$.asObservable());
|
|
3439
3904
|
}
|
|
3440
3905
|
get activeMenuId() {
|
|
3441
|
-
return this._activeMenuId;
|
|
3906
|
+
return this._activeMenuId$.value;
|
|
3442
3907
|
}
|
|
3443
3908
|
registerMenu(menuId, hide) {
|
|
3444
3909
|
this._menuMap.set(menuId, hide);
|
|
3445
3910
|
return (0, _univerjs_core.toDisposable)(() => {
|
|
3446
3911
|
this._menuMap.delete(menuId);
|
|
3447
|
-
if (this.
|
|
3912
|
+
if (this.activeMenuId === menuId) this._activeMenuId$.next(null);
|
|
3448
3913
|
});
|
|
3449
3914
|
}
|
|
3450
3915
|
activateMenu(menuId) {
|
|
3451
3916
|
this.hideActiveMenu(menuId);
|
|
3452
|
-
this._activeMenuId
|
|
3917
|
+
this._activeMenuId$.next(menuId);
|
|
3453
3918
|
}
|
|
3454
3919
|
deactivateMenu(menuId) {
|
|
3455
|
-
if (this.
|
|
3920
|
+
if (this.activeMenuId === menuId) this._activeMenuId$.next(null);
|
|
3456
3921
|
}
|
|
3457
3922
|
hideActiveMenu(exceptMenuId) {
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3923
|
+
const activeMenuId = this.activeMenuId;
|
|
3924
|
+
if (!activeMenuId || activeMenuId === exceptMenuId) return;
|
|
3925
|
+
const hide = this._menuMap.get(activeMenuId);
|
|
3926
|
+
this._activeMenuId$.next(null);
|
|
3461
3927
|
hide === null || hide === void 0 || hide();
|
|
3462
3928
|
}
|
|
3929
|
+
dispose() {
|
|
3930
|
+
this._activeMenuId$.complete();
|
|
3931
|
+
super.dispose();
|
|
3932
|
+
}
|
|
3463
3933
|
};
|
|
3464
3934
|
|
|
3465
3935
|
//#endregion
|
|
@@ -4433,6 +4903,9 @@ function ContextMenuMenuItem(props) {
|
|
|
4433
4903
|
setInputValue(value);
|
|
4434
4904
|
}, [value]);
|
|
4435
4905
|
(0, react.useEffect)(() => () => clearSubmenuCloseTimer(), [clearSubmenuCloseTimer]);
|
|
4906
|
+
(0, react.useEffect)(() => {
|
|
4907
|
+
if (disabled) closeSubmenu();
|
|
4908
|
+
}, [closeSubmenu, disabled]);
|
|
4436
4909
|
(0, react.useEffect)(() => {
|
|
4437
4910
|
if (!submenuVisible) {
|
|
4438
4911
|
setSubmenuPositionReady(false);
|
|
@@ -5016,7 +5489,7 @@ function Sidebar() {
|
|
|
5016
5489
|
children: [options === null || options === void 0 ? void 0 : options.header, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
5017
5490
|
ref: closeButtonRef,
|
|
5018
5491
|
type: "button",
|
|
5019
|
-
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",
|
|
5492
|
+
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",
|
|
5020
5493
|
onClick: handleClose,
|
|
5021
5494
|
"aria-label": localeService.t("ui.sidebar.close"),
|
|
5022
5495
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CloseIcon, {})
|
|
@@ -5024,7 +5497,6 @@ function Sidebar() {
|
|
|
5024
5497
|
}),
|
|
5025
5498
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
5026
5499
|
className: "univer-box-border univer-cursor-default univer-px-4",
|
|
5027
|
-
style: options === null || options === void 0 ? void 0 : options.bodyStyle,
|
|
5028
5500
|
children: options === null || options === void 0 ? void 0 : options.children
|
|
5029
5501
|
}),
|
|
5030
5502
|
(options === null || options === void 0 ? void 0 : options.footer) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("footer", {
|
|
@@ -5498,7 +5970,7 @@ const IUIController = (0, _univerjs_core.createIdentifier)("univer.ui.ui-control
|
|
|
5498
5970
|
//#endregion
|
|
5499
5971
|
//#region package.json
|
|
5500
5972
|
var name = "@univerjs/ui";
|
|
5501
|
-
var version = "1.0.0-alpha.
|
|
5973
|
+
var version = "1.0.0-alpha.7";
|
|
5502
5974
|
|
|
5503
5975
|
//#endregion
|
|
5504
5976
|
//#region src/views/color-picker/interface.ts
|
|
@@ -20500,11 +20972,12 @@ function EmojiPicker(props) {
|
|
|
20500
20972
|
};
|
|
20501
20973
|
}, [localStorageService, recentStorageKey]);
|
|
20502
20974
|
const handleSelect = (item, options) => {
|
|
20503
|
-
var _extraProps$onSelect;
|
|
20975
|
+
var _props$onChange, _extraProps$onSelect;
|
|
20504
20976
|
const nextRecents = promoteRecentEmoji(recents, item);
|
|
20505
20977
|
setActiveEmoji(item.emoji);
|
|
20506
20978
|
setRecents(nextRecents);
|
|
20507
20979
|
writeRecents(localStorageService, recentStorageKey, nextRecents);
|
|
20980
|
+
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, item.emoji);
|
|
20508
20981
|
extraProps === null || extraProps === void 0 || (_extraProps$onSelect = extraProps.onSelect) === null || _extraProps$onSelect === void 0 || _extraProps$onSelect.call(extraProps, item.emoji, options);
|
|
20509
20982
|
};
|
|
20510
20983
|
const handleRandom = () => {
|
|
@@ -20524,7 +20997,7 @@ function EmojiPicker(props) {
|
|
|
20524
20997
|
};
|
|
20525
20998
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
20526
20999
|
"data-u-comp": EMOJI_PICKER_COMPONENT,
|
|
20527
|
-
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",
|
|
21000
|
+
className: (0, _univerjs_design.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"),
|
|
20528
21001
|
children: [
|
|
20529
21002
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
20530
21003
|
className: "univer-flex univer-items-center univer-gap-1 univer-px-3 univer-pb-2 univer-pt-3",
|
|
@@ -20546,7 +21019,7 @@ function EmojiPicker(props) {
|
|
|
20546
21019
|
}),
|
|
20547
21020
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
20548
21021
|
ref: scrollRef,
|
|
20549
|
-
className: "univer-relative univer-min-h-0 univer-flex-1 univer-overflow-y-auto univer-px-3",
|
|
21022
|
+
className: (0, _univerjs_design.clsx)("univer-relative univer-min-h-0 univer-flex-1 univer-overflow-y-auto univer-px-3", _univerjs_design.scrollbarClassName),
|
|
20550
21023
|
onScroll: handleScroll,
|
|
20551
21024
|
children: renderedSections.length ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
20552
21025
|
className: "univer-flex univer-flex-col univer-gap-1.5 univer-pb-2",
|
|
@@ -21297,8 +21770,8 @@ function ZoomInput(props) {
|
|
|
21297
21770
|
className: (0, _univerjs_design.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 }),
|
|
21298
21771
|
onClick: (e) => e.stopPropagation(),
|
|
21299
21772
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
21300
|
-
className: "univer-box-border univer-h-6 univer-w-
|
|
21301
|
-
inputClass: "univer-w-
|
|
21773
|
+
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",
|
|
21774
|
+
inputClass: "univer-w-full",
|
|
21302
21775
|
size: "mini",
|
|
21303
21776
|
value: inputValue,
|
|
21304
21777
|
disabled,
|
|
@@ -21516,6 +21989,234 @@ function Slider(props) {
|
|
|
21516
21989
|
});
|
|
21517
21990
|
}
|
|
21518
21991
|
|
|
21992
|
+
//#endregion
|
|
21993
|
+
//#region src/views/symbol-picker/symbols.ts
|
|
21994
|
+
const SYMBOL_CATEGORIES = [
|
|
21995
|
+
{
|
|
21996
|
+
key: "mathematics",
|
|
21997
|
+
titleKey: "ui.symbolPicker.mathematics",
|
|
21998
|
+
symbols: [
|
|
21999
|
+
"+",
|
|
22000
|
+
"−",
|
|
22001
|
+
"×",
|
|
22002
|
+
"÷",
|
|
22003
|
+
"≠",
|
|
22004
|
+
"≈",
|
|
22005
|
+
"<",
|
|
22006
|
+
">",
|
|
22007
|
+
"≤",
|
|
22008
|
+
"≥",
|
|
22009
|
+
"≪",
|
|
22010
|
+
"≫",
|
|
22011
|
+
"≡",
|
|
22012
|
+
"±",
|
|
22013
|
+
"%",
|
|
22014
|
+
"‰",
|
|
22015
|
+
"‱",
|
|
22016
|
+
"½",
|
|
22017
|
+
"⅓",
|
|
22018
|
+
"⅔",
|
|
22019
|
+
"¼",
|
|
22020
|
+
"¾",
|
|
22021
|
+
"¹",
|
|
22022
|
+
"²",
|
|
22023
|
+
"³",
|
|
22024
|
+
"ⁿ",
|
|
22025
|
+
"₁",
|
|
22026
|
+
"₂",
|
|
22027
|
+
"₃",
|
|
22028
|
+
"|a|",
|
|
22029
|
+
"∟",
|
|
22030
|
+
"∠",
|
|
22031
|
+
"⊿",
|
|
22032
|
+
"△",
|
|
22033
|
+
"∥",
|
|
22034
|
+
"⊥",
|
|
22035
|
+
"∫",
|
|
22036
|
+
"∬",
|
|
22037
|
+
"∭",
|
|
22038
|
+
"∮",
|
|
22039
|
+
"∯",
|
|
22040
|
+
"∰",
|
|
22041
|
+
"∝",
|
|
22042
|
+
"∞",
|
|
22043
|
+
"∼",
|
|
22044
|
+
"≌",
|
|
22045
|
+
"∈",
|
|
22046
|
+
"∉",
|
|
22047
|
+
"⊆",
|
|
22048
|
+
"⊂",
|
|
22049
|
+
"∅",
|
|
22050
|
+
"∩",
|
|
22051
|
+
"∪",
|
|
22052
|
+
"∧",
|
|
22053
|
+
"∨",
|
|
22054
|
+
"⋅",
|
|
22055
|
+
"⋮",
|
|
22056
|
+
"⋰",
|
|
22057
|
+
"⋱",
|
|
22058
|
+
"⋯",
|
|
22059
|
+
"∏",
|
|
22060
|
+
"∑",
|
|
22061
|
+
"∃",
|
|
22062
|
+
"∄",
|
|
22063
|
+
"∀",
|
|
22064
|
+
"∂",
|
|
22065
|
+
"∆",
|
|
22066
|
+
"⊙",
|
|
22067
|
+
"⊕",
|
|
22068
|
+
"%"
|
|
22069
|
+
]
|
|
22070
|
+
},
|
|
22071
|
+
{
|
|
22072
|
+
key: "greek",
|
|
22073
|
+
titleKey: "ui.symbolPicker.greek",
|
|
22074
|
+
symbols: [
|
|
22075
|
+
"α",
|
|
22076
|
+
"β",
|
|
22077
|
+
"γ",
|
|
22078
|
+
"δ",
|
|
22079
|
+
"ε",
|
|
22080
|
+
"ζ",
|
|
22081
|
+
"η",
|
|
22082
|
+
"θ",
|
|
22083
|
+
"ι",
|
|
22084
|
+
"κ",
|
|
22085
|
+
"λ",
|
|
22086
|
+
"μ",
|
|
22087
|
+
"ν",
|
|
22088
|
+
"ξ",
|
|
22089
|
+
"ο",
|
|
22090
|
+
"π",
|
|
22091
|
+
"ρ",
|
|
22092
|
+
"σ",
|
|
22093
|
+
"τ",
|
|
22094
|
+
"υ",
|
|
22095
|
+
"φ",
|
|
22096
|
+
"χ",
|
|
22097
|
+
"ψ",
|
|
22098
|
+
"ω",
|
|
22099
|
+
"Α",
|
|
22100
|
+
"Β",
|
|
22101
|
+
"Γ",
|
|
22102
|
+
"Δ",
|
|
22103
|
+
"Ε",
|
|
22104
|
+
"Ζ",
|
|
22105
|
+
"Η",
|
|
22106
|
+
"Θ",
|
|
22107
|
+
"Ι",
|
|
22108
|
+
"Κ",
|
|
22109
|
+
"Λ",
|
|
22110
|
+
"Μ",
|
|
22111
|
+
"Ν",
|
|
22112
|
+
"Ξ",
|
|
22113
|
+
"Ο",
|
|
22114
|
+
"Π",
|
|
22115
|
+
"Ρ",
|
|
22116
|
+
"Σ",
|
|
22117
|
+
"Τ",
|
|
22118
|
+
"Υ",
|
|
22119
|
+
"Φ",
|
|
22120
|
+
"Χ",
|
|
22121
|
+
"Ψ",
|
|
22122
|
+
"Ω"
|
|
22123
|
+
]
|
|
22124
|
+
},
|
|
22125
|
+
{
|
|
22126
|
+
key: "common",
|
|
22127
|
+
titleKey: "ui.symbolPicker.common",
|
|
22128
|
+
symbols: [
|
|
22129
|
+
"kg",
|
|
22130
|
+
"mm",
|
|
22131
|
+
"cm",
|
|
22132
|
+
"m²",
|
|
22133
|
+
"°C",
|
|
22134
|
+
"°",
|
|
22135
|
+
"§",
|
|
22136
|
+
"◎",
|
|
22137
|
+
"©",
|
|
22138
|
+
"®",
|
|
22139
|
+
"{",
|
|
22140
|
+
"⌜",
|
|
22141
|
+
"〚",
|
|
22142
|
+
"№",
|
|
22143
|
+
"$",
|
|
22144
|
+
"¥",
|
|
22145
|
+
"@",
|
|
22146
|
+
"&",
|
|
22147
|
+
"*",
|
|
22148
|
+
"|",
|
|
22149
|
+
"#",
|
|
22150
|
+
"※",
|
|
22151
|
+
"√",
|
|
22152
|
+
"×",
|
|
22153
|
+
"…",
|
|
22154
|
+
"①",
|
|
22155
|
+
"②",
|
|
22156
|
+
"③",
|
|
22157
|
+
"↑",
|
|
22158
|
+
"↓",
|
|
22159
|
+
"←",
|
|
22160
|
+
"→"
|
|
22161
|
+
]
|
|
22162
|
+
}
|
|
22163
|
+
];
|
|
22164
|
+
|
|
22165
|
+
//#endregion
|
|
22166
|
+
//#region src/views/symbol-picker/SymbolPicker.tsx
|
|
22167
|
+
const SYMBOL_PICKER_COMPONENT = "ui.symbol-picker";
|
|
22168
|
+
function SymbolPicker(props) {
|
|
22169
|
+
var _props$popup;
|
|
22170
|
+
const extraProps = (_props$popup = props.popup) === null || _props$popup === void 0 ? void 0 : _props$popup.extraProps;
|
|
22171
|
+
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
22172
|
+
(0, _wendellhu_redi_react_bindings.useObservable)(localeService.currentLocale$, localeService.getCurrentLocale());
|
|
22173
|
+
const [activeSymbol, setActiveSymbol] = (0, react.useState)(extraProps === null || extraProps === void 0 ? void 0 : extraProps.activeSymbol);
|
|
22174
|
+
const handleSelect = (symbol) => {
|
|
22175
|
+
var _props$onChange, _extraProps$onSelect;
|
|
22176
|
+
setActiveSymbol(symbol);
|
|
22177
|
+
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, symbol);
|
|
22178
|
+
extraProps === null || extraProps === void 0 || (_extraProps$onSelect = extraProps.onSelect) === null || _extraProps$onSelect === void 0 || _extraProps$onSelect.call(extraProps, symbol, { keepOpen: true });
|
|
22179
|
+
};
|
|
22180
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
22181
|
+
"data-u-comp": SYMBOL_PICKER_COMPONENT,
|
|
22182
|
+
className: (0, _univerjs_design.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),
|
|
22183
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
22184
|
+
className: (0, _univerjs_design.clsx)("univer-min-h-0 univer-flex-1 univer-overflow-y-auto univer-p-4", _univerjs_design.scrollbarClassName),
|
|
22185
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
22186
|
+
className: "univer-flex univer-flex-col univer-gap-5",
|
|
22187
|
+
children: SYMBOL_CATEGORIES.map((category) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SymbolSection, {
|
|
22188
|
+
activeSymbol,
|
|
22189
|
+
category,
|
|
22190
|
+
onSelect: handleSelect
|
|
22191
|
+
}, category.key))
|
|
22192
|
+
})
|
|
22193
|
+
})
|
|
22194
|
+
});
|
|
22195
|
+
}
|
|
22196
|
+
function SymbolSection(props) {
|
|
22197
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
22198
|
+
className: "univer-flex univer-flex-col univer-gap-2",
|
|
22199
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
22200
|
+
className: "univer-text-sm univer-font-semibold univer-text-gray-900 dark:!univer-text-gray-100",
|
|
22201
|
+
children: (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService).t(props.category.titleKey)
|
|
22202
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
22203
|
+
className: "univer-grid univer-grid-cols-10 univer-gap-1",
|
|
22204
|
+
children: props.category.symbols.map((symbol, index) => {
|
|
22205
|
+
const active = props.activeSymbol === symbol;
|
|
22206
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
22207
|
+
type: "button",
|
|
22208
|
+
"aria-label": symbol,
|
|
22209
|
+
"aria-pressed": active,
|
|
22210
|
+
title: symbol,
|
|
22211
|
+
className: (0, _univerjs_design.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"),
|
|
22212
|
+
onClick: () => props.onSelect(symbol),
|
|
22213
|
+
children: symbol
|
|
22214
|
+
}, `${props.category.key}-${symbol}-${index}`);
|
|
22215
|
+
})
|
|
22216
|
+
})]
|
|
22217
|
+
});
|
|
22218
|
+
}
|
|
22219
|
+
|
|
21519
22220
|
//#endregion
|
|
21520
22221
|
//#region src/controllers/components.controller.ts
|
|
21521
22222
|
/**
|
|
@@ -21545,9 +22246,11 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
21545
22246
|
this.disposeWithMe(this._iconManager.register({
|
|
21546
22247
|
ExpandIcon: _univerjs_icons.ExpandIcon,
|
|
21547
22248
|
IncreaseIcon: _univerjs_icons.IncreaseIcon,
|
|
22249
|
+
KeyboardIcon: _univerjs_icons.KeyboardIcon,
|
|
21548
22250
|
MoreDownIcon: _univerjs_icons.MoreDownIcon,
|
|
21549
22251
|
RedoIcon: _univerjs_icons.RedoIcon,
|
|
21550
22252
|
ReduceIcon: _univerjs_icons.ReduceIcon,
|
|
22253
|
+
FeatureSearchIcon: _univerjs_icons.FeatureSearchIcon,
|
|
21551
22254
|
ShortcutIcon: _univerjs_icons.ShortcutIcon,
|
|
21552
22255
|
ShrinkIcon: _univerjs_icons.ShrinkIcon,
|
|
21553
22256
|
UndoIcon: _univerjs_icons.UndoIcon
|
|
@@ -21561,7 +22264,9 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
21561
22264
|
[FONT_FAMILY_ITEM_COMPONENT, FontFamilyItem],
|
|
21562
22265
|
[FONT_SIZE_COMPONENT, FontSize],
|
|
21563
22266
|
[COLOR_PICKER_COMPONENT, _univerjs_design.ColorPicker],
|
|
21564
|
-
[EMOJI_PICKER_COMPONENT, EmojiPicker]
|
|
22267
|
+
[EMOJI_PICKER_COMPONENT, EmojiPicker],
|
|
22268
|
+
[SYMBOL_PICKER_COMPONENT, SymbolPicker],
|
|
22269
|
+
[FEATURE_SEARCH_COMPONENT, FeatureSearch]
|
|
21565
22270
|
].forEach(([key, comp]) => {
|
|
21566
22271
|
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
21567
22272
|
});
|
|
@@ -21570,6 +22275,24 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
21570
22275
|
};
|
|
21571
22276
|
ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(IconManager))], ComponentsController);
|
|
21572
22277
|
|
|
22278
|
+
//#endregion
|
|
22279
|
+
//#region src/controllers/feature-search/feature-search.controller.ts
|
|
22280
|
+
const FeatureSearchShortcut = {
|
|
22281
|
+
id: OpenFeatureSearchOperation.id,
|
|
22282
|
+
binding: 4096 | 1024 | 80,
|
|
22283
|
+
description: "ui.featureSearch.title",
|
|
22284
|
+
group: "10_global-shortcut",
|
|
22285
|
+
groupTitle: "ui.global-shortcut"
|
|
22286
|
+
};
|
|
22287
|
+
let FeatureSearchController = class FeatureSearchController extends _univerjs_core.Disposable {
|
|
22288
|
+
constructor(commandService, shortcutService) {
|
|
22289
|
+
super();
|
|
22290
|
+
this.disposeWithMe(commandService.registerCommand(OpenFeatureSearchOperation));
|
|
22291
|
+
this.disposeWithMe(shortcutService.registerShortcut(FeatureSearchShortcut));
|
|
22292
|
+
}
|
|
22293
|
+
};
|
|
22294
|
+
FeatureSearchController = __decorate([__decorateParam(0, _univerjs_core.ICommandService), __decorateParam(1, IShortcutService)], FeatureSearchController);
|
|
22295
|
+
|
|
21573
22296
|
//#endregion
|
|
21574
22297
|
//#region src/views/components/ribbon/MobileRibbon.tsx
|
|
21575
22298
|
const toolbarScrollOffset = 168;
|
|
@@ -21793,7 +22516,8 @@ function MobileMenu(props) {
|
|
|
21793
22516
|
menuManagerService,
|
|
21794
22517
|
menuType,
|
|
21795
22518
|
onExecute: onOptionSelect,
|
|
21796
|
-
onOpenView: openView
|
|
22519
|
+
onOpenView: openView,
|
|
22520
|
+
inheritedDisabled$: currentView === null || currentView === void 0 ? void 0 : currentView.disabled$
|
|
21797
22521
|
})
|
|
21798
22522
|
}), (currentView === null || currentView === void 0 ? void 0 : currentView.kind) === "options" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
21799
22523
|
className: "univer-overflow-hidden univer-rounded-2xl univer-bg-white",
|
|
@@ -21802,6 +22526,7 @@ function MobileMenu(props) {
|
|
|
21802
22526
|
menuItem: currentView.menuItem,
|
|
21803
22527
|
options: currentView.options,
|
|
21804
22528
|
currentValue: currentView.currentValue,
|
|
22529
|
+
inheritedDisabled$: currentView.disabled$,
|
|
21805
22530
|
onExecute: onOptionSelect
|
|
21806
22531
|
})
|
|
21807
22532
|
})]
|
|
@@ -21809,7 +22534,7 @@ function MobileMenu(props) {
|
|
|
21809
22534
|
});
|
|
21810
22535
|
}
|
|
21811
22536
|
function MobileSchemaList(props) {
|
|
21812
|
-
const { schemas, menuManagerService, menuType, onExecute, onOpenView } = props;
|
|
22537
|
+
const { schemas, menuManagerService, menuType, onExecute, onOpenView, inheritedDisabled$ } = props;
|
|
21813
22538
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
21814
22539
|
const hiddenGroupStates = useContextGroupHiddenStates(schemas);
|
|
21815
22540
|
const visibleSchemas = (0, react.useMemo)(() => {
|
|
@@ -21827,6 +22552,7 @@ function MobileSchemaList(props) {
|
|
|
21827
22552
|
menuType,
|
|
21828
22553
|
onExecute,
|
|
21829
22554
|
onOpenView,
|
|
22555
|
+
inheritedDisabled$,
|
|
21830
22556
|
bordered: index !== visibleSchemas.length - 1
|
|
21831
22557
|
}, schema.key);
|
|
21832
22558
|
if (!((_schema$children2 = schema.children) === null || _schema$children2 === void 0 ? void 0 : _schema$children2.length)) return null;
|
|
@@ -21841,18 +22567,20 @@ function MobileSchemaList(props) {
|
|
|
21841
22567
|
menuType,
|
|
21842
22568
|
onExecute,
|
|
21843
22569
|
onOpenView,
|
|
22570
|
+
inheritedDisabled$,
|
|
21844
22571
|
bordered: childIndex !== schema.children.length - 1
|
|
21845
22572
|
}, childSchema.key))]
|
|
21846
22573
|
}, schema.key);
|
|
21847
22574
|
}) });
|
|
21848
22575
|
}
|
|
21849
22576
|
function MobileSchemaRow(props) {
|
|
21850
|
-
const { schema, menuManagerService, menuType, onExecute, onOpenView, bordered } = props;
|
|
22577
|
+
const { schema, menuManagerService, menuType, onExecute, onOpenView, inheritedDisabled$, bordered } = props;
|
|
21851
22578
|
const interaction = useMobileSchemaInteraction({
|
|
21852
22579
|
schema,
|
|
21853
22580
|
menuManagerService,
|
|
21854
22581
|
menuType,
|
|
21855
|
-
onOpenView
|
|
22582
|
+
onOpenView,
|
|
22583
|
+
inheritedDisabled$
|
|
21856
22584
|
});
|
|
21857
22585
|
if (!interaction || interaction.hidden) return null;
|
|
21858
22586
|
const { menuItem, disabled, value, currentValueText, hasSubmenu, onPress } = interaction;
|
|
@@ -21880,7 +22608,8 @@ function MobileSchemaRow(props) {
|
|
|
21880
22608
|
});
|
|
21881
22609
|
}
|
|
21882
22610
|
function MobileSelectionOptionsView(props) {
|
|
21883
|
-
const { options, menuKey, menuItem, currentValue, onExecute } = props;
|
|
22611
|
+
const { options, menuKey, menuItem, currentValue, inheritedDisabled$, onExecute } = props;
|
|
22612
|
+
const inheritedDisabled = (0, _wendellhu_redi_react_bindings.useObservable)(inheritedDisabled$, false);
|
|
21884
22613
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: options.map((option, index) => {
|
|
21885
22614
|
var _option$value;
|
|
21886
22615
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileSelectionOptionRow, {
|
|
@@ -21888,6 +22617,7 @@ function MobileSelectionOptionsView(props) {
|
|
|
21888
22617
|
menuKey,
|
|
21889
22618
|
menuItem,
|
|
21890
22619
|
currentValue,
|
|
22620
|
+
disabled: inheritedDisabled,
|
|
21891
22621
|
bordered: index !== options.length - 1,
|
|
21892
22622
|
onExecute
|
|
21893
22623
|
}, `${menuKey}-${String((_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : index)}`);
|
|
@@ -21895,15 +22625,17 @@ function MobileSelectionOptionsView(props) {
|
|
|
21895
22625
|
}
|
|
21896
22626
|
function MobileSelectionOptionRow(props) {
|
|
21897
22627
|
var _option$value2;
|
|
21898
|
-
const { option, menuKey, menuItem, currentValue, bordered, onExecute } = props;
|
|
22628
|
+
const { option, menuKey, menuItem, currentValue, disabled, bordered, onExecute } = props;
|
|
21899
22629
|
const optionValue = (0, _wendellhu_redi_react_bindings.useObservable)(option.value$);
|
|
21900
22630
|
const displayValue = (_option$value2 = option.value) !== null && _option$value2 !== void 0 ? _option$value2 : optionValue;
|
|
21901
22631
|
const selected = displayValue === currentValue;
|
|
22632
|
+
const optionDisabled = disabled || Boolean(option.disabled);
|
|
21902
22633
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
21903
22634
|
type: "button",
|
|
21904
22635
|
className: (0, _univerjs_design.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 && _univerjs_design.borderBottomClassName),
|
|
21905
|
-
disabled:
|
|
22636
|
+
disabled: optionDisabled,
|
|
21906
22637
|
onClick: () => {
|
|
22638
|
+
if (optionDisabled) return;
|
|
21907
22639
|
onExecute === null || onExecute === void 0 || onExecute({
|
|
21908
22640
|
...option,
|
|
21909
22641
|
value: displayValue,
|
|
@@ -21925,11 +22657,15 @@ function MobileSelectionOptionRow(props) {
|
|
|
21925
22657
|
}
|
|
21926
22658
|
function useMobileSchemaInteraction(props) {
|
|
21927
22659
|
var _schema$children3;
|
|
21928
|
-
const { schema, menuManagerService, menuType, onOpenView } = props;
|
|
22660
|
+
const { schema, menuManagerService, menuType, onOpenView, inheritedDisabled$ } = props;
|
|
21929
22661
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
21930
22662
|
const menuItem = schema.item;
|
|
21931
22663
|
const selectorItem = menuItem;
|
|
21932
|
-
const disabled = (0,
|
|
22664
|
+
const disabled$ = (0, react.useMemo)(() => {
|
|
22665
|
+
const sources = [inheritedDisabled$, menuItem === null || menuItem === void 0 ? void 0 : menuItem.disabled$].filter((source) => Boolean(source));
|
|
22666
|
+
return sources.length ? (0, rxjs.combineLatest)(sources.map((source) => source.pipe((0, rxjs_operators.startWith)(false)))).pipe((0, rxjs.map)((states) => states.some(Boolean))) : void 0;
|
|
22667
|
+
}, [inheritedDisabled$, menuItem === null || menuItem === void 0 ? void 0 : menuItem.disabled$]);
|
|
22668
|
+
const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(disabled$, false);
|
|
21933
22669
|
const hidden = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem === null || menuItem === void 0 ? void 0 : menuItem.hidden$, false);
|
|
21934
22670
|
const value = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem === null || menuItem === void 0 ? void 0 : menuItem.value$);
|
|
21935
22671
|
const selectionsFromObservable = (0, _wendellhu_redi_react_bindings.useObservable)(selectorItem && (0, rxjs.isObservable)(selectorItem.selections) ? selectorItem.selections : void 0);
|
|
@@ -21951,11 +22687,13 @@ function useMobileSchemaInteraction(props) {
|
|
|
21951
22687
|
const hasSubmenu = schemaChildren.length > 0 || selections.length > 0 || subMenuItems.length > 0;
|
|
21952
22688
|
const currentValueText = typeof value === "string" || typeof value === "number" ? String(value) : "";
|
|
21953
22689
|
const onPress = (onExecute) => {
|
|
22690
|
+
if (disabled) return;
|
|
21954
22691
|
if (schemaChildren.length > 0) {
|
|
21955
22692
|
onOpenView({
|
|
21956
22693
|
kind: "schema",
|
|
21957
22694
|
title: getMenuSchemaTitle(schema, localeService),
|
|
21958
|
-
schemas: schemaChildren
|
|
22695
|
+
schemas: schemaChildren,
|
|
22696
|
+
disabled$
|
|
21959
22697
|
});
|
|
21960
22698
|
return;
|
|
21961
22699
|
}
|
|
@@ -21966,7 +22704,8 @@ function useMobileSchemaInteraction(props) {
|
|
|
21966
22704
|
options: selections,
|
|
21967
22705
|
menuItem: selectorItem,
|
|
21968
22706
|
menuKey: schema.key,
|
|
21969
|
-
currentValue: value
|
|
22707
|
+
currentValue: value,
|
|
22708
|
+
disabled$
|
|
21970
22709
|
});
|
|
21971
22710
|
return;
|
|
21972
22711
|
}
|
|
@@ -21974,7 +22713,8 @@ function useMobileSchemaInteraction(props) {
|
|
|
21974
22713
|
onOpenView({
|
|
21975
22714
|
kind: "schema",
|
|
21976
22715
|
title: getMenuSchemaTitle(schema, localeService),
|
|
21977
|
-
schemas: subMenuItems
|
|
22716
|
+
schemas: subMenuItems,
|
|
22717
|
+
disabled$
|
|
21978
22718
|
});
|
|
21979
22719
|
return;
|
|
21980
22720
|
}
|
|
@@ -22529,7 +23269,7 @@ let BrowserClipboardService = class BrowserClipboardService extends _univerjs_co
|
|
|
22529
23269
|
this._notificationService = _notificationService;
|
|
22530
23270
|
}
|
|
22531
23271
|
async write(text, html, customData) {
|
|
22532
|
-
if (!this.supportClipboard) return this._legacyCopyHtml(text, html);
|
|
23272
|
+
if (!this.supportClipboard || typeof ClipboardItem === "undefined" || typeof navigator.clipboard.write !== "function") return this._legacyCopyHtml(text, html);
|
|
22533
23273
|
try {
|
|
22534
23274
|
return await navigator.clipboard.write([new ClipboardItem({
|
|
22535
23275
|
[PLAIN_TEXT_CLIPBOARD_MIME_TYPE]: new Blob([text], { type: PLAIN_TEXT_CLIPBOARD_MIME_TYPE }),
|
|
@@ -22861,10 +23601,6 @@ let DesktopConfirmService = class DesktopConfirmService extends _univerjs_core.D
|
|
|
22861
23601
|
};
|
|
22862
23602
|
DesktopConfirmService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, IUIPartsService)], DesktopConfirmService);
|
|
22863
23603
|
|
|
22864
|
-
//#endregion
|
|
22865
|
-
//#region src/services/dialog/dialog.service.ts
|
|
22866
|
-
const IDialogService = (0, _univerjs_core.createIdentifier)("univer.ui.dialog-service");
|
|
22867
|
-
|
|
22868
23604
|
//#endregion
|
|
22869
23605
|
//#region src/views/components/dialog-part/DialogPart.tsx
|
|
22870
23606
|
function DialogPart() {
|
|
@@ -23508,6 +24244,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends _univerjs_core.Plu
|
|
|
23508
24244
|
}],
|
|
23509
24245
|
[SharedController],
|
|
23510
24246
|
[ErrorController],
|
|
24247
|
+
[FeatureSearchController],
|
|
23511
24248
|
[ShortcutPanelController]
|
|
23512
24249
|
], this._config.override));
|
|
23513
24250
|
(0, _univerjs_core.touchDependencies)(this._injector, [
|
|
@@ -23517,7 +24254,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends _univerjs_core.Plu
|
|
|
23517
24254
|
]);
|
|
23518
24255
|
}
|
|
23519
24256
|
onReady() {
|
|
23520
|
-
(0, _univerjs_core.touchDependencies)(this._injector, [[SharedController]]);
|
|
24257
|
+
(0, _univerjs_core.touchDependencies)(this._injector, [[SharedController], [FeatureSearchController]]);
|
|
23521
24258
|
}
|
|
23522
24259
|
onSteady() {
|
|
23523
24260
|
(0, _univerjs_core.touchDependencies)(this._injector, [[ShortcutPanelController]]);
|
|
@@ -23610,6 +24347,7 @@ let UniverUIPlugin = class UniverUIPlugin extends _univerjs_core.Plugin {
|
|
|
23610
24347
|
}],
|
|
23611
24348
|
[SharedController],
|
|
23612
24349
|
[ErrorController],
|
|
24350
|
+
[FeatureSearchController],
|
|
23613
24351
|
[ShortcutPanelController]
|
|
23614
24352
|
], this._config.override));
|
|
23615
24353
|
(0, _univerjs_core.touchDependencies)(this._injector, [
|
|
@@ -23619,7 +24357,7 @@ let UniverUIPlugin = class UniverUIPlugin extends _univerjs_core.Plugin {
|
|
|
23619
24357
|
]);
|
|
23620
24358
|
}
|
|
23621
24359
|
onReady() {
|
|
23622
|
-
(0, _univerjs_core.touchDependencies)(this._injector, [[SharedController]]);
|
|
24360
|
+
(0, _univerjs_core.touchDependencies)(this._injector, [[SharedController], [FeatureSearchController]]);
|
|
23623
24361
|
}
|
|
23624
24362
|
onSteady() {
|
|
23625
24363
|
(0, _univerjs_core.touchDependencies)(this._injector, [[ShortcutPanelController]]);
|
|
@@ -24528,6 +25266,7 @@ Object.defineProperty(exports, 'DesktopUIController', {
|
|
|
24528
25266
|
return DesktopUIController;
|
|
24529
25267
|
}
|
|
24530
25268
|
});
|
|
25269
|
+
exports.EMBED_CHILD_UNIT_ID_ATTRIBUTE = EMBED_CHILD_UNIT_ID_ATTRIBUTE;
|
|
24531
25270
|
exports.EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE;
|
|
24532
25271
|
exports.EMOJI_CATEGORIES = EMOJI_CATEGORIES;
|
|
24533
25272
|
exports.EMOJI_PICKER_COMPONENT = EMOJI_PICKER_COMPONENT;
|
|
@@ -24638,6 +25377,8 @@ exports.RibbonOverrideService = RibbonOverrideService;
|
|
|
24638
25377
|
exports.RibbonPosition = RibbonPosition;
|
|
24639
25378
|
exports.RibbonStartGroup = RibbonStartGroup;
|
|
24640
25379
|
exports.RibbonViewGroup = RibbonViewGroup;
|
|
25380
|
+
exports.SYMBOL_CATEGORIES = SYMBOL_CATEGORIES;
|
|
25381
|
+
exports.SYMBOL_PICKER_COMPONENT = SYMBOL_PICKER_COMPONENT;
|
|
24641
25382
|
Object.defineProperty(exports, 'SharedController', {
|
|
24642
25383
|
enumerable: true,
|
|
24643
25384
|
get: function () {
|
|
@@ -24662,6 +25403,7 @@ exports.Sidebar = Sidebar;
|
|
|
24662
25403
|
exports.SingleCanvasPopup = SingleCanvasPopup;
|
|
24663
25404
|
exports.SingleUnitUIController = SingleUnitUIController;
|
|
24664
25405
|
exports.Slider = Slider;
|
|
25406
|
+
exports.SymbolPicker = SymbolPicker;
|
|
24665
25407
|
exports.ThemeSwitcherService = ThemeSwitcherService;
|
|
24666
25408
|
exports.ToggleFullscreenOperation = ToggleFullscreenOperation;
|
|
24667
25409
|
exports.ToggleShortcutPanelOperation = ToggleShortcutPanelOperation;
|
|
@@ -24708,6 +25450,7 @@ Object.defineProperty(exports, 'connectInjector', {
|
|
|
24708
25450
|
exports.getAllEmojis = getAllEmojis;
|
|
24709
25451
|
exports.getDefaultRecentEmojis = getDefaultRecentEmojis;
|
|
24710
25452
|
exports.getEmbedBoundaryOwner = getEmbedBoundaryOwner;
|
|
25453
|
+
exports.getEmbedChildUnitId = getEmbedChildUnitId;
|
|
24711
25454
|
exports.getEmojiLocaleData = getEmojiLocaleData;
|
|
24712
25455
|
exports.getHeaderFooterMenuHiddenObservable = getHeaderFooterMenuHiddenObservable;
|
|
24713
25456
|
exports.getLocalizedEmojiTitle = getLocalizedEmojiTitle;
|