@univerjs/ui 0.24.0 → 0.25.0-insiders.20260608-e4336f7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +8 -7
- package/lib/cjs/index.js +576 -186
- package/lib/cjs/locale/ar-SA.js +81 -0
- package/lib/cjs/locale/ca-ES.js +5 -3
- package/lib/cjs/locale/de-DE.js +81 -0
- package/lib/cjs/locale/en-US.js +5 -3
- package/lib/cjs/locale/es-ES.js +5 -3
- package/lib/cjs/locale/fa-IR.js +5 -3
- package/lib/cjs/locale/fr-FR.js +5 -3
- package/lib/cjs/locale/id-ID.js +81 -0
- package/lib/cjs/locale/it-IT.js +81 -0
- package/lib/cjs/locale/ja-JP.js +5 -3
- package/lib/cjs/locale/ko-KR.js +5 -3
- package/lib/cjs/locale/pl-PL.js +81 -0
- package/lib/cjs/locale/pt-BR.js +81 -0
- package/lib/cjs/locale/ru-RU.js +5 -3
- package/lib/cjs/locale/sk-SK.js +5 -3
- package/lib/cjs/locale/vi-VN.js +5 -3
- package/lib/cjs/locale/zh-CN.js +5 -3
- package/lib/cjs/locale/zh-HK.js +81 -0
- package/lib/cjs/locale/zh-TW.js +5 -3
- package/lib/es/facade.js +8 -7
- package/lib/es/index.js +577 -170
- package/lib/es/locale/ar-SA.js +80 -0
- package/lib/es/locale/ca-ES.js +5 -3
- package/lib/es/locale/de-DE.js +80 -0
- package/lib/es/locale/en-US.js +5 -3
- package/lib/es/locale/es-ES.js +5 -3
- package/lib/es/locale/fa-IR.js +5 -3
- package/lib/es/locale/fr-FR.js +5 -3
- package/lib/es/locale/id-ID.js +80 -0
- package/lib/es/locale/it-IT.js +80 -0
- package/lib/es/locale/ja-JP.js +5 -3
- package/lib/es/locale/ko-KR.js +5 -3
- package/lib/es/locale/pl-PL.js +80 -0
- package/lib/es/locale/pt-BR.js +80 -0
- package/lib/es/locale/ru-RU.js +5 -3
- package/lib/es/locale/sk-SK.js +5 -3
- package/lib/es/locale/vi-VN.js +5 -3
- package/lib/es/locale/zh-CN.js +5 -3
- package/lib/es/locale/zh-HK.js +80 -0
- package/lib/es/locale/zh-TW.js +5 -3
- package/lib/facade.js +8 -7
- package/lib/index.css +9 -4
- package/lib/index.js +577 -170
- package/lib/locale/ar-SA.js +80 -0
- package/lib/locale/ca-ES.js +5 -3
- package/lib/locale/de-DE.js +80 -0
- package/lib/locale/en-US.js +5 -3
- package/lib/locale/es-ES.js +5 -3
- package/lib/locale/fa-IR.js +5 -3
- package/lib/locale/fr-FR.js +5 -3
- package/lib/locale/id-ID.js +80 -0
- package/lib/locale/it-IT.js +80 -0
- package/lib/locale/ja-JP.js +5 -3
- package/lib/locale/ko-KR.js +5 -3
- package/lib/locale/pl-PL.js +80 -0
- package/lib/locale/pt-BR.js +80 -0
- package/lib/locale/ru-RU.js +5 -3
- package/lib/locale/sk-SK.js +5 -3
- package/lib/locale/vi-VN.js +5 -3
- package/lib/locale/zh-CN.js +5 -3
- package/lib/locale/zh-HK.js +80 -0
- package/lib/locale/zh-TW.js +5 -3
- package/lib/types/components/common-label/index.d.ts +1 -1
- package/lib/types/components/custom-label/CustomLabel.d.ts +1 -1
- package/lib/types/components/font-family/FontFamily.d.ts +1 -1
- package/lib/types/components/font-family/FontFamilyItem.d.ts +1 -1
- package/lib/types/components/font-size/FontSize.d.ts +1 -1
- package/lib/types/components/heading-item/index.d.ts +1 -1
- package/lib/types/components/menu/desktop/DesignTinyMenuGroup.d.ts +2 -1
- package/lib/types/components/menu/desktop/TinyMenuGroup.d.ts +6 -2
- package/lib/types/components/menu/mobile/MobileMenu.d.ts +1 -1
- package/lib/types/components/menu/mobile/MobileMenu.stories.d.ts +1 -1
- package/lib/types/components/message/MessageContainer.d.ts +1 -1
- package/lib/types/components/notification/Notification.d.ts +1 -1
- package/lib/types/components/notification/Notification.stories.d.ts +5 -5
- package/lib/types/components/progress-bar/ProgressBar.d.ts +1 -1
- package/lib/types/components/slider/Slider.d.ts +2 -1
- package/lib/types/components/slider/Slider.stories.d.ts +1 -1
- package/lib/types/facade/f-shortcut.d.ts +2 -1
- package/lib/types/facade/f-univer.d.ts +8 -4
- package/lib/types/index.d.ts +0 -1
- package/lib/types/{components/hooks/locale.d.ts → locale/ar-SA.d.ts} +3 -3
- package/lib/types/locale/de-DE.d.ts +18 -0
- package/lib/types/locale/en-US.d.ts +79 -75
- package/lib/types/locale/id-ID.d.ts +18 -0
- package/lib/types/locale/it-IT.d.ts +18 -0
- package/lib/types/locale/pl-PL.d.ts +18 -0
- package/lib/types/locale/pt-BR.d.ts +18 -0
- package/lib/types/locale/zh-HK.d.ts +18 -0
- package/lib/types/services/before-close/before-close.service.d.ts +5 -1
- package/lib/types/services/clipboard/clipboard-interface.service.d.ts +2 -2
- package/lib/types/services/menu/menu-manager.service.d.ts +1 -0
- package/lib/types/services/ribbon/ribbon.service.d.ts +2 -0
- package/lib/types/services/shortcut/shortcut.service.d.ts +8 -0
- package/lib/types/utils/storage-driver.d.ts +26 -0
- package/lib/types/views/components/confirm-part/ConfirmPart.d.ts +1 -1
- package/lib/types/views/components/context-menu/AnchoredContextMenu.d.ts +1 -1
- package/lib/types/views/components/context-menu/ContextMenu.d.ts +1 -1
- package/lib/types/views/components/context-menu/ContextMenuPanel.d.ts +6 -1
- package/lib/types/views/components/dialog-part/DialogPart.d.ts +1 -1
- package/lib/types/views/components/dom/FloatDom.d.ts +2 -2
- package/lib/types/views/components/dom/Print.d.ts +1 -1
- package/lib/types/views/components/gallery-part/GalleryPart.d.ts +1 -1
- package/lib/types/views/components/popup/CanvasPopup.d.ts +2 -2
- package/lib/types/views/components/popup/RectPopup.d.ts +1 -1
- package/lib/types/views/components/ribbon/MobileRibbon.d.ts +1 -1
- package/lib/types/views/components/ribbon/Ribbon.d.ts +1 -1
- package/lib/types/views/components/ribbon/ToolbarButton.d.ts +1 -1
- package/lib/types/views/components/ribbon/TooltipButtonWrapper.d.ts +2 -2
- package/lib/types/views/components/ribbon/ribbon-menu/ClassicMenu.d.ts +1 -1
- package/lib/types/views/components/ribbon/ribbon-menu/DefaultMenu.d.ts +1 -1
- package/lib/types/views/components/shortcut-panel/ShortcutPanel.d.ts +1 -1
- package/lib/types/views/components/sidebar/Sidebar.d.ts +1 -1
- package/lib/types/views/components/zen-zone/ZenZone.d.ts +1 -1
- package/lib/types/views/mobile-workbench/MobileWorkbench.d.ts +1 -1
- package/lib/types/views/workbench/Workbench.d.ts +2 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +51 -43
- package/lib/umd/locale/ar-SA.js +1 -0
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -0
- 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 -0
- package/lib/umd/locale/it-IT.js +1 -0
- 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 -0
- package/lib/umd/locale/pt-BR.js +1 -0
- 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 -0
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +9 -10
- package/LICENSE +0 -176
package/lib/cjs/index.js
CHANGED
|
@@ -37,10 +37,8 @@ let _univerjs_design = require("@univerjs/design");
|
|
|
37
37
|
let _univerjs_engine_render = require("@univerjs/engine-render");
|
|
38
38
|
let rxjs_operators = require("rxjs/operators");
|
|
39
39
|
let react_dom = require("react-dom");
|
|
40
|
-
let localforage = require("localforage");
|
|
41
|
-
localforage = __toESM(localforage);
|
|
42
40
|
|
|
43
|
-
//#region \0@oxc-project+runtime@0.
|
|
41
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/typeof.js
|
|
44
42
|
function _typeof(o) {
|
|
45
43
|
"@babel/helpers - typeof";
|
|
46
44
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -51,7 +49,7 @@ function _typeof(o) {
|
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
//#endregion
|
|
54
|
-
//#region \0@oxc-project+runtime@0.
|
|
52
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPrimitive.js
|
|
55
53
|
function toPrimitive(t, r) {
|
|
56
54
|
if ("object" != _typeof(t) || !t) return t;
|
|
57
55
|
var e = t[Symbol.toPrimitive];
|
|
@@ -64,14 +62,14 @@ function toPrimitive(t, r) {
|
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
//#endregion
|
|
67
|
-
//#region \0@oxc-project+runtime@0.
|
|
65
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPropertyKey.js
|
|
68
66
|
function toPropertyKey(t) {
|
|
69
67
|
var i = toPrimitive(t, "string");
|
|
70
68
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
//#endregion
|
|
74
|
-
//#region \0@oxc-project+runtime@0.
|
|
72
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/defineProperty.js
|
|
75
73
|
function _defineProperty(e, r, t) {
|
|
76
74
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
77
75
|
value: t,
|
|
@@ -140,7 +138,7 @@ const ToggleShortcutPanelOperation = {
|
|
|
140
138
|
} else {
|
|
141
139
|
shortcutPanelService.open();
|
|
142
140
|
sidebarService.open({
|
|
143
|
-
header: { title: "shortcut-panel.title" },
|
|
141
|
+
header: { title: "ui.shortcut-panel.title" },
|
|
144
142
|
children: { label: ShortcutPanelComponentName }
|
|
145
143
|
});
|
|
146
144
|
}
|
|
@@ -368,9 +366,13 @@ function getMenuHiddenObservable(accessor, targetUniverType, matchUnitId, needHi
|
|
|
368
366
|
subscriber.next(univerType !== targetUniverType);
|
|
369
367
|
});
|
|
370
368
|
const focusedUniverInstance = univerInstanceService.getFocusedUnit();
|
|
371
|
-
if (focusedUniverInstance == null)
|
|
372
|
-
|
|
373
|
-
|
|
369
|
+
if (focusedUniverInstance == null) {
|
|
370
|
+
const currentUnit = univerInstanceService.getCurrentUnitOfType(targetUniverType);
|
|
371
|
+
subscriber.next(currentUnit == null);
|
|
372
|
+
} else {
|
|
373
|
+
const univerType = univerInstanceService.getUnitType(focusedUniverInstance.getUnitId());
|
|
374
|
+
subscriber.next(univerType !== targetUniverType);
|
|
375
|
+
}
|
|
374
376
|
return () => subscription.unsubscribe();
|
|
375
377
|
});
|
|
376
378
|
}
|
|
@@ -384,9 +386,11 @@ function getHeaderFooterMenuHiddenObservable(accessor) {
|
|
|
384
386
|
subscriber.next(documentFlavor !== _univerjs_core.DocumentFlavor.TRADITIONAL);
|
|
385
387
|
});
|
|
386
388
|
const docDataModel = univerInstanceService.getCurrentUniverDocInstance();
|
|
387
|
-
if (docDataModel == null)
|
|
388
|
-
|
|
389
|
-
|
|
389
|
+
if (docDataModel == null) subscriber.next(true);
|
|
390
|
+
else {
|
|
391
|
+
const documentFlavor = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot().documentStyle.documentFlavor;
|
|
392
|
+
subscriber.next(documentFlavor !== _univerjs_core.DocumentFlavor.TRADITIONAL);
|
|
393
|
+
}
|
|
390
394
|
return () => subscription.unsubscribe();
|
|
391
395
|
});
|
|
392
396
|
}
|
|
@@ -795,7 +799,7 @@ const configSymbol = Symbol(UI_PLUGIN_CONFIG_KEY);
|
|
|
795
799
|
const defaultPluginConfig = {};
|
|
796
800
|
|
|
797
801
|
//#endregion
|
|
798
|
-
//#region \0@oxc-project+runtime@0.
|
|
802
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/decorateParam.js
|
|
799
803
|
function __decorateParam(paramIndex, decorator) {
|
|
800
804
|
return function(target, key) {
|
|
801
805
|
decorator(target, key, paramIndex);
|
|
@@ -803,7 +807,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
803
807
|
}
|
|
804
808
|
|
|
805
809
|
//#endregion
|
|
806
|
-
//#region \0@oxc-project+runtime@0.
|
|
810
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/decorate.js
|
|
807
811
|
function __decorate(decorators, target, key, desc) {
|
|
808
812
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
809
813
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -817,67 +821,67 @@ const IFontService = (0, _univerjs_core.createIdentifier)("univer.font-service")
|
|
|
817
821
|
const DEFAULT_FONT_LIST = [
|
|
818
822
|
{
|
|
819
823
|
value: "Arial",
|
|
820
|
-
label: "fontFamily.arial",
|
|
824
|
+
label: "ui.fontFamily.arial",
|
|
821
825
|
category: "sans-serif"
|
|
822
826
|
},
|
|
823
827
|
{
|
|
824
828
|
value: "Times New Roman",
|
|
825
|
-
label: "fontFamily.times-new-roman",
|
|
829
|
+
label: "ui.fontFamily.times-new-roman",
|
|
826
830
|
category: "serif"
|
|
827
831
|
},
|
|
828
832
|
{
|
|
829
833
|
value: "Tahoma",
|
|
830
|
-
label: "fontFamily.tahoma",
|
|
834
|
+
label: "ui.fontFamily.tahoma",
|
|
831
835
|
category: "sans-serif"
|
|
832
836
|
},
|
|
833
837
|
{
|
|
834
838
|
value: "Verdana",
|
|
835
|
-
label: "fontFamily.verdana",
|
|
839
|
+
label: "ui.fontFamily.verdana",
|
|
836
840
|
category: "sans-serif"
|
|
837
841
|
},
|
|
838
842
|
{
|
|
839
843
|
value: "Microsoft YaHei",
|
|
840
|
-
label: "fontFamily.microsoft-yahei",
|
|
844
|
+
label: "ui.fontFamily.microsoft-yahei",
|
|
841
845
|
category: "sans-serif"
|
|
842
846
|
},
|
|
843
847
|
{
|
|
844
848
|
value: "SimSun",
|
|
845
|
-
label: "fontFamily.simsun",
|
|
849
|
+
label: "ui.fontFamily.simsun",
|
|
846
850
|
category: "serif"
|
|
847
851
|
},
|
|
848
852
|
{
|
|
849
853
|
value: "SimHei",
|
|
850
|
-
label: "fontFamily.simhei",
|
|
854
|
+
label: "ui.fontFamily.simhei",
|
|
851
855
|
category: "sans-serif"
|
|
852
856
|
},
|
|
853
857
|
{
|
|
854
858
|
value: "Kaiti",
|
|
855
|
-
label: "fontFamily.kaiti",
|
|
859
|
+
label: "ui.fontFamily.kaiti",
|
|
856
860
|
category: "serif"
|
|
857
861
|
},
|
|
858
862
|
{
|
|
859
863
|
value: "FangSong",
|
|
860
|
-
label: "fontFamily.fangsong",
|
|
864
|
+
label: "ui.fontFamily.fangsong",
|
|
861
865
|
category: "serif"
|
|
862
866
|
},
|
|
863
867
|
{
|
|
864
868
|
value: "NSimSun",
|
|
865
|
-
label: "fontFamily.nsimsun",
|
|
869
|
+
label: "ui.fontFamily.nsimsun",
|
|
866
870
|
category: "serif"
|
|
867
871
|
},
|
|
868
872
|
{
|
|
869
873
|
value: "STXinwei",
|
|
870
|
-
label: "fontFamily.stxinwei",
|
|
874
|
+
label: "ui.fontFamily.stxinwei",
|
|
871
875
|
category: "serif"
|
|
872
876
|
},
|
|
873
877
|
{
|
|
874
878
|
value: "STXingkai",
|
|
875
|
-
label: "fontFamily.stxingkai",
|
|
879
|
+
label: "ui.fontFamily.stxingkai",
|
|
876
880
|
category: "serif"
|
|
877
881
|
},
|
|
878
882
|
{
|
|
879
883
|
value: "STLiti",
|
|
880
|
-
label: "fontFamily.stliti",
|
|
884
|
+
label: "ui.fontFamily.stliti",
|
|
881
885
|
category: "serif"
|
|
882
886
|
}
|
|
883
887
|
];
|
|
@@ -1166,7 +1170,7 @@ const FontFamilyItem = ({ id, value }) => {
|
|
|
1166
1170
|
type: "button",
|
|
1167
1171
|
onClick: () => handleSelectFont(font.value),
|
|
1168
1172
|
children: [localeService.t(font.label), !fontService.isFontSupported(font.value) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
|
|
1169
|
-
title: localeService.t("fontFamily.not-supported"),
|
|
1173
|
+
title: localeService.t("ui.fontFamily.not-supported"),
|
|
1170
1174
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.InfoIcon, { className: "univer-text-gray-300 dark:!univer-text-gray-400" })
|
|
1171
1175
|
})]
|
|
1172
1176
|
}) }, font.value))
|
|
@@ -1274,35 +1278,35 @@ const FONT_SIZE_LIST = [
|
|
|
1274
1278
|
];
|
|
1275
1279
|
const HEADING_LIST = [
|
|
1276
1280
|
{
|
|
1277
|
-
label: "toolbar.heading.normal",
|
|
1281
|
+
label: "ui.toolbar.heading.normal",
|
|
1278
1282
|
value: _univerjs_core.NamedStyleType.NORMAL_TEXT
|
|
1279
1283
|
},
|
|
1280
1284
|
{
|
|
1281
|
-
label: "toolbar.heading.title",
|
|
1285
|
+
label: "ui.toolbar.heading.title",
|
|
1282
1286
|
value: _univerjs_core.NamedStyleType.TITLE
|
|
1283
1287
|
},
|
|
1284
1288
|
{
|
|
1285
|
-
label: "toolbar.heading.subTitle",
|
|
1289
|
+
label: "ui.toolbar.heading.subTitle",
|
|
1286
1290
|
value: _univerjs_core.NamedStyleType.SUBTITLE
|
|
1287
1291
|
},
|
|
1288
1292
|
{
|
|
1289
|
-
label: "toolbar.heading.1",
|
|
1293
|
+
label: "ui.toolbar.heading.1",
|
|
1290
1294
|
value: _univerjs_core.NamedStyleType.HEADING_1
|
|
1291
1295
|
},
|
|
1292
1296
|
{
|
|
1293
|
-
label: "toolbar.heading.2",
|
|
1297
|
+
label: "ui.toolbar.heading.2",
|
|
1294
1298
|
value: _univerjs_core.NamedStyleType.HEADING_2
|
|
1295
1299
|
},
|
|
1296
1300
|
{
|
|
1297
|
-
label: "toolbar.heading.3",
|
|
1301
|
+
label: "ui.toolbar.heading.3",
|
|
1298
1302
|
value: _univerjs_core.NamedStyleType.HEADING_3
|
|
1299
1303
|
},
|
|
1300
1304
|
{
|
|
1301
|
-
label: "toolbar.heading.4",
|
|
1305
|
+
label: "ui.toolbar.heading.4",
|
|
1302
1306
|
value: _univerjs_core.NamedStyleType.HEADING_4
|
|
1303
1307
|
},
|
|
1304
1308
|
{
|
|
1305
|
-
label: "toolbar.heading.5",
|
|
1309
|
+
label: "ui.toolbar.heading.5",
|
|
1306
1310
|
value: _univerjs_core.NamedStyleType.HEADING_5
|
|
1307
1311
|
}
|
|
1308
1312
|
];
|
|
@@ -1494,27 +1498,6 @@ const useVirtualList = (list, options) => {
|
|
|
1494
1498
|
}];
|
|
1495
1499
|
};
|
|
1496
1500
|
|
|
1497
|
-
//#endregion
|
|
1498
|
-
//#region src/components/hooks/locale.ts
|
|
1499
|
-
/**
|
|
1500
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1501
|
-
*
|
|
1502
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1503
|
-
* you may not use this file except in compliance with the License.
|
|
1504
|
-
* You may obtain a copy of the License at
|
|
1505
|
-
*
|
|
1506
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1507
|
-
*
|
|
1508
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1509
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1510
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1511
|
-
* See the License for the specific language governing permissions and
|
|
1512
|
-
* limitations under the License.
|
|
1513
|
-
*/
|
|
1514
|
-
function t(localeService, key, ...args) {
|
|
1515
|
-
return localeService.t(key);
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
1501
|
//#endregion
|
|
1519
1502
|
//#region src/components/progress-bar/ProgressBar.tsx
|
|
1520
1503
|
/**
|
|
@@ -2026,15 +2009,17 @@ function whenEditorFocusedButNotCellEditor(contextService) {
|
|
|
2026
2009
|
}
|
|
2027
2010
|
const CopyShortcutItem = {
|
|
2028
2011
|
id: CopyCommand.id,
|
|
2029
|
-
description: "shortcut.copy",
|
|
2012
|
+
description: "ui.shortcut.copy",
|
|
2030
2013
|
group: "1_common-edit",
|
|
2014
|
+
groupTitle: "ui.common-edit",
|
|
2031
2015
|
binding: 67 | 4096,
|
|
2032
2016
|
preconditions: whenEditorFocused
|
|
2033
2017
|
};
|
|
2034
2018
|
const CutShortcutItem = {
|
|
2035
2019
|
id: CutCommand.id,
|
|
2036
|
-
description: "shortcut.cut",
|
|
2020
|
+
description: "ui.shortcut.cut",
|
|
2037
2021
|
group: "1_common-edit",
|
|
2022
|
+
groupTitle: "ui.common-edit",
|
|
2038
2023
|
binding: 88 | 4096,
|
|
2039
2024
|
preconditions: whenEditorFocused
|
|
2040
2025
|
};
|
|
@@ -2043,22 +2028,25 @@ const CutShortcutItem = {
|
|
|
2043
2028
|
*/
|
|
2044
2029
|
const OnlyDisplayPasteShortcutItem = {
|
|
2045
2030
|
id: PasteCommand.id,
|
|
2046
|
-
description: "shortcut.paste",
|
|
2031
|
+
description: "ui.shortcut.paste",
|
|
2047
2032
|
group: "1_common-edit",
|
|
2033
|
+
groupTitle: "ui.common-edit",
|
|
2048
2034
|
binding: 86 | 4096,
|
|
2049
2035
|
preconditions: () => false
|
|
2050
2036
|
};
|
|
2051
2037
|
const UndoShortcutItem = {
|
|
2052
2038
|
id: _univerjs_core.UndoCommand.id,
|
|
2053
|
-
description: "shortcut.undo",
|
|
2039
|
+
description: "ui.shortcut.undo",
|
|
2054
2040
|
group: "1_common-edit",
|
|
2041
|
+
groupTitle: "ui.common-edit",
|
|
2055
2042
|
binding: 90 | 4096,
|
|
2056
2043
|
preconditions: whenEditorFocusedButNotCellEditor
|
|
2057
2044
|
};
|
|
2058
2045
|
const RedoShortcutItem = {
|
|
2059
2046
|
id: _univerjs_core.RedoCommand.id,
|
|
2060
|
-
description: "shortcut.redo",
|
|
2047
|
+
description: "ui.shortcut.redo",
|
|
2061
2048
|
group: "1_common-edit",
|
|
2049
|
+
groupTitle: "ui.common-edit",
|
|
2062
2050
|
binding: 89 | 4096,
|
|
2063
2051
|
preconditions: whenEditorFocusedButNotCellEditor
|
|
2064
2052
|
};
|
|
@@ -2195,6 +2183,7 @@ let MenuManagerService = class MenuManagerService extends _univerjs_core.Disposa
|
|
|
2195
2183
|
["ribbon"]: {
|
|
2196
2184
|
["ribbon.start"]: {
|
|
2197
2185
|
order: 0,
|
|
2186
|
+
title: "ui.ribbon.start",
|
|
2198
2187
|
["ribbon.start.history"]: { order: 0 },
|
|
2199
2188
|
["ribbon.start.format"]: { order: 1 },
|
|
2200
2189
|
["ribbon.start.layout"]: { order: 2 },
|
|
@@ -2202,17 +2191,20 @@ let MenuManagerService = class MenuManagerService extends _univerjs_core.Disposa
|
|
|
2202
2191
|
},
|
|
2203
2192
|
["ribbon.insert"]: {
|
|
2204
2193
|
order: 1,
|
|
2194
|
+
title: "ui.ribbon.insert",
|
|
2205
2195
|
["ribbon.insert.edit"]: { order: 0 },
|
|
2206
2196
|
["ribbon.insert.media"]: { order: 1 },
|
|
2207
2197
|
["ribbon.insert.others"]: { order: 2 }
|
|
2208
2198
|
},
|
|
2209
2199
|
["ribbon.formulas"]: {
|
|
2210
2200
|
order: 2,
|
|
2201
|
+
title: "ui.ribbon.formulas",
|
|
2211
2202
|
["ribbon.formulas.basic"]: { order: 0 },
|
|
2212
2203
|
["ribbon.formulas.others"]: { order: 1 }
|
|
2213
2204
|
},
|
|
2214
2205
|
["ribbon.data"]: {
|
|
2215
2206
|
order: 3,
|
|
2207
|
+
title: "ui.ribbon.data",
|
|
2216
2208
|
["ribbon.data.formulas"]: { order: 0 },
|
|
2217
2209
|
["ribbon.data.rules"]: { order: 1 },
|
|
2218
2210
|
["ribbon.data.organization"]: { order: 2 },
|
|
@@ -2220,12 +2212,14 @@ let MenuManagerService = class MenuManagerService extends _univerjs_core.Disposa
|
|
|
2220
2212
|
},
|
|
2221
2213
|
["ribbon.view"]: {
|
|
2222
2214
|
order: 4,
|
|
2215
|
+
title: "ui.ribbon.view",
|
|
2223
2216
|
["ribbon.view.display"]: { order: 0 },
|
|
2224
2217
|
["ribbon.view.Visibility"]: { order: 0 },
|
|
2225
2218
|
["ribbon.view.others"]: { order: 0 }
|
|
2226
2219
|
},
|
|
2227
2220
|
["ribbon.others"]: {
|
|
2228
2221
|
order: 5,
|
|
2222
|
+
title: "ui.ribbon.others",
|
|
2229
2223
|
["ribbon.others.others"]: { order: 0 }
|
|
2230
2224
|
}
|
|
2231
2225
|
},
|
|
@@ -2320,7 +2314,8 @@ let MenuManagerService = class MenuManagerService extends _univerjs_core.Disposa
|
|
|
2320
2314
|
order: value.order,
|
|
2321
2315
|
title: value.title,
|
|
2322
2316
|
contextual: value.contextual,
|
|
2323
|
-
quickLayout: value.quickLayout
|
|
2317
|
+
quickLayout: value.quickLayout,
|
|
2318
|
+
tiny: value.tiny
|
|
2324
2319
|
};
|
|
2325
2320
|
if (value.menuItemFactory) {
|
|
2326
2321
|
const item = this._injector.invoke(value.menuItemFactory);
|
|
@@ -2338,7 +2333,7 @@ let MenuManagerService = class MenuManagerService extends _univerjs_core.Disposa
|
|
|
2338
2333
|
if (menuItem.item || menuItem.children) result.push(menuItem);
|
|
2339
2334
|
}
|
|
2340
2335
|
}
|
|
2341
|
-
return result;
|
|
2336
|
+
return result.sort((a, b) => normalizeMenuOrder(a.order) - normalizeMenuOrder(b.order));
|
|
2342
2337
|
}
|
|
2343
2338
|
/**
|
|
2344
2339
|
* Get menu schema by position key
|
|
@@ -2379,6 +2374,9 @@ let MenuManagerService = class MenuManagerService extends _univerjs_core.Disposa
|
|
|
2379
2374
|
}
|
|
2380
2375
|
};
|
|
2381
2376
|
MenuManagerService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, _univerjs_core.IConfigService)], MenuManagerService);
|
|
2377
|
+
function normalizeMenuOrder(order) {
|
|
2378
|
+
return order !== null && order !== void 0 ? order : 0;
|
|
2379
|
+
}
|
|
2382
2380
|
|
|
2383
2381
|
//#endregion
|
|
2384
2382
|
//#region src/views/components/shortcut-panel/ShortcutPanel.tsx
|
|
@@ -2408,6 +2406,7 @@ function ShortcutPanel() {
|
|
|
2408
2406
|
const updateShortcuts = (0, react.useCallback)(() => {
|
|
2409
2407
|
const shortcutGroups = /* @__PURE__ */ new Map();
|
|
2410
2408
|
const shortcuts = shortcutService.getAllShortcuts().filter((item) => !!item.group);
|
|
2409
|
+
const groupTitles = /* @__PURE__ */ new Map();
|
|
2411
2410
|
for (const shortcut of shortcuts) {
|
|
2412
2411
|
var _shortcut$description;
|
|
2413
2412
|
const group = shortcut.group;
|
|
@@ -2415,16 +2414,18 @@ function ShortcutPanel() {
|
|
|
2415
2414
|
title: localeService.t((_shortcut$description = shortcut.description) !== null && _shortcut$description !== void 0 ? _shortcut$description : shortcut.id),
|
|
2416
2415
|
shortcut: shortcutService.getShortcutDisplay(shortcut)
|
|
2417
2416
|
};
|
|
2418
|
-
if (
|
|
2417
|
+
if (!/^\d+_/.test(group)) throw new Error(`[ShortcutPanel]: Invalid shortcut group: ${group}!`);
|
|
2418
|
+
if (!shortcut.groupTitle) throw new Error(`[ShortcutPanel]: Shortcut group "${group}" must provide a groupTitle!`);
|
|
2419
|
+
if (!groupTitles.has(group)) groupTitles.set(group, shortcut.groupTitle);
|
|
2419
2420
|
if (!shortcutGroups.has(group)) shortcutGroups.set(group, []);
|
|
2420
2421
|
shortcutGroups.get(group).push(shortcutItem);
|
|
2421
2422
|
}
|
|
2422
2423
|
setShortcutItems(Array.from(shortcutGroups.entries()).map(([name, items]) => {
|
|
2423
2424
|
const groupSequence = name.split("_")[0];
|
|
2424
|
-
const
|
|
2425
|
+
const localeKey = groupTitles.get(name);
|
|
2425
2426
|
return {
|
|
2426
2427
|
sequence: +groupSequence,
|
|
2427
|
-
name: localeService.t(
|
|
2428
|
+
name: localeService.t(localeKey),
|
|
2428
2429
|
items: (0, _univerjs_core.dedupeBy)(items, (item) => item.title + item.shortcut)
|
|
2429
2430
|
};
|
|
2430
2431
|
}).sort((a, b) => a.sequence - b.sequence));
|
|
@@ -2461,8 +2462,9 @@ function ShortcutPanel() {
|
|
|
2461
2462
|
const ToggleShortcutPanelShortcut = {
|
|
2462
2463
|
id: ToggleShortcutPanelOperation.id,
|
|
2463
2464
|
binding: 4096 | 220,
|
|
2464
|
-
description: "shortcut.shortcut-panel",
|
|
2465
|
-
group: "10_global-shortcut"
|
|
2465
|
+
description: "ui.shortcut.shortcut-panel",
|
|
2466
|
+
group: "10_global-shortcut",
|
|
2467
|
+
groupTitle: "ui.global-shortcut"
|
|
2466
2468
|
};
|
|
2467
2469
|
let ShortcutPanelController = class ShortcutPanelController extends _univerjs_core.Disposable {
|
|
2468
2470
|
constructor(injector, componentManager, shortcutService, _menuManagerService, commandService) {
|
|
@@ -2513,7 +2515,7 @@ function UndoMenuItemFactory(accessor) {
|
|
|
2513
2515
|
type: 0,
|
|
2514
2516
|
icon: "UndoIcon",
|
|
2515
2517
|
title: "Undo",
|
|
2516
|
-
tooltip: "
|
|
2518
|
+
tooltip: "ui.shortcut.undo",
|
|
2517
2519
|
disabled$: undoRedoDisableFactory$(accessor, true)
|
|
2518
2520
|
};
|
|
2519
2521
|
}
|
|
@@ -2523,7 +2525,7 @@ function RedoMenuItemFactory(accessor) {
|
|
|
2523
2525
|
type: 0,
|
|
2524
2526
|
icon: "RedoIcon",
|
|
2525
2527
|
title: "Redo",
|
|
2526
|
-
tooltip: "
|
|
2528
|
+
tooltip: "ui.shortcut.redo",
|
|
2527
2529
|
disabled$: undoRedoDisableFactory$(accessor, false)
|
|
2528
2530
|
};
|
|
2529
2531
|
}
|
|
@@ -2533,8 +2535,8 @@ function RedoMenuItemFactory(accessor) {
|
|
|
2533
2535
|
function ShortcutPanelMenuItemFactory() {
|
|
2534
2536
|
return {
|
|
2535
2537
|
id: ToggleShortcutPanelOperation.id,
|
|
2536
|
-
title: "toggle-shortcut-panel",
|
|
2537
|
-
tooltip: "toggle-shortcut-panel",
|
|
2538
|
+
title: "ui.toggle-shortcut-panel",
|
|
2539
|
+
tooltip: "ui.toggle-shortcut-panel",
|
|
2538
2540
|
icon: "ShortcutIcon",
|
|
2539
2541
|
type: 0
|
|
2540
2542
|
};
|
|
@@ -3084,6 +3086,7 @@ let DesktopRibbonService = class DesktopRibbonService extends _univerjs_core.Dis
|
|
|
3084
3086
|
_defineProperty(this, "_visibleContextualTabs", /* @__PURE__ */ new Set());
|
|
3085
3087
|
_defineProperty(this, "_contextualTabs", /* @__PURE__ */ new Set());
|
|
3086
3088
|
_defineProperty(this, "_lastNonContextualActivatedTab", "ribbon.start");
|
|
3089
|
+
_defineProperty(this, "_hiddenSubscription", null);
|
|
3087
3090
|
this._initRibbonSubscription();
|
|
3088
3091
|
}
|
|
3089
3092
|
setActivatedTab(tab) {
|
|
@@ -3116,6 +3119,7 @@ let DesktopRibbonService = class DesktopRibbonService extends _univerjs_core.Dis
|
|
|
3116
3119
|
}));
|
|
3117
3120
|
}
|
|
3118
3121
|
_updateRibbon() {
|
|
3122
|
+
var _this$_hiddenSubscrip;
|
|
3119
3123
|
const ribbon = this._filterContextualTabs(this._menuManagerService.getMenuByPositionKey("ribbon"));
|
|
3120
3124
|
const hiddenObservableMap = [];
|
|
3121
3125
|
const hiddenKeyMap = [];
|
|
@@ -3132,7 +3136,8 @@ let DesktopRibbonService = class DesktopRibbonService extends _univerjs_core.Dis
|
|
|
3132
3136
|
this._setRibbon(ribbon);
|
|
3133
3137
|
return;
|
|
3134
3138
|
}
|
|
3135
|
-
(
|
|
3139
|
+
(_this$_hiddenSubscrip = this._hiddenSubscription) === null || _this$_hiddenSubscrip === void 0 || _this$_hiddenSubscrip.unsubscribe();
|
|
3140
|
+
this._hiddenSubscription = (0, rxjs.combineLatest)(hiddenObservableMap).pipe((0, rxjs_operators.startWith)(new Array(hiddenObservableMap.length).fill(false))).subscribe((hiddenMap) => {
|
|
3136
3141
|
const newRibbon = [];
|
|
3137
3142
|
const hiddenPathMap = hiddenMap.map((hidden, index) => {
|
|
3138
3143
|
if (hidden) return hiddenKeyMap[index];
|
|
@@ -3173,7 +3178,7 @@ let DesktopRibbonService = class DesktopRibbonService extends _univerjs_core.Dis
|
|
|
3173
3178
|
})) newRibbon.push(newGroup);
|
|
3174
3179
|
}
|
|
3175
3180
|
this._setRibbon(newRibbon);
|
|
3176
|
-
})
|
|
3181
|
+
});
|
|
3177
3182
|
}
|
|
3178
3183
|
_filterContextualTabs(ribbon) {
|
|
3179
3184
|
this._contextualTabs.clear();
|
|
@@ -3189,12 +3194,27 @@ let DesktopRibbonService = class DesktopRibbonService extends _univerjs_core.Dis
|
|
|
3189
3194
|
var _ref, _ribbon$find;
|
|
3190
3195
|
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];
|
|
3191
3196
|
if (fallbackTab) this._activatedTab$.next(fallbackTab.key);
|
|
3197
|
+
} else if (!activeGroup && ribbon.some((group) => group.key === "ribbon.start")) {
|
|
3198
|
+
const fallbackTab = ribbon.find((group) => group.key === "ribbon.start");
|
|
3199
|
+
this._activatedTab$.next(fallbackTab.key);
|
|
3200
|
+
if (!fallbackTab.contextual) this._lastNonContextualActivatedTab = fallbackTab.key;
|
|
3192
3201
|
} else if (activeGroup && !activeGroup.contextual) this._lastNonContextualActivatedTab = activeGroup.key;
|
|
3193
3202
|
this._ribbon$.next(ribbon);
|
|
3194
3203
|
}
|
|
3195
3204
|
_isContextualTab(tab) {
|
|
3196
3205
|
return this._contextualTabs.has(tab) || this._ribbon$.getValue().some((group) => group.key === tab && group.contextual);
|
|
3197
3206
|
}
|
|
3207
|
+
dispose() {
|
|
3208
|
+
var _this$_hiddenSubscrip2;
|
|
3209
|
+
(_this$_hiddenSubscrip2 = this._hiddenSubscription) === null || _this$_hiddenSubscrip2 === void 0 || _this$_hiddenSubscrip2.unsubscribe();
|
|
3210
|
+
this._hiddenSubscription = null;
|
|
3211
|
+
this._ribbon$.next([]);
|
|
3212
|
+
this._ribbon$.complete();
|
|
3213
|
+
this._activatedTab$.complete();
|
|
3214
|
+
this._collapsedIds$.complete();
|
|
3215
|
+
this._fakeToolbarVisible$.complete();
|
|
3216
|
+
super.dispose();
|
|
3217
|
+
}
|
|
3198
3218
|
};
|
|
3199
3219
|
DesktopRibbonService = __decorate([__decorateParam(0, IMenuManagerService), __decorateParam(1, _univerjs_core.IUniverInstanceService)], DesktopRibbonService);
|
|
3200
3220
|
|
|
@@ -3237,14 +3257,14 @@ function ClassicMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
|
3237
3257
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3238
3258
|
className: "univer-flex univer-size-full univer-items-center univer-justify-center univer-gap-1 univer-overflow-x-auto univer-rounded-md univer-bg-gray-50 univer-px-3 dark:!univer-bg-gray-900",
|
|
3239
3259
|
role: "tablist",
|
|
3240
|
-
"aria-label": localeService.t("ribbon.menu"),
|
|
3260
|
+
"aria-label": localeService.t("ui.ribbon.menu"),
|
|
3241
3261
|
children: ribbon.map((group) => {
|
|
3242
3262
|
const isActive = activatedTab === group.key;
|
|
3243
3263
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3244
3264
|
type: "button",
|
|
3245
3265
|
role: "tab",
|
|
3246
3266
|
"aria-selected": isActive,
|
|
3247
|
-
title: localeService.t(group.key),
|
|
3267
|
+
title: localeService.t(group.title || group.key),
|
|
3248
3268
|
onClick: () => onSelectTab(group),
|
|
3249
3269
|
className: (0, _univerjs_design.clsx)("univer-focus:outline-none univer-focus:ring-2 univer-focus:ring-primary-500 dark:!univer-focus:ring-primary-300 univer-flex univer-cursor-pointer univer-appearance-none univer-items-center univer-gap-1 univer-rounded-sm univer-border-none univer-px-2 univer-py-1 univer-text-sm univer-transition-colors", isActive ? `
|
|
3250
3270
|
univer-bg-primary-50 univer-font-semibold univer-text-primary-600 univer-shadow-sm
|
|
@@ -3255,7 +3275,7 @@ function ClassicMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
|
3255
3275
|
univer-bg-transparent univer-text-gray-700
|
|
3256
3276
|
dark:!univer-text-gray-200
|
|
3257
3277
|
`),
|
|
3258
|
-
children: localeService.t(group.key)
|
|
3278
|
+
children: localeService.t(group.title || group.key)
|
|
3259
3279
|
}, group.key);
|
|
3260
3280
|
})
|
|
3261
3281
|
});
|
|
@@ -3272,7 +3292,9 @@ const iconMap = {
|
|
|
3272
3292
|
["ribbon.others"]: _univerjs_icons.MoreFunctionIcon
|
|
3273
3293
|
};
|
|
3274
3294
|
function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
3295
|
+
var _ribbon$find;
|
|
3275
3296
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
3297
|
+
const activatedTabTitle = ((_ribbon$find = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find === void 0 ? void 0 : _ribbon$find.title) || activatedTab;
|
|
3276
3298
|
const [groupSelectorVisible, setGroupSelectorVisible] = (0, react.useState)(false);
|
|
3277
3299
|
function handleSelectTab(tab) {
|
|
3278
3300
|
onSelectTab(tab);
|
|
@@ -3299,10 +3321,10 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
|
3299
3321
|
className: "univer-flex univer-flex-col",
|
|
3300
3322
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
3301
3323
|
className: "univer-text-sm univer-font-semibold univer-text-gray-800 dark:!univer-text-gray-200",
|
|
3302
|
-
children: localeService.t(group.key)
|
|
3324
|
+
children: localeService.t(group.title || group.key)
|
|
3303
3325
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3304
3326
|
className: "univer-text-xs univer-text-gray-400",
|
|
3305
|
-
children: localeService.t(`${group.key}Desc`)
|
|
3327
|
+
children: localeService.t(`${group.title || group.key}Desc`)
|
|
3306
3328
|
})]
|
|
3307
3329
|
})]
|
|
3308
3330
|
}, group.key);
|
|
@@ -3312,7 +3334,7 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
|
3312
3334
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
|
|
3313
3335
|
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",
|
|
3314
3336
|
onClick: () => setGroupSelectorVisible(true),
|
|
3315
|
-
children: [localeService.t(
|
|
3337
|
+
children: [localeService.t(activatedTabTitle), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "univer-text-gray-200 dark:!univer-text-gray-500" })]
|
|
3316
3338
|
})
|
|
3317
3339
|
});
|
|
3318
3340
|
}
|
|
@@ -3403,8 +3425,13 @@ function useToolbarItemStatus(menuItem) {
|
|
|
3403
3425
|
disabled$ && subscriptions.push(disabled$.subscribe((disabled) => setDisabled(disabled)));
|
|
3404
3426
|
hidden$ && subscriptions.push(hidden$.subscribe((hidden) => setHidden(hidden)));
|
|
3405
3427
|
activated$ && subscriptions.push(activated$.subscribe((activated) => setActivated(activated)));
|
|
3406
|
-
value$ && subscriptions.push(value$.subscribe((value) =>
|
|
3407
|
-
|
|
3428
|
+
value$ && subscriptions.push(value$.subscribe((value) => {
|
|
3429
|
+
setValue(value);
|
|
3430
|
+
}));
|
|
3431
|
+
selectionsValue$ && subscriptions.push(selectionsValue$.subscribe((value) => {
|
|
3432
|
+
setSelectionsValue(value);
|
|
3433
|
+
setValue(value);
|
|
3434
|
+
}));
|
|
3408
3435
|
return () => subscriptions.forEach((subscription) => subscription.unsubscribe());
|
|
3409
3436
|
}, [
|
|
3410
3437
|
activated$,
|
|
@@ -3534,6 +3561,10 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3534
3561
|
function handleVisibleChange(visible) {
|
|
3535
3562
|
setDropdownVisible(visible);
|
|
3536
3563
|
}
|
|
3564
|
+
function handleOptionSelect(option) {
|
|
3565
|
+
onOptionSelect(option);
|
|
3566
|
+
setDropdownVisible(false);
|
|
3567
|
+
}
|
|
3537
3568
|
(0, react.useEffect)(() => {
|
|
3538
3569
|
const subscriptions = [];
|
|
3539
3570
|
menuItems.forEach((item) => {
|
|
@@ -3572,7 +3603,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3572
3603
|
overlay: options.map((option, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
|
|
3573
3604
|
value,
|
|
3574
3605
|
option,
|
|
3575
|
-
onOptionSelect
|
|
3606
|
+
onOptionSelect: handleOptionSelect
|
|
3576
3607
|
}, index)),
|
|
3577
3608
|
children
|
|
3578
3609
|
});
|
|
@@ -3586,15 +3617,16 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3586
3617
|
icon: option.icon,
|
|
3587
3618
|
value,
|
|
3588
3619
|
option,
|
|
3589
|
-
onOptionSelect
|
|
3620
|
+
onOptionSelect: handleOptionSelect
|
|
3590
3621
|
}),
|
|
3591
3622
|
disabled: option.disabled,
|
|
3592
3623
|
onSelect: () => {
|
|
3593
3624
|
if (typeof option.value === "undefined") return;
|
|
3594
|
-
|
|
3625
|
+
handleOptionSelect({ ...option });
|
|
3595
3626
|
}
|
|
3596
3627
|
};
|
|
3597
3628
|
});
|
|
3629
|
+
if (filteredMenuItems.length) items.push({ type: "separator" });
|
|
3598
3630
|
for (const menuItem of filteredMenuItems) {
|
|
3599
3631
|
if (!menuItem.item) continue;
|
|
3600
3632
|
const { title, id, commandId, icon } = menuItem.item;
|
|
@@ -3610,7 +3642,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3610
3642
|
} }
|
|
3611
3643
|
}),
|
|
3612
3644
|
onSelect: () => {
|
|
3613
|
-
|
|
3645
|
+
handleOptionSelect({
|
|
3614
3646
|
commandId,
|
|
3615
3647
|
id
|
|
3616
3648
|
});
|
|
@@ -3643,7 +3675,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3643
3675
|
} }
|
|
3644
3676
|
}),
|
|
3645
3677
|
onSelect: () => {
|
|
3646
|
-
|
|
3678
|
+
handleOptionSelect({
|
|
3647
3679
|
commandId,
|
|
3648
3680
|
id
|
|
3649
3681
|
});
|
|
@@ -3669,7 +3701,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3669
3701
|
const commandService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ICommandService);
|
|
3670
3702
|
const layoutService = (0, _wendellhu_redi_react_bindings.useDependency)(ILayoutService);
|
|
3671
3703
|
const componentManager = (0, _wendellhu_redi_react_bindings.useDependency)(ComponentManager);
|
|
3672
|
-
const { value, hidden, disabled, activated
|
|
3704
|
+
const { value, hidden, disabled, activated } = useToolbarItemStatus(props);
|
|
3673
3705
|
const executeCommand = (commandId, params) => {
|
|
3674
3706
|
layoutService.focus();
|
|
3675
3707
|
commandService.executeCommand(commandId, params);
|
|
@@ -3730,7 +3762,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3730
3762
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
|
|
3731
3763
|
icon: iconToDisplay,
|
|
3732
3764
|
title,
|
|
3733
|
-
value
|
|
3765
|
+
value,
|
|
3734
3766
|
label,
|
|
3735
3767
|
onChange: handleSelectionsValueChange
|
|
3736
3768
|
})
|
|
@@ -3849,13 +3881,17 @@ function Ribbon(props) {
|
|
|
3849
3881
|
}
|
|
3850
3882
|
return ribbonData;
|
|
3851
3883
|
}, [ribbonType, ribbonData]);
|
|
3884
|
+
const activatedTabTitle = (0, react.useMemo)(() => {
|
|
3885
|
+
var _ribbon$find;
|
|
3886
|
+
return ((_ribbon$find = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find === void 0 ? void 0 : _ribbon$find.title) || activatedTab;
|
|
3887
|
+
}, [ribbon, activatedTab]);
|
|
3852
3888
|
const handleSelectTab = (0, react.useCallback)((group) => {
|
|
3853
3889
|
toolbarItemRefs.current = {};
|
|
3854
3890
|
ribbonService.setActivatedTab(group.key);
|
|
3855
3891
|
}, []);
|
|
3856
3892
|
const activeGroup = (0, react.useMemo)(() => {
|
|
3857
|
-
var _ribbon$find$children, _ribbon$
|
|
3858
|
-
const allGroups = (_ribbon$find$children = (_ribbon$
|
|
3893
|
+
var _ribbon$find$children, _ribbon$find2;
|
|
3894
|
+
const allGroups = (_ribbon$find$children = (_ribbon$find2 = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find2 === void 0 ? void 0 : _ribbon$find2.children) !== null && _ribbon$find$children !== void 0 ? _ribbon$find$children : [];
|
|
3859
3895
|
const visibleGroups = [];
|
|
3860
3896
|
const hiddenGroups = [];
|
|
3861
3897
|
for (const item of allGroups) if (item.children) {
|
|
@@ -3885,14 +3921,14 @@ function Ribbon(props) {
|
|
|
3885
3921
|
for (const entry of entries) {
|
|
3886
3922
|
ribbonService.setFakeToolbarVisible(true);
|
|
3887
3923
|
timer = requestAnimationFrame(() => {
|
|
3888
|
-
var _ribbon$find$children2, _ribbon$
|
|
3924
|
+
var _ribbon$find$children2, _ribbon$find3;
|
|
3889
3925
|
const { width: avaliableWidth } = entry.contentRect;
|
|
3890
3926
|
const sortedToolbarItems = Object.values(toolbarItemRefs.current).sort((a, b) => {
|
|
3891
3927
|
return a.order - b.order || a.groupOrder - b.groupOrder || a.itemOrder - b.itemOrder;
|
|
3892
3928
|
});
|
|
3893
3929
|
const newCollapsedIds = [];
|
|
3894
3930
|
let totalWidth = 32;
|
|
3895
|
-
const gapWidth = (((_ribbon$find$children2 = (_ribbon$
|
|
3931
|
+
const gapWidth = (((_ribbon$find$children2 = (_ribbon$find3 = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find3 === void 0 ? void 0 : _ribbon$find3.children) !== null && _ribbon$find$children2 !== void 0 ? _ribbon$find$children2 : []).length - 1) * 8;
|
|
3896
3932
|
totalWidth += gapWidth;
|
|
3897
3933
|
for (const { el, key } of sortedToolbarItems) {
|
|
3898
3934
|
const { width } = el.getBoundingClientRect();
|
|
@@ -3917,7 +3953,7 @@ function Ribbon(props) {
|
|
|
3917
3953
|
children: activeGroup.allGroups.map((groupItem, index) => {
|
|
3918
3954
|
var _groupItem$children, _groupItem$children2;
|
|
3919
3955
|
return (((_groupItem$children = groupItem.children) === null || _groupItem$children === void 0 ? void 0 : _groupItem$children.length) || groupItem.item) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3920
|
-
className: "univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2",
|
|
3956
|
+
className: "\n univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2\n empty:univer-hidden\n ",
|
|
3921
3957
|
children: groupItem.children && ((_groupItem$children2 = groupItem.children) === null || _groupItem$children2 === void 0 ? void 0 : _groupItem$children2.map((child) => child.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, {
|
|
3922
3958
|
...child.item,
|
|
3923
3959
|
ref: (ref) => {
|
|
@@ -3938,7 +3974,7 @@ function Ribbon(props) {
|
|
|
3938
3974
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3939
3975
|
"data-u-comp": "ribbon-header-menu",
|
|
3940
3976
|
className: (0, _univerjs_design.clsx)("univer-relative univer-select-none", { "univer-h-9": ribbonType === "classic" || headerMenuComponents && headerMenuComponents.size > 0 }),
|
|
3941
|
-
children: [ribbonType === "classic" && ribbon.length
|
|
3977
|
+
children: [ribbonType === "classic" && ribbon.length >= 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ClassicMenu, {
|
|
3942
3978
|
ribbon,
|
|
3943
3979
|
activatedTab,
|
|
3944
3980
|
onSelectTab: handleSelectTab
|
|
@@ -3949,11 +3985,10 @@ function Ribbon(props) {
|
|
|
3949
3985
|
}),
|
|
3950
3986
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3951
3987
|
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", {
|
|
3952
|
-
"univer-grid-cols-[1fr] univer-justify-center": ribbonType === "classic",
|
|
3953
|
-
"univer-grid-cols-[auto,1fr]": ribbon.length > 1 && ribbonType !== "classic"
|
|
3954
|
-
"univer-grid-cols-none": ribbon.length === 1
|
|
3988
|
+
"univer-grid-cols-[1fr] univer-justify-center": ribbonType === "classic" || ribbon.length === 1,
|
|
3989
|
+
"univer-grid-cols-[auto,1fr]": ribbon.length > 1 && ribbonType !== "classic"
|
|
3955
3990
|
}, _univerjs_design.borderBottomClassName),
|
|
3956
|
-
children: [ribbonType === "collapsed" && ribbon.length
|
|
3991
|
+
children: [ribbonType === "collapsed" && ribbon.length >= 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultMenu, {
|
|
3957
3992
|
ribbon,
|
|
3958
3993
|
activatedTab,
|
|
3959
3994
|
onSelectTab: handleSelectTab
|
|
@@ -3962,11 +3997,11 @@ function Ribbon(props) {
|
|
|
3962
3997
|
ref: containerRef,
|
|
3963
3998
|
className: (0, _univerjs_design.clsx)("univer-flex univer-overflow-hidden", _univerjs_design.divideXClassName, { "univer-justify-center": ribbonType === "classic" }),
|
|
3964
3999
|
role: "toolbar",
|
|
3965
|
-
"aria-label": localeService.t(
|
|
4000
|
+
"aria-label": localeService.t(activatedTabTitle),
|
|
3966
4001
|
children: [activeGroup.visibleGroups.map((groupItem) => {
|
|
3967
4002
|
var _groupItem$children3, _groupItem$children4;
|
|
3968
4003
|
return (((_groupItem$children3 = groupItem.children) === null || _groupItem$children3 === void 0 ? void 0 : _groupItem$children3.length) || groupItem.item) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3969
|
-
className: "univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2",
|
|
4004
|
+
className: "\n univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2\n empty:univer-hidden\n ",
|
|
3970
4005
|
children: groupItem.children && ((_groupItem$children4 = groupItem.children) === null || _groupItem$children4 === void 0 ? void 0 : _groupItem$children4.map((child) => child.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, { ...child.item }, child.key)))
|
|
3971
4006
|
}) }, groupItem.key);
|
|
3972
4007
|
}), collapsedIds.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -3994,7 +4029,7 @@ function Ribbon(props) {
|
|
|
3994
4029
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3995
4030
|
type: "button",
|
|
3996
4031
|
className: toolbarButtonClassName,
|
|
3997
|
-
"aria-label": localeService.t("ribbon.more"),
|
|
4032
|
+
"aria-label": localeService.t("ui.ribbon.more"),
|
|
3998
4033
|
"aria-haspopup": "true",
|
|
3999
4034
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreFunctionIcon, {})
|
|
4000
4035
|
})
|
|
@@ -4119,7 +4154,7 @@ function DesignTinyMenuGroup({ items }) {
|
|
|
4119
4154
|
const ele = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4120
4155
|
className: (0, _univerjs_design.clsx)("univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-md hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-900", { "univer-bg-gray-50 dark:!univer-bg-gray-900": item.active }, item.className),
|
|
4121
4156
|
onClick: () => item.onClick(),
|
|
4122
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(item.Icon, { className: "univer-size-4 univer-text-gray-900 dark:!univer-text-gray-200" })
|
|
4157
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(item.Icon, { className: (0, _univerjs_design.clsx)("univer-size-4 univer-text-gray-900 dark:!univer-text-gray-200", item.iconClassName) })
|
|
4123
4158
|
}, item.key);
|
|
4124
4159
|
return item.tooltip ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
|
|
4125
4160
|
title: item.tooltip,
|
|
@@ -4131,8 +4166,21 @@ function DesignTinyMenuGroup({ items }) {
|
|
|
4131
4166
|
|
|
4132
4167
|
//#endregion
|
|
4133
4168
|
//#region src/components/menu/desktop/TinyMenuGroup.tsx
|
|
4169
|
+
const EMPTY_HIDDEN_ITEM_IDS = [];
|
|
4170
|
+
function resolveMenuItemActiveState(itemId, observableActive, activeItemIds) {
|
|
4171
|
+
if (activeItemIds) return Boolean(itemId && activeItemIds.includes(itemId));
|
|
4172
|
+
return observableActive;
|
|
4173
|
+
}
|
|
4174
|
+
function getTinyMenuChildStateKey(child) {
|
|
4175
|
+
var _child$item$id, _child$item;
|
|
4176
|
+
return (_child$item$id = (_child$item = child.item) === null || _child$item === void 0 ? void 0 : _child$item.id) !== null && _child$item$id !== void 0 ? _child$item$id : child.key;
|
|
4177
|
+
}
|
|
4178
|
+
function getVisibleTinyMenuChildren(children, hiddenItemKeys) {
|
|
4179
|
+
const hiddenSet = new Set(hiddenItemKeys);
|
|
4180
|
+
return children.filter((child) => !hiddenSet.has(getTinyMenuChildStateKey(child)));
|
|
4181
|
+
}
|
|
4134
4182
|
function QuickTileMenuItem(props) {
|
|
4135
|
-
const { menuSchema, onOptionSelect } = props;
|
|
4183
|
+
const { menuSchema, activeItemIds, onOptionSelect } = props;
|
|
4136
4184
|
const componentManager = (0, _wendellhu_redi_react_bindings.useDependency)(ComponentManager);
|
|
4137
4185
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
4138
4186
|
const menuItem = menuSchema.item;
|
|
@@ -4147,7 +4195,7 @@ function QuickTileMenuItem(props) {
|
|
|
4147
4195
|
univer-cursor-pointer
|
|
4148
4196
|
hover:univer-bg-gray-50
|
|
4149
4197
|
dark:hover:!univer-bg-gray-600
|
|
4150
|
-
`, activated && `
|
|
4198
|
+
`, resolveMenuItemActiveState(menuItem.id, activated, activeItemIds) && `
|
|
4151
4199
|
univer-bg-primary-50 univer-text-primary-700 univer-ring-1 univer-ring-primary-600
|
|
4152
4200
|
dark:!univer-bg-primary-900 dark:!univer-text-primary-100
|
|
4153
4201
|
`),
|
|
@@ -4172,20 +4220,21 @@ function QuickTileMenuItem(props) {
|
|
|
4172
4220
|
});
|
|
4173
4221
|
}
|
|
4174
4222
|
function UITinyMenuGroup(props) {
|
|
4175
|
-
const { item, onOptionSelect } = props;
|
|
4223
|
+
const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, onOptionSelect } = props;
|
|
4176
4224
|
const [activeItems, setActiveItems] = (0, react.useState)([]);
|
|
4225
|
+
const [hiddenItems, setHiddenItems] = (0, react.useState)([]);
|
|
4177
4226
|
const componentManager = (0, _wendellhu_redi_react_bindings.useDependency)(ComponentManager);
|
|
4178
4227
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
4179
4228
|
(0, react.useEffect)(() => {
|
|
4180
4229
|
if (!item.children) return;
|
|
4181
4230
|
const observables = item.children.map((child) => {
|
|
4182
|
-
var _child$item$activated, _child$
|
|
4183
|
-
return (0, _univerjs_core.convertObservableToBehaviorSubject)((_child$item$activated = (_child$
|
|
4231
|
+
var _child$item$activated, _child$item2;
|
|
4232
|
+
return (0, _univerjs_core.convertObservableToBehaviorSubject)((_child$item$activated = (_child$item2 = child.item) === null || _child$item2 === void 0 ? void 0 : _child$item2.activated$) !== null && _child$item$activated !== void 0 ? _child$item$activated : (0, rxjs.of)(false), false);
|
|
4184
4233
|
});
|
|
4185
4234
|
const subscription = (0, rxjs.combineLatest)(observables).subscribe((activedArr) => {
|
|
4186
4235
|
const actived = activedArr.map((actived, index) => ({
|
|
4187
4236
|
actived,
|
|
4188
|
-
item: item.children[index]
|
|
4237
|
+
item: getTinyMenuChildStateKey(item.children[index])
|
|
4189
4238
|
})).filter((actived) => actived.actived);
|
|
4190
4239
|
if (actived.length === 0) setActiveItems([]);
|
|
4191
4240
|
else setActiveItems(actived.map((actived) => actived.item));
|
|
@@ -4197,34 +4246,65 @@ function UITinyMenuGroup(props) {
|
|
|
4197
4246
|
});
|
|
4198
4247
|
};
|
|
4199
4248
|
}, [item]);
|
|
4249
|
+
(0, react.useEffect)(() => {
|
|
4250
|
+
if (!item.children) return;
|
|
4251
|
+
const observables = item.children.map((child) => {
|
|
4252
|
+
var _child$item$hidden$, _child$item3;
|
|
4253
|
+
return (0, _univerjs_core.convertObservableToBehaviorSubject)((_child$item$hidden$ = (_child$item3 = child.item) === null || _child$item3 === void 0 ? void 0 : _child$item3.hidden$) !== null && _child$item$hidden$ !== void 0 ? _child$item$hidden$ : (0, rxjs.of)(false), false);
|
|
4254
|
+
});
|
|
4255
|
+
const subscription = (0, rxjs.combineLatest)(observables).subscribe((hiddenArr) => {
|
|
4256
|
+
const hidden = hiddenArr.map((hidden, index) => ({
|
|
4257
|
+
hidden,
|
|
4258
|
+
item: getTinyMenuChildStateKey(item.children[index])
|
|
4259
|
+
})).filter((hidden) => hidden.hidden);
|
|
4260
|
+
if (hidden.length === 0) setHiddenItems([]);
|
|
4261
|
+
else setHiddenItems(hidden.map((hidden) => hidden.item));
|
|
4262
|
+
});
|
|
4263
|
+
return () => {
|
|
4264
|
+
subscription.unsubscribe();
|
|
4265
|
+
observables.forEach((observable) => {
|
|
4266
|
+
observable.complete();
|
|
4267
|
+
});
|
|
4268
|
+
};
|
|
4269
|
+
}, [item]);
|
|
4270
|
+
const visibleChildren = (0, react.useMemo)(() => {
|
|
4271
|
+
var _item$children;
|
|
4272
|
+
return getVisibleTinyMenuChildren((_item$children = item.children) !== null && _item$children !== void 0 ? _item$children : [], [...hiddenItems, ...hiddenItemIds]);
|
|
4273
|
+
}, [
|
|
4274
|
+
hiddenItemIds,
|
|
4275
|
+
hiddenItems,
|
|
4276
|
+
item.children
|
|
4277
|
+
]);
|
|
4200
4278
|
if (!item.children) return null;
|
|
4201
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DesignTinyMenuGroup, { items:
|
|
4202
|
-
var _child$item$
|
|
4279
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DesignTinyMenuGroup, { items: visibleChildren.map((child) => {
|
|
4280
|
+
var _child$item9, _child$item10, _child$item$id3, _child$item11;
|
|
4203
4281
|
return {
|
|
4204
4282
|
key: child.key,
|
|
4205
4283
|
onClick: () => {
|
|
4206
|
-
var _child$item$
|
|
4284
|
+
var _child$item$id2, _child$item4, _child$item5, _child$item6, _child$item7, _child$item8;
|
|
4207
4285
|
onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
|
|
4208
|
-
label: (_child$item$
|
|
4209
|
-
commandId: (_child$
|
|
4210
|
-
id: (_child$
|
|
4211
|
-
tooltip: ((_child$
|
|
4286
|
+
label: (_child$item$id2 = (_child$item4 = child.item) === null || _child$item4 === void 0 ? void 0 : _child$item4.id) !== null && _child$item$id2 !== void 0 ? _child$item$id2 : child.key,
|
|
4287
|
+
commandId: (_child$item5 = child.item) === null || _child$item5 === void 0 ? void 0 : _child$item5.commandId,
|
|
4288
|
+
id: (_child$item6 = child.item) === null || _child$item6 === void 0 ? void 0 : _child$item6.id,
|
|
4289
|
+
tooltip: ((_child$item7 = child.item) === null || _child$item7 === void 0 ? void 0 : _child$item7.tooltip) && localeService.t((_child$item8 = child.item) === null || _child$item8 === void 0 ? void 0 : _child$item8.tooltip)
|
|
4212
4290
|
});
|
|
4213
4291
|
},
|
|
4214
4292
|
className: "",
|
|
4293
|
+
iconClassName: ((_child$item9 = child.item) === null || _child$item9 === void 0 ? void 0 : _child$item9.icon) === "TextTypeIcon" ? "!univer-size-3.5" : void 0,
|
|
4215
4294
|
Icon: componentManager.get(child.item.icon),
|
|
4216
|
-
active: activeItems.includes((_child$item$
|
|
4295
|
+
active: resolveMenuItemActiveState((_child$item10 = child.item) === null || _child$item10 === void 0 ? void 0 : _child$item10.id, activeItems.includes((_child$item$id3 = (_child$item11 = child.item) === null || _child$item11 === void 0 ? void 0 : _child$item11.id) !== null && _child$item$id3 !== void 0 ? _child$item$id3 : ""), activeItemIds)
|
|
4217
4296
|
};
|
|
4218
4297
|
}) });
|
|
4219
4298
|
}
|
|
4220
4299
|
function UIQuickTileMenuGroup(props) {
|
|
4221
|
-
var _item$
|
|
4222
|
-
const { item, onOptionSelect } = props;
|
|
4223
|
-
if (!((_item$
|
|
4300
|
+
var _item$children2;
|
|
4301
|
+
const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, onOptionSelect } = props;
|
|
4302
|
+
if (!((_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.length)) return null;
|
|
4224
4303
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4225
4304
|
className: "univer-item-center univer-grid univer-grid-cols-3 univer-gap-1.5 univer-py-1",
|
|
4226
|
-
children: item.children.map((menuSchema) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(QuickTileMenuItem, {
|
|
4305
|
+
children: getVisibleTinyMenuChildren(item.children, hiddenItemIds).map((menuSchema) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(QuickTileMenuItem, {
|
|
4227
4306
|
menuSchema,
|
|
4307
|
+
activeItemIds,
|
|
4228
4308
|
onOptionSelect
|
|
4229
4309
|
}, menuSchema.key))
|
|
4230
4310
|
});
|
|
@@ -4236,6 +4316,7 @@ const contentClassName = "univer-inline-flex univer-items-center univer-gap-2";
|
|
|
4236
4316
|
const menuViewportPadding = 8;
|
|
4237
4317
|
const submenuOverlapOffset = 2;
|
|
4238
4318
|
const submenuVisualGap = 20;
|
|
4319
|
+
const CONTEXT_MENU_SUBMENU_CLOSE_DELAY = 500;
|
|
4239
4320
|
const CONTEXT_MENU_SUBMENU_PORTAL_ATTR = "data-u-context-menu-submenu";
|
|
4240
4321
|
function isNonSelectableLabel(label) {
|
|
4241
4322
|
return typeof label === "object" && (label === null || label === void 0 ? void 0 : label.selectable) === false;
|
|
@@ -4243,9 +4324,15 @@ function isNonSelectableLabel(label) {
|
|
|
4243
4324
|
function isNonHoverableLabel(label) {
|
|
4244
4325
|
return typeof label === "object" && (label === null || label === void 0 ? void 0 : label.hoverable) === false;
|
|
4245
4326
|
}
|
|
4327
|
+
function hasRenderableContextMenuSchema(menuSchema) {
|
|
4328
|
+
var _menuSchema$children;
|
|
4329
|
+
if (menuSchema.item) return true;
|
|
4330
|
+
if (!((_menuSchema$children = menuSchema.children) === null || _menuSchema$children === void 0 ? void 0 : _menuSchema$children.length)) return false;
|
|
4331
|
+
return menuSchema.children.some((childSchema) => Boolean(childSchema.item));
|
|
4332
|
+
}
|
|
4246
4333
|
function ContextMenuPanel(props) {
|
|
4247
4334
|
var _layoutService$rootCo, _layoutService$rootCo2;
|
|
4248
|
-
const { menuType, menuSessionVersion = 0, className, onOptionSelect } = props;
|
|
4335
|
+
const { menuType, menuSessionVersion = 0, className, activeItemIds, hiddenItemIds, onOptionSelect } = props;
|
|
4249
4336
|
const menuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
|
|
4250
4337
|
const layoutService = (0, _wendellhu_redi_react_bindings.useDependency)(ILayoutService);
|
|
4251
4338
|
const [menuElement, setMenuElement] = (0, react.useState)(null);
|
|
@@ -4289,23 +4376,26 @@ function ContextMenuPanel(props) {
|
|
|
4289
4376
|
menuSchemas: menuItems,
|
|
4290
4377
|
menuSessionVersion,
|
|
4291
4378
|
submenuPortalContainer,
|
|
4379
|
+
activeItemIds,
|
|
4380
|
+
hiddenItemIds,
|
|
4292
4381
|
onOptionSelect,
|
|
4293
4382
|
maxMenuHeight
|
|
4294
4383
|
})
|
|
4295
4384
|
});
|
|
4296
4385
|
}
|
|
4297
4386
|
function ContextMenuMenu(props) {
|
|
4298
|
-
const { menuSchemas, menuSessionVersion, submenuPortalContainer, onOptionSelect, maxMenuHeight } = props;
|
|
4387
|
+
const { menuSchemas, menuSessionVersion, submenuPortalContainer, activeItemIds, hiddenItemIds, onOptionSelect, maxMenuHeight } = props;
|
|
4299
4388
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
4300
4389
|
const hiddenGroupStates = useContextGroupHiddenStates$1(menuSchemas);
|
|
4301
4390
|
const visibleSchemas = (0, react.useMemo)(() => {
|
|
4302
4391
|
return menuSchemas.filter((item) => {
|
|
4392
|
+
if (!hasRenderableContextMenuSchema(item)) return false;
|
|
4303
4393
|
if (!item.children) return true;
|
|
4304
4394
|
return !hiddenGroupStates[item.key];
|
|
4305
4395
|
});
|
|
4306
4396
|
}, [hiddenGroupStates, menuSchemas]);
|
|
4307
4397
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: visibleSchemas.map((menuSchema, index) => {
|
|
4308
|
-
var _menuSchema$
|
|
4398
|
+
var _menuSchema$children2;
|
|
4309
4399
|
const hasSeparator = index !== visibleSchemas.length - 1;
|
|
4310
4400
|
if (menuSchema.item) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextMenuMenuItem, {
|
|
4311
4401
|
menuKey: menuSchema.key,
|
|
@@ -4313,19 +4403,38 @@ function ContextMenuMenu(props) {
|
|
|
4313
4403
|
menuSessionVersion,
|
|
4314
4404
|
submenuPortalContainer,
|
|
4315
4405
|
onOptionSelect,
|
|
4316
|
-
maxMenuHeight
|
|
4406
|
+
maxMenuHeight,
|
|
4407
|
+
hiddenItemIds
|
|
4317
4408
|
}, menuSchema.key);
|
|
4318
|
-
if (!((_menuSchema$
|
|
4409
|
+
if (!((_menuSchema$children2 = menuSchema.children) === null || _menuSchema$children2 === void 0 ? void 0 : _menuSchema$children2.length)) return null;
|
|
4319
4410
|
if (menuSchema.quickLayout) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4320
4411
|
className: (0, _univerjs_design.clsx)("univer-py-1", hasSeparator && _univerjs_design.borderBottomClassName),
|
|
4321
4412
|
children: menuSchema.quickLayout === "tile" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UIQuickTileMenuGroup, {
|
|
4322
4413
|
item: menuSchema,
|
|
4414
|
+
activeItemIds,
|
|
4415
|
+
hiddenItemIds,
|
|
4323
4416
|
onOptionSelect
|
|
4324
4417
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UITinyMenuGroup, {
|
|
4325
4418
|
item: menuSchema,
|
|
4419
|
+
activeItemIds,
|
|
4420
|
+
hiddenItemIds,
|
|
4326
4421
|
onOptionSelect
|
|
4327
4422
|
})
|
|
4328
4423
|
}, menuSchema.key);
|
|
4424
|
+
if (menuSchema.tiny) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4425
|
+
className: (0, _univerjs_design.clsx)("univer-flex univer-items-center univer-gap-1 univer-py-1", hasSeparator && _univerjs_design.borderBottomClassName),
|
|
4426
|
+
children: menuSchema.children.map((childSchema) => childSchema.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextMenuMenuItem, {
|
|
4427
|
+
menuKey: childSchema.key,
|
|
4428
|
+
menuItem: childSchema.item,
|
|
4429
|
+
menuSessionVersion,
|
|
4430
|
+
submenuPortalContainer,
|
|
4431
|
+
activeItemIds,
|
|
4432
|
+
hiddenItemIds,
|
|
4433
|
+
onOptionSelect,
|
|
4434
|
+
maxMenuHeight,
|
|
4435
|
+
compact: true
|
|
4436
|
+
}, childSchema.key))
|
|
4437
|
+
}, menuSchema.key);
|
|
4329
4438
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4330
4439
|
className: (0, _univerjs_design.clsx)("univer-grid univer-gap-1 univer-py-1", hasSeparator && _univerjs_design.borderBottomClassName),
|
|
4331
4440
|
children: [menuSchema.title && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
@@ -4336,6 +4445,8 @@ function ContextMenuMenu(props) {
|
|
|
4336
4445
|
menuItem: childSchema.item,
|
|
4337
4446
|
menuSessionVersion,
|
|
4338
4447
|
submenuPortalContainer,
|
|
4448
|
+
activeItemIds,
|
|
4449
|
+
hiddenItemIds,
|
|
4339
4450
|
onOptionSelect,
|
|
4340
4451
|
maxMenuHeight
|
|
4341
4452
|
}, childSchema.key))]
|
|
@@ -4343,8 +4454,9 @@ function ContextMenuMenu(props) {
|
|
|
4343
4454
|
}) });
|
|
4344
4455
|
}
|
|
4345
4456
|
function ContextMenuMenuItem(props) {
|
|
4346
|
-
const { menuKey, menuItem, menuSessionVersion, submenuPortalContainer, onOptionSelect, maxMenuHeight } = props;
|
|
4347
|
-
const
|
|
4457
|
+
const { menuKey, menuItem, menuSessionVersion, submenuPortalContainer, activeItemIds, hiddenItemIds = [], compact = false, onOptionSelect, maxMenuHeight } = props;
|
|
4458
|
+
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
4459
|
+
const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$);
|
|
4348
4460
|
const menuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
|
|
4349
4461
|
const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem.disabled$, false);
|
|
4350
4462
|
const activated = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem.activated$, false);
|
|
@@ -4362,6 +4474,7 @@ function ContextMenuMenuItem(props) {
|
|
|
4362
4474
|
const [submenuPlacement, setSubmenuPlacement] = (0, react.useState)("right");
|
|
4363
4475
|
const menuItemElementRef = (0, react.useRef)(null);
|
|
4364
4476
|
const submenuElementRef = (0, react.useRef)(null);
|
|
4477
|
+
const submenuCloseTimerRef = (0, react.useRef)(null);
|
|
4365
4478
|
const selections = (0, react.useMemo)(() => {
|
|
4366
4479
|
if (menuItem.type !== 1 && menuItem.type !== 2) return [];
|
|
4367
4480
|
if (selectionsFromObservable) return selectionsFromObservable;
|
|
@@ -4383,9 +4496,23 @@ function ContextMenuMenuItem(props) {
|
|
|
4383
4496
|
const hasSelectionSubmenu = selections.length > 0;
|
|
4384
4497
|
const hasSubItemSubmenu = subMenuItems.length > 0;
|
|
4385
4498
|
const hasSubmenu = hasSelectionSubmenu || hasSubItemSubmenu;
|
|
4499
|
+
const selectionsCommandId = selectorItem.selectionsCommandId;
|
|
4500
|
+
const clearSubmenuCloseTimer = (0, react.useCallback)(() => {
|
|
4501
|
+
if (submenuCloseTimerRef.current == null) return;
|
|
4502
|
+
clearTimeout(submenuCloseTimerRef.current);
|
|
4503
|
+
submenuCloseTimerRef.current = null;
|
|
4504
|
+
}, []);
|
|
4505
|
+
const scheduleSubmenuClose = (0, react.useCallback)(() => {
|
|
4506
|
+
clearSubmenuCloseTimer();
|
|
4507
|
+
submenuCloseTimerRef.current = setTimeout(() => {
|
|
4508
|
+
submenuCloseTimerRef.current = null;
|
|
4509
|
+
setSubmenuVisible(false);
|
|
4510
|
+
}, 500);
|
|
4511
|
+
}, [clearSubmenuCloseTimer]);
|
|
4386
4512
|
(0, react.useEffect)(() => {
|
|
4387
4513
|
setInputValue(value);
|
|
4388
4514
|
}, [value]);
|
|
4515
|
+
(0, react.useEffect)(() => () => clearSubmenuCloseTimer(), [clearSubmenuCloseTimer]);
|
|
4389
4516
|
(0, react.useEffect)(() => {
|
|
4390
4517
|
if (!submenuVisible) {
|
|
4391
4518
|
setSubmenuPositionReady(false);
|
|
@@ -4422,19 +4549,30 @@ function ContextMenuMenuItem(props) {
|
|
|
4422
4549
|
hasSelectionSubmenu,
|
|
4423
4550
|
hasSubItemSubmenu
|
|
4424
4551
|
]);
|
|
4425
|
-
|
|
4552
|
+
const hiddenById = menuItem.id != null && hiddenItemIds.includes(menuItem.id) || hiddenItemIds.includes(menuKey);
|
|
4553
|
+
if (hidden || hiddenById) return null;
|
|
4426
4554
|
const onChange = (v) => {
|
|
4427
4555
|
setInputValue((0, _univerjs_core.isRealNum)(v) && typeof v === "string" ? Number.parseInt(v) : v);
|
|
4428
4556
|
};
|
|
4429
4557
|
const onSubmenuOptionSelect = (option) => {
|
|
4430
4558
|
onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect(option);
|
|
4559
|
+
clearSubmenuCloseTimer();
|
|
4431
4560
|
setSubmenuVisible(false);
|
|
4432
4561
|
};
|
|
4433
|
-
const itemClassName = (0, _univerjs_design.clsx)(
|
|
4562
|
+
const itemClassName = (0, _univerjs_design.clsx)(compact ? `
|
|
4563
|
+
univer-relative univer-flex univer-size-8 univer-items-center univer-justify-center univer-rounded-md
|
|
4564
|
+
univer-border-none univer-bg-transparent univer-p-0 univer-text-left univer-text-sm
|
|
4565
|
+
dark:!univer-text-white
|
|
4566
|
+
` : `
|
|
4567
|
+
univer-relative univer-flex univer-min-h-8 univer-w-full univer-items-center univer-justify-between
|
|
4568
|
+
univer-gap-3 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left
|
|
4569
|
+
univer-text-sm
|
|
4570
|
+
dark:!univer-text-white
|
|
4571
|
+
`, disabled ? "univer-cursor-not-allowed univer-opacity-60" : `
|
|
4434
4572
|
univer-cursor-pointer
|
|
4435
4573
|
hover:univer-bg-gray-50
|
|
4436
4574
|
dark:hover:!univer-bg-gray-600
|
|
4437
|
-
`, activated && `
|
|
4575
|
+
`, resolveMenuItemActiveState(menuItem.id, activated, activeItemIds) && `
|
|
4438
4576
|
univer-bg-gray-200
|
|
4439
4577
|
dark:!univer-bg-gray-600
|
|
4440
4578
|
`);
|
|
@@ -4442,7 +4580,7 @@ function ContextMenuMenuItem(props) {
|
|
|
4442
4580
|
className: contentClassName,
|
|
4443
4581
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
|
|
4444
4582
|
value: inputValue,
|
|
4445
|
-
title: menuItem.title,
|
|
4583
|
+
title: compact ? void 0 : menuItem.title,
|
|
4446
4584
|
label: menuItem.label,
|
|
4447
4585
|
icon: menuItem.icon,
|
|
4448
4586
|
onChange
|
|
@@ -4458,6 +4596,7 @@ function ContextMenuMenuItem(props) {
|
|
|
4458
4596
|
ref: menuItemElementRef,
|
|
4459
4597
|
className: "univer-relative",
|
|
4460
4598
|
onMouseEnter: () => {
|
|
4599
|
+
clearSubmenuCloseTimer();
|
|
4461
4600
|
if (hasSubmenu && !disabled) {
|
|
4462
4601
|
setSubmenuPositionReady(false);
|
|
4463
4602
|
setSubmenuVisible(true);
|
|
@@ -4468,7 +4607,7 @@ function ContextMenuMenuItem(props) {
|
|
|
4468
4607
|
var _submenuElementRef$cu;
|
|
4469
4608
|
const nextTarget = event.relatedTarget;
|
|
4470
4609
|
if (nextTarget && ((_submenuElementRef$cu = submenuElementRef.current) === null || _submenuElementRef$cu === void 0 ? void 0 : _submenuElementRef$cu.contains(nextTarget))) return;
|
|
4471
|
-
|
|
4610
|
+
scheduleSubmenuClose();
|
|
4472
4611
|
}
|
|
4473
4612
|
},
|
|
4474
4613
|
children: [renderAsContainer ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -4479,8 +4618,21 @@ function ContextMenuMenuItem(props) {
|
|
|
4479
4618
|
type: "button",
|
|
4480
4619
|
className: interactiveItemClassName,
|
|
4481
4620
|
disabled,
|
|
4621
|
+
title: compact && typeof menuItem.tooltip === "string" ? localeService.t(menuItem.tooltip) : void 0,
|
|
4482
4622
|
onClick: () => {
|
|
4623
|
+
clearSubmenuCloseTimer();
|
|
4483
4624
|
if (hasSubmenu) {
|
|
4625
|
+
if (canExecuteItem) {
|
|
4626
|
+
const item = menuItem;
|
|
4627
|
+
onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
|
|
4628
|
+
commandId: item.commandId,
|
|
4629
|
+
params: item.params,
|
|
4630
|
+
value: inputValue,
|
|
4631
|
+
id: item.id,
|
|
4632
|
+
label: menuKey
|
|
4633
|
+
});
|
|
4634
|
+
return;
|
|
4635
|
+
}
|
|
4484
4636
|
setSubmenuPositionReady(false);
|
|
4485
4637
|
setSubmenuVisible(true);
|
|
4486
4638
|
return;
|
|
@@ -4489,12 +4641,13 @@ function ContextMenuMenuItem(props) {
|
|
|
4489
4641
|
const item = menuItem;
|
|
4490
4642
|
onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
|
|
4491
4643
|
commandId: item.commandId,
|
|
4644
|
+
params: item.params,
|
|
4492
4645
|
value: inputValue,
|
|
4493
4646
|
id: item.id,
|
|
4494
4647
|
label: menuKey
|
|
4495
4648
|
});
|
|
4496
4649
|
},
|
|
4497
|
-
children: [contentNode, hasSubmenu && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreIcon, { className: "univer-size-3.5 univer-text-gray-400 dark:!univer-text-gray-200" })]
|
|
4650
|
+
children: [contentNode, hasSubmenu && !compact && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreIcon, { className: "univer-size-3.5 univer-text-gray-400 dark:!univer-text-gray-200" })]
|
|
4498
4651
|
}), hasSubmenu && submenuVisible && (submenuPortalContainer ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4499
4652
|
ref: submenuElementRef,
|
|
4500
4653
|
dir: direction,
|
|
@@ -4510,11 +4663,12 @@ function ContextMenuMenuItem(props) {
|
|
|
4510
4663
|
visibility: submenuPositionReady ? "visible" : "hidden",
|
|
4511
4664
|
pointerEvents: submenuPositionReady ? "auto" : "none"
|
|
4512
4665
|
},
|
|
4666
|
+
onMouseEnter: clearSubmenuCloseTimer,
|
|
4513
4667
|
onMouseLeave: (event) => {
|
|
4514
4668
|
var _menuItemElementRef$c;
|
|
4515
4669
|
const nextTarget = event.relatedTarget;
|
|
4516
4670
|
if (nextTarget && ((_menuItemElementRef$c = menuItemElementRef.current) === null || _menuItemElementRef$c === void 0 ? void 0 : _menuItemElementRef$c.contains(nextTarget))) return;
|
|
4517
|
-
|
|
4671
|
+
scheduleSubmenuClose();
|
|
4518
4672
|
},
|
|
4519
4673
|
onWheel: (event) => event.stopPropagation(),
|
|
4520
4674
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -4543,12 +4697,13 @@ function ContextMenuMenuItem(props) {
|
|
|
4543
4697
|
label: option.label,
|
|
4544
4698
|
icon: option.icon,
|
|
4545
4699
|
onChange: (optionValue) => {
|
|
4700
|
+
var _option$commandId;
|
|
4546
4701
|
onSubmenuOptionSelect === null || onSubmenuOptionSelect === void 0 || onSubmenuOptionSelect({
|
|
4547
4702
|
...option,
|
|
4548
4703
|
value: optionValue,
|
|
4549
4704
|
id: menuItem.id,
|
|
4550
4705
|
label: menuKey,
|
|
4551
|
-
commandId: option.commandId
|
|
4706
|
+
commandId: (_option$commandId = option.commandId) !== null && _option$commandId !== void 0 ? _option$commandId : selectionsCommandId
|
|
4552
4707
|
});
|
|
4553
4708
|
}
|
|
4554
4709
|
})
|
|
@@ -4558,11 +4713,12 @@ function ContextMenuMenuItem(props) {
|
|
|
4558
4713
|
className: optionClassName,
|
|
4559
4714
|
disabled: option.disabled,
|
|
4560
4715
|
onClick: () => {
|
|
4716
|
+
var _option$commandId2;
|
|
4561
4717
|
onSubmenuOptionSelect === null || onSubmenuOptionSelect === void 0 || onSubmenuOptionSelect({
|
|
4562
4718
|
...option,
|
|
4563
4719
|
id: menuItem.id,
|
|
4564
4720
|
label: menuKey,
|
|
4565
|
-
commandId: option.commandId
|
|
4721
|
+
commandId: (_option$commandId2 = option.commandId) !== null && _option$commandId2 !== void 0 ? _option$commandId2 : selectionsCommandId
|
|
4566
4722
|
});
|
|
4567
4723
|
},
|
|
4568
4724
|
children: optionContentNode
|
|
@@ -4576,6 +4732,8 @@ function ContextMenuMenuItem(props) {
|
|
|
4576
4732
|
menuSchemas: subMenuItems,
|
|
4577
4733
|
menuSessionVersion,
|
|
4578
4734
|
submenuPortalContainer,
|
|
4735
|
+
activeItemIds,
|
|
4736
|
+
hiddenItemIds,
|
|
4579
4737
|
onOptionSelect: onSubmenuOptionSelect,
|
|
4580
4738
|
maxMenuHeight
|
|
4581
4739
|
})]
|
|
@@ -4587,8 +4745,8 @@ function useContextGroupHiddenStates$1(menuSchemas) {
|
|
|
4587
4745
|
const [hiddenStates, setHiddenStates] = (0, react.useState)({});
|
|
4588
4746
|
(0, react.useEffect)(() => {
|
|
4589
4747
|
const subscriptions = menuSchemas.map((menuSchema) => {
|
|
4590
|
-
var _menuSchema$
|
|
4591
|
-
if (!((_menuSchema$
|
|
4748
|
+
var _menuSchema$children3;
|
|
4749
|
+
if (!((_menuSchema$children3 = menuSchema.children) === null || _menuSchema$children3 === void 0 ? void 0 : _menuSchema$children3.length)) return null;
|
|
4592
4750
|
return (0, rxjs.combineLatest)(menuSchema.children.map((childSchema) => {
|
|
4593
4751
|
var _childSchema$item$hid, _childSchema$item;
|
|
4594
4752
|
return (_childSchema$item$hid = (_childSchema$item = childSchema.item) === null || _childSchema$item === void 0 ? void 0 : _childSchema$item.hidden$) !== null && _childSchema$item$hid !== void 0 ? _childSchema$item$hid : (0, rxjs.of)(false);
|
|
@@ -4757,7 +4915,9 @@ function DesktopContextMenu() {
|
|
|
4757
4915
|
onRequestClose: handleClose,
|
|
4758
4916
|
onOptionSelect: (params) => {
|
|
4759
4917
|
const { label: id, commandId, value } = params;
|
|
4760
|
-
|
|
4918
|
+
const rawParams = typeof params.params === "function" ? params.params() : params.params;
|
|
4919
|
+
const commandParams = typeof rawParams === "undefined" ? { value } : rawParams;
|
|
4920
|
+
if (commandService) commandService.executeCommand(commandId !== null && commandId !== void 0 ? commandId : id, commandParams);
|
|
4761
4921
|
injector.get(ILayoutService).focus();
|
|
4762
4922
|
handleClose();
|
|
4763
4923
|
}
|
|
@@ -5296,7 +5456,7 @@ const IUIController = (0, _univerjs_core.createIdentifier)("univer.ui.ui-control
|
|
|
5296
5456
|
//#endregion
|
|
5297
5457
|
//#region package.json
|
|
5298
5458
|
var name = "@univerjs/ui";
|
|
5299
|
-
var version = "0.
|
|
5459
|
+
var version = "0.25.0-insiders.20260608-e4336f7";
|
|
5300
5460
|
|
|
5301
5461
|
//#endregion
|
|
5302
5462
|
//#region src/views/components/ribbon/MobileRibbon.tsx
|
|
@@ -5364,7 +5524,7 @@ function MobileRibbon(props) {
|
|
|
5364
5524
|
const container = toolbarScrollRef.current;
|
|
5365
5525
|
if (!container) return;
|
|
5366
5526
|
container.scrollBy({
|
|
5367
|
-
left: direction === "left" ? -
|
|
5527
|
+
left: direction === "left" ? -168 : toolbarScrollOffset,
|
|
5368
5528
|
behavior: "smooth"
|
|
5369
5529
|
});
|
|
5370
5530
|
}
|
|
@@ -5405,7 +5565,7 @@ function MobileRibbon(props) {
|
|
|
5405
5565
|
dark:!univer-text-gray-200
|
|
5406
5566
|
`),
|
|
5407
5567
|
onClick: () => selectTab(index),
|
|
5408
|
-
children: [localeService.t(group.key), active && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "\n univer-absolute univer-bottom-0 univer-left-1/2 univer-h-0.5 univer-w-8\n -univer-translate-x-1/2 univer-rounded-full univer-bg-primary-600\n dark:!univer-bg-primary-400\n " })]
|
|
5568
|
+
children: [localeService.t(group.title || group.key), active && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "\n univer-absolute univer-bottom-0 univer-left-1/2 univer-h-0.5 univer-w-8\n -univer-translate-x-1/2 univer-rounded-full univer-bg-primary-600\n dark:!univer-bg-primary-400\n " })]
|
|
5409
5569
|
}, group.key);
|
|
5410
5570
|
})
|
|
5411
5571
|
}),
|
|
@@ -5826,8 +5986,8 @@ function MobileContextMenu() {
|
|
|
5826
5986
|
}
|
|
5827
5987
|
const sheetTitle = (0, react.useMemo)(() => {
|
|
5828
5988
|
switch (menuType) {
|
|
5829
|
-
case "contextMenu.rowHeader": return localeService.t("row");
|
|
5830
|
-
case "contextMenu.colHeader": return localeService.t("column");
|
|
5989
|
+
case "contextMenu.rowHeader": return localeService.t("ui.row");
|
|
5990
|
+
case "contextMenu.colHeader": return localeService.t("ui.column");
|
|
5831
5991
|
default: return "";
|
|
5832
5992
|
}
|
|
5833
5993
|
}, [localeService, menuType]);
|
|
@@ -5837,7 +5997,7 @@ function MobileContextMenu() {
|
|
|
5837
5997
|
className: "univer-fixed univer-inset-0 univer-z-[1080] univer-flex univer-items-end",
|
|
5838
5998
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
5839
5999
|
type: "button",
|
|
5840
|
-
"aria-label": localeService.t("rangeSelector.cancel"),
|
|
6000
|
+
"aria-label": localeService.t("ui.rangeSelector.cancel"),
|
|
5841
6001
|
className: "univer-absolute univer-inset-0 univer-bg-[rgba(15,23,42,0.32)] univer-backdrop-blur-[2px]",
|
|
5842
6002
|
onClick: handleClose
|
|
5843
6003
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
@@ -5858,7 +6018,7 @@ function MobileContextMenu() {
|
|
|
5858
6018
|
})
|
|
5859
6019
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
5860
6020
|
type: "button",
|
|
5861
|
-
"aria-label": localeService.t("rangeSelector.cancel"),
|
|
6021
|
+
"aria-label": localeService.t("ui.rangeSelector.cancel"),
|
|
5862
6022
|
className: "\n univer-flex univer-size-8 univer-shrink-0 univer-appearance-none univer-items-center\n univer-justify-center univer-rounded-full univer-border-0 univer-bg-white univer-p-0\n univer-leading-none univer-text-gray-600 univer-shadow-sm univer-outline-none\n univer-ring-0 univer-transition-colors\n hover:univer-bg-gray-100\n active:univer-bg-gray-200\n ",
|
|
5863
6023
|
style: { margin: 0 },
|
|
5864
6024
|
onClick: handleClose,
|
|
@@ -6084,13 +6244,40 @@ const INotificationService = (0, _univerjs_core.createIdentifier)("ui.notificati
|
|
|
6084
6244
|
//#endregion
|
|
6085
6245
|
//#region src/services/before-close/before-close.service.ts
|
|
6086
6246
|
const IBeforeCloseService = (0, _univerjs_core.createIdentifier)("univer.ui.before-close-service");
|
|
6087
|
-
let DesktopBeforeCloseService = class DesktopBeforeCloseService {
|
|
6247
|
+
let DesktopBeforeCloseService = class DesktopBeforeCloseService extends _univerjs_core.Disposable {
|
|
6088
6248
|
constructor(_notificationService) {
|
|
6249
|
+
super();
|
|
6089
6250
|
this._notificationService = _notificationService;
|
|
6090
6251
|
_defineProperty(this, "_beforeUnloadCallbacks", []);
|
|
6091
6252
|
_defineProperty(this, "_onCloseCallbacks", []);
|
|
6253
|
+
_defineProperty(this, "_beforeUnloadHandler", void 0);
|
|
6254
|
+
_defineProperty(this, "_unloadHandler", void 0);
|
|
6255
|
+
this._beforeUnloadHandler = (_event) => {
|
|
6256
|
+
let event = _event;
|
|
6257
|
+
const message = this._beforeUnloadCallbacks.map((callback) => callback()).filter((m) => !!m).join("\n");
|
|
6258
|
+
if (message) {
|
|
6259
|
+
this._notificationService.show({
|
|
6260
|
+
type: "error",
|
|
6261
|
+
title: "Some changes are not saved",
|
|
6262
|
+
content: message
|
|
6263
|
+
});
|
|
6264
|
+
if (typeof event === "undefined") event = window.event;
|
|
6265
|
+
event.returnValue = message;
|
|
6266
|
+
return message;
|
|
6267
|
+
}
|
|
6268
|
+
};
|
|
6269
|
+
this._unloadHandler = () => {
|
|
6270
|
+
this._onCloseCallbacks.forEach((callback) => callback());
|
|
6271
|
+
};
|
|
6092
6272
|
this._init();
|
|
6093
6273
|
}
|
|
6274
|
+
dispose() {
|
|
6275
|
+
window.removeEventListener("beforeunload", this._beforeUnloadHandler);
|
|
6276
|
+
window.removeEventListener("unload", this._unloadHandler);
|
|
6277
|
+
this._beforeUnloadCallbacks = [];
|
|
6278
|
+
this._onCloseCallbacks = [];
|
|
6279
|
+
super.dispose();
|
|
6280
|
+
}
|
|
6094
6281
|
registerBeforeClose(callback) {
|
|
6095
6282
|
this._beforeUnloadCallbacks.push(callback);
|
|
6096
6283
|
return { dispose: () => {
|
|
@@ -6104,23 +6291,8 @@ let DesktopBeforeCloseService = class DesktopBeforeCloseService {
|
|
|
6104
6291
|
} };
|
|
6105
6292
|
}
|
|
6106
6293
|
_init() {
|
|
6107
|
-
window.addEventListener("beforeunload",
|
|
6108
|
-
|
|
6109
|
-
const message = this._beforeUnloadCallbacks.map((callback) => callback()).filter((m) => !!m).join("\n");
|
|
6110
|
-
if (message) {
|
|
6111
|
-
this._notificationService.show({
|
|
6112
|
-
type: "error",
|
|
6113
|
-
title: "Some changes are not saved",
|
|
6114
|
-
content: message
|
|
6115
|
-
});
|
|
6116
|
-
if (typeof event === "undefined") event = window.event;
|
|
6117
|
-
event.returnValue = message;
|
|
6118
|
-
return message;
|
|
6119
|
-
}
|
|
6120
|
-
});
|
|
6121
|
-
window.addEventListener("unload", () => {
|
|
6122
|
-
this._onCloseCallbacks.forEach((callback) => callback());
|
|
6123
|
-
});
|
|
6294
|
+
window.addEventListener("beforeunload", this._beforeUnloadHandler);
|
|
6295
|
+
window.addEventListener("unload", this._unloadHandler);
|
|
6124
6296
|
}
|
|
6125
6297
|
};
|
|
6126
6298
|
DesktopBeforeCloseService = __decorate([__decorateParam(0, INotificationService)], DesktopBeforeCloseService);
|
|
@@ -6308,14 +6480,25 @@ let BrowserClipboardService = class BrowserClipboardService extends _univerjs_co
|
|
|
6308
6480
|
this._logService = _logService;
|
|
6309
6481
|
this._notificationService = _notificationService;
|
|
6310
6482
|
}
|
|
6311
|
-
async write(text, html) {
|
|
6312
|
-
if (!this.supportClipboard) return this._legacyCopyHtml(html);
|
|
6483
|
+
async write(text, html, customData) {
|
|
6484
|
+
if (!this.supportClipboard) return this._legacyCopyHtml(text, html);
|
|
6313
6485
|
try {
|
|
6314
6486
|
return await navigator.clipboard.write([new ClipboardItem({
|
|
6315
6487
|
[PLAIN_TEXT_CLIPBOARD_MIME_TYPE]: new Blob([text], { type: PLAIN_TEXT_CLIPBOARD_MIME_TYPE }),
|
|
6316
|
-
[HTML_CLIPBOARD_MIME_TYPE]: new Blob([html], { type: HTML_CLIPBOARD_MIME_TYPE })
|
|
6488
|
+
[HTML_CLIPBOARD_MIME_TYPE]: new Blob([html], { type: HTML_CLIPBOARD_MIME_TYPE }),
|
|
6489
|
+
...Object.fromEntries(Object.entries(customData !== null && customData !== void 0 ? customData : {}).map(([type, value]) => [type, new Blob([value], { type })]))
|
|
6317
6490
|
})]);
|
|
6318
6491
|
} catch (error) {
|
|
6492
|
+
if (customData && Object.keys(customData).length) try {
|
|
6493
|
+
return await navigator.clipboard.write([new ClipboardItem({
|
|
6494
|
+
[PLAIN_TEXT_CLIPBOARD_MIME_TYPE]: new Blob([text], { type: PLAIN_TEXT_CLIPBOARD_MIME_TYPE }),
|
|
6495
|
+
[HTML_CLIPBOARD_MIME_TYPE]: new Blob([html], { type: HTML_CLIPBOARD_MIME_TYPE })
|
|
6496
|
+
})]);
|
|
6497
|
+
} catch (fallbackError) {
|
|
6498
|
+
this._logService.error("[BrowserClipboardService]", fallbackError);
|
|
6499
|
+
this._showClipboardAuthenticationNotification();
|
|
6500
|
+
return;
|
|
6501
|
+
}
|
|
6319
6502
|
this._logService.error("[BrowserClipboardService]", error);
|
|
6320
6503
|
this._showClipboardAuthenticationNotification();
|
|
6321
6504
|
}
|
|
@@ -6349,17 +6532,34 @@ let BrowserClipboardService = class BrowserClipboardService extends _univerjs_co
|
|
|
6349
6532
|
return "";
|
|
6350
6533
|
}
|
|
6351
6534
|
}
|
|
6352
|
-
_legacyCopyHtml(html) {
|
|
6535
|
+
_legacyCopyHtml(text, html) {
|
|
6353
6536
|
const activeElement = document.activeElement;
|
|
6354
|
-
const
|
|
6355
|
-
|
|
6356
|
-
|
|
6537
|
+
const sanitizedHtml = serializeSanitizedHtmlForClipboard(html);
|
|
6538
|
+
let handledByClipboardEvent = false;
|
|
6539
|
+
const onCopy = (event) => {
|
|
6540
|
+
if (!event.clipboardData) return;
|
|
6541
|
+
event.preventDefault();
|
|
6542
|
+
event.clipboardData.setData(PLAIN_TEXT_CLIPBOARD_MIME_TYPE, text);
|
|
6543
|
+
event.clipboardData.setData(HTML_CLIPBOARD_MIME_TYPE, sanitizedHtml);
|
|
6544
|
+
handledByClipboardEvent = true;
|
|
6545
|
+
};
|
|
6546
|
+
document.addEventListener("copy", onCopy);
|
|
6357
6547
|
try {
|
|
6358
|
-
select(container);
|
|
6359
6548
|
document.execCommand("copy");
|
|
6549
|
+
if (!handledByClipboardEvent) {
|
|
6550
|
+
const container = createCopyHtmlContainer();
|
|
6551
|
+
document.body.appendChild(container);
|
|
6552
|
+
container.innerHTML = sanitizedHtml;
|
|
6553
|
+
try {
|
|
6554
|
+
select(container);
|
|
6555
|
+
document.execCommand("copy");
|
|
6556
|
+
} finally {
|
|
6557
|
+
document.body.removeChild(container);
|
|
6558
|
+
}
|
|
6559
|
+
}
|
|
6360
6560
|
} finally {
|
|
6561
|
+
document.removeEventListener("copy", onCopy);
|
|
6361
6562
|
if (activeElement instanceof HTMLElement) activeElement.focus();
|
|
6362
|
-
document.body.removeChild(container);
|
|
6363
6563
|
}
|
|
6364
6564
|
}
|
|
6365
6565
|
_legacyCopyText(text) {
|
|
@@ -6379,8 +6579,8 @@ let BrowserClipboardService = class BrowserClipboardService extends _univerjs_co
|
|
|
6379
6579
|
var _this$_notificationSe;
|
|
6380
6580
|
(_this$_notificationSe = this._notificationService) === null || _this$_notificationSe === void 0 || _this$_notificationSe.show({
|
|
6381
6581
|
type: "warning",
|
|
6382
|
-
title: this._localeService.t("clipboard.authentication.title"),
|
|
6383
|
-
content: this._localeService.t("clipboard.authentication.content")
|
|
6582
|
+
title: this._localeService.t("ui.clipboard.authentication.title"),
|
|
6583
|
+
content: this._localeService.t("ui.clipboard.authentication.content")
|
|
6384
6584
|
});
|
|
6385
6585
|
}
|
|
6386
6586
|
};
|
|
@@ -6417,6 +6617,11 @@ function sanitizeHtmlForClipboard(html) {
|
|
|
6417
6617
|
});
|
|
6418
6618
|
return fragment;
|
|
6419
6619
|
}
|
|
6620
|
+
function serializeSanitizedHtmlForClipboard(html) {
|
|
6621
|
+
const container = document.createElement("div");
|
|
6622
|
+
container.appendChild(sanitizeHtmlForClipboard(html));
|
|
6623
|
+
return container.innerHTML;
|
|
6624
|
+
}
|
|
6420
6625
|
function sanitizeHtmlNode(node) {
|
|
6421
6626
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
6422
6627
|
var _node$textContent;
|
|
@@ -6813,29 +7018,215 @@ var DesktopLocalFileService = class extends _univerjs_core.Disposable {
|
|
|
6813
7018
|
*/
|
|
6814
7019
|
const ILocalFileService = (0, _univerjs_core.createIdentifier)("univer-ui.local-file.service");
|
|
6815
7020
|
|
|
7021
|
+
//#endregion
|
|
7022
|
+
//#region src/utils/storage-driver.ts
|
|
7023
|
+
/**
|
|
7024
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
7025
|
+
*
|
|
7026
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7027
|
+
* you may not use this file except in compliance with the License.
|
|
7028
|
+
* You may obtain a copy of the License at
|
|
7029
|
+
*
|
|
7030
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7031
|
+
*
|
|
7032
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
7033
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
7034
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
7035
|
+
* See the License for the specific language governing permissions and
|
|
7036
|
+
* limitations under the License.
|
|
7037
|
+
*/
|
|
7038
|
+
const DB_NAME = "UniverLocalStorage";
|
|
7039
|
+
const STORE_NAME = "kv";
|
|
7040
|
+
const DB_VERSION = 1;
|
|
7041
|
+
var IndexedDBDriver = class {
|
|
7042
|
+
constructor() {
|
|
7043
|
+
_defineProperty(this, "_db", void 0);
|
|
7044
|
+
this._db = this._init();
|
|
7045
|
+
}
|
|
7046
|
+
_init() {
|
|
7047
|
+
return new Promise((resolve, reject) => {
|
|
7048
|
+
const req = indexedDB.open(DB_NAME, DB_VERSION);
|
|
7049
|
+
req.onerror = () => reject(req.error);
|
|
7050
|
+
req.onsuccess = () => resolve(req.result);
|
|
7051
|
+
req.onupgradeneeded = () => {
|
|
7052
|
+
req.result.createObjectStore(STORE_NAME);
|
|
7053
|
+
};
|
|
7054
|
+
});
|
|
7055
|
+
}
|
|
7056
|
+
_store(mode) {
|
|
7057
|
+
return this._db.then((db) => {
|
|
7058
|
+
return db.transaction(STORE_NAME, mode).objectStore(STORE_NAME);
|
|
7059
|
+
});
|
|
7060
|
+
}
|
|
7061
|
+
async getItem(key) {
|
|
7062
|
+
const store = await this._store("readonly");
|
|
7063
|
+
return new Promise((resolve, reject) => {
|
|
7064
|
+
const req = store.get(key);
|
|
7065
|
+
req.onsuccess = () => {
|
|
7066
|
+
var _req$result;
|
|
7067
|
+
return resolve((_req$result = req.result) !== null && _req$result !== void 0 ? _req$result : null);
|
|
7068
|
+
};
|
|
7069
|
+
req.onerror = () => reject(req.error);
|
|
7070
|
+
});
|
|
7071
|
+
}
|
|
7072
|
+
async setItem(key, value) {
|
|
7073
|
+
const store = await this._store("readwrite");
|
|
7074
|
+
return new Promise((resolve, reject) => {
|
|
7075
|
+
const req = store.put(value, key);
|
|
7076
|
+
req.onsuccess = () => resolve(value);
|
|
7077
|
+
req.onerror = () => reject(req.error);
|
|
7078
|
+
});
|
|
7079
|
+
}
|
|
7080
|
+
async removeItem(key) {
|
|
7081
|
+
const store = await this._store("readwrite");
|
|
7082
|
+
return new Promise((resolve, reject) => {
|
|
7083
|
+
const req = store.delete(key);
|
|
7084
|
+
req.onsuccess = () => resolve();
|
|
7085
|
+
req.onerror = () => reject(req.error);
|
|
7086
|
+
});
|
|
7087
|
+
}
|
|
7088
|
+
async clear() {
|
|
7089
|
+
const store = await this._store("readwrite");
|
|
7090
|
+
return new Promise((resolve, reject) => {
|
|
7091
|
+
const req = store.clear();
|
|
7092
|
+
req.onsuccess = () => resolve();
|
|
7093
|
+
req.onerror = () => reject(req.error);
|
|
7094
|
+
});
|
|
7095
|
+
}
|
|
7096
|
+
async key(index) {
|
|
7097
|
+
const store = await this._store("readonly");
|
|
7098
|
+
return new Promise((resolve, reject) => {
|
|
7099
|
+
const req = store.openCursor();
|
|
7100
|
+
let i = 0;
|
|
7101
|
+
req.onsuccess = () => {
|
|
7102
|
+
const cursor = req.result;
|
|
7103
|
+
if (!cursor) return resolve(null);
|
|
7104
|
+
if (i === index) return resolve(cursor.key);
|
|
7105
|
+
i++;
|
|
7106
|
+
cursor.continue();
|
|
7107
|
+
};
|
|
7108
|
+
req.onerror = () => reject(req.error);
|
|
7109
|
+
});
|
|
7110
|
+
}
|
|
7111
|
+
async keys() {
|
|
7112
|
+
const store = await this._store("readonly");
|
|
7113
|
+
return new Promise((resolve, reject) => {
|
|
7114
|
+
const req = store.openCursor();
|
|
7115
|
+
const keys = [];
|
|
7116
|
+
req.onsuccess = () => {
|
|
7117
|
+
const cursor = req.result;
|
|
7118
|
+
if (!cursor) return resolve(keys);
|
|
7119
|
+
keys.push(cursor.key);
|
|
7120
|
+
cursor.continue();
|
|
7121
|
+
};
|
|
7122
|
+
req.onerror = () => reject(req.error);
|
|
7123
|
+
});
|
|
7124
|
+
}
|
|
7125
|
+
async iterate(iteratee) {
|
|
7126
|
+
const store = await this._store("readonly");
|
|
7127
|
+
return new Promise((resolve, reject) => {
|
|
7128
|
+
const req = store.openCursor();
|
|
7129
|
+
let i = 1;
|
|
7130
|
+
let result = void 0;
|
|
7131
|
+
req.onsuccess = () => {
|
|
7132
|
+
const cursor = req.result;
|
|
7133
|
+
if (!cursor) return resolve(result);
|
|
7134
|
+
result = iteratee(cursor.value, cursor.key, i++);
|
|
7135
|
+
if (result !== void 0) return resolve(result);
|
|
7136
|
+
cursor.continue();
|
|
7137
|
+
};
|
|
7138
|
+
req.onerror = () => reject(req.error);
|
|
7139
|
+
});
|
|
7140
|
+
}
|
|
7141
|
+
};
|
|
7142
|
+
var LocalStorageDriver = class {
|
|
7143
|
+
constructor() {
|
|
7144
|
+
_defineProperty(this, "_prefix", `${DB_NAME}/`);
|
|
7145
|
+
}
|
|
7146
|
+
_key(key) {
|
|
7147
|
+
return this._prefix + key;
|
|
7148
|
+
}
|
|
7149
|
+
_rawKey(key) {
|
|
7150
|
+
return key.startsWith(this._prefix) ? key.slice(this._prefix.length) : key;
|
|
7151
|
+
}
|
|
7152
|
+
async getItem(key) {
|
|
7153
|
+
try {
|
|
7154
|
+
const item = localStorage.getItem(this._key(key));
|
|
7155
|
+
return item ? JSON.parse(item) : null;
|
|
7156
|
+
} catch {
|
|
7157
|
+
return null;
|
|
7158
|
+
}
|
|
7159
|
+
}
|
|
7160
|
+
async setItem(key, value) {
|
|
7161
|
+
localStorage.setItem(this._key(key), JSON.stringify(value));
|
|
7162
|
+
return value;
|
|
7163
|
+
}
|
|
7164
|
+
async removeItem(key) {
|
|
7165
|
+
localStorage.removeItem(this._key(key));
|
|
7166
|
+
}
|
|
7167
|
+
async clear() {
|
|
7168
|
+
const toRemove = [];
|
|
7169
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
7170
|
+
const k = localStorage.key(i);
|
|
7171
|
+
if (k.startsWith(this._prefix)) toRemove.push(k);
|
|
7172
|
+
}
|
|
7173
|
+
toRemove.forEach((k) => localStorage.removeItem(k));
|
|
7174
|
+
}
|
|
7175
|
+
async key(index) {
|
|
7176
|
+
var _keys$index;
|
|
7177
|
+
return (_keys$index = this._keys()[index]) !== null && _keys$index !== void 0 ? _keys$index : null;
|
|
7178
|
+
}
|
|
7179
|
+
async keys() {
|
|
7180
|
+
return this._keys();
|
|
7181
|
+
}
|
|
7182
|
+
_keys() {
|
|
7183
|
+
const keys = [];
|
|
7184
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
7185
|
+
const k = localStorage.key(i);
|
|
7186
|
+
if (k.startsWith(this._prefix)) keys.push(this._rawKey(k));
|
|
7187
|
+
}
|
|
7188
|
+
return keys;
|
|
7189
|
+
}
|
|
7190
|
+
async iterate(iteratee) {
|
|
7191
|
+
const keys = this._keys();
|
|
7192
|
+
for (let i = 0; i < keys.length; i++) {
|
|
7193
|
+
const key = keys[i];
|
|
7194
|
+
const result = iteratee(await this.getItem(key), key, i + 1);
|
|
7195
|
+
if (result !== void 0) return result;
|
|
7196
|
+
}
|
|
7197
|
+
}
|
|
7198
|
+
};
|
|
7199
|
+
function createDriver() {
|
|
7200
|
+
try {
|
|
7201
|
+
if (typeof indexedDB !== "undefined") return new IndexedDBDriver();
|
|
7202
|
+
} catch {}
|
|
7203
|
+
return new LocalStorageDriver();
|
|
7204
|
+
}
|
|
7205
|
+
const browserStorage = createDriver();
|
|
7206
|
+
|
|
6816
7207
|
//#endregion
|
|
6817
7208
|
//#region src/services/local-storage/local-storage.service.ts
|
|
6818
7209
|
var DesktopLocalStorageService = class {
|
|
6819
7210
|
getItem(key) {
|
|
6820
|
-
return
|
|
7211
|
+
return browserStorage.getItem(key);
|
|
6821
7212
|
}
|
|
6822
7213
|
setItem(key, value) {
|
|
6823
|
-
return
|
|
7214
|
+
return browserStorage.setItem(key, value);
|
|
6824
7215
|
}
|
|
6825
7216
|
removeItem(key) {
|
|
6826
|
-
return
|
|
7217
|
+
return browserStorage.removeItem(key);
|
|
6827
7218
|
}
|
|
6828
7219
|
clear() {
|
|
6829
|
-
return
|
|
7220
|
+
return browserStorage.clear();
|
|
6830
7221
|
}
|
|
6831
7222
|
key(index) {
|
|
6832
|
-
return
|
|
7223
|
+
return browserStorage.key(index);
|
|
6833
7224
|
}
|
|
6834
7225
|
keys() {
|
|
6835
|
-
return
|
|
7226
|
+
return browserStorage.keys();
|
|
6836
7227
|
}
|
|
6837
7228
|
iterate(iteratee) {
|
|
6838
|
-
return
|
|
7229
|
+
return browserStorage.iterate(iteratee);
|
|
6839
7230
|
}
|
|
6840
7231
|
};
|
|
6841
7232
|
|
|
@@ -8219,7 +8610,6 @@ exports.parseHtmlFragment = parseHtmlFragment;
|
|
|
8219
8610
|
exports.sanitizeParsedHtml = sanitizeParsedHtml;
|
|
8220
8611
|
exports.splitSpanText = splitSpanText;
|
|
8221
8612
|
exports.supportClipboardAPI = supportClipboardAPI;
|
|
8222
|
-
exports.t = t;
|
|
8223
8613
|
exports.textTrim = textTrim;
|
|
8224
8614
|
exports.useClickOutSide = useClickOutSide;
|
|
8225
8615
|
exports.useComponentsOfPart = useComponentsOfPart;
|