@univerjs/ui 0.24.0 → 0.25.0
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 +374 -173
- 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 +375 -158
- 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 +375 -158
- 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/menu/desktop/DesignTinyMenuGroup.d.ts +1 -0
- package/lib/types/components/menu/desktop/TinyMenuGroup.d.ts +4 -0
- 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/views/components/context-menu/ContextMenuPanel.d.ts +5 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +51 -36
- 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 +8 -8
package/lib/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { map as map$1, scan as scan$1, startWith as startWith$1 } from "rxjs/ope
|
|
|
10
10
|
import { createPortal } from "react-dom";
|
|
11
11
|
import localforage from "localforage";
|
|
12
12
|
|
|
13
|
-
//#region \0@oxc-project+runtime@0.
|
|
13
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
14
14
|
function _typeof(o) {
|
|
15
15
|
"@babel/helpers - typeof";
|
|
16
16
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -21,7 +21,7 @@ function _typeof(o) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
|
-
//#region \0@oxc-project+runtime@0.
|
|
24
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
|
|
25
25
|
function toPrimitive(t, r) {
|
|
26
26
|
if ("object" != _typeof(t) || !t) return t;
|
|
27
27
|
var e = t[Symbol.toPrimitive];
|
|
@@ -34,14 +34,14 @@ function toPrimitive(t, r) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
|
-
//#region \0@oxc-project+runtime@0.
|
|
37
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
|
|
38
38
|
function toPropertyKey(t) {
|
|
39
39
|
var i = toPrimitive(t, "string");
|
|
40
40
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
//#endregion
|
|
44
|
-
//#region \0@oxc-project+runtime@0.
|
|
44
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
|
|
45
45
|
function _defineProperty(e, r, t) {
|
|
46
46
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
47
47
|
value: t,
|
|
@@ -110,7 +110,7 @@ const ToggleShortcutPanelOperation = {
|
|
|
110
110
|
} else {
|
|
111
111
|
shortcutPanelService.open();
|
|
112
112
|
sidebarService.open({
|
|
113
|
-
header: { title: "shortcut-panel.title" },
|
|
113
|
+
header: { title: "ui.shortcut-panel.title" },
|
|
114
114
|
children: { label: ShortcutPanelComponentName }
|
|
115
115
|
});
|
|
116
116
|
}
|
|
@@ -338,9 +338,13 @@ function getMenuHiddenObservable(accessor, targetUniverType, matchUnitId, needHi
|
|
|
338
338
|
subscriber.next(univerType !== targetUniverType);
|
|
339
339
|
});
|
|
340
340
|
const focusedUniverInstance = univerInstanceService.getFocusedUnit();
|
|
341
|
-
if (focusedUniverInstance == null)
|
|
342
|
-
|
|
343
|
-
|
|
341
|
+
if (focusedUniverInstance == null) {
|
|
342
|
+
const currentUnit = univerInstanceService.getCurrentUnitOfType(targetUniverType);
|
|
343
|
+
subscriber.next(currentUnit == null);
|
|
344
|
+
} else {
|
|
345
|
+
const univerType = univerInstanceService.getUnitType(focusedUniverInstance.getUnitId());
|
|
346
|
+
subscriber.next(univerType !== targetUniverType);
|
|
347
|
+
}
|
|
344
348
|
return () => subscription.unsubscribe();
|
|
345
349
|
});
|
|
346
350
|
}
|
|
@@ -354,9 +358,11 @@ function getHeaderFooterMenuHiddenObservable(accessor) {
|
|
|
354
358
|
subscriber.next(documentFlavor !== DocumentFlavor.TRADITIONAL);
|
|
355
359
|
});
|
|
356
360
|
const docDataModel = univerInstanceService.getCurrentUniverDocInstance();
|
|
357
|
-
if (docDataModel == null)
|
|
358
|
-
|
|
359
|
-
|
|
361
|
+
if (docDataModel == null) subscriber.next(true);
|
|
362
|
+
else {
|
|
363
|
+
const documentFlavor = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot().documentStyle.documentFlavor;
|
|
364
|
+
subscriber.next(documentFlavor !== DocumentFlavor.TRADITIONAL);
|
|
365
|
+
}
|
|
360
366
|
return () => subscription.unsubscribe();
|
|
361
367
|
});
|
|
362
368
|
}
|
|
@@ -765,7 +771,7 @@ const configSymbol = Symbol(UI_PLUGIN_CONFIG_KEY);
|
|
|
765
771
|
const defaultPluginConfig = {};
|
|
766
772
|
|
|
767
773
|
//#endregion
|
|
768
|
-
//#region \0@oxc-project+runtime@0.
|
|
774
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
|
|
769
775
|
function __decorateParam(paramIndex, decorator) {
|
|
770
776
|
return function(target, key) {
|
|
771
777
|
decorator(target, key, paramIndex);
|
|
@@ -773,7 +779,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
773
779
|
}
|
|
774
780
|
|
|
775
781
|
//#endregion
|
|
776
|
-
//#region \0@oxc-project+runtime@0.
|
|
782
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
|
|
777
783
|
function __decorate(decorators, target, key, desc) {
|
|
778
784
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
779
785
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -787,67 +793,67 @@ const IFontService = createIdentifier("univer.font-service");
|
|
|
787
793
|
const DEFAULT_FONT_LIST = [
|
|
788
794
|
{
|
|
789
795
|
value: "Arial",
|
|
790
|
-
label: "fontFamily.arial",
|
|
796
|
+
label: "ui.fontFamily.arial",
|
|
791
797
|
category: "sans-serif"
|
|
792
798
|
},
|
|
793
799
|
{
|
|
794
800
|
value: "Times New Roman",
|
|
795
|
-
label: "fontFamily.times-new-roman",
|
|
801
|
+
label: "ui.fontFamily.times-new-roman",
|
|
796
802
|
category: "serif"
|
|
797
803
|
},
|
|
798
804
|
{
|
|
799
805
|
value: "Tahoma",
|
|
800
|
-
label: "fontFamily.tahoma",
|
|
806
|
+
label: "ui.fontFamily.tahoma",
|
|
801
807
|
category: "sans-serif"
|
|
802
808
|
},
|
|
803
809
|
{
|
|
804
810
|
value: "Verdana",
|
|
805
|
-
label: "fontFamily.verdana",
|
|
811
|
+
label: "ui.fontFamily.verdana",
|
|
806
812
|
category: "sans-serif"
|
|
807
813
|
},
|
|
808
814
|
{
|
|
809
815
|
value: "Microsoft YaHei",
|
|
810
|
-
label: "fontFamily.microsoft-yahei",
|
|
816
|
+
label: "ui.fontFamily.microsoft-yahei",
|
|
811
817
|
category: "sans-serif"
|
|
812
818
|
},
|
|
813
819
|
{
|
|
814
820
|
value: "SimSun",
|
|
815
|
-
label: "fontFamily.simsun",
|
|
821
|
+
label: "ui.fontFamily.simsun",
|
|
816
822
|
category: "serif"
|
|
817
823
|
},
|
|
818
824
|
{
|
|
819
825
|
value: "SimHei",
|
|
820
|
-
label: "fontFamily.simhei",
|
|
826
|
+
label: "ui.fontFamily.simhei",
|
|
821
827
|
category: "sans-serif"
|
|
822
828
|
},
|
|
823
829
|
{
|
|
824
830
|
value: "Kaiti",
|
|
825
|
-
label: "fontFamily.kaiti",
|
|
831
|
+
label: "ui.fontFamily.kaiti",
|
|
826
832
|
category: "serif"
|
|
827
833
|
},
|
|
828
834
|
{
|
|
829
835
|
value: "FangSong",
|
|
830
|
-
label: "fontFamily.fangsong",
|
|
836
|
+
label: "ui.fontFamily.fangsong",
|
|
831
837
|
category: "serif"
|
|
832
838
|
},
|
|
833
839
|
{
|
|
834
840
|
value: "NSimSun",
|
|
835
|
-
label: "fontFamily.nsimsun",
|
|
841
|
+
label: "ui.fontFamily.nsimsun",
|
|
836
842
|
category: "serif"
|
|
837
843
|
},
|
|
838
844
|
{
|
|
839
845
|
value: "STXinwei",
|
|
840
|
-
label: "fontFamily.stxinwei",
|
|
846
|
+
label: "ui.fontFamily.stxinwei",
|
|
841
847
|
category: "serif"
|
|
842
848
|
},
|
|
843
849
|
{
|
|
844
850
|
value: "STXingkai",
|
|
845
|
-
label: "fontFamily.stxingkai",
|
|
851
|
+
label: "ui.fontFamily.stxingkai",
|
|
846
852
|
category: "serif"
|
|
847
853
|
},
|
|
848
854
|
{
|
|
849
855
|
value: "STLiti",
|
|
850
|
-
label: "fontFamily.stliti",
|
|
856
|
+
label: "ui.fontFamily.stliti",
|
|
851
857
|
category: "serif"
|
|
852
858
|
}
|
|
853
859
|
];
|
|
@@ -1136,7 +1142,7 @@ const FontFamilyItem = ({ id, value }) => {
|
|
|
1136
1142
|
type: "button",
|
|
1137
1143
|
onClick: () => handleSelectFont(font.value),
|
|
1138
1144
|
children: [localeService.t(font.label), !fontService.isFontSupported(font.value) && /* @__PURE__ */ jsx(Tooltip, {
|
|
1139
|
-
title: localeService.t("fontFamily.not-supported"),
|
|
1145
|
+
title: localeService.t("ui.fontFamily.not-supported"),
|
|
1140
1146
|
children: /* @__PURE__ */ jsx(InfoIcon, { className: "univer-text-gray-300 dark:!univer-text-gray-400" })
|
|
1141
1147
|
})]
|
|
1142
1148
|
}) }, font.value))
|
|
@@ -1244,35 +1250,35 @@ const FONT_SIZE_LIST = [
|
|
|
1244
1250
|
];
|
|
1245
1251
|
const HEADING_LIST = [
|
|
1246
1252
|
{
|
|
1247
|
-
label: "toolbar.heading.normal",
|
|
1253
|
+
label: "ui.toolbar.heading.normal",
|
|
1248
1254
|
value: NamedStyleType.NORMAL_TEXT
|
|
1249
1255
|
},
|
|
1250
1256
|
{
|
|
1251
|
-
label: "toolbar.heading.title",
|
|
1257
|
+
label: "ui.toolbar.heading.title",
|
|
1252
1258
|
value: NamedStyleType.TITLE
|
|
1253
1259
|
},
|
|
1254
1260
|
{
|
|
1255
|
-
label: "toolbar.heading.subTitle",
|
|
1261
|
+
label: "ui.toolbar.heading.subTitle",
|
|
1256
1262
|
value: NamedStyleType.SUBTITLE
|
|
1257
1263
|
},
|
|
1258
1264
|
{
|
|
1259
|
-
label: "toolbar.heading.1",
|
|
1265
|
+
label: "ui.toolbar.heading.1",
|
|
1260
1266
|
value: NamedStyleType.HEADING_1
|
|
1261
1267
|
},
|
|
1262
1268
|
{
|
|
1263
|
-
label: "toolbar.heading.2",
|
|
1269
|
+
label: "ui.toolbar.heading.2",
|
|
1264
1270
|
value: NamedStyleType.HEADING_2
|
|
1265
1271
|
},
|
|
1266
1272
|
{
|
|
1267
|
-
label: "toolbar.heading.3",
|
|
1273
|
+
label: "ui.toolbar.heading.3",
|
|
1268
1274
|
value: NamedStyleType.HEADING_3
|
|
1269
1275
|
},
|
|
1270
1276
|
{
|
|
1271
|
-
label: "toolbar.heading.4",
|
|
1277
|
+
label: "ui.toolbar.heading.4",
|
|
1272
1278
|
value: NamedStyleType.HEADING_4
|
|
1273
1279
|
},
|
|
1274
1280
|
{
|
|
1275
|
-
label: "toolbar.heading.5",
|
|
1281
|
+
label: "ui.toolbar.heading.5",
|
|
1276
1282
|
value: NamedStyleType.HEADING_5
|
|
1277
1283
|
}
|
|
1278
1284
|
];
|
|
@@ -1464,12 +1470,6 @@ const useVirtualList = (list, options) => {
|
|
|
1464
1470
|
}];
|
|
1465
1471
|
};
|
|
1466
1472
|
|
|
1467
|
-
//#endregion
|
|
1468
|
-
//#region src/components/hooks/locale.ts
|
|
1469
|
-
function t(localeService, key, ...args) {
|
|
1470
|
-
return localeService.t(key);
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
1473
|
//#endregion
|
|
1474
1474
|
//#region src/components/progress-bar/ProgressBar.tsx
|
|
1475
1475
|
/**
|
|
@@ -1981,15 +1981,17 @@ function whenEditorFocusedButNotCellEditor(contextService) {
|
|
|
1981
1981
|
}
|
|
1982
1982
|
const CopyShortcutItem = {
|
|
1983
1983
|
id: CopyCommand.id,
|
|
1984
|
-
description: "shortcut.copy",
|
|
1984
|
+
description: "ui.shortcut.copy",
|
|
1985
1985
|
group: "1_common-edit",
|
|
1986
|
+
groupTitle: "ui.common-edit",
|
|
1986
1987
|
binding: 67 | 4096,
|
|
1987
1988
|
preconditions: whenEditorFocused
|
|
1988
1989
|
};
|
|
1989
1990
|
const CutShortcutItem = {
|
|
1990
1991
|
id: CutCommand.id,
|
|
1991
|
-
description: "shortcut.cut",
|
|
1992
|
+
description: "ui.shortcut.cut",
|
|
1992
1993
|
group: "1_common-edit",
|
|
1994
|
+
groupTitle: "ui.common-edit",
|
|
1993
1995
|
binding: 88 | 4096,
|
|
1994
1996
|
preconditions: whenEditorFocused
|
|
1995
1997
|
};
|
|
@@ -1998,22 +2000,25 @@ const CutShortcutItem = {
|
|
|
1998
2000
|
*/
|
|
1999
2001
|
const OnlyDisplayPasteShortcutItem = {
|
|
2000
2002
|
id: PasteCommand.id,
|
|
2001
|
-
description: "shortcut.paste",
|
|
2003
|
+
description: "ui.shortcut.paste",
|
|
2002
2004
|
group: "1_common-edit",
|
|
2005
|
+
groupTitle: "ui.common-edit",
|
|
2003
2006
|
binding: 86 | 4096,
|
|
2004
2007
|
preconditions: () => false
|
|
2005
2008
|
};
|
|
2006
2009
|
const UndoShortcutItem = {
|
|
2007
2010
|
id: UndoCommand.id,
|
|
2008
|
-
description: "shortcut.undo",
|
|
2011
|
+
description: "ui.shortcut.undo",
|
|
2009
2012
|
group: "1_common-edit",
|
|
2013
|
+
groupTitle: "ui.common-edit",
|
|
2010
2014
|
binding: 90 | 4096,
|
|
2011
2015
|
preconditions: whenEditorFocusedButNotCellEditor
|
|
2012
2016
|
};
|
|
2013
2017
|
const RedoShortcutItem = {
|
|
2014
2018
|
id: RedoCommand.id,
|
|
2015
|
-
description: "shortcut.redo",
|
|
2019
|
+
description: "ui.shortcut.redo",
|
|
2016
2020
|
group: "1_common-edit",
|
|
2021
|
+
groupTitle: "ui.common-edit",
|
|
2017
2022
|
binding: 89 | 4096,
|
|
2018
2023
|
preconditions: whenEditorFocusedButNotCellEditor
|
|
2019
2024
|
};
|
|
@@ -2150,6 +2155,7 @@ let MenuManagerService = class MenuManagerService extends Disposable {
|
|
|
2150
2155
|
["ribbon"]: {
|
|
2151
2156
|
["ribbon.start"]: {
|
|
2152
2157
|
order: 0,
|
|
2158
|
+
title: "ui.ribbon.start",
|
|
2153
2159
|
["ribbon.start.history"]: { order: 0 },
|
|
2154
2160
|
["ribbon.start.format"]: { order: 1 },
|
|
2155
2161
|
["ribbon.start.layout"]: { order: 2 },
|
|
@@ -2157,17 +2163,20 @@ let MenuManagerService = class MenuManagerService extends Disposable {
|
|
|
2157
2163
|
},
|
|
2158
2164
|
["ribbon.insert"]: {
|
|
2159
2165
|
order: 1,
|
|
2166
|
+
title: "ui.ribbon.insert",
|
|
2160
2167
|
["ribbon.insert.edit"]: { order: 0 },
|
|
2161
2168
|
["ribbon.insert.media"]: { order: 1 },
|
|
2162
2169
|
["ribbon.insert.others"]: { order: 2 }
|
|
2163
2170
|
},
|
|
2164
2171
|
["ribbon.formulas"]: {
|
|
2165
2172
|
order: 2,
|
|
2173
|
+
title: "ui.ribbon.formulas",
|
|
2166
2174
|
["ribbon.formulas.basic"]: { order: 0 },
|
|
2167
2175
|
["ribbon.formulas.others"]: { order: 1 }
|
|
2168
2176
|
},
|
|
2169
2177
|
["ribbon.data"]: {
|
|
2170
2178
|
order: 3,
|
|
2179
|
+
title: "ui.ribbon.data",
|
|
2171
2180
|
["ribbon.data.formulas"]: { order: 0 },
|
|
2172
2181
|
["ribbon.data.rules"]: { order: 1 },
|
|
2173
2182
|
["ribbon.data.organization"]: { order: 2 },
|
|
@@ -2175,12 +2184,14 @@ let MenuManagerService = class MenuManagerService extends Disposable {
|
|
|
2175
2184
|
},
|
|
2176
2185
|
["ribbon.view"]: {
|
|
2177
2186
|
order: 4,
|
|
2187
|
+
title: "ui.ribbon.view",
|
|
2178
2188
|
["ribbon.view.display"]: { order: 0 },
|
|
2179
2189
|
["ribbon.view.Visibility"]: { order: 0 },
|
|
2180
2190
|
["ribbon.view.others"]: { order: 0 }
|
|
2181
2191
|
},
|
|
2182
2192
|
["ribbon.others"]: {
|
|
2183
2193
|
order: 5,
|
|
2194
|
+
title: "ui.ribbon.others",
|
|
2184
2195
|
["ribbon.others.others"]: { order: 0 }
|
|
2185
2196
|
}
|
|
2186
2197
|
},
|
|
@@ -2275,7 +2286,8 @@ let MenuManagerService = class MenuManagerService extends Disposable {
|
|
|
2275
2286
|
order: value.order,
|
|
2276
2287
|
title: value.title,
|
|
2277
2288
|
contextual: value.contextual,
|
|
2278
|
-
quickLayout: value.quickLayout
|
|
2289
|
+
quickLayout: value.quickLayout,
|
|
2290
|
+
tiny: value.tiny
|
|
2279
2291
|
};
|
|
2280
2292
|
if (value.menuItemFactory) {
|
|
2281
2293
|
const item = this._injector.invoke(value.menuItemFactory);
|
|
@@ -2293,7 +2305,7 @@ let MenuManagerService = class MenuManagerService extends Disposable {
|
|
|
2293
2305
|
if (menuItem.item || menuItem.children) result.push(menuItem);
|
|
2294
2306
|
}
|
|
2295
2307
|
}
|
|
2296
|
-
return result;
|
|
2308
|
+
return result.sort((a, b) => normalizeMenuOrder(a.order) - normalizeMenuOrder(b.order));
|
|
2297
2309
|
}
|
|
2298
2310
|
/**
|
|
2299
2311
|
* Get menu schema by position key
|
|
@@ -2334,6 +2346,9 @@ let MenuManagerService = class MenuManagerService extends Disposable {
|
|
|
2334
2346
|
}
|
|
2335
2347
|
};
|
|
2336
2348
|
MenuManagerService = __decorate([__decorateParam(0, Inject(Injector)), __decorateParam(1, IConfigService)], MenuManagerService);
|
|
2349
|
+
function normalizeMenuOrder(order) {
|
|
2350
|
+
return order !== null && order !== void 0 ? order : 0;
|
|
2351
|
+
}
|
|
2337
2352
|
|
|
2338
2353
|
//#endregion
|
|
2339
2354
|
//#region src/views/components/shortcut-panel/ShortcutPanel.tsx
|
|
@@ -2363,6 +2378,7 @@ function ShortcutPanel() {
|
|
|
2363
2378
|
const updateShortcuts = useCallback(() => {
|
|
2364
2379
|
const shortcutGroups = /* @__PURE__ */ new Map();
|
|
2365
2380
|
const shortcuts = shortcutService.getAllShortcuts().filter((item) => !!item.group);
|
|
2381
|
+
const groupTitles = /* @__PURE__ */ new Map();
|
|
2366
2382
|
for (const shortcut of shortcuts) {
|
|
2367
2383
|
var _shortcut$description;
|
|
2368
2384
|
const group = shortcut.group;
|
|
@@ -2370,16 +2386,18 @@ function ShortcutPanel() {
|
|
|
2370
2386
|
title: localeService.t((_shortcut$description = shortcut.description) !== null && _shortcut$description !== void 0 ? _shortcut$description : shortcut.id),
|
|
2371
2387
|
shortcut: shortcutService.getShortcutDisplay(shortcut)
|
|
2372
2388
|
};
|
|
2373
|
-
if (
|
|
2389
|
+
if (!/^\d+_/.test(group)) throw new Error(`[ShortcutPanel]: Invalid shortcut group: ${group}!`);
|
|
2390
|
+
if (!shortcut.groupTitle) throw new Error(`[ShortcutPanel]: Shortcut group "${group}" must provide a groupTitle!`);
|
|
2391
|
+
if (!groupTitles.has(group)) groupTitles.set(group, shortcut.groupTitle);
|
|
2374
2392
|
if (!shortcutGroups.has(group)) shortcutGroups.set(group, []);
|
|
2375
2393
|
shortcutGroups.get(group).push(shortcutItem);
|
|
2376
2394
|
}
|
|
2377
2395
|
setShortcutItems(Array.from(shortcutGroups.entries()).map(([name, items]) => {
|
|
2378
2396
|
const groupSequence = name.split("_")[0];
|
|
2379
|
-
const
|
|
2397
|
+
const localeKey = groupTitles.get(name);
|
|
2380
2398
|
return {
|
|
2381
2399
|
sequence: +groupSequence,
|
|
2382
|
-
name: localeService.t(
|
|
2400
|
+
name: localeService.t(localeKey),
|
|
2383
2401
|
items: dedupeBy(items, (item) => item.title + item.shortcut)
|
|
2384
2402
|
};
|
|
2385
2403
|
}).sort((a, b) => a.sequence - b.sequence));
|
|
@@ -2416,8 +2434,9 @@ function ShortcutPanel() {
|
|
|
2416
2434
|
const ToggleShortcutPanelShortcut = {
|
|
2417
2435
|
id: ToggleShortcutPanelOperation.id,
|
|
2418
2436
|
binding: 4096 | 220,
|
|
2419
|
-
description: "shortcut.shortcut-panel",
|
|
2420
|
-
group: "10_global-shortcut"
|
|
2437
|
+
description: "ui.shortcut.shortcut-panel",
|
|
2438
|
+
group: "10_global-shortcut",
|
|
2439
|
+
groupTitle: "ui.global-shortcut"
|
|
2421
2440
|
};
|
|
2422
2441
|
let ShortcutPanelController = class ShortcutPanelController extends Disposable {
|
|
2423
2442
|
constructor(injector, componentManager, shortcutService, _menuManagerService, commandService) {
|
|
@@ -2468,7 +2487,7 @@ function UndoMenuItemFactory(accessor) {
|
|
|
2468
2487
|
type: 0,
|
|
2469
2488
|
icon: "UndoIcon",
|
|
2470
2489
|
title: "Undo",
|
|
2471
|
-
tooltip: "
|
|
2490
|
+
tooltip: "ui.shortcut.undo",
|
|
2472
2491
|
disabled$: undoRedoDisableFactory$(accessor, true)
|
|
2473
2492
|
};
|
|
2474
2493
|
}
|
|
@@ -2478,7 +2497,7 @@ function RedoMenuItemFactory(accessor) {
|
|
|
2478
2497
|
type: 0,
|
|
2479
2498
|
icon: "RedoIcon",
|
|
2480
2499
|
title: "Redo",
|
|
2481
|
-
tooltip: "
|
|
2500
|
+
tooltip: "ui.shortcut.redo",
|
|
2482
2501
|
disabled$: undoRedoDisableFactory$(accessor, false)
|
|
2483
2502
|
};
|
|
2484
2503
|
}
|
|
@@ -2488,8 +2507,8 @@ function RedoMenuItemFactory(accessor) {
|
|
|
2488
2507
|
function ShortcutPanelMenuItemFactory() {
|
|
2489
2508
|
return {
|
|
2490
2509
|
id: ToggleShortcutPanelOperation.id,
|
|
2491
|
-
title: "toggle-shortcut-panel",
|
|
2492
|
-
tooltip: "toggle-shortcut-panel",
|
|
2510
|
+
title: "ui.toggle-shortcut-panel",
|
|
2511
|
+
tooltip: "ui.toggle-shortcut-panel",
|
|
2493
2512
|
icon: "ShortcutIcon",
|
|
2494
2513
|
type: 0
|
|
2495
2514
|
};
|
|
@@ -3039,6 +3058,7 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
|
|
|
3039
3058
|
_defineProperty(this, "_visibleContextualTabs", /* @__PURE__ */ new Set());
|
|
3040
3059
|
_defineProperty(this, "_contextualTabs", /* @__PURE__ */ new Set());
|
|
3041
3060
|
_defineProperty(this, "_lastNonContextualActivatedTab", "ribbon.start");
|
|
3061
|
+
_defineProperty(this, "_hiddenSubscription", null);
|
|
3042
3062
|
this._initRibbonSubscription();
|
|
3043
3063
|
}
|
|
3044
3064
|
setActivatedTab(tab) {
|
|
@@ -3071,6 +3091,7 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
|
|
|
3071
3091
|
}));
|
|
3072
3092
|
}
|
|
3073
3093
|
_updateRibbon() {
|
|
3094
|
+
var _this$_hiddenSubscrip;
|
|
3074
3095
|
const ribbon = this._filterContextualTabs(this._menuManagerService.getMenuByPositionKey("ribbon"));
|
|
3075
3096
|
const hiddenObservableMap = [];
|
|
3076
3097
|
const hiddenKeyMap = [];
|
|
@@ -3087,7 +3108,8 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
|
|
|
3087
3108
|
this._setRibbon(ribbon);
|
|
3088
3109
|
return;
|
|
3089
3110
|
}
|
|
3090
|
-
|
|
3111
|
+
(_this$_hiddenSubscrip = this._hiddenSubscription) === null || _this$_hiddenSubscrip === void 0 || _this$_hiddenSubscrip.unsubscribe();
|
|
3112
|
+
this._hiddenSubscription = combineLatest(hiddenObservableMap).pipe(startWith$1(new Array(hiddenObservableMap.length).fill(false))).subscribe((hiddenMap) => {
|
|
3091
3113
|
const newRibbon = [];
|
|
3092
3114
|
const hiddenPathMap = hiddenMap.map((hidden, index) => {
|
|
3093
3115
|
if (hidden) return hiddenKeyMap[index];
|
|
@@ -3128,7 +3150,7 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
|
|
|
3128
3150
|
})) newRibbon.push(newGroup);
|
|
3129
3151
|
}
|
|
3130
3152
|
this._setRibbon(newRibbon);
|
|
3131
|
-
})
|
|
3153
|
+
});
|
|
3132
3154
|
}
|
|
3133
3155
|
_filterContextualTabs(ribbon) {
|
|
3134
3156
|
this._contextualTabs.clear();
|
|
@@ -3144,12 +3166,27 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
|
|
|
3144
3166
|
var _ref, _ribbon$find;
|
|
3145
3167
|
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];
|
|
3146
3168
|
if (fallbackTab) this._activatedTab$.next(fallbackTab.key);
|
|
3169
|
+
} else if (!activeGroup && ribbon.some((group) => group.key === "ribbon.start")) {
|
|
3170
|
+
const fallbackTab = ribbon.find((group) => group.key === "ribbon.start");
|
|
3171
|
+
this._activatedTab$.next(fallbackTab.key);
|
|
3172
|
+
if (!fallbackTab.contextual) this._lastNonContextualActivatedTab = fallbackTab.key;
|
|
3147
3173
|
} else if (activeGroup && !activeGroup.contextual) this._lastNonContextualActivatedTab = activeGroup.key;
|
|
3148
3174
|
this._ribbon$.next(ribbon);
|
|
3149
3175
|
}
|
|
3150
3176
|
_isContextualTab(tab) {
|
|
3151
3177
|
return this._contextualTabs.has(tab) || this._ribbon$.getValue().some((group) => group.key === tab && group.contextual);
|
|
3152
3178
|
}
|
|
3179
|
+
dispose() {
|
|
3180
|
+
var _this$_hiddenSubscrip2;
|
|
3181
|
+
(_this$_hiddenSubscrip2 = this._hiddenSubscription) === null || _this$_hiddenSubscrip2 === void 0 || _this$_hiddenSubscrip2.unsubscribe();
|
|
3182
|
+
this._hiddenSubscription = null;
|
|
3183
|
+
this._ribbon$.next([]);
|
|
3184
|
+
this._ribbon$.complete();
|
|
3185
|
+
this._activatedTab$.complete();
|
|
3186
|
+
this._collapsedIds$.complete();
|
|
3187
|
+
this._fakeToolbarVisible$.complete();
|
|
3188
|
+
super.dispose();
|
|
3189
|
+
}
|
|
3153
3190
|
};
|
|
3154
3191
|
DesktopRibbonService = __decorate([__decorateParam(0, IMenuManagerService), __decorateParam(1, IUniverInstanceService)], DesktopRibbonService);
|
|
3155
3192
|
|
|
@@ -3192,14 +3229,14 @@ function ClassicMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
|
3192
3229
|
return /* @__PURE__ */ jsx("div", {
|
|
3193
3230
|
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",
|
|
3194
3231
|
role: "tablist",
|
|
3195
|
-
"aria-label": localeService.t("ribbon.menu"),
|
|
3232
|
+
"aria-label": localeService.t("ui.ribbon.menu"),
|
|
3196
3233
|
children: ribbon.map((group) => {
|
|
3197
3234
|
const isActive = activatedTab === group.key;
|
|
3198
3235
|
return /* @__PURE__ */ jsx("button", {
|
|
3199
3236
|
type: "button",
|
|
3200
3237
|
role: "tab",
|
|
3201
3238
|
"aria-selected": isActive,
|
|
3202
|
-
title: localeService.t(group.key),
|
|
3239
|
+
title: localeService.t(group.title || group.key),
|
|
3203
3240
|
onClick: () => onSelectTab(group),
|
|
3204
3241
|
className: 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 ? `
|
|
3205
3242
|
univer-bg-primary-50 univer-font-semibold univer-text-primary-600 univer-shadow-sm
|
|
@@ -3210,7 +3247,7 @@ function ClassicMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
|
3210
3247
|
univer-bg-transparent univer-text-gray-700
|
|
3211
3248
|
dark:!univer-text-gray-200
|
|
3212
3249
|
`),
|
|
3213
|
-
children: localeService.t(group.key)
|
|
3250
|
+
children: localeService.t(group.title || group.key)
|
|
3214
3251
|
}, group.key);
|
|
3215
3252
|
})
|
|
3216
3253
|
});
|
|
@@ -3227,7 +3264,9 @@ const iconMap = {
|
|
|
3227
3264
|
["ribbon.others"]: MoreFunctionIcon
|
|
3228
3265
|
};
|
|
3229
3266
|
function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
3267
|
+
var _ribbon$find;
|
|
3230
3268
|
const localeService = useDependency(LocaleService);
|
|
3269
|
+
const activatedTabTitle = ((_ribbon$find = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find === void 0 ? void 0 : _ribbon$find.title) || activatedTab;
|
|
3231
3270
|
const [groupSelectorVisible, setGroupSelectorVisible] = useState(false);
|
|
3232
3271
|
function handleSelectTab(tab) {
|
|
3233
3272
|
onSelectTab(tab);
|
|
@@ -3254,10 +3293,10 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
|
3254
3293
|
className: "univer-flex univer-flex-col",
|
|
3255
3294
|
children: [/* @__PURE__ */ jsx("strong", {
|
|
3256
3295
|
className: "univer-text-sm univer-font-semibold univer-text-gray-800 dark:!univer-text-gray-200",
|
|
3257
|
-
children: localeService.t(group.key)
|
|
3296
|
+
children: localeService.t(group.title || group.key)
|
|
3258
3297
|
}), /* @__PURE__ */ jsx("span", {
|
|
3259
3298
|
className: "univer-text-xs univer-text-gray-400",
|
|
3260
|
-
children: localeService.t(`${group.key}Desc`)
|
|
3299
|
+
children: localeService.t(`${group.title || group.key}Desc`)
|
|
3261
3300
|
})]
|
|
3262
3301
|
})]
|
|
3263
3302
|
}, group.key);
|
|
@@ -3267,7 +3306,7 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
|
3267
3306
|
children: /* @__PURE__ */ jsxs("a", {
|
|
3268
3307
|
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",
|
|
3269
3308
|
onClick: () => setGroupSelectorVisible(true),
|
|
3270
|
-
children: [localeService.t(
|
|
3309
|
+
children: [localeService.t(activatedTabTitle), /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-text-gray-200 dark:!univer-text-gray-500" })]
|
|
3271
3310
|
})
|
|
3272
3311
|
});
|
|
3273
3312
|
}
|
|
@@ -3489,6 +3528,10 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3489
3528
|
function handleVisibleChange(visible) {
|
|
3490
3529
|
setDropdownVisible(visible);
|
|
3491
3530
|
}
|
|
3531
|
+
function handleOptionSelect(option) {
|
|
3532
|
+
onOptionSelect(option);
|
|
3533
|
+
setDropdownVisible(false);
|
|
3534
|
+
}
|
|
3492
3535
|
useEffect(() => {
|
|
3493
3536
|
const subscriptions = [];
|
|
3494
3537
|
menuItems.forEach((item) => {
|
|
@@ -3527,7 +3570,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3527
3570
|
overlay: options.map((option, index) => /* @__PURE__ */ jsx(Label, {
|
|
3528
3571
|
value,
|
|
3529
3572
|
option,
|
|
3530
|
-
onOptionSelect
|
|
3573
|
+
onOptionSelect: handleOptionSelect
|
|
3531
3574
|
}, index)),
|
|
3532
3575
|
children
|
|
3533
3576
|
});
|
|
@@ -3541,15 +3584,16 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3541
3584
|
icon: option.icon,
|
|
3542
3585
|
value,
|
|
3543
3586
|
option,
|
|
3544
|
-
onOptionSelect
|
|
3587
|
+
onOptionSelect: handleOptionSelect
|
|
3545
3588
|
}),
|
|
3546
3589
|
disabled: option.disabled,
|
|
3547
3590
|
onSelect: () => {
|
|
3548
3591
|
if (typeof option.value === "undefined") return;
|
|
3549
|
-
|
|
3592
|
+
handleOptionSelect({ ...option });
|
|
3550
3593
|
}
|
|
3551
3594
|
};
|
|
3552
3595
|
});
|
|
3596
|
+
if (filteredMenuItems.length) items.push({ type: "separator" });
|
|
3553
3597
|
for (const menuItem of filteredMenuItems) {
|
|
3554
3598
|
if (!menuItem.item) continue;
|
|
3555
3599
|
const { title, id, commandId, icon } = menuItem.item;
|
|
@@ -3565,7 +3609,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3565
3609
|
} }
|
|
3566
3610
|
}),
|
|
3567
3611
|
onSelect: () => {
|
|
3568
|
-
|
|
3612
|
+
handleOptionSelect({
|
|
3569
3613
|
commandId,
|
|
3570
3614
|
id
|
|
3571
3615
|
});
|
|
@@ -3598,7 +3642,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3598
3642
|
} }
|
|
3599
3643
|
}),
|
|
3600
3644
|
onSelect: () => {
|
|
3601
|
-
|
|
3645
|
+
handleOptionSelect({
|
|
3602
3646
|
commandId,
|
|
3603
3647
|
id
|
|
3604
3648
|
});
|
|
@@ -3804,13 +3848,17 @@ function Ribbon(props) {
|
|
|
3804
3848
|
}
|
|
3805
3849
|
return ribbonData;
|
|
3806
3850
|
}, [ribbonType, ribbonData]);
|
|
3851
|
+
const activatedTabTitle = useMemo(() => {
|
|
3852
|
+
var _ribbon$find;
|
|
3853
|
+
return ((_ribbon$find = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find === void 0 ? void 0 : _ribbon$find.title) || activatedTab;
|
|
3854
|
+
}, [ribbon, activatedTab]);
|
|
3807
3855
|
const handleSelectTab = useCallback((group) => {
|
|
3808
3856
|
toolbarItemRefs.current = {};
|
|
3809
3857
|
ribbonService.setActivatedTab(group.key);
|
|
3810
3858
|
}, []);
|
|
3811
3859
|
const activeGroup = useMemo(() => {
|
|
3812
|
-
var _ribbon$find$children, _ribbon$
|
|
3813
|
-
const allGroups = (_ribbon$find$children = (_ribbon$
|
|
3860
|
+
var _ribbon$find$children, _ribbon$find2;
|
|
3861
|
+
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 : [];
|
|
3814
3862
|
const visibleGroups = [];
|
|
3815
3863
|
const hiddenGroups = [];
|
|
3816
3864
|
for (const item of allGroups) if (item.children) {
|
|
@@ -3840,14 +3888,14 @@ function Ribbon(props) {
|
|
|
3840
3888
|
for (const entry of entries) {
|
|
3841
3889
|
ribbonService.setFakeToolbarVisible(true);
|
|
3842
3890
|
timer = requestAnimationFrame(() => {
|
|
3843
|
-
var _ribbon$find$children2, _ribbon$
|
|
3891
|
+
var _ribbon$find$children2, _ribbon$find3;
|
|
3844
3892
|
const { width: avaliableWidth } = entry.contentRect;
|
|
3845
3893
|
const sortedToolbarItems = Object.values(toolbarItemRefs.current).sort((a, b) => {
|
|
3846
3894
|
return a.order - b.order || a.groupOrder - b.groupOrder || a.itemOrder - b.itemOrder;
|
|
3847
3895
|
});
|
|
3848
3896
|
const newCollapsedIds = [];
|
|
3849
3897
|
let totalWidth = 32;
|
|
3850
|
-
const gapWidth = (((_ribbon$find$children2 = (_ribbon$
|
|
3898
|
+
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;
|
|
3851
3899
|
totalWidth += gapWidth;
|
|
3852
3900
|
for (const { el, key } of sortedToolbarItems) {
|
|
3853
3901
|
const { width } = el.getBoundingClientRect();
|
|
@@ -3872,7 +3920,7 @@ function Ribbon(props) {
|
|
|
3872
3920
|
children: activeGroup.allGroups.map((groupItem, index) => {
|
|
3873
3921
|
var _groupItem$children, _groupItem$children2;
|
|
3874
3922
|
return (((_groupItem$children = groupItem.children) === null || _groupItem$children === void 0 ? void 0 : _groupItem$children.length) || groupItem.item) && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", {
|
|
3875
|
-
className: "univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2",
|
|
3923
|
+
className: "\n univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2\n empty:univer-hidden\n ",
|
|
3876
3924
|
children: groupItem.children && ((_groupItem$children2 = groupItem.children) === null || _groupItem$children2 === void 0 ? void 0 : _groupItem$children2.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, {
|
|
3877
3925
|
...child.item,
|
|
3878
3926
|
ref: (ref) => {
|
|
@@ -3893,7 +3941,7 @@ function Ribbon(props) {
|
|
|
3893
3941
|
/* @__PURE__ */ jsxs("div", {
|
|
3894
3942
|
"data-u-comp": "ribbon-header-menu",
|
|
3895
3943
|
className: clsx("univer-relative univer-select-none", { "univer-h-9": ribbonType === "classic" || headerMenuComponents && headerMenuComponents.size > 0 }),
|
|
3896
|
-
children: [ribbonType === "classic" && ribbon.length
|
|
3944
|
+
children: [ribbonType === "classic" && ribbon.length >= 1 && /* @__PURE__ */ jsx(ClassicMenu, {
|
|
3897
3945
|
ribbon,
|
|
3898
3946
|
activatedTab,
|
|
3899
3947
|
onSelectTab: handleSelectTab
|
|
@@ -3904,11 +3952,10 @@ function Ribbon(props) {
|
|
|
3904
3952
|
}),
|
|
3905
3953
|
/* @__PURE__ */ jsxs("div", {
|
|
3906
3954
|
className: clsx("univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3 univer-text-sm", {
|
|
3907
|
-
"univer-grid-cols-[1fr] univer-justify-center": ribbonType === "classic",
|
|
3908
|
-
"univer-grid-cols-[auto,1fr]": ribbon.length > 1 && ribbonType !== "classic"
|
|
3909
|
-
"univer-grid-cols-none": ribbon.length === 1
|
|
3955
|
+
"univer-grid-cols-[1fr] univer-justify-center": ribbonType === "classic" || ribbon.length === 1,
|
|
3956
|
+
"univer-grid-cols-[auto,1fr]": ribbon.length > 1 && ribbonType !== "classic"
|
|
3910
3957
|
}, borderBottomClassName),
|
|
3911
|
-
children: [ribbonType === "collapsed" && ribbon.length
|
|
3958
|
+
children: [ribbonType === "collapsed" && ribbon.length >= 1 && /* @__PURE__ */ jsx(DefaultMenu, {
|
|
3912
3959
|
ribbon,
|
|
3913
3960
|
activatedTab,
|
|
3914
3961
|
onSelectTab: handleSelectTab
|
|
@@ -3917,11 +3964,11 @@ function Ribbon(props) {
|
|
|
3917
3964
|
ref: containerRef,
|
|
3918
3965
|
className: clsx("univer-flex univer-overflow-hidden", divideXClassName, { "univer-justify-center": ribbonType === "classic" }),
|
|
3919
3966
|
role: "toolbar",
|
|
3920
|
-
"aria-label": localeService.t(
|
|
3967
|
+
"aria-label": localeService.t(activatedTabTitle),
|
|
3921
3968
|
children: [activeGroup.visibleGroups.map((groupItem) => {
|
|
3922
3969
|
var _groupItem$children3, _groupItem$children4;
|
|
3923
3970
|
return (((_groupItem$children3 = groupItem.children) === null || _groupItem$children3 === void 0 ? void 0 : _groupItem$children3.length) || groupItem.item) && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", {
|
|
3924
|
-
className: "univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2",
|
|
3971
|
+
className: "\n univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2\n empty:univer-hidden\n ",
|
|
3925
3972
|
children: groupItem.children && ((_groupItem$children4 = groupItem.children) === null || _groupItem$children4 === void 0 ? void 0 : _groupItem$children4.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, { ...child.item }, child.key)))
|
|
3926
3973
|
}) }, groupItem.key);
|
|
3927
3974
|
}), collapsedIds.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
@@ -3949,7 +3996,7 @@ function Ribbon(props) {
|
|
|
3949
3996
|
children: /* @__PURE__ */ jsx("button", {
|
|
3950
3997
|
type: "button",
|
|
3951
3998
|
className: toolbarButtonClassName,
|
|
3952
|
-
"aria-label": localeService.t("ribbon.more"),
|
|
3999
|
+
"aria-label": localeService.t("ui.ribbon.more"),
|
|
3953
4000
|
"aria-haspopup": "true",
|
|
3954
4001
|
children: /* @__PURE__ */ jsx(MoreFunctionIcon, {})
|
|
3955
4002
|
})
|
|
@@ -4074,7 +4121,7 @@ function DesignTinyMenuGroup({ items }) {
|
|
|
4074
4121
|
const ele = /* @__PURE__ */ jsx("div", {
|
|
4075
4122
|
className: 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),
|
|
4076
4123
|
onClick: () => item.onClick(),
|
|
4077
|
-
children: /* @__PURE__ */ jsx(item.Icon, { className: "univer-size-4 univer-text-gray-900 dark:!univer-text-gray-200" })
|
|
4124
|
+
children: /* @__PURE__ */ jsx(item.Icon, { className: clsx("univer-size-4 univer-text-gray-900 dark:!univer-text-gray-200", item.iconClassName) })
|
|
4078
4125
|
}, item.key);
|
|
4079
4126
|
return item.tooltip ? /* @__PURE__ */ jsx(Tooltip, {
|
|
4080
4127
|
title: item.tooltip,
|
|
@@ -4086,8 +4133,21 @@ function DesignTinyMenuGroup({ items }) {
|
|
|
4086
4133
|
|
|
4087
4134
|
//#endregion
|
|
4088
4135
|
//#region src/components/menu/desktop/TinyMenuGroup.tsx
|
|
4136
|
+
const EMPTY_HIDDEN_ITEM_IDS = [];
|
|
4137
|
+
function resolveMenuItemActiveState(itemId, observableActive, activeItemIds) {
|
|
4138
|
+
if (activeItemIds) return Boolean(itemId && activeItemIds.includes(itemId));
|
|
4139
|
+
return observableActive;
|
|
4140
|
+
}
|
|
4141
|
+
function getTinyMenuChildStateKey(child) {
|
|
4142
|
+
var _child$item$id, _child$item;
|
|
4143
|
+
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;
|
|
4144
|
+
}
|
|
4145
|
+
function getVisibleTinyMenuChildren(children, hiddenItemKeys) {
|
|
4146
|
+
const hiddenSet = new Set(hiddenItemKeys);
|
|
4147
|
+
return children.filter((child) => !hiddenSet.has(getTinyMenuChildStateKey(child)));
|
|
4148
|
+
}
|
|
4089
4149
|
function QuickTileMenuItem(props) {
|
|
4090
|
-
const { menuSchema, onOptionSelect } = props;
|
|
4150
|
+
const { menuSchema, activeItemIds, onOptionSelect } = props;
|
|
4091
4151
|
const componentManager = useDependency(ComponentManager);
|
|
4092
4152
|
const localeService = useDependency(LocaleService);
|
|
4093
4153
|
const menuItem = menuSchema.item;
|
|
@@ -4102,7 +4162,7 @@ function QuickTileMenuItem(props) {
|
|
|
4102
4162
|
univer-cursor-pointer
|
|
4103
4163
|
hover:univer-bg-gray-50
|
|
4104
4164
|
dark:hover:!univer-bg-gray-600
|
|
4105
|
-
`, activated && `
|
|
4165
|
+
`, resolveMenuItemActiveState(menuItem.id, activated, activeItemIds) && `
|
|
4106
4166
|
univer-bg-primary-50 univer-text-primary-700 univer-ring-1 univer-ring-primary-600
|
|
4107
4167
|
dark:!univer-bg-primary-900 dark:!univer-text-primary-100
|
|
4108
4168
|
`),
|
|
@@ -4127,20 +4187,21 @@ function QuickTileMenuItem(props) {
|
|
|
4127
4187
|
});
|
|
4128
4188
|
}
|
|
4129
4189
|
function UITinyMenuGroup(props) {
|
|
4130
|
-
const { item, onOptionSelect } = props;
|
|
4190
|
+
const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, onOptionSelect } = props;
|
|
4131
4191
|
const [activeItems, setActiveItems] = useState([]);
|
|
4192
|
+
const [hiddenItems, setHiddenItems] = useState([]);
|
|
4132
4193
|
const componentManager = useDependency(ComponentManager);
|
|
4133
4194
|
const localeService = useDependency(LocaleService);
|
|
4134
4195
|
useEffect(() => {
|
|
4135
4196
|
if (!item.children) return;
|
|
4136
4197
|
const observables = item.children.map((child) => {
|
|
4137
|
-
var _child$item$activated, _child$
|
|
4138
|
-
return convertObservableToBehaviorSubject((_child$item$activated = (_child$
|
|
4198
|
+
var _child$item$activated, _child$item2;
|
|
4199
|
+
return convertObservableToBehaviorSubject((_child$item$activated = (_child$item2 = child.item) === null || _child$item2 === void 0 ? void 0 : _child$item2.activated$) !== null && _child$item$activated !== void 0 ? _child$item$activated : of(false), false);
|
|
4139
4200
|
});
|
|
4140
4201
|
const subscription = combineLatest(observables).subscribe((activedArr) => {
|
|
4141
4202
|
const actived = activedArr.map((actived, index) => ({
|
|
4142
4203
|
actived,
|
|
4143
|
-
item: item.children[index]
|
|
4204
|
+
item: getTinyMenuChildStateKey(item.children[index])
|
|
4144
4205
|
})).filter((actived) => actived.actived);
|
|
4145
4206
|
if (actived.length === 0) setActiveItems([]);
|
|
4146
4207
|
else setActiveItems(actived.map((actived) => actived.item));
|
|
@@ -4152,34 +4213,65 @@ function UITinyMenuGroup(props) {
|
|
|
4152
4213
|
});
|
|
4153
4214
|
};
|
|
4154
4215
|
}, [item]);
|
|
4216
|
+
useEffect(() => {
|
|
4217
|
+
if (!item.children) return;
|
|
4218
|
+
const observables = item.children.map((child) => {
|
|
4219
|
+
var _child$item$hidden$, _child$item3;
|
|
4220
|
+
return convertObservableToBehaviorSubject((_child$item$hidden$ = (_child$item3 = child.item) === null || _child$item3 === void 0 ? void 0 : _child$item3.hidden$) !== null && _child$item$hidden$ !== void 0 ? _child$item$hidden$ : of(false), false);
|
|
4221
|
+
});
|
|
4222
|
+
const subscription = combineLatest(observables).subscribe((hiddenArr) => {
|
|
4223
|
+
const hidden = hiddenArr.map((hidden, index) => ({
|
|
4224
|
+
hidden,
|
|
4225
|
+
item: getTinyMenuChildStateKey(item.children[index])
|
|
4226
|
+
})).filter((hidden) => hidden.hidden);
|
|
4227
|
+
if (hidden.length === 0) setHiddenItems([]);
|
|
4228
|
+
else setHiddenItems(hidden.map((hidden) => hidden.item));
|
|
4229
|
+
});
|
|
4230
|
+
return () => {
|
|
4231
|
+
subscription.unsubscribe();
|
|
4232
|
+
observables.forEach((observable) => {
|
|
4233
|
+
observable.complete();
|
|
4234
|
+
});
|
|
4235
|
+
};
|
|
4236
|
+
}, [item]);
|
|
4237
|
+
const visibleChildren = useMemo(() => {
|
|
4238
|
+
var _item$children;
|
|
4239
|
+
return getVisibleTinyMenuChildren((_item$children = item.children) !== null && _item$children !== void 0 ? _item$children : [], [...hiddenItems, ...hiddenItemIds]);
|
|
4240
|
+
}, [
|
|
4241
|
+
hiddenItemIds,
|
|
4242
|
+
hiddenItems,
|
|
4243
|
+
item.children
|
|
4244
|
+
]);
|
|
4155
4245
|
if (!item.children) return null;
|
|
4156
|
-
return /* @__PURE__ */ jsx(DesignTinyMenuGroup, { items:
|
|
4157
|
-
var _child$item$
|
|
4246
|
+
return /* @__PURE__ */ jsx(DesignTinyMenuGroup, { items: visibleChildren.map((child) => {
|
|
4247
|
+
var _child$item9, _child$item10, _child$item$id3, _child$item11;
|
|
4158
4248
|
return {
|
|
4159
4249
|
key: child.key,
|
|
4160
4250
|
onClick: () => {
|
|
4161
|
-
var _child$item$
|
|
4251
|
+
var _child$item$id2, _child$item4, _child$item5, _child$item6, _child$item7, _child$item8;
|
|
4162
4252
|
onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
|
|
4163
|
-
label: (_child$item$
|
|
4164
|
-
commandId: (_child$
|
|
4165
|
-
id: (_child$
|
|
4166
|
-
tooltip: ((_child$
|
|
4253
|
+
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,
|
|
4254
|
+
commandId: (_child$item5 = child.item) === null || _child$item5 === void 0 ? void 0 : _child$item5.commandId,
|
|
4255
|
+
id: (_child$item6 = child.item) === null || _child$item6 === void 0 ? void 0 : _child$item6.id,
|
|
4256
|
+
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)
|
|
4167
4257
|
});
|
|
4168
4258
|
},
|
|
4169
4259
|
className: "",
|
|
4260
|
+
iconClassName: ((_child$item9 = child.item) === null || _child$item9 === void 0 ? void 0 : _child$item9.icon) === "TextTypeIcon" ? "!univer-size-3.5" : void 0,
|
|
4170
4261
|
Icon: componentManager.get(child.item.icon),
|
|
4171
|
-
active: activeItems.includes((_child$item$
|
|
4262
|
+
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)
|
|
4172
4263
|
};
|
|
4173
4264
|
}) });
|
|
4174
4265
|
}
|
|
4175
4266
|
function UIQuickTileMenuGroup(props) {
|
|
4176
|
-
var _item$
|
|
4177
|
-
const { item, onOptionSelect } = props;
|
|
4178
|
-
if (!((_item$
|
|
4267
|
+
var _item$children2;
|
|
4268
|
+
const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, onOptionSelect } = props;
|
|
4269
|
+
if (!((_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.length)) return null;
|
|
4179
4270
|
return /* @__PURE__ */ jsx("div", {
|
|
4180
4271
|
className: "univer-item-center univer-grid univer-grid-cols-3 univer-gap-1.5 univer-py-1",
|
|
4181
|
-
children: item.children.map((menuSchema) => /* @__PURE__ */ jsx(QuickTileMenuItem, {
|
|
4272
|
+
children: getVisibleTinyMenuChildren(item.children, hiddenItemIds).map((menuSchema) => /* @__PURE__ */ jsx(QuickTileMenuItem, {
|
|
4182
4273
|
menuSchema,
|
|
4274
|
+
activeItemIds,
|
|
4183
4275
|
onOptionSelect
|
|
4184
4276
|
}, menuSchema.key))
|
|
4185
4277
|
});
|
|
@@ -4191,6 +4283,7 @@ const contentClassName = "univer-inline-flex univer-items-center univer-gap-2";
|
|
|
4191
4283
|
const menuViewportPadding = 8;
|
|
4192
4284
|
const submenuOverlapOffset = 2;
|
|
4193
4285
|
const submenuVisualGap = 20;
|
|
4286
|
+
const CONTEXT_MENU_SUBMENU_CLOSE_DELAY = 500;
|
|
4194
4287
|
const CONTEXT_MENU_SUBMENU_PORTAL_ATTR = "data-u-context-menu-submenu";
|
|
4195
4288
|
function isNonSelectableLabel(label) {
|
|
4196
4289
|
return typeof label === "object" && (label === null || label === void 0 ? void 0 : label.selectable) === false;
|
|
@@ -4198,9 +4291,15 @@ function isNonSelectableLabel(label) {
|
|
|
4198
4291
|
function isNonHoverableLabel(label) {
|
|
4199
4292
|
return typeof label === "object" && (label === null || label === void 0 ? void 0 : label.hoverable) === false;
|
|
4200
4293
|
}
|
|
4294
|
+
function hasRenderableContextMenuSchema(menuSchema) {
|
|
4295
|
+
var _menuSchema$children;
|
|
4296
|
+
if (menuSchema.item) return true;
|
|
4297
|
+
if (!((_menuSchema$children = menuSchema.children) === null || _menuSchema$children === void 0 ? void 0 : _menuSchema$children.length)) return false;
|
|
4298
|
+
return menuSchema.children.some((childSchema) => Boolean(childSchema.item));
|
|
4299
|
+
}
|
|
4201
4300
|
function ContextMenuPanel(props) {
|
|
4202
4301
|
var _layoutService$rootCo, _layoutService$rootCo2;
|
|
4203
|
-
const { menuType, menuSessionVersion = 0, className, onOptionSelect } = props;
|
|
4302
|
+
const { menuType, menuSessionVersion = 0, className, activeItemIds, hiddenItemIds, onOptionSelect } = props;
|
|
4204
4303
|
const menuManagerService = useDependency(IMenuManagerService);
|
|
4205
4304
|
const layoutService = useDependency(ILayoutService);
|
|
4206
4305
|
const [menuElement, setMenuElement] = useState(null);
|
|
@@ -4244,23 +4343,26 @@ function ContextMenuPanel(props) {
|
|
|
4244
4343
|
menuSchemas: menuItems,
|
|
4245
4344
|
menuSessionVersion,
|
|
4246
4345
|
submenuPortalContainer,
|
|
4346
|
+
activeItemIds,
|
|
4347
|
+
hiddenItemIds,
|
|
4247
4348
|
onOptionSelect,
|
|
4248
4349
|
maxMenuHeight
|
|
4249
4350
|
})
|
|
4250
4351
|
});
|
|
4251
4352
|
}
|
|
4252
4353
|
function ContextMenuMenu(props) {
|
|
4253
|
-
const { menuSchemas, menuSessionVersion, submenuPortalContainer, onOptionSelect, maxMenuHeight } = props;
|
|
4354
|
+
const { menuSchemas, menuSessionVersion, submenuPortalContainer, activeItemIds, hiddenItemIds, onOptionSelect, maxMenuHeight } = props;
|
|
4254
4355
|
const localeService = useDependency(LocaleService);
|
|
4255
4356
|
const hiddenGroupStates = useContextGroupHiddenStates$1(menuSchemas);
|
|
4256
4357
|
const visibleSchemas = useMemo(() => {
|
|
4257
4358
|
return menuSchemas.filter((item) => {
|
|
4359
|
+
if (!hasRenderableContextMenuSchema(item)) return false;
|
|
4258
4360
|
if (!item.children) return true;
|
|
4259
4361
|
return !hiddenGroupStates[item.key];
|
|
4260
4362
|
});
|
|
4261
4363
|
}, [hiddenGroupStates, menuSchemas]);
|
|
4262
4364
|
return /* @__PURE__ */ jsx(Fragment$1, { children: visibleSchemas.map((menuSchema, index) => {
|
|
4263
|
-
var _menuSchema$
|
|
4365
|
+
var _menuSchema$children2;
|
|
4264
4366
|
const hasSeparator = index !== visibleSchemas.length - 1;
|
|
4265
4367
|
if (menuSchema.item) return /* @__PURE__ */ jsx(ContextMenuMenuItem, {
|
|
4266
4368
|
menuKey: menuSchema.key,
|
|
@@ -4268,19 +4370,38 @@ function ContextMenuMenu(props) {
|
|
|
4268
4370
|
menuSessionVersion,
|
|
4269
4371
|
submenuPortalContainer,
|
|
4270
4372
|
onOptionSelect,
|
|
4271
|
-
maxMenuHeight
|
|
4373
|
+
maxMenuHeight,
|
|
4374
|
+
hiddenItemIds
|
|
4272
4375
|
}, menuSchema.key);
|
|
4273
|
-
if (!((_menuSchema$
|
|
4376
|
+
if (!((_menuSchema$children2 = menuSchema.children) === null || _menuSchema$children2 === void 0 ? void 0 : _menuSchema$children2.length)) return null;
|
|
4274
4377
|
if (menuSchema.quickLayout) return /* @__PURE__ */ jsx("div", {
|
|
4275
4378
|
className: clsx("univer-py-1", hasSeparator && borderBottomClassName),
|
|
4276
4379
|
children: menuSchema.quickLayout === "tile" ? /* @__PURE__ */ jsx(UIQuickTileMenuGroup, {
|
|
4277
4380
|
item: menuSchema,
|
|
4381
|
+
activeItemIds,
|
|
4382
|
+
hiddenItemIds,
|
|
4278
4383
|
onOptionSelect
|
|
4279
4384
|
}) : /* @__PURE__ */ jsx(UITinyMenuGroup, {
|
|
4280
4385
|
item: menuSchema,
|
|
4386
|
+
activeItemIds,
|
|
4387
|
+
hiddenItemIds,
|
|
4281
4388
|
onOptionSelect
|
|
4282
4389
|
})
|
|
4283
4390
|
}, menuSchema.key);
|
|
4391
|
+
if (menuSchema.tiny) return /* @__PURE__ */ jsx("div", {
|
|
4392
|
+
className: clsx("univer-flex univer-items-center univer-gap-1 univer-py-1", hasSeparator && borderBottomClassName),
|
|
4393
|
+
children: menuSchema.children.map((childSchema) => childSchema.item && /* @__PURE__ */ jsx(ContextMenuMenuItem, {
|
|
4394
|
+
menuKey: childSchema.key,
|
|
4395
|
+
menuItem: childSchema.item,
|
|
4396
|
+
menuSessionVersion,
|
|
4397
|
+
submenuPortalContainer,
|
|
4398
|
+
activeItemIds,
|
|
4399
|
+
hiddenItemIds,
|
|
4400
|
+
onOptionSelect,
|
|
4401
|
+
maxMenuHeight,
|
|
4402
|
+
compact: true
|
|
4403
|
+
}, childSchema.key))
|
|
4404
|
+
}, menuSchema.key);
|
|
4284
4405
|
return /* @__PURE__ */ jsxs("div", {
|
|
4285
4406
|
className: clsx("univer-grid univer-gap-1 univer-py-1", hasSeparator && borderBottomClassName),
|
|
4286
4407
|
children: [menuSchema.title && /* @__PURE__ */ jsx("strong", {
|
|
@@ -4291,6 +4412,8 @@ function ContextMenuMenu(props) {
|
|
|
4291
4412
|
menuItem: childSchema.item,
|
|
4292
4413
|
menuSessionVersion,
|
|
4293
4414
|
submenuPortalContainer,
|
|
4415
|
+
activeItemIds,
|
|
4416
|
+
hiddenItemIds,
|
|
4294
4417
|
onOptionSelect,
|
|
4295
4418
|
maxMenuHeight
|
|
4296
4419
|
}, childSchema.key))]
|
|
@@ -4298,8 +4421,9 @@ function ContextMenuMenu(props) {
|
|
|
4298
4421
|
}) });
|
|
4299
4422
|
}
|
|
4300
4423
|
function ContextMenuMenuItem(props) {
|
|
4301
|
-
const { menuKey, menuItem, menuSessionVersion, submenuPortalContainer, onOptionSelect, maxMenuHeight } = props;
|
|
4302
|
-
const
|
|
4424
|
+
const { menuKey, menuItem, menuSessionVersion, submenuPortalContainer, activeItemIds, hiddenItemIds = [], compact = false, onOptionSelect, maxMenuHeight } = props;
|
|
4425
|
+
const localeService = useDependency(LocaleService);
|
|
4426
|
+
const direction = useObservable(localeService.direction$);
|
|
4303
4427
|
const menuManagerService = useDependency(IMenuManagerService);
|
|
4304
4428
|
const disabled = useObservable(menuItem.disabled$, false);
|
|
4305
4429
|
const activated = useObservable(menuItem.activated$, false);
|
|
@@ -4317,6 +4441,7 @@ function ContextMenuMenuItem(props) {
|
|
|
4317
4441
|
const [submenuPlacement, setSubmenuPlacement] = useState("right");
|
|
4318
4442
|
const menuItemElementRef = useRef(null);
|
|
4319
4443
|
const submenuElementRef = useRef(null);
|
|
4444
|
+
const submenuCloseTimerRef = useRef(null);
|
|
4320
4445
|
const selections = useMemo(() => {
|
|
4321
4446
|
if (menuItem.type !== 1 && menuItem.type !== 2) return [];
|
|
4322
4447
|
if (selectionsFromObservable) return selectionsFromObservable;
|
|
@@ -4338,9 +4463,23 @@ function ContextMenuMenuItem(props) {
|
|
|
4338
4463
|
const hasSelectionSubmenu = selections.length > 0;
|
|
4339
4464
|
const hasSubItemSubmenu = subMenuItems.length > 0;
|
|
4340
4465
|
const hasSubmenu = hasSelectionSubmenu || hasSubItemSubmenu;
|
|
4466
|
+
const selectionsCommandId = selectorItem.selectionsCommandId;
|
|
4467
|
+
const clearSubmenuCloseTimer = useCallback(() => {
|
|
4468
|
+
if (submenuCloseTimerRef.current == null) return;
|
|
4469
|
+
clearTimeout(submenuCloseTimerRef.current);
|
|
4470
|
+
submenuCloseTimerRef.current = null;
|
|
4471
|
+
}, []);
|
|
4472
|
+
const scheduleSubmenuClose = useCallback(() => {
|
|
4473
|
+
clearSubmenuCloseTimer();
|
|
4474
|
+
submenuCloseTimerRef.current = setTimeout(() => {
|
|
4475
|
+
submenuCloseTimerRef.current = null;
|
|
4476
|
+
setSubmenuVisible(false);
|
|
4477
|
+
}, 500);
|
|
4478
|
+
}, [clearSubmenuCloseTimer]);
|
|
4341
4479
|
useEffect(() => {
|
|
4342
4480
|
setInputValue(value);
|
|
4343
4481
|
}, [value]);
|
|
4482
|
+
useEffect(() => () => clearSubmenuCloseTimer(), [clearSubmenuCloseTimer]);
|
|
4344
4483
|
useEffect(() => {
|
|
4345
4484
|
if (!submenuVisible) {
|
|
4346
4485
|
setSubmenuPositionReady(false);
|
|
@@ -4377,19 +4516,30 @@ function ContextMenuMenuItem(props) {
|
|
|
4377
4516
|
hasSelectionSubmenu,
|
|
4378
4517
|
hasSubItemSubmenu
|
|
4379
4518
|
]);
|
|
4380
|
-
|
|
4519
|
+
const hiddenById = menuItem.id != null && hiddenItemIds.includes(menuItem.id) || hiddenItemIds.includes(menuKey);
|
|
4520
|
+
if (hidden || hiddenById) return null;
|
|
4381
4521
|
const onChange = (v) => {
|
|
4382
4522
|
setInputValue(isRealNum(v) && typeof v === "string" ? Number.parseInt(v) : v);
|
|
4383
4523
|
};
|
|
4384
4524
|
const onSubmenuOptionSelect = (option) => {
|
|
4385
4525
|
onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect(option);
|
|
4526
|
+
clearSubmenuCloseTimer();
|
|
4386
4527
|
setSubmenuVisible(false);
|
|
4387
4528
|
};
|
|
4388
|
-
const itemClassName = clsx(
|
|
4529
|
+
const itemClassName = clsx(compact ? `
|
|
4530
|
+
univer-relative univer-flex univer-size-8 univer-items-center univer-justify-center univer-rounded-md
|
|
4531
|
+
univer-border-none univer-bg-transparent univer-p-0 univer-text-left univer-text-sm
|
|
4532
|
+
dark:!univer-text-white
|
|
4533
|
+
` : `
|
|
4534
|
+
univer-relative univer-flex univer-min-h-8 univer-w-full univer-items-center univer-justify-between
|
|
4535
|
+
univer-gap-3 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left
|
|
4536
|
+
univer-text-sm
|
|
4537
|
+
dark:!univer-text-white
|
|
4538
|
+
`, disabled ? "univer-cursor-not-allowed univer-opacity-60" : `
|
|
4389
4539
|
univer-cursor-pointer
|
|
4390
4540
|
hover:univer-bg-gray-50
|
|
4391
4541
|
dark:hover:!univer-bg-gray-600
|
|
4392
|
-
`, activated && `
|
|
4542
|
+
`, resolveMenuItemActiveState(menuItem.id, activated, activeItemIds) && `
|
|
4393
4543
|
univer-bg-gray-200
|
|
4394
4544
|
dark:!univer-bg-gray-600
|
|
4395
4545
|
`);
|
|
@@ -4397,7 +4547,7 @@ function ContextMenuMenuItem(props) {
|
|
|
4397
4547
|
className: contentClassName,
|
|
4398
4548
|
children: [/* @__PURE__ */ jsx(CustomLabel, {
|
|
4399
4549
|
value: inputValue,
|
|
4400
|
-
title: menuItem.title,
|
|
4550
|
+
title: compact ? void 0 : menuItem.title,
|
|
4401
4551
|
label: menuItem.label,
|
|
4402
4552
|
icon: menuItem.icon,
|
|
4403
4553
|
onChange
|
|
@@ -4413,6 +4563,7 @@ function ContextMenuMenuItem(props) {
|
|
|
4413
4563
|
ref: menuItemElementRef,
|
|
4414
4564
|
className: "univer-relative",
|
|
4415
4565
|
onMouseEnter: () => {
|
|
4566
|
+
clearSubmenuCloseTimer();
|
|
4416
4567
|
if (hasSubmenu && !disabled) {
|
|
4417
4568
|
setSubmenuPositionReady(false);
|
|
4418
4569
|
setSubmenuVisible(true);
|
|
@@ -4423,7 +4574,7 @@ function ContextMenuMenuItem(props) {
|
|
|
4423
4574
|
var _submenuElementRef$cu;
|
|
4424
4575
|
const nextTarget = event.relatedTarget;
|
|
4425
4576
|
if (nextTarget && ((_submenuElementRef$cu = submenuElementRef.current) === null || _submenuElementRef$cu === void 0 ? void 0 : _submenuElementRef$cu.contains(nextTarget))) return;
|
|
4426
|
-
|
|
4577
|
+
scheduleSubmenuClose();
|
|
4427
4578
|
}
|
|
4428
4579
|
},
|
|
4429
4580
|
children: [renderAsContainer ? /* @__PURE__ */ jsxs("div", {
|
|
@@ -4434,8 +4585,21 @@ function ContextMenuMenuItem(props) {
|
|
|
4434
4585
|
type: "button",
|
|
4435
4586
|
className: interactiveItemClassName,
|
|
4436
4587
|
disabled,
|
|
4588
|
+
title: compact && typeof menuItem.tooltip === "string" ? localeService.t(menuItem.tooltip) : void 0,
|
|
4437
4589
|
onClick: () => {
|
|
4590
|
+
clearSubmenuCloseTimer();
|
|
4438
4591
|
if (hasSubmenu) {
|
|
4592
|
+
if (canExecuteItem) {
|
|
4593
|
+
const item = menuItem;
|
|
4594
|
+
onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
|
|
4595
|
+
commandId: item.commandId,
|
|
4596
|
+
params: item.params,
|
|
4597
|
+
value: inputValue,
|
|
4598
|
+
id: item.id,
|
|
4599
|
+
label: menuKey
|
|
4600
|
+
});
|
|
4601
|
+
return;
|
|
4602
|
+
}
|
|
4439
4603
|
setSubmenuPositionReady(false);
|
|
4440
4604
|
setSubmenuVisible(true);
|
|
4441
4605
|
return;
|
|
@@ -4444,12 +4608,13 @@ function ContextMenuMenuItem(props) {
|
|
|
4444
4608
|
const item = menuItem;
|
|
4445
4609
|
onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
|
|
4446
4610
|
commandId: item.commandId,
|
|
4611
|
+
params: item.params,
|
|
4447
4612
|
value: inputValue,
|
|
4448
4613
|
id: item.id,
|
|
4449
4614
|
label: menuKey
|
|
4450
4615
|
});
|
|
4451
4616
|
},
|
|
4452
|
-
children: [contentNode, hasSubmenu && /* @__PURE__ */ jsx(MoreIcon, { className: "univer-size-3.5 univer-text-gray-400 dark:!univer-text-gray-200" })]
|
|
4617
|
+
children: [contentNode, hasSubmenu && !compact && /* @__PURE__ */ jsx(MoreIcon, { className: "univer-size-3.5 univer-text-gray-400 dark:!univer-text-gray-200" })]
|
|
4453
4618
|
}), hasSubmenu && submenuVisible && (submenuPortalContainer ? createPortal(/* @__PURE__ */ jsx("div", {
|
|
4454
4619
|
ref: submenuElementRef,
|
|
4455
4620
|
dir: direction,
|
|
@@ -4465,11 +4630,12 @@ function ContextMenuMenuItem(props) {
|
|
|
4465
4630
|
visibility: submenuPositionReady ? "visible" : "hidden",
|
|
4466
4631
|
pointerEvents: submenuPositionReady ? "auto" : "none"
|
|
4467
4632
|
},
|
|
4633
|
+
onMouseEnter: clearSubmenuCloseTimer,
|
|
4468
4634
|
onMouseLeave: (event) => {
|
|
4469
4635
|
var _menuItemElementRef$c;
|
|
4470
4636
|
const nextTarget = event.relatedTarget;
|
|
4471
4637
|
if (nextTarget && ((_menuItemElementRef$c = menuItemElementRef.current) === null || _menuItemElementRef$c === void 0 ? void 0 : _menuItemElementRef$c.contains(nextTarget))) return;
|
|
4472
|
-
|
|
4638
|
+
scheduleSubmenuClose();
|
|
4473
4639
|
},
|
|
4474
4640
|
onWheel: (event) => event.stopPropagation(),
|
|
4475
4641
|
children: /* @__PURE__ */ jsxs("div", {
|
|
@@ -4498,12 +4664,13 @@ function ContextMenuMenuItem(props) {
|
|
|
4498
4664
|
label: option.label,
|
|
4499
4665
|
icon: option.icon,
|
|
4500
4666
|
onChange: (optionValue) => {
|
|
4667
|
+
var _option$commandId;
|
|
4501
4668
|
onSubmenuOptionSelect === null || onSubmenuOptionSelect === void 0 || onSubmenuOptionSelect({
|
|
4502
4669
|
...option,
|
|
4503
4670
|
value: optionValue,
|
|
4504
4671
|
id: menuItem.id,
|
|
4505
4672
|
label: menuKey,
|
|
4506
|
-
commandId: option.commandId
|
|
4673
|
+
commandId: (_option$commandId = option.commandId) !== null && _option$commandId !== void 0 ? _option$commandId : selectionsCommandId
|
|
4507
4674
|
});
|
|
4508
4675
|
}
|
|
4509
4676
|
})
|
|
@@ -4513,11 +4680,12 @@ function ContextMenuMenuItem(props) {
|
|
|
4513
4680
|
className: optionClassName,
|
|
4514
4681
|
disabled: option.disabled,
|
|
4515
4682
|
onClick: () => {
|
|
4683
|
+
var _option$commandId2;
|
|
4516
4684
|
onSubmenuOptionSelect === null || onSubmenuOptionSelect === void 0 || onSubmenuOptionSelect({
|
|
4517
4685
|
...option,
|
|
4518
4686
|
id: menuItem.id,
|
|
4519
4687
|
label: menuKey,
|
|
4520
|
-
commandId: option.commandId
|
|
4688
|
+
commandId: (_option$commandId2 = option.commandId) !== null && _option$commandId2 !== void 0 ? _option$commandId2 : selectionsCommandId
|
|
4521
4689
|
});
|
|
4522
4690
|
},
|
|
4523
4691
|
children: optionContentNode
|
|
@@ -4531,6 +4699,8 @@ function ContextMenuMenuItem(props) {
|
|
|
4531
4699
|
menuSchemas: subMenuItems,
|
|
4532
4700
|
menuSessionVersion,
|
|
4533
4701
|
submenuPortalContainer,
|
|
4702
|
+
activeItemIds,
|
|
4703
|
+
hiddenItemIds,
|
|
4534
4704
|
onOptionSelect: onSubmenuOptionSelect,
|
|
4535
4705
|
maxMenuHeight
|
|
4536
4706
|
})]
|
|
@@ -4542,8 +4712,8 @@ function useContextGroupHiddenStates$1(menuSchemas) {
|
|
|
4542
4712
|
const [hiddenStates, setHiddenStates] = useState({});
|
|
4543
4713
|
useEffect(() => {
|
|
4544
4714
|
const subscriptions = menuSchemas.map((menuSchema) => {
|
|
4545
|
-
var _menuSchema$
|
|
4546
|
-
if (!((_menuSchema$
|
|
4715
|
+
var _menuSchema$children3;
|
|
4716
|
+
if (!((_menuSchema$children3 = menuSchema.children) === null || _menuSchema$children3 === void 0 ? void 0 : _menuSchema$children3.length)) return null;
|
|
4547
4717
|
return combineLatest(menuSchema.children.map((childSchema) => {
|
|
4548
4718
|
var _childSchema$item$hid, _childSchema$item;
|
|
4549
4719
|
return (_childSchema$item$hid = (_childSchema$item = childSchema.item) === null || _childSchema$item === void 0 ? void 0 : _childSchema$item.hidden$) !== null && _childSchema$item$hid !== void 0 ? _childSchema$item$hid : of(false);
|
|
@@ -4712,7 +4882,9 @@ function DesktopContextMenu() {
|
|
|
4712
4882
|
onRequestClose: handleClose,
|
|
4713
4883
|
onOptionSelect: (params) => {
|
|
4714
4884
|
const { label: id, commandId, value } = params;
|
|
4715
|
-
|
|
4885
|
+
const rawParams = typeof params.params === "function" ? params.params() : params.params;
|
|
4886
|
+
const commandParams = typeof rawParams === "undefined" ? { value } : rawParams;
|
|
4887
|
+
if (commandService) commandService.executeCommand(commandId !== null && commandId !== void 0 ? commandId : id, commandParams);
|
|
4716
4888
|
injector.get(ILayoutService).focus();
|
|
4717
4889
|
handleClose();
|
|
4718
4890
|
}
|
|
@@ -5251,7 +5423,7 @@ const IUIController = createIdentifier("univer.ui.ui-controller");
|
|
|
5251
5423
|
//#endregion
|
|
5252
5424
|
//#region package.json
|
|
5253
5425
|
var name = "@univerjs/ui";
|
|
5254
|
-
var version = "0.
|
|
5426
|
+
var version = "0.25.0";
|
|
5255
5427
|
|
|
5256
5428
|
//#endregion
|
|
5257
5429
|
//#region src/views/components/ribbon/MobileRibbon.tsx
|
|
@@ -5319,7 +5491,7 @@ function MobileRibbon(props) {
|
|
|
5319
5491
|
const container = toolbarScrollRef.current;
|
|
5320
5492
|
if (!container) return;
|
|
5321
5493
|
container.scrollBy({
|
|
5322
|
-
left: direction === "left" ? -
|
|
5494
|
+
left: direction === "left" ? -168 : toolbarScrollOffset,
|
|
5323
5495
|
behavior: "smooth"
|
|
5324
5496
|
});
|
|
5325
5497
|
}
|
|
@@ -5360,7 +5532,7 @@ function MobileRibbon(props) {
|
|
|
5360
5532
|
dark:!univer-text-gray-200
|
|
5361
5533
|
`),
|
|
5362
5534
|
onClick: () => selectTab(index),
|
|
5363
|
-
children: [localeService.t(group.key), active && /* @__PURE__ */ 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 " })]
|
|
5535
|
+
children: [localeService.t(group.title || group.key), active && /* @__PURE__ */ 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 " })]
|
|
5364
5536
|
}, group.key);
|
|
5365
5537
|
})
|
|
5366
5538
|
}),
|
|
@@ -5781,8 +5953,8 @@ function MobileContextMenu() {
|
|
|
5781
5953
|
}
|
|
5782
5954
|
const sheetTitle = useMemo(() => {
|
|
5783
5955
|
switch (menuType) {
|
|
5784
|
-
case "contextMenu.rowHeader": return localeService.t("row");
|
|
5785
|
-
case "contextMenu.colHeader": return localeService.t("column");
|
|
5956
|
+
case "contextMenu.rowHeader": return localeService.t("ui.row");
|
|
5957
|
+
case "contextMenu.colHeader": return localeService.t("ui.column");
|
|
5786
5958
|
default: return "";
|
|
5787
5959
|
}
|
|
5788
5960
|
}, [localeService, menuType]);
|
|
@@ -5792,7 +5964,7 @@ function MobileContextMenu() {
|
|
|
5792
5964
|
className: "univer-fixed univer-inset-0 univer-z-[1080] univer-flex univer-items-end",
|
|
5793
5965
|
children: [/* @__PURE__ */ jsx("button", {
|
|
5794
5966
|
type: "button",
|
|
5795
|
-
"aria-label": localeService.t("rangeSelector.cancel"),
|
|
5967
|
+
"aria-label": localeService.t("ui.rangeSelector.cancel"),
|
|
5796
5968
|
className: "univer-absolute univer-inset-0 univer-bg-[rgba(15,23,42,0.32)] univer-backdrop-blur-[2px]",
|
|
5797
5969
|
onClick: handleClose
|
|
5798
5970
|
}), /* @__PURE__ */ jsxs("section", {
|
|
@@ -5813,7 +5985,7 @@ function MobileContextMenu() {
|
|
|
5813
5985
|
})
|
|
5814
5986
|
}), /* @__PURE__ */ jsx("button", {
|
|
5815
5987
|
type: "button",
|
|
5816
|
-
"aria-label": localeService.t("rangeSelector.cancel"),
|
|
5988
|
+
"aria-label": localeService.t("ui.rangeSelector.cancel"),
|
|
5817
5989
|
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 ",
|
|
5818
5990
|
style: { margin: 0 },
|
|
5819
5991
|
onClick: handleClose,
|
|
@@ -6039,13 +6211,40 @@ const INotificationService = createIdentifier("ui.notification.service");
|
|
|
6039
6211
|
//#endregion
|
|
6040
6212
|
//#region src/services/before-close/before-close.service.ts
|
|
6041
6213
|
const IBeforeCloseService = createIdentifier("univer.ui.before-close-service");
|
|
6042
|
-
let DesktopBeforeCloseService = class DesktopBeforeCloseService {
|
|
6214
|
+
let DesktopBeforeCloseService = class DesktopBeforeCloseService extends Disposable {
|
|
6043
6215
|
constructor(_notificationService) {
|
|
6216
|
+
super();
|
|
6044
6217
|
this._notificationService = _notificationService;
|
|
6045
6218
|
_defineProperty(this, "_beforeUnloadCallbacks", []);
|
|
6046
6219
|
_defineProperty(this, "_onCloseCallbacks", []);
|
|
6220
|
+
_defineProperty(this, "_beforeUnloadHandler", void 0);
|
|
6221
|
+
_defineProperty(this, "_unloadHandler", void 0);
|
|
6222
|
+
this._beforeUnloadHandler = (_event) => {
|
|
6223
|
+
let event = _event;
|
|
6224
|
+
const message = this._beforeUnloadCallbacks.map((callback) => callback()).filter((m) => !!m).join("\n");
|
|
6225
|
+
if (message) {
|
|
6226
|
+
this._notificationService.show({
|
|
6227
|
+
type: "error",
|
|
6228
|
+
title: "Some changes are not saved",
|
|
6229
|
+
content: message
|
|
6230
|
+
});
|
|
6231
|
+
if (typeof event === "undefined") event = window.event;
|
|
6232
|
+
event.returnValue = message;
|
|
6233
|
+
return message;
|
|
6234
|
+
}
|
|
6235
|
+
};
|
|
6236
|
+
this._unloadHandler = () => {
|
|
6237
|
+
this._onCloseCallbacks.forEach((callback) => callback());
|
|
6238
|
+
};
|
|
6047
6239
|
this._init();
|
|
6048
6240
|
}
|
|
6241
|
+
dispose() {
|
|
6242
|
+
window.removeEventListener("beforeunload", this._beforeUnloadHandler);
|
|
6243
|
+
window.removeEventListener("unload", this._unloadHandler);
|
|
6244
|
+
this._beforeUnloadCallbacks = [];
|
|
6245
|
+
this._onCloseCallbacks = [];
|
|
6246
|
+
super.dispose();
|
|
6247
|
+
}
|
|
6049
6248
|
registerBeforeClose(callback) {
|
|
6050
6249
|
this._beforeUnloadCallbacks.push(callback);
|
|
6051
6250
|
return { dispose: () => {
|
|
@@ -6059,23 +6258,8 @@ let DesktopBeforeCloseService = class DesktopBeforeCloseService {
|
|
|
6059
6258
|
} };
|
|
6060
6259
|
}
|
|
6061
6260
|
_init() {
|
|
6062
|
-
window.addEventListener("beforeunload",
|
|
6063
|
-
|
|
6064
|
-
const message = this._beforeUnloadCallbacks.map((callback) => callback()).filter((m) => !!m).join("\n");
|
|
6065
|
-
if (message) {
|
|
6066
|
-
this._notificationService.show({
|
|
6067
|
-
type: "error",
|
|
6068
|
-
title: "Some changes are not saved",
|
|
6069
|
-
content: message
|
|
6070
|
-
});
|
|
6071
|
-
if (typeof event === "undefined") event = window.event;
|
|
6072
|
-
event.returnValue = message;
|
|
6073
|
-
return message;
|
|
6074
|
-
}
|
|
6075
|
-
});
|
|
6076
|
-
window.addEventListener("unload", () => {
|
|
6077
|
-
this._onCloseCallbacks.forEach((callback) => callback());
|
|
6078
|
-
});
|
|
6261
|
+
window.addEventListener("beforeunload", this._beforeUnloadHandler);
|
|
6262
|
+
window.addEventListener("unload", this._unloadHandler);
|
|
6079
6263
|
}
|
|
6080
6264
|
};
|
|
6081
6265
|
DesktopBeforeCloseService = __decorate([__decorateParam(0, INotificationService)], DesktopBeforeCloseService);
|
|
@@ -6263,14 +6447,25 @@ let BrowserClipboardService = class BrowserClipboardService extends Disposable {
|
|
|
6263
6447
|
this._logService = _logService;
|
|
6264
6448
|
this._notificationService = _notificationService;
|
|
6265
6449
|
}
|
|
6266
|
-
async write(text, html) {
|
|
6267
|
-
if (!this.supportClipboard) return this._legacyCopyHtml(html);
|
|
6450
|
+
async write(text, html, customData) {
|
|
6451
|
+
if (!this.supportClipboard) return this._legacyCopyHtml(text, html);
|
|
6268
6452
|
try {
|
|
6269
6453
|
return await navigator.clipboard.write([new ClipboardItem({
|
|
6270
6454
|
[PLAIN_TEXT_CLIPBOARD_MIME_TYPE]: new Blob([text], { type: PLAIN_TEXT_CLIPBOARD_MIME_TYPE }),
|
|
6271
|
-
[HTML_CLIPBOARD_MIME_TYPE]: new Blob([html], { type: HTML_CLIPBOARD_MIME_TYPE })
|
|
6455
|
+
[HTML_CLIPBOARD_MIME_TYPE]: new Blob([html], { type: HTML_CLIPBOARD_MIME_TYPE }),
|
|
6456
|
+
...Object.fromEntries(Object.entries(customData !== null && customData !== void 0 ? customData : {}).map(([type, value]) => [type, new Blob([value], { type })]))
|
|
6272
6457
|
})]);
|
|
6273
6458
|
} catch (error) {
|
|
6459
|
+
if (customData && Object.keys(customData).length) try {
|
|
6460
|
+
return await navigator.clipboard.write([new ClipboardItem({
|
|
6461
|
+
[PLAIN_TEXT_CLIPBOARD_MIME_TYPE]: new Blob([text], { type: PLAIN_TEXT_CLIPBOARD_MIME_TYPE }),
|
|
6462
|
+
[HTML_CLIPBOARD_MIME_TYPE]: new Blob([html], { type: HTML_CLIPBOARD_MIME_TYPE })
|
|
6463
|
+
})]);
|
|
6464
|
+
} catch (fallbackError) {
|
|
6465
|
+
this._logService.error("[BrowserClipboardService]", fallbackError);
|
|
6466
|
+
this._showClipboardAuthenticationNotification();
|
|
6467
|
+
return;
|
|
6468
|
+
}
|
|
6274
6469
|
this._logService.error("[BrowserClipboardService]", error);
|
|
6275
6470
|
this._showClipboardAuthenticationNotification();
|
|
6276
6471
|
}
|
|
@@ -6304,17 +6499,34 @@ let BrowserClipboardService = class BrowserClipboardService extends Disposable {
|
|
|
6304
6499
|
return "";
|
|
6305
6500
|
}
|
|
6306
6501
|
}
|
|
6307
|
-
_legacyCopyHtml(html) {
|
|
6502
|
+
_legacyCopyHtml(text, html) {
|
|
6308
6503
|
const activeElement = document.activeElement;
|
|
6309
|
-
const
|
|
6310
|
-
|
|
6311
|
-
|
|
6504
|
+
const sanitizedHtml = serializeSanitizedHtmlForClipboard(html);
|
|
6505
|
+
let handledByClipboardEvent = false;
|
|
6506
|
+
const onCopy = (event) => {
|
|
6507
|
+
if (!event.clipboardData) return;
|
|
6508
|
+
event.preventDefault();
|
|
6509
|
+
event.clipboardData.setData(PLAIN_TEXT_CLIPBOARD_MIME_TYPE, text);
|
|
6510
|
+
event.clipboardData.setData(HTML_CLIPBOARD_MIME_TYPE, sanitizedHtml);
|
|
6511
|
+
handledByClipboardEvent = true;
|
|
6512
|
+
};
|
|
6513
|
+
document.addEventListener("copy", onCopy);
|
|
6312
6514
|
try {
|
|
6313
|
-
select(container);
|
|
6314
6515
|
document.execCommand("copy");
|
|
6516
|
+
if (!handledByClipboardEvent) {
|
|
6517
|
+
const container = createCopyHtmlContainer();
|
|
6518
|
+
document.body.appendChild(container);
|
|
6519
|
+
container.innerHTML = sanitizedHtml;
|
|
6520
|
+
try {
|
|
6521
|
+
select(container);
|
|
6522
|
+
document.execCommand("copy");
|
|
6523
|
+
} finally {
|
|
6524
|
+
document.body.removeChild(container);
|
|
6525
|
+
}
|
|
6526
|
+
}
|
|
6315
6527
|
} finally {
|
|
6528
|
+
document.removeEventListener("copy", onCopy);
|
|
6316
6529
|
if (activeElement instanceof HTMLElement) activeElement.focus();
|
|
6317
|
-
document.body.removeChild(container);
|
|
6318
6530
|
}
|
|
6319
6531
|
}
|
|
6320
6532
|
_legacyCopyText(text) {
|
|
@@ -6334,8 +6546,8 @@ let BrowserClipboardService = class BrowserClipboardService extends Disposable {
|
|
|
6334
6546
|
var _this$_notificationSe;
|
|
6335
6547
|
(_this$_notificationSe = this._notificationService) === null || _this$_notificationSe === void 0 || _this$_notificationSe.show({
|
|
6336
6548
|
type: "warning",
|
|
6337
|
-
title: this._localeService.t("clipboard.authentication.title"),
|
|
6338
|
-
content: this._localeService.t("clipboard.authentication.content")
|
|
6549
|
+
title: this._localeService.t("ui.clipboard.authentication.title"),
|
|
6550
|
+
content: this._localeService.t("ui.clipboard.authentication.content")
|
|
6339
6551
|
});
|
|
6340
6552
|
}
|
|
6341
6553
|
};
|
|
@@ -6372,6 +6584,11 @@ function sanitizeHtmlForClipboard(html) {
|
|
|
6372
6584
|
});
|
|
6373
6585
|
return fragment;
|
|
6374
6586
|
}
|
|
6587
|
+
function serializeSanitizedHtmlForClipboard(html) {
|
|
6588
|
+
const container = document.createElement("div");
|
|
6589
|
+
container.appendChild(sanitizeHtmlForClipboard(html));
|
|
6590
|
+
return container.innerHTML;
|
|
6591
|
+
}
|
|
6375
6592
|
function sanitizeHtmlNode(node) {
|
|
6376
6593
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
6377
6594
|
var _node$textContent;
|
|
@@ -7911,4 +8128,4 @@ const PrintFloatDomSingle = memo((props) => {
|
|
|
7911
8128
|
});
|
|
7912
8129
|
|
|
7913
8130
|
//#endregion
|
|
7914
|
-
export { AnchoredContextMenu, BrowserClipboardService, BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, CanvasFloatDomService, CanvasPopup, CanvasPopupService, CommonLabel, ComponentContainer, ComponentManager, DesktopContextMenu as ContextMenu, ContextMenuGroup, ContextMenuHostService, ContextMenuPanel, ContextMenuPosition, ContextMenuService, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DISABLE_AUTO_FOCUS_KEY, DesktopBeforeCloseService, DesktopConfirmService, DesktopDialogService, DesktopGalleryService, DesktopLayoutService, DesktopLocalFileService, DesktopLocalStorageService, DesktopMessageService, DesktopNotificationService, DesktopRibbonService, DesktopSidebarService, DesktopUIController, DesktopZenZoneService, ErrorController, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE_SVG_XML_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FloatDom, FloatDomSingle, FontFamily, FontFamilyItem, FontSize, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, HeadingItem, IBeforeCloseService, ICanvasPopupService, IClipboardInterfaceService, IContextMenuHostService, IContextMenuService, IDialogService, IFontService, IGalleryService, ILayoutService, ILeftSidebarService, ILocalFileService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonService, IShortcutService, ISidebarService, IUIController, IUIPartsService, IZenZoneService, KeyCode, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileContextMenu, MockMessageService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, ThemeSwitcherService, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoShortcutItem, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, ZIndexManager, ZenZone, connectDependencies, connectInjector, getHeaderFooterMenuHiddenObservable, getMenuHiddenObservable, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, imageMimeTypeSet, mergeMenuConfigs, parseHtmlDocument, parseHtmlFragment, sanitizeParsedHtml, splitSpanText, supportClipboardAPI,
|
|
8131
|
+
export { AnchoredContextMenu, BrowserClipboardService, BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, CanvasFloatDomService, CanvasPopup, CanvasPopupService, CommonLabel, ComponentContainer, ComponentManager, DesktopContextMenu as ContextMenu, ContextMenuGroup, ContextMenuHostService, ContextMenuPanel, ContextMenuPosition, ContextMenuService, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DISABLE_AUTO_FOCUS_KEY, DesktopBeforeCloseService, DesktopConfirmService, DesktopDialogService, DesktopGalleryService, DesktopLayoutService, DesktopLocalFileService, DesktopLocalStorageService, DesktopMessageService, DesktopNotificationService, DesktopRibbonService, DesktopSidebarService, DesktopUIController, DesktopZenZoneService, ErrorController, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE_SVG_XML_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FloatDom, FloatDomSingle, FontFamily, FontFamilyItem, FontSize, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, HeadingItem, IBeforeCloseService, ICanvasPopupService, IClipboardInterfaceService, IContextMenuHostService, IContextMenuService, IDialogService, IFontService, IGalleryService, ILayoutService, ILeftSidebarService, ILocalFileService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonService, IShortcutService, ISidebarService, IUIController, IUIPartsService, IZenZoneService, KeyCode, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileContextMenu, MockMessageService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, ThemeSwitcherService, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoShortcutItem, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, ZIndexManager, ZenZone, connectDependencies, connectInjector, getHeaderFooterMenuHiddenObservable, getMenuHiddenObservable, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, imageMimeTypeSet, mergeMenuConfigs, parseHtmlDocument, parseHtmlFragment, sanitizeParsedHtml, splitSpanText, supportClipboardAPI, textTrim, useClickOutSide, useComponentsOfPart, useConfigValue, useDebounceFn, useDependency, useEvent, useInjector, useObservable, useObservableRef, useScrollYOverContainer, useSidebarClick, useToolbarItemStatus, useUpdateBinder, useUpdateEffect, useVirtualList };
|