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(plugin): remove command manager, register manager (#116)

Dushusir35c109d2bc38
diff --git a/examples/univer-sheet-ts/src/main.tsx b/examples/univer-sheet-ts/src/main.tsx
index 004b5b58e5..f5eb58d5bb 100644
--- a/examples/univer-sheet-ts/src/main.tsx
+++ b/examples/univer-sheet-ts/src/main.tsx
@@ -35,11 +35,11 @@ univer.registerPlugin(SheetUIPlugin, {
},
});
-// univer.registerPlugin(NumfmtPlugin);
-// univer.registerPlugin(FindPlugin);
-// univer.registerPlugin(FormulaPlugin, DEFAULT_FORMULA_DATA_DEMO);
-// univer.registerPlugin(ImportXlsxPlugin);
-// univer.registerPlugin(ImagePlugin);
+univer.registerPlugin(NumfmtPlugin);
+univer.registerPlugin(FindPlugin);
+univer.registerPlugin(FormulaPlugin, DEFAULT_FORMULA_DATA_DEMO);
+univer.registerPlugin(ImportXlsxPlugin);
+univer.registerPlugin(ImagePlugin);
// univer.registerPlugin(OperationPlugin);
// use for console test
diff --git a/packages/common-plugin-collaboration/.gitignore b/packages/common-plugin-collaboration/.gitignore
deleted file mode 100644
index 12e1bd6bec..0000000000
--- a/packages/common-plugin-collaboration/.gitignore
+++ /dev/null
@@ -1,101 +0,0 @@
-#ide
-*.DS_Store
-.idea
-.vscode
-
-#npm
-package-lock.json
-
-dist
-lib
-docs/.vuepress/dist
-
-# Logs
-logs
-*.log
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-lerna-debug.log*
-
-# Runtime config
-pids
-*.pid
-*.seed
-*.pid.lock
-
-# Directory for instrumented libs generated by jscoverage/JSCover
-lib-cov
-
-# Coverage directory used by tools like istanbul
-coverage
-
-# nyc test coverage
-.nyc_output
-
-# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
-.grunt
-
-# Bower dependency directory (https://bower.io/)
-bower_components
-
-# node-waf configuration
-.lock-wscript
-
-# Compiled binary addons (https://nodejs.org/api/addons.html)
-build/Release
-
-# Dependency directories
-node_modules
-jspm_packages/
-
-# TypeScript v1 declaration files
-typings/
-
-# Optional npm cache directory
-.npm
-
-# Optional eslint cache
-.eslintcache
-
-# Optional REPL History
-.node_repl_history
-
-# Output of 'npm pack'
-*.tgz
-
-# Yarn Integrity file
-.yarn-integrity
-
-# dotenv environment variables file
-.env
-
-# next.js build output
-.next
-
-#lerna-changelog
-.changelog
-
-
-#editor workspace file
-.idea/
-
-
-.DS_Store
-
-.history
-# examples
-
-
-# Production
-/build
-
-# Generated files
-.docusaurus
-.cache-loader
-
-# Misc
-.env.local
-.env.development.local
-.env.test.local
-.env.production.local
diff --git a/packages/common-plugin-collaboration/README-zh.md b/packages/common-plugin-collaboration/README-zh.md
deleted file mode 100644
index 84d12077ab..0000000000
--- a/packages/common-plugin-collaboration/README-zh.md
+++ /dev/null
@@ -1,55 +0,0 @@
-# style-univer
-
-简体中文 | [English](./README.md)
-
-## 介绍
-
-UniverSheet Collaboration 插件
-
-### 安装
-
-```shell
-npm i @univerjs/common-plugin-collaboration
-```
-
-### 使用
-
-```js
-import { Collaboration } from '@univerjs/common-plugin-collaboration';
-
-const univerSheet = new UniverSheet();
-univerSheet.installPlugin(new Collaboration());
-```
-
-## 本地开发
-
-### 环境
-
-- [Node.js](https://nodejs.org/en/) Version >= 10
-- [npm](https://www.npmjs.com/) Version >= 6
-
-### 安装
-
-```
-pnpm install
-```
-
-### 开发
-
-```
-# 当前目录 ./packages/common-plugin-collaboration/
-npm run dev
-
-# 或者项目根目录 ./
-pnpm run --filter @univerjs/common-plugin-collaboration dev
-```
-
-### 打包
-
-```
-# 当前目录 ./packages/common-plugin-collaboration/
-npm run build
-
-# 或者根目录 ./
-pnpm run --filter @univerjs/common-plugin-collaboration build
-```
diff --git a/packages/common-plugin-collaboration/README.md b/packages/common-plugin-collaboration/README.md
deleted file mode 100644
index b734d476a3..0000000000
--- a/packages/common-plugin-collaboration/README.md
+++ /dev/null
@@ -1,55 +0,0 @@
-# style-univer
-
-English| [简体中文](./README-zh.md)
-
-## Introduction
-
-UniverSheet Plugin Collaboration
-
-### Installation
-
-```shell
-npm i @univerjs/common-plugin-collaboration
-```
-
-### Usage
-
-```js
-import { Collaboration } from '@univerjs/common-plugin-collaboration';
-
-const univerSheet = new UniverSheet();
-univerSheet.installPlugin(new Collaboration());
-```
-
-## Local development
-
-### Requirements
-
-- [Node.js](https://nodejs.org/en/) Version >= 10
-- [npm](https://www.npmjs.com/) Version >= 6
-
-### Installation
-
-```
-pnpm install
-```
-
-### Development
-
-```
-# Current directory ./packages/common-plugin-collaboration/
-npm run dev
-
-# Or project root directory ./
-pnpm run --filter @univerjs/common-plugin-collaboration dev
-```
-
-### Package
-
-```
-# Current directory ./packages/common-plugin-collaboration/
-npm run build
-
-# Or root directory ./
-pnpm run --filter @univerjs/common-plugin-collaboration build
-```
diff --git a/packages/common-plugin-collaboration/jest.config.js b/packages/common-plugin-collaboration/jest.config.js
deleted file mode 100644
index a1ab72c760..0000000000
--- a/packages/common-plugin-collaboration/jest.config.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
-module.exports = {
- preset: 'ts-jest',
- testEnvironment: 'jsdom',
- moduleFileExtensions: ['js', 'ts', 'tsx'],
-
- roots: ['<rootDir>/src'],
- testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'],
- transform: {
- '^.+\\.(ts|tsx)$': 'ts-jest',
- '^.+\\.tsx?$': 'babel-jest', // https://github.com/kulshekhar/ts-jest/issues/937#issuecomment-455431207
- },
- globals: {
- 'ts-jest': {
- tsConfig: 'tsconfig.json',
- },
- },
-};
diff --git a/packages/common-plugin-collaboration/package.json b/packages/common-plugin-collaboration/package.json
deleted file mode 100644
index 7f4cb61023..0000000000
--- a/packages/common-plugin-collaboration/package.json
+++ /dev/null
@@ -1,64 +0,0 @@
-{
- "name": "@univerjs/common-plugin-collaboration",
- "version": "0.0.1",
- "description": "UniverSheet normal common-plugin-collaboration",
- "keywords": [],
- "author": "DreamNum <[email protected]>",
- "license": "MIT",
- "main": "./src/index.ts",
- "module": "./src/index.ts",
- "types": "./src/Types/index.d.ts",
- "publishConfig": {
- "main": "./lib/univer-common-plugin-collaboration.cjs.js",
- "module": "./lib/univer-common-plugin-collaboration.js",
- "types": "./lib/index.d.ts",
- "exports": {
- ".": {
- "require": "./lib/univer-common-plugin-collaboration.cjs.js",
- "default": "./lib/univer-common-plugin-collaboration.js"
- },
- "./*": "./lib/*"
- },
- "access": "public"
- },
- "exports": {
- ".": "./src/index.ts",
- "./*": "./src/*"
- },
- "directories": {
- "lib": "lib"
- },
- "files": [
- "lib"
- ],
- "private": true,
- "scripts": {
- "test": "jest",
- "dev": "vite",
- "build": "tsc && vite build",
- "watch": "vite build",
- "serve": "vite preview"
- },
- "devDependencies": {
- "@preact/preset-vite": "2.0.0",
- "@testing-library/preact": "^2.0.1",
- "@types/jest": "^27.0.1",
- "@types/node": "^18.14.0",
- "@vitejs/plugin-legacy": "^1.5.1",
- "less": "^4.1.1",
- "prettier": "^2.3.2",
- "ts-jest": "29.0.1",
- "ts-node": "^10.9.1",
- "typescript": "^4.4.1-rc",
- "vite": "^2.4.4"
- },
- "dependencies": {
- "@univerjs/base-docs": "workspace:^0.0.1",
- "@univerjs/base-render": "workspace:^0.0.1",
- "@univerjs/base-sheets": "workspace:^0.0.1",
- "@univerjs/base-slides": "workspace:^0.0.1",
- "@univerjs/base-ui": "workspace:^0.0.1",
- "@univerjs/core": "workspace:^0.0.1",
- "preact": "^10.12.1"
- }
-}
\ No newline at end of file
diff --git a/packages/common-plugin-collaboration/src/Basics/Const/PLUGIN_NAME.ts b/packages/common-plugin-collaboration/src/Basics/Const/PLUGIN_NAME.ts
deleted file mode 100644
index 39bd5b305a..0000000000
--- a/packages/common-plugin-collaboration/src/Basics/Const/PLUGIN_NAME.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const COLLABORATION_PLUGIN_NAME = 'collaboration';
diff --git a/packages/common-plugin-collaboration/src/Basics/Const/index.ts b/packages/common-plugin-collaboration/src/Basics/Const/index.ts
deleted file mode 100644
index 0dc96d927a..0000000000
--- a/packages/common-plugin-collaboration/src/Basics/Const/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './PLUGIN_NAME';
diff --git a/packages/common-plugin-collaboration/src/Basics/Enum/index.ts b/packages/common-plugin-collaboration/src/Basics/Enum/index.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/common-plugin-collaboration/src/Basics/Shared/index.ts b/packages/common-plugin-collaboration/src/Basics/Shared/index.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/common-plugin-collaboration/src/Basics/index.ts b/packages/common-plugin-collaboration/src/Basics/index.ts
deleted file mode 100644
index 343f4071a9..0000000000
--- a/packages/common-plugin-collaboration/src/Basics/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './Const';
-export * from '../Locale';
diff --git a/packages/common-plugin-collaboration/src/CollaborationPlugin.ts b/packages/common-plugin-collaboration/src/CollaborationPlugin.ts
deleted file mode 100644
index bd86348367..0000000000
--- a/packages/common-plugin-collaboration/src/CollaborationPlugin.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-import { Plugin, UniverSheet, UniverDoc, UniverSlide } from '@univerjs/core';
-import { zh, en } from './Locale';
-import { COLLABORATION_PLUGIN_NAME } from './Basics/Const/PLUGIN_NAME';
-import { CollaborationController } from './Controller/CollaborationController';
-
-export interface ICollaborationPluginConfig {
- url: string;
-}
-
-export class CollaborationPlugin extends Plugin {
- config: ICollaborationPluginConfig;
-
- private _collaborationController: CollaborationController;
-
- constructor(config?: ICollaborationPluginConfig) {
- super(COLLABORATION_PLUGIN_NAME);
- this.config = config || { url: '' };
- }
-
- static create(config?: ICollaborationPluginConfig) {
- return new CollaborationPlugin(config);
- }
-
- installTo(univerInstance: UniverSheet | UniverDoc | UniverSlide) {
- univerInstance.installPlugin(this);
- }
-
- initialize(): void {
- const context = this.getGlobalContext();
-
- /**
- * load more Locale object
- */
- context.getLocale().load({
- en,
- zh,
- });
-
- this._collaborationController = new CollaborationController(this);
- }
-
- onMounted(): void {
- this.initialize();
- }
-
- onDestroy(): void {}
-
- // TODO common function
- getConfig() {
- return this.config;
- }
-
- getCollaborationController() {
- return this._collaborationController;
- }
-}
diff --git a/packages/common-plugin-collaboration/src/Controller/CollaborationController.ts b/packages/common-plugin-collaboration/src/Controller/CollaborationController.ts
deleted file mode 100644
index 74508bfde1..0000000000
--- a/packages/common-plugin-collaboration/src/Controller/CollaborationController.ts
+++ /dev/null
@@ -1,439 +0,0 @@
-import { SheetPlugin, SetSelectionValueAction, ISetSelectionValueActionData } from '@univerjs/base-sheets';
-import {
- ActionOperation,
- ACTION_NAMES,
- Command,
- CommandManager,
- HEART_BEAT_MESSAGE,
- IKeyValue,
- IOSocket,
- IOSocketListenType,
- ISetRangeDataActionData,
- ISheetActionData,
- PLUGIN_NAMES,
- SheetActionBase,
- SheetContext,
- IActionData,
- IGridRange,
-} from '@univerjs/core';
-import { CollaborationPlugin } from '../CollaborationPlugin';
-
-interface Clients {
- clientName: string;
- clientID: string;
- selectionActionData: ISetSelectionValueActionData;
-}
-
-interface JsonDataType {
- type: string;
- revision: number;
- data: string;
- clientName: string;
- clientID: string;
- clients: Clients[];
-}
-
-interface MessageConfigType {
- univerId: string;
- actionData: IActionData;
-}
-
-export class CollaborationController {
- socket: IOSocket;
-
- previousMessage: string;
-
- clientID: string;
-
- private _plugin: CollaborationPlugin;
-
- private _sheetPlugin: SheetPlugin;
-
- private _collaborationActionList: string[];
-
- constructor(plugin: CollaborationPlugin) {
- this._plugin = plugin;
- this._sheetPlugin = plugin.getUniver().getCurrentUniverSheetInstance().context.getPluginManager().getRequirePluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET);
- this._initialize();
- }
-
- onMessage(data: string) {
- const json: JsonDataType = JSON.parse(data);
- const stringData = json.data;
-
- // 初始化获取clientID
- if (json.type === 'document') {
- return this.handleDocument(json);
- }
-
- // 获取其他客户端信息,初始化所有光标
- if (json.type === 'clients') {
- return this.handleClients(json);
- }
-
- // 其他客户端下线通知,移除光标
- if (json.type === 'offline') {
- return this.handleOffline(json);
- }
-
- if (json.type !== 'data' || stringData === HEART_BEAT_MESSAGE || this.previousMessage === stringData || this.clientID === json.clientID) {
- return;
- }
-
- this.previousMessage = stringData;
-
- try {
- const message: MessageConfigType = JSON.parse(stringData);
-
- const context = this._sheetPlugin.getContext();
-
- const currentUnitId = context.getWorkBook().getUnitId();
- const actionUnitId = message.univerId;
-
- if (currentUnitId !== actionUnitId) return;
-
- if (message) {
- const { actionName } = message.actionData;
-
- switch (actionName) {
- case ACTION_NAMES.SET_RANGE_DATA_ACTION:
- this.refreshRange(message);
- break;
- case SetSelectionValueAction.NAME:
- this.highlightCell(message, json.clientID, json.clientName);
- break;
-
- default:
- break;
- }
- }
- } catch (error) {
- console.error(error, stringData);
- }
-
- console.info('onmessage json: ', json);
- }
-
- onMessage_back(data: string) {
- const json = JSON.parse(data);
- const content = json.content;
- if (content === HEART_BEAT_MESSAGE || this.previousMessage === content) {
- return;
- }
-
- this.previousMessage = content;
-
- try {
- const message = JSON.parse(content);
-
- if (message && message.type === 'workbookData') {
- console.log('refresh');
- this.refresh(message.config);
- }
- } catch (error) {
- console.error(content);
- }
- }
-
- onError(data: IKeyValue) {
- console.log('Collaboration Error: ', data);
- }
-
- onOpen(data: IKeyValue) {
- console.log('Collaboration Open: ', data);
- }
-
- onClose(data: IKeyValue) {
- console.log('Collaboration Close: ', data);
- }
-
- onRetry(data: IKeyValue) {
- console.log('Collaboration Retry: ', data);
- }
-
- onDestroy(data: IKeyValue) {
- console.log('Collaboration Destroy: ', data);
- }
-
- close() {
- this.socket.close();
- }
-
- handleDocument(json: JsonDataType) {
- this.clientID = json.clientID;
- }
-
- handleClients(json: JsonDataType) {
- const clients = json.clients;
-
- if (clients == null) return;
-
- const editTooltipsController = this._plugin
- .getContext()
- .getUniver()
- .getCurrentUniverSheetInstance()
- .getWorkBook()
- .getContext()
- .getPluginManager()
- .getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)
- ?.getEditTooltipsController();
-
- clients.forEach((client) => {
- const clientID = client.clientID;
- if (clientID === this.clientID) {
- return;
- }
- const clientName = client.clientName;
- const sheetId = client.selectionActionData.sheetId;
-
- if (!client.selectionActionData.selections) return;
-
- const startRow = client.selectionActionData.selections[0].cell?.row;
- const startColumn = client.selectionActionData.selections[0].cell?.column;
- editTooltipsController?.createIfEditTooltips(clientID, sheetId, { text: clientName });
- editTooltipsController?.setRowColumn(clientID, sheetId, startRow || 0, startColumn || 0);
- });
-
- editTooltipsController?.refreshEditTooltips();
- }
-
- handleOffline(json: JsonDataType) {
- const clientID = json.clientID;
-
- if (clientID == null || clientID === '') return;
-
- const editTooltipsController = this._plugin
- .getContext()
- .getUniver()
- .getCurrentUniverSheetInstance()
- .getWorkBook()
- .getContext()
- .getPluginManager()
- .getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)
- ?.getEditTooltipsController();
-
- editTooltipsController?.removeEditTooltipsByKey(clientID);
- editTooltipsController?.refreshEditTooltips();
- }
-
- refreshRange(config: MessageConfigType) {
- const { actionData } = config;
- const { sheetId, cellValue } = actionData as ISetRangeDataActionData;
-
- const context = this._sheetPlugin.getContext();
- const _commandManager = context.getCommandManager();
- const worksheet = this._sheetPlugin.getWorkbook().getSheetBySheetId(sheetId);
-
- if (!worksheet) return;
-
- console.log('收到协同更新==范围:', '数据:', cellValue);
-
- let setValue: ISetRangeDataActionData = {
- sheetId: worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_DATA_ACTION,
- cellValue,
- };
- setValue = ActionOperation.make<ISetRangeDataActionData>(setValue).removeCollaboration().getAction();
- const command = new Command(
- {
- WorkBookUnit: context.getWorkBook(),
- },
- setValue
- );
- _commandManager.invoke(command);
- }
-
- highlightCell(config: MessageConfigType, clientID: string, clientName: string) {
- const { actionData } = config;
- const { sheetId, selections } = actionData as ISetSelectionValueActionData;
-
- const context = this._sheetPlugin.getContext();
- const _commandManager = context.getCommandManager();
- const worksheet = this._sheetPlugin.getWorkbook().getSheetBySheetId(sheetId);
-
- if (!worksheet || !selections[0].cell) return;
-
- const { row: startRow, column: startColumn } = selections[0].cell;
- const range: IGridRange = {
- sheetId,
- rangeData: {
- startRow,
- startColumn,
- endRow: startRow,
- endColumn: startColumn,
- },
- };
-
- const editTooltipsController = this._plugin
- .getContext()
- .getUniver()
- .getCurrentUniverSheetInstance()
- .getWorkBook()
- .getContext()
- .getPluginManager()
- .getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)
- ?.getEditTooltipsController();
-
- editTooltipsController?.createIfEditTooltips(clientID, sheetId, { text: clientName });
- editTooltipsController?.setRowColumn(clientID, sheetId, startRow, startColumn);
- editTooltipsController?.refreshEditTooltips();
- }
-
- refresh(config: IKeyValue) {
- const context = this._plugin.getContext() as SheetContext;
- context.refreshWorkbook(config);
-
- const worksheet = context.getWorkBook().getActiveSheet();
- if (worksheet) {
- try {
- const sheetPlugin = context.getPluginManager().getRequirePluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET);
- const canvasView = sheetPlugin.getCanvasView();
- if (canvasView) {
- canvasView.updateToSheet(worksheet);
- sheetPlugin.getMainComponent().makeDirty(true);
- }
- } catch (error) {
- console.info(error);
- }
- }
- }
-
- private _initialize() {
- const config = this._plugin.getConfig();
- const { url } = config;
-
- if (url === '') {
- console.warn('url must be input');
- return;
- }
-
- this._collaborationActionList = [ACTION_NAMES.SET_RANGE_DATA_ACTION, SetSelectionValueAction.NAME];
-
- this._initSocket(url);
- this._initObserver();
- }
-
- private _initSocket(url: string) {
- this.socket = new IOSocket({ url });
- this.socket.on(IOSocketListenType.MESSAGE, (event: MessageEvent) => {
- this.onMessage(event && event.data);
- });
- this.socket.on(IOSocketListenType.ERROR, (event: MessageEvent) => {
- this.onError(event && event.data);
- });
- this.socket.on(IOSocketListenType.OPEN, (event: MessageEvent) => {
- this.onOpen(event && event.data);
- });
- this.socket.on(IOSocketListenType.CLOSE, (event: MessageEvent) => {
- this.onClose(event && event.data);
- });
- this.socket.on(IOSocketListenType.RETRY, (event: MessageEvent) => {
- this.onRetry(event && event.data);
- });
- this.socket.on(IOSocketListenType.DESTROY, (event: MessageEvent) => {
- this.onDestroy(event && event.data);
- });
- this.socket.link();
- }
-
- private _initObserver() {
- let timer: NodeJS.Timeout | null = null;
- CommandManager.getCommandObservers().add(({ actions }) => {
- const plugin: CollaborationPlugin = this._plugin;
-
- if (!plugin) return;
- if (!actions || actions.length === 0) return;
- const action = actions[0] as SheetActionBase<ISheetActionData, ISheetActionData, void>;
-
- const actionData = action.getDoActionData();
- if (!ActionOperation.hasCollaboration(actionData)) return;
-
- const actionName = actionData.actionName;
- if (!this._collaborationActionList.includes(actionName)) return;
-
- const context = this._sheetPlugin.getContext();
-
- const currentUnitId = context.getWorkBook().getUnitId();
- const actionUnitId = action.getWorkBook().getUnitId();
-
- if (currentUnitId !== actionUnitId) return;
-
- // Only the currently active worksheet needs to be refreshed
- const worksheet = action.getWorkBook().getActiveSheet();
- if (worksheet) {
- try {
- if (timer) {
- clearTimeout(timer);
- timer = null;
- }
-
- // timer = setTimeout(() => {
- // const currentEditRangeValue = this._sheetPlugin.getCellEditorController().getCurrentEditRangeData();
- const data: MessageConfigType = {
- univerId: currentUnitId,
- actionData: action.getDoActionData(),
- };
-
- let stringData = JSON.stringify(data);
- const message = {
- type: 'data',
- data: stringData,
- };
-
- const stringMessage = JSON.stringify(message);
- this.previousMessage = stringData;
- this.socket.send(stringMessage);
- // }, 100);
- } catch (error) {
- console.info(error);
- }
- }
- });
- }
-
- private _initObserver_back() {
- let timer: NodeJS.Timeout | null = null;
- CommandManager.getCommandObservers().add(({ actions }) => {
- const plugin: CollaborationPlugin = this._plugin;
-
- if (!plugin) return;
- if (!actions || actions.length === 0) return;
- const action = actions[0] as SheetActionBase<ISheetActionData, ISheetActionData, void>;
- const actionName = action.getDoActionData().actionName;
-
- if (actionName !== ACTION_NAMES.SET_RANGE_DATA_ACTION) return;
-
- const context = plugin.getUniver().getCurrentUniverSheetInstance().context;
-
- const currentUnitId = context.getWorkBook().getUnitId();
- const actionUnitId = action.getWorkBook().getUnitId();
-
- if (currentUnitId !== actionUnitId) return;
-
- // Only the currently active worksheet needs to be refreshed
- const worksheet = action.getWorkBook().getActiveSheet();
- if (worksheet) {
- try {
- if (timer) {
- clearTimeout(timer);
- timer = null;
- }
-
- timer = setTimeout(() => {
- const config = context.getWorkBook().getConfig();
- const message = {
- type: 'workbookData',
- config,
- };
-
- const stringMessage = JSON.stringify(message);
- this.previousMessage = stringMessage;
- this.socket.send(stringMessage);
- }, 100);
- } catch (error) {
- console.info(error);
- }
- }
- });
- }
-}
diff --git a/packages/common-plugin-collaboration/src/Controller/index.ts b/packages/common-plugin-collaboration/src/Controller/index.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/common-plugin-collaboration/src/Locale/en.ts b/packages/common-plugin-collaboration/src/Locale/en.ts
deleted file mode 100644
index 74adc7647b..0000000000
--- a/packages/common-plugin-collaboration/src/Locale/en.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export default {
- collaboration: {
- tooltip: 'Collaboration',
- one: 'one',
- two: 'two',
- three: 'three',
- },
-};
diff --git a/packages/common-plugin-collaboration/src/Locale/index.ts b/packages/common-plugin-collaboration/src/Locale/index.ts
deleted file mode 100644
index 3ac4bcd0fd..0000000000
--- a/packages/common-plugin-collaboration/src/Locale/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import zh from './zh';
-import en from './en';
-
-export { zh, en };
diff --git a/packages/common-plugin-collaboration/src/Locale/zh.ts b/packages/common-plugin-collaboration/src/Locale/zh.ts
deleted file mode 100644
index 8d6942c2e3..0000000000
--- a/packages/common-plugin-collaboration/src/Locale/zh.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export default {
- collaboration: {
- tooltip: 'Collaboration',
- one: '一',
- two: '二',
- three: '三',
- },
-};
diff --git a/packages/common-plugin-collaboration/src/Model/index.ts b/packages/common-plugin-collaboration/src/Model/index.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/common-plugin-collaboration/src/Service/index.ts b/packages/common-plugin-collaboration/src/Service/index.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/common-plugin-collaboration/src/Types/index.d.ts b/packages/common-plugin-collaboration/src/Types/index.d.ts
deleted file mode 100644
index 13dfb82994..0000000000
--- a/packages/common-plugin-collaboration/src/Types/index.d.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-/// <reference types="vite/client" />
-
-export * from '../index';
-declare module '@univerjs/common-plugin-collaboration' {}
-
-// use css module
-declare module '*.less' {
- const resource: { [key: string]: string };
- export = resource;
-}
diff --git a/packages/common-plugin-collaboration/src/Types/preact.d.ts b/packages/common-plugin-collaboration/src/Types/preact.d.ts
deleted file mode 100644
index 0d092b3751..0000000000
--- a/packages/common-plugin-collaboration/src/Types/preact.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="enzyme-adapter-preact-pure" />
-import JSX = preact.JSX;
-
-declare module 'enzyme';
diff --git a/packages/common-plugin-collaboration/src/View/Render/index.ts b/packages/common-plugin-collaboration/src/View/Render/index.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/common-plugin-collaboration/src/View/UI/index.ts b/packages/common-plugin-collaboration/src/View/UI/index.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/common-plugin-collaboration/src/index.ts b/packages/common-plugin-collaboration/src/index.ts
deleted file mode 100644
index 56c9a2dbb3..0000000000
--- a/packages/common-plugin-collaboration/src/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './CollaborationPlugin';
diff --git a/packages/common-plugin-collaboration/tsconfig.json b/packages/common-plugin-collaboration/tsconfig.json
deleted file mode 100644
index 69b5c31f0b..0000000000
--- a/packages/common-plugin-collaboration/tsconfig.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "extends": "../../tsconfig.json",
- "compilerOptions": {
- "rootDir": "./",
- "outDir": "lib",
- "moduleResolution": "Node", //This value is needed for Node.js.
- "baseUrl": "./",
- "esModuleInterop": true, // auto allowSyntheticDefaultImports true
- "strictPropertyInitialization": false
- },
- "include": [
- "src/**/*",
- "test/**/*.test.(ts|tsx|js)"
- ]
-}
\ No newline at end of file
diff --git a/packages/common-plugin-collaboration/vite.config.ts b/packages/common-plugin-collaboration/vite.config.ts
deleted file mode 100644
index dcdbd9e822..0000000000
--- a/packages/common-plugin-collaboration/vite.config.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import { defineConfig } from 'vite';
-import path from 'path';
-import preact from '@preact/preset-vite';
-import legacy from '@vitejs/plugin-legacy';
-import { name, version } from './package.json';
-
-const resolve = (url: string) => path.resolve(__dirname, url);
-
-export default defineConfig({
- build: {
- // lib: {
- // entry: resolve('src/index.ts'),
- // name: 'BaseStyleUniver',
- // formats: ['es', 'umd', 'cjs'],
- // fileName: 'index',
- // },
- // outDir: './lib',
- },
- define: {
- pkgJson: { name, version },
- },
- css: {
- modules: {
- localsConvention: 'camelCaseOnly', // dash to camelCase conversion// .apply-color -> applyColor
- generateScopedName: 'univer-[local]', // custom prefix class name
- },
- preprocessorOptions: {
- less: {
- javascriptEnabled: true,
- },
- },
- },
- server: {
- port: 3103,
- open: true, // Automatically open the app in the browser on server start.
- },
- plugins: [
- preact(),
- legacy({
- targets: ['ie >= 11'],
- additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
- }),
- ],
-});
diff --git a/packages/core/src/Sheets/Domain/Freeze.ts b/packages/core/src/Sheets/Domain/Freeze.ts
deleted file mode 100644
index d09deb66a5..0000000000
--- a/packages/core/src/Sheets/Domain/Freeze.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import { SheetContext } from '../../Basics';
-import { Command, CommandManager } from '../../Command';
-import { Worksheet } from './Worksheet';
-import { ACTION_NAMES } from '../../Types/Const';
-import { Inject } from '@wendellhu/redi';
-import { ICurrentUniverService } from 'src/services/Current.service';
-
-export class Freeze {
- private _worksheet: Worksheet;
-
- constructor(
- workSheet: Worksheet,
- @Inject(CommandManager) private readonly _commandManager: CommandManager,
- @ICurrentUniverService private readonly _currentUniverService: ICurrentUniverService
- ) {
- this._worksheet = workSheet;
- }
-
- setFrozenColumns(columns: number): Worksheet {
- const { _commandManager } = this;
- const configure = {
- actionName: ACTION_NAMES.SET_FROZEN_COLUMNS_ACTION,
- sheetId: this._worksheet.getSheetId(),
- numColumns: columns,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- configure
- );
- _commandManager.invoke(command);
-
- return this._worksheet;
- }
-
- setFrozenRows(rows: number): Worksheet {
- const { _commandManager } = this;
- const configure = {
- actionName: ACTION_NAMES.SET_FROZEN_ROWS_ACTION,
- sheetId: this._worksheet.getSheetId(),
- numRows: rows,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- configure
- );
- _commandManager.invoke(command);
-
- return this._worksheet;
- }
-}
diff --git a/packages/core/src/Sheets/Domain/NamedRange.ts b/packages/core/src/Sheets/Domain/NamedRange.ts
deleted file mode 100644
index 1092660c3f..0000000000
--- a/packages/core/src/Sheets/Domain/NamedRange.ts
+++ /dev/null
@@ -1,172 +0,0 @@
-import { Command } from '../../Command';
-import { IAddNamedRangeActionData, IDeleteNamedRangeActionData, ISetNamedRangeActionData, AddNamedRangeAction } from '../Action';
-import { ACTION_NAMES } from '../../Types/Const';
-import { INamedRange } from '../../Types/Interfaces';
-
-// TODO: @Dushudir: the purpose of this class is prettry suspicious...
-
-/**
- * Create, access and modify named ranges in a spreadsheet. Named ranges are ranges that have associated string aliases.
- *
- * Reference: https://developers.google.com/apps-script/reference/spreadsheet/named-range
- */
-export class NamedRange {
- // private _name: string;
- // private _range: Range;
- // private _namedRangeId: string;
-
- constructor() {
- this._commandManager = this._workbook.getCommandManager();
-
- // this._name = name;
- // this._range = range;
- // this._namedRangeId = 'named-range-' + Tools.generateRandomId(6);
- // this._addNamedRange();
- }
-
- addNamedRange(namedRange: INamedRange) {
- const { _workbook, _commandManager } = this;
-
- // const namedRange: INamedRange = {
- // namedRangeId: this._namedRangeId,
- // name: this._name,
- // range: {
- // sheetId: this._worksheet.getSheetId(),
- // rangeData: this._range.getRangeData(),
- // },
- // };
- // Organize action data
- const actionData: IAddNamedRangeActionData = {
- actionName: AddNamedRangeAction.NAME,
- namedRange,
- sheetId: namedRange.range.sheetId,
- };
-
- // Execute action
- const command = new Command(
- {
- WorkBookUnit: _workbook,
- },
- actionData
- );
- _commandManager.invoke(command);
-
- // // manage instance
- // this._workbook.getNamedRanges().push(this);
- }
-
- setNamedRange(namedRange: INamedRange) {
- const { _commandManager } = this;
-
- // const namedRange: INamedRange = {
- // namedRangeId: this._namedRangeId,
- // name: this._name,
- // range: {
- // sheetId: this._worksheet.getSheetId(),
- // rangeData: this._range.getRangeData(),
- // },
- // };
- // Organize action data
- const actionData: ISetNamedRangeActionData = {
- actionName: ACTION_NAMES.SET_NAMED_RANGE_ACTION,
- namedRange,
- sheetId: namedRange.range.sheetId,
- };
-
- // Execute action
- const command = new Command(
- {
- WorkBookUnit: _workbook,
- },
- actionData
- );
- _commandManager.invoke(command);
- }
-
- /**
- * Gets the name of this named range.
- *
- * @returns String — the name of this named range
- */
- // getName(): string {
- // return this._name;
- // }
-
- /**
- * Sets/updates the name of the named range.
- * @param name The new name of the named range.
- *
- * @returns NamedRange — the range whose name was set by the call
- */
- // setName(name: string): NamedRange {
- // this._name = name;
-
- // this._setNamedRange();
-
- // return this;
- // }
-
- /**
- * Gets the range referenced by this named range.
- *
- * @returns Range — the spreadsheet range that is associated with this named range
- */
- // getRange(): Range {
- // return this._range;
- // }
-
- /**
- * Sets/updates the range for this named range.
- * @param range The spreadsheet range to associate with this named range.
- * @returns NamedRange — the named range for which the spreadsheet range was set
- */
- // setRange(range: Range): NamedRange {
- // this._range = range;
-
- // this._setNamedRange();
-
- // return this;
- // }
-
- /**
- * Gets the namedRangeId of this named range.
- *
- * @returns String — the namedRangeId of this named range
- */
- // getNamedRangeId(): string {
- // return this._namedRangeId;
- // }
-
- /**
- * Deletes this named range.
- */
- remove(namedRangeId: string): void {
- const { _workbook, _commandManager } = this;
-
- // Organize action data
- const actionData: IDeleteNamedRangeActionData = {
- actionName: ACTION_NAMES.DELETE_NAMED_RANGE_ACTION,
- namedRangeId,
- sheetId: _workbook.getActiveSheet().getSheetId(),
- };
-
- // Execute action
- const command = new Command(
- {
- WorkBookUnit: _workbook,
- },
- actionData
- );
- _commandManager.invoke(command);
-
- // const namedRanges = this._workbook.getNamedRanges();
-
- // return namedRanges.find((currentNamedRange: NamedRange, i) => {
- // if (currentNamedRange.getNamedRangeId() === this._namedRangeId) {
- // // remove
- // namedRanges.splice(i, 1);
- // return currentNamedRange;
- // }
- // })!;
- }
-}
\ No newline at end of file
diff --git a/packages/sheets-plugin-find/src/FindPlugin.ts b/packages/sheets-plugin-find/src/FindPlugin.ts
index 8cee51155d..b5db9f606d 100644
--- a/packages/sheets-plugin-find/src/FindPlugin.ts
+++ b/packages/sheets-plugin-find/src/FindPlugin.ts
@@ -1,4 +1,4 @@
-import { CommandManager, ICurrentUniverService, LocaleService, Plugin, PluginType } from '@univerjs/core';
+import { ICurrentUniverService, LocaleService, Plugin, PluginType } from '@univerjs/core';
// import { TextFinder } from './Domain/TextFind';
import { Dependency, Inject, Injector } from '@wendellhu/redi';
@@ -29,7 +29,6 @@ export class FindPlugin extends Plugin<FindPluginObserve> {
@ICurrentUniverService private readonly _currentUniverService: ICurrentUniverService,
@Inject(LocaleService) private readonly _localeService: LocaleService,
@Inject(Injector) private readonly _sheetInjector: Injector,
- @Inject(CommandManager) private readonly _commandManager: CommandManager
) {
super(FIND_PLUGIN_NAME);
diff --git a/packages/sheets-plugin-formula/src/Basics/Register/FormulaActionExtension.ts b/packages/sheets-plugin-formula/src/Basics/Register/FormulaActionExtension.ts
index 691decfdda..979f98a07e 100644
--- a/packages/sheets-plugin-formula/src/Basics/Register/FormulaActionExtension.ts
+++ b/packages/sheets-plugin-formula/src/Basics/Register/FormulaActionExtension.ts
@@ -1,204 +1,204 @@
-import {
- ActionOperation,
- ACTION_NAMES,
- BaseActionExtension,
- BaseActionExtensionFactory,
- Command,
- IRangeData,
- ISetRangeDataActionData,
- isFormulaString,
- ISheetActionData,
- IUnitRange,
- Nullable,
- ObjectMatrix,
- Tools,
- ICurrentUniverService,
- IActionData,
- CommandManager,
-} from '@univerjs/core';
-import { Inject, Injector } from '@wendellhu/redi';
-import { FormulaDataType, FormulaEngineService } from '@univerjs/base-formula-engine';
-import { ISetFormulaRangeActionData } from '../../Model/Action/SetFormulaRangeDataAction';
-import { ACTION_NAMES as PLUGIN_ACTION_NAMES } from '../Enum';
-import { FormulaController } from '../../Controller/FormulaController';
-
-//
-export class FormulaActionExtension extends BaseActionExtension {
- constructor(
- actionDataList: IActionData[],
- @Inject(Injector) private readonly _sheetInjector: Injector,
- @ICurrentUniverService private readonly _currentUniverService: ICurrentUniverService,
- @Inject(FormulaController) private readonly _formulaController: FormulaController,
- @Inject(FormulaEngineService) private readonly _formulaEngineService: FormulaEngineService,
- @Inject(CommandManager) private readonly _commandManager: CommandManager
- ) {
- super(actionDataList);
- }
-
- override execute() {
- const formulaController = this._formulaController;
- const formulaDataModel = formulaController.getDataModel();
- // The purpose of deep copy is to trigger the modification of formulaData through Command instead of reference relationship
- const formulaData = Tools.deepClone(formulaDataModel.getFormulaData());
- const unitId = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getUnitId();
- const actionDataList = this.actionDataList as ISetRangeDataActionData[];
-
- const unitRange: IUnitRange[] = [];
- let isCalculate = false;
-
- // handle each action
- actionDataList.forEach((actionData) => {
- if (actionData.operation != null && !ActionOperation.hasExtension(actionData)) return false;
- if (actionData.actionName !== ACTION_NAMES.SET_RANGE_DATA_ACTION) return false;
-
- // Filter out Actions that contain formulas, inject setRangeDataAction
- const { sheetId, cellValue } = actionData;
-
- if (Tools.isEmptyObject(formulaData)) return;
-
- if (!formulaData[unitId][sheetId]) {
- formulaData[unitId][sheetId] = {};
- }
- const cellData = new ObjectMatrix(formulaData[unitId][sheetId]);
-
- if (cellValue == null) return;
-
- const rangeMatrix = new ObjectMatrix(cellValue);
-
- let isArrayForm = false;
-
- // update formula string,Any modification to cellData will be linked to formulaData
- rangeMatrix.forValue((r, c, cell) => {
- const arrayFormCellRangeData = this.checkArrayFormValue(r, c);
- const formulaString = cell.m;
- if (arrayFormCellRangeData && formulaString === '') {
- isArrayForm = true;
- isCalculate = true;
-
- unitRange.push({ unitId, sheetId, rangeData: arrayFormCellRangeData });
- } else if (Tools.isStringNumber(formulaString)) {
- isCalculate = true;
-
- // if change formula to number, remove formula
- const formulaCell = cellData.getRow(r)?.get(c);
- if (formulaCell) {
- cellData.deleteValue(r, c);
- }
- } else if (isFormulaString(formulaString)) {
- isCalculate = true;
- cellData.setValue(r, c, { formula: formulaString, row: r, column: c, sheetId });
- }
- });
-
- if (!isArrayForm) {
- unitRange.push({ unitId, sheetId, rangeData: rangeMatrix.getDataRange() });
- }
- });
-
- if (unitRange.length === 0 || !isCalculate) return;
-
- this.executeFormula(unitId, formulaData, formulaController, unitRange, actionDataList);
- }
-
- executeFormula(unitId: string, formulaData: FormulaDataType, formulaController: FormulaController, unitRange: IUnitRange[], actionDataList: ISetRangeDataActionData[]) {
- const engine = this._formulaEngineService;
- // Add command after calculating the formula
- engine.execute(unitId, formulaData, formulaController.toInterpreterCalculateProps(), false, unitRange).then((data) => {
- const { sheetData, arrayFormulaData } = data;
-
- if (!sheetData) {
- console.error('No sheetData from Formula Engine!');
- return;
- }
-
- if (arrayFormulaData) {
- this._formulaController.addArrayFormulaData(arrayFormulaData);
- }
-
- const sheetIds = Object.keys(sheetData);
-
- // Update each calculated value, possibly involving all cells
- const actionDatas: ISetRangeDataActionData[] = [];
- sheetIds.forEach((sheetId) => {
- const cellData = sheetData[sheetId];
- cellData.forValue((r, c, value) => {
- const cellCalculate = cellData.getValue(r, c);
-
- // cell.v = cellCalculate?.v;
- // cell.t = cellCalculate?.t;
- if (cellCalculate && cellCalculate.p) {
- delete cellCalculate.p;
- }
-
- if (cellCalculate && Number.isNaN(cellCalculate.v)) {
- cellCalculate.v = 0;
- }
-
- const action = {
- actionName: ACTION_NAMES.SET_RANGE_DATA_ACTION,
- sheetId,
- cellValue: {
- [r]: {
- [c]: cellCalculate || {},
- },
- },
- };
-
- const actionData = ActionOperation.make<ISetRangeDataActionData>(action).removeCollaboration().removeUndo().removeExtension().getAction();
- actionDatas.push(actionData);
- });
- });
-
- const setFormulaDataAction: ISetFormulaRangeActionData = {
- actionName: PLUGIN_ACTION_NAMES.SET_FORMULA_RANGE_DATA_ACTION,
- sheetId: actionDataList[0].sheetId, // Any sheetId can be passed in, it has no practical effect
- formulaData,
- injector: this._sheetInjector,
- };
- const workBook = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
- const commandManager = this._commandManager;
- const command = new Command({ WorkBookUnit: workBook }, ...actionDatas, setFormulaDataAction);
- commandManager.invoke(command);
- });
- }
-
- checkArrayFormValue(row: number, column: number): Nullable<IRangeData> {
- let formula: Nullable<IRangeData>;
- const arrayFormulaData = this._formulaController.getDataModel().getArrayFormulaData();
-
- if (!arrayFormulaData) return null;
-
- Object.keys(arrayFormulaData).forEach((sheetId) => {
- const sheetData = arrayFormulaData[sheetId];
-
- sheetData.forValue((rowIndex: number, columnIndex: number, value: IRangeData) => {
- const { startRow, startColumn, endRow, endColumn } = value;
- if (row >= startRow && row < endRow && column >= startColumn && column < endColumn) {
- formula = {
- startRow,
- endRow: startRow,
- startColumn,
- endColumn: startColumn,
- };
- return false;
- }
- });
- });
-
- return formula;
- }
-}
-
-export class FormulaActionExtensionFactory extends BaseActionExtensionFactory {
- constructor(@Inject(Injector) private readonly _sheetInjector: Injector) {
- super();
- }
-
- override get zIndex(): number {
- return 1;
- }
-
- override create(actionDataList: ISheetActionData[]): BaseActionExtension {
- return this._sheetInjector.createInstance(FormulaActionExtension, actionDataList);
- }
-}
+// import {
+// ActionOperation,
+// ACTION_NAMES,
+// BaseActionExtension,
+// BaseActionExtensionFactory,
+// Command,
+// IRangeData,
+// ISetRangeDataActionData,
+// isFormulaString,
+// ISheetActionData,
+// IUnitRange,
+// Nullable,
+// ObjectMatrix,
+// Tools,
+// ICurrentUniverService,
+// IActionData,
+// CommandManager,
+// } from '@univerjs/core';
+// import { Inject, Injector } from '@wendellhu/redi';
+// import { FormulaDataType, FormulaEngineService } from '@univerjs/base-formula-engine';
+// import { ISetFormulaRangeActionData } from '../../Model/Action/SetFormulaRangeDataAction';
+// import { ACTION_NAMES as PLUGIN_ACTION_NAMES } from '../Enum';
+// import { FormulaController } from '../../Controller/FormulaController';
+
+// //
+// export class FormulaActionExtension extends BaseActionExtension {
+// constructor(
+// actionDataList: IActionData[],
+// @Inject(Injector) private readonly _sheetInjector: Injector,
+// @ICurrentUniverService private readonly _currentUniverService: ICurrentUniverService,
+// @Inject(FormulaController) private readonly _formulaController: FormulaController,
+// @Inject(FormulaEngineService) private readonly _formulaEngineService: FormulaEngineService,
+// @Inject(CommandManager) private readonly _commandManager: CommandManager
+// ) {
+// super(actionDataList);
+// }
+
+// override execute() {
+// const formulaController = this._formulaController;
+// const formulaDataModel = formulaController.getDataModel();
+// // The purpose of deep copy is to trigger the modification of formulaData through Command instead of reference relationship
+// const formulaData = Tools.deepClone(formulaDataModel.getFormulaData());
+// const unitId = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getUnitId();
+// const actionDataList = this.actionDataList as ISetRangeDataActionData[];
+
+// const unitRange: IUnitRange[] = [];
+// let isCalculate = false;
+
+// // handle each action
+// actionDataList.forEach((actionData) => {
+// if (actionData.operation != null && !ActionOperation.hasExtension(actionData)) return false;
+// if (actionData.actionName !== ACTION_NAMES.SET_RANGE_DATA_ACTION) return false;
+
+// // Filter out Actions that contain formulas, inject setRangeDataAction
+// const { sheetId, cellValue } = actionData;
+
+// if (Tools.isEmptyObject(formulaData)) return;
+
+// if (!formulaData[unitId][sheetId]) {
+// formulaData[unitId][sheetId] = {};
+// }
+// const cellData = new ObjectMatrix(formulaData[unitId][sheetId]);
+
+// if (cellValue == null) return;
+
+// const rangeMatrix = new ObjectMatrix(cellValue);
+
+// let isArrayForm = false;
+
+// // update formula string,Any modification to cellData will be linked to formulaData
+// rangeMatrix.forValue((r, c, cell) => {
+// const arrayFormCellRangeData = this.checkArrayFormValue(r, c);
+// const formulaString = cell.m;
+// if (arrayFormCellRangeData && formulaString === '') {
+// isArrayForm = true;
+// isCalculate = true;
+
+// unitRange.push({ unitId, sheetId, rangeData: arrayFormCellRangeData });
+// } else if (Tools.isStringNumber(formulaString)) {
+// isCalculate = true;
+
+// // if change formula to number, remove formula
+// const formulaCell = cellData.getRow(r)?.get(c);
+// if (formulaCell) {
+// cellData.deleteValue(r, c);
+// }
+// } else if (isFormulaString(formulaString)) {
+// isCalculate = true;
+// cellData.setValue(r, c, { formula: formulaString, row: r, column: c, sheetId });
+// }
+// });
+
+// if (!isArrayForm) {
+// unitRange.push({ unitId, sheetId, rangeData: rangeMatrix.getDataRange() });
+// }
+// });
+
+// if (unitRange.length === 0 || !isCalculate) return;
+
+// this.executeFormula(unitId, formulaData, formulaController, unitRange, actionDataList);
+// }
+
+// executeFormula(unitId: string, formulaData: FormulaDataType, formulaController: FormulaController, unitRange: IUnitRange[], actionDataList: ISetRangeDataActionData[]) {
+// const engine = this._formulaEngineService;
+// // Add command after calculating the formula
+// engine.execute(unitId, formulaData, formulaController.toInterpreterCalculateProps(), false, unitRange).then((data) => {
+// const { sheetData, arrayFormulaData } = data;
+
+// if (!sheetData) {
+// console.error('No sheetData from Formula Engine!');
+// return;
+// }
+
+// if (arrayFormulaData) {
+// this._formulaController.addArrayFormulaData(arrayFormulaData);
+// }
+
+// const sheetIds = Object.keys(sheetData);
+
+// // Update each calculated value, possibly involving all cells
+// const actionDatas: ISetRangeDataActionData[] = [];
+// sheetIds.forEach((sheetId) => {
+// const cellData = sheetData[sheetId];
+// cellData.forValue((r, c, value) => {
+// const cellCalculate = cellData.getValue(r, c);
+
+// // cell.v = cellCalculate?.v;
+// // cell.t = cellCalculate?.t;
+// if (cellCalculate && cellCalculate.p) {
+// delete cellCalculate.p;
+// }
+
+// if (cellCalculate && Number.isNaN(cellCalculate.v)) {
+// cellCalculate.v = 0;
+// }
+
+// const action = {
+// actionName: ACTION_NAMES.SET_RANGE_DATA_ACTION,
+// sheetId,
+// cellValue: {
+// [r]: {
+// [c]: cellCalculate || {},
+// },
+// },
+// };
+
+// const actionData = ActionOperation.make<ISetRangeDataActionData>(action).removeCollaboration().removeUndo().removeExtension().getAction();
+// actionDatas.push(actionData);
+// });
+// });
+
+// const setFormulaDataAction: ISetFormulaRangeActionData = {
+// actionName: PLUGIN_ACTION_NAMES.SET_FORMULA_RANGE_DATA_ACTION,
+// sheetId: actionDataList[0].sheetId, // Any sheetId can be passed in, it has no practical effect
+// formulaData,
+// injector: this._sheetInjector,
+// };
+// const workBook = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
+// const commandManager = this._commandManager;
+// const command = new Command({ WorkBookUnit: workBook }, ...actionDatas, setFormulaDataAction);
+// commandManager.invoke(command);
+// });
+// }
+
+// checkArrayFormValue(row: number, column: number): Nullable<IRangeData> {
+// let formula: Nullable<IRangeData>;
+// const arrayFormulaData = this._formulaController.getDataModel().getArrayFormulaData();
+
+// if (!arrayFormulaData) return null;
+
+// Object.keys(arrayFormulaData).forEach((sheetId) => {
+// const sheetData = arrayFormulaData[sheetId];
+
+// sheetData.forValue((rowIndex: number, columnIndex: number, value: IRangeData) => {
+// const { startRow, startColumn, endRow, endColumn } = value;
+// if (row >= startRow && row < endRow && column >= startColumn && column < endColumn) {
+// formula = {
+// startRow,
+// endRow: startRow,
+// startColumn,
+// endColumn: startColumn,
+// };
+// return false;
+// }
+// });
+// });
+
+// return formula;
+// }
+// }
+
+// export class FormulaActionExtensionFactory extends BaseActionExtensionFactory {
+// constructor(@Inject(Injector) private readonly _sheetInjector: Injector) {
+// super();
+// }
+
+// override get zIndex(): number {
+// return 1;
+// }
+
+// override create(actionDataList: ISheetActionData[]): BaseActionExtension {
+// return this._sheetInjector.createInstance(FormulaActionExtension, actionDataList);
+// }
+// }
diff --git a/packages/sheets-plugin-formula/src/Controller/FirstLoader.ts b/packages/sheets-plugin-formula/src/Controller/FirstLoader.ts
index 96dfa0c417..66d17747bf 100644
--- a/packages/sheets-plugin-formula/src/Controller/FirstLoader.ts
+++ b/packages/sheets-plugin-formula/src/Controller/FirstLoader.ts
@@ -1,4 +1,3 @@
-import { ActionOperation, ACTION_NAMES, ISetRangeDataActionData, Command, ObjectMatrix, ICellData } from '@univerjs/core';
import { FormulaController } from './FormulaController';
export function firstLoader(formulaController: FormulaController) {
@@ -7,41 +6,41 @@ export function firstLoader(formulaController: FormulaController) {
const sheetDataPromise = engine.execute(formulaController.getUnitId(), dataModel.getFormulaData(), formulaController.toInterpreterCalculateProps(), true);
- const commandManager = formulaController.getCommandManager();
+ // const commandManager = formulaController.getCommandManager();
- const workBook = formulaController.getWorkbook();
+ // const workBook = formulaController.getWorkbook();
- sheetDataPromise.then((data) => {
- if (!data) return;
- const { sheetData, arrayFormulaData } = data;
+ // sheetDataPromise.then((data) => {
+ // if (!data) return;
+ // const { sheetData, arrayFormulaData } = data;
- if (!sheetData) {
- return;
- }
+ // if (!sheetData) {
+ // return;
+ // }
- const sheetIds = Object.keys(sheetData);
+ // const sheetIds = Object.keys(sheetData);
- const actionList: ISetRangeDataActionData[] = [];
+ // const actionList: ISetRangeDataActionData[] = [];
- for (let i = 0, len = sheetIds.length; i < len; i++) {
- const sheetId = sheetIds[i];
- const cellData: ObjectMatrix<ICellData> = sheetData[sheetId];
- cellData.forValue((row, column, mainCell) => {
- const action = {
- actionName: ACTION_NAMES.SET_RANGE_DATA_ACTION,
- sheetId,
- cellValue: {
- [row]: {
- [column]: mainCell,
- },
- },
- };
+ // for (let i = 0, len = sheetIds.length; i < len; i++) {
+ // const sheetId = sheetIds[i];
+ // const cellData: ObjectMatrix<ICellData> = sheetData[sheetId];
+ // cellData.forValue((row, column, mainCell) => {
+ // const action = {
+ // actionName: ACTION_NAMES.SET_RANGE_DATA_ACTION,
+ // sheetId,
+ // cellValue: {
+ // [row]: {
+ // [column]: mainCell,
+ // },
+ // },
+ // };
- actionList.push(ActionOperation.make<ISetRangeDataActionData>(action).removeCollaboration().removeUndo().removeExtension().getAction());
- });
- }
+ // actionList.push(ActionOperation.make<ISetRangeDataActionData>(action).removeCollaboration().removeUndo().removeExtension().getAction());
+ // });
+ // }
- const command = new Command({ WorkBookUnit: workBook }, ...actionList);
- commandManager.invoke(command);
- });
+ // const command = new Command({ WorkBookUnit: workBook }, ...actionList);
+ // commandManager.invoke(command);
+ // });
}
diff --git a/packages/sheets-plugin-formula/src/Controller/FormulaController.ts b/packages/sheets-plugin-formula/src/Controller/FormulaController.ts
index 316ff2086d..c9d74aa4a4 100644
--- a/packages/sheets-plugin-formula/src/Controller/FormulaController.ts
+++ b/packages/sheets-plugin-formula/src/Controller/FormulaController.ts
@@ -1,7 +1,8 @@
-import { IInterpreterDatasetConfig, SheetDataType, UnitDataType, SheetNameMapType, ArrayFormulaDataType, FormulaEngineService } from '@univerjs/base-formula-engine';
+import { ArrayFormulaDataType, FormulaEngineService, IInterpreterDatasetConfig, SheetDataType, SheetNameMapType, UnitDataType } from '@univerjs/base-formula-engine';
import { ISelectionManager, SelectionManager } from '@univerjs/base-sheets';
-import { CommandManager, ICurrentUniverService } from '@univerjs/core';
+import { ICurrentUniverService } from '@univerjs/core';
import { Inject, Injector } from '@wendellhu/redi';
+
import { IFormulaConfig } from '../Basics/Interfaces/IFormula';
import { FormulaDataModel } from '../Model/FormulaDataModel';
import { ArrayFormulaLineControl } from './ArrayFormulaLineController';
@@ -21,7 +22,6 @@ export class FormulaController {
config: IFormulaConfig,
@ISelectionManager private readonly _selectionManager: SelectionManager,
@ICurrentUniverService private readonly _currentUniverService: ICurrentUniverService,
- @Inject(CommandManager) private readonly _commandManager: CommandManager,
@Inject(Injector) private readonly _sheetInjector: Injector
) {
this._formulaDataModel = new FormulaDataModel(config);
@@ -95,10 +95,6 @@ export class FormulaController {
return this._interpreterCalculatePropsCache;
}
- getCommandManager() {
- return this._commandManager;
- }
-
getWorkbook() {
return this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
}
diff --git a/packages/sheets-plugin-formula/src/FormulaPlugin.tsx b/packages/sheets-plugin-formula/src/FormulaPlugin.tsx
index 331a1e4adf..de2edf632a 100644
--- a/packages/sheets-plugin-formula/src/FormulaPlugin.tsx
+++ b/packages/sheets-plugin-formula/src/FormulaPlugin.tsx
@@ -1,5 +1,5 @@
import { Dependency, Inject, Injector } from '@wendellhu/redi';
-import { Plugin, CommandManager, PluginType, LocaleService } from '@univerjs/core';
+import { Plugin, PluginType, LocaleService } from '@univerjs/core';
import { FormulaEngineService } from '@univerjs/base-formula-engine';
import { CellEditExtensionManager, CellInputExtensionManager, ComponentManager, Icon } from '@univerjs/base-ui';
import { SheetContainerUIController } from '@univerjs/ui-plugin-sheets';
@@ -30,7 +30,6 @@ export class FormulaPlugin extends Plugin<FormulaPluginObserve> {
constructor(
private _config: IFormulaConfig,
@Inject(Injector) override readonly _injector: Injector,
- @Inject(CommandManager) private readonly _commandManager: CommandManager,
@Inject(LocaleService) private readonly _localeService: LocaleService
) {
super(FORMULA_PLUGIN_NAME);
@@ -104,8 +103,8 @@ export class FormulaPlugin extends Plugin<FormulaPluginObserve> {
}
override onDestroy(): void {
- const actionRegister = this._commandManager.getActionExtensionManager().getRegister();
- actionRegister.delete(this._formulaActionExtensionFactory);
+ // const actionRegister = this._commandManager.getActionExtensionManager().getRegister();
+ // actionRegister.delete(this._formulaActionExtensionFactory);
}
registerExtension() {
@@ -119,9 +118,9 @@ export class FormulaPlugin extends Plugin<FormulaPluginObserve> {
this._injector.add([FormulaCellInputExtensionFactory, { useValue: formulaCellInputExtensionFactory }]);
cellInputRegister.add(formulaCellInputExtensionFactory);
- const actionRegister = this._commandManager.getActionExtensionManager().getRegister();
- this._formulaActionExtensionFactory = new FormulaActionExtensionFactory(this._injector);
- actionRegister.add(this._formulaActionExtensionFactory);
+ // const actionRegister = this._commandManager.getActionExtensionManager().getRegister();
+ // this._formulaActionExtensionFactory = new FormulaActionExtensionFactory(this._injector);
+ // actionRegister.add(this._formulaActionExtensionFactory);
}
getFormulaEngine() {
diff --git a/packages/sheets-plugin-formula/src/Model/RegisterAction.ts b/packages/sheets-plugin-formula/src/Model/RegisterAction.ts
index 877bb510bd..fcd5b81567 100644
--- a/packages/sheets-plugin-formula/src/Model/RegisterAction.ts
+++ b/packages/sheets-plugin-formula/src/Model/RegisterAction.ts
@@ -1,5 +1,7 @@
-import { CommandManager } from '@univerjs/core';
-import { ACTION_NAMES } from '../Basics/Enum/ACTION_NAMES';
-import { SetFormulaRangeDataAction } from './Action/SetFormulaRangeDataAction';
+// TODO new formula command
-CommandManager.register(ACTION_NAMES.SET_FORMULA_RANGE_DATA_ACTION, SetFormulaRangeDataAction);
+// import { CommandManager } from '@univerjs/core';
+// import { ACTION_NAMES } from '../Basics/Enum/ACTION_NAMES';
+// import { SetFormulaRangeDataAction } from './Action/SetFormulaRangeDataAction';
+
+// CommandManager.register(ACTION_NAMES.SET_FORMULA_RANGE_DATA_ACTION, SetFormulaRangeDataAction);
diff --git a/packages/sheets-plugin-image/src/ImagePlugin.tsx b/packages/sheets-plugin-image/src/ImagePlugin.tsx
index 20e9aab455..9c55cfd11a 100644
--- a/packages/sheets-plugin-image/src/ImagePlugin.tsx
+++ b/packages/sheets-plugin-image/src/ImagePlugin.tsx
@@ -1,12 +1,13 @@
-import { Plugin, PluginType, CommandManager, LocaleService } from '@univerjs/core';
-import { Dependency, Inject, Injector } from '@wendellhu/redi';
import { uninstall } from '@univerjs/base-sheets';
+import { LocaleService, Plugin, PluginType } from '@univerjs/core';
import { SheetContainerUIController } from '@univerjs/ui-plugin-sheets';
-import { OverImageRender } from './View/Render';
-import { IImagePluginData } from './Symbol';
-import { OVER_GRID_IMAGE_PLUGIN_NAME, IOverGridImagePluginConfig, IOverGridImageProperty, install } from './Basics';
-import { OverGridImageController, CellImageController } from './Controller';
+import { Dependency, Inject, Injector } from '@wendellhu/redi';
+
+import { install, IOverGridImagePluginConfig, IOverGridImageProperty, OVER_GRID_IMAGE_PLUGIN_NAME } from './Basics';
+import { CellImageController, OverGridImageController } from './Controller';
import { UploadService } from './services/upload.service';
+import { IImagePluginData } from './Symbol';
+import { OverImageRender } from './View/Render';
/**
* TODO: 考虑加入单元格图片的情况,
@@ -28,8 +29,7 @@ export class ImagePlugin extends Plugin {
constructor(
private _config: IOverGridImagePluginConfig,
@Inject(Injector) override readonly _injector: Injector,
- @Inject(LocaleService) private readonly _localeService: LocaleService,
- @Inject(CommandManager) private readonly _commandManager: CommandManager
+ @Inject(LocaleService) private readonly _localeService: LocaleService
) {
super(OVER_GRID_IMAGE_PLUGIN_NAME);
this._imagePluginData = new Map<string, IOverGridImageProperty>();
@@ -49,7 +49,7 @@ export class ImagePlugin extends Plugin {
}
private _initializeDependencies(sheetInjector: Injector) {
- const dependencies: Dependency[] = [[OverGridImageController], [CellImageController], [OverImageRender],[UploadService]];
+ const dependencies: Dependency[] = [[OverGridImageController], [CellImageController], [OverImageRender], [UploadService]];
dependencies.forEach((d) => {
sheetInjector.add(d);
});
diff --git a/packages/sheets-plugin-image/src/RegisterAction.ts b/packages/sheets-plugin-image/src/RegisterAction.ts
index 21beaf35e5..8af4021f46 100644
--- a/packages/sheets-plugin-image/src/RegisterAction.ts
+++ b/packages/sheets-plugin-image/src/RegisterAction.ts
@@ -1,6 +1,8 @@
-import { CommandManager } from '@univerjs/core';
-import { AddOverGridImageAction, RemoveOverGridImageAction, SetImageTypeAction } from './Model';
+// TODO new command
-CommandManager.register(SetImageTypeAction.NAME, SetImageTypeAction);
-CommandManager.register(AddOverGridImageAction.NAME, AddOverGridImageAction);
-CommandManager.register(RemoveOverGridImageAction.NAME, RemoveOverGridImageAction);
+// import { CommandManager } from '@univerjs/core';
+// import { AddOverGridImageAction, RemoveOverGridImageAction, SetImageTypeAction } from './Model';
+
+// CommandManager.register(SetImageTypeAction.NAME, SetImageTypeAction);
+// CommandManager.register(AddOverGridImageAction.NAME, AddOverGridImageAction);
+// CommandManager.register(RemoveOverGridImageAction.NAME, RemoveOverGridImageAction);
diff --git a/packages/sheets-plugin-image/src/View/Render/OverImageRender.ts b/packages/sheets-plugin-image/src/View/Render/OverImageRender.ts
index 61ad0e5293..df4e95627d 100644
--- a/packages/sheets-plugin-image/src/View/Render/OverImageRender.ts
+++ b/packages/sheets-plugin-image/src/View/Render/OverImageRender.ts
@@ -1,9 +1,9 @@
-import { Scene, IRenderingEngine } from '@univerjs/base-render';
-import { CommandManager, ObserverManager } from '@univerjs/core';
+import { IRenderingEngine, Scene } from '@univerjs/base-render';
+import { ObserverManager } from '@univerjs/core';
import { Inject, Injector } from '@wendellhu/redi';
-import { OverImageShape } from './OverImageShape';
+
import { IOverGridImageProperty } from '../../Basics';
-import { AddOverGridImageAction, IAddOverGridImageActionData, IRemoveOverGridImageActionData, RemoveOverGridImageAction } from '../../Model';
+import { OverImageShape } from './OverImageShape';
export class OverImageRender {
static LAYER_Z_INDEX: number = 1000;
@@ -16,20 +16,22 @@ export class OverImageRender {
if (this._mainScene == null) {
throw new Error('main scene is null !!');
}
- CommandManager.getActionObservers().add((event) => {
- switch (event.data.actionName) {
- case AddOverGridImageAction.NAME: {
- const data = event.data as IAddOverGridImageActionData;
- this.addOverImage(data);
- break;
- }
- case RemoveOverGridImageAction.NAME: {
- const data = event.data as IRemoveOverGridImageActionData;
- this.removeOverImage(data.id);
- break;
- }
- }
- });
+
+ // TODO new command listener
+ // CommandManager.getActionObservers().add((event) => {
+ // switch (event.data.actionName) {
+ // case AddOverGridImageAction.NAME: {
+ // const data = event.data as IAddOverGridImageActionData;
+ // this.addOverImage(data);
+ // break;
+ // }
+ // case RemoveOverGridImageAction.NAME: {
+ // const data = event.data as IRemoveOverGridImageActionData;
+ // this.removeOverImage(data.id);
+ // break;
+ // }
+ // }
+ // });
}
addOverImage(property: IOverGridImageProperty): void {
diff --git a/packages/sheets-plugin-image/src/services/upload.service.ts b/packages/sheets-plugin-image/src/services/upload.service.ts
index 9876b2e688..e095fc45b2 100644
--- a/packages/sheets-plugin-image/src/services/upload.service.ts
+++ b/packages/sheets-plugin-image/src/services/upload.service.ts
@@ -1,15 +1,13 @@
import { ISelectionManager, SelectionManager } from '@univerjs/base-sheets';
-import { Command, CommandManager, ICurrentUniverService, Tools } from '@univerjs/core';
+import { ICurrentUniverService } from '@univerjs/core';
import { Inject, Injector } from '@wendellhu/redi';
-import { FileSelected, OverGridImageBorderType } from '../Basics';
-import { AddOverGridImageAction, IAddOverGridImageActionData } from '../Model';
+import { FileSelected } from '../Basics';
export class UploadService {
constructor(
@Inject(Injector) readonly _injector: Injector,
@ICurrentUniverService private readonly _currentUniverService: ICurrentUniverService,
- @Inject(CommandManager) private _commandManager: CommandManager,
@ISelectionManager private readonly _selectionManager: SelectionManager
) {}
@@ -27,23 +25,23 @@ export class UploadService {
};
img.onload = () => {
// FIXME use command system
- const action: IAddOverGridImageActionData = {
- actionName: AddOverGridImageAction.NAME,
- id: Tools.generateRandomId(),
- borderType: OverGridImageBorderType.SOLID,
- row: rowIndex || 1,
- column: columnIndex || 1,
- url: img.src,
- radius: 0,
- width: img.width,
- height: img.height,
- borderColor: '#000000',
- borderWidth: 1,
- sheetId: workbook.getActiveSheet().getSheetId(),
- injector: _injector,
- };
- const command = new Command({ WorkBookUnit: workbook }, action);
- this._commandManager.invoke(command);
+ // const action: IAddOverGridImageActionData = {
+ // actionName: AddOverGridImageAction.NAME,
+ // id: Tools.generateRandomId(),
+ // borderType: OverGridImageBorderType.SOLID,
+ // row: rowIndex || 1,
+ // column: columnIndex || 1,
+ // url: img.src,
+ // radius: 0,
+ // width: img.width,
+ // height: img.height,
+ // borderColor: '#000000',
+ // borderWidth: 1,
+ // sheetId: workbook.getActiveSheet().getSheetId(),
+ // injector: _injector,
+ // };
+ // const command = new Command({ WorkBookUnit: workbook }, action);
+ // this._commandManager.invoke(command);
};
});
}
diff --git a/packages/sheets-plugin-import-xlsx/src/ImportXlsxPlugin.tsx b/packages/sheets-plugin-import-xlsx/src/ImportXlsxPlugin.tsx
index 35f8c437c9..af4ccf1a24 100644
--- a/packages/sheets-plugin-import-xlsx/src/ImportXlsxPlugin.tsx
+++ b/packages/sheets-plugin-import-xlsx/src/ImportXlsxPlugin.tsx
@@ -1,4 +1,3 @@
-import { RegisterManager } from '@univerjs/base-ui';
import { LocaleService, Plugin, PluginType } from '@univerjs/core';
import { Inject, Injector } from '@wendellhu/redi';
@@ -17,12 +16,7 @@ export class ImportXlsxPlugin extends Plugin<any> {
private _dragAndDropExtensionFactory: DragAndDropExtensionFactory;
- constructor(
- config: IImportXlsxPluginConfig,
- @Inject(Injector) override readonly _injector: Injector,
- @Inject(RegisterManager) private readonly _registerManager: RegisterManager,
- @Inject(LocaleService) private readonly _localeService: LocaleService
- ) {
+ constructor(config: IImportXlsxPluginConfig, @Inject(Injector) override readonly _injector: Injector, @Inject(LocaleService) private readonly _localeService: LocaleService) {
super(IMPORT_XLSX_PLUGIN_NAME);
}
@@ -44,10 +38,9 @@ export class ImportXlsxPlugin extends Plugin<any> {
}
registerExtension() {
- const dragAndDropRegister = this._registerManager.getDragAndDropExtensionManager().getRegister();
-
- this._dragAndDropExtensionFactory = new DragAndDropExtensionFactory(this._injector);
- dragAndDropRegister.add(this._dragAndDropExtensionFactory);
+ // const dragAndDropRegister = this._registerManager.getDragAndDropExtensionManager().getRegister();
+ // this._dragAndDropExtensionFactory = new DragAndDropExtensionFactory(this._injector);
+ // dragAndDropRegister.add(this._dragAndDropExtensionFactory);
}
override onMounted(): void {
@@ -55,8 +48,8 @@ export class ImportXlsxPlugin extends Plugin<any> {
}
override onDestroy(): void {
- const dragAndDropRegister = this._registerManager.getDragAndDropExtensionManager().getRegister();
- dragAndDropRegister.delete(this._dragAndDropExtensionFactory);
+ // const dragAndDropRegister = this._registerManager.getDragAndDropExtensionManager().getRegister();
+ // dragAndDropRegister.delete(this._dragAndDropExtensionFactory);
}
getImportXlsxController() {
diff --git a/packages/sheets-plugin-numfmt/src/Basics/Register/NumfmtActionExtension.ts b/packages/sheets-plugin-numfmt/src/Basics/Register/NumfmtActionExtension.ts
index f288f23b40..dbfe11e236 100644
--- a/packages/sheets-plugin-numfmt/src/Basics/Register/NumfmtActionExtension.ts
+++ b/packages/sheets-plugin-numfmt/src/Basics/Register/NumfmtActionExtension.ts
@@ -1,89 +1,88 @@
-import {
- BaseActionExtension,
- ObjectMatrix,
- ISheetActionData,
- ACTION_NAMES,
- ActionOperation,
- IActionData,
- BaseActionExtensionFactory,
- CommandManager,
- ISetRangeDataActionData,
- ICurrentUniverService,
-} from '@univerjs/core';
-import { numfmt } from '@univerjs/base-numfmt-engine';
-import { Inject, Injector } from '@wendellhu/redi';
-import { NumfmtPlugin } from '../../NumfmtPlugin';
-import { INumfmtPluginData } from '../../Symbol';
-import { NumfmtModel } from '../../Model';
-import { ACTION_NAMES as PLUGIN_ACTION_NAMES } from '../Enum';
+// import { numfmt } from '@univerjs/base-numfmt-engine';
+// import {
+// ACTION_NAMES,
+// ActionOperation,
+// BaseActionExtension,
+// BaseActionExtensionFactory,
+// IActionData,
+// ICurrentUniverService,
+// ISetRangeDataActionData,
+// ISheetActionData,
+// ObjectMatrix,
+// } from '@univerjs/core';
+// import { Inject, Injector } from '@wendellhu/redi';
-export class NumfmtActionExtension extends BaseActionExtension {
- constructor(
- actionDataList: IActionData[],
- @ICurrentUniverService private readonly _currentUniverService: ICurrentUniverService,
- @Inject(INumfmtPluginData) private _numfmtPluginData: NumfmtModel,
- @Inject(Injector) private readonly _sheetInjector: Injector,
- @Inject(CommandManager) private readonly _commandManager: CommandManager
- ) {
- super(actionDataList);
- }
+// import { NumfmtModel } from '../../Model';
+// import { NumfmtPlugin } from '../../NumfmtPlugin';
+// import { INumfmtPluginData } from '../../Symbol';
+// import { ACTION_NAMES as PLUGIN_ACTION_NAMES } from '../Enum';
- override execute() {
- const numfmtMatrix = new ObjectMatrix<string>();
- const actionDataList = this.actionDataList as ISetRangeDataActionData[];
+// export class NumfmtActionExtension extends BaseActionExtension {
+// constructor(
+// actionDataList: IActionData[],
+// @ICurrentUniverService private readonly _currentUniverService: ICurrentUniverService,
+// @Inject(INumfmtPluginData) private _numfmtPluginData: NumfmtModel,
+// @Inject(Injector) private readonly _sheetInjector: Injector
+// ) {
+// super(actionDataList);
+// }
- actionDataList.forEach((actionData) => {
- if (actionData.operation != null && !ActionOperation.hasExtension(actionData)) {
- return false;
- }
+// override execute() {
+// const numfmtMatrix = new ObjectMatrix<string>();
+// const actionDataList = this.actionDataList as ISetRangeDataActionData[];
- if (actionData.actionName !== ACTION_NAMES.SET_RANGE_DATA_ACTION) {
- return false;
- }
+// actionDataList.forEach((actionData) => {
+// if (actionData.operation != null && !ActionOperation.hasExtension(actionData)) {
+// return false;
+// }
- const { cellValue, sheetId } = actionData;
- const numfmtConfig = this._numfmtPluginData.getNumfmtBySheetIdConfig(sheetId);
- const currSheetNumfmtMatrix = new ObjectMatrix(numfmtConfig);
- const rangeMatrix = new ObjectMatrix(cellValue);
+// if (actionData.actionName !== ACTION_NAMES.SET_RANGE_DATA_ACTION) {
+// return false;
+// }
- rangeMatrix.forValue((r, c, cell) => {
- const typed = numfmt.parseValue(cell.v) as unknown as { z: string; v: string };
+// const { cellValue, sheetId } = actionData;
+// const numfmtConfig = this._numfmtPluginData.getNumfmtBySheetIdConfig(sheetId);
+// const currSheetNumfmtMatrix = new ObjectMatrix(numfmtConfig);
+// const rangeMatrix = new ObjectMatrix(cellValue);
- if (typed) {
- // format already set,get format, e.g. 100% => =sum(2), we will set 200%
- const currNumfmtValue = currSheetNumfmtMatrix.getValue(r, c);
- // if (currNumfmtValue) {
- // typed.z = ;
- // }
+// rangeMatrix.forValue((r, c, cell) => {
+// const typed = numfmt.parseValue(cell.v) as unknown as { z: string; v: string };
- const format = numfmt(typed.z);
- cell.m = format(typed.v);
- cell.v = typed.v || String();
- numfmtMatrix.setValue(r, c, typed.z);
- }
- });
+// if (typed) {
+// // format already set,get format, e.g. 100% => =sum(2), we will set 200%
+// const currNumfmtValue = currSheetNumfmtMatrix.getValue(r, c);
+// // if (currNumfmtValue) {
+// // typed.z = ;
+// // }
- const setNumfmtRangeDataAction = {
- actionName: PLUGIN_ACTION_NAMES.SET_NUMFMT_RANGE_DATA_ACTION,
- sheetId,
- cellValue: numfmtMatrix.toJSON(),
- injector: this._sheetInjector,
- };
- this.push(setNumfmtRangeDataAction);
- });
- }
-}
+// const format = numfmt(typed.z);
+// cell.m = format(typed.v);
+// cell.v = typed.v || String();
+// numfmtMatrix.setValue(r, c, typed.z);
+// }
+// });
-export class NumfmtActionExtensionFactory extends BaseActionExtensionFactory {
- constructor(_plugin: NumfmtPlugin, @Inject(Injector) private readonly _sheetInjector: Injector) {
- super(_plugin);
- }
+// const setNumfmtRangeDataAction = {
+// actionName: PLUGIN_ACTION_NAMES.SET_NUMFMT_RANGE_DATA_ACTION,
+// sheetId,
+// cellValue: numfmtMatrix.toJSON(),
+// injector: this._sheetInjector,
+// };
+// this.push(setNumfmtRangeDataAction);
+// });
+// }
+// }
- override get zIndex(): number {
- return 2;
- }
+// export class NumfmtActionExtensionFactory extends BaseActionExtensionFactory {
+// constructor(_plugin: NumfmtPlugin, @Inject(Injector) private readonly _sheetInjector: Injector) {
+// super(_plugin);
+// }
- override create(actionDataList: ISheetActionData[]): BaseActionExtension {
- return this._sheetInjector.createInstance(NumfmtActionExtension, actionDataList);
- }
-}
+// override get zIndex(): number {
+// return 2;
+// }
+
+// override create(actionDataList: ISheetActionData[]): BaseActionExtension {
+// return this._sheetInjector.createInstance(NumfmtActionExtension, actionDataList);
+// }
+// }
diff --git a/packages/sheets-plugin-numfmt/src/Controller/NumfmtController.ts b/packages/sheets-plugin-numfmt/src/Controller/NumfmtController.ts
index b5a3ca4a1c..676d9db8ae 100644
--- a/packages/sheets-plugin-numfmt/src/Controller/NumfmtController.ts
+++ b/packages/sheets-plugin-numfmt/src/Controller/NumfmtController.ts
@@ -1,16 +1,5 @@
import { BaseComponentRender, ComponentManager, IMenuService } from '@univerjs/base-ui';
-import {
- ACTION_NAMES as CORE_ACTION_NAME,
- Command,
- CommandManager,
- Disposable,
- ICommandService,
- ICurrentUniverService,
- IRangeData,
- ObjectMatrix,
- ObjectMatrixPrimitiveType,
- Range,
-} from '@univerjs/core';
+import { Disposable, ICommandService, ICurrentUniverService, IRangeData, ObjectMatrix, ObjectMatrixPrimitiveType, Range } from '@univerjs/core';
import { Inject, Injector } from '@wendellhu/redi';
import { NUMFMT_PLUGIN_NAME } from '../Basics/Const';
@@ -93,7 +82,6 @@ export class NumfmtController extends Disposable {
protected _render: BaseComponentRender;
constructor(
- @Inject(CommandManager) private readonly _commandManager: CommandManager,
@Inject(ComponentManager) private readonly _componentManager: ComponentManager,
@Inject(Injector) private readonly _injector: Injector,
@Inject(INumfmtPluginData) private _numfmtPluginData: NumfmtModel,
@@ -120,40 +108,46 @@ export class NumfmtController extends Disposable {
Range.foreach(numfmtRange, (row, column) => {
numfmtMatrix.setValue(row, column, numfmtValue);
});
- const commandManager = this._commandManager;
- const config = {
- actionName: CORE_ACTION_NAME.SET_RANGE_DATA_ACTION,
- sheetId,
- rangeData: numfmtRange,
- cellValue: numfmtMatrix.toJSON(),
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- config
- );
- commandManager.invoke(command);
+
+ // TODO new command
+
+ // const commandManager = this._commandManager;
+ // const config = {
+ // actionName: CORE_ACTION_NAME.SET_RANGE_DATA_ACTION,
+ // sheetId,
+ // rangeData: numfmtRange,
+ // cellValue: numfmtMatrix.toJSON(),
+ // };
+ // const command = new Command(
+ // {
+ // WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
+ // },
+ // config
+ // );
+ // commandManager.invoke(command);
}
setNumfmtByCoords(sheetId: string, row: number, column: number, numfmt: string): void {
const numfmtMatrix = new ObjectMatrix<string>();
numfmtMatrix.setValue(row, column, numfmt);
const numfmtRange: IRangeData = { startRow: row, startColumn: column, endRow: row, endColumn: column };
- const commandManager = this._commandManager;
- const config = {
- actionName: CORE_ACTION_NAME.SET_RANGE_DATA_ACTION,
- sheetId,
- rangeData: numfmtRange,
- cellValue: numfmtMatrix.toJSON(),
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- config
- );
- commandManager.invoke(command);
+
+ // TODO new command
+
+ // const commandManager = this._commandManager;
+ // const config = {
+ // actionName: CORE_ACTION_NAME.SET_RANGE_DATA_ACTION,
+ // sheetId,
+ // rangeData: numfmtRange,
+ // cellValue: numfmtMatrix.toJSON(),
+ // };
+ // const command = new Command(
+ // {
+ // WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
+ // },
+ // config
+ // );
+ // commandManager.invoke(command);
}
private _initializeContextMenu() {
diff --git a/packages/sheets-plugin-numfmt/src/Model/Action/SetNumfmtRangeDataAction.ts b/packages/sheets-plugin-numfmt/src/Model/Action/SetNumfmtRangeDataAction.ts
index 36021458b3..64dabb6780 100644
--- a/packages/sheets-plugin-numfmt/src/Model/Action/SetNumfmtRangeDataAction.ts
+++ b/packages/sheets-plugin-numfmt/src/Model/Action/SetNumfmtRangeDataAction.ts
@@ -1,38 +1,38 @@
-import { SheetActionBase, ActionObservers, ISheetActionData, ObjectMatrixPrimitiveType, CommandUnit } from '@univerjs/core';
-import { SetNumfmtRangeData } from '../Apply';
-import { NumfmtController } from '../../Controller';
+// import { SheetActionBase, ActionObservers, ISheetActionData, ObjectMatrixPrimitiveType, CommandUnit } from '@univerjs/core';
+// import { SetNumfmtRangeData } from '../Apply';
+// import { NumfmtController } from '../../Controller';
-export interface ISetNumfmtRangeActionData extends ISheetActionData {
- numfmtMatrix: ObjectMatrixPrimitiveType<string>;
-}
+// export interface ISetNumfmtRangeActionData extends ISheetActionData {
+// numfmtMatrix: ObjectMatrixPrimitiveType<string>;
+// }
-export class SetNumfmtRangeDataAction extends SheetActionBase<ISetNumfmtRangeActionData, ISetNumfmtRangeActionData> {
- constructor(actionData: ISetNumfmtRangeActionData, commandUnit: CommandUnit, observers: ActionObservers) {
- super(actionData, commandUnit, observers);
- this._doActionData = {
- ...actionData,
- };
- this._oldActionData = {
- ...actionData,
- numfmtMatrix: this.do(),
- };
- }
+// export class SetNumfmtRangeDataAction extends SheetActionBase<ISetNumfmtRangeActionData, ISetNumfmtRangeActionData> {
+// constructor(actionData: ISetNumfmtRangeActionData, commandUnit: CommandUnit, observers: ActionObservers) {
+// super(actionData, commandUnit, observers);
+// this._doActionData = {
+// ...actionData,
+// };
+// this._oldActionData = {
+// ...actionData,
+// numfmtMatrix: this.do(),
+// };
+// }
- do(): ObjectMatrixPrimitiveType<string> {
- return this.redo();
- }
+// do(): ObjectMatrixPrimitiveType<string> {
+// return this.redo();
+// }
- redo(): ObjectMatrixPrimitiveType<string> {
- const { injector } = this._doActionData;
- return SetNumfmtRangeData(this.getWorkBook(), this._doActionData.sheetId, this._doActionData.numfmtMatrix, injector!.get(NumfmtController));
- }
+// redo(): ObjectMatrixPrimitiveType<string> {
+// const { injector } = this._doActionData;
+// return SetNumfmtRangeData(this.getWorkBook(), this._doActionData.sheetId, this._doActionData.numfmtMatrix, injector!.get(NumfmtController));
+// }
- undo(): void {
- const { injector } = this._oldActionData;
- SetNumfmtRangeData(this.getWorkBook(), this._oldActionData.sheetId, this._oldActionData.numfmtMatrix, injector!.get(NumfmtController));
- }
+// undo(): void {
+// const { injector } = this._oldActionData;
+// SetNumfmtRangeData(this.getWorkBook(), this._oldActionData.sheetId, this._oldActionData.numfmtMatrix, injector!.get(NumfmtController));
+// }
- validate(): boolean {
- return false;
- }
-}
+// validate(): boolean {
+// return false;
+// }
+// }
diff --git a/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts b/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts
index 28894fd1d3..00a5b39890 100644
--- a/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts
+++ b/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts
@@ -1,4 +1,4 @@
-import { CommandManager, IRangeData, LocaleService, ObjectMatrixPrimitiveType, Plugin, PluginType } from '@univerjs/core';
+import { IRangeData, LocaleService, ObjectMatrixPrimitiveType, Plugin, PluginType } from '@univerjs/core';
import { SheetContainerUIController } from '@univerjs/ui-plugin-sheets';
import { Dependency, Inject, Injector } from '@wendellhu/redi';
@@ -25,8 +25,7 @@ export class NumfmtPlugin extends Plugin<NumfmtPluginObserve> {
constructor(
config: Partial<INumfmtPluginConfig>,
@Inject(LocaleService) private readonly _localeService: LocaleService,
- @Inject(Injector) override readonly _injector: Injector,
- @Inject(CommandManager) private readonly _commandManager: CommandManager
+ @Inject(Injector) override readonly _injector: Injector
) {
super(NUMFMT_PLUGIN_NAME);
@@ -45,20 +44,20 @@ export class NumfmtPlugin extends Plugin<NumfmtPluginObserve> {
this._localeService.getLocale().load({ en, zh });
this._numfmtController = this._injector.get(NumfmtController);
this._numfmtModalController = this._injector.get(NumfmtModalController);
- const actionRegister = this._commandManager.getActionExtensionManager().getRegister();
- actionRegister.add(this._numfmtActionExtensionFactory);
+ // const actionRegister = this._commandManager.getActionExtensionManager().getRegister();
+ // actionRegister.add(this._numfmtActionExtensionFactory);
}
override onDestroy(): void {
super.onDestroy();
- const actionRegister = this._commandManager.getActionExtensionManager().getRegister();
- actionRegister.delete(this._numfmtActionExtensionFactory);
+ // const actionRegister = this._commandManager.getActionExtensionManager().getRegister();
+ // actionRegister.delete(this._numfmtActionExtensionFactory);
}
registerExtension(): void {
- const actionRegister = this._commandManager.getActionExtensionManager().getRegister();
- this._numfmtActionExtensionFactory = new NumfmtActionExtensionFactory(this, this._injector);
- actionRegister.add(this._numfmtActionExtensionFactory);
+ // const actionRegister = this._commandManager.getActionExtensionManager().getRegister();
+ // this._numfmtActionExtensionFactory = new NumfmtActionExtensionFactory(this, this._injector);
+ // actionRegister.add(this._numfmtActionExtensionFactory);
}
getNumfmtBySheetIdConfig(sheetId: string): ObjectMatrixPrimitiveType<string> {
diff --git a/packages/sheets-plugin-numfmt/src/RegisterAction.ts b/packages/sheets-plugin-numfmt/src/RegisterAction.ts
index 08927d1f5f..77ce1eaff0 100644
--- a/packages/sheets-plugin-numfmt/src/RegisterAction.ts
+++ b/packages/sheets-plugin-numfmt/src/RegisterAction.ts
@@ -1,5 +1,7 @@
-import { CommandManager } from '@univerjs/core';
-import { ACTION_NAMES } from './Basics/Enum';
-import { SetNumfmtRangeDataAction } from './Model/Action/SetNumfmtRangeDataAction';
+// TODO new command
-CommandManager.register(ACTION_NAMES.SET_NUMFMT_RANGE_DATA_ACTION, SetNumfmtRangeDataAction);
+// import { CommandManager } from '@univerjs/core';
+// import { ACTION_NAMES } from './Basics/Enum';
+// import { SetNumfmtRangeDataAction } from './Model/Action/SetNumfmtRangeDataAction';
+
+// CommandManager.register(ACTION_NAMES.SET_NUMFMT_RANGE_DATA_ACTION, SetNumfmtRangeDataAction);
diff --git a/packages/sheets-plugin-operation/src/OperationPlugin.ts b/packages/sheets-plugin-operation/src/OperationPlugin.ts
index 26cbcddb4a..89baffd55c 100644
--- a/packages/sheets-plugin-operation/src/OperationPlugin.ts
+++ b/packages/sheets-plugin-operation/src/OperationPlugin.ts
@@ -1,16 +1,16 @@
import { LocaleService, Plugin, PluginType } from '@univerjs/core';
import { Dependency, Inject, Injector } from '@wendellhu/redi';
-import { RegisterManager } from '@univerjs/base-ui';
-import { en, zh } from './Locale';
-import { OPERATION_PLUGIN } from './Const';
-import { Copy, Paste, UniverCopy, UniverPaste } from './Domain';
-import { PasteExtensionFactory } from './Basics/Register/PasteExtension';
-import { PasteOfficeExtensionFactory } from './Basics/Register/PasteOfficeExtension';
+
import { DEFAULT_OPERATION_PLUGIN_DATA } from './Basics/Const/DEFAULT_OPERATION_PLUGIN_DATA';
import { IOperationPluginConfig } from './Basics/Interfaces/IOperationPluginConfig';
import { CopyExtensionFactory } from './Basics/Register/CopyExtension';
import { CopyImageExtensionFactory } from './Basics/Register/CopyImageExtension';
+import { PasteExtensionFactory } from './Basics/Register/PasteExtension';
import { PasteImageExtensionFactory } from './Basics/Register/PasteImageExtension';
+import { PasteOfficeExtensionFactory } from './Basics/Register/PasteOfficeExtension';
+import { OPERATION_PLUGIN } from './Const';
+import { Copy, Paste, UniverCopy, UniverPaste } from './Domain';
+import { en, zh } from './Locale';
interface CopyResolver {
name: string;
@@ -48,8 +48,7 @@ export class OperationPlugin extends Plugin {
constructor(
config: Partial<IOperationPluginConfig>,
@Inject(LocaleService) private readonly _localeService: LocaleService,
- @Inject(Injector) override readonly _injector: Injector,
- @Inject(RegisterManager) private readonly _registerManager: RegisterManager
+ @Inject(Injector) override readonly _injector: Injector
) {
super(OPERATION_PLUGIN);
this._config = Object.assign(DEFAULT_OPERATION_PLUGIN_DATA, config);
@@ -72,23 +71,19 @@ export class OperationPlugin extends Plugin {
}
registerExtension() {
- const pasteRegister = this._registerManager.getPasteExtensionManager().getRegister();
-
- this._pasteExtensionFactory = new PasteExtensionFactory(this);
- pasteRegister.add(this._pasteExtensionFactory);
-
- this._pasteOfficeExtensionFactory = new PasteOfficeExtensionFactory(this);
- pasteRegister.add(this._pasteOfficeExtensionFactory);
- this._pasteImageExtensionFactory = new PasteImageExtensionFactory(this);
- pasteRegister.add(this._pasteImageExtensionFactory);
-
- const copyRegister = this._registerManager.getCopyExtensionManager().getRegister();
-
- this._copyExtensionFactory = new CopyExtensionFactory(this);
- copyRegister.add(this._copyExtensionFactory);
-
- this._copyImageExtensionFactory = new CopyImageExtensionFactory(this);
- copyRegister.add(this._copyImageExtensionFactory);
+ // TODO copy paste service?
+ // const pasteRegister = this._registerManager.getPasteExtensionManager().getRegister();
+ // this._pasteExtensionFactory = new PasteExtensionFactory(this);
+ // pasteRegister.add(this._pasteExtensionFactory);
+ // this._pasteOfficeExtensionFactory = new PasteOfficeExtensionFactory(this);
+ // pasteRegister.add(this._pasteOfficeExtensionFactory);
+ // this._pasteImageExtensionFactory = new PasteImageExtensionFactory(this);
+ // pasteRegister.add(this._pasteImageExtensionFactory);
+ // const copyRegister = this._registerManager.getCopyExtensionManager().getRegister();
+ // this._copyExtensionFactory = new CopyExtensionFactory(this);
+ // copyRegister.add(this._copyExtensionFactory);
+ // this._copyImageExtensionFactory = new CopyImageExtensionFactory(this);
+ // copyRegister.add(this._copyImageExtensionFactory);
}
// installTo(universheetInstance: UniverSheet) {
@@ -96,15 +91,14 @@ export class OperationPlugin extends Plugin {
// }
override onDestroy(): void {
- const pasteRegister = this._registerManager.getPasteExtensionManager().getRegister();
- pasteRegister.delete(this._pasteExtensionFactory);
- pasteRegister.delete(this._pasteOfficeExtensionFactory);
- pasteRegister.delete(this._pasteImageExtensionFactory);
-
- const copyRegister = this._registerManager.getCopyExtensionManager().getRegister();
-
- copyRegister.delete(this._copyExtensionFactory);
- copyRegister.delete(this._copyImageExtensionFactory);
+ // TODO copy paste service?
+ // const pasteRegister = this._registerManager.getPasteExtensionManager().getRegister();
+ // pasteRegister.delete(this._pasteExtensionFactory);
+ // pasteRegister.delete(this._pasteOfficeExtensionFactory);
+ // pasteRegister.delete(this._pasteImageExtensionFactory);
+ // const copyRegister = this._registerManager.getCopyExtensionManager().getRegister();
+ // copyRegister.delete(this._copyExtensionFactory);
+ // copyRegister.delete(this._copyImageExtensionFactory);
}
override onMounted(): void {