@univerjs/drawing-ui 1.0.4 → 1.2.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 +55 -42
- package/lib/es/index.js +53 -40
- package/lib/index.css +4 -23
- package/lib/index.js +53 -40
- package/lib/umd/index.js +3 -3
- package/package.json +11 -11
package/lib/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { CURSOR_TYPE, Canvas, DRAWING_OBJECT_LAYER_INDEX, DrawingGroupObject, Gr
|
|
|
4
4
|
import { BuiltInUIPart, ComponentManager, ContextMenuGroup, ContextMenuPosition, IDialogService, IGalleryService, ILayoutService, IMenuManagerService, IMessageService, IShortcutService, IUIPartsService, IconManager, KeyCode, MenuItemType, MobileMenu, connectInjector, useDependency, useObservable } from "@univerjs/ui";
|
|
5
5
|
import { BehaviorSubject, Observable, bufferTime, combineLatest, filter, map, merge as merge$1, of, startWith, switchMap } from "rxjs";
|
|
6
6
|
import { ArrowDownIcon, ArrowUpIcon, AutofillDoubleIcon, BottomIcon, ChartIcon, CheckMarkIcon, CloseIcon, CreateCopyIcon, CropIcon, DeleteIcon, DocSettingIcon, ExpandIcon, EyeIcon, EyelashIcon, GroupIcon, LocateFixedIcon, LockIcon, MoreDownIcon, MoveDownIcon, MoveUpIcon, TextWrapShapeIcon, TopmostIcon, UngroupIcon, UnlockIcon } from "@univerjs/icons";
|
|
7
|
-
import { Button, Checkbox, Dropdown, DropdownMenu, Input, InputNumber, MessageType, MobileActionRow, MobileSelect, Select, Separator, StateIconButton, Tooltip, borderClassName, clsx, render, unmount } from "@univerjs/design";
|
|
7
|
+
import { Button, Checkbox, Dropdown, DropdownMenu, Input, InputNumber, MessageType, MobileActionRow, MobileSelect, Select, Separator, StateIconButton, Textarea, Tooltip, borderClassName, clsx, render, unmount } from "@univerjs/design";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { createElement, useEffect, useMemo, useRef, useState } from "react";
|
|
10
10
|
|
|
@@ -650,7 +650,7 @@ const menuSchema = { [ContextMenuPosition.DRAWING]: { [ContextMenuGroup.OTHERS]:
|
|
|
650
650
|
//#endregion
|
|
651
651
|
//#region package.json
|
|
652
652
|
var name = "@univerjs/drawing-ui";
|
|
653
|
-
var version = "1.0
|
|
653
|
+
var version = "1.2.0";
|
|
654
654
|
|
|
655
655
|
//#endregion
|
|
656
656
|
//#region src/config/config.ts
|
|
@@ -659,7 +659,7 @@ const configSymbol = Symbol(DRAWING_UI_PLUGIN_CONFIG_KEY);
|
|
|
659
659
|
const defaultPluginConfig = {};
|
|
660
660
|
|
|
661
661
|
//#endregion
|
|
662
|
-
//#region \0@oxc-project+runtime@0.
|
|
662
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
663
663
|
function _typeof(o) {
|
|
664
664
|
"@babel/helpers - typeof";
|
|
665
665
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -670,7 +670,7 @@ function _typeof(o) {
|
|
|
670
670
|
}
|
|
671
671
|
|
|
672
672
|
//#endregion
|
|
673
|
-
//#region \0@oxc-project+runtime@0.
|
|
673
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
674
674
|
function toPrimitive(t, r) {
|
|
675
675
|
if ("object" != _typeof(t) || !t) return t;
|
|
676
676
|
var e = t[Symbol.toPrimitive];
|
|
@@ -683,14 +683,14 @@ function toPrimitive(t, r) {
|
|
|
683
683
|
}
|
|
684
684
|
|
|
685
685
|
//#endregion
|
|
686
|
-
//#region \0@oxc-project+runtime@0.
|
|
686
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
687
687
|
function toPropertyKey(t) {
|
|
688
688
|
var i = toPrimitive(t, "string");
|
|
689
689
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
690
690
|
}
|
|
691
691
|
|
|
692
692
|
//#endregion
|
|
693
|
-
//#region \0@oxc-project+runtime@0.
|
|
693
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
694
694
|
function _defineProperty(e, r, t) {
|
|
695
695
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
696
696
|
value: t,
|
|
@@ -743,7 +743,7 @@ var DrawingImageClipService = class extends Disposable {
|
|
|
743
743
|
};
|
|
744
744
|
|
|
745
745
|
//#endregion
|
|
746
|
-
//#region \0@oxc-project+runtime@0.
|
|
746
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
747
747
|
function __decorateParam(paramIndex, decorator) {
|
|
748
748
|
return function(target, key) {
|
|
749
749
|
decorator(target, key, paramIndex);
|
|
@@ -751,7 +751,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
751
751
|
}
|
|
752
752
|
|
|
753
753
|
//#endregion
|
|
754
|
-
//#region \0@oxc-project+runtime@0.
|
|
754
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
755
755
|
function __decorate(decorators, target, key, desc) {
|
|
756
756
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
757
757
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1339,6 +1339,14 @@ let DrawingUpdateController = class DrawingUpdateController extends Disposable {
|
|
|
1339
1339
|
if (disposeDrawingRenderObject(scene, param)) {
|
|
1340
1340
|
var _scene$getTransformer2;
|
|
1341
1341
|
(_scene$getTransformer2 = scene.getTransformer()) === null || _scene$getTransformer2 === void 0 || _scene$getTransformer2.clearSelectedObjects();
|
|
1342
|
+
} else {
|
|
1343
|
+
const transformer = scene.getTransformer();
|
|
1344
|
+
const key = getDrawingShapeKeyByDrawingSearch(param);
|
|
1345
|
+
const selectedKeys = [...(transformer === null || transformer === void 0 ? void 0 : transformer.getSelectedObjectMap().keys()) ?? []].filter((selectedKey) => selectedKey === key || selectedKey.startsWith(`${key}#-#`));
|
|
1346
|
+
if (selectedKeys.length > 0) {
|
|
1347
|
+
if (selectedKeys.length === (transformer === null || transformer === void 0 ? void 0 : transformer.getSelectedObjectMap().size)) transformer.clearSelectedObjects();
|
|
1348
|
+
else transformer === null || transformer === void 0 || transformer.clearControlByIds(selectedKeys);
|
|
1349
|
+
}
|
|
1342
1350
|
}
|
|
1343
1351
|
});
|
|
1344
1352
|
}));
|
|
@@ -1385,7 +1393,6 @@ let DrawingUpdateController = class DrawingUpdateController extends Disposable {
|
|
|
1385
1393
|
_drawingRefreshListener() {
|
|
1386
1394
|
this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe((params) => {
|
|
1387
1395
|
params.forEach((param) => {
|
|
1388
|
-
var _setClipBounds2;
|
|
1389
1396
|
const { unitId, subUnitId, drawingId } = param;
|
|
1390
1397
|
const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
|
|
1391
1398
|
if (renderObject == null) return;
|
|
@@ -1394,38 +1401,44 @@ let DrawingUpdateController = class DrawingUpdateController extends Disposable {
|
|
|
1394
1401
|
const { transform } = drawingParam;
|
|
1395
1402
|
const { scene } = renderObject;
|
|
1396
1403
|
if (transform == null) return true;
|
|
1397
|
-
const drawingShapeKey = getDrawingShapeKeyByDrawingSearch({
|
|
1398
|
-
unitId,
|
|
1399
|
-
subUnitId,
|
|
1400
|
-
drawingId
|
|
1401
|
-
});
|
|
1402
|
-
const drawingShape = scene.getObjectIncludeInGroup(drawingShapeKey);
|
|
1403
1404
|
const drawingParamWithRefreshMetadata = mergeRefreshMetadata(drawingParam, param);
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1405
|
+
const isMultiTransform = drawingParam.isMultiTransform === BooleanNumber.TRUE;
|
|
1406
|
+
const transforms = isMultiTransform ? drawingParam.transforms ?? [] : [transform];
|
|
1407
|
+
let hasMissingShape = false;
|
|
1408
|
+
transforms.forEach((instanceTransform, index) => {
|
|
1409
|
+
var _setClipBounds2;
|
|
1410
|
+
const drawingShapeKey = getDrawingShapeKeyByDrawingSearch({
|
|
1407
1411
|
unitId,
|
|
1408
1412
|
subUnitId,
|
|
1409
1413
|
drawingId
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
top,
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1414
|
+
}, isMultiTransform ? index : void 0);
|
|
1415
|
+
const drawingShape = scene.getObjectIncludeInGroup(drawingShapeKey);
|
|
1416
|
+
if (drawingShape == null) {
|
|
1417
|
+
hasMissingShape = true;
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
const { left = 0, top = 0, width = 0, height = 0, angle = 0, flipX = false, flipY = false, skewX = 0, skewY = 0 } = instanceTransform;
|
|
1421
|
+
drawingShape.transformByState({
|
|
1422
|
+
left,
|
|
1423
|
+
top,
|
|
1424
|
+
width,
|
|
1425
|
+
height,
|
|
1426
|
+
angle,
|
|
1427
|
+
flipX,
|
|
1428
|
+
flipY,
|
|
1429
|
+
skewX,
|
|
1430
|
+
skewY
|
|
1431
|
+
});
|
|
1432
|
+
(_setClipBounds2 = drawingShape.setClipBounds) === null || _setClipBounds2 === void 0 || _setClipBounds2.call(drawingShape, instanceTransform.clipBounds);
|
|
1433
|
+
syncDrawingHiddenState(drawingShape, drawingParamWithRefreshMetadata);
|
|
1434
|
+
syncDrawingSelectableState(drawingShape, drawingParamWithRefreshMetadata, scene, this._drawingManagerService);
|
|
1435
|
+
ensureDrawingRenderLayer(scene, drawingShape, drawingParamWithRefreshMetadata);
|
|
1424
1436
|
});
|
|
1425
|
-
(
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1437
|
+
if (hasMissingShape && drawingParamWithRefreshMetadata.hidden !== true) this._drawingManagerService.addNotification([{
|
|
1438
|
+
unitId,
|
|
1439
|
+
subUnitId,
|
|
1440
|
+
drawingId
|
|
1441
|
+
}]);
|
|
1429
1442
|
});
|
|
1430
1443
|
}));
|
|
1431
1444
|
}
|
|
@@ -5052,7 +5065,7 @@ function ObjectListPanelBase(props) {
|
|
|
5052
5065
|
["locked", labels.filterLocked]
|
|
5053
5066
|
].map(([mode, label]) => /* @__PURE__ */ jsx("button", {
|
|
5054
5067
|
type: "button",
|
|
5055
|
-
className: clsx("univer-min-w-0 univer-flex-1 univer-rounded-md univer-border univer-border-solid univer-px-2 univer-text-xs univer-outline-none univer-transition-colors dark:!univer-border-gray-700", "univer-h-7", filterMode === mode ? "
|
|
5068
|
+
className: clsx("univer-min-w-0 univer-flex-1 univer-rounded-md univer-border univer-border-solid univer-px-2 univer-text-xs univer-outline-none univer-transition-colors dark:!univer-border-gray-700", "univer-h-7", filterMode === mode ? "univer-border-primary-500 univer-bg-primary-50 univer-text-primary-600 dark:!univer-bg-primary-900 dark:!univer-text-primary-200" : clsx("univer-border-gray-200 univer-bg-gray-0 univer-text-gray-600 dark:!univer-bg-gray-900 dark:!univer-text-gray-300", "hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-800")),
|
|
5056
5069
|
"aria-pressed": filterMode === mode,
|
|
5057
5070
|
onClick: () => setFilterMode(mode),
|
|
5058
5071
|
children: /* @__PURE__ */ jsx("span", {
|
|
@@ -5267,8 +5280,8 @@ function ObjectDetailsEditor(props) {
|
|
|
5267
5280
|
children: [/* @__PURE__ */ jsx("span", {
|
|
5268
5281
|
className: "univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",
|
|
5269
5282
|
children: labels.description
|
|
5270
|
-
}), /* @__PURE__ */ jsx(
|
|
5271
|
-
className: clsx(
|
|
5283
|
+
}), /* @__PURE__ */ jsx(Textarea, {
|
|
5284
|
+
className: clsx("univer-min-h-16 univer-resize-none univer-text-sm", descriptionClassName),
|
|
5272
5285
|
value: draftDescription,
|
|
5273
5286
|
disabled,
|
|
5274
5287
|
placeholder: labels.descriptionPlaceholder,
|
|
@@ -5404,7 +5417,7 @@ function MobileObjectListPanel(props) {
|
|
|
5404
5417
|
["locked", labels.filterLocked]
|
|
5405
5418
|
].map(([mode, label]) => /* @__PURE__ */ jsx("button", {
|
|
5406
5419
|
type: "button",
|
|
5407
|
-
className: clsx("univer-min-w-0 univer-flex-1 univer-rounded-md univer-border univer-border-solid univer-px-2 univer-text-xs univer-outline-none univer-transition-colors dark:!univer-border-gray-700", "univer-h-11 univer-text-sm", filterMode === mode ? "
|
|
5420
|
+
className: clsx("univer-min-w-0 univer-flex-1 univer-rounded-md univer-border univer-border-solid univer-px-2 univer-text-xs univer-outline-none univer-transition-colors dark:!univer-border-gray-700", "univer-h-11 univer-text-sm", filterMode === mode ? "univer-border-primary-500 univer-bg-primary-50 univer-text-primary-600 dark:!univer-bg-primary-900 dark:!univer-text-primary-200" : clsx("univer-border-gray-200 univer-bg-gray-0 univer-text-gray-600 dark:!univer-bg-gray-900 dark:!univer-text-gray-300")),
|
|
5408
5421
|
"aria-pressed": filterMode === mode,
|
|
5409
5422
|
onClick: () => setFilterMode(mode),
|
|
5410
5423
|
children: /* @__PURE__ */ jsx("span", {
|