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.

chore(workspace): 1. onUIDidMount 2. remove unused file 3. collaboration demo

Dushusirdd536e4acb6a
diff --git a/examples/univer-doc-ts/src/main.tsx b/examples/univer-doc-ts/src/main.tsx
index 100d01b083..b39f3ebb43 100644
--- a/examples/univer-doc-ts/src/main.tsx
+++ b/examples/univer-doc-ts/src/main.tsx
@@ -4,6 +4,7 @@ import { RenderEngine } from '@univerjs/base-render';
import { DocPlugin } from '@univerjs/base-docs';
import { DEFAULT_DOCUMENT_DATA_EN } from '@univerjs/common-plugin-data';
import { DocUIPlugin } from '@univerjs/ui-plugin-docs';
+import { UIPlugin } from '@univerjs/base-ui';
// univer
const univer = new Univer();
@@ -15,6 +16,7 @@ univer.install(new RenderEngine());
const univerdoc = UniverDoc.newInstance(DEFAULT_DOCUMENT_DATA_EN);
univer.addUniverDoc(univerdoc);
+univer.install(new UIPlugin())
univerdoc.installPlugin(new DocPlugin());
univer.install(
new DocUIPlugin({
diff --git a/examples/univer-preact-ts/index.html b/examples/univer-preact-ts/index.html
index 90f44663a3..0d8fbde566 100644
--- a/examples/univer-preact-ts/index.html
+++ b/examples/univer-preact-ts/index.html
@@ -16,7 +16,7 @@
<body>
<div id="app" style="z-index: 1; position: fixed; font-size: 20px; color: green;"></div>
- <div id="universheet-demo" style="height: 50vh;"></div>
+ <div id="universheet-demo" style="height: 90vh;"></div>
<div id="universheet-demo-down" style="height: 50vh;"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
diff --git a/examples/univer-preact-ts/src/index.ts b/examples/univer-preact-ts/src/index.ts
index db0b583056..87c166882f 100644
--- a/examples/univer-preact-ts/src/index.ts
+++ b/examples/univer-preact-ts/src/index.ts
@@ -13,6 +13,7 @@ import { DEFAULT_FORMULA_DATA, FormulaPlugin, IFormulaConfig } from '@univerjs/s
import { CollaborationPlugin, ICollaborationPluginConfig } from '@univerjs/common-plugin-collaboration';
import { ClipboardPlugin } from '@univerjs/sheets-plugin-clipboard';
import { ImportXlsxPlugin } from '@univerjs/sheets-plugin-import-xlsx';
+import { UIPlugin } from '@univerjs/base-ui';
// import { INumfmtPluginConfig, NumfmtPlugin } from '@univerjs/sheets-plugin-numfmt';
// import { ClipboardPlugin } from '@univerjs/sheets-plugin-clipboard';
// import { ImportXlsxPlugin } from '@univerjs/sheets-plugin-import-xlsx';
@@ -39,8 +40,11 @@ class UniverSheetCustom {
// universheet instance
const universheet = UniverSheet.newInstance(config.coreConfig);
univer.addUniverSheet(universheet);
+
+ univer.install(new UIPlugin())
// base-sheets
universheet.installPlugin(new SheetPlugin(config.baseSheetsConfig));
+
// ui-plugin-sheets
univer.install(
new SheetUIPlugin(config.uiSheetsConfig)
@@ -86,6 +90,7 @@ class UniverDocCustom {
const univerdoc = UniverDoc.newInstance(config.coreConfig);
univer.addUniverDoc(univerdoc);
+ univer.install(new UIPlugin())
// base-docs
univerdoc.installPlugin(new DocPlugin(config.baseDocsConfig));
@@ -125,6 +130,8 @@ class UniverSlideCustom {
// universlide instance
const universlide = UniverSlide.newInstance(config.coreConfig);
univer.addUniverSlide(universlide);
+
+ univer.install(new UIPlugin())
// base-slides
universlide.installPlugin(new SlidePlugin(config.baseSlidesConfig));
// ui-plugin-slides
diff --git a/examples/univer-preact-ts/src/main.tsx b/examples/univer-preact-ts/src/main.tsx
index 37abce247f..5f3f1130dc 100644
--- a/examples/univer-preact-ts/src/main.tsx
+++ b/examples/univer-preact-ts/src/main.tsx
@@ -60,15 +60,230 @@ const defaultWorkbookData = Tools.deepClone(DEFAULT_WORKBOOK_DATA_DEMO);
// },
// };
-univerSheetCustom({
- coreConfig: defaultWorkbookData,
- baseSheetsConfig,
- uiSheetsConfig,
- collaborationConfig: {
- url: 'ws://localhost:8448/ws',
- // url: 'ws://luckysheet.lashuju.com/ws',
- },
-});
+
+
+
+
+const serverURL = 'http://localhost:8080/new';
+const config = {"type":"sheet","template":"DEMO1"}
+const wsURL = 'ws://localhost:8080/ws/'
+
+insertButton()
+insertUpdateButton()
+
+function insertInputBox(id) {
+ // 创建一个输入框元素
+ const box = document.createElement('input');
+ box.type = 'text';
+
+ document.body.appendChild(box);
+
+ box.style.position = 'fixed';
+ box.style.right = '0';
+ box.style.top = '70px';
+ box.addEventListener('blur',(e)=>{
+ const txt = e.target.value;
+ const message = {
+ "type": "data",
+ "data": txt
+ }
+ sendMessage(message)
+ })
+
+ const url = `${wsURL}${id}`;
+ const socket = new WebSocket(url);
+
+ // 连接建立时触发的事件
+ socket.onopen = function(event) {
+ console.log("WebSocket connected");
+ };
+
+ // 接收到消息时触发的事件
+ socket.onmessage = function(event) {
+ const message = JSON.parse(event.data);
+ console.log("Received message:", message);
+ };
+
+ // 连接关闭时触发的事件
+ socket.onclose = function(event) {
+ console.log("WebSocket closed:", event);
+ };
+
+ // 发送消息
+ function sendMessage(message) {
+ socket.send(JSON.stringify(message));
+ }
+}
+// openDocs()
+function insertUpdateButton() {
+ // 创建一个输入框元素
+ const input = document.createElement('input');
+ input.type = 'text';
+
+ document.body.appendChild(input);
+
+ input.style.position = 'fixed';
+ input.style.right = '0';
+ input.style.top = '30px';
+
+ // 创建一个按钮元素
+ const button = document.createElement('button');
+ button.textContent = '确定';
+
+ document.body.appendChild(button);
+
+ button.style.position = 'fixed';
+ button.style.right = '0';
+ button.style.top = '50px';
+
+
+ // 添加按钮点击事件处理程序
+ button.addEventListener('click', function() {
+ // 获取输入框的值
+ const inputValue = input.value;
+ openDocs(inputValue,(json)=>{
+ const universheetconfig = json.config;
+ const id = json.id;
+
+ const downUISheetsConfig = {
+ container: 'universheet-demo',
+ }
+ univerSheetCustom({
+ coreConfig:JSON.parse(universheetconfig),
+ uiSheetsConfig:downUISheetsConfig,
+ collaborationConfig:{
+ url: `${wsURL}${id}`
+ }
+ });
+
+
+ // insertInputBox(id)
+ })
+
+ // insertInputBox(inputValue)
+ });
+}
+
+function insertButton() {
+ // 创建一个按钮元素
+ const button = document.createElement('button');
+ // 设置按钮文本
+ button.textContent = 'New Docs';
+ // 将按钮添加到body元素中
+ document.body.appendChild(button);
+
+ button.style.position = 'fixed';
+ button.style.right = '0';
+ button.style.top = '0';
+
+
+ // 添加按钮点击事件处理程序
+ button.addEventListener('click', function() {
+ newDocs(serverURL,config,(json)=>{
+ const id = json.id;
+ const config = json.config;
+
+
+ console.log('id==: ',id)
+
+ let coreConfig
+ if(config === 'default'){
+ coreConfig = defaultWorkbookData
+ }
+ const universheet = univerSheetCustom({
+ coreConfig,
+ baseSheetsConfig,
+ uiSheetsConfig,
+ });
+
+ const universheetconfig = universheet.getWorkBook().getConfig()
+
+ updateDocs(id,universheetconfig)
+
+
+ })
+ });
+
+
+
+}
+function newDocs(url:string, params:object, cb?:(json:object)=>void) {
+ fetch(url, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify(params)
+ }).then(response => {
+ if (response.ok) {
+ return response.json();
+ } else {
+ throw new Error(response.statusText);
+ }
+ })
+ .then(document => {
+ // 处理获取到的文档信息
+ console.log(document);
+ cb && cb(document)
+ })
+ .catch(error => {
+ console.error(error);
+ });
+
+ }
+
+
+ function openDocs(id,cb?) {
+ // 定义请求参数
+ const data = new FormData();
+ data.append('id', id);
+
+ // 创建 XMLHttpRequest 对象
+ const xhr = new XMLHttpRequest();
+
+ // 监听请求完成事件
+ xhr.onload = function() {
+ if (xhr.status === 200) {
+ const document = JSON.parse(xhr.responseText);
+ // 处理获取到的文档信息
+ console.log(document);
+ cb && cb(document)
+ } else {
+ console.error(xhr.statusText);
+ }
+ };
+
+ // 发送 POST 请求
+ xhr.open('POST', 'http://localhost:8080/open', true);
+ xhr.send(data);
+
+ }
+ function updateDocs(id,config,cb?) {
+ // 定义请求参数
+ const data = new FormData();
+ data.append('id', id);
+ data.append('config', JSON.stringify(config));
+
+ // 创建 XMLHttpRequest 对象
+ const xhr = new XMLHttpRequest();
+
+ // 监听请求完成事件
+ xhr.onload = function() {
+ if (xhr.status === 200) {
+ const document = JSON.parse(xhr.responseText);
+ // 处理获取到的文档信息
+ console.log(document);
+ cb && cb(document)
+ } else {
+ console.error(xhr.statusText);
+ }
+ };
+
+ // 发送 POST 请求
+ xhr.open('POST', 'http://localhost:8080/update', true);
+ xhr.send(data);
+
+ }
// const sheetConfigDown = {
// container: 'universheet-demo-down',
diff --git a/examples/univer-sheet-ts/src/main.tsx b/examples/univer-sheet-ts/src/main.tsx
index 42f024acec..7c40a4d9b8 100644
--- a/examples/univer-sheet-ts/src/main.tsx
+++ b/examples/univer-sheet-ts/src/main.tsx
@@ -20,6 +20,7 @@ import {
import { ClipboardPlugin } from '@univerjs/sheets-plugin-clipboard';
import { ImportXlsxPlugin } from '@univerjs/sheets-plugin-import-xlsx';
import { FindPlugin } from '@univerjs/sheets-plugin-find';
+import { UIPlugin } from '@univerjs/base-ui';
const uiDefaultConfigDemo = {
container: 'universheet',
@@ -55,6 +56,7 @@ univer.install(new RenderEngine());
const universheet = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA_DEMO);
// sheet.installPlugin(new RenderEngine());
univer.addUniverSheet(universheet);
+univer.install(new UIPlugin())
// base-sheet
universheet.installPlugin(new SheetPlugin());
diff --git a/examples/univer-slide-ts/src/main.tsx b/examples/univer-slide-ts/src/main.tsx
index 6e3df16c63..4e2e80d61a 100644
--- a/examples/univer-slide-ts/src/main.tsx
+++ b/examples/univer-slide-ts/src/main.tsx
@@ -4,6 +4,7 @@ import { RenderEngine } from '@univerjs/base-render';
import { SlidePlugin } from '@univerjs/base-slides';
import { DEFAULT_SLIDE_DATA } from '@univerjs/common-plugin-data';
import {SlideUIPlugin} from '@univerjs/ui-plugin-slides'
+import { UIPlugin } from '@univerjs/base-ui';
// univer
const univer = new Univer();
@@ -15,6 +16,7 @@ univer.install(new RenderEngine());
const universlide = UniverSlide.newInstance(DEFAULT_SLIDE_DATA);
univer.addUniverSlide(universlide);
+univer.install(new UIPlugin())
universlide.installPlugin(new SlidePlugin());
univer.install(new SlideUIPlugin({
container: 'universlide',
diff --git a/examples/univer-vanilla-ts/src/main.tsx b/examples/univer-vanilla-ts/src/main.tsx
index c55ea9f8e3..595eb9602f 100644
--- a/examples/univer-vanilla-ts/src/main.tsx
+++ b/examples/univer-vanilla-ts/src/main.tsx
@@ -4,6 +4,7 @@ import { SheetPlugin } from '@univerjs/base-sheets';
import { CanvasView as SlideCanvasView } from '@univerjs/base-slides';
import { SheetUIPlugin } from '@univerjs/ui-plugin-sheets';
import { SlideUIPlugin } from '@univerjs/ui-plugin-slides';
+import { UIPlugin } from '@univerjs/base-ui';
import {
DEFAULT_FORMULA_DATA,
DEFAULT_FORMULA_DATA_DEMO,
@@ -33,6 +34,7 @@ univer.install(new RenderEngine());
const universheet = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA_DEMO);
univer.addUniverSheet(universheet);
+univer.install(new UIPlugin())
// base-sheet
universheet.installPlugin(
new SheetPlugin({
diff --git a/packages/base-docs/index.html b/packages/base-docs/index.html
deleted file mode 100644
index e7892b74ee..0000000000
--- a/packages/base-docs/index.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
- <meta charset="UTF-8" />
- <link rel="icon" type="image/svg+xml" href="favicon.svg" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>UniverDoc</title>
- <style>
- html,
- body {
- height: 100%;
- margin: 0;
- }
- </style>
-</head>
-
-<body>
- <div id="app" style="position:absolute;z-index: 1;"></div>
- <div id="univerdoc" style="height: 100%;"></div>
- <script type="module" src="/src/main.tsx"></script>
-</body>
-
-</html>
\ No newline at end of file
diff --git a/packages/base-docs/src/DocPlugin.tsx b/packages/base-docs/src/DocPlugin.ts
similarity index 86%
rename from packages/base-docs/src/DocPlugin.tsx
rename to packages/base-docs/src/DocPlugin.ts
index 040ad711c8..b3d1a7a812 100644
--- a/packages/base-docs/src/DocPlugin.tsx
+++ b/packages/base-docs/src/DocPlugin.ts
@@ -1,4 +1,4 @@
-import { DocContext, Plugin, PLUGIN_NAMES, UniverSheet } from '@univerjs/core';
+import { DocContext, Plugin, PLUGIN_NAMES, UIObserver, UniverSheet } from '@univerjs/core';
import { Engine, RenderEngine } from '@univerjs/base-render';
import { zh, en } from './Locale';
import { DocPluginObserve, install } from './Basics/Observer';
@@ -50,6 +50,8 @@ export class DocPlugin extends Plugin<DocPluginObserve, DocContext> {
});
install(this);
+
+ this.listenEventManager();
}
initializeAfterUI() {
@@ -73,6 +75,12 @@ export class DocPlugin extends Plugin<DocPluginObserve, DocContext> {
}
}
+ listenEventManager() {
+ this._getCoreObserver<boolean>('onUIDidMountObservable').add(({ name, value }) => {
+ this.initializeAfterUI();
+ });
+ }
+
getConfig() {
return this._config;
}
@@ -118,4 +126,8 @@ export class DocPlugin extends Plugin<DocPluginObserve, DocContext> {
}
onDestroy(): void {}
+
+ protected _getCoreObserver<T>(type: string) {
+ return this.getGlobalContext().getObserverManager().requiredObserver<UIObserver<T>>(type, 'core');
+ }
}
diff --git a/packages/base-docs/src/main.tsx b/packages/base-docs/src/main.tsx
deleted file mode 100644
index 2a78107d75..0000000000
--- a/packages/base-docs/src/main.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import { UniverDoc } from '@univerjs/core';
-import { RenderEngine } from '@univerjs/base-render';
-
-import { DocPlugin } from './DocPlugin';
-import { DEFAULT_DOCUMENT_DATA_EN } from '@univerjs/common-plugin-data';
-
-const univerDocUp = UniverDoc.newInstance(DEFAULT_DOCUMENT_DATA_EN);
-
-univerDocUp.installPlugin(new RenderEngine());
-univerDocUp.installPlugin(new UniverComponentSheet());
-
-univerDocUp.installPlugin(new DocPlugin());
diff --git a/packages/base-formula-engine/index.html b/packages/base-formula-engine/index.html
deleted file mode 100644
index e8b1031294..0000000000
--- a/packages/base-formula-engine/index.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
- <meta charset="UTF-8" />
- <link rel="icon" type="image/svg+xml" href="favicon.svg" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>UniverSheet</title>
- <style>
- html,
- body {
- height: 100%;
- margin: 0;
- }
- </style>
-</head>
-
-<body>
- <div id="app"></div>
- <div id="universheet-demo" style="height: 100%;"></div>
- <script type="module" src="/src/main.tsx"></script>
-</body>
-
-</html>
\ No newline at end of file
diff --git a/packages/base-formula-engine/src/FormulaEnginePlugin.tsx b/packages/base-formula-engine/src/FormulaEnginePlugin.ts
similarity index 100%
rename from packages/base-formula-engine/src/FormulaEnginePlugin.tsx
rename to packages/base-formula-engine/src/FormulaEnginePlugin.ts
index 83cce12d03..b25e9517fb 100644
--- a/packages/base-formula-engine/src/FormulaEnginePlugin.tsx
+++ b/packages/base-formula-engine/src/FormulaEnginePlugin.ts
@@ -18,6 +18,10 @@ export class FormulaEnginePlugin extends Plugin<FormulaEnginePluginObserver> {
super('formulaEngine');
}
+ static create(config?: IFormulaEnginePlugin) {
+ return new FormulaEnginePlugin(config);
+ }
+
/**
*
* @param unitId
@@ -92,8 +96,4 @@ export class FormulaEnginePlugin extends Plugin<FormulaEnginePluginObserver> {
}
onDestroy(): void {}
-
- static create(config?: IFormulaEnginePlugin) {
- return new FormulaEnginePlugin(config);
- }
}
diff --git a/packages/base-numfmt-engine/index.html b/packages/base-numfmt-engine/index.html
deleted file mode 100644
index dfd279c1b4..0000000000
--- a/packages/base-numfmt-engine/index.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
- <meta charset="UTF-8" />
- <link rel="icon" type="image/svg+xml" href="favicon.svg" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>UniverSheet</title>
-</head>
-
-<body>
- <div id="app"></div>
- <div id="universheet-demo-up"></div>
- <div id="universheet-demo-down"></div>
- <script type="module" src="/src/main.tsx"></script>
-</body>
-
-</html>
\ No newline at end of file
diff --git a/packages/base-render/index.html b/packages/base-render/index.html
deleted file mode 100644
index dfd279c1b4..0000000000
--- a/packages/base-render/index.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
- <meta charset="UTF-8" />
- <link rel="icon" type="image/svg+xml" href="favicon.svg" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>UniverSheet</title>
-</head>
-
-<body>
- <div id="app"></div>
- <div id="universheet-demo-up"></div>
- <div id="universheet-demo-down"></div>
- <script type="module" src="/src/main.tsx"></script>
-</body>
-
-</html>
\ No newline at end of file
diff --git a/packages/base-sheets/index.html b/packages/base-sheets/index.html
deleted file mode 100644
index d319769a37..0000000000
--- a/packages/base-sheets/index.html
+++ /dev/null
@@ -1,26 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
- <meta charset="UTF-8" />
- <link rel="icon" type="image/svg+xml" href="favicon.svg" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>UniverSheet</title>
- <style>
- html,
- body {
- height: 100%;
- margin: 0;
- }
- </style>
-</head>
-
-<body>
- <div id="app" style="z-index: 1; position: fixed; font-size: 20px; color: green;"></div>
- <!-- <div id="universheet-demo-demo" style="height: 100vh;"></div> -->
- <div id="universheet-demo-up" style="height: 100%;"></div>
- <div id="universheet-demo-down" style="height: 50vh;"></div>
- <script type="module" src="/src/main.tsx"></script>
-</body>
-
-</html>
\ No newline at end of file
diff --git a/packages/base-sheets/src/SheetPlugin.ts b/packages/base-sheets/src/SheetPlugin.ts
index 670849ea5b..f6812c19f2 100644
--- a/packages/base-sheets/src/SheetPlugin.ts
+++ b/packages/base-sheets/src/SheetPlugin.ts
@@ -62,6 +62,7 @@ export class SheetPlugin extends Plugin<SheetPluginObserve, SheetContext> {
this.initController();
this.initCanvasView();
this.registerExtension();
+ this.listenEventManager();
}
getConfig() {
diff --git a/packages/base-sheets/src/main.tsx b/packages/base-sheets/src/main.tsx
deleted file mode 100644
index 86759b4b25..0000000000
--- a/packages/base-sheets/src/main.tsx
+++ /dev/null
@@ -1,138 +0,0 @@
-import { UniverSheet } from '@univerjs/core';
-import { RenderEngine } from '@univerjs/base-render';
-
-import { NumfmtPlugin } from '@univerjs/sheets-plugin-numfmt';
-import { DEFAULT_WORKBOOK_DATA, DEFAULT_WORKBOOK_DATA_DOWN } from '@univerjs/common-plugin-data';
-import { DEFAULT_FORMULA_DATA_DOWN, FormulaPlugin } from '@univerjs/sheets-plugin-formula';
-import { SheetPlugin } from './SheetPlugin';
-
-const uiDefaultConfigUp = {
- container: 'universheet-demo-up',
- layout: {
- sheetContainerConfig: {
- infoBar: true,
- formulaBar: true,
- toolbar: true,
- sheetBar: true,
- countBar: true,
- rightMenu: true,
- },
- },
-
- selections: {
- 'sheet-01': [
- {
- selection: {
- startRow: 0,
- endRow: 0,
- startColumn: 3,
- endColumn: 3,
- },
- cell: {
- row: 0,
- column: 3,
- },
- },
- ],
- },
-
- render: {
- top: 0,
- left: 0,
- width: '100%',
- height: '100%',
- zIndex: 11,
- angle: 0,
- scaleX: 0,
- scaleY: 0,
- skewX: 0,
- skewY: 0,
- flipX: false,
- flipY: false,
- isTransformer: false,
- forceRender: false,
- },
-};
-
-// const univer = new Univer();
-// univer.installPlugin(new RenderEngine());
-// univer.installPlugin(new UniverComponentSheet());
-// univer.installPlugin(new FormulaEngine());
-
-const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);
-univerSheetUp.installPlugin(new RenderEngine());
-univerSheetUp.installPlugin(new UniverComponentSheet());
-
-let sheetPlugin = new SheetPlugin(uiDefaultConfigUp);
-
-univerSheetUp.installPlugin(sheetPlugin);
-// univerSheetUp.installPlugin(new NumfmtPlugin());
-// FormulaPlugin.create(DEFAULT_FORMULA_DATA).installTo(univerSheetUp);
-
-// univerSheetUp.refreshWorkbook(DEFAULT_WORKBOOK_DATA_DOWN);
-
-(window as any).sheetPlugin = sheetPlugin;
-
-const uiDefaultConfigDown = {
- container: 'universheet-demo-down',
- layout: {
- sheetContainerConfig: {
- infoBar: false,
- formulaBar: false,
- toolbar: true,
- sheetBar: true,
- countBar: true,
- rightMenu: true,
- },
- },
- selections: {
- 'sheet-0001': [
- {
- selection: {
- startRow: 2,
- endRow: 2,
- startColumn: 3,
- endColumn: 3,
- },
- cell: {
- row: 2,
- column: 3,
- },
- },
- ],
- },
-};
-
-const univerSheetDown = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA_DOWN);
-univerSheetDown.installPlugin(new RenderEngine());
-univerSheetDown.installPlugin(new UniverComponentSheet());
-
-univerSheetDown.installPlugin(new SheetPlugin(uiDefaultConfigDown));
-univerSheetDown.installPlugin(new NumfmtPlugin());
-FormulaPlugin.create(DEFAULT_FORMULA_DATA_DOWN).installTo(univerSheetDown);
-
-// const uiDefaultConfigDemo = {
-// container: 'universheet-demo-demo',
-// selections: {
-// 'sheet-0001': [
-// {
-// selection: {
-// startRow: 2,
-// endRow: 2,
-// startColumn: 3,
-// endColumn: 3,
-// },
-// cell: {
-// row: 2,
-// column: 3,
-// },
-// },
-// ],
-// },
-// };
-
-// const univerSheetDemo = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA_DEMO);
-// univerSheetDemo.installPlugin(new RenderEngine());
-// univerSheetDemo.installPlugin(new UniverComponentSheet());
-// univerSheetDemo.installPlugin(new SheetPlugin(uiDefaultConfigDemo));
-// FormulaPlugin.create(DEFAULT_FORMULA_DATA_DEMO).installTo(univerSheetDemo);
diff --git a/packages/base-slides/src/SlidePlugin.tsx b/packages/base-slides/src/SlidePlugin.ts
similarity index 98%
rename from packages/base-slides/src/SlidePlugin.tsx
rename to packages/base-slides/src/SlidePlugin.ts
index a8f19fff46..ffd38995f6 100644
--- a/packages/base-slides/src/SlidePlugin.tsx
+++ b/packages/base-slides/src/SlidePlugin.ts
@@ -41,6 +41,7 @@ export class SlidePlugin extends Plugin<SlidePluginObserve, SlideContext> {
this.initController();
this.initCanvasView();
this.registerExtension();
+ this.listenEventManager();
}
getConfig() {
diff --git a/packages/base-ui/index.html b/packages/base-ui/index.html
deleted file mode 100644
index c120642d1d..0000000000
--- a/packages/base-ui/index.html
+++ /dev/null
@@ -1,31 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
- <meta charset="UTF-8" />
- <link rel="icon" type="image/svg+xml" href="favicon.svg" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>UniverSheet</title>
- <style>
- #universheet-demo-up {
- width: 100%;
- height: 50vh;
- }
-
- #universheet-demo-down {
- width: 100%;
- height: 40vh;
- position: absolute;
- bottom: 0;
- }
- </style>
-</head>
-
-<body>
- <div id="universheet-demo-up"></div>
- <div id="universheet-demo-down"></div>
-
- <script type="module" src="/src/main.tsx"></script>
-</body>
-
-</html>
\ No newline at end of file
diff --git a/packages/base-ui/src/Common/EventManager.ts b/packages/base-ui/src/Common/EventManager.ts
index 90a9dd40d2..f10291a485 100644
--- a/packages/base-ui/src/Common/EventManager.ts
+++ b/packages/base-ui/src/Common/EventManager.ts
@@ -5,13 +5,14 @@ export class EventManager {
private _observerManager: ObserverManager;
constructor(private _plugin: Plugin) {
- this._observerManager = this._plugin.getContext().getObserverManager();
+ this._observerManager = this._plugin.getGlobalContext().getObserverManager();
this._installObserver();
}
private _installObserver() {
// Event = > UIcHnage
this._observerManager.addObserver('onUIChangeObservable', 'core', new Observable());
+ this._observerManager.addObserver('onUIDidMountObservable', 'core', new Observable());
this._observerManager.addObserver('onAfterChangeUISkinObservable', 'core', new Observable());
this._observerManager.addObserver('onAfterChangeUILocaleObservable', 'core', new Observable());
this._observerManager.addObserver('onViewComponentFocusChange', 'core', new Observable());
diff --git a/packages/base-ui/src/UIPlugin.ts b/packages/base-ui/src/UIPlugin.ts
new file mode 100644
index 0000000000..349d77b8b9
--- /dev/null
+++ b/packages/base-ui/src/UIPlugin.ts
@@ -0,0 +1,48 @@
+import { Plugin, PLUGIN_NAMES, Univer, Context } from '@univerjs/core';
+import { EventManager } from './Common';
+
+export interface IUIPluginConfig {}
+
+const DEFAULT_SLIDE_PLUGIN_DATA = {};
+
+export class UIPlugin extends Plugin<any, Context> {
+ private _config: IUIPluginConfig;
+
+ private _eventManager: EventManager;
+
+ constructor(config: Partial<IUIPluginConfig> = {}) {
+ super(PLUGIN_NAMES.BASE_UI);
+
+ this._config = Object.assign(DEFAULT_SLIDE_PLUGIN_DATA, config);
+ }
+
+ static create(config?: IUIPluginConfig) {
+ return new UIPlugin(config);
+ }
+
+ installTo(univerInstance: Univer) {
+ univerInstance.install(this);
+ }
+
+ initialize(context: Context): void {
+ this.context = context;
+
+ this.initEventManager();
+ }
+
+ getConfig() {
+ return this._config;
+ }
+
+ onMounted(ctx: Context): void {
+ this.initialize(ctx);
+ }
+
+ initEventManager() {
+ this._eventManager = new EventManager(this);
+ }
+
+ getEventManager() {
+ return this._eventManager;
+ }
+}
diff --git a/packages/base-ui/src/index.ts b/packages/base-ui/src/index.ts
index 162bba72f4..31d1e405a0 100644
--- a/packages/base-ui/src/index.ts
+++ b/packages/base-ui/src/index.ts
@@ -7,3 +7,4 @@ export * from './Helpers';
export * from './Components';
export * from './BaseComponent';
export * from './Framework';
+export * from './UIPlugin';
diff --git a/packages/common-plugin-collaboration/index.html b/packages/common-plugin-collaboration/index.html
deleted file mode 100644
index 7326249c9f..0000000000
--- a/packages/common-plugin-collaboration/index.html
+++ /dev/null
@@ -1,26 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
- <meta charset="UTF-8" />
- <link rel="icon" type="image/svg+xml" href="favicon.svg" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>Univer</title>
- <style>
- html,
- body {
- height: 100%;
- margin: 0;
- }
- </style>
-</head>
-
-<body>
- <div id="app" style="position:absolute;z-index: 1;"></div>
- <div id="universheet" style="height: 30vh;"></div>
- <div id="univerdoc" style="height: 30vh;"></div>
- <div id="universlide" style="height: 30vh;"></div>
- <script type="module" src="/src/main.tsx"></script>
-</body>
-
-</html>
\ No newline at end of file
diff --git a/packages/common-plugin-collaboration/src/Controller/CollaborationController.ts b/packages/common-plugin-collaboration/src/Controller/CollaborationController.ts
index 90a2dd6e3c..56b59b450b 100644
--- a/packages/common-plugin-collaboration/src/Controller/CollaborationController.ts
+++ b/packages/common-plugin-collaboration/src/Controller/CollaborationController.ts
@@ -1,11 +1,14 @@
import { SheetPlugin } from '@univerjs/base-sheets';
import {
+ ActionOperation,
ACTION_NAMES,
+ Command,
CommandManager,
HEART_BEAT_MESSAGE,
IKeyValue,
IOSocket,
IOSocketListenType,
+ ISetRangeDataActionData,
ISheetActionData,
PLUGIN_NAMES,
SheetActionBase,
@@ -13,19 +16,65 @@ import {
} from '@univerjs/core';
import { CollaborationPlugin } from '../CollaborationPlugin';
+interface MessageConfigType {
+ univerId: string;
+ actionData: ISetRangeDataActionData;
+}
+
export class CollaborationController {
socket: IOSocket;
previousMessage: string;
- protected _plugin: CollaborationPlugin;
+ private _plugin: CollaborationPlugin;
+
+ private _sheetPlugin: SheetPlugin;
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 = JSON.parse(data);
+ const stringData = json.data;
+ if (json.type !== 'data' || stringData === HEART_BEAT_MESSAGE || this.previousMessage === stringData) {
+ 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;
+
+ 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) {
@@ -70,6 +119,33 @@ export class CollaborationController {
this.socket.close();
}
+ refreshRange(config: MessageConfigType) {
+ const { actionData } = config;
+ const { sheetId, cellValue } = actionData;
+
+ 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);
+ }
+
refresh(config: IKeyValue) {
const context = this._plugin.getContext() as SheetContext;
context.refreshWorkbook(config);
@@ -126,6 +202,61 @@ export class CollaborationController {
}
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 (actionName !== ACTION_NAMES.SET_RANGE_DATA_ACTION) 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() as ISetRangeDataActionData,
+ };
+
+ 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;
diff --git a/packages/core/index.html b/packages/core/index.html
deleted file mode 100644
index 9df55fe771..0000000000
--- a/packages/core/index.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
- <meta charset="UTF-8" />
- <link rel="icon" type="image/svg+xml" href="favicon.svg" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>UniverSheet</title>
-</head>
-
-<body>
- <div id="app"></div>
- <script type="module" src="/src/main.tsx"></script>
-</body>
-
-</html>
\ No newline at end of file
diff --git a/packages/core/src/Const/PLUGIN_NAMES.ts b/packages/core/src/Const/PLUGIN_NAMES.ts
index aada6c5df2..3fc2ca2c66 100644
--- a/packages/core/src/Const/PLUGIN_NAMES.ts
+++ b/packages/core/src/Const/PLUGIN_NAMES.ts
@@ -5,6 +5,7 @@ export enum PLUGIN_NAMES {
// base-
BASE_COMPONENT = 'baseComponent',
BASE_RENDER = 'renderEngine',
+ BASE_UI = 'baseUI',
// office
SPREADSHEET = 'spreadsheet',
diff --git a/packages/core/src/Sheets/Domain/Range.ts b/packages/core/src/Sheets/Domain/Range.ts
index 948cf2a8fd..1f76e0e6a0 100644
--- a/packages/core/src/Sheets/Domain/Range.ts
+++ b/packages/core/src/Sheets/Domain/Range.ts
@@ -50,6 +50,7 @@ import {
Nullable,
ObjectArrayPrimitiveType,
ObjectMatrix,
+ ObjectMatrixPrimitiveType,
Tools,
Tuples,
} from '../../Shared';
@@ -3149,7 +3150,7 @@ export class Range {
* @returns Range — This range, for chaining.
*/
setRangeDatas(values: ICellData[][]): Range;
- setRangeDatas(values: ObjectMatrix<ICellData>): Range;
+ setRangeDatas(values: ObjectMatrixPrimitiveType<ICellData>): Range;
setRangeDatas(...argument: any): Range {
const { _rangeData, _context, _commandManager, _worksheet } = this;
const values = argument[0];
@@ -3176,7 +3177,7 @@ export class Range {
setValue
);
_commandManager.invoke(command);
- } else if (Tuples.checkup(argument, ObjectMatrix)) {
+ } else if (Tuples.checkup(argument, Tuples.OBJECT_TYPE)) {
const setValue: ISetRangeDataActionData = {
sheetId: _worksheet.getSheetId(),
actionName: ACTION_NAMES.SET_RANGE_DATA_ACTION,
diff --git a/packages/core/src/Sheets/Domain/Workbook.ts b/packages/core/src/Sheets/Domain/Workbook.ts
index 4813c3deb1..e9d2183b86 100644
--- a/packages/core/src/Sheets/Domain/Workbook.ts
+++ b/packages/core/src/Sheets/Domain/Workbook.ts
@@ -72,7 +72,7 @@ export class Workbook {
this._context = context;
const { styles } = this._config;
- if (this._config.id === '') {
+ if (this._config.id == null || this._config.id.length === 0) {
this._config.id = Tools.generateRandomId(6);
}
this._unitId = this._config.id;
diff --git a/packages/ui-plugin-docs/src/Controller/DocContainerUIController.ts b/packages/ui-plugin-docs/src/Controller/DocContainerUIController.ts
index 79e3dc0fbe..d1d612f243 100644
--- a/packages/ui-plugin-docs/src/Controller/DocContainerUIController.ts
+++ b/packages/ui-plugin-docs/src/Controller/DocContainerUIController.ts
@@ -1,5 +1,5 @@
-import { EventManager } from '@univerjs/base-ui';
-import { LocaleType, UniverDoc } from '@univerjs/core';
+import { getRefElement } from '@univerjs/base-ui';
+import { LocaleType } from '@univerjs/core';
import { IDocUIPluginConfig } from '../Basics';
import { DocUIPlugin } from '../DocUIPlugin';
import { DocContainer } from '../View';
@@ -17,8 +17,6 @@ export class DocContainerUIController {
private _config: IDocUIPluginConfig;
- private _eventManager: EventManager;
-
constructor(plugin: DocUIPlugin) {
this._plugin = plugin;
@@ -54,7 +52,11 @@ export class DocContainerUIController {
// 获取SheetContainer组件
getComponent = (ref: DocContainer) => {
this._docContainer = ref;
+
+ let container = getRefElement(ref.getContentRef());
+ this._plugin.initRender(container);
this._plugin.getObserver('onUIDidMount')?.notifyObservers(this._docContainer);
+ this._plugin.getGlobalContext().getObserverManager().requiredObserver<boolean>('onUIDidMountObservable', 'core').notifyObservers(true);
this._initDocContainer();
};
@@ -80,17 +82,6 @@ export class DocContainerUIController {
return this._docContainer.getContentRef();
}
- setEventManager() {
- const univerDocs = this._plugin.getUniver().getAllUniverDocsInstance();
- univerDocs.forEach((univerDoc: UniverDoc) => {
- // univerDocs.getWorkBook().getContext().getPluginManager().getRequirePluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET).listenEventManager();
- });
- }
-
- getEventManager() {
- return this._eventManager;
- }
-
getToolbarController() {
return this._toolbarController;
}
@@ -105,11 +96,7 @@ export class DocContainerUIController {
return this._docContainer;
}
- private _initialize() {
- this._eventManager = new EventManager(this._plugin);
-
- this.setEventManager();
- }
+ private _initialize() {}
private _initDocContainer() {
// handle drag event
diff --git a/packages/ui-plugin-docs/src/DocUIPlugin.ts b/packages/ui-plugin-docs/src/DocUIPlugin.ts
index 59e9f32b86..159f0717c8 100644
--- a/packages/ui-plugin-docs/src/DocUIPlugin.ts
+++ b/packages/ui-plugin-docs/src/DocUIPlugin.ts
@@ -1,7 +1,6 @@
-import { Plugin, Context, UniverDoc, PLUGIN_NAMES, Tools } from '@univerjs/core';
+import { Plugin, Context, PLUGIN_NAMES, Tools, Univer } from '@univerjs/core';
import { RenderEngine } from '@univerjs/base-render';
-import { ComponentManager, getRefElement, RegisterManager } from '@univerjs/base-ui';
-import { DocPlugin } from '@univerjs/base-docs';
+import { ComponentManager, RegisterManager } from '@univerjs/base-ui';
import { zh, en } from './Locale';
import { DOC_UI_PLUGIN_NAME } from './Basics/Const/PLUGIN_NAME';
import { DefaultDocUiConfig, IDocUIPluginConfig } from './Basics';
@@ -25,8 +24,8 @@ export class DocUIPlugin extends Plugin<any, Context> {
return new DocUIPlugin(config);
}
- installTo(universheetInstance: UniverDoc) {
- universheetInstance.installPlugin(this);
+ installTo(univerInstance: Univer) {
+ univerInstance.install(this);
}
initialize(ctx: Context): void {
@@ -41,24 +40,21 @@ export class DocUIPlugin extends Plugin<any, Context> {
this._componentManager = new ComponentManager();
this._appUIController = new AppUIController(this);
- this.UIDidMount(() => {
- this.initRender();
- });
+ // this.UIDidMount(() => {
+ // this.initRender();
+ // });
}
getConfig() {
return this._config;
}
- initRender() {
+ initRender(container: HTMLElement) {
const engine = this.getPluginByName<RenderEngine>(PLUGIN_NAMES.BASE_RENDER)?.getEngine()!;
- let container = getRefElement(this._appUIController.getDocContainerController().getContentRef());
// mount canvas to DOM container
engine.setContainer(container);
- this.getUniver().getCurrentUniverDocInstance().context.getPluginManager().getRequirePluginByName<DocPlugin>(PLUGIN_NAMES.DOCUMENT).initializeAfterUI();
-
window.addEventListener('resize', () => {
engine.resize();
});
diff --git a/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts b/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts
index 00fb6d144f..d6a9752245 100644
--- a/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts
+++ b/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts
@@ -1,6 +1,5 @@
-import { SheetPlugin } from '@univerjs/base-sheets';
-import { DragManager, EventManager, getRefElement, Prompt } from '@univerjs/base-ui';
-import { LocaleType, PLUGIN_NAMES, UniverSheet } from '@univerjs/core';
+import { DragManager, getRefElement, Prompt } from '@univerjs/base-ui';
+import { LocaleType } from '@univerjs/core';
import { ISheetUIPluginConfig, SHEET_UI_PLUGIN_NAME } from '../Basics';
import { SheetUIPlugin } from '../SheetUIPlugin';
import { SheetContainer } from '../View';
@@ -38,8 +37,6 @@ export class SheetContainerUIController {
private _dragManager: DragManager;
- private _eventManager: EventManager;
-
constructor(plugin: SheetUIPlugin) {
this._plugin = plugin;
@@ -109,6 +106,8 @@ export class SheetContainerUIController {
this._sheetContainer = ref;
this._plugin.getObserver('onUIDidMount')?.notifyObservers(this._sheetContainer);
+ this._plugin.getGlobalContext().getObserverManager().requiredObserver<boolean>('onUIDidMountObservable', 'core').notifyObservers(true);
+
this.setSheetContainer();
};
@@ -133,17 +132,6 @@ export class SheetContainerUIController {
return this._sheetContainer.getContentRef();
}
- setEventManager() {
- const universheets = this._plugin.getUniver().getAllUniverSheetsInstance();
- universheets.forEach((universheet: UniverSheet) => {
- universheet.getWorkBook().getContext().getPluginManager().getRequirePluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET).listenEventManager();
- });
- }
-
- getEventManager() {
- return this._eventManager;
- }
-
getCellEditorUIController() {
return this._cellEditorUIController;
}
@@ -168,9 +156,6 @@ export class SheetContainerUIController {
private _initialize() {
this._dragManager = new DragManager(this._plugin);
- this._eventManager = new EventManager(this._plugin);
-
- this.setEventManager();
}
private setSheetContainer() {
diff --git a/packages/ui-plugin-sheets/src/SheetUIPlugin.ts b/packages/ui-plugin-sheets/src/SheetUIPlugin.ts
index 21bc066a30..9d46ff0022 100644
--- a/packages/ui-plugin-sheets/src/SheetUIPlugin.ts
+++ b/packages/ui-plugin-sheets/src/SheetUIPlugin.ts
@@ -1,4 +1,4 @@
-import { Plugin, UniverSheet, Tools, PLUGIN_NAMES, Context } from '@univerjs/core';
+import { Plugin, Tools, PLUGIN_NAMES, Context, Univer } from '@univerjs/core';
import { ComponentManager, getRefElement, RegisterManager, KeyboardManager } from '@univerjs/base-ui';
import { RenderEngine } from '@univerjs/base-render';
import { DefaultSheetUIConfig, installObserver, ISheetUIPluginConfig, SheetUIPluginObserve, SHEET_UI_PLUGIN_NAME } from './Basics';
@@ -28,8 +28,8 @@ export class SheetUIPlugin extends Plugin<SheetUIPluginObserve, Context> {
return new SheetUIPlugin(config);
}
- installTo(univerInstance: UniverSheet) {
- univerInstance.installPlugin(this);
+ installTo(univerInstance: Univer) {
+ univerInstance.install(this);
}
initialize(ctx: Context): void {
diff --git a/packages/ui-plugin-slides/src/Controller/SlideContainerUIController.ts b/packages/ui-plugin-slides/src/Controller/SlideContainerUIController.ts
index 129eff1dc2..65d13f0839 100644
--- a/packages/ui-plugin-slides/src/Controller/SlideContainerUIController.ts
+++ b/packages/ui-plugin-slides/src/Controller/SlideContainerUIController.ts
@@ -1,6 +1,5 @@
-import { SlidePlugin } from '@univerjs/base-slides';
-import { DragManager, EventManager, getRefElement } from '@univerjs/base-ui';
-import { LocaleType, PLUGIN_NAMES, UniverSlide } from '@univerjs/core';
+import { DragManager, getRefElement } from '@univerjs/base-ui';
+import { LocaleType } from '@univerjs/core';
import { ISlideUIPluginConfig } from '../Basics';
import { SlideUIPlugin } from '../SlideUIPlugin';
import { SlideContainer } from '../View';
@@ -23,8 +22,6 @@ export class SlideContainerUIController {
private _dragManager: DragManager;
- private _eventManager: EventManager;
-
constructor(plugin: SlideUIPlugin) {
this._plugin = plugin;
@@ -68,6 +65,7 @@ export class SlideContainerUIController {
getComponent = (ref: SlideContainer) => {
this._slideContainer = ref;
this._plugin.getObserver('onUIDidMount')?.notifyObservers(this._slideContainer);
+ this._plugin.getGlobalContext().getObserverManager().requiredObserver<boolean>('onUIDidMountObservable', 'core').notifyObservers(true);
this.setSlideContainer();
};
@@ -93,17 +91,6 @@ export class SlideContainerUIController {
return this._slideContainer.getContentRef();
}
- setEventManager() {
- const universlides = this._plugin.getUniver().getAllUniverSlidesInstance();
- universlides.forEach((universlide: UniverSlide) => {
- universlide.context.getPluginManager().getRequirePluginByName<SlidePlugin>(PLUGIN_NAMES.SLIDE).listenEventManager();
- });
- }
-
- getEventManager() {
- return this._eventManager;
- }
-
getToolbarController() {
return this._toolbarController;
}
@@ -116,9 +103,6 @@ export class SlideContainerUIController {
private _initialize() {
this._dragManager = new DragManager(this._plugin);
- this._eventManager = new EventManager(this._plugin);
-
- this.setEventManager();
}
private setSlideContainer() {
diff --git a/packages/ui-plugin-slides/src/SlideUIPlugin.ts b/packages/ui-plugin-slides/src/SlideUIPlugin.ts
index 77aee41aff..4e7027c6af 100644
--- a/packages/ui-plugin-slides/src/SlideUIPlugin.ts
+++ b/packages/ui-plugin-slides/src/SlideUIPlugin.ts
@@ -1,4 +1,4 @@
-import { Plugin, Context, UniverSlide, Tools, PLUGIN_NAMES } from '@univerjs/core';
+import { Plugin, Context, Tools, PLUGIN_NAMES, Univer } from '@univerjs/core';
import { RegisterManager, ComponentManager, getRefElement } from '@univerjs/base-ui';
import { RenderEngine } from '@univerjs/base-render';
import { SlidePlugin } from '@univerjs/base-slides';
@@ -26,8 +26,8 @@ export class SlideUIPlugin extends Plugin<SlideUIPluginObserve, Context> {
return new SlideUIPlugin(config);
}
- installTo(universheetInstance: UniverSlide) {
- universheetInstance.installPlugin(this);
+ installTo(univerInstance: Univer) {
+ univerInstance.install(this);
}
initialize(ctx: Context): void {