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.

build(demo): 1. support npm run dev:demo, npm run build:demo

Dushusir7d71875ad3e3
diff --git a/README-zh.md b/README-zh.md
index 64917e7741..633e907a1c 100644
--- a/README-zh.md
+++ b/README-zh.md
@@ -6,7 +6,11 @@
🚀Univer,原 [Luckysheet 2.0](https://github.com/dream-num/Luckysheet) 升级。
-> ⚠️该项目仍在开发中,仅用于测试和学习,不得用于生产
+> ⚠️ 该项目仍在开发中,仅用于测试和学习,不得用于生产
+
+## Demo
+
+- [Univer Demo](dream-num.github.io/univer-demo/)
## 开发
@@ -15,6 +19,7 @@
[Node.js](https://nodejs.org/en/) Version >= 14.19
### 安装
+
```
git clone http://github.com/dream-num/univer
cd univer
@@ -22,24 +27,27 @@ npm i -g pnpm # MacOS : sudo npm i -g pnpm
npx playwright install
pnpm i
```
+
### 开发
-启动sheets
+启动 sheets
+
```
npm run dev
```
-启动docs
+启动 docs
+
```
npm run dev:doc
```
-启动slides
+启动 slides
+
```
npm run dev:slide
```
-
更多开发教程请参考 [贡献指南](./.github/contributing-zh.md)。
## 问题反馈
@@ -54,94 +62,98 @@ npm run dev:slide
### Sheets
-- 基础能力
- - [x] 核心数据结构
- - [x] 渲染
- - [x] 界面
- - [x] 单元格编辑
-
-- sheet操作
- - [x] sheet删除
- - [x] sheet复制
- - [x] sheet排序
- - [x] sheet重命名
- - [x] sheet更改颜色
- - [x] sheet隐藏
- - [x] sheet取消隐藏
- - [x] sheet向左移
- - [x] sheet向右移
-
-- 右击菜单
- - [x] 复制
- - [x] 粘贴
- - [x] 插入行
- - [x] 插入列
- - [x] 删除选中行
- - [x] 删除选中列
- - [x] 删除单元格
- - [x] 清除内容
-
-- 工具栏
- - [x] 撤销
- - [x] 重做
- - [ ] 格式刷
- - [ ] 货币格式
- - [ ] 百分比格式
- - [ ] 减少小数位数
- - [ ] 增加小数位数
- - [ ] 更多格式
- - [x] 字体
- - [x] 字体大小
- - [x] 加粗
- - [x] 斜体
- - [x] 删除线
- - [x] 下划线
- - [x] 文本颜色
- - [x] 单元格颜色
- - [x] 边框
- - [x] 合并单元格
- - [x] 水平对齐
- - [x] 垂直对齐
- - [x] 文本换行
- - [x] 文本旋转
-
-- 计数栏
- - [x] 计数
- - [x] 缩放
-
-
-- 插件
- - [x] 剪切板
- - [ ] 单元格格式
- - [ ] 公式
- - [ ] 图片
- - [ ] 冻结
- - [ ] 链接
- - [ ] 批注
- - [ ] 数据透视表
- - [ ] 图表
- - [ ] 排序
- - [ ] 筛选
- - [ ] 条件格式
- - [ ] 交替颜色
- - [ ] 数据验证
- - [ ] 分列
- - [ ] 截图
- - [ ] 查找
- - [ ] 替换
- - [ ] 工作表保护
- - [ ] 打印
- - [ ] 导入导出
- - [ ] 协同
+- 基础能力
+
+ - [x] 核心数据结构
+ - [x] 渲染
+ - [x] 界面
+ - [x] 单元格编辑
+
+- sheet 操作
+
+ - [x] sheet 删除
+ - [x] sheet 复制
+ - [x] sheet 排序
+ - [x] sheet 重命名
+ - [x] sheet 更改颜色
+ - [x] sheet 隐藏
+ - [x] sheet 取消隐藏
+ - [x] sheet 向左移
+ - [x] sheet 向右移
+
+- 右击菜单
+
+ - [x] 复制
+ - [x] 粘贴
+ - [x] 插入行
+ - [x] 插入列
+ - [x] 删除选中行
+ - [x] 删除选中列
+ - [x] 删除单元格
+ - [x] 清除内容
+
+- 工具栏
+
+ - [x] 撤销
+ - [x] 重做
+ - [ ] 格式刷
+ - [ ] 货币格式
+ - [ ] 百分比格式
+ - [ ] 减少小数位数
+ - [ ] 增加小数位数
+ - [ ] 更多格式
+ - [x] 字体
+ - [x] 字体大小
+ - [x] 加粗
+ - [x] 斜体
+ - [x] 删除线
+ - [x] 下划线
+ - [x] 文本颜色
+ - [x] 单元格颜色
+ - [x] 边框
+ - [x] 合并单元格
+ - [x] 水平对齐
+ - [x] 垂直对齐
+ - [x] 文本换行
+ - [x] 文本旋转
+
+- 计数栏
+
+ - [x] 计数
+ - [x] 缩放
+
+- 插件
+ - [x] 剪切板
+ - [ ] 单元格格式
+ - [ ] 公式
+ - [ ] 图片
+ - [ ] 冻结
+ - [ ] 链接
+ - [ ] 批注
+ - [ ] 数据透视表
+ - [ ] 图表
+ - [ ] 排序
+ - [ ] 筛选
+ - [ ] 条件格式
+ - [ ] 交替颜色
+ - [ ] 数据验证
+ - [ ] 分列
+ - [ ] 截图
+ - [ ] 查找
+ - [ ] 替换
+ - [ ] 工作表保护
+ - [ ] 打印
+ - [ ] 导入导出
+ - [ ] 协同
+
### Docs
-- [x] 渲染
-- [ ] 界面
-- [ ] 待定
+- [x] 渲染
+- [ ] 界面
+- [ ] 待定
### Slides
-- [ ] 渲染
-- [ ] 界面
-- [ ] 待定
-
+- [ ] 渲染
+- [ ] 界面
+- [ ] 待定
diff --git a/README.md b/README.md
index 80a18cedc0..adecfcb475 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,10 @@ English | [简体中文](./README-zh.md)
> ⚠️ This project is still in development, only for testing and learning, not for production
+## Demo
+
+- [Univer Demo](dream-num.github.io/univer-demo/)
+
## Development
### Requirements
@@ -15,26 +19,31 @@ English | [简体中文](./README-zh.md)
[Node.js](https://nodejs.org/en/) Version >= 14.19
### Installation
-````
+
+```
git clone http://github.com/dream-num/univer
cd univer
npm i -g pnpm # MacOS : sudo npm i -g pnpm
npx playwright install
pnpm i
-````
+```
+
### Development
Start sheets
+
```
npm run dev
```
Start docs
+
```
npm run dev:doc
```
Start slides
+
```
npm run dev:slide
```
@@ -53,94 +62,98 @@ Please file an issue at [Issues](http://github.com/dream-num/univer/issues).
### Sheets
-- Basic ability
- - [x] core data structures
- - [x] render
- - [x] UI
- - [x] cell editing
-
-- Sheet operation
- - [x] sheet delete
- - [x] sheet copy
- - [x] sheet sort
- - [x] sheet rename
- - [x] sheet change color
- - [x] sheet hide
- - [x] sheet unhide
- - [x] sheet move left
- - [x] sheet moves right
-
-- Right click menu
- - [x] copy
- - [x] paste
- - [x] insert row
- - [x] insert column
- - [x] delete selected rows
- - [x] delete selected columns
- - [x] delete cell
- - [x] clear content
-
-- Toolbar
- - [x] undo
- - [x] redo
- - [ ] formatter
- - [ ] currency format
- - [ ] percent format
- - [ ] decrease decimal places
- - [ ] increase the number of decimal places
- - [ ] more formats
- - [x] font family
- - [x] font size
- - [x] bold
- - [x] italic
- - [x] strikethrough
- - [x] underscore
- - [x] text color
- - [x] fill color
- - [x] border
- - [x] merge cells
- - [x] horizontal alignment
- - [x] vertical alignment
- - [x] text wrap
- - [x] text rotation
-
-- Count bar
- - [x] count
- - [x] zoom
-
-
-- Plugins
- - [x] clipboard
- - [ ] format
- - [ ] formula
- - [ ] image
- - [ ] freeze
- - [ ] link
- - [ ] comment
- - [ ] pivot table
- - [ ] chart
- - [ ] sort
- - [ ] filter
- - [ ] conditional format
- - [ ] alternating colors
- - [ ] data validation
- - [ ] split column
- - [ ] screenshot
- - [ ] find
- - [ ] replace
- - [ ] protection
- - [ ] print
- - [ ] import and export
- - [ ] collaboration
+- Basic ability
+
+ - [x] core data structures
+ - [x] render
+ - [x] UI
+ - [x] cell editing
+
+- Sheet operation
+
+ - [x] sheet delete
+ - [x] sheet copy
+ - [x] sheet sort
+ - [x] sheet rename
+ - [x] sheet change color
+ - [x] sheet hide
+ - [x] sheet unhide
+ - [x] sheet move left
+ - [x] sheet moves right
+
+- Right click menu
+
+ - [x] copy
+ - [x] paste
+ - [x] insert row
+ - [x] insert column
+ - [x] delete selected rows
+ - [x] delete selected columns
+ - [x] delete cell
+ - [x] clear content
+
+- Toolbar
+
+ - [x] undo
+ - [x] redo
+ - [ ] formatter
+ - [ ] currency format
+ - [ ] percent format
+ - [ ] decrease decimal places
+ - [ ] increase the number of decimal places
+ - [ ] more formats
+ - [x] font family
+ - [x] font size
+ - [x] bold
+ - [x] italic
+ - [x] strikethrough
+ - [x] underscore
+ - [x] text color
+ - [x] fill color
+ - [x] border
+ - [x] merge cells
+ - [x] horizontal alignment
+ - [x] vertical alignment
+ - [x] text wrap
+ - [x] text rotation
+
+- Count bar
+
+ - [x] count
+ - [x] zoom
+
+- Plugins
+ - [x] clipboard
+ - [ ] format
+ - [ ] formula
+ - [ ] image
+ - [ ] freeze
+ - [ ] link
+ - [ ] comment
+ - [ ] pivot table
+ - [ ] chart
+ - [ ] sort
+ - [ ] filter
+ - [ ] conditional format
+ - [ ] alternating colors
+ - [ ] data validation
+ - [ ] split column
+ - [ ] screenshot
+ - [ ] find
+ - [ ] replace
+ - [ ] protection
+ - [ ] print
+ - [ ] import and export
+ - [ ] collaboration
### Docs
-- [x] render
-- [ ] UI
-- [ ] pending
+- [x] render
+- [ ] UI
+- [ ] pending
### Slides
-- [ ] render
-- [ ] UI
-- [ ] pending
\ No newline at end of file
+- [ ] render
+- [ ] UI
+- [ ] pending
diff --git a/examples/univer-sheet-ts/.eslintrc.js b/examples/univer-sheet-ts/.eslintrc.js
new file mode 100644
index 0000000000..7f4cf3e7ba
--- /dev/null
+++ b/examples/univer-sheet-ts/.eslintrc.js
@@ -0,0 +1,51 @@
+module.exports = {
+ env: {
+ browser: true,
+ es2021: true,
+ node: true,
+ },
+ parser: '@typescript-eslint/parser',
+ extends: [
+ 'airbnb-typescript',
+ 'prettier',
+ 'eslint:recommended',
+ 'plugin:import/recommended',
+ 'plugin:import/typescript',
+ ],
+ parserOptions: {
+ ecmaVersion: 12,
+ sourceType: 'module',
+ project: './tsconfig.json',
+ },
+ plugins: ['@typescript-eslint', 'prettier', 'import'],
+ rules: {
+ 'prettier/prettier': [
+ 'error',
+ {
+ endOfLine: 'auto',
+ },
+ ],
+ 'import/prefer-default-export': 'off',
+ 'import/no-extraneous-dependencies': [
+ 'error',
+ { devDependencies: true },
+ ],
+ // turn on errors for missing imports
+ 'import/no-unresolved': 'error',
+ },
+ settings: {
+ 'import/parsers': {
+ '@typescript-eslint/parser': ['.ts', '.tsx'],
+ },
+ 'import/resolver': {
+ typescript: {
+ alwaysTryTypes: true, // always try to resolve config under `<root>@config` directory even it doesn't contain any source code, like `@config/unist`
+
+ // Choose from one of the "project" configs below or omit to use <root>/tsconfig.json by default
+
+ // use <root>/path/to/folder/tsconfig.json
+ project: './tsconfig.json',
+ },
+ },
+ },
+};
diff --git a/examples/univer-sheet-ts/.gitignore b/examples/univer-sheet-ts/.gitignore
new file mode 100644
index 0000000000..12e1bd6bec
--- /dev/null
+++ b/examples/univer-sheet-ts/.gitignore
@@ -0,0 +1,101 @@
+#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/examples/univer-sheet-ts/.prettierrc.js b/examples/univer-sheet-ts/.prettierrc.js
new file mode 100644
index 0000000000..001317e0a5
--- /dev/null
+++ b/examples/univer-sheet-ts/.prettierrc.js
@@ -0,0 +1,6 @@
+module.exports = {
+ singleQuote: true,
+ trailingComma: 'es5',
+ tabWidth: 4,
+ semi: true,
+};
diff --git a/examples/univer-sheet-ts/README-zh.md b/examples/univer-sheet-ts/README-zh.md
new file mode 100644
index 0000000000..7d93896bf5
--- /dev/null
+++ b/examples/univer-sheet-ts/README-zh.md
@@ -0,0 +1,31 @@
+# univer-vanilla-ts
+
+简体中文 | [English](./README.md)
+
+## 介绍
+
+Univer原生ts项目案例
+
+## 用法
+
+### 环境
+
+- [Node.js](https://nodejs.org/en/) Version >= 10
+
+### 安装
+
+```
+npm i
+```
+
+### 开发
+
+```
+npm run dev
+```
+
+### 打包
+
+```
+npm run build
+```
\ No newline at end of file
diff --git a/examples/univer-sheet-ts/README.md b/examples/univer-sheet-ts/README.md
new file mode 100644
index 0000000000..90ef00cd9a
--- /dev/null
+++ b/examples/univer-sheet-ts/README.md
@@ -0,0 +1,31 @@
+# univer-vanilla-ts
+
+English| [简体中文](./README-zh.md)
+
+## Introduction
+
+Univer vanilla ts project case
+
+## Usage
+
+### Requirements
+
+- [Node.js](https://nodejs.org/en/) Version >= 10
+
+### Installation
+
+```
+npm i
+```
+
+### Development
+
+```
+npm run dev
+```
+
+### Package
+
+```
+npm run build
+```
\ No newline at end of file
diff --git a/examples/univer-sheet-ts/index.html b/examples/univer-sheet-ts/index.html
new file mode 100644
index 0000000000..c5e5e1855a
--- /dev/null
+++ b/examples/univer-sheet-ts/index.html
@@ -0,0 +1,24 @@
+<!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" style="height: 100vh;"></div>
+ <script type="module" src="./src/main.tsx"></script>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/examples/univer-sheet-ts/package.json b/examples/univer-sheet-ts/package.json
new file mode 100644
index 0000000000..9962a49bfb
--- /dev/null
+++ b/examples/univer-sheet-ts/package.json
@@ -0,0 +1,61 @@
+{
+ "name": "univer-sheet-ts",
+ "version": "0.0.1",
+ "description": "Univer vanilla ts demo project",
+ "keywords": [],
+ "author": "DreamNum <[email protected]>",
+ "license": "MIT",
+ "directories": {
+ "lib": "lib"
+ },
+ "scripts": {
+ "test": "jest",
+ "dev": "vite",
+ "build": "tsc && vite build",
+ "build:demo": "vite build -c vite.demo.config.ts",
+ "watch": "vite build",
+ "link": "pnpm link ./",
+ "serve": "vite preview"
+ },
+ "devDependencies": {
+ "@preact/preset-vite": "2.0.0",
+ "@testing-library/preact": "^2.0.1",
+ "@types/jest": "^27.5.2",
+ "@types/node": "^16.4.6",
+ "@vitejs/plugin-legacy": "^1.5.1",
+ "enzyme": "^3.11.0",
+ "enzyme-adapter-preact-pure": "^3.3.0",
+ "eslint": "^8.22.0",
+ "eslint-config-airbnb-typescript": "^17.0.0",
+ "eslint-config-prettier": "^8.3.0",
+ "eslint-plugin-import": "^2.23.4",
+ "eslint-plugin-jsx-a11y": "^6.5.1",
+ "eslint-plugin-prettier": "^3.4.0",
+ "eslint-plugin-react": "^7.28.0",
+ "eslint-plugin-react-hooks": "^4.3.0",
+ "identity-obj-proxy": "^3.0.0",
+ "jest-dev-server": "^6.1.1",
+ "jest-environment-jsdom": "^29.0.3",
+ "less": "^4.1.1",
+ "prettier": "^2.3.2",
+ "ts-jest": "29.0.1",
+ "ts-node": "^10.2.1",
+ "typescript": "^4.4.1-rc",
+ "vite": "^2.4.4",
+ "vite-plugin-external": "1.2.3"
+ },
+ "dependencies": {
+ "@univer/base-component": "workspace:^0.0.1",
+ "@univer/base-docs": "workspace:^0.0.1",
+ "@univer/base-render": "workspace:^0.0.1",
+ "@univer/base-sheets": "workspace:^0.0.1",
+ "@univer/base-slides": "workspace:^0.0.1",
+ "@univer/common-plugin-data": "workspace:^0.0.1",
+ "@univer/core": "workspace:^0.0.1",
+ "@univer/sheets-plugin-clipboard": "workspace:^0.0.1",
+ "@univer/sheets-plugin-formula": "workspace:^0.0.1",
+ "@univer/sheets-plugin-numfmt": "workspace:^0.0.1",
+ "@univer/style-universheet": "workspace:^0.0.1",
+ "preact": "^10.5.14"
+ }
+}
diff --git a/examples/univer-sheet-ts/src/Types/index.d.ts b/examples/univer-sheet-ts/src/Types/index.d.ts
new file mode 100644
index 0000000000..bf64e445ee
--- /dev/null
+++ b/examples/univer-sheet-ts/src/Types/index.d.ts
@@ -0,0 +1,10 @@
+/// <reference types="vite/client" />
+
+export * from '../index';
+declare module 'univer-sheet-ts' {}
+
+// use css module
+declare module '*.less' {
+ const resource: { [key: string]: string };
+ export = resource;
+}
diff --git a/examples/univer-sheet-ts/src/Types/preact.d.ts b/examples/univer-sheet-ts/src/Types/preact.d.ts
new file mode 100644
index 0000000000..21573e1251
--- /dev/null
+++ b/examples/univer-sheet-ts/src/Types/preact.d.ts
@@ -0,0 +1,4 @@
+/// <reference types="enzyme-adapter-preact-pure" />
+import JSX = preact.JSX;
+
+declare module 'enzyme';
\ No newline at end of file
diff --git a/examples/univer-sheet-ts/src/main.tsx b/examples/univer-sheet-ts/src/main.tsx
new file mode 100644
index 0000000000..7ef555ec0e
--- /dev/null
+++ b/examples/univer-sheet-ts/src/main.tsx
@@ -0,0 +1,45 @@
+import { UniverSheet, UniverDoc, UniverSlide } from '@univer/core';
+import { RenderEngine } from '@univer/base-render';
+import { UniverComponentSheet } from '@univer/style-universheet';
+import { SheetPlugin } from '@univer/base-sheets';
+import { DocPlugin } from '@univer/base-docs';
+import { SlidePlugin } from '@univer/base-slides';
+import {
+ DEFAULT_FORMULA_DATA,
+ DEFAULT_FORMULA_DATA_DEMO,
+ FormulaPlugin,
+} from '@univer/sheets-plugin-formula';
+import { NumfmtPlugin } from '@univer/sheets-plugin-numfmt';
+import {
+ DEFAULT_WORKBOOK_DATA,
+ DEFAULT_WORKBOOK_DATA_DEMO,
+ DEFAULT_WORKBOOK_DATA_DOWN,
+} from '@univer/common-plugin-data';
+import { ClipboardPlugin } from '@univer/sheets-plugin-clipboard';
+import { BaseComponentPlugin } from '@univer/base-component';
+
+const uiDefaultConfigDemo = {
+ container: 'universheet',
+ 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/examples/univer-sheet-ts/tsconfig.json b/examples/univer-sheet-ts/tsconfig.json
new file mode 100644
index 0000000000..c9a567bad1
--- /dev/null
+++ b/examples/univer-sheet-ts/tsconfig.json
@@ -0,0 +1,32 @@
+{
+ "compilerOptions": {
+ "rootDir": "./",
+ "outDir": "lib",
+ "target": "ESNext",
+
+ "lib": ["ESNext", "DOM", "WebWorker"],
+ "module": "ESNext",
+ "moduleResolution": "Node", //This value is needed for Node.js.
+
+ "declaration": true,
+ "declarationDir": "./lib",
+ "declarationMap": true,
+ "sourceMap": true,
+ "resolveJsonModule": true,
+ "strict": true,
+ "allowJs": true,
+ "downlevelIteration": true,
+
+ "baseUrl": "./",
+ "skipLibCheck": true,
+ "esModuleInterop": true, // auto allowSyntheticDefaultImports true
+ "jsx": "preserve",
+ "jsxFactory": "h",
+ "jsxFragmentFactory": "Fragment",
+ "experimentalDecorators": true,
+ "emitDecoratorMetadata": true,
+ "suppressImplicitAnyIndexErrors": true,
+ "strictPropertyInitialization": false,
+ },
+ "include": ["src/**/*", "test/**/*.test.(ts|tsx|js)"]
+}
diff --git a/examples/univer-sheet-ts/tsconfig.ref.json b/examples/univer-sheet-ts/tsconfig.ref.json
new file mode 100644
index 0000000000..d2a1d98e5e
--- /dev/null
+++ b/examples/univer-sheet-ts/tsconfig.ref.json
@@ -0,0 +1,7 @@
+{
+ "extends": "./tsconfig.json",
+ "include": ["src/**/*"],
+ "compilerOptions": {
+ "composite": true
+ }
+}
diff --git a/examples/univer-sheet-ts/vite.config.ts b/examples/univer-sheet-ts/vite.config.ts
new file mode 100644
index 0000000000..58b8e2b17c
--- /dev/null
+++ b/examples/univer-sheet-ts/vite.config.ts
@@ -0,0 +1,52 @@
+import { defineConfig } from 'vite';
+import path from 'path';
+import preact from '@preact/preset-vite';
+import { name, version } from './package.json';
+import createExternal from 'vite-plugin-external';
+
+const resolve = (url: string) => path.resolve(__dirname, url);
+
+export default defineConfig({
+ build: {
+ lib: {
+ entry: resolve('src/index.ts'),
+ name: 'UniverVanillaTs',
+ formats: ['es', 'cjs', 'umd', 'iife'],
+ fileName: 'univer-sheet-ts',
+ },
+ 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'],
+ // }),
+ createExternal({
+ externals: {
+ // '@univer/core': '@univer/core',
+ // '@univer/style-universheet': '@univer/style-universheet',
+ // preact: 'preact',
+ // react: 'react',
+ },
+ }),
+ ],
+});
diff --git a/examples/univer-sheet-ts/vite.demo.config.ts b/examples/univer-sheet-ts/vite.demo.config.ts
new file mode 100644
index 0000000000..4f831b2034
--- /dev/null
+++ b/examples/univer-sheet-ts/vite.demo.config.ts
@@ -0,0 +1,82 @@
+import { defineConfig } from 'vite';
+import path from 'path';
+import preact from '@preact/preset-vite';
+import legacy from '@vitejs/plugin-legacy';
+import { name, version } from '../../packages/base-sheets/package.json';
+import createExternal from 'vite-plugin-external';
+
+const resolve = (url: string) => path.resolve(__dirname, url);
+
+export default defineConfig({
+ base: '',
+ build: {
+ rollupOptions: {
+ output: {
+ entryFileNames: `assets/[name].js`,
+ chunkFileNames: `assets/[name].js`,
+ assetFileNames: `assets/[name].[ext]`,
+ },
+ },
+ },
+ 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,
+ },
+ },
+ },
+ // resolve: {
+ // alias: [
+ // {
+ // find: '@',
+ // replacement: path.resolve(__dirname, './node_modules')
+ // }
+ // ],
+ // },
+ server: {
+ port: 3103,
+ open: true, // Automatically open the app in the browser on server start.
+ hmr: true,
+ },
+ plugins: [
+ preact(),
+ legacy({
+ targets: ['ie >= 11'],
+ additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
+ }),
+ createExternal({
+ externals: {
+ // '@univer/core': '@univer/core',
+ // '@univer/base-render': '@univer/base-render',
+ // '@univer/base-component': '@univer/base-component',
+ // '@univer/style-universheet': '@univer/style-universheet',
+ // 'css-vars-ponyfill': 'css-vars-ponyfill',
+ // nanoid: 'nanoid',
+ // preact: 'preact',
+ // react: 'react',
+ },
+ }),
+ ],
+ resolve: {
+ // preserveSymlinks: true,
+ // alias: [
+ // {
+ // find: '@Basics',
+ // replacement: path.resolve('..', '/src/Basics'),
+ // },
+ // ],
+ // alias: [
+ // {
+ // find: /^@([^univer].*)$/,
+ // replacement: path.resolve(__dirname, './src/$1'),
+ // },
+ // ],
+ },
+});
diff --git a/examples/univer-vanilla-ts/src/index.ts b/examples/univer-vanilla-ts/src/index.ts
deleted file mode 100644
index b826f399a5..0000000000
--- a/examples/univer-vanilla-ts/src/index.ts
+++ /dev/null
@@ -1,97 +0,0 @@
-import { IDocumentData, ISlideData, IWorkbookConfig, UniverDoc, UniverSheet, UniverSlide } from '@univer/core';
-import * as UniverCore from '@univer/core'
-import { RenderEngine } from '@univer/base-render';
-import { UniverComponentSheet } from '@univer/style-universheet';
-import { ISheetPluginConfig, SheetPlugin } from '@univer/base-sheets';
-import { IDocPluginConfig, DocPlugin } from '@univer/base-docs';
-import { ISlidePluginConfig, SlidePlugin } from '@univer/base-slides';
-import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';
-
-interface ISheetPropsCustom {
- coreConfig?: Partial<IWorkbookConfig>;
- baseSheetsConfig?: ISheetPluginConfig;
-}
-
-/**
- * Initialize the core and all plugins
- */
-class UniverSheetCustom {
- constructor() {}
- init(config: ISheetPropsCustom = {}): UniverSheet {
- const universheet = UniverSheet.newInstance(config.coreConfig);
-
- universheet.installPlugin(new RenderEngine());
- universheet.installPlugin(new UniverComponentSheet());
- universheet.installPlugin(new SheetPlugin(config.baseSheetsConfig));
-
- return universheet;
- }
-}
-/**
- * Wrapped into a function,easy to use
- * @param config
- * @returns
- */
-const univerSheetCustom = function (config?: ISheetPropsCustom) {
- return new UniverSheetCustom().init(config);
-};
-
-interface IDocPropsCustom {
- coreConfig?: Partial<IDocumentData>;
- baseDocsConfig?: IDocPluginConfig;
-}
-
-/**
- * Initialize the core and all plugins
- */
-class UniverDocCustom {
- constructor() {}
- init(config: IDocPropsCustom = {}): UniverDoc {
- const univerdoc = UniverDoc.newInstance(config.coreConfig);
-
- univerdoc.installPlugin(new RenderEngine());
- univerdoc.installPlugin(new UniverComponentSheet());
- univerdoc.installPlugin(new DocPlugin(config.baseDocsConfig));
-
- return univerdoc;
- }
-}
-/**
- * Wrapped into a function,easy to use
- * @param config
- * @returns
- */
-const univerDocCustom = function (config?: IDocPropsCustom) {
- return new UniverDocCustom().init(config);
-};
-
-interface ISlidePropsCustom {
- coreConfig?: Partial<ISlideData>;
- baseSlidesConfig?: ISlidePluginConfig;
-}
-
-/**
- * Initialize the core and all plugins
- */
-class UniverSlideCustom {
- constructor() {}
- init(config: ISlidePropsCustom = {}): UniverSlide {
- const universlide = UniverSlide.newInstance(config.coreConfig);
-
- universlide.installPlugin(new RenderEngine());
- universlide.installPlugin(new UniverComponentSheet());
- universlide.installPlugin(new SlidePlugin(config.baseSlidesConfig));
-
- return universlide;
- }
-}
-/**
- * Wrapped into a function,easy to use
- * @param config
- * @returns
- */
-const univerSlideCustom = function (config?: ISlidePropsCustom) {
- return new UniverSlideCustom().init(config);
-};
-
-export {UniverCore, univerSheetCustom,univerDocCustom,univerSlideCustom, DEFAULT_WORKBOOK_DATA };
diff --git a/package.json b/package.json
index b4a61aadd7..84781dbf8b 100644
--- a/package.json
+++ b/package.json
@@ -8,12 +8,14 @@
"test:ui": "pnpm run --filter @univer/style-universheet test",
"test:e2e": "pnpm run --filter @univer/base-sheets test:play",
"dev": "node scripts/dev",
+ "dev:demo": "pnpm run --filter univer-sheet-ts dev",
"dev:doc": "pnpm run --filter @univer/base-docs dev",
"dev:slide": "pnpm run --filter @univer/base-slides dev",
"d": "pnpm run --filter univer-vanilla-ts dev",
"api": "node scripts/api",
"lighthouse-dev": "start /B node scripts/dev && lighthouse http://127.0.0.1:3103 --output html --output-path ./report.html",
"build": "node scripts/build.js",
+ "build:demo": "pnpm run --filter univer-sheet-ts build:demo",
"link": "node scripts/link.js",
"build:customd": "cd cli/src/templates/univer-custom-build && npm run build:d",
"clean": "npm cache clean --force && pnpm dlx rimraf node_modules **/node_modules/ package-lock.json yarn.lock pnpm-lock.yaml && pnpm install && pnpm dlx playwright install",
diff --git a/packages/base-sheets/index.html b/packages/base-sheets/index.html
index 52903d275e..432d28ef89 100644
--- a/packages/base-sheets/index.html
+++ b/packages/base-sheets/index.html
@@ -17,9 +17,9 @@
<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: 50vh;"></div> -->
- <!-- <div id="universheet-demo-down" style="height: 50vh;"></div> -->
+ <!-- <div id="universheet-demo-demo" style="height: 100vh;"></div> -->
+ <div id="universheet-demo-up" style="height: 50vh;"></div>
+ <div id="universheet-demo-down" style="height: 50vh;"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
diff --git a/packages/base-sheets/package.json b/packages/base-sheets/package.json
index 906001a80d..44466f9671 100644
--- a/packages/base-sheets/package.json
+++ b/packages/base-sheets/package.json
@@ -52,9 +52,7 @@
"@univer/base-component": "workspace:^0.0.1",
"@univer/base-render": "workspace:^0.0.1",
"@univer/common-plugin-data": "workspace:^0.0.1",
- "@univer/common-plugin-register": "workspace:^0.0.1",
"@univer/core": "workspace:^0.0.1",
- "@univer/sheets-plugin-clipboard": "workspace:^0.0.1",
"@univer/sheets-plugin-formula": "workspace:^0.0.1",
"@univer/sheets-plugin-numfmt": "workspace:^0.0.1",
"@univer/style-universheet": "workspace:^0.0.1",
diff --git a/packages/base-sheets/src/main.tsx b/packages/base-sheets/src/main.tsx
index 3dbb4b423e..d6f970974a 100644
--- a/packages/base-sheets/src/main.tsx
+++ b/packages/base-sheets/src/main.tsx
@@ -4,7 +4,6 @@ import { UniverComponentSheet } from '@univer/style-universheet';
import { NumfmtPlugin } from '@univer/sheets-plugin-numfmt';
import { DEFAULT_WORKBOOK_DATA, DEFAULT_WORKBOOK_DATA_DEMO, DEFAULT_WORKBOOK_DATA_DOWN } from '@univer/common-plugin-data';
import { DEFAULT_FORMULA_DATA, DEFAULT_FORMULA_DATA_DEMO, FormulaPlugin } from '@univer/sheets-plugin-formula';
-import { ClipboardPlugin } from '@univer/sheets-plugin-clipboard';
import { SheetPlugin } from './SheetPlugin';
const uiDefaultConfigUp = {
@@ -132,29 +131,28 @@ 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 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));
-univerSheetDemo.installPlugin(new ClipboardPlugin());
-FormulaPlugin.create(DEFAULT_FORMULA_DATA_DEMO).installTo(univerSheetDemo);
+// 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-sheets/vite.config.ts b/packages/base-sheets/vite.config.ts
index 644c35f398..74d47bb5c4 100644
--- a/packages/base-sheets/vite.config.ts
+++ b/packages/base-sheets/vite.config.ts
@@ -16,7 +16,7 @@ export default defineConfig({
fileName: 'univer-base-sheets',
},
outDir: './lib',
- sourcemap: true
+ sourcemap: true,
},
define: {
pkgJson: { name, version },
@@ -58,7 +58,7 @@ export default defineConfig({
'@univer/base-component': '@univer/base-component',
'@univer/style-universheet': '@univer/style-universheet',
'css-vars-ponyfill': 'css-vars-ponyfill',
- 'nanoid': 'nanoid',
+ nanoid: 'nanoid',
preact: 'preact',
react: 'react',
},