@univerjs/ui 1.0.0-beta.1 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +210 -121
- package/lib/es/index.js +205 -121
- package/lib/index.css +12 -0
- package/lib/index.js +205 -121
- package/lib/types/common/icon-manager.d.ts +1 -0
- package/lib/types/services/workbench/workbench.service.d.ts +9 -2
- package/lib/types/views/components/ribbon/ToolbarItem.d.ts +1 -0
- package/lib/types/views/components/ribbon/TooltipButtonWrapper.d.ts +4 -2
- package/lib/types/views/custom-label/CustomLabel.d.ts +1 -0
- package/lib/types/views/hooks/virtual-list.d.ts +2 -1
- package/lib/umd/index.js +13 -13
- package/package.json +7 -7
package/lib/cjs/index.js
CHANGED
|
@@ -2574,9 +2574,11 @@ const SingleCanvasPopup = ({ popup, children }) => {
|
|
|
2574
2574
|
var _popup$excludeRects$;
|
|
2575
2575
|
return (_popup$excludeRects$ = popup.excludeRects$) === null || _popup$excludeRects$ === void 0 ? void 0 : _popup$excludeRects$.pipe((0, rxjs.throttleTime)(0, rxjs.animationFrameScheduler));
|
|
2576
2576
|
}, [popup.excludeRects$]), popup.excludeRects);
|
|
2577
|
-
const { canvasElement, constrainToCanvas = false, hideOnInvisible = true, hiddenType = "destroy" } = popup;
|
|
2577
|
+
const { boundaryInsets, canvasElement, constrainToCanvas = false, hideOnInvisible = true, hiddenType = "destroy" } = popup;
|
|
2578
2578
|
const hidden = (0, _wendellhu_redi_react_bindings.useObservable)(hideOnInvisible ? () => (0, rxjs.combineLatest)([anchorRect$, hiddenRects$]).pipe((0, rxjs.map)(([rectWithOffset, hiddenRects]) => {
|
|
2579
2579
|
const { top, left, bottom, right } = canvasElement.getBoundingClientRect();
|
|
2580
|
+
const insetTop = constrainToCanvas ? (boundaryInsets === null || boundaryInsets === void 0 ? void 0 : boundaryInsets.top) ?? 0 : 0;
|
|
2581
|
+
const insetLeft = constrainToCanvas ? (boundaryInsets === null || boundaryInsets === void 0 ? void 0 : boundaryInsets.left) ?? 0 : 0;
|
|
2580
2582
|
const rectHeight = rectWithOffset.bottom - rectWithOffset.top;
|
|
2581
2583
|
const rectWidth = rectWithOffset.right - rectWithOffset.left;
|
|
2582
2584
|
const isInHiddenRect = hiddenRects.some((hiddenRect) => {
|
|
@@ -2584,10 +2586,12 @@ const SingleCanvasPopup = ({ popup, children }) => {
|
|
|
2584
2586
|
const bufferX = Math.min(.5 * rectWidth, 10);
|
|
2585
2587
|
return rectWithOffset.top >= hiddenRect.top - bufferY && rectWithOffset.bottom <= hiddenRect.bottom + bufferY && rectWithOffset.left >= hiddenRect.left - bufferX && rectWithOffset.right <= hiddenRect.right + bufferX;
|
|
2586
2588
|
});
|
|
2587
|
-
return rectWithOffset.bottom < top || rectWithOffset.top > bottom || rectWithOffset.right < left || rectWithOffset.left > right || isInHiddenRect;
|
|
2589
|
+
return rectWithOffset.bottom < top + insetTop || rectWithOffset.top > bottom || rectWithOffset.right < left + insetLeft || rectWithOffset.left > right || isInHiddenRect;
|
|
2588
2590
|
})) : null, false, false, [
|
|
2589
2591
|
anchorRect$,
|
|
2592
|
+
boundaryInsets,
|
|
2590
2593
|
canvasElement,
|
|
2594
|
+
constrainToCanvas,
|
|
2591
2595
|
hiddenRects$,
|
|
2592
2596
|
hideOnInvisible
|
|
2593
2597
|
]);
|
|
@@ -2744,7 +2748,10 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
|
2744
2748
|
onClick: () => handleSelectTab(group),
|
|
2745
2749
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2746
2750
|
className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-size-9 univer-flex-shrink-0 univer-items-center univer-justify-center univer-rounded-lg", _univerjs_design.borderClassName),
|
|
2747
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
2751
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
2752
|
+
className: "univer-text-gray-500 dark:!univer-text-gray-300",
|
|
2753
|
+
preserveStrokeWidth: true
|
|
2754
|
+
})
|
|
2748
2755
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2749
2756
|
className: "univer-flex univer-flex-col",
|
|
2750
2757
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
@@ -2762,7 +2769,10 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
|
|
|
2762
2769
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
|
|
2763
2770
|
className: "univer-mr-2 univer-flex univer-h-7 univer-cursor-pointer univer-items-center univer-gap-1.5 univer-whitespace-nowrap !univer-rounded-full univer-bg-gray-700 univer-pl-3 univer-pr-2 univer-text-sm univer-text-gray-0 dark:!univer-bg-gray-200 dark:!univer-text-gray-800",
|
|
2764
2771
|
onClick: () => setGroupSelectorVisible(true),
|
|
2765
|
-
children: [localeService.t(activatedTabTitle), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {
|
|
2772
|
+
children: [localeService.t(activatedTabTitle), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {
|
|
2773
|
+
className: "univer-text-gray-200 dark:!univer-text-gray-500",
|
|
2774
|
+
preserveStrokeWidth: true
|
|
2775
|
+
})]
|
|
2766
2776
|
})
|
|
2767
2777
|
});
|
|
2768
2778
|
}
|
|
@@ -2882,7 +2892,7 @@ function getCells(row, column, rowSpan, columnSpan) {
|
|
|
2882
2892
|
* @param props
|
|
2883
2893
|
*/
|
|
2884
2894
|
function CustomLabel(props) {
|
|
2885
|
-
const { className, iconSize, title, icon, label, value, value$ } = props;
|
|
2895
|
+
const { className, iconSize, preserveStrokeWidth, title, icon, label, value, value$ } = props;
|
|
2886
2896
|
const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
|
|
2887
2897
|
const componentManager = (0, _wendellhu_redi_react_bindings.useDependency)(ComponentManager);
|
|
2888
2898
|
const iconManager = (0, _wendellhu_redi_react_bindings.useDependency)(IconManager);
|
|
@@ -2906,7 +2916,8 @@ function CustomLabel(props) {
|
|
|
2906
2916
|
width: iconSize,
|
|
2907
2917
|
height: iconSize
|
|
2908
2918
|
} : void 0,
|
|
2909
|
-
extend: { colorChannel1: isValid ? String(realValue) : "var(--univer-primary-600)" }
|
|
2919
|
+
extend: { colorChannel1: isValid ? String(realValue) : "var(--univer-primary-600)" },
|
|
2920
|
+
preserveStrokeWidth
|
|
2910
2921
|
}, index++));
|
|
2911
2922
|
}
|
|
2912
2923
|
if (label) {
|
|
@@ -3067,6 +3078,7 @@ function ToolbarTooltip(props) {
|
|
|
3067
3078
|
}, [popupOpen]);
|
|
3068
3079
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
|
|
3069
3080
|
...tooltipProps,
|
|
3081
|
+
className: (0, _univerjs_design.clsx)("univer-fill-mode-backwards univer-delay-100", tooltipProps.className),
|
|
3070
3082
|
visible: !popupOpen && tooltipVisible,
|
|
3071
3083
|
onVisibleChange: (visible) => {
|
|
3072
3084
|
if (!popupOpen) setTooltipVisible(visible);
|
|
@@ -3155,7 +3167,7 @@ function DropdownWrapper(props) {
|
|
|
3155
3167
|
})
|
|
3156
3168
|
});
|
|
3157
3169
|
}
|
|
3158
|
-
function DropdownMenuLabel({ icon, value, option, onOptionSelect }) {
|
|
3170
|
+
function DropdownMenuLabel({ icon, value, option, preserveStrokeWidth, onOptionSelect }) {
|
|
3159
3171
|
var _option$label;
|
|
3160
3172
|
const onChange = (v) => {
|
|
3161
3173
|
onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
|
|
@@ -3172,6 +3184,7 @@ function DropdownMenuLabel({ icon, value, option, onOptionSelect }) {
|
|
|
3172
3184
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
|
|
3173
3185
|
className: "univer-text-sm",
|
|
3174
3186
|
icon,
|
|
3187
|
+
preserveStrokeWidth,
|
|
3175
3188
|
value$: option.value$,
|
|
3176
3189
|
value: option.value,
|
|
3177
3190
|
label: option.label,
|
|
@@ -3179,7 +3192,10 @@ function DropdownMenuLabel({ icon, value, option, onOptionSelect }) {
|
|
|
3179
3192
|
})
|
|
3180
3193
|
}), hasCheckMark && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3181
3194
|
className: "univer-ml-auto univer-flex univer-w-4 univer-flex-shrink-0 univer-justify-end",
|
|
3182
|
-
children: selected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CheckMarkIcon, {
|
|
3195
|
+
children: selected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CheckMarkIcon, {
|
|
3196
|
+
className: "univer-text-primary-600",
|
|
3197
|
+
preserveStrokeWidth
|
|
3198
|
+
})
|
|
3183
3199
|
})]
|
|
3184
3200
|
});
|
|
3185
3201
|
}
|
|
@@ -3187,7 +3203,7 @@ function getOptionKey(option) {
|
|
|
3187
3203
|
var _option$label2;
|
|
3188
3204
|
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));
|
|
3189
3205
|
}
|
|
3190
|
-
function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, onOptionSelect }) {
|
|
3206
|
+
function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, preserveStrokeWidth, onOptionSelect }) {
|
|
3191
3207
|
const { dropdownVisible, setDropdownVisible } = (0, react.useContext)(TooltipWrapperContext);
|
|
3192
3208
|
(0, react.useEffect)(() => {
|
|
3193
3209
|
if (disabled) setDropdownVisible(false);
|
|
@@ -3231,6 +3247,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3231
3247
|
overlay: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuLabel, {
|
|
3232
3248
|
value,
|
|
3233
3249
|
option,
|
|
3250
|
+
preserveStrokeWidth,
|
|
3234
3251
|
onOptionSelect: handleOptionSelect
|
|
3235
3252
|
}, getOptionKey(option))),
|
|
3236
3253
|
children
|
|
@@ -3250,6 +3267,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3250
3267
|
icon: option.icon,
|
|
3251
3268
|
value,
|
|
3252
3269
|
option,
|
|
3270
|
+
preserveStrokeWidth,
|
|
3253
3271
|
onOptionSelect: handleOptionSelect
|
|
3254
3272
|
}),
|
|
3255
3273
|
disabled: option.disabled,
|
|
@@ -3269,6 +3287,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3269
3287
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuLabel, {
|
|
3270
3288
|
icon,
|
|
3271
3289
|
value,
|
|
3290
|
+
preserveStrokeWidth,
|
|
3272
3291
|
option: { label: {
|
|
3273
3292
|
name: title,
|
|
3274
3293
|
selectable: false
|
|
@@ -3305,6 +3324,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3305
3324
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuLabel, {
|
|
3306
3325
|
icon,
|
|
3307
3326
|
value,
|
|
3327
|
+
preserveStrokeWidth,
|
|
3308
3328
|
option: { label: {
|
|
3309
3329
|
name: title,
|
|
3310
3330
|
selectable: false
|
|
@@ -3422,7 +3442,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3422
3442
|
layoutService.focus();
|
|
3423
3443
|
commandService.executeCommand(commandId, params);
|
|
3424
3444
|
};
|
|
3425
|
-
const { tooltip, shortcut, icon, title, label, id, commandId, type, slot, params, grid, large, showLabel, iconSize, iconColor, fullWidth } = props;
|
|
3445
|
+
const { tooltip, shortcut, icon, title, label, id, commandId, type, slot, params, grid, large, showLabel, iconSize, iconColor, fullWidth, preserveStrokeWidth } = props;
|
|
3426
3446
|
const gridLabel = title ?? tooltip;
|
|
3427
3447
|
const shortcutDisplay = useToolbarShortcutDisplay({
|
|
3428
3448
|
id,
|
|
@@ -3492,6 +3512,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3492
3512
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
|
|
3493
3513
|
icon: iconToDisplay,
|
|
3494
3514
|
iconSize,
|
|
3515
|
+
preserveStrokeWidth,
|
|
3495
3516
|
title: titleToDisplay,
|
|
3496
3517
|
value: iconColor ?? value,
|
|
3497
3518
|
label,
|
|
@@ -3503,6 +3524,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3503
3524
|
value,
|
|
3504
3525
|
options,
|
|
3505
3526
|
disabled,
|
|
3527
|
+
preserveStrokeWidth,
|
|
3506
3528
|
onOptionSelect: handleSelect,
|
|
3507
3529
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3508
3530
|
className: (0, _univerjs_design.clsx)(toolbarButtonSelectorTriggerVariants({
|
|
@@ -3513,7 +3535,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3513
3535
|
"univer-h-full": grid && !large
|
|
3514
3536
|
}),
|
|
3515
3537
|
"data-disabled": disabled,
|
|
3516
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {})
|
|
3538
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { preserveStrokeWidth })
|
|
3517
3539
|
})
|
|
3518
3540
|
})]
|
|
3519
3541
|
});
|
|
@@ -3523,6 +3545,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3523
3545
|
value,
|
|
3524
3546
|
options,
|
|
3525
3547
|
disabled,
|
|
3548
|
+
preserveStrokeWidth,
|
|
3526
3549
|
onOptionSelect: handleSelect,
|
|
3527
3550
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3528
3551
|
"data-u-command": id,
|
|
@@ -3537,7 +3560,8 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3537
3560
|
}, grid && !large && !icon && _univerjs_design.borderClassName),
|
|
3538
3561
|
children: grid && large ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
|
|
3539
3562
|
icon: iconToDisplay,
|
|
3540
|
-
iconSize
|
|
3563
|
+
iconSize,
|
|
3564
|
+
preserveStrokeWidth
|
|
3541
3565
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3542
3566
|
className: (0, _univerjs_design.clsx)(toolbarSelectorTriggerVariants({ disabled }), "univer-h-4 univer-justify-center univer-gap-0.5"),
|
|
3543
3567
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
|
|
@@ -3545,17 +3569,18 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3545
3569
|
value,
|
|
3546
3570
|
label,
|
|
3547
3571
|
onChange: handleSelectionsValueChange
|
|
3548
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {})]
|
|
3572
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { preserveStrokeWidth })]
|
|
3549
3573
|
})] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
|
|
3550
3574
|
icon: iconToDisplay,
|
|
3551
3575
|
iconSize,
|
|
3576
|
+
preserveStrokeWidth,
|
|
3552
3577
|
title: titleToDisplay,
|
|
3553
3578
|
value,
|
|
3554
3579
|
label,
|
|
3555
3580
|
onChange: handleSelectionsValueChange
|
|
3556
3581
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3557
3582
|
className: (0, _univerjs_design.clsx)(toolbarSelectorTriggerVariants({ disabled }), { "univer-ml-auto rtl:univer-ml-0 rtl:univer-mr-auto": grid && !large && !icon }),
|
|
3558
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {})
|
|
3583
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { preserveStrokeWidth })
|
|
3559
3584
|
})] })
|
|
3560
3585
|
})
|
|
3561
3586
|
});
|
|
@@ -3601,6 +3626,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
|
|
|
3601
3626
|
children: icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
|
|
3602
3627
|
icon,
|
|
3603
3628
|
iconSize,
|
|
3629
|
+
preserveStrokeWidth,
|
|
3604
3630
|
title: grid && (large || showLabel) ? gridLabel : void 0
|
|
3605
3631
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, { title })
|
|
3606
3632
|
});
|
|
@@ -3654,7 +3680,8 @@ function RibbonGrid({ groups, title, className, ...props }) {
|
|
|
3654
3680
|
large: placement.rowSpan > 1,
|
|
3655
3681
|
showLabel: placement.showLabel,
|
|
3656
3682
|
iconSize: placement.iconSize,
|
|
3657
|
-
fullWidth: placement.width !== void 0
|
|
3683
|
+
fullWidth: placement.width !== void 0,
|
|
3684
|
+
preserveStrokeWidth: true
|
|
3658
3685
|
})
|
|
3659
3686
|
}, placement.item.key))
|
|
3660
3687
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -3789,6 +3816,7 @@ function Ribbon(props) {
|
|
|
3789
3816
|
className: "univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2 empty:univer-hidden",
|
|
3790
3817
|
children: groupItem.children && ((_groupItem$children2 = groupItem.children) === null || _groupItem$children2 === void 0 ? void 0 : _groupItem$children2.map((child) => child.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, {
|
|
3791
3818
|
...child.item,
|
|
3819
|
+
preserveStrokeWidth: true,
|
|
3792
3820
|
ref: (ref) => {
|
|
3793
3821
|
if (ref === null || ref === void 0 ? void 0 : ref.el) toolbarItemRefs.current[child.key] = {
|
|
3794
3822
|
el: ref.el,
|
|
@@ -3866,7 +3894,10 @@ function Ribbon(props) {
|
|
|
3866
3894
|
var _groupItem$children3, _groupItem$children4;
|
|
3867
3895
|
return (((_groupItem$children3 = groupItem.children) === null || _groupItem$children3 === void 0 ? void 0 : _groupItem$children3.length) || groupItem.item) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3868
3896
|
className: "univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2 empty:univer-hidden",
|
|
3869
|
-
children: groupItem.children && ((_groupItem$children4 = groupItem.children) === null || _groupItem$children4 === void 0 ? void 0 : _groupItem$children4.map((child) => child.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, {
|
|
3897
|
+
children: groupItem.children && ((_groupItem$children4 = groupItem.children) === null || _groupItem$children4 === void 0 ? void 0 : _groupItem$children4.map((child) => child.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, {
|
|
3898
|
+
...child.item,
|
|
3899
|
+
preserveStrokeWidth: true
|
|
3900
|
+
}, child.key)))
|
|
3870
3901
|
}) }, groupItem.key);
|
|
3871
3902
|
}), collapsedIds.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3872
3903
|
className: "univer-pl-2 rtl:univer-pr-2",
|
|
@@ -3884,7 +3915,13 @@ function Ribbon(props) {
|
|
|
3884
3915
|
className: "univer-flex univer-items-center univer-gap-2",
|
|
3885
3916
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3886
3917
|
className: "univer-flex univer-flex-wrap univer-gap-2",
|
|
3887
|
-
children: groupItem.children ? (_groupItem$children5 = groupItem.children) === null || _groupItem$children5 === void 0 ? void 0 : _groupItem$children5.map((child) => child.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, {
|
|
3918
|
+
children: groupItem.children ? (_groupItem$children5 = groupItem.children) === null || _groupItem$children5 === void 0 ? void 0 : _groupItem$children5.map((child) => child.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, {
|
|
3919
|
+
...child.item,
|
|
3920
|
+
preserveStrokeWidth: true
|
|
3921
|
+
}, child.key)) : groupItem.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, {
|
|
3922
|
+
...groupItem.item,
|
|
3923
|
+
preserveStrokeWidth: true
|
|
3924
|
+
}, groupItem.key)
|
|
3888
3925
|
})
|
|
3889
3926
|
}, groupItem.key);
|
|
3890
3927
|
})
|
|
@@ -3892,7 +3929,7 @@ function Ribbon(props) {
|
|
|
3892
3929
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3893
3930
|
type: "button",
|
|
3894
3931
|
className: toolbarButtonClassName,
|
|
3895
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreVerticalIcon, {})
|
|
3932
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreVerticalIcon, { preserveStrokeWidth: true })
|
|
3896
3933
|
})
|
|
3897
3934
|
})
|
|
3898
3935
|
})] }, activatedTab)
|
|
@@ -3962,12 +3999,34 @@ var ThemeSwitcherService = class extends _univerjs_core.Disposable {
|
|
|
3962
3999
|
//#endregion
|
|
3963
4000
|
//#region src/services/workbench/workbench.service.ts
|
|
3964
4001
|
const IWorkbenchService = (0, _univerjs_core.createIdentifier)("univer.ui.workbench.service");
|
|
3965
|
-
|
|
3966
|
-
constructor(
|
|
3967
|
-
super(
|
|
4002
|
+
let WorkbenchService = class WorkbenchService extends _univerjs_core.Disposable {
|
|
4003
|
+
constructor(univerInstanceService) {
|
|
4004
|
+
super();
|
|
3968
4005
|
_defineProperty(this, "_tokens", /* @__PURE__ */ new Set());
|
|
4006
|
+
_defineProperty(this, "_subscriptions", new rxjs.Subscription());
|
|
4007
|
+
_defineProperty(this, "_rootUnitId", null);
|
|
4008
|
+
_defineProperty(this, "_rootUnitType$", new rxjs.BehaviorSubject(null));
|
|
3969
4009
|
_defineProperty(this, "_skeletonVisible$", new rxjs.BehaviorSubject(false));
|
|
4010
|
+
_defineProperty(this, "rootUnitType$", this._rootUnitType$.asObservable());
|
|
3970
4011
|
_defineProperty(this, "skeletonVisible$", this._skeletonVisible$.asObservable());
|
|
4012
|
+
this._subscriptions.add(univerInstanceService.unitAdded$.subscribe(({ unit, options }) => {
|
|
4013
|
+
const unitId = unit.getUnitId();
|
|
4014
|
+
if ((options === null || options === void 0 ? void 0 : options.makeCurrent) === false || !isWorkbenchRootUnit(unitId, options)) return;
|
|
4015
|
+
this._setRootUnit(unitId, unit.type);
|
|
4016
|
+
}));
|
|
4017
|
+
this._subscriptions.add(univerInstanceService.focused$.subscribe((unitId) => {
|
|
4018
|
+
if (!unitId) return;
|
|
4019
|
+
const unit = univerInstanceService.getUnit(unitId);
|
|
4020
|
+
if (unit && isWorkbenchRootUnit(unitId, univerInstanceService.getUnitCreateOptions(unitId) ?? void 0)) this._setRootUnit(unitId, unit.type);
|
|
4021
|
+
}));
|
|
4022
|
+
this._subscriptions.add(univerInstanceService.unitDisposed$.subscribe((unit) => {
|
|
4023
|
+
const unitId = unit.getUnitId();
|
|
4024
|
+
if (this._rootUnitId === unitId) this._setRootUnit(null, null);
|
|
4025
|
+
}));
|
|
4026
|
+
}
|
|
4027
|
+
_setRootUnit(unitId, unitType) {
|
|
4028
|
+
this._rootUnitId = unitId;
|
|
4029
|
+
if (this._rootUnitType$.getValue() !== unitType) this._rootUnitType$.next(unitType);
|
|
3971
4030
|
}
|
|
3972
4031
|
acquireSkeleton() {
|
|
3973
4032
|
const token = Symbol("workbench-skeleton");
|
|
@@ -3980,11 +4039,18 @@ var WorkbenchService = class extends _univerjs_core.Disposable {
|
|
|
3980
4039
|
return this.disposeWithMe(disposable);
|
|
3981
4040
|
}
|
|
3982
4041
|
dispose() {
|
|
3983
|
-
|
|
4042
|
+
this._subscriptions.unsubscribe();
|
|
3984
4043
|
this._tokens.clear();
|
|
4044
|
+
this._rootUnitId = null;
|
|
4045
|
+
this._rootUnitType$.complete();
|
|
3985
4046
|
this._skeletonVisible$.complete();
|
|
4047
|
+
super.dispose();
|
|
3986
4048
|
}
|
|
3987
4049
|
};
|
|
4050
|
+
WorkbenchService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService))], WorkbenchService);
|
|
4051
|
+
function isWorkbenchRootUnit(unitId, options) {
|
|
4052
|
+
return !(0, _univerjs_core.isInternalEditorID)(unitId) && !(options === null || options === void 0 ? void 0 : options.skipAutoRender) && !(options === null || options === void 0 ? void 0 : options.embeddedRender);
|
|
4053
|
+
}
|
|
3988
4054
|
|
|
3989
4055
|
//#endregion
|
|
3990
4056
|
//#region src/services/contextmenu/contextmenu.service.ts
|
|
@@ -4274,6 +4340,7 @@ function DesignTinyMenuGroup({ items, columns, sizeVariant = "default", layoutVa
|
|
|
4274
4340
|
})
|
|
4275
4341
|
}, item.key);
|
|
4276
4342
|
return showTooltip ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
|
|
4343
|
+
className: "univer-fill-mode-backwards univer-delay-100",
|
|
4277
4344
|
title: item.tooltip,
|
|
4278
4345
|
children: ele
|
|
4279
4346
|
}, item.key) : ele;
|
|
@@ -6262,7 +6329,7 @@ const IUIController = (0, _univerjs_core.createIdentifier)("univer.ui.ui-control
|
|
|
6262
6329
|
//#endregion
|
|
6263
6330
|
//#region package.json
|
|
6264
6331
|
var name = "@univerjs/ui";
|
|
6265
|
-
var version = "1.0.0-beta.
|
|
6332
|
+
var version = "1.0.0-beta.2";
|
|
6266
6333
|
|
|
6267
6334
|
//#endregion
|
|
6268
6335
|
//#region src/views/color-picker/interface.ts
|
|
@@ -23608,7 +23675,10 @@ function MobileRibbon(props) {
|
|
|
23608
23675
|
disabled: activeIndex === 0,
|
|
23609
23676
|
"aria-label": localeService.t("ui.navigation.previous"),
|
|
23610
23677
|
onClick: () => selectTab(activeIndex - 1),
|
|
23611
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreLeftIcon, {
|
|
23678
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreLeftIcon, {
|
|
23679
|
+
className: "univer-rotate-180 univer-text-sm",
|
|
23680
|
+
preserveStrokeWidth: true
|
|
23681
|
+
})
|
|
23612
23682
|
})
|
|
23613
23683
|
}),
|
|
23614
23684
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -23645,7 +23715,10 @@ function MobileRibbon(props) {
|
|
|
23645
23715
|
disabled: activeIndex >= ribbon.length - 1,
|
|
23646
23716
|
"aria-label": localeService.t("ui.navigation.next"),
|
|
23647
23717
|
onClick: () => selectTab(activeIndex + 1),
|
|
23648
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreRightIcon, {
|
|
23718
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreRightIcon, {
|
|
23719
|
+
className: "univer-text-sm",
|
|
23720
|
+
preserveStrokeWidth: true
|
|
23721
|
+
})
|
|
23649
23722
|
}), hasHeaderMenu && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
23650
23723
|
className: "univer-flex univer-items-center univer-gap-1 [&>*]:univer-m-0 [&>*]:univer-inline-flex [&>*]:univer-min-h-7 [&>*]:univer-min-w-7 [&>*]:univer-appearance-none [&>*]:univer-items-center [&>*]:univer-justify-center [&>*]:univer-rounded-md [&>*]:univer-border-0 [&>*]:univer-px-1.5 [&>*]:univer-leading-none [&>*]:univer-outline-none",
|
|
23651
23724
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, { components: headerMenuComponents })
|
|
@@ -23665,7 +23738,10 @@ function MobileRibbon(props) {
|
|
|
23665
23738
|
disabled: !canScrollLeft,
|
|
23666
23739
|
"aria-label": localeService.t("ui.navigation.previous"),
|
|
23667
23740
|
onClick: () => scrollToolbar("left"),
|
|
23668
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreLeftIcon, {
|
|
23741
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreLeftIcon, {
|
|
23742
|
+
className: "univer-text-sm",
|
|
23743
|
+
preserveStrokeWidth: true
|
|
23744
|
+
})
|
|
23669
23745
|
}),
|
|
23670
23746
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
23671
23747
|
ref: toolbarScrollRef,
|
|
@@ -23679,7 +23755,10 @@ function MobileRibbon(props) {
|
|
|
23679
23755
|
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 }),
|
|
23680
23756
|
children: groupItems.map((child) => child.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
23681
23757
|
className: (0, _univerjs_design.clsx)("[&_button]:!univer-font-inherit univer-flex univer-h-8 univer-shrink-0 univer-items-center univer-rounded-md [&_*]:univer-box-border [&_.univer-custom-label]:univer-text-sm [&_.univer-custom-label]:univer-leading-none [&_.univer-toolbar-button-selector-main]:!univer-h-8 [&_.univer-toolbar-button-selector-main]:!univer-rounded-none [&_.univer-toolbar-button-selector-main]:!univer-rounded-l-md [&_.univer-toolbar-button-selector-main]:!univer-px-1.5 [&_.univer-toolbar-button-selector-root]:!univer-h-8 [&_.univer-toolbar-button-selector-root]:univer-overflow-hidden [&_.univer-toolbar-button-selector-root]:!univer-rounded-md [&_.univer-toolbar-button-selector-root]:!univer-pr-0 [&_.univer-toolbar-button-selector-trigger]:!univer-static [&_.univer-toolbar-button-selector-trigger]:!univer-h-8 [&_.univer-toolbar-button-selector-trigger]:!univer-w-6 [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-none [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-r-md [&_.univer-toolbar-selector-root]:!univer-h-8 [&_.univer-toolbar-selector-root]:!univer-gap-1 [&_.univer-toolbar-selector-root]:!univer-rounded-md [&_.univer-toolbar-selector-root]:!univer-px-1.5 [&_.univer-toolbar-selector-trigger]:!univer-pl-0.5 [&_.univer-tooltip]:univer-inline-flex [&_.univer-tooltip]:univer-h-full [&_.univer-tooltip]:univer-items-center [&_[data-u-command]]:!univer-h-8 [&_[data-u-command]]:!univer-min-h-8 [&_[data-u-command]]:!univer-rounded-md [&_[data-u-command]]:!univer-px-1.5 [&_button]:!univer-m-0 [&_button]:!univer-h-8 [&_button]:!univer-min-w-8 [&_button]:!univer-appearance-none [&_button]:!univer-rounded-md [&_button]:!univer-border-0 [&_button]:!univer-bg-transparent [&_button]:!univer-p-0 [&_button]:!univer-px-1.5 [&_button]:!univer-leading-none [&_button]:!univer-outline-none [&_input]:!univer-m-0 [&_input]:!univer-appearance-none [&_input]:!univer-border-0 [&_input]:!univer-bg-transparent [&_input]:!univer-p-0 [&_input]:!univer-leading-none [&_input]:!univer-outline-none"),
|
|
23682
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, {
|
|
23758
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, {
|
|
23759
|
+
...child.item,
|
|
23760
|
+
preserveStrokeWidth: true
|
|
23761
|
+
})
|
|
23683
23762
|
}, child.key))
|
|
23684
23763
|
}, groupItem.key);
|
|
23685
23764
|
})
|
|
@@ -23694,7 +23773,10 @@ function MobileRibbon(props) {
|
|
|
23694
23773
|
disabled: !canScrollRight,
|
|
23695
23774
|
"aria-label": localeService.t("ui.navigation.next"),
|
|
23696
23775
|
onClick: () => scrollToolbar("right"),
|
|
23697
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreRightIcon, {
|
|
23776
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreRightIcon, {
|
|
23777
|
+
className: "univer-text-sm",
|
|
23778
|
+
preserveStrokeWidth: true
|
|
23779
|
+
})
|
|
23698
23780
|
})
|
|
23699
23781
|
]
|
|
23700
23782
|
})]
|
|
@@ -25341,6 +25423,43 @@ let DesktopNotificationService = class DesktopNotificationService extends _unive
|
|
|
25341
25423
|
};
|
|
25342
25424
|
DesktopNotificationService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, IUIPartsService)], DesktopNotificationService);
|
|
25343
25425
|
|
|
25426
|
+
//#endregion
|
|
25427
|
+
//#region src/services/presence/unit-presence-ui-adapter.service.ts
|
|
25428
|
+
const IUnitPresenceUIAdapterRegistry = (0, _univerjs_core.createIdentifier)("ui.unit-presence-adapter-registry");
|
|
25429
|
+
const EMPTY_ADAPTERS = Object.freeze([]);
|
|
25430
|
+
var UnitPresenceUIAdapterRegistry = class extends _univerjs_core.Disposable {
|
|
25431
|
+
constructor(..._args) {
|
|
25432
|
+
super(..._args);
|
|
25433
|
+
_defineProperty(this, "_adapters", /* @__PURE__ */ new Map());
|
|
25434
|
+
_defineProperty(this, "_adapters$", new rxjs.BehaviorSubject(EMPTY_ADAPTERS));
|
|
25435
|
+
_defineProperty(this, "adapters$", this._adapters$.asObservable());
|
|
25436
|
+
}
|
|
25437
|
+
dispose() {
|
|
25438
|
+
this._adapters.clear();
|
|
25439
|
+
this._adapters$.complete();
|
|
25440
|
+
super.dispose();
|
|
25441
|
+
}
|
|
25442
|
+
register(adapter) {
|
|
25443
|
+
if (this._adapters.has(adapter.unitType)) throw new Error(`A unit presence adapter is already registered for UniverInstanceType "${adapter.unitType}".`);
|
|
25444
|
+
this._adapters.set(adapter.unitType, adapter);
|
|
25445
|
+
this._emitAdapters();
|
|
25446
|
+
return (0, _univerjs_core.toDisposable)(() => {
|
|
25447
|
+
if (this._adapters.get(adapter.unitType) !== adapter) return;
|
|
25448
|
+
this._adapters.delete(adapter.unitType);
|
|
25449
|
+
this._emitAdapters();
|
|
25450
|
+
});
|
|
25451
|
+
}
|
|
25452
|
+
get(unitType) {
|
|
25453
|
+
return this._adapters.get(unitType) ?? null;
|
|
25454
|
+
}
|
|
25455
|
+
getAll() {
|
|
25456
|
+
return this._adapters$.getValue();
|
|
25457
|
+
}
|
|
25458
|
+
_emitAdapters() {
|
|
25459
|
+
this._adapters$.next(Object.freeze(Array.from(this._adapters.values())));
|
|
25460
|
+
}
|
|
25461
|
+
};
|
|
25462
|
+
|
|
25344
25463
|
//#endregion
|
|
25345
25464
|
//#region src/services/sidebar/desktop-sidebar.service.ts
|
|
25346
25465
|
var DesktopSidebarService = class extends _univerjs_core.Disposable {
|
|
@@ -25412,6 +25531,61 @@ var DesktopSidebarService = class extends _univerjs_core.Disposable {
|
|
|
25412
25531
|
}
|
|
25413
25532
|
};
|
|
25414
25533
|
|
|
25534
|
+
//#endregion
|
|
25535
|
+
//#region src/services/undo-redo/undo-redo-group.service.ts
|
|
25536
|
+
/**
|
|
25537
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
25538
|
+
*
|
|
25539
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
25540
|
+
* you may not use this file except in compliance with the License.
|
|
25541
|
+
* You may obtain a copy of the License at
|
|
25542
|
+
*
|
|
25543
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
25544
|
+
*
|
|
25545
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
25546
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
25547
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
25548
|
+
* See the License for the specific language governing permissions and
|
|
25549
|
+
* limitations under the License.
|
|
25550
|
+
*/
|
|
25551
|
+
const HISTORY_GROUP_WINDOW = 1e3;
|
|
25552
|
+
let UndoRedoGroupService = class UndoRedoGroupService {
|
|
25553
|
+
constructor(_undoRedoService) {
|
|
25554
|
+
this._undoRedoService = _undoRedoService;
|
|
25555
|
+
_defineProperty(this, "_sessions", /* @__PURE__ */ new Map());
|
|
25556
|
+
}
|
|
25557
|
+
run(unitId, action, mode = "append") {
|
|
25558
|
+
return this._run(unitId, (0, _univerjs_core.generateRandomId)(8), mode, action);
|
|
25559
|
+
}
|
|
25560
|
+
createRunner(unitId, mode = "append") {
|
|
25561
|
+
const groupId = (0, _univerjs_core.generateRandomId)(8);
|
|
25562
|
+
return (action) => this._run(unitId, groupId, mode, action);
|
|
25563
|
+
}
|
|
25564
|
+
runTimed(unitId, scope, action, mode = "replace") {
|
|
25565
|
+
const now = Date.now();
|
|
25566
|
+
const sessionKey = `${unitId}:${scope}`;
|
|
25567
|
+
const current = this._sessions.get(sessionKey);
|
|
25568
|
+
const groupId = current && current.expiresAt >= now ? current.id : (0, _univerjs_core.generateRandomId)(8);
|
|
25569
|
+
this._sessions.set(sessionKey, {
|
|
25570
|
+
id: groupId,
|
|
25571
|
+
expiresAt: now + HISTORY_GROUP_WINDOW
|
|
25572
|
+
});
|
|
25573
|
+
if (this._sessions.size > 100) this._sessions.forEach((session, key) => {
|
|
25574
|
+
if (session.expiresAt < now) this._sessions.delete(key);
|
|
25575
|
+
});
|
|
25576
|
+
return this._run(unitId, groupId, mode, action);
|
|
25577
|
+
}
|
|
25578
|
+
_run(unitId, groupId, mode, action) {
|
|
25579
|
+
const group = this._undoRedoService.beginUndoRedoGroup(unitId, groupId, mode);
|
|
25580
|
+
try {
|
|
25581
|
+
return action();
|
|
25582
|
+
} finally {
|
|
25583
|
+
group.dispose();
|
|
25584
|
+
}
|
|
25585
|
+
}
|
|
25586
|
+
};
|
|
25587
|
+
UndoRedoGroupService = __decorate([__decorateParam(0, _univerjs_core.IUndoRedoService)], UndoRedoGroupService);
|
|
25588
|
+
|
|
25415
25589
|
//#endregion
|
|
25416
25590
|
//#region src/mobile-plugin.ts
|
|
25417
25591
|
const DISABLE_AUTO_FOCUS_KEY$1 = "DISABLE_AUTO_FOCUS";
|
|
@@ -25433,6 +25607,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends _univerjs_core.Plu
|
|
|
25433
25607
|
[IconManager],
|
|
25434
25608
|
[ComponentsController],
|
|
25435
25609
|
[ThemeSwitcherService],
|
|
25610
|
+
[UndoRedoGroupService],
|
|
25436
25611
|
[IWorkbenchService, { useClass: WorkbenchService }],
|
|
25437
25612
|
[ZIndexManager],
|
|
25438
25613
|
[ShortcutPanelService],
|
|
@@ -25441,6 +25616,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends _univerjs_core.Plu
|
|
|
25441
25616
|
[IRibbonService, { useClass: DesktopRibbonService }],
|
|
25442
25617
|
[IShortcutService, { useClass: ShortcutService }],
|
|
25443
25618
|
[IPlatformService, { useClass: PlatformService }],
|
|
25619
|
+
[IUnitPresenceUIAdapterRegistry, { useClass: UnitPresenceUIAdapterRegistry }],
|
|
25444
25620
|
[IMenuManagerService, { useClass: MenuManagerService }],
|
|
25445
25621
|
[IContextMenuHostService, { useClass: ContextMenuHostService }],
|
|
25446
25622
|
[IContextMenuService, { useClass: ContextMenuService }],
|
|
@@ -25515,98 +25691,6 @@ UniverMobileUIPlugin = __decorate([
|
|
|
25515
25691
|
__decorateParam(3, _univerjs_core.IConfigService)
|
|
25516
25692
|
], UniverMobileUIPlugin);
|
|
25517
25693
|
|
|
25518
|
-
//#endregion
|
|
25519
|
-
//#region src/services/presence/unit-presence-ui-adapter.service.ts
|
|
25520
|
-
const IUnitPresenceUIAdapterRegistry = (0, _univerjs_core.createIdentifier)("ui.unit-presence-adapter-registry");
|
|
25521
|
-
const EMPTY_ADAPTERS = Object.freeze([]);
|
|
25522
|
-
var UnitPresenceUIAdapterRegistry = class extends _univerjs_core.Disposable {
|
|
25523
|
-
constructor(..._args) {
|
|
25524
|
-
super(..._args);
|
|
25525
|
-
_defineProperty(this, "_adapters", /* @__PURE__ */ new Map());
|
|
25526
|
-
_defineProperty(this, "_adapters$", new rxjs.BehaviorSubject(EMPTY_ADAPTERS));
|
|
25527
|
-
_defineProperty(this, "adapters$", this._adapters$.asObservable());
|
|
25528
|
-
}
|
|
25529
|
-
dispose() {
|
|
25530
|
-
this._adapters.clear();
|
|
25531
|
-
this._adapters$.complete();
|
|
25532
|
-
super.dispose();
|
|
25533
|
-
}
|
|
25534
|
-
register(adapter) {
|
|
25535
|
-
if (this._adapters.has(adapter.unitType)) throw new Error(`A unit presence adapter is already registered for UniverInstanceType "${adapter.unitType}".`);
|
|
25536
|
-
this._adapters.set(adapter.unitType, adapter);
|
|
25537
|
-
this._emitAdapters();
|
|
25538
|
-
return (0, _univerjs_core.toDisposable)(() => {
|
|
25539
|
-
if (this._adapters.get(adapter.unitType) !== adapter) return;
|
|
25540
|
-
this._adapters.delete(adapter.unitType);
|
|
25541
|
-
this._emitAdapters();
|
|
25542
|
-
});
|
|
25543
|
-
}
|
|
25544
|
-
get(unitType) {
|
|
25545
|
-
return this._adapters.get(unitType) ?? null;
|
|
25546
|
-
}
|
|
25547
|
-
getAll() {
|
|
25548
|
-
return this._adapters$.getValue();
|
|
25549
|
-
}
|
|
25550
|
-
_emitAdapters() {
|
|
25551
|
-
this._adapters$.next(Object.freeze(Array.from(this._adapters.values())));
|
|
25552
|
-
}
|
|
25553
|
-
};
|
|
25554
|
-
|
|
25555
|
-
//#endregion
|
|
25556
|
-
//#region src/services/undo-redo/undo-redo-group.service.ts
|
|
25557
|
-
/**
|
|
25558
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
25559
|
-
*
|
|
25560
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
25561
|
-
* you may not use this file except in compliance with the License.
|
|
25562
|
-
* You may obtain a copy of the License at
|
|
25563
|
-
*
|
|
25564
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
25565
|
-
*
|
|
25566
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
25567
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
25568
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
25569
|
-
* See the License for the specific language governing permissions and
|
|
25570
|
-
* limitations under the License.
|
|
25571
|
-
*/
|
|
25572
|
-
const HISTORY_GROUP_WINDOW = 1e3;
|
|
25573
|
-
let UndoRedoGroupService = class UndoRedoGroupService {
|
|
25574
|
-
constructor(_undoRedoService) {
|
|
25575
|
-
this._undoRedoService = _undoRedoService;
|
|
25576
|
-
_defineProperty(this, "_sessions", /* @__PURE__ */ new Map());
|
|
25577
|
-
}
|
|
25578
|
-
run(unitId, action, mode = "append") {
|
|
25579
|
-
return this._run(unitId, (0, _univerjs_core.generateRandomId)(8), mode, action);
|
|
25580
|
-
}
|
|
25581
|
-
createRunner(unitId, mode = "append") {
|
|
25582
|
-
const groupId = (0, _univerjs_core.generateRandomId)(8);
|
|
25583
|
-
return (action) => this._run(unitId, groupId, mode, action);
|
|
25584
|
-
}
|
|
25585
|
-
runTimed(unitId, scope, action, mode = "replace") {
|
|
25586
|
-
const now = Date.now();
|
|
25587
|
-
const sessionKey = `${unitId}:${scope}`;
|
|
25588
|
-
const current = this._sessions.get(sessionKey);
|
|
25589
|
-
const groupId = current && current.expiresAt >= now ? current.id : (0, _univerjs_core.generateRandomId)(8);
|
|
25590
|
-
this._sessions.set(sessionKey, {
|
|
25591
|
-
id: groupId,
|
|
25592
|
-
expiresAt: now + HISTORY_GROUP_WINDOW
|
|
25593
|
-
});
|
|
25594
|
-
if (this._sessions.size > 100) this._sessions.forEach((session, key) => {
|
|
25595
|
-
if (session.expiresAt < now) this._sessions.delete(key);
|
|
25596
|
-
});
|
|
25597
|
-
return this._run(unitId, groupId, mode, action);
|
|
25598
|
-
}
|
|
25599
|
-
_run(unitId, groupId, mode, action) {
|
|
25600
|
-
const group = this._undoRedoService.beginUndoRedoGroup(unitId, groupId, mode);
|
|
25601
|
-
try {
|
|
25602
|
-
return action();
|
|
25603
|
-
} finally {
|
|
25604
|
-
group.dispose();
|
|
25605
|
-
}
|
|
25606
|
-
}
|
|
25607
|
-
};
|
|
25608
|
-
UndoRedoGroupService = __decorate([__decorateParam(0, _univerjs_core.IUndoRedoService)], UndoRedoGroupService);
|
|
25609
|
-
|
|
25610
25694
|
//#endregion
|
|
25611
25695
|
//#region src/plugin.ts
|
|
25612
25696
|
const DISABLE_AUTO_FOCUS_KEY = "DISABLE_AUTO_FOCUS";
|
|
@@ -26803,7 +26887,12 @@ Object.defineProperty(exports, 'WithDependency', {
|
|
|
26803
26887
|
return _wendellhu_redi_react_bindings.WithDependency;
|
|
26804
26888
|
}
|
|
26805
26889
|
});
|
|
26806
|
-
exports
|
|
26890
|
+
Object.defineProperty(exports, 'WorkbenchService', {
|
|
26891
|
+
enumerable: true,
|
|
26892
|
+
get: function () {
|
|
26893
|
+
return WorkbenchService;
|
|
26894
|
+
}
|
|
26895
|
+
});
|
|
26807
26896
|
exports.ZIndexManager = ZIndexManager;
|
|
26808
26897
|
exports.ZoomInput = ZoomInput;
|
|
26809
26898
|
Object.defineProperty(exports, 'connectDependencies', {
|