@univerjs/docs-drawing-ui 0.1.13

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.
Files changed (39) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +16 -0
  3. package/lib/cjs/index.js +1 -0
  4. package/lib/es/index.js +963 -0
  5. package/lib/index.css +1 -0
  6. package/lib/locale/en-US.json +24 -0
  7. package/lib/locale/ru-RU.json +24 -0
  8. package/lib/locale/zh-CN.json +24 -0
  9. package/lib/types/commands/commands/delete-drawings.command.d.ts +3 -0
  10. package/lib/types/commands/commands/group-doc-drawing.command.d.ts +6 -0
  11. package/lib/types/commands/commands/insert-doc-drawing.command.d.ts +6 -0
  12. package/lib/types/commands/commands/interfaces.d.ts +21 -0
  13. package/lib/types/commands/commands/move-drawings.command.d.ts +6 -0
  14. package/lib/types/commands/commands/remove-doc-drawing.command.d.ts +6 -0
  15. package/lib/types/commands/commands/set-doc-drawing.command.d.ts +6 -0
  16. package/lib/types/commands/commands/set-drawing-arrange.command.d.ts +10 -0
  17. package/lib/types/commands/commands/ungroup-doc-drawing.command.d.ts +6 -0
  18. package/lib/types/commands/commands/utils.d.ts +4 -0
  19. package/lib/types/commands/operations/clear-drawing-transformer.operation.d.ts +3 -0
  20. package/lib/types/commands/operations/edit-doc-drawing.operation.d.ts +4 -0
  21. package/lib/types/commands/operations/insert-image.operation.d.ts +6 -0
  22. package/lib/types/commands/operations/open-drawing-panel.operation.d.ts +6 -0
  23. package/lib/types/controllers/doc-drawing-update.controller.d.ts +35 -0
  24. package/lib/types/controllers/doc-drawing.controller.d.ts +17 -0
  25. package/lib/types/controllers/drawing-popup-menu.controller.d.ts +20 -0
  26. package/lib/types/controllers/shortcuts/drawing.shortcut.d.ts +10 -0
  27. package/lib/types/index.d.ts +16 -0
  28. package/lib/types/locale/en-US.d.ts +4 -0
  29. package/lib/types/locale/ru-RU.d.ts +4 -0
  30. package/lib/types/locale/zh-CN.d.ts +40 -0
  31. package/lib/types/plugin.d.ts +12 -0
  32. package/lib/types/views/doc-image-panel/DocDrawingAnchor.d.ts +7 -0
  33. package/lib/types/views/doc-image-panel/DocDrawingPanel.d.ts +3 -0
  34. package/lib/types/views/doc-image-panel/component-name.d.ts +16 -0
  35. package/lib/types/views/menu/image.menu.d.ts +6 -0
  36. package/lib/types/views/upload-component/UploadFile.d.ts +3 -0
  37. package/lib/types/views/upload-component/component-name.d.ts +16 -0
  38. package/lib/umd/index.js +1 -0
  39. package/package.json +100 -0
package/lib/index.css ADDED
@@ -0,0 +1 @@
1
+ .univer-upload-file-menu{position:absolute;height:100%;width:100%;text-align:center}.univer-upload-file-menu-input{display:none}.univer-image-common-panel{text-align:center;padding:var(--padding-sm);font-size:var(--font-size-sm)}.univer-image-common-panel-grid{position:relative;width:100%}.univer-image-common-panel-border{border-top:1px solid rgb(var(--border-color));margin-top:20px}.univer-image-common-panel-title{color:rgb(var(--text-color-secondary));text-align:left}.univer-image-common-panel-row{position:relative;display:flex;justify-content:flex-start;align-items:flex-start;height:100%;margin-top:10px}.univer-image-common-panel-row-vertical{justify-content:center;align-items:center;height:36px}.univer-image-common-panel-column{width:100%}.univer-image-common-panel-column-center{display:flex;justify-content:center;align-items:center}.univer-image-common-panel-inline{display:flex;align-items:center;gap:var(--margin-xxs)}.univer-image-common-panel-span2{width:50%}.univer-image-common-panel-span3{width:33.33333333%}.univer-image-common-panel-input{width:90%}.univer-sheet-image-menu{position:absolute;height:100%;width:100%;text-align:center}.univer-sheet-image-menu-input{display:none}
@@ -0,0 +1,24 @@
1
+ {
2
+ "docImage": {
3
+ "title": "Image",
4
+ "upload": {
5
+ "float": "Insert Image"
6
+ },
7
+ "panel": {
8
+ "title": "Edit Image"
9
+ }
10
+ },
11
+ "image-popup": {
12
+ "replace": "Replace",
13
+ "delete": "Delete",
14
+ "edit": "Edit",
15
+ "crop": "Crop",
16
+ "reset": "Reset Size"
17
+ },
18
+ "update-status": {
19
+ "exceedMaxSize": "Image size exceeds limit, limit is {0}M",
20
+ "invalidImageType": "Invalid image type",
21
+ "exceedMaxCount": "Only {0} images can be uploaded at a time",
22
+ "invalidImage": "Invalid image"
23
+ }
24
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "docImage": {
3
+ "title": "Изображение",
4
+ "upload": {
5
+ "float": "Вставить изображение"
6
+ },
7
+ "panel": {
8
+ "title": "Редактировать изображение"
9
+ }
10
+ },
11
+ "image-popup": {
12
+ "replace": "Заменить",
13
+ "delete": "Удалить",
14
+ "edit": "Редактировать",
15
+ "crop": "Обрезать",
16
+ "reset": "Сбросить размер"
17
+ },
18
+ "update-status": {
19
+ "exceedMaxSize": "Размер изображения превышает лимит, лимит составляет {0}М",
20
+ "invalidImageType": "Недопустимый тип изображения",
21
+ "exceedMaxCount": "За один раз можно загрузить только {0} изображений",
22
+ "invalidImage": "Недопустимое изображение"
23
+ }
24
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "docImage": {
3
+ "title": "图片",
4
+ "upload": {
5
+ "float": "插入图片"
6
+ },
7
+ "panel": {
8
+ "title": "编辑图片"
9
+ }
10
+ },
11
+ "image-popup": {
12
+ "replace": "替换",
13
+ "delete": "删除",
14
+ "edit": "编辑",
15
+ "crop": "裁剪",
16
+ "reset": "重置大小"
17
+ },
18
+ "update-status": {
19
+ "exceedMaxSize": "图片大小超过限制, 限制为{0}M",
20
+ "invalidImageType": "图片类型错误",
21
+ "exceedMaxCount": "图片只能一次上传{0}张",
22
+ "invalidImage": "无效图片"
23
+ }
24
+ }
@@ -0,0 +1,3 @@
1
+ import { ICommand } from '@univerjs/core';
2
+
3
+ export declare const DeleteDocDrawingsCommand: ICommand;
@@ -0,0 +1,6 @@
1
+ import { ICommand } from '@univerjs/core';
2
+
3
+ /**
4
+ * The command to insert new defined name
5
+ */
6
+ export declare const GroupDocDrawingCommand: ICommand;
@@ -0,0 +1,6 @@
1
+ import { ICommand } from '@univerjs/core';
2
+
3
+ /**
4
+ * The command to insert new defined name
5
+ */
6
+ export declare const InsertDocDrawingCommand: ICommand;
@@ -0,0 +1,21 @@
1
+ import { DrawingTypeEnum } from '@univerjs/core';
2
+ import { IDocDrawing } from '@univerjs/docs-drawing';
3
+
4
+ export interface IInsertDrawingCommandParams {
5
+ unitId: string;
6
+ drawings: IDocDrawing[];
7
+ }
8
+ export interface IDeleteDrawingCommandParam {
9
+ unitId: string;
10
+ subUnitId: string;
11
+ drawingId: string;
12
+ drawingType: DrawingTypeEnum;
13
+ }
14
+ export interface IDeleteDrawingCommandParams {
15
+ unitId: string;
16
+ drawings: IDeleteDrawingCommandParam[];
17
+ }
18
+ export interface ISetDrawingCommandParams {
19
+ unitId: string;
20
+ drawings: Partial<IDocDrawing>[];
21
+ }
@@ -0,0 +1,6 @@
1
+ import { ICommand, Direction } from '@univerjs/core';
2
+
3
+ export interface IMoveDrawingsCommandParams {
4
+ direction: Direction;
5
+ }
6
+ export declare const MoveDocDrawingsCommand: ICommand;
@@ -0,0 +1,6 @@
1
+ import { ICommand } from '@univerjs/core';
2
+
3
+ /**
4
+ * The command to remove new sheet image
5
+ */
6
+ export declare const RemoveDocDrawingCommand: ICommand;
@@ -0,0 +1,6 @@
1
+ import { ICommand } from '@univerjs/core';
2
+
3
+ /**
4
+ * The command to update defined name
5
+ */
6
+ export declare const SetDocDrawingCommand: ICommand;
@@ -0,0 +1,10 @@
1
+ import { ICommand } from '@univerjs/core';
2
+ import { IDrawingOrderMapParam, ArrangeTypeEnum } from '@univerjs/drawing';
3
+
4
+ export interface ISetDrawingArrangeCommandParams extends IDrawingOrderMapParam {
5
+ arrangeType: ArrangeTypeEnum;
6
+ }
7
+ /**
8
+ * The command to insert new defined name
9
+ */
10
+ export declare const SetDocDrawingArrangeCommand: ICommand;
@@ -0,0 +1,6 @@
1
+ import { ICommand } from '@univerjs/core';
2
+
3
+ /**
4
+ * The command to insert new defined name
5
+ */
6
+ export declare const UngroupDocDrawingCommand: ICommand;
@@ -0,0 +1,4 @@
1
+ import { IDrawingGroupUpdateParam } from '@univerjs/drawing';
2
+
3
+ export declare function ungroupToGroup(ungroupParams: IDrawingGroupUpdateParam[]): IDrawingGroupUpdateParam[];
4
+ export declare function groupToUngroup(groupParams: IDrawingGroupUpdateParam[]): IDrawingGroupUpdateParam[];
@@ -0,0 +1,3 @@
1
+ import { IMutation } from '@univerjs/core';
2
+
3
+ export declare const ClearDocDrawingTransformerOperation: IMutation<string[]>;
@@ -0,0 +1,4 @@
1
+ import { IOperation } from '@univerjs/core';
2
+ import { IDrawingSearch } from '@univerjs/drawing';
3
+
4
+ export declare const EditDocDrawingOperation: IOperation<IDrawingSearch>;
@@ -0,0 +1,6 @@
1
+ import { IOperation, Nullable } from '@univerjs/core';
2
+
3
+ export interface IInsertImageOperationParams {
4
+ files: Nullable<File[]>;
5
+ }
6
+ export declare const InsertDocImageOperation: IOperation<IInsertImageOperationParams>;
@@ -0,0 +1,6 @@
1
+ import { ICommand } from '@univerjs/core';
2
+
3
+ export interface IUIComponentCommandParams {
4
+ value: string;
5
+ }
6
+ export declare const SidebarDocDrawingOperation: ICommand;
@@ -0,0 +1,35 @@
1
+ import { Disposable, ICommandService, IContextService, IUniverInstanceService, LocaleService } from '@univerjs/core';
2
+ import { IDrawingManagerService, IImageIoService } from '@univerjs/drawing';
3
+ import { IMessageService } from '@univerjs/ui';
4
+ import { IDocDrawingService } from '@univerjs/docs-drawing';
5
+ import { DocSkeletonManagerService, TextSelectionManagerService } from '@univerjs/docs';
6
+ import { IRenderManagerService } from '@univerjs/engine-render';
7
+
8
+ export declare class DocDrawingUpdateController extends Disposable {
9
+ private readonly _commandService;
10
+ private readonly _univerInstanceService;
11
+ private readonly _textSelectionManagerService;
12
+ private readonly _imageIoService;
13
+ private readonly _sheetDrawingService;
14
+ private readonly _drawingManagerService;
15
+ private readonly _contextService;
16
+ private readonly _messageService;
17
+ private readonly _localeService;
18
+ private readonly _docSkeletonManagerService;
19
+ private readonly _renderManagerService;
20
+ constructor(_commandService: ICommandService, _univerInstanceService: IUniverInstanceService, _textSelectionManagerService: TextSelectionManagerService, _imageIoService: IImageIoService, _sheetDrawingService: IDocDrawingService, _drawingManagerService: IDrawingManagerService, _contextService: IContextService, _messageService: IMessageService, _localeService: LocaleService, _docSkeletonManagerService: DocSkeletonManagerService, _renderManagerService: IRenderManagerService);
21
+ private _init;
22
+ /**
23
+ * Upload image to cell or float image
24
+ */
25
+ private _initCommandListeners;
26
+ private _insertFloatImage;
27
+ private _getUnitInfo;
28
+ private _getImagePosition;
29
+ private _updateOrderListener;
30
+ private _updateDrawingListener;
31
+ private _getDocsOffsetInfo;
32
+ private _refreshDocSkeleton;
33
+ private _groupDrawingListener;
34
+ private _focusDrawingListener;
35
+ }
@@ -0,0 +1,17 @@
1
+ import { Disposable, ICommandService } from '@univerjs/core';
2
+ import { ComponentManager, IMenuService, IShortcutService } from '@univerjs/ui';
3
+ import { Injector } from '@wendellhu/redi';
4
+
5
+ export declare class DocDrawingUIController extends Disposable {
6
+ private readonly _injector;
7
+ private readonly _componentManager;
8
+ private readonly _menuService;
9
+ private readonly _commandService;
10
+ private readonly _shortcutService;
11
+ constructor(_injector: Injector, _componentManager: ComponentManager, _menuService: IMenuService, _commandService: ICommandService, _shortcutService: IShortcutService);
12
+ private _initCustomComponents;
13
+ private _initMenus;
14
+ private _initCommands;
15
+ private _initShortcuts;
16
+ private _init;
17
+ }
@@ -0,0 +1,20 @@
1
+ import { IContextService, IUniverInstanceService, RxDisposable } from '@univerjs/core';
2
+ import { IRenderManagerService } from '@univerjs/engine-render';
3
+ import { DocCanvasPopManagerService } from '@univerjs/docs-ui';
4
+ import { IDrawingManagerService } from '@univerjs/drawing';
5
+
6
+ export declare class DocDrawingPopupMenuController extends RxDisposable {
7
+ private readonly _drawingManagerService;
8
+ private readonly _canvasPopManagerService;
9
+ private readonly _renderManagerService;
10
+ private readonly _univerInstanceService;
11
+ private readonly _contextService;
12
+ private _initImagePopupMenu;
13
+ constructor(_drawingManagerService: IDrawingManagerService, _canvasPopManagerService: DocCanvasPopManagerService, _renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _contextService: IContextService);
14
+ private _init;
15
+ private _dispose;
16
+ private _create;
17
+ private _hasCropObject;
18
+ private _popupMenuListener;
19
+ private _getImageMenuItems;
20
+ }
@@ -0,0 +1,10 @@
1
+ import { IContextService } from '@univerjs/core';
2
+ import { IShortcutItem } from '@univerjs/ui';
3
+ import { IMoveDrawingsCommandParams } from '../../commands/commands/move-drawings.command';
4
+
5
+ export declare function whenDocDrawingFocused(contextService: IContextService): boolean;
6
+ export declare const MoveDrawingDownShortcutItem: IShortcutItem<IMoveDrawingsCommandParams>;
7
+ export declare const MoveDrawingUpShortcutItem: IShortcutItem<IMoveDrawingsCommandParams>;
8
+ export declare const MoveDrawingLeftShortcutItem: IShortcutItem<IMoveDrawingsCommandParams>;
9
+ export declare const MoveDrawingRightShortcutItem: IShortcutItem<IMoveDrawingsCommandParams>;
10
+ export declare const DeleteDrawingsShortcutItem: IShortcutItem;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { UniverDocsDrawingUIPlugin } from './plugin';
@@ -0,0 +1,4 @@
1
+ import { default as zhCN } from './zh-CN';
2
+
3
+ declare const locale: typeof zhCN;
4
+ export default locale;
@@ -0,0 +1,4 @@
1
+ import { default as zhCN } from './zh-CN';
2
+
3
+ declare const locale: typeof zhCN;
4
+ export default locale;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ declare const locale: {
17
+ docImage: {
18
+ title: string;
19
+ upload: {
20
+ float: string;
21
+ };
22
+ panel: {
23
+ title: string;
24
+ };
25
+ };
26
+ 'image-popup': {
27
+ replace: string;
28
+ delete: string;
29
+ edit: string;
30
+ crop: string;
31
+ reset: string;
32
+ };
33
+ 'update-status': {
34
+ exceedMaxSize: string;
35
+ invalidImageType: string;
36
+ exceedMaxCount: string;
37
+ invalidImage: string;
38
+ };
39
+ };
40
+ export default locale;
@@ -0,0 +1,12 @@
1
+ import { LocaleService, Plugin, UniverInstanceType } from '@univerjs/core';
2
+ import { Injector } from '@wendellhu/redi';
3
+
4
+ export declare class UniverDocsDrawingUIPlugin extends Plugin {
5
+ protected _injector: Injector;
6
+ private readonly _localeService;
7
+ static type: UniverInstanceType;
8
+ static pluginName: string;
9
+ constructor(config: undefined, _injector: Injector, _localeService: LocaleService);
10
+ onStarting(_injector: Injector): void;
11
+ private _initDependencies;
12
+ }
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ import { IDrawingParam } from '@univerjs/drawing';
3
+
4
+ export interface IDocDrawingAnchorProps {
5
+ drawings: IDrawingParam[];
6
+ }
7
+ export declare const DocDrawingAnchor: (props: IDocDrawingAnchorProps) => React.JSX.Element | undefined;
@@ -0,0 +1,3 @@
1
+ import { default as React } from 'react';
2
+
3
+ export declare const DocDrawingPanel: () => React.JSX.Element | undefined;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export declare const COMPONENT_DOC_DRAWING_PANEL = "COMPONENT_DOC_DRAWING_PANEL";
@@ -0,0 +1,6 @@
1
+ import { IMenuItem } from '@univerjs/ui';
2
+ import { IAccessor } from '@wendellhu/redi';
3
+
4
+ export declare const ImageUploadIcon = "addition-and-subtraction-single";
5
+ export declare function ImageMenuFactory(accessor: IAccessor): IMenuItem;
6
+ export declare function UploadFloatImageMenuFactory(_accessor: IAccessor): IMenuItem;
@@ -0,0 +1,3 @@
1
+ import { default as React } from 'react';
2
+
3
+ export declare const UploadFileMenu: () => React.JSX.Element;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export declare const COMPONENT_DOC_UPLOAD_FILE_MENU = "COMPONENT_DOC_UPLOAD_FILE_MENU";
@@ -0,0 +1 @@
1
+ (function(f,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/engine-render"),require("@univerjs/drawing-ui"),require("rxjs"),require("@univerjs/docs-ui"),require("@univerjs/drawing"),require("@univerjs/docs-drawing"),require("@univerjs/ui"),require("@wendellhu/redi/react-bindings"),require("react"),require("clsx"),require("@univerjs/design"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/engine-render","@univerjs/drawing-ui","rxjs","@univerjs/docs-ui","@univerjs/drawing","@univerjs/docs-drawing","@univerjs/ui","@wendellhu/redi/react-bindings","react","clsx","@univerjs/design","@univerjs/docs"],a):(f=typeof globalThis<"u"?globalThis:f||self,a(f.UniverDocsDrawingUi={},f.UniverCore,f["@wendellhu/redi"],f.UniverEngineRender,f.UniverDrawingUi,f.rxjs,f.UniverDocsUi,f.UniverDrawing,f.UniverDocsDrawing,f.UniverUi,f["@wendellhu/redi/react-bindings"],f.React,f.clsx,f.UniverDesign,f.UniverDocs))})(this,function(f,a,C,E,R,Y,N,I,m,_,U,S,F,V,Q){"use strict";var Ke=Object.defineProperty;var ke=(f,a,C)=>a in f?Ke(f,a,{enumerable:!0,configurable:!0,writable:!0,value:C}):f[a]=C;var k=(f,a,C)=>(ke(f,typeof a!="symbol"?a+"":a,C),C);var K;const M={id:"sheet.operation.clear-drawing-transformer",type:a.CommandType.MUTATION,handler:(e,n)=>{const i=e.get(E.IRenderManagerService);return n.forEach(t=>{var r,o;(o=(r=i.getRenderById(t))==null?void 0:r.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},z={id:"doc.command.remove-doc-image",type:a.CommandType.COMMAND,handler:(e,n)=>{const i=e.get(a.ICommandService),t=e.get(a.IUndoRedoService),r=e.get(m.IDocDrawingService);if(!n)return!1;const{drawings:o}=n,s=[];o.forEach(h=>{const{unitId:D}=h;s.push(D)});const c=r.getBatchRemoveOp(o),{unitId:d,subUnitId:u,undo:p,redo:l,objects:g}=c;return i.syncExecuteCommand(m.SetDocDrawingApplyMutation.id,{unitId:d,subUnitId:u,op:l,objects:g,type:m.DocDrawingApplyType.REMOVE})?(t.pushUndoRedo({unitID:d,undoMutations:[{id:m.SetDocDrawingApplyMutation.id,params:{unitId:d,subUnitId:u,op:p,objects:g,type:m.DocDrawingApplyType.INSERT}},{id:M.id,params:s}],redoMutations:[{id:m.SetDocDrawingApplyMutation.id,params:{unitId:d,subUnitId:u,op:l,objects:g,type:m.DocDrawingApplyType.REMOVE}},{id:M.id,params:s}]}),!0):!1}},X="COMPONENT_DOC_DRAWING_PANEL",J={id:"sidebar.operation.doc-image",type:a.CommandType.COMMAND,handler:async(e,n)=>{const i=e.get(_.ISidebarService),t=e.get(a.LocaleService),r=e.get(I.IDrawingManagerService);switch(n.value){case"open":i.open({header:{title:t.t("docImage.panel.title")},children:{label:X},onClose:()=>{r.focusDrawing(null)},width:360});break;case"close":default:i.close();break}return!0}},ee={id:"sheet.operation.edit-sheet-image",type:a.CommandType.OPERATION,handler:(e,n)=>{const i=e.get(I.IDrawingManagerService),t=e.get(a.ICommandService);return n==null?!1:(i.focusDrawing([n]),t.executeCommand(J.id,{value:"open"}),!0)}};var ge=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,Ie=(e,n,i,t)=>{for(var r=t>1?void 0:t?fe(n,i):n,o=e.length-1,s;o>=0;o--)(s=e[o])&&(r=(t?s(n,i,r):s(r))||r);return t&&r&&ge(n,i,r),r},j=(e,n)=>(i,t)=>n(i,t,e);let $=class extends a.RxDisposable{constructor(n,i,t,r,o){super();k(this,"_initImagePopupMenu",new Set);this._drawingManagerService=n,this._canvasPopManagerService=i,this._renderManagerService=t,this._univerInstanceService=r,this._contextService=o,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_DOC).pipe(Y.takeUntil(this.dispose$)).subscribe(n=>this._create(n)),this._univerInstanceService.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_DOC).pipe(Y.takeUntil(this.dispose$)).subscribe(n=>this._dispose(n)),this._univerInstanceService.getAllUnitsForType(a.UniverInstanceType.UNIVER_DOC).forEach(n=>this._create(n))}_dispose(n){const i=n.getUnitId();this._renderManagerService.removeRender(i)}_create(n){if(!n)return;const i=n.getUnitId();this._renderManagerService.has(i)&&!this._initImagePopupMenu.has(i)&&(this._popupMenuListener(i),this._initImagePopupMenu.add(i))}_hasCropObject(n){const i=n.getAllObjects();for(const t of i)if(t instanceof R.ImageCropperObject)return!0;return!1}_popupMenuListener(n){var o;const i=(o=this._renderManagerService.getRenderById(n))==null?void 0:o.scene;if(!i)return;const t=i.getTransformerByCreate();if(!t)return;const r=[];this.disposeWithMe(a.toDisposable(t.onCreateControlObservable.add(()=>{if(this._hasCropObject(i))return;const s=t.getSelectedObjectMap();if(s.size>1){r.forEach(v=>v.dispose());return}const c=s.values().next().value;if(!c)return;const d=c.oKey,u=this._drawingManagerService.getDrawingOKey(d);if(!u)return;const{unitId:p,subUnitId:l,drawingId:g}=u;r.push(this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(c,{componentKey:R.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(p,l,g)}}))),this._drawingManagerService.focusDrawing([{unitId:p,subUnitId:l,drawingId:g}])}))),this.disposeWithMe(a.toDisposable(t.onClearControlObservable.add(()=>{r.forEach(s=>s.dispose()),this._contextService.setContextValue(a.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)}))),this.disposeWithMe(a.toDisposable(t.onChangingObservable.add(()=>{r.forEach(s=>s.dispose())})))}_getImageMenuItems(n,i,t){return[{label:"image-popup.edit",index:0,commandId:ee.id,commandParams:{unitId:n,subUnitId:i,drawingId:t},disable:!1},{label:"image-popup.delete",index:1,commandId:z.id,commandParams:{unitId:n,drawings:[{unitId:n,subUnitId:i,drawingId:t}]},disable:!1},{label:"image-popup.crop",index:2,commandId:R.OpenImageCropOperation.id,commandParams:{unitId:n,subUnitId:i,drawingId:t},disable:!1},{label:"image-popup.reset",index:3,commandId:R.ImageResetSizeOperation.id,commandParams:[{unitId:n,subUnitId:i,drawingId:t}],disable:!1}]}};$=Ie([a.OnLifecycle(a.LifecycleStages.Rendered,$),j(0,I.IDrawingManagerService),j(1,C.Inject(N.DocCanvasPopManagerService)),j(2,E.IRenderManagerService),j(3,a.IUniverInstanceService),j(4,a.IContextService)],$);var w=function(){return w=Object.assign||function(e){for(var n,i=1,t=arguments.length;i<t;i++){n=arguments[i];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},w.apply(this,arguments)},ve=function(e,n){var i={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(i[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(e);r<t.length;r++)n.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(e,t[r])&&(i[t[r]]=e[t[r]]);return i},ne=S.forwardRef(function(e,n){var i=e.icon,t=e.id,r=e.className,o=e.extend,s=ve(e,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),d=S.useRef("_".concat(Se()));return te(i,"".concat(t),{defIds:i.defIds,idSuffix:d.current},w({ref:n,className:c},s),o)});function te(e,n,i,t,r){return S.createElement(e.tag,w(w({key:n},he(e,i,r)),t),(De(e,i).children||[]).map(function(o,s){return te(o,"".concat(n,"-").concat(e.tag,"-").concat(s),i,void 0,r)}))}function he(e,n,i){var t=w({},e.attrs);i!=null&&i.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=i.colorChannel1);var r=n.defIds;return!r||r.length===0||(e.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(t[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function De(e,n){var i,t=n.defIds;return!t||t.length===0?e:e.tag==="defs"&&(!((i=e.children)===null||i===void 0)&&i.length)?w(w({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?w(w({},r),{attrs:w(w({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):e}function Se(){return Math.random().toString(36).substring(2,8)}ne.displayName="UniverIcon";var _e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z"}}]},ie=S.forwardRef(function(e,n){return S.createElement(ne,Object.assign({},e,{id:"add-image-single",ref:n,icon:_e}))});ie.displayName="AddImageSingle";const H={id:"doc.operation.insert-float-image",type:a.CommandType.OPERATION,handler:(e,n)=>!0},re={uploadFileMenu:"univer-upload-file-menu",uploadFileMenuInput:"univer-upload-file-menu-input"},Ce=()=>{const e=U.useDependency(a.ICommandService),n=S.useRef(null),i=()=>{var o;(o=n.current)==null||o.click()},t=I.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(o=>`.${o.replace("image/","")}`).join(","),r=o=>{const s=o.target.files;if(s==null)return;const c=Array.from(s);e.executeCommand(H.id,{files:c}),n.current&&(n.current.value="")};return S.createElement("div",{onClick:i,className:re.uploadFileMenu},S.createElement("input",{type:"file",className:re.uploadFileMenuInput,ref:n,onChange:r,accept:t,multiple:!0}))},oe="COMPONENT_DOC_UPLOAD_FILE_MENU",ae="addition-and-subtraction-single",se="doc.menu.image";function ye(e){return{id:se,type:_.MenuItemType.SUBITEMS,positions:[_.MenuPosition.TOOLBAR_START],group:_.MenuGroup.TOOLBAR_LAYOUT,icon:ae,tooltip:"docImage.title",hidden$:_.getMenuHiddenObservable(e,a.UniverInstanceType.UNIVER_DOC)}}function Me(e){return{id:H.id,title:"docImage.upload.float",type:_.MenuItemType.SELECTOR,label:{name:oe},positions:[se],hidden$:_.getMenuHiddenObservable(e,a.UniverInstanceType.UNIVER_DOC)}}const T={imageCommonPanel:"univer-image-common-panel",imageCommonPanelGrid:"univer-image-common-panel-grid",imageCommonPanelBorder:"univer-image-common-panel-border",imageCommonPanelTitle:"univer-image-common-panel-title",imageCommonPanelRow:"univer-image-common-panel-row",imageCommonPanelRowVertical:"univer-image-common-panel-row-vertical",imageCommonPanelColumn:"univer-image-common-panel-column",imageCommonPanelColumnCenter:"univer-image-common-panel-column-center",imageCommonPanelInline:"univer-image-common-panel-inline",imageCommonPanelSpan2:"univer-image-common-panel-span2",imageCommonPanelSpan3:"univer-image-common-panel-span3",imageCommonPanelInput:"univer-image-common-panel-input",sheetImageMenu:"univer-sheet-image-menu",sheetImageMenuInput:"univer-sheet-image-menu-input"},Z={id:"doc.command.set-doc-image",type:a.CommandType.COMMAND,handler:(e,n)=>{const i=e.get(a.ICommandService),t=e.get(a.IUndoRedoService),r=e.get(m.IDocDrawingService);if(!n)return!1;const{drawings:o}=n,s=r.getBatchUpdateOp(o),{unitId:c,subUnitId:d,undo:u,redo:p,objects:l}=s;return i.syncExecuteCommand(m.SetDocDrawingApplyMutation.id,{unitId:c,subUnitId:d,op:p,objects:l,type:m.DocDrawingApplyType.UPDATE})?(t.pushUndoRedo({unitID:c,undoMutations:[{id:m.SetDocDrawingApplyMutation.id,params:{unitId:c,subUnitId:d,op:u,objects:l,type:m.DocDrawingApplyType.UPDATE}},{id:M.id,params:[c]}],redoMutations:[{id:m.SetDocDrawingApplyMutation.id,params:{unitId:c,subUnitId:d,op:p,objects:l,type:m.DocDrawingApplyType.UPDATE}},{id:M.id,params:[c]}]}),!0):!1}},we=e=>{U.useDependency(a.ICommandService);const n=U.useDependency(a.LocaleService),i=U.useDependency(I.IDrawingManagerService),t=U.useDependency(E.IRenderManagerService),{drawings:r}=e,o=r[0];if(o==null)return;const{unitId:s}=o,c=t.getRenderById(s),d=c==null?void 0:c.scene;if(d==null)return;const u=d.getTransformerByCreate(),[p,l]=S.useState(!0);S.useState("");function g(h,D){const y=[];return h.forEach(P=>{const{oKey:A}=P;if(D.getDrawingOKey(A)==null)return y.push(null),!0}),y}S.useEffect(()=>{const h=u.onClearControlObservable.add(y=>{y===!0&&l(!1)}),D=u.onChangeStartObservable.add(y=>{const{objects:P}=y;g(P,i)});return()=>{D==null||D.dispose(),h==null||h.dispose()}},[]);const v=h=>h?"block":"none";return S.createElement("div",{className:F(T.imageCommonPanelGrid,T.imageCommonPanelBorder),style:{display:v(p)}},S.createElement("div",{className:T.imageCommonPanelRow},S.createElement("div",{className:F(T.imageCommonPanelColumn,T.imageCommonPanelTitle)},S.createElement("div",null,n.t("drawing-anchor.title")))),S.createElement("div",{className:F(T.imageCommonPanelRow)},S.createElement("div",{className:F(T.imageCommonPanelColumn)})))},Oe=()=>{const e=U.useDependency(I.IDrawingManagerService),n=e.getFocusDrawings();if(n==null||n.length===0)return;const[i,t]=S.useState(n);return S.useEffect(()=>{const r=e.focus$.subscribe(o=>{t(o)});return()=>{r.unsubscribe()}},[]),S.createElement("div",{className:T.imageCommonPanel},S.createElement(R.DrawingCommonPanel,{drawings:i}),S.createElement(we,{drawings:i}))},L={id:"doc.command.move-drawing",type:a.CommandType.COMMAND,handler:(e,n)=>{const i=e.get(a.ICommandService),t=e.get(m.IDocDrawingService),{direction:r}=n,o=t.getFocusDrawings();if(o.length===0)return!1;const s=o[0].unitId,c=o.map(u=>{const{transform:p}=u;if(p==null)return null;const l={...p},{left:g=0,top:v=0}=p;return r===a.Direction.UP?l.top=v-1:r===a.Direction.DOWN?l.top=v+1:r===a.Direction.LEFT?l.left=g-1:r===a.Direction.RIGHT&&(l.left=g+1),{...u,transform:l,docTransform:N.transformToDocDrawingPosition(l)}}).filter(u=>u!=null);return i.syncExecuteCommand(Z.id,{unitId:s,drawings:c})?(i.syncExecuteCommand(M.id,[s]),!0):!1}},ce={id:"doc.command.delete-drawing",type:a.CommandType.COMMAND,handler:e=>{const n=e.get(a.ICommandService),t=e.get(m.IDocDrawingService).getFocusDrawings();if(t.length===0)return!1;const r=t[0].unitId,o=t.map(s=>{const{unitId:c,subUnitId:d,drawingId:u,drawingType:p}=s;return{unitId:c,subUnitId:d,drawingId:u,drawingType:p}});return n.executeCommand(z.id,{unitId:r,drawings:o})}},de={id:"doc.command.set-drawing-arrange",type:a.CommandType.COMMAND,handler:(e,n)=>{const i=e.get(a.ICommandService),t=e.get(a.IUndoRedoService);if(!n)return!1;const r=e.get(m.IDocDrawingService),{unitId:o,subUnitId:s,drawingIds:c,arrangeType:d}=n,u={unitId:o,subUnitId:s,drawingIds:c};let p;if(d===I.ArrangeTypeEnum.forward?p=r.getForwardDrawingsOp(u):d===I.ArrangeTypeEnum.backward?p=r.getBackwardDrawingOp(u):d===I.ArrangeTypeEnum.front?p=r.getFrontDrawingsOp(u):d===I.ArrangeTypeEnum.back&&(p=r.getBackDrawingsOp(u)),p==null)return!1;const{objects:l,redo:g,undo:v}=p;return i.syncExecuteCommand(m.SetDocDrawingApplyMutation.id,{op:g,unitId:o,subUnitId:s,objects:l,type:m.DocDrawingApplyType.ARRANGE})?(t.pushUndoRedo({unitID:o,undoMutations:[{id:m.SetDocDrawingApplyMutation.id,params:{op:v,unitId:o,subUnitId:s,objects:l,type:m.DocDrawingApplyType.ARRANGE}}],redoMutations:[{id:m.SetDocDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:s,objects:l,type:m.DocDrawingApplyType.ARRANGE}}]}),!0):!1}};function Pe(e){const n=[];return e.forEach(i=>{const{parent:t,children:r}=i,{unitId:o,subUnitId:s,drawingId:c}=t,d=E.getGroupState(0,0,r.map(l=>l.transform||{})),u=r.map(l=>{const g=l.transform||{left:0,top:0},{unitId:v,subUnitId:h,drawingId:D}=l;return{unitId:v,subUnitId:h,drawingId:D,transform:{...g,left:g.left-d.left,top:g.top-d.top},groupId:c}}),p={unitId:o,subUnitId:s,drawingId:c,drawingType:I.DrawingTypeEnum.DRAWING_GROUP,transform:d};n.push({parent:p,children:u})}),n}function Te(e){const n=[];return e.forEach(i=>{const{parent:t,children:r}=i,{unitId:o,subUnitId:s,drawingId:c,transform:d={width:0,height:0}}=t;if(d==null)return;const u=r.map(l=>{const{transform:g}=l,{unitId:v,subUnitId:h,drawingId:D}=l,y=E.transformObjectOutOfGroup(g||{},d,d.width||0,d.height||0);return{unitId:v,subUnitId:h,drawingId:D,transform:y,groupId:void 0}}),p={unitId:o,subUnitId:s,drawingId:c,drawingType:I.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};n.push({parent:p,children:u})}),n}const ue={id:"doc.command.ungroup-doc-image",type:a.CommandType.COMMAND,handler:(e,n)=>{const i=e.get(a.ICommandService),t=e.get(a.IUndoRedoService),r=e.get(m.IDocDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:v,children:h})=>{o.push(v.unitId),h.forEach(D=>{o.push(D.unitId)})});const s=r.getUngroupDrawingOp(n),{unitId:c,subUnitId:d,undo:u,redo:p,objects:l}=s;return i.syncExecuteCommand(m.SetDocDrawingApplyMutation.id,{op:p,unitId:c,subUnitId:d,objects:l,type:m.DocDrawingApplyType.UNGROUP})?(t.pushUndoRedo({unitID:c,undoMutations:[{id:m.SetDocDrawingApplyMutation.id,params:{op:u,unitId:c,subUnitId:d,objects:Pe(l),type:m.DocDrawingApplyType.GROUP}},{id:M.id,params:o}],redoMutations:[{id:m.SetDocDrawingApplyMutation.id,params:{op:p,unitId:c,subUnitId:d,objects:l,type:m.DocDrawingApplyType.UNGROUP}},{id:M.id,params:o}]}),!0):!1}},me={id:"doc.command.group-doc-image",type:a.CommandType.COMMAND,handler:(e,n)=>{const i=e.get(a.ICommandService),t=e.get(a.IUndoRedoService),r=e.get(m.IDocDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:v,children:h})=>{o.push(v.unitId),h.forEach(D=>{o.push(D.unitId)})});const s=r.getGroupDrawingOp(n),{unitId:c,subUnitId:d,undo:u,redo:p,objects:l}=s;return i.syncExecuteCommand(m.SetDocDrawingApplyMutation.id,{op:p,unitId:c,subUnitId:d,objects:l,type:m.DocDrawingApplyType.GROUP})?(t.pushUndoRedo({unitID:c,undoMutations:[{id:m.SetDocDrawingApplyMutation.id,params:{op:u,unitId:c,subUnitId:d,objects:Te(l),type:m.DocDrawingApplyType.UNGROUP}},{id:M.id,params:o}],redoMutations:[{id:m.SetDocDrawingApplyMutation.id,params:{op:p,unitId:c,subUnitId:d,objects:l,type:m.DocDrawingApplyType.GROUP}},{id:M.id,params:o}]}),!0):!1}},le={id:"doc.command.insert-doc-image",type:a.CommandType.COMMAND,handler:(e,n)=>{const i=e.get(a.ICommandService),t=e.get(a.IUndoRedoService),r=e.get(m.IDocDrawingService);if(!n)return!1;const o=n.drawings,s=o.map(h=>h.unitId),c=r.getBatchAddOp(o),{unitId:d,subUnitId:u,undo:p,redo:l,objects:g}=c;return i.syncExecuteCommand(m.SetDocDrawingApplyMutation.id,{op:l,unitId:d,subUnitId:u,objects:g,type:m.DocDrawingApplyType.INSERT})?(t.pushUndoRedo({unitID:d,undoMutations:[{id:m.SetDocDrawingApplyMutation.id,params:{op:p,unitId:d,subUnitId:u,objects:g,type:m.DocDrawingApplyType.REMOVE}},{id:M.id,params:s}],redoMutations:[{id:m.SetDocDrawingApplyMutation.id,params:{op:l,unitId:d,subUnitId:u,objects:g,type:m.DocDrawingApplyType.INSERT}},{id:M.id,params:s}]}),!0):!1}};function G(e){return!e.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&e.getContextValue(a.FOCUSING_COMMON_DRAWINGS)}const Ee={id:L.id,description:"shortcut.doc.drawing-move-down",group:"4_doc-drawing-view",binding:_.KeyCode.ARROW_DOWN,priority:100,preconditions:G,staticParameters:{direction:a.Direction.DOWN}},Ue={id:L.id,description:"shortcut.doc.drawing-move-up",group:"4_doc-drawing-view",binding:_.KeyCode.ARROW_UP,priority:100,preconditions:G,staticParameters:{direction:a.Direction.UP}},Ae={id:L.id,description:"shortcut.doc.drawing-move-left",group:"4_doc-drawing-view",binding:_.KeyCode.ARROW_LEFT,priority:100,preconditions:G,staticParameters:{direction:a.Direction.LEFT}},be={id:L.id,description:"shortcut.doc.drawing-move-right",group:"4_doc-drawing-view",binding:_.KeyCode.ARROW_RIGHT,priority:100,preconditions:G,staticParameters:{direction:a.Direction.RIGHT}},Re={id:ce.id,description:"shortcut.doc.drawing-delete",group:"4_doc-drawing-view",preconditions:G,binding:_.KeyCode.DELETE,mac:_.KeyCode.BACKSPACE};var Ne=Object.defineProperty,je=Object.getOwnPropertyDescriptor,Le=(e,n,i,t)=>{for(var r=t>1?void 0:t?je(n,i):n,o=e.length-1,s;o>=0;o--)(s=e[o])&&(r=(t?s(n,i,r):s(r))||r);return t&&r&&Ne(n,i,r),r},x=(e,n)=>(i,t)=>n(i,t,e);let B=class extends a.Disposable{constructor(e,n,i,t,r){super(),this._injector=e,this._componentManager=n,this._menuService=i,this._commandService=t,this._shortcutService=r,this._init()}_initCustomComponents(){const e=this._componentManager;this.disposeWithMe(e.register(ae,ie)),this.disposeWithMe(e.register(oe,Ce)),this.disposeWithMe(e.register(X,Oe))}_initMenus(){[ye,Me].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e),{}))})}_initCommands(){[H,le,z,Z,J,M,ee,me,ue,L,ce,de].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_initShortcuts(){[Ee,Ue,Ae,be,Re].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};B=Le([a.OnLifecycle(a.LifecycleStages.Ready,B),x(0,C.Inject(C.Injector)),x(1,C.Inject(_.ComponentManager)),x(2,_.IMenuService),x(3,a.ICommandService),x(4,_.IShortcutService)],B);var Ge=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,We=(e,n,i,t)=>{for(var r=t>1?void 0:t?xe(n,i):n,o=e.length-1,s;o>=0;o--)(s=e[o])&&(r=(t?s(n,i,r):s(r))||r);return t&&r&&Ge(n,i,r),r},O=(e,n)=>(i,t)=>n(i,t,e);let q=class extends a.Disposable{constructor(e,n,i,t,r,o,s,c,d,u,p){super(),this._commandService=e,this._univerInstanceService=n,this._textSelectionManagerService=i,this._imageIoService=t,this._sheetDrawingService=r,this._drawingManagerService=o,this._contextService=s,this._messageService=c,this._localeService=d,this._docSkeletonManagerService=u,this._renderManagerService=p,this._init()}_init(){this._initCommandListeners(),this._updateDrawingListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}_initCommandListeners(){this.disposeWithMe(this._commandService.onCommandExecuted(async e=>{if(e.id===H.id){const n=e.params;if(n.files==null)return;const i=n.files.length;if(i>I.DRAWING_IMAGE_COUNT_LIMIT){this._messageService.show({type:V.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(I.DRAWING_IMAGE_COUNT_LIMIT))});return}this._imageIoService.setWaitCount(i),n.files.forEach(async t=>{await this._insertFloatImage(t)})}}))}async _insertFloatImage(e){var A;let n;try{n=await this._imageIoService.saveImage(e)}catch(W){const b=W.message;b===I.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:V.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(I.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):b===I.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:V.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):b===I.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:V.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return;const i=this._getUnitInfo();if(i==null)return;const{unitId:t,subUnitId:r}=i,{imageId:o,imageSourceType:s,source:c,base64Cache:d}=n,{width:u,height:p,image:l}=await I.getImageSize(d||""),g=this._renderManagerService.getRenderById(t);if(g==null)return;const{width:v,height:h}=g.scene;this._imageIoService.addImageSourceCache(o,s,l);let D=1;if(u>I.DRAWING_IMAGE_WIDTH_LIMIT||p>I.DRAWING_IMAGE_HEIGHT_LIMIT){const W=I.DRAWING_IMAGE_WIDTH_LIMIT/u,b=I.DRAWING_IMAGE_HEIGHT_LIMIT/p;D=Math.max(W,b)}const y=this._getImagePosition(u*D,p*D,v,h);if(y==null)return;const P={unitId:t,subUnitId:r,drawingId:o,drawingType:I.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:s,source:c,transform:N.docDrawingPositionToTransform(y),docTransform:y,title:"",description:"",layoutType:a.PositionedObjectLayoutType.WRAP_SQUARE};this._commandService.executeCommand(le.id,{unitId:t,drawings:[P]}),(A=this._docSkeletonManagerService.getCurrent())==null||A.skeleton.calculate()}_getUnitInfo(){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_DOC);if(e==null)return;const n=e.getUnitId();return{unitId:n,subUnitId:n}}_getImagePosition(e,n,i,t){const r=this._textSelectionManagerService.getActiveTextRange(),o=(r==null?void 0:r.getAbsolutePosition())||{left:0,top:0};return{size:{width:e,height:n},positionH:{relativeFrom:a.ObjectRelativeFromH.MARGIN,posOffset:o.left},positionV:{relativeFrom:a.ObjectRelativeFromV.PAGE,posOffset:o.top},angle:0}}_updateOrderListener(){this._drawingManagerService.featurePluginOrderUpdate$.subscribe(e=>{const{unitId:n,subUnitId:i,drawingIds:t,arrangeType:r}=e;this._commandService.executeCommand(de.id,{unitId:n,subUnitId:i,drawingIds:t,arrangeType:r})})}_updateDrawingListener(){this._drawingManagerService.featurePluginUpdate$.subscribe(e=>{const n=[];e.length!==0&&(e.forEach(i=>{const{unitId:t,subUnitId:r,drawingId:o,drawingType:s,transform:c}=i;if(c==null)return;const d=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:r,drawingId:o});if(d==null)return;const u=N.transformToDocDrawingPosition({...d.transform,...c});if(u==null)return;const p={...i,transform:{...c,...N.docDrawingPositionToTransform(u)},docTransform:{...u}};n.push(p)}),n.length>0&&(this._commandService.syncExecuteCommand(Z.id,{unitId:e[0].unitId,drawings:n}),this._refreshDocSkeleton()))})}_getDocsOffsetInfo(){const e=this._docSkeletonManagerService.getCurrent();if(e==null)return{pageMarginCache:new Map,docsLeft:0,docsTop:0};const{unitId:n,skeleton:i}=e,t=this._renderManagerService.getRenderById(n),r=i==null?void 0:i.getSkeletonData();if(t==null||!r)return{pageMarginCache:new Map,docsLeft:0,docsTop:0};const{mainComponent:o}=t,s=o,{left:c,top:d,pageLayoutType:u,pageMarginLeft:p,pageMarginTop:l}=s,{pages:g}=r,v=new E.Liquid,h=new Map;for(let D=0,y=g.length;D<y;D++){const P=g[D],{skeDrawings:A,marginLeft:W,marginTop:b}=P;v.translatePagePadding(P),A.forEach(Be=>{const{aLeft:mn,aTop:ln,height:pn,width:gn,drawingId:qe,drawingOrigin:fn}=Be;h.set(qe,{marginLeft:v.x,marginTop:v.y})}),v.restorePagePadding(P),v.translatePage(P,u,p,l)}return{pageMarginCache:h,docsLeft:c,docsTop:d}}_refreshDocSkeleton(){const e=this._docSkeletonManagerService.getCurrent();if(e==null)return;const{unitId:n,skeleton:i}=e,t=this._renderManagerService.getRenderById(n);if(t==null)return;const{mainComponent:r}=t;i==null||i.calculate(),r==null||r.makeDirty()}_groupDrawingListener(){this._drawingManagerService.featurePluginGroupUpdate$.subscribe(e=>{this._commandService.executeCommand(me.id,e)}),this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(e=>{this._commandService.executeCommand(ue.id,e)})}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(e=>{e==null||e.length===0?(this._contextService.setContextValue(a.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(a.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(e))}))}};q=We([a.OnLifecycle(a.LifecycleStages.Rendered,q),O(0,a.ICommandService),O(1,a.IUniverInstanceService),O(2,C.Inject(Q.TextSelectionManagerService)),O(3,I.IImageIoService),O(4,m.IDocDrawingService),O(5,I.IDrawingManagerService),O(6,a.IContextService),O(7,_.IMessageService),O(8,C.Inject(a.LocaleService)),O(9,C.Inject(Q.DocSkeletonManagerService)),O(10,E.IRenderManagerService)],q);var Fe=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,$e=(e,n,i,t)=>{for(var r=t>1?void 0:t?Ve(n,i):n,o=e.length-1,s;o>=0;o--)(s=e[o])&&(r=(t?s(n,i,r):s(r))||r);return t&&r&&Fe(n,i,r),r},pe=(e,n)=>(i,t)=>n(i,t,e);const He="Docs_Drawing_UI_PLUGIN";f.UniverDocsDrawingUIPlugin=(K=class extends a.Plugin{constructor(n,i,t){super(),this._injector=i,this._localeService=t}onStarting(n){this._initDependencies(n)}_initDependencies(n){[[B],[q],[$]].forEach(t=>n.add(t))}},k(K,"type",a.UniverInstanceType.UNIVER_DOC),k(K,"pluginName",He),K),f.UniverDocsDrawingUIPlugin=$e([pe(1,C.Inject(C.Injector)),pe(2,C.Inject(a.LocaleService))],f.UniverDocsDrawingUIPlugin),Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
package/package.json ADDED
@@ -0,0 +1,100 @@
1
+ {
2
+ "name": "@univerjs/docs-drawing-ui",
3
+ "version": "0.1.13",
4
+ "private": false,
5
+ "description": "",
6
+ "author": "DreamNum <developer@univer.ai>",
7
+ "license": "Apache-2.0",
8
+ "funding": {
9
+ "type": "opencollective",
10
+ "url": "https://opencollective.com/univer"
11
+ },
12
+ "homepage": "https://univer.ai",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/dream-num/univer"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/dream-num/univer/issues"
19
+ },
20
+ "keywords": [],
21
+ "sideEffects": [
22
+ "**/*.css"
23
+ ],
24
+ "exports": {
25
+ ".": {
26
+ "import": "./lib/es/index.js",
27
+ "require": "./lib/cjs/index.js",
28
+ "types": "./lib/types/index.d.ts"
29
+ },
30
+ "./*": {
31
+ "import": "./lib/es/*",
32
+ "require": "./lib/cjs/*",
33
+ "types": "./lib/types/index.d.ts"
34
+ },
35
+ "./locale/*": "./lib/locale/*.json",
36
+ "./lib/*": "./lib/*"
37
+ },
38
+ "main": "./lib/cjs/index.js",
39
+ "module": "./lib/es/index.js",
40
+ "types": "./lib/types/index.d.ts",
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "directories": {
45
+ "lib": "lib"
46
+ },
47
+ "files": [
48
+ "lib"
49
+ ],
50
+ "engines": {
51
+ "node": ">=16.0.0",
52
+ "npm": ">=8.0.0"
53
+ },
54
+ "peerDependencies": {
55
+ "@wendellhu/redi": "0.15.2",
56
+ "clsx": ">=2.0.0",
57
+ "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
58
+ "rxjs": ">=7.0.0",
59
+ "@univerjs/core": "0.1.13",
60
+ "@univerjs/design": "0.1.13",
61
+ "@univerjs/docs": "0.1.13",
62
+ "@univerjs/docs-drawing": "0.1.13",
63
+ "@univerjs/drawing": "0.1.13",
64
+ "@univerjs/docs-ui": "0.1.13",
65
+ "@univerjs/drawing-ui": "0.1.13",
66
+ "@univerjs/engine-render": "0.1.13",
67
+ "@univerjs/ui": "0.1.13"
68
+ },
69
+ "dependencies": {
70
+ "@univerjs/icons": "^0.1.55"
71
+ },
72
+ "devDependencies": {
73
+ "@wendellhu/redi": "0.15.2",
74
+ "clsx": "^2.1.1",
75
+ "less": "^4.2.0",
76
+ "ot-json1": "^1.0.2",
77
+ "react": "18.2.0",
78
+ "rxjs": "^7.8.1",
79
+ "typescript": "^5.4.5",
80
+ "vite": "^5.2.12",
81
+ "vitest": "^1.6.0",
82
+ "@univerjs/docs": "0.1.13",
83
+ "@univerjs/core": "0.1.13",
84
+ "@univerjs/design": "0.1.13",
85
+ "@univerjs/docs-drawing": "0.1.13",
86
+ "@univerjs/drawing": "0.1.13",
87
+ "@univerjs/drawing-ui": "0.1.13",
88
+ "@univerjs/docs-ui": "0.1.13",
89
+ "@univerjs/shared": "0.1.13",
90
+ "@univerjs/engine-render": "0.1.13",
91
+ "@univerjs/ui": "0.1.13"
92
+ },
93
+ "scripts": {
94
+ "test": "vitest run",
95
+ "test:watch": "vitest",
96
+ "coverage": "vitest run --coverage",
97
+ "lint:types": "tsc --noEmit",
98
+ "build": "tsc && vite build"
99
+ }
100
+ }