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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
build(cli): add common-plugin template
dushusirb61c2d936d50
diff --git a/cli/src/templates/common-plugin/.eslintrc.js b/cli/src/templates/common-plugin/.eslintrc.jsnew file mode 100644index 0000000000..7f4cf3e7ba--- /dev/null+++ b/cli/src/templates/common-plugin/.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/cli/src/templates/common-plugin/.gitignore b/cli/src/templates/common-plugin/.gitignorenew file mode 100644index 0000000000..12e1bd6bec--- /dev/null+++ b/cli/src/templates/common-plugin/.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.localdiff --git a/cli/src/templates/common-plugin/.prettierrc.cjs b/cli/src/templates/common-plugin/.prettierrc.cjsnew file mode 100644index 0000000000..6604107223--- /dev/null+++ b/cli/src/templates/common-plugin/.prettierrc.cjs@@ -0,0 +1,7 @@+module.exports = {+ singleQuote: true,+ trailingComma: 'es5',+ tabWidth: 4,+ semi: true,+ printWidth: 180,+};diff --git a/cli/src/templates/common-plugin/README-zh.md b/cli/src/templates/common-plugin/README-zh.mdnew file mode 100644index 0000000000..ce9ee6ae8e--- /dev/null+++ b/cli/src/templates/common-plugin/README-zh.md@@ -0,0 +1,55 @@+# style-universheet++简体中文 | [English](./README.md)++## 介绍++UniverSheet <%= projectUpperValue %>插件++### 安装++```bash+npm i @univer/<%= projectName %>+```++### 使用++```js+impport {<%= projectUpperValue %>} from '@univer/<%= projectName %>'++const univerSheet = new UniverSheet();+univerSheet.installPlugin(new <%= projectUpperValue %>());+```++## 本地开发++### 环境++- [Node.js](https://nodejs.org/en/) Version >= 10+- [npm](https://www.npmjs.com/) Version >= 6++### 安装++```+pnpm install+```++### 开发++```+# 当前目录 ./packages/<%= projectName %>/+npm run dev++# 或者项目根目录 ./+pnpm run --filter @univer/<%= projectName %> dev+```++### 打包++```+# 当前目录 ./packages/<%= projectName %>/+npm run build++# 或者根目录 ./+pnpm run --filter @univer/<%= projectName %> build+```diff --git a/cli/src/templates/common-plugin/README.md b/cli/src/templates/common-plugin/README.mdnew file mode 100644index 0000000000..36a4be688c--- /dev/null+++ b/cli/src/templates/common-plugin/README.md@@ -0,0 +1,55 @@+# style-universheet++English| [简体中文](./README-zh.md)++## Introduction++UniverSheet Plugin <%= projectUpperValue %>++### Installation++```bash+npm i @univer/<%= projectName %>+```++### Usage++```js+impport {<%= projectUpperValue %>} from '@univer/<%= projectName %>'++const univerSheet = new UniverSheet();+univerSheet.installPlugin(new <%= projectUpperValue %>());+```++## 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/<%= projectName %>/+npm run dev++# Or project root directory ./+pnpm run --filter @univer/<%= projectName %> dev+```++### Package++```+# Current directory ./packages/<%= projectName %>/+npm run build++# Or root directory ./+pnpm run --filter @univer/<%= projectName %> build+```diff --git a/cli/src/templates/common-plugin/index.html b/cli/src/templates/common-plugin/index.htmlnew file mode 100644index 0000000000..d8d577832d--- /dev/null+++ b/cli/src/templates/common-plugin/index.html@@ -0,0 +1,26 @@+<!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="position:absolute;z-index: 99999;"></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 filediff --git a/cli/src/templates/common-plugin/jest.config.js b/cli/src/templates/common-plugin/jest.config.jsnew file mode 100644index 0000000000..73ef4bae42--- /dev/null+++ b/cli/src/templates/common-plugin/jest.config.js@@ -0,0 +1,18 @@+/** @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.test.json',+ },+ },+};diff --git a/cli/src/templates/common-plugin/package.json b/cli/src/templates/common-plugin/package.jsonnew file mode 100644index 0000000000..c98efd4b85--- /dev/null+++ b/cli/src/templates/common-plugin/package.json@@ -0,0 +1,69 @@+{+ "name": "@univer/<%= projectName %>",+ "version": "0.0.1",+ "description": "UniverSheet normal <%= projectName %>",+ "keywords": [],+ "author": "DreamNum <[email protected]>",+ "license": "MIT",+ "main": "./lib/univer-<%= projectName %>.cjs.js",+ "module": "./lib/univer-<%= projectName %>.es.js",+ "browser": {+ "./lib/univer-<%= projectName %>.cjs.js": "./src/index.ts",+ "./lib/univer-<%= projectName %>.es.js": "./src/index.ts"+ },+ "types": "./src/Types/index.d.ts",+ "exports": {+ ".": {+ "import": {+ "node": "./lib/univer-<%= projectName %>.cjs.js",+ "default": "./lib/univer-<%= projectName %>.es.js"+ },+ "require": "./lib/univer-<%= projectName %>.cjs.js",+ "types": "./lib/univer-<%= projectName %>.d.ts"+ },+ "./*": "./src/*"+ },+ "directories": {+ "lib": "lib"+ },+ "scripts": {+ "test": "jest",+ "dev": "vite",+ "build": "tsc && vite build",+ "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.0.1",+ "@types/node": "^16.4.6",+ "@vitejs/plugin-legacy": "^1.5.1",+ "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-prettier": "^3.4.0",+ "eslint-plugin-jsx-a11y": "^6.5.1",+ "eslint-plugin-react": "^7.28.0",+ "eslint-plugin-react-hooks": "^4.3.0",+ "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"+ },+ "dependencies": {+ "@univer/common-plugin-data": "workspace:^0.0.1",+ "@univer/base-component": "workspace:^0.0.1",+ "@univer/base-render": "workspace:^0.0.1",+ "@univer/core": "workspace:^0.0.1",+ "@univer/base-sheets": "workspace:^0.0.1",+ "@univer/base-docs": "workspace:^0.0.1",+ "@univer/base-slides": "workspace:^0.0.1",+ "@univer/style-universheet": "workspace:^0.0.1",+ "preact": "^10.5.14"+ }+}diff --git a/cli/src/templates/common-plugin/src/Basic/Const/PLUGIN_NAME.ts b/cli/src/templates/common-plugin/src/Basic/Const/PLUGIN_NAME.tsnew file mode 100644index 0000000000..5964f8ac95--- /dev/null+++ b/cli/src/templates/common-plugin/src/Basic/Const/PLUGIN_NAME.ts@@ -0,0 +1 @@+export const <%= projectConstantValue %>_PLUGIN_NAME = '<%= projectValue %>';diff --git a/cli/src/templates/common-plugin/src/Basic/Const/index.ts b/cli/src/templates/common-plugin/src/Basic/Const/index.tsnew file mode 100644index 0000000000..e69de29bb2diff --git a/cli/src/templates/common-plugin/src/Basic/Enum/index.ts b/cli/src/templates/common-plugin/src/Basic/Enum/index.tsnew file mode 100644index 0000000000..e69de29bb2diff --git a/cli/src/templates/common-plugin/src/Basic/Shared/index.ts b/cli/src/templates/common-plugin/src/Basic/Shared/index.tsnew file mode 100644index 0000000000..e69de29bb2diff --git a/cli/src/templates/common-plugin/src/Basic/index.ts b/cli/src/templates/common-plugin/src/Basic/index.tsnew file mode 100644index 0000000000..640d1bb8b3--- /dev/null+++ b/cli/src/templates/common-plugin/src/Basic/index.ts@@ -0,0 +1,4 @@+export * from './Const';+export * from './Enum';+export * from '../Locale';+export * from './Shared';diff --git a/cli/src/templates/common-plugin/src/Controller/index.ts b/cli/src/templates/common-plugin/src/Controller/index.tsnew file mode 100644index 0000000000..e69de29bb2diff --git a/cli/src/templates/common-plugin/src/Locale/en.ts b/cli/src/templates/common-plugin/src/Locale/en.tsnew file mode 100644index 0000000000..7c550a79a9--- /dev/null+++ b/cli/src/templates/common-plugin/src/Locale/en.ts@@ -0,0 +1,9 @@+export default {+ <%= projectValue %>Label: '<%= projectUpperValue %>',+ <%= projectValue %>RightLabel: 'more <%= projectUpperValue %>',+ <%= projectValue %>: {+ one:'one',+ two:'two',+ three:'three',+ },+};diff --git a/cli/src/templates/common-plugin/src/Locale/index.ts b/cli/src/templates/common-plugin/src/Locale/index.tsnew file mode 100644index 0000000000..3ac4bcd0fd--- /dev/null+++ b/cli/src/templates/common-plugin/src/Locale/index.ts@@ -0,0 +1,4 @@+import zh from './zh';+import en from './en';++export { zh, en };diff --git a/cli/src/templates/common-plugin/src/Locale/zh.ts b/cli/src/templates/common-plugin/src/Locale/zh.tsnew file mode 100644index 0000000000..eaecc5a5b7--- /dev/null+++ b/cli/src/templates/common-plugin/src/Locale/zh.ts@@ -0,0 +1,9 @@+export default {+ <%= projectValue %>Label: '插件',+ <%= projectValue %>RightLabel: '更多 <%= projectUpperValue %>',+ <%= projectValue %>: {+ one:'一',+ two:'二',+ three:'三',+ },+};diff --git a/cli/src/templates/common-plugin/src/Model/index.ts b/cli/src/templates/common-plugin/src/Model/index.tsnew file mode 100644index 0000000000..e69de29bb2diff --git a/cli/src/templates/common-plugin/src/Service/index.ts b/cli/src/templates/common-plugin/src/Service/index.tsnew file mode 100644index 0000000000..e69de29bb2diff --git a/cli/src/templates/common-plugin/src/SortPlugin.tsx b/cli/src/templates/common-plugin/src/SortPlugin.tsxnew file mode 100644index 0000000000..a727e0dd95--- /dev/null+++ b/cli/src/templates/common-plugin/src/SortPlugin.tsx@@ -0,0 +1,55 @@+import { Context, Plugin, PLUGIN_NAMES, UniverSheet, UniverDoc, UniverSlide } from '@univer/core';+import { <%= projectUpperValue %>Button } from './View/UI/<%= projectUpperValue %>Button';+import { zh, en } from './Locale';++import { IToolBarItemProps, ISlotElement } from '@univer/base-component';+import { IOCContainer } from '@univer/core';+import { SheetPlugin } from '@univer/base-sheets';+import { <%= projectConstantValue %>_PLUGIN_NAME} from './Basic/Const/PLUGIN_NAME'++export interface I<%= projectUpperValue %>PluginConfig {}++export class <%= projectUpperValue %>Plugin extends Plugin {++ constructor(config ?: IPluginConfig) {+ super(<%= projectConstantValue %>_PLUGIN_NAME);+ }++ static create(config?: I<%= projectUpperValue %>PluginConfig) {+ return new <%= projectUpperValue %>Plugin(config);+ }++ installTo(univerInstance: UniverSheet | UniverDoc | UniverSlide) {+ univerInstance.installPlugin(this);+ }++ initialize(): void {++ const context = this.getContext();++ /**+ * load more Locale object+ */+ context.getLocale().load({+ en: en,+ zh: zh,+ });+++ // const item: IToolBarItemProps = {+ // locale: '<%= projectValue %>',+ // type: ISlotElement.JSX,+ // show: true,+ // label: <<%= projectUpperValue %>Button />+ // }+ // context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.addToolButton(item)+}++onMapping(IOC: IOCContainer): void {}++onMounted(ctx: Context): void {+ this.initialize()+}++onDestroy(): void {}+}diff --git a/cli/src/templates/common-plugin/src/Types/index.d.ts b/cli/src/templates/common-plugin/src/Types/index.d.tsnew file mode 100644index 0000000000..9820ab8ea2--- /dev/null+++ b/cli/src/templates/common-plugin/src/Types/index.d.ts@@ -0,0 +1,10 @@+/// <reference types="vite/client" />++export * from '../index';+declare module '@univer/<%= projectName %>' {}++// use css module+declare module '*.less' {+ const resource: { [key: string]: string };+ export = resource;+}diff --git a/cli/src/templates/common-plugin/src/Types/preact.d.ts b/cli/src/templates/common-plugin/src/Types/preact.d.tsnew file mode 100644index 0000000000..0d092b3751--- /dev/null+++ b/cli/src/templates/common-plugin/src/Types/preact.d.ts@@ -0,0 +1,4 @@+/// <reference types="enzyme-adapter-preact-pure" />+import JSX = preact.JSX;++declare module 'enzyme';diff --git a/cli/src/templates/common-plugin/src/View/Render/index.ts b/cli/src/templates/common-plugin/src/View/Render/index.tsnew file mode 100644index 0000000000..e69de29bb2diff --git a/cli/src/templates/common-plugin/src/View/UI/SortButton.tsx b/cli/src/templates/common-plugin/src/View/UI/SortButton.tsxnew file mode 100644index 0000000000..725533bf60--- /dev/null+++ b/cli/src/templates/common-plugin/src/View/UI/SortButton.tsx@@ -0,0 +1,104 @@+import { Nullable, Observer } from '@univer/core';+import { ISelectButton, IToolBarItemProps, Component, BaseSelectProps } from '@univer/base-component';++interface IProps {}+// Types for state+interface IState {+ <%= projectValue %>: IToolBarItemProps;+}++export class <%= projectUpperValue %>Button extends Component<IProps, IState> {++ private _localeObserver: Nullable<Observer<void>>;+ initialize(props: IProps) {++ const OrderASCIcon = this.getComponentRender().renderFunction('OrderASCIcon');+ const OrderDESCIcon = this.getComponentRender().renderFunction('OrderDESCIcon');+ const OrderIcon = this.getComponentRender().renderFunction('OrderIcon');+ const NextIcon = this.getComponentRender().renderFunction('NextIcon');++ const <%= projectValue %>: IToolBarItemProps = {+ locale: '<%= projectValue %>',+ type: 'select',+ label: <OrderASCIcon />,+ icon: <NextIcon />,+ show: true,+ border: false,+ selectType: ISelectButton.DOUBLE,+ needChange: false,+ children: [+ {+ locale: '<%= projectValue %>.one',+ icon: <OrderASCIcon />,+ },+ {+ locale: '<%= projectValue %>.two',+ icon: <OrderDESCIcon />,+ },+ {+ locale: '<%= projectValue %>.three',+ icon: <OrderIcon />,+ },+ ],+ };++ this.state = {+ <%= projectValue %>: <%= projectValue %>,+ };+ }++ /**+ * init+ */+ componentWillMount() {+ this.setLocale();++ // subscribe Locale change event++ this._localeObserver = this._context.getObserverManager().getObserver('onAfterChangeUILocaleObservable','core')?.add(() => {+ this.setLocale();+ });+ }+ /**+ * destory+ */+ componentWillUnmount() {+ // this._context.getObserverManager().getObserver('onAfterChangeUILocaleObservable','core')?.remove(this._localeObserver);+ }+ /**+ * set text by config setting and Locale message+ */+ setLocale() {+ const locale = this._context.getLocale();+ this.setState((prevState: IState) => {+ let item = prevState.<%= projectValue %>;+ // set current Locale string for tooltip+ item.tooltip = locale.get(`${item.locale}Label`);+ item.tooltipRight = locale.get(`${item.locale}RightLabel`);++ // set current Locale string for select+ item.children?.forEach((ele: IToolBarItemProps) => {+ if (ele.locale) {+ ele.label = locale.get(`${ele.locale}`);+ }+ });+ item.label = typeof item.label == 'object' ? item.label : item.children![0].label;++ return {+ <%= projectValue %>: item,+ };+ });+ }++ /**+ * Render the component's HTML+ *+ * @returns {void}+ */+ render(props: IProps, state: IState) {+ const { <%= projectValue %> } = state;+ const Select = this.getComponentRender().renderFunction('Select');+ // Set Provider for entire Container+ return <Select tooltip={<%= projectValue %>.tooltip} tooltipRight={<%= projectValue %>.tooltipRight} border={<%= projectValue %>.border} needChange={<%= projectValue %>.needChange} key={<%= projectValue %>.locale} children={<%= projectValue %>.children as BaseSelectProps[]} label={<%= projectValue %>.label} icon={<%= projectValue %>.icon} />;+ }+}diff --git a/cli/src/templates/common-plugin/src/index.ts b/cli/src/templates/common-plugin/src/index.tsnew file mode 100644index 0000000000..245449c0b4--- /dev/null+++ b/cli/src/templates/common-plugin/src/index.ts@@ -0,0 +1,3 @@+import { <%= projectUpperValue %>Plugin } from './<%= projectUpperValue %>Plugin';++export { <%= projectUpperValue %>Plugin };diff --git a/cli/src/templates/common-plugin/src/main.tsx b/cli/src/templates/common-plugin/src/main.tsxnew file mode 100644index 0000000000..17a9b29d35--- /dev/null+++ b/cli/src/templates/common-plugin/src/main.tsx@@ -0,0 +1,53 @@+import { UniverSheet, UniverDoc, UniverSlide } from '@univer/core';+import { RenderEngine } from '@univer/base-render';+import { SheetPlugin } from '@univer/base-sheets';+import { DocPlugin } from '@univer/base-docs';+import { SlidePlugin } from '@univer/base-slides';+import { UniverComponentSheet } from '@univer/style-universheet';+import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';++import { <%= projectUpperValue %>Plugin } from './<%= projectUpperValue %>Plugin';++// sheet+const sheetPluginConfig = {+ container: 'universheet',+ layout: 'auto',+};++const univerSheet = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);++univerSheet.installPlugin(new RenderEngine());+univerSheet.installPlugin(new UniverComponentSheet());++univerSheet.installPlugin(new SheetPlugin(sheetPluginConfig));+univerSheet.installPlugin(new <%= projectUpperValue %>Plugin());++// doc++const docPluginConfig = {+ container: 'univerdoc',+ layout: 'auto',+};+const univerDoc = UniverDoc.newInstance();++univerDoc.installPlugin(new RenderEngine());+univerDoc.installPlugin(new UniverComponentSheet());++univerDoc.installPlugin(new DocPlugin(docPluginConfig));+univerDoc.installPlugin(new <%= projectUpperValue %>Plugin());+++// SlidePlugin++const slidePluginConfig = {+ container: 'universlide',+ layout: 'auto'+};++const univerSlide = UniverSlide.newInstance();++univerSlide.installPlugin(new RenderEngine());+univerSlide.installPlugin(new UniverComponentSheet());++univerSlide.installPlugin(new SlidePlugin(slidePluginConfig));+univerSlide.installPlugin(new <%= projectUpperValue %>Plugin());diff --git a/cli/src/templates/common-plugin/tsconfig.json b/cli/src/templates/common-plugin/tsconfig.jsonnew file mode 100644index 0000000000..fc81cbd47e--- /dev/null+++ b/cli/src/templates/common-plugin/tsconfig.json@@ -0,0 +1,31 @@+{+ "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,++ "baseUrl": "./",+ "skipLibCheck": true,+ "esModuleInterop": true, // auto allowSyntheticDefaultImports tru+ "suppressImplicitAnyIndexErrors": true,+ "experimentalDecorators": true,+ "jsx": "preserve",+ "jsxFactory": "h",+ "jsxFragmentFactory": "Fragment",+ "strictPropertyInitialization": false,+ "types": ["jest", "node", "@types/jest"]+ },+ "include": ["src/**/*", "test/**/*.test.(ts|tsx|js)"]+}diff --git a/cli/src/templates/common-plugin/tsconfig.ref.json b/cli/src/templates/common-plugin/tsconfig.ref.jsonnew file mode 100644index 0000000000..0c86b2c554--- /dev/null+++ b/cli/src/templates/common-plugin/tsconfig.ref.json@@ -0,0 +1,7 @@+{+ "extends": "./tsconfig.json",+ "include": ["src/**/*"],+ "compilerOptions": {+ "composite": true+ }+}diff --git a/cli/src/templates/common-plugin/tsconfig.test.json b/cli/src/templates/common-plugin/tsconfig.test.jsonnew file mode 100644index 0000000000..a2ac02c4ae--- /dev/null+++ b/cli/src/templates/common-plugin/tsconfig.test.json@@ -0,0 +1,7 @@+{+ "extends": "./tsconfig.json",+ "compilerOptions": {+ "jsx": "react-jsx",+ "jsxImportSource": "preact"+ }+}diff --git a/cli/src/templates/common-plugin/vite.config.ts b/cli/src/templates/common-plugin/vite.config.tsnew file mode 100644index 0000000000..020ecd6209--- /dev/null+++ b/cli/src/templates/common-plugin/vite.config.ts@@ -0,0 +1,44 @@+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'],+ // 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/cli/src/templates/sheets-plugin/package.json b/cli/src/templates/sheets-plugin/package.jsonindex 824406dccb..f67a9d8f8a 100644--- a/cli/src/templates/sheets-plugin/package.json+++ b/cli/src/templates/sheets-plugin/package.json@@ -56,11 +56,11 @@"vite": "^2.4.4"},"dependencies": {+ "@univer/common-plugin-data": "workspace:^0.0.1","@univer/base-component": "workspace:^0.0.1","@univer/base-render": "workspace:^0.0.1","@univer/core": "workspace:^0.0.1","@univer/base-sheets": "workspace:^0.0.1",- "@univer/sheets-plugin-filter": "workspace:^0.0.1","@univer/style-universheet": "workspace:^0.0.1","preact": "^10.5.14"}diff --git a/cli/src/templates/sheets-plugin/src/SortPlugin.tsx b/cli/src/templates/sheets-plugin/src/SortPlugin.tsxindex 0502e4babe..5818d95a7f 100644--- a/cli/src/templates/sheets-plugin/src/SortPlugin.tsx+++ b/cli/src/templates/sheets-plugin/src/SortPlugin.tsx@@ -41,7 +41,7 @@ export class <%= projectUpperValue %>Plugin extends Plugin {show: true,label: <<%= projectUpperValue %>Button />}- context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.addButton(item)+ context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.addToolButton(item)}onMapping(IOC: IOCContainer): void {}diff --git a/cli/src/templates/sheets-plugin/src/main.tsx b/cli/src/templates/sheets-plugin/src/main.tsxindex bacb968b69..47249c6780 100644--- a/cli/src/templates/sheets-plugin/src/main.tsx+++ b/cli/src/templates/sheets-plugin/src/main.tsx@@ -1,9 +1,9 @@-import { defaultWorkbookData, UniverSheet } from '@univer/core';+import { UniverSheet } from '@univer/core';import { RenderEngine } from '@univer/base-render';import { SheetPlugin } from '@univer/base-sheets';import { UniverComponentSheet } from '@univer/style-universheet';+import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';-import { FilterPlugin } from '@univer/sheets-plugin-filter';import { <%= projectUpperValue %>Plugin } from './<%= projectUpperValue %>Plugin';@@ -12,11 +12,10 @@ const uiDefaultConfigUp = {layout: 'auto',};-const univerSheetUp = UniverSheet.newInstance(defaultWorkbookData);+const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());univerSheetUp.installPlugin(new SheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(new FilterPlugin());univerSheetUp.installPlugin(new <%= projectUpperValue %>Plugin());