@univerjs/sheets-drawing-ui 1.0.3 → 1.1.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 +18 -43
- package/lib/cjs/index.js +510 -67
- package/lib/cjs/locale/ar-SA.js +1 -0
- package/lib/cjs/locale/ca-ES.js +1 -0
- package/lib/cjs/locale/de-DE.js +1 -0
- package/lib/cjs/locale/en-US.js +1 -0
- package/lib/cjs/locale/es-ES.js +1 -0
- package/lib/cjs/locale/fa-IR.js +1 -0
- package/lib/cjs/locale/fr-FR.js +1 -0
- package/lib/cjs/locale/id-ID.js +1 -0
- package/lib/cjs/locale/it-IT.js +1 -0
- package/lib/cjs/locale/ja-JP.js +1 -0
- package/lib/cjs/locale/ko-KR.js +1 -0
- package/lib/cjs/locale/pl-PL.js +1 -0
- package/lib/cjs/locale/pt-BR.js +1 -0
- package/lib/cjs/locale/ru-RU.js +1 -0
- package/lib/cjs/locale/sk-SK.js +1 -0
- package/lib/cjs/locale/vi-VN.js +1 -0
- package/lib/cjs/locale/zh-CN.js +1 -0
- package/lib/cjs/locale/zh-HK.js +1 -0
- package/lib/cjs/locale/zh-TW.js +1 -0
- package/lib/es/facade.js +18 -43
- package/lib/es/index.js +509 -66
- package/lib/es/locale/ar-SA.js +1 -0
- package/lib/es/locale/ca-ES.js +1 -0
- package/lib/es/locale/de-DE.js +1 -0
- package/lib/es/locale/en-US.js +1 -0
- package/lib/es/locale/es-ES.js +1 -0
- package/lib/es/locale/fa-IR.js +1 -0
- package/lib/es/locale/fr-FR.js +1 -0
- package/lib/es/locale/id-ID.js +1 -0
- package/lib/es/locale/it-IT.js +1 -0
- package/lib/es/locale/ja-JP.js +1 -0
- package/lib/es/locale/ko-KR.js +1 -0
- package/lib/es/locale/pl-PL.js +1 -0
- package/lib/es/locale/pt-BR.js +1 -0
- package/lib/es/locale/ru-RU.js +1 -0
- package/lib/es/locale/sk-SK.js +1 -0
- package/lib/es/locale/vi-VN.js +1 -0
- package/lib/es/locale/zh-CN.js +1 -0
- package/lib/es/locale/zh-HK.js +1 -0
- package/lib/es/locale/zh-TW.js +1 -0
- package/lib/facade.js +18 -43
- package/lib/index.css +290 -0
- package/lib/index.js +509 -66
- package/lib/locale/ar-SA.js +1 -0
- package/lib/locale/ca-ES.js +1 -0
- package/lib/locale/de-DE.js +1 -0
- package/lib/locale/en-US.js +1 -0
- package/lib/locale/es-ES.js +1 -0
- package/lib/locale/fa-IR.js +1 -0
- package/lib/locale/fr-FR.js +1 -0
- package/lib/locale/id-ID.js +1 -0
- package/lib/locale/it-IT.js +1 -0
- package/lib/locale/ja-JP.js +1 -0
- package/lib/locale/ko-KR.js +1 -0
- package/lib/locale/pl-PL.js +1 -0
- package/lib/locale/pt-BR.js +1 -0
- package/lib/locale/ru-RU.js +1 -0
- package/lib/locale/sk-SK.js +1 -0
- package/lib/locale/vi-VN.js +1 -0
- package/lib/locale/zh-CN.js +1 -0
- package/lib/locale/zh-HK.js +1 -0
- package/lib/locale/zh-TW.js +1 -0
- package/lib/types/commands/operations/preview-sheet-image-opacity.operation.d.ts +20 -0
- package/lib/types/controllers/sheet-drawing-active-render.controller.d.ts +7 -2
- package/lib/types/facade/f-worksheet.d.ts +1 -0
- package/lib/types/locale/en-US.d.ts +3 -0
- package/lib/types/services/canvas-float-dom-manager.service.d.ts +2 -0
- package/lib/types/views/sheet-image-panel/SheetImageTransparency.d.ts +20 -0
- package/lib/types/views/sheet-image-panel/SheetImageTransparencySlider.d.ts +24 -0
- package/lib/types/views/sheet-image-panel/sheet-drawing-panel.util.d.ts +18 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +16 -16
package/lib/cjs/index.js
CHANGED
|
@@ -428,7 +428,7 @@ function readUint32Be(bytes, offset) {
|
|
|
428
428
|
}
|
|
429
429
|
|
|
430
430
|
//#endregion
|
|
431
|
-
//#region \0@oxc-project+runtime@0.
|
|
431
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
432
432
|
function _typeof(o) {
|
|
433
433
|
"@babel/helpers - typeof";
|
|
434
434
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -439,7 +439,7 @@ function _typeof(o) {
|
|
|
439
439
|
}
|
|
440
440
|
|
|
441
441
|
//#endregion
|
|
442
|
-
//#region \0@oxc-project+runtime@0.
|
|
442
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
443
443
|
function toPrimitive(t, r) {
|
|
444
444
|
if ("object" != _typeof(t) || !t) return t;
|
|
445
445
|
var e = t[Symbol.toPrimitive];
|
|
@@ -452,14 +452,14 @@ function toPrimitive(t, r) {
|
|
|
452
452
|
}
|
|
453
453
|
|
|
454
454
|
//#endregion
|
|
455
|
-
//#region \0@oxc-project+runtime@0.
|
|
455
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
456
456
|
function toPropertyKey(t) {
|
|
457
457
|
var i = toPrimitive(t, "string");
|
|
458
458
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
459
459
|
}
|
|
460
460
|
|
|
461
461
|
//#endregion
|
|
462
|
-
//#region \0@oxc-project+runtime@0.
|
|
462
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
463
463
|
function _defineProperty(e, r, t) {
|
|
464
464
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
465
465
|
value: t,
|
|
@@ -470,7 +470,7 @@ function _defineProperty(e, r, t) {
|
|
|
470
470
|
}
|
|
471
471
|
|
|
472
472
|
//#endregion
|
|
473
|
-
//#region \0@oxc-project+runtime@0.
|
|
473
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
474
474
|
function __decorateParam(paramIndex, decorator) {
|
|
475
475
|
return function(target, key) {
|
|
476
476
|
decorator(target, key, paramIndex);
|
|
@@ -478,7 +478,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
478
478
|
}
|
|
479
479
|
|
|
480
480
|
//#endregion
|
|
481
|
-
//#region \0@oxc-project+runtime@0.
|
|
481
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
482
482
|
function __decorate(decorators, target, key, desc) {
|
|
483
483
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
484
484
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3071,7 +3071,12 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
3071
3071
|
domAnchor,
|
|
3072
3072
|
unitId,
|
|
3073
3073
|
subUnitId,
|
|
3074
|
-
id: drawingId
|
|
3074
|
+
id: drawingId,
|
|
3075
|
+
runtimeMetadata: {
|
|
3076
|
+
componentKey,
|
|
3077
|
+
data,
|
|
3078
|
+
allowTransform
|
|
3079
|
+
}
|
|
3075
3080
|
};
|
|
3076
3081
|
const initedPosition = calcSheetFloatDomPosition(domRect, renderObject.renderUnit.scene, skeletonParam.skeleton, target.worksheet, floatDomInfo);
|
|
3077
3082
|
const position$ = new rxjs.BehaviorSubject(initedPosition);
|
|
@@ -3275,7 +3280,12 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
3275
3280
|
right: viewMain.right
|
|
3276
3281
|
},
|
|
3277
3282
|
domAnchor: domLayoutParam,
|
|
3278
|
-
scrollDirectionResponse: "HORIZONTAL"
|
|
3283
|
+
scrollDirectionResponse: "HORIZONTAL",
|
|
3284
|
+
runtimeMetadata: {
|
|
3285
|
+
componentKey,
|
|
3286
|
+
data,
|
|
3287
|
+
allowTransform
|
|
3288
|
+
}
|
|
3279
3289
|
};
|
|
3280
3290
|
const initedPosition = calcSheetFloatDomPosition(domRect, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet, floatDomInfo);
|
|
3281
3291
|
const position$ = new rxjs.BehaviorSubject(initedPosition);
|
|
@@ -3718,7 +3728,7 @@ const menuSchema = {
|
|
|
3718
3728
|
//#endregion
|
|
3719
3729
|
//#region package.json
|
|
3720
3730
|
var name = "@univerjs/sheets-drawing-ui";
|
|
3721
|
-
var version = "1.0
|
|
3731
|
+
var version = "1.1.0";
|
|
3722
3732
|
|
|
3723
3733
|
//#endregion
|
|
3724
3734
|
//#region src/config/config.ts
|
|
@@ -3949,9 +3959,19 @@ function MobileBatchSaveImagesDialog() {
|
|
|
3949
3959
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BatchSaveImagesDialog, { SelectComponent: _univerjs_design.MobileSelect });
|
|
3950
3960
|
}
|
|
3951
3961
|
|
|
3962
|
+
//#endregion
|
|
3963
|
+
//#region src/views/sheet-image-panel/sheet-drawing-panel.util.ts
|
|
3964
|
+
function isSheetDrawing(drawing) {
|
|
3965
|
+
return Boolean(drawing && "sheetTransform" in drawing && drawing.sheetTransform);
|
|
3966
|
+
}
|
|
3967
|
+
|
|
3952
3968
|
//#endregion
|
|
3953
3969
|
//#region src/views/sheet-image-panel/SheetDrawingAnchor.tsx
|
|
3954
3970
|
const SheetDrawingAnchor = (props) => {
|
|
3971
|
+
function getAnchorKind(value) {
|
|
3972
|
+
if (value === _univerjs_sheets_drawing.SheetDrawingAnchorType.Position || value === _univerjs_sheets_drawing.SheetDrawingAnchorType.Both || value === _univerjs_sheets_drawing.SheetDrawingAnchorType.None) return value;
|
|
3973
|
+
return null;
|
|
3974
|
+
}
|
|
3955
3975
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
3956
3976
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
3957
3977
|
const drawingManagerService = (0, _univerjs_ui.useDependency)(_univerjs_drawing.IDrawingManagerService);
|
|
@@ -4067,12 +4087,389 @@ const SheetDrawingAnchor = (props) => {
|
|
|
4067
4087
|
}) })]
|
|
4068
4088
|
});
|
|
4069
4089
|
};
|
|
4070
|
-
|
|
4071
|
-
|
|
4090
|
+
|
|
4091
|
+
//#endregion
|
|
4092
|
+
//#region src/commands/operations/preview-sheet-image-opacity.operation.ts
|
|
4093
|
+
const PreviewSheetImageOpacityOperation = {
|
|
4094
|
+
id: "sheet.operation.preview-image-opacity",
|
|
4095
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
4096
|
+
handler: (accessor, params) => {
|
|
4097
|
+
var _renderManagerService;
|
|
4098
|
+
if (!params || !Number.isFinite(params.opacity)) return false;
|
|
4099
|
+
const scene = (_renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService).getRenderUnitById(params.unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.scene;
|
|
4100
|
+
const image = scene === null || scene === void 0 ? void 0 : scene.getObject((0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)(params));
|
|
4101
|
+
if (!(image instanceof _univerjs_engine_render.Image)) return false;
|
|
4102
|
+
image.setOpacity(Math.min(Math.max(params.opacity, 0), 1));
|
|
4103
|
+
return true;
|
|
4104
|
+
}
|
|
4105
|
+
};
|
|
4106
|
+
|
|
4107
|
+
//#endregion
|
|
4108
|
+
//#region src/views/sheet-image-panel/SheetImageTransparencySlider.tsx
|
|
4109
|
+
const MIN_TRANSPARENCY = 0;
|
|
4110
|
+
const MAX_TRANSPARENCY = 100;
|
|
4111
|
+
const TRANSPARENCY_STEP = 1;
|
|
4112
|
+
const TRANSPARENCY_PAGE_STEP = 10;
|
|
4113
|
+
const DRAG_PREVIEW_INTERVAL = 50;
|
|
4114
|
+
function SheetImageTransparencySlider(props) {
|
|
4115
|
+
const { value, shortcuts, ariaLabel, disabled = false, onChange, onChangeComplete } = props;
|
|
4116
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
4117
|
+
const isRtl = (0, _univerjs_ui.useObservable)(localeService.direction$, localeService.getDirection()) === "rtl";
|
|
4118
|
+
const sliderRailRef = (0, react.useRef)(null);
|
|
4119
|
+
const dragValueRef = (0, react.useRef)(value);
|
|
4120
|
+
const pendingDragValueRef = (0, react.useRef)(null);
|
|
4121
|
+
const lastPreviewedDragValueRef = (0, react.useRef)(value);
|
|
4122
|
+
const dragPreviewTimerRef = (0, react.useRef)(null);
|
|
4123
|
+
const dragCleanupRef = (0, react.useRef)(null);
|
|
4124
|
+
const [isDragging, setIsDragging] = (0, react.useState)(false);
|
|
4125
|
+
const [dragValue, setDragValue] = (0, react.useState)(value);
|
|
4126
|
+
(0, react.useEffect)(() => () => {
|
|
4127
|
+
var _dragCleanupRef$curre;
|
|
4128
|
+
(_dragCleanupRef$curre = dragCleanupRef.current) === null || _dragCleanupRef$curre === void 0 || _dragCleanupRef$curre.call(dragCleanupRef);
|
|
4129
|
+
clearDragPreviewTimer();
|
|
4130
|
+
}, []);
|
|
4131
|
+
function getValueByClientX(clientX) {
|
|
4132
|
+
const rail = sliderRailRef.current;
|
|
4133
|
+
if (!rail) return value;
|
|
4134
|
+
const railRect = rail.getBoundingClientRect();
|
|
4135
|
+
if (railRect.width <= 0) return value;
|
|
4136
|
+
let ratio = (clientX - railRect.left) / railRect.width;
|
|
4137
|
+
ratio = Math.min(Math.max(ratio, 0), 1);
|
|
4138
|
+
if (isRtl) ratio = 1 - ratio;
|
|
4139
|
+
return normalizeTransparency$1(MIN_TRANSPARENCY + ratio * 100);
|
|
4140
|
+
}
|
|
4141
|
+
function clearDragPreviewTimer() {
|
|
4142
|
+
if (dragPreviewTimerRef.current != null) {
|
|
4143
|
+
window.clearTimeout(dragPreviewTimerRef.current);
|
|
4144
|
+
dragPreviewTimerRef.current = null;
|
|
4145
|
+
}
|
|
4146
|
+
}
|
|
4147
|
+
function previewDragValue(nextValue) {
|
|
4148
|
+
if (nextValue === lastPreviewedDragValueRef.current) return;
|
|
4149
|
+
lastPreviewedDragValueRef.current = nextValue;
|
|
4150
|
+
onChange === null || onChange === void 0 || onChange(nextValue);
|
|
4151
|
+
}
|
|
4152
|
+
function flushDragPreview() {
|
|
4153
|
+
clearDragPreviewTimer();
|
|
4154
|
+
const nextValue = pendingDragValueRef.current;
|
|
4155
|
+
pendingDragValueRef.current = null;
|
|
4156
|
+
if (nextValue != null) previewDragValue(nextValue);
|
|
4157
|
+
}
|
|
4158
|
+
function scheduleDragPreview(nextValue) {
|
|
4159
|
+
pendingDragValueRef.current = nextValue;
|
|
4160
|
+
if (dragPreviewTimerRef.current != null) return;
|
|
4161
|
+
dragPreviewTimerRef.current = window.setTimeout(() => {
|
|
4162
|
+
dragPreviewTimerRef.current = null;
|
|
4163
|
+
const pendingValue = pendingDragValueRef.current;
|
|
4164
|
+
pendingDragValueRef.current = null;
|
|
4165
|
+
if (pendingValue != null) previewDragValue(pendingValue);
|
|
4166
|
+
}, DRAG_PREVIEW_INTERVAL);
|
|
4167
|
+
}
|
|
4168
|
+
function updateDragValue(clientX) {
|
|
4169
|
+
const nextValue = getValueByClientX(clientX);
|
|
4170
|
+
dragValueRef.current = nextValue;
|
|
4171
|
+
setDragValue(nextValue);
|
|
4172
|
+
return nextValue;
|
|
4173
|
+
}
|
|
4174
|
+
function handlePointerDown(e) {
|
|
4175
|
+
var _dragCleanupRef$curre2;
|
|
4176
|
+
if (disabled) return;
|
|
4177
|
+
e.preventDefault();
|
|
4178
|
+
e.stopPropagation();
|
|
4179
|
+
(_dragCleanupRef$curre2 = dragCleanupRef.current) === null || _dragCleanupRef$curre2 === void 0 || _dragCleanupRef$curre2.call(dragCleanupRef);
|
|
4180
|
+
clearDragPreviewTimer();
|
|
4181
|
+
pendingDragValueRef.current = null;
|
|
4182
|
+
lastPreviewedDragValueRef.current = value;
|
|
4183
|
+
setIsDragging(true);
|
|
4184
|
+
scheduleDragPreview(updateDragValue(e.clientX));
|
|
4185
|
+
function cleanup() {
|
|
4186
|
+
window.removeEventListener("pointermove", handlePointerMove);
|
|
4187
|
+
window.removeEventListener("pointerup", handlePointerUp);
|
|
4188
|
+
window.removeEventListener("pointercancel", handlePointerUp);
|
|
4189
|
+
dragCleanupRef.current = null;
|
|
4190
|
+
}
|
|
4191
|
+
function handlePointerMove(event) {
|
|
4192
|
+
scheduleDragPreview(updateDragValue(event.clientX));
|
|
4193
|
+
}
|
|
4194
|
+
function handlePointerUp() {
|
|
4195
|
+
cleanup();
|
|
4196
|
+
flushDragPreview();
|
|
4197
|
+
setIsDragging(false);
|
|
4198
|
+
onChangeComplete === null || onChangeComplete === void 0 || onChangeComplete(dragValueRef.current);
|
|
4199
|
+
}
|
|
4200
|
+
dragCleanupRef.current = cleanup;
|
|
4201
|
+
window.addEventListener("pointermove", handlePointerMove);
|
|
4202
|
+
window.addEventListener("pointerup", handlePointerUp);
|
|
4203
|
+
window.addEventListener("pointercancel", handlePointerUp);
|
|
4204
|
+
}
|
|
4205
|
+
function handleSliderKeyDown(e) {
|
|
4206
|
+
let nextValue = null;
|
|
4207
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowDown") nextValue = value - TRANSPARENCY_STEP;
|
|
4208
|
+
else if (e.key === "ArrowRight" || e.key === "ArrowUp") nextValue = value + TRANSPARENCY_STEP;
|
|
4209
|
+
else if (e.key === "PageDown") nextValue = value - TRANSPARENCY_PAGE_STEP;
|
|
4210
|
+
else if (e.key === "PageUp") nextValue = value + TRANSPARENCY_PAGE_STEP;
|
|
4211
|
+
else if (e.key === "Home") nextValue = MIN_TRANSPARENCY;
|
|
4212
|
+
else if (e.key === "End") nextValue = MAX_TRANSPARENCY;
|
|
4213
|
+
if (nextValue == null || disabled) return;
|
|
4214
|
+
e.preventDefault();
|
|
4215
|
+
e.stopPropagation();
|
|
4216
|
+
const normalizedValue = normalizeTransparency$1(nextValue);
|
|
4217
|
+
onChange === null || onChange === void 0 || onChange(normalizedValue);
|
|
4218
|
+
onChangeComplete === null || onChangeComplete === void 0 || onChangeComplete(normalizedValue);
|
|
4219
|
+
}
|
|
4220
|
+
const visualValue = isDragging ? dragValue : value;
|
|
4221
|
+
const sliderOffset = normalizeTransparency$1(visualValue);
|
|
4222
|
+
const handleOffset = isRtl ? MAX_TRANSPARENCY - sliderOffset : sliderOffset;
|
|
4223
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4224
|
+
className: (0, _univerjs_design.clsx)("univer-flex univer-select-none univer-items-center univer-gap-1.5", { "univer-cursor-not-allowed": disabled }),
|
|
4225
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4226
|
+
className: "univer-flex univer-h-6 univer-min-w-0 univer-flex-1 univer-items-center",
|
|
4227
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4228
|
+
className: (0, _univerjs_design.clsx)("univer-relative univer-h-1.5 univer-w-full univer-rounded-full univer-bg-gray-200 univer-px-1.5 univer-transition-colors dark:!univer-bg-gray-600", { "univer-opacity-60": disabled }),
|
|
4229
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4230
|
+
ref: sliderRailRef,
|
|
4231
|
+
"data-u-comp": "sheet-image-transparency-slider-track",
|
|
4232
|
+
className: "univer-relative univer-h-1.5 univer-bg-gray-200 dark:!univer-bg-gray-600",
|
|
4233
|
+
onPointerDown: handlePointerDown,
|
|
4234
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4235
|
+
className: (0, _univerjs_design.clsx)("univer-bg-primary-500/60 univer-absolute univer-top-0 univer-h-full univer-rounded-full", isRtl ? "univer-right-0" : "univer-left-0"),
|
|
4236
|
+
style: { width: `${sliderOffset}%` }
|
|
4237
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4238
|
+
className: (0, _univerjs_design.clsx)("univer-absolute univer-top-1/2 univer-size-3.5 -univer-translate-x-1/2 -univer-translate-y-1/2 univer-rounded-full univer-bg-gray-0 univer-shadow-sm focus-visible:univer-outline-none focus-visible:univer-ring-2 focus-visible:univer-ring-primary-100 dark:!univer-bg-gray-800", _univerjs_design.borderClassName, {
|
|
4239
|
+
"univer-cursor-pointer hover:univer-border-primary-600 hover:univer-shadow-md": !disabled,
|
|
4240
|
+
"univer-cursor-not-allowed": disabled,
|
|
4241
|
+
"univer-scale-105 univer-border-primary-600 univer-shadow-md": isDragging,
|
|
4242
|
+
"univer-transition-all": !isDragging,
|
|
4243
|
+
"univer-transition-none": isDragging
|
|
4244
|
+
}),
|
|
4245
|
+
role: "slider",
|
|
4246
|
+
"aria-label": ariaLabel,
|
|
4247
|
+
"aria-valuemin": MIN_TRANSPARENCY,
|
|
4248
|
+
"aria-valuemax": MAX_TRANSPARENCY,
|
|
4249
|
+
"aria-valuenow": visualValue,
|
|
4250
|
+
"aria-valuetext": `${visualValue}%`,
|
|
4251
|
+
disabled,
|
|
4252
|
+
type: "button",
|
|
4253
|
+
style: { left: `${handleOffset}%` },
|
|
4254
|
+
onKeyDown: handleSliderKeyDown
|
|
4255
|
+
})]
|
|
4256
|
+
})
|
|
4257
|
+
})
|
|
4258
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetImageTransparencyInput, {
|
|
4259
|
+
value,
|
|
4260
|
+
shortcuts,
|
|
4261
|
+
ariaLabel,
|
|
4262
|
+
disabled,
|
|
4263
|
+
onChange,
|
|
4264
|
+
onChangeComplete
|
|
4265
|
+
})]
|
|
4266
|
+
});
|
|
4267
|
+
}
|
|
4268
|
+
function SheetImageTransparencyInput(props) {
|
|
4269
|
+
const { value, shortcuts, ariaLabel, disabled = false, onChange, onChangeComplete } = props;
|
|
4270
|
+
const iconManager = (0, _univerjs_ui.useDependency)(_univerjs_ui.IconManager);
|
|
4271
|
+
const isEditingRef = (0, react.useRef)(false);
|
|
4272
|
+
const [listVisible, setListVisible] = (0, react.useState)(false);
|
|
4273
|
+
const [inputValue, setInputValue] = (0, react.useState)(() => `${value}%`);
|
|
4274
|
+
(0, react.useEffect)(() => {
|
|
4275
|
+
if (!isEditingRef.current) setInputValue(`${value}%`);
|
|
4276
|
+
}, [value]);
|
|
4277
|
+
function emitValue(nextValue) {
|
|
4278
|
+
const normalizedValue = normalizeTransparency$1(nextValue);
|
|
4279
|
+
onChange === null || onChange === void 0 || onChange(normalizedValue);
|
|
4280
|
+
onChangeComplete === null || onChangeComplete === void 0 || onChangeComplete(normalizedValue);
|
|
4281
|
+
}
|
|
4282
|
+
function handleSelect(nextValue) {
|
|
4283
|
+
if (disabled) return;
|
|
4284
|
+
setListVisible(false);
|
|
4285
|
+
emitValue(nextValue);
|
|
4286
|
+
}
|
|
4287
|
+
function handleFocus() {
|
|
4288
|
+
if (disabled) return;
|
|
4289
|
+
isEditingRef.current = true;
|
|
4290
|
+
setInputValue(String(value));
|
|
4291
|
+
}
|
|
4292
|
+
function commitInput() {
|
|
4293
|
+
if (disabled || !isEditingRef.current) return;
|
|
4294
|
+
const parsedValue = parseTransparency(inputValue);
|
|
4295
|
+
isEditingRef.current = false;
|
|
4296
|
+
if (parsedValue == null) {
|
|
4297
|
+
setInputValue(`${value}%`);
|
|
4298
|
+
return;
|
|
4299
|
+
}
|
|
4300
|
+
if (parsedValue === value) {
|
|
4301
|
+
setInputValue(`${parsedValue}%`);
|
|
4302
|
+
return;
|
|
4303
|
+
}
|
|
4304
|
+
emitValue(parsedValue);
|
|
4305
|
+
}
|
|
4306
|
+
function handleKeyDown(e) {
|
|
4307
|
+
e.stopPropagation();
|
|
4308
|
+
if (e.key === "Enter") {
|
|
4309
|
+
e.preventDefault();
|
|
4310
|
+
commitInput();
|
|
4311
|
+
e.currentTarget.blur();
|
|
4312
|
+
}
|
|
4313
|
+
}
|
|
4314
|
+
const items = [{
|
|
4315
|
+
type: "radio",
|
|
4316
|
+
value: value.toString(),
|
|
4317
|
+
options: shortcuts.map((shortcut) => ({
|
|
4318
|
+
value: shortcut.toString(),
|
|
4319
|
+
label: `${shortcut}%`
|
|
4320
|
+
})),
|
|
4321
|
+
onSelect: (selectedValue) => handleSelect(Number(selectedValue))
|
|
4322
|
+
}];
|
|
4323
|
+
const MoreDownIcon = iconManager.get("MoreDownIcon");
|
|
4324
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4325
|
+
className: (0, _univerjs_design.clsx)("univer-flex univer-h-6 univer-w-[68px] univer-flex-shrink-0 univer-items-center univer-overflow-hidden univer-rounded-md univer-border univer-border-gray-200 univer-bg-gray-0 dark:!univer-border-gray-600 dark:!univer-bg-gray-800", { "univer-opacity-60": disabled }),
|
|
4326
|
+
onClick: (e) => e.stopPropagation(),
|
|
4327
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
4328
|
+
className: "univer-box-border univer-h-6 univer-min-w-0 univer-flex-1 univer-border-none univer-bg-transparent [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-full [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-px-1 [&_input]:univer-text-center [&_input]:univer-text-xs [&_input]:univer-tabular-nums",
|
|
4329
|
+
inputClass: "univer-w-full",
|
|
4330
|
+
size: "mini",
|
|
4331
|
+
"aria-label": ariaLabel,
|
|
4332
|
+
value: inputValue,
|
|
4333
|
+
disabled,
|
|
4334
|
+
type: "text",
|
|
4335
|
+
onChange: setInputValue,
|
|
4336
|
+
onFocus: handleFocus,
|
|
4337
|
+
onBlur: commitInput,
|
|
4338
|
+
onKeyDown: handleKeyDown
|
|
4339
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
|
|
4340
|
+
align: "end",
|
|
4341
|
+
items,
|
|
4342
|
+
open: listVisible,
|
|
4343
|
+
disabled,
|
|
4344
|
+
onOpenChange: setListVisible,
|
|
4345
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
4346
|
+
className: "univer-h-6 univer-w-4 univer-rounded-none univer-p-0",
|
|
4347
|
+
size: "small",
|
|
4348
|
+
variant: "text",
|
|
4349
|
+
"aria-label": ariaLabel,
|
|
4350
|
+
disabled,
|
|
4351
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MoreDownIcon, { className: "univer-size-3 univer-text-gray-500 dark:!univer-text-gray-300" })
|
|
4352
|
+
})
|
|
4353
|
+
})]
|
|
4354
|
+
});
|
|
4072
4355
|
}
|
|
4073
|
-
function
|
|
4074
|
-
|
|
4075
|
-
return null;
|
|
4356
|
+
function parseTransparency(rawValue) {
|
|
4357
|
+
const normalizedValue = rawValue.trim().replace(/%$/, "").trim();
|
|
4358
|
+
if (normalizedValue === "") return null;
|
|
4359
|
+
const parsedValue = Number(normalizedValue);
|
|
4360
|
+
return Number.isFinite(parsedValue) ? normalizeTransparency$1(parsedValue) : null;
|
|
4361
|
+
}
|
|
4362
|
+
function normalizeTransparency$1(value) {
|
|
4363
|
+
return Math.min(Math.max(Math.round(value), MIN_TRANSPARENCY), MAX_TRANSPARENCY);
|
|
4364
|
+
}
|
|
4365
|
+
|
|
4366
|
+
//#endregion
|
|
4367
|
+
//#region src/views/sheet-image-panel/SheetImageTransparency.tsx
|
|
4368
|
+
const IMAGE_TRANSPARENCY_PRESETS = [
|
|
4369
|
+
0,
|
|
4370
|
+
15,
|
|
4371
|
+
30,
|
|
4372
|
+
50,
|
|
4373
|
+
65,
|
|
4374
|
+
80
|
|
4375
|
+
];
|
|
4376
|
+
const SheetImageTransparency = ({ drawings }) => {
|
|
4377
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
4378
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
4379
|
+
const sheetDrawingService = (0, _univerjs_ui.useDependency)(_univerjs_sheets_drawing.ISheetDrawingService);
|
|
4380
|
+
const drawingParam = isSheetDrawing(drawings[0]) ? drawings[0] : void 0;
|
|
4381
|
+
const currentDrawing = drawingParam ? sheetDrawingService.getDrawingByParam(drawingParam) ?? drawingParam : void 0;
|
|
4382
|
+
const image = (currentDrawing === null || currentDrawing === void 0 ? void 0 : currentDrawing.drawingType) === _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE ? currentDrawing : void 0;
|
|
4383
|
+
const modelOpacity = (0, _univerjs_drawing.normalizeImageOpacity)(image === null || image === void 0 ? void 0 : image.opacity);
|
|
4384
|
+
const modelTransparency = Math.round((1 - modelOpacity) * 100);
|
|
4385
|
+
const [previewState, setPreviewState] = (0, react.useState)(null);
|
|
4386
|
+
const previewPendingRef = (0, react.useRef)(false);
|
|
4387
|
+
const [, setModelRevision] = (0, react.useState)(0);
|
|
4388
|
+
const transparency = image && (previewState === null || previewState === void 0 ? void 0 : previewState.unitId) === image.unitId && previewState.subUnitId === image.subUnitId && previewState.drawingId === image.drawingId ? previewState.transparency : modelTransparency;
|
|
4389
|
+
(0, react.useEffect)(() => {
|
|
4390
|
+
if (!drawingParam) return;
|
|
4391
|
+
const subscription = sheetDrawingService.update$.subscribe((updatedDrawings) => {
|
|
4392
|
+
if (updatedDrawings.some((updatedDrawing) => updatedDrawing.unitId === drawingParam.unitId && updatedDrawing.subUnitId === drawingParam.subUnitId && updatedDrawing.drawingId === drawingParam.drawingId)) setModelRevision((revision) => revision + 1);
|
|
4393
|
+
});
|
|
4394
|
+
return () => subscription.unsubscribe();
|
|
4395
|
+
}, [drawingParam, sheetDrawingService]);
|
|
4396
|
+
(0, react.useEffect)(() => {
|
|
4397
|
+
previewPendingRef.current = false;
|
|
4398
|
+
return () => {
|
|
4399
|
+
if (!previewPendingRef.current || !image) return;
|
|
4400
|
+
commandService.syncExecuteCommand(PreviewSheetImageOpacityOperation.id, {
|
|
4401
|
+
unitId: image.unitId,
|
|
4402
|
+
subUnitId: image.subUnitId,
|
|
4403
|
+
drawingId: image.drawingId,
|
|
4404
|
+
opacity: modelOpacity
|
|
4405
|
+
});
|
|
4406
|
+
};
|
|
4407
|
+
}, [
|
|
4408
|
+
commandService,
|
|
4409
|
+
image,
|
|
4410
|
+
modelOpacity,
|
|
4411
|
+
modelTransparency
|
|
4412
|
+
]);
|
|
4413
|
+
if (!image) return null;
|
|
4414
|
+
const title = localeService.t("sheets-drawing-ui.image-transparency.title");
|
|
4415
|
+
const { unitId, subUnitId, drawingId } = image;
|
|
4416
|
+
function previewTransparency(nextTransparency) {
|
|
4417
|
+
const normalizedTransparency = normalizeTransparency(nextTransparency);
|
|
4418
|
+
const opacity = transparencyToOpacity(normalizedTransparency);
|
|
4419
|
+
previewPendingRef.current = true;
|
|
4420
|
+
setPreviewState({
|
|
4421
|
+
unitId,
|
|
4422
|
+
subUnitId,
|
|
4423
|
+
drawingId,
|
|
4424
|
+
transparency: normalizedTransparency
|
|
4425
|
+
});
|
|
4426
|
+
commandService.syncExecuteCommand(PreviewSheetImageOpacityOperation.id, {
|
|
4427
|
+
unitId,
|
|
4428
|
+
subUnitId,
|
|
4429
|
+
drawingId,
|
|
4430
|
+
opacity
|
|
4431
|
+
});
|
|
4432
|
+
}
|
|
4433
|
+
function commitTransparency(nextTransparency) {
|
|
4434
|
+
const opacity = transparencyToOpacity(normalizeTransparency(nextTransparency));
|
|
4435
|
+
previewPendingRef.current = false;
|
|
4436
|
+
setPreviewState(null);
|
|
4437
|
+
if (opacity === modelOpacity) return;
|
|
4438
|
+
if (!commandService.syncExecuteCommand(_univerjs_sheets_drawing.SetSheetDrawingCommand.id, {
|
|
4439
|
+
unitId,
|
|
4440
|
+
drawings: [{
|
|
4441
|
+
unitId,
|
|
4442
|
+
subUnitId,
|
|
4443
|
+
drawingId,
|
|
4444
|
+
opacity
|
|
4445
|
+
}]
|
|
4446
|
+
})) commandService.syncExecuteCommand(PreviewSheetImageOpacityOperation.id, {
|
|
4447
|
+
unitId,
|
|
4448
|
+
subUnitId,
|
|
4449
|
+
drawingId,
|
|
4450
|
+
opacity: modelOpacity
|
|
4451
|
+
});
|
|
4452
|
+
}
|
|
4453
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
4454
|
+
className: "univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",
|
|
4455
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
|
|
4456
|
+
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
4457
|
+
children: title
|
|
4458
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetImageTransparencySlider, {
|
|
4459
|
+
value: transparency,
|
|
4460
|
+
shortcuts: IMAGE_TRANSPARENCY_PRESETS,
|
|
4461
|
+
ariaLabel: title,
|
|
4462
|
+
onChange: previewTransparency,
|
|
4463
|
+
onChangeComplete: commitTransparency
|
|
4464
|
+
})]
|
|
4465
|
+
});
|
|
4466
|
+
};
|
|
4467
|
+
function normalizeTransparency(transparency) {
|
|
4468
|
+
if (!Number.isFinite(transparency)) return 0;
|
|
4469
|
+
return Math.min(Math.max(Math.round(transparency), 0), 100);
|
|
4470
|
+
}
|
|
4471
|
+
function transparencyToOpacity(transparency) {
|
|
4472
|
+
return (100 - transparency) / 100;
|
|
4076
4473
|
}
|
|
4077
4474
|
|
|
4078
4475
|
//#endregion
|
|
@@ -4097,7 +4494,11 @@ const SheetDrawingPanel = () => {
|
|
|
4097
4494
|
const drawings = (0, _univerjs_ui.useObservable)(() => drawingManagerService.focus$, drawingManagerService.getFocusDrawings(), false, [drawingManagerService]);
|
|
4098
4495
|
return !!(drawings === null || drawings === void 0 ? void 0 : drawings.length) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4099
4496
|
className: "univer-text-sm",
|
|
4100
|
-
children: [
|
|
4497
|
+
children: [
|
|
4498
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_drawing_ui.DrawingCommonPanel, { drawings }),
|
|
4499
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetImageTransparency, { drawings }),
|
|
4500
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetDrawingAnchor, { drawings })
|
|
4501
|
+
]
|
|
4101
4502
|
});
|
|
4102
4503
|
};
|
|
4103
4504
|
|
|
@@ -4508,80 +4909,121 @@ SheetCellImageCopyPasteController = __decorate([
|
|
|
4508
4909
|
//#endregion
|
|
4509
4910
|
//#region src/controllers/sheet-drawing-active-render.controller.ts
|
|
4510
4911
|
let SheetDrawingActiveRenderController = class SheetDrawingActiveRenderController extends _univerjs_core.Disposable {
|
|
4511
|
-
constructor(_context, _commandService, _sheetSkeletonService, _sheetDrawingService, _drawingManagerService) {
|
|
4912
|
+
constructor(_context, _commandService, _sheetSkeletonService, _sheetDrawingService, _drawingManagerService, _logService) {
|
|
4512
4913
|
super();
|
|
4513
4914
|
this._context = _context;
|
|
4514
4915
|
this._commandService = _commandService;
|
|
4515
4916
|
this._sheetSkeletonService = _sheetSkeletonService;
|
|
4516
4917
|
this._sheetDrawingService = _sheetDrawingService;
|
|
4517
4918
|
this._drawingManagerService = _drawingManagerService;
|
|
4919
|
+
this._logService = _logService;
|
|
4920
|
+
_defineProperty(this, "_renderTimeout", void 0);
|
|
4518
4921
|
this._commandListener();
|
|
4519
4922
|
}
|
|
4923
|
+
dispose() {
|
|
4924
|
+
this._cancelPendingRender();
|
|
4925
|
+
super.dispose();
|
|
4926
|
+
}
|
|
4927
|
+
_cancelPendingRender() {
|
|
4928
|
+
if (this._renderTimeout !== void 0) {
|
|
4929
|
+
clearTimeout(this._renderTimeout);
|
|
4930
|
+
this._renderTimeout = void 0;
|
|
4931
|
+
}
|
|
4932
|
+
}
|
|
4933
|
+
_scheduleRender(callback) {
|
|
4934
|
+
this._cancelPendingRender();
|
|
4935
|
+
this._renderTimeout = setTimeout(() => {
|
|
4936
|
+
this._renderTimeout = void 0;
|
|
4937
|
+
callback();
|
|
4938
|
+
}, 0);
|
|
4939
|
+
}
|
|
4520
4940
|
_commandListener() {
|
|
4941
|
+
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
4942
|
+
if (command.id !== _univerjs_sheets.SetWorksheetActiveOperation.id) return;
|
|
4943
|
+
const { unitId, subUnitId } = command.params;
|
|
4944
|
+
const { unit, unitId: contextUnitId } = this._context;
|
|
4945
|
+
if (unitId !== contextUnitId || !unit.getSheetBySheetId(subUnitId) || unit.getActiveSheet().getSheetId() === subUnitId) return;
|
|
4946
|
+
this._clearDrawings(unitId, subUnitId);
|
|
4947
|
+
}));
|
|
4521
4948
|
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
4522
4949
|
if (command.id === _univerjs_sheets.SetWorksheetActiveOperation.id) {
|
|
4523
4950
|
const { unitId, subUnitId } = command.params;
|
|
4524
|
-
this._updateDrawings(unitId, subUnitId);
|
|
4951
|
+
if (unitId === this._context.unitId && subUnitId === this._context.unit.getActiveSheet().getSheetId()) this._updateDrawings(unitId, subUnitId);
|
|
4525
4952
|
}
|
|
4526
4953
|
}));
|
|
4527
4954
|
this.disposeWithMe(this._context.activated$.subscribe((activated) => {
|
|
4528
4955
|
const { unit, unitId } = this._context;
|
|
4529
|
-
if (activated)
|
|
4530
|
-
|
|
4956
|
+
if (activated) {
|
|
4957
|
+
const subUnitId = unit.getActiveSheet().getSheetId();
|
|
4958
|
+
this._clearDrawings(unitId, subUnitId);
|
|
4959
|
+
this._updateDrawings(unitId, subUnitId);
|
|
4960
|
+
} else this._clearDrawings(unitId);
|
|
4531
4961
|
}));
|
|
4532
4962
|
}
|
|
4533
|
-
_clearDrawings(
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
});
|
|
4545
|
-
});
|
|
4546
|
-
});
|
|
4547
|
-
this._sheetDrawingService.removeNotification(removeDrawings);
|
|
4548
|
-
this._drawingManagerService.removeNotification(removeDrawings);
|
|
4549
|
-
});
|
|
4963
|
+
_clearDrawings(unitId, keepSubUnitId) {
|
|
4964
|
+
this._cancelPendingRender();
|
|
4965
|
+
const subUnitMap = this._drawingManagerService.drawingManagerData[unitId] ?? {};
|
|
4966
|
+
const removeDrawings = [];
|
|
4967
|
+
for (const subUnitId of Object.keys(subUnitMap)) {
|
|
4968
|
+
var _subUnitMap$subUnitId;
|
|
4969
|
+
if (subUnitId === keepSubUnitId) continue;
|
|
4970
|
+
for (const drawing of Object.values(((_subUnitMap$subUnitId = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId === void 0 ? void 0 : _subUnitMap$subUnitId.data) ?? {})) removeDrawings.push(drawing);
|
|
4971
|
+
}
|
|
4972
|
+
this._sheetDrawingService.removeNotification(removeDrawings);
|
|
4973
|
+
this._drawingManagerService.removeNotification(removeDrawings);
|
|
4550
4974
|
}
|
|
4551
4975
|
_updateDrawings(showUnitId, showSubunitId) {
|
|
4552
|
-
|
|
4976
|
+
this._scheduleRender(() => {
|
|
4977
|
+
var _subUnitMap$showSubun;
|
|
4553
4978
|
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(showUnitId, showSubunitId);
|
|
4554
|
-
const
|
|
4555
|
-
const
|
|
4556
|
-
const removeDrawings = [];
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
const subUnitMap = drawingMap[unitId] ?? {};
|
|
4560
|
-
Object.keys(subUnitMap).forEach((subUnitId) => {
|
|
4561
|
-
var _subUnitMap$subUnitId2;
|
|
4562
|
-
const drawingData = ((_subUnitMap$subUnitId2 = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId2 === void 0 ? void 0 : _subUnitMap$subUnitId2.data) ?? {};
|
|
4563
|
-
Object.keys(drawingData).forEach((drawingId) => {
|
|
4564
|
-
if (unitId === showUnitId && subUnitId === showSubunitId) {
|
|
4565
|
-
const drawing = drawingData[drawingId];
|
|
4566
|
-
if (drawing.sheetTransform && drawing.anchorType !== _univerjs_sheets_drawing.SheetDrawingAnchorType.None) drawing.transform = (0, _univerjs_sheets_drawing.drawingPositionToTransform)(drawing.sheetTransform, sheetSkeletonParam);
|
|
4567
|
-
insertDrawings.push(drawingData[drawingId]);
|
|
4568
|
-
} else removeDrawings.push(drawingData[drawingId]);
|
|
4569
|
-
});
|
|
4570
|
-
});
|
|
4571
|
-
});
|
|
4979
|
+
const drawingData = ((_subUnitMap$showSubun = (this._drawingManagerService.drawingManagerData[showUnitId] ?? {})[showSubunitId]) === null || _subUnitMap$showSubun === void 0 ? void 0 : _subUnitMap$showSubun.data) ?? {};
|
|
4980
|
+
const { successDrawings, refreshedDrawings, failures } = prepareSheetDrawings(Object.values(drawingData), sheetSkeletonParam === null || sheetSkeletonParam === void 0 ? void 0 : sheetSkeletonParam.skeleton);
|
|
4981
|
+
const removeDrawings = failures.map(({ drawingId }) => drawingData[drawingId]);
|
|
4982
|
+
this._sheetDrawingService.refreshTransform(refreshedDrawings);
|
|
4983
|
+
this._drawingManagerService.refreshTransform(refreshedDrawings);
|
|
4572
4984
|
this._sheetDrawingService.removeNotification(removeDrawings);
|
|
4573
|
-
this._sheetDrawingService.addNotification(
|
|
4985
|
+
this._sheetDrawingService.addNotification(successDrawings);
|
|
4574
4986
|
this._drawingManagerService.removeNotification(removeDrawings);
|
|
4575
|
-
this._drawingManagerService.addNotification(
|
|
4576
|
-
|
|
4987
|
+
this._drawingManagerService.addNotification(successDrawings);
|
|
4988
|
+
if (failures.length) this._logService.error("[SheetDrawingActiveRenderController]", {
|
|
4989
|
+
unitId: showUnitId,
|
|
4990
|
+
subUnitId: showSubunitId,
|
|
4991
|
+
failures
|
|
4992
|
+
});
|
|
4993
|
+
});
|
|
4577
4994
|
}
|
|
4578
4995
|
};
|
|
4579
4996
|
SheetDrawingActiveRenderController = __decorate([
|
|
4580
4997
|
__decorateParam(1, _univerjs_core.ICommandService),
|
|
4581
4998
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetSkeletonService)),
|
|
4582
4999
|
__decorateParam(3, _univerjs_sheets_drawing.ISheetDrawingService),
|
|
4583
|
-
__decorateParam(4, _univerjs_drawing.IDrawingManagerService)
|
|
5000
|
+
__decorateParam(4, _univerjs_drawing.IDrawingManagerService),
|
|
5001
|
+
__decorateParam(5, _univerjs_core.ILogService)
|
|
4584
5002
|
], SheetDrawingActiveRenderController);
|
|
5003
|
+
function prepareSheetDrawings(drawings, skeleton) {
|
|
5004
|
+
const successDrawings = [];
|
|
5005
|
+
const refreshedDrawings = [];
|
|
5006
|
+
const failures = [];
|
|
5007
|
+
for (const drawing of drawings) {
|
|
5008
|
+
if (skeleton && drawing.sheetTransform && drawing.anchorType !== _univerjs_sheets_drawing.SheetDrawingAnchorType.None) try {
|
|
5009
|
+
refreshedDrawings.push((0, _univerjs_sheets_drawing.applySheetDrawingPlacement)(drawing, (0, _univerjs_sheets_drawing.getSheetDrawingPlacement)(drawing), skeleton));
|
|
5010
|
+
} catch (error) {
|
|
5011
|
+
failures.push({
|
|
5012
|
+
drawingId: drawing.drawingId,
|
|
5013
|
+
drawingType: drawing.drawingType,
|
|
5014
|
+
anchorType: drawing.anchorType ?? _univerjs_sheets_drawing.SheetDrawingAnchorType.Position,
|
|
5015
|
+
error
|
|
5016
|
+
});
|
|
5017
|
+
continue;
|
|
5018
|
+
}
|
|
5019
|
+
successDrawings.push(drawing);
|
|
5020
|
+
}
|
|
5021
|
+
return {
|
|
5022
|
+
successDrawings,
|
|
5023
|
+
refreshedDrawings,
|
|
5024
|
+
failures
|
|
5025
|
+
};
|
|
5026
|
+
}
|
|
4585
5027
|
|
|
4586
5028
|
//#endregion
|
|
4587
5029
|
//#region src/controllers/sheet-drawing-copy-paste.controller.ts
|
|
@@ -5633,7 +6075,8 @@ let SheetDrawingUIController = class SheetDrawingUIController extends _univerjs_
|
|
|
5633
6075
|
MoveDrawingsCommand,
|
|
5634
6076
|
DeleteDrawingsCommand,
|
|
5635
6077
|
SaveCellImagesCommand,
|
|
5636
|
-
FlipSheetDrawingCommand
|
|
6078
|
+
FlipSheetDrawingCommand,
|
|
6079
|
+
PreviewSheetImageOpacityOperation
|
|
5637
6080
|
].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
|
|
5638
6081
|
}
|
|
5639
6082
|
_initShortcuts() {
|
|
@@ -6552,7 +6995,7 @@ UniverSheetsDrawingUIPlugin = __decorate([
|
|
|
6552
6995
|
|
|
6553
6996
|
//#endregion
|
|
6554
6997
|
exports.AddWorksheetBackgroundImageCommand = AddWorksheetBackgroundImageCommand;
|
|
6555
|
-
Object.defineProperty(exports,
|
|
6998
|
+
Object.defineProperty(exports, "BatchSaveImagesService", {
|
|
6556
6999
|
enumerable: true,
|
|
6557
7000
|
get: function () {
|
|
6558
7001
|
return BatchSaveImagesService;
|
|
@@ -6573,26 +7016,26 @@ exports.SHEETS_IMAGE_MENU_ID = SHEETS_IMAGE_MENU_ID;
|
|
|
6573
7016
|
exports.SHEET_CHART_RENDER_OBJECT_CONFIG = SHEET_CHART_RENDER_OBJECT_CONFIG;
|
|
6574
7017
|
exports.SHEET_FLOAT_DOM_PREFIX = SHEET_FLOAT_DOM_PREFIX;
|
|
6575
7018
|
exports.SaveCellImagesCommand = SaveCellImagesCommand;
|
|
6576
|
-
Object.defineProperty(exports,
|
|
7019
|
+
Object.defineProperty(exports, "SheetCanvasFloatDomManagerService", {
|
|
6577
7020
|
enumerable: true,
|
|
6578
7021
|
get: function () {
|
|
6579
7022
|
return SheetCanvasFloatDomManagerService;
|
|
6580
7023
|
}
|
|
6581
7024
|
});
|
|
6582
7025
|
exports.SheetDrawingAnchor = SheetDrawingAnchor;
|
|
6583
|
-
Object.defineProperty(exports,
|
|
7026
|
+
Object.defineProperty(exports, "SheetDrawingHitTestService", {
|
|
6584
7027
|
enumerable: true,
|
|
6585
7028
|
get: function () {
|
|
6586
7029
|
return SheetDrawingHitTestService;
|
|
6587
7030
|
}
|
|
6588
7031
|
});
|
|
6589
|
-
Object.defineProperty(exports,
|
|
7032
|
+
Object.defineProperty(exports, "SheetDrawingUpdateController", {
|
|
6590
7033
|
enumerable: true,
|
|
6591
7034
|
get: function () {
|
|
6592
7035
|
return SheetDrawingUpdateController;
|
|
6593
7036
|
}
|
|
6594
7037
|
});
|
|
6595
|
-
Object.defineProperty(exports,
|
|
7038
|
+
Object.defineProperty(exports, "SheetsDrawingGroupCopyPasteController", {
|
|
6596
7039
|
enumerable: true,
|
|
6597
7040
|
get: function () {
|
|
6598
7041
|
return SheetsDrawingGroupCopyPasteController;
|
|
@@ -6601,13 +7044,13 @@ Object.defineProperty(exports, 'SheetsDrawingGroupCopyPasteController', {
|
|
|
6601
7044
|
exports.SheetsDrawingUIMenuSchema = menuSchema;
|
|
6602
7045
|
exports.SidebarSheetDrawingOperation = SidebarSheetDrawingOperation;
|
|
6603
7046
|
exports.UngroupSheetDrawingCommand = UngroupSheetDrawingCommand;
|
|
6604
|
-
Object.defineProperty(exports,
|
|
7047
|
+
Object.defineProperty(exports, "UniverSheetsDrawingMobileUIPlugin", {
|
|
6605
7048
|
enumerable: true,
|
|
6606
7049
|
get: function () {
|
|
6607
7050
|
return UniverSheetsDrawingMobileUIPlugin;
|
|
6608
7051
|
}
|
|
6609
7052
|
});
|
|
6610
|
-
Object.defineProperty(exports,
|
|
7053
|
+
Object.defineProperty(exports, "UniverSheetsDrawingUIPlugin", {
|
|
6611
7054
|
enumerable: true,
|
|
6612
7055
|
get: function () {
|
|
6613
7056
|
return UniverSheetsDrawingUIPlugin;
|