@univerjs/sheets-drawing-ui 1.1.0 → 1.3.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/index.js +47 -21
- package/lib/es/index.js +48 -22
- package/lib/index.css +4 -0
- package/lib/index.js +48 -22
- package/lib/types/controllers/render-controllers/sheet-drawing.render-controller.d.ts +3 -2
- package/lib/umd/index.js +2 -2
- package/package.json +15 -15
package/lib/cjs/index.js
CHANGED
|
@@ -650,7 +650,7 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
|
|
|
650
650
|
if (width > _univerjs_drawing.DRAWING_IMAGE_WIDTH_LIMIT || height > _univerjs_drawing.DRAWING_IMAGE_HEIGHT_LIMIT) {
|
|
651
651
|
const scaleWidth = _univerjs_drawing.DRAWING_IMAGE_WIDTH_LIMIT / width;
|
|
652
652
|
const scaleHeight = _univerjs_drawing.DRAWING_IMAGE_HEIGHT_LIMIT / height;
|
|
653
|
-
scale = Math.
|
|
653
|
+
scale = Math.min(scaleWidth, scaleHeight);
|
|
654
654
|
}
|
|
655
655
|
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
656
656
|
if (!sheetSkeletonParam) return;
|
|
@@ -3728,7 +3728,7 @@ const menuSchema = {
|
|
|
3728
3728
|
//#endregion
|
|
3729
3729
|
//#region package.json
|
|
3730
3730
|
var name = "@univerjs/sheets-drawing-ui";
|
|
3731
|
-
var version = "1.
|
|
3731
|
+
var version = "1.3.0";
|
|
3732
3732
|
|
|
3733
3733
|
//#endregion
|
|
3734
3734
|
//#region src/config/config.ts
|
|
@@ -4232,7 +4232,7 @@ function SheetImageTransparencySlider(props) {
|
|
|
4232
4232
|
className: "univer-relative univer-h-1.5 univer-bg-gray-200 dark:!univer-bg-gray-600",
|
|
4233
4233
|
onPointerDown: handlePointerDown,
|
|
4234
4234
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4235
|
-
className: (0, _univerjs_design.clsx)("univer-
|
|
4235
|
+
className: (0, _univerjs_design.clsx)("univer-absolute univer-top-0 univer-h-full univer-rounded-full univer-bg-primary-500", isRtl ? "univer-right-0" : "univer-left-0"),
|
|
4236
4236
|
style: { width: `${sliderOffset}%` }
|
|
4237
4237
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4238
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, {
|
|
@@ -4274,6 +4274,12 @@ function SheetImageTransparencyInput(props) {
|
|
|
4274
4274
|
(0, react.useEffect)(() => {
|
|
4275
4275
|
if (!isEditingRef.current) setInputValue(`${value}%`);
|
|
4276
4276
|
}, [value]);
|
|
4277
|
+
function parseTransparency(rawValue) {
|
|
4278
|
+
const normalizedValue = rawValue.trim().replace(/%$/, "").trim();
|
|
4279
|
+
if (normalizedValue === "") return null;
|
|
4280
|
+
const parsedValue = Number(normalizedValue);
|
|
4281
|
+
return Number.isFinite(parsedValue) ? normalizeTransparency$1(parsedValue) : null;
|
|
4282
|
+
}
|
|
4277
4283
|
function emitValue(nextValue) {
|
|
4278
4284
|
const normalizedValue = normalizeTransparency$1(nextValue);
|
|
4279
4285
|
onChange === null || onChange === void 0 || onChange(normalizedValue);
|
|
@@ -4353,12 +4359,6 @@ function SheetImageTransparencyInput(props) {
|
|
|
4353
4359
|
})]
|
|
4354
4360
|
});
|
|
4355
4361
|
}
|
|
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
4362
|
function normalizeTransparency$1(value) {
|
|
4363
4363
|
return Math.min(Math.max(Math.round(value), MIN_TRANSPARENCY), MAX_TRANSPARENCY);
|
|
4364
4364
|
}
|
|
@@ -4606,12 +4606,13 @@ SheetCellImageHoverRenderController = __decorate([
|
|
|
4606
4606
|
//#endregion
|
|
4607
4607
|
//#region src/controllers/render-controllers/sheet-drawing.render-controller.ts
|
|
4608
4608
|
let SheetsDrawingRenderController = class SheetsDrawingRenderController extends _univerjs_core.Disposable {
|
|
4609
|
-
constructor(_context, _sheetDrawingService, _drawingManagerService, _sheetSkeletonService) {
|
|
4609
|
+
constructor(_context, _sheetDrawingService, _drawingManagerService, _sheetSkeletonService, _logService) {
|
|
4610
4610
|
super();
|
|
4611
4611
|
this._context = _context;
|
|
4612
4612
|
this._sheetDrawingService = _sheetDrawingService;
|
|
4613
4613
|
this._drawingManagerService = _drawingManagerService;
|
|
4614
4614
|
this._sheetSkeletonService = _sheetSkeletonService;
|
|
4615
|
+
this._logService = _logService;
|
|
4615
4616
|
this._init();
|
|
4616
4617
|
}
|
|
4617
4618
|
_init() {
|
|
@@ -4620,22 +4621,38 @@ let SheetsDrawingRenderController = class SheetsDrawingRenderController extends
|
|
|
4620
4621
|
_drawingInitializeListener() {
|
|
4621
4622
|
this._sheetDrawingService.initializeNotification(this._context.unitId);
|
|
4622
4623
|
const data = this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);
|
|
4624
|
+
const refreshedDrawings = [];
|
|
4623
4625
|
for (const subUnit in data) {
|
|
4624
4626
|
const subUnitData = data[subUnit];
|
|
4625
4627
|
for (const drawingId in subUnitData.data) {
|
|
4626
4628
|
const drawingData = subUnitData.data[drawingId];
|
|
4627
4629
|
const { unitId, subUnitId } = drawingData;
|
|
4628
4630
|
const skeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
4629
|
-
if (skeletonParam && drawingData.sheetTransform && !drawingData.groupId && drawingData.anchorType !== _univerjs_sheets_drawing.SheetDrawingAnchorType.None) {
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4631
|
+
if (skeletonParam && drawingData.sheetTransform && !drawingData.groupId && drawingData.anchorType !== _univerjs_sheets_drawing.SheetDrawingAnchorType.None) try {
|
|
4632
|
+
if (drawingData.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_GROUP) {
|
|
4633
|
+
const transform = (0, _univerjs_sheets_drawing.drawingPositionToTransform)(drawingData.sheetTransform, skeletonParam);
|
|
4634
|
+
refreshedDrawings.push({
|
|
4635
|
+
...drawingData,
|
|
4636
|
+
transform: transform && {
|
|
4637
|
+
...transform,
|
|
4638
|
+
left: (transform.left ?? 0) - skeletonParam.skeleton.rowHeaderWidthAndMarginLeft,
|
|
4639
|
+
top: (transform.top ?? 0) - skeletonParam.skeleton.columnHeaderHeightAndMarginTop
|
|
4640
|
+
}
|
|
4641
|
+
});
|
|
4642
|
+
} else refreshedDrawings.push((0, _univerjs_sheets_drawing.refreshSheetDrawingPlacement)(drawingData, skeletonParam.skeleton));
|
|
4643
|
+
} catch (error) {
|
|
4644
|
+
this._logService.warn("[SheetsDrawingRenderController]", "Skipping drawing placement initialization", {
|
|
4645
|
+
unitId,
|
|
4646
|
+
subUnitId,
|
|
4647
|
+
drawingId,
|
|
4648
|
+
transform: drawingData.transform,
|
|
4649
|
+
sheetTransform: drawingData.sheetTransform,
|
|
4650
|
+
error
|
|
4651
|
+
});
|
|
4636
4652
|
}
|
|
4637
4653
|
}
|
|
4638
4654
|
}
|
|
4655
|
+
this._sheetDrawingService.refreshTransform(refreshedDrawings);
|
|
4639
4656
|
this._drawingManagerService.registerDrawingData(this._context.unitId, this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId));
|
|
4640
4657
|
this._drawingManagerService.initializeNotification(this._context.unitId);
|
|
4641
4658
|
}
|
|
@@ -4643,7 +4660,8 @@ let SheetsDrawingRenderController = class SheetsDrawingRenderController extends
|
|
|
4643
4660
|
SheetsDrawingRenderController = __decorate([
|
|
4644
4661
|
__decorateParam(1, _univerjs_sheets_drawing.ISheetDrawingService),
|
|
4645
4662
|
__decorateParam(2, _univerjs_drawing.IDrawingManagerService),
|
|
4646
|
-
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetSkeletonService))
|
|
4663
|
+
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetSkeletonService)),
|
|
4664
|
+
__decorateParam(4, _univerjs_core.ILogService)
|
|
4647
4665
|
], SheetsDrawingRenderController);
|
|
4648
4666
|
|
|
4649
4667
|
//#endregion
|
|
@@ -4977,8 +4995,7 @@ let SheetDrawingActiveRenderController = class SheetDrawingActiveRenderControlle
|
|
|
4977
4995
|
var _subUnitMap$showSubun;
|
|
4978
4996
|
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(showUnitId, showSubunitId);
|
|
4979
4997
|
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]);
|
|
4998
|
+
const { successDrawings, refreshedDrawings, removeDrawings, failures } = prepareSheetDrawings(Object.values(drawingData), sheetSkeletonParam === null || sheetSkeletonParam === void 0 ? void 0 : sheetSkeletonParam.skeleton);
|
|
4982
4999
|
this._sheetDrawingService.refreshTransform(refreshedDrawings);
|
|
4983
5000
|
this._drawingManagerService.refreshTransform(refreshedDrawings);
|
|
4984
5001
|
this._sheetDrawingService.removeNotification(removeDrawings);
|
|
@@ -5003,11 +5020,19 @@ SheetDrawingActiveRenderController = __decorate([
|
|
|
5003
5020
|
function prepareSheetDrawings(drawings, skeleton) {
|
|
5004
5021
|
const successDrawings = [];
|
|
5005
5022
|
const refreshedDrawings = [];
|
|
5023
|
+
const removeDrawings = [];
|
|
5006
5024
|
const failures = [];
|
|
5007
5025
|
for (const drawing of drawings) {
|
|
5008
5026
|
if (skeleton && drawing.sheetTransform && drawing.anchorType !== _univerjs_sheets_drawing.SheetDrawingAnchorType.None) try {
|
|
5009
|
-
|
|
5027
|
+
var _refreshed$transform, _refreshed$transform2;
|
|
5028
|
+
const refreshed = (0, _univerjs_sheets_drawing.refreshSheetDrawingPlacement)(drawing, skeleton);
|
|
5029
|
+
refreshedDrawings.push(refreshed);
|
|
5030
|
+
if ((drawing.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE || drawing.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_DOM) && (((_refreshed$transform = refreshed.transform) === null || _refreshed$transform === void 0 ? void 0 : _refreshed$transform.width) === 0 || ((_refreshed$transform2 = refreshed.transform) === null || _refreshed$transform2 === void 0 ? void 0 : _refreshed$transform2.height) === 0)) {
|
|
5031
|
+
removeDrawings.push(drawing);
|
|
5032
|
+
continue;
|
|
5033
|
+
}
|
|
5010
5034
|
} catch (error) {
|
|
5035
|
+
removeDrawings.push(drawing);
|
|
5011
5036
|
failures.push({
|
|
5012
5037
|
drawingId: drawing.drawingId,
|
|
5013
5038
|
drawingType: drawing.drawingType,
|
|
@@ -5021,6 +5046,7 @@ function prepareSheetDrawings(drawings, skeleton) {
|
|
|
5021
5046
|
return {
|
|
5022
5047
|
successDrawings,
|
|
5023
5048
|
refreshedDrawings,
|
|
5049
|
+
removeDrawings,
|
|
5024
5050
|
failures
|
|
5025
5051
|
};
|
|
5026
5052
|
}
|
package/lib/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BooleanNumber, BuildTextUtils, CommandType, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DependentOn, Direction, Disposable, DisposableCollection, DrawingTypeEnum, FOCUSING_COMMON_DRAWINGS, FOCUSING_FX_BAR_EDITOR, FOCUSING_PANEL_EDITOR, FOCUSING_SHAPE_TEXT_EDITOR, FOCUSING_SHEET, ICommandService, IConfigService, IContextService, IImageIoService, ILogService, IPermissionService, IURLImageService, IUndoRedoService, IUniverInstanceService, ImageCacheMap, ImageSourceType, ImageUploadStatusType, Inject, Injector, InterceptorEffectEnum, LifecycleService, LifecycleStages, LocaleService, ObjectMatrix, Optional, Plugin, PositionedObjectLayoutType, RxDisposable, Tools, UniverInstanceType, UserManagerService, WrapTextType, createDocumentModelWithStyle, createIdentifier, fromEventSubject, generateRandomId, merge, mergeOverrideWithDependencies, registerDependencies, sequenceExecute, toDisposable, touchDependencies } from "@univerjs/core";
|
|
2
|
-
import { ClearSheetDrawingTransformerOperation, DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SetSheetDrawingPlacementCommand, SetWorksheetBackgroundImageCommand, SetWorksheetBackgroundImageMutation, SheetDrawingAnchorType, UniverSheetsDrawingPlugin,
|
|
2
|
+
import { ClearSheetDrawingTransformerOperation, DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SetSheetDrawingPlacementCommand, SetWorksheetBackgroundImageCommand, SetWorksheetBackgroundImageMutation, SheetDrawingAnchorType, UniverSheetsDrawingPlugin, drawingPositionToTransform, getSheetDrawingPlacement, refreshSheetDrawingPlacement, transformToAxisAlignPosition, transformToDrawingPosition } from "@univerjs/sheets-drawing";
|
|
3
3
|
import { CURSOR_TYPE, DEFAULT_TRANSFORMER_CONFIG, DRAWING_OBJECT_LAYER_INDEX, IRenderManagerService, Image, ObjectType, Rect, SHEET_EXTENSION_TYPE, SHEET_VIEWPORT_KEY, SheetExtension, UniverRenderEnginePlugin, Vector2, getCurrentTypeOfRenderer, getGroupState, transformObjectOutOfGroup } from "@univerjs/engine-render";
|
|
4
4
|
import { Button, Checkbox, CheckboxGroup, DropdownMenu, FormLayout, Input, MessageType, MobileSelect, Radio, RadioGroup, Select, borderClassName, clsx, render, unmount } from "@univerjs/design";
|
|
5
5
|
import { buildDocTransform, docDrawingPositionToTransform } from "@univerjs/docs";
|
|
@@ -649,7 +649,7 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
|
|
|
649
649
|
if (width > DRAWING_IMAGE_WIDTH_LIMIT || height > DRAWING_IMAGE_HEIGHT_LIMIT) {
|
|
650
650
|
const scaleWidth = DRAWING_IMAGE_WIDTH_LIMIT / width;
|
|
651
651
|
const scaleHeight = DRAWING_IMAGE_HEIGHT_LIMIT / height;
|
|
652
|
-
scale = Math.
|
|
652
|
+
scale = Math.min(scaleWidth, scaleHeight);
|
|
653
653
|
}
|
|
654
654
|
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
655
655
|
if (!sheetSkeletonParam) return;
|
|
@@ -3727,7 +3727,7 @@ const menuSchema = {
|
|
|
3727
3727
|
//#endregion
|
|
3728
3728
|
//#region package.json
|
|
3729
3729
|
var name = "@univerjs/sheets-drawing-ui";
|
|
3730
|
-
var version = "1.
|
|
3730
|
+
var version = "1.3.0";
|
|
3731
3731
|
|
|
3732
3732
|
//#endregion
|
|
3733
3733
|
//#region src/config/config.ts
|
|
@@ -4231,7 +4231,7 @@ function SheetImageTransparencySlider(props) {
|
|
|
4231
4231
|
className: "univer-relative univer-h-1.5 univer-bg-gray-200 dark:!univer-bg-gray-600",
|
|
4232
4232
|
onPointerDown: handlePointerDown,
|
|
4233
4233
|
children: [/* @__PURE__ */ jsx("div", {
|
|
4234
|
-
className: clsx("univer-
|
|
4234
|
+
className: clsx("univer-absolute univer-top-0 univer-h-full univer-rounded-full univer-bg-primary-500", isRtl ? "univer-right-0" : "univer-left-0"),
|
|
4235
4235
|
style: { width: `${sliderOffset}%` }
|
|
4236
4236
|
}), /* @__PURE__ */ jsx("button", {
|
|
4237
4237
|
className: 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", borderClassName, {
|
|
@@ -4273,6 +4273,12 @@ function SheetImageTransparencyInput(props) {
|
|
|
4273
4273
|
useEffect(() => {
|
|
4274
4274
|
if (!isEditingRef.current) setInputValue(`${value}%`);
|
|
4275
4275
|
}, [value]);
|
|
4276
|
+
function parseTransparency(rawValue) {
|
|
4277
|
+
const normalizedValue = rawValue.trim().replace(/%$/, "").trim();
|
|
4278
|
+
if (normalizedValue === "") return null;
|
|
4279
|
+
const parsedValue = Number(normalizedValue);
|
|
4280
|
+
return Number.isFinite(parsedValue) ? normalizeTransparency$1(parsedValue) : null;
|
|
4281
|
+
}
|
|
4276
4282
|
function emitValue(nextValue) {
|
|
4277
4283
|
const normalizedValue = normalizeTransparency$1(nextValue);
|
|
4278
4284
|
onChange === null || onChange === void 0 || onChange(normalizedValue);
|
|
@@ -4352,12 +4358,6 @@ function SheetImageTransparencyInput(props) {
|
|
|
4352
4358
|
})]
|
|
4353
4359
|
});
|
|
4354
4360
|
}
|
|
4355
|
-
function parseTransparency(rawValue) {
|
|
4356
|
-
const normalizedValue = rawValue.trim().replace(/%$/, "").trim();
|
|
4357
|
-
if (normalizedValue === "") return null;
|
|
4358
|
-
const parsedValue = Number(normalizedValue);
|
|
4359
|
-
return Number.isFinite(parsedValue) ? normalizeTransparency$1(parsedValue) : null;
|
|
4360
|
-
}
|
|
4361
4361
|
function normalizeTransparency$1(value) {
|
|
4362
4362
|
return Math.min(Math.max(Math.round(value), MIN_TRANSPARENCY), MAX_TRANSPARENCY);
|
|
4363
4363
|
}
|
|
@@ -4605,12 +4605,13 @@ SheetCellImageHoverRenderController = __decorate([
|
|
|
4605
4605
|
//#endregion
|
|
4606
4606
|
//#region src/controllers/render-controllers/sheet-drawing.render-controller.ts
|
|
4607
4607
|
let SheetsDrawingRenderController = class SheetsDrawingRenderController extends Disposable {
|
|
4608
|
-
constructor(_context, _sheetDrawingService, _drawingManagerService, _sheetSkeletonService) {
|
|
4608
|
+
constructor(_context, _sheetDrawingService, _drawingManagerService, _sheetSkeletonService, _logService) {
|
|
4609
4609
|
super();
|
|
4610
4610
|
this._context = _context;
|
|
4611
4611
|
this._sheetDrawingService = _sheetDrawingService;
|
|
4612
4612
|
this._drawingManagerService = _drawingManagerService;
|
|
4613
4613
|
this._sheetSkeletonService = _sheetSkeletonService;
|
|
4614
|
+
this._logService = _logService;
|
|
4614
4615
|
this._init();
|
|
4615
4616
|
}
|
|
4616
4617
|
_init() {
|
|
@@ -4619,22 +4620,38 @@ let SheetsDrawingRenderController = class SheetsDrawingRenderController extends
|
|
|
4619
4620
|
_drawingInitializeListener() {
|
|
4620
4621
|
this._sheetDrawingService.initializeNotification(this._context.unitId);
|
|
4621
4622
|
const data = this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);
|
|
4623
|
+
const refreshedDrawings = [];
|
|
4622
4624
|
for (const subUnit in data) {
|
|
4623
4625
|
const subUnitData = data[subUnit];
|
|
4624
4626
|
for (const drawingId in subUnitData.data) {
|
|
4625
4627
|
const drawingData = subUnitData.data[drawingId];
|
|
4626
4628
|
const { unitId, subUnitId } = drawingData;
|
|
4627
4629
|
const skeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
4628
|
-
if (skeletonParam && drawingData.sheetTransform && !drawingData.groupId && drawingData.anchorType !== SheetDrawingAnchorType.None) {
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4630
|
+
if (skeletonParam && drawingData.sheetTransform && !drawingData.groupId && drawingData.anchorType !== SheetDrawingAnchorType.None) try {
|
|
4631
|
+
if (drawingData.drawingType === DrawingTypeEnum.DRAWING_GROUP) {
|
|
4632
|
+
const transform = drawingPositionToTransform(drawingData.sheetTransform, skeletonParam);
|
|
4633
|
+
refreshedDrawings.push({
|
|
4634
|
+
...drawingData,
|
|
4635
|
+
transform: transform && {
|
|
4636
|
+
...transform,
|
|
4637
|
+
left: (transform.left ?? 0) - skeletonParam.skeleton.rowHeaderWidthAndMarginLeft,
|
|
4638
|
+
top: (transform.top ?? 0) - skeletonParam.skeleton.columnHeaderHeightAndMarginTop
|
|
4639
|
+
}
|
|
4640
|
+
});
|
|
4641
|
+
} else refreshedDrawings.push(refreshSheetDrawingPlacement(drawingData, skeletonParam.skeleton));
|
|
4642
|
+
} catch (error) {
|
|
4643
|
+
this._logService.warn("[SheetsDrawingRenderController]", "Skipping drawing placement initialization", {
|
|
4644
|
+
unitId,
|
|
4645
|
+
subUnitId,
|
|
4646
|
+
drawingId,
|
|
4647
|
+
transform: drawingData.transform,
|
|
4648
|
+
sheetTransform: drawingData.sheetTransform,
|
|
4649
|
+
error
|
|
4650
|
+
});
|
|
4635
4651
|
}
|
|
4636
4652
|
}
|
|
4637
4653
|
}
|
|
4654
|
+
this._sheetDrawingService.refreshTransform(refreshedDrawings);
|
|
4638
4655
|
this._drawingManagerService.registerDrawingData(this._context.unitId, this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId));
|
|
4639
4656
|
this._drawingManagerService.initializeNotification(this._context.unitId);
|
|
4640
4657
|
}
|
|
@@ -4642,7 +4659,8 @@ let SheetsDrawingRenderController = class SheetsDrawingRenderController extends
|
|
|
4642
4659
|
SheetsDrawingRenderController = __decorate([
|
|
4643
4660
|
__decorateParam(1, ISheetDrawingService),
|
|
4644
4661
|
__decorateParam(2, IDrawingManagerService),
|
|
4645
|
-
__decorateParam(3, Inject(SheetSkeletonService))
|
|
4662
|
+
__decorateParam(3, Inject(SheetSkeletonService)),
|
|
4663
|
+
__decorateParam(4, ILogService)
|
|
4646
4664
|
], SheetsDrawingRenderController);
|
|
4647
4665
|
|
|
4648
4666
|
//#endregion
|
|
@@ -4976,8 +4994,7 @@ let SheetDrawingActiveRenderController = class SheetDrawingActiveRenderControlle
|
|
|
4976
4994
|
var _subUnitMap$showSubun;
|
|
4977
4995
|
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(showUnitId, showSubunitId);
|
|
4978
4996
|
const drawingData = ((_subUnitMap$showSubun = (this._drawingManagerService.drawingManagerData[showUnitId] ?? {})[showSubunitId]) === null || _subUnitMap$showSubun === void 0 ? void 0 : _subUnitMap$showSubun.data) ?? {};
|
|
4979
|
-
const { successDrawings, refreshedDrawings, failures } = prepareSheetDrawings(Object.values(drawingData), sheetSkeletonParam === null || sheetSkeletonParam === void 0 ? void 0 : sheetSkeletonParam.skeleton);
|
|
4980
|
-
const removeDrawings = failures.map(({ drawingId }) => drawingData[drawingId]);
|
|
4997
|
+
const { successDrawings, refreshedDrawings, removeDrawings, failures } = prepareSheetDrawings(Object.values(drawingData), sheetSkeletonParam === null || sheetSkeletonParam === void 0 ? void 0 : sheetSkeletonParam.skeleton);
|
|
4981
4998
|
this._sheetDrawingService.refreshTransform(refreshedDrawings);
|
|
4982
4999
|
this._drawingManagerService.refreshTransform(refreshedDrawings);
|
|
4983
5000
|
this._sheetDrawingService.removeNotification(removeDrawings);
|
|
@@ -5002,11 +5019,19 @@ SheetDrawingActiveRenderController = __decorate([
|
|
|
5002
5019
|
function prepareSheetDrawings(drawings, skeleton) {
|
|
5003
5020
|
const successDrawings = [];
|
|
5004
5021
|
const refreshedDrawings = [];
|
|
5022
|
+
const removeDrawings = [];
|
|
5005
5023
|
const failures = [];
|
|
5006
5024
|
for (const drawing of drawings) {
|
|
5007
5025
|
if (skeleton && drawing.sheetTransform && drawing.anchorType !== SheetDrawingAnchorType.None) try {
|
|
5008
|
-
|
|
5026
|
+
var _refreshed$transform, _refreshed$transform2;
|
|
5027
|
+
const refreshed = refreshSheetDrawingPlacement(drawing, skeleton);
|
|
5028
|
+
refreshedDrawings.push(refreshed);
|
|
5029
|
+
if ((drawing.drawingType === DrawingTypeEnum.DRAWING_IMAGE || drawing.drawingType === DrawingTypeEnum.DRAWING_DOM) && (((_refreshed$transform = refreshed.transform) === null || _refreshed$transform === void 0 ? void 0 : _refreshed$transform.width) === 0 || ((_refreshed$transform2 = refreshed.transform) === null || _refreshed$transform2 === void 0 ? void 0 : _refreshed$transform2.height) === 0)) {
|
|
5030
|
+
removeDrawings.push(drawing);
|
|
5031
|
+
continue;
|
|
5032
|
+
}
|
|
5009
5033
|
} catch (error) {
|
|
5034
|
+
removeDrawings.push(drawing);
|
|
5010
5035
|
failures.push({
|
|
5011
5036
|
drawingId: drawing.drawingId,
|
|
5012
5037
|
drawingType: drawing.drawingType,
|
|
@@ -5020,6 +5045,7 @@ function prepareSheetDrawings(drawings, skeleton) {
|
|
|
5020
5045
|
return {
|
|
5021
5046
|
successDrawings,
|
|
5022
5047
|
refreshedDrawings,
|
|
5048
|
+
removeDrawings,
|
|
5023
5049
|
failures
|
|
5024
5050
|
};
|
|
5025
5051
|
}
|
package/lib/index.css
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BooleanNumber, BuildTextUtils, CommandType, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DependentOn, Direction, Disposable, DisposableCollection, DrawingTypeEnum, FOCUSING_COMMON_DRAWINGS, FOCUSING_FX_BAR_EDITOR, FOCUSING_PANEL_EDITOR, FOCUSING_SHAPE_TEXT_EDITOR, FOCUSING_SHEET, ICommandService, IConfigService, IContextService, IImageIoService, ILogService, IPermissionService, IURLImageService, IUndoRedoService, IUniverInstanceService, ImageCacheMap, ImageSourceType, ImageUploadStatusType, Inject, Injector, InterceptorEffectEnum, LifecycleService, LifecycleStages, LocaleService, ObjectMatrix, Optional, Plugin, PositionedObjectLayoutType, RxDisposable, Tools, UniverInstanceType, UserManagerService, WrapTextType, createDocumentModelWithStyle, createIdentifier, fromEventSubject, generateRandomId, merge, mergeOverrideWithDependencies, registerDependencies, sequenceExecute, toDisposable, touchDependencies } from "@univerjs/core";
|
|
2
|
-
import { ClearSheetDrawingTransformerOperation, DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SetSheetDrawingPlacementCommand, SetWorksheetBackgroundImageCommand, SetWorksheetBackgroundImageMutation, SheetDrawingAnchorType, UniverSheetsDrawingPlugin,
|
|
2
|
+
import { ClearSheetDrawingTransformerOperation, DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SetSheetDrawingPlacementCommand, SetWorksheetBackgroundImageCommand, SetWorksheetBackgroundImageMutation, SheetDrawingAnchorType, UniverSheetsDrawingPlugin, drawingPositionToTransform, getSheetDrawingPlacement, refreshSheetDrawingPlacement, transformToAxisAlignPosition, transformToDrawingPosition } from "@univerjs/sheets-drawing";
|
|
3
3
|
import { CURSOR_TYPE, DEFAULT_TRANSFORMER_CONFIG, DRAWING_OBJECT_LAYER_INDEX, IRenderManagerService, Image, ObjectType, Rect, SHEET_EXTENSION_TYPE, SHEET_VIEWPORT_KEY, SheetExtension, UniverRenderEnginePlugin, Vector2, getCurrentTypeOfRenderer, getGroupState, transformObjectOutOfGroup } from "@univerjs/engine-render";
|
|
4
4
|
import { Button, Checkbox, CheckboxGroup, DropdownMenu, FormLayout, Input, MessageType, MobileSelect, Radio, RadioGroup, Select, borderClassName, clsx, render, unmount } from "@univerjs/design";
|
|
5
5
|
import { buildDocTransform, docDrawingPositionToTransform } from "@univerjs/docs";
|
|
@@ -649,7 +649,7 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
|
|
|
649
649
|
if (width > DRAWING_IMAGE_WIDTH_LIMIT || height > DRAWING_IMAGE_HEIGHT_LIMIT) {
|
|
650
650
|
const scaleWidth = DRAWING_IMAGE_WIDTH_LIMIT / width;
|
|
651
651
|
const scaleHeight = DRAWING_IMAGE_HEIGHT_LIMIT / height;
|
|
652
|
-
scale = Math.
|
|
652
|
+
scale = Math.min(scaleWidth, scaleHeight);
|
|
653
653
|
}
|
|
654
654
|
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
655
655
|
if (!sheetSkeletonParam) return;
|
|
@@ -3727,7 +3727,7 @@ const menuSchema = {
|
|
|
3727
3727
|
//#endregion
|
|
3728
3728
|
//#region package.json
|
|
3729
3729
|
var name = "@univerjs/sheets-drawing-ui";
|
|
3730
|
-
var version = "1.
|
|
3730
|
+
var version = "1.3.0";
|
|
3731
3731
|
|
|
3732
3732
|
//#endregion
|
|
3733
3733
|
//#region src/config/config.ts
|
|
@@ -4231,7 +4231,7 @@ function SheetImageTransparencySlider(props) {
|
|
|
4231
4231
|
className: "univer-relative univer-h-1.5 univer-bg-gray-200 dark:!univer-bg-gray-600",
|
|
4232
4232
|
onPointerDown: handlePointerDown,
|
|
4233
4233
|
children: [/* @__PURE__ */ jsx("div", {
|
|
4234
|
-
className: clsx("univer-
|
|
4234
|
+
className: clsx("univer-absolute univer-top-0 univer-h-full univer-rounded-full univer-bg-primary-500", isRtl ? "univer-right-0" : "univer-left-0"),
|
|
4235
4235
|
style: { width: `${sliderOffset}%` }
|
|
4236
4236
|
}), /* @__PURE__ */ jsx("button", {
|
|
4237
4237
|
className: 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", borderClassName, {
|
|
@@ -4273,6 +4273,12 @@ function SheetImageTransparencyInput(props) {
|
|
|
4273
4273
|
useEffect(() => {
|
|
4274
4274
|
if (!isEditingRef.current) setInputValue(`${value}%`);
|
|
4275
4275
|
}, [value]);
|
|
4276
|
+
function parseTransparency(rawValue) {
|
|
4277
|
+
const normalizedValue = rawValue.trim().replace(/%$/, "").trim();
|
|
4278
|
+
if (normalizedValue === "") return null;
|
|
4279
|
+
const parsedValue = Number(normalizedValue);
|
|
4280
|
+
return Number.isFinite(parsedValue) ? normalizeTransparency$1(parsedValue) : null;
|
|
4281
|
+
}
|
|
4276
4282
|
function emitValue(nextValue) {
|
|
4277
4283
|
const normalizedValue = normalizeTransparency$1(nextValue);
|
|
4278
4284
|
onChange === null || onChange === void 0 || onChange(normalizedValue);
|
|
@@ -4352,12 +4358,6 @@ function SheetImageTransparencyInput(props) {
|
|
|
4352
4358
|
})]
|
|
4353
4359
|
});
|
|
4354
4360
|
}
|
|
4355
|
-
function parseTransparency(rawValue) {
|
|
4356
|
-
const normalizedValue = rawValue.trim().replace(/%$/, "").trim();
|
|
4357
|
-
if (normalizedValue === "") return null;
|
|
4358
|
-
const parsedValue = Number(normalizedValue);
|
|
4359
|
-
return Number.isFinite(parsedValue) ? normalizeTransparency$1(parsedValue) : null;
|
|
4360
|
-
}
|
|
4361
4361
|
function normalizeTransparency$1(value) {
|
|
4362
4362
|
return Math.min(Math.max(Math.round(value), MIN_TRANSPARENCY), MAX_TRANSPARENCY);
|
|
4363
4363
|
}
|
|
@@ -4605,12 +4605,13 @@ SheetCellImageHoverRenderController = __decorate([
|
|
|
4605
4605
|
//#endregion
|
|
4606
4606
|
//#region src/controllers/render-controllers/sheet-drawing.render-controller.ts
|
|
4607
4607
|
let SheetsDrawingRenderController = class SheetsDrawingRenderController extends Disposable {
|
|
4608
|
-
constructor(_context, _sheetDrawingService, _drawingManagerService, _sheetSkeletonService) {
|
|
4608
|
+
constructor(_context, _sheetDrawingService, _drawingManagerService, _sheetSkeletonService, _logService) {
|
|
4609
4609
|
super();
|
|
4610
4610
|
this._context = _context;
|
|
4611
4611
|
this._sheetDrawingService = _sheetDrawingService;
|
|
4612
4612
|
this._drawingManagerService = _drawingManagerService;
|
|
4613
4613
|
this._sheetSkeletonService = _sheetSkeletonService;
|
|
4614
|
+
this._logService = _logService;
|
|
4614
4615
|
this._init();
|
|
4615
4616
|
}
|
|
4616
4617
|
_init() {
|
|
@@ -4619,22 +4620,38 @@ let SheetsDrawingRenderController = class SheetsDrawingRenderController extends
|
|
|
4619
4620
|
_drawingInitializeListener() {
|
|
4620
4621
|
this._sheetDrawingService.initializeNotification(this._context.unitId);
|
|
4621
4622
|
const data = this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);
|
|
4623
|
+
const refreshedDrawings = [];
|
|
4622
4624
|
for (const subUnit in data) {
|
|
4623
4625
|
const subUnitData = data[subUnit];
|
|
4624
4626
|
for (const drawingId in subUnitData.data) {
|
|
4625
4627
|
const drawingData = subUnitData.data[drawingId];
|
|
4626
4628
|
const { unitId, subUnitId } = drawingData;
|
|
4627
4629
|
const skeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
4628
|
-
if (skeletonParam && drawingData.sheetTransform && !drawingData.groupId && drawingData.anchorType !== SheetDrawingAnchorType.None) {
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4630
|
+
if (skeletonParam && drawingData.sheetTransform && !drawingData.groupId && drawingData.anchorType !== SheetDrawingAnchorType.None) try {
|
|
4631
|
+
if (drawingData.drawingType === DrawingTypeEnum.DRAWING_GROUP) {
|
|
4632
|
+
const transform = drawingPositionToTransform(drawingData.sheetTransform, skeletonParam);
|
|
4633
|
+
refreshedDrawings.push({
|
|
4634
|
+
...drawingData,
|
|
4635
|
+
transform: transform && {
|
|
4636
|
+
...transform,
|
|
4637
|
+
left: (transform.left ?? 0) - skeletonParam.skeleton.rowHeaderWidthAndMarginLeft,
|
|
4638
|
+
top: (transform.top ?? 0) - skeletonParam.skeleton.columnHeaderHeightAndMarginTop
|
|
4639
|
+
}
|
|
4640
|
+
});
|
|
4641
|
+
} else refreshedDrawings.push(refreshSheetDrawingPlacement(drawingData, skeletonParam.skeleton));
|
|
4642
|
+
} catch (error) {
|
|
4643
|
+
this._logService.warn("[SheetsDrawingRenderController]", "Skipping drawing placement initialization", {
|
|
4644
|
+
unitId,
|
|
4645
|
+
subUnitId,
|
|
4646
|
+
drawingId,
|
|
4647
|
+
transform: drawingData.transform,
|
|
4648
|
+
sheetTransform: drawingData.sheetTransform,
|
|
4649
|
+
error
|
|
4650
|
+
});
|
|
4635
4651
|
}
|
|
4636
4652
|
}
|
|
4637
4653
|
}
|
|
4654
|
+
this._sheetDrawingService.refreshTransform(refreshedDrawings);
|
|
4638
4655
|
this._drawingManagerService.registerDrawingData(this._context.unitId, this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId));
|
|
4639
4656
|
this._drawingManagerService.initializeNotification(this._context.unitId);
|
|
4640
4657
|
}
|
|
@@ -4642,7 +4659,8 @@ let SheetsDrawingRenderController = class SheetsDrawingRenderController extends
|
|
|
4642
4659
|
SheetsDrawingRenderController = __decorate([
|
|
4643
4660
|
__decorateParam(1, ISheetDrawingService),
|
|
4644
4661
|
__decorateParam(2, IDrawingManagerService),
|
|
4645
|
-
__decorateParam(3, Inject(SheetSkeletonService))
|
|
4662
|
+
__decorateParam(3, Inject(SheetSkeletonService)),
|
|
4663
|
+
__decorateParam(4, ILogService)
|
|
4646
4664
|
], SheetsDrawingRenderController);
|
|
4647
4665
|
|
|
4648
4666
|
//#endregion
|
|
@@ -4976,8 +4994,7 @@ let SheetDrawingActiveRenderController = class SheetDrawingActiveRenderControlle
|
|
|
4976
4994
|
var _subUnitMap$showSubun;
|
|
4977
4995
|
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(showUnitId, showSubunitId);
|
|
4978
4996
|
const drawingData = ((_subUnitMap$showSubun = (this._drawingManagerService.drawingManagerData[showUnitId] ?? {})[showSubunitId]) === null || _subUnitMap$showSubun === void 0 ? void 0 : _subUnitMap$showSubun.data) ?? {};
|
|
4979
|
-
const { successDrawings, refreshedDrawings, failures } = prepareSheetDrawings(Object.values(drawingData), sheetSkeletonParam === null || sheetSkeletonParam === void 0 ? void 0 : sheetSkeletonParam.skeleton);
|
|
4980
|
-
const removeDrawings = failures.map(({ drawingId }) => drawingData[drawingId]);
|
|
4997
|
+
const { successDrawings, refreshedDrawings, removeDrawings, failures } = prepareSheetDrawings(Object.values(drawingData), sheetSkeletonParam === null || sheetSkeletonParam === void 0 ? void 0 : sheetSkeletonParam.skeleton);
|
|
4981
4998
|
this._sheetDrawingService.refreshTransform(refreshedDrawings);
|
|
4982
4999
|
this._drawingManagerService.refreshTransform(refreshedDrawings);
|
|
4983
5000
|
this._sheetDrawingService.removeNotification(removeDrawings);
|
|
@@ -5002,11 +5019,19 @@ SheetDrawingActiveRenderController = __decorate([
|
|
|
5002
5019
|
function prepareSheetDrawings(drawings, skeleton) {
|
|
5003
5020
|
const successDrawings = [];
|
|
5004
5021
|
const refreshedDrawings = [];
|
|
5022
|
+
const removeDrawings = [];
|
|
5005
5023
|
const failures = [];
|
|
5006
5024
|
for (const drawing of drawings) {
|
|
5007
5025
|
if (skeleton && drawing.sheetTransform && drawing.anchorType !== SheetDrawingAnchorType.None) try {
|
|
5008
|
-
|
|
5026
|
+
var _refreshed$transform, _refreshed$transform2;
|
|
5027
|
+
const refreshed = refreshSheetDrawingPlacement(drawing, skeleton);
|
|
5028
|
+
refreshedDrawings.push(refreshed);
|
|
5029
|
+
if ((drawing.drawingType === DrawingTypeEnum.DRAWING_IMAGE || drawing.drawingType === DrawingTypeEnum.DRAWING_DOM) && (((_refreshed$transform = refreshed.transform) === null || _refreshed$transform === void 0 ? void 0 : _refreshed$transform.width) === 0 || ((_refreshed$transform2 = refreshed.transform) === null || _refreshed$transform2 === void 0 ? void 0 : _refreshed$transform2.height) === 0)) {
|
|
5030
|
+
removeDrawings.push(drawing);
|
|
5031
|
+
continue;
|
|
5032
|
+
}
|
|
5009
5033
|
} catch (error) {
|
|
5034
|
+
removeDrawings.push(drawing);
|
|
5010
5035
|
failures.push({
|
|
5011
5036
|
drawingId: drawing.drawingId,
|
|
5012
5037
|
drawingType: drawing.drawingType,
|
|
@@ -5020,6 +5045,7 @@ function prepareSheetDrawings(drawings, skeleton) {
|
|
|
5020
5045
|
return {
|
|
5021
5046
|
successDrawings,
|
|
5022
5047
|
refreshedDrawings,
|
|
5048
|
+
removeDrawings,
|
|
5023
5049
|
failures
|
|
5024
5050
|
};
|
|
5025
5051
|
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';
|
|
17
|
-
import { Disposable } from '@univerjs/core';
|
|
17
|
+
import { Disposable, ILogService } from '@univerjs/core';
|
|
18
18
|
import { IDrawingManagerService } from '@univerjs/drawing';
|
|
19
19
|
import { SheetSkeletonService } from '@univerjs/sheets';
|
|
20
20
|
import { ISheetDrawingService } from '@univerjs/sheets-drawing';
|
|
@@ -23,7 +23,8 @@ export declare class SheetsDrawingRenderController extends Disposable implements
|
|
|
23
23
|
private readonly _sheetDrawingService;
|
|
24
24
|
private readonly _drawingManagerService;
|
|
25
25
|
private readonly _sheetSkeletonService;
|
|
26
|
-
|
|
26
|
+
private readonly _logService;
|
|
27
|
+
constructor(_context: IRenderContext, _sheetDrawingService: ISheetDrawingService, _drawingManagerService: IDrawingManagerService, _sheetSkeletonService: SheetSkeletonService, _logService: ILogService);
|
|
27
28
|
private _init;
|
|
28
29
|
private _drawingInitializeListener;
|
|
29
30
|
}
|