Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

refactor(drawing): fix incorrect dependency (#2379)

Wenzhao Huec2fd66519d1
diff --git a/examples/package.json b/examples/package.json
index 8e0c586aeb..e55247f274 100644
--- a/examples/package.json
+++ b/examples/package.json
@@ -17,6 +17,7 @@
"@univerjs/debugger": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/docs": "workspace:*",
+ "@univerjs/docs-drawing": "workspace:*",
"@univerjs/docs-drawing-ui": "workspace:*",
"@univerjs/docs-ui": "workspace:*",
"@univerjs/drawing": "workspace:*",
@@ -31,6 +32,7 @@
"@univerjs/sheets-conditional-formatting": "workspace:*",
"@univerjs/sheets-conditional-formatting-ui": "workspace:*",
"@univerjs/sheets-data-validation": "workspace:*",
+ "@univerjs/sheets-drawing": "workspace:*",
"@univerjs/sheets-drawing-ui": "workspace:*",
"@univerjs/sheets-filter": "workspace:*",
"@univerjs/sheets-filter-ui": "workspace:*",
diff --git a/examples/src/docs/main.ts b/examples/src/docs/main.ts
index 0f1d3345c3..1762644c48 100644
--- a/examples/src/docs/main.ts
+++ b/examples/src/docs/main.ts
@@ -25,6 +25,7 @@ import { UniverDrawingPlugin } from '@univerjs/drawing';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
import { UniverDebuggerPlugin } from '@univerjs/debugger';
import { UniverDrawingUIPlugin } from '@univerjs/drawing-ui';
+import { UniverDocsDrawingPlugin } from '@univerjs/docs-drawing';
import { UniverDocsDrawingUIPlugin } from '@univerjs/docs-drawing-ui';
import { DEFAULT_DOCUMENT_DATA_CN } from '../data';
import { enUS, ruRU, zhCN } from '../locales';
@@ -69,6 +70,7 @@ univer.registerPlugin(UniverDocsUIPlugin, {
});
univer.registerPlugin(UniverDrawingUIPlugin);
+univer.registerPlugin(UniverDocsDrawingPlugin);
univer.registerPlugin(UniverDocsDrawingUIPlugin);
univer.createUnit(UniverInstanceType.UNIVER_DOC, DEFAULT_DOCUMENT_DATA_CN);
diff --git a/examples/src/sheets/main.ts b/examples/src/sheets/main.ts
index c153770245..9310ff27f6 100644
--- a/examples/src/sheets/main.ts
+++ b/examples/src/sheets/main.ts
@@ -42,7 +42,10 @@ import { FUniver } from '@univerjs/facade';
import { IThreadCommentMentionDataService } from '@univerjs/thread-comment-ui';
import { UniverDrawingPlugin } from '@univerjs/drawing';
import { UniverDrawingUIPlugin } from '@univerjs/drawing-ui';
+import { UniverSheetsDrawingPlugin } from '@univerjs/sheets-drawing';
import { UniverSheetsDrawingUIPlugin } from '@univerjs/sheets-drawing-ui';
+
+import { UniverDocsDrawingPlugin } from '@univerjs/docs-drawing';
import { DEFAULT_WORKBOOK_DATA_DEMO } from '../data/sheets/demo/default-workbook-data-demo';
import { enUS, ruRU, zhCN } from '../locales';
@@ -111,7 +114,10 @@ univer.registerPlugin(UniverSheetsConditionalFormattingUIPlugin);
// sheet permission
univer.registerPlugin(UniverSheetsPermissionUIPlugin);
+
// drawing
+univer.registerPlugin(UniverDocsDrawingPlugin);
+univer.registerPlugin(UniverSheetsDrawingPlugin);
univer.registerPlugin(UniverDrawingUIPlugin);
univer.registerPlugin(UniverSheetsDrawingUIPlugin);
diff --git a/packages/docs-drawing-ui/package.json b/packages/docs-drawing-ui/package.json
index 56d663b833..6710b22608 100644
--- a/packages/docs-drawing-ui/package.json
+++ b/packages/docs-drawing-ui/package.json
@@ -69,6 +69,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/docs": "workspace:*",
+ "@univerjs/docs-drawing": "workspace:*",
"@univerjs/docs-ui": "workspace:*",
"@univerjs/drawing": "workspace:*",
"@univerjs/drawing-ui": "workspace:*",
@@ -86,6 +87,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/docs": "workspace:*",
+ "@univerjs/docs-drawing": "workspace:*",
"@univerjs/docs-ui": "workspace:*",
"@univerjs/drawing": "workspace:*",
"@univerjs/drawing-ui": "workspace:*",
diff --git a/packages/docs-drawing-ui/src/commands/commands/delete-drawings.command.ts b/packages/docs-drawing-ui/src/commands/commands/delete-drawings.command.ts
index 15ebd56eef..e652ae193d 100644
--- a/packages/docs-drawing-ui/src/commands/commands/delete-drawings.command.ts
+++ b/packages/docs-drawing-ui/src/commands/commands/delete-drawings.command.ts
@@ -16,8 +16,8 @@
import { CommandType, type ICommand, ICommandService } from '@univerjs/core';
import type { IAccessor } from '@wendellhu/redi';
-import type { IDocDrawing } from '@univerjs/docs';
-import { IDocDrawingService } from '@univerjs/docs';
+import type { IDocDrawing } from '@univerjs/docs-drawing';
+import { IDocDrawingService } from '@univerjs/docs-drawing';
import { RemoveDocDrawingCommand } from './remove-doc-drawing.command';
import type { IDeleteDrawingCommandParams } from './interfaces';
diff --git a/packages/docs-drawing-ui/src/commands/commands/group-doc-drawing.command.ts b/packages/docs-drawing-ui/src/commands/commands/group-doc-drawing.command.ts
index 89d2c2bd8d..366ca9f8b3 100644
--- a/packages/docs-drawing-ui/src/commands/commands/group-doc-drawing.command.ts
+++ b/packages/docs-drawing-ui/src/commands/commands/group-doc-drawing.command.ts
@@ -23,7 +23,7 @@ import {
import type { IAccessor } from '@wendellhu/redi';
import type { IDrawingJsonUndo1 } from '@univerjs/drawing';
-import { DocDrawingApplyType, IDocDrawingService, SetDocDrawingApplyMutation } from '@univerjs/docs';
+import { DocDrawingApplyType, IDocDrawingService, SetDocDrawingApplyMutation } from '@univerjs/docs-drawing';
import { ClearDocDrawingTransformerOperation } from '../operations/clear-drawing-transformer.operation';
import { groupToUngroup } from './utils';
diff --git a/packages/docs-drawing-ui/src/commands/commands/insert-doc-drawing.command.ts b/packages/docs-drawing-ui/src/commands/commands/insert-doc-drawing.command.ts
index e7872cf508..5218b99e5d 100644
--- a/packages/docs-drawing-ui/src/commands/commands/insert-doc-drawing.command.ts
+++ b/packages/docs-drawing-ui/src/commands/commands/insert-doc-drawing.command.ts
@@ -21,7 +21,7 @@ import {
IUndoRedoService,
} from '@univerjs/core';
-import { DocDrawingApplyType, IDocDrawingService, SetDocDrawingApplyMutation } from '@univerjs/docs';
+import { DocDrawingApplyType, IDocDrawingService, SetDocDrawingApplyMutation } from '@univerjs/docs-drawing';
import type { IAccessor } from '@wendellhu/redi';
import type { IDrawingJsonUndo1 } from '@univerjs/drawing';
import { ClearDocDrawingTransformerOperation } from '../operations/clear-drawing-transformer.operation';
diff --git a/packages/docs-drawing-ui/src/commands/commands/interfaces.ts b/packages/docs-drawing-ui/src/commands/commands/interfaces.ts
index 14601ace2a..01ece4a550 100644
--- a/packages/docs-drawing-ui/src/commands/commands/interfaces.ts
+++ b/packages/docs-drawing-ui/src/commands/commands/interfaces.ts
@@ -15,7 +15,7 @@
*/
import type { DrawingTypeEnum } from '@univerjs/core';
-import type { IDocDrawing } from '@univerjs/docs';
+import type { IDocDrawing } from '@univerjs/docs-drawing';
export interface IInsertDrawingCommandParams {
unitId: string;
diff --git a/packages/docs-drawing-ui/src/commands/commands/move-drawings.command.ts b/packages/docs-drawing-ui/src/commands/commands/move-drawings.command.ts
index b9896caba2..96c108329b 100644
--- a/packages/docs-drawing-ui/src/commands/commands/move-drawings.command.ts
+++ b/packages/docs-drawing-ui/src/commands/commands/move-drawings.command.ts
@@ -18,9 +18,8 @@ import type { ICommand } from '@univerjs/core';
import { CommandType, Direction, ICommandService } from '@univerjs/core';
import type { IAccessor } from '@wendellhu/redi';
-import type { IDocDrawing } from '@univerjs/docs';
-import { IDocDrawingService } from '@univerjs/docs';
-import { ITextSelectionRenderManager } from '@univerjs/engine-render';
+import type { IDocDrawing } from '@univerjs/docs-drawing';
+import { IDocDrawingService } from '@univerjs/docs-drawing';
import { transformToDocDrawingPosition } from '@univerjs/docs-ui';
import { ClearDocDrawingTransformerOperation } from '../operations/clear-drawing-transformer.operation';
import type { ISetDrawingCommandParams } from './interfaces';
@@ -36,7 +35,6 @@ export const MoveDocDrawingsCommand: ICommand = {
handler: (accessor: IAccessor, params: IMoveDrawingsCommandParams) => {
const commandService = accessor.get(ICommandService);
const docDrawingService = accessor.get(IDocDrawingService);
- const textSelectionRenderService = accessor.get(ITextSelectionRenderManager);
const { direction } = params;
diff --git a/packages/docs-drawing-ui/src/commands/commands/remove-doc-drawing.command.ts b/packages/docs-drawing-ui/src/commands/commands/remove-doc-drawing.command.ts
index c3136cf448..62ebfcd63a 100644
--- a/packages/docs-drawing-ui/src/commands/commands/remove-doc-drawing.command.ts
+++ b/packages/docs-drawing-ui/src/commands/commands/remove-doc-drawing.command.ts
@@ -20,7 +20,7 @@ import {
ICommandService,
IUndoRedoService,
} from '@univerjs/core';
-import { DocDrawingApplyType, IDocDrawingService, SetDocDrawingApplyMutation } from '@univerjs/docs';
+import { DocDrawingApplyType, IDocDrawingService, SetDocDrawingApplyMutation } from '@univerjs/docs-drawing';
import type { IAccessor } from '@wendellhu/redi';
import type { IDrawingJsonUndo1 } from '@univerjs/drawing';
import { ClearDocDrawingTransformerOperation } from '../operations/clear-drawing-transformer.operation';
diff --git a/packages/docs-drawing-ui/src/commands/commands/set-doc-drawing.command.ts b/packages/docs-drawing-ui/src/commands/commands/set-doc-drawing.command.ts
index d356b1d51e..8bb72648ec 100644
--- a/packages/docs-drawing-ui/src/commands/commands/set-doc-drawing.command.ts
+++ b/packages/docs-drawing-ui/src/commands/commands/set-doc-drawing.command.ts
@@ -23,8 +23,8 @@ import {
import type { IAccessor } from '@wendellhu/redi';
import type { IDrawingJsonUndo1 } from '@univerjs/drawing';
-import type { IDocDrawing } from '@univerjs/docs';
-import { DocDrawingApplyType, IDocDrawingService, SetDocDrawingApplyMutation } from '@univerjs/docs';
+import type { IDocDrawing } from '@univerjs/docs-drawing';
+import { DocDrawingApplyType, IDocDrawingService, SetDocDrawingApplyMutation } from '@univerjs/docs-drawing';
import { ClearDocDrawingTransformerOperation } from '../operations/clear-drawing-transformer.operation';
import type { ISetDrawingCommandParams } from './interfaces';
diff --git a/packages/docs-drawing-ui/src/commands/commands/set-drawing-arrange.command.ts b/packages/docs-drawing-ui/src/commands/commands/set-drawing-arrange.command.ts
index bc154ccc66..524fcdca4d 100644
--- a/packages/docs-drawing-ui/src/commands/commands/set-drawing-arrange.command.ts
+++ b/packages/docs-drawing-ui/src/commands/commands/set-drawing-arrange.command.ts
@@ -20,7 +20,7 @@ import { ArrangeTypeEnum,
ICommandService,
IUndoRedoService,
} from '@univerjs/core';
-import { DocDrawingApplyType, IDocDrawingService, SetDocDrawingApplyMutation } from '@univerjs/docs';
+import { DocDrawingApplyType, IDocDrawingService, SetDocDrawingApplyMutation } from '@univerjs/docs-drawing';
import type { IDrawingJsonUndo1 } from '@univerjs/drawing';
import type { IAccessor } from '@wendellhu/redi';
diff --git a/packages/docs-drawing-ui/src/commands/commands/ungroup-doc-drawing.command.ts b/packages/docs-drawing-ui/src/commands/commands/ungroup-doc-drawing.command.ts
index 27345963c0..0db5e4d1ca 100644
--- a/packages/docs-drawing-ui/src/commands/commands/ungroup-doc-drawing.command.ts
+++ b/packages/docs-drawing-ui/src/commands/commands/ungroup-doc-drawing.command.ts
@@ -23,7 +23,7 @@ import {
import type { IAccessor } from '@wendellhu/redi';
import type { IDrawingJsonUndo1 } from '@univerjs/drawing';
-import { DocDrawingApplyType, IDocDrawingService, SetDocDrawingApplyMutation } from '@univerjs/docs';
+import { DocDrawingApplyType, IDocDrawingService, SetDocDrawingApplyMutation } from '@univerjs/docs-drawing';
import { ClearDocDrawingTransformerOperation } from '../operations/clear-drawing-transformer.operation';
import { ungroupToGroup } from './utils';
diff --git a/packages/docs-drawing-ui/src/controllers/doc-drawing-update.controller.ts b/packages/docs-drawing-ui/src/controllers/doc-drawing-update.controller.ts
index 6acd14d6c3..2c3292ad96 100644
--- a/packages/docs-drawing-ui/src/controllers/doc-drawing-update.controller.ts
+++ b/packages/docs-drawing-ui/src/controllers/doc-drawing-update.controller.ts
@@ -20,8 +20,9 @@ import { Inject } from '@wendellhu/redi';
import { DRAWING_IMAGE_ALLOW_SIZE, DRAWING_IMAGE_COUNT_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_WIDTH_LIMIT, getImageSize } from '@univerjs/drawing';
import { IMessageService } from '@univerjs/ui';
import { MessageType } from '@univerjs/design';
-import type { IDocDrawing } from '@univerjs/docs';
-import { DocSkeletonManagerService, IDocDrawingService, TextSelectionManagerService } from '@univerjs/docs';
+import type { IDocDrawing } from '@univerjs/docs-drawing';
+import { IDocDrawingService } from '@univerjs/docs-drawing';
+import { DocSkeletonManagerService, TextSelectionManagerService } from '@univerjs/docs';
import { docDrawingPositionToTransform, transformToDocDrawingPosition } from '@univerjs/docs-ui';
import type { Documents } from '@univerjs/engine-render';
import { IRenderManagerService, ITextSelectionRenderManager, Liquid } from '@univerjs/engine-render';
@@ -166,7 +167,7 @@ export class DocDrawingUpdateController extends Disposable {
drawingType: DrawingTypeEnum.DRAWING_IMAGE,
imageSourceType,
source,
- transform: docDrawingPositionToTransform(docTransform, this._textSelectionRenderManager),
+ transform: docDrawingPositionToTransform(docTransform),
docTransform,
title: '', description: '', layoutType: PositionedObjectLayoutType.WRAP_SQUARE,
};
@@ -266,7 +267,7 @@ export class DocDrawingUpdateController extends Disposable {
const newDrawing: Partial<IDocDrawing> = {
...param,
- transform: { ...transform, ...docDrawingPositionToTransform(docTransform, this._textSelectionRenderManager) },
+ transform: { ...transform, ...docDrawingPositionToTransform(docTransform) },
docTransform: { ...docTransform },
};
diff --git a/packages/docs-drawing-ui/src/views/doc-image-panel/DocDrawingAnchor.tsx b/packages/docs-drawing-ui/src/views/doc-image-panel/DocDrawingAnchor.tsx
index 4ccbaa200a..c3e636ee42 100644
--- a/packages/docs-drawing-ui/src/views/doc-image-panel/DocDrawingAnchor.tsx
+++ b/packages/docs-drawing-ui/src/views/doc-image-panel/DocDrawingAnchor.tsx
@@ -22,7 +22,7 @@ import clsx from 'clsx';
import styles from '@univerjs/drawing-ui/views/panel/index.module.less';
import type { BaseObject } from '@univerjs/engine-render';
import { IRenderManagerService } from '@univerjs/engine-render';
-import type { IDocDrawing } from '@univerjs/docs';
+import type { IDocDrawing } from '@univerjs/docs-drawing';
import { SetDocDrawingCommand } from '../../commands/commands/set-doc-drawing.command';
export interface IDocDrawingAnchorProps {
diff --git a/packages/docs-drawing/README.md b/packages/docs-drawing/README.md
new file mode 100644
index 0000000000..ba97c788b8
--- /dev/null
+++ b/packages/docs-drawing/README.md
@@ -0,0 +1,16 @@
+# @univerjs/docs-drawing
+
+[![npm version](https://img.shields.io/npm/v/@univerjs/docs-drawing)](https://npmjs.org/packages/@univerjs/docs-drawing)
+[![license](https://img.shields.io/npm/l/@univerjs/docs-drawing)](https://img.shields.io/npm/l/@univerjs/docs-drawing)
+
+## Introduction
+
+> TODO: Introduction
+
+## Usage
+
+### Installation
+
+```shell
+npm i @univerjs/docs-drawing
+```
diff --git a/packages/docs-drawing/package.json b/packages/docs-drawing/package.json
new file mode 100644
index 0000000000..914522755a
--- /dev/null
+++ b/packages/docs-drawing/package.json
@@ -0,0 +1,83 @@
+{
+ "name": "@univerjs/docs-drawing",
+ "version": "0.0.1",
+ "private": true,
+ "description": "",
+ "author": "DreamNum <[email protected]>",
+ "license": "Apache-2.0",
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/univer"
+ },
+ "homepage": "https://univer.ai",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/dream-num/univer"
+ },
+ "bugs": {
+ "url": "https://github.com/dream-num/univer/issues"
+ },
+ "keywords": [],
+ "exports": {
+ ".": "./src/index.ts",
+ "./*": "./src/*"
+ },
+ "main": "./lib/cjs/index.js",
+ "module": "./lib/es/index.js",
+ "types": "./lib/types/index.d.ts",
+ "publishConfig": {
+ "access": "public",
+ "main": "./lib/cjs/index.js",
+ "module": "./lib/es/index.js",
+ "exports": {
+ ".": {
+ "import": "./lib/es/index.js",
+ "require": "./lib/cjs/index.js",
+ "types": "./lib/types/index.d.ts"
+ },
+ "./*": {
+ "import": "./lib/es/*",
+ "require": "./lib/cjs/*",
+ "types": "./lib/types/index.d.ts"
+ },
+ "./lib/*": "./lib/*"
+ }
+ },
+ "directories": {
+ "lib": "lib"
+ },
+ "files": [
+ "lib"
+ ],
+ "scripts": {
+ "test": "vitest run",
+ "test:watch": "vitest",
+ "coverage": "vitest run --coverage",
+ "lint:types": "tsc --noEmit",
+ "build": "tsc && vite build"
+ },
+ "peerDependencies": {
+ "@univerjs/core": "workspace:*",
+ "@univerjs/docs": "workspace:*",
+ "@univerjs/docs-ui": "workspace:*",
+ "@univerjs/drawing": "workspace:*",
+ "@univerjs/engine-render": "workspace:*",
+ "@wendellhu/redi": ">=0.12.13",
+ "rxjs": ">=7.0.0"
+ },
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@univerjs/core": "workspace:*",
+ "@univerjs/docs": "workspace:*",
+ "@univerjs/docs-ui": "workspace:*",
+ "@univerjs/drawing": "workspace:*",
+ "@univerjs/engine-render": "workspace:*",
+ "@univerjs/shared": "workspace:*",
+ "@wendellhu/redi": "^0.15.2",
+ "rxjs": "^7.8.1",
+ "typescript": "^5.4.5",
+ "vite": "^5.2.11",
+ "vitest": "^1.6.0"
+ }
+}
diff --git a/packages/docs/src/commands/mutations/set-drawing-apply.mutation.ts b/packages/docs-drawing/src/commands/mutations/set-drawing-apply.mutation.ts
similarity index 98%
rename from packages/docs/src/commands/mutations/set-drawing-apply.mutation.ts
rename to packages/docs-drawing/src/commands/mutations/set-drawing-apply.mutation.ts
index a42b3afb12..d7e6c51bb7 100644
--- a/packages/docs/src/commands/mutations/set-drawing-apply.mutation.ts
+++ b/packages/docs-drawing/src/commands/mutations/set-drawing-apply.mutation.ts
@@ -33,7 +33,7 @@ export interface ISetDrawingApplyMutationParams extends IDrawingJson1Type {
}
export const SetDocDrawingApplyMutation: IMutation<ISetDrawingApplyMutationParams> = {
- id: 'doc.mutation.set-drawing-json-apply',
+ id: 'doc.mutation.set-drawing-apply',
type: CommandType.MUTATION,
handler: (accessor, params) => {
const drawingManagerService = accessor.get(IDrawingManagerService);
diff --git a/packages/docs/src/controllers/doc-drawing-data.controller.ts b/packages/docs-drawing/src/controllers/doc-drawing.controller.ts
similarity index 53%
rename from packages/docs/src/controllers/doc-drawing-data.controller.ts
rename to packages/docs-drawing/src/controllers/doc-drawing.controller.ts
index 36d1b8b9de..e6aee6d1cb 100644
--- a/packages/docs/src/controllers/doc-drawing-data.controller.ts
+++ b/packages/docs-drawing/src/controllers/doc-drawing.controller.ts
@@ -14,18 +14,34 @@
* limitations under the License.
*/
-import type { DocumentDataModel, IDrawingMapItem, IDrawingSubunitMap } from '@univerjs/core';
-import { Disposable, IDrawingManagerService, IResourceManagerService, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
+import type { DocumentDataModel, IDrawingMapItem, IDrawingMapItemData, IDrawingSubunitMap } from '@univerjs/core';
+import { Disposable, ICommandService, IDrawingManagerService, IResourceManagerService, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
+import { ITextSelectionRenderManager } from '@univerjs/engine-render';
+import { docDrawingPositionToTransform } from '@univerjs/docs-ui';
import { type IDocDrawing, IDocDrawingService } from '../services/doc-drawing.service';
+import { SetDocDrawingApplyMutation } from '../commands/mutations/set-drawing-apply.mutation';
-export const DOC_DRAWING_PLUGIN = 'DOC_DRAWING_PLUGIN';
-@OnLifecycle(LifecycleStages.Rendered, DocDrawingDataController)
-export class DocDrawingDataController extends Disposable {
+export const DOCS_DRAWING_PLUGIN = 'DOC_DRAWING_PLUGIN';
+
+@OnLifecycle(LifecycleStages.Starting, DocDrawingLoadController)
+export class DocDrawingLoadController extends Disposable {
+ constructor(
+ @ICommandService private readonly _commandService: ICommandService
+ ) {
+ super();
+
+ this.disposeWithMe(this._commandService.registerCommand(SetDocDrawingApplyMutation));
+ }
+}
+
+@OnLifecycle(LifecycleStages.Rendered, DocDrawingController)
+export class DocDrawingController extends Disposable {
constructor(
@IDocDrawingService private readonly _docDrawingService: IDocDrawingService,
@IDrawingManagerService private readonly _drawingManagerService: IDrawingManagerService,
@IResourceManagerService private _resourceManagerService: IResourceManagerService,
- @IUniverInstanceService private _univerInstanceService: IUniverInstanceService
+ @IUniverInstanceService private _univerInstanceService: IUniverInstanceService,
+ @ITextSelectionRenderManager private readonly _textSelectionRenderManager: ITextSelectionRenderManager
) {
super();
@@ -34,6 +50,7 @@ export class DocDrawingDataController extends Disposable {
private _init(): void {
this._initSnapshot();
+ this._initDataLoader();
}
private _initSnapshot() {
@@ -56,7 +73,7 @@ export class DocDrawingDataController extends Disposable {
};
this.disposeWithMe(
this._resourceManagerService.registerPluginResource<IDrawingSubunitMap<IDocDrawing>>({
- pluginName: DOC_DRAWING_PLUGIN,
+ pluginName: DOCS_DRAWING_PLUGIN,
businesses: [UniverInstanceType.UNIVER_DOC],
toJson: (unitId) => toJson(unitId),
parseJson: (json) => parseJson(json),
@@ -82,4 +99,44 @@ export class DocDrawingDataController extends Disposable {
documentDataModel.resetDrawing(drawingMapItem.data, drawingMapItem.order);
}
+
+ private _initDataLoader(): boolean {
+ const dataModel = this._univerInstanceService.getCurrentUnitForType<DocumentDataModel>(UniverInstanceType.UNIVER_DOC);
+ if (!dataModel) {
+ return false;
+ }
+
+ const unitId = dataModel.getUnitId();
+ const subUnitId = unitId;
+
+ const drawingDataModels = dataModel.getDrawings();
+ const drawingOrderModel = dataModel.getDrawingsOrder();
+
+ if (!drawingDataModels || !drawingOrderModel) {
+ return false;
+ }
+
+ // TODO@wzhudev: should move to docs-drawing
+
+ Object.keys(drawingDataModels).forEach((drawingId) => {
+ const drawingDataModel = drawingDataModels[drawingId];
+ const docTransform = drawingDataModel.docTransform;
+ const transform = docDrawingPositionToTransform(docTransform);
+
+ drawingDataModels[drawingId] = { ...drawingDataModel, transform } as IDocDrawing;
+ });
+
+ const subDrawings = {
+ [subUnitId]: {
+ unitId,
+ subUnitId,
+ data: drawingDataModels as IDrawingMapItemData<IDocDrawing>,
+ order: drawingOrderModel,
+ },
+ };
+
+ this._docDrawingService.registerDrawingData(unitId, subDrawings);
+ this._drawingManagerService.registerDrawingData(unitId, subDrawings);
+ return true;
+ }
}
diff --git a/packages/docs-drawing/src/index.ts b/packages/docs-drawing/src/index.ts
new file mode 100644
index 0000000000..26478f8d39
--- /dev/null
+++ b/packages/docs-drawing/src/index.ts
@@ -0,0 +1,19 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export { UniverDocsDrawingPlugin } from './plugin';
+export { DocDrawingApplyType, SetDocDrawingApplyMutation, type ISetDrawingApplyMutationParams } from './commands/mutations/set-drawing-apply.mutation';
+export { type IDocDrawing, IDocDrawingService, DocDrawingService } from './services/doc-drawing.service';
diff --git a/packages/docs-drawing/src/plugin.ts b/packages/docs-drawing/src/plugin.ts
new file mode 100644
index 0000000000..8729a24822
--- /dev/null
+++ b/packages/docs-drawing/src/plugin.ts
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Plugin, UniverInstanceType } from '@univerjs/core';
+import type { Dependency } from '@wendellhu/redi';
+import { Inject, Injector } from '@wendellhu/redi';
+import { DocDrawingController, DocDrawingLoadController, DOCS_DRAWING_PLUGIN } from './controllers/doc-drawing.controller';
+import { DocDrawingService, IDocDrawingService } from './services/doc-drawing.service';
+
+export class UniverDocsDrawingPlugin extends Plugin {
+ static override pluginName = DOCS_DRAWING_PLUGIN;
+ static override type = UniverInstanceType.UNIVER_DOC;
+
+ constructor(
+ _config: undefined,
+ @Inject(Injector) override _injector: Injector
+ ) {
+ super();
+ }
+
+ override onStarting(_injector: Injector): void {
+ ([
+ [DocDrawingLoadController],
+ [DocDrawingController],
+ [DocDrawingService],
+ [IDocDrawingService, { useClass: DocDrawingService }],
+ ] as Dependency[
+
+ ]).forEach((dependency) => _injector.add(dependency));
+ }
+}
diff --git a/packages/docs/src/services/doc-drawing.service.ts b/packages/docs-drawing/src/services/doc-drawing.service.ts
similarity index 100%
rename from packages/docs/src/services/doc-drawing.service.ts
rename to packages/docs-drawing/src/services/doc-drawing.service.ts
diff --git a/packages/docs-drawing/src/vite-env.d.ts b/packages/docs-drawing/src/vite-env.d.ts
new file mode 100644
index 0000000000..11f02fe2a0
--- /dev/null
+++ b/packages/docs-drawing/src/vite-env.d.ts
@@ -0,0 +1 @@
+/// <reference types="vite/client" />
diff --git a/packages/docs-drawing/tsconfig.json b/packages/docs-drawing/tsconfig.json
new file mode 100644
index 0000000000..d676ad2a20
--- /dev/null
+++ b/packages/docs-drawing/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "@univerjs/shared/tsconfigs/base",
+ "compilerOptions": {
+ "rootDir": "src",
+ "outDir": "lib/types"
+ },
+ "references": [{ "path": "./tsconfig.node.json" }],
+ "include": ["src"]
+}
diff --git a/packages/docs-drawing/tsconfig.node.json b/packages/docs-drawing/tsconfig.node.json
new file mode 100644
index 0000000000..e53dac8868
--- /dev/null
+++ b/packages/docs-drawing/tsconfig.node.json
@@ -0,0 +1,4 @@
+{
+ "extends": "@univerjs/shared/tsconfigs/node",
+ "include": ["vite.config.ts"]
+}
diff --git a/packages/docs-drawing/vite.config.ts b/packages/docs-drawing/vite.config.ts
new file mode 100644
index 0000000000..67b2fff8f2
--- /dev/null
+++ b/packages/docs-drawing/vite.config.ts
@@ -0,0 +1,7 @@
+import createViteConfig from '@univerjs/shared/vite';
+import pkg from './package.json';
+
+export default ({ mode }) => createViteConfig({}, {
+ mode,
+ pkg,
+});
diff --git a/packages/docs-ui/src/basics/transform-position.ts b/packages/docs-ui/src/basics/transform-position.ts
index c28c013b43..d9ecddca7e 100644
--- a/packages/docs-ui/src/basics/transform-position.ts
+++ b/packages/docs-ui/src/basics/transform-position.ts
@@ -15,9 +15,8 @@
*/
import { type IDocDrawingPosition, type ITransformState, type Nullable, ObjectRelativeFromH, ObjectRelativeFromV } from '@univerjs/core';
-import type { ITextSelectionRenderManager } from '@univerjs/engine-render';
-export function docDrawingPositionToTransform(position: IDocDrawingPosition, textSelectionRenderService: ITextSelectionRenderManager): Nullable<ITransformState> {
+export function docDrawingPositionToTransform(position: IDocDrawingPosition): Nullable<ITransformState> {
// const { from, to } = position;
// const { column: fromColumn, columnOffset: fromColumnOffset, row: fromRow, rowOffset: fromRowOffset } = from;
// const { column: toColumn, columnOffset: toColumnOffset, row: toRow, rowOffset: toRowOffset } = to;
diff --git a/packages/docs-ui/src/controllers/doc-ui.controller.ts b/packages/docs-ui/src/controllers/doc-ui.controller.ts
index abfe932659..9fb24de79e 100644
--- a/packages/docs-ui/src/controllers/doc-ui.controller.ts
+++ b/packages/docs-ui/src/controllers/doc-ui.controller.ts
@@ -14,15 +14,14 @@
* limitations under the License.
*/
-import type { DocumentDataModel, IDrawingMapItemData } from '@univerjs/core';
-import { Disposable, IDrawingManagerService, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
+import type { DocumentDataModel } from '@univerjs/core';
+import { Disposable, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
import type { IMenuItemFactory } from '@univerjs/ui';
import { BuiltInUIPart, ComponentManager, IEditorService, ILayoutService, IMenuService, IUIPartsService } from '@univerjs/ui';
import { Inject, Injector } from '@wendellhu/redi';
import { connectInjector } from '@wendellhu/redi/react-bindings';
import { ITextSelectionRenderManager } from '@univerjs/engine-render';
-import { type IDocDrawing, IDocDrawingService } from '@univerjs/docs';
import { COLOR_PICKER_COMPONENT, ColorPicker } from '../components/color-picker';
import {
FONT_FAMILY_COMPONENT,
@@ -33,7 +32,6 @@ import {
import { FONT_SIZE_COMPONENT, FontSize } from '../components/font-size';
import { DocBackground } from '../views/doc-background/DocBackground';
import type { IUniverDocsUIConfig } from '../basics';
-import { docDrawingPositionToTransform } from '../basics/transform-position';
import {
AlignCenterMenuItemFactory,
AlignJustifyMenuItemFactory,
@@ -65,10 +63,7 @@ export class DocUIController extends Disposable {
@IEditorService private readonly _editorService: IEditorService,
@IMenuService private readonly _menuService: IMenuService,
@IUIPartsService private readonly _uiPartsService: IUIPartsService,
- @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
- @Inject(ITextSelectionRenderManager) private readonly _textSelectionRenderManager: ITextSelectionRenderManager,
- @IDocDrawingService private readonly _docDrawingService: IDocDrawingService,
- @IDrawingManagerService private readonly _drawingManagerService: IDrawingManagerService
+ @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService
) {
super();
@@ -117,7 +112,6 @@ export class DocUIController extends Disposable {
this._initMenus();
this._initDocBackground();
this._initFocusHandler();
- this._initDataLoader();
}
private _initDocBackground() {
@@ -142,41 +136,4 @@ export class DocUIController extends Disposable {
})
);
}
-
- private _initDataLoader() {
- const dataModel = this._univerInstanceService.getCurrentUnitForType<DocumentDataModel>(UniverInstanceType.UNIVER_DOC);
- if (!dataModel) {
- return false;
- }
-
- const unitId = dataModel.getUnitId();
- const subUnitId = unitId;
-
- const drawingDataModels = dataModel.getDrawings();
- const drawingOrderModel = dataModel.getDrawingsOrder();
-
- if (!drawingDataModels || !drawingOrderModel) {
- return false;
- }
-
- Object.keys(drawingDataModels).forEach((drawingId) => {
- const drawingDataModel = drawingDataModels[drawingId];
- const docTransform = drawingDataModel.docTransform;
- const transform = docDrawingPositionToTransform(docTransform, this._textSelectionRenderManager);
-
- drawingDataModels[drawingId] = { ...drawingDataModel, transform } as IDocDrawing;
- });
-
- const subDrawings = {
- [subUnitId]: {
- unitId,
- subUnitId,
- data: drawingDataModels as IDrawingMapItemData<IDocDrawing>,
- order: drawingOrderModel,
- },
- };
-
- this._docDrawingService.registerDrawingData(unitId, subDrawings);
- this._drawingManagerService.registerDrawingData(unitId, subDrawings);
- }
}
diff --git a/packages/docs/package.json b/packages/docs/package.json
index 8c795c4a48..3474c745de 100644
--- a/packages/docs/package.json
+++ b/packages/docs/package.json
@@ -64,14 +64,12 @@
},
"peerDependencies": {
"@univerjs/core": "workspace:*",
- "@univerjs/drawing": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@wendellhu/redi": "0.15.2",
"rxjs": ">=7.0.0"
},
"devDependencies": {
"@univerjs/core": "workspace:*",
- "@univerjs/drawing": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@univerjs/shared": "workspace:*",
"@wendellhu/redi": "0.15.2",
diff --git a/packages/docs/src/doc-plugin.ts b/packages/docs/src/doc-plugin.ts
index 2129972b8a..63007198f3 100644
--- a/packages/docs/src/doc-plugin.ts
+++ b/packages/docs/src/doc-plugin.ts
@@ -58,9 +58,6 @@ import { IMEInputManagerService } from './services/ime-input-manager.service';
import { TextSelectionManagerService } from './services/text-selection-manager.service';
import { DocStateChangeManagerService } from './services/doc-state-change-manager.service';
import { AlignCenterCommand, AlignJustifyCommand, AlignLeftCommand, AlignOperationCommand, AlignRightCommand } from './commands/commands/paragraph-align.command';
-import { SetDocDrawingApplyMutation } from './commands/mutations/set-drawing-apply.mutation';
-import { DocDrawingService, IDocDrawingService } from './services/doc-drawing.service';
-import { DocDrawingDataController } from './controllers/doc-drawing-data.controller';
export interface IUniverDocsConfig {
hasScroll?: boolean;
@@ -123,7 +120,6 @@ export class UniverDocsPlugin extends Plugin {
AlignRightCommand,
AlignOperationCommand,
AlignJustifyCommand,
- SetDocDrawingApplyMutation,
] as ICommand[]
).forEach((command) => {
this._injector.get(ICommandService).registerCommand(command);
@@ -145,13 +141,11 @@ export class UniverDocsPlugin extends Plugin {
},
],
[TextSelectionManagerService],
- [IDocDrawingService, { useClass: DocDrawingService }],
// controllers
[NormalInputController],
[IMEInputController],
[MoveCursorController],
- [DocDrawingDataController],
] as Dependency[]
).forEach((d) => docInjector.add(d));
}
diff --git a/packages/docs/src/index.ts b/packages/docs/src/index.ts
index fa25116ab2..8901e66dcc 100644
--- a/packages/docs/src/index.ts
+++ b/packages/docs/src/index.ts
@@ -14,13 +14,6 @@
* limitations under the License.
*/
-export {
- IDocDrawingService,
- DocDrawingService,
- type IDocUpdateDrawing,
- type IDocDrawing,
-} from './services/doc-drawing.service';
-
export type { IDocObjectParam } from './basics/component-tools';
export { getDocObject, getDocObjectById } from './basics/component-tools';
export * from './basics/docs-view-key';
@@ -72,4 +65,3 @@ export { SelectAllOperation } from './commands/operations/select-all.operation';
export { CutContentCommand, InnerPasteCommand } from './commands/commands/clipboard.inner.command';
export { SetDocZoomRatioOperation, type ISetDocZoomRatioOperationParams } from './commands/operations/set-doc-zoom-ratio.operation';
export { SetDocZoomRatioCommand } from './commands/commands/set-doc-zoom-ratio.command';
-export { SetDocDrawingApplyMutation, DocDrawingApplyType } from './commands/mutations/set-drawing-apply.mutation';
diff --git a/packages/sheets-drawing-ui/package.json b/packages/sheets-drawing-ui/package.json
index bcc73ab507..4b190671f1 100644
--- a/packages/sheets-drawing-ui/package.json
+++ b/packages/sheets-drawing-ui/package.json
@@ -72,6 +72,7 @@
"@univerjs/drawing-ui": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@univerjs/sheets": "workspace:*",
+ "@univerjs/sheets-drawing": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
"@wendellhu/redi": "0.15.2",
@@ -90,6 +91,7 @@
"@univerjs/engine-render": "workspace:*",
"@univerjs/shared": "workspace:*",
"@univerjs/sheets": "workspace:*",
+ "@univerjs/sheets-drawing": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
"@wendellhu/redi": "0.15.2",
diff --git a/packages/sheets-drawing-ui/src/basics/transform-position.ts b/packages/sheets-drawing-ui/src/basics/transform-position.ts
index a7de44ea9c..8204e13e88 100644
--- a/packages/sheets-drawing-ui/src/basics/transform-position.ts
+++ b/packages/sheets-drawing-ui/src/basics/transform-position.ts
@@ -16,7 +16,7 @@
import type { ITransformState, Nullable } from '@univerjs/core';
import { precisionTo } from '@univerjs/engine-render';
-import type { ISheetDrawingPosition } from '@univerjs/sheets';
+import type { ISheetDrawingPosition } from '@univerjs/sheets-drawing';
import type { ISelectionRenderService } from '@univerjs/sheets-ui';
export function drawingPositionToTransform(position: ISheetDrawingPosition, selectionRenderService: ISelectionRenderService): Nullable<ITransformState> {
diff --git a/packages/sheets-drawing-ui/src/commands/commands/delete-drawings.command.ts b/packages/sheets-drawing-ui/src/commands/commands/delete-drawings.command.ts
index 44785d2051..87cea14c81 100644
--- a/packages/sheets-drawing-ui/src/commands/commands/delete-drawings.command.ts
+++ b/packages/sheets-drawing-ui/src/commands/commands/delete-drawings.command.ts
@@ -15,8 +15,8 @@
*/
import { CommandType, type ICommand, ICommandService } from '@univerjs/core';
-import type { ISheetDrawing } from '@univerjs/sheets';
-import { ISheetDrawingService } from '@univerjs/sheets';
+import type { ISheetDrawing } from '@univerjs/sheets-drawing';
+import { ISheetDrawingService } from '@univerjs/sheets-drawing';
import type { IAccessor } from '@wendellhu/redi';
import { RemoveSheetDrawingCommand } from './remove-sheet-drawing.command';
import type { IDeleteDrawingCommandParams } from './interfaces';
diff --git a/packages/sheets-drawing-ui/src/commands/commands/group-sheet-drawing.command.ts b/packages/sheets-drawing-ui/src/commands/commands/group-sheet-drawing.command.ts
index 74dffc79f7..f0660fedb0 100644
--- a/packages/sheets-drawing-ui/src/commands/commands/group-sheet-drawing.command.ts
+++ b/packages/sheets-drawing-ui/src/commands/commands/group-sheet-drawing.command.ts
@@ -21,7 +21,7 @@ import {
IUndoRedoService,
} from '@univerjs/core';
-import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation } from '@univerjs/sheets';
+import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation } from '@univerjs/sheets-drawing';
import type { IAccessor } from '@wendellhu/redi';
import type { IDrawingJsonUndo1 } from '@univerjs/drawing';
import { ClearSheetDrawingTransformerOperation } from '../operations/clear-drawing-transformer.operation';
diff --git a/packages/sheets-drawing-ui/src/commands/commands/insert-sheet-drawing.command.ts b/packages/sheets-drawing-ui/src/commands/commands/insert-sheet-drawing.command.ts
index 75f0fe4f65..eecce8aa2d 100644
--- a/packages/sheets-drawing-ui/src/commands/commands/insert-sheet-drawing.command.ts
+++ b/packages/sheets-drawing-ui/src/commands/commands/insert-sheet-drawing.command.ts
@@ -21,7 +21,7 @@ import {
IUndoRedoService,
} from '@univerjs/core';
-import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation } from '@univerjs/sheets';
+import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation } from '@univerjs/sheets-drawing';
import type { IAccessor } from '@wendellhu/redi';
import type { IDrawingJsonUndo1 } from '@univerjs/drawing';
import { ClearSheetDrawingTransformerOperation } from '../operations/clear-drawing-transformer.operation';
diff --git a/packages/sheets-drawing-ui/src/commands/commands/interfaces.ts b/packages/sheets-drawing-ui/src/commands/commands/interfaces.ts
index 750e00c284..371cd78328 100644
--- a/packages/sheets-drawing-ui/src/commands/commands/interfaces.ts
+++ b/packages/sheets-drawing-ui/src/commands/commands/interfaces.ts
@@ -15,7 +15,7 @@
*/
import type { DrawingTypeEnum } from '@univerjs/core';
-import type { ISheetDrawing } from '@univerjs/sheets';
+import type { ISheetDrawing } from '@univerjs/sheets-drawing';
export interface IInsertDrawingCommandParams {
unitId: string;
diff --git a/packages/sheets-drawing-ui/src/commands/commands/move-drawings.command.ts b/packages/sheets-drawing-ui/src/commands/commands/move-drawings.command.ts
index 3c41109647..42cd251fef 100644
--- a/packages/sheets-drawing-ui/src/commands/commands/move-drawings.command.ts
+++ b/packages/sheets-drawing-ui/src/commands/commands/move-drawings.command.ts
@@ -16,8 +16,8 @@
import type { ICommand } from '@univerjs/core';
import { CommandType, Direction, ICommandService } from '@univerjs/core';
-import type { ISheetDrawing } from '@univerjs/sheets';
-import { ISheetDrawingService } from '@univerjs/sheets';
+import type { ISheetDrawing } from '@univerjs/sheets-drawing';
+import { ISheetDrawingService } from '@univerjs/sheets-drawing';
import type { IAccessor } from '@wendellhu/redi';
import { ISelectionRenderService } from '@univerjs/sheets-ui';
diff --git a/packages/sheets-drawing-ui/src/commands/commands/remove-sheet-drawing.command.ts b/packages/sheets-drawing-ui/src/commands/commands/remove-sheet-drawing.command.ts
index a06dc9d268..57d0bd84e1 100644
--- a/packages/sheets-drawing-ui/src/commands/commands/remove-sheet-drawing.command.ts
+++ b/packages/sheets-drawing-ui/src/commands/commands/remove-sheet-drawing.command.ts
@@ -20,7 +20,7 @@ import {
ICommandService,
IUndoRedoService,
} from '@univerjs/core';
-import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation } from '@univerjs/sheets';
+import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation } from '@univerjs/sheets-drawing';
import type { IAccessor } from '@wendellhu/redi';
import type { IDrawingJsonUndo1 } from '@univerjs/drawing';
import { ClearSheetDrawingTransformerOperation } from '../operations/clear-drawing-transformer.operation';
diff --git a/packages/sheets-drawing-ui/src/commands/commands/set-drawing-arrange.command.ts b/packages/sheets-drawing-ui/src/commands/commands/set-drawing-arrange.command.ts
index 3993866a4c..89cd48b941 100644
--- a/packages/sheets-drawing-ui/src/commands/commands/set-drawing-arrange.command.ts
+++ b/packages/sheets-drawing-ui/src/commands/commands/set-drawing-arrange.command.ts
@@ -21,7 +21,7 @@ import { ArrangeTypeEnum,
IUndoRedoService,
} from '@univerjs/core';
import type { IDrawingJsonUndo1 } from '@univerjs/drawing';
-import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation } from '@univerjs/sheets';
+import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation } from '@univerjs/sheets-drawing';
import type { IAccessor } from '@wendellhu/redi';
export interface ISetDrawingArrangeCommandParams extends IDrawingOrderMapParam {
diff --git a/packages/sheets-drawing-ui/src/commands/commands/set-sheet-drawing.command.ts b/packages/sheets-drawing-ui/src/commands/commands/set-sheet-drawing.command.ts
index 931238911e..b2bc5444a4 100644
--- a/packages/sheets-drawing-ui/src/commands/commands/set-sheet-drawing.command.ts
+++ b/packages/sheets-drawing-ui/src/commands/commands/set-sheet-drawing.command.ts
@@ -21,8 +21,8 @@ import {
IUndoRedoService,
} from '@univerjs/core';
-import type { ISheetDrawing } from '@univerjs/sheets';
-import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation } from '@univerjs/sheets';
+import type { ISheetDrawing } from '@univerjs/sheets-drawing';
+import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation } from '@univerjs/sheets-drawing';
import type { IAccessor } from '@wendellhu/redi';
import type { IDrawingJsonUndo1 } from '@univerjs/drawing';
import { ClearSheetDrawingTransformerOperation } from '../operations/clear-drawing-transformer.operation';
diff --git a/packages/sheets-drawing-ui/src/commands/commands/ungroup-sheet-drawing.command.ts b/packages/sheets-drawing-ui/src/commands/commands/ungroup-sheet-drawing.command.ts
index 3c7edfbff7..bda5b09973 100644
--- a/packages/sheets-drawing-ui/src/commands/commands/ungroup-sheet-drawing.command.ts
+++ b/packages/sheets-drawing-ui/src/commands/commands/ungroup-sheet-drawing.command.ts
@@ -21,7 +21,7 @@ import {
IUndoRedoService,
} from '@univerjs/core';
-import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation } from '@univerjs/sheets';
+import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation } from '@univerjs/sheets-drawing';
import type { IAccessor } from '@wendellhu/redi';
import type { IDrawingJsonUndo1 } from '@univerjs/drawing';
import { ClearSheetDrawingTransformerOperation } from '../operations/clear-drawing-transformer.operation';
diff --git a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-transform-affected.controller.ts b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-transform-affected.controller.ts
index 362ad2ff96..0eb5f60592 100644
--- a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-transform-affected.controller.ts
+++ b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-transform-affected.controller.ts
@@ -17,12 +17,14 @@
import type { ICommandInfo, IDrawingParam, IMutationInfo, IRange, ITransformState, Nullable } from '@univerjs/core';
import { Disposable, ICommandService, IDrawingManagerService, IUniverInstanceService, LifecycleStages, OnLifecycle, Rectangle } from '@univerjs/core';
import { Inject } from '@wendellhu/redi';
-import type { IInsertColCommandParams, IInsertRowCommandParams, IRemoveRowColCommandParams, ISetColHiddenMutationParams, ISetColVisibleMutationParams, ISetRowHiddenMutationParams, ISetRowVisibleMutationParams, ISetSpecificColsVisibleCommandParams, ISetSpecificRowsVisibleCommandParams, ISetWorksheetActiveOperationParams, ISetWorksheetColWidthMutationParams, ISetWorksheetRowHeightMutationParams, ISetWorksheetRowIsAutoHeightMutationParams, ISheetDrawing, ISheetDrawingPosition } from '@univerjs/sheets';
-import { DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeltaColumnWidthCommand, DeltaRowHeightCommand, DrawingApplyType, getSheetCommandTarget, InsertColCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowCommand, ISheetDrawingService, RemoveColCommand, RemoveRowCommand, SetColHiddenCommand, SetColHiddenMutation, SetColVisibleMutation, SetColWidthCommand, SetDrawingApplyMutation, SetRowHeightCommand, SetRowHiddenCommand, SetRowHiddenMutation, SetRowVisibleMutation, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetWorksheetActiveOperation, SetWorksheetColWidthMutation, SetWorksheetRowHeightMutation, SheetDrawingAnchorType, SheetInterceptorService } from '@univerjs/sheets';
import { ISelectionRenderService } from '@univerjs/sheets-ui';
import type { IDrawingJsonUndo1 } from '@univerjs/drawing';
-import { ClearSheetDrawingTransformerOperation } from '../commands/operations/clear-drawing-transformer.operation';
+import type { IInsertColCommandParams, IInsertRowCommandParams, IRemoveRowColCommandParams, ISetColHiddenMutationParams, ISetColVisibleMutationParams, ISetRowHiddenMutationParams, ISetRowVisibleMutationParams, ISetSpecificColsVisibleCommandParams, ISetSpecificRowsVisibleCommandParams, ISetWorksheetActiveOperationParams, ISetWorksheetColWidthMutationParams, ISetWorksheetRowHeightMutationParams, ISetWorksheetRowIsAutoHeightMutationParams } from '@univerjs/sheets';
+import { DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeltaColumnWidthCommand, DeltaRowHeightCommand, getSheetCommandTarget, InsertColCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowCommand, RemoveColCommand, RemoveRowCommand, SetColHiddenCommand, SetColHiddenMutation, SetColVisibleMutation, SetColWidthCommand, SetRowHeightCommand, SetRowHiddenCommand, SetRowHiddenMutation, SetRowVisibleMutation, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetWorksheetActiveOperation, SetWorksheetColWidthMutation, SetWorksheetRowHeightMutation, SheetInterceptorService } from '@univerjs/sheets';
+import type { ISheetDrawing, ISheetDrawingPosition } from '@univerjs/sheets-drawing';
+import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation, SheetDrawingAnchorType } from '@univerjs/sheets-drawing';
import { drawingPositionToTransform, transformToDrawingPosition } from '../basics/transform-position';
+import { ClearSheetDrawingTransformerOperation } from '../commands/operations/clear-drawing-transformer.operation';
enum RangeMoveUndoType {
deleteLeft,
diff --git a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-update.controller.ts b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-update.controller.ts
index a36b609817..b3ca1149ce 100644
--- a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-update.controller.ts
+++ b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-update.controller.ts
@@ -19,8 +19,9 @@ import { Disposable, DrawingTypeEnum, FOCUSING_COMMON_DRAWINGS, ICommandService,
import { Inject } from '@wendellhu/redi';
import type { IImageData } from '@univerjs/drawing';
import { DRAWING_IMAGE_ALLOW_SIZE, DRAWING_IMAGE_COUNT_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_WIDTH_LIMIT, getImageSize } from '@univerjs/drawing';
-import type { ISheetDrawing, ISheetDrawingPosition } from '@univerjs/sheets';
-import { ISheetDrawingService, SelectionManagerService } from '@univerjs/sheets';
+import type { ISheetDrawing, ISheetDrawingPosition } from '@univerjs/sheets-drawing';
+import { ISheetDrawingService } from '@univerjs/sheets-drawing';
+import { SelectionManagerService } from '@univerjs/sheets';
import { ISelectionRenderService } from '@univerjs/sheets-ui';
import { IMessageService } from '@univerjs/ui';
import { MessageType } from '@univerjs/design';
diff --git a/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts b/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts
index 5780c8c110..80cac36d84 100644
--- a/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts
+++ b/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts
@@ -18,8 +18,6 @@ import type { IPosition, ITransformState, Nullable, Worksheet } from '@univerjs/
import { Disposable, DisposableCollection, DrawingTypeEnum, ICommandService, IDrawingManagerService, IUniverInstanceService, Tools } from '@univerjs/core';
import type { BaseObject, IBoundRectNoAngle, IRectProps, IRender, Scene, SpreadsheetSkeleton } from '@univerjs/engine-render';
import { DRAWING_OBJECT_LAYER_INDEX, IRenderManagerService, Rect } from '@univerjs/engine-render';
-import type { IFloatDomData, ISetFrozenMutationParams, ISheetDrawingPosition, ISheetFloatDom } from '@univerjs/sheets';
-import { DrawingApplyType, getSheetCommandTarget, ISheetDrawingService, SetDrawingApplyMutation, SetFrozenMutation } from '@univerjs/sheets';
import type { IFloatDomLayout } from '@univerjs/ui';
import { CanvasFloatDomService } from '@univerjs/ui';
import type { IDisposable } from '@wendellhu/redi';
@@ -28,8 +26,12 @@ import { BehaviorSubject, Subject } from 'rxjs';
import type { IDrawingJsonUndo1 } from '@univerjs/drawing';
import { getDrawingShapeKeyByDrawingSearch } from '@univerjs/drawing';
import { ISelectionRenderService, SetScrollOperation, SetZoomRatioOperation, SheetSkeletonManagerService, VIEWPORT_KEY } from '@univerjs/sheets-ui';
-import { InsertSheetDrawingCommand } from '../commands/commands/insert-sheet-drawing.command';
+import type { ISetFrozenMutationParams } from '@univerjs/sheets';
+import { getSheetCommandTarget, SetFrozenMutation } from '@univerjs/sheets';
+import type { IFloatDomData, ISheetDrawingPosition, ISheetFloatDom } from '@univerjs/sheets-drawing';
+import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation } from '@univerjs/sheets-drawing';
import type { IInsertDrawingCommandParams } from '../commands/commands/interfaces';
+import { InsertSheetDrawingCommand } from '../commands/commands/insert-sheet-drawing.command';
export interface ICanvasFloatDom {
allowTransform: boolean;
diff --git a/packages/sheets-drawing-ui/src/views/sheet-image-panel/SheetDrawingAnchor.tsx b/packages/sheets-drawing-ui/src/views/sheet-image-panel/SheetDrawingAnchor.tsx
index d0e16eebea..922a62f82d 100644
--- a/packages/sheets-drawing-ui/src/views/sheet-image-panel/SheetDrawingAnchor.tsx
+++ b/packages/sheets-drawing-ui/src/views/sheet-image-panel/SheetDrawingAnchor.tsx
@@ -21,8 +21,8 @@ import React, { useEffect, useState } from 'react';
import { Radio, RadioGroup } from '@univerjs/design';
import clsx from 'clsx';
import styles from '@univerjs/drawing-ui/views/panel/index.module.less';
-import type { ISheetDrawing } from '@univerjs/sheets';
-import { SheetDrawingAnchorType } from '@univerjs/sheets';
+import type { ISheetDrawing } from '@univerjs/sheets-drawing';
+import { SheetDrawingAnchorType } from '@univerjs/sheets-drawing';
import type { BaseObject } from '@univerjs/engine-render';
import { IRenderManagerService } from '@univerjs/engine-render';
import { SetSheetDrawingCommand } from '../../commands/commands/set-sheet-drawing.command';
diff --git a/packages/sheets-drawing/README.md b/packages/sheets-drawing/README.md
new file mode 100644
index 0000000000..228e2c54f4
--- /dev/null
+++ b/packages/sheets-drawing/README.md
@@ -0,0 +1,16 @@
+# @univerjs/sheets-drawing
+
+[![npm version](https://img.shields.io/npm/v/@univerjs/sheets-drawing)](https://npmjs.org/packages/@univerjs/sheets-drawing)
+[![license](https://img.shields.io/npm/l/@univerjs/sheets-drawing)](https://img.shields.io/npm/l/@univerjs/sheets-drawing)
+
+## Introduction
+
+> This plugin adds drawing features to Univer.
+
+## Usage
+
+### Installation
+
+```shell
+npm i @univerjs/sheets-drawing
+```
diff --git a/packages/sheets-drawing/package.json b/packages/sheets-drawing/package.json
new file mode 100644
index 0000000000..8171da9ad9
--- /dev/null
+++ b/packages/sheets-drawing/package.json
@@ -0,0 +1,79 @@
+{
+ "name": "@univerjs/sheets-drawing",
+ "version": "0.0.1",
+ "private": true,
+ "description": "",
+ "author": "DreamNum <[email protected]>",
+ "license": "Apache-2.0",
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/univer"
+ },
+ "homepage": "https://univer.ai",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/dream-num/univer"
+ },
+ "bugs": {
+ "url": "https://github.com/dream-num/univer/issues"
+ },
+ "keywords": [],
+ "exports": {
+ ".": "./src/index.ts",
+ "./*": "./src/*"
+ },
+ "main": "./lib/cjs/index.js",
+ "module": "./lib/es/index.js",
+ "types": "./lib/types/index.d.ts",
+ "publishConfig": {
+ "access": "public",
+ "main": "./lib/cjs/index.js",
+ "module": "./lib/es/index.js",
+ "exports": {
+ ".": {
+ "import": "./lib/es/index.js",
+ "require": "./lib/cjs/index.js",
+ "types": "./lib/types/index.d.ts"
+ },
+ "./*": {
+ "import": "./lib/es/*",
+ "require": "./lib/cjs/*",
+ "types": "./lib/types/index.d.ts"
+ },
+ "./lib/*": "./lib/*"
+ }
+ },
+ "directories": {
+ "lib": "lib"
+ },
+ "files": [
+ "lib"
+ ],
+ "scripts": {
+ "test": "vitest run",
+ "test:watch": "vitest",
+ "coverage": "vitest run --coverage",
+ "lint:types": "tsc --noEmit",
+ "build": "tsc && vite build"
+ },
+ "peerDependencies": {
+ "@univerjs/core": "workspace:*",
+ "@univerjs/drawing": "workspace:*",
+ "@univerjs/sheets": "workspace:*",
+ "@wendellhu/redi": ">=0.12.13",
+ "rxjs": ">=7.0.0"
+ },
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@univerjs/core": "workspace:*",
+ "@univerjs/drawing": "workspace:*",
+ "@univerjs/shared": "workspace:*",
+ "@univerjs/sheets": "workspace:*",
+ "@wendellhu/redi": "^0.15.2",
+ "rxjs": "^7.8.1",
+ "typescript": "^5.4.5",
+ "vite": "^5.2.11",
+ "vitest": "^1.6.0"
+ }
+}
diff --git a/packages/sheets/src/commands/mutations/set-drawing-apply.mutation.ts b/packages/sheets-drawing/src/commands/mutations/set-drawing-apply.mutation.ts
similarity index 98%
rename from packages/sheets/src/commands/mutations/set-drawing-apply.mutation.ts
rename to packages/sheets-drawing/src/commands/mutations/set-drawing-apply.mutation.ts
index 41fa690703..c82f735ed0 100644
--- a/packages/sheets/src/commands/mutations/set-drawing-apply.mutation.ts
+++ b/packages/sheets-drawing/src/commands/mutations/set-drawing-apply.mutation.ts
@@ -33,7 +33,7 @@ export interface ISetDrawingApplyMutationParams extends IDrawingJson1Type {
}
export const SetDrawingApplyMutation: IMutation<ISetDrawingApplyMutationParams> = {
- id: 'sheet.mutation.set-drawing-json-apply',
+ id: 'sheet.mutation.set-drawing-apply',
type: CommandType.MUTATION,
handler: (accessor, params) => {
const drawingManagerService = accessor.get(IDrawingManagerService);
diff --git a/packages/sheets/src/controllers/sheet-drawing-data.controller.ts b/packages/sheets-drawing/src/controllers/sheet-drawing.controller.ts
similarity index 74%
rename from packages/sheets/src/controllers/sheet-drawing-data.controller.ts
rename to packages/sheets-drawing/src/controllers/sheet-drawing.controller.ts
index 0454409397..1e7a34910b 100644
--- a/packages/sheets/src/controllers/sheet-drawing-data.controller.ts
+++ b/packages/sheets-drawing/src/controllers/sheet-drawing.controller.ts
@@ -15,12 +15,26 @@
*/
import type { IDrawingSubunitMap } from '@univerjs/core';
-import { Disposable, IDrawingManagerService, IResourceManagerService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
-import { type ISheetDrawing, ISheetDrawingService } from '../services/sheet-drawing.service';
+import { Disposable, ICommandService, IDrawingManagerService, IResourceManagerService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
+import type { ISheetDrawing } from '../services/sheet-drawing.service';
+import { ISheetDrawingService } from '../services/sheet-drawing.service';
+import { SetDrawingApplyMutation } from '../commands/mutations/set-drawing-apply.mutation';
export const SHEET_DRAWING_PLUGIN = 'SHEET_DRAWING_PLUGIN';
-@OnLifecycle(LifecycleStages.Ready, SheetDrawingDataController)
-export class SheetDrawingDataController extends Disposable {
+
+@OnLifecycle(LifecycleStages.Starting, SheetsDrawingLoadController)
+export class SheetsDrawingLoadController extends Disposable {
+ constructor(
+ @ICommandService private readonly _commandService: ICommandService
+ ) {
+ super();
+
+ this.disposeWithMe(this._commandService.registerCommand(SetDrawingApplyMutation));
+ }
+}
+
+@OnLifecycle(LifecycleStages.Ready, SheetsDrawingController)
+export class SheetsDrawingController extends Disposable {
constructor(
@ISheetDrawingService private readonly _sheetDrawingService: ISheetDrawingService,
@IDrawingManagerService private readonly _drawingManagerService: IDrawingManagerService,
diff --git a/packages/sheets-drawing/src/index.ts b/packages/sheets-drawing/src/index.ts
new file mode 100644
index 0000000000..08f6db2b67
--- /dev/null
+++ b/packages/sheets-drawing/src/index.ts
@@ -0,0 +1,21 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export { UniverSheetsDrawingPlugin } from './plugin';
+export { DrawingApplyType, SetDrawingApplyMutation } from './commands/mutations/set-drawing-apply.mutation';
+export { ISheetDrawingService, SheetDrawingAnchorType } from './services/sheet-drawing.service';
+export type { IFloatDomData, ISheetDrawing, ISheetDrawingPosition, ISheetFloatDom } from './services/sheet-drawing.service';
+
diff --git a/packages/sheets-drawing/src/plugin.ts b/packages/sheets-drawing/src/plugin.ts
new file mode 100644
index 0000000000..5b2e755931
--- /dev/null
+++ b/packages/sheets-drawing/src/plugin.ts
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Plugin, UniverInstanceType } from '@univerjs/core';
+import type { Dependency } from '@wendellhu/redi';
+import { Inject, Injector } from '@wendellhu/redi';
+import { SHEET_DRAWING_PLUGIN, SheetsDrawingController, SheetsDrawingLoadController } from './controllers/sheet-drawing.controller';
+import { ISheetDrawingService, SheetDrawingService } from './services/sheet-drawing.service';
+
+export class UniverSheetsDrawingPlugin extends Plugin {
+ static override pluginName = SHEET_DRAWING_PLUGIN;
+ static override type = UniverInstanceType.UNIVER_SHEET;
+
+ constructor(
+ @Inject(Injector) override readonly _injector: Injector
+ ) {
+ super();
+ }
+
+ override onStarting(_injector: Injector): void {
+ ([
+ [SheetsDrawingLoadController],
+ [SheetsDrawingController],
+ [ISheetDrawingService, { useClass: SheetDrawingService }],
+ ] as Dependency[]).forEach((dependency) => _injector.add(dependency));
+ }
+}
diff --git a/packages/sheets/src/services/sheet-drawing.service.ts b/packages/sheets-drawing/src/services/sheet-drawing.service.ts
similarity index 94%
rename from packages/sheets/src/services/sheet-drawing.service.ts
rename to packages/sheets-drawing/src/services/sheet-drawing.service.ts
index 65bbcf2ccd..69814c217d 100644
--- a/packages/sheets/src/services/sheet-drawing.service.ts
+++ b/packages/sheets-drawing/src/services/sheet-drawing.service.ts
@@ -56,6 +56,7 @@ export interface IFloatDomData extends IDrawingParam {
componentKey: string;
}
+// TODO@wzhudev: this shouldn't be here. It should be in the sheets package
export interface ISheetFloatDom extends IFloatDomData, ISheetDrawingBase {}
export type ISheetDrawing = ISheetImage | ISheetShape | ISheetFloatDom;
@@ -67,4 +68,4 @@ export class SheetDrawingService extends UnitDrawingService<ISheetDrawing> {}
export interface ISheetDrawingService extends IUnitDrawingService<ISheetDrawing> {}
-export const ISheetDrawingService = createIdentifier<ISheetDrawingService>('univer.sheet.plugin.sheet-drawing.service');
+export const ISheetDrawingService = createIdentifier<ISheetDrawingService>('sheets-drawing.sheet-drawing.service');
diff --git a/packages/sheets-drawing/src/vite-env.d.ts b/packages/sheets-drawing/src/vite-env.d.ts
new file mode 100644
index 0000000000..11f02fe2a0
--- /dev/null
+++ b/packages/sheets-drawing/src/vite-env.d.ts
@@ -0,0 +1 @@
+/// <reference types="vite/client" />
diff --git a/packages/sheets-drawing/tsconfig.json b/packages/sheets-drawing/tsconfig.json
new file mode 100644
index 0000000000..d676ad2a20
--- /dev/null
+++ b/packages/sheets-drawing/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "@univerjs/shared/tsconfigs/base",
+ "compilerOptions": {
+ "rootDir": "src",
+ "outDir": "lib/types"
+ },
+ "references": [{ "path": "./tsconfig.node.json" }],
+ "include": ["src"]
+}
diff --git a/packages/sheets-drawing/tsconfig.node.json b/packages/sheets-drawing/tsconfig.node.json
new file mode 100644
index 0000000000..e53dac8868
--- /dev/null
+++ b/packages/sheets-drawing/tsconfig.node.json
@@ -0,0 +1,4 @@
+{
+ "extends": "@univerjs/shared/tsconfigs/node",
+ "include": ["vite.config.ts"]
+}
diff --git a/packages/sheets-drawing/vite.config.ts b/packages/sheets-drawing/vite.config.ts
new file mode 100644
index 0000000000..67b2fff8f2
--- /dev/null
+++ b/packages/sheets-drawing/vite.config.ts
@@ -0,0 +1,7 @@
+import createViteConfig from '@univerjs/shared/vite';
+import pkg from './package.json';
+
+export default ({ mode }) => createViteConfig({}, {
+ mode,
+ pkg,
+});
diff --git a/packages/sheets/package.json b/packages/sheets/package.json
index 892b8d9e5e..fabafba089 100644
--- a/packages/sheets/package.json
+++ b/packages/sheets/package.json
@@ -66,7 +66,6 @@
},
"peerDependencies": {
"@univerjs/core": "workspace:*",
- "@univerjs/drawing": "workspace:*",
"@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@wendellhu/redi": "0.15.2",
@@ -77,7 +76,6 @@
},
"devDependencies": {
"@univerjs/core": "workspace:*",
- "@univerjs/drawing": "workspace:*",
"@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-numfmt": "workspace:*",
"@univerjs/engine-render": "workspace:*",
diff --git a/packages/sheets/src/controllers/basic-worksheet.controller.ts b/packages/sheets/src/controllers/basic-worksheet.controller.ts
index faa1b23000..8e56d73175 100644
--- a/packages/sheets/src/controllers/basic-worksheet.controller.ts
+++ b/packages/sheets/src/controllers/basic-worksheet.controller.ts
@@ -127,7 +127,6 @@ import { SetRangeProtectionCommand } from '../commands/commands/set-range-protec
import { AddRangeProtectionMutation } from '../commands/mutations/add-range-protection.mutation';
import { DeleteRangeProtectionMutation } from '../commands/mutations/delete-range-protection.mutation';
import { SetRangeProtectionMutation } from '../commands/mutations/set-range-protection.mutation';
-import { SetDrawingApplyMutation } from '../commands/mutations/set-drawing-apply.mutation';
import { AddWorksheetMergeMutation } from '../commands/mutations/add-worksheet-merge.mutation';
import { MAX_CELL_PER_SHEET_DEFAULT, MAX_CELL_PER_SHEET_KEY } from './config/config';
import { ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY } from './config';
@@ -262,7 +261,6 @@ export class BasicWorksheetController extends Disposable implements IDisposable
// TODO: more commands should be moved into this array
[
SetWorksheetShowCommand,
- SetDrawingApplyMutation,
].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
}
diff --git a/packages/sheets/src/index.ts b/packages/sheets/src/index.ts
index c83f6f595d..175efe1d7c 100644
--- a/packages/sheets/src/index.ts
+++ b/packages/sheets/src/index.ts
@@ -304,8 +304,6 @@ export { SetDefinedNameCommand, type ISetDefinedNameCommandParams } from './comm
export { ScrollToCellOperation } from './commands/operations/scroll-to-cell.operation';
export type { FormatType } from './services/numfmt/type';
export { getMoveRangeUndoRedoMutations } from './commands/commands/move-range.command';
-export { type ISheetDrawing, type ISheetUpdateDrawing, type ISheetDrawingPosition, ISheetDrawingService, SheetDrawingAnchorType, type ISheetDrawingBase, type IFloatDomData, type ISheetFloatDom } from './services/sheet-drawing.service';
-export { SetDrawingApplyMutation, type ISetDrawingApplyMutationParams, DrawingApplyType } from './commands/mutations/set-drawing-apply.mutation';
// permission
export { defaultWorksheetPermissionPoint, getAllWorksheetPermissionPoint, getAllWorksheetPermissionPointByPointPanel } from './services/permission';
diff --git a/packages/sheets/src/sheets-plugin.ts b/packages/sheets/src/sheets-plugin.ts
index 119ed7b165..e1d5582975 100644
--- a/packages/sheets/src/sheets-plugin.ts
+++ b/packages/sheets/src/sheets-plugin.ts
@@ -38,9 +38,7 @@ import { RangeProtectionRuleModel } from './model/range-protection-rule.model';
import { RangeProtectionRefRangeService } from './services/permission/range-permission/range-protection.ref-range';
import { RangeProtectionService } from './services/permission/range-permission/range-protection.service';
-import { ISheetDrawingService, SheetDrawingService } from './services/sheet-drawing.service';
import { ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY } from './controllers/config';
-import { SheetDrawingDataController } from './controllers/sheet-drawing-data.controller';
const PLUGIN_NAME = 'SHEET_PLUGIN';
@@ -112,15 +110,11 @@ export class UniverSheetsPlugin extends Plugin {
];
if (!this._config?.notExecuteFormula) {
+ // Should execute formula.
dependencies.push(
[CalculateResultApplyController],
[FeatureCalculationController]
);
- } else {
- dependencies.push(
- [ISheetDrawingService, { useClass: SheetDrawingService }],
- [SheetDrawingDataController]
- );
}
mergeOverrideWithDependencies(dependencies, this._config?.override).forEach((d) => {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2c6ef960d0..d89d1f610c 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -216,6 +216,9 @@ importers:
'@univerjs/docs':
specifier: workspace:*
version: link:../packages/docs
+ '@univerjs/docs-drawing':
+ specifier: workspace:*
+ version: link:../packages/docs-drawing
'@univerjs/docs-drawing-ui':
specifier: workspace:*
version: link:../packages/docs-drawing-ui
@@ -258,6 +261,9 @@ importers:
'@univerjs/sheets-data-validation':
specifier: workspace:*
version: link:../packages/sheets-data-validation
+ '@univerjs/sheets-drawing':
+ specifier: workspace:*
+ version: link:../packages/sheets-drawing
'@univerjs/sheets-drawing-ui':
specifier: workspace:*
version: link:../packages/sheets-drawing-ui
@@ -594,6 +600,39 @@ importers:
'@univerjs/core':
specifier: workspace:*
version: link:../core
+ '@univerjs/engine-render':
+ specifier: workspace:*
+ version: link:../engine-render
+ '@univerjs/shared':
+ specifier: workspace:*
+ version: link:../../common/shared
+ '@wendellhu/redi':
+ specifier: 0.15.2
+ version: 0.15.2
+ rxjs:
+ specifier: ^7.8.1
+ version: 7.8.1
+ typescript:
+ specifier: ^5.4.5
+ version: 5.4.5
+ vite:
+ specifier: ^5.2.12
+ vitest:
+ specifier: ^1.6.0
+
+ packages/docs-drawing:
+ devDependencies:
+ '@univerjs/core':
+ specifier: workspace:*
+ version: link:../core
+ '@univerjs/docs':
+ specifier: workspace:*
+ version: link:../docs
+ '@univerjs/docs-ui':
+ specifier: workspace:*
+ version: link:../docs-ui
'@univerjs/drawing':
specifier: workspace:*
version: link:../drawing
@@ -604,7 +643,7 @@ importers:
specifier: workspace:*
version: link:../../common/shared
'@wendellhu/redi':
- specifier: 0.15.2
+ specifier: ^0.15.2
version: 0.15.2
rxjs:
specifier: ^7.8.1
@@ -613,7 +652,7 @@ importers:
specifier: ^5.4.5
version: 5.4.5
vite:
- specifier: ^5.2.12
+ specifier: ^5.2.11
vitest:
specifier: ^1.6.0
@@ -634,6 +673,9 @@ importers:
'@univerjs/docs':
specifier: workspace:*
version: link:../docs
+ '@univerjs/docs-drawing':
+ specifier: workspace:*
+ version: link:../docs-drawing
'@univerjs/docs-ui':
specifier: workspace:*
version: link:../docs-ui
@@ -1070,9 +1112,6 @@ importers:
'@univerjs/core':
specifier: workspace:*
version: link:../core
- '@univerjs/drawing':
- specifier: workspace:*
- version: link:../drawing
'@univerjs/engine-formula':
specifier: workspace:*
version: link:../engine-formula
@@ -1299,6 +1338,36 @@ importers:
specifier: ^1.6.0
+ packages/sheets-drawing:
+ devDependencies:
+ '@univerjs/core':
+ specifier: workspace:*
+ version: link:../core
+ '@univerjs/drawing':
+ specifier: workspace:*
+ version: link:../drawing
+ '@univerjs/shared':
+ specifier: workspace:*
+ version: link:../../common/shared
+ '@univerjs/sheets':
+ specifier: workspace:*
+ version: link:../sheets
+ '@wendellhu/redi':
+ specifier: ^0.15.2
+ version: 0.15.2
+ rxjs:
+ specifier: ^7.8.1
+ version: 7.8.1
+ typescript:
+ specifier: ^5.4.5
+ version: 5.4.5
+ vite:
+ specifier: ^5.2.11
+ vitest:
+ specifier: ^1.6.0
+
packages/sheets-drawing-ui:
dependencies:
'@univerjs/icons':
@@ -1326,6 +1395,9 @@ importers:
'@univerjs/sheets':
specifier: workspace:*
version: link:../sheets
+ '@univerjs/sheets-drawing':
+ specifier: workspace:*
+ version: link:../sheets-drawing
'@univerjs/sheets-ui':
specifier: workspace:*
version: link:../sheets-ui
@@ -11127,7 +11199,7 @@ snapshots:
'@babel/helper-validator-identifier': 7.22.20
chalk: 2.4.2
js-tokens: 4.0.0
- picocolors: https://r2.cnpmjs.org/picocolors/-/picocolors-1.0.0.tgz
+ picocolors: 1.0.1
dependencies:
@@ -20146,7 +20218,7 @@ snapshots:
dependencies:
browserslist: 4.23.0
escalade: 3.1.2
- picocolors: https://r2.cnpmjs.org/picocolors/-/picocolors-1.0.0.tgz
+ picocolors: 1.0.1
dependencies: