From beb196f4cc5ca22717461c0663ec5465987b3f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E7=86=B1?= Date: Tue, 6 Jan 2026 13:07:30 +0800 Subject: [PATCH] chore: remove experimental packages from pnpm workspace and simplify vitest configuration (#6422) --- .release-it.json | 3 +- .vscode/settings.json | 4 +- CONTRIBUTING.md | 1 - .../debugger/README.md | 0 .../debugger/package.json | 0 .../debugger/postcss.config.mjs | 0 .../debugger/src/components/FloatButton.tsx | 0 .../debugger/src/components/Image.tsx | 0 .../debugger/src/components/RangeLoading.tsx | 0 .../debugger/src/components/VueComponent.vue | 0 .../debugger/src/components/WebComponent.ts | 0 .../debugger/src/controllers/config.schema.ts | 0 .../src/controllers/debugger.controller.ts | 0 .../src/controllers/e2e/data/default-doc.ts | 0 .../src/controllers/e2e/data/default-sheet.ts | 0 .../src/controllers/e2e/e2e.controller.ts | 0 .../local-save/record.controller.ts | 0 .../src/controllers/local-save/util.ts | 0 .../performance-monitor.controller.ts | 0 .../controllers/watermark.menu.controller.ts | 0 .../debugger/src/global.css | 0 .../debugger/src/index.ts | 0 .../debugger/src/plugin.ts | 0 .../debugger/src/views/Fab.tsx | 0 .../src/views/test-editor/component-name.ts | 0 .../debugger/src/views/use-cell-content.ts | 0 .../debugger/src/views/use-dark-mode.ts | 0 .../debugger/src/views/use-dialog.ts | 0 .../debugger/src/views/use-dispose.ts | 0 .../debugger/src/views/use-editable.ts | 0 .../debugger/src/views/use-floating-dom.ts | 0 .../debugger/src/views/use-locale.ts | 0 .../debugger/src/views/use-message.ts | 0 .../debugger/src/views/use-notification.ts | 0 .../debugger/src/views/use-sidebar.ts | 0 .../debugger/src/views/use-snapshot.ts | 0 .../debugger/src/views/use-theme.ts | 0 .../debugger/src/views/use-units.ts | 0 .../debugger/src/views/use-user.ts | 0 .../debugger/src/views/use-watermark.ts | 0 .../views/watermark/WatermarkImageSetting.tsx | 0 .../src/views/watermark/WatermarkPanel.tsx | 0 .../views/watermark/WatermarkPanelFooter.tsx | 0 .../views/watermark/WatermarkTextSetting.tsx | 0 .../debugger/src/vite-env.d.ts | 0 .../debugger/tailwind.config.ts | 0 .../debugger/tsconfig.json | 0 .../debugger/tsconfig.node.json | 0 .../debugger/vitest.config.ts | 0 {mockdata => common/mockdata}/.gitignore | 0 {mockdata => common/mockdata}/README.md | 0 {mockdata => common/mockdata}/package.json | 1 - .../mockdata}/scripts/generate-locales.ts | 12 +- .../src/docs/default-document-data-cn.ts | 0 .../src/docs/default-document-data-dreamer.ts | 0 .../src/docs/default-document-data-en.ts | 0 .../src/docs/default-document-data.ts | 0 .../src/docs/default-document.data-simple.ts | 0 .../mockdata}/src/docs/index.ts | 0 {mockdata => common/mockdata}/src/index.ts | 0 .../src/sheets/default-workbook-data.ts | 0 .../default-workbook-data-default-style.ts | 0 .../sheets/demo/default-workbook-data-demo.ts | 0 .../demo/default-workbook-data-demo1.ts | 0 .../demo/default-workbook-data-demo2.ts | 0 .../demo/default-workbook-data-demo3.ts | 0 .../demo/default-workbook-data-demo4.ts | 0 .../demo/default-workbook-data-demo5.ts | 0 .../demo/default-workbook-data-demo6.ts | 0 .../demo/default-workbook-data-demo7.ts | 0 .../demo/default-workbook-data-demo8.ts | 0 .../demo/default-workbook-data-validation.ts | 0 .../mockdata}/src/sheets/demo/index.ts | 0 .../mockdata}/src/sheets/index.ts | 0 .../src/sheets/slide-workbook-data.ts | 0 .../mockdata}/src/sheets/uniscript-data.ts | 0 .../src/slides/default-pages/page1.ts | 0 .../src/slides/default-pages/page2.ts | 0 .../src/slides/default-pages/page3.ts | 0 .../src/slides/default-pages/page4.ts | 0 .../src/slides/default-pages/page5.ts | 0 .../src/slides/default-pages/page6.ts | 0 .../src/slides/default-pages/page7.ts | 0 .../src/slides/default-slide-data.ts | 0 .../mockdata}/src/slides/index.ts | 0 .../src/slides/rich-text/page3-richtext1.ts | 0 .../src/slides/rich-text/page3-richtext2.ts | 0 .../src/slides/rich-text/page3-richtext3.ts | 0 .../src/slides/rich-text/page5-richtext1.ts | 0 .../src/slides/unlimited-slide-data.ts | 0 {mockdata => common/mockdata}/tsconfig.json | 0 common/shared/vitest/index.js | 1 - common/storybook/tailwind.config.ts | 1 - e2e/e2e.d.ts | 2 +- examples/esbuild.config.ts | 5 - examples/package.json | 6 - examples/src/main.tsx | 3 - examples/src/uni/lazy.ts | 39 - examples/src/uni/main.ts | 159 --- examples/src/uni/worker.ts | 31 - examples/tailwind.config.ts | 3 +- packages-experimental/README.md | 4 - packages-experimental/uni-docs-ui/README.md | 16 - .../uni-docs-ui/package.json | 79 -- .../uni-docs-ui/postcss.config.mjs | 1 - .../src/controllers/menu.schema.ts | 52 - .../uni-docs-ui/src/controllers/menu.ts | 272 ------ .../src/controllers/uni-docs-ui.controller.ts | 95 -- .../uni-docs-ui/src/index.ts | 17 - .../uni-docs-ui/src/vite-env.d.ts | 1 - .../uni-docs-ui/tailwind.config.ts | 27 - .../uni-docs-ui/tsconfig.json | 15 - .../uni-docs-ui/tsconfig.node.json | 4 - .../uni-docs-ui/vitest.config.ts | 3 - .../uni-formula-ui/README.md | 16 - .../uni-formula-ui/package.json | 92 -- .../uni-formula-ui/postcss.config.mjs | 1 - .../src/commands/commands/doc.command.ts | 102 -- .../src/commands/commands/slide.command.ts | 75 -- .../src/commands/operations/operation.ts | 78 -- .../uni-formula-ui/src/const.ts | 17 - .../doc-formula-input.controller.ts | 188 ---- .../slide-formula-input.controller.ts | 114 --- .../controllers/uni-formula-ui.controller.ts | 37 - .../uni-formula-ui/src/global.css | 2 - .../uni-formula-ui/src/index.ts | 20 - .../uni-formula-ui/src/locale/ca-ES.ts | 38 - .../uni-formula-ui/src/locale/en-US.ts | 36 - .../uni-formula-ui/src/locale/es-ES.ts | 38 - .../uni-formula-ui/src/locale/fa-IR.ts | 38 - .../uni-formula-ui/src/locale/fr-FR.ts | 38 - .../uni-formula-ui/src/locale/ja-JP.ts | 38 - .../uni-formula-ui/src/locale/ko-KR.ts | 38 - .../uni-formula-ui/src/locale/ru-RU.ts | 38 - .../uni-formula-ui/src/locale/vi-VN.ts | 38 - .../uni-formula-ui/src/locale/zh-CN.ts | 38 - .../uni-formula-ui/src/locale/zh-TW.ts | 38 - .../uni-formula-ui/src/plugin.ts | 65 -- .../src/services/formula-popup.service.ts | 178 ---- .../slide-ui-formula-cache.service.ts | 76 -- .../src/services/uni-formula.service.ts | 430 --------- .../src/views/components/DocFormulaPopup.tsx | 159 --- .../uni-formula-ui/src/vite-env.d.ts | 1 - .../uni-formula-ui/tailwind.config.ts | 27 - .../uni-formula-ui/tsconfig.json | 15 - .../uni-formula-ui/tsconfig.node.json | 4 - .../uni-formula-ui/vitest.config.ts | 3 - packages-experimental/uni-formula/README.md | 16 - .../uni-formula/package.json | 67 -- .../mutations/doc-formula.mutation.ts | 78 -- .../mutations/slide-formua.mutation.ts | 58 -- .../uni-formula/src/const.ts | 19 - .../src/controller/uni-formula.controller.ts | 34 - .../uni-formula/src/index.ts | 29 - .../uni-formula/src/models/doc-formula.ts | 55 -- .../uni-formula/src/models/slide-formula.ts | 50 - .../uni-formula/src/plugin.ts | 45 - .../src/services/uni-formula.service.ts | 216 ----- .../uni-formula/src/vite-env.d.ts | 1 - .../uni-formula/tsconfig.json | 15 - .../uni-formula/tsconfig.node.json | 4 - .../uni-formula/vitest.config.ts | 3 - packages-experimental/uni-sheets-ui/README.md | 16 - .../uni-sheets-ui/package.json | 84 -- .../uni-sheets-ui/postcss.config.mjs | 1 - .../src/controllers/menu.schema.ts | 52 - .../uni-sheets-ui/src/controllers/menu.ts | 284 ------ .../controllers/uni-sheets-ui.controller.tsx | 118 --- .../uni-sheets-ui/src/global.css | 2 - .../uni-sheets-ui/src/index.ts | 19 - .../src/views/uni-sheet-bar/UniSheetBar.tsx | 149 --- .../uni-sheets-ui/src/vite-env.d.ts | 1 - .../uni-sheets-ui/tailwind.config.ts | 27 - .../uni-sheets-ui/tsconfig.json | 15 - .../uni-sheets-ui/tsconfig.node.json | 4 - .../uni-sheets-ui/vitest.config.ts | 3 - packages-experimental/uni-slides-ui/README.md | 16 - .../uni-slides-ui/package.json | 80 -- .../uni-slides-ui/postcss.config.mjs | 1 - .../src/controllers/menu.schema.ts | 24 - .../controllers/uni-slides-ui.controller.tsx | 69 -- .../uni-slides-ui/src/global.css | 2 - .../uni-slides-ui/src/index.ts | 19 - .../src/views/UniSlideSideBar.tsx | 145 --- .../uni-slides-ui/src/vite-env.d.ts | 1 - .../uni-slides-ui/tailwind.config.ts | 27 - .../uni-slides-ui/tsconfig.json | 15 - .../uni-slides-ui/tsconfig.node.json | 4 - .../uni-slides-ui/vitest.config.ts | 3 - packages-experimental/uniui/README.md | 16 - packages-experimental/uniui/package.json | 86 -- .../uniui/postcss.config.mjs | 1 - .../operations/set-flow-viewport.operation.ts | 51 - .../operations/uni-focus-unit.operation.ts | 33 - .../src/commands/operations/uni.operation.ts | 31 - .../uniui/src/controllers/menu.schema.ts | 109 --- .../uniui/src/controllers/menu.ts | 248 ----- .../controllers/uniui-desktop.controller.tsx | 114 --- .../src/controllers/uniui-flow.controller.tsx | 53 - .../uniui-leftsidebar.controller.tsx | 63 -- .../controllers/uniui-toolbar.controller.tsx | 72 -- .../uniui/src/controllers/utils.ts | 25 - packages-experimental/uniui/src/global.css | 2 - packages-experimental/uniui/src/index.ts | 28 - packages-experimental/uniui/src/plugin.ts | 150 --- .../src/services/flow/flow-manager.service.ts | 73 -- .../services/toolbar/uni-toolbar-service.ts | 125 --- .../services/unit-grid/unit-grid.service.ts | 202 ---- .../uniui/src/views/hooks/title.ts | 33 - .../uniui/src/views/outline/Outline.tsx | 30 - .../src/views/uni-controls/UniControls.tsx | 224 ----- .../src/views/uni-sidebar/UniSidebar.tsx | 151 --- .../src/views/uni-toolbar/UniFloatToolbar.tsx | 132 --- .../src/views/uni-toolbar/UniFormulaBar.tsx | 240 ----- .../src/views/uni-toolbar/UniToolbar.tsx | 87 -- .../src/views/workbench/UniWorkbench.tsx | 385 -------- packages-experimental/uniui/src/vite-env.d.ts | 1 - .../uniui/tailwind.config.ts | 27 - packages-experimental/uniui/tsconfig.json | 15 - .../uniui/tsconfig.node.json | 4 - packages-experimental/uniui/vitest.config.ts | 3 - pnpm-lock.yaml | 908 ++++-------------- pnpm-workspace.yaml | 1 - vitest.workspace.ts | 51 +- 224 files changed, 225 insertions(+), 8393 deletions(-) rename {packages-experimental => common}/debugger/README.md (100%) rename {packages-experimental => common}/debugger/package.json (100%) rename {packages-experimental => common}/debugger/postcss.config.mjs (100%) rename {packages-experimental => common}/debugger/src/components/FloatButton.tsx (100%) rename {packages-experimental => common}/debugger/src/components/Image.tsx (100%) rename {packages-experimental => common}/debugger/src/components/RangeLoading.tsx (100%) rename {packages-experimental => common}/debugger/src/components/VueComponent.vue (100%) rename {packages-experimental => common}/debugger/src/components/WebComponent.ts (100%) rename {packages-experimental => common}/debugger/src/controllers/config.schema.ts (100%) rename {packages-experimental => common}/debugger/src/controllers/debugger.controller.ts (100%) rename {packages-experimental => common}/debugger/src/controllers/e2e/data/default-doc.ts (100%) rename {packages-experimental => common}/debugger/src/controllers/e2e/data/default-sheet.ts (100%) rename {packages-experimental => common}/debugger/src/controllers/e2e/e2e.controller.ts (100%) rename {packages-experimental => common}/debugger/src/controllers/local-save/record.controller.ts (100%) rename {packages-experimental => common}/debugger/src/controllers/local-save/util.ts (100%) rename {packages-experimental => common}/debugger/src/controllers/performance-monitor.controller.ts (100%) rename {packages-experimental => common}/debugger/src/controllers/watermark.menu.controller.ts (100%) rename {packages-experimental => common}/debugger/src/global.css (100%) rename {packages-experimental => common}/debugger/src/index.ts (100%) rename {packages-experimental => common}/debugger/src/plugin.ts (100%) rename {packages-experimental => common}/debugger/src/views/Fab.tsx (100%) rename {packages-experimental => common}/debugger/src/views/test-editor/component-name.ts (100%) rename {packages-experimental => common}/debugger/src/views/use-cell-content.ts (100%) rename {packages-experimental => common}/debugger/src/views/use-dark-mode.ts (100%) rename {packages-experimental => common}/debugger/src/views/use-dialog.ts (100%) rename {packages-experimental => common}/debugger/src/views/use-dispose.ts (100%) rename {packages-experimental => common}/debugger/src/views/use-editable.ts (100%) rename {packages-experimental => common}/debugger/src/views/use-floating-dom.ts (100%) rename {packages-experimental => common}/debugger/src/views/use-locale.ts (100%) rename {packages-experimental => common}/debugger/src/views/use-message.ts (100%) rename {packages-experimental => common}/debugger/src/views/use-notification.ts (100%) rename {packages-experimental => common}/debugger/src/views/use-sidebar.ts (100%) rename {packages-experimental => common}/debugger/src/views/use-snapshot.ts (100%) rename {packages-experimental => common}/debugger/src/views/use-theme.ts (100%) rename {packages-experimental => common}/debugger/src/views/use-units.ts (100%) rename {packages-experimental => common}/debugger/src/views/use-user.ts (100%) rename {packages-experimental => common}/debugger/src/views/use-watermark.ts (100%) rename {packages-experimental => common}/debugger/src/views/watermark/WatermarkImageSetting.tsx (100%) rename {packages-experimental => common}/debugger/src/views/watermark/WatermarkPanel.tsx (100%) rename {packages-experimental => common}/debugger/src/views/watermark/WatermarkPanelFooter.tsx (100%) rename {packages-experimental => common}/debugger/src/views/watermark/WatermarkTextSetting.tsx (100%) rename {packages-experimental => common}/debugger/src/vite-env.d.ts (100%) rename {packages-experimental => common}/debugger/tailwind.config.ts (100%) rename {packages-experimental => common}/debugger/tsconfig.json (100%) rename {packages-experimental => common}/debugger/tsconfig.node.json (100%) rename {packages-experimental => common}/debugger/vitest.config.ts (100%) rename {mockdata => common/mockdata}/.gitignore (100%) rename {mockdata => common/mockdata}/README.md (100%) rename {mockdata => common/mockdata}/package.json (98%) rename {mockdata => common/mockdata}/scripts/generate-locales.ts (84%) rename {mockdata => common/mockdata}/src/docs/default-document-data-cn.ts (100%) rename {mockdata => common/mockdata}/src/docs/default-document-data-dreamer.ts (100%) rename {mockdata => common/mockdata}/src/docs/default-document-data-en.ts (100%) rename {mockdata => common/mockdata}/src/docs/default-document-data.ts (100%) rename {mockdata => common/mockdata}/src/docs/default-document.data-simple.ts (100%) rename {mockdata => common/mockdata}/src/docs/index.ts (100%) rename {mockdata => common/mockdata}/src/index.ts (100%) rename {mockdata => common/mockdata}/src/sheets/default-workbook-data.ts (100%) rename {mockdata => common/mockdata}/src/sheets/demo/default-workbook-data-default-style.ts (100%) rename {mockdata => common/mockdata}/src/sheets/demo/default-workbook-data-demo.ts (100%) rename {mockdata => common/mockdata}/src/sheets/demo/default-workbook-data-demo1.ts (100%) rename {mockdata => common/mockdata}/src/sheets/demo/default-workbook-data-demo2.ts (100%) rename {mockdata => common/mockdata}/src/sheets/demo/default-workbook-data-demo3.ts (100%) rename {mockdata => common/mockdata}/src/sheets/demo/default-workbook-data-demo4.ts (100%) rename {mockdata => common/mockdata}/src/sheets/demo/default-workbook-data-demo5.ts (100%) rename {mockdata => common/mockdata}/src/sheets/demo/default-workbook-data-demo6.ts (100%) rename {mockdata => common/mockdata}/src/sheets/demo/default-workbook-data-demo7.ts (100%) rename {mockdata => common/mockdata}/src/sheets/demo/default-workbook-data-demo8.ts (100%) rename {mockdata => common/mockdata}/src/sheets/demo/default-workbook-data-validation.ts (100%) rename {mockdata => common/mockdata}/src/sheets/demo/index.ts (100%) rename {mockdata => common/mockdata}/src/sheets/index.ts (100%) rename {mockdata => common/mockdata}/src/sheets/slide-workbook-data.ts (100%) rename {mockdata => common/mockdata}/src/sheets/uniscript-data.ts (100%) rename {mockdata => common/mockdata}/src/slides/default-pages/page1.ts (100%) rename {mockdata => common/mockdata}/src/slides/default-pages/page2.ts (100%) rename {mockdata => common/mockdata}/src/slides/default-pages/page3.ts (100%) rename {mockdata => common/mockdata}/src/slides/default-pages/page4.ts (100%) rename {mockdata => common/mockdata}/src/slides/default-pages/page5.ts (100%) rename {mockdata => common/mockdata}/src/slides/default-pages/page6.ts (100%) rename {mockdata => common/mockdata}/src/slides/default-pages/page7.ts (100%) rename {mockdata => common/mockdata}/src/slides/default-slide-data.ts (100%) rename {mockdata => common/mockdata}/src/slides/index.ts (100%) rename {mockdata => common/mockdata}/src/slides/rich-text/page3-richtext1.ts (100%) rename {mockdata => common/mockdata}/src/slides/rich-text/page3-richtext2.ts (100%) rename {mockdata => common/mockdata}/src/slides/rich-text/page3-richtext3.ts (100%) rename {mockdata => common/mockdata}/src/slides/rich-text/page5-richtext1.ts (100%) rename {mockdata => common/mockdata}/src/slides/unlimited-slide-data.ts (100%) rename {mockdata => common/mockdata}/tsconfig.json (100%) delete mode 100644 examples/src/uni/lazy.ts delete mode 100644 examples/src/uni/main.ts delete mode 100644 examples/src/uni/worker.ts delete mode 100644 packages-experimental/README.md delete mode 100644 packages-experimental/uni-docs-ui/README.md delete mode 100644 packages-experimental/uni-docs-ui/package.json delete mode 100644 packages-experimental/uni-docs-ui/postcss.config.mjs delete mode 100644 packages-experimental/uni-docs-ui/src/controllers/menu.schema.ts delete mode 100644 packages-experimental/uni-docs-ui/src/controllers/menu.ts delete mode 100644 packages-experimental/uni-docs-ui/src/controllers/uni-docs-ui.controller.ts delete mode 100644 packages-experimental/uni-docs-ui/src/index.ts delete mode 100644 packages-experimental/uni-docs-ui/src/vite-env.d.ts delete mode 100644 packages-experimental/uni-docs-ui/tailwind.config.ts delete mode 100644 packages-experimental/uni-docs-ui/tsconfig.json delete mode 100644 packages-experimental/uni-docs-ui/tsconfig.node.json delete mode 100644 packages-experimental/uni-docs-ui/vitest.config.ts delete mode 100644 packages-experimental/uni-formula-ui/README.md delete mode 100644 packages-experimental/uni-formula-ui/package.json delete mode 100644 packages-experimental/uni-formula-ui/postcss.config.mjs delete mode 100644 packages-experimental/uni-formula-ui/src/commands/commands/doc.command.ts delete mode 100644 packages-experimental/uni-formula-ui/src/commands/commands/slide.command.ts delete mode 100644 packages-experimental/uni-formula-ui/src/commands/operations/operation.ts delete mode 100644 packages-experimental/uni-formula-ui/src/const.ts delete mode 100644 packages-experimental/uni-formula-ui/src/controllers/doc-formula-input.controller.ts delete mode 100644 packages-experimental/uni-formula-ui/src/controllers/slide-formula-input.controller.ts delete mode 100644 packages-experimental/uni-formula-ui/src/controllers/uni-formula-ui.controller.ts delete mode 100644 packages-experimental/uni-formula-ui/src/global.css delete mode 100644 packages-experimental/uni-formula-ui/src/index.ts delete mode 100644 packages-experimental/uni-formula-ui/src/locale/ca-ES.ts delete mode 100644 packages-experimental/uni-formula-ui/src/locale/en-US.ts delete mode 100644 packages-experimental/uni-formula-ui/src/locale/es-ES.ts delete mode 100644 packages-experimental/uni-formula-ui/src/locale/fa-IR.ts delete mode 100644 packages-experimental/uni-formula-ui/src/locale/fr-FR.ts delete mode 100644 packages-experimental/uni-formula-ui/src/locale/ja-JP.ts delete mode 100644 packages-experimental/uni-formula-ui/src/locale/ko-KR.ts delete mode 100644 packages-experimental/uni-formula-ui/src/locale/ru-RU.ts delete mode 100644 packages-experimental/uni-formula-ui/src/locale/vi-VN.ts delete mode 100644 packages-experimental/uni-formula-ui/src/locale/zh-CN.ts delete mode 100644 packages-experimental/uni-formula-ui/src/locale/zh-TW.ts delete mode 100644 packages-experimental/uni-formula-ui/src/plugin.ts delete mode 100644 packages-experimental/uni-formula-ui/src/services/formula-popup.service.ts delete mode 100644 packages-experimental/uni-formula-ui/src/services/slide-ui-formula-cache.service.ts delete mode 100644 packages-experimental/uni-formula-ui/src/services/uni-formula.service.ts delete mode 100644 packages-experimental/uni-formula-ui/src/views/components/DocFormulaPopup.tsx delete mode 100644 packages-experimental/uni-formula-ui/src/vite-env.d.ts delete mode 100644 packages-experimental/uni-formula-ui/tailwind.config.ts delete mode 100644 packages-experimental/uni-formula-ui/tsconfig.json delete mode 100644 packages-experimental/uni-formula-ui/tsconfig.node.json delete mode 100644 packages-experimental/uni-formula-ui/vitest.config.ts delete mode 100644 packages-experimental/uni-formula/README.md delete mode 100644 packages-experimental/uni-formula/package.json delete mode 100644 packages-experimental/uni-formula/src/commands/mutations/doc-formula.mutation.ts delete mode 100644 packages-experimental/uni-formula/src/commands/mutations/slide-formua.mutation.ts delete mode 100644 packages-experimental/uni-formula/src/const.ts delete mode 100644 packages-experimental/uni-formula/src/controller/uni-formula.controller.ts delete mode 100644 packages-experimental/uni-formula/src/index.ts delete mode 100644 packages-experimental/uni-formula/src/models/doc-formula.ts delete mode 100644 packages-experimental/uni-formula/src/models/slide-formula.ts delete mode 100644 packages-experimental/uni-formula/src/plugin.ts delete mode 100644 packages-experimental/uni-formula/src/services/uni-formula.service.ts delete mode 100644 packages-experimental/uni-formula/src/vite-env.d.ts delete mode 100644 packages-experimental/uni-formula/tsconfig.json delete mode 100644 packages-experimental/uni-formula/tsconfig.node.json delete mode 100644 packages-experimental/uni-formula/vitest.config.ts delete mode 100644 packages-experimental/uni-sheets-ui/README.md delete mode 100644 packages-experimental/uni-sheets-ui/package.json delete mode 100644 packages-experimental/uni-sheets-ui/postcss.config.mjs delete mode 100644 packages-experimental/uni-sheets-ui/src/controllers/menu.schema.ts delete mode 100644 packages-experimental/uni-sheets-ui/src/controllers/menu.ts delete mode 100644 packages-experimental/uni-sheets-ui/src/controllers/uni-sheets-ui.controller.tsx delete mode 100644 packages-experimental/uni-sheets-ui/src/global.css delete mode 100644 packages-experimental/uni-sheets-ui/src/index.ts delete mode 100644 packages-experimental/uni-sheets-ui/src/views/uni-sheet-bar/UniSheetBar.tsx delete mode 100644 packages-experimental/uni-sheets-ui/src/vite-env.d.ts delete mode 100644 packages-experimental/uni-sheets-ui/tailwind.config.ts delete mode 100644 packages-experimental/uni-sheets-ui/tsconfig.json delete mode 100644 packages-experimental/uni-sheets-ui/tsconfig.node.json delete mode 100644 packages-experimental/uni-sheets-ui/vitest.config.ts delete mode 100644 packages-experimental/uni-slides-ui/README.md delete mode 100644 packages-experimental/uni-slides-ui/package.json delete mode 100644 packages-experimental/uni-slides-ui/postcss.config.mjs delete mode 100644 packages-experimental/uni-slides-ui/src/controllers/menu.schema.ts delete mode 100644 packages-experimental/uni-slides-ui/src/controllers/uni-slides-ui.controller.tsx delete mode 100644 packages-experimental/uni-slides-ui/src/global.css delete mode 100644 packages-experimental/uni-slides-ui/src/index.ts delete mode 100644 packages-experimental/uni-slides-ui/src/views/UniSlideSideBar.tsx delete mode 100644 packages-experimental/uni-slides-ui/src/vite-env.d.ts delete mode 100644 packages-experimental/uni-slides-ui/tailwind.config.ts delete mode 100644 packages-experimental/uni-slides-ui/tsconfig.json delete mode 100644 packages-experimental/uni-slides-ui/tsconfig.node.json delete mode 100644 packages-experimental/uni-slides-ui/vitest.config.ts delete mode 100644 packages-experimental/uniui/README.md delete mode 100644 packages-experimental/uniui/package.json delete mode 100644 packages-experimental/uniui/postcss.config.mjs delete mode 100644 packages-experimental/uniui/src/commands/operations/set-flow-viewport.operation.ts delete mode 100644 packages-experimental/uniui/src/commands/operations/uni-focus-unit.operation.ts delete mode 100644 packages-experimental/uniui/src/commands/operations/uni.operation.ts delete mode 100644 packages-experimental/uniui/src/controllers/menu.schema.ts delete mode 100644 packages-experimental/uniui/src/controllers/menu.ts delete mode 100644 packages-experimental/uniui/src/controllers/uniui-desktop.controller.tsx delete mode 100644 packages-experimental/uniui/src/controllers/uniui-flow.controller.tsx delete mode 100644 packages-experimental/uniui/src/controllers/uniui-leftsidebar.controller.tsx delete mode 100644 packages-experimental/uniui/src/controllers/uniui-toolbar.controller.tsx delete mode 100644 packages-experimental/uniui/src/controllers/utils.ts delete mode 100644 packages-experimental/uniui/src/global.css delete mode 100644 packages-experimental/uniui/src/index.ts delete mode 100644 packages-experimental/uniui/src/plugin.ts delete mode 100644 packages-experimental/uniui/src/services/flow/flow-manager.service.ts delete mode 100644 packages-experimental/uniui/src/services/toolbar/uni-toolbar-service.ts delete mode 100644 packages-experimental/uniui/src/services/unit-grid/unit-grid.service.ts delete mode 100644 packages-experimental/uniui/src/views/hooks/title.ts delete mode 100644 packages-experimental/uniui/src/views/outline/Outline.tsx delete mode 100644 packages-experimental/uniui/src/views/uni-controls/UniControls.tsx delete mode 100644 packages-experimental/uniui/src/views/uni-sidebar/UniSidebar.tsx delete mode 100644 packages-experimental/uniui/src/views/uni-toolbar/UniFloatToolbar.tsx delete mode 100644 packages-experimental/uniui/src/views/uni-toolbar/UniFormulaBar.tsx delete mode 100644 packages-experimental/uniui/src/views/uni-toolbar/UniToolbar.tsx delete mode 100644 packages-experimental/uniui/src/views/workbench/UniWorkbench.tsx delete mode 100644 packages-experimental/uniui/src/vite-env.d.ts delete mode 100644 packages-experimental/uniui/tailwind.config.ts delete mode 100644 packages-experimental/uniui/tsconfig.json delete mode 100644 packages-experimental/uniui/tsconfig.node.json delete mode 100644 packages-experimental/uniui/vitest.config.ts diff --git a/.release-it.json b/.release-it.json index 714ea70e92..47df77b91a 100644 --- a/.release-it.json +++ b/.release-it.json @@ -19,8 +19,7 @@ "skipChecks": true, "workspaces": [ "common/*", - "packages/*", - "packages-experimental/action-recorder" + "packages/*" ] } } diff --git a/.vscode/settings.json b/.vscode/settings.json index 21cc6b0816..75ddc5ae96 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -57,5 +57,7 @@ "editor.quickSuggestions": { "strings": "on" - } + }, + + "vitest.maximumConfigs": 80 } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 974b249dc6..6349c53a82 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -66,7 +66,6 @@ The structure of the repository is as follows: ├── examples/ demos running on the web ├── mockdata/ mock data for development ├── packages/ Univer core and plugins -├── packages-experimental/ experimental plugins (not published on npm.com) ``` The file structure of a plugin should be organized as follows: diff --git a/packages-experimental/debugger/README.md b/common/debugger/README.md similarity index 100% rename from packages-experimental/debugger/README.md rename to common/debugger/README.md diff --git a/packages-experimental/debugger/package.json b/common/debugger/package.json similarity index 100% rename from packages-experimental/debugger/package.json rename to common/debugger/package.json diff --git a/packages-experimental/debugger/postcss.config.mjs b/common/debugger/postcss.config.mjs similarity index 100% rename from packages-experimental/debugger/postcss.config.mjs rename to common/debugger/postcss.config.mjs diff --git a/packages-experimental/debugger/src/components/FloatButton.tsx b/common/debugger/src/components/FloatButton.tsx similarity index 100% rename from packages-experimental/debugger/src/components/FloatButton.tsx rename to common/debugger/src/components/FloatButton.tsx diff --git a/packages-experimental/debugger/src/components/Image.tsx b/common/debugger/src/components/Image.tsx similarity index 100% rename from packages-experimental/debugger/src/components/Image.tsx rename to common/debugger/src/components/Image.tsx diff --git a/packages-experimental/debugger/src/components/RangeLoading.tsx b/common/debugger/src/components/RangeLoading.tsx similarity index 100% rename from packages-experimental/debugger/src/components/RangeLoading.tsx rename to common/debugger/src/components/RangeLoading.tsx diff --git a/packages-experimental/debugger/src/components/VueComponent.vue b/common/debugger/src/components/VueComponent.vue similarity index 100% rename from packages-experimental/debugger/src/components/VueComponent.vue rename to common/debugger/src/components/VueComponent.vue diff --git a/packages-experimental/debugger/src/components/WebComponent.ts b/common/debugger/src/components/WebComponent.ts similarity index 100% rename from packages-experimental/debugger/src/components/WebComponent.ts rename to common/debugger/src/components/WebComponent.ts diff --git a/packages-experimental/debugger/src/controllers/config.schema.ts b/common/debugger/src/controllers/config.schema.ts similarity index 100% rename from packages-experimental/debugger/src/controllers/config.schema.ts rename to common/debugger/src/controllers/config.schema.ts diff --git a/packages-experimental/debugger/src/controllers/debugger.controller.ts b/common/debugger/src/controllers/debugger.controller.ts similarity index 100% rename from packages-experimental/debugger/src/controllers/debugger.controller.ts rename to common/debugger/src/controllers/debugger.controller.ts diff --git a/packages-experimental/debugger/src/controllers/e2e/data/default-doc.ts b/common/debugger/src/controllers/e2e/data/default-doc.ts similarity index 100% rename from packages-experimental/debugger/src/controllers/e2e/data/default-doc.ts rename to common/debugger/src/controllers/e2e/data/default-doc.ts diff --git a/packages-experimental/debugger/src/controllers/e2e/data/default-sheet.ts b/common/debugger/src/controllers/e2e/data/default-sheet.ts similarity index 100% rename from packages-experimental/debugger/src/controllers/e2e/data/default-sheet.ts rename to common/debugger/src/controllers/e2e/data/default-sheet.ts diff --git a/packages-experimental/debugger/src/controllers/e2e/e2e.controller.ts b/common/debugger/src/controllers/e2e/e2e.controller.ts similarity index 100% rename from packages-experimental/debugger/src/controllers/e2e/e2e.controller.ts rename to common/debugger/src/controllers/e2e/e2e.controller.ts diff --git a/packages-experimental/debugger/src/controllers/local-save/record.controller.ts b/common/debugger/src/controllers/local-save/record.controller.ts similarity index 100% rename from packages-experimental/debugger/src/controllers/local-save/record.controller.ts rename to common/debugger/src/controllers/local-save/record.controller.ts diff --git a/packages-experimental/debugger/src/controllers/local-save/util.ts b/common/debugger/src/controllers/local-save/util.ts similarity index 100% rename from packages-experimental/debugger/src/controllers/local-save/util.ts rename to common/debugger/src/controllers/local-save/util.ts diff --git a/packages-experimental/debugger/src/controllers/performance-monitor.controller.ts b/common/debugger/src/controllers/performance-monitor.controller.ts similarity index 100% rename from packages-experimental/debugger/src/controllers/performance-monitor.controller.ts rename to common/debugger/src/controllers/performance-monitor.controller.ts diff --git a/packages-experimental/debugger/src/controllers/watermark.menu.controller.ts b/common/debugger/src/controllers/watermark.menu.controller.ts similarity index 100% rename from packages-experimental/debugger/src/controllers/watermark.menu.controller.ts rename to common/debugger/src/controllers/watermark.menu.controller.ts diff --git a/packages-experimental/debugger/src/global.css b/common/debugger/src/global.css similarity index 100% rename from packages-experimental/debugger/src/global.css rename to common/debugger/src/global.css diff --git a/packages-experimental/debugger/src/index.ts b/common/debugger/src/index.ts similarity index 100% rename from packages-experimental/debugger/src/index.ts rename to common/debugger/src/index.ts diff --git a/packages-experimental/debugger/src/plugin.ts b/common/debugger/src/plugin.ts similarity index 100% rename from packages-experimental/debugger/src/plugin.ts rename to common/debugger/src/plugin.ts diff --git a/packages-experimental/debugger/src/views/Fab.tsx b/common/debugger/src/views/Fab.tsx similarity index 100% rename from packages-experimental/debugger/src/views/Fab.tsx rename to common/debugger/src/views/Fab.tsx diff --git a/packages-experimental/debugger/src/views/test-editor/component-name.ts b/common/debugger/src/views/test-editor/component-name.ts similarity index 100% rename from packages-experimental/debugger/src/views/test-editor/component-name.ts rename to common/debugger/src/views/test-editor/component-name.ts diff --git a/packages-experimental/debugger/src/views/use-cell-content.ts b/common/debugger/src/views/use-cell-content.ts similarity index 100% rename from packages-experimental/debugger/src/views/use-cell-content.ts rename to common/debugger/src/views/use-cell-content.ts diff --git a/packages-experimental/debugger/src/views/use-dark-mode.ts b/common/debugger/src/views/use-dark-mode.ts similarity index 100% rename from packages-experimental/debugger/src/views/use-dark-mode.ts rename to common/debugger/src/views/use-dark-mode.ts diff --git a/packages-experimental/debugger/src/views/use-dialog.ts b/common/debugger/src/views/use-dialog.ts similarity index 100% rename from packages-experimental/debugger/src/views/use-dialog.ts rename to common/debugger/src/views/use-dialog.ts diff --git a/packages-experimental/debugger/src/views/use-dispose.ts b/common/debugger/src/views/use-dispose.ts similarity index 100% rename from packages-experimental/debugger/src/views/use-dispose.ts rename to common/debugger/src/views/use-dispose.ts diff --git a/packages-experimental/debugger/src/views/use-editable.ts b/common/debugger/src/views/use-editable.ts similarity index 100% rename from packages-experimental/debugger/src/views/use-editable.ts rename to common/debugger/src/views/use-editable.ts diff --git a/packages-experimental/debugger/src/views/use-floating-dom.ts b/common/debugger/src/views/use-floating-dom.ts similarity index 100% rename from packages-experimental/debugger/src/views/use-floating-dom.ts rename to common/debugger/src/views/use-floating-dom.ts diff --git a/packages-experimental/debugger/src/views/use-locale.ts b/common/debugger/src/views/use-locale.ts similarity index 100% rename from packages-experimental/debugger/src/views/use-locale.ts rename to common/debugger/src/views/use-locale.ts diff --git a/packages-experimental/debugger/src/views/use-message.ts b/common/debugger/src/views/use-message.ts similarity index 100% rename from packages-experimental/debugger/src/views/use-message.ts rename to common/debugger/src/views/use-message.ts diff --git a/packages-experimental/debugger/src/views/use-notification.ts b/common/debugger/src/views/use-notification.ts similarity index 100% rename from packages-experimental/debugger/src/views/use-notification.ts rename to common/debugger/src/views/use-notification.ts diff --git a/packages-experimental/debugger/src/views/use-sidebar.ts b/common/debugger/src/views/use-sidebar.ts similarity index 100% rename from packages-experimental/debugger/src/views/use-sidebar.ts rename to common/debugger/src/views/use-sidebar.ts diff --git a/packages-experimental/debugger/src/views/use-snapshot.ts b/common/debugger/src/views/use-snapshot.ts similarity index 100% rename from packages-experimental/debugger/src/views/use-snapshot.ts rename to common/debugger/src/views/use-snapshot.ts diff --git a/packages-experimental/debugger/src/views/use-theme.ts b/common/debugger/src/views/use-theme.ts similarity index 100% rename from packages-experimental/debugger/src/views/use-theme.ts rename to common/debugger/src/views/use-theme.ts diff --git a/packages-experimental/debugger/src/views/use-units.ts b/common/debugger/src/views/use-units.ts similarity index 100% rename from packages-experimental/debugger/src/views/use-units.ts rename to common/debugger/src/views/use-units.ts diff --git a/packages-experimental/debugger/src/views/use-user.ts b/common/debugger/src/views/use-user.ts similarity index 100% rename from packages-experimental/debugger/src/views/use-user.ts rename to common/debugger/src/views/use-user.ts diff --git a/packages-experimental/debugger/src/views/use-watermark.ts b/common/debugger/src/views/use-watermark.ts similarity index 100% rename from packages-experimental/debugger/src/views/use-watermark.ts rename to common/debugger/src/views/use-watermark.ts diff --git a/packages-experimental/debugger/src/views/watermark/WatermarkImageSetting.tsx b/common/debugger/src/views/watermark/WatermarkImageSetting.tsx similarity index 100% rename from packages-experimental/debugger/src/views/watermark/WatermarkImageSetting.tsx rename to common/debugger/src/views/watermark/WatermarkImageSetting.tsx diff --git a/packages-experimental/debugger/src/views/watermark/WatermarkPanel.tsx b/common/debugger/src/views/watermark/WatermarkPanel.tsx similarity index 100% rename from packages-experimental/debugger/src/views/watermark/WatermarkPanel.tsx rename to common/debugger/src/views/watermark/WatermarkPanel.tsx diff --git a/packages-experimental/debugger/src/views/watermark/WatermarkPanelFooter.tsx b/common/debugger/src/views/watermark/WatermarkPanelFooter.tsx similarity index 100% rename from packages-experimental/debugger/src/views/watermark/WatermarkPanelFooter.tsx rename to common/debugger/src/views/watermark/WatermarkPanelFooter.tsx diff --git a/packages-experimental/debugger/src/views/watermark/WatermarkTextSetting.tsx b/common/debugger/src/views/watermark/WatermarkTextSetting.tsx similarity index 100% rename from packages-experimental/debugger/src/views/watermark/WatermarkTextSetting.tsx rename to common/debugger/src/views/watermark/WatermarkTextSetting.tsx diff --git a/packages-experimental/debugger/src/vite-env.d.ts b/common/debugger/src/vite-env.d.ts similarity index 100% rename from packages-experimental/debugger/src/vite-env.d.ts rename to common/debugger/src/vite-env.d.ts diff --git a/packages-experimental/debugger/tailwind.config.ts b/common/debugger/tailwind.config.ts similarity index 100% rename from packages-experimental/debugger/tailwind.config.ts rename to common/debugger/tailwind.config.ts diff --git a/packages-experimental/debugger/tsconfig.json b/common/debugger/tsconfig.json similarity index 100% rename from packages-experimental/debugger/tsconfig.json rename to common/debugger/tsconfig.json diff --git a/packages-experimental/debugger/tsconfig.node.json b/common/debugger/tsconfig.node.json similarity index 100% rename from packages-experimental/debugger/tsconfig.node.json rename to common/debugger/tsconfig.node.json diff --git a/packages-experimental/debugger/vitest.config.ts b/common/debugger/vitest.config.ts similarity index 100% rename from packages-experimental/debugger/vitest.config.ts rename to common/debugger/vitest.config.ts diff --git a/mockdata/.gitignore b/common/mockdata/.gitignore similarity index 100% rename from mockdata/.gitignore rename to common/mockdata/.gitignore diff --git a/mockdata/README.md b/common/mockdata/README.md similarity index 100% rename from mockdata/README.md rename to common/mockdata/README.md diff --git a/mockdata/package.json b/common/mockdata/package.json similarity index 98% rename from mockdata/package.json rename to common/mockdata/package.json index 76f0b8bd08..c329fdc5bd 100644 --- a/mockdata/package.json +++ b/common/mockdata/package.json @@ -69,7 +69,6 @@ "@univerjs/thread-comment": "workspace:*", "@univerjs/thread-comment-ui": "workspace:*", "@univerjs/ui": "workspace:*", - "@univerjs/uni-formula-ui": "workspace:*", "@univerjs/uniscript": "workspace:*" }, "devDependencies": { diff --git a/mockdata/scripts/generate-locales.ts b/common/mockdata/scripts/generate-locales.ts similarity index 84% rename from mockdata/scripts/generate-locales.ts rename to common/mockdata/scripts/generate-locales.ts index f2cdc64adb..c9908f4e47 100644 --- a/mockdata/scripts/generate-locales.ts +++ b/common/mockdata/scripts/generate-locales.ts @@ -42,15 +42,11 @@ async function generateLocales() { const pkgJsonFile = fs.readJsonSync(path.resolve(__dirname, '../package.json')); - const packages = fs.readdirSync(path.resolve(__dirname, '../../packages')) - .filter((dir) => fs.statSync(path.join(__dirname, '../../packages', dir)).isDirectory()) - .map((dir) => path.join(__dirname, '../../packages', dir)); + const packages = fs.readdirSync(path.resolve(__dirname, '../../../packages')) + .filter((dir) => fs.statSync(path.join(__dirname, '../../../packages', dir)).isDirectory()) + .map((dir) => path.join(__dirname, '../../../packages', dir)); - const experimentalPackages = fs.readdirSync(path.resolve(__dirname, '../../packages-experimental')) - .filter((dir) => fs.statSync(path.join(__dirname, '../../packages-experimental', dir)).isDirectory()) - .map((dir) => path.join(__dirname, '../../packages-experimental', dir)); - - const allPackages = [...packages, ...experimentalPackages]; + const allPackages = [...packages]; for (const pkg of allPackages) { const localePath = path.join(pkg, 'src/locale'); if (fs.existsSync(localePath)) { diff --git a/mockdata/src/docs/default-document-data-cn.ts b/common/mockdata/src/docs/default-document-data-cn.ts similarity index 100% rename from mockdata/src/docs/default-document-data-cn.ts rename to common/mockdata/src/docs/default-document-data-cn.ts diff --git a/mockdata/src/docs/default-document-data-dreamer.ts b/common/mockdata/src/docs/default-document-data-dreamer.ts similarity index 100% rename from mockdata/src/docs/default-document-data-dreamer.ts rename to common/mockdata/src/docs/default-document-data-dreamer.ts diff --git a/mockdata/src/docs/default-document-data-en.ts b/common/mockdata/src/docs/default-document-data-en.ts similarity index 100% rename from mockdata/src/docs/default-document-data-en.ts rename to common/mockdata/src/docs/default-document-data-en.ts diff --git a/mockdata/src/docs/default-document-data.ts b/common/mockdata/src/docs/default-document-data.ts similarity index 100% rename from mockdata/src/docs/default-document-data.ts rename to common/mockdata/src/docs/default-document-data.ts diff --git a/mockdata/src/docs/default-document.data-simple.ts b/common/mockdata/src/docs/default-document.data-simple.ts similarity index 100% rename from mockdata/src/docs/default-document.data-simple.ts rename to common/mockdata/src/docs/default-document.data-simple.ts diff --git a/mockdata/src/docs/index.ts b/common/mockdata/src/docs/index.ts similarity index 100% rename from mockdata/src/docs/index.ts rename to common/mockdata/src/docs/index.ts diff --git a/mockdata/src/index.ts b/common/mockdata/src/index.ts similarity index 100% rename from mockdata/src/index.ts rename to common/mockdata/src/index.ts diff --git a/mockdata/src/sheets/default-workbook-data.ts b/common/mockdata/src/sheets/default-workbook-data.ts similarity index 100% rename from mockdata/src/sheets/default-workbook-data.ts rename to common/mockdata/src/sheets/default-workbook-data.ts diff --git a/mockdata/src/sheets/demo/default-workbook-data-default-style.ts b/common/mockdata/src/sheets/demo/default-workbook-data-default-style.ts similarity index 100% rename from mockdata/src/sheets/demo/default-workbook-data-default-style.ts rename to common/mockdata/src/sheets/demo/default-workbook-data-default-style.ts diff --git a/mockdata/src/sheets/demo/default-workbook-data-demo.ts b/common/mockdata/src/sheets/demo/default-workbook-data-demo.ts similarity index 100% rename from mockdata/src/sheets/demo/default-workbook-data-demo.ts rename to common/mockdata/src/sheets/demo/default-workbook-data-demo.ts diff --git a/mockdata/src/sheets/demo/default-workbook-data-demo1.ts b/common/mockdata/src/sheets/demo/default-workbook-data-demo1.ts similarity index 100% rename from mockdata/src/sheets/demo/default-workbook-data-demo1.ts rename to common/mockdata/src/sheets/demo/default-workbook-data-demo1.ts diff --git a/mockdata/src/sheets/demo/default-workbook-data-demo2.ts b/common/mockdata/src/sheets/demo/default-workbook-data-demo2.ts similarity index 100% rename from mockdata/src/sheets/demo/default-workbook-data-demo2.ts rename to common/mockdata/src/sheets/demo/default-workbook-data-demo2.ts diff --git a/mockdata/src/sheets/demo/default-workbook-data-demo3.ts b/common/mockdata/src/sheets/demo/default-workbook-data-demo3.ts similarity index 100% rename from mockdata/src/sheets/demo/default-workbook-data-demo3.ts rename to common/mockdata/src/sheets/demo/default-workbook-data-demo3.ts diff --git a/mockdata/src/sheets/demo/default-workbook-data-demo4.ts b/common/mockdata/src/sheets/demo/default-workbook-data-demo4.ts similarity index 100% rename from mockdata/src/sheets/demo/default-workbook-data-demo4.ts rename to common/mockdata/src/sheets/demo/default-workbook-data-demo4.ts diff --git a/mockdata/src/sheets/demo/default-workbook-data-demo5.ts b/common/mockdata/src/sheets/demo/default-workbook-data-demo5.ts similarity index 100% rename from mockdata/src/sheets/demo/default-workbook-data-demo5.ts rename to common/mockdata/src/sheets/demo/default-workbook-data-demo5.ts diff --git a/mockdata/src/sheets/demo/default-workbook-data-demo6.ts b/common/mockdata/src/sheets/demo/default-workbook-data-demo6.ts similarity index 100% rename from mockdata/src/sheets/demo/default-workbook-data-demo6.ts rename to common/mockdata/src/sheets/demo/default-workbook-data-demo6.ts diff --git a/mockdata/src/sheets/demo/default-workbook-data-demo7.ts b/common/mockdata/src/sheets/demo/default-workbook-data-demo7.ts similarity index 100% rename from mockdata/src/sheets/demo/default-workbook-data-demo7.ts rename to common/mockdata/src/sheets/demo/default-workbook-data-demo7.ts diff --git a/mockdata/src/sheets/demo/default-workbook-data-demo8.ts b/common/mockdata/src/sheets/demo/default-workbook-data-demo8.ts similarity index 100% rename from mockdata/src/sheets/demo/default-workbook-data-demo8.ts rename to common/mockdata/src/sheets/demo/default-workbook-data-demo8.ts diff --git a/mockdata/src/sheets/demo/default-workbook-data-validation.ts b/common/mockdata/src/sheets/demo/default-workbook-data-validation.ts similarity index 100% rename from mockdata/src/sheets/demo/default-workbook-data-validation.ts rename to common/mockdata/src/sheets/demo/default-workbook-data-validation.ts diff --git a/mockdata/src/sheets/demo/index.ts b/common/mockdata/src/sheets/demo/index.ts similarity index 100% rename from mockdata/src/sheets/demo/index.ts rename to common/mockdata/src/sheets/demo/index.ts diff --git a/mockdata/src/sheets/index.ts b/common/mockdata/src/sheets/index.ts similarity index 100% rename from mockdata/src/sheets/index.ts rename to common/mockdata/src/sheets/index.ts diff --git a/mockdata/src/sheets/slide-workbook-data.ts b/common/mockdata/src/sheets/slide-workbook-data.ts similarity index 100% rename from mockdata/src/sheets/slide-workbook-data.ts rename to common/mockdata/src/sheets/slide-workbook-data.ts diff --git a/mockdata/src/sheets/uniscript-data.ts b/common/mockdata/src/sheets/uniscript-data.ts similarity index 100% rename from mockdata/src/sheets/uniscript-data.ts rename to common/mockdata/src/sheets/uniscript-data.ts diff --git a/mockdata/src/slides/default-pages/page1.ts b/common/mockdata/src/slides/default-pages/page1.ts similarity index 100% rename from mockdata/src/slides/default-pages/page1.ts rename to common/mockdata/src/slides/default-pages/page1.ts diff --git a/mockdata/src/slides/default-pages/page2.ts b/common/mockdata/src/slides/default-pages/page2.ts similarity index 100% rename from mockdata/src/slides/default-pages/page2.ts rename to common/mockdata/src/slides/default-pages/page2.ts diff --git a/mockdata/src/slides/default-pages/page3.ts b/common/mockdata/src/slides/default-pages/page3.ts similarity index 100% rename from mockdata/src/slides/default-pages/page3.ts rename to common/mockdata/src/slides/default-pages/page3.ts diff --git a/mockdata/src/slides/default-pages/page4.ts b/common/mockdata/src/slides/default-pages/page4.ts similarity index 100% rename from mockdata/src/slides/default-pages/page4.ts rename to common/mockdata/src/slides/default-pages/page4.ts diff --git a/mockdata/src/slides/default-pages/page5.ts b/common/mockdata/src/slides/default-pages/page5.ts similarity index 100% rename from mockdata/src/slides/default-pages/page5.ts rename to common/mockdata/src/slides/default-pages/page5.ts diff --git a/mockdata/src/slides/default-pages/page6.ts b/common/mockdata/src/slides/default-pages/page6.ts similarity index 100% rename from mockdata/src/slides/default-pages/page6.ts rename to common/mockdata/src/slides/default-pages/page6.ts diff --git a/mockdata/src/slides/default-pages/page7.ts b/common/mockdata/src/slides/default-pages/page7.ts similarity index 100% rename from mockdata/src/slides/default-pages/page7.ts rename to common/mockdata/src/slides/default-pages/page7.ts diff --git a/mockdata/src/slides/default-slide-data.ts b/common/mockdata/src/slides/default-slide-data.ts similarity index 100% rename from mockdata/src/slides/default-slide-data.ts rename to common/mockdata/src/slides/default-slide-data.ts diff --git a/mockdata/src/slides/index.ts b/common/mockdata/src/slides/index.ts similarity index 100% rename from mockdata/src/slides/index.ts rename to common/mockdata/src/slides/index.ts diff --git a/mockdata/src/slides/rich-text/page3-richtext1.ts b/common/mockdata/src/slides/rich-text/page3-richtext1.ts similarity index 100% rename from mockdata/src/slides/rich-text/page3-richtext1.ts rename to common/mockdata/src/slides/rich-text/page3-richtext1.ts diff --git a/mockdata/src/slides/rich-text/page3-richtext2.ts b/common/mockdata/src/slides/rich-text/page3-richtext2.ts similarity index 100% rename from mockdata/src/slides/rich-text/page3-richtext2.ts rename to common/mockdata/src/slides/rich-text/page3-richtext2.ts diff --git a/mockdata/src/slides/rich-text/page3-richtext3.ts b/common/mockdata/src/slides/rich-text/page3-richtext3.ts similarity index 100% rename from mockdata/src/slides/rich-text/page3-richtext3.ts rename to common/mockdata/src/slides/rich-text/page3-richtext3.ts diff --git a/mockdata/src/slides/rich-text/page5-richtext1.ts b/common/mockdata/src/slides/rich-text/page5-richtext1.ts similarity index 100% rename from mockdata/src/slides/rich-text/page5-richtext1.ts rename to common/mockdata/src/slides/rich-text/page5-richtext1.ts diff --git a/mockdata/src/slides/unlimited-slide-data.ts b/common/mockdata/src/slides/unlimited-slide-data.ts similarity index 100% rename from mockdata/src/slides/unlimited-slide-data.ts rename to common/mockdata/src/slides/unlimited-slide-data.ts diff --git a/mockdata/tsconfig.json b/common/mockdata/tsconfig.json similarity index 100% rename from mockdata/tsconfig.json rename to common/mockdata/tsconfig.json diff --git a/common/shared/vitest/index.js b/common/shared/vitest/index.js index 3c3c560b57..4f4d33d825 100644 --- a/common/shared/vitest/index.js +++ b/common/shared/vitest/index.js @@ -50,7 +50,6 @@ function createConfig(options) { 'src/locale/**', '**/*.stories.tsx', '**/__testing__/**', - 'packages-experimental/**/*', '**/*/tailwind.config.ts', ], }, diff --git a/common/storybook/tailwind.config.ts b/common/storybook/tailwind.config.ts index 5dec6b875e..4d4326ec49 100644 --- a/common/storybook/tailwind.config.ts +++ b/common/storybook/tailwind.config.ts @@ -24,7 +24,6 @@ import animate from 'tailwindcss-animate'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const packagesDir = fs.readdirSync(path.resolve(__dirname, '../../packages')).map((dir) => path.resolve(__dirname, `../../packages/${dir}`)); -const packagesExperimentalDir = fs.readdirSync(path.resolve(__dirname, '../../packages-experimental')).map((dir) => path.resolve(__dirname, `../../packages-experimental/${dir}`)); const tailwindProjects = packagesDir.concat(packagesExperimentalDir).reduce((acc, dir) => { const tailwindConfig = path.resolve(dir, 'tailwind.config.ts'); diff --git a/e2e/e2e.d.ts b/e2e/e2e.d.ts index 33ab4e0395..8218b8fa29 100644 --- a/e2e/e2e.d.ts +++ b/e2e/e2e.d.ts @@ -1,5 +1,5 @@ // The type definition is copied from: -// packages-experimental/debugger/src/controllers/e2e/e2e.controller.ts +// common/debugger/src/controllers/e2e/e2e.controller.ts export interface IE2EControllerAPI { loadAndRelease(id: number, loadTimeout?: number, disposeTimeout?: number): Promise; loadDefaultSheet(loadTimeout?: number): Promise; diff --git a/examples/esbuild.config.ts b/examples/esbuild.config.ts index 1d74f2c763..ef18b4630d 100644 --- a/examples/esbuild.config.ts +++ b/examples/esbuild.config.ts @@ -131,11 +131,6 @@ const entryPoints = [ // slides './src/slides/main.ts', - // uni - './src/uni/main.ts', - './src/uni/worker.ts', - './src/uni/lazy.ts', - // mobile sheet './src/mobile-s/main.ts', './src/mobile-s/worker.ts', diff --git a/examples/package.json b/examples/package.json index 4f9b3621ba..00046ff382 100644 --- a/examples/package.json +++ b/examples/package.json @@ -75,13 +75,7 @@ "@univerjs/ui": "workspace:*", "@univerjs/ui-adapter-vue3": "workspace:*", "@univerjs/ui-adapter-web-component": "workspace:*", - "@univerjs/uni-docs-ui": "workspace:*", - "@univerjs/uni-formula": "workspace:*", - "@univerjs/uni-formula-ui": "workspace:*", - "@univerjs/uni-sheets-ui": "workspace:*", - "@univerjs/uni-slides-ui": "workspace:*", "@univerjs/uniscript": "workspace:*", - "@univerjs/uniui": "workspace:*", "@univerjs/watermark": "workspace:*", "lit": "^3.3.2", "monaco-editor": "0.55.1", diff --git a/examples/src/main.tsx b/examples/src/main.tsx index 04cb734e1a..0dc24cafb3 100644 --- a/examples/src/main.tsx +++ b/examples/src/main.tsx @@ -67,9 +67,6 @@ function Examples() { }, { title: '📚 Docs Uniscript', href: './docs-uniscript/', - }, { - title: '🌌 Uni Mode', - href: './uni/', }, { title: '📱 Mobile', href: './mobile-s/', diff --git a/examples/src/uni/lazy.ts b/examples/src/uni/lazy.ts deleted file mode 100644 index 8c2f82c0b7..0000000000 --- a/examples/src/uni/lazy.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { UniverSheetsFilterUIPlugin } from '@univerjs/sheets-filter-ui'; -import { UniverDocUniFormulaUIPlugin } from '@univerjs/uni-formula-ui'; -import type { Plugin, PluginCtor } from '@univerjs/core'; -// import { UniverUniscriptPlugin } from '@univerjs/uniscript'; - -export default function getLazyPlugins(): Array<[PluginCtor] | [PluginCtor, unknown]> { - return [ - // [ - // UniverUniscriptPlugin, - // { - // getWorkerUrl(moduleID: string, label: string) { - // if (label === 'typescript' || label === 'javascript') { - // return './vs/language/typescript/ts.worker.js'; - // } - - // return './vs/editor/editor.worker.js'; - // }, - // }, - // ], - [UniverSheetsFilterUIPlugin], - [UniverDocUniFormulaUIPlugin], - ]; -} diff --git a/examples/src/uni/main.ts b/examples/src/uni/main.ts deleted file mode 100644 index 7f2aea8f5c..0000000000 --- a/examples/src/uni/main.ts +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Injector, LocaleType, LogLevel, Univer, UniverInstanceType } from '@univerjs/core'; -import { FUniver } from '@univerjs/core/facade'; -import { UniverDocsPlugin } from '@univerjs/docs'; -import { UniverDocsDrawingUIPlugin } from '@univerjs/docs-drawing-ui'; -import { DocUIController, UniverDocsUIPlugin } from '@univerjs/docs-ui'; -import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula'; -import { UniverRenderEnginePlugin } from '@univerjs/engine-render'; -import { DEFAULT_DOCUMENT_DATA_CN, DEFAULT_DOCUMENT_DATA_EN, DEFAULT_SLIDE_DATA, DEFAULT_WORKBOOK_DATA_DEMO, DEFAULT_WORKBOOK_DATA_DEMO1 } from '@univerjs/mockdata'; -import zhCN from '@univerjs/mockdata/locales/zh-CN'; -import { UniverRPCMainThreadPlugin } from '@univerjs/rpc'; -import { UniverSheetsPlugin } from '@univerjs/sheets'; -import { UniverSheetsConditionalFormattingUIPlugin } from '@univerjs/sheets-conditional-formatting-ui'; -import { UniverSheetsDrawingUIPlugin } from '@univerjs/sheets-drawing-ui'; -import { UniverSheetsFindReplacePlugin } from '@univerjs/sheets-find-replace'; -import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula'; -import { UniverSheetsFormulaUIPlugin } from '@univerjs/sheets-formula-ui'; -import { UniverSheetsHyperLinkUIPlugin } from '@univerjs/sheets-hyper-link-ui'; -import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt'; -import { UniverSheetsNumfmtUIPlugin } from '@univerjs/sheets-numfmt-ui'; -import { UniverSheetsSortUIPlugin } from '@univerjs/sheets-sort-ui'; -import { UniverSheetsThreadCommentPlugin } from '@univerjs/sheets-thread-comment'; -import { SheetUIController, UniverSheetsUIPlugin } from '@univerjs/sheets-ui'; -import { UniverSlidesPlugin } from '@univerjs/slides'; -import { SlidesUIController, UniverSlidesUIPlugin } from '@univerjs/slides-ui'; -import { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui'; -import { UniDocsUIController } from '@univerjs/uni-docs-ui'; -import { UniverDocUniFormulaPlugin } from '@univerjs/uni-formula'; -import { UniSheetsUIController } from '@univerjs/uni-sheets-ui'; -import { UniSlidesUIController } from '@univerjs/uni-slides-ui'; -import { UniverUniUIPlugin } from '@univerjs/uniui'; - -import '../global.css'; - -const LOAD_LAZY_PLUGINS_TIMEOUT = 4_000; - -// univer -const univer = new Univer({ - locale: LocaleType.ZH_CN, - locales: { - [LocaleType.ZH_CN]: zhCN, - }, - logLevel: LogLevel.VERBOSE, -}); - -registerBasicPlugins(univer); -registerSheetPlugins(univer); -registerSlidePlugins(univer); -registerUniPlugins(univer); - -// create univer instances -univer.createUnit(UniverInstanceType.UNIVER_SHEET, DEFAULT_WORKBOOK_DATA_DEMO); -univer.createUnit(UniverInstanceType.UNIVER_DOC, DEFAULT_DOCUMENT_DATA_EN); -univer.createUnit(UniverInstanceType.UNIVER_SHEET, DEFAULT_WORKBOOK_DATA_DEMO1); - -declare global { - // eslint-disable-next-line ts/naming-convention - interface Window { - univer?: Univer; - univerAPI?: ReturnType; - } -} - -setTimeout(() => { - import('./lazy').then((lazy) => { - const plugins = lazy.default(); - plugins.forEach((p) => univer.registerPlugin(p[0], p[1])); - - univer.createUnit(UniverInstanceType.UNIVER_DOC, DEFAULT_DOCUMENT_DATA_CN); - univer.createUnit(UniverInstanceType.UNIVER_SLIDE, DEFAULT_SLIDE_DATA); - }); -}, LOAD_LAZY_PLUGINS_TIMEOUT); - -window.univer = univer; -window.univerAPI = FUniver.newAPI(univer); - -function registerBasicPlugins(univer: Univer) { - univer.registerPlugin(UniverDocsPlugin); - univer.registerPlugin(UniverFormulaEnginePlugin, { - notExecuteFormula: true, - }); - univer.registerPlugin(UniverRenderEnginePlugin); - univer.registerPlugin(UniverUniUIPlugin, { - container: 'app', - }); - - univer.registerPlugin(UniverDocsUIPlugin, { - override: [ - [DocUIController, { - useFactory: (injector) => { - injector.createInstance(UniDocsUIController, {}); - }, - deps: [Injector], - }], - ], - }); - - const worker = new Worker(new URL('./worker.js', import.meta.url), { type: 'module' }); - univer.registerPlugin(UniverRPCMainThreadPlugin, { workerURL: worker }); - univer.onDispose(() => worker.terminate()); - - univer.registerPlugin(UniverThreadCommentUIPlugin); - - univer.registerPlugin(UniverDocsDrawingUIPlugin); -} - -function registerSheetPlugins(univer: Univer) { - univer.registerPlugin(UniverSheetsPlugin); - univer.registerPlugin(UniverSheetsUIPlugin, { - override: [ - [SheetUIController, { - useFactory: (injector) => { - injector.createInstance(UniSheetsUIController, {}); - }, - deps: [Injector], - }], - ], - }); - univer.registerPlugin(UniverSheetsNumfmtPlugin); - univer.registerPlugin(UniverSheetsNumfmtUIPlugin); - univer.registerPlugin(UniverSheetsFormulaPlugin); - univer.registerPlugin(UniverSheetsFormulaUIPlugin); - univer.registerPlugin(UniverSheetsFindReplacePlugin); - univer.registerPlugin(UniverSheetsHyperLinkUIPlugin); - univer.registerPlugin(UniverSheetsSortUIPlugin); - univer.registerPlugin(UniverSheetsThreadCommentPlugin); - univer.registerPlugin(UniverSheetsConditionalFormattingUIPlugin); - univer.registerPlugin(UniverSheetsDrawingUIPlugin); -} - -function registerSlidePlugins(univer: Univer) { - univer.registerPlugin(UniverSlidesPlugin); - univer.registerPlugin(UniverSlidesUIPlugin, { - override: [ - [SlidesUIController, { - useClass: UniSlidesUIController, - }], - ], - }); -} - -function registerUniPlugins(univer: Univer) { - univer.registerPlugin(UniverDocUniFormulaPlugin); -} diff --git a/examples/src/uni/worker.ts b/examples/src/uni/worker.ts deleted file mode 100644 index a6fb7752e0..0000000000 --- a/examples/src/uni/worker.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { LocaleType, Univer } from '@univerjs/core'; -import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula'; -import { UniverRPCWorkerThreadPlugin } from '@univerjs/rpc'; -import { UniverSheetsPlugin } from '@univerjs/sheets'; - -const univer = new Univer({ - locale: LocaleType.ZH_CN, -}); - -univer.registerPlugin(UniverSheetsPlugin, { onlyRegisterFormulaRelatedMutations: true }); -univer.registerPlugin(UniverFormulaEnginePlugin); -univer.registerPlugin(UniverRPCWorkerThreadPlugin); - -declare let self: WorkerGlobalScope & typeof globalThis & { univer: Univer }; -self.univer = univer; diff --git a/examples/tailwind.config.ts b/examples/tailwind.config.ts index d167bd838e..648746fbad 100644 --- a/examples/tailwind.config.ts +++ b/examples/tailwind.config.ts @@ -24,9 +24,8 @@ import animate from 'tailwindcss-animate'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const packagesDir = fs.readdirSync(path.resolve(__dirname, '../packages')).map((dir) => path.resolve(__dirname, `../packages/${dir}`)); -const packagesExperimentalDir = fs.readdirSync(path.resolve(__dirname, '../packages-experimental')).map((dir) => path.resolve(__dirname, `../packages-experimental/${dir}`)); -const tailwindProjects = packagesDir.concat(packagesExperimentalDir).reduce((acc, dir) => { +const tailwindProjects = packagesDir.reduce((acc, dir) => { const tailwindConfig = path.resolve(dir, 'tailwind.config.ts'); if (fs.existsSync(tailwindConfig)) { acc.push(`${dir}/src/**/*.{js,ts,jsx,tsx}`); diff --git a/packages-experimental/README.md b/packages-experimental/README.md deleted file mode 100644 index 3b61bacaf8..0000000000 --- a/packages-experimental/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Experimental Packages - -Experimental packages in development. These packages are not meant to be published to npm or used in production so set -`private` to `true` in package.json files. diff --git a/packages-experimental/uni-docs-ui/README.md b/packages-experimental/uni-docs-ui/README.md deleted file mode 100644 index 0a4b4bad90..0000000000 --- a/packages-experimental/uni-docs-ui/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# @univerjs/uni-docs-ui - -[![npm version](https://img.shields.io/npm/v/@univerjs/uni-sheets-ui)](https://npmjs.org/packages/@univerjs/uni-sheets-ui) -[![license](https://img.shields.io/npm/l/@univerjs/uni-sheets-ui)](https://img.shields.io/npm/l/@univerjs/uni-sheets-ui) - -## Introduction - -This package provides a UI controller in replacement of the `@univerjs/docs-ui` package. - -## Usage - -### Installation - -```shell -npm i @univerjs/uni-docs-ui -``` diff --git a/packages-experimental/uni-docs-ui/package.json b/packages-experimental/uni-docs-ui/package.json deleted file mode 100644 index b1ac3e59ed..0000000000 --- a/packages-experimental/uni-docs-ui/package.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "name": "@univerjs/uni-docs-ui", - "version": "0.0.0", - "private": true, - "description": "", - "author": "DreamNum ", - "license": "Apache-2.0", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/univer" - }, - "homepage": "https://univer.ai", - "repository": { - "type": "git", - "url": "https://github.com/dream-num/univer" - }, - "bugs": { - "url": "https://github.com/dream-num/univer/issues" - }, - "keywords": [], - "exports": { - ".": "./src/index.ts", - "./*": "./src/*" - }, - "main": "./src/index.ts", - "types": "./lib/types/index.d.ts", - "publishConfig": { - "access": "public", - "main": "./lib/es/index.js", - "module": "./lib/es/index.js", - "exports": { - ".": { - "import": "./lib/es/index.js", - "require": "./lib/cjs/index.js", - "types": "./lib/types/index.d.ts" - }, - "./*": { - "import": "./lib/es/*", - "require": "./lib/cjs/*", - "types": "./lib/types/index.d.ts" - }, - "./lib/*": "./lib/*" - } - }, - "directories": { - "lib": "lib" - }, - "files": [ - "lib" - ], - "scripts": { - "test": "vitest run", - "test:watch": "vitest", - "coverage": "vitest run --coverage", - "typecheck": "tsc --noEmit", - "build": "univer-cli build" - }, - "peerDependencies": { - "rxjs": ">=7.0.0" - }, - "dependencies": { - "@univerjs/core": "workspace:*", - "@univerjs/docs": "workspace:*", - "@univerjs/docs-drawing-ui": "workspace:*", - "@univerjs/docs-ui": "workspace:*", - "@univerjs/engine-render": "workspace:*", - "@univerjs/ui": "workspace:*", - "@univerjs/uniui": "workspace:*" - }, - "devDependencies": { - "@univerjs-infra/shared": "workspace:*", - "postcss": "^8.5.6", - "rxjs": "^7.8.2", - "tailwindcss": "3.4.18", - "typescript": "^5.9.3", - "vite": "^7.3.0", - "vitest": "^4.0.16" - } -} diff --git a/packages-experimental/uni-docs-ui/postcss.config.mjs b/packages-experimental/uni-docs-ui/postcss.config.mjs deleted file mode 100644 index 7d59f53133..0000000000 --- a/packages-experimental/uni-docs-ui/postcss.config.mjs +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@univerjs-infra/shared/postcss'; diff --git a/packages-experimental/uni-docs-ui/src/controllers/menu.schema.ts b/packages-experimental/uni-docs-ui/src/controllers/menu.schema.ts deleted file mode 100644 index 5c221f3ac0..0000000000 --- a/packages-experimental/uni-docs-ui/src/controllers/menu.schema.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { MenuSchemaType } from '@univerjs/ui'; -import { DocsUIMenuSchema } from '@univerjs/docs-ui'; -import { RibbonStartGroup } from '@univerjs/ui'; -import { FONT_GROUP_MENU_ID, UNI_MENU_POSITIONS } from '@univerjs/uniui'; -import { - DOC_BOLD_MUTATION_ID, - DOC_ITALIC_MUTATION_ID, - DOC_STRIKE_MUTATION_ID, - DOC_UNDERLINE_MUTATION_ID, - DocBoldMenuItemFactory, - DocItalicMenuItemFactory, - DocStrikeThroughMenuItemFactory, - DocUnderlineMenuItemFactory, -} from './menu'; - -export const menuSchema: MenuSchemaType = { - [UNI_MENU_POSITIONS.TOOLBAR_MAIN]: (DocsUIMenuSchema as any)[RibbonStartGroup.FORMAT], - [FONT_GROUP_MENU_ID]: { - [DOC_BOLD_MUTATION_ID]: { - order: 0, - menuItemFactory: DocBoldMenuItemFactory, - }, - [DOC_ITALIC_MUTATION_ID]: { - order: 1, - menuItemFactory: DocItalicMenuItemFactory, - }, - [DOC_UNDERLINE_MUTATION_ID]: { - order: 2, - menuItemFactory: DocUnderlineMenuItemFactory, - }, - [DOC_STRIKE_MUTATION_ID]: { - order: 3, - menuItemFactory: DocStrikeThroughMenuItemFactory, - }, - }, -}; diff --git a/packages-experimental/uni-docs-ui/src/controllers/menu.ts b/packages-experimental/uni-docs-ui/src/controllers/menu.ts deleted file mode 100644 index 68892d88ab..0000000000 --- a/packages-experimental/uni-docs-ui/src/controllers/menu.ts +++ /dev/null @@ -1,272 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { IAccessor } from '@univerjs/core'; -import type { IMenuButtonItem, IMenuItem } from '@univerjs/ui'; -import { BooleanNumber, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, ICommandService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core'; -import { DocSelectionManagerService, DocSkeletonManagerService, SetTextSelectionsOperation } from '@univerjs/docs'; -import { SetInlineFormatCommand } from '@univerjs/docs-ui'; -import { DocumentEditArea, IRenderManagerService } from '@univerjs/engine-render'; -import { getHeaderFooterMenuHiddenObservable, getMenuHiddenObservable, MenuItemType } from '@univerjs/ui'; -import { combineLatest, Observable } from 'rxjs'; - -export const DOC_ITALIC_MUTATION_ID = 'doc.command.uni-italic'; -export const DOC_BOLD_MUTATION_ID = 'doc.command.uni-bold'; -export const DOC_UNDERLINE_MUTATION_ID = 'doc.command.uni-underline'; -export const DOC_STRIKE_MUTATION_ID = 'doc.command.uni-strike'; -export const DOC_TABLE_MUTATION_ID = 'doc.command.uni-table'; - -export function DocBoldMenuItemFactory(accessor: IAccessor): IMenuButtonItem { - const commandService = accessor.get(ICommandService); - - return { - id: DOC_BOLD_MUTATION_ID, - type: MenuItemType.BUTTON, - icon: 'BoldIcon', - title: 'Set bold', - tooltip: 'toolbar.bold', - activated$: new Observable((subscriber) => { - const disposable = commandService.onCommandExecuted((c) => { - const id = c.id; - - if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) { - const textRun = getFontStyleAtCursor(accessor); - - if (textRun == null) { - return; - } - - const bl = textRun.ts?.bl; - - subscriber.next(bl === BooleanNumber.TRUE); - } - }); - - subscriber.next(false); - - return disposable.dispose; - }), - hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC), - }; -} - -export function DocItalicMenuItemFactory(accessor: IAccessor): IMenuButtonItem { - const commandService = accessor.get(ICommandService); - - return { - id: DOC_ITALIC_MUTATION_ID, - type: MenuItemType.BUTTON, - icon: 'ItalicIcon', - title: 'Set italic', - tooltip: 'toolbar.italic', - activated$: new Observable((subscriber) => { - const disposable = commandService.onCommandExecuted((c) => { - const id = c.id; - - if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) { - const textRun = getFontStyleAtCursor(accessor); - - if (textRun == null) { - return; - } - - const it = textRun.ts?.it; - - subscriber.next(it === BooleanNumber.TRUE); - } - }); - - subscriber.next(false); - - return disposable.dispose; - }), - hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC), - }; -} - -export function DocUnderlineMenuItemFactory(accessor: IAccessor): IMenuButtonItem { - const commandService = accessor.get(ICommandService); - - return { - id: DOC_UNDERLINE_MUTATION_ID, - type: MenuItemType.BUTTON, - icon: 'UnderlineIcon', - title: 'Set underline', - tooltip: 'toolbar.underline', - activated$: new Observable((subscriber) => { - const disposable = commandService.onCommandExecuted((c) => { - const id = c.id; - - if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) { - const textRun = getFontStyleAtCursor(accessor); - - if (textRun == null) { - return; - } - - const ul = textRun.ts?.ul; - - subscriber.next(ul?.s === BooleanNumber.TRUE); - } - }); - - subscriber.next(false); - - return disposable.dispose; - }), - hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC), - }; -} - -export function DocStrikeThroughMenuItemFactory(accessor: IAccessor): IMenuButtonItem { - const commandService = accessor.get(ICommandService); - - return { - id: DOC_STRIKE_MUTATION_ID, - type: MenuItemType.BUTTON, - icon: 'StrikethroughIcon', - title: 'Set strike through', - tooltip: 'toolbar.strikethrough', - activated$: new Observable((subscriber) => { - const disposable = commandService.onCommandExecuted((c) => { - const id = c.id; - - if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) { - const textRun = getFontStyleAtCursor(accessor); - - if (textRun == null) { - return; - } - - const st = textRun.ts?.st; - - subscriber.next(st?.s === BooleanNumber.TRUE); - } - }); - - subscriber.next(false); - - return disposable.dispose; - }), - hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC), - }; -} - -export function DocTableMenuFactory(accessor: IAccessor): IMenuItem { - return { - id: DOC_TABLE_MUTATION_ID, - type: MenuItemType.BUTTON, - icon: 'GridIcon', - tooltip: 'toolbar.table.main', - disabled$: getTableDisabledObservable(accessor), - // Do not show header footer menu and insert table at zen mode. - hidden$: combineLatest(getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC), getInsertTableHiddenObservable(accessor), getHeaderFooterMenuHiddenObservable(accessor), (one, two, three) => { - return one || two || three; - }), - }; -} - -function getFontStyleAtCursor(accessor: IAccessor) { - const univerInstanceService = accessor.get(IUniverInstanceService); - const textSelectionService = accessor.get(DocSelectionManagerService); - - const editorDataModel = univerInstanceService.getUniverDocInstance(DOCS_NORMAL_EDITOR_UNIT_ID_KEY); - const activeTextRange = textSelectionService.getActiveTextRange(); - - if (editorDataModel == null || activeTextRange == null) return null; - - const textRuns = editorDataModel.getBody()?.textRuns; - if (textRuns == null) return; - - const { startOffset } = activeTextRange; - const textRun = textRuns.find(({ st, ed }) => startOffset! >= st && startOffset! <= ed); - return textRun; -} - -function getTableDisabledObservable(accessor: IAccessor): Observable { - const docSelectionManagerService = accessor.get(DocSelectionManagerService); - - return new Observable((subscriber) => { - const subscription = docSelectionManagerService.textSelection$.subscribe((selection) => { - if (selection == null) { - subscriber.next(true); - return; - } - - const { textRanges } = selection; - - if (textRanges.length !== 1) { - subscriber.next(true); - return; - } - - const textRange = textRanges[0]; - const { collapsed, startNodePosition } = textRange; - - if (!collapsed) { - subscriber.next(true); - return; - } - - if (startNodePosition != null) { - const { path } = startNodePosition; - - // TODO: Not support insert table in table cell now. - if (path.indexOf('cells') !== -1) { - subscriber.next(true); - return; - } - } - - subscriber.next(false); - }); - - return () => subscription.unsubscribe(); - }); -} - -function getInsertTableHiddenObservable( - accessor: IAccessor -): Observable { - const univerInstanceService = accessor.get(IUniverInstanceService); - const renderManagerService = accessor.get(IRenderManagerService); - - return new Observable((subscriber) => { - const subscription = univerInstanceService.focused$.subscribe((unitId) => { - if (unitId == null) { - return subscriber.next(true); - } - const univerType = univerInstanceService.getUnitType(unitId); - - if (univerType !== UniverInstanceType.UNIVER_DOC) { - return subscriber.next(true); - } - - const currentRender = renderManagerService.getRenderById(unitId); - if (currentRender == null) { - return subscriber.next(true); - } - - const viewModel = currentRender.with(DocSkeletonManagerService).getViewModel(); - - viewModel.editAreaChange$.subscribe((editArea) => { - subscriber.next(editArea === DocumentEditArea.HEADER || editArea === DocumentEditArea.FOOTER); - }); - }); - - return () => subscription.unsubscribe(); - }); -} diff --git a/packages-experimental/uni-docs-ui/src/controllers/uni-docs-ui.controller.ts b/packages-experimental/uni-docs-ui/src/controllers/uni-docs-ui.controller.ts deleted file mode 100644 index d807efe0d4..0000000000 --- a/packages-experimental/uni-docs-ui/src/controllers/uni-docs-ui.controller.ts +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { ICommandService, IConfigService, Inject, Injector, IUniverInstanceService, UniverInstanceType } from '@univerjs/core'; -import { DOCS_IMAGE_MENU_ID } from '@univerjs/docs-drawing-ui'; -import { - BulletListCommand, - DocCreateTableOperation, - DocUIController, - OrderListCommand, - SetInlineFormatBoldCommand, - SetInlineFormatFontFamilyCommand, - SetInlineFormatFontSizeCommand, - SetInlineFormatItalicCommand, - SetInlineFormatStrikethroughCommand, - SetInlineFormatTextBackgroundColorCommand, - SetInlineFormatTextColorCommand, - SetInlineFormatUnderlineCommand, -} from '@univerjs/docs-ui'; -import { ComponentManager, ILayoutService, IMenuManagerService, IShortcutService, IUIPartsService } from '@univerjs/ui'; -import { BuiltinUniToolbarItemId, generateCloneMutation, UniToolbarService } from '@univerjs/uniui'; -import { DOC_BOLD_MUTATION_ID, DOC_ITALIC_MUTATION_ID, DOC_STRIKE_MUTATION_ID, DOC_TABLE_MUTATION_ID, DOC_UNDERLINE_MUTATION_ID } from './menu'; -import { menuSchema } from './menu.schema'; - -export class UniDocsUIController extends DocUIController { - constructor( - @Inject(Injector) injector: Injector, - @Inject(ComponentManager) componentManager: ComponentManager, - @ICommandService commandService: ICommandService, - @ILayoutService layoutService: ILayoutService, - @IMenuManagerService menuManagerService: IMenuManagerService, - @IUIPartsService uiPartsService: IUIPartsService, - @IUniverInstanceService univerInstanceService: IUniverInstanceService, - @IShortcutService shortcutService: IShortcutService, - @IConfigService configService: IConfigService, - @Inject(UniToolbarService) private readonly _toolbarService: UniToolbarService - ) { - super( - injector, - componentManager, - commandService, - layoutService, - menuManagerService, - uiPartsService, - univerInstanceService, - shortcutService, - configService - ); - - this._initUniMenus(); - this._initMutations(); - } - - private _initUniMenus(): void { - this._menuManagerService.appendRootMenu(menuSchema); - - ([ - [BuiltinUniToolbarItemId.FONT_FAMILY, SetInlineFormatFontFamilyCommand.id], - [BuiltinUniToolbarItemId.FONT_SIZE, SetInlineFormatFontSizeCommand.id], - [BuiltinUniToolbarItemId.COLOR, SetInlineFormatTextColorCommand.id], - [BuiltinUniToolbarItemId.BACKGROUND, SetInlineFormatTextBackgroundColorCommand.id], - [BuiltinUniToolbarItemId.IMAGE, DOCS_IMAGE_MENU_ID], - [BuiltinUniToolbarItemId.TABLE, DOC_TABLE_MUTATION_ID], - [BuiltinUniToolbarItemId.ORDER_LIST, OrderListCommand.id], - [BuiltinUniToolbarItemId.UNORDER_LIST, BulletListCommand.id], - ]).forEach(([id, menuId]) => { - this.disposeWithMe(this._toolbarService.implementItem(id, { id: menuId, type: UniverInstanceType.UNIVER_DOC })); - }); - } - - private _initMutations() { - [ - generateCloneMutation(DOC_BOLD_MUTATION_ID, SetInlineFormatBoldCommand), - generateCloneMutation(DOC_ITALIC_MUTATION_ID, SetInlineFormatItalicCommand), - generateCloneMutation(DOC_UNDERLINE_MUTATION_ID, SetInlineFormatUnderlineCommand), - generateCloneMutation(DOC_STRIKE_MUTATION_ID, SetInlineFormatStrikethroughCommand), - generateCloneMutation(DOC_TABLE_MUTATION_ID, DocCreateTableOperation), - ].forEach((mutation) => { - this.disposeWithMe(this._commandService.registerCommand(mutation)); - }); - } -} diff --git a/packages-experimental/uni-docs-ui/src/index.ts b/packages-experimental/uni-docs-ui/src/index.ts deleted file mode 100644 index 67f5352c2e..0000000000 --- a/packages-experimental/uni-docs-ui/src/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export { UniDocsUIController } from './controllers/uni-docs-ui.controller'; diff --git a/packages-experimental/uni-docs-ui/src/vite-env.d.ts b/packages-experimental/uni-docs-ui/src/vite-env.d.ts deleted file mode 100644 index 11f02fe2a0..0000000000 --- a/packages-experimental/uni-docs-ui/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/packages-experimental/uni-docs-ui/tailwind.config.ts b/packages-experimental/uni-docs-ui/tailwind.config.ts deleted file mode 100644 index 75967f186f..0000000000 --- a/packages-experimental/uni-docs-ui/tailwind.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { Config } from 'tailwindcss'; -import preset from '@univerjs-infra/shared/tailwind'; - -const config: Config = { - presets: [preset], - content: [ - './src/**/*.{js,ts,jsx,tsx}', - ], -}; - -export default config; diff --git a/packages-experimental/uni-docs-ui/tsconfig.json b/packages-experimental/uni-docs-ui/tsconfig.json deleted file mode 100644 index 018601b6b9..0000000000 --- a/packages-experimental/uni-docs-ui/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "extends": "@univerjs-infra/shared/tsconfigs/base", - "compilerOptions": { - "rootDir": "src", - "outDir": "lib/types" - }, - "references": [ - { - "path": "./tsconfig.node.json" - } - ], - "include": [ - "src" - ] -} diff --git a/packages-experimental/uni-docs-ui/tsconfig.node.json b/packages-experimental/uni-docs-ui/tsconfig.node.json deleted file mode 100644 index 4947a09903..0000000000 --- a/packages-experimental/uni-docs-ui/tsconfig.node.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "@univerjs-infra/shared/tsconfigs/node", - "include": ["vitest.config.ts"] -} diff --git a/packages-experimental/uni-docs-ui/vitest.config.ts b/packages-experimental/uni-docs-ui/vitest.config.ts deleted file mode 100644 index af97c6d7a2..0000000000 --- a/packages-experimental/uni-docs-ui/vitest.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import createConfig from '@univerjs-infra/shared/vitest'; - -export default createConfig(); diff --git a/packages-experimental/uni-formula-ui/README.md b/packages-experimental/uni-formula-ui/README.md deleted file mode 100644 index 953e36f3d2..0000000000 --- a/packages-experimental/uni-formula-ui/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# @univerjs/uni-formula-ui - -[![npm version](https://img.shields.io/npm/v/@univerjs/uni-formula-ui)](https://npmjs.org/packages/@univerjs/uni-formula-ui) -[![license](https://img.shields.io/npm/l/@univerjs/uni-formula-ui)](https://img.shields.io/npm/l/@univerjs/uni-formula-ui) - -## Introduction - -> TODO: Introduction - -## Usage - -### Installation - -```shell -npm i @univerjs/uni-formula-ui -``` diff --git a/packages-experimental/uni-formula-ui/package.json b/packages-experimental/uni-formula-ui/package.json deleted file mode 100644 index 4f117a9363..0000000000 --- a/packages-experimental/uni-formula-ui/package.json +++ /dev/null @@ -1,92 +0,0 @@ -{ - "name": "@univerjs/uni-formula-ui", - "version": "0.0.0", - "private": true, - "description": "", - "author": "DreamNum ", - "license": "Apache-2.0", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/univer" - }, - "homepage": "https://univer.ai", - "repository": { - "type": "git", - "url": "https://github.com/dream-num/univer" - }, - "bugs": { - "url": "https://github.com/dream-num/univer/issues" - }, - "keywords": [], - "exports": { - ".": "./src/index.ts", - "./*": "./src/*", - "./locale/*": "./src/locale/*.ts" - }, - "main": "./src/index.ts", - "types": "./lib/types/index.d.ts", - "publishConfig": { - "access": "public", - "main": "./lib/es/index.js", - "module": "./lib/es/index.js", - "exports": { - ".": { - "import": "./lib/es/index.js", - "require": "./lib/cjs/index.js", - "types": "./lib/types/index.d.ts" - }, - "./*": { - "import": "./lib/es/*", - "require": "./lib/cjs/*", - "types": "./lib/types/index.d.ts" - }, - "./locale/*": { - "import": "./lib/es/locale/*.js", - "require": "./lib/cjs/locale/*.js", - "types": "./lib/types/locale/*.d.ts" - }, - "./lib/*": "./lib/*" - } - }, - "directories": { - "lib": "lib" - }, - "files": [ - "lib" - ], - "scripts": { - "test": "vitest run", - "test:watch": "vitest", - "coverage": "vitest run --coverage", - "typecheck": "tsc --noEmit", - "build": "univer-cli build" - }, - "peerDependencies": { - "react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc", - "rxjs": ">=7.0.0" - }, - "dependencies": { - "@univerjs/core": "workspace:*", - "@univerjs/design": "workspace:*", - "@univerjs/docs": "workspace:*", - "@univerjs/docs-ui": "workspace:*", - "@univerjs/engine-formula": "workspace:*", - "@univerjs/engine-render": "workspace:*", - "@univerjs/icons": "^1.1.0", - "@univerjs/rpc": "workspace:*", - "@univerjs/sheets-formula-ui": "workspace:*", - "@univerjs/slides-ui": "workspace:*", - "@univerjs/ui": "workspace:*", - "@univerjs/uni-formula": "workspace:*" - }, - "devDependencies": { - "@univerjs-infra/shared": "workspace:*", - "postcss": "^8.5.6", - "react": "18.3.1", - "rxjs": "^7.8.2", - "tailwindcss": "3.4.18", - "typescript": "^5.9.3", - "vite": "^7.3.0", - "vitest": "^4.0.16" - } -} diff --git a/packages-experimental/uni-formula-ui/postcss.config.mjs b/packages-experimental/uni-formula-ui/postcss.config.mjs deleted file mode 100644 index 7d59f53133..0000000000 --- a/packages-experimental/uni-formula-ui/postcss.config.mjs +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@univerjs-infra/shared/postcss'; diff --git a/packages-experimental/uni-formula-ui/src/commands/commands/doc.command.ts b/packages-experimental/uni-formula-ui/src/commands/commands/doc.command.ts deleted file mode 100644 index c4b8960672..0000000000 --- a/packages-experimental/uni-formula-ui/src/commands/commands/doc.command.ts +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { ICommand, IDocumentBody, IMutationInfo } from '@univerjs/core'; -import type { IAddDocUniFormulaMutationParams, IRemoveDocUniFormulaMutationParams, IUpdateDocUniFormulaMutationParams } from '@univerjs/uni-formula'; -import { BuildTextUtils, CommandType, CustomRangeType, generateRandomId, ICommandService, LocaleService, makeCustomRangeStream, sequenceExecute } from '@univerjs/core'; -import { replaceSelectionFactory } from '@univerjs/docs'; -import { AddDocUniFormulaMutation, RemoveDocUniFormulaMutation, UpdateDocUniFormulaMutation } from '@univerjs/uni-formula'; - -export interface IAddDocUniFormulaCommandParams { - unitId: string; - startIndex: number; - - f: string; -} - -export const AddDocUniFormulaCommand: ICommand = { - type: CommandType.COMMAND, - id: 'doc.command.add-uni-formula', - async handler(accessor, params: IAddDocUniFormulaCommandParams) { - const { f, unitId, startIndex } = params; - - const commandService = accessor.get(ICommandService); - const localeService = accessor.get(LocaleService); - - const rangeId = generateRandomId(); - const placeholder = localeService.t('uni-formula.command.stream-placeholder'); - const dataStream = makeCustomRangeStream(placeholder); - const body: IDocumentBody = { - dataStream, - customRanges: [{ - startIndex: 0, - endIndex: dataStream.length - 1, - rangeId, - rangeType: CustomRangeType.UNI_FORMULA, - wholeEntity: true, - }], - }; - - const insertCustomRangeMutation = replaceSelectionFactory(accessor, { - unitId, - body, - selection: BuildTextUtils.selection.makeSelection(startIndex, startIndex + 1), - }); - - if (insertCustomRangeMutation) { - const addFormulaResourceMutation: IMutationInfo = { - id: AddDocUniFormulaMutation.id, - params: { unitId, rangeId, f }, - }; - - return sequenceExecute([insertCustomRangeMutation, addFormulaResourceMutation], commandService).result; - } - - return false; - }, -}; - -export interface IUpdateDocUniFormulaCommandParams { - unitId: string; - rangeId: string; - f: string; -} - -// TODO: implement update & remove command - -export const UpdateDocUniFormulaCommand: ICommand = { - type: CommandType.COMMAND, - id: 'doc.command.update-uni-formula', - handler: (accessor, params: IUpdateDocUniFormulaCommandParams) => { - const commandService = accessor.get(ICommandService); - return commandService.syncExecuteCommand(UpdateDocUniFormulaMutation.id, params as IUpdateDocUniFormulaMutationParams); - }, -}; - -export interface IRemoveDocUniFormulaCommandParams { - unitId: string; - rangeId: string; -} - -export const RemoveDocUniFormulaCommand: ICommand = { - type: CommandType.COMMAND, - id: 'doc.command.remove-uni-formula', - handler: (accessor, params: IRemoveDocUniFormulaCommandParams) => { - const commandService = accessor.get(ICommandService); - // TODO: maybe remove formula under selection? - return commandService.syncExecuteCommand(RemoveDocUniFormulaMutation.id, params as IRemoveDocUniFormulaMutationParams); - }, -}; diff --git a/packages-experimental/uni-formula-ui/src/commands/commands/slide.command.ts b/packages-experimental/uni-formula-ui/src/commands/commands/slide.command.ts deleted file mode 100644 index d3176b0ccc..0000000000 --- a/packages-experimental/uni-formula-ui/src/commands/commands/slide.command.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { ICommand, IDocumentBody } from '@univerjs/core'; -import { BuildTextUtils, CommandType, CustomRangeType, generateRandomId, ICommandService, LocaleService, makeCustomRangeStream } from '@univerjs/core'; -import { replaceSelectionFactory } from '@univerjs/docs'; -import { SLIDE_EDITOR_ID } from '@univerjs/slides-ui'; -import { SlideUIFormulaCacheService } from '../../services/slide-ui-formula-cache.service'; - -export interface IAddSlideUniFormulaCommandParams { - unitId: string; - pageId: string; - elementId: string; - startIndex: number; - - f: string; -} - -export const AddSlideUniFormulaCommand: ICommand = { - type: CommandType.COMMAND, - id: 'slide.command.add-slide-uni-formula', - async handler(accessor, params: IAddSlideUniFormulaCommandParams) { - const { startIndex } = params; - - const commandService = accessor.get(ICommandService); - const slideUiFormulaCacheService = accessor.get(SlideUIFormulaCacheService); - const localeService = accessor.get(LocaleService); - const placeholder = localeService.t('uni-formula.command.stream-placeholder'); - - // TODO: use placeholder here? - const rangeId = generateRandomId(); - const dataStream = makeCustomRangeStream(placeholder); - const body: IDocumentBody = { - dataStream, - customRanges: [{ - startIndex: 0, - endIndex: dataStream.length - 1, - rangeId, - rangeType: CustomRangeType.UNI_FORMULA, - wholeEntity: true, - }], - }; - - const insertCustomRangeMutation = replaceSelectionFactory(accessor, { - unitId: SLIDE_EDITOR_ID, - body, - selection: BuildTextUtils.selection.makeSelection(startIndex, startIndex + 1), - }); - - // NOTE: For slides, the process to update a element's content is pretty different from docs. - // Since the text editor in slides is temporary, we don't need to update the content of the element when user - // has not confirmed the change. So we don't need to add a mutation to update resources here. - // We will do that when user confirms the change. - - if (insertCustomRangeMutation) { - slideUiFormulaCacheService.writeCache(rangeId, params); - return commandService.executeCommand(insertCustomRangeMutation.id, insertCustomRangeMutation.params, { onlyLocal: true }); - } - - return false; - }, -}; diff --git a/packages-experimental/uni-formula-ui/src/commands/operations/operation.ts b/packages-experimental/uni-formula-ui/src/commands/operations/operation.ts deleted file mode 100644 index 4cb6439c0d..0000000000 --- a/packages-experimental/uni-formula-ui/src/commands/operations/operation.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { ICommand, IOperation } from '@univerjs/core'; -import { CommandType } from '@univerjs/core'; -import { UniFormulaPopupService } from '../../services/formula-popup.service'; - -export interface IDocPopupPosition { - rangeId?: string; -} - -export interface ISlidePopupPosition extends IDocPopupPosition { - pageId: string; - elementId: string; -} - -export type IPopupPosition = IDocPopupPosition | ISlidePopupPosition; - -export function isSlidePosition(position?: IPopupPosition): position is ISlidePopupPosition { - return !!position && 'pageId' in position; -} - -export interface IShowDocFormulaPopupOperationParams { - unitId: string; - startIndex: number; - type?: 'new' | 'existing'; - position: IDocPopupPosition; -} - -export interface IShowSlideFormulaPopupOPerationParams extends IShowDocFormulaPopupOperationParams { - position: ISlidePopupPosition; -} - -export type IShowFormulaPopupOperationParams = IShowDocFormulaPopupOperationParams | IShowSlideFormulaPopupOPerationParams; - -export const ShowFormulaPopupOperation: IOperation = { - id: 'uni-formula.operation.show-formula-popup', - type: CommandType.OPERATION, - handler(accessor, params: IShowFormulaPopupOperationParams) { - const { type = 'new', startIndex, unitId, position } = params; - const { rangeId } = position; - const formulaPopupService = accessor.get(UniFormulaPopupService); - - if (type === 'existing' && !rangeId) return false; - return formulaPopupService.showDocPopup(unitId, startIndex, type, position); - }, -}; - -export const CloseFormulaPopupOperation: IOperation = { - id: 'uni-formula.operation.close-formula-popup', - type: CommandType.OPERATION, - handler(accessor) { - const docFormulaPopupService = accessor.get(UniFormulaPopupService); - return docFormulaPopupService.closePopup(true); - }, -}; - -export const ConfirmFormulaPopupCommand: ICommand = { - id: 'uni-formula.operation.confirm-formula-popup', - type: CommandType.COMMAND, - handler(accessor) { - const docFormulaPopupService = accessor.get(UniFormulaPopupService); - return docFormulaPopupService.confirmPopup(); - }, -}; diff --git a/packages-experimental/uni-formula-ui/src/const.ts b/packages-experimental/uni-formula-ui/src/const.ts deleted file mode 100644 index a1125577fa..0000000000 --- a/packages-experimental/uni-formula-ui/src/const.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export const DOC_FORMULA_UI_PLUGIN_NAME = 'DOC_FORMULA_UI_PLUGIN'; diff --git a/packages-experimental/uni-formula-ui/src/controllers/doc-formula-input.controller.ts b/packages-experimental/uni-formula-ui/src/controllers/doc-formula-input.controller.ts deleted file mode 100644 index c02e742ed9..0000000000 --- a/packages-experimental/uni-formula-ui/src/controllers/doc-formula-input.controller.ts +++ /dev/null @@ -1,188 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { DocumentDataModel } from '@univerjs/core'; -import type { IInsertCommandParams } from '@univerjs/docs-ui'; -import type { IShowFormulaPopupOperationParams } from '../commands/operations/operation'; -import { CustomRangeType, Disposable, ICommandService, ILogService, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core'; -import { DocSelectionManagerService } from '@univerjs/docs'; - -import { DeleteLeftCommand, DocEventManagerService, IEditorService, InsertCommand, MoveCursorOperation } from '@univerjs/docs-ui'; -import { IRenderManagerService } from '@univerjs/engine-render'; -import { filter, map, switchMap } from 'rxjs'; -import { AddDocUniFormulaCommand, RemoveDocUniFormulaCommand, UpdateDocUniFormulaCommand } from '../commands/commands/doc.command'; -import { CloseFormulaPopupOperation, ShowFormulaPopupOperation } from '../commands/operations/operation'; -import { UniFormulaPopupService } from '../services/formula-popup.service'; -import { UNI_FORMULA_EDITOR_ID } from '../views/components/DocFormulaPopup'; - -const FORMULA_INPUT_TRIGGER_CHAR = '='; - -export class DocUniFormulaInputController extends Disposable { - constructor( - @ICommandService private readonly _commandService: ICommandService, - @IUniverInstanceService private readonly _instanceSrv: IUniverInstanceService, - @IEditorService private readonly _editorService: IEditorService, - @ILogService private readonly _logService: ILogService, - @Inject(UniFormulaPopupService) private readonly _formulaPopupSrv: UniFormulaPopupService, - @IRenderManagerService private readonly _renderManagerService: IRenderManagerService, - @Inject(DocSelectionManagerService) private readonly _textSelectionManagerService: DocSelectionManagerService - ) { - super(); - - this._initKeyboardListeners(); - this._initCommands(); - this._initHoverListener(); - } - - private _initCommands(): void { - [ - AddDocUniFormulaCommand, - RemoveDocUniFormulaCommand, - UpdateDocUniFormulaCommand, - ].forEach((command) => this._commandService.registerCommand(command)); - } - - private _initKeyboardListeners(): void { - // TODO@wzhudev: only need to listen when a doc unit is focused. - // The formula input trigger works not exactly the same as Mention. - this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => { - const currentEditor = this._editorService.getFocusEditor(); - const focusedUnit = this._instanceSrv.getFocusedUnit(); - - const { id } = commandInfo; - - if ( - currentEditor?.getEditorId() === UNI_FORMULA_EDITOR_ID || - focusedUnit?.type !== UniverInstanceType.UNIVER_DOC - ) { - return; - } - - if (id === InsertCommand.id) { - const params = commandInfo.params as IInsertCommandParams; - const activeRange = this._textSelectionManagerService.getActiveTextRange(); - if (params.body.dataStream === FORMULA_INPUT_TRIGGER_CHAR && activeRange) { - this._showPopup({ - startIndex: activeRange.startOffset! - 1, - unitId: focusedUnit.getUnitId(), - position: {}, - }); - } else if (this._formulaPopupSrv.popupInfo) { - this._closePopup(); - } - } - - if (id === MoveCursorOperation.id || id === DeleteLeftCommand.id) { - this._closePopup(); - } - })); - } - - private _initHoverListener(): void { - const rangesWithDoc$ = this._instanceSrv.focused$.pipe( - map((focused) => focused ? this._instanceSrv.getUnit(focused, UniverInstanceType.UNIVER_DOC) : null), - map((doc) => doc && { doc, docEventManagerService: this._renderManagerService.getRenderById(doc!.getUnitId())?.with(DocEventManagerService) }), - filter((info) => !!info), - switchMap((info) => info.docEventManagerService!.hoverCustomRanges$.pipe(map((ranges) => ({ doc: info.doc, ranges })))) - ); - - this.disposeWithMe(rangesWithDoc$.subscribe(({ doc, ranges: customRanges }) => { - if ( - !doc || - this._formulaPopupSrv.popupInfo?.type === 'new' || - this._formulaPopupSrv.popupLocked - ) { - return; - } - - const formulaCustomRange = customRanges.find((range) => range.range.rangeType === CustomRangeType.UNI_FORMULA)?.range; - if (formulaCustomRange) { - const { startIndex, rangeId } = formulaCustomRange; - this._logService.debug('[DocUniFormulaController]: activeCustomRanges', customRanges); - this._showPopup({ - startIndex, - unitId: doc.getUnitId(), - position: { rangeId }, - type: 'existing', - }); - } else { - if (!this._hovered) { - this._closePopup(500); - } - } - })); - this.disposeWithMe(rangesWithDoc$.subscribe(({ doc, ranges: customRanges }) => { - if ( - !doc || - this._formulaPopupSrv.popupInfo?.type === 'new' || - this._formulaPopupSrv.popupLocked - ) { - return; - } - - const formulaCustomRange = customRanges.find((range) => range.range.rangeType === CustomRangeType.UNI_FORMULA)?.range; - if (formulaCustomRange) { - const { startIndex, rangeId } = formulaCustomRange; - this._logService.debug('[DocUniFormulaController]: activeCustomRanges', customRanges); - this._showPopup({ - startIndex, - unitId: doc.getUnitId(), - position: { rangeId }, - type: 'existing', - }); - } else { - if (!this._hovered) { - this._closePopup(500); - } - } - })); - - this.disposeWithMe(this._formulaPopupSrv.popupHovered$.subscribe((hovered) => { - if (hovered) { - this._removeTimer(); - } - - this._hovered = hovered; - })); - } - - private _hovered = false; - - private _removeTimer(): void { - if (this._closePopupTimer !== null) { - window.clearTimeout(this._closePopupTimer); - this._closePopupTimer = null; - } - } - - private _showPopup(params: IShowFormulaPopupOperationParams): void { - this._removeTimer(); - this._commandService.executeCommand(ShowFormulaPopupOperation.id, params); - } - - private _closePopupTimer: number | null = null; - private _closePopup(timeout: number = 0): void { - if (!this._formulaPopupSrv.popupInfo) { - return; - } - - if (timeout === 0) { - this._commandService.executeCommand(CloseFormulaPopupOperation.id); - } else { - this._closePopupTimer = window.setTimeout(() => this._closePopup(0), timeout); - } - } -} diff --git a/packages-experimental/uni-formula-ui/src/controllers/slide-formula-input.controller.ts b/packages-experimental/uni-formula-ui/src/controllers/slide-formula-input.controller.ts deleted file mode 100644 index b7b7bd0df5..0000000000 --- a/packages-experimental/uni-formula-ui/src/controllers/slide-formula-input.controller.ts +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { IInsertCommandParams } from '@univerjs/docs-ui'; -import type { IShowFormulaPopupOperationParams, ISlidePopupPosition } from '../commands/operations/operation'; -import { Disposable, ICommandService, Inject, Injector, IUniverInstanceService, UniverInstanceType } from '@univerjs/core'; -import { DocSelectionManagerService } from '@univerjs/docs'; -import { IEditorService, InsertCommand } from '@univerjs/docs-ui'; -import { ISlideEditorBridgeService } from '@univerjs/slides-ui'; -import { AddSlideUniFormulaCommand } from '../commands/commands/slide.command'; -import { CloseFormulaPopupOperation, ShowFormulaPopupOperation } from '../commands/operations/operation'; -import { UniFormulaPopupService } from '../services/formula-popup.service'; -import { UNI_FORMULA_EDITOR_ID } from '../views/components/DocFormulaPopup'; - -const FORMULA_INPUT_TRIGGER_CHAR = '='; - -export class SlideUniFormulaInputController extends Disposable { - constructor( - @Inject(Injector) private readonly _injector: Injector, - @IUniverInstanceService private readonly _instanceSrv: IUniverInstanceService, - @ICommandService private readonly _commandSrv: ICommandService, - @IEditorService private readonly _editorSrv: IEditorService, - @Inject(DocSelectionManagerService) private readonly _textSelectionManagerService: DocSelectionManagerService, - @Inject(UniFormulaPopupService) private readonly _formulaPopupSrv: UniFormulaPopupService - ) { - super(); - - this._initCommands(); - this._initKeyboardListeners(); - } - - private _initCommands() { - [ - AddSlideUniFormulaCommand, - ].forEach((cmd) => this._commandSrv.registerCommand(cmd)); - } - - private _initKeyboardListeners(): void { - this.disposeWithMe(this._commandSrv.onCommandExecuted((commandInfo) => { - const currentEditor = this._editorSrv.getFocusEditor(); - const focusedUnit = this._instanceSrv.getFocusedUnit(); - - const { id } = commandInfo; - - if ( - currentEditor?.getEditorId() === UNI_FORMULA_EDITOR_ID || - focusedUnit?.type !== UniverInstanceType.UNIVER_SLIDE - ) { - return; - } - - if (id === InsertCommand.id) { - const params = commandInfo.params as IInsertCommandParams; - const activeRange = this._textSelectionManagerService.getActiveTextRange(); - if (params.body.dataStream === FORMULA_INPUT_TRIGGER_CHAR && activeRange) { - // NOTE: we can avoid manually get the SlideEditorBridgeService when we split - // slide formula editor plugin into a separate package. - const editorBridgeService = this._injector.get(ISlideEditorBridgeService); - const editorRect = editorBridgeService.getEditorRect(); - const { pageId, richTextObj } = editorRect; - const { oKey } = richTextObj; - this._showPopup({ - startIndex: activeRange.startOffset! - 1, - unitId: focusedUnit.getUnitId(), - position: { - pageId, - elementId: oKey, - } as ISlidePopupPosition, - }); - } else if (this._formulaPopupSrv.popupInfo) { - this._closePopup(); - } - } - })); - } - - private _removeTimer(): void { - if (this._closePopupTimer !== null) { - window.clearTimeout(this._closePopupTimer); - this._closePopupTimer = null; - } - } - - private _showPopup(params: IShowFormulaPopupOperationParams): void { - this._removeTimer(); - this._commandSrv.executeCommand(ShowFormulaPopupOperation.id, params); - } - - private _closePopupTimer: number | null = null; - private _closePopup(timeout: number = 0): void { - if (!this._formulaPopupSrv.popupInfo) { - return; - } - - if (timeout === 0) { - this._commandSrv.executeCommand(CloseFormulaPopupOperation.id); - } else { - this._closePopupTimer = window.setTimeout(() => this._closePopup(0), timeout); - } - } -} diff --git a/packages-experimental/uni-formula-ui/src/controllers/uni-formula-ui.controller.ts b/packages-experimental/uni-formula-ui/src/controllers/uni-formula-ui.controller.ts deleted file mode 100644 index e4f940df50..0000000000 --- a/packages-experimental/uni-formula-ui/src/controllers/uni-formula-ui.controller.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Disposable, ICommandService, Inject } from '@univerjs/core'; -import { ComponentManager } from '@univerjs/ui'; -import { CloseFormulaPopupOperation, ConfirmFormulaPopupCommand, ShowFormulaPopupOperation } from '../commands/operations/operation'; -import { UniFormulaPopup } from '../views/components/DocFormulaPopup'; - -export class UniFormulaUniController extends Disposable { - constructor( - @ICommandService private readonly _commandSrv: ICommandService, - @Inject(ComponentManager) private readonly _componentManager: ComponentManager - ) { - super(); - - [ - ShowFormulaPopupOperation, - CloseFormulaPopupOperation, - ConfirmFormulaPopupCommand, - ].forEach((command) => this._commandSrv.registerCommand(command)); - - this.disposeWithMe(this._componentManager.register(UniFormulaPopup.componentKey, UniFormulaPopup)); - } -} diff --git a/packages-experimental/uni-formula-ui/src/global.css b/packages-experimental/uni-formula-ui/src/global.css deleted file mode 100644 index 7c05d4ddc4..0000000000 --- a/packages-experimental/uni-formula-ui/src/global.css +++ /dev/null @@ -1,2 +0,0 @@ -@tailwind components; -@tailwind utilities; diff --git a/packages-experimental/uni-formula-ui/src/index.ts b/packages-experimental/uni-formula-ui/src/index.ts deleted file mode 100644 index bdde3d6a5f..0000000000 --- a/packages-experimental/uni-formula-ui/src/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import './global.css'; - -export { UniverDocUniFormulaUIPlugin } from './plugin'; -export { UniFormulaService } from './services/uni-formula.service'; diff --git a/packages-experimental/uni-formula-ui/src/locale/ca-ES.ts b/packages-experimental/uni-formula-ui/src/locale/ca-ES.ts deleted file mode 100644 index 8afd24641a..0000000000 --- a/packages-experimental/uni-formula-ui/src/locale/ca-ES.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type enUS from './en-US'; - -const locale: typeof enUS = { - 'uni-formula': { - popup: { - title: { - new: 'Crear nova fórmula', - existing: 'Edita la fórmula', - }, - placeholder: 'Fes clic aquí per inserir una fórmula o continua escrivint per tancar...', - button: { - confirm: 'Confirma', - cancel: 'Cancel·la', - }, - }, - command: { - 'stream-placeholder': 'Fórmula Uni', - }, - }, -}; - -export default locale; diff --git a/packages-experimental/uni-formula-ui/src/locale/en-US.ts b/packages-experimental/uni-formula-ui/src/locale/en-US.ts deleted file mode 100644 index 5609285675..0000000000 --- a/packages-experimental/uni-formula-ui/src/locale/en-US.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const locale = { - 'uni-formula': { - popup: { - title: { - new: 'Create new formula', - existing: 'Edit formula', - }, - placeholder: 'Click here to insert formula or continue typing to close...', - button: { - confirm: 'Confirm', - cancel: 'Cancel', - }, - }, - command: { - 'stream-placeholder': 'Uni Formula', - }, - }, -}; - -export default locale; diff --git a/packages-experimental/uni-formula-ui/src/locale/es-ES.ts b/packages-experimental/uni-formula-ui/src/locale/es-ES.ts deleted file mode 100644 index a9492fbe4e..0000000000 --- a/packages-experimental/uni-formula-ui/src/locale/es-ES.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type enUS from './en-US'; - -const locale: typeof enUS = { - 'uni-formula': { - popup: { - title: { - new: 'Crear nueva fórmula', - existing: 'Editar fórmula', - }, - placeholder: 'Haz clic aquí para insertar una fórmula o continúa escribiendo para cerrar...', - button: { - confirm: 'Confirmar', - cancel: 'Cancelar', - }, - }, - command: { - 'stream-placeholder': 'Fórmula Uni', - }, - }, -}; - -export default locale; diff --git a/packages-experimental/uni-formula-ui/src/locale/fa-IR.ts b/packages-experimental/uni-formula-ui/src/locale/fa-IR.ts deleted file mode 100644 index 60e6fa98ad..0000000000 --- a/packages-experimental/uni-formula-ui/src/locale/fa-IR.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type enUS from './en-US'; - -const locale: typeof enUS = { - 'uni-formula': { - popup: { - title: { - new: 'ایجاد فرمول جدید', - existing: 'ویرایش فرمول', - }, - placeholder: 'برای درج فرمول اینجا کلیک کنید یا برای ادامه تایپ کردن بسته شود...', - button: { - confirm: 'تایید', - cancel: 'انصراف', - }, - }, - command: { - 'stream-placeholder': 'فرمول Uni', - }, - }, -}; - -export default locale; diff --git a/packages-experimental/uni-formula-ui/src/locale/fr-FR.ts b/packages-experimental/uni-formula-ui/src/locale/fr-FR.ts deleted file mode 100644 index 87f9fab2db..0000000000 --- a/packages-experimental/uni-formula-ui/src/locale/fr-FR.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type enUS from './en-US'; - -const locale: typeof enUS = { - 'uni-formula': { - popup: { - title: { - new: 'Créer une nouvelle formule', - existing: 'Modifier la formule', - }, - placeholder: 'Cliquez ici pour insérer une formule ou continuez à taper pour fermer...', - button: { - confirm: 'Confirmer', - cancel: 'Annuler', - }, - }, - command: { - 'stream-placeholder': 'Formule Uni', - }, - }, -}; - -export default locale; diff --git a/packages-experimental/uni-formula-ui/src/locale/ja-JP.ts b/packages-experimental/uni-formula-ui/src/locale/ja-JP.ts deleted file mode 100644 index bd1096dd55..0000000000 --- a/packages-experimental/uni-formula-ui/src/locale/ja-JP.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type enUS from './en-US'; - -const locale: typeof enUS = { - 'uni-formula': { - popup: { - title: { - new: '新しい数式を作成', - existing: '数式を編集', - }, - placeholder: '数式を挿入するか、入力を続けて閉じます...', - button: { - confirm: '確定', - cancel: 'キャンセル', - }, - }, - command: { - 'stream-placeholder': 'Uni Formula', - }, - }, -}; - -export default locale; diff --git a/packages-experimental/uni-formula-ui/src/locale/ko-KR.ts b/packages-experimental/uni-formula-ui/src/locale/ko-KR.ts deleted file mode 100644 index 40e7d2f324..0000000000 --- a/packages-experimental/uni-formula-ui/src/locale/ko-KR.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type enUS from './en-US'; - -const locale: typeof enUS = { - 'uni-formula': { - popup: { - title: { - new: '새 수식 생성', - existing: '수식 편집', - }, - placeholder: '수식을 삽입하거나 계속 입력하여 닫습니다...', - button: { - confirm: '확인', - cancel: '취소', - }, - }, - command: { - 'stream-placeholder': 'Uni Formula', - }, - }, -}; - -export default locale; diff --git a/packages-experimental/uni-formula-ui/src/locale/ru-RU.ts b/packages-experimental/uni-formula-ui/src/locale/ru-RU.ts deleted file mode 100644 index 9ff3b4452f..0000000000 --- a/packages-experimental/uni-formula-ui/src/locale/ru-RU.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type enUS from './en-US'; - -const locale: typeof enUS = { - 'uni-formula': { - popup: { - title: { - new: 'Create new formula', - existing: 'Edit formula', - }, - placeholder: 'Click here to insert formula or continue typing to close...', - button: { - confirm: 'Confirm', - cancel: 'Cancel', - }, - }, - command: { - 'stream-placeholder': 'Uni Formula', - }, - }, -}; - -export default locale; diff --git a/packages-experimental/uni-formula-ui/src/locale/vi-VN.ts b/packages-experimental/uni-formula-ui/src/locale/vi-VN.ts deleted file mode 100644 index 9ff3b4452f..0000000000 --- a/packages-experimental/uni-formula-ui/src/locale/vi-VN.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type enUS from './en-US'; - -const locale: typeof enUS = { - 'uni-formula': { - popup: { - title: { - new: 'Create new formula', - existing: 'Edit formula', - }, - placeholder: 'Click here to insert formula or continue typing to close...', - button: { - confirm: 'Confirm', - cancel: 'Cancel', - }, - }, - command: { - 'stream-placeholder': 'Uni Formula', - }, - }, -}; - -export default locale; diff --git a/packages-experimental/uni-formula-ui/src/locale/zh-CN.ts b/packages-experimental/uni-formula-ui/src/locale/zh-CN.ts deleted file mode 100644 index 8e7a9ab1c0..0000000000 --- a/packages-experimental/uni-formula-ui/src/locale/zh-CN.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type enUS from './en-US'; - -const locale: typeof enUS = { - 'uni-formula': { - popup: { - title: { - new: '添加公式', - existing: '编辑公式', - }, - placeholder: '点击此处添加公式,或继续输入以关闭', - button: { - confirm: '确认', - cancel: '取消', - }, - }, - command: { - 'stream-placeholder': '无界公式', - }, - }, -}; - -export default locale; diff --git a/packages-experimental/uni-formula-ui/src/locale/zh-TW.ts b/packages-experimental/uni-formula-ui/src/locale/zh-TW.ts deleted file mode 100644 index 9ff3b4452f..0000000000 --- a/packages-experimental/uni-formula-ui/src/locale/zh-TW.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type enUS from './en-US'; - -const locale: typeof enUS = { - 'uni-formula': { - popup: { - title: { - new: 'Create new formula', - existing: 'Edit formula', - }, - placeholder: 'Click here to insert formula or continue typing to close...', - button: { - confirm: 'Confirm', - cancel: 'Cancel', - }, - }, - command: { - 'stream-placeholder': 'Uni Formula', - }, - }, -}; - -export default locale; diff --git a/packages-experimental/uni-formula-ui/src/plugin.ts b/packages-experimental/uni-formula-ui/src/plugin.ts deleted file mode 100644 index 919728b9df..0000000000 --- a/packages-experimental/uni-formula-ui/src/plugin.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { Dependency } from '@univerjs/core'; -import { DependentOn, Inject, Injector, Plugin, touchDependencies, UniverInstanceType } from '@univerjs/core'; - -import { IUniFormulaService, UniverDocUniFormulaPlugin } from '@univerjs/uni-formula'; -import { DOC_FORMULA_UI_PLUGIN_NAME } from './const'; -import { DocUniFormulaInputController } from './controllers/doc-formula-input.controller'; -import { SlideUniFormulaInputController } from './controllers/slide-formula-input.controller'; -import { UniFormulaUniController } from './controllers/uni-formula-ui.controller'; -import { UniFormulaPopupService } from './services/formula-popup.service'; -import { SlideUIFormulaCacheService } from './services/slide-ui-formula-cache.service'; -import { UniFormulaService } from './services/uni-formula.service'; - -@DependentOn(UniverDocUniFormulaPlugin) -export class UniverDocUniFormulaUIPlugin extends Plugin { - static override pluginName: string = DOC_FORMULA_UI_PLUGIN_NAME; - static override type: UniverInstanceType = UniverInstanceType.UNIVER_UNKNOWN; - - constructor( - _config: unknown, - @Inject(Injector) protected readonly _injector: Injector - ) { - super(); - } - - override onStarting() { - ([ - [UniFormulaUniController], - [DocUniFormulaInputController], - [SlideUniFormulaInputController], - [SlideUIFormulaCacheService], - [UniFormulaPopupService], - [IUniFormulaService, { useClass: UniFormulaService }], - ] as Dependency[]).forEach((d) => this._injector.add(d)); - } - - override onReady(): void { - touchDependencies(this._injector, [ - [IUniFormulaService], - ]); - } - - override onSteady(): void { - touchDependencies(this._injector, [ - [UniFormulaUniController], - [DocUniFormulaInputController], - [SlideUniFormulaInputController], - ]); - } -} diff --git a/packages-experimental/uni-formula-ui/src/services/formula-popup.service.ts b/packages-experimental/uni-formula-ui/src/services/formula-popup.service.ts deleted file mode 100644 index 57458d82a5..0000000000 --- a/packages-experimental/uni-formula-ui/src/services/formula-popup.service.ts +++ /dev/null @@ -1,178 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { IDisposable, Nullable } from '@univerjs/core'; -import type { IShortcutItem } from '@univerjs/ui'; -import type { IAddDocUniFormulaCommandParams } from '../commands/commands/doc.command'; -import type { IAddSlideUniFormulaCommandParams } from '../commands/commands/slide.command'; -import type { IPopupPosition } from '../commands/operations/operation'; -import { BuildTextUtils, Disposable, FORMULA_EDITOR_ACTIVATED, ICommandService, IContextService, ILogService, Inject } from '@univerjs/core'; -import { DocCanvasPopManagerService } from '@univerjs/docs-ui'; -import { FORMULA_PROMPT_ACTIVATED } from '@univerjs/sheets-formula-ui'; -import { IShortcutService, KeyCode } from '@univerjs/ui'; -import { IUniFormulaService } from '@univerjs/uni-formula'; -import { BehaviorSubject, Subject } from 'rxjs'; -import { AddDocUniFormulaCommand } from '../commands/commands/doc.command'; -import { AddSlideUniFormulaCommand } from '../commands/commands/slide.command'; -import { ConfirmFormulaPopupCommand, isSlidePosition } from '../commands/operations/operation'; - -export const DOC_FORMULA_POPUP_KEY = 'DOC_FORMULA_POPUP' as const; - -export interface IUniFormulaPopupInfo { - unitId: string; - type: 'new' | 'existing'; - f: Nullable; - disposable: IDisposable; - startIndex: number; - position?: IPopupPosition; -} - -export class UniFormulaPopupService extends Disposable { - private readonly _popupInfo$ = new BehaviorSubject>(null); - readonly popupInfo$ = this._popupInfo$.asObservable(); - get popupInfo(): Nullable { return this._popupInfo$.getValue(); } - - private _popupLocked = false; - get popupLocked(): boolean { return this._popupLocked; } - - private readonly _popupHovered$ = new Subject(); - readonly popupHovered$ = this._popupHovered$.asObservable(); - - private _cachedFormulaString = ''; - - constructor( - @Inject(DocCanvasPopManagerService) private readonly _docCanvasPopupManagerService: DocCanvasPopManagerService, - @IUniFormulaService private readonly _uniFormulaService: IUniFormulaService, - @IContextService private readonly _contextService: IContextService, - @ILogService private readonly _logService: ILogService, - @ICommandService private readonly _commandService: ICommandService, - @IShortcutService private readonly _shortcutService: IShortcutService - ) { - super(); - - const UniFormulaConfirmShortcut: IShortcutItem = { - id: ConfirmFormulaPopupCommand.id, - binding: KeyCode.ENTER, - description: 'shortcut.doc.confirm-formula-popup', - preconditions: (contextService) => - !contextService.getContextValue(FORMULA_PROMPT_ACTIVATED) && this.canConfirmPopup(), - priority: 10000, - }; - - this.disposeWithMe(this._shortcutService.registerShortcut(UniFormulaConfirmShortcut)); - } - - override dispose(): void { - super.dispose(); - - this._popupInfo$.next(null); - this._popupInfo$.complete(); - - this._popupHovered$.complete(); - } - - cacheFormulaString(f: string): void { - this._cachedFormulaString = f; - } - - hoverPopup(hovered: boolean): void { - this._popupHovered$.next(hovered); - } - - showDocPopup(unitId: string, startIndex: number, type: 'new'): boolean; - showDocPopup(unitId: string, startIndex: number, type: 'existing', position: IPopupPosition): boolean; - showDocPopup(unitId: string, startIndex: number, type: 'new' | 'existing', position?: IPopupPosition): boolean; - showDocPopup(unitId: string, startIndex: number, type: 'new' | 'existing', position?: IPopupPosition): boolean { - this.closePopup(); - - // Open existing doc formula. - const f = (position && position.rangeId && type === 'existing') - ? this._uniFormulaService.getDocFormula(unitId, position.rangeId)?.f ?? '=' - : '='; - - const disposable = this._docCanvasPopupManagerService.attachPopupToRange( - BuildTextUtils.selection.makeSelection(startIndex), - { - componentKey: DOC_FORMULA_POPUP_KEY, - onClickOutside: () => this.closePopup(), // user may update ref range selections - direction: 'top', - }, - unitId - ); - this._popupInfo$.next({ unitId, disposable, type, f, startIndex, position }); - return true; - } - - lockPopup(): void { - this._popupLocked = true; - this._contextService.setContextValue(FORMULA_EDITOR_ACTIVATED, true); - } - - canConfirmPopup(): boolean { - return this._cachedFormulaString !== ''; - } - - async confirmPopup(): Promise { - const info = this.popupInfo; - if (!info) return true; - - const f = this._cachedFormulaString; - if (!f) { - this._logService.warn('[FormulaPopupService]: cannot write empty formula into the field.'); - return false; - } - - this.unlockPopup(); - this.closePopup(); - - // Write to slide. - if (isSlidePosition(info.position)) { - return this._commandService.executeCommand(AddSlideUniFormulaCommand.id, { - unitId: info.unitId, - f, - startIndex: info.startIndex, - pageId: info.position.pageId, - elementId: info.position.elementId, - }); - } - - // Write to doc. - return this._commandService.executeCommand(AddDocUniFormulaCommand.id, { - unitId: info.unitId, - f, - startIndex: info.startIndex, - } as IAddDocUniFormulaCommandParams); - } - - unlockPopup(): void { - this._popupLocked = false; - } - - closePopup(force = false): boolean { - if (this._popupLocked && !force) return false; - - this._popupLocked = false; - this._cachedFormulaString = ''; - - this.popupInfo?.disposable.dispose(); - this._popupInfo$.next(null); - this._popupHovered$.next(false); - - this._contextService.setContextValue(FORMULA_EDITOR_ACTIVATED, false); - - return true; - } -} diff --git a/packages-experimental/uni-formula-ui/src/services/slide-ui-formula-cache.service.ts b/packages-experimental/uni-formula-ui/src/services/slide-ui-formula-cache.service.ts deleted file mode 100644 index eeff1ca8d4..0000000000 --- a/packages-experimental/uni-formula-ui/src/services/slide-ui-formula-cache.service.ts +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { CustomRangeType, Disposable } from '@univerjs/core'; -import { ISlideEditorBridgeService } from '@univerjs/slides-ui'; -import { IUniFormulaService } from '@univerjs/uni-formula'; -import type { RichText } from '@univerjs/engine-render'; -import type { IAddSlideUniFormulaCommandParams } from '../commands/commands/slide.command'; -import type { UniFormulaService } from './uni-formula.service'; - -export class SlideUIFormulaCacheService extends Disposable { - private readonly _caches: Map = new Map(); - - constructor( - @ISlideEditorBridgeService private readonly _editorBridgeService: ISlideEditorBridgeService, - @IUniFormulaService private readonly _uniFormulaService: UniFormulaService - ) { - super(); - - this._editorBridgeService.endEditing$.subscribe((richText) => this._checkApplyCache(richText)); - } - - writeCache(rangeId: string, params: IAddSlideUniFormulaCommandParams) { - if (this._caches.size && this._caches.values().next().value?.unitId !== params.unitId) { - this.clearCache(); - } - - this._caches.set(rangeId, params); - } - - private _checkApplyCache(richText: RichText) { - const document = richText.documentData; - const customRanges = document.body?.customRanges; - if (!customRanges || customRanges.length === 0) { - this.clearCache(); - return; - }; - - // Check if there are custom ranges in the rich text. If there are, we would write apply the cache - // to the uni formula service - customRanges.forEach((range) => { - if (range.rangeType === CustomRangeType.UNI_FORMULA) { - const cache = this._caches.get(range.rangeId); - if (cache) { - this._applyCache(range.rangeId, cache); - } else { - throw new Error('[SlideUIFormulaCacheService]: cache not found!'); - } - } - }); - - this.clearCache(); - } - - private _applyCache(rangeId: string, cache: IAddSlideUniFormulaCommandParams) { - const { unitId, pageId, elementId, f } = cache; - this._uniFormulaService.registerSlideFormula(unitId, pageId, elementId, rangeId, f); - } - - clearCache() { - this._caches.clear(); - } -} diff --git a/packages-experimental/uni-formula-ui/src/services/uni-formula.service.ts b/packages-experimental/uni-formula-ui/src/services/uni-formula.service.ts deleted file mode 100644 index 3f8e4ce612..0000000000 --- a/packages-experimental/uni-formula-ui/src/services/uni-formula.service.ts +++ /dev/null @@ -1,430 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { - DocumentDataModel, - ICellData, - ICommand, - IDisposable, - IDocumentBody, - Nullable, - SlideDataModel, -} from '@univerjs/core'; -import type { IDocFormulaCache, ISlideFormulaCache } from '@univerjs/uni-formula'; -import type { IDocPopupPosition, ISlidePopupPosition } from '../commands/operations/operation'; -import { - BuildTextUtils, - CommandType, - CustomRangeType, - ICommandService, - Inject, - Injector, - IResourceManagerService, - IUniverInstanceService, - makeCustomRangeStream, - Quantity, - RCDisposable, - toDisposable, - UniverInstanceType, -} from '@univerjs/core'; -import { replaceSelectionFactory } from '@univerjs/docs'; -import { OtherFormulaBizType, RegisterOtherFormulaService } from '@univerjs/engine-formula'; -import { RichText } from '@univerjs/engine-render'; -import { DataSyncPrimaryController } from '@univerjs/rpc'; -import { CanvasView } from '@univerjs/slides-ui'; -import { DumbUniFormulaService, IUniFormulaService } from '@univerjs/uni-formula'; -import { take } from 'rxjs'; -import { isSlidePosition } from '../commands/operations/operation'; - -const PSEUDO_SUBUNIT = 'PSEUDO_SUBUNIT'; - -export interface IUpdateSlideUniFormulaCacheCommandParams { - unitId: string; - positions: ISlidePopupPosition[]; - cache: ISlideFormulaCache[]; -} - -export interface IUpdateDocUniFormulaCacheCommandParams { - /** The doc in which formula results changed. */ - unitId: string; - positions: ISlidePopupPosition[] | IDocPopupPosition[]; - /** Calculation results. */ - cache: IDocFormulaCache[]; -} - -export const UpdateSlideUniFormulaCacheCommand: ICommand = { - type: CommandType.COMMAND, - id: 'uni-formula.mutation.update-slide-uni-formula-cache', - handler(accessor, params: IUpdateSlideUniFormulaCacheCommandParams) { - const { unitId, positions, cache } = params; - - const uniFormulaService = accessor.get(IUniFormulaService); - const instanceService = accessor.get(IUniverInstanceService); - const slideCanvasView = accessor.get(CanvasView); - - const slide = instanceService.getUnit(unitId, UniverInstanceType.UNIVER_SLIDE); - if (!slide) return true; - - return positions.every((position, index) => { - // TODO@wzhudev: we should get the slide's rendering modules to update the formula results. - // Note that this is very hacky because Univer Slide hasn't provide any mutations to - // modify its content. This is just for POC of uni formula. - const scene = slideCanvasView.getRenderUnitByPageId(position.pageId, unitId).scene; - if (!scene) return false; - - const element = scene.getObject(position.elementId); - if (!element || !(element instanceof RichText)) return false; - - const documentModel = element.documentModel; - const originBody = documentModel.getBody()!; - const range = originBody.customRanges?.find((r) => r.rangeId === position.rangeId); - if (!range) return false; - - const dataStream = makeCustomRangeStream(`${cache[index].v ?? ''}`); - const body: IDocumentBody = { - dataStream, - customRanges: [{ - startIndex: 0, - endIndex: dataStream.length - 1, - rangeId: position.rangeId!, - rangeType: CustomRangeType.UNI_FORMULA, - wholeEntity: true, - }], - }; - - const redoMutation = replaceSelectionFactory(accessor, { - unitId, - body, - selection: BuildTextUtils.selection.makeSelection(range.startIndex, range.endIndex), - doc: documentModel, - }); - - if (!redoMutation) return false; - - // This is pretty annoying... - element.documentModel.apply(redoMutation.params.actions); - element.refreshDocumentByDocData(); // trigger re-render - - uniFormulaService.updateSlideFormulaResults(unitId, position.pageId, position.elementId, position.rangeId!, cache[index]); - - return true; - }); - }, -}; - -/** - * This command is internal. It should not be exposed to third-party developers. - * - * @ignore - */ -export const UpdateDocUniFormulaCacheCommand: ICommand = { - type: CommandType.COMMAND, - id: 'uni-formula.mutation.update-doc-uni-formula-cache', - handler(accessor, params: IUpdateDocUniFormulaCacheCommandParams) { - const { unitId, positions, cache } = params; - - const uniFormulaService = accessor.get(IUniFormulaService); - const instanceService = accessor.get(IUniverInstanceService); - const commandService = accessor.get(ICommandService); - - const doc = instanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC); - // The document may have not loaded on this client. We are safe to ignore cache updating. - if (!doc) return true; - - const body = doc.getBody(); - - function getRange(rangeId: string) { - return body?.customRanges?.find((r) => r.rangeId === rangeId); - } - - const ids = positions.map((position) => position.rangeId!); - const saveCacheResult = uniFormulaService.updateDocFormulaResults(unitId, ids, cache); - if (!saveCacheResult) return false; - - return ids.every((id, index) => { - const range = getRange(id); - if (!range) return true; // If we cannot find that rangeId, we are save to ignore cache. - - const dataStream = makeCustomRangeStream(`${cache[index].v ?? ''}`); - const body: IDocumentBody = { - dataStream, - customRanges: [{ - startIndex: 0, - endIndex: dataStream.length - 1, - rangeId: id, - rangeType: CustomRangeType.UNI_FORMULA, - wholeEntity: true, - }], - }; - - const redoMutation = replaceSelectionFactory(accessor, { - unitId, - body, - selection: BuildTextUtils.selection.makeSelection(range.startIndex, range.endIndex), - }); - - if (redoMutation) { - return commandService.syncExecuteCommand(redoMutation.id, redoMutation.params); - } - - return false; - }); - }, -}; - -/** - * This service provides methods for docs and slides to register a formula into Univer's formula system. - * And it also manages formula resources fields of docs and slides. `SHEET_FORMULA_REMOTE_PLUGIN` - * is not required but optional here. - */ -export class UniFormulaService extends DumbUniFormulaService implements IUniFormulaService { - private readonly _formulaIdToKey = new Map(); - - private _canPerformFormulaCalculation = false; - - private get _registerOtherFormulaSrv() { return this._injector.get(RegisterOtherFormulaService); } - private get _dataSyncPrimaryController() { return this._injector.get(DataSyncPrimaryController, Quantity.OPTIONAL); } - - constructor( - @Inject(Injector) private readonly _injector: Injector, - @IResourceManagerService resourceManagerService: IResourceManagerService, - @ICommandService commandSrv: ICommandService, - @IUniverInstanceService instanceSrv: IUniverInstanceService - ) { - super(resourceManagerService, commandSrv, instanceSrv); - - [ - UpdateSlideUniFormulaCacheCommand, - UpdateDocUniFormulaCacheCommand, - ].forEach((command) => commandSrv.registerCommand(command)); - - // Only able to perform formula calculation after a sheet is loaded. - // FIXME: the formula engine is not unit-agnostic. - if (instanceSrv.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).length) { - this._canPerformFormulaCalculation = true; - } else { - this.disposeWithMe(this._instanceSrv.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).pipe(take(1)) - .subscribe(() => { - this._canPerformFormulaCalculation = true; - this._initFormulaRegistration(); - })); - } - } - - /** - * Register a doc formula into the formula system. - */ - override registerDocFormula(unitId: string, rangeId: string, f: string, v: ICellData['v'], t: ICellData['t']): IDisposable { - const key = getDocFormulaKey(unitId, rangeId); - if (this._docFormulas.has(key)) { - throw new Error(`[UniFormulaService]: cannot register formula ${key} when it is already registered!`); - } - - if (this._canPerformFormulaCalculation) { - const pseudoId = getPseudoUnitKey(unitId); - this._checkSyncingUnit(pseudoId); - - const id = this._registerOtherFormulaSrv.registerFormulaWithRange(pseudoId, PSEUDO_SUBUNIT, f, undefined, undefined, OtherFormulaBizType.DOC, rangeId); - this._docFormulas.set(key, { unitId, rangeId, f, formulaId: id, v, t }); - this._formulaIdToKey.set(id, key); - - this._checkResultSubscription(); - } else { - this._docFormulas.set(key, { unitId, rangeId, f, formulaId: '', v, t }); - } - - return toDisposable(() => this.unregisterDocFormula(unitId, rangeId)); - } - - override registerSlideFormula( - unitId: string, - pageId: string, - elementId: string, - rangeId: string, - f: string, - v: ICellData['v'], - t: ICellData['t'] - ): IDisposable { - const key = getSlideFormulaKey(unitId, pageId, elementId, rangeId); - if (this._slideFormulas.has(key)) { - throw new Error(`[UniFormulaService]: cannot register formula ${key} when it is already registered!`); - } - - if (this._canPerformFormulaCalculation) { - const pseudoId = getPseudoUnitKey(unitId); - this._checkSyncingUnit(pseudoId); - - const id = this._registerOtherFormulaSrv.registerFormulaWithRange(pseudoId, PSEUDO_SUBUNIT, f, undefined, undefined, OtherFormulaBizType.SLIDE, `${pageId}_${elementId}_${rangeId}`); - this._slideFormulas.set(key, { unitId, pageId, elementId, rangeId, f, formulaId: id, v, t }); - this._formulaIdToKey.set(id, key); - - this._checkResultSubscription(); - } else { - this._slideFormulas.set(key, { unitId, pageId, elementId, rangeId, f, formulaId: '', v, t }); - } - - return toDisposable(() => this.unregisterSlideFormula(unitId, pageId, elementId, rangeId)); - } - - override unregisterDocFormula(unitId: string, rangeId: string): void { - const key = getDocFormulaKey(unitId, rangeId); - const item = this._docFormulas.get(key); - if (!item) return; - - const pseudoId = getPseudoUnitKey(unitId); - this._checkDisposingResultSubscription(); - this._dataSyncDisposables.get(pseudoId)?.dec(); - - if (this._canPerformFormulaCalculation) { - this._registerOtherFormulaSrv.deleteFormula(pseudoId, PSEUDO_SUBUNIT, [item.formulaId]); - this._formulaIdToKey.delete(item.formulaId); - } - - this._docFormulas.delete(key); - } - - override unregisterSlideFormula(unitId: string, pageId: string, elementId: string, formulaId: string): void { - const key = getSlideFormulaKey(unitId, pageId, elementId, formulaId); - const item = this._slideFormulas.get(key); - if (!item) return; - - const pseudoId = getPseudoUnitKey(unitId); - this._checkDisposingResultSubscription(); - this._dataSyncDisposables.get(pseudoId)?.dec(); - - if (this._canPerformFormulaCalculation) { - this._registerOtherFormulaSrv.deleteFormula(pseudoId, PSEUDO_SUBUNIT, [item.formulaId]); - this._formulaIdToKey.delete(item.formulaId); - } - - this._slideFormulas.delete(key); - } - - private _initFormulaRegistration(): void { - // When the doc bootstraps, there could be no sheets modules loaded. So we need to check if there - // are registered formulas but not added to the formula system. - this._docFormulas.forEach((value, key) => { - if (!value.formulaId) { - const { unitId, f, rangeId } = value; - const pseudoId = getPseudoUnitKey(unitId); - this._checkSyncingUnit(pseudoId); - - const id = this._registerOtherFormulaSrv.registerFormulaWithRange(pseudoId, PSEUDO_SUBUNIT, f, undefined, undefined, OtherFormulaBizType.DOC, rangeId); - value.formulaId = id; - this._formulaIdToKey.set(id, key); - } - }); - } - - private _dataSyncDisposables = new Map(); - private _checkSyncingUnit(unitId: string): void { - if (!this._dataSyncPrimaryController) return; - - if (!this._dataSyncDisposables.has(unitId)) { - this._dataSyncPrimaryController.syncUnit(unitId); - this._dataSyncDisposables.set(unitId, new RCDisposable(toDisposable(() => this._dataSyncDisposables.delete(unitId)))); - } - - this._dataSyncDisposables.get(unitId)!.inc(); - } - - private _resultSubscription: Nullable; - private _checkResultSubscription(): void { - if (this._resultSubscription || !this._registerOtherFormulaSrv) return; - - this._resultSubscription = toDisposable(this._registerOtherFormulaSrv.formulaResult$.subscribe((resultMap) => { - for (const resultOfUnit in resultMap) { - const results = resultMap[resultOfUnit][PSEUDO_SUBUNIT]; - if (results) { - const mutationParam = results.map((result) => { - const formulaId = result.formulaId; - const key = this._formulaIdToKey.get(formulaId); - if (!key) return null; - - const docItem = this._docFormulas.get(key); - if (docItem) { - const r = result.result?.[0][0][0][0]; // Ranges defaults to one row and one column - if (docItem.v === r?.v && docItem.t === r?.t) return null; - - return { position: { rangeId: docItem.rangeId }, unitId: docItem.unitId, cache: r }; - }; - - const slideItem = this._slideFormulas.get(key); - if (slideItem) { - const r = result.result?.[0][0][0][0]; // Ranges defaults to one row and one column - if (slideItem.v === r?.v && slideItem.t === r?.t) return null; - - return { - unitId: slideItem.unitId, - position: { - elementId: slideItem.elementId, - rangeId: slideItem.rangeId, - pageId: slideItem.pageId, - }, - cache: r, - }; - } - - return null; - }).reduce((previous, curr) => { - if (!curr || !curr.cache) return previous; - - if (!previous.unitId) previous.unitId = curr.unitId; - previous.positions.push(curr.position); - previous.cache.push(curr.cache); - - return previous; - }, { - unitId: '', - positions: [] as (ISlidePopupPosition | IDocPopupPosition)[], - cache: [] as Pick[], - }); - - if (mutationParam.positions.length === 0) return; - - if (isSlidePosition(mutationParam.positions[0])) { - this._commandSrv.executeCommand(UpdateSlideUniFormulaCacheCommand.id, mutationParam as IUpdateSlideUniFormulaCacheCommandParams); - } else { - this._commandSrv.executeCommand(UpdateDocUniFormulaCacheCommand.id, mutationParam as IUpdateDocUniFormulaCacheCommandParams); - } - } - } - })); - } - - private _checkDisposingResultSubscription(): void { - if (this._docFormulas.size === 0) this._disposeResultSubscription(); - } - - private _disposeResultSubscription(): void { - if (this._resultSubscription) { - this._resultSubscription.dispose(); - this._resultSubscription = null; - } - } -} - -function getPseudoUnitKey(unitId: string): string { - return `pseudo-${unitId}`; -} - -function getDocFormulaKey(unitId: string, formulaId: string): string { - return `pseudo-${unitId}-${formulaId}`; -} - -function getSlideFormulaKey(unitId: string, pageId: string, elementId: string, rangeId: string): string { - return `pseudo-${unitId}-${pageId}-${elementId}-${rangeId}`; -} diff --git a/packages-experimental/uni-formula-ui/src/views/components/DocFormulaPopup.tsx b/packages-experimental/uni-formula-ui/src/views/components/DocFormulaPopup.tsx deleted file mode 100644 index 0433292b70..0000000000 --- a/packages-experimental/uni-formula-ui/src/views/components/DocFormulaPopup.tsx +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { IDocumentData, Nullable } from '@univerjs/core'; -import type { IUniFormulaPopupInfo } from '../../services/formula-popup.service'; - -import { - BooleanNumber, - createInternalEditorID, - DEFAULT_EMPTY_DOCUMENT_VALUE, - DocumentFlavor, - HorizontalAlign, - ICommandService, - LocaleService, - VerticalAlign, - WrapStrategy, -} from '@univerjs/core'; -import { borderClassName, clsx } from '@univerjs/design'; -import { CheckMarkIcon, CloseIcon } from '@univerjs/icons'; -import { useDependency, useObservable } from '@univerjs/ui'; -import { useCallback, useEffect, useRef, useState } from 'react'; -import { CloseFormulaPopupOperation, ConfirmFormulaPopupCommand } from '../../commands/operations/operation'; -import { DOC_FORMULA_POPUP_KEY, UniFormulaPopupService } from '../../services/formula-popup.service'; - -export const UNI_FORMULA_EDITOR_ID = createInternalEditorID('UNI_FORMULA'); - -function makeSnapshot(f: string): IDocumentData { - return { - id: UNI_FORMULA_EDITOR_ID, - body: { - dataStream: `${f}${DEFAULT_EMPTY_DOCUMENT_VALUE}`, - textRuns: [], - paragraphs: [ - { - startIndex: 0, - }, - ], - }, - documentStyle: { - documentFlavor: DocumentFlavor.UNSPECIFIED, - marginTop: 5, - marginBottom: 5, - marginRight: 0, - marginLeft: 0, - paragraphLineGapDefault: 0, - pageSize: { - width: Number.POSITIVE_INFINITY, - height: Number.POSITIVE_INFINITY, - }, - renderConfig: { - horizontalAlign: HorizontalAlign.UNSPECIFIED, - verticalAlign: VerticalAlign.TOP, - centerAngle: 0, - vertexAngle: 0, - wrapStrategy: WrapStrategy.OVERFLOW, - isRenderStyle: BooleanNumber.FALSE, - }, - }, - }; -} - -export function UniFormulaPopup() { - const docFormulaPopupService = useDependency(UniFormulaPopupService); - const popupInfo = useObservable(docFormulaPopupService.popupInfo$); - - if (!popupInfo) { - return null; - } - - return ; -} - -UniFormulaPopup.componentKey = DOC_FORMULA_POPUP_KEY; - -function DocFormula(props: { popupInfo: IUniFormulaPopupInfo }) { - const { popupInfo } = props; - const { f } = popupInfo; - - const localeService = useDependency(LocaleService); - const formulaPopupService = useDependency(UniFormulaPopupService); - const commandService = useDependency(ICommandService); - - const [formulaString, setFormulaString] = useState>(f); - const snapshotRef = useRef(makeSnapshot(f ?? '')); - - const [focused, setFocused] = useState(false); - - const onFormulaStringChange = useCallback((formulaString: string) => { - setFormulaString(formulaString); - formulaPopupService.cacheFormulaString(formulaString); - }, [formulaPopupService]); - - const onConfirm = useCallback(() => { - // TODO: call operation instead - commandService.executeCommand(ConfirmFormulaPopupCommand.id); - }, [commandService]); - - const onHovered = useCallback((hovered: boolean) => { - formulaPopupService.hoverPopup(hovered); - }, [formulaPopupService]); - - const onCancel = useCallback(() => { - commandService.executeCommand(CloseFormulaPopupOperation.id); - }, [commandService]); - - const handleEscKey = useCallback((event: { key: string }) => { - if (event.key === 'Escape') { - onCancel(); - } - }, [onCancel]); - - useEffect(() => { - document.addEventListener('keydown', handleEscKey); - return () => { - document.removeEventListener('keydown', handleEscKey); - }; - }, [handleEscKey]); - - return ( -
onHovered(true)} - onMouseLeave={() => onHovered(false)} - > -
- - - - - - -
-
- ); -} diff --git a/packages-experimental/uni-formula-ui/src/vite-env.d.ts b/packages-experimental/uni-formula-ui/src/vite-env.d.ts deleted file mode 100644 index 11f02fe2a0..0000000000 --- a/packages-experimental/uni-formula-ui/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/packages-experimental/uni-formula-ui/tailwind.config.ts b/packages-experimental/uni-formula-ui/tailwind.config.ts deleted file mode 100644 index 75967f186f..0000000000 --- a/packages-experimental/uni-formula-ui/tailwind.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { Config } from 'tailwindcss'; -import preset from '@univerjs-infra/shared/tailwind'; - -const config: Config = { - presets: [preset], - content: [ - './src/**/*.{js,ts,jsx,tsx}', - ], -}; - -export default config; diff --git a/packages-experimental/uni-formula-ui/tsconfig.json b/packages-experimental/uni-formula-ui/tsconfig.json deleted file mode 100644 index 018601b6b9..0000000000 --- a/packages-experimental/uni-formula-ui/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "extends": "@univerjs-infra/shared/tsconfigs/base", - "compilerOptions": { - "rootDir": "src", - "outDir": "lib/types" - }, - "references": [ - { - "path": "./tsconfig.node.json" - } - ], - "include": [ - "src" - ] -} diff --git a/packages-experimental/uni-formula-ui/tsconfig.node.json b/packages-experimental/uni-formula-ui/tsconfig.node.json deleted file mode 100644 index 4947a09903..0000000000 --- a/packages-experimental/uni-formula-ui/tsconfig.node.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "@univerjs-infra/shared/tsconfigs/node", - "include": ["vitest.config.ts"] -} diff --git a/packages-experimental/uni-formula-ui/vitest.config.ts b/packages-experimental/uni-formula-ui/vitest.config.ts deleted file mode 100644 index af97c6d7a2..0000000000 --- a/packages-experimental/uni-formula-ui/vitest.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import createConfig from '@univerjs-infra/shared/vitest'; - -export default createConfig(); diff --git a/packages-experimental/uni-formula/README.md b/packages-experimental/uni-formula/README.md deleted file mode 100644 index e18aba50e1..0000000000 --- a/packages-experimental/uni-formula/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# @univerjs/uni-formula - -[![npm version](https://img.shields.io/npm/v/@univerjs/uni-formula)](https://npmjs.org/packages/@univerjs/uni-formula) -[![license](https://img.shields.io/npm/l/@univerjs/uni-formula)](https://img.shields.io/npm/l/@univerjs/uni-formula) - -## Introduction - -Provide formula feature in Univer Docs and Univer Slides. - -## Usage - -### Installation - -```shell -npm i @univerjs/uni-formula -``` diff --git a/packages-experimental/uni-formula/package.json b/packages-experimental/uni-formula/package.json deleted file mode 100644 index b4b959e2d9..0000000000 --- a/packages-experimental/uni-formula/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@univerjs/uni-formula", - "version": "0.0.0", - "private": true, - "description": "", - "author": "DreamNum ", - "license": "Apache-2.0", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/univer" - }, - "homepage": "https://univer.ai", - "repository": { - "type": "git", - "url": "https://github.com/dream-num/univer" - }, - "bugs": { - "url": "https://github.com/dream-num/univer/issues" - }, - "keywords": [], - "exports": { - ".": "./src/index.ts", - "./*": "./src/*" - }, - "main": "./src/index.ts", - "types": "./lib/types/index.d.ts", - "publishConfig": { - "access": "public", - "main": "./lib/es/index.js", - "module": "./lib/es/index.js", - "exports": { - ".": { - "import": "./lib/es/index.js", - "require": "./lib/cjs/index.js", - "types": "./lib/types/index.d.ts" - }, - "./*": { - "import": "./lib/es/*", - "require": "./lib/cjs/*", - "types": "./lib/types/index.d.ts" - }, - "./lib/*": "./lib/*" - } - }, - "directories": { - "lib": "lib" - }, - "files": [ - "lib" - ], - "scripts": { - "test": "vitest run", - "test:watch": "vitest", - "coverage": "vitest run --coverage", - "typecheck": "tsc --noEmit", - "build": "univer-cli build" - }, - "dependencies": { - "@univerjs/core": "workspace:*" - }, - "devDependencies": { - "@univerjs-infra/shared": "workspace:*", - "typescript": "^5.9.3", - "vite": "^7.3.0", - "vitest": "^4.0.16" - } -} diff --git a/packages-experimental/uni-formula/src/commands/mutations/doc-formula.mutation.ts b/packages-experimental/uni-formula/src/commands/mutations/doc-formula.mutation.ts deleted file mode 100644 index 01e7d6fd75..0000000000 --- a/packages-experimental/uni-formula/src/commands/mutations/doc-formula.mutation.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { IMutation } from '@univerjs/core'; -import { CommandType } from '@univerjs/core'; - -import { IUniFormulaService } from '../../services/uni-formula.service'; - -export interface IAddDocUniFormulaMutationParams { - unitId: string; - rangeId: string; - - f: string; -} - -export const AddDocUniFormulaMutation: IMutation = { - type: CommandType.MUTATION, - id: 'doc.mutation.add-doc-uni-formula', - handler(accessor, params: IAddDocUniFormulaMutationParams) { - const { unitId, f, rangeId: id } = params; - const uniFormulaService = accessor.get(IUniFormulaService); - - uniFormulaService.registerDocFormula(unitId, id, f); - - return true; - }, -}; - -export interface IUpdateDocUniFormulaMutationParams extends IAddDocUniFormulaMutationParams {} - -export const UpdateDocUniFormulaMutation: IMutation = { - type: CommandType.MUTATION, - id: 'doc.mutation.update-doc-uni-formula', - handler(accessor, params: IUpdateDocUniFormulaMutationParams) { - const { unitId, f, rangeId: id } = params; - const uniFormulaService = accessor.get(IUniFormulaService); - - if (!uniFormulaService.hasDocFormula(unitId, id)) return false; - - uniFormulaService.unregisterDocFormula(unitId, id); - uniFormulaService.registerDocFormula(unitId, id, f); - return true; - }, -}; - -export interface IRemoveDocUniFormulaMutationParams { - unitId: string; - rangeId: string; -} - -export const RemoveDocUniFormulaMutation: IMutation = { - type: CommandType.MUTATION, - id: 'doc.mutation.remove-doc-uni-formula', - handler(accessor, params: IRemoveDocUniFormulaMutationParams) { - const { unitId, rangeId: id } = params; - const uniFormulaService = accessor.get(IUniFormulaService); - - if (!uniFormulaService.hasDocFormula(unitId, id)) { - return false; - } - - uniFormulaService.unregisterDocFormula(unitId, id); - return true; - }, -}; diff --git a/packages-experimental/uni-formula/src/commands/mutations/slide-formua.mutation.ts b/packages-experimental/uni-formula/src/commands/mutations/slide-formua.mutation.ts deleted file mode 100644 index 302ef64c9b..0000000000 --- a/packages-experimental/uni-formula/src/commands/mutations/slide-formua.mutation.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { IMutation } from '@univerjs/core'; -import { CommandType } from '@univerjs/core'; -import { IUniFormulaService } from '../../services/uni-formula.service'; - -export interface IAddSlideUniFormulaMutationParams { - unitId: string; - pageId: string; - elementId: string; - rangeId: string; - - f: string; -} - -export const AddSlideUniFormulaMutation: IMutation = { - type: CommandType.MUTATION, - id: 'slide.mutation.add-slide-uni-formula', - handler(accessor, params: IAddSlideUniFormulaMutationParams) { - const { unitId, pageId, elementId, f, rangeId: id } = params; - const uniFormulaService = accessor.get(IUniFormulaService); - - uniFormulaService.registerSlideFormula(unitId, pageId, elementId, id, f); - - return true; - }, -}; - -export interface IUpdateSlideUniFormulaMutationParams extends IAddSlideUniFormulaMutationParams {} - -export const UpdateSlideUniFormulaMutation: IMutation = { - type: CommandType.MUTATION, - id: 'slide.mutation.update-slide-uni-formula', - handler(accessor, params: IUpdateSlideUniFormulaMutationParams) { - const { unitId, pageId, elementId, f, rangeId: id } = params; - const uniFormulaService = accessor.get(IUniFormulaService); - - if (!uniFormulaService.hasSlideFormula(unitId, pageId, elementId, id)) return false; - - uniFormulaService.unregisterSlideFormula(unitId, pageId, elementId, id); - uniFormulaService.registerSlideFormula(unitId, pageId, elementId, id, f); - return true; - }, -}; diff --git a/packages-experimental/uni-formula/src/const.ts b/packages-experimental/uni-formula/src/const.ts deleted file mode 100644 index a2219bac31..0000000000 --- a/packages-experimental/uni-formula/src/const.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export const UNI_FORMULA_PLUGIN_NAME = 'UI_FORMULA_PLUGIN'; - -export const DOC_UNI_FORMULA_RESOURCE_NAME = 'DOC_FORMULA_PLUGIN'; diff --git a/packages-experimental/uni-formula/src/controller/uni-formula.controller.ts b/packages-experimental/uni-formula/src/controller/uni-formula.controller.ts deleted file mode 100644 index ceb55b89d1..0000000000 --- a/packages-experimental/uni-formula/src/controller/uni-formula.controller.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { ICommandService } from '@univerjs/core'; -import { AddDocUniFormulaMutation, RemoveDocUniFormulaMutation, UpdateDocUniFormulaMutation } from '../commands/mutations/doc-formula.mutation'; - -export class UniFormulaController { - constructor( - @ICommandService private readonly _commandSrv: ICommandService - ) { - this._initCommands(); - } - - private _initCommands(): void { - [ - AddDocUniFormulaMutation, - UpdateDocUniFormulaMutation, - RemoveDocUniFormulaMutation, - ].forEach((command) => this._commandSrv.registerCommand(command)); - } -} diff --git a/packages-experimental/uni-formula/src/index.ts b/packages-experimental/uni-formula/src/index.ts deleted file mode 100644 index cfc6283a98..0000000000 --- a/packages-experimental/uni-formula/src/index.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export { - AddDocUniFormulaMutation, - type IAddDocUniFormulaMutationParams, - type IRemoveDocUniFormulaMutationParams, - type IUpdateDocUniFormulaMutationParams, - RemoveDocUniFormulaMutation, - UpdateDocUniFormulaMutation, -} from './commands/mutations/doc-formula.mutation'; -export { UNI_FORMULA_PLUGIN_NAME as DOC_FORMULA_PLUGIN_NAME } from './const'; -export type { IDocFormulaCache, IDocFormulaData, IDocFormulaReference } from './models/doc-formula'; -export type { ISlideFormulaCache, ISlideFormulaData, ISlideFormulaReference } from './models/slide-formula'; -export { UniverDocUniFormulaPlugin } from './plugin'; -export { DumbUniFormulaService, IUniFormulaService } from './services/uni-formula.service'; diff --git a/packages-experimental/uni-formula/src/models/doc-formula.ts b/packages-experimental/uni-formula/src/models/doc-formula.ts deleted file mode 100644 index 02adebb672..0000000000 --- a/packages-experimental/uni-formula/src/models/doc-formula.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { ICellData } from '@univerjs/core'; - -export const DOC_FORMULA_RESOURCE_KEY = 'DOC_FORMULA_RESOURCE'; - -/** - * This interface represents a single formula entity in a Univer Doc. - */ -export interface IDocFormulaData { - /** Id of this formula. It should be unique in a single document, and bound to the custom range's id. */ - rangeId: string; - - /** - * Raw formula string. For example `=SUM(A1:B4)`. - */ - f: string; - - /** - * Formula calculation result. - */ - v?: ICellData['v']; - - /** - * Formula calculation format. - */ - t?: ICellData['t']; -} - -export interface IDocFormulaReference extends IDocFormulaData { - unitId: string; - - /** Formula id assigned by the formula engine. It should not be written to snapshot. */ - formulaId: string; -} - -export interface IDocFormulaCache extends Pick { } - -export function toJson(formulas: IDocFormulaReference[]): string { - return JSON.stringify(formulas.map((f) => ({ rangeId: f.rangeId, f: f.f, v: f.v, t: f.t }))); -} diff --git a/packages-experimental/uni-formula/src/models/slide-formula.ts b/packages-experimental/uni-formula/src/models/slide-formula.ts deleted file mode 100644 index e06eccc406..0000000000 --- a/packages-experimental/uni-formula/src/models/slide-formula.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { ICellData } from '@univerjs/core'; - -export interface ISlideFormulaData { - rangeId: string; - - f: string; - - v?: ICellData['v']; - - t?: ICellData['t']; -} - -export interface ISlideFormulaReference extends ISlideFormulaData { - unitId: string; - - pageId: string; - - elementId: string; - - formulaId: string; -} - -export interface ISlideFormulaCache extends Pick { } - -export function slideToJson(formulas: ISlideFormulaReference[]): string { - return JSON.stringify(formulas.map((f) => ({ - rangeId: f.rangeId, - pageId: f.pageId, - elementId: f.elementId, - f: f.f, - v: f.v, - t: f.t, - }))); -} diff --git a/packages-experimental/uni-formula/src/plugin.ts b/packages-experimental/uni-formula/src/plugin.ts deleted file mode 100644 index e1d81262ca..0000000000 --- a/packages-experimental/uni-formula/src/plugin.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { Dependency } from '@univerjs/core'; -import { Inject, Injector, Plugin, registerDependencies, touchDependencies, UniverInstanceType } from '@univerjs/core'; -import { UNI_FORMULA_PLUGIN_NAME } from './const'; -import { UniFormulaController } from './controller/uni-formula.controller'; -import { DumbUniFormulaService, IUniFormulaService } from './services/uni-formula.service'; - -export class UniverDocUniFormulaPlugin extends Plugin { - static override pluginName: string = UNI_FORMULA_PLUGIN_NAME; - - // This plugin should load only when sheet related modules are loaded. - static override type: UniverInstanceType = UniverInstanceType.UNIVER_UNKNOWN; - - constructor( - private readonly _config: { playDumb: boolean } | undefined, - @Inject(Injector) protected readonly _injector: Injector - ) { - super(); - } - - override onStarting(): void { - const dependencies: Dependency[] = [[UniFormulaController]]; - if (this._config?.playDumb) { - dependencies.push([IUniFormulaService, { useClass: DumbUniFormulaService }]); - } - - registerDependencies(this._injector, dependencies); - touchDependencies(this._injector, dependencies.map((d) => [d[0]])); - } -} diff --git a/packages-experimental/uni-formula/src/services/uni-formula.service.ts b/packages-experimental/uni-formula/src/services/uni-formula.service.ts deleted file mode 100644 index 09e6c5a0f2..0000000000 --- a/packages-experimental/uni-formula/src/services/uni-formula.service.ts +++ /dev/null @@ -1,216 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { ICellData, IDisposable, Nullable } from '@univerjs/core'; -import type { IDocFormulaCache, IDocFormulaData, IDocFormulaReference } from '../models/doc-formula'; - -import type { ISlideFormulaReference } from '../models/slide-formula'; -import { - createIdentifier, - Disposable, - ICommandService, - IResourceManagerService, - IUniverInstanceService, - toDisposable, - UniverInstanceType, -} from '@univerjs/core'; -import { DOC_UNI_FORMULA_RESOURCE_NAME } from '../const'; -import { toJson } from '../models/doc-formula'; - -export interface IUniFormulaService { - updateDocFormulaResults(unitId: string, formulaIds: string[], v: IDocFormulaCache[]): boolean; - updateSlideFormulaResults(unitId: string, pageId: string, elementId: string, formulaId: string, v: IDocFormulaCache): boolean; - - // #region doc - hasDocFormula(unitId: string, formulaId: string): boolean; - getDocFormula(unitId: string, rangeId: string): Nullable; - registerDocFormula(unitId: string, rangeId: string, f: string, v: ICellData['v'], t: ICellData['t']): IDisposable; - unregisterDocFormula(unitId: string, rangeId: string): void; - // #endregion - - // #region slide - hasSlideFormula(unitId: string, pageId: string, elementId: string, formulaId: string): boolean; - getSlideFormula(unitId: string, pageId: string, elementId: string, formulaId: string): Nullable; - registerSlideFormula(unitId: string, pageId: string, elementId: string, f: string, v: ICellData['v'], t: ICellData['t']): IDisposable; - unregisterSlideFormula(unitId: string, pageId: string, elementId: string, formulaId: string): void; - // #endregion -} - -export const IUniFormulaService = createIdentifier('uni-formula.uni-formula.service'); - -// NOTE@wzhudev: we implement formula for doc and slide here for convenience, but we should separate them in the future. - -export class DumbUniFormulaService extends Disposable implements IUniFormulaService { - protected readonly _docFormulas = new Map(); - protected readonly _slideFormulas = new Map(); - - constructor( - @IResourceManagerService resourceManagerSrv: IResourceManagerService, - @ICommandService protected readonly _commandSrv: ICommandService, - @IUniverInstanceService protected readonly _instanceSrv: IUniverInstanceService - ) { - super(); - - this._initDocFormulaResources(resourceManagerSrv); - - this._instanceSrv.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_DOC).subscribe((doc) => { - this._unregisterDoc(doc.getUnitId()); - }); - } - - // #region docs - - hasDocFormula(unitId: string, formulaId: string): boolean { - return this._docFormulas.has(getDocFormulaKey(unitId, formulaId)); - } - - getDocFormula(unitId: string, rangeId: string): Nullable { - return this._docFormulas.get(getDocFormulaKey(unitId, rangeId)) ?? null; - } - - updateDocFormulaResults(unitId: string, formulaIds: string[], v: IDocFormulaCache[]): boolean { - formulaIds.forEach((id, index) => { - const formulaData = this._docFormulas.get(getDocFormulaKey(unitId, id)); - if (!formulaData) return true; - - formulaData.v = v[index].v; - formulaData.t = v[index].t; - return true; - }); - - return true; - } - - /** - * Register a doc formula into the formula system. - */ - registerDocFormula(unitId: string, rangeId: string, f: string, v: ICellData['v'], t: ICellData['t']): IDisposable { - const key = getDocFormulaKey(unitId, rangeId); - if (this._docFormulas.has(key)) { - throw new Error(`[UniFormulaService]: cannot register formula ${key} when it is already registered!`); - } - - this._docFormulas.set(key, { unitId, rangeId, f, formulaId: '', v, t }); - - return toDisposable(() => this.unregisterDocFormula(unitId, rangeId)); - } - - unregisterDocFormula(unitId: string, rangeId: string): void { - const key = getDocFormulaKey(unitId, rangeId); - const item = this._docFormulas.get(key); - if (item) { - this._docFormulas.delete(key); - } - } - - updateSlideFormulaResults(unitId: string, pageId: string, elementId: string, formulaId: string, v: IDocFormulaCache): boolean { - const formulaData = this._slideFormulas.get(getSlideFormulaKey(unitId, pageId, elementId, formulaId)); - if (!formulaData) return true; - - formulaData.v = v.v; - formulaData.t = v.t; - return true; - } - - private _initDocFormulaResources(resourceManagerService: IResourceManagerService): void { - resourceManagerService.registerPluginResource({ - pluginName: DOC_UNI_FORMULA_RESOURCE_NAME, - businesses: [UniverInstanceType.UNIVER_DOC], - toJson: (unitId: string) => { - const formulas = this._getAllFormulasOfUnit(unitId); - return toJson(formulas.map((f) => f[1])); - }, - parseJson: (json: string) => { - const formulas = JSON.parse(json) as IDocFormulaData[]; - return formulas; - }, - onLoad: (unitId, formulas) => { - formulas.forEach((f) => this.registerDocFormula(unitId, f.rangeId, f.f, f.v, f.t)); - }, - onUnLoad: (unitId) => { - this._unregisterDoc(unitId); - }, - }); - } - - /** - * Remove all formulas under a doc. - */ - private _unregisterDoc(unitId: string): void { - const existingFormulas = Array.from(this._docFormulas.entries()); - existingFormulas.forEach(([_, value]) => { - if (value.unitId === unitId) this.unregisterDocFormula(unitId, value.rangeId); - }); - } - - // #endregion - - // #region slides - - registerSlideFormula( - unitId: string, - pageId: string, - elementId: string, - rangeId: string, - f: string, - v: ICellData['v'], - t: ICellData['t'] - ): IDisposable { - const key = getSlideFormulaKey(unitId, pageId, elementId, f); - if (this._slideFormulas.has(key)) { - throw new Error(`[UniFormulaService]: cannot register formula ${key} when it is already registered!`); - } - - this._slideFormulas.set(key, { unitId, pageId, elementId, rangeId, formulaId: '', f, v, t }); - - return toDisposable(() => this.unregisterDocFormula(unitId, rangeId)); - } - - hasSlideFormula(unitId: string, pageId: string, elementId: string, formulaId: string): boolean { - return this._slideFormulas.has(getSlideFormulaKey(unitId, pageId, elementId, formulaId)); - } - - getSlideFormula(unitId: string, pageId: string, elementId: string, formulaId: string): Nullable { - return this._slideFormulas.get(getSlideFormulaKey(unitId, pageId, elementId, formulaId)) ?? null; - } - - unregisterSlideFormula(unitId: string, pageId: string, elementId: string, formulaId: string): void { - const key = getSlideFormulaKey(unitId, pageId, elementId, formulaId); - const item = this._slideFormulas.get(key); - if (item) { - this._slideFormulas.delete(key); - } - } - - // #endregion - - private _getAllFormulasOfUnit(unitId: string) { - const formulas = Array.from(this._docFormulas.entries()).filter((v) => v[1].unitId === unitId); - return formulas; - } -} - -export function getPseudoDocUnitKey(unitId: string): string { - return `pseudo-${unitId}`; -} - -export function getDocFormulaKey(unitId: string, formulaId: string): string { - return `pseudo-${unitId}-${formulaId}`; -} - -function getSlideFormulaKey(unitId: string, pageId: string, elementId: string, formulaId: string): string { - return `pseudo-${unitId}-${pageId}-${elementId}-${formulaId}`; -} diff --git a/packages-experimental/uni-formula/src/vite-env.d.ts b/packages-experimental/uni-formula/src/vite-env.d.ts deleted file mode 100644 index 11f02fe2a0..0000000000 --- a/packages-experimental/uni-formula/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/packages-experimental/uni-formula/tsconfig.json b/packages-experimental/uni-formula/tsconfig.json deleted file mode 100644 index 018601b6b9..0000000000 --- a/packages-experimental/uni-formula/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "extends": "@univerjs-infra/shared/tsconfigs/base", - "compilerOptions": { - "rootDir": "src", - "outDir": "lib/types" - }, - "references": [ - { - "path": "./tsconfig.node.json" - } - ], - "include": [ - "src" - ] -} diff --git a/packages-experimental/uni-formula/tsconfig.node.json b/packages-experimental/uni-formula/tsconfig.node.json deleted file mode 100644 index 4947a09903..0000000000 --- a/packages-experimental/uni-formula/tsconfig.node.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "@univerjs-infra/shared/tsconfigs/node", - "include": ["vitest.config.ts"] -} diff --git a/packages-experimental/uni-formula/vitest.config.ts b/packages-experimental/uni-formula/vitest.config.ts deleted file mode 100644 index af97c6d7a2..0000000000 --- a/packages-experimental/uni-formula/vitest.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import createConfig from '@univerjs-infra/shared/vitest'; - -export default createConfig(); diff --git a/packages-experimental/uni-sheets-ui/README.md b/packages-experimental/uni-sheets-ui/README.md deleted file mode 100644 index 52972216df..0000000000 --- a/packages-experimental/uni-sheets-ui/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# @univerjs/uni-sheets-ui - -[![npm version](https://img.shields.io/npm/v/@univerjs/uni-sheets-ui)](https://npmjs.org/packages/@univerjs/uni-sheets-ui) -[![license](https://img.shields.io/npm/l/@univerjs/uni-sheets-ui)](https://img.shields.io/npm/l/@univerjs/uni-sheets-ui) - -## Introduction - -> TODO: Introduction - -## Usage - -### Installation - -```shell -npm i @univerjs/uni-sheets-ui -``` diff --git a/packages-experimental/uni-sheets-ui/package.json b/packages-experimental/uni-sheets-ui/package.json deleted file mode 100644 index f3fc8132dc..0000000000 --- a/packages-experimental/uni-sheets-ui/package.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "name": "@univerjs/uni-sheets-ui", - "version": "0.0.0", - "private": true, - "description": "", - "author": "DreamNum ", - "license": "Apache-2.0", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/univer" - }, - "homepage": "https://univer.ai", - "repository": { - "type": "git", - "url": "https://github.com/dream-num/univer" - }, - "bugs": { - "url": "https://github.com/dream-num/univer/issues" - }, - "keywords": [], - "exports": { - ".": "./src/index.ts", - "./*": "./src/*" - }, - "main": "./src/index.ts", - "types": "./lib/types/index.d.ts", - "publishConfig": { - "access": "public", - "main": "./lib/es/index.js", - "module": "./lib/es/index.js", - "exports": { - ".": { - "import": "./lib/es/index.js", - "require": "./lib/cjs/index.js", - "types": "./lib/types/index.d.ts" - }, - "./*": { - "import": "./lib/es/*", - "require": "./lib/cjs/*", - "types": "./lib/types/index.d.ts" - }, - "./lib/*": "./lib/*" - } - }, - "directories": { - "lib": "lib" - }, - "files": [ - "lib" - ], - "scripts": { - "test": "vitest run", - "test:watch": "vitest", - "coverage": "vitest run --coverage", - "typecheck": "tsc --noEmit", - "build": "univer-cli build" - }, - "peerDependencies": { - "react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc", - "rxjs": ">=7.0.0" - }, - "dependencies": { - "@univerjs/core": "workspace:*", - "@univerjs/design": "workspace:*", - "@univerjs/docs": "workspace:*", - "@univerjs/docs-ui": "workspace:*", - "@univerjs/icons": "^1.1.0", - "@univerjs/sheets": "workspace:*", - "@univerjs/sheets-drawing-ui": "workspace:*", - "@univerjs/sheets-ui": "workspace:*", - "@univerjs/ui": "workspace:*", - "@univerjs/uniui": "workspace:*" - }, - "devDependencies": { - "@univerjs-infra/shared": "workspace:*", - "postcss": "^8.5.6", - "react": "18.3.1", - "rxjs": "^7.8.2", - "tailwindcss": "3.4.18", - "typescript": "^5.9.3", - "vite": "^7.3.0", - "vitest": "^4.0.16" - } -} diff --git a/packages-experimental/uni-sheets-ui/postcss.config.mjs b/packages-experimental/uni-sheets-ui/postcss.config.mjs deleted file mode 100644 index 7d59f53133..0000000000 --- a/packages-experimental/uni-sheets-ui/postcss.config.mjs +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@univerjs-infra/shared/postcss'; diff --git a/packages-experimental/uni-sheets-ui/src/controllers/menu.schema.ts b/packages-experimental/uni-sheets-ui/src/controllers/menu.schema.ts deleted file mode 100644 index 38a28030ed..0000000000 --- a/packages-experimental/uni-sheets-ui/src/controllers/menu.schema.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { MenuSchemaType } from '@univerjs/ui'; -import { SheetsUIMenuSchema } from '@univerjs/sheets-ui'; -import { RibbonStartGroup } from '@univerjs/ui'; -import { FONT_GROUP_MENU_ID, UNI_MENU_POSITIONS } from '@univerjs/uniui'; -import { - SHEET_BOLD_MUTATION_ID, - SHEET_ITALIC_MUTATION_ID, - SHEET_STRIKE_MUTATION_ID, - SHEET_UNDERLINE_MUTATION_ID, - SheetBoldMenuItemFactory, - SheetItalicMenuItemFactory, - SheetStrikeThroughMenuItemFactory, - SheetUnderlineMenuItemFactory, -} from './menu'; - -export const menuSchema: MenuSchemaType = { - [UNI_MENU_POSITIONS.TOOLBAR_MAIN]: (SheetsUIMenuSchema as any)[RibbonStartGroup.FORMAT], - [FONT_GROUP_MENU_ID]: { - [SHEET_BOLD_MUTATION_ID]: { - order: 0, - menuItemFactory: SheetBoldMenuItemFactory, - }, - [SHEET_ITALIC_MUTATION_ID]: { - order: 1, - menuItemFactory: SheetItalicMenuItemFactory, - }, - [SHEET_UNDERLINE_MUTATION_ID]: { - order: 2, - menuItemFactory: SheetUnderlineMenuItemFactory, - }, - [SHEET_STRIKE_MUTATION_ID]: { - order: 3, - menuItemFactory: SheetStrikeThroughMenuItemFactory, - }, - }, -}; diff --git a/packages-experimental/uni-sheets-ui/src/controllers/menu.ts b/packages-experimental/uni-sheets-ui/src/controllers/menu.ts deleted file mode 100644 index b8abb7452e..0000000000 --- a/packages-experimental/uni-sheets-ui/src/controllers/menu.ts +++ /dev/null @@ -1,284 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { IAccessor } from '@univerjs/core'; -import type { IMenuButtonItem } from '@univerjs/ui'; -import { BooleanNumber, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, EDITOR_ACTIVATED, FOCUSING_SHEET, FontItalic, FontWeight, ICommandService, IContextService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core'; -import { DocSelectionManagerService, SetTextSelectionsOperation } from '@univerjs/docs'; -import { SetInlineFormatCommand } from '@univerjs/docs-ui'; -import { - RangeProtectionPermissionEditPoint, - SetRangeValuesMutation, - SetSelectionsOperation, - SetWorksheetActiveOperation, - SheetsSelectionsService, - WorkbookEditablePermission, - WorksheetEditPermission, - WorksheetSetCellStylePermission, -} from '@univerjs/sheets'; -import { deriveStateFromActiveSheet$, getCurrentRangeDisable$ } from '@univerjs/sheets-ui'; -import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui'; -import { Observable } from 'rxjs'; - -export const SHEET_BOLD_MUTATION_ID = 'sheet.command.uni-bold'; -export const SHEET_ITALIC_MUTATION_ID = 'sheet.command.uni-italic'; -export const SHEET_UNDERLINE_MUTATION_ID = 'sheet.command.uni-underline'; -export const SHEET_STRIKE_MUTATION_ID = 'sheet.command.uni-strike'; - -export function SheetBoldMenuItemFactory(accessor: IAccessor): IMenuButtonItem { - const commandService = accessor.get(ICommandService); - const univerInstanceService = accessor.get(IUniverInstanceService); - const contextService = accessor.get(IContextService); - const selectionManagerService = accessor.get(SheetsSelectionsService); - - return { - id: SHEET_BOLD_MUTATION_ID, - type: MenuItemType.BUTTON, - icon: 'BoldIcon', - title: 'Set bold', - tooltip: 'toolbar.bold', - disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }), - activated$: deriveStateFromActiveSheet$(univerInstanceService, false, ({ worksheet }) => new Observable((subscriber) => { - const disposable = commandService.onCommandExecuted((c) => { - const id = c.id; - if (id === SetRangeValuesMutation.id || id === SetSelectionsOperation.id || id === SetWorksheetActiveOperation.id) { - const primary = selectionManagerService.getCurrentLastSelection()?.primary; - let isBold = FontWeight.NORMAL; - - if (primary != null) { - const range = worksheet.getRange(primary.startRow, primary.startColumn); - isBold = range?.getFontWeight(); - } - - subscriber.next(isBold === FontWeight.BOLD); - } - - if ( - (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) && - contextService.getContextValue(EDITOR_ACTIVATED) && - contextService.getContextValue(FOCUSING_SHEET) - ) { - const textRun = getFontStyleAtCursor(accessor); - if (textRun == null) { - return; - } - - const bl = textRun.ts?.bl; - subscriber.next(bl === BooleanNumber.TRUE); - } - }); - - const primary = selectionManagerService.getCurrentLastSelection()?.primary; - if (!worksheet) { - subscriber.next(false); - return; - } - - let isBold = FontWeight.NORMAL; - if (primary != null) { - const range = worksheet.getRange(primary.startRow, primary.startColumn); - isBold = range?.getFontWeight(); - } - subscriber.next(isBold === FontWeight.BOLD); - - return disposable.dispose; - })), - hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET), - }; -} - -export function SheetItalicMenuItemFactory(accessor: IAccessor): IMenuButtonItem { - const commandService = accessor.get(ICommandService); - const univerInstanceService = accessor.get(IUniverInstanceService); - const selectionManagerService = accessor.get(SheetsSelectionsService); - const contextService = accessor.get(IContextService); - - return { - id: SHEET_ITALIC_MUTATION_ID, - type: MenuItemType.BUTTON, - icon: 'ItalicIcon', - title: 'Set italic', - tooltip: 'toolbar.italic', - disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }), - activated$: deriveStateFromActiveSheet$(univerInstanceService, false, ({ worksheet }) => new Observable((subscriber) => { - const disposable = commandService.onCommandExecuted((c) => { - const id = c.id; - if (id === SetRangeValuesMutation.id || id === SetSelectionsOperation.id || id === SetWorksheetActiveOperation.id) { - const primary = selectionManagerService.getCurrentLastSelection()?.primary; - let isItalic = FontItalic.NORMAL; - if (primary != null) { - const range = worksheet.getRange(primary.startRow, primary.startColumn); - isItalic = range?.getFontStyle(); - } - - subscriber.next(isItalic === FontItalic.ITALIC); - } - - if ( - (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) && - contextService.getContextValue(EDITOR_ACTIVATED) && - contextService.getContextValue(FOCUSING_SHEET) - ) { - const textRun = getFontStyleAtCursor(accessor); - if (textRun == null) return; - - const it = textRun.ts?.it; - subscriber.next(it === BooleanNumber.TRUE); - } - }); - - const primary = selectionManagerService.getCurrentLastSelection()?.primary; - let isItalic = FontItalic.NORMAL; - if (primary != null) { - const range = worksheet.getRange(primary.startRow, primary.startColumn); - isItalic = range?.getFontStyle(); - } - - subscriber.next(isItalic === FontItalic.ITALIC); - return disposable.dispose; - })), - hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET), - }; -} - -export function SheetUnderlineMenuItemFactory(accessor: IAccessor): IMenuButtonItem { - const commandService = accessor.get(ICommandService); - const univerInstanceService = accessor.get(IUniverInstanceService); - const selectionManagerService = accessor.get(SheetsSelectionsService); - const contextService = accessor.get(IContextService); - - return { - id: SHEET_UNDERLINE_MUTATION_ID, - type: MenuItemType.BUTTON, - icon: 'UnderlineIcon', - title: 'Set underline', - tooltip: 'toolbar.underline', - activated$: deriveStateFromActiveSheet$(univerInstanceService, false, ({ worksheet }) => new Observable((subscriber) => { - const disposable = commandService.onCommandExecuted((c) => { - const id = c.id; - if (id === SetRangeValuesMutation.id || id === SetSelectionsOperation.id || id === SetWorksheetActiveOperation.id) { - const primary = selectionManagerService.getCurrentLastSelection()?.primary; - let isUnderline; - if (primary != null) { - const range = worksheet.getRange(primary.startRow, primary.startColumn); - isUnderline = range?.getUnderline(); - } - - subscriber.next(!!(isUnderline && isUnderline.s)); - } - - if ( - (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) && - contextService.getContextValue(EDITOR_ACTIVATED) && - contextService.getContextValue(FOCUSING_SHEET) - ) { - const textRun = getFontStyleAtCursor(accessor); - if (textRun == null) return; - - const ul = textRun.ts?.ul; - subscriber.next(ul?.s === BooleanNumber.TRUE); - } - }); - - const primary = selectionManagerService.getCurrentLastSelection()?.primary; - let isUnderline; - if (primary != null) { - const range = worksheet.getRange(primary.startRow, primary.startColumn); - isUnderline = range?.getUnderline(); - } - - subscriber.next(!!(isUnderline && isUnderline.s)); - return disposable.dispose; - })), - disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }), - hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET), - }; -} - -export function SheetStrikeThroughMenuItemFactory(accessor: IAccessor): IMenuButtonItem { - const commandService = accessor.get(ICommandService); - const univerInstanceService = accessor.get(IUniverInstanceService); - const selectionManagerService = accessor.get(SheetsSelectionsService); - const contextService = accessor.get(IContextService); - - return { - id: SHEET_STRIKE_MUTATION_ID, - type: MenuItemType.BUTTON, - icon: 'StrikethroughIcon', - title: 'Set strike through', - tooltip: 'toolbar.strikethrough', - disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }), - activated$: deriveStateFromActiveSheet$(univerInstanceService, false, ({ worksheet }) => new Observable((subscriber) => { - const disposable = commandService.onCommandExecuted((c) => { - const id = c.id; - if (id === SetRangeValuesMutation.id || id === SetSelectionsOperation.id || id === SetWorksheetActiveOperation.id) { - const primary = selectionManagerService.getCurrentLastSelection()?.primary; - let st; - if (primary != null) { - const range = worksheet.getRange(primary.startRow, primary.startColumn); - st = range?.getStrikeThrough(); - } - - subscriber.next(!!(st && st.s)); - } - - if ( - (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) && - contextService.getContextValue(EDITOR_ACTIVATED) && - contextService.getContextValue(FOCUSING_SHEET) - ) { - const textRun = getFontStyleAtCursor(accessor); - - if (textRun == null) { - return; - } - - const st = textRun.ts?.st; - - subscriber.next(st?.s === BooleanNumber.TRUE); - } - }); - - const primary = selectionManagerService.getCurrentLastSelection()?.primary; - let st; - if (primary != null) { - const range = worksheet.getRange(primary.startRow, primary.startColumn); - st = range?.getStrikeThrough(); - } - - subscriber.next(!!(st && st.s)); - return disposable.dispose; - })), - hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET), - }; -} - -function getFontStyleAtCursor(accessor: IAccessor) { - const univerInstanceService = accessor.get(IUniverInstanceService); - const textSelectionService = accessor.get(DocSelectionManagerService); - - const editorDataModel = univerInstanceService.getUniverDocInstance(DOCS_NORMAL_EDITOR_UNIT_ID_KEY); - const activeTextRange = textSelectionService.getActiveRectRange(); - - if (editorDataModel == null || activeTextRange == null) return null; - - const textRuns = editorDataModel.getBody()?.textRuns; - if (textRuns == null) return; - - const { startOffset } = activeTextRange; - const textRun = textRuns.find(({ st, ed }) => startOffset! >= st && startOffset! <= ed); - return textRun; -} diff --git a/packages-experimental/uni-sheets-ui/src/controllers/uni-sheets-ui.controller.tsx b/packages-experimental/uni-sheets-ui/src/controllers/uni-sheets-ui.controller.tsx deleted file mode 100644 index efc0640dcb..0000000000 --- a/packages-experimental/uni-sheets-ui/src/controllers/uni-sheets-ui.controller.tsx +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { Workbook } from '@univerjs/core'; -import { ICommandService, IConfigService, Inject, Injector, IUniverInstanceService, UniverInstanceType } from '@univerjs/core'; -import { SetBackgroundColorCommand } from '@univerjs/sheets'; -import { SHEETS_IMAGE_MENU_ID } from '@univerjs/sheets-drawing-ui'; -import { - RenderSheetContent, - SetRangeBoldCommand, - SetRangeFontFamilyCommand, - SetRangeFontSizeCommand, - SetRangeItalicCommand, - SetRangeStrickThroughCommand, - SetRangeTextColorCommand, - SetRangeUnderlineCommand, - SheetUIController, -} from '@univerjs/sheets-ui'; -import { - BuiltInUIPart, - ComponentManager, - connectInjector, - ILayoutService, - IMenuManagerService, - IShortcutService, - IUIPartsService, - useDependency, - useObservable, -} from '@univerjs/ui'; -import { BuiltinUniToolbarItemId, generateCloneMutation, UniToolbarService, UniUIPart } from '@univerjs/uniui'; -import { UniSheetBar } from '../views/uni-sheet-bar/UniSheetBar'; -import { SHEET_BOLD_MUTATION_ID, SHEET_ITALIC_MUTATION_ID, SHEET_STRIKE_MUTATION_ID, SHEET_UNDERLINE_MUTATION_ID } from './menu'; -import { menuSchema } from './menu.schema'; - -export class UniSheetsUIController extends SheetUIController { - constructor( - @Inject(Injector) injector: Injector, - @Inject(ComponentManager) componentManager: ComponentManager, - @ILayoutService layoutService: ILayoutService, - @ICommandService commandService: ICommandService, - @IShortcutService shortcutService: IShortcutService, - @IMenuManagerService menuManagerService: IMenuManagerService, - @IUIPartsService uiPartsService: IUIPartsService, - @IConfigService configService: IConfigService, - @Inject(UniToolbarService) private readonly _toolbarService: UniToolbarService - ) { - super( - injector, - componentManager, - layoutService, - commandService, - shortcutService, - menuManagerService, - uiPartsService, - configService - ); - this._initUniMenus(); - this._initMutations(); - } - - protected override _initWorkbenchParts(): void { - const uiController = this._uiPartsService; - const injector = this._injector; - - this.disposeWithMe(uiController.registerComponent(UniUIPart.OUTLINE, () => connectInjector(RenderOutline, injector))); - this.disposeWithMe(uiController.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(RenderSheetContent, injector))); - } - - private _initUniMenus(): void { - this._menuManagerService.appendRootMenu(menuSchema); - - ([ - [BuiltinUniToolbarItemId.FONT_FAMILY, SetRangeFontFamilyCommand.id], - [BuiltinUniToolbarItemId.FONT_SIZE, SetRangeFontSizeCommand.id], - [BuiltinUniToolbarItemId.COLOR, SetRangeTextColorCommand.id], - [BuiltinUniToolbarItemId.BACKGROUND, SetBackgroundColorCommand.id], - [BuiltinUniToolbarItemId.IMAGE, SHEETS_IMAGE_MENU_ID], - ]).forEach(([id, menuId]) => { - this._toolbarService.implementItem(id, { id: menuId, type: UniverInstanceType.UNIVER_SHEET }); - }); - } - - private _initMutations() { - [ - generateCloneMutation(SHEET_BOLD_MUTATION_ID, SetRangeBoldCommand), - generateCloneMutation(SHEET_ITALIC_MUTATION_ID, SetRangeItalicCommand), - generateCloneMutation(SHEET_UNDERLINE_MUTATION_ID, SetRangeUnderlineCommand), - generateCloneMutation(SHEET_STRIKE_MUTATION_ID, SetRangeStrickThroughCommand), - ].forEach((mutation) => { - this.disposeWithMe(this._commandService.registerCommand(mutation)); - }); - } -} - -function RenderOutline() { - const univerInstanceService = useDependency(IUniverInstanceService); - const focused = useObservable(univerInstanceService.focused$); - const workbook = useObservable(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), null, false, []); - - if (!workbook || focused !== workbook?.getUnitId()) return null; - - return ( - - ); -} diff --git a/packages-experimental/uni-sheets-ui/src/global.css b/packages-experimental/uni-sheets-ui/src/global.css deleted file mode 100644 index 7c05d4ddc4..0000000000 --- a/packages-experimental/uni-sheets-ui/src/global.css +++ /dev/null @@ -1,2 +0,0 @@ -@tailwind components; -@tailwind utilities; diff --git a/packages-experimental/uni-sheets-ui/src/index.ts b/packages-experimental/uni-sheets-ui/src/index.ts deleted file mode 100644 index e5a1ffd7ea..0000000000 --- a/packages-experimental/uni-sheets-ui/src/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import './global.css'; - -export { UniSheetsUIController } from './controllers/uni-sheets-ui.controller'; diff --git a/packages-experimental/uni-sheets-ui/src/views/uni-sheet-bar/UniSheetBar.tsx b/packages-experimental/uni-sheets-ui/src/views/uni-sheet-bar/UniSheetBar.tsx deleted file mode 100644 index 398ea244ec..0000000000 --- a/packages-experimental/uni-sheets-ui/src/views/uni-sheet-bar/UniSheetBar.tsx +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { ICommandInfo } from '@univerjs/core'; -import type { IBaseSheetBarProps } from '@univerjs/sheets-ui'; -import { ICommandService } from '@univerjs/core'; -import { clsx, scrollbarClassName, Tooltip } from '@univerjs/design'; -import { IncreaseIcon } from '@univerjs/icons'; -import { - InsertSheetCommand, - InsertSheetMutation, - RemoveSheetMutation, - SetTabColorMutation, - SetWorksheetActiveOperation, - SetWorksheetHideMutation, - SetWorksheetNameMutation, - SetWorksheetOrderMutation, -} from '@univerjs/sheets'; -import { useActiveWorkbook } from '@univerjs/sheets-ui'; -import { useDependency } from '@univerjs/ui'; -import { useCallback, useEffect, useRef, useState } from 'react'; - -export function UniSheetBar() { - const [sheetList, setSheetList] = useState([]); - const [activeKey, setActiveKey] = useState(''); - const workbook = useActiveWorkbook()!; - const commandService = useDependency(ICommandService); - const sheetBarRef = useRef(null); - - const updateSheetItems = useCallback(() => { - const currentSubUnitId = workbook.getActiveSheet()?.getSheetId() || ''; - setActiveKey(currentSubUnitId); - - const sheets = workbook.getSheets(); - const activeSheet = workbook.getActiveSheet(); - const sheetListItems = sheets - .filter((sheet) => !sheet.isSheetHidden()) - .map((sheet, index) => { - return { - sheetId: sheet.getSheetId(), - label: sheet.getName(), - index, - selected: activeSheet === sheet, - color: sheet.getTabColor() ?? undefined, - }; - }); - - setSheetList(sheetListItems); - setActiveKey(currentSubUnitId); - }, [workbook]); - - useEffect(() => { - updateSheetItems(); - const disposable = setupStatusUpdate(); - - return () => { - disposable.dispose(); - }; - }, [workbook]); - - const handleSheetActiveChange = (subUnitId: string | undefined) => { - if (!subUnitId) return; - - commandService.executeCommand(SetWorksheetActiveOperation.id, { - subUnitId, - unitId: workbook.getUnitId(), - }); - }; - - const handleSheetAdd = () => { - commandService.executeCommand(InsertSheetCommand.id); - }; - - const setupStatusUpdate = () => - commandService.onCommandExecuted((commandInfo: ICommandInfo) => { - switch (commandInfo.id) { - case SetTabColorMutation.id: - case SetWorksheetHideMutation.id: - case RemoveSheetMutation.id: - case SetWorksheetNameMutation.id: - case InsertSheetMutation.id: - case SetWorksheetOrderMutation.id: - case SetWorksheetActiveOperation.id: - updateSheetItems(); - break; - default: - break; - } - }); - - return ( -
-
-
- {sheetList.map((item, index) => ( -
handleSheetActiveChange(item.sheetId)} - > - - - {' '} - {item.label} - {' '} - - -
- ))} -
-
- - -
- ); -} diff --git a/packages-experimental/uni-sheets-ui/src/vite-env.d.ts b/packages-experimental/uni-sheets-ui/src/vite-env.d.ts deleted file mode 100644 index 11f02fe2a0..0000000000 --- a/packages-experimental/uni-sheets-ui/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/packages-experimental/uni-sheets-ui/tailwind.config.ts b/packages-experimental/uni-sheets-ui/tailwind.config.ts deleted file mode 100644 index 75967f186f..0000000000 --- a/packages-experimental/uni-sheets-ui/tailwind.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { Config } from 'tailwindcss'; -import preset from '@univerjs-infra/shared/tailwind'; - -const config: Config = { - presets: [preset], - content: [ - './src/**/*.{js,ts,jsx,tsx}', - ], -}; - -export default config; diff --git a/packages-experimental/uni-sheets-ui/tsconfig.json b/packages-experimental/uni-sheets-ui/tsconfig.json deleted file mode 100644 index 018601b6b9..0000000000 --- a/packages-experimental/uni-sheets-ui/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "extends": "@univerjs-infra/shared/tsconfigs/base", - "compilerOptions": { - "rootDir": "src", - "outDir": "lib/types" - }, - "references": [ - { - "path": "./tsconfig.node.json" - } - ], - "include": [ - "src" - ] -} diff --git a/packages-experimental/uni-sheets-ui/tsconfig.node.json b/packages-experimental/uni-sheets-ui/tsconfig.node.json deleted file mode 100644 index 4947a09903..0000000000 --- a/packages-experimental/uni-sheets-ui/tsconfig.node.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "@univerjs-infra/shared/tsconfigs/node", - "include": ["vitest.config.ts"] -} diff --git a/packages-experimental/uni-sheets-ui/vitest.config.ts b/packages-experimental/uni-sheets-ui/vitest.config.ts deleted file mode 100644 index af97c6d7a2..0000000000 --- a/packages-experimental/uni-sheets-ui/vitest.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import createConfig from '@univerjs-infra/shared/vitest'; - -export default createConfig(); diff --git a/packages-experimental/uni-slides-ui/README.md b/packages-experimental/uni-slides-ui/README.md deleted file mode 100644 index e4801469ab..0000000000 --- a/packages-experimental/uni-slides-ui/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# @univerjs/uni-slides-ui - -[![npm version](https://img.shields.io/npm/v/@univerjs/uni-slides-ui)](https://npmjs.org/packages/@univerjs/uni-slides-ui) -[![license](https://img.shields.io/npm/l/@univerjs/uni-slides-ui)](https://img.shields.io/npm/l/@univerjs/uni-slides-ui) - -## Introduction - -> TODO: Introduction - -## Usage - -### Installation - -```shell -npm i @univerjs/uni-slides-ui -``` diff --git a/packages-experimental/uni-slides-ui/package.json b/packages-experimental/uni-slides-ui/package.json deleted file mode 100644 index 323354a83e..0000000000 --- a/packages-experimental/uni-slides-ui/package.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "name": "@univerjs/uni-slides-ui", - "version": "0.0.0", - "private": true, - "description": "", - "author": "DreamNum ", - "license": "Apache-2.0", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/univer" - }, - "homepage": "https://univer.ai", - "repository": { - "type": "git", - "url": "https://github.com/dream-num/univer" - }, - "bugs": { - "url": "https://github.com/dream-num/univer/issues" - }, - "keywords": [], - "exports": { - ".": "./src/index.ts", - "./*": "./src/*" - }, - "main": "./src/index.ts", - "types": "./lib/types/index.d.ts", - "publishConfig": { - "access": "public", - "main": "./lib/es/index.js", - "module": "./lib/es/index.js", - "exports": { - ".": { - "import": "./lib/es/index.js", - "require": "./lib/cjs/index.js", - "types": "./lib/types/index.d.ts" - }, - "./*": { - "import": "./lib/es/*", - "require": "./lib/cjs/*", - "types": "./lib/types/index.d.ts" - }, - "./lib/*": "./lib/*" - } - }, - "directories": { - "lib": "lib" - }, - "files": [ - "lib" - ], - "scripts": { - "test": "vitest run", - "test:watch": "vitest", - "coverage": "vitest run --coverage", - "typecheck": "tsc --noEmit", - "build": "univer-cli build" - }, - "peerDependencies": { - "react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" - }, - "dependencies": { - "@univerjs/core": "workspace:*", - "@univerjs/design": "workspace:*", - "@univerjs/engine-render": "workspace:*", - "@univerjs/icons": "^1.1.0", - "@univerjs/slides-ui": "workspace:*", - "@univerjs/ui": "workspace:*", - "@univerjs/uniui": "workspace:*" - }, - "devDependencies": { - "@univerjs-infra/shared": "workspace:*", - "postcss": "^8.5.6", - "react": "18.3.1", - "rxjs": "^7.8.2", - "tailwindcss": "3.4.18", - "typescript": "^5.9.3", - "vite": "^7.3.0", - "vitest": "^4.0.16" - } -} diff --git a/packages-experimental/uni-slides-ui/postcss.config.mjs b/packages-experimental/uni-slides-ui/postcss.config.mjs deleted file mode 100644 index 7d59f53133..0000000000 --- a/packages-experimental/uni-slides-ui/postcss.config.mjs +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@univerjs-infra/shared/postcss'; diff --git a/packages-experimental/uni-slides-ui/src/controllers/menu.schema.ts b/packages-experimental/uni-slides-ui/src/controllers/menu.schema.ts deleted file mode 100644 index b3024f179f..0000000000 --- a/packages-experimental/uni-slides-ui/src/controllers/menu.schema.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { MenuSchemaType } from '@univerjs/ui'; -import { SlidesUIMenuSchema } from '@univerjs/slides-ui'; -import { RibbonStartGroup } from '@univerjs/ui'; -import { UNI_MENU_POSITIONS } from '@univerjs/uniui'; - -export const menuSchema: MenuSchemaType = { - [UNI_MENU_POSITIONS.TOOLBAR_MAIN]: (SlidesUIMenuSchema as any)[RibbonStartGroup.FORMAT], -}; diff --git a/packages-experimental/uni-slides-ui/src/controllers/uni-slides-ui.controller.tsx b/packages-experimental/uni-slides-ui/src/controllers/uni-slides-ui.controller.tsx deleted file mode 100644 index e99b72ab0a..0000000000 --- a/packages-experimental/uni-slides-ui/src/controllers/uni-slides-ui.controller.tsx +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { SlideDataModel } from '@univerjs/core'; -import { ICommandService, Inject, Injector, IUniverInstanceService, UniverInstanceType } from '@univerjs/core'; -import { SHAPE_MENU_ID, SlideAddTextCommand, SlideEditorContainer, SLIDES_IMAGE_MENU_ID, SlidesUIController } from '@univerjs/slides-ui'; -import { BuiltInUIPart, ComponentManager, connectInjector, IMenuManagerService, IShortcutService, IUIPartsService, useDependency, useObservable } from '@univerjs/ui'; -import { BuiltinUniToolbarItemId, UniToolbarService, UniUIPart } from '@univerjs/uniui'; -import { UniSlideSideBar } from '../views/UniSlideSideBar'; -import { menuSchema } from './menu.schema'; - -export class UniSlidesUIController extends SlidesUIController { - constructor( - @Inject(Injector) _injector: Injector, - @IMenuManagerService _menuManagerService: IMenuManagerService, - @Inject(ComponentManager) _componentManager: ComponentManager, - @IUIPartsService _uiPartsService: IUIPartsService, - @ICommandService _commandService: ICommandService, - @IShortcutService _shortcutService: IShortcutService, - @Inject(UniToolbarService) private readonly _toolbarService: UniToolbarService - ) { - super(_injector, _menuManagerService, _componentManager, _uiPartsService, _commandService, _shortcutService); - this._initUniMenus(); - } - - protected override _initUIComponents(): void { - this.disposeWithMe(this._uiPartsService.registerComponent(UniUIPart.OUTLINE, () => connectInjector(RenderOutline, this._injector))); - - this.disposeWithMe( - this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(SlideEditorContainer, this._injector)) - ); - } - - private _initUniMenus(): void { - this._menuManagerService.appendRootMenu(menuSchema); - - ([ - [BuiltinUniToolbarItemId.IMAGE, SLIDES_IMAGE_MENU_ID], - [BuiltinUniToolbarItemId.FONT_GROUP, SHAPE_MENU_ID], - [BuiltinUniToolbarItemId.TABLE, SlideAddTextCommand.id], - ]).forEach(([id, menuId]) => { - this._toolbarService.implementItem(id, { id: menuId, type: UniverInstanceType.UNIVER_SLIDE }); - }); - } -} - -function RenderOutline() { - const univerInstanceService = useDependency(IUniverInstanceService); - const focused = useObservable(univerInstanceService.focused$); - const slide = useObservable(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SLIDE), null, false, []); - if (!slide || focused !== slide.getUnitId()) return null; - - return ( - - ); -} diff --git a/packages-experimental/uni-slides-ui/src/global.css b/packages-experimental/uni-slides-ui/src/global.css deleted file mode 100644 index 7c05d4ddc4..0000000000 --- a/packages-experimental/uni-slides-ui/src/global.css +++ /dev/null @@ -1,2 +0,0 @@ -@tailwind components; -@tailwind utilities; diff --git a/packages-experimental/uni-slides-ui/src/index.ts b/packages-experimental/uni-slides-ui/src/index.ts deleted file mode 100644 index b12e44bdb9..0000000000 --- a/packages-experimental/uni-slides-ui/src/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import './global.css'; - -export { UniSlidesUIController } from './controllers/uni-slides-ui.controller'; diff --git a/packages-experimental/uni-slides-ui/src/views/UniSlideSideBar.tsx b/packages-experimental/uni-slides-ui/src/views/UniSlideSideBar.tsx deleted file mode 100644 index 936d23dd0e..0000000000 --- a/packages-experimental/uni-slides-ui/src/views/UniSlideSideBar.tsx +++ /dev/null @@ -1,145 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { SlideDataModel } from '@univerjs/core'; -import { ICommandService, IUniverInstanceService, LocaleService, UniverInstanceType } from '@univerjs/core'; -import { borderClassName, clsx, scrollbarClassName } from '@univerjs/design'; -import { IRenderManagerService } from '@univerjs/engine-render'; -import { IncreaseIcon } from '@univerjs/icons'; -import { ActivateSlidePageOperation, AppendSlideOperation, SetSlidePageThumbOperation } from '@univerjs/slides-ui'; -import { useDependency, useObservable } from '@univerjs/ui'; -import { createRef, useCallback, useEffect, useMemo, useRef, useState } from 'react'; - -/** - * This components works as the root component of the left Sidebar of Slide. - */ - -export function UniSlideSideBar() { - const univerInstanceService = useDependency(IUniverInstanceService); - const commandService = useDependency(ICommandService); - const renderManagerService = useDependency(IRenderManagerService); - const localeService = useDependency(LocaleService); - - const slideBarRef = useRef(null); - const currentSlide = useObservable( - () => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SLIDE), - undefined, - undefined, - [] - ); - const pages = currentSlide?.getPages(); - const pageOrder = currentSlide?.getPageOrder(); - - if (!pages || !pageOrder) { - return null; - } - - const slideList = pageOrder.map((id) => pages[id]); - - const [activatePageId, setActivatePageId] = useState(pageOrder[0]); - const [barHeight, setBarHeight] = useState(0); - - const divRefs = useMemo(() => slideList.map(() => createRef()), [slideList]); - - useEffect(() => { - const subscriber = currentSlide?.activePage$.subscribe((page) => { - const id = page?.id ?? null; - - id && setActivatePageId(id); - }); - - return () => { - subscriber?.unsubscribe(); - }; - }, []); - - useEffect(() => { - divRefs.forEach((ref, index) => { - if (ref.current) { - const slide = slideList[index]; - renderManagerService.getRenderById(slide.id)?.engine.setContainer(ref.current); - } - }); - - if (divRefs.length > 0) { - commandService.syncExecuteCommand(SetSlidePageThumbOperation.id, { - unitId: currentSlide?.getUnitId(), - }); - } - }, [divRefs, commandService, renderManagerService, slideList, currentSlide]); // 依赖于divRefs数组的变化 - - useEffect(() => { - const slideBar = slideBarRef.current; - if (slideBar) { - setBarHeight(slideBar.clientHeight - 38); - } - }, []); - - const activatePage = useCallback((page: string) => { - commandService.syncExecuteCommand(ActivateSlidePageOperation.id, { id: page, unitId: currentSlide?.getUnitId() }); - }, [commandService, currentSlide]); - - const handleAppendSlide = useCallback(() => { - commandService.syncExecuteCommand(AppendSlideOperation.id, { unitId: currentSlide?.getUnitId() }); - }, [commandService, currentSlide]); - - return ( -
-
- {slideList.map((item, index) => ( -
activatePage(item.id)} - > - - {index + 1} - -
-
- ))} -
- -
- ); -} diff --git a/packages-experimental/uni-slides-ui/src/vite-env.d.ts b/packages-experimental/uni-slides-ui/src/vite-env.d.ts deleted file mode 100644 index 11f02fe2a0..0000000000 --- a/packages-experimental/uni-slides-ui/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/packages-experimental/uni-slides-ui/tailwind.config.ts b/packages-experimental/uni-slides-ui/tailwind.config.ts deleted file mode 100644 index 75967f186f..0000000000 --- a/packages-experimental/uni-slides-ui/tailwind.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { Config } from 'tailwindcss'; -import preset from '@univerjs-infra/shared/tailwind'; - -const config: Config = { - presets: [preset], - content: [ - './src/**/*.{js,ts,jsx,tsx}', - ], -}; - -export default config; diff --git a/packages-experimental/uni-slides-ui/tsconfig.json b/packages-experimental/uni-slides-ui/tsconfig.json deleted file mode 100644 index 018601b6b9..0000000000 --- a/packages-experimental/uni-slides-ui/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "extends": "@univerjs-infra/shared/tsconfigs/base", - "compilerOptions": { - "rootDir": "src", - "outDir": "lib/types" - }, - "references": [ - { - "path": "./tsconfig.node.json" - } - ], - "include": [ - "src" - ] -} diff --git a/packages-experimental/uni-slides-ui/tsconfig.node.json b/packages-experimental/uni-slides-ui/tsconfig.node.json deleted file mode 100644 index 4947a09903..0000000000 --- a/packages-experimental/uni-slides-ui/tsconfig.node.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "@univerjs-infra/shared/tsconfigs/node", - "include": ["vitest.config.ts"] -} diff --git a/packages-experimental/uni-slides-ui/vitest.config.ts b/packages-experimental/uni-slides-ui/vitest.config.ts deleted file mode 100644 index af97c6d7a2..0000000000 --- a/packages-experimental/uni-slides-ui/vitest.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import createConfig from '@univerjs-infra/shared/vitest'; - -export default createConfig(); diff --git a/packages-experimental/uniui/README.md b/packages-experimental/uniui/README.md deleted file mode 100644 index fb7f05dcb9..0000000000 --- a/packages-experimental/uniui/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# @univerjs/uniui - -[![npm version](https://img.shields.io/npm/v/@univerjs/uniui)](https://npmjs.org/packages/@univerjs/uniui) -[![license](https://img.shields.io/npm/l/@univerjs/uniui)](https://img.shields.io/npm/l/@univerjs/uniui) - -## Introduction - -> TODO: Introduction - -## Usage - -### Installation - -```shell -npm i @univerjs/uniui -``` diff --git a/packages-experimental/uniui/package.json b/packages-experimental/uniui/package.json deleted file mode 100644 index 2388247cff..0000000000 --- a/packages-experimental/uniui/package.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "name": "@univerjs/uniui", - "version": "0.0.0", - "private": true, - "description": "", - "author": "DreamNum ", - "license": "Apache-2.0", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/univer" - }, - "homepage": "https://univer.ai", - "repository": { - "type": "git", - "url": "https://github.com/dream-num/univer" - }, - "bugs": { - "url": "https://github.com/dream-num/univer/issues" - }, - "keywords": [], - "exports": { - ".": "./src/index.ts", - "./*": "./src/*" - }, - "main": "./src/index.ts", - "types": "./lib/types/index.d.ts", - "publishConfig": { - "access": "public", - "main": "./lib/es/index.js", - "module": "./lib/es/index.js", - "exports": { - ".": { - "import": "./lib/es/index.js", - "require": "./lib/cjs/index.js", - "types": "./lib/types/index.d.ts" - }, - "./*": { - "import": "./lib/es/*", - "require": "./lib/cjs/*", - "types": "./lib/types/index.d.ts" - }, - "./lib/*": "./lib/*" - } - }, - "directories": { - "lib": "lib" - }, - "files": [ - "lib" - ], - "scripts": { - "test": "vitest run", - "test:watch": "vitest", - "coverage": "vitest run --coverage", - "typecheck": "tsc --noEmit", - "build": "univer-cli build" - }, - "peerDependencies": { - "react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc", - "react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc", - "rxjs": ">=7.0.0" - }, - "dependencies": { - "@floating-ui/react-dom": "^2.1.6", - "@univerjs/core": "workspace:*", - "@univerjs/design": "workspace:*", - "@univerjs/engine-render": "workspace:*", - "@univerjs/icons": "^1.1.0", - "@univerjs/sheets": "workspace:*", - "@univerjs/sheets-ui": "workspace:*", - "@univerjs/ui": "workspace:*", - "@xyflow/react": "^12.10.0" - }, - "devDependencies": { - "@univerjs-infra/shared": "workspace:*", - "@univerjs/themes": "workspace:*", - "postcss": "^8.5.6", - "react": "18.3.1", - "react-dom": "18.3.1", - "rxjs": "^7.8.2", - "tailwindcss": "3.4.18", - "typescript": "^5.9.3", - "vite": "^7.3.0", - "vitest": "^4.0.16" - } -} diff --git a/packages-experimental/uniui/postcss.config.mjs b/packages-experimental/uniui/postcss.config.mjs deleted file mode 100644 index 7d59f53133..0000000000 --- a/packages-experimental/uniui/postcss.config.mjs +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@univerjs-infra/shared/postcss'; diff --git a/packages-experimental/uniui/src/commands/operations/set-flow-viewport.operation.ts b/packages-experimental/uniui/src/commands/operations/set-flow-viewport.operation.ts deleted file mode 100644 index 00741bcbcb..0000000000 --- a/packages-experimental/uniui/src/commands/operations/set-flow-viewport.operation.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { IAccessor, ICommand, IExecutionOptions } from '@univerjs/core'; -import { CommandType } from '@univerjs/core'; -import { FlowManagerService } from '../../services/flow/flow-manager.service'; - -export interface ISetFlowViewportParams { - viewport: { - zoom: number; - x: number; - y: number; - }; -} - -// This operation will not trigger viewport change locally but for live-share collaboration. - -export const SetFlowViewportOperation: ICommand = { - id: 'uniui.operation.set-flow-viewport', - type: CommandType.OPERATION, - handler: async (accessor: IAccessor, params: ISetFlowViewportParams, options?: IExecutionOptions) => { - const { fromCollab } = options || {}; - if (!fromCollab) { - return true; - } - const flowManagerService = accessor.get(FlowManagerService); - const oldViewport = flowManagerService.getViewport(); - const { viewport } = params; - const { zoom, x, y } = viewport; - if (oldViewport) { - if (zoom === oldViewport.zoom && x === oldViewport.x && y === oldViewport.y) { - return false; - } - } - flowManagerService.setViewport(viewport); - return true; - }, -}; diff --git a/packages-experimental/uniui/src/commands/operations/uni-focus-unit.operation.ts b/packages-experimental/uniui/src/commands/operations/uni-focus-unit.operation.ts deleted file mode 100644 index 61dfb91d37..0000000000 --- a/packages-experimental/uniui/src/commands/operations/uni-focus-unit.operation.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { IAccessor, ICommand } from '@univerjs/core'; -import { CommandType, IUniverInstanceService } from '@univerjs/core'; - -export interface IUniFocusUnitParams { - unitId: string | null; -} - -export const UniFocusUnitOperation: ICommand = { - id: 'uniui.operation.uni-focus-unit', - type: CommandType.OPERATION, - handler: async (accessor: IAccessor, params: IUniFocusUnitParams) => { - const { unitId } = params; - const instanceService = accessor.get(IUniverInstanceService); - instanceService.focusUnit(unitId); - return true; - }, -}; diff --git a/packages-experimental/uniui/src/commands/operations/uni.operation.ts b/packages-experimental/uniui/src/commands/operations/uni.operation.ts deleted file mode 100644 index 6de9a3b25a..0000000000 --- a/packages-experimental/uniui/src/commands/operations/uni.operation.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { IAccessor, ICommand } from '@univerjs/core'; -import { CommandType, IUniverInstanceService } from '@univerjs/core'; - -export const DisposeUnitOperation: ICommand = { - id: 'uniui.operation.dispose-unit', - type: CommandType.OPERATION, - handler: async (accessor: IAccessor) => { - const univerInstanceService = accessor.get(IUniverInstanceService); - const unitId = univerInstanceService.getFocusedUnit()?.getUnitId(); - if (unitId) { - univerInstanceService.disposeUnit(unitId); - } - return true; - }, -}; diff --git a/packages-experimental/uniui/src/controllers/menu.schema.ts b/packages-experimental/uniui/src/controllers/menu.schema.ts deleted file mode 100644 index 26cd397d80..0000000000 --- a/packages-experimental/uniui/src/controllers/menu.schema.ts +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { MenuSchemaType } from '@univerjs/ui'; -import { RibbonStartGroup, UIMenuSchema } from '@univerjs/ui'; -import { FONT_GROUP_MENU_ID } from '@univerjs/uniui'; -import { - DELETE_MENU_ID, - DeleteMenuItemFactory, - DOWNLOAD_MENU_ID, - DownloadMenuItemFactory, - FAKE_BG_COLOR_MENU_ID, - FAKE_FONT_COLOR_MENU_ID, - FAKE_FONT_FAMILY_MENU_ID, - FAKE_FONT_GROUP_MENU_ID, - FAKE_FONT_SIZE_MENU_ID, - FAKE_IMAGE_MENU_ID, - FAKE_ORDER_LIST_MENU_ID, - FAKE_TABLE_MENU_ID, - FAKE_UNORDER_LIST_MENU_ID, - FakeBackgroundColorSelectorMenuItemFactory, - FakeFontFamilySelectorMenuItemFactory, - FakeFontGroupMenuItemFactory, - FakeFontSizeSelectorMenuItemFactory, - FakeImageMenuFactory, - FakeOrderListMenuItemFactory, - FakePivotTableMenuItemFactory, - FakeTextColorSelectorMenuItemFactory, - FakeUnorderListMenuItemFactory, - FontGroupMenuItemFactory, - // LOCK_MENU_ID, - // LockMenuItemFactory, - PRINT_MENU_ID, - PrintMenuItemFactory, - SHARE_MENU_ID, - ShareMenuItemFactory, - UNI_MENU_POSITIONS, - ZEN_MENU_ID, - ZenMenuItemFactory, -} from './menu'; - -export const menuSchema: MenuSchemaType = { - [UNI_MENU_POSITIONS.TOOLBAR_MAIN]: { - ...(UIMenuSchema as any)[RibbonStartGroup.HISTORY], - [FAKE_FONT_FAMILY_MENU_ID]: { - menuItemFactory: FakeFontFamilySelectorMenuItemFactory, - }, - [FAKE_FONT_SIZE_MENU_ID]: { - menuItemFactory: FakeFontSizeSelectorMenuItemFactory, - }, - [FAKE_FONT_COLOR_MENU_ID]: { - menuItemFactory: FakeTextColorSelectorMenuItemFactory, - }, - [FAKE_BG_COLOR_MENU_ID]: { - menuItemFactory: FakeBackgroundColorSelectorMenuItemFactory, - }, - [FAKE_IMAGE_MENU_ID]: { - menuItemFactory: FakeImageMenuFactory, - }, - [FAKE_UNORDER_LIST_MENU_ID]: { - menuItemFactory: FakeUnorderListMenuItemFactory, - }, - [FAKE_ORDER_LIST_MENU_ID]: { - menuItemFactory: FakeOrderListMenuItemFactory, - }, - [FONT_GROUP_MENU_ID]: { - menuItemFactory: FontGroupMenuItemFactory, - }, - [FAKE_FONT_GROUP_MENU_ID]: { - menuItemFactory: FakeFontGroupMenuItemFactory, - }, - [FAKE_TABLE_MENU_ID]: { - menuItemFactory: FakePivotTableMenuItemFactory, - }, - }, - [UNI_MENU_POSITIONS.TOOLBAR_FLOAT]: { - [DOWNLOAD_MENU_ID]: { - menuItemFactory: DownloadMenuItemFactory, - }, - [SHARE_MENU_ID]: { - menuItemFactory: ShareMenuItemFactory, - }, - // [LOCK_MENU_ID]: { - // menuItemFactory: LockMenuItemFactory, - // }, - [PRINT_MENU_ID]: { - menuItemFactory: PrintMenuItemFactory, - }, - [ZEN_MENU_ID]: { - menuItemFactory: ZenMenuItemFactory, - }, - [DELETE_MENU_ID]: { - menuItemFactory: DeleteMenuItemFactory, - }, - }, -}; diff --git a/packages-experimental/uniui/src/controllers/menu.ts b/packages-experimental/uniui/src/controllers/menu.ts deleted file mode 100644 index 10a5ce1c30..0000000000 --- a/packages-experimental/uniui/src/controllers/menu.ts +++ /dev/null @@ -1,248 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { IAccessor } from '@univerjs/core'; -import type { IMenuButtonItem, IMenuItem, IMenuSelectorItem } from '@univerjs/ui'; -import { IUniverInstanceService, UniverInstanceType } from '@univerjs/core'; -import { MenuItemType } from '@univerjs/ui'; -import { Observable } from 'rxjs'; -import { DisposeUnitOperation } from '../commands/operations/uni.operation'; - -export const UNIT_LINE_COLOR_MENU_ID = 'UNIT_LINE_COLOR_MENU_ID'; -export const DOWNLOAD_MENU_ID = 'DOWNLOAD_MENU_ID'; -export const SHARE_MENU_ID = 'SHARE_MENU_ID'; -export const LOCK_MENU_ID = 'LOCK_MENU_ID'; -export const PRINT_MENU_ID = 'PRINT_MENU_ID'; -export const ZEN_MENU_ID = 'ZEN_MENU_ID'; -export const DELETE_MENU_ID = DisposeUnitOperation.id; -export const FRAME_SIZE_MENU_ID = 'FRAME_SIZE_MENU_ID'; - -export const FONT_GROUP_MENU_ID = 'FONT_GROUP_MENU_ID'; - -export const FAKE_FONT_FAMILY_MENU_ID = 'FAKE_FONT_FAMILY_MENU_ID'; -export const FAKE_FONT_SIZE_MENU_ID = 'FAKE_FONT_SIZE_MENU_ID'; -export const FAKE_FONT_COLOR_MENU_ID = 'FAKE_FONT_COLOR_MENU_ID'; -export const FAKE_BG_COLOR_MENU_ID = 'FAKE_BG_COLOR_MENU_ID'; -export const FAKE_IMAGE_MENU_ID = 'FAKE_IMAGE_MENU_ID'; -export const FAKE_FONT_GROUP_MENU_ID = 'FAKE_FONT_GROUP_MENU_ID'; -export const FAKE_TABLE_MENU_ID = 'FAKE_TABLE_MENU_ID'; -export const FAKE_UNORDER_LIST_MENU_ID = 'FAKE_UNORDER_LIST_MENU_ID'; -export const FAKE_ORDER_LIST_MENU_ID = 'FAKE_ORDER_LIST_MENU_ID'; - -export enum UNI_MENU_POSITIONS { - TOOLBAR_MAIN = 'toolbar_main', - TOOLBAR_FLOAT = 'toolbar_float', -} - -export function FakeFontFamilySelectorMenuItemFactory(): IMenuSelectorItem { - return { - id: FAKE_FONT_FAMILY_MENU_ID, - tooltip: 'toolbar.font', - type: MenuItemType.SELECTOR, - label: 'UI_PLUGIN_DOCS_FONT_SIZE_COMPONENT', - selections: [], - disabled$: new Observable((subscriber) => { subscriber.next(true); }), - }; -} - -export function FakeFontSizeSelectorMenuItemFactory(): IMenuSelectorItem { - return { - id: FAKE_FONT_SIZE_MENU_ID, - type: MenuItemType.SELECTOR, - tooltip: 'toolbar.fontSize', - label: { - name: 'UI_PLUGIN_DOCS_FONT_SIZE_COMPONENT', - props: { - min: 1, - max: 400, - }, - }, - selections: [], - disabled$: new Observable((subscriber) => { subscriber.next(true); }), - }; -} - -export function FakeTextColorSelectorMenuItemFactory(): IMenuSelectorItem { - return { - id: FAKE_FONT_COLOR_MENU_ID, - icon: 'FontColorDoubleIcon', - tooltip: 'toolbar.textColor.main', - type: MenuItemType.BUTTON_SELECTOR, - selections: [], - disabled$: new Observable((subscriber) => { subscriber.next(true); }), - }; -} - -export function FakeBackgroundColorSelectorMenuItemFactory(): IMenuSelectorItem { - return { - id: FAKE_BG_COLOR_MENU_ID, - tooltip: 'toolbar.fillColor.main', - type: MenuItemType.BUTTON_SELECTOR, - icon: 'PaintBucketDoubleIcon', - selections: [], - disabled$: new Observable((subscriber) => { subscriber.next(true); }), - }; -} - -export function FakeImageMenuFactory(): IMenuItem { - return { - id: FAKE_IMAGE_MENU_ID, - type: MenuItemType.SUBITEMS, - icon: 'AdditionAndSubtractionIcon', - tooltip: 'sheetImage.title', - disabled$: new Observable((subscriber) => { subscriber.next(true); }), - }; -} - -export function FakeUnorderListMenuItemFactory(): IMenuItem { - return { - id: FAKE_UNORDER_LIST_MENU_ID, - type: MenuItemType.BUTTON_SELECTOR, - icon: 'UnorderIcon', - tooltip: 'toolbar.unorder', - disabled$: new Observable((subscriber) => { subscriber.next(true); }), - }; -} - -export function FakeOrderListMenuItemFactory(): IMenuItem { - return { - id: FAKE_ORDER_LIST_MENU_ID, - type: MenuItemType.BUTTON_SELECTOR, - icon: 'OrderIcon', - tooltip: 'toolbar.order', - disabled$: new Observable((subscriber) => { subscriber.next(true); }), - }; -} - -export function FontGroupMenuItemFactory(accessor: IAccessor): IMenuSelectorItem { - const univerInstanceService = accessor.get(IUniverInstanceService); - return { - id: FONT_GROUP_MENU_ID, - type: MenuItemType.SUBITEMS, - tooltip: 'Font group', - icon: 'BoldIcon', - hidden$: new Observable((subscriber) => { - const subscription = univerInstanceService.focused$.subscribe((unitId) => { - if (unitId == null) { - return subscriber.next(true); - } - const univerType = univerInstanceService.getUnitType(unitId); - - subscriber.next(univerType === UniverInstanceType.UNIVER_SLIDE); - }); - - const focusedUniverInstance = univerInstanceService.getFocusedUnit(); - - if (focusedUniverInstance == null) { - return subscriber.next(true); - } - - const univerType = univerInstanceService.getUnitType(focusedUniverInstance.getUnitId()); - subscriber.next(univerType === UniverInstanceType.UNIVER_SLIDE); - - return () => subscription.unsubscribe(); - }), - }; -} - -export function FakeFontGroupMenuItemFactory(): IMenuSelectorItem { - return { - id: FAKE_FONT_GROUP_MENU_ID, - type: MenuItemType.SUBITEMS, - tooltip: 'Font group', - icon: 'BoldIcon', - disabled$: new Observable((subscriber) => { subscriber.next(true); }), - }; -} - -export function FakePivotTableMenuItemFactory(): IMenuItem { - return { - id: FAKE_TABLE_MENU_ID, - type: MenuItemType.BUTTON, - icon: 'PivotTableIcon', - tooltip: 'PivotTable', - disabled$: new Observable((subscriber) => { subscriber.next(true); }), - }; -} - -export function UnitLineColorMenuItemFactory(): IMenuButtonItem { - return { - id: UNIT_LINE_COLOR_MENU_ID, - type: MenuItemType.BUTTON, - title: '', - icon: '', - }; -} - -export function DownloadMenuItemFactory(): IMenuButtonItem { - return { - id: DOWNLOAD_MENU_ID, - type: MenuItemType.BUTTON, - title: '', - tooltip: 'Download', - icon: 'DownloadIcon', - }; -} - -export function ShareMenuItemFactory(): IMenuButtonItem { - return { - id: SHARE_MENU_ID, - type: MenuItemType.BUTTON, - title: '', - tooltip: 'Share', - icon: 'ShareIcon', - }; -} - -export function LockMenuItemFactory(): IMenuButtonItem { - return { - id: LOCK_MENU_ID, - type: MenuItemType.BUTTON, - title: '', - tooltip: 'Lock', - icon: 'LockIcon', - }; -} - -export function PrintMenuItemFactory(): IMenuButtonItem { - return { - id: PRINT_MENU_ID, - type: MenuItemType.BUTTON, - title: '', - tooltip: 'Print', - icon: 'PrintIcon', - }; -} - -export function ZenMenuItemFactory(): IMenuButtonItem { - return { - id: ZEN_MENU_ID, - type: MenuItemType.BUTTON, - title: '', - icon: 'ZenIcon', - tooltip: 'Full screen', - }; -} - -export function DeleteMenuItemFactory(): IMenuButtonItem { - return { - id: DELETE_MENU_ID, - type: MenuItemType.BUTTON, - title: 'Delete', - tooltip: 'Delete', - icon: 'DeleteIcon', - }; -} diff --git a/packages-experimental/uniui/src/controllers/uniui-desktop.controller.tsx b/packages-experimental/uniui/src/controllers/uniui-desktop.controller.tsx deleted file mode 100644 index 758cf8efd6..0000000000 --- a/packages-experimental/uniui/src/controllers/uniui-desktop.controller.tsx +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { IDisposable } from '@univerjs/core'; -import type { IUniverUIConfig, IWorkbenchOptions } from '@univerjs/ui'; -import { Disposable, Inject, Injector, LifecycleService, LifecycleStages, Optional, toDisposable } from '@univerjs/core'; -import { render as createRoot, unmount } from '@univerjs/design'; -import { BuiltInUIPart, CanvasPopup, connectInjector, FloatDom, ILayoutService, IUIPartsService } from '@univerjs/ui'; -import { delay, filter, take } from 'rxjs'; - -import { UniWorkbench } from '../views/workbench/UniWorkbench'; - -const STEADY_TIMEOUT = 3000; - -export class UniverUniUIController extends Disposable { - constructor( - private readonly _config: IUniverUIConfig, - @Inject(Injector) private readonly _injector: Injector, - @Inject(LifecycleService) private readonly _lifecycleService: LifecycleService, - @IUIPartsService private readonly _uiPartsService: IUIPartsService, - @Optional(ILayoutService) private readonly _layoutService?: ILayoutService - ) { - super(); - - this._initBuiltinComponents(); - - Promise.resolve().then(() => this._bootstrapWorkbench()); - } - - private _bootstrapWorkbench(): void { - this.disposeWithMe( - bootstrap(this._injector, this._config, (contentEl, containerEl) => { - if (this._layoutService) { - this.disposeWithMe(this._layoutService.registerContentElement(contentEl)); - this.disposeWithMe(this._layoutService.registerContainerElement(containerEl)); - } - - this._lifecycleService.lifecycle$.pipe( - filter((lifecycle) => lifecycle === LifecycleStages.Ready), - delay(300), - take(1) - ).subscribe(() => { - this._lifecycleService.stage = LifecycleStages.Rendered; - setTimeout(() => this._lifecycleService.stage = LifecycleStages.Steady, STEADY_TIMEOUT); - }); - }) - ); - } - - private _initBuiltinComponents() { - this.disposeWithMe(this._uiPartsService.registerComponent(BuiltInUIPart.FLOATING, () => connectInjector(CanvasPopup, this._injector))); - this.disposeWithMe(this._uiPartsService.registerComponent(BuiltInUIPart.UNIT, () => connectInjector(FloatDom, this._injector))); - } -} - -function bootstrap( - injector: Injector, - options: IWorkbenchOptions, - callback: (contentEl: HTMLElement, containerElement: HTMLElement) => void -): IDisposable { - let mountContainer: HTMLElement; - - const container = options.container; - if (typeof container === 'string') { - const containerElement = document.getElementById(container); - if (!containerElement) { - mountContainer = createContainer(container); - } else { - mountContainer = containerElement; - } - } else if (container instanceof HTMLElement) { - mountContainer = container; - } else { - mountContainer = createContainer('univer'); - } - - const ConnectedApp = connectInjector(UniWorkbench, injector); - function render() { - createRoot( - callback(contentEl, mountContainer)} - />, - mountContainer - ); - } - - render(); - - return toDisposable(() => { - unmount(mountContainer); - }); -} - -function createContainer(id: string): HTMLElement { - const element = document.createElement('div'); - element.id = id; - // FIXME: the element is not append to the DOM tree. So it won't be rendered. - return element; -} diff --git a/packages-experimental/uniui/src/controllers/uniui-flow.controller.tsx b/packages-experimental/uniui/src/controllers/uniui-flow.controller.tsx deleted file mode 100644 index c1d0e06d73..0000000000 --- a/packages-experimental/uniui/src/controllers/uniui-flow.controller.tsx +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { IFlowViewport } from '../services/flow/flow-manager.service'; -import { Disposable, ICommandService, Inject } from '@univerjs/core'; -import { auditTime, throttleTime } from 'rxjs'; -import { SetFlowViewportOperation } from '../commands/operations/set-flow-viewport.operation'; -import { UniFocusUnitOperation } from '../commands/operations/uni-focus-unit.operation'; -import { FlowManagerService } from '../services/flow/flow-manager.service'; - -export class UniuiFlowController extends Disposable { - constructor( - @ICommandService protected readonly _commandService: ICommandService, - @Inject(FlowManagerService) protected readonly _flowManagerService: FlowManagerService - ) { - super(); - this._initCommands(); - this._triggerCommands(); - } - - private _initCommands(): void { - [ - SetFlowViewportOperation, - UniFocusUnitOperation, - ].forEach((c) => { - this.disposeWithMe(this._commandService.registerCommand(c)); - }); - } - - private _triggerCommands() { - this._flowManagerService.viewportChanged$.pipe( - throttleTime(100, undefined, { leading: true, trailing: true }), - auditTime(100) - ).subscribe((viewport: IFlowViewport | null) => { - if (viewport) { - this._commandService.executeCommand(SetFlowViewportOperation.id, { viewport }); - } - }); - } -} diff --git a/packages-experimental/uniui/src/controllers/uniui-leftsidebar.controller.tsx b/packages-experimental/uniui/src/controllers/uniui-leftsidebar.controller.tsx deleted file mode 100644 index c57665f9b9..0000000000 --- a/packages-experimental/uniui/src/controllers/uniui-leftsidebar.controller.tsx +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { ISidebarService } from '@univerjs/ui'; -import { Disposable, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core'; -import { ComponentManager, ILeftSidebarService } from '@univerjs/ui'; -import { distinctUntilChanged, map } from 'rxjs'; -import { Outline } from '../views/outline/Outline'; - -const OUTLINE_COMPONENT = 'OUTLINE_COMPONENT'; - -export class UniuiLeftSidebarController extends Disposable { - constructor( - @Inject(ComponentManager) private readonly _componentManager: ComponentManager, - @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService, - @ILeftSidebarService private readonly _leftSidebarService: ISidebarService - ) { - super(); - - this._initComponents(); - this._initShowOutlineListener(); - } - - private _initComponents(): void { - this.disposeWithMe(this._componentManager.register(OUTLINE_COMPONENT, Outline)); - } - - private _initShowOutlineListener(): void { - this.disposeWithMe(this._univerInstanceService.focused$.pipe( - map((unitId) => !unitId ? false : this._univerInstanceService.getUnit(unitId)?.type !== UniverInstanceType.UNIVER_DOC), - distinctUntilChanged() - ).subscribe((showOutline) => { - if (showOutline) { - this._leftSidebarService.open({ - children: { label: OUTLINE_COMPONENT }, - visible: true, - width: 185, - }); - } else { - this._leftSidebarService.close(); - } - })); - - this.disposeWithMe(this._univerInstanceService.unitDisposed$.pipe( - distinctUntilChanged() - ).subscribe(() => { - this._leftSidebarService.close(); - })); - } -} diff --git a/packages-experimental/uniui/src/controllers/uniui-toolbar.controller.tsx b/packages-experimental/uniui/src/controllers/uniui-toolbar.controller.tsx deleted file mode 100644 index e436ba2adf..0000000000 --- a/packages-experimental/uniui/src/controllers/uniui-toolbar.controller.tsx +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { MenuConfig } from '@univerjs/ui'; -import { Disposable, ICommandService, Inject, Injector } from '@univerjs/core'; -import { DeleteIcon, DownloadIcon, LockIcon, PivotTableIcon, PrintIcon, ShareIcon, ZenIcon } from '@univerjs/icons'; -import { ComponentManager, IMenuManagerService } from '@univerjs/ui'; -import { DisposeUnitOperation } from '../commands/operations/uni.operation'; -import { UniToolbarService } from '../services/toolbar/uni-toolbar-service'; -import { menuSchema } from './menu.schema'; - -export interface IUniuiToolbarConfig { - menu: MenuConfig; -} - -export const DefaultUniuiToolbarConfig = {}; - -export class UniuiToolbarController extends Disposable { - constructor( - @IMenuManagerService protected readonly _menuManagerService: IMenuManagerService, - @Inject(Injector) protected readonly _injector: Injector, - @Inject(ComponentManager) protected readonly _componentManager: ComponentManager, - @ICommandService protected readonly _commandService: ICommandService, - @Inject(UniToolbarService) protected readonly _toolbarService: UniToolbarService - ) { - super(); - this._initComponent(); - this._initMenus(); - this._initCommands(); - } - - private _initComponent(): void { - const componentManager = this._componentManager; - const iconList: Record> = { - DownloadIcon, - ShareIcon, - LockIcon, - PrintIcon, - ZenIcon, - DeleteIcon, - PivotTableIcon, - }; - for (const k in iconList) { - this.disposeWithMe(componentManager.register(k, iconList[k])); - } - } - - private _initMenus(): void { - this._menuManagerService.appendRootMenu(menuSchema); - } - - private _initCommands(): void { - [ - DisposeUnitOperation, - ].forEach((c) => { - this.disposeWithMe(this._commandService.registerCommand(c)); - }); - } -} diff --git a/packages-experimental/uniui/src/controllers/utils.ts b/packages-experimental/uniui/src/controllers/utils.ts deleted file mode 100644 index 2b3e590257..0000000000 --- a/packages-experimental/uniui/src/controllers/utils.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { ICommand } from '@univerjs/core'; -import { Tools } from '@univerjs/core'; - -export const generateCloneMutation = (cloneId: string, sourceMutation: ICommand): ICommand => { - return { - ...Tools.deepClone(sourceMutation), - id: cloneId, - }; -}; diff --git a/packages-experimental/uniui/src/global.css b/packages-experimental/uniui/src/global.css deleted file mode 100644 index 7c05d4ddc4..0000000000 --- a/packages-experimental/uniui/src/global.css +++ /dev/null @@ -1,2 +0,0 @@ -@tailwind components; -@tailwind utilities; diff --git a/packages-experimental/uniui/src/index.ts b/packages-experimental/uniui/src/index.ts deleted file mode 100644 index f6b8726e59..0000000000 --- a/packages-experimental/uniui/src/index.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import './global.css'; - -export { SetFlowViewportOperation } from './commands/operations/set-flow-viewport.operation'; -export { UniFocusUnitOperation } from './commands/operations/uni-focus-unit.operation'; -export { DELETE_MENU_ID, DOWNLOAD_MENU_ID, FONT_GROUP_MENU_ID, LOCK_MENU_ID, PRINT_MENU_ID, SHARE_MENU_ID, UNI_MENU_POSITIONS, ZEN_MENU_ID } from './controllers/menu'; -export { generateCloneMutation } from './controllers/utils'; -export { UniverUniUIPlugin } from './plugin'; -export { UniToolbarService } from './services/toolbar/uni-toolbar-service'; -export { BuiltinUniToolbarItemId } from './services/toolbar/uni-toolbar-service'; -export { getGridUnitLocalCacheKey, type IProjectNode, type IUnitGrid, IUnitGridService, UnitGridService } from './services/unit-grid/unit-grid.service'; -export { UniUIPart } from './views/outline/Outline'; -export { UniFloatToolbarUIPart } from './views/uni-toolbar/UniFloatToolbar'; diff --git a/packages-experimental/uniui/src/plugin.ts b/packages-experimental/uniui/src/plugin.ts deleted file mode 100644 index fe98a2e550..0000000000 --- a/packages-experimental/uniui/src/plugin.ts +++ /dev/null @@ -1,150 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { Dependency } from '@univerjs/core'; -import type { IUniverUIConfig } from '@univerjs/ui'; -import { DependentOn, ICommandService, IConfirmService, IContextService, ILocalStorageService, Inject, Injector, merge, mergeOverrideWithDependencies, Plugin } from '@univerjs/core'; -import { UniverRenderEnginePlugin } from '@univerjs/engine-render'; -import { - BrowserClipboardService, - CanvasFloatDomService, - CanvasPopupService, - ComponentManager, - ContextMenuService, - DesktopBeforeCloseService, - DesktopConfirmService, - DesktopDialogService, - DesktopGalleryService, - DesktopGlobalZoneService, - DesktopLayoutService, - DesktopLocalFileService, - DesktopLocalStorageService, - DesktopMessageService, - DesktopNotificationService, - DesktopSidebarService, - DesktopZenZoneService, - DISABLE_AUTO_FOCUS_KEY, - ErrorController, - IBeforeCloseService, - ICanvasPopupService, - IClipboardInterfaceService, - IContextMenuService, - IDialogService, - IGalleryService, - IGlobalZoneService, - ILayoutService, - ILeftSidebarService, - ILocalFileService, - IMenuManagerService, - IMessageService, - INotificationService, - IPlatformService, - IShortcutService, - ISidebarService, - IUIController, - IUIPartsService, - IZenZoneService, - MenuManagerService, - PlatformService, - SharedController, - ShortcutPanelController, - ShortcutPanelService, - ShortcutService, - ThemeSwitcherService, - UIPartsService, - UNIVER_UI_PLUGIN_NAME, - ZIndexManager, -} from '@univerjs/ui'; -import { UniverUniUIController } from './controllers/uniui-desktop.controller'; -import { UniuiFlowController } from './controllers/uniui-flow.controller'; -import { UniuiLeftSidebarController } from './controllers/uniui-leftsidebar.controller'; -import { UniuiToolbarController } from './controllers/uniui-toolbar.controller'; -import { FlowManagerService } from './services/flow/flow-manager.service'; -import { UniToolbarService } from './services/toolbar/uni-toolbar-service'; -import { IUnitGridService, UnitGridService } from './services/unit-grid/unit-grid.service'; - -/** - * This plugin enables the Uni Mode of Univer. It should replace - * `UniverUIPlugin` when registered. - */ -@DependentOn(UniverRenderEnginePlugin) -export class UniverUniUIPlugin extends Plugin { - static override pluginName: string = UNIVER_UI_PLUGIN_NAME; - - constructor( - private readonly _config: Partial = {}, - @Inject(Injector) protected readonly _injector: Injector, - @IContextService private readonly _contextService: IContextService, - @ICommandService private readonly _commandService: ICommandService - ) { - super(); - - this._config = merge({}, this._config); - if (this._config.disableAutoFocus) { - this._contextService.setContextValue(DISABLE_AUTO_FOCUS_KEY, true); - } - } - - override onStarting(): void { - const dependencies: Dependency[] = mergeOverrideWithDependencies([ - [ComponentManager], - [ZIndexManager], - [ShortcutPanelService], - [FlowManagerService], - [UniToolbarService], - [IUnitGridService, { useClass: UnitGridService }], - [IUIPartsService, { useClass: UIPartsService }], - [ILayoutService, { useClass: DesktopLayoutService }], - [IShortcutService, { useClass: ShortcutService }], - [IPlatformService, { useClass: PlatformService }], - [IMenuManagerService, { useClass: MenuManagerService }], - [IContextMenuService, { useClass: ContextMenuService }], - [ThemeSwitcherService], - [IClipboardInterfaceService, { useClass: BrowserClipboardService, lazy: true }], - [INotificationService, { useClass: DesktopNotificationService, lazy: true }], - [IGalleryService, { useClass: DesktopGalleryService, lazy: true }], - [IDialogService, { useClass: DesktopDialogService, lazy: true }], - [IConfirmService, { useClass: DesktopConfirmService, lazy: true }], - [ISidebarService, { useClass: DesktopSidebarService, lazy: true }], - [ILeftSidebarService, { useClass: DesktopSidebarService, lazy: true }], - [IZenZoneService, { useClass: DesktopZenZoneService, lazy: true }], - [IGlobalZoneService, { useClass: DesktopGlobalZoneService, lazy: true }], - [IMessageService, { useClass: DesktopMessageService, lazy: true }], - [ILocalStorageService, { useClass: DesktopLocalStorageService, lazy: true }], - [IBeforeCloseService, { useClass: DesktopBeforeCloseService }], - [ILocalFileService, { useClass: DesktopLocalFileService }], - [ICanvasPopupService, { useClass: CanvasPopupService }], - [CanvasFloatDomService], - [IUIController, { - useFactory: () => this._injector.createInstance(UniverUniUIController, this._config), - }], - [SharedController], - [ErrorController], - [ShortcutPanelController], - [UniuiLeftSidebarController], - [UniuiToolbarController], - [UniuiFlowController], - ], this._config.override); - dependencies.forEach((dependency) => this._injector.add(dependency)); - } - - override onReady(): void { - this._injector.get(IUIController); // Do not move it to onStarting, otherwise the univer instance may not be mounted. - this._injector.get(UniuiFlowController); - this._injector.get(UniuiLeftSidebarController); - this._injector.get(UniuiToolbarController); - } -} diff --git a/packages-experimental/uniui/src/services/flow/flow-manager.service.ts b/packages-experimental/uniui/src/services/flow/flow-manager.service.ts deleted file mode 100644 index b3edea7b77..0000000000 --- a/packages-experimental/uniui/src/services/flow/flow-manager.service.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { ReactFlowInstance } from '@xyflow/react'; -import { Disposable } from '@univerjs/core'; - -import { BehaviorSubject } from 'rxjs'; - -export interface IFlowViewport { - zoom: number; - x: number; - y: number; -} - -export class FlowManagerService extends Disposable { - private readonly _viewportChanged$ = new BehaviorSubject(null); - readonly viewportChanged$ = this._viewportChanged$.asObservable(); - - private _flowInstance: ReactFlowInstance; - - constructor() { - super(); - } - - getViewport() { - return this._flowInstance?.getViewport(); - } - - setViewport(viewport: { zoom: number; x: number; y: number }) { - this._flowInstance?.setViewport(viewport, { - duration: 100, - }); - } - - setReactFlowInstance(instance: ReactFlowInstance) { - this._flowInstance = instance; - } - - fitView() { - if (this._flowInstance) { - this._flowInstance.fitView(); - } - } - - zoomIn() { - if (this._flowInstance) { - this._flowInstance.zoomIn(); - } - } - - zoomOut() { - if (this._flowInstance) { - this._flowInstance.zoomOut(); - } - } - - setViewportChanged(viewport: IFlowViewport) { - this._viewportChanged$.next(viewport); - } -} diff --git a/packages-experimental/uniui/src/services/toolbar/uni-toolbar-service.ts b/packages-experimental/uniui/src/services/toolbar/uni-toolbar-service.ts deleted file mode 100644 index 263f28f14d..0000000000 --- a/packages-experimental/uniui/src/services/toolbar/uni-toolbar-service.ts +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Disposable, RedoCommand, toDisposable, UndoCommand, UniverInstanceType } from '@univerjs/core'; -import { FAKE_BG_COLOR_MENU_ID, FAKE_FONT_COLOR_MENU_ID, FAKE_FONT_FAMILY_MENU_ID, FAKE_FONT_GROUP_MENU_ID, FAKE_FONT_SIZE_MENU_ID, FAKE_IMAGE_MENU_ID, FAKE_ORDER_LIST_MENU_ID, FAKE_TABLE_MENU_ID, FAKE_UNORDER_LIST_MENU_ID, FONT_GROUP_MENU_ID } from '../../controllers/menu'; - -interface IItemImpl { - id: string; - type: UniverInstanceType; -} - -export interface IUniToolbarItem { - id: string; - impl: IItemImpl[]; -} - -export enum BuiltinUniToolbarItemId { - UNDO = 'undo', - REDO = 'redo', - FONT_FAMILY = 'font-famaily', - FONT_SIZE = 'font-size', - FONT_GROUP = 'font-group', - COLOR = 'color', - BACKGROUND = 'background', - IMAGE = 'image', - TABLE = 'table', - UNORDER_LIST = 'unorder-list', - ORDER_LIST = 'order-list', -} - -export class UniToolbarService extends Disposable { - private _items: IUniToolbarItem[]; - constructor() { - super(); - this._init(); - } - - private _init() { - this._items = [ - { - id: BuiltinUniToolbarItemId.UNDO, - impl: [{ id: UndoCommand.id, type: UniverInstanceType.UNIVER_UNKNOWN }], - }, - { - id: BuiltinUniToolbarItemId.REDO, - impl: [{ id: RedoCommand.id, type: UniverInstanceType.UNIVER_UNKNOWN }], - }, - { - id: BuiltinUniToolbarItemId.FONT_FAMILY, - impl: [{ id: FAKE_FONT_FAMILY_MENU_ID, type: UniverInstanceType.UNIVER_UNKNOWN }], - }, - { - id: BuiltinUniToolbarItemId.FONT_SIZE, - impl: [{ id: FAKE_FONT_SIZE_MENU_ID, type: UniverInstanceType.UNIVER_UNKNOWN }], - }, - { - id: BuiltinUniToolbarItemId.FONT_GROUP, - impl: [ - { id: FAKE_FONT_GROUP_MENU_ID, type: UniverInstanceType.UNIVER_UNKNOWN }, - { id: FONT_GROUP_MENU_ID, type: UniverInstanceType.UNIVER_SHEET }, - { id: FONT_GROUP_MENU_ID, type: UniverInstanceType.UNIVER_DOC }, - ], - }, - { - id: BuiltinUniToolbarItemId.COLOR, - impl: [{ id: FAKE_FONT_COLOR_MENU_ID, type: UniverInstanceType.UNIVER_UNKNOWN }], - }, - { - id: BuiltinUniToolbarItemId.BACKGROUND, - impl: [{ id: FAKE_BG_COLOR_MENU_ID, type: UniverInstanceType.UNIVER_UNKNOWN }], - }, - { - id: BuiltinUniToolbarItemId.IMAGE, - impl: [{ id: FAKE_IMAGE_MENU_ID, type: UniverInstanceType.UNIVER_UNKNOWN }], - }, - { - id: BuiltinUniToolbarItemId.UNORDER_LIST, - impl: [{ id: FAKE_UNORDER_LIST_MENU_ID, type: UniverInstanceType.UNIVER_UNKNOWN }], - }, - { - id: BuiltinUniToolbarItemId.ORDER_LIST, - impl: [{ id: FAKE_ORDER_LIST_MENU_ID, type: UniverInstanceType.UNIVER_UNKNOWN }], - }, - { - id: BuiltinUniToolbarItemId.TABLE, - impl: [{ id: FAKE_TABLE_MENU_ID, type: UniverInstanceType.UNIVER_UNKNOWN }], - }, - ]; - } - - addItem(item: IUniToolbarItem) { - this._items.push(item); - return toDisposable(() => { - this._items = this._items.filter((i) => i.id !== item.id); - }); - } - - getItems() { - return this._items; - } - - implementItem(id: string, impl: IItemImpl) { - const item = this._items.find((item) => item.id === id); - if (item) { - item.impl.push(impl); - return toDisposable(() => { - item.impl = item.impl.filter((i) => i.id !== impl.id); - }); - } - return toDisposable(() => {}); - } -} diff --git a/packages-experimental/uniui/src/services/unit-grid/unit-grid.service.ts b/packages-experimental/uniui/src/services/unit-grid/unit-grid.service.ts deleted file mode 100644 index 37f498736b..0000000000 --- a/packages-experimental/uniui/src/services/unit-grid/unit-grid.service.ts +++ /dev/null @@ -1,202 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { Nullable, UnitModel } from '@univerjs/core'; -import { createIdentifier, Disposable, ILocalStorageService, isInternalEditorID, IUniverInstanceService, UniverInstanceType } from '@univerjs/core'; -import type { IRender } from '@univerjs/engine-render'; -import { IRenderManagerService } from '@univerjs/engine-render'; -import type { Observable } from 'rxjs'; -import { BehaviorSubject } from 'rxjs'; - -export type IUnitGrid = IProjectNode[]; - -export interface IProjectNode { - id: string; - data: { - unitId: string; - type: UniverInstanceType; - }; - style: { - width: string; - height: string; - display: string; - borderRadius: string; - border: string; - backgroundColor: string; - }; - position: { - x: number; - y: number; - }; -} - -export interface IUnitGridService { - readonly unitGrid: IProjectNode[]; - readonly unitGrid$: Observable; - readonly newNode: IProjectNode | null; - readonly newNode$: Observable; - - setContainerForRender(unitId: string, element: HTMLElement): void; - - changeDimension(id: string, dimensions: { width: number; height: number }): void; - changePosition(id: string, position: { x: number; y: number }): void; - -} - -export const IUnitGridService = createIdentifier('uniui.grid.service'); - -// NOTE: please note that caching position and dimension of units is just for demo. -// The grid should be a unit itself. - -/** - * This services decides which (now at maximum two) units are going to be rendered in the browser. - */ -export class UnitGridService extends Disposable implements IUnitGridService { - // TODO@wzhudev: currently we only support at maximum 2 units rendered side by side. - // In the future we would introduce a grid system (very much like vscode's) to support more - // units and more complex layout. - protected _unitGrid: IUnitGrid = []; - private readonly _unitGrid$ = new BehaviorSubject(this._unitGrid); - readonly unitGrid$ = this._unitGrid$.asObservable(); - - protected _newNode: IProjectNode | null = null; - private readonly _newNode$ = new BehaviorSubject(null); - readonly newNode$ = this._newNode$.asObservable(); - - get unitGrid() { return this._unitGrid; } - get cachedGrid() { return this._cachedGrid; } - get newNode() { return this._newNode; } - - private _nodeIndex = 0; - - constructor( - @IRenderManagerService protected readonly _renderSrv: IRenderManagerService, - @ILocalStorageService protected readonly _localStorageService: ILocalStorageService, - @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService - ) { - super(); - - this._init(); - } - - override dispose(): void { - super.dispose(); - - this._unitGrid$.complete(); - this._newNode$.complete(); - } - - setNewNodeObserver() { - this._newNode$.next(this._newNode); - } - - setContainerForRender(unitId: string, element: HTMLElement) { - this._renderSrv.getRenderById(unitId)?.engine.setContainer(element); - } - - changeDimension(id: string, dimension: { width: number; height: number }): void { - const node = this._unitGrid.find((item) => item.id === id); - if (node) { - node.style.width = `${dimension.width}px`; - node.style.height = `${dimension.height}px`; - this._cacheData(); - } - } - - changePosition(id: string, position: { x: number; y: number }): void { - const node = this._unitGrid.find((item) => item.id === id); - if (node) { - node.position.x = position.x; - node.position.y = position.y; - this._cacheData(); - } - } - - private async _init(): Promise { - await this._initData(); - - this._renderSrv.getRenderAll().forEach((renderer) => this._onRendererCreated(renderer)); - this.disposeWithMe(this._renderSrv.created$.subscribe((render) => this._onRendererCreated(render))); - // When hot reload in development mode, render dispose will be triggered, causing data to be cleared. Replace it with unitDispose - this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe((unitModel) => this._onUnitDisposed(unitModel))); - } - - protected _cachedGrid: Nullable = null; - protected async _initData(): Promise { - const raw = await this._localStorageService.getItem(getGridUnitLocalCacheKey('static')); - if (raw) { - this._cachedGrid = raw; - } - } - - protected _cacheData(): void { - this._localStorageService.setItem(getGridUnitLocalCacheKey('static'), this.unitGrid); - } - - protected _onRendererCreated(renderer: IRender): void { - const { unitId, type, isThumbNail } = renderer; - if (isInternalEditorID(unitId) || isThumbNail) { - return; - } - - this._insertNewNode(unitId, type); - } - - private _insertNewNode(unitId: string, type: UniverInstanceType): void { - const index = this._nodeIndex; - this._nodeIndex += 1; - - const MAX_COUNT_IN_ROW = 3; - const newNode: IProjectNode = this._cachedGrid?.find((item) => item.id === unitId) ?? { - id: unitId, - data: { - unitId, - type, - }, - style: { - width: type === UniverInstanceType.UNIVER_SLIDE ? '1000px' : '940px', - height: '854px', - display: 'flex', - borderRadius: '8px', - border: '1px solid #ccc', - backgroundColor: type === UniverInstanceType.UNIVER_SHEET ? '#fff' : '#f4f6f8', - }, - position: { x: (index % MAX_COUNT_IN_ROW) * 1050, y: Math.floor(index / MAX_COUNT_IN_ROW) * 950 + 40 }, - }; - - this._unitGrid.push(newNode); - this._newNode = newNode; // set new node, for viewport to scroll to - this._emitLayoutChange(); - } - - protected _onUnitDisposed(unitModel: UnitModel): void { - const unitId = unitModel.getUnitId(); - const idx = this._unitGrid.findIndex((item) => item.id === unitId); - if (idx !== -1) { - this._unitGrid.splice(idx, 1); - this._emitLayoutChange(); - } - } - - private _emitLayoutChange(): void { - this._unitGrid$.next(this._unitGrid.slice()); - this._cacheData(); - } -} - -export function getGridUnitLocalCacheKey(projectId: string): string { - return `project-cache-${projectId}`; -} diff --git a/packages-experimental/uniui/src/views/hooks/title.ts b/packages-experimental/uniui/src/views/hooks/title.ts deleted file mode 100644 index f32bd6eec7..0000000000 --- a/packages-experimental/uniui/src/views/hooks/title.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { Nullable } from '@univerjs/core'; -import { IUniverInstanceService } from '@univerjs/core'; -import { useDependency, useObservable } from '@univerjs/ui'; -import { useMemo } from 'react'; - -export function useUnitTitle(unitId: string): string | undefined { - const instanceService = useDependency(IUniverInstanceService); - const unit = useMemo(() => instanceService.getUnit(unitId), [unitId, instanceService]); - const title = useObservable(unit?.name$, '', false, [unit]); - return title; -} - -export function useUnitFocused(unitId: string): boolean { - const instanceService = useDependency(IUniverInstanceService); - const focusedUnitId = useObservable>(instanceService.focused$); - return unitId === focusedUnitId; -} diff --git a/packages-experimental/uniui/src/views/outline/Outline.tsx b/packages-experimental/uniui/src/views/outline/Outline.tsx deleted file mode 100644 index 76f621e5a6..0000000000 --- a/packages-experimental/uniui/src/views/outline/Outline.tsx +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { ComponentContainer, useComponentsOfPart } from '@univerjs/ui'; - -export enum UniUIPart { - OUTLINE = 'OUTLINE', -} - -export function Outline() { - const outlineComponent = useComponentsOfPart(UniUIPart.OUTLINE); - return ( - - ); -} - -Outline.componentName = 'Outline'; diff --git a/packages-experimental/uniui/src/views/uni-controls/UniControls.tsx b/packages-experimental/uniui/src/views/uni-controls/UniControls.tsx deleted file mode 100644 index 87a440ca14..0000000000 --- a/packages-experimental/uniui/src/views/uni-controls/UniControls.tsx +++ /dev/null @@ -1,224 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { CSSProperties, ReactElement } from 'react'; -import type { IProjectNode } from '../../services/unit-grid/unit-grid.service'; -import { borderClassName, Button, clsx, Dropdown, Tooltip } from '@univerjs/design'; -import { CheckMarkIcon, FullscreenIcon, IncreaseIcon, ZoomReduceIcon } from '@univerjs/icons'; -import { ISidebarService, useDependency } from '@univerjs/ui'; -import { useReactFlow } from '@xyflow/react'; -import { useCallback, useEffect, useLayoutEffect, useState } from 'react'; -import { IUnitGridService } from '../../services/unit-grid/unit-grid.service'; -import { UniDiv } from '../uni-toolbar/UniFloatToolbar'; - -export const UniControlButton = (props: { tooltips: string; children?: ReactElement; onClick: () => void; style?: CSSProperties }) => { - const { children, onClick, style, tooltips } = props; - return ( - - - - - ); -}; - -export const MAX_ZOOM = 2; -export const MIN_ZOOM = 0.1; -export const DEFAULT_ZOOM = 1; - -// 0 means fit view -const shortcuts = [10, 50, 75, 100, 125, 150, 200, 0]; - -export enum UniControlItem { - AI = 'AI', -} - -// The component on the bottom right corner of the screen, providing zoom in, zoom out, fit view, -// and AI button and other shared functionalities. -export const UniControls = ({ zoom, onItemClick }: { zoom: number; onItemClick?: (key: UniControlItem) => void }) => { - const unitGridService = useDependency(IUnitGridService); - const { zoomIn, zoomOut, fitView, getNodes, setCenter, getZoom } = useReactFlow(); - - const zoomPercent = Math.floor(zoom * 100); - const rightPadding = useRightSidebarVisible() ? 360 : 12; - - const onZoomInHandler = () => { - zoomIn(); - }; - const onZoomOutHandler = () => { - zoomOut(); - }; - - const onFullscreenHandler = () => { - document.body.requestFullscreen(); - }; - - const setZoomAtCenter = useCallback((zoom: number) => { - const nodes = getNodes(); - const xLeftPositions = nodes.map((node) => node.position.x); - const xRightPositions = nodes.map((node) => node.position.x + (node.measured?.width ?? 0)); - const yTopPositions = nodes.map((node) => node.position.y); - const yDownPositions = nodes.map((node) => node.position.y + (node.measured?.height ?? 0)); - const centerX = (Math.min(...xLeftPositions) + Math.max(...xRightPositions)) / 2; - const centerY = (Math.min(...yTopPositions) + Math.max(...yDownPositions)) / 2; - setCenter(centerX, centerY, { zoom }); - }, [getNodes, setCenter]); - - const handleFitView = (node: IProjectNode | null) => { - if (node) { - const { x, y } = node.position; - const width = Number.parseInt(`${node.style?.width}`) || 0; - const height = Number.parseInt(`${node.style?.height}`) || 0; - - // Use the setCenter method to position the viewport to the center of the node. - setCenter(x + width / 2, y + height / 2, { - duration: 300, - zoom: 1, - }); - } - }; - const onZoomMenuChange = useCallback((value: number) => { - if (value === 0) { - fitView(); - } else { - setZoomAtCenter(value / 100); - } - }, [setZoomAtCenter, fitView]); - - useLayoutEffect(() => { - setTimeout(() => { - setZoomAtCenter(1); - }, 1000); - }, [setZoomAtCenter]); - - useEffect(() => { - const newNodeSubscribe = unitGridService.newNode$.subscribe((node) => handleFitView(node)); - - // const timer = setTimeout(() => { - // fitView(); - // }, 1000); - - return () => { - // clearTimeout(timer); - newNodeSubscribe.unsubscribe(); - }; - }, [fitView]); - - return ( - - )} - > - - {zoomPercent} - % - - - - - - - onItemClick?.(UniControlItem.AI)} style={{ background: '#274FEE' }}> - - - - - - - - - - -
- ); -}; - -function useRightSidebarVisible() { - const sidebarService = useDependency(ISidebarService); - const [visible, setVisible] = useState(false); - useEffect(() => { - const sidebarSubscription = sidebarService.sidebarOptions$.subscribe((options) => { - setVisible(!!options.visible); - }); - - return () => { - sidebarSubscription.unsubscribe(); - }; - }, [sidebarService]); - - return visible; -} diff --git a/packages-experimental/uniui/src/views/uni-sidebar/UniSidebar.tsx b/packages-experimental/uniui/src/views/uni-sidebar/UniSidebar.tsx deleted file mode 100644 index 1647208a6e..0000000000 --- a/packages-experimental/uniui/src/views/uni-sidebar/UniSidebar.tsx +++ /dev/null @@ -1,151 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { ISidebarMethodOptions } from '@univerjs/ui'; -import type { ReactNode } from 'react'; -import { borderClassName, clsx, scrollbarClassName } from '@univerjs/design'; -import { CloseIcon } from '@univerjs/icons'; -import { CustomLabel, ILeftSidebarService, ISidebarService, useDependency, useObservable } from '@univerjs/ui'; -import { useEffect, useMemo, useRef } from 'react'; - -export interface IUniSidebarProps { - position: 'left' | 'right'; - sidebarService: ISidebarService; - showClose?: boolean; -} - -export function LeftSidebar() { - const sidebarService = useDependency(ILeftSidebarService); - return ; -} - -export function RightSidebar() { - const sidebarService = useDependency(ISidebarService); - return ; -} - -export function UniSidebar(props: IUniSidebarProps) { - const { sidebarService, position, showClose = true } = props; - const sidebarOptions = useObservable(sidebarService.sidebarOptions$); - const scrollRef = useRef(null); - - const options = useMemo(() => { - if (!sidebarOptions) { - return null; - } - - const copy = { ...sidebarOptions } as Omit & { - children?: ReactNode; - header?: ReactNode; - footer?: ReactNode; - }; - - for (const key of ['children', 'header', 'footer']) { - const k = key as keyof ISidebarMethodOptions; - - if (sidebarOptions[k]) { - const props = sidebarOptions[k] as any; - - if (props) { - (copy as any)[k] = ; - } - } - } - - return copy; - }, [sidebarOptions]); - - useEffect(() => { - const handleScroll = (e: Event) => { - sidebarService.scrollEvent$.next(e); - }; - const scrollElement = scrollRef.current; - if (scrollElement) { - scrollElement.addEventListener('scroll', handleScroll); - } - - return () => { - scrollElement?.removeEventListener('scroll', handleScroll); - }; - }, [sidebarService]); - - const width = useMemo(() => { - if (!options?.visible) return '0px'; - - if (typeof options.width === 'number') { - return `${options.width}px`; - } - - return options.width; - }, [options]); - - function handleClose() { - const options = { - ...sidebarOptions, - visible: false, - }; - - sidebarService.sidebarOptions$.next(options); - options?.onClose?.(); - } - - const visible = options?.visible ?? false; - return ( - - ); -} diff --git a/packages-experimental/uniui/src/views/uni-toolbar/UniFloatToolbar.tsx b/packages-experimental/uniui/src/views/uni-toolbar/UniFloatToolbar.tsx deleted file mode 100644 index 5a6f7721ab..0000000000 --- a/packages-experimental/uniui/src/views/uni-toolbar/UniFloatToolbar.tsx +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { Nullable } from '@univerjs/core'; -import type { IMenuItem } from '@univerjs/ui'; -import type { IUnitRendererProps } from '../workbench/UniWorkbench'; -import { flip, offset, shift, useFloating } from '@floating-ui/react-dom'; -import { IUniverInstanceService } from '@univerjs/core'; -import { ComponentContainer, IMenuManagerService, ToolbarItem, useComponentsOfPart, useDependency, useObservable } from '@univerjs/ui'; -import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'; -import { DELETE_MENU_ID, DOWNLOAD_MENU_ID, LOCK_MENU_ID, PRINT_MENU_ID, SHARE_MENU_ID, UNI_MENU_POSITIONS, ZEN_MENU_ID } from '../../controllers/menu'; - -export interface IFloatingToolbarRef { - update: () => void; -} - -export enum UniFloatToolbarUIPart { - NAME = 'name', -} - -const UNI_FLOATING_TOOLBAR_SCHEMA: string[] = [ - DOWNLOAD_MENU_ID, - SHARE_MENU_ID, - LOCK_MENU_ID, - PRINT_MENU_ID, - ZEN_MENU_ID, - DELETE_MENU_ID, -]; - -export const UniFloatingToolbar = forwardRef }>(({ node }, ref) => { - const menuManagerService = useDependency(IMenuManagerService); - const isMenuChange = useObservable(menuManagerService.menuChanged$); - const [uniVisibleItems, setUniVisibleItems] = useState([]); - - const { x, y, refs, strategy, update } = useFloating({ - placement: 'top', - middleware: [offset(10), flip(), shift({ padding: 5 })], - }); - - const { setReference, setFloating } = refs; - - const toolbarNameComponents = useComponentsOfPart(UniFloatToolbarUIPart.NAME); - - // Function to update the visible items - const updateVisibleItems = () => { - const menus = menuManagerService.getMenuByPositionKey(UNI_MENU_POSITIONS.TOOLBAR_FLOAT); - if (menus) { - const visibleItems = UNI_FLOATING_TOOLBAR_SCHEMA.map((id) => menus.find((item) => item.key === id)?.item).filter((item) => !!item); - setUniVisibleItems(visibleItems); - } - }; - - useImperativeHandle(ref, () => ({ - update: () => update(), - }), [update]); - - useEffect(() => { - if (node) { - const ref = document.querySelector(`[data-id="${node.unitId}"]`); - setReference(ref); - } - }, [node, setReference]); - - // Listen for menu changes and update visible items - useEffect(() => { - updateVisibleItems(); - }, [isMenuChange]); - - if (!node || !refs.reference.current) { - return null; - } - - return ( -
-
- } - /> - -
- {uniVisibleItems.map((subItem) => )} -
-
-
- ); -}); - -export function UniDiv() { - return
; -} - -export function UnitName({ unitId }: { unitId: string }) { - const instanceService = useDependency(IUniverInstanceService); - const unit = instanceService.getUnit(unitId); - const name = useObservable(unit?.name$); - return ( -
- {name} -
- ); -}; diff --git a/packages-experimental/uniui/src/views/uni-toolbar/UniFormulaBar.tsx b/packages-experimental/uniui/src/views/uni-toolbar/UniFormulaBar.tsx deleted file mode 100644 index 5c29f16db6..0000000000 --- a/packages-experimental/uniui/src/views/uni-toolbar/UniFormulaBar.tsx +++ /dev/null @@ -1,240 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { Workbook } from '@univerjs/core'; -import { - DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, - FOCUSING_FX_BAR_EDITOR, - ICommandService, - IContextService, - IPermissionService, - IUniverInstanceService, - Rectangle, - UniverInstanceType, -} from '@univerjs/core'; -import { Button, clsx } from '@univerjs/design'; -import { DeviceInputEventType } from '@univerjs/engine-render'; -import { CheckMarkIcon, CloseIcon, FxIcon } from '@univerjs/icons'; -import { - RangeProtectionPermissionEditPoint, - RangeProtectionRuleModel, - SheetsSelectionsService, - WorkbookEditablePermission, - WorksheetEditPermission, - WorksheetProtectionRuleModel, - WorksheetSetCellValuePermission, -} from '@univerjs/sheets'; -import { EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, IEditorBridgeService, IFormulaEditorManagerService, SetCellEditVisibleOperation, useActiveWorkbook, useKeyEventConfig } from '@univerjs/sheets-ui'; -import { ComponentManager, KeyCode, useDependency, useObservable } from '@univerjs/ui'; -import { useCallback, useLayoutEffect, useRef, useState } from 'react'; -import { EMPTY, merge, switchMap } from 'rxjs'; - -export const UniFormulaBar = () => { - const editorBridgeService = useDependency(IEditorBridgeService); - const univerInstanceService = useDependency(IUniverInstanceService); - const commandService = useDependency(ICommandService); - - const visibleInfo = useObservable(editorBridgeService.visible$); - const focusedId = useObservable(univerInstanceService.focused$); - const visible = (visibleInfo?.visible && focusedId) || false; - - const handleOpenWrite = useCallback(() => { - if (focusedId) { - commandService.executeCommand(SetCellEditVisibleOperation.id, { - visible: true, - eventType: DeviceInputEventType.PointerDown, - unitId: focusedId, - }); - } - }, [editorBridgeService, focusedId]); - - return ( - <> -
handleOpenWrite()} - > - - - Write formula - -
-
- -
- - ); -}; - -// This copies the FormulaBar component from the sheets-ui package. -// FIXME@wzhudev: it is not appropriate to copy the component here. -export function FormulaBar() { - const formulaEditorManagerService = useDependency(IFormulaEditorManagerService); - const editorBridgeService = useDependency(IEditorBridgeService); - const componentManager = useDependency(ComponentManager); - const commandService = useDependency(ICommandService); - const selectionManager = useDependency(SheetsSelectionsService); - const worksheetProtectionRuleModel = useDependency(WorksheetProtectionRuleModel); - const rangeProtectionRuleModel = useDependency(RangeProtectionRuleModel); - const permissionService = useDependency(IPermissionService); - const contextService = useDependency(IContextService); - - const [disable, setDisable] = useState(false); - const univerInstanceService = useDependency(IUniverInstanceService); - const FormulaEditor = componentManager.get(EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY); - const currentWorkbook = useActiveWorkbook(); - const isFocusFxBar = contextService.getContextValue(FOCUSING_FX_BAR_EDITOR); - const editState = useObservable(editorBridgeService.currentEditCellState$); - const isRefSelecting = useRef<0 | 1 | 2>(0); - const keyCodeConfig = useKeyEventConfig(isRefSelecting, editState?.unitId ?? ''); - - function getPermissionIds(unitId: string, subUnitId: string): string[] { - return [ - new WorkbookEditablePermission(unitId).id, - new WorksheetSetCellValuePermission(unitId, subUnitId).id, - new WorksheetEditPermission(unitId, subUnitId).id, - ]; - } - - useLayoutEffect(() => { - const workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET)!; - const subscription = merge( - worksheetProtectionRuleModel.ruleChange$, - rangeProtectionRuleModel.ruleChange$, - selectionManager.selectionMoveEnd$, - selectionManager.selectionSet$, - workbook.activeSheet$ - ).pipe( - switchMap(() => { - const unitId = workbook.getUnitId(); - const worksheet = workbook.getActiveSheet(); - if (!worksheet) return EMPTY; - - const subUnitId = worksheet.getSheetId(); - const range = selectionManager.getCurrentLastSelection()?.range; - if (!range) return EMPTY; - - const permissionIds = getPermissionIds(unitId, subUnitId); - - const selectionRanges = selectionManager.getCurrentSelections()?.map((selection) => selection.range); - const permissionList = rangeProtectionRuleModel.getSubunitRuleList(unitId, subUnitId).filter((rule) => { - return rule.ranges.some((r) => selectionRanges?.some((selectionRange) => Rectangle.intersects(r, selectionRange))); - }); - - permissionList.forEach((p) => { - permissionIds.push(new RangeProtectionPermissionEditPoint(unitId, subUnitId, p.permissionId).id); - }); - - return permissionService.composePermission$(permissionIds); - }) - ).subscribe((permissions) => { - if (permissions) { - setDisable(!permissions.every((p) => p.value)); - } - }); - - return () => { - subscription.unsubscribe(); - }; - }, []); - - // Handle click the "×" button. - function handleCloseBtnClick() { - const visibleState = editorBridgeService.isVisible(); - if (visibleState.visible) { - commandService.executeCommand(SetCellEditVisibleOperation.id, { - visible: false, - eventType: DeviceInputEventType.Keyboard, - keycode: KeyCode.ESC, - unitId: currentWorkbook?.getUnitId() ?? '', - }); - } - } - - // Handle click the "√" button. - function handleConfirmBtnClick() { - const visibleState = editorBridgeService.isVisible(); - if (visibleState.visible) { - commandService.executeCommand(SetCellEditVisibleOperation.id, { - visible: false, - eventType: DeviceInputEventType.PointerDown, - unitId: currentWorkbook?.getUnitId() ?? '', - }); - } - } - - return ( -
-
- - -
- {FormulaEditor && ( - { }} - isFocus={isFocusFxBar} - unitId={editState?.unitId} - subUnitId={editState?.sheetId} - autofocus={false} - isSupportAcrossSheet - resetSelectionOnBlur={false} - isSingle={false} - keyboardEventConfig={keyCodeConfig} - onFormulaSelectingChange={(isSelecting: 0 | 1 | 2, isFocusing: boolean) => { - isRefSelecting.current = isSelecting; - if (!isFocusing) return; - if (isSelecting) { - editorBridgeService.enableForceKeepVisible(); - } else { - editorBridgeService.disableForceKeepVisible(); - } - }} - autoScrollbar={false} - disableContextMenu={false} - /> - )} -
- ); -} diff --git a/packages-experimental/uniui/src/views/uni-toolbar/UniToolbar.tsx b/packages-experimental/uniui/src/views/uni-toolbar/UniToolbar.tsx deleted file mode 100644 index aeca3e52f4..0000000000 --- a/packages-experimental/uniui/src/views/uni-toolbar/UniToolbar.tsx +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { IMenuItem } from '@univerjs/ui'; -import type { ComponentType } from 'react'; -import { IUniverInstanceService, UniverInstanceType } from '@univerjs/core'; -import { useWorkbooks } from '@univerjs/sheets-ui'; -import { IMenuManagerService, ToolbarItem, useDependency, useObservable } from '@univerjs/ui'; -import { useEffect, useState } from 'react'; -import { UNI_MENU_POSITIONS } from '../../controllers/menu'; -import { UniToolbarService } from '../../services/toolbar/uni-toolbar-service'; -import { UniFormulaBar } from './UniFormulaBar'; - -export interface IToolbarProps { - headerMenuComponents?: Set; -} - -export function UniToolbar() { - const uniToolbarService = useDependency(UniToolbarService); - const instanceService = useDependency(IUniverInstanceService); - const focusedUnit = useObservable(instanceService.focused$); - const menuManagerService = useDependency(IMenuManagerService); - const isMenuChange = useObservable(menuManagerService.menuChanged$); - const [uniVisibleItems, setUniVisibleItems] = useState<(IMenuItem | null)[]>([]); - - const type = focusedUnit ? (instanceService.getUnit(focusedUnit)?.type ?? UniverInstanceType.UNIVER_UNKNOWN) : UniverInstanceType.UNIVER_UNKNOWN; - - const toolbarItems = uniToolbarService.getItems(); - const hasWorkbooks = useWorkbooks().length > 0; - - // The initialization of the UniToolbar component may be earlier than the initialization of the SheetUIController in the onReady cycle, resulting in the UNI_MENU_POSITIONS.TOOLBAR_MAIN menu not being registered - // Function to update the visible items - const updateVisibleItems = () => { - const menus = menuManagerService.getMenuByPositionKey(UNI_MENU_POSITIONS.TOOLBAR_MAIN); - if (menus) { - const visibleItems = toolbarItems.map((item) => { - const { impl } = item; - const typeImpl = impl.find((item) => item.type === type); - const visibleItem = menus.find((item) => item.key === typeImpl?.id)?.item; - if (visibleItem) { - return visibleItem; - } - const placeHolderImpl = impl.find((item) => item.type === UniverInstanceType.UNIVER_UNKNOWN); - const placeHolderItem = menus.find((item) => item.key === placeHolderImpl?.id)?.item; - if (placeHolderItem) { - return placeHolderItem; - } - return null; - }).filter((item) => !!item && !item.id.startsWith('FAKE_')); - setUniVisibleItems(visibleItems); - } - }; - - // Listen for menu changes and update visible items - useEffect(() => { - updateVisibleItems(); - }, [isMenuChange]); - - return ( -
- {hasWorkbooks && } -
- {uniVisibleItems.map((subItem) => subItem && )} -
-
- - ); -} diff --git a/packages-experimental/uniui/src/views/workbench/UniWorkbench.tsx b/packages-experimental/uniui/src/views/workbench/UniWorkbench.tsx deleted file mode 100644 index ca70e54657..0000000000 --- a/packages-experimental/uniui/src/views/workbench/UniWorkbench.tsx +++ /dev/null @@ -1,385 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Refer to packages/ui/src/views/App.tsx - -import type { IWorkbenchOptions } from '@univerjs/ui'; -import type { NodeTypes, ReactFlowInstance, Viewport } from '@xyflow/react'; -import type { IFloatingToolbarRef } from '../uni-toolbar/UniFloatToolbar'; -import { debounce, ICommandService, IContextService, IUniverInstanceService, LocaleService, ThemeService } from '@univerjs/core'; -import { borderClassName, clsx, ConfigContext, ConfigProvider } from '@univerjs/design'; -import { IRenderManagerService } from '@univerjs/engine-render'; -import { MenuIcon } from '@univerjs/icons'; -import { - BuiltInUIPart, - ComponentContainer, - ContextMenu, - GlobalZone, - ThemeSwitcherService, - UNI_DISABLE_CHANGING_FOCUS_KEY, - useComponentsOfPart, - useDependency, - useObservable, -} from '@univerjs/ui'; -import { - Background, - NodeResizer, - ReactFlow, - ReactFlowProvider, - useNodesState, -} from '@xyflow/react'; -import { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'; -import { createPortal } from 'react-dom'; -import { UniFocusUnitOperation } from '../../commands/operations/uni-focus-unit.operation'; -import { FlowManagerService } from '../../services/flow/flow-manager.service'; -import { IUnitGridService } from '../../services/unit-grid/unit-grid.service'; -import { useUnitFocused, useUnitTitle } from '../hooks/title'; -import { DEFAULT_ZOOM, MAX_ZOOM, MIN_ZOOM, UniControlItem, UniControls } from '../uni-controls/UniControls'; -import { LeftSidebar, RightSidebar } from '../uni-sidebar/UniSidebar'; -import { UniFloatingToolbar } from '../uni-toolbar/UniFloatToolbar'; -import { UniToolbar } from '../uni-toolbar/UniToolbar'; - -import '@xyflow/react/dist/style.css'; -// Refer to packages/ui/src/views/workbench/Workbench.tsx - -export interface IUniWorkbenchProps extends IWorkbenchOptions { - mountContainer: HTMLElement; - - onRendered: (contentEl: HTMLElement) => void; -} - -export function UniWorkbench(props: IUniWorkbenchProps) { - const { - header = true, - contextMenu = true, - mountContainer, - onRendered, - } = props; - - const localeService = useDependency(LocaleService); - const themeService = useDependency(ThemeService); - const unitGridService = useDependency(IUnitGridService); - const instanceService = useDependency(IUniverInstanceService); - const renderManagerService = useDependency(IRenderManagerService); - const flowManagerService = useDependency(FlowManagerService); - const commandService = useDependency(ICommandService); - const themeSwitcherService = useDependency(ThemeSwitcherService); - - const contentRef = useRef(null); - const floatingToolbarRef = useRef(null); - const reactFlowInstance = useRef(null); - - const headerComponents = useComponentsOfPart(BuiltInUIPart.HEADER); - const contentComponents = useComponentsOfPart(BuiltInUIPart.CONTENT); - const globalComponents = useComponentsOfPart(BuiltInUIPart.GLOBAL); - - const focusedUnit = useObservable(instanceService.focused$); - - useEffect(() => { - if (contentRef.current) { - onRendered?.(contentRef.current); - } - }, [onRendered]); - - useLayoutEffect(() => { - const sub = themeService.currentTheme$.subscribe((theme) => { - themeSwitcherService.injectThemeToHead(theme); - }); - - return () => { - sub.unsubscribe(); - }; - }, []); - - const [locale, setLocale] = useState(localeService.getLocales()); - const [zoom, setZoom] = useState(DEFAULT_ZOOM); - - const onControlItemClick = useCallback((key: UniControlItem) => { - switch (key) { - case UniControlItem.AI: { - commandService.executeCommand('project.controls-pro-search.operation'); - break; - } - } - }, [commandService]); - - const resizeUnits = useCallback(debounce(() => { - renderManagerService.getRenderAll().forEach((renderer) => renderer.engine.resize()); - }, 400), [renderManagerService]); // TODO: this is not - - // Create a portal container for injecting global component themes. - const portalContainer = useMemo(() => document.createElement('div'), []); - - useEffect(() => { - document.body.appendChild(portalContainer); - - const subscriptions = [ - localeService.localeChanged$.subscribe(() => { - setLocale(localeService.getLocales()); - }), - ]; - - return () => { - // batch unsubscribe - subscriptions.forEach((subscription) => subscription.unsubscribe()); - - // cleanup - document.body.removeChild(portalContainer); - }; - }, [localeService, mountContainer, portalContainer]); - - const nodeTypes: NodeTypes = { - customNode: UnitNode, - }; - - const unitGrid = useObservable(unitGridService.unitGrid$, undefined, true); - const gridNodes = useMemo(() => unitGrid.map((item) => ({ - id: item.id, - type: 'customNode', - dragHandle: '.univer-uni-node-drag-handle', - style: item.style, - focusable: true, - data: { - unitId: item.data.unitId, - gridService: unitGridService, - instanceService, - }, - position: item.position, - })), [unitGrid]); - - const [nodes, setNodes, onNodesChange] = useNodesState(gridNodes); - useEffect(() => { - setNodes(gridNodes); - }, [gridNodes]); - - const onMove = useCallback((event: MouseEvent | TouchEvent | null, viewport: Viewport) => { - floatingToolbarRef.current?.update(); - const { zoom } = viewport; - setZoom(zoom); - flowManagerService.setViewportChanged(viewport); - }, [floatingToolbarRef, setZoom, flowManagerService]); - - const onFlowInit = useCallback((instance: ReactFlowInstance) => { - flowManagerService.setReactFlowInstance(instance); - }, [flowManagerService]); - - const disableReactFlowBehavior = !!focusedUnit; - - return ( - - {/** - * IMPORTANT! This `tabIndex` should not be moved. This attribute allows the element to catch - * all focusin event merged from its descendants. The DesktopLayoutService would listen to focusin events - * bubbled to this element and refocus the input element. - */} - -
e.stopPropagation()} - > -
-
e.preventDefault()} - > - { - nodes.forEach((node) => { - if (node.type === 'dimensions' && node.resizing) { - unitGridService.changeDimension(node.id, { width: node.dimensions!.width, height: node.dimensions!.height }); - } else if (node.type === 'position') { - unitGridService.changePosition(node.id, { x: node.position!.x, y: node.position!.y }); - } - }); - - onNodesChange(nodes); - }} - onReset={resizeUnits} - fitView - defaultViewport={{ zoom: MIN_ZOOM, x: 0, y: 0 }} - onPointerDown={(event) => { - if (event.target instanceof HTMLElement - && ( - event.target.dataset.uComp === 'render-canvas' - || event.target.classList.contains('react-flow__resize-control')) - ) { - return; - } - commandService.executeCommand(UniFocusUnitOperation.id, { unitId: null }); - }} - onMove={onMove} - onInit={onFlowInit} - > - - - - {/* Sheet cell editors etc. Their size would not be affected the scale of ReactFlow. */} - -
-
-
*]:univer-pointer-events-auto - `} - > - {/* header */} - {header && ( -
-
- - -
-
- )} - n.id === focusedUnit)?.data} /> - - - - - {/* uni mode controller buttons */} - -
-
- - - {contextMenu && } - -
-
- ); -} - -interface IUnitNodeProps { - data: IUnitRendererProps; -} - -function UnitNode({ data }: IUnitNodeProps) { - const { unitId } = data; - const title = useUnitTitle(unitId); - const focused = useUnitFocused(unitId); - const unitComponents = useComponentsOfPart(BuiltInUIPart.UNIT); - - const contextService = useDependency(IContextService); - const commandService = useDependency(ICommandService); - - const disableChangingUnitFocusing = useObservable( - () => contextService.subscribeContextValue$(UNI_DISABLE_CHANGING_FOCUS_KEY), - false, - false, - [] - ); - - const focus = useCallback(() => { - if (!disableChangingUnitFocusing && !focused) { - commandService.executeCommand(UniFocusUnitOperation.id, { unitId }); - } - }, [disableChangingUnitFocusing, focused, unitId, commandService]); - - return ( -
- - - -
- -
- -
- {title} -
- -
- - ); -} - -export interface IUnitRendererProps { - unitId: string; - - gridService: IUnitGridService; - instanceService: IUniverInstanceService; -} - -function UnitRenderer(props: IUnitRendererProps) { - const { unitId, gridService } = props; - const mountRef = useRef(null); - - const instanceService = useDependency(IUniverInstanceService); - - const focusedUnit = useObservable(instanceService.focused$); - const focused = focusedUnit === unitId; - - useEffect(() => { - if (mountRef.current) { - gridService.setContainerForRender(unitId, mountRef.current); - } - }, [gridService, unitId]); - - return ( -
event.stopPropagation()} - /> - ); -} - -function FloatingContainer() { - const { mountContainer } = useContext(ConfigContext); - const floatingComponents = useComponentsOfPart(BuiltInUIPart.FLOATING); - - return createPortal(, mountContainer!); -} diff --git a/packages-experimental/uniui/src/vite-env.d.ts b/packages-experimental/uniui/src/vite-env.d.ts deleted file mode 100644 index 11f02fe2a0..0000000000 --- a/packages-experimental/uniui/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/packages-experimental/uniui/tailwind.config.ts b/packages-experimental/uniui/tailwind.config.ts deleted file mode 100644 index 75967f186f..0000000000 --- a/packages-experimental/uniui/tailwind.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { Config } from 'tailwindcss'; -import preset from '@univerjs-infra/shared/tailwind'; - -const config: Config = { - presets: [preset], - content: [ - './src/**/*.{js,ts,jsx,tsx}', - ], -}; - -export default config; diff --git a/packages-experimental/uniui/tsconfig.json b/packages-experimental/uniui/tsconfig.json deleted file mode 100644 index 018601b6b9..0000000000 --- a/packages-experimental/uniui/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "extends": "@univerjs-infra/shared/tsconfigs/base", - "compilerOptions": { - "rootDir": "src", - "outDir": "lib/types" - }, - "references": [ - { - "path": "./tsconfig.node.json" - } - ], - "include": [ - "src" - ] -} diff --git a/packages-experimental/uniui/tsconfig.node.json b/packages-experimental/uniui/tsconfig.node.json deleted file mode 100644 index 4947a09903..0000000000 --- a/packages-experimental/uniui/tsconfig.node.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "@univerjs-infra/shared/tsconfigs/node", - "include": ["vitest.config.ts"] -} diff --git a/packages-experimental/uniui/vitest.config.ts b/packages-experimental/uniui/vitest.config.ts deleted file mode 100644 index af97c6d7a2..0000000000 --- a/packages-experimental/uniui/vitest.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import createConfig from '@univerjs-infra/shared/vitest'; - -export default createConfig(); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 99a38188e0..61ab52bffc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -111,6 +111,212 @@ importers: specifier: ^4.0.16 version: 4.0.16(@types/node@25.0.3)(happy-dom@20.0.11)(jiti@2.6.1)(jsdom@27.0.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) + common/debugger: + dependencies: + '@univerjs/core': + specifier: workspace:* + version: link:../../packages/core + '@univerjs/design': + specifier: workspace:* + version: link:../../packages/design + '@univerjs/docs-drawing-ui': + specifier: workspace:* + version: link:../../packages/docs-drawing-ui + '@univerjs/engine-render': + specifier: workspace:* + version: link:../../packages/engine-render + '@univerjs/icons': + specifier: ^1.1.0 + version: 1.1.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@univerjs/mockdata': + specifier: workspace:* + version: link:../mockdata + '@univerjs/sheets': + specifier: workspace:* + version: link:../../packages/sheets + '@univerjs/sheets-drawing-ui': + specifier: workspace:* + version: link:../../packages/sheets-drawing-ui + '@univerjs/themes': + specifier: workspace:* + version: link:../../packages/themes + '@univerjs/ui': + specifier: workspace:* + version: link:../../packages/ui + '@univerjs/watermark': + specifier: workspace:* + version: link:../../packages/watermark + devDependencies: + '@univerjs-infra/shared': + specifier: workspace:* + version: link:../shared + postcss: + specifier: ^8.5.6 + version: 8.5.6 + react: + specifier: 19.2.3 + version: 19.2.3 + rxjs: + specifier: ^7.8.2 + version: 7.8.2 + tailwindcss: + specifier: 3.4.18 + version: 3.4.18 + typescript: + specifier: ^5.9.3 + version: 5.9.3 + vite: + specifier: ^7.3.0 + version: 7.3.0(@types/node@25.0.3)(jiti@2.6.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) + vitest: + specifier: ^4.0.16 + version: 4.0.16(@types/node@25.0.3)(happy-dom@20.0.11)(jiti@2.6.1)(jsdom@27.0.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) + vue: + specifier: ^3.5.26 + version: 3.5.26(typescript@5.9.3) + + common/mockdata: + dependencies: + '@univerjs/action-recorder': + specifier: workspace:* + version: link:../../packages/action-recorder + '@univerjs/core': + specifier: workspace:* + version: link:../../packages/core + '@univerjs/data-validation': + specifier: workspace:* + version: link:../../packages/data-validation + '@univerjs/design': + specifier: workspace:* + version: link:../../packages/design + '@univerjs/docs': + specifier: workspace:* + version: link:../../packages/docs + '@univerjs/docs-drawing': + specifier: workspace:* + version: link:../../packages/docs-drawing + '@univerjs/docs-drawing-ui': + specifier: workspace:* + version: link:../../packages/docs-drawing-ui + '@univerjs/docs-hyper-link-ui': + specifier: workspace:* + version: link:../../packages/docs-hyper-link-ui + '@univerjs/docs-quick-insert-ui': + specifier: workspace:* + version: link:../../packages/docs-quick-insert-ui + '@univerjs/docs-ui': + specifier: workspace:* + version: link:../../packages/docs-ui + '@univerjs/drawing': + specifier: workspace:* + version: link:../../packages/drawing + '@univerjs/drawing-ui': + specifier: workspace:* + version: link:../../packages/drawing-ui + '@univerjs/engine-render': + specifier: workspace:* + version: link:../../packages/engine-render + '@univerjs/find-replace': + specifier: workspace:* + version: link:../../packages/find-replace + '@univerjs/sheets': + specifier: workspace:* + version: link:../../packages/sheets + '@univerjs/sheets-conditional-formatting': + specifier: workspace:* + version: link:../../packages/sheets-conditional-formatting + '@univerjs/sheets-conditional-formatting-ui': + specifier: workspace:* + version: link:../../packages/sheets-conditional-formatting-ui + '@univerjs/sheets-crosshair-highlight': + specifier: workspace:* + version: link:../../packages/sheets-crosshair-highlight + '@univerjs/sheets-data-validation': + specifier: workspace:* + version: link:../../packages/sheets-data-validation + '@univerjs/sheets-data-validation-ui': + specifier: workspace:* + version: link:../../packages/sheets-data-validation-ui + '@univerjs/sheets-drawing': + specifier: workspace:* + version: link:../../packages/sheets-drawing + '@univerjs/sheets-drawing-ui': + specifier: workspace:* + version: link:../../packages/sheets-drawing-ui + '@univerjs/sheets-filter': + specifier: workspace:* + version: link:../../packages/sheets-filter + '@univerjs/sheets-filter-ui': + specifier: workspace:* + version: link:../../packages/sheets-filter-ui + '@univerjs/sheets-find-replace': + specifier: workspace:* + version: link:../../packages/sheets-find-replace + '@univerjs/sheets-formula': + specifier: workspace:* + version: link:../../packages/sheets-formula + '@univerjs/sheets-formula-ui': + specifier: workspace:* + version: link:../../packages/sheets-formula-ui + '@univerjs/sheets-hyper-link': + specifier: workspace:* + version: link:../../packages/sheets-hyper-link + '@univerjs/sheets-hyper-link-ui': + specifier: workspace:* + version: link:../../packages/sheets-hyper-link-ui + '@univerjs/sheets-note-ui': + specifier: workspace:* + version: link:../../packages/sheets-note-ui + '@univerjs/sheets-numfmt-ui': + specifier: workspace:* + version: link:../../packages/sheets-numfmt-ui + '@univerjs/sheets-sort': + specifier: workspace:* + version: link:../../packages/sheets-sort + '@univerjs/sheets-sort-ui': + specifier: workspace:* + version: link:../../packages/sheets-sort-ui + '@univerjs/sheets-table-ui': + specifier: workspace:* + version: link:../../packages/sheets-table-ui + '@univerjs/sheets-thread-comment': + specifier: workspace:* + version: link:../../packages/sheets-thread-comment + '@univerjs/sheets-thread-comment-ui': + specifier: workspace:* + version: link:../../packages/sheets-thread-comment-ui + '@univerjs/sheets-ui': + specifier: workspace:* + version: link:../../packages/sheets-ui + '@univerjs/sheets-zen-editor': + specifier: workspace:* + version: link:../../packages/sheets-zen-editor + '@univerjs/slides-ui': + specifier: workspace:* + version: link:../../packages/slides-ui + '@univerjs/thread-comment': + specifier: workspace:* + version: link:../../packages/thread-comment + '@univerjs/thread-comment-ui': + specifier: workspace:* + version: link:../../packages/thread-comment-ui + '@univerjs/ui': + specifier: workspace:* + version: link:../../packages/ui + '@univerjs/uniscript': + specifier: workspace:* + version: link:../../packages/uniscript + devDependencies: + '@univerjs-infra/shared': + specifier: workspace:* + version: link:../shared + fs-extra: + specifier: ^11.3.3 + version: 11.3.3 + typescript: + specifier: ^5.9.3 + version: 5.9.3 + common/shared: dependencies: '@typescript-eslint/parser': @@ -285,7 +491,7 @@ importers: version: link:../packages/data-validation '@univerjs/debugger': specifier: workspace:* - version: link:../packages-experimental/debugger + version: link:../common/debugger '@univerjs/design': specifier: workspace:* version: link:../packages/design @@ -333,7 +539,7 @@ importers: version: 1.1.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@univerjs/mockdata': specifier: workspace:* - version: link:../mockdata + version: link:../common/mockdata '@univerjs/network': specifier: workspace:* version: link:../packages/network @@ -448,27 +654,9 @@ importers: '@univerjs/ui-adapter-web-component': specifier: workspace:* version: link:../packages/ui-adapter-web-component - '@univerjs/uni-docs-ui': - specifier: workspace:* - version: link:../packages-experimental/uni-docs-ui - '@univerjs/uni-formula': - specifier: workspace:* - version: link:../packages-experimental/uni-formula - '@univerjs/uni-formula-ui': - specifier: workspace:* - version: link:../packages-experimental/uni-formula-ui - '@univerjs/uni-sheets-ui': - specifier: workspace:* - version: link:../packages-experimental/uni-sheets-ui - '@univerjs/uni-slides-ui': - specifier: workspace:* - version: link:../packages-experimental/uni-slides-ui '@univerjs/uniscript': specifier: workspace:* version: link:../packages/uniscript - '@univerjs/uniui': - specifier: workspace:* - version: link:../packages-experimental/uniui '@univerjs/watermark': specifier: workspace:* version: link:../packages/watermark @@ -534,512 +722,6 @@ importers: specifier: ^5.9.3 version: 5.9.3 - mockdata: - dependencies: - '@univerjs/action-recorder': - specifier: workspace:* - version: link:../packages/action-recorder - '@univerjs/core': - specifier: workspace:* - version: link:../packages/core - '@univerjs/data-validation': - specifier: workspace:* - version: link:../packages/data-validation - '@univerjs/design': - specifier: workspace:* - version: link:../packages/design - '@univerjs/docs': - specifier: workspace:* - version: link:../packages/docs - '@univerjs/docs-drawing': - specifier: workspace:* - version: link:../packages/docs-drawing - '@univerjs/docs-drawing-ui': - specifier: workspace:* - version: link:../packages/docs-drawing-ui - '@univerjs/docs-hyper-link-ui': - specifier: workspace:* - version: link:../packages/docs-hyper-link-ui - '@univerjs/docs-quick-insert-ui': - specifier: workspace:* - version: link:../packages/docs-quick-insert-ui - '@univerjs/docs-ui': - specifier: workspace:* - version: link:../packages/docs-ui - '@univerjs/drawing': - specifier: workspace:* - version: link:../packages/drawing - '@univerjs/drawing-ui': - specifier: workspace:* - version: link:../packages/drawing-ui - '@univerjs/engine-render': - specifier: workspace:* - version: link:../packages/engine-render - '@univerjs/find-replace': - specifier: workspace:* - version: link:../packages/find-replace - '@univerjs/sheets': - specifier: workspace:* - version: link:../packages/sheets - '@univerjs/sheets-conditional-formatting': - specifier: workspace:* - version: link:../packages/sheets-conditional-formatting - '@univerjs/sheets-conditional-formatting-ui': - specifier: workspace:* - version: link:../packages/sheets-conditional-formatting-ui - '@univerjs/sheets-crosshair-highlight': - specifier: workspace:* - version: link:../packages/sheets-crosshair-highlight - '@univerjs/sheets-data-validation': - specifier: workspace:* - version: link:../packages/sheets-data-validation - '@univerjs/sheets-data-validation-ui': - specifier: workspace:* - version: link:../packages/sheets-data-validation-ui - '@univerjs/sheets-drawing': - specifier: workspace:* - version: link:../packages/sheets-drawing - '@univerjs/sheets-drawing-ui': - specifier: workspace:* - version: link:../packages/sheets-drawing-ui - '@univerjs/sheets-filter': - specifier: workspace:* - version: link:../packages/sheets-filter - '@univerjs/sheets-filter-ui': - specifier: workspace:* - version: link:../packages/sheets-filter-ui - '@univerjs/sheets-find-replace': - specifier: workspace:* - version: link:../packages/sheets-find-replace - '@univerjs/sheets-formula': - specifier: workspace:* - version: link:../packages/sheets-formula - '@univerjs/sheets-formula-ui': - specifier: workspace:* - version: link:../packages/sheets-formula-ui - '@univerjs/sheets-hyper-link': - specifier: workspace:* - version: link:../packages/sheets-hyper-link - '@univerjs/sheets-hyper-link-ui': - specifier: workspace:* - version: link:../packages/sheets-hyper-link-ui - '@univerjs/sheets-note-ui': - specifier: workspace:* - version: link:../packages/sheets-note-ui - '@univerjs/sheets-numfmt-ui': - specifier: workspace:* - version: link:../packages/sheets-numfmt-ui - '@univerjs/sheets-sort': - specifier: workspace:* - version: link:../packages/sheets-sort - '@univerjs/sheets-sort-ui': - specifier: workspace:* - version: link:../packages/sheets-sort-ui - '@univerjs/sheets-table-ui': - specifier: workspace:* - version: link:../packages/sheets-table-ui - '@univerjs/sheets-thread-comment': - specifier: workspace:* - version: link:../packages/sheets-thread-comment - '@univerjs/sheets-thread-comment-ui': - specifier: workspace:* - version: link:../packages/sheets-thread-comment-ui - '@univerjs/sheets-ui': - specifier: workspace:* - version: link:../packages/sheets-ui - '@univerjs/sheets-zen-editor': - specifier: workspace:* - version: link:../packages/sheets-zen-editor - '@univerjs/slides-ui': - specifier: workspace:* - version: link:../packages/slides-ui - '@univerjs/thread-comment': - specifier: workspace:* - version: link:../packages/thread-comment - '@univerjs/thread-comment-ui': - specifier: workspace:* - version: link:../packages/thread-comment-ui - '@univerjs/ui': - specifier: workspace:* - version: link:../packages/ui - '@univerjs/uni-formula-ui': - specifier: workspace:* - version: link:../packages-experimental/uni-formula-ui - '@univerjs/uniscript': - specifier: workspace:* - version: link:../packages/uniscript - devDependencies: - '@univerjs-infra/shared': - specifier: workspace:* - version: link:../common/shared - fs-extra: - specifier: ^11.3.3 - version: 11.3.3 - typescript: - specifier: ^5.9.3 - version: 5.9.3 - - packages-experimental/debugger: - dependencies: - '@univerjs/core': - specifier: workspace:* - version: link:../../packages/core - '@univerjs/design': - specifier: workspace:* - version: link:../../packages/design - '@univerjs/docs-drawing-ui': - specifier: workspace:* - version: link:../../packages/docs-drawing-ui - '@univerjs/engine-render': - specifier: workspace:* - version: link:../../packages/engine-render - '@univerjs/icons': - specifier: ^1.1.0 - version: 1.1.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3) - '@univerjs/mockdata': - specifier: workspace:* - version: link:../../mockdata - '@univerjs/sheets': - specifier: workspace:* - version: link:../../packages/sheets - '@univerjs/sheets-drawing-ui': - specifier: workspace:* - version: link:../../packages/sheets-drawing-ui - '@univerjs/themes': - specifier: workspace:* - version: link:../../packages/themes - '@univerjs/ui': - specifier: workspace:* - version: link:../../packages/ui - '@univerjs/watermark': - specifier: workspace:* - version: link:../../packages/watermark - devDependencies: - '@univerjs-infra/shared': - specifier: workspace:* - version: link:../../common/shared - postcss: - specifier: ^8.5.6 - version: 8.5.6 - react: - specifier: 19.2.3 - version: 19.2.3 - rxjs: - specifier: ^7.8.2 - version: 7.8.2 - tailwindcss: - specifier: 3.4.18 - version: 3.4.18 - typescript: - specifier: ^5.9.3 - version: 5.9.3 - vite: - specifier: ^7.3.0 - version: 7.3.0(@types/node@25.0.3)(jiti@2.6.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) - vitest: - specifier: ^4.0.16 - version: 4.0.16(@types/node@25.0.3)(happy-dom@20.0.11)(jiti@2.6.1)(jsdom@27.0.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) - vue: - specifier: ^3.5.26 - version: 3.5.26(typescript@5.9.3) - - packages-experimental/uni-docs-ui: - dependencies: - '@univerjs/core': - specifier: workspace:* - version: link:../../packages/core - '@univerjs/docs': - specifier: workspace:* - version: link:../../packages/docs - '@univerjs/docs-drawing-ui': - specifier: workspace:* - version: link:../../packages/docs-drawing-ui - '@univerjs/docs-ui': - specifier: workspace:* - version: link:../../packages/docs-ui - '@univerjs/engine-render': - specifier: workspace:* - version: link:../../packages/engine-render - '@univerjs/ui': - specifier: workspace:* - version: link:../../packages/ui - '@univerjs/uniui': - specifier: workspace:* - version: link:../uniui - devDependencies: - '@univerjs-infra/shared': - specifier: workspace:* - version: link:../../common/shared - postcss: - specifier: ^8.5.6 - version: 8.5.6 - rxjs: - specifier: ^7.8.2 - version: 7.8.2 - tailwindcss: - specifier: 3.4.18 - version: 3.4.18 - typescript: - specifier: ^5.9.3 - version: 5.9.3 - vite: - specifier: ^7.3.0 - version: 7.3.0(@types/node@25.0.3)(jiti@2.6.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) - vitest: - specifier: ^4.0.16 - version: 4.0.16(@types/node@25.0.3)(happy-dom@20.0.11)(jiti@2.6.1)(jsdom@27.0.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) - - packages-experimental/uni-formula: - dependencies: - '@univerjs/core': - specifier: workspace:* - version: link:../../packages/core - devDependencies: - '@univerjs-infra/shared': - specifier: workspace:* - version: link:../../common/shared - typescript: - specifier: ^5.9.3 - version: 5.9.3 - vite: - specifier: ^7.3.0 - version: 7.3.0(@types/node@25.0.3)(jiti@2.6.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) - vitest: - specifier: ^4.0.16 - version: 4.0.16(@types/node@25.0.3)(happy-dom@20.0.11)(jiti@2.6.1)(jsdom@27.0.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) - - packages-experimental/uni-formula-ui: - dependencies: - '@univerjs/core': - specifier: workspace:* - version: link:../../packages/core - '@univerjs/design': - specifier: workspace:* - version: link:../../packages/design - '@univerjs/docs': - specifier: workspace:* - version: link:../../packages/docs - '@univerjs/docs-ui': - specifier: workspace:* - version: link:../../packages/docs-ui - '@univerjs/engine-formula': - specifier: workspace:* - version: link:../../packages/engine-formula - '@univerjs/engine-render': - specifier: workspace:* - version: link:../../packages/engine-render - '@univerjs/icons': - specifier: ^1.1.0 - version: 1.1.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3) - '@univerjs/rpc': - specifier: workspace:* - version: link:../../packages/rpc - '@univerjs/sheets-formula-ui': - specifier: workspace:* - version: link:../../packages/sheets-formula-ui - '@univerjs/slides-ui': - specifier: workspace:* - version: link:../../packages/slides-ui - '@univerjs/ui': - specifier: workspace:* - version: link:../../packages/ui - '@univerjs/uni-formula': - specifier: workspace:* - version: link:../uni-formula - devDependencies: - '@univerjs-infra/shared': - specifier: workspace:* - version: link:../../common/shared - postcss: - specifier: ^8.5.6 - version: 8.5.6 - react: - specifier: 19.2.3 - version: 19.2.3 - rxjs: - specifier: ^7.8.2 - version: 7.8.2 - tailwindcss: - specifier: 3.4.18 - version: 3.4.18 - typescript: - specifier: ^5.9.3 - version: 5.9.3 - vite: - specifier: ^7.3.0 - version: 7.3.0(@types/node@25.0.3)(jiti@2.6.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) - vitest: - specifier: ^4.0.16 - version: 4.0.16(@types/node@25.0.3)(happy-dom@20.0.11)(jiti@2.6.1)(jsdom@27.0.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) - - packages-experimental/uni-sheets-ui: - dependencies: - '@univerjs/core': - specifier: workspace:* - version: link:../../packages/core - '@univerjs/design': - specifier: workspace:* - version: link:../../packages/design - '@univerjs/docs': - specifier: workspace:* - version: link:../../packages/docs - '@univerjs/docs-ui': - specifier: workspace:* - version: link:../../packages/docs-ui - '@univerjs/icons': - specifier: ^1.1.0 - version: 1.1.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3) - '@univerjs/sheets': - specifier: workspace:* - version: link:../../packages/sheets - '@univerjs/sheets-drawing-ui': - specifier: workspace:* - version: link:../../packages/sheets-drawing-ui - '@univerjs/sheets-ui': - specifier: workspace:* - version: link:../../packages/sheets-ui - '@univerjs/ui': - specifier: workspace:* - version: link:../../packages/ui - '@univerjs/uniui': - specifier: workspace:* - version: link:../uniui - devDependencies: - '@univerjs-infra/shared': - specifier: workspace:* - version: link:../../common/shared - postcss: - specifier: ^8.5.6 - version: 8.5.6 - react: - specifier: 19.2.3 - version: 19.2.3 - rxjs: - specifier: ^7.8.2 - version: 7.8.2 - tailwindcss: - specifier: 3.4.18 - version: 3.4.18 - typescript: - specifier: ^5.9.3 - version: 5.9.3 - vite: - specifier: ^7.3.0 - version: 7.3.0(@types/node@25.0.3)(jiti@2.6.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) - vitest: - specifier: ^4.0.16 - version: 4.0.16(@types/node@25.0.3)(happy-dom@20.0.11)(jiti@2.6.1)(jsdom@27.0.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) - - packages-experimental/uni-slides-ui: - dependencies: - '@univerjs/core': - specifier: workspace:* - version: link:../../packages/core - '@univerjs/design': - specifier: workspace:* - version: link:../../packages/design - '@univerjs/engine-render': - specifier: workspace:* - version: link:../../packages/engine-render - '@univerjs/icons': - specifier: ^1.1.0 - version: 1.1.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3) - '@univerjs/slides-ui': - specifier: workspace:* - version: link:../../packages/slides-ui - '@univerjs/ui': - specifier: workspace:* - version: link:../../packages/ui - '@univerjs/uniui': - specifier: workspace:* - version: link:../uniui - devDependencies: - '@univerjs-infra/shared': - specifier: workspace:* - version: link:../../common/shared - postcss: - specifier: ^8.5.6 - version: 8.5.6 - react: - specifier: 19.2.3 - version: 19.2.3 - rxjs: - specifier: ^7.8.2 - version: 7.8.2 - tailwindcss: - specifier: 3.4.18 - version: 3.4.18 - typescript: - specifier: ^5.9.3 - version: 5.9.3 - vite: - specifier: ^7.3.0 - version: 7.3.0(@types/node@25.0.3)(jiti@2.6.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) - vitest: - specifier: ^4.0.16 - version: 4.0.16(@types/node@25.0.3)(happy-dom@20.0.11)(jiti@2.6.1)(jsdom@27.0.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) - - packages-experimental/uniui: - dependencies: - '@floating-ui/react-dom': - specifier: ^2.1.6 - version: 2.1.6(react-dom@19.2.3(react@19.2.3))(react@19.2.3) - '@univerjs/core': - specifier: workspace:* - version: link:../../packages/core - '@univerjs/design': - specifier: workspace:* - version: link:../../packages/design - '@univerjs/engine-render': - specifier: workspace:* - version: link:../../packages/engine-render - '@univerjs/icons': - specifier: ^1.1.0 - version: 1.1.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3) - '@univerjs/sheets': - specifier: workspace:* - version: link:../../packages/sheets - '@univerjs/sheets-ui': - specifier: workspace:* - version: link:../../packages/sheets-ui - '@univerjs/ui': - specifier: workspace:* - version: link:../../packages/ui - '@xyflow/react': - specifier: ^12.10.0 - version: 12.10.0(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) - devDependencies: - '@univerjs-infra/shared': - specifier: workspace:* - version: link:../../common/shared - '@univerjs/themes': - specifier: workspace:* - version: link:../../packages/themes - postcss: - specifier: ^8.5.6 - version: 8.5.6 - react: - specifier: 19.2.3 - version: 19.2.3 - react-dom: - specifier: 19.2.3 - version: 19.2.3(react@19.2.3) - rxjs: - specifier: ^7.8.2 - version: 7.8.2 - tailwindcss: - specifier: 3.4.18 - version: 3.4.18 - typescript: - specifier: ^5.9.3 - version: 5.9.3 - vite: - specifier: ^7.3.0 - version: 7.3.0(@types/node@25.0.3)(jiti@2.6.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) - vitest: - specifier: ^4.0.16 - version: 4.0.16(@types/node@25.0.3)(happy-dom@20.0.11)(jiti@2.6.1)(jsdom@27.0.1)(sass@1.87.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) - packages/action-recorder: dependencies: '@univerjs/core': @@ -3539,7 +3221,7 @@ importers: version: link:../../packages/engine-formula '@univerjs/mockdata': specifier: workspace:* - version: link:../../mockdata + version: link:../../common/mockdata '@univerjs/rpc': specifier: workspace:* version: link:../../packages/rpc @@ -5681,24 +5363,6 @@ packages: '@types/conventional-commits-parser@5.0.2': resolution: {integrity: sha512-BgT2szDXnVypgpNxOK8aL5SGjUdaQbC++WZNjF1Qge3Og2+zhHj+RWhmehLhYyvQwqAmvezruVfOf8+3m74W+g==} - '@types/d3-color@3.1.3': - resolution: {integrity: sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A==} - - '@types/d3-drag@3.0.7': - resolution: {integrity: sha512-HE3jVKlzU9AaMazNufooRJ5ZpWmLIoc90A37WU2JMmeq28w1FQqCZswHZ3xR+SuxYftzHq6WU6KJHvqxKzTxxQ==} - - '@types/d3-interpolate@3.0.4': - resolution: {integrity: sha512-mgLPETlrpVV1YRJIglr4Ez47g7Yxjl1lj7YKsiMCb27VJH9W8NVM6Bb9d8kkpG/uAQS5AmbA48q2IAolKKo1MA==} - - '@types/d3-selection@3.0.11': - resolution: {integrity: sha512-bhAXu23DJWsrI45xafYpkQ4NtcKMwWnAC/vKrd2l+nxMFuvOT3XMYTIj2opv8vq8AO5Yh7Qac/nSeP/3zjTK0w==} - - '@types/d3-transition@3.0.9': - resolution: {integrity: sha512-uZS5shfxzO3rGlu0cC3bjmMFKsXv+SmZZcgp0KD22ts4uGXp5EVYGzu/0YdwZeKmddhcAccYtREJKkPfXkZuCg==} - - '@types/d3-zoom@3.0.8': - resolution: {integrity: sha512-iqMC4/YlFCSlO8+2Ii1GGGliCAY4XdeG748w5vQUbevlbDu0zSjH/+jojorQVBK/se0j6DUFNPBGSqD3YWYnDw==} - '@types/debug@4.1.12': resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==} @@ -6135,15 +5799,6 @@ packages: '@xtuc/long@4.2.2': resolution: {integrity: sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==} - '@xyflow/react@12.10.0': - resolution: {integrity: sha512-eOtz3whDMWrB4KWVatIBrKuxECHqip6PfA8fTpaS2RUGVpiEAe+nqDKsLqkViVWxDGreq0lWX71Xth/SPAzXiw==} - peerDependencies: - react: 19.2.3 - react-dom: 19.2.3 - - '@xyflow/system@0.0.74': - resolution: {integrity: sha512-7v7B/PkiVrkdZzSbL+inGAo6tkR/WQHHG0/jhSvLQToCsfa8YubOGmBYd1s08tpKpihdHDZFwzQZeR69QSBb4Q==} - '@zeit/schemas@2.36.0': resolution: {integrity: sha512-7kjMwcChYEzMKjeex9ZFXkt1AyNov9R5HZtjBKVsmVpw7pa7ZtlCGvCBC2vnnXctaYN+aRI61HjIqeetZW5ROg==} @@ -6613,9 +6268,6 @@ packages: class-variance-authority@0.7.1: resolution: {integrity: sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==} - classcat@5.0.5: - resolution: {integrity: sha512-JhZUT7JFcQy/EzW605k/ktHtncoo9vnyW/2GspNYwFlN1C/WmjuV/xtS04e9SOkL2sTdw0VAZ2UGCcQ9lR6p6w==} - classnames@2.5.1: resolution: {integrity: sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==} @@ -6898,44 +6550,6 @@ packages: csstype@3.2.3: resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==} - d3-color@3.1.0: - resolution: {integrity: sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==} - engines: {node: '>=12'} - - d3-dispatch@3.0.1: - resolution: {integrity: sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg==} - engines: {node: '>=12'} - - d3-drag@3.0.0: - resolution: {integrity: sha512-pWbUJLdETVA8lQNJecMxoXfH6x+mO2UQo8rSmZ+QqxcbyA3hfeprFgIT//HW2nlHChWeIIMwS2Fq+gEARkhTkg==} - engines: {node: '>=12'} - - d3-ease@3.0.1: - resolution: {integrity: sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==} - engines: {node: '>=12'} - - d3-interpolate@3.0.1: - resolution: {integrity: sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==} - engines: {node: '>=12'} - - d3-selection@3.0.0: - resolution: {integrity: sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==} - engines: {node: '>=12'} - - d3-timer@3.0.1: - resolution: {integrity: sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==} - engines: {node: '>=12'} - - d3-transition@3.0.1: - resolution: {integrity: sha512-ApKvfjsSR6tg06xrL434C0WydLr7JewBB3V+/39RMHsaXTOG0zmt/OAXeng5M5LBm0ojmxJrpomQVZ1aPvBL4w==} - engines: {node: '>=12'} - peerDependencies: - d3-selection: 2 - 3 - - d3-zoom@3.0.0: - resolution: {integrity: sha512-b8AmV3kfQaqWAuacbPuNbL6vahnOJflOhexLzMMNLga62+/nh0JzvJ0aO/5a5MVgUFGS7Hu1P9P03o3fJkDCyw==} - engines: {node: '>=12'} - dargs@8.1.0: resolution: {integrity: sha512-wAV9QHOsNbwnWdNW2FYvE1P56wtgSbM+3SZcdGiWQILwVjACCXDCI3Ai8QlCjMDB8YK5zySiXZYBiwGmNY3lnw==} engines: {node: '>=12'} @@ -11113,21 +10727,6 @@ packages: zod@4.3.2: resolution: {integrity: sha512-b8L8yn4rIVfiXyHAmnr52/ZEpDumlT0bmxiq3Ws1ybrinhflGpt12Hvv54kYnEsGPRs6o/Ka3/ppA2OWY21IVg==} - zustand@4.5.7: - resolution: {integrity: sha512-CHOUy7mu3lbD6o6LJLfllpjkzhHXSBlX8B9+qPddUsIfeF5S/UZ5q0kmCsnRqT1UHFQZchNFDDzMbQsuesHWlw==} - engines: {node: '>=12.7.0'} - peerDependencies: - '@types/react': 19.2.7 - immer: '>=9.0.6' - react: 19.2.3 - peerDependenciesMeta: - '@types/react': - optional: true - immer: - optional: true - react: - optional: true - zwitch@2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} @@ -13375,27 +12974,6 @@ snapshots: dependencies: '@types/node': 25.0.3 - '@types/d3-color@3.1.3': {} - - '@types/d3-drag@3.0.7': - dependencies: - '@types/d3-selection': 3.0.11 - - '@types/d3-interpolate@3.0.4': - dependencies: - '@types/d3-color': 3.1.3 - - '@types/d3-selection@3.0.11': {} - - '@types/d3-transition@3.0.9': - dependencies: - '@types/d3-selection': 3.0.11 - - '@types/d3-zoom@3.0.8': - dependencies: - '@types/d3-interpolate': 3.0.4 - '@types/d3-selection': 3.0.11 - '@types/debug@4.1.12': dependencies: '@types/ms': 2.1.0 @@ -13972,29 +13550,6 @@ snapshots: '@xtuc/long@4.2.2': {} - '@xyflow/react@12.10.0(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': - dependencies: - '@xyflow/system': 0.0.74 - classcat: 5.0.5 - react: 19.2.3 - react-dom: 19.2.3(react@19.2.3) - zustand: 4.5.7(@types/react@19.2.7)(react@19.2.3) - transitivePeerDependencies: - - '@types/react' - - immer - - '@xyflow/system@0.0.74': - dependencies: - '@types/d3-drag': 3.0.7 - '@types/d3-interpolate': 3.0.4 - '@types/d3-selection': 3.0.11 - '@types/d3-transition': 3.0.9 - '@types/d3-zoom': 3.0.8 - d3-drag: 3.0.0 - d3-interpolate: 3.0.1 - d3-selection: 3.0.0 - d3-zoom: 3.0.0 - '@zeit/schemas@2.36.0': {} JSONStream@1.3.5: @@ -14468,8 +14023,6 @@ snapshots: dependencies: clsx: 2.1.1 - classcat@5.0.5: {} - classnames@2.5.1: {} clean-css@5.3.3: @@ -14751,42 +14304,6 @@ snapshots: csstype@3.2.3: {} - d3-color@3.1.0: {} - - d3-dispatch@3.0.1: {} - - d3-drag@3.0.0: - dependencies: - d3-dispatch: 3.0.1 - d3-selection: 3.0.0 - - d3-ease@3.0.1: {} - - d3-interpolate@3.0.1: - dependencies: - d3-color: 3.1.0 - - d3-selection@3.0.0: {} - - d3-timer@3.0.1: {} - - d3-transition@3.0.1(d3-selection@3.0.0): - dependencies: - d3-color: 3.1.0 - d3-dispatch: 3.0.1 - d3-ease: 3.0.1 - d3-interpolate: 3.0.1 - d3-selection: 3.0.0 - d3-timer: 3.0.1 - - d3-zoom@3.0.0: - dependencies: - d3-dispatch: 3.0.1 - d3-drag: 3.0.0 - d3-interpolate: 3.0.1 - d3-selection: 3.0.0 - d3-transition: 3.0.1(d3-selection@3.0.0) - dargs@8.1.0: {} data-uri-to-buffer@6.0.2: {} @@ -19636,11 +19153,4 @@ snapshots: zod@4.3.2: {} - zustand@4.5.7(@types/react@19.2.7)(react@19.2.3): - dependencies: - use-sync-external-store: 1.6.0(react@19.2.3) - optionalDependencies: - '@types/react': 19.2.7 - react: 19.2.3 - zwitch@2.0.4: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 6d50fc539f..fc76dec939 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -2,7 +2,6 @@ packages: - common/* - examples - mockdata - - packages-experimental/* - packages/* - tests/* publicHoistPattern: diff --git a/vitest.workspace.ts b/vitest.workspace.ts index b7133b4c02..f0b415dade 100644 --- a/vitest.workspace.ts +++ b/vitest.workspace.ts @@ -1,46 +1,7 @@ -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; -import fs from 'fs-extra'; -import { defineWorkspace } from 'vitest/config'; +import { defineConfig } from 'vitest/config'; -const __dirname = path.dirname(fileURLToPath(import.meta.url)); - -function findVitestConfigs(): string[] { - const baseDirs = [ - path.resolve(__dirname, './packages'), - path.resolve(__dirname, './packages-experimental'), - path.resolve(__dirname, './tests'), - ]; - - const vitestConfigPaths: string[] = []; - - function traverseDir(dir: string) { - const entries = fs.readdirSync(dir, { withFileTypes: true }); - - for (const entry of entries) { - const fullPath = path.join(dir, entry.name); - - if (entry.isDirectory()) { - const packageJsonPath = path.join(fullPath, 'package.json'); - if (fs.existsSync(packageJsonPath)) { - const viteConfigPath = path.join(fullPath, 'vitest.config.ts'); - if (fs.existsSync(viteConfigPath)) { - vitestConfigPaths.push(viteConfigPath); - } - } else { - traverseDir(fullPath); - } - } - } - } - - for (const baseDir of baseDirs) { - if (fs.existsSync(baseDir)) { - traverseDir(baseDir); - } - } - - return vitestConfigPaths; -} - -export default defineWorkspace(findVitestConfigs()); +export default defineConfig({ + test: { + projects: ['packages/*'], + }, +});