@univerjs/ui 1.0.0-alpha.7 → 1.0.0-beta.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 +9 -41
- package/lib/cjs/index.js +744 -525
- package/lib/es/facade.js +11 -43
- package/lib/es/index.js +747 -531
- package/lib/facade.js +11 -43
- package/lib/index.css +49 -8
- package/lib/index.js +747 -531
- package/lib/types/facade/f-univer.d.ts +0 -8
- package/lib/types/facade/index.d.ts +0 -2
- package/lib/types/index.d.ts +3 -2
- package/lib/types/services/dom/canvas-dom-layer.service.d.ts +3 -0
- package/lib/types/services/parts/parts.service.d.ts +3 -0
- package/lib/types/services/shortcut/shortcut.service.d.ts +17 -0
- package/lib/types/services/workbench/workbench.service.d.ts +30 -0
- package/lib/types/views/components/context-menu/ContextMenuPanel.d.ts +2 -1
- package/lib/types/views/components/workbench-skeleton/WorkbenchSkeleton.d.ts +22 -0
- package/lib/types/views/emoji-picker/emoji-picker-utils.d.ts +1 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +17 -14
- package/package.json +8 -8
- package/lib/types/facade/f-hooks.d.ts +0 -63
package/lib/cjs/index.js
CHANGED
|
@@ -29,19 +29,17 @@ let _univerjs_icons = require("@univerjs/icons");
|
|
|
29
29
|
const EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
|
|
30
30
|
const EMBED_CHILD_UNIT_ID_ATTRIBUTE = "data-embed-child-unit-id";
|
|
31
31
|
function getEmbedBoundaryOwner(target) {
|
|
32
|
-
var _ref, _getAttributeValue;
|
|
33
32
|
if (!hasClosest(target)) return;
|
|
34
33
|
const ownerElement = target.closest(`[${EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE}]`);
|
|
35
|
-
return
|
|
34
|
+
return getAttributeValue(target, "data-embed-interaction-boundary-owner") ?? getAttributeValue(ownerElement, "data-embed-interaction-boundary-owner") ?? void 0;
|
|
36
35
|
}
|
|
37
36
|
function isEmbedBoundaryTarget(target) {
|
|
38
37
|
return hasClosest(target) && target.closest(`[${"data-embed-interaction-boundary-owner"}]`) != null;
|
|
39
38
|
}
|
|
40
39
|
function getEmbedChildUnitId(target) {
|
|
41
|
-
var _ref2, _getAttributeValue2;
|
|
42
40
|
if (!hasClosest(target)) return;
|
|
43
41
|
const childRuntime = target.closest(`[${EMBED_CHILD_UNIT_ID_ATTRIBUTE}]`);
|
|
44
|
-
return
|
|
42
|
+
return getAttributeValue(target, "data-embed-child-unit-id") ?? getAttributeValue(childRuntime, "data-embed-child-unit-id") ?? void 0;
|
|
45
43
|
}
|
|
46
44
|
function keepInteractionInsideSameEmbedBoundary(event) {
|
|
47
45
|
const owner = getEmbedBoundaryOwner(event.currentTarget);
|
|
@@ -52,13 +50,12 @@ function hasClosest(target) {
|
|
|
52
50
|
return !!target && typeof target.closest === "function";
|
|
53
51
|
}
|
|
54
52
|
function getAttributeValue(target, name) {
|
|
55
|
-
var _getAttribute$call;
|
|
56
53
|
const getAttribute = target === null || target === void 0 ? void 0 : target.getAttribute;
|
|
57
|
-
return typeof getAttribute === "function" ?
|
|
54
|
+
return typeof getAttribute === "function" ? getAttribute.call(target, name) ?? void 0 : void 0;
|
|
58
55
|
}
|
|
59
56
|
|
|
60
57
|
//#endregion
|
|
61
|
-
//#region \0@oxc-project+runtime@0.
|
|
58
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
62
59
|
function _typeof(o) {
|
|
63
60
|
"@babel/helpers - typeof";
|
|
64
61
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -69,7 +66,7 @@ function _typeof(o) {
|
|
|
69
66
|
}
|
|
70
67
|
|
|
71
68
|
//#endregion
|
|
72
|
-
//#region \0@oxc-project+runtime@0.
|
|
69
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
73
70
|
function toPrimitive(t, r) {
|
|
74
71
|
if ("object" != _typeof(t) || !t) return t;
|
|
75
72
|
var e = t[Symbol.toPrimitive];
|
|
@@ -82,14 +79,14 @@ function toPrimitive(t, r) {
|
|
|
82
79
|
}
|
|
83
80
|
|
|
84
81
|
//#endregion
|
|
85
|
-
//#region \0@oxc-project+runtime@0.
|
|
82
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
86
83
|
function toPropertyKey(t) {
|
|
87
84
|
var i = toPrimitive(t, "string");
|
|
88
85
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
89
86
|
}
|
|
90
87
|
|
|
91
88
|
//#endregion
|
|
92
|
-
//#region \0@oxc-project+runtime@0.
|
|
89
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
93
90
|
function _defineProperty(e, r, t) {
|
|
94
91
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
95
92
|
value: t,
|
|
@@ -100,7 +97,7 @@ function _defineProperty(e, r, t) {
|
|
|
100
97
|
}
|
|
101
98
|
|
|
102
99
|
//#endregion
|
|
103
|
-
//#region \0@oxc-project+runtime@0.
|
|
100
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
104
101
|
function __decorateParam(paramIndex, decorator) {
|
|
105
102
|
return function(target, key) {
|
|
106
103
|
decorator(target, key, paramIndex);
|
|
@@ -108,7 +105,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
108
105
|
}
|
|
109
106
|
|
|
110
107
|
//#endregion
|
|
111
|
-
//#region \0@oxc-project+runtime@0.
|
|
108
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
112
109
|
function __decorate(decorators, target, key, desc) {
|
|
113
110
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
114
111
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -860,6 +857,15 @@ var UIRuntimeScopeService = class extends _univerjs_core.Disposable {
|
|
|
860
857
|
//#endregion
|
|
861
858
|
//#region src/services/shortcut/shortcut.service.ts
|
|
862
859
|
/**
|
|
860
|
+
* Defines whether a Univer shortcut should yield to the browser's native behavior
|
|
861
|
+
* when the keyboard event originates from an editable text element.
|
|
862
|
+
*/
|
|
863
|
+
let NativeTextEditorShortcutBehavior = /* @__PURE__ */ function(NativeTextEditorShortcutBehavior) {
|
|
864
|
+
NativeTextEditorShortcutBehavior[NativeTextEditorShortcutBehavior["ALLOW_NATIVE"] = 0] = "ALLOW_NATIVE";
|
|
865
|
+
NativeTextEditorShortcutBehavior[NativeTextEditorShortcutBehavior["OVERRIDE_NATIVE"] = 1] = "OVERRIDE_NATIVE";
|
|
866
|
+
return NativeTextEditorShortcutBehavior;
|
|
867
|
+
}({});
|
|
868
|
+
/**
|
|
863
869
|
* The dependency injection identifier of the {@link IShortcutService}.
|
|
864
870
|
*/
|
|
865
871
|
const IShortcutService = (0, _univerjs_core.createIdentifier)("ui.shortcut.service");
|
|
@@ -912,14 +918,13 @@ let ShortcutService = class ShortcutService extends _univerjs_core.Disposable {
|
|
|
912
918
|
return null;
|
|
913
919
|
}
|
|
914
920
|
getShortcutDisplay(shortcut) {
|
|
915
|
-
var _KeyCodeToChar;
|
|
916
921
|
const binding = this._getBindingFromItem(shortcut);
|
|
917
922
|
if (!binding) return null;
|
|
918
923
|
const ctrlKey = binding & 4096;
|
|
919
924
|
const shiftKey = binding & 1024;
|
|
920
925
|
const altKey = binding & 2048;
|
|
921
926
|
const macCtrl = binding & 8192;
|
|
922
|
-
const body =
|
|
927
|
+
const body = KeyCodeToChar[binding & 255] ?? "<->";
|
|
923
928
|
if (this._platformService.isMac) return `${ctrlKey ? "⌘+" : ""}${shiftKey ? "⇧+" : ""}${altKey ? "⌥+" : ""}${macCtrl ? "⌃+" : ""}${body}`;
|
|
924
929
|
return `${ctrlKey ? "Ctrl+" : ""}${shiftKey ? "Shift+" : ""}${altKey ? "Alt+" : ""}${body}`;
|
|
925
930
|
}
|
|
@@ -939,28 +944,25 @@ let ShortcutService = class ShortcutService extends _univerjs_core.Disposable {
|
|
|
939
944
|
_resolveKeyboardEvent(e) {
|
|
940
945
|
const candidate = this.dispatch(e);
|
|
941
946
|
if (candidate) {
|
|
942
|
-
var _this$_getRuntimeServ
|
|
943
|
-
(_this$_getRuntimeServ =
|
|
947
|
+
var _this$_getRuntimeServ;
|
|
948
|
+
((_this$_getRuntimeServ = this._getRuntimeService(e, _univerjs_core.ICommandService)) === null || _this$_getRuntimeServ === void 0 ? void 0 : _this$_getRuntimeServ.executeCommand(candidate.id, candidate.staticParameters)) ?? this._commandService.executeCommand(candidate.id, candidate.staticParameters);
|
|
944
949
|
e.preventDefault();
|
|
945
950
|
}
|
|
946
951
|
}
|
|
947
952
|
dispatch(e) {
|
|
948
|
-
var _this$_getRuntimeServ3;
|
|
949
953
|
if (this._forceEscaped || this._forceDisabled) return;
|
|
950
954
|
if (this._layoutService && !this._layoutService.checkElementInCurrentContainers(e.target)) return;
|
|
951
955
|
const binding = this._deriveBindingFromEvent(e);
|
|
952
956
|
if (binding === null) return;
|
|
953
|
-
if (this._shouldLetEmbedTextEditorHandleNativeShortcut(e, binding)) return;
|
|
954
957
|
const shortcuts = this._shortCutMapping.get(binding);
|
|
955
958
|
if (shortcuts === void 0) return;
|
|
956
|
-
const contextService =
|
|
957
|
-
|
|
958
|
-
var
|
|
959
|
-
return ((
|
|
960
|
-
}).find((s) => {
|
|
961
|
-
var _s$preconditions, _s$preconditions2;
|
|
962
|
-
return (_s$preconditions = (_s$preconditions2 = s.preconditions) === null || _s$preconditions2 === void 0 ? void 0 : _s$preconditions2.call(s, contextService)) !== null && _s$preconditions !== void 0 ? _s$preconditions : true;
|
|
959
|
+
const contextService = this._getRuntimeService(e, _univerjs_core.IContextService) ?? this._contextService;
|
|
960
|
+
const candidateShortcut = Array.from(shortcuts).sort((s1, s2) => (s2.priority ?? 0) - (s1.priority ?? 0)).find((s) => {
|
|
961
|
+
var _s$eventPreconditions, _s$preconditions;
|
|
962
|
+
return (((_s$eventPreconditions = s.eventPreconditions) === null || _s$eventPreconditions === void 0 ? void 0 : _s$eventPreconditions.call(s, e)) ?? true) && (((_s$preconditions = s.preconditions) === null || _s$preconditions === void 0 ? void 0 : _s$preconditions.call(s, contextService)) ?? true);
|
|
963
963
|
});
|
|
964
|
+
if (this._shouldLetEmbedTextEditorHandleNativeShortcut(e, binding) && (candidateShortcut === null || candidateShortcut === void 0 ? void 0 : candidateShortcut.nativeTextEditorBehavior) !== 1) return;
|
|
965
|
+
return candidateShortcut;
|
|
964
966
|
}
|
|
965
967
|
_getBindingFromItem(item) {
|
|
966
968
|
if (this._platformService.isMac && item.mac) return item.mac;
|
|
@@ -1299,7 +1301,7 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
|
|
|
1299
1301
|
* @param target default is root menu
|
|
1300
1302
|
*/
|
|
1301
1303
|
mergeMenu(source, target) {
|
|
1302
|
-
const _target = target
|
|
1304
|
+
const _target = target ?? this._menu;
|
|
1303
1305
|
for (const [key, value] of Object.entries(_target)) if (key in source) {
|
|
1304
1306
|
const targetRecord = _target;
|
|
1305
1307
|
const sourceRecord = source;
|
|
@@ -1366,7 +1368,6 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
|
|
|
1366
1368
|
* @returns Menu schema array or empty array if not found
|
|
1367
1369
|
*/
|
|
1368
1370
|
getMenuByPositionKey(key) {
|
|
1369
|
-
var _findKey;
|
|
1370
1371
|
const findKey = (obj) => {
|
|
1371
1372
|
if (key in obj) return this._buildMenuSchema(obj[key]);
|
|
1372
1373
|
for (const k in obj) {
|
|
@@ -1377,7 +1378,7 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
|
|
|
1377
1378
|
}
|
|
1378
1379
|
}
|
|
1379
1380
|
};
|
|
1380
|
-
return
|
|
1381
|
+
return findKey(this._menu) ?? [];
|
|
1381
1382
|
}
|
|
1382
1383
|
/**
|
|
1383
1384
|
* Get flat menu schema by position key
|
|
@@ -1401,7 +1402,7 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
|
|
|
1401
1402
|
};
|
|
1402
1403
|
MenuManagerService = _MenuManagerService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, _univerjs_core.IConfigService)], MenuManagerService);
|
|
1403
1404
|
function normalizeMenuOrder(order) {
|
|
1404
|
-
return order
|
|
1405
|
+
return order ?? 0;
|
|
1405
1406
|
}
|
|
1406
1407
|
function isMenuSchemaRecord(value) {
|
|
1407
1408
|
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -1599,8 +1600,7 @@ let DesktopRibbonService = class DesktopRibbonService extends _univerjs_core.Dis
|
|
|
1599
1600
|
const activatedTab = this._activatedTab$.getValue();
|
|
1600
1601
|
const activeGroup = ribbon.find((group) => group.key === activatedTab);
|
|
1601
1602
|
if (!activeGroup && this._contextualTabs.has(activatedTab)) {
|
|
1602
|
-
|
|
1603
|
-
const fallbackTab = (_ref = (_ribbon$find = ribbon.find((group) => group.key === this._lastNonContextualActivatedTab && !group.contextual)) !== null && _ribbon$find !== void 0 ? _ribbon$find : ribbon.find((group) => group.key === "ribbon.start")) !== null && _ref !== void 0 ? _ref : ribbon[0];
|
|
1603
|
+
const fallbackTab = ribbon.find((group) => group.key === this._lastNonContextualActivatedTab && !group.contextual) ?? ribbon.find((group) => group.key === "ribbon.start") ?? ribbon[0];
|
|
1604
1604
|
if (fallbackTab) this._activatedTab$.next(fallbackTab.key);
|
|
1605
1605
|
} else if (!activeGroup && ribbon.some((group) => group.key === "ribbon.start")) {
|
|
1606
1606
|
const fallbackTab = ribbon.find((group) => group.key === "ribbon.start");
|
|
@@ -1650,12 +1650,10 @@ function useObservableRef(observable, defaultValue) {
|
|
|
1650
1650
|
const FEATURE_SEARCH_COMPONENT = "FeatureSearch";
|
|
1651
1651
|
const FEATURE_SEARCH_DIALOG_ID = "FEATURE_SEARCH_DIALOG";
|
|
1652
1652
|
function resolveParams(item, value) {
|
|
1653
|
-
|
|
1654
|
-
return params !== null && params !== void 0 ? params : value === void 0 ? void 0 : { value };
|
|
1653
|
+
return (typeof item.params === "function" ? item.params() : item.params) ?? (value === void 0 ? void 0 : { value });
|
|
1655
1654
|
}
|
|
1656
1655
|
function resolveOptionParams(option) {
|
|
1657
|
-
|
|
1658
|
-
return params !== null && params !== void 0 ? params : option.value === void 0 ? void 0 : { value: option.value };
|
|
1656
|
+
return (typeof option.params === "function" ? option.params(option.value) : option.params) ?? (option.value === void 0 ? void 0 : { value: option.value });
|
|
1659
1657
|
}
|
|
1660
1658
|
function deduplicate(items) {
|
|
1661
1659
|
return items.filter((item, index) => items.findIndex((candidate) => candidate.commandId === item.commandId && _univerjs_core.Tools.diffValue(candidate.params, item.params)) === index);
|
|
@@ -1669,14 +1667,12 @@ function FeatureSearch() {
|
|
|
1669
1667
|
const ribbonService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonService);
|
|
1670
1668
|
const items = (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => {
|
|
1671
1669
|
function getItemTitle(item) {
|
|
1672
|
-
|
|
1673
|
-
const titleKey = (_ref = (_item$title = item.title) !== null && _item$title !== void 0 ? _item$title : item.tooltip) !== null && _ref !== void 0 ? _ref : item.description;
|
|
1670
|
+
const titleKey = item.title ?? item.tooltip ?? item.description;
|
|
1674
1671
|
return titleKey ? localeService.t(titleKey) : "";
|
|
1675
1672
|
}
|
|
1676
1673
|
function collectCandidates(schemas, path, keyPath, ancestors = [], parentTitle) {
|
|
1677
1674
|
return schemas.flatMap((schema, index) => {
|
|
1678
|
-
|
|
1679
|
-
const schemaTitle = localeService.t((_schema$title = schema.title) !== null && _schema$title !== void 0 ? _schema$title : "");
|
|
1675
|
+
const schemaTitle = localeService.t(schema.title ?? "");
|
|
1680
1676
|
const schemaPath = schemaTitle ? [...path, schemaTitle] : path;
|
|
1681
1677
|
const schemaKeyPath = [...keyPath, `${schema.key}:${index}`];
|
|
1682
1678
|
const result = [];
|
|
@@ -1699,48 +1695,44 @@ function FeatureSearch() {
|
|
|
1699
1695
|
});
|
|
1700
1696
|
}
|
|
1701
1697
|
function observeCandidate(candidate) {
|
|
1702
|
-
var _item$hidden
|
|
1698
|
+
var _item$hidden$, _item$disabled$, _item$value$;
|
|
1703
1699
|
const { item } = candidate;
|
|
1704
1700
|
const hasOptions = item.type === 1 || item.type === 2;
|
|
1705
1701
|
const selections = hasOptions ? item.selections : void 0;
|
|
1706
|
-
const selections$ = (0, rxjs.isObservable)(selections) ? selections.pipe((0, rxjs_operators.startWith)([])) : (0, rxjs.of)(selections
|
|
1702
|
+
const selections$ = (0, rxjs.isObservable)(selections) ? selections.pipe((0, rxjs_operators.startWith)([])) : (0, rxjs.of)(selections ?? []);
|
|
1707
1703
|
return (0, rxjs.combineLatest)([
|
|
1708
1704
|
candidate.ancestors.length ? (0, rxjs.combineLatest)(candidate.ancestors.map((ancestor) => {
|
|
1709
|
-
var _ancestor$hidden
|
|
1710
|
-
return (
|
|
1705
|
+
var _ancestor$hidden$;
|
|
1706
|
+
return ((_ancestor$hidden$ = ancestor.hidden$) === null || _ancestor$hidden$ === void 0 ? void 0 : _ancestor$hidden$.pipe((0, rxjs_operators.startWith)(true))) ?? (0, rxjs.of)(false);
|
|
1711
1707
|
})).pipe((0, rxjs_operators.map)((states) => states.some(Boolean))) : (0, rxjs.of)(false),
|
|
1712
1708
|
candidate.ancestors.length ? (0, rxjs.combineLatest)(candidate.ancestors.map((ancestor) => {
|
|
1713
|
-
var _ancestor$disabled
|
|
1714
|
-
return (
|
|
1709
|
+
var _ancestor$disabled$;
|
|
1710
|
+
return ((_ancestor$disabled$ = ancestor.disabled$) === null || _ancestor$disabled$ === void 0 ? void 0 : _ancestor$disabled$.pipe((0, rxjs_operators.startWith)(true))) ?? (0, rxjs.of)(false);
|
|
1715
1711
|
})).pipe((0, rxjs_operators.map)((states) => states.some(Boolean))) : (0, rxjs.of)(false),
|
|
1716
|
-
(
|
|
1717
|
-
(
|
|
1718
|
-
(
|
|
1712
|
+
((_item$hidden$ = item.hidden$) === null || _item$hidden$ === void 0 ? void 0 : _item$hidden$.pipe((0, rxjs_operators.startWith)(true))) ?? (0, rxjs.of)(false),
|
|
1713
|
+
((_item$disabled$ = item.disabled$) === null || _item$disabled$ === void 0 ? void 0 : _item$disabled$.pipe((0, rxjs_operators.startWith)(true))) ?? (0, rxjs.of)(false),
|
|
1714
|
+
((_item$value$ = item.value$) === null || _item$value$ === void 0 ? void 0 : _item$value$.pipe((0, rxjs_operators.startWith)(void 0))) ?? (0, rxjs.of)(void 0),
|
|
1719
1715
|
selections$
|
|
1720
1716
|
]).pipe((0, rxjs_operators.map)(([ancestorHidden, ancestorDisabled, hidden, disabled, value, options]) => {
|
|
1721
1717
|
if (ancestorHidden || ancestorDisabled || hidden || disabled) return [];
|
|
1722
1718
|
const title = getItemTitle(item);
|
|
1723
1719
|
const path = candidate.path.join(" / ");
|
|
1724
1720
|
const result = [];
|
|
1725
|
-
if (title && item.type !== 1 && item.type !== 3) {
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
getParams: () => resolveParams(item, value)
|
|
1736
|
-
});
|
|
1737
|
-
}
|
|
1721
|
+
if (title && item.type !== 1 && item.type !== 3) result.push({
|
|
1722
|
+
key: candidate.key,
|
|
1723
|
+
title,
|
|
1724
|
+
parentTitle: candidate.parentTitle,
|
|
1725
|
+
description: localeService.t(item.description ?? ""),
|
|
1726
|
+
path,
|
|
1727
|
+
commandId: item.commandId ?? item.id,
|
|
1728
|
+
params: resolveParams(item, value),
|
|
1729
|
+
getParams: () => resolveParams(item, value)
|
|
1730
|
+
});
|
|
1738
1731
|
if (hasOptions) options.forEach((option, index) => {
|
|
1739
|
-
var _ref2, _ref3, _ref4, _option$commandId, _ref5, _ref6, _option$id;
|
|
1740
1732
|
if (option.disabled || typeof option.label !== "string") return;
|
|
1741
|
-
const commandId =
|
|
1733
|
+
const commandId = option.commandId ?? option.id ?? item.selectionsCommandId ?? item.commandId ?? item.id;
|
|
1742
1734
|
result.push({
|
|
1743
|
-
key: `${candidate.key}:option:${
|
|
1735
|
+
key: `${candidate.key}:option:${option.id ?? option.commandId ?? option.value ?? index}`,
|
|
1744
1736
|
title: localeService.t(option.label),
|
|
1745
1737
|
parentTitle: title,
|
|
1746
1738
|
description: "",
|
|
@@ -1773,35 +1765,32 @@ function FeatureSearch() {
|
|
|
1773
1765
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.CommandInput, {
|
|
1774
1766
|
autoFocus: true,
|
|
1775
1767
|
placeholder: localeService.t("ui.featureSearch.placeholder")
|
|
1776
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.CommandList, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.CommandEmpty, { children: localeService.t("ui.featureSearch.empty") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.CommandGroup, { children: items.map((item) => {
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1788
|
-
className: "univer-
|
|
1789
|
-
children:
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
className: "univer-truncate",
|
|
1797
|
-
children: item.title
|
|
1798
|
-
})]
|
|
1799
|
-
}), item.path && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1800
|
-
className: "univer-max-w-1/2 univer-truncate univer-text-xs univer-text-gray-400",
|
|
1801
|
-
children: item.path
|
|
1768
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.CommandList, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.CommandEmpty, { children: localeService.t("ui.featureSearch.empty") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.CommandGroup, { children: items.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.CommandItem, {
|
|
1769
|
+
value: item.key,
|
|
1770
|
+
keywords: [
|
|
1771
|
+
item.parentTitle ?? "",
|
|
1772
|
+
item.title,
|
|
1773
|
+
item.description,
|
|
1774
|
+
item.path
|
|
1775
|
+
],
|
|
1776
|
+
onSelect: () => execute(item),
|
|
1777
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1778
|
+
className: "univer-flex univer-min-w-0 univer-flex-1 univer-items-center univer-gap-1",
|
|
1779
|
+
children: [item.parentTitle && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1780
|
+
className: "univer-shrink-0",
|
|
1781
|
+
children: item.parentTitle
|
|
1782
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1783
|
+
className: "univer-text-gray-400",
|
|
1784
|
+
children: "/"
|
|
1785
|
+
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1786
|
+
className: "univer-truncate",
|
|
1787
|
+
children: item.title
|
|
1802
1788
|
})]
|
|
1803
|
-
}, item.
|
|
1804
|
-
|
|
1789
|
+
}), item.path && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1790
|
+
className: "univer-max-w-1/2 univer-truncate univer-text-xs univer-text-gray-400",
|
|
1791
|
+
children: item.path
|
|
1792
|
+
})]
|
|
1793
|
+
}, item.key)) })] })]
|
|
1805
1794
|
});
|
|
1806
1795
|
}
|
|
1807
1796
|
|
|
@@ -1939,6 +1928,7 @@ var UIPartsService = class extends _univerjs_core.Disposable {
|
|
|
1939
1928
|
constructor(..._args) {
|
|
1940
1929
|
super(..._args);
|
|
1941
1930
|
_defineProperty(this, "_componentsByPart", /* @__PURE__ */ new Map());
|
|
1931
|
+
_defineProperty(this, "_disabledUIParts", /* @__PURE__ */ new Map());
|
|
1942
1932
|
_defineProperty(this, "_componentRegistered$", new rxjs.Subject());
|
|
1943
1933
|
_defineProperty(this, "componentRegistered$", this._componentRegistered$.asObservable());
|
|
1944
1934
|
_defineProperty(this, "_uiVisible", /* @__PURE__ */ new Map());
|
|
@@ -1948,20 +1938,54 @@ var UIPartsService = class extends _univerjs_core.Disposable {
|
|
|
1948
1938
|
dispose() {
|
|
1949
1939
|
super.dispose();
|
|
1950
1940
|
this._componentsByPart.clear();
|
|
1941
|
+
this._disabledUIParts.clear();
|
|
1951
1942
|
this._uiVisible.clear();
|
|
1952
1943
|
this._componentRegistered$.complete();
|
|
1953
1944
|
this._uiVisibleChange$.complete();
|
|
1954
1945
|
}
|
|
1955
1946
|
setUIVisible(part, visible) {
|
|
1947
|
+
const wasVisible = this.isUIVisible(part);
|
|
1956
1948
|
this._uiVisible.set(part, visible);
|
|
1957
|
-
this.
|
|
1949
|
+
const isVisible = this.isUIVisible(part);
|
|
1950
|
+
if (wasVisible !== isVisible) this._uiVisibleChange$.next({
|
|
1958
1951
|
ui: part,
|
|
1959
|
-
visible
|
|
1952
|
+
visible: isVisible
|
|
1960
1953
|
});
|
|
1961
1954
|
}
|
|
1962
1955
|
isUIVisible(part) {
|
|
1963
|
-
var _this$
|
|
1964
|
-
return (
|
|
1956
|
+
var _this$_disabledUIPart;
|
|
1957
|
+
return (this._uiVisible.get(part) ?? true) && !((_this$_disabledUIPart = this._disabledUIParts.get(part)) === null || _this$_disabledUIPart === void 0 ? void 0 : _this$_disabledUIPart.size);
|
|
1958
|
+
}
|
|
1959
|
+
registerDisabledUIParts(parts, disabled$) {
|
|
1960
|
+
const uniqueParts = [...new Set(parts)];
|
|
1961
|
+
const registration = Symbol("disabled-ui-parts");
|
|
1962
|
+
let disabled = false;
|
|
1963
|
+
const update = (nextDisabled) => {
|
|
1964
|
+
if (disabled === nextDisabled) return;
|
|
1965
|
+
disabled = nextDisabled;
|
|
1966
|
+
uniqueParts.forEach((part) => {
|
|
1967
|
+
const wasVisible = this.isUIVisible(part);
|
|
1968
|
+
const registrations = this._disabledUIParts.get(part) ?? /* @__PURE__ */ new Set();
|
|
1969
|
+
if (disabled) {
|
|
1970
|
+
registrations.add(registration);
|
|
1971
|
+
this._disabledUIParts.set(part, registrations);
|
|
1972
|
+
} else {
|
|
1973
|
+
registrations.delete(registration);
|
|
1974
|
+
if (registrations.size === 0) this._disabledUIParts.delete(part);
|
|
1975
|
+
}
|
|
1976
|
+
const isVisible = this.isUIVisible(part);
|
|
1977
|
+
if (wasVisible !== isVisible) this._uiVisibleChange$.next({
|
|
1978
|
+
ui: part,
|
|
1979
|
+
visible: isVisible
|
|
1980
|
+
});
|
|
1981
|
+
});
|
|
1982
|
+
};
|
|
1983
|
+
const subscription = disabled$.subscribe(update);
|
|
1984
|
+
const disposable = (0, _univerjs_core.toDisposable)(() => {
|
|
1985
|
+
subscription.unsubscribe();
|
|
1986
|
+
update(false);
|
|
1987
|
+
});
|
|
1988
|
+
return this.disposeWithMe(disposable);
|
|
1965
1989
|
}
|
|
1966
1990
|
registerComponent(part, componentFactory) {
|
|
1967
1991
|
const componentType = componentFactory();
|
|
@@ -1990,6 +2014,7 @@ var CanvasFloatDomService = class extends _univerjs_core.Disposable {
|
|
|
1990
2014
|
constructor(..._args) {
|
|
1991
2015
|
super(..._args);
|
|
1992
2016
|
_defineProperty(this, "_domLayerMap", /* @__PURE__ */ new Map());
|
|
2017
|
+
_defineProperty(this, "_scopedRenderRootCount", /* @__PURE__ */ new Map());
|
|
1993
2018
|
_defineProperty(this, "_domLayers$", new rxjs.BehaviorSubject([]));
|
|
1994
2019
|
_defineProperty(this, "domLayers$", this._domLayers$.asObservable());
|
|
1995
2020
|
}
|
|
@@ -2012,6 +2037,20 @@ var CanvasFloatDomService = class extends _univerjs_core.Disposable {
|
|
|
2012
2037
|
this._domLayerMap.set(item.id, item);
|
|
2013
2038
|
this._notice();
|
|
2014
2039
|
}
|
|
2040
|
+
hasScopedRenderRoot(unitId) {
|
|
2041
|
+
return this._scopedRenderRootCount.has(unitId);
|
|
2042
|
+
}
|
|
2043
|
+
registerScopedRenderRoot(unitId) {
|
|
2044
|
+
this._scopedRenderRootCount.set(unitId, (this._scopedRenderRootCount.get(unitId) ?? 0) + 1);
|
|
2045
|
+
this._notice();
|
|
2046
|
+
return (0, _univerjs_core.toDisposable)(() => {
|
|
2047
|
+
const count = this._scopedRenderRootCount.get(unitId);
|
|
2048
|
+
if (count == null) return;
|
|
2049
|
+
if (count === 1) this._scopedRenderRootCount.delete(unitId);
|
|
2050
|
+
else this._scopedRenderRootCount.set(unitId, count - 1);
|
|
2051
|
+
this._notice();
|
|
2052
|
+
});
|
|
2053
|
+
}
|
|
2015
2054
|
removeFloatDom(id) {
|
|
2016
2055
|
if (this._domLayerMap.delete(id)) this._notice();
|
|
2017
2056
|
}
|
|
@@ -2021,6 +2060,7 @@ var CanvasFloatDomService = class extends _univerjs_core.Disposable {
|
|
|
2021
2060
|
}
|
|
2022
2061
|
dispose() {
|
|
2023
2062
|
this._domLayerMap.clear();
|
|
2063
|
+
this._scopedRenderRootCount.clear();
|
|
2024
2064
|
this._domLayers$.next([]);
|
|
2025
2065
|
this._domLayers$.complete();
|
|
2026
2066
|
super.dispose();
|
|
@@ -2067,9 +2107,8 @@ var CanvasFloatDomPreviewService = class extends _univerjs_core.Disposable {
|
|
|
2067
2107
|
const LEGACY_WRAPPER_INSET = 2;
|
|
2068
2108
|
const LEGACY_CONTENT_INSET = 4;
|
|
2069
2109
|
function resolveFloatDomLayout(position, contentBox) {
|
|
2070
|
-
|
|
2071
|
-
const
|
|
2072
|
-
const contentInset = (_contentBox$contentIn = contentBox === null || contentBox === void 0 ? void 0 : contentBox.contentInset) !== null && _contentBox$contentIn !== void 0 ? _contentBox$contentIn : LEGACY_CONTENT_INSET;
|
|
2110
|
+
const wrapperInset = (contentBox === null || contentBox === void 0 ? void 0 : contentBox.wrapperInset) ?? LEGACY_WRAPPER_INSET;
|
|
2111
|
+
const contentInset = (contentBox === null || contentBox === void 0 ? void 0 : contentBox.contentInset) ?? LEGACY_CONTENT_INSET;
|
|
2073
2112
|
return {
|
|
2074
2113
|
wrapper: {
|
|
2075
2114
|
top: position.startY,
|
|
@@ -2077,7 +2116,7 @@ function resolveFloatDomLayout(position, contentBox) {
|
|
|
2077
2116
|
width: Math.max(position.endX - position.startX - wrapperInset, 0),
|
|
2078
2117
|
height: Math.max(position.endY - position.startY - wrapperInset, 0),
|
|
2079
2118
|
transform: `rotate(${position.rotate}deg)`,
|
|
2080
|
-
opacity:
|
|
2119
|
+
opacity: position.opacity ?? 1
|
|
2081
2120
|
},
|
|
2082
2121
|
inner: {
|
|
2083
2122
|
width: position.width - contentInset,
|
|
@@ -2206,17 +2245,20 @@ function FloatDomSingleContent(props) {
|
|
|
2206
2245
|
});
|
|
2207
2246
|
}
|
|
2208
2247
|
const FloatDom = ({ unitId }) => {
|
|
2209
|
-
var _layers$filter;
|
|
2210
2248
|
const instanceService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
2211
|
-
const
|
|
2249
|
+
const domLayerService = (0, _wendellhu_redi_react_bindings.useDependency)(CanvasFloatDomService);
|
|
2250
|
+
const layers = (0, _wendellhu_redi_react_bindings.useObservable)(domLayerService.domLayers$);
|
|
2212
2251
|
const currentUnitId = resolveFloatDomCurrentUnitId(unitId, (0, _wendellhu_redi_react_bindings.useObservable)(instanceService.focused$));
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2252
|
+
(0, react.useEffect)(() => {
|
|
2253
|
+
if (typeof unitId !== "string") return;
|
|
2254
|
+
const disposable = domLayerService.registerScopedRenderRoot(unitId);
|
|
2255
|
+
return () => disposable.dispose();
|
|
2256
|
+
}, [domLayerService, unitId]);
|
|
2257
|
+
const visibleLayers = typeof unitId === "string" ? layers === null || layers === void 0 ? void 0 : layers.filter((layer) => layer[1].unitId === unitId) : layers === null || layers === void 0 ? void 0 : layers.filter((layer) => !domLayerService.hasScopedRenderRoot(layer[1].unitId) && shouldRenderFloatDomLayer(layer[1], currentUnitId));
|
|
2258
|
+
return visibleLayers === null || visibleLayers === void 0 ? void 0 : visibleLayers.map((layer) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FloatDomSingle, {
|
|
2259
|
+
id: layer[1].domId ?? layer[0],
|
|
2260
|
+
layer: layer[1]
|
|
2261
|
+
}, layer[0]));
|
|
2220
2262
|
};
|
|
2221
2263
|
function resolveFloatDomCurrentUnitId(unitId, focusedUnit) {
|
|
2222
2264
|
if (typeof unitId === "string") return unitId;
|
|
@@ -2228,9 +2270,8 @@ function resolveFloatDomCurrentUnitId(unitId, focusedUnit) {
|
|
|
2228
2270
|
return null;
|
|
2229
2271
|
}
|
|
2230
2272
|
function resolveFloatDomOverflow(props) {
|
|
2231
|
-
var _viewport$bleedWidth;
|
|
2232
2273
|
const viewport = props.customBlockRenderViewport;
|
|
2233
|
-
if (!(Number.isFinite(viewport === null || viewport === void 0 ? void 0 : viewport.bleedWidth) && ((
|
|
2274
|
+
if (!(Number.isFinite(viewport === null || viewport === void 0 ? void 0 : viewport.bleedWidth) && ((viewport === null || viewport === void 0 ? void 0 : viewport.bleedWidth) ?? 0) > 0)) return {
|
|
2234
2275
|
outerOverflow: "hidden",
|
|
2235
2276
|
innerOverflow: "hidden"
|
|
2236
2277
|
};
|
|
@@ -2354,11 +2395,10 @@ function calcPopupPosition(layout) {
|
|
|
2354
2395
|
};
|
|
2355
2396
|
}
|
|
2356
2397
|
function RectPopup(props) {
|
|
2357
|
-
var _uiConfig$popupRootId;
|
|
2358
2398
|
const { mask, portal, children, anchorRect$, direction = "vertical", onClickOutside, excludeOutside, excludeRects, onPointerEnter, onPointerLeave, onClick, hidden, onContextMenu, zIndex = 1020, maskZIndex = 100, onMaskClick, noPushMinimumGap, autoRelayout = true } = props;
|
|
2359
2399
|
const nodeRef = (0, react.useRef)(null);
|
|
2360
|
-
const clickOtherFn = useEvent(onClickOutside
|
|
2361
|
-
const contextMenuFn = useEvent(onContextMenu
|
|
2400
|
+
const clickOtherFn = useEvent(onClickOutside ?? (() => {}));
|
|
2401
|
+
const contextMenuFn = useEvent(onContextMenu ?? (() => {}));
|
|
2362
2402
|
const positionRef = (0, react.useRef)({
|
|
2363
2403
|
top: -9999,
|
|
2364
2404
|
left: -9999
|
|
@@ -2367,7 +2407,7 @@ function RectPopup(props) {
|
|
|
2367
2407
|
const configService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IConfigService);
|
|
2368
2408
|
const anchorRectRef = (0, react.useRef)(void 0);
|
|
2369
2409
|
const uiConfig = configService.getConfig(UI_PLUGIN_CONFIG_KEY);
|
|
2370
|
-
const popupRootId = (
|
|
2410
|
+
const popupRootId = (uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.popupRootId) ?? "univer-popup-portal";
|
|
2371
2411
|
const updatePosition = useEvent((position) => {
|
|
2372
2412
|
requestAnimationFrame(() => {
|
|
2373
2413
|
if (!nodeRef.current) return;
|
|
@@ -2410,11 +2450,10 @@ function RectPopup(props) {
|
|
|
2410
2450
|
}, [anchorRect$, direction]);
|
|
2411
2451
|
(0, react.useEffect)(() => {
|
|
2412
2452
|
const handleClickOther = (e) => {
|
|
2413
|
-
var _excludeRectsRef$curr;
|
|
2414
2453
|
if (excludeOutside && (excludeOutside.indexOf(e.target) > -1 || excludeOutside.some((item) => item.contains(e.target)))) return;
|
|
2415
2454
|
const x = e.clientX;
|
|
2416
2455
|
const y = e.clientY;
|
|
2417
|
-
const rects = [...(
|
|
2456
|
+
const rects = [...(excludeRectsRef === null || excludeRectsRef === void 0 ? void 0 : excludeRectsRef.current) ?? []];
|
|
2418
2457
|
if (anchorRectRef.current) rects.push(anchorRectRef.current);
|
|
2419
2458
|
for (const rect of rects) if (x <= rect.right && x >= rect.left && y <= rect.bottom && y >= rect.top) return;
|
|
2420
2459
|
clickOtherFn(e);
|
|
@@ -2474,9 +2513,8 @@ RectPopup.useContext = () => (0, react.useContext)(RectPopupContext);
|
|
|
2474
2513
|
//#region src/views/components/popup/CanvasPopup.tsx
|
|
2475
2514
|
const SingleCanvasPopup = ({ popup, children }) => {
|
|
2476
2515
|
const anchorRect$ = (0, react.useMemo)(() => popup.anchorRect$.pipe((0, rxjs.throttleTime)(0, rxjs.animationFrameScheduler), (0, rxjs.map)((anchorRect) => {
|
|
2477
|
-
var _popup$offset;
|
|
2478
2516
|
const { bottom, left, right, top } = anchorRect;
|
|
2479
|
-
const [x = 0, y = 0] =
|
|
2517
|
+
const [x = 0, y = 0] = popup.offset ?? [];
|
|
2480
2518
|
return {
|
|
2481
2519
|
left: left - x,
|
|
2482
2520
|
right: right + x,
|
|
@@ -2485,8 +2523,8 @@ const SingleCanvasPopup = ({ popup, children }) => {
|
|
|
2485
2523
|
};
|
|
2486
2524
|
})), [popup.anchorRect$, popup.offset]);
|
|
2487
2525
|
const hiddenRects$ = (0, react.useMemo)(() => {
|
|
2488
|
-
var _popup$hiddenRects
|
|
2489
|
-
return (
|
|
2526
|
+
var _popup$hiddenRects$;
|
|
2527
|
+
return ((_popup$hiddenRects$ = popup.hiddenRects$) === null || _popup$hiddenRects$ === void 0 ? void 0 : _popup$hiddenRects$.pipe((0, rxjs.throttleTime)(0, rxjs.animationFrameScheduler))) ?? (0, rxjs.of)([]);
|
|
2490
2528
|
}, [popup.hiddenRects$]);
|
|
2491
2529
|
const excludeRectsRef = useObservableRef((0, react.useMemo)(() => {
|
|
2492
2530
|
var _popup$excludeRects$;
|
|
@@ -2578,11 +2616,10 @@ var RibbonOverrideService = class extends _univerjs_core.Disposable {
|
|
|
2578
2616
|
//#region src/views/components/ComponentContainer.tsx
|
|
2579
2617
|
function ComponentContainer(props) {
|
|
2580
2618
|
const { components, fallback, sharedProps } = props;
|
|
2581
|
-
if (!components || components.size === 0) return fallback
|
|
2619
|
+
if (!components || components.size === 0) return fallback ?? null;
|
|
2582
2620
|
return Array.from(components.values()).map((component, index) => {
|
|
2583
|
-
var _component$displayNam;
|
|
2584
2621
|
return (0, react.createElement)(component, {
|
|
2585
|
-
key: `${
|
|
2622
|
+
key: `${component.displayName ?? index}`,
|
|
2586
2623
|
...sharedProps
|
|
2587
2624
|
});
|
|
2588
2625
|
});
|
|
@@ -2595,9 +2632,8 @@ function ComponentContainer(props) {
|
|
|
2595
2632
|
* component.
|
|
2596
2633
|
*/
|
|
2597
2634
|
function useComponentsOfPart(part, injector) {
|
|
2598
|
-
var _injector$get;
|
|
2599
2635
|
const injectedUIPartsService = (0, _wendellhu_redi_react_bindings.useDependency)(IUIPartsService);
|
|
2600
|
-
const uiPartsService = (
|
|
2636
|
+
const uiPartsService = (injector === null || injector === void 0 ? void 0 : injector.get(IUIPartsService)) ?? injectedUIPartsService;
|
|
2601
2637
|
const changeInfo = (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => uiPartsService.uiVisibleChange$.pipe((0, rxjs.filter)((ui) => ui.ui === part)), [part, uiPartsService]));
|
|
2602
2638
|
const updateCounterRef = (0, react.useRef)(0);
|
|
2603
2639
|
return (0, react.useMemo)(() => uiPartsService.isUIVisible(part) ? uiPartsService.getComponents(part) : /* @__PURE__ */ new Set(), [(0, _wendellhu_redi_react_bindings.useObservable)(() => uiPartsService.componentRegistered$.pipe((0, rxjs.filter)((key) => key === part), (0, rxjs.debounceTime)(200), (0, rxjs.map)(() => updateCounterRef.current += 1), (0, rxjs.startWith)(updateCounterRef.current += 1)), void 0, void 0, [
|
|
@@ -2655,8 +2691,7 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
|
2655
2691
|
overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2656
2692
|
className: "univer-grid univer-gap-1 univer-px-2 univer-py-1",
|
|
2657
2693
|
children: ribbon.map((group) => {
|
|
2658
|
-
|
|
2659
|
-
const Icon = (_iconMap = iconMap[group.key]) !== null && _iconMap !== void 0 ? _iconMap : _univerjs_icons.MoreVerticalIcon;
|
|
2694
|
+
const Icon = iconMap[group.key] ?? _univerjs_icons.MoreVerticalIcon;
|
|
2660
2695
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
|
|
2661
2696
|
"data-u-comp": "ribbon-group-btn",
|
|
2662
2697
|
className: "univer-box-border univer-flex univer-cursor-pointer univer-items-center univer-gap-2.5 univer-rounded-lg univer-px-2 univer-py-1.5 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
|
|
@@ -2719,53 +2754,70 @@ function placeRibbonGridItems(items) {
|
|
|
2719
2754
|
const occupied = /* @__PURE__ */ new Set();
|
|
2720
2755
|
const placements = /* @__PURE__ */ new Map();
|
|
2721
2756
|
const fallbackItems = [];
|
|
2722
|
-
let maxExplicitColumn = 0;
|
|
2723
2757
|
for (const item of items) {
|
|
2724
|
-
var _layout$rowSpan, _layout$columnSpan, _layout$showLabel;
|
|
2725
2758
|
const layout = item.gridLayout;
|
|
2726
2759
|
if (!layout) {
|
|
2727
|
-
fallbackItems.push(item);
|
|
2760
|
+
fallbackItems.push({ item });
|
|
2728
2761
|
continue;
|
|
2729
2762
|
}
|
|
2730
|
-
const rowSpan =
|
|
2731
|
-
const columnSpan =
|
|
2763
|
+
const rowSpan = layout.rowSpan ?? 1;
|
|
2764
|
+
const columnSpan = layout.columnSpan ?? 1;
|
|
2732
2765
|
const cells = getCells(layout.row, layout.column, rowSpan, columnSpan);
|
|
2733
|
-
if (!(
|
|
2734
|
-
fallbackItems.push(item);
|
|
2766
|
+
if (!isValidGridGeometry(layout, rowSpan, cells)) {
|
|
2767
|
+
fallbackItems.push({ item });
|
|
2735
2768
|
continue;
|
|
2736
2769
|
}
|
|
2737
|
-
|
|
2738
|
-
maxExplicitColumn = Math.max(maxExplicitColumn, layout.column + columnSpan - 1);
|
|
2739
|
-
placements.set(item, {
|
|
2770
|
+
const placement = {
|
|
2740
2771
|
item,
|
|
2741
2772
|
row: layout.row,
|
|
2742
2773
|
column: layout.column,
|
|
2743
2774
|
rowSpan,
|
|
2744
2775
|
columnSpan,
|
|
2745
|
-
showLabel:
|
|
2776
|
+
showLabel: layout.showLabel ?? false,
|
|
2746
2777
|
width: layout.width,
|
|
2747
2778
|
iconSize: layout.iconSize
|
|
2748
|
-
}
|
|
2779
|
+
};
|
|
2780
|
+
if (cells.some((cell) => occupied.has(cell))) {
|
|
2781
|
+
fallbackItems.push({
|
|
2782
|
+
item,
|
|
2783
|
+
layout: placement
|
|
2784
|
+
});
|
|
2785
|
+
continue;
|
|
2786
|
+
}
|
|
2787
|
+
cells.forEach((cell) => occupied.add(cell));
|
|
2788
|
+
placements.set(item, placement);
|
|
2749
2789
|
}
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2790
|
+
for (const { item, layout } of fallbackItems) {
|
|
2791
|
+
const rowSpan = (layout === null || layout === void 0 ? void 0 : layout.rowSpan) ?? 1;
|
|
2792
|
+
const columnSpan = (layout === null || layout === void 0 ? void 0 : layout.columnSpan) ?? 1;
|
|
2793
|
+
const { row, column, cells } = findFirstAvailableCells(occupied, rowSpan, columnSpan);
|
|
2794
|
+
cells.forEach((cell) => occupied.add(cell));
|
|
2753
2795
|
placements.set(item, {
|
|
2754
2796
|
item,
|
|
2755
|
-
row
|
|
2756
|
-
column
|
|
2757
|
-
rowSpan
|
|
2758
|
-
columnSpan
|
|
2759
|
-
showLabel: false
|
|
2797
|
+
row,
|
|
2798
|
+
column,
|
|
2799
|
+
rowSpan,
|
|
2800
|
+
columnSpan,
|
|
2801
|
+
showLabel: (layout === null || layout === void 0 ? void 0 : layout.showLabel) ?? false,
|
|
2802
|
+
width: layout === null || layout === void 0 ? void 0 : layout.width,
|
|
2803
|
+
iconSize: layout === null || layout === void 0 ? void 0 : layout.iconSize
|
|
2760
2804
|
});
|
|
2761
|
-
fallbackRow += 1;
|
|
2762
|
-
if (fallbackRow > RIBBON_GRID_ROWS) {
|
|
2763
|
-
fallbackRow = 1;
|
|
2764
|
-
fallbackColumn += 1;
|
|
2765
|
-
}
|
|
2766
2805
|
}
|
|
2767
2806
|
return items.map((item) => placements.get(item));
|
|
2768
2807
|
}
|
|
2808
|
+
function isValidGridGeometry(layout, rowSpan, cells) {
|
|
2809
|
+
return cells.length > 0 && layout.row + rowSpan - 1 <= RIBBON_GRID_ROWS && (layout.width === void 0 || Number.isFinite(layout.width) && layout.width > 0) && (layout.iconSize === void 0 || Number.isFinite(layout.iconSize) && layout.iconSize > 0);
|
|
2810
|
+
}
|
|
2811
|
+
function findFirstAvailableCells(occupied, rowSpan, columnSpan) {
|
|
2812
|
+
for (let column = 1;; column++) for (let row = 1; row + rowSpan - 1 <= RIBBON_GRID_ROWS; row++) {
|
|
2813
|
+
const cells = getCells(row, column, rowSpan, columnSpan);
|
|
2814
|
+
if (cells.every((cell) => !occupied.has(cell))) return {
|
|
2815
|
+
row,
|
|
2816
|
+
column,
|
|
2817
|
+
cells
|
|
2818
|
+
};
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2769
2821
|
function getCells(row, column, rowSpan, columnSpan) {
|
|
2770
2822
|
if (![
|
|
2771
2823
|
row,
|
|
@@ -2789,13 +2841,13 @@ function CustomLabel(props) {
|
|
|
2789
2841
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
2790
2842
|
const componentManager = (0, _wendellhu_redi_react_bindings.useDependency)(ComponentManager);
|
|
2791
2843
|
const iconManager = (0, _wendellhu_redi_react_bindings.useDependency)(IconManager);
|
|
2792
|
-
const subscribedValue = (0, _wendellhu_redi_react_bindings.useObservable)(value$
|
|
2844
|
+
const subscribedValue = (0, _wendellhu_redi_react_bindings.useObservable)(value$ ?? null, value);
|
|
2793
2845
|
const subscribedIcon = (0, _wendellhu_redi_react_bindings.useObservable)((0, rxjs.isObservable)(icon) ? icon : null, "");
|
|
2794
|
-
const realIcon = (0, rxjs.isObservable)(icon) ? subscribedIcon : icon
|
|
2846
|
+
const realIcon = (0, rxjs.isObservable)(icon) ? subscribedIcon : icon ?? "";
|
|
2795
2847
|
const nodes = [];
|
|
2796
2848
|
let index = 0;
|
|
2797
2849
|
const realValue = (0, react.useMemo)(() => {
|
|
2798
|
-
return value
|
|
2850
|
+
return value ?? subscribedValue;
|
|
2799
2851
|
}, [subscribedValue, value]);
|
|
2800
2852
|
const isValid = (0, react.useMemo)(() => {
|
|
2801
2853
|
if (realValue && typeof realValue === "string") return new _univerjs_core.ColorKit(realValue).isValid;
|
|
@@ -2845,7 +2897,6 @@ function CustomLabel(props) {
|
|
|
2845
2897
|
* @returns The menu item's status
|
|
2846
2898
|
*/
|
|
2847
2899
|
function useToolbarItemStatus(menuItem) {
|
|
2848
|
-
var _selectionsValue$2;
|
|
2849
2900
|
const { disabled$, hidden$, activated$, value$ } = menuItem;
|
|
2850
2901
|
let selectionsValue$;
|
|
2851
2902
|
if (isMenuButtonSelectorItem(menuItem)) {
|
|
@@ -2855,23 +2906,20 @@ function useToolbarItemStatus(menuItem) {
|
|
|
2855
2906
|
selectionsValue$ = selections === null || selections === void 0 || (_selections$ = selections[0]) === null || _selections$ === void 0 ? void 0 : _selections$.value$;
|
|
2856
2907
|
}
|
|
2857
2908
|
}
|
|
2858
|
-
const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(disabled$
|
|
2859
|
-
const activated = (0, _wendellhu_redi_react_bindings.useObservable)(activated$
|
|
2860
|
-
const hidden = (0, _wendellhu_redi_react_bindings.useObservable)(hidden$
|
|
2909
|
+
const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(disabled$ ?? null, false);
|
|
2910
|
+
const activated = (0, _wendellhu_redi_react_bindings.useObservable)(activated$ ?? null, false);
|
|
2911
|
+
const hidden = (0, _wendellhu_redi_react_bindings.useObservable)(hidden$ ?? null, false);
|
|
2861
2912
|
return {
|
|
2862
2913
|
disabled,
|
|
2863
|
-
value: (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() =>
|
|
2864
|
-
var _selectionsValue$;
|
|
2865
|
-
return (0, rxjs.merge)(value$ !== null && value$ !== void 0 ? value$ : rxjs.EMPTY, (_selectionsValue$ = selectionsValue$) !== null && _selectionsValue$ !== void 0 ? _selectionsValue$ : rxjs.EMPTY);
|
|
2866
|
-
}, [selectionsValue$, value$])),
|
|
2914
|
+
value: (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => (0, rxjs.merge)(value$ ?? rxjs.EMPTY, selectionsValue$ ?? rxjs.EMPTY), [selectionsValue$, value$])),
|
|
2867
2915
|
activated,
|
|
2868
2916
|
hidden,
|
|
2869
|
-
selectionsValue: (0, _wendellhu_redi_react_bindings.useObservable)(
|
|
2917
|
+
selectionsValue: (0, _wendellhu_redi_react_bindings.useObservable)(selectionsValue$ ?? null)
|
|
2870
2918
|
};
|
|
2871
2919
|
}
|
|
2872
2920
|
function useToolbarShortcutDisplay({ id, commandId, shortcut }) {
|
|
2873
2921
|
const shortcutService = (0, _wendellhu_redi_react_bindings.useDependency)(IShortcutService);
|
|
2874
|
-
const shortcutCommandId = commandId
|
|
2922
|
+
const shortcutCommandId = commandId ?? id;
|
|
2875
2923
|
return (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => shortcut ? (0, rxjs.of)(shortcut) : shortcutService.shortcutChanged$.pipe((0, rxjs.map)(() => shortcutService.getShortcutDisplayOfCommand(shortcutCommandId)), (0, rxjs.startWith)(shortcutService.getShortcutDisplayOfCommand(shortcutCommandId))), [
|
|
2876
2924
|
shortcut,
|
|
2877
2925
|
shortcutService,
|
|
@@ -3079,8 +3127,8 @@ function DropdownMenuLabel({ icon, value, option, onOptionSelect }) {
|
|
|
3079
3127
|
});
|
|
3080
3128
|
}
|
|
3081
3129
|
function getOptionKey(option) {
|
|
3082
|
-
var
|
|
3083
|
-
return String(
|
|
3130
|
+
var _option$label2;
|
|
3131
|
+
return String(option.id ?? option.commandId ?? option.value ?? (typeof option.label === "string" ? option.label : (_option$label2 = option.label) === null || _option$label2 === void 0 ? void 0 : _option$label2.name));
|
|
3084
3132
|
}
|
|
3085
3133
|
function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, onOptionSelect }) {
|
|
3086
3134
|
const { dropdownVisible, setDropdownVisible } = (0, react.useContext)(TooltipWrapperContext);
|
|
@@ -3092,11 +3140,11 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3092
3140
|
const menuItems = (0, _wendellhu_redi_react_bindings.useObservable)(() => menuManagerService.menuChanged$.pipe((0, rxjs.map)(resolveMenuItems), (0, rxjs.startWith)(resolveMenuItems())), resolveMenuItems(), false, [menuId, menuManagerService]);
|
|
3093
3141
|
const hiddenStates = (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => {
|
|
3094
3142
|
const itemStates = menuItems.map((item) => {
|
|
3095
|
-
var _item$item
|
|
3143
|
+
var _item$item;
|
|
3096
3144
|
return (item.children ? (0, rxjs.combineLatest)(item.children.map((subItem) => {
|
|
3097
|
-
var _subItem$item
|
|
3098
|
-
return (
|
|
3099
|
-
})).pipe((0, rxjs.map)((hiddenValues) => hiddenValues.every(Boolean))) : (
|
|
3145
|
+
var _subItem$item;
|
|
3146
|
+
return ((_subItem$item = subItem.item) === null || _subItem$item === void 0 ? void 0 : _subItem$item.hidden$) ?? (0, rxjs.of)(false);
|
|
3147
|
+
})).pipe((0, rxjs.map)((hiddenValues) => hiddenValues.every(Boolean))) : ((_item$item = item.item) === null || _item$item === void 0 ? void 0 : _item$item.hidden$) ?? (0, rxjs.of)(false)).pipe((0, rxjs.map)((hidden) => [String(item.key), hidden]));
|
|
3100
3148
|
});
|
|
3101
3149
|
return itemStates.length ? (0, rxjs.merge)(...itemStates).pipe((0, rxjs.scan)((states, [key, hidden]) => ({
|
|
3102
3150
|
...states,
|
|
@@ -3107,7 +3155,8 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3107
3155
|
return menuItems.filter((item) => {
|
|
3108
3156
|
var _item$key;
|
|
3109
3157
|
if (!item.children) return !hiddenStates[item.key];
|
|
3110
|
-
|
|
3158
|
+
const itemKey = ((_item$key = item.key) === null || _item$key === void 0 ? void 0 : _item$key.toString()) || "";
|
|
3159
|
+
return !hiddenStates[itemKey];
|
|
3111
3160
|
});
|
|
3112
3161
|
}, [menuItems, hiddenStates]);
|
|
3113
3162
|
function handleVisibleChange(visible) {
|
|
@@ -3130,15 +3179,15 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3130
3179
|
children
|
|
3131
3180
|
});
|
|
3132
3181
|
if (options === null || options === void 0 ? void 0 : options.length) {
|
|
3133
|
-
var _options$0$label;
|
|
3134
|
-
const
|
|
3182
|
+
var _options$0$label, _options$0$label$prop;
|
|
3183
|
+
const isSingleEmbeddedCustomPanel = filteredMenuItems.length === 0 && options.length === 1 && typeof options[0].label === "object" && ((_options$0$label = options[0].label) === null || _options$0$label === void 0 ? void 0 : _options$0$label.hoverable) === false && ((_options$0$label$prop = options[0].label.props) === null || _options$0$label$prop === void 0 ? void 0 : _options$0$label$prop.embedded) === true;
|
|
3135
3184
|
const items = options.map((option) => {
|
|
3136
|
-
var _option$label3
|
|
3185
|
+
var _option$label3;
|
|
3137
3186
|
return {
|
|
3138
3187
|
type: "item",
|
|
3139
3188
|
className: (0, _univerjs_design.clsx)({
|
|
3140
3189
|
"focus:univer-bg-white": typeof option.label !== "string" && ((_option$label3 = option.label) === null || _option$label3 === void 0 ? void 0 : _option$label3.hoverable) === false,
|
|
3141
|
-
"!univer-p-0":
|
|
3190
|
+
"!univer-p-0": isSingleEmbeddedCustomPanel
|
|
3142
3191
|
}),
|
|
3143
3192
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuLabel, {
|
|
3144
3193
|
icon: option.icon,
|
|
@@ -3178,7 +3227,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3178
3227
|
}
|
|
3179
3228
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
|
|
3180
3229
|
align: "start",
|
|
3181
|
-
className: (0, _univerjs_design.clsx)({ "!univer-p-0":
|
|
3230
|
+
className: (0, _univerjs_design.clsx)({ "!univer-p-0": isSingleEmbeddedCustomPanel }),
|
|
3182
3231
|
items,
|
|
3183
3232
|
disabled,
|
|
3184
3233
|
open: dropdownVisible,
|
|
@@ -3317,7 +3366,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3317
3366
|
commandService.executeCommand(commandId, params);
|
|
3318
3367
|
};
|
|
3319
3368
|
const { tooltip, shortcut, icon, title, label, id, commandId, type, slot, params, grid, large, showLabel, iconSize, iconColor, fullWidth } = props;
|
|
3320
|
-
const gridLabel = title
|
|
3369
|
+
const gridLabel = title ?? tooltip;
|
|
3321
3370
|
const shortcutDisplay = useToolbarShortcutDisplay({
|
|
3322
3371
|
id,
|
|
3323
3372
|
commandId,
|
|
@@ -3335,8 +3384,8 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3335
3384
|
const iconToDisplay = (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => {
|
|
3336
3385
|
if ((0, rxjs.isObservable)(icon)) return icon;
|
|
3337
3386
|
else return new rxjs.Observable((subscribe) => {
|
|
3338
|
-
var _options$find
|
|
3339
|
-
const v = (
|
|
3387
|
+
var _options$find;
|
|
3388
|
+
const v = (options === null || options === void 0 || (_options$find = options.find((o) => o.value === value)) === null || _options$find === void 0 ? void 0 : _options$find.icon) ?? icon;
|
|
3340
3389
|
subscribe.next(v);
|
|
3341
3390
|
});
|
|
3342
3391
|
}, [
|
|
@@ -3345,17 +3394,16 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3345
3394
|
value
|
|
3346
3395
|
]), void 0, true);
|
|
3347
3396
|
function renderSelectorType(menuType) {
|
|
3348
|
-
var _ref;
|
|
3349
3397
|
const selectionsCommandId = props.selectionsCommandId;
|
|
3350
|
-
const bId = commandId
|
|
3351
|
-
const sId =
|
|
3398
|
+
const bId = commandId ?? id;
|
|
3399
|
+
const sId = selectionsCommandId ?? commandId ?? id;
|
|
3352
3400
|
const titleToDisplay = grid ? showLabel ? gridLabel : large ? void 0 : title : title;
|
|
3353
3401
|
function handleSelect(option) {
|
|
3354
3402
|
if (disabled) return;
|
|
3355
3403
|
let commandId = sId;
|
|
3356
3404
|
if (option.id) commandId = option.id;
|
|
3357
3405
|
const commandParams = typeof option.params === "function" ? option.params(option.value) : option.params;
|
|
3358
|
-
executeCommand(commandId, commandParams
|
|
3406
|
+
executeCommand(commandId, commandParams ?? { value: option.value });
|
|
3359
3407
|
}
|
|
3360
3408
|
function handleSelectionsValueChange(value) {
|
|
3361
3409
|
if (disabled) return;
|
|
@@ -3365,7 +3413,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3365
3413
|
if (disabled) return;
|
|
3366
3414
|
if (menuType === 2) {
|
|
3367
3415
|
const commandParams = typeof params === "function" ? params() : params;
|
|
3368
|
-
executeCommand(bId, commandParams
|
|
3416
|
+
executeCommand(bId, commandParams ?? { value });
|
|
3369
3417
|
}
|
|
3370
3418
|
}
|
|
3371
3419
|
if (menuType === 2) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -3388,7 +3436,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3388
3436
|
icon: iconToDisplay,
|
|
3389
3437
|
iconSize,
|
|
3390
3438
|
title: titleToDisplay,
|
|
3391
|
-
value: iconColor
|
|
3439
|
+
value: iconColor ?? value,
|
|
3392
3440
|
label,
|
|
3393
3441
|
onChange: handleSelectionsValueChange
|
|
3394
3442
|
})
|
|
@@ -3456,8 +3504,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3456
3504
|
});
|
|
3457
3505
|
}
|
|
3458
3506
|
function renderButtonType() {
|
|
3459
|
-
|
|
3460
|
-
const isCustomComponent = componentManager.get(typeof label === "string" ? label : (_label$name = label === null || label === void 0 ? void 0 : label.name) !== null && _label$name !== void 0 ? _label$name : "");
|
|
3507
|
+
const isCustomComponent = componentManager.get(typeof label === "string" ? label : (label === null || label === void 0 ? void 0 : label.name) ?? "");
|
|
3461
3508
|
const buttonClassName = (0, _univerjs_design.clsx)(grid && !large && "univer-h-full univer-min-w-8 [&>svg]:univer-size-4", grid && large ? "univer-h-full univer-min-w-14 univer-flex-col univer-gap-1 univer-px-1.5 univer-py-1 univer-text-xs [&>svg]:univer-size-8" : showLabel ? "univer-gap-1 univer-px-1.5 univer-text-sm" : "univer-text-sm", grid && fullWidth && isCustomComponent && "!univer-px-0");
|
|
3462
3509
|
const buttonStyle = grid && large ? {
|
|
3463
3510
|
textAlign: "center",
|
|
@@ -3487,9 +3534,8 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3487
3534
|
active: activated,
|
|
3488
3535
|
disabled,
|
|
3489
3536
|
onClick: () => {
|
|
3490
|
-
var _props$commandId;
|
|
3491
3537
|
const commandParams = typeof params === "function" ? params() : params;
|
|
3492
|
-
executeCommand(
|
|
3538
|
+
executeCommand(props.commandId ?? props.id, commandParams ?? (typeof value === "undefined" ? void 0 : { value }));
|
|
3493
3539
|
},
|
|
3494
3540
|
onDoubleClick: () => props.subId && executeCommand(props.subId),
|
|
3495
3541
|
children: icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
|
|
@@ -3529,14 +3575,13 @@ function RibbonGrid({ groups, title, className, ...props }) {
|
|
|
3529
3575
|
role: "toolbar",
|
|
3530
3576
|
"aria-label": localeService.t(title),
|
|
3531
3577
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarDropdownProvider, { children: groups.map((group) => {
|
|
3532
|
-
var _group$children;
|
|
3533
3578
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3534
3579
|
"data-u-comp": "ribbon-grid-group",
|
|
3535
3580
|
className: "univer-relative univer-box-border univer-flex univer-min-w-16 univer-shrink-0 univer-flex-col univer-px-2",
|
|
3536
3581
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3537
3582
|
"data-testid": "ribbon-grid-group-grid",
|
|
3538
3583
|
className: "univer-grid univer-min-h-0 univer-flex-1 univer-grid-flow-col univer-grid-rows-2 univer-content-center univer-gap-x-1 univer-gap-y-2 univer-py-2 [&>div>span>span]:univer-h-full",
|
|
3539
|
-
children: placeRibbonGridItems(
|
|
3584
|
+
children: placeRibbonGridItems(group.children ?? []).map((placement) => placement.item.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3540
3585
|
className: (0, _univerjs_design.clsx)("univer-flex univer-items-stretch [&>span>button]:univer-h-full [&>span]:univer-h-full", placement.width && "[&>span>span]:univer-w-full [&>span]:univer-w-full [&_[data-u-command]]:univer-w-full"),
|
|
3541
3586
|
style: {
|
|
3542
3587
|
gridRow: `${placement.row} / span ${placement.rowSpan}`,
|
|
@@ -3565,13 +3610,12 @@ function RibbonGrid({ groups, title, className, ...props }) {
|
|
|
3565
3610
|
//#endregion
|
|
3566
3611
|
//#region src/views/components/ribbon/Ribbon.tsx
|
|
3567
3612
|
function Ribbon(props) {
|
|
3568
|
-
var _ribbonOverride$ribbo;
|
|
3569
3613
|
const { ribbonType, headerMenuComponents, headerMenu = true, toolbarOnly = false, headerClassName } = props;
|
|
3570
3614
|
const defaultRibbonService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonService);
|
|
3571
3615
|
const ribbonOverrideService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonOverrideService);
|
|
3572
3616
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
3573
3617
|
const ribbonOverride = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonOverrideService.override$, ribbonOverrideService.getOverride());
|
|
3574
|
-
const ribbonService = (
|
|
3618
|
+
const ribbonService = (ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.ribbonService) ?? defaultRibbonService;
|
|
3575
3619
|
const containerRef = (0, react.useRef)(null);
|
|
3576
3620
|
const toolbarItemRefs = (0, react.useRef)({});
|
|
3577
3621
|
const ribbonData = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonService.ribbon$, []);
|
|
@@ -3606,8 +3650,8 @@ function Ribbon(props) {
|
|
|
3606
3650
|
ribbonService.setActivatedTab(group.key);
|
|
3607
3651
|
}, [ribbonService]);
|
|
3608
3652
|
const activeGroup = (0, react.useMemo)(() => {
|
|
3609
|
-
var _ribbon$
|
|
3610
|
-
const allGroups = (
|
|
3653
|
+
var _ribbon$find2;
|
|
3654
|
+
const allGroups = ((_ribbon$find2 = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find2 === void 0 ? void 0 : _ribbon$find2.children) ?? [];
|
|
3611
3655
|
const visibleGroups = [];
|
|
3612
3656
|
const hiddenGroups = [];
|
|
3613
3657
|
for (const item of allGroups) if (item.children) {
|
|
@@ -3644,14 +3688,14 @@ function Ribbon(props) {
|
|
|
3644
3688
|
for (const entry of entries) {
|
|
3645
3689
|
ribbonService.setFakeToolbarVisible(true);
|
|
3646
3690
|
timer = requestAnimationFrame(() => {
|
|
3647
|
-
var _ribbon$
|
|
3691
|
+
var _ribbon$find3;
|
|
3648
3692
|
const { width: avaliableWidth } = entry.contentRect;
|
|
3649
3693
|
const sortedToolbarItems = Object.values(toolbarItemRefs.current).sort((a, b) => {
|
|
3650
3694
|
return a.order - b.order || a.groupOrder - b.groupOrder || a.itemOrder - b.itemOrder;
|
|
3651
3695
|
});
|
|
3652
3696
|
const newCollapsedIds = [];
|
|
3653
3697
|
let totalWidth = 32;
|
|
3654
|
-
const gapWidth = (((
|
|
3698
|
+
const gapWidth = ((((_ribbon$find3 = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find3 === void 0 ? void 0 : _ribbon$find3.children) ?? []).length - 1) * 8;
|
|
3655
3699
|
totalWidth += gapWidth;
|
|
3656
3700
|
for (const { el, key } of sortedToolbarItems) {
|
|
3657
3701
|
const { width } = el.getBoundingClientRect();
|
|
@@ -3799,7 +3843,6 @@ function Ribbon(props) {
|
|
|
3799
3843
|
});
|
|
3800
3844
|
}
|
|
3801
3845
|
function RibbonOverrideRuntimeProvider(props) {
|
|
3802
|
-
var _override$portalConta;
|
|
3803
3846
|
const { override, children } = props;
|
|
3804
3847
|
const config = (0, react.useContext)(_univerjs_design.ConfigContext);
|
|
3805
3848
|
const injector = override === null || override === void 0 ? void 0 : override.injector;
|
|
@@ -3808,7 +3851,7 @@ function RibbonOverrideRuntimeProvider(props) {
|
|
|
3808
3851
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConnectedRibbonOverrideConfigProvider, {
|
|
3809
3852
|
locale: config.locale,
|
|
3810
3853
|
direction: config.direction,
|
|
3811
|
-
mountContainer:
|
|
3854
|
+
mountContainer: override.portalContainer ?? config.mountContainer,
|
|
3812
3855
|
children
|
|
3813
3856
|
});
|
|
3814
3857
|
}
|
|
@@ -3856,6 +3899,33 @@ var ThemeSwitcherService = class extends _univerjs_core.Disposable {
|
|
|
3856
3899
|
}
|
|
3857
3900
|
};
|
|
3858
3901
|
|
|
3902
|
+
//#endregion
|
|
3903
|
+
//#region src/services/workbench/workbench.service.ts
|
|
3904
|
+
const IWorkbenchService = (0, _univerjs_core.createIdentifier)("univer.ui.workbench.service");
|
|
3905
|
+
var WorkbenchService = class extends _univerjs_core.Disposable {
|
|
3906
|
+
constructor(..._args) {
|
|
3907
|
+
super(..._args);
|
|
3908
|
+
_defineProperty(this, "_tokens", /* @__PURE__ */ new Set());
|
|
3909
|
+
_defineProperty(this, "_skeletonVisible$", new rxjs.BehaviorSubject(false));
|
|
3910
|
+
_defineProperty(this, "skeletonVisible$", this._skeletonVisible$.asObservable());
|
|
3911
|
+
}
|
|
3912
|
+
acquireSkeleton() {
|
|
3913
|
+
const token = Symbol("workbench-skeleton");
|
|
3914
|
+
this._tokens.add(token);
|
|
3915
|
+
if (this._tokens.size === 1) this._skeletonVisible$.next(true);
|
|
3916
|
+
const disposable = (0, _univerjs_core.toDisposable)(() => {
|
|
3917
|
+
if (!this._tokens.delete(token) || this._tokens.size > 0) return;
|
|
3918
|
+
this._skeletonVisible$.next(false);
|
|
3919
|
+
});
|
|
3920
|
+
return this.disposeWithMe(disposable);
|
|
3921
|
+
}
|
|
3922
|
+
dispose() {
|
|
3923
|
+
super.dispose();
|
|
3924
|
+
this._tokens.clear();
|
|
3925
|
+
this._skeletonVisible$.complete();
|
|
3926
|
+
}
|
|
3927
|
+
};
|
|
3928
|
+
|
|
3859
3929
|
//#endregion
|
|
3860
3930
|
//#region src/services/contextmenu/contextmenu.service.ts
|
|
3861
3931
|
const IContextMenuService = (0, _univerjs_core.createIdentifier)("ui.contextmenu.service");
|
|
@@ -3866,8 +3936,8 @@ var ContextMenuService = class extends _univerjs_core.Disposable {
|
|
|
3866
3936
|
_defineProperty(this, "disabled", false);
|
|
3867
3937
|
}
|
|
3868
3938
|
get visible() {
|
|
3869
|
-
var _this$_currentHandler
|
|
3870
|
-
return (_this$_currentHandler =
|
|
3939
|
+
var _this$_currentHandler;
|
|
3940
|
+
return ((_this$_currentHandler = this._currentHandler) === null || _this$_currentHandler === void 0 ? void 0 : _this$_currentHandler.visible) ?? false;
|
|
3871
3941
|
}
|
|
3872
3942
|
disable() {
|
|
3873
3943
|
this.disabled = true;
|
|
@@ -3876,14 +3946,14 @@ var ContextMenuService = class extends _univerjs_core.Disposable {
|
|
|
3876
3946
|
this.disabled = false;
|
|
3877
3947
|
}
|
|
3878
3948
|
triggerContextMenu(event, menuType, context) {
|
|
3879
|
-
var _this$
|
|
3949
|
+
var _this$_currentHandler2;
|
|
3880
3950
|
event.stopPropagation();
|
|
3881
3951
|
if (this.disabled) return;
|
|
3882
|
-
(_this$
|
|
3952
|
+
(_this$_currentHandler2 = this._currentHandler) === null || _this$_currentHandler2 === void 0 || _this$_currentHandler2.handleContextMenu(event, menuType, context);
|
|
3883
3953
|
}
|
|
3884
3954
|
hideContextMenu() {
|
|
3885
|
-
var _this$
|
|
3886
|
-
(_this$
|
|
3955
|
+
var _this$_currentHandler3;
|
|
3956
|
+
(_this$_currentHandler3 = this._currentHandler) === null || _this$_currentHandler3 === void 0 || _this$_currentHandler3.hideContextMenu();
|
|
3887
3957
|
}
|
|
3888
3958
|
registerContextMenuHandler(handler) {
|
|
3889
3959
|
if (this._currentHandler) throw new Error("There is already a context menu handler!");
|
|
@@ -3966,10 +4036,10 @@ function useScrollYOverContainer(element, container) {
|
|
|
3966
4036
|
(0, react.useEffect)(() => {
|
|
3967
4037
|
if (!(0, _univerjs_design.isBrowser)() || !element || !container) return;
|
|
3968
4038
|
updater();
|
|
3969
|
-
const resizeObserver =
|
|
4039
|
+
const resizeObserver = new ResizeObserver(updater);
|
|
3970
4040
|
resizeObserver.observe(element);
|
|
3971
4041
|
return () => {
|
|
3972
|
-
resizeObserver.
|
|
4042
|
+
resizeObserver.disconnect();
|
|
3973
4043
|
};
|
|
3974
4044
|
}, [element, container]);
|
|
3975
4045
|
}
|
|
@@ -4077,11 +4147,10 @@ function DesignTinyMenuGroup({ items, columns, sizeVariant = "default", layoutVa
|
|
|
4077
4147
|
}),
|
|
4078
4148
|
style: gridTemplateColumns ? { gridTemplateColumns } : void 0,
|
|
4079
4149
|
children: items.map((item) => {
|
|
4080
|
-
var _item$tooltip;
|
|
4081
4150
|
const showTooltip = !isParagraphTVariant && item.tooltip;
|
|
4082
4151
|
const ele = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4083
4152
|
type: "button",
|
|
4084
|
-
"aria-label":
|
|
4153
|
+
"aria-label": item.tooltip ?? item.key,
|
|
4085
4154
|
title: showTooltip ? item.tooltip : void 0,
|
|
4086
4155
|
className: tinyMenuButtonVariants({
|
|
4087
4156
|
variant,
|
|
@@ -4131,8 +4200,8 @@ function resolveMenuItemActiveState(itemId, observableActive, activeItemIds) {
|
|
|
4131
4200
|
return observableActive;
|
|
4132
4201
|
}
|
|
4133
4202
|
function getTinyMenuChildStateKey(child) {
|
|
4134
|
-
var _child$item
|
|
4135
|
-
return (
|
|
4203
|
+
var _child$item;
|
|
4204
|
+
return ((_child$item = child.item) === null || _child$item === void 0 ? void 0 : _child$item.id) ?? child.key;
|
|
4136
4205
|
}
|
|
4137
4206
|
function getVisibleTinyMenuChildren(children, hiddenItemKeys) {
|
|
4138
4207
|
const hiddenSet = new Set(hiddenItemKeys);
|
|
@@ -4148,18 +4217,18 @@ function QuickTileMenuItem(props) {
|
|
|
4148
4217
|
const activated = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem === null || menuItem === void 0 ? void 0 : menuItem.activated$, false);
|
|
4149
4218
|
if (!menuItem || hidden) return null;
|
|
4150
4219
|
const Icon = menuItem.icon ? iconManager.get(menuItem.icon) : null;
|
|
4220
|
+
const active = resolveMenuItemActiveState(menuItem.id, activated, activeItemIds);
|
|
4151
4221
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
4152
4222
|
type: "button",
|
|
4153
4223
|
className: quickTileMenuButtonVariants({
|
|
4154
4224
|
disabled,
|
|
4155
|
-
active
|
|
4225
|
+
active
|
|
4156
4226
|
}),
|
|
4157
4227
|
disabled,
|
|
4158
4228
|
onClick: () => {
|
|
4159
|
-
var _menuItem$id;
|
|
4160
4229
|
if (disabled) return;
|
|
4161
4230
|
onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
|
|
4162
|
-
label:
|
|
4231
|
+
label: menuItem.id ?? menuSchema.key,
|
|
4163
4232
|
commandId: menuItem.commandId,
|
|
4164
4233
|
id: menuItem.id,
|
|
4165
4234
|
params: menuItem.params,
|
|
@@ -4177,25 +4246,21 @@ function QuickTileMenuItem(props) {
|
|
|
4177
4246
|
});
|
|
4178
4247
|
}
|
|
4179
4248
|
function UITinyMenuGroup(props) {
|
|
4180
|
-
var _item$children;
|
|
4181
4249
|
const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, hoverSuppressed, columns, sizeVariant = "default", layoutVariant = "default", onOptionSelect } = props;
|
|
4182
4250
|
const iconManager = (0, _wendellhu_redi_react_bindings.useDependency)(IconManager);
|
|
4183
4251
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
4184
|
-
const children =
|
|
4252
|
+
const children = item.children ?? EMPTY_TINY_MENU_CHILDREN;
|
|
4185
4253
|
const activeItems$ = (0, react.useMemo)(() => children.length ? (0, rxjs.combineLatest)(children.map((child) => {
|
|
4186
|
-
var _child$
|
|
4187
|
-
return ((
|
|
4254
|
+
var _child$item2;
|
|
4255
|
+
return (((_child$item2 = child.item) === null || _child$item2 === void 0 ? void 0 : _child$item2.activated$) ?? (0, rxjs.of)(false)).pipe((0, rxjs.startWith)(false));
|
|
4188
4256
|
})).pipe((0, rxjs.map)((states) => children.flatMap((child, index) => states[index] ? [getTinyMenuChildStateKey(child)] : []))) : (0, rxjs.of)([]), [children]);
|
|
4189
4257
|
const hiddenItems$ = (0, react.useMemo)(() => children.length ? (0, rxjs.combineLatest)(children.map((child) => {
|
|
4190
|
-
var _child$
|
|
4191
|
-
return ((
|
|
4258
|
+
var _child$item3;
|
|
4259
|
+
return (((_child$item3 = child.item) === null || _child$item3 === void 0 ? void 0 : _child$item3.hidden$) ?? (0, rxjs.of)(false)).pipe((0, rxjs.startWith)(false));
|
|
4192
4260
|
})).pipe((0, rxjs.map)((states) => children.flatMap((child, index) => states[index] ? [getTinyMenuChildStateKey(child)] : []))) : (0, rxjs.of)([]), [children]);
|
|
4193
4261
|
const activeItems = (0, _wendellhu_redi_react_bindings.useObservable)(activeItems$, []);
|
|
4194
4262
|
const hiddenItems = (0, _wendellhu_redi_react_bindings.useObservable)(hiddenItems$, []);
|
|
4195
|
-
const visibleChildren = (0, react.useMemo)(() =>
|
|
4196
|
-
var _item$children2;
|
|
4197
|
-
return getVisibleTinyMenuChildren((_item$children2 = item.children) !== null && _item$children2 !== void 0 ? _item$children2 : [], [...hiddenItems, ...hiddenItemIds]);
|
|
4198
|
-
}, [
|
|
4263
|
+
const visibleChildren = (0, react.useMemo)(() => getVisibleTinyMenuChildren(item.children ?? [], [...hiddenItems, ...hiddenItemIds]), [
|
|
4199
4264
|
hiddenItemIds,
|
|
4200
4265
|
hiddenItems,
|
|
4201
4266
|
item.children
|
|
@@ -4207,15 +4272,15 @@ function UITinyMenuGroup(props) {
|
|
|
4207
4272
|
layoutVariant,
|
|
4208
4273
|
hoverSuppressed,
|
|
4209
4274
|
items: visibleChildren.map((child) => {
|
|
4210
|
-
var _child$item4, _child$item12, _child$item13, _child$
|
|
4275
|
+
var _child$item4, _child$item12, _child$item13, _child$item14, _child$item15;
|
|
4211
4276
|
const Icon = ((_child$item4 = child.item) === null || _child$item4 === void 0 ? void 0 : _child$item4.icon) ? iconManager.get(child.item.icon) : void 0;
|
|
4212
4277
|
if (!Icon) return null;
|
|
4213
4278
|
return {
|
|
4214
4279
|
key: child.key,
|
|
4215
4280
|
onClick: () => {
|
|
4216
|
-
var _child$
|
|
4281
|
+
var _child$item5, _child$item6, _child$item7, _child$item8, _child$item9, _child$item10, _child$item11;
|
|
4217
4282
|
onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
|
|
4218
|
-
label: (
|
|
4283
|
+
label: ((_child$item5 = child.item) === null || _child$item5 === void 0 ? void 0 : _child$item5.id) ?? child.key,
|
|
4219
4284
|
commandId: (_child$item6 = child.item) === null || _child$item6 === void 0 ? void 0 : _child$item6.commandId,
|
|
4220
4285
|
id: (_child$item7 = child.item) === null || _child$item7 === void 0 ? void 0 : _child$item7.id,
|
|
4221
4286
|
params: (_child$item8 = child.item) === null || _child$item8 === void 0 ? void 0 : _child$item8.params,
|
|
@@ -4226,16 +4291,16 @@ function UITinyMenuGroup(props) {
|
|
|
4226
4291
|
className: "",
|
|
4227
4292
|
iconClassName: ((_child$item12 = child.item) === null || _child$item12 === void 0 ? void 0 : _child$item12.icon) === "TextTypeIcon" ? sizeVariant === "paragraph-t" ? "!univer-size-4" : "!univer-size-3.5" : void 0,
|
|
4228
4293
|
Icon,
|
|
4229
|
-
active: resolveMenuItemActiveState((_child$item13 = child.item) === null || _child$item13 === void 0 ? void 0 : _child$item13.id, activeItems.includes((
|
|
4294
|
+
active: resolveMenuItemActiveState((_child$item13 = child.item) === null || _child$item13 === void 0 ? void 0 : _child$item13.id, activeItems.includes(((_child$item14 = child.item) === null || _child$item14 === void 0 ? void 0 : _child$item14.id) ?? ""), activeItemIds),
|
|
4230
4295
|
tooltip: ((_child$item15 = child.item) === null || _child$item15 === void 0 ? void 0 : _child$item15.tooltip) ? localeService.t(child.item.tooltip) : void 0
|
|
4231
4296
|
};
|
|
4232
4297
|
}).filter((child) => child != null)
|
|
4233
4298
|
});
|
|
4234
4299
|
}
|
|
4235
4300
|
function UIQuickTileMenuGroup(props) {
|
|
4236
|
-
var _item$
|
|
4301
|
+
var _item$children;
|
|
4237
4302
|
const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, onOptionSelect } = props;
|
|
4238
|
-
if (!((_item$
|
|
4303
|
+
if (!((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length)) return null;
|
|
4239
4304
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4240
4305
|
className: "univer-item-center univer-grid univer-grid-cols-3 univer-gap-1.5 univer-py-1",
|
|
4241
4306
|
children: getVisibleTinyMenuChildren(item.children, hiddenItemIds).map((menuSchema) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(QuickTileMenuItem, {
|
|
@@ -4451,11 +4516,11 @@ function getContextMenuPanelClassName(sizeVariant) {
|
|
|
4451
4516
|
function getContextMenuGroupClassName(sizeVariant) {
|
|
4452
4517
|
return contextMenuGroupVariants({ sizeVariant });
|
|
4453
4518
|
}
|
|
4454
|
-
function
|
|
4455
|
-
return
|
|
4519
|
+
function isHeaderQuickGroup(menuSchema) {
|
|
4520
|
+
return menuSchema.quickLayout === "icon" && CONTEXT_MENU_HEADER_QUICK_GROUP_KEYS.has(menuSchema.key);
|
|
4456
4521
|
}
|
|
4457
|
-
function
|
|
4458
|
-
return
|
|
4522
|
+
function shouldClusterHeaderQuickGroups(currentSchema, nextSchema) {
|
|
4523
|
+
return isHeaderQuickGroup(currentSchema) && !!nextSchema && isHeaderQuickGroup(nextSchema);
|
|
4459
4524
|
}
|
|
4460
4525
|
function getContextMenuQuickGroupClassName(menuSchema, visibleSchemas, index, sizeVariant) {
|
|
4461
4526
|
if (sizeVariant !== "paragraph-t" || !CONTEXT_MENU_HEADER_QUICK_GROUP_KEYS.has(menuSchema.key)) return getContextMenuGroupClassName(sizeVariant);
|
|
@@ -4508,7 +4573,7 @@ function getFirstMenuButtonByVisualOrder(buttons) {
|
|
|
4508
4573
|
})[0];
|
|
4509
4574
|
}
|
|
4510
4575
|
function getNextMenuButtonByDirection(buttons, activeIndex, key) {
|
|
4511
|
-
var _scoredCandidates
|
|
4576
|
+
var _scoredCandidates$;
|
|
4512
4577
|
const direction = key === "ArrowDown" || key === "ArrowRight" ? 1 : -1;
|
|
4513
4578
|
const fallbackButton = buttons[activeIndex < 0 ? direction > 0 ? 0 : buttons.length - 1 : (activeIndex + direction + buttons.length) % buttons.length];
|
|
4514
4579
|
const activeButton = activeIndex >= 0 ? buttons[activeIndex] : null;
|
|
@@ -4516,20 +4581,16 @@ function getNextMenuButtonByDirection(buttons, activeIndex, key) {
|
|
|
4516
4581
|
const rows = getMenuButtonRows(buttons);
|
|
4517
4582
|
const activeRowIndex = rows.findIndex((row) => row.includes(activeButton));
|
|
4518
4583
|
const activeRow = rows[activeRowIndex];
|
|
4519
|
-
if (activeRow && (key === "ArrowRight" || key === "ArrowLeft"))
|
|
4520
|
-
const nextRowButton = activeRow[activeRow.indexOf(activeButton) + (key === "ArrowRight" ? 1 : -1)];
|
|
4521
|
-
return nextRowButton !== null && nextRowButton !== void 0 ? nextRowButton : fallbackButton;
|
|
4522
|
-
}
|
|
4584
|
+
if (activeRow && (key === "ArrowRight" || key === "ArrowLeft")) return activeRow[activeRow.indexOf(activeButton) + (key === "ArrowRight" ? 1 : -1)] ?? fallbackButton;
|
|
4523
4585
|
if (activeRow && (key === "ArrowDown" || key === "ArrowUp")) {
|
|
4524
4586
|
const nextRow = rows[activeRowIndex + (key === "ArrowDown" ? 1 : -1)];
|
|
4525
4587
|
if (nextRow) {
|
|
4526
|
-
var _sort$;
|
|
4527
4588
|
const activeCenter = getMenuButtonCenter(activeButton);
|
|
4528
|
-
return
|
|
4589
|
+
return [...nextRow].sort((left, right) => Math.abs(getMenuButtonCenter(left).x - activeCenter.x) - Math.abs(getMenuButtonCenter(right).x - activeCenter.x))[0] ?? fallbackButton;
|
|
4529
4590
|
}
|
|
4530
4591
|
}
|
|
4531
4592
|
const activeCenter = getMenuButtonCenter(activeButton);
|
|
4532
|
-
return (
|
|
4593
|
+
return ((_scoredCandidates$ = buttons.filter((button) => button !== activeButton).map((button) => {
|
|
4533
4594
|
const center = getMenuButtonCenter(button);
|
|
4534
4595
|
const deltaX = center.x - activeCenter.x;
|
|
4535
4596
|
const deltaY = center.y - activeCenter.y;
|
|
@@ -4540,14 +4601,14 @@ function getNextMenuButtonByDirection(buttons, activeIndex, key) {
|
|
|
4540
4601
|
button,
|
|
4541
4602
|
score: primaryDistance * 1e3 + secondaryDistance
|
|
4542
4603
|
};
|
|
4543
|
-
}).filter((candidate) => candidate != null).sort((left, right) => left.score - right.score)[0]) === null || _scoredCandidates$ === void 0 ? void 0 : _scoredCandidates$.button)
|
|
4604
|
+
}).filter((candidate) => candidate != null).sort((left, right) => left.score - right.score)[0]) === null || _scoredCandidates$ === void 0 ? void 0 : _scoredCandidates$.button) ?? fallbackButton;
|
|
4544
4605
|
}
|
|
4545
|
-
function getContextMenuSchemaRenderGroups(visibleSchemas,
|
|
4606
|
+
function getContextMenuSchemaRenderGroups(visibleSchemas, flowQuickGroups = false) {
|
|
4546
4607
|
const renderGroups = [];
|
|
4547
4608
|
for (let index = 0; index < visibleSchemas.length; index++) {
|
|
4548
4609
|
const menuSchema = visibleSchemas[index];
|
|
4549
4610
|
const nextSchema = visibleSchemas[index + 1];
|
|
4550
|
-
if (
|
|
4611
|
+
if (flowQuickGroups && shouldClusterHeaderQuickGroups(menuSchema, nextSchema)) {
|
|
4551
4612
|
renderGroups.push({
|
|
4552
4613
|
startIndex: index,
|
|
4553
4614
|
endIndex: index + 1,
|
|
@@ -4564,6 +4625,15 @@ function getContextMenuSchemaRenderGroups(visibleSchemas, sizeVariant) {
|
|
|
4564
4625
|
}
|
|
4565
4626
|
return renderGroups;
|
|
4566
4627
|
}
|
|
4628
|
+
function mergeContextMenuQuickGroupSchemas(menuSchemas) {
|
|
4629
|
+
const firstSchema = menuSchemas[0];
|
|
4630
|
+
return {
|
|
4631
|
+
...firstSchema,
|
|
4632
|
+
key: menuSchemas.map((schema) => schema.key).join("-"),
|
|
4633
|
+
quickColumns: getContextMenuQuickGroupColumns(firstSchema),
|
|
4634
|
+
children: menuSchemas.flatMap((schema) => schema.children ?? [])
|
|
4635
|
+
};
|
|
4636
|
+
}
|
|
4567
4637
|
function getContextMenuHeaderClassName(sizeVariant) {
|
|
4568
4638
|
return contextMenuHeaderVariants({ sizeVariant });
|
|
4569
4639
|
}
|
|
@@ -4574,12 +4644,12 @@ function getContextMenuSubmenuPanelClassName(sizeVariant) {
|
|
|
4574
4644
|
return contextMenuSubmenuPanelVariants({ sizeVariant });
|
|
4575
4645
|
}
|
|
4576
4646
|
function ContextMenuPanel(props) {
|
|
4577
|
-
var _layoutService$rootCo
|
|
4578
|
-
const { menuType, menuManagerService: providedMenuManagerService, layoutService: providedLayoutService, menuSessionVersion = 0, className, activeItemIds, hiddenItemIds, sizeVariant = "default", autoFocus, autoFocusTarget = "first-item", suppressHoverUntilPointerMove = false, onCancel, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
|
|
4647
|
+
var _layoutService$rootCo;
|
|
4648
|
+
const { menuType, menuManagerService: providedMenuManagerService, layoutService: providedLayoutService, menuSessionVersion = 0, className, activeItemIds, hiddenItemIds, flowQuickGroups, sizeVariant = "default", autoFocus, autoFocusTarget = "first-item", suppressHoverUntilPointerMove = false, onCancel, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
|
|
4579
4649
|
const rootMenuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
|
|
4580
4650
|
const rootLayoutService = (0, _wendellhu_redi_react_bindings.useDependency)(ILayoutService);
|
|
4581
|
-
const menuManagerService = providedMenuManagerService
|
|
4582
|
-
const layoutService = providedLayoutService
|
|
4651
|
+
const menuManagerService = providedMenuManagerService ?? rootMenuManagerService;
|
|
4652
|
+
const layoutService = providedLayoutService ?? rootLayoutService;
|
|
4583
4653
|
const [menuElement, setMenuElement] = (0, react.useState)(null);
|
|
4584
4654
|
const [maxMenuHeight, setMaxMenuHeight] = (0, react.useState)(() => {
|
|
4585
4655
|
if (typeof window === "undefined") return 240;
|
|
@@ -4592,23 +4662,21 @@ function ContextMenuPanel(props) {
|
|
|
4592
4662
|
(0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => menuManagerService.menuChanged$.pipe((0, rxjs.startWith)(void 0), (0, rxjs.scan)((version) => version + 1, 0)), [menuManagerService]), 0),
|
|
4593
4663
|
menuSessionVersion
|
|
4594
4664
|
]);
|
|
4595
|
-
const submenuPortalContainer = (_layoutService$rootCo =
|
|
4665
|
+
const submenuPortalContainer = ((_layoutService$rootCo = layoutService.rootContainerElement) === null || _layoutService$rootCo === void 0 || (_layoutService$rootCo = _layoutService$rootCo.ownerDocument) === null || _layoutService$rootCo === void 0 ? void 0 : _layoutService$rootCo.body) ?? (typeof document !== "undefined" ? document.body : null);
|
|
4596
4666
|
useScrollYOverContainer(menuElement, layoutService.rootContainerElement);
|
|
4597
4667
|
const getFocusableMenuButtons = (0, react.useCallback)(() => {
|
|
4598
4668
|
if (!menuElement) return [];
|
|
4599
4669
|
return Array.from(menuElement.querySelectorAll("button:not(:disabled)"));
|
|
4600
4670
|
}, [menuElement]);
|
|
4601
4671
|
(0, react.useEffect)(() => {
|
|
4602
|
-
var _menuElement$ownerDoc;
|
|
4603
4672
|
if (!autoFocus || !menuElement) return;
|
|
4604
|
-
const view =
|
|
4673
|
+
const view = menuElement.ownerDocument.defaultView ?? window;
|
|
4605
4674
|
const frameId = view.requestAnimationFrame(() => {
|
|
4606
4675
|
if (autoFocusTarget === "container") {
|
|
4607
4676
|
menuElement.focus();
|
|
4608
4677
|
return;
|
|
4609
4678
|
}
|
|
4610
|
-
|
|
4611
|
-
(firstButton !== null && firstButton !== void 0 ? firstButton : menuElement).focus();
|
|
4679
|
+
(getFirstMenuButtonByVisualOrder(getFocusableMenuButtons()) ?? menuElement).focus();
|
|
4612
4680
|
});
|
|
4613
4681
|
return () => view.cancelAnimationFrame(frameId);
|
|
4614
4682
|
}, [
|
|
@@ -4652,8 +4720,8 @@ function ContextMenuPanel(props) {
|
|
|
4652
4720
|
onCancel
|
|
4653
4721
|
]);
|
|
4654
4722
|
(0, react.useEffect)(() => {
|
|
4655
|
-
var _layoutService$
|
|
4656
|
-
const defaultView = (
|
|
4723
|
+
var _layoutService$rootCo2;
|
|
4724
|
+
const defaultView = ((_layoutService$rootCo2 = layoutService.rootContainerElement) === null || _layoutService$rootCo2 === void 0 || (_layoutService$rootCo2 = _layoutService$rootCo2.ownerDocument) === null || _layoutService$rootCo2 === void 0 ? void 0 : _layoutService$rootCo2.defaultView) ?? (typeof window !== "undefined" ? window : null);
|
|
4657
4725
|
if (!defaultView) return;
|
|
4658
4726
|
let frameId = 0;
|
|
4659
4727
|
const updateMaxHeight = () => {
|
|
@@ -4688,6 +4756,7 @@ function ContextMenuPanel(props) {
|
|
|
4688
4756
|
rootMenuElement: menuElement,
|
|
4689
4757
|
activeItemIds,
|
|
4690
4758
|
hiddenItemIds,
|
|
4759
|
+
flowQuickGroups,
|
|
4691
4760
|
hoverSuppressed,
|
|
4692
4761
|
sizeVariant,
|
|
4693
4762
|
onMenuPointerEnter,
|
|
@@ -4698,7 +4767,7 @@ function ContextMenuPanel(props) {
|
|
|
4698
4767
|
});
|
|
4699
4768
|
}
|
|
4700
4769
|
function ContextMenuMenu(props) {
|
|
4701
|
-
const { menuSchemas, menuManagerService, menuSessionVersion, submenuPortalContainer, rootMenuElement, activeItemIds, hiddenItemIds, hoverSuppressed, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect, maxMenuHeight } = props;
|
|
4770
|
+
const { menuSchemas, menuManagerService, menuSessionVersion, submenuPortalContainer, rootMenuElement, activeItemIds, hiddenItemIds, flowQuickGroups, hoverSuppressed, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect, maxMenuHeight } = props;
|
|
4702
4771
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
4703
4772
|
const hiddenGroupStates = useContextGroupHiddenStates$1(menuSchemas);
|
|
4704
4773
|
const [activeSubmenuKey, setActiveSubmenuKey] = (0, react.useState)(null);
|
|
@@ -4709,7 +4778,7 @@ function ContextMenuMenu(props) {
|
|
|
4709
4778
|
return !hiddenGroupStates[item.key];
|
|
4710
4779
|
});
|
|
4711
4780
|
}, [hiddenGroupStates, menuSchemas]);
|
|
4712
|
-
const renderGroups = (0, react.useMemo)(() => getContextMenuSchemaRenderGroups(visibleSchemas,
|
|
4781
|
+
const renderGroups = (0, react.useMemo)(() => getContextMenuSchemaRenderGroups(visibleSchemas, flowQuickGroups), [flowQuickGroups, visibleSchemas]);
|
|
4713
4782
|
const renderQuickLayoutGroup = (menuSchema, index, renderAsClusterChild = false, hasSeparator = false) => {
|
|
4714
4783
|
const titleNode = renderMenuSchemaHeader(menuSchema);
|
|
4715
4784
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -4737,10 +4806,13 @@ function ContextMenuMenu(props) {
|
|
|
4737
4806
|
const menuSchema = groupedSchemas[0];
|
|
4738
4807
|
const hasSeparator = shouldShowContextMenuGroupSeparator(visibleSchemas, endIndex);
|
|
4739
4808
|
const titleNode = renderMenuSchemaHeader(menuSchema);
|
|
4740
|
-
if (groupedSchemas.length > 1)
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4809
|
+
if (groupedSchemas.length > 1) {
|
|
4810
|
+
const mergedMenuSchema = mergeContextMenuQuickGroupSchemas(groupedSchemas);
|
|
4811
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4812
|
+
className: (0, _univerjs_design.clsx)(getContextMenuQuickGroupClusterClassName(sizeVariant), hasSeparator && _univerjs_design.borderBottomClassName),
|
|
4813
|
+
children: renderQuickLayoutGroup(mergedMenuSchema, startIndex, true)
|
|
4814
|
+
}, groupedSchemas.map((schema) => schema.key).join("-"));
|
|
4815
|
+
}
|
|
4744
4816
|
if (menuSchema.item) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextMenuMenuItem, {
|
|
4745
4817
|
menuKey: menuSchema.key,
|
|
4746
4818
|
menuItem: menuSchema.item,
|
|
@@ -4925,9 +4997,10 @@ function ContextMenuMenuItem(props) {
|
|
|
4925
4997
|
const left = useLeft ? leftLeft : rightLeft;
|
|
4926
4998
|
setSubmenuPlacement(useLeft ? "left" : "right");
|
|
4927
4999
|
const maxTop = window.innerHeight - menuViewportPadding - submenuRect.height;
|
|
5000
|
+
const top = maxTop < menuViewportPadding ? menuViewportPadding : Math.min(Math.max(menuItemRect.top, menuViewportPadding), maxTop);
|
|
4928
5001
|
setSubmenuPosition({
|
|
4929
5002
|
left,
|
|
4930
|
-
top
|
|
5003
|
+
top
|
|
4931
5004
|
});
|
|
4932
5005
|
setSubmenuPositionReady(true);
|
|
4933
5006
|
};
|
|
@@ -4948,7 +5021,8 @@ function ContextMenuMenuItem(props) {
|
|
|
4948
5021
|
const hiddenById = menuItem.id != null && hiddenItemIds.includes(menuItem.id) || hiddenItemIds.includes(menuKey);
|
|
4949
5022
|
if (hidden || hiddenById) return null;
|
|
4950
5023
|
const onChange = (v) => {
|
|
4951
|
-
|
|
5024
|
+
const newValue = (0, _univerjs_core.isRealNum)(v) && typeof v === "string" ? Number.parseInt(v) : v;
|
|
5025
|
+
setInputValue(newValue);
|
|
4952
5026
|
};
|
|
4953
5027
|
const onSubmenuOptionSelect = (option) => {
|
|
4954
5028
|
onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect(option);
|
|
@@ -5088,8 +5162,7 @@ function ContextMenuMenuItem(props) {
|
|
|
5088
5162
|
children: [hasSelectionSubmenu && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5089
5163
|
className: sizeVariant === "paragraph-t" ? "univer-grid univer-gap-2" : "univer-grid univer-gap-1",
|
|
5090
5164
|
children: selections.map((option, index) => {
|
|
5091
|
-
|
|
5092
|
-
const optionKey = `${menuItem.id}-${(_option$label = option.label) !== null && _option$label !== void 0 ? _option$label : option.id}-${index}`;
|
|
5165
|
+
const optionKey = `${menuItem.id}-${option.label ?? option.id}-${index}`;
|
|
5093
5166
|
const optionSelected = typeof inputValue !== "undefined" && String(inputValue) === String(option.value);
|
|
5094
5167
|
const optionSelectable = !isNonSelectableLabel(option.label);
|
|
5095
5168
|
const optionHoverable = !isNonHoverableLabel(option.label);
|
|
@@ -5102,13 +5175,12 @@ function ContextMenuMenuItem(props) {
|
|
|
5102
5175
|
label: option.label,
|
|
5103
5176
|
icon: option.icon,
|
|
5104
5177
|
onChange: (optionValue) => {
|
|
5105
|
-
var _option$commandId;
|
|
5106
5178
|
onSubmenuOptionSelect === null || onSubmenuOptionSelect === void 0 || onSubmenuOptionSelect({
|
|
5107
5179
|
...option,
|
|
5108
5180
|
value: optionValue,
|
|
5109
5181
|
id: menuItem.id,
|
|
5110
5182
|
label: menuKey,
|
|
5111
|
-
commandId:
|
|
5183
|
+
commandId: option.commandId ?? selectionsCommandId
|
|
5112
5184
|
});
|
|
5113
5185
|
}
|
|
5114
5186
|
})
|
|
@@ -5118,12 +5190,11 @@ function ContextMenuMenuItem(props) {
|
|
|
5118
5190
|
className: optionClassName,
|
|
5119
5191
|
disabled: option.disabled,
|
|
5120
5192
|
onClick: () => {
|
|
5121
|
-
var _option$commandId2;
|
|
5122
5193
|
onSubmenuOptionSelect === null || onSubmenuOptionSelect === void 0 || onSubmenuOptionSelect({
|
|
5123
5194
|
...option,
|
|
5124
5195
|
id: menuItem.id,
|
|
5125
5196
|
label: menuKey,
|
|
5126
|
-
commandId:
|
|
5197
|
+
commandId: option.commandId ?? selectionsCommandId
|
|
5127
5198
|
});
|
|
5128
5199
|
},
|
|
5129
5200
|
children: optionContentNode
|
|
@@ -5155,11 +5226,11 @@ function ContextMenuMenuItem(props) {
|
|
|
5155
5226
|
function useContextGroupHiddenStates$1(menuSchemas) {
|
|
5156
5227
|
return (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => {
|
|
5157
5228
|
const groupStates = menuSchemas.flatMap((menuSchema) => {
|
|
5158
|
-
var _menuSchema$
|
|
5159
|
-
const hiddenObservables = (
|
|
5160
|
-
var _childSchema$item
|
|
5161
|
-
return (
|
|
5162
|
-
}))
|
|
5229
|
+
var _menuSchema$children3;
|
|
5230
|
+
const hiddenObservables = ((_menuSchema$children3 = menuSchema.children) === null || _menuSchema$children3 === void 0 ? void 0 : _menuSchema$children3.map((childSchema) => {
|
|
5231
|
+
var _childSchema$item;
|
|
5232
|
+
return ((_childSchema$item = childSchema.item) === null || _childSchema$item === void 0 ? void 0 : _childSchema$item.hidden$) ?? (0, rxjs.of)(false);
|
|
5233
|
+
})) ?? [];
|
|
5163
5234
|
return hiddenObservables.length ? [(0, rxjs.combineLatest)(hiddenObservables).pipe((0, rxjs.map)((values) => [menuSchema.key, values.every(Boolean)]))] : [];
|
|
5164
5235
|
});
|
|
5165
5236
|
return groupStates.length ? (0, rxjs.merge)(...groupStates).pipe((0, rxjs.scan)((states, [key, hidden]) => ({
|
|
@@ -5332,7 +5403,7 @@ function DesktopContextMenu() {
|
|
|
5332
5403
|
const { label: id, commandId, value } = params;
|
|
5333
5404
|
const rawParams = typeof params.params === "function" ? params.params() : params.params;
|
|
5334
5405
|
const commandParams = typeof rawParams === "undefined" ? { value } : rawParams;
|
|
5335
|
-
if (activeCommandService) activeCommandService.executeCommand(commandId
|
|
5406
|
+
if (activeCommandService) activeCommandService.executeCommand(commandId ?? id, commandParams);
|
|
5336
5407
|
activeLayoutService.focus();
|
|
5337
5408
|
handleClose();
|
|
5338
5409
|
}
|
|
@@ -5496,7 +5567,7 @@ function Sidebar() {
|
|
|
5496
5567
|
})]
|
|
5497
5568
|
}),
|
|
5498
5569
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
5499
|
-
className: "univer-box-border univer-cursor-default univer-px-4",
|
|
5570
|
+
className: "univer-box-border univer-min-w-0 univer-cursor-default univer-px-4",
|
|
5500
5571
|
children: options === null || options === void 0 ? void 0 : options.children
|
|
5501
5572
|
}),
|
|
5502
5573
|
(options === null || options === void 0 ? void 0 : options.footer) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("footer", {
|
|
@@ -5508,6 +5579,95 @@ function Sidebar() {
|
|
|
5508
5579
|
});
|
|
5509
5580
|
}
|
|
5510
5581
|
|
|
5582
|
+
//#endregion
|
|
5583
|
+
//#region src/views/components/workbench-skeleton/WorkbenchSkeleton.tsx
|
|
5584
|
+
function WorkbenchSkeleton({ darkMode, direction, overlay = false }) {
|
|
5585
|
+
const shimmerClassName = `
|
|
5586
|
+
univer-animate-pulse univer-bg-gray-100 motion-reduce:univer-animate-none
|
|
5587
|
+
dark:!univer-bg-gray-700
|
|
5588
|
+
`;
|
|
5589
|
+
const shimmerStyle = { animationDuration: "1.2s" };
|
|
5590
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
5591
|
+
"aria-busy": "true",
|
|
5592
|
+
className: (0, _univerjs_design.clsx)("univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-overflow-hidden univer-bg-gray-50 dark:!univer-bg-gray-900", {
|
|
5593
|
+
"univer-absolute univer-inset-0 univer-z-50": overlay,
|
|
5594
|
+
"univer-dark": darkMode
|
|
5595
|
+
}),
|
|
5596
|
+
dir: direction,
|
|
5597
|
+
children: [
|
|
5598
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
5599
|
+
"data-u-comp": "workbench-skeleton-toolbar",
|
|
5600
|
+
className: "univer-flex univer-h-11 univer-shrink-0 univer-items-center univer-gap-2 univer-border-0 univer-border-b univer-border-solid univer-border-gray-200 univer-bg-white univer-px-4 dark:!univer-border-gray-700 dark:!univer-bg-gray-800",
|
|
5601
|
+
children: [
|
|
5602
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5603
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5604
|
+
className: (0, _univerjs_design.clsx)(shimmerClassName, "univer-h-4 univer-w-24 univer-rounded"),
|
|
5605
|
+
style: shimmerStyle
|
|
5606
|
+
}),
|
|
5607
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5608
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5609
|
+
className: (0, _univerjs_design.clsx)(shimmerClassName, "univer-ml-2 univer-size-6 univer-rounded"),
|
|
5610
|
+
style: shimmerStyle
|
|
5611
|
+
}),
|
|
5612
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5613
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5614
|
+
className: (0, _univerjs_design.clsx)(shimmerClassName, "univer-size-6 univer-rounded"),
|
|
5615
|
+
style: shimmerStyle
|
|
5616
|
+
})
|
|
5617
|
+
]
|
|
5618
|
+
}),
|
|
5619
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("main", {
|
|
5620
|
+
"data-u-comp": "workbench-skeleton-content",
|
|
5621
|
+
className: "univer-flex univer-min-h-0 univer-min-w-0 univer-flex-1 univer-flex-col univer-gap-4 univer-p-4",
|
|
5622
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5623
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5624
|
+
className: (0, _univerjs_design.clsx)(shimmerClassName, "univer-h-4 univer-w-1/3 univer-rounded"),
|
|
5625
|
+
style: shimmerStyle
|
|
5626
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5627
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5628
|
+
className: (0, _univerjs_design.clsx)(shimmerClassName, "univer-flex-1 univer-rounded-md"),
|
|
5629
|
+
style: shimmerStyle
|
|
5630
|
+
})]
|
|
5631
|
+
}),
|
|
5632
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("footer", {
|
|
5633
|
+
"data-u-comp": "workbench-skeleton-footer",
|
|
5634
|
+
className: "univer-flex univer-h-10 univer-shrink-0 univer-items-center univer-justify-between univer-border-0 univer-border-t univer-border-solid univer-border-gray-200 univer-bg-white univer-px-4 dark:!univer-border-gray-700 dark:!univer-bg-gray-800",
|
|
5635
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
5636
|
+
className: "univer-flex univer-items-center univer-gap-2",
|
|
5637
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5638
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5639
|
+
className: (0, _univerjs_design.clsx)(shimmerClassName, "univer-size-5 univer-rounded"),
|
|
5640
|
+
style: shimmerStyle
|
|
5641
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5642
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5643
|
+
className: (0, _univerjs_design.clsx)(shimmerClassName, "univer-h-5 univer-w-14 univer-rounded"),
|
|
5644
|
+
style: shimmerStyle
|
|
5645
|
+
})]
|
|
5646
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
5647
|
+
className: "univer-flex univer-items-center univer-gap-2",
|
|
5648
|
+
children: [
|
|
5649
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5650
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5651
|
+
className: (0, _univerjs_design.clsx)(shimmerClassName, "univer-size-5 univer-rounded"),
|
|
5652
|
+
style: shimmerStyle
|
|
5653
|
+
}),
|
|
5654
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5655
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5656
|
+
className: (0, _univerjs_design.clsx)(shimmerClassName, "univer-h-2 univer-w-24 univer-rounded-full"),
|
|
5657
|
+
style: shimmerStyle
|
|
5658
|
+
}),
|
|
5659
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5660
|
+
"data-u-comp": "workbench-skeleton-shimmer",
|
|
5661
|
+
className: (0, _univerjs_design.clsx)(shimmerClassName, "univer-size-5 univer-rounded"),
|
|
5662
|
+
style: shimmerStyle
|
|
5663
|
+
})
|
|
5664
|
+
]
|
|
5665
|
+
})]
|
|
5666
|
+
})
|
|
5667
|
+
]
|
|
5668
|
+
});
|
|
5669
|
+
}
|
|
5670
|
+
|
|
5511
5671
|
//#endregion
|
|
5512
5672
|
//#region src/views/hooks/update-effect.ts
|
|
5513
5673
|
/**
|
|
@@ -5711,9 +5871,10 @@ function mountDesktopWorkbench(injector, options, mountContainer, onRendered) {
|
|
|
5711
5871
|
}), mountContainer);
|
|
5712
5872
|
}
|
|
5713
5873
|
function DesktopWorkbenchContent(props) {
|
|
5714
|
-
var _uiConfig$popupRootId;
|
|
5715
5874
|
const { header = true, toolbar = true, footer = true, headerMenu = true, contextMenu = true, ribbonType = "classic", mountContainer, onRendered } = props;
|
|
5716
5875
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
5876
|
+
const lifecycleService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LifecycleService);
|
|
5877
|
+
const workbenchService = (0, _wendellhu_redi_react_bindings.useDependency)(IWorkbenchService);
|
|
5717
5878
|
const themeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ThemeService);
|
|
5718
5879
|
const themeSwitcherService = (0, _wendellhu_redi_react_bindings.useDependency)(ThemeSwitcherService);
|
|
5719
5880
|
const contentRef = (0, react.useRef)(null);
|
|
@@ -5726,7 +5887,10 @@ function DesktopWorkbenchContent(props) {
|
|
|
5726
5887
|
const leftSidebarComponents = useComponentsOfPart("left-sidebar");
|
|
5727
5888
|
const globalComponents = useComponentsOfPart("global");
|
|
5728
5889
|
const toolbarComponents = useComponentsOfPart("toolbar");
|
|
5729
|
-
const
|
|
5890
|
+
const lifecycleStage = (0, _wendellhu_redi_react_bindings.useObservable)(lifecycleService.lifecycle$, lifecycleService.stage);
|
|
5891
|
+
const externalSkeletonVisible = (0, _wendellhu_redi_react_bindings.useObservable)(workbenchService.skeletonVisible$, void 0, true);
|
|
5892
|
+
const ready = lifecycleStage >= _univerjs_core.LifecycleStages.Ready;
|
|
5893
|
+
const popupRootId = (uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.popupRootId) ?? "univer-popup-portal";
|
|
5730
5894
|
(0, react.useLayoutEffect)(() => {
|
|
5731
5895
|
const sub = themeService.currentTheme$.subscribe((theme) => {
|
|
5732
5896
|
themeSwitcherService.injectThemeToHead(theme);
|
|
@@ -5741,8 +5905,8 @@ function DesktopWorkbenchContent(props) {
|
|
|
5741
5905
|
else document.documentElement.classList.remove("univer-dark");
|
|
5742
5906
|
}, [darkMode]);
|
|
5743
5907
|
(0, react.useEffect)(() => {
|
|
5744
|
-
if (contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
|
|
5745
|
-
}, [onRendered]);
|
|
5908
|
+
if (ready && contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
|
|
5909
|
+
}, [ready, onRendered]);
|
|
5746
5910
|
const locale = (0, _wendellhu_redi_react_bindings.useObservable)(() => localeService.localeChanged$.pipe((0, rxjs.map)(() => localeService.getLocales())), localeService.getLocales(), false, [localeService]);
|
|
5747
5911
|
const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$, localeService.getDirection());
|
|
5748
5912
|
const portalContainer = (0, react.useMemo)(() => document.createElement("div"), []);
|
|
@@ -5760,61 +5924,68 @@ function DesktopWorkbenchContent(props) {
|
|
|
5760
5924
|
direction,
|
|
5761
5925
|
mountContainer: portalContainer,
|
|
5762
5926
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
5763
|
-
"
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
className: "univer-
|
|
5790
|
-
children: [
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
className: "univer-relative univer-overflow-hidden dark:!univer-bg-gray-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5927
|
+
className: "univer-relative univer-h-full univer-min-h-0",
|
|
5928
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
5929
|
+
"data-u-comp": "workbench-layout",
|
|
5930
|
+
className: (0, _univerjs_design.clsx)("univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800", { "univer-dark": darkMode }),
|
|
5931
|
+
tabIndex: -1,
|
|
5932
|
+
onBlur: (e) => e.stopPropagation(),
|
|
5933
|
+
onContextMenu: (e) => e.preventDefault(),
|
|
5934
|
+
dir: direction,
|
|
5935
|
+
children: [
|
|
5936
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5937
|
+
className: "univer-relative univer-flex univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800",
|
|
5938
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, { components: customHeaderComponents }, "custom-header")
|
|
5939
|
+
}),
|
|
5940
|
+
header && toolbar && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
|
|
5941
|
+
"data-u-comp": "headerbar",
|
|
5942
|
+
className: "univer-relative univer-z-10 univer-w-full univer-overflow-hidden",
|
|
5943
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, {
|
|
5944
|
+
components: toolbarComponents,
|
|
5945
|
+
sharedProps: {
|
|
5946
|
+
ribbonType,
|
|
5947
|
+
headerMenuComponents,
|
|
5948
|
+
headerMenu
|
|
5949
|
+
}
|
|
5950
|
+
}, "toolbar")
|
|
5951
|
+
}),
|
|
5952
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
5953
|
+
className: "univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col",
|
|
5954
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
5955
|
+
className: "univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden",
|
|
5956
|
+
children: [
|
|
5957
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("aside", {
|
|
5958
|
+
"data-u-comp": "left-sidebar",
|
|
5959
|
+
className: "univer-h-full",
|
|
5960
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, { components: leftSidebarComponents }, "left-sidebar")
|
|
5961
|
+
}),
|
|
5962
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
5963
|
+
className: (0, _univerjs_design.clsx)("univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white dark:!univer-bg-gray-800", _univerjs_design.borderBottomClassName),
|
|
5964
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", { children: header && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, { components: headerComponents }, "header") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
5965
|
+
className: "univer-relative univer-overflow-hidden dark:!univer-bg-gray-900",
|
|
5966
|
+
ref: contentRef,
|
|
5967
|
+
"data-range-selector": true,
|
|
5968
|
+
onContextMenu: (e) => e.preventDefault(),
|
|
5969
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, { components: contentComponents }, "content")
|
|
5970
|
+
})]
|
|
5971
|
+
}),
|
|
5972
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("aside", {
|
|
5973
|
+
"data-u-comp": "right-sidebar",
|
|
5974
|
+
className: "univer-z-[100] univer-h-full",
|
|
5975
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Sidebar, {})
|
|
5976
|
+
})
|
|
5977
|
+
]
|
|
5978
|
+
}), footer && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("footer", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, {
|
|
5979
|
+
components: footerComponents,
|
|
5980
|
+
sharedProps: { contextMenu }
|
|
5981
|
+
}, "footer") })]
|
|
5982
|
+
})
|
|
5983
|
+
]
|
|
5984
|
+
}), (!ready || externalSkeletonVisible) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkbenchSkeleton, {
|
|
5985
|
+
darkMode,
|
|
5986
|
+
direction,
|
|
5987
|
+
overlay: true
|
|
5988
|
+
})]
|
|
5818
5989
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
5819
5990
|
dir: direction,
|
|
5820
5991
|
children: [
|
|
@@ -5859,6 +6030,9 @@ var SingleUnitUIController = class extends _univerjs_core.Disposable {
|
|
|
5859
6030
|
delete this._renderManagerService;
|
|
5860
6031
|
}
|
|
5861
6032
|
_bootstrapWorkbench() {
|
|
6033
|
+
var _this$_injector$get;
|
|
6034
|
+
const initialSkeleton = (_this$_injector$get = this._injector.get(IWorkbenchService, _univerjs_core.Quantity.OPTIONAL)) === null || _this$_injector$get === void 0 ? void 0 : _this$_injector$get.acquireSkeleton();
|
|
6035
|
+
if (initialSkeleton) this.disposeWithMe(initialSkeleton);
|
|
5862
6036
|
this.disposeWithMe(this.bootstrap(async (contentElement, containerElement) => {
|
|
5863
6037
|
if (this._layoutService) {
|
|
5864
6038
|
this.disposeWithMe(this._layoutService.registerRootContainerElement(containerElement));
|
|
@@ -5869,6 +6043,7 @@ var SingleUnitUIController = class extends _univerjs_core.Disposable {
|
|
|
5869
6043
|
this._renderTimeout = window.setTimeout(() => {
|
|
5870
6044
|
const allRenders = this._renderManagerService.getRenderAll();
|
|
5871
6045
|
for (const [key] of allRenders) if (this._changeRenderUnit(key, contentElement)) break;
|
|
6046
|
+
requestAnimationFrame(() => requestAnimationFrame(() => initialSkeleton === null || initialSkeleton === void 0 ? void 0 : initialSkeleton.dispose()));
|
|
5872
6047
|
this.disposeWithMe(this._instanceService.focused$.subscribe((unit) => {
|
|
5873
6048
|
if (unit) this._changeRenderUnit(unit, contentElement);
|
|
5874
6049
|
}));
|
|
@@ -5896,9 +6071,9 @@ var SingleUnitUIController = class extends _univerjs_core.Disposable {
|
|
|
5896
6071
|
var _this$_instanceServic2;
|
|
5897
6072
|
if (this._currentRenderId === rendererId) return false;
|
|
5898
6073
|
if ((_this$_instanceServic2 = this._instanceService.getUnitCreateOptions(rendererId)) === null || _this$_instanceServic2 === void 0 ? void 0 : _this$_instanceServic2.embeddedRender) return false;
|
|
5899
|
-
const renderer = this._renderManagerService.
|
|
6074
|
+
const renderer = this._renderManagerService.getRenderUnitById(rendererId);
|
|
5900
6075
|
if (!renderer || !renderer.unitId || (0, _univerjs_core.isInternalEditorID)(renderer.unitId)) return false;
|
|
5901
|
-
const currentRenderer = this._currentRenderId ? this._renderManagerService.
|
|
6076
|
+
const currentRenderer = this._currentRenderId ? this._renderManagerService.getRenderUnitById(this._currentRenderId) : null;
|
|
5902
6077
|
currentRenderer === null || currentRenderer === void 0 || currentRenderer.deactivate();
|
|
5903
6078
|
currentRenderer === null || currentRenderer === void 0 || currentRenderer.engine.unmount();
|
|
5904
6079
|
renderer.engine.mount(contentElement);
|
|
@@ -5970,7 +6145,7 @@ const IUIController = (0, _univerjs_core.createIdentifier)("univer.ui.ui-control
|
|
|
5970
6145
|
//#endregion
|
|
5971
6146
|
//#region package.json
|
|
5972
6147
|
var name = "@univerjs/ui";
|
|
5973
|
-
var version = "1.0.0-
|
|
6148
|
+
var version = "1.0.0-beta.0";
|
|
5974
6149
|
|
|
5975
6150
|
//#endregion
|
|
5976
6151
|
//#region src/views/color-picker/interface.ts
|
|
@@ -6014,9 +6189,9 @@ const CommonLabel = (props) => {
|
|
|
6014
6189
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6015
6190
|
className: "univer-truncate univer-text-sm",
|
|
6016
6191
|
children: (0, react.useMemo)(() => {
|
|
6017
|
-
var _selections$find
|
|
6192
|
+
var _selections$find;
|
|
6018
6193
|
if (value == null) return "";
|
|
6019
|
-
return localeService.t((
|
|
6194
|
+
return localeService.t(((_selections$find = selections.find((item) => item.value === value)) === null || _selections$find === void 0 ? void 0 : _selections$find.label) ?? "");
|
|
6020
6195
|
}, [value, selections])
|
|
6021
6196
|
});
|
|
6022
6197
|
};
|
|
@@ -6052,10 +6227,9 @@ function ShortcutPanel() {
|
|
|
6052
6227
|
const shortcuts = shortcutService.getAllShortcuts().filter((item) => !!item.group);
|
|
6053
6228
|
const groupTitles = /* @__PURE__ */ new Map();
|
|
6054
6229
|
for (const shortcut of shortcuts) {
|
|
6055
|
-
var _shortcut$description;
|
|
6056
6230
|
const group = shortcut.group;
|
|
6057
6231
|
const shortcutItem = {
|
|
6058
|
-
title: localeService.t(
|
|
6232
|
+
title: localeService.t(shortcut.description ?? shortcut.id),
|
|
6059
6233
|
shortcut: shortcutService.getShortcutDisplay(shortcut)
|
|
6060
6234
|
};
|
|
6061
6235
|
if (!/^\d+_/.test(group)) throw new Error(`[ShortcutPanel]: Invalid shortcut group: ${group}!`);
|
|
@@ -6064,7 +6238,7 @@ function ShortcutPanel() {
|
|
|
6064
6238
|
if (!shortcutGroups.has(group)) shortcutGroups.set(group, []);
|
|
6065
6239
|
shortcutGroups.get(group).push(shortcutItem);
|
|
6066
6240
|
}
|
|
6067
|
-
|
|
6241
|
+
const toRender = Array.from(shortcutGroups.entries()).map(([name, items]) => {
|
|
6068
6242
|
const groupSequence = name.split("_")[0];
|
|
6069
6243
|
const localeKey = groupTitles.get(name);
|
|
6070
6244
|
return {
|
|
@@ -6072,7 +6246,8 @@ function ShortcutPanel() {
|
|
|
6072
6246
|
name: localeService.t(localeKey),
|
|
6073
6247
|
items: (0, _univerjs_core.dedupeBy)(items, (item) => item.title + item.shortcut)
|
|
6074
6248
|
};
|
|
6075
|
-
}).sort((a, b) => a.sequence - b.sequence)
|
|
6249
|
+
}).sort((a, b) => a.sequence - b.sequence);
|
|
6250
|
+
setShortcutItems(toRender);
|
|
6076
6251
|
}, [
|
|
6077
6252
|
shortcutService,
|
|
6078
6253
|
localeService,
|
|
@@ -20902,13 +21077,11 @@ function parseStoredRecentEmojis(value) {
|
|
|
20902
21077
|
}
|
|
20903
21078
|
}
|
|
20904
21079
|
function getRandomEmoji(random = Math.random) {
|
|
20905
|
-
var _allEmojis$Math$floor;
|
|
20906
21080
|
const allEmojis = getAllEmojis();
|
|
20907
|
-
return
|
|
21081
|
+
return allEmojis[Math.floor(random() * allEmojis.length)] ?? getDefaultRecentEmojis()[0];
|
|
20908
21082
|
}
|
|
20909
21083
|
function getLocalizedEmojiTitle(item, emojiTitles) {
|
|
20910
|
-
|
|
20911
|
-
return (_emojiTitles$item$emo = emojiTitles === null || emojiTitles === void 0 ? void 0 : emojiTitles[item.emoji]) !== null && _emojiTitles$item$emo !== void 0 ? _emojiTitles$item$emo : item.title;
|
|
21084
|
+
return (emojiTitles === null || emojiTitles === void 0 ? void 0 : emojiTitles[item.emoji]) ?? item.title;
|
|
20912
21085
|
}
|
|
20913
21086
|
function getEmojiLocaleData(localeService) {
|
|
20914
21087
|
const localePack = localeService.getLocales();
|
|
@@ -20931,37 +21104,54 @@ function normalizeStoredRecentEmojis(value) {
|
|
|
20931
21104
|
const EMOJI_PICKER_COMPONENT = "ui.emoji-picker";
|
|
20932
21105
|
const RECENTS_STORAGE_KEY = "univer.ui.recent-emojis";
|
|
20933
21106
|
const ACTIVE_SECTION_SCROLL_OFFSET = 28;
|
|
21107
|
+
const EMOJI_COLUMN_COUNT = 10;
|
|
21108
|
+
const EMOJI_ROW_HEIGHT = 32;
|
|
21109
|
+
const EMOJI_SECTION_HEADER_HEIGHT = 24;
|
|
21110
|
+
const EMOJI_VIRTUAL_OVERSCAN = 3;
|
|
20934
21111
|
function EmojiPicker(props) {
|
|
20935
|
-
var _props$popup
|
|
21112
|
+
var _props$popup;
|
|
20936
21113
|
const extraProps = (_props$popup = props.popup) === null || _props$popup === void 0 ? void 0 : _props$popup.extraProps;
|
|
20937
21114
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
20938
21115
|
const localStorageService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ILocalStorageService);
|
|
20939
21116
|
const currentLocale = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.currentLocale$, localeService.getCurrentLocale());
|
|
20940
|
-
const scrollRef = (0, react.useRef)(
|
|
20941
|
-
const
|
|
21117
|
+
const scrollRef = (0, react.useRef)(void 0);
|
|
21118
|
+
const pendingSectionRef = (0, react.useRef)(null);
|
|
20942
21119
|
const [query, setQuery] = (0, react.useState)("");
|
|
20943
21120
|
const [activeEmoji, setActiveEmoji] = (0, react.useState)(extraProps === null || extraProps === void 0 ? void 0 : extraProps.activeEmoji);
|
|
20944
21121
|
const [activeTab, setActiveTab] = (0, react.useState)("recent");
|
|
20945
21122
|
const [recents, setRecents] = (0, react.useState)(() => getDefaultRecentEmojis());
|
|
20946
21123
|
const deferredQuery = (0, react.useDeferredValue)(query);
|
|
20947
|
-
const emojiLocaleData =
|
|
21124
|
+
const emojiLocaleData = getEmojiLocaleData(localeService);
|
|
20948
21125
|
const searchResults = (0, react.useMemo)(() => searchEmojis(deferredQuery, emojiLocaleData.emojiSearchIndex), [deferredQuery, emojiLocaleData]);
|
|
20949
|
-
const recentStorageKey = (
|
|
21126
|
+
const recentStorageKey = (extraProps === null || extraProps === void 0 ? void 0 : extraProps.recentStorageKey) ?? RECENTS_STORAGE_KEY;
|
|
20950
21127
|
const isSearching = deferredQuery.trim().length > 0;
|
|
20951
|
-
const
|
|
20952
|
-
|
|
20953
|
-
|
|
20954
|
-
|
|
20955
|
-
|
|
20956
|
-
|
|
20957
|
-
|
|
20958
|
-
|
|
20959
|
-
|
|
20960
|
-
|
|
20961
|
-
|
|
20962
|
-
|
|
20963
|
-
|
|
20964
|
-
|
|
21128
|
+
const { rows, sectionPositions } = (0, react.useMemo)(() => {
|
|
21129
|
+
const normalSections = [{
|
|
21130
|
+
key: "recent",
|
|
21131
|
+
title: localeService.t("ui.emojiPicker.recents"),
|
|
21132
|
+
emojis: recents
|
|
21133
|
+
}, ...EMOJI_CATEGORIES.map((category) => ({
|
|
21134
|
+
key: category.key,
|
|
21135
|
+
title: localeService.t(category.titleKey),
|
|
21136
|
+
emojis: emojis[category.key]
|
|
21137
|
+
}))];
|
|
21138
|
+
return createEmojiVirtualRows(isSearching ? [{
|
|
21139
|
+
key: "people",
|
|
21140
|
+
title: localeService.t("ui.emojiPicker.searchResults"),
|
|
21141
|
+
emojis: searchResults
|
|
21142
|
+
}] : normalSections, currentLocale);
|
|
21143
|
+
}, [
|
|
21144
|
+
currentLocale,
|
|
21145
|
+
isSearching,
|
|
21146
|
+
localeService,
|
|
21147
|
+
recents,
|
|
21148
|
+
searchResults
|
|
21149
|
+
]);
|
|
21150
|
+
const [virtualRows, { containerProps, scrollTo, wrapperStyle }] = useVirtualList(rows, {
|
|
21151
|
+
containerTarget: scrollRef,
|
|
21152
|
+
itemHeight: getEmojiVirtualRowHeight,
|
|
21153
|
+
overscan: EMOJI_VIRTUAL_OVERSCAN
|
|
21154
|
+
});
|
|
20965
21155
|
(0, react.useEffect)(() => {
|
|
20966
21156
|
let disposed = false;
|
|
20967
21157
|
localStorageService.getItem(recentStorageKey).then((storedRecents) => {
|
|
@@ -20971,6 +21161,17 @@ function EmojiPicker(props) {
|
|
|
20971
21161
|
disposed = true;
|
|
20972
21162
|
};
|
|
20973
21163
|
}, [localStorageService, recentStorageKey]);
|
|
21164
|
+
(0, react.useEffect)(() => {
|
|
21165
|
+
const pendingSection = pendingSectionRef.current;
|
|
21166
|
+
if (isSearching || !pendingSection) return;
|
|
21167
|
+
const position = sectionPositions.find((item) => item.key === pendingSection);
|
|
21168
|
+
if (position) scrollTo(position.rowIndex);
|
|
21169
|
+
pendingSectionRef.current = null;
|
|
21170
|
+
}, [
|
|
21171
|
+
isSearching,
|
|
21172
|
+
scrollTo,
|
|
21173
|
+
sectionPositions
|
|
21174
|
+
]);
|
|
20974
21175
|
const handleSelect = (item, options) => {
|
|
20975
21176
|
var _props$onChange, _extraProps$onSelect;
|
|
20976
21177
|
const nextRecents = promoteRecentEmoji(recents, item);
|
|
@@ -20984,16 +21185,19 @@ function EmojiPicker(props) {
|
|
|
20984
21185
|
handleSelect(getRandomEmoji(), { keepOpen: true });
|
|
20985
21186
|
};
|
|
20986
21187
|
const handleScroll = (event) => {
|
|
21188
|
+
containerProps.onScroll(event);
|
|
20987
21189
|
if (isSearching) return;
|
|
20988
|
-
setActiveTab(getActiveSectionByScrollTop(
|
|
21190
|
+
setActiveTab(getActiveSectionByScrollTop(sectionPositions, event.currentTarget.scrollTop));
|
|
20989
21191
|
};
|
|
20990
21192
|
const scrollToSection = (section) => {
|
|
20991
21193
|
setQuery("");
|
|
20992
21194
|
setActiveTab(section);
|
|
20993
|
-
|
|
20994
|
-
|
|
20995
|
-
|
|
20996
|
-
|
|
21195
|
+
const position = sectionPositions.find((item) => item.key === section);
|
|
21196
|
+
if (!isSearching && position) {
|
|
21197
|
+
scrollTo(position.rowIndex);
|
|
21198
|
+
return;
|
|
21199
|
+
}
|
|
21200
|
+
pendingSectionRef.current = section;
|
|
20997
21201
|
};
|
|
20998
21202
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
20999
21203
|
"data-u-comp": EMOJI_PICKER_COMPONENT,
|
|
@@ -21021,17 +21225,19 @@ function EmojiPicker(props) {
|
|
|
21021
21225
|
ref: scrollRef,
|
|
21022
21226
|
className: (0, _univerjs_design.clsx)("univer-relative univer-min-h-0 univer-flex-1 univer-overflow-y-auto univer-px-3", _univerjs_design.scrollbarClassName),
|
|
21023
21227
|
onScroll: handleScroll,
|
|
21024
|
-
children:
|
|
21025
|
-
|
|
21026
|
-
children:
|
|
21228
|
+
children: rows.length ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
21229
|
+
style: wrapperStyle,
|
|
21230
|
+
children: virtualRows.map(({ data: row }) => row.type === "header" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
21231
|
+
style: { height: EMOJI_SECTION_HEADER_HEIGHT },
|
|
21232
|
+
className: "univer-flex univer-items-center univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",
|
|
21233
|
+
children: row.title
|
|
21234
|
+
}, row.key) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EmojiGrid, {
|
|
21027
21235
|
activeEmoji,
|
|
21028
21236
|
emojiTitles: emojiLocaleData.emojiTitles,
|
|
21029
|
-
|
|
21030
|
-
|
|
21031
|
-
|
|
21032
|
-
|
|
21033
|
-
}
|
|
21034
|
-
}, section.key))
|
|
21237
|
+
items: row.items,
|
|
21238
|
+
keyPrefix: row.key,
|
|
21239
|
+
onSelect: handleSelect
|
|
21240
|
+
}, row.key))
|
|
21035
21241
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
21036
21242
|
className: "univer-py-7 univer-text-center univer-text-sm univer-text-gray-400 dark:!univer-text-gray-500",
|
|
21037
21243
|
children: localeService.t("ui.emojiPicker.noResults")
|
|
@@ -21041,12 +21247,12 @@ function EmojiPicker(props) {
|
|
|
21041
21247
|
className: (0, _univerjs_design.clsx)("univer-flex univer-h-10 univer-shrink-0 univer-items-center univer-border-gray-200 univer-px-2.5 dark:!univer-border-gray-600 [&_svg]:univer-size-5", _univerjs_design.borderTopClassName),
|
|
21042
21248
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategoryButton, {
|
|
21043
21249
|
selected: !isSearching && activeTab === "recent",
|
|
21044
|
-
|
|
21250
|
+
title: localeService.t("ui.emojiPicker.recents"),
|
|
21045
21251
|
onClick: () => scrollToSection("recent"),
|
|
21046
21252
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.RecentIcon, {})
|
|
21047
21253
|
}), EMOJI_CATEGORIES.map((category) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategoryButton, {
|
|
21048
21254
|
selected: !isSearching && activeTab === category.key,
|
|
21049
|
-
|
|
21255
|
+
title: localeService.t(category.titleKey),
|
|
21050
21256
|
onClick: () => scrollToSection(category.key),
|
|
21051
21257
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategoryIcon, { category: category.key })
|
|
21052
21258
|
}, category.key))]
|
|
@@ -21054,25 +21260,10 @@ function EmojiPicker(props) {
|
|
|
21054
21260
|
]
|
|
21055
21261
|
});
|
|
21056
21262
|
}
|
|
21057
|
-
function EmojiSectionView(props) {
|
|
21058
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
21059
|
-
ref: props.refElement,
|
|
21060
|
-
className: "univer-flex univer-flex-col univer-gap-1",
|
|
21061
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
21062
|
-
className: "univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",
|
|
21063
|
-
children: props.section.title
|
|
21064
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EmojiGrid, {
|
|
21065
|
-
activeEmoji: props.activeEmoji,
|
|
21066
|
-
emojiTitles: props.emojiTitles,
|
|
21067
|
-
items: props.section.emojis,
|
|
21068
|
-
keyPrefix: props.section.key,
|
|
21069
|
-
onSelect: props.onSelect
|
|
21070
|
-
})]
|
|
21071
|
-
});
|
|
21072
|
-
}
|
|
21073
21263
|
function EmojiGrid(props) {
|
|
21074
21264
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
21075
21265
|
className: "univer-grid univer-grid-cols-10 univer-justify-between univer-gap-1",
|
|
21266
|
+
style: { height: EMOJI_ROW_HEIGHT },
|
|
21076
21267
|
children: props.items.map((item) => {
|
|
21077
21268
|
const title = getLocalizedEmojiTitle(item, props.emojiTitles);
|
|
21078
21269
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
@@ -21087,12 +21278,11 @@ function EmojiGrid(props) {
|
|
|
21087
21278
|
});
|
|
21088
21279
|
}
|
|
21089
21280
|
function CategoryButton(props) {
|
|
21090
|
-
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
21091
21281
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
21092
21282
|
type: "button",
|
|
21093
|
-
"aria-label":
|
|
21283
|
+
"aria-label": props.title,
|
|
21094
21284
|
"aria-selected": props.selected,
|
|
21095
|
-
title:
|
|
21285
|
+
title: props.title,
|
|
21096
21286
|
className: (0, _univerjs_design.clsx)("univer-flex univer-h-[30px] univer-flex-1 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-lg univer-border-0 univer-bg-transparent univer-p-0 univer-text-gray-500 dark:!univer-text-gray-400", props.selected ? "univer-bg-primary-50 univer-text-primary-500 dark:!univer-bg-gray-800 dark:!univer-text-primary-400" : "hover:univer-bg-gray-50 hover:univer-text-gray-700 dark:hover:!univer-bg-gray-800 dark:hover:!univer-text-gray-300"),
|
|
21097
21287
|
onClick: props.onClick,
|
|
21098
21288
|
children: props.children
|
|
@@ -21101,11 +21291,44 @@ function CategoryButton(props) {
|
|
|
21101
21291
|
function writeRecents(localStorageService, storageKey, recents) {
|
|
21102
21292
|
localStorageService.setItem(storageKey, recents).catch(() => void 0);
|
|
21103
21293
|
}
|
|
21104
|
-
function
|
|
21105
|
-
|
|
21294
|
+
function createEmojiVirtualRows(sections, locale) {
|
|
21295
|
+
const rows = [];
|
|
21296
|
+
const sectionPositions = [];
|
|
21297
|
+
let top = 0;
|
|
21106
21298
|
sections.forEach((section) => {
|
|
21107
|
-
|
|
21108
|
-
|
|
21299
|
+
if (!section.emojis.length) return;
|
|
21300
|
+
sectionPositions.push({
|
|
21301
|
+
key: section.key,
|
|
21302
|
+
rowIndex: rows.length,
|
|
21303
|
+
top
|
|
21304
|
+
});
|
|
21305
|
+
rows.push({
|
|
21306
|
+
key: `${locale}-${section.key}-header`,
|
|
21307
|
+
title: section.title,
|
|
21308
|
+
type: "header"
|
|
21309
|
+
});
|
|
21310
|
+
top += EMOJI_SECTION_HEADER_HEIGHT;
|
|
21311
|
+
for (let start = 0; start < section.emojis.length; start += EMOJI_COLUMN_COUNT) {
|
|
21312
|
+
rows.push({
|
|
21313
|
+
items: section.emojis.slice(start, start + EMOJI_COLUMN_COUNT),
|
|
21314
|
+
key: `${locale}-${section.key}-${start / EMOJI_COLUMN_COUNT}`,
|
|
21315
|
+
type: "emojis"
|
|
21316
|
+
});
|
|
21317
|
+
top += EMOJI_ROW_HEIGHT;
|
|
21318
|
+
}
|
|
21319
|
+
});
|
|
21320
|
+
return {
|
|
21321
|
+
rows,
|
|
21322
|
+
sectionPositions
|
|
21323
|
+
};
|
|
21324
|
+
}
|
|
21325
|
+
function getEmojiVirtualRowHeight(_index, row) {
|
|
21326
|
+
return row.type === "header" ? EMOJI_SECTION_HEADER_HEIGHT : EMOJI_ROW_HEIGHT;
|
|
21327
|
+
}
|
|
21328
|
+
function getActiveSectionByScrollTop(sectionPositions, scrollTop) {
|
|
21329
|
+
let active = "recent";
|
|
21330
|
+
sectionPositions.forEach((position) => {
|
|
21331
|
+
if (position.top <= scrollTop + ACTIVE_SECTION_SCROLL_OFFSET) active = position.key;
|
|
21109
21332
|
});
|
|
21110
21333
|
return active;
|
|
21111
21334
|
}
|
|
@@ -21330,8 +21553,7 @@ let FontService = class FontService {
|
|
|
21330
21553
|
constructor(_configService) {
|
|
21331
21554
|
this._configService = _configService;
|
|
21332
21555
|
_defineProperty(this, "fonts$", new rxjs.BehaviorSubject([]));
|
|
21333
|
-
const
|
|
21334
|
-
const { customFontFamily } = config !== null && config !== void 0 ? config : {};
|
|
21556
|
+
const { customFontFamily } = this._configService.getConfig("ui.config") ?? {};
|
|
21335
21557
|
let fonts = [];
|
|
21336
21558
|
if (customFontFamily) if (Array.isArray(customFontFamily)) fonts = [...DEFAULT_FONT_LIST, ...customFontFamily];
|
|
21337
21559
|
else if (customFontFamily.override) fonts = [...customFontFamily.list];
|
|
@@ -21435,7 +21657,7 @@ const FontFamily = ({ className, disabled: disabledProp, value, disabled$, onCha
|
|
|
21435
21657
|
fonts,
|
|
21436
21658
|
localeService
|
|
21437
21659
|
]);
|
|
21438
|
-
const inputValue = draftValue
|
|
21660
|
+
const inputValue = draftValue ?? viewValue;
|
|
21439
21661
|
function resetValue() {
|
|
21440
21662
|
setDraftValue(null);
|
|
21441
21663
|
}
|
|
@@ -21563,8 +21785,8 @@ function FontFamilyDropdown(props) {
|
|
|
21563
21785
|
const FontSize = (props) => {
|
|
21564
21786
|
const { value, min, max, onChange, disabled$ } = props;
|
|
21565
21787
|
const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(disabled$);
|
|
21566
|
-
const [realValue, setRealValue] = (0, react.useState)(Number(value
|
|
21567
|
-
const _value = (0, react.useMemo)(() => Number(value
|
|
21788
|
+
const [realValue, setRealValue] = (0, react.useState)(Number(value ?? 0));
|
|
21789
|
+
const _value = (0, react.useMemo)(() => Number(value ?? realValue), [value]);
|
|
21568
21790
|
function handleChange(value) {
|
|
21569
21791
|
if (value === null) return;
|
|
21570
21792
|
setRealValue(value);
|
|
@@ -21691,7 +21913,7 @@ const FONT_SIZE_COMPONENT = "UI_FONT_SIZE_COMPONENT";
|
|
|
21691
21913
|
//#endregion
|
|
21692
21914
|
//#region src/views/HeadingItem.tsx
|
|
21693
21915
|
const HeadingItem = (props) => {
|
|
21694
|
-
var _style$cl
|
|
21916
|
+
var _style$cl;
|
|
21695
21917
|
const { value, text } = props;
|
|
21696
21918
|
const style = _univerjs_core.NAMED_STYLE_MAP[value];
|
|
21697
21919
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
@@ -21699,7 +21921,7 @@ const HeadingItem = (props) => {
|
|
|
21699
21921
|
className: (0, _univerjs_design.clsx)("univer-text-sm", { "univer-font-bold": style === null || style === void 0 ? void 0 : style.bl }),
|
|
21700
21922
|
style: {
|
|
21701
21923
|
fontSize: style === null || style === void 0 ? void 0 : style.fs,
|
|
21702
|
-
color: (
|
|
21924
|
+
color: (style === null || style === void 0 || (_style$cl = style.cl) === null || _style$cl === void 0 ? void 0 : _style$cl.rgb) ?? void 0
|
|
21703
21925
|
},
|
|
21704
21926
|
children: localeService.t(text)
|
|
21705
21927
|
});
|
|
@@ -21805,7 +22027,6 @@ const DRAG_COMMIT_INTERVAL = 50;
|
|
|
21805
22027
|
* Slider Component
|
|
21806
22028
|
*/
|
|
21807
22029
|
function Slider(props) {
|
|
21808
|
-
var _getSliderOffset;
|
|
21809
22030
|
const iconManager = (0, _wendellhu_redi_react_bindings.useDependency)(IconManager);
|
|
21810
22031
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
21811
22032
|
const { value, min = 0, max = 400, disabled = false, resetPoint = 100, shortcuts, onChange } = props;
|
|
@@ -21916,7 +22137,7 @@ function Slider(props) {
|
|
|
21916
22137
|
window.addEventListener("pointerout", onPointerOut);
|
|
21917
22138
|
}
|
|
21918
22139
|
const visualValue = isDragging ? dragValue : value;
|
|
21919
|
-
const sliderOffset = Math.min(Math.max(
|
|
22140
|
+
const sliderOffset = Math.min(Math.max(getSliderOffset(visualValue) ?? 0, 0), 100);
|
|
21920
22141
|
const handleOffset = isRtl ? 100 - sliderOffset : sliderOffset;
|
|
21921
22142
|
const ReduceIcon = iconManager.get("ReduceIcon");
|
|
21922
22143
|
const IncreaseIcon = iconManager.get("IncreaseIcon");
|
|
@@ -22297,7 +22518,6 @@ FeatureSearchController = __decorate([__decorateParam(0, _univerjs_core.ICommand
|
|
|
22297
22518
|
//#region src/views/components/ribbon/MobileRibbon.tsx
|
|
22298
22519
|
const toolbarScrollOffset = 168;
|
|
22299
22520
|
function MobileRibbon(props) {
|
|
22300
|
-
var _activeGroup$children;
|
|
22301
22521
|
const { headerMenuComponents, headerMenu = true } = props;
|
|
22302
22522
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
22303
22523
|
const ribbonService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonService);
|
|
@@ -22308,7 +22528,7 @@ function MobileRibbon(props) {
|
|
|
22308
22528
|
return index === -1 ? 0 : index;
|
|
22309
22529
|
}, [activatedTab, ribbon]);
|
|
22310
22530
|
const activeGroup = ribbon[activeIndex];
|
|
22311
|
-
const activeGroups = (
|
|
22531
|
+
const activeGroups = (activeGroup === null || activeGroup === void 0 ? void 0 : activeGroup.children) ?? [];
|
|
22312
22532
|
const hasHeaderMenu = !!(headerMenu && headerMenuComponents && headerMenuComponents.size > 0);
|
|
22313
22533
|
const toolbarScrollRef = (0, react.useRef)(null);
|
|
22314
22534
|
const [canScrollLeft, setCanScrollLeft] = (0, react.useState)(false);
|
|
@@ -22429,8 +22649,8 @@ function MobileRibbon(props) {
|
|
|
22429
22649
|
"data-u-comp": "mobile-ribbon-toolbar",
|
|
22430
22650
|
className: "univer-flex univer-min-w-0 univer-items-center univer-gap-1.5 univer-overflow-x-auto univer-scroll-smooth univer-px-0.5 [&::-webkit-scrollbar]:univer-hidden",
|
|
22431
22651
|
children: activeGroups.map((groupItem, groupIndex) => {
|
|
22432
|
-
var _groupItem$children
|
|
22433
|
-
const groupItems = (
|
|
22652
|
+
var _groupItem$children;
|
|
22653
|
+
const groupItems = ((_groupItem$children = groupItem.children) === null || _groupItem$children === void 0 ? void 0 : _groupItem$children.filter((child) => !!child.item)) ?? [];
|
|
22434
22654
|
if (!groupItems.length) return null;
|
|
22435
22655
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
22436
22656
|
className: (0, _univerjs_design.clsx)("univer-flex univer-shrink-0 univer-items-center univer-gap-0.5 univer-pr-1.5 rtl:univer-pl-1.5 rtl:univer-pr-0", { [_univerjs_design.borderRightClassName]: groupIndex !== activeGroups.length - 1 }),
|
|
@@ -22461,11 +22681,10 @@ function MobileRibbon(props) {
|
|
|
22461
22681
|
//#endregion
|
|
22462
22682
|
//#region src/views/menu/mobile/MobileMenu.tsx
|
|
22463
22683
|
function MobileMenu(props) {
|
|
22464
|
-
var _viewStack;
|
|
22465
22684
|
const { menuType, onOptionSelect, schemas: providedSchemas, menuManagerService: providedMenuManagerService } = props;
|
|
22466
22685
|
const rootMenuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
|
|
22467
22686
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
22468
|
-
const menuManagerService = providedMenuManagerService
|
|
22687
|
+
const menuManagerService = providedMenuManagerService ?? rootMenuManagerService;
|
|
22469
22688
|
const [viewStack, setViewStack] = (0, react.useState)([]);
|
|
22470
22689
|
const menuSchemas = (0, react.useMemo)(() => {
|
|
22471
22690
|
if (providedSchemas) return providedSchemas;
|
|
@@ -22482,7 +22701,7 @@ function MobileMenu(props) {
|
|
|
22482
22701
|
(0, react.useEffect)(() => {
|
|
22483
22702
|
setViewStack([]);
|
|
22484
22703
|
}, [menuType, providedSchemas]);
|
|
22485
|
-
const currentView =
|
|
22704
|
+
const currentView = viewStack[viewStack.length - 1] ?? null;
|
|
22486
22705
|
if (!menuType && !providedSchemas) return null;
|
|
22487
22706
|
const openView = (view) => setViewStack((stack) => [...stack, view]);
|
|
22488
22707
|
const closeView = () => setViewStack((stack) => stack.slice(0, -1));
|
|
@@ -22610,24 +22829,20 @@ function MobileSchemaRow(props) {
|
|
|
22610
22829
|
function MobileSelectionOptionsView(props) {
|
|
22611
22830
|
const { options, menuKey, menuItem, currentValue, inheritedDisabled$, onExecute } = props;
|
|
22612
22831
|
const inheritedDisabled = (0, _wendellhu_redi_react_bindings.useObservable)(inheritedDisabled$, false);
|
|
22613
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: options.map((option, index) => {
|
|
22614
|
-
|
|
22615
|
-
|
|
22616
|
-
|
|
22617
|
-
|
|
22618
|
-
|
|
22619
|
-
|
|
22620
|
-
|
|
22621
|
-
|
|
22622
|
-
onExecute
|
|
22623
|
-
}, `${menuKey}-${String((_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : index)}`);
|
|
22624
|
-
}) });
|
|
22832
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: options.map((option, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileSelectionOptionRow, {
|
|
22833
|
+
option,
|
|
22834
|
+
menuKey,
|
|
22835
|
+
menuItem,
|
|
22836
|
+
currentValue,
|
|
22837
|
+
disabled: inheritedDisabled,
|
|
22838
|
+
bordered: index !== options.length - 1,
|
|
22839
|
+
onExecute
|
|
22840
|
+
}, `${menuKey}-${String(option.value ?? index)}`)) });
|
|
22625
22841
|
}
|
|
22626
22842
|
function MobileSelectionOptionRow(props) {
|
|
22627
|
-
var _option$value2;
|
|
22628
22843
|
const { option, menuKey, menuItem, currentValue, disabled, bordered, onExecute } = props;
|
|
22629
22844
|
const optionValue = (0, _wendellhu_redi_react_bindings.useObservable)(option.value$);
|
|
22630
|
-
const displayValue =
|
|
22845
|
+
const displayValue = option.value ?? optionValue;
|
|
22631
22846
|
const selected = displayValue === currentValue;
|
|
22632
22847
|
const optionDisabled = disabled || Boolean(option.disabled);
|
|
22633
22848
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
@@ -22656,7 +22871,6 @@ function MobileSelectionOptionRow(props) {
|
|
|
22656
22871
|
});
|
|
22657
22872
|
}
|
|
22658
22873
|
function useMobileSchemaInteraction(props) {
|
|
22659
|
-
var _schema$children3;
|
|
22660
22874
|
const { schema, menuManagerService, menuType, onOpenView, inheritedDisabled$ } = props;
|
|
22661
22875
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
22662
22876
|
const menuItem = schema.item;
|
|
@@ -22683,7 +22897,7 @@ function useMobileSchemaInteraction(props) {
|
|
|
22683
22897
|
return menuManagerService.getMenuByPositionKey(menuItem.id);
|
|
22684
22898
|
}, [menuItem, menuManagerService]);
|
|
22685
22899
|
if (!menuItem) return null;
|
|
22686
|
-
const schemaChildren =
|
|
22900
|
+
const schemaChildren = schema.children ?? [];
|
|
22687
22901
|
const hasSubmenu = schemaChildren.length > 0 || selections.length > 0 || subMenuItems.length > 0;
|
|
22688
22902
|
const currentValueText = typeof value === "string" || typeof value === "number" ? String(value) : "";
|
|
22689
22903
|
const onPress = (onExecute) => {
|
|
@@ -22750,8 +22964,8 @@ function useContextGroupHiddenStates(menuSchemas) {
|
|
|
22750
22964
|
const groupStates = menuSchemas.flatMap((menuSchema) => {
|
|
22751
22965
|
var _menuSchema$children;
|
|
22752
22966
|
const hiddenObservables = ((_menuSchema$children = menuSchema.children) === null || _menuSchema$children === void 0 ? void 0 : _menuSchema$children.length) ? getLeafItemSchemas(menuSchema.children).map((childSchema) => {
|
|
22753
|
-
var _childSchema$item
|
|
22754
|
-
return (
|
|
22967
|
+
var _childSchema$item;
|
|
22968
|
+
return ((_childSchema$item = childSchema.item) === null || _childSchema$item === void 0 ? void 0 : _childSchema$item.hidden$) ?? (0, rxjs.of)(false);
|
|
22755
22969
|
}) : [];
|
|
22756
22970
|
return hiddenObservables.length ? [(0, rxjs.combineLatest)(hiddenObservables).pipe((0, rxjs.map)((values) => [menuSchema.key, values.every(Boolean)]))] : [];
|
|
22757
22971
|
});
|
|
@@ -22763,8 +22977,8 @@ function useContextGroupHiddenStates(menuSchemas) {
|
|
|
22763
22977
|
}
|
|
22764
22978
|
function getLeafItemSchemas(schemas) {
|
|
22765
22979
|
return schemas.reduce((acc, schema) => {
|
|
22766
|
-
var _schema$
|
|
22767
|
-
if ((_schema$
|
|
22980
|
+
var _schema$children3;
|
|
22981
|
+
if ((_schema$children3 = schema.children) === null || _schema$children3 === void 0 ? void 0 : _schema$children3.length) return [...acc, ...getLeafItemSchemas(schema.children)];
|
|
22768
22982
|
if (schema.item) return [...acc, schema];
|
|
22769
22983
|
return acc;
|
|
22770
22984
|
}, []);
|
|
@@ -22832,8 +23046,7 @@ function MobileContextMenu() {
|
|
|
22832
23046
|
menuType,
|
|
22833
23047
|
menuManagerService: (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(IMenuManagerService)) ? activeScope.get(IMenuManagerService) : menuManagerService,
|
|
22834
23048
|
onOptionSelect: (params) => {
|
|
22835
|
-
|
|
22836
|
-
const commandId = (_ref = (_params$commandId = params.commandId) !== null && _params$commandId !== void 0 ? _params$commandId : params.id) !== null && _ref !== void 0 ? _ref : params.label;
|
|
23049
|
+
const commandId = params.commandId ?? params.id ?? params.label;
|
|
22837
23050
|
const fallbackParams = typeof params.params === "function" ? params.params() : params.params;
|
|
22838
23051
|
const commandParams = typeof params.value === "undefined" ? fallbackParams : { value: params.value };
|
|
22839
23052
|
if (!commandId) return;
|
|
@@ -22892,6 +23105,8 @@ function mountMobileWorkbench(injector, options, mountContainer, onRendered) {
|
|
|
22892
23105
|
function MobileWorkbench(props) {
|
|
22893
23106
|
const { header = true, toolbar = true, footer = true, headerMenu = true, ribbonType = "classic", contextMenu = true, mountContainer, onRendered } = props;
|
|
22894
23107
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
23108
|
+
const lifecycleService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LifecycleService);
|
|
23109
|
+
const workbenchService = (0, _wendellhu_redi_react_bindings.useDependency)(IWorkbenchService);
|
|
22895
23110
|
const themeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ThemeService);
|
|
22896
23111
|
const themeSwitcherService = (0, _wendellhu_redi_react_bindings.useDependency)(ThemeSwitcherService);
|
|
22897
23112
|
const contentRef = (0, react.useRef)(null);
|
|
@@ -22903,9 +23118,12 @@ function MobileWorkbench(props) {
|
|
|
22903
23118
|
const globalComponents = useComponentsOfPart("global");
|
|
22904
23119
|
const toolbarComponents = useComponentsOfPart("toolbar");
|
|
22905
23120
|
const darkMode = (0, _wendellhu_redi_react_bindings.useObservable)(themeService.darkMode$, themeService.darkMode);
|
|
23121
|
+
const lifecycleStage = (0, _wendellhu_redi_react_bindings.useObservable)(lifecycleService.lifecycle$, lifecycleService.stage);
|
|
23122
|
+
const externalSkeletonVisible = (0, _wendellhu_redi_react_bindings.useObservable)(workbenchService.skeletonVisible$, void 0, true);
|
|
23123
|
+
const ready = lifecycleStage >= _univerjs_core.LifecycleStages.Ready;
|
|
22906
23124
|
(0, react.useEffect)(() => {
|
|
22907
|
-
if (contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
|
|
22908
|
-
}, [onRendered]);
|
|
23125
|
+
if (ready && contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
|
|
23126
|
+
}, [ready, onRendered]);
|
|
22909
23127
|
const locale = (0, _wendellhu_redi_react_bindings.useObservable)(() => localeService.localeChanged$.pipe((0, rxjs.map)(() => localeService.getLocales())), localeService.getLocales(), false, [localeService]);
|
|
22910
23128
|
const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$, localeService.getDirection());
|
|
22911
23129
|
const portalContainer = (0, react.useMemo)(() => document.createElement("div"), []);
|
|
@@ -22931,51 +23149,58 @@ function MobileWorkbench(props) {
|
|
|
22931
23149
|
direction,
|
|
22932
23150
|
mountContainer: portalContainer,
|
|
22933
23151
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
22934
|
-
"
|
|
22935
|
-
|
|
22936
|
-
|
|
22937
|
-
|
|
22938
|
-
|
|
22939
|
-
|
|
22940
|
-
|
|
22941
|
-
|
|
22942
|
-
|
|
22943
|
-
|
|
22944
|
-
|
|
22945
|
-
|
|
22946
|
-
|
|
22947
|
-
|
|
22948
|
-
|
|
22949
|
-
|
|
22950
|
-
|
|
22951
|
-
|
|
22952
|
-
|
|
22953
|
-
|
|
22954
|
-
className: "univer-
|
|
22955
|
-
children: [
|
|
22956
|
-
|
|
22957
|
-
|
|
22958
|
-
|
|
22959
|
-
|
|
22960
|
-
|
|
22961
|
-
|
|
22962
|
-
|
|
22963
|
-
className: "univer-
|
|
22964
|
-
children:
|
|
22965
|
-
|
|
22966
|
-
|
|
22967
|
-
|
|
22968
|
-
|
|
22969
|
-
|
|
22970
|
-
|
|
22971
|
-
|
|
22972
|
-
|
|
22973
|
-
|
|
22974
|
-
|
|
22975
|
-
|
|
22976
|
-
|
|
22977
|
-
|
|
22978
|
-
|
|
23152
|
+
className: "univer-relative univer-h-full univer-min-h-0",
|
|
23153
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
23154
|
+
"data-u-comp": "app-layout",
|
|
23155
|
+
className: (0, _univerjs_design.clsx)("univer-relative univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800", { "univer-dark": darkMode }),
|
|
23156
|
+
tabIndex: -1,
|
|
23157
|
+
onBlur: (e) => e.stopPropagation(),
|
|
23158
|
+
onContextMenu: (e) => e.preventDefault(),
|
|
23159
|
+
dir: direction,
|
|
23160
|
+
children: [header && toolbar && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
|
|
23161
|
+
"data-u-comp": "headerbar",
|
|
23162
|
+
className: "univer-relative univer-z-10 univer-w-full univer-overflow-hidden",
|
|
23163
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, {
|
|
23164
|
+
components: toolbarComponents,
|
|
23165
|
+
sharedProps: {
|
|
23166
|
+
ribbonType,
|
|
23167
|
+
headerMenuComponents,
|
|
23168
|
+
headerMenu
|
|
23169
|
+
}
|
|
23170
|
+
}, "toolbar")
|
|
23171
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
23172
|
+
className: "univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col",
|
|
23173
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
23174
|
+
className: "univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden",
|
|
23175
|
+
children: [
|
|
23176
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("aside", {
|
|
23177
|
+
className: "univer-h-full",
|
|
23178
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, { components: leftSidebarComponents }, "left-sidebar")
|
|
23179
|
+
}),
|
|
23180
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
23181
|
+
className: (0, _univerjs_design.clsx)("univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white dark:!univer-bg-gray-800", _univerjs_design.borderBottomClassName),
|
|
23182
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
|
|
23183
|
+
className: "univer-w-screen",
|
|
23184
|
+
children: header && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, { components: headerComponents }, "header")
|
|
23185
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
23186
|
+
ref: contentRef,
|
|
23187
|
+
className: "univer-relative univer-overflow-hidden",
|
|
23188
|
+
"data-range-selector": true,
|
|
23189
|
+
onContextMenu: (e) => e.preventDefault(),
|
|
23190
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, { components: contentComponents }, "content")
|
|
23191
|
+
})]
|
|
23192
|
+
}),
|
|
23193
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("aside", {
|
|
23194
|
+
className: "univer-h-full",
|
|
23195
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Sidebar, {})
|
|
23196
|
+
})
|
|
23197
|
+
]
|
|
23198
|
+
}), footer && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("footer", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, { components: footerComponents }, "footer") })]
|
|
23199
|
+
})]
|
|
23200
|
+
}), (!ready || externalSkeletonVisible) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkbenchSkeleton, {
|
|
23201
|
+
darkMode,
|
|
23202
|
+
direction,
|
|
23203
|
+
overlay: true
|
|
22979
23204
|
})]
|
|
22980
23205
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
22981
23206
|
dir: direction,
|
|
@@ -23274,7 +23499,7 @@ let BrowserClipboardService = class BrowserClipboardService extends _univerjs_co
|
|
|
23274
23499
|
return await navigator.clipboard.write([new ClipboardItem({
|
|
23275
23500
|
[PLAIN_TEXT_CLIPBOARD_MIME_TYPE]: new Blob([text], { type: PLAIN_TEXT_CLIPBOARD_MIME_TYPE }),
|
|
23276
23501
|
[HTML_CLIPBOARD_MIME_TYPE]: new Blob([html], { type: HTML_CLIPBOARD_MIME_TYPE }),
|
|
23277
|
-
...Object.fromEntries(Object.entries(customData
|
|
23502
|
+
...Object.fromEntries(Object.entries(customData ?? {}).map(([type, value]) => [type, new Blob([value], { type })]))
|
|
23278
23503
|
})]);
|
|
23279
23504
|
} catch (error) {
|
|
23280
23505
|
if (customData && Object.keys(customData).length) try {
|
|
@@ -23411,10 +23636,7 @@ function serializeSanitizedHtmlForClipboard(html) {
|
|
|
23411
23636
|
return container.innerHTML;
|
|
23412
23637
|
}
|
|
23413
23638
|
function sanitizeHtmlNode(node) {
|
|
23414
|
-
if (node.nodeType === Node.TEXT_NODE)
|
|
23415
|
-
var _node$textContent;
|
|
23416
|
-
return document.createTextNode((_node$textContent = node.textContent) !== null && _node$textContent !== void 0 ? _node$textContent : "");
|
|
23417
|
-
}
|
|
23639
|
+
if (node.nodeType === Node.TEXT_NODE) return document.createTextNode(node.textContent ?? "");
|
|
23418
23640
|
if (node.nodeType !== Node.ELEMENT_NODE) return null;
|
|
23419
23641
|
const sourceElement = node;
|
|
23420
23642
|
const tagName = sourceElement.tagName.toLowerCase();
|
|
@@ -23743,11 +23965,10 @@ DesktopGalleryService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject
|
|
|
23743
23965
|
var DesktopLocalFileService = class extends _univerjs_core.Disposable {
|
|
23744
23966
|
openFile(options) {
|
|
23745
23967
|
return new Promise((resolve) => {
|
|
23746
|
-
var _options$accept, _options$multiple;
|
|
23747
23968
|
const inputElement = document.createElement("input");
|
|
23748
23969
|
inputElement.type = "file";
|
|
23749
|
-
inputElement.accept = (
|
|
23750
|
-
inputElement.multiple = (
|
|
23970
|
+
inputElement.accept = (options === null || options === void 0 ? void 0 : options.accept) ?? "";
|
|
23971
|
+
inputElement.multiple = (options === null || options === void 0 ? void 0 : options.multiple) ?? false;
|
|
23751
23972
|
inputElement.onchange = (event) => {
|
|
23752
23973
|
const fileList = event.target.files;
|
|
23753
23974
|
if (fileList) resolve(Array.from(fileList));
|
|
@@ -23829,10 +24050,7 @@ var IndexedDBDriver = class {
|
|
|
23829
24050
|
const store = await this._store("readonly");
|
|
23830
24051
|
return new Promise((resolve, reject) => {
|
|
23831
24052
|
const req = store.get(key);
|
|
23832
|
-
req.onsuccess = () =>
|
|
23833
|
-
var _req$result;
|
|
23834
|
-
return resolve((_req$result = req.result) !== null && _req$result !== void 0 ? _req$result : null);
|
|
23835
|
-
};
|
|
24053
|
+
req.onsuccess = () => resolve(req.result ?? null);
|
|
23836
24054
|
req.onerror = () => reject(req.error);
|
|
23837
24055
|
});
|
|
23838
24056
|
}
|
|
@@ -23940,8 +24158,7 @@ var LocalStorageDriver = class {
|
|
|
23940
24158
|
toRemove.forEach((k) => localStorage.removeItem(k));
|
|
23941
24159
|
}
|
|
23942
24160
|
async key(index) {
|
|
23943
|
-
|
|
23944
|
-
return (_keys$index = this._keys()[index]) !== null && _keys$index !== void 0 ? _keys$index : null;
|
|
24161
|
+
return this._keys()[index] ?? null;
|
|
23945
24162
|
}
|
|
23946
24163
|
async keys() {
|
|
23947
24164
|
return this._keys();
|
|
@@ -24042,8 +24259,7 @@ let DesktopMessageService = class DesktopMessageService extends _univerjs_core.D
|
|
|
24042
24259
|
(0, _univerjs_design.removeMessage)();
|
|
24043
24260
|
}
|
|
24044
24261
|
show(options) {
|
|
24045
|
-
|
|
24046
|
-
const id = (_options$id = options.id) !== null && _options$id !== void 0 ? _options$id : `message-${Date.now()}-${messageId}`;
|
|
24262
|
+
const id = options.id ?? `message-${Date.now()}-${messageId}`;
|
|
24047
24263
|
messageId += 1;
|
|
24048
24264
|
(0, _univerjs_design.message)(Object.assign({}, options, { id }));
|
|
24049
24265
|
return (0, _univerjs_core.toDisposable)(() => (0, _univerjs_design.removeMessage)(id));
|
|
@@ -24189,6 +24405,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends _univerjs_core.Plu
|
|
|
24189
24405
|
[IconManager],
|
|
24190
24406
|
[ComponentsController],
|
|
24191
24407
|
[ThemeSwitcherService],
|
|
24408
|
+
[IWorkbenchService, { useClass: WorkbenchService }],
|
|
24192
24409
|
[ZIndexManager],
|
|
24193
24410
|
[ShortcutPanelService],
|
|
24194
24411
|
[IUIPartsService, { useClass: UIPartsService }],
|
|
@@ -24294,6 +24511,7 @@ let UniverUIPlugin = class UniverUIPlugin extends _univerjs_core.Plugin {
|
|
|
24294
24511
|
[ZIndexManager],
|
|
24295
24512
|
[ShortcutPanelService],
|
|
24296
24513
|
[IUIPartsService, { useClass: UIPartsService }],
|
|
24514
|
+
[IWorkbenchService, { useClass: WorkbenchService }],
|
|
24297
24515
|
[ILayoutService, { useClass: DesktopLayoutService }],
|
|
24298
24516
|
[IRibbonService, { useClass: DesktopRibbonService }],
|
|
24299
24517
|
[IRibbonOverrideService, { useClass: RibbonOverrideService }],
|
|
@@ -24469,8 +24687,7 @@ function handleDomToJson($dom) {
|
|
|
24469
24687
|
let span = nodeList[`${i}`];
|
|
24470
24688
|
let str;
|
|
24471
24689
|
if (span.nodeName === "#text") {
|
|
24472
|
-
|
|
24473
|
-
str = (_span$textContent = span.textContent) !== null && _span$textContent !== void 0 ? _span$textContent : "";
|
|
24690
|
+
str = span.textContent ?? "";
|
|
24474
24691
|
span = span.parentElement;
|
|
24475
24692
|
} else str = span.innerText;
|
|
24476
24693
|
const textStyle = handleStringToStyle(span);
|
|
@@ -24502,8 +24719,8 @@ function handleDomToJson($dom) {
|
|
|
24502
24719
|
* @returns
|
|
24503
24720
|
*/
|
|
24504
24721
|
function handleStringToStyle($dom, cssStyle = "") {
|
|
24505
|
-
var _$dom$style
|
|
24506
|
-
let cssText = (
|
|
24722
|
+
var _$dom$style;
|
|
24723
|
+
let cssText = ($dom === null || $dom === void 0 || (_$dom$style = $dom.style) === null || _$dom$style === void 0 ? void 0 : _$dom$style.cssText) ?? "";
|
|
24507
24724
|
cssText += cssStyle;
|
|
24508
24725
|
cssText = cssText.replace(/[\r\n]+/g, "");
|
|
24509
24726
|
if (cssText.length === 0) return {};
|
|
@@ -24523,8 +24740,10 @@ function handleStringToStyle($dom, cssStyle = "") {
|
|
|
24523
24740
|
else styleList.bl = 0;
|
|
24524
24741
|
else if (key === "font-style") if (value === "italic") styleList.it = 1;
|
|
24525
24742
|
else styleList.it = 0;
|
|
24526
|
-
else if (key === "font-family")
|
|
24527
|
-
|
|
24743
|
+
else if (key === "font-family") {
|
|
24744
|
+
const fontFamily = extractFontFamily(textTrim(originStr));
|
|
24745
|
+
styleList.ff = fontFamily;
|
|
24746
|
+
} else if (key === "font-size") {
|
|
24528
24747
|
let fs = Number.parseInt(value);
|
|
24529
24748
|
if (cssText.indexOf("vertical-align") > -1 && (cssText.indexOf("sub") > -1 || cssText.indexOf("sup") > -1)) fs *= 2;
|
|
24530
24749
|
if (value.indexOf("px") !== -1) fs = getPtFontSizeByPx(Number.parseInt(value, 10));
|
|
@@ -24851,10 +25070,9 @@ function handelTableToJson(table) {
|
|
|
24851
25070
|
while (c < colLen && data[r][c] != null) c++;
|
|
24852
25071
|
if (c === colLen) return;
|
|
24853
25072
|
if (data[r][c] == null) {
|
|
24854
|
-
var _Number, _Number2;
|
|
24855
25073
|
data[r][c] = cell;
|
|
24856
|
-
const rowSpan =
|
|
24857
|
-
const colSpan =
|
|
25074
|
+
const rowSpan = Number(td.getAttribute("rowSpan")) ?? 1;
|
|
25075
|
+
const colSpan = Number(td.getAttribute("colSpan")) ?? 1;
|
|
24858
25076
|
if (rowSpan > 1 || colSpan > 1) {
|
|
24859
25077
|
const first = {
|
|
24860
25078
|
rs: +rowSpan - 1,
|
|
@@ -24961,10 +25179,9 @@ function handelExcelToJson(html) {
|
|
|
24961
25179
|
while (c < colLen && data[r][c] != null) c++;
|
|
24962
25180
|
if (c === colLen) return;
|
|
24963
25181
|
if (data[r][c] == null) {
|
|
24964
|
-
var _Number3, _Number4;
|
|
24965
25182
|
data[r][c] = cell;
|
|
24966
|
-
const rowSpan =
|
|
24967
|
-
const colSpan =
|
|
25183
|
+
const rowSpan = Number(td.getAttribute("rowSpan")) ?? 1;
|
|
25184
|
+
const colSpan = Number(td.getAttribute("colSpan")) ?? 1;
|
|
24968
25185
|
if (rowSpan > 1 || colSpan > 1) {
|
|
24969
25186
|
const first = {
|
|
24970
25187
|
rs: +rowSpan - 1,
|
|
@@ -25028,14 +25245,13 @@ function RegisteredPrintFloatDomSingle(props) {
|
|
|
25028
25245
|
});
|
|
25029
25246
|
}
|
|
25030
25247
|
function PrintFloatDomSingleContent(props) {
|
|
25031
|
-
var _position$startY, _position$startX;
|
|
25032
25248
|
const { layer, id, position, Component } = props;
|
|
25033
25249
|
const univerInstanceService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
25034
25250
|
const domRef = (0, react.useRef)(null);
|
|
25035
25251
|
const innerDomRef = (0, react.useRef)(null);
|
|
25036
25252
|
const transformRef = (0, react.useRef)(`transform: rotate(${position === null || position === void 0 ? void 0 : position.rotate}deg) translate(${position === null || position === void 0 ? void 0 : position.startX}px, ${position === null || position === void 0 ? void 0 : position.startY}px)`);
|
|
25037
|
-
const topRef = (0, react.useRef)((
|
|
25038
|
-
const leftRef = (0, react.useRef)((
|
|
25253
|
+
const topRef = (0, react.useRef)((position === null || position === void 0 ? void 0 : position.startY) ?? 0);
|
|
25254
|
+
const leftRef = (0, react.useRef)((position === null || position === void 0 ? void 0 : position.startX) ?? 0);
|
|
25039
25255
|
const layerProps = (0, react.useMemo)(() => ({
|
|
25040
25256
|
data: layer.data,
|
|
25041
25257
|
...layer.props
|
|
@@ -25325,6 +25541,7 @@ exports.ISidebarService = ISidebarService;
|
|
|
25325
25541
|
exports.IUIController = IUIController;
|
|
25326
25542
|
exports.IUIPartsService = IUIPartsService;
|
|
25327
25543
|
exports.IUIRuntimeScopeService = IUIRuntimeScopeService;
|
|
25544
|
+
exports.IWorkbenchService = IWorkbenchService;
|
|
25328
25545
|
Object.defineProperty(exports, 'IconManager', {
|
|
25329
25546
|
enumerable: true,
|
|
25330
25547
|
get: function () {
|
|
@@ -25343,6 +25560,7 @@ Object.defineProperty(exports, 'MenuManagerService', {
|
|
|
25343
25560
|
exports.MetaKeys = MetaKeys;
|
|
25344
25561
|
exports.MobileContextMenu = MobileContextMenu;
|
|
25345
25562
|
exports.MockMessageService = MockMessageService;
|
|
25563
|
+
exports.NativeTextEditorShortcutBehavior = NativeTextEditorShortcutBehavior;
|
|
25346
25564
|
exports.PLAIN_TEXT_CLIPBOARD_MIME_TYPE = PLAIN_TEXT_CLIPBOARD_MIME_TYPE;
|
|
25347
25565
|
exports.PasteCommand = PasteCommand;
|
|
25348
25566
|
exports.PlatformService = PlatformService;
|
|
@@ -25433,6 +25651,7 @@ Object.defineProperty(exports, 'WithDependency', {
|
|
|
25433
25651
|
return _wendellhu_redi_react_bindings.WithDependency;
|
|
25434
25652
|
}
|
|
25435
25653
|
});
|
|
25654
|
+
exports.WorkbenchService = WorkbenchService;
|
|
25436
25655
|
exports.ZIndexManager = ZIndexManager;
|
|
25437
25656
|
exports.ZoomInput = ZoomInput;
|
|
25438
25657
|
Object.defineProperty(exports, 'connectDependencies', {
|