@univerjs/drawing-ui 0.3.0 → 0.4.0-alpha.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/es/index.js CHANGED
@@ -4,7 +4,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
5
  import { getDrawingShapeKeyByDrawingSearch, DrawingTypeEnum, ImageSourceType, IDrawingManagerService, IImageIoService, ArrangeTypeEnum } from "@univerjs/drawing";
6
6
  import { Group, DRAWING_OBJECT_LAYER_INDEX, Image, IRenderManagerService, getGroupState, transformObjectOutOfGroup, RENDER_CLASS_TYPE, Shape, Rect, Canvas, precisionTo, CURSOR_TYPE, Vector2, degToRad } from "@univerjs/engine-render";
7
- import { UniverInstanceType, useDependency, LocaleService, debounce, CommandType, ICommandService, Tools, OnLifecycle, LifecycleStages, Disposable, checkIfMove, toDisposable, IUniverInstanceService, Inject, Injector, Plugin, IConfigService } from "@univerjs/core";
7
+ import { UniverInstanceType, useDependency, LocaleService, debounce, CommandType, ICommandService, Tools, Inject, Disposable, checkIfMove, toDisposable, IUniverInstanceService, Injector, Plugin, IConfigService } from "@univerjs/core";
8
8
  import React, { forwardRef, useRef, createElement, useState, useEffect } from "react";
9
9
  import { Button, InputNumber, Checkbox, Select, Dropdown, MessageType } from "@univerjs/design";
10
10
  import clsx from "clsx";
@@ -753,13 +753,50 @@ const AutoImageCropOperation = {
753
753
  )
754
754
  )
755
755
  );
756
- }, "ImagePopupMenu"), COMPONENT_IMAGE_POPUP_MENU = "COMPONENT_IMAGE_POPUP_MENU";
756
+ }, "ImagePopupMenu"), COMPONENT_IMAGE_POPUP_MENU = "COMPONENT_IMAGE_POPUP_MENU", PLUGIN_CONFIG_KEY = "drawing-ui.config", defaultPluginConfig = {}, ImageResetSizeOperation = {
757
+ id: "sheet.operation.image-reset-size",
758
+ type: CommandType.OPERATION,
759
+ handler: /* @__PURE__ */ __name((accessor, params) => !0, "handler")
760
+ }, COMPONENT_IMAGE_VIEWER = "COMPONENT_IMAGE_VIEWER", ImageViewer = /* @__PURE__ */ __name((props) => {
761
+ const { src } = props;
762
+ return src ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("img", { src, alt: "Univer Image Viewer", style: { width: "100%", height: "100%", position: "relative" } })) : null;
763
+ }, "ImageViewer");
757
764
  var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
758
765
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
759
766
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
760
767
  return kind && result && __defProp$4(target, key, result), result;
761
768
  }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a2;
762
- let DrawingUpdateController = (_a2 = class extends Disposable {
769
+ let DrawingUIController = (_a2 = class extends Disposable {
770
+ constructor(_componentManager, _commandService) {
771
+ super(), this._componentManager = _componentManager, this._commandService = _commandService, this._init();
772
+ }
773
+ _initCustomComponents() {
774
+ const componentManager = this._componentManager;
775
+ this.disposeWithMe(componentManager.register(COMPONENT_IMAGE_POPUP_MENU, ImagePopupMenu)), this.disposeWithMe(componentManager.register(COMPONENT_IMAGE_VIEWER, ImageViewer));
776
+ }
777
+ _initCommands() {
778
+ [
779
+ OpenImageCropOperation,
780
+ CloseImageCropOperation,
781
+ ImageResetSizeOperation,
782
+ SetDrawingAlignOperation,
783
+ AutoImageCropOperation
784
+ ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
785
+ }
786
+ _init() {
787
+ this._initCommands(), this._initCustomComponents();
788
+ }
789
+ }, __name(_a2, "DrawingUIController"), _a2);
790
+ DrawingUIController = __decorateClass$4([
791
+ __decorateParam$4(0, Inject(ComponentManager)),
792
+ __decorateParam$4(1, ICommandService)
793
+ ], DrawingUIController);
794
+ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
795
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
796
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
797
+ return kind && result && __defProp$3(target, key, result), result;
798
+ }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a3;
799
+ let DrawingUpdateController = (_a3 = class extends Disposable {
763
800
  constructor(_currentUniverService, _commandService, _renderManagerService, _drawingManagerService) {
764
801
  super();
765
802
  __publicField(this, "_sceneListenerOnDrawingMap", /* @__PURE__ */ new WeakSet());
@@ -1052,13 +1089,13 @@ let DrawingUpdateController = (_a2 = class extends Disposable {
1052
1089
  _insertDrawing(params) {
1053
1090
  const sceneList = [];
1054
1091
  params.forEach((param) => {
1055
- const { unitId, subUnitId, drawingId } = param;
1092
+ const { unitId } = param;
1056
1093
  if (this._drawingManagerService.getDrawingByParam(param) == null)
1057
1094
  return;
1058
1095
  const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1059
1096
  if (renderObject == null)
1060
1097
  return;
1061
- const { scene, transformer } = renderObject;
1098
+ const { scene } = renderObject;
1062
1099
  sceneList.includes(scene) || sceneList.push(scene);
1063
1100
  }), sceneList.forEach((scene) => {
1064
1101
  this._sceneListenerOnDrawingMap.has(scene) || (this._addListenerOnDrawing(scene), this._sceneListenerOnDrawingMap.add(scene));
@@ -1199,53 +1236,13 @@ let DrawingUpdateController = (_a2 = class extends Disposable {
1199
1236
  )
1200
1237
  );
1201
1238
  }
1202
- }, __name(_a2, "DrawingUpdateController"), _a2);
1203
- DrawingUpdateController = __decorateClass$4([
1204
- OnLifecycle(LifecycleStages.Rendered, DrawingUpdateController),
1205
- __decorateParam$4(0, IUniverInstanceService),
1206
- __decorateParam$4(1, ICommandService),
1207
- __decorateParam$4(2, IRenderManagerService),
1208
- __decorateParam$4(3, IDrawingManagerService)
1239
+ }, __name(_a3, "DrawingUpdateController"), _a3);
1240
+ DrawingUpdateController = __decorateClass$3([
1241
+ __decorateParam$3(0, IUniverInstanceService),
1242
+ __decorateParam$3(1, ICommandService),
1243
+ __decorateParam$3(2, IRenderManagerService),
1244
+ __decorateParam$3(3, IDrawingManagerService)
1209
1245
  ], DrawingUpdateController);
1210
- const ImageViewer = /* @__PURE__ */ __name((props) => {
1211
- const { src } = props;
1212
- return src ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("img", { src, alt: "Univer Image Viewer", style: { width: "100%", height: "100%", position: "relative" } })) : null;
1213
- }, "ImageViewer"), COMPONENT_IMAGE_VIEWER = "COMPONENT_IMAGE_VIEWER", ImageResetSizeOperation = {
1214
- id: "sheet.operation.image-reset-size",
1215
- type: CommandType.OPERATION,
1216
- handler: /* @__PURE__ */ __name((accessor, params) => !0, "handler")
1217
- };
1218
- var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1219
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1220
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1221
- return kind && result && __defProp$3(target, key, result), result;
1222
- }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a3;
1223
- let DrawingUIController = (_a3 = class extends Disposable {
1224
- constructor(_componentManager, _commandService) {
1225
- super(), this._componentManager = _componentManager, this._commandService = _commandService, this._init();
1226
- }
1227
- _initCustomComponents() {
1228
- const componentManager = this._componentManager;
1229
- this.disposeWithMe(componentManager.register(COMPONENT_IMAGE_POPUP_MENU, ImagePopupMenu)), this.disposeWithMe(componentManager.register(COMPONENT_IMAGE_VIEWER, ImageViewer));
1230
- }
1231
- _initCommands() {
1232
- [
1233
- OpenImageCropOperation,
1234
- CloseImageCropOperation,
1235
- ImageResetSizeOperation,
1236
- SetDrawingAlignOperation,
1237
- AutoImageCropOperation
1238
- ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
1239
- }
1240
- _init() {
1241
- this._initCommands(), this._initCustomComponents();
1242
- }
1243
- }, __name(_a3, "DrawingUIController"), _a3);
1244
- DrawingUIController = __decorateClass$3([
1245
- OnLifecycle(LifecycleStages.Rendered, DrawingUIController),
1246
- __decorateParam$3(0, Inject(ComponentManager)),
1247
- __decorateParam$3(1, ICommandService)
1248
- ], DrawingUIController);
1249
1246
  const _ImageCropperObject = class _ImageCropperObject extends Shape {
1250
1247
  constructor(key, props) {
1251
1248
  props == null && (props = {}), props.transformerConfig = {
@@ -1599,7 +1596,6 @@ let ImageCropperController = (_a4 = class extends Disposable {
1599
1596
  }
1600
1597
  }, __name(_a4, "ImageCropperController"), _a4);
1601
1598
  ImageCropperController = __decorateClass$2([
1602
- OnLifecycle(LifecycleStages.Rendered, ImageCropperController),
1603
1599
  __decorateParam$2(0, ICommandService),
1604
1600
  __decorateParam$2(1, IDrawingManagerService),
1605
1601
  __decorateParam$2(2, IRenderManagerService),
@@ -1780,7 +1776,6 @@ let ImageUpdateController = (_a5 = class extends Disposable {
1780
1776
  }
1781
1777
  }, __name(_a5, "ImageUpdateController"), _a5);
1782
1778
  ImageUpdateController = __decorateClass$1([
1783
- OnLifecycle(LifecycleStages.Rendered, ImageUpdateController),
1784
1779
  __decorateParam$1(0, ICommandService),
1785
1780
  __decorateParam$1(1, IRenderManagerService),
1786
1781
  __decorateParam$1(2, IDrawingManagerService),
@@ -1789,7 +1784,6 @@ ImageUpdateController = __decorateClass$1([
1789
1784
  __decorateParam$1(5, IUniverInstanceService),
1790
1785
  __decorateParam$1(6, Inject(DrawingRenderService))
1791
1786
  ], ImageUpdateController);
1792
- const PLUGIN_CONFIG_KEY = "drawing-ui.config", defaultPluginConfig = {};
1793
1787
  var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1794
1788
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1795
1789
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
@@ -1806,11 +1800,12 @@ let UniverDrawingUIPlugin = (_a6 = class extends Plugin {
1806
1800
  onStarting() {
1807
1801
  this._initDependencies();
1808
1802
  }
1803
+ onRendered() {
1804
+ this._injector.get(DrawingUpdateController), this._injector.get(DrawingUIController), this._injector.get(ImageCropperController), this._injector.get(ImageUpdateController);
1805
+ }
1809
1806
  _initDependencies() {
1810
1807
  [
1811
- // services
1812
1808
  [DrawingRenderService],
1813
- // controllers
1814
1809
  [DrawingUpdateController],
1815
1810
  [DrawingUIController],
1816
1811
  [ImageCropperController],
@@ -0,0 +1,54 @@
1
+ {
2
+ "image-popup": {
3
+ "replace": "تعویض",
4
+ "delete": "حذف",
5
+ "edit": "ویرایش",
6
+ "crop": "کراپ",
7
+ "reset": "بازنشانی اندازه"
8
+ },
9
+ "image-cropper": {
10
+ "error": "کراپ کردن اشیاء غیرتصویری امکان‌پذیر نیست."
11
+ },
12
+ "image-panel": {
13
+ "arrange": {
14
+ "title": "ترتیب‌دهی",
15
+ "forward": "آوردن به جلو",
16
+ "backward": "فرستادن به عقب",
17
+ "front": "آوردن به جلوی همه",
18
+ "back": "فرستادن به پشت همه"
19
+ },
20
+ "transform": {
21
+ "title": "تبدیل",
22
+ "rotate": "چرخش (°)",
23
+ "x": "X (px)",
24
+ "y": "Y (px)",
25
+ "width": "عرض (px)",
26
+ "height": "ارتفاع (px)",
27
+ "lock": "قفل نسبت (%)"
28
+ },
29
+ "crop": {
30
+ "title": "کراپ",
31
+ "start": "شروع کراپ",
32
+ "mode": "آزاد"
33
+ },
34
+ "group": {
35
+ "title": "گروه",
36
+ "group": "گروه‌بندی",
37
+ "reGroup": "گروه‌بندی مجدد",
38
+ "unGroup": "لغو گروه‌بندی"
39
+ },
40
+ "align": {
41
+ "title": "تراز",
42
+ "default": "انتخاب نوع تراز",
43
+ "left": "تراز چپ",
44
+ "center": "تراز وسط",
45
+ "right": "تراز راست",
46
+ "top": "تراز بالا",
47
+ "middle": "تراز وسط",
48
+ "bottom": "تراز پایین",
49
+ "horizon": "توزیع افقی",
50
+ "vertical": "توزیع عمودی"
51
+ },
52
+ "null": "هیچ شیئی انتخاب نشده است"
53
+ }
54
+ }
@@ -1,6 +1,6 @@
1
1
  import { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
2
- import { IRenderManagerService } from '@univerjs/engine-render';
3
2
  import { IDrawingManagerService } from '@univerjs/drawing';
3
+ import { IRenderManagerService } from '@univerjs/engine-render';
4
4
  export declare class DrawingUpdateController extends Disposable {
5
5
  private readonly _currentUniverService;
6
6
  private readonly _commandService;
@@ -1,6 +1,6 @@
1
1
  import { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
2
- import { IRenderManagerService } from '@univerjs/engine-render';
3
2
  import { IDrawingManagerService, IImageIoService } from '@univerjs/drawing';
3
+ import { IRenderManagerService } from '@univerjs/engine-render';
4
4
  import { IDialogService } from '@univerjs/ui';
5
5
  import { DrawingRenderService } from '../services/drawing-render.service';
6
6
  export declare class ImageUpdateController extends Disposable {
@@ -0,0 +1,3 @@
1
+ import { default as zhCN } from './zh-CN';
2
+ declare const locale: typeof zhCN;
3
+ export default locale;
@@ -1,5 +1,5 @@
1
- import { IConfigService, Injector, Plugin } from '@univerjs/core';
2
1
  import { IUniverDrawingUIConfig } from './controllers/config.schema';
2
+ import { IConfigService, Injector, Plugin } from '@univerjs/core';
3
3
  export declare class UniverDrawingUIPlugin extends Plugin {
4
4
  private readonly _config;
5
5
  protected _injector: Injector;
@@ -7,5 +7,6 @@ export declare class UniverDrawingUIPlugin extends Plugin {
7
7
  static pluginName: string;
8
8
  constructor(_config: Partial<IUniverDrawingUIConfig> | undefined, _injector: Injector, _configService: IConfigService);
9
9
  onStarting(): void;
10
+ onRendered(): void;
10
11
  private _initDependencies;
11
12
  }