Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

refactor(slides)!: remove OSS packages after Pro migration (#8084)

白熱4bbfb68aeb35
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 1fe467b763..cb156add3c 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -48,28 +48,6 @@
"order": 3
}
},
- {
- "name": "Launch Slide (Chrome)",
- "request": "launch",
- "type": "chrome",
- "url": "http://localhost:5173/#slides",
- "webRoot": "${workspaceFolder}/examples",
- "presentation": {
- "group": "0_example",
- "order": 6
- }
- },
- {
- "name": "Launch Slide (Edge)",
- "request": "launch",
- "type": "msedge",
- "url": "http://localhost:5173/#slides",
- "webRoot": "${workspaceFolder}/examples",
- "presentation": {
- "group": "0_example",
- "order": 5
- }
- },
{
"type": "node",
"name": "vscode-jest-tests",
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 744302b6c3..ab2b10132f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -174,7 +174,7 @@ Also, with the help of vscode and its rich ecosystem, you could directly debug u
### Browser workbench
-`pnpm dev` starts one Vite workbench with lazy-loaded Sheets, Docs, and Slides routes. Use the navigation bar or `#sheets`, `#docs`, and `#slides` URLs to switch products; only one Univer instance stays mounted. The Settings menu provides every built-in language, LTR/RTL direction, region, theme, appearance, ribbon, UI chrome, and zoom controls. Preferences are stored in localStorage and applied to the active instance through runtime APIs without remounting it. Development locale data is loaded on demand so unused product and language graphs do not remain in Vite's memory. End-to-end suites should consume built packages outside this repository instead of coupling tests to source examples.
+`pnpm dev` starts one Vite workbench with lazy-loaded Sheets and Docs routes. Use the navigation bar or `#sheets` and `#docs` URLs to switch products; only one Univer instance stays mounted. The Settings menu provides every built-in language, LTR/RTL direction, region, theme, appearance, ribbon, UI chrome, and zoom controls. Preferences are stored in localStorage and applied to the active instance through runtime APIs without remounting it. Development locale data is loaded on demand so unused product and language graphs do not remain in Vite's memory. End-to-end suites should consume built packages outside this repository instead of coupling tests to source examples.
### Build Preview
diff --git a/DREAMNUM.md b/DREAMNUM.md
index b87e4a6901..98e87130dc 100644
--- a/DREAMNUM.md
+++ b/DREAMNUM.md
@@ -1,13 +1,13 @@
# dream-num/univer
-> The open-source, isomorphic office SDK for building embeddable spreadsheet, document, and presentation experiences in browsers and Node.js.
+> The open-source, isomorphic office SDK for building embeddable spreadsheet and document experiences in browsers and Node.js.
## Responsibilities
### Owns
- The open-source Univer runtime, plugin system, command and service infrastructure, Facade API, formula engine, and Canvas rendering engine. See the [repository overview](README.md#-what-is-univer).
-- Open-source models, editing capabilities, and UI plugins for Sheets, Docs, and Slides, including shared drawing, commenting, validation, formatting, and localization infrastructure. See the [open-source capability boundary](README.md#-open-source-and-pro).
+- Open-source models, editing capabilities, and UI plugins for Sheets and Docs, including shared drawing, commenting, validation, formatting, and localization infrastructure. See the [open-source capability boundary](README.md#-open-source-and-pro).
- Browser, Node.js, and Web Worker integration paths, plus React-based UI and Vue 3 and Web Component adapters. See the [compatibility and integration overview](README.md#-compatibility).
- First-party open-source package presets and the examples and test projects used to exercise the SDK. See the [workspace definition](pnpm-workspace.yaml) and [repository guide](README.md#-repository-guide).
- Public API compatibility rules for stable, experimental, internal, and deprecated interfaces. See the [API Stability Policy](docs/API_STABILITY.md).
@@ -17,7 +17,7 @@ The repository does not own Univer Pro's commercial collaboration, import/export
## Provides
- `@univerjs/core`, `@univerjs/engine-formula`, and `@univerjs/engine-render` — Core runtime and data models, Facade APIs, formula calculation, and shared rendering. Contract: [package manifests](packages/core/package.json) and [API reference](https://docs.univer.ai/reference/classes/univer).
-- `@univerjs/sheets`, `@univerjs/docs`, `@univerjs/slides`, and their UI and feature packages — Composable office models, plugins, and editing interfaces. Contract: [package directory](packages) and [API stability rules](docs/API_STABILITY.md).
+- `@univerjs/sheets`, `@univerjs/docs`, and their UI and feature packages — Composable office models, plugins, and editing interfaces. Contract: [package directory](packages) and [API stability rules](docs/API_STABILITY.md).
- `@univerjs/presets` and `@univerjs/preset-*` — Curated plugin collections for browser and Node.js integrations. Contract: [preset packages](presets/packages) and [preset-mode guide](README.md#-quick-start).
- `@univerjs/ui-adapter-vue3` and `@univerjs/ui-adapter-web-component` — Framework adapters for integrating Univer UI services. Contract: [Vue 3 adapter](packages/ui-adapter-vue3/README.md) and [Web Component adapter](packages/ui-adapter-web-component/README.md).
- `sync-univer` repository-dispatch event — Notifies the separate Univer Pro repository after changes reach `dev`. Contract: [dispatch workflow](.github/workflows/dispatch-sync-univer-pro.yml).
diff --git a/README.md b/README.md
index 3584e4b61a..2fa62b51c5 100644
--- a/README.md
+++ b/README.md
@@ -291,7 +291,7 @@ For API compatibility expectations, experimental APIs, internal APIs, and deprec
| --- | --- | --- |
| **Sheets** | Workbooks, worksheets, ranges, selection, formulas, number formatting, filtering, sorting, data validation, conditional formatting, hyperlinks, comments, find and replace, notes, tables, drawing integration, and extensible UI plugins. | Real-time collaboration, edit history, import/export, printing, charts, pivot tables, sparklines, outlines, shapes, in-cell graphics, data connectors, server-side calculation, and performance-enhanced formula features. |
| **Docs** | Rich document model, editing UI, lists, hyperlinks, drawing integration, comments, quick insert, and shared document architecture. | Collaboration, import/export, printing, enhanced tables and lists, columns, callouts, code blocks, quotes, shapes, and remote comment resources. |
-| **Slides** | Presentation data model and editing UI packages. | Pro slide model and UI, slide import/export, chart and table model/UI plugins, and shared shape-editing infrastructure. |
+| **Slides** | — | Slide model and UI, slide import/export, chart and table model/UI plugins, and shared shape-editing infrastructure. |
| **Bases** | Build custom structured-data experiences on top of Univer's plugin, command, and model architecture. | Base database model, commands, formula integration, workbench UI, field editors, and render-engine views. |
| **Runtime** | Browser apps, Node.js headless usage, Web Worker/RPC patterns, multi-instance usage, and server-oriented automation. | Collaboration client/server packages, Node.js collaboration client, Pro server services, SSR, computing delegation, server-side calculation, and changeset replay tooling. |
| **Integrations** | React, Vue, Web Components, framework templates, theming, localization, and custom plugins. | Pro presets and enterprise deployment packages. |
@@ -307,7 +307,7 @@ This repository contains Univer's open-source core and first-party OSS plugins.
| **Foundation** | Core SDK, plugin system, rendering engine, formula engine, Facade API, themes, i18n, and framework adapters. | Pro presets and enterprise deployment packages. |
| **Sheets** | Core spreadsheet editing, formulas, number formatting, filter/sort, data validation, conditional formatting, notes, tables, hyperlinks, comments, drawing, find and replace. | Collaboration, edit history, import/export, print, charts, pivot tables, sparklines, outlines, shapes, in-cell graphics, data connectors, range preprocessing, and enhanced formula engine features. |
| **Docs** | Document model and editor UI, lists, hyperlinks, comments, quick insert, and drawing integration. | Collaboration, import/export, print, enhanced tables/lists, columns, callouts, code blocks, quotes, shapes, and remote thread-comment resources. |
-| **Slides** | OSS presentation model and UI packages. | Pro slide model/UI packages, slide import/export, charts, tables, and reusable shape editor UI. |
+| **Slides** | — | Slide model/UI packages, slide import/export, charts, tables, and reusable shape editor UI. |
| **Bases** | Extensible plugin architecture for custom data-centric products. | Base database core model, commands, mutations, formula integration, workbench UI, field editors, and render-engine integration. |
| **Server and runtime** | Node.js headless runtime, RPC/Web Worker patterns, and server-oriented automation primitives. | Collaboration server, Node.js collaboration client, SSR services, computing delegation, server-side calculation, and collaboration changeset replay tooling. |
@@ -366,7 +366,7 @@ Useful commands:
| Command | Purpose |
| --- | --- |
-| `pnpm dev` | Start the all-in-one Sheets, Docs, and Slides workbench with Vite 8 Bundled Dev and HMR. |
+| `pnpm dev` | Start the Sheets and Docs workbench with Vite 8 Bundled Dev and HMR. |
| `pnpm build` | Build workspace packages, excluding internal common packages. |
| `pnpm test` | Run unit tests through Turbo. |
| `pnpm typecheck` | Run TypeScript checks through Turbo. |
diff --git a/docs/readme/es-ES.md b/docs/readme/es-ES.md
index 466f83259c..8f3aa728fd 100644
--- a/docs/readme/es-ES.md
+++ b/docs/readme/es-ES.md
@@ -291,7 +291,7 @@ Para expectativas de compatibilidad de API, APIs experimentales, APIs internas y
| --- | --- | --- |
| **Sheets** | Libros, hojas, rangos, selección, fórmulas, formato numérico, filtros, ordenación, validación de datos, formato condicional, hipervínculos, comentarios, buscar y reemplazar, notas, tablas, integración de dibujo y plugins de UI extensibles. | Colaboración en tiempo real, historial de edición, importación/exportación, impresión, gráficos, tablas dinámicas, sparklines, esquemas, formas, gráficos dentro de celdas, conectores de datos, cálculo del lado del servidor y funciones de fórmulas mejoradas. |
| **Docs** | Modelo de documento enriquecido, UI de edición, listas, hipervínculos, integración de dibujo, comentarios, inserción rápida y arquitectura compartida de documentos. | Colaboración, importación/exportación, impresión, tablas y listas mejoradas, columnas, callouts, bloques de código, citas, formas y recursos remotos de comentarios. |
-| **Slides** | Modelo de datos de presentaciones y paquetes de UI de edición. | Modelo y UI Pro para presentaciones, importación/exportación de slides, plugins de modelo/UI para gráficos y tablas, e infraestructura compartida de edición de formas. |
+| **Slides** | — | Modelo y UI para presentaciones, importación/exportación de slides, plugins de modelo/UI para gráficos y tablas, e infraestructura compartida de edición de formas. |
| **Bases** | Experiencias de datos estructurados personalizadas sobre la arquitectura de plugins, comandos y modelos de Univer. | Modelo de base de datos Base, comandos, integración de fórmulas, UI de workbench, editores de campos y vistas del motor de renderizado. |
| **Runtime** | Aplicaciones en navegador, uso headless en Node.js, patrones Web Worker/RPC, múltiples instancias y automatización orientada al servidor. | Paquetes de cliente/servidor de colaboración, cliente de colaboración para Node.js, servicios Pro de servidor, SSR, delegación de cómputo, cálculo del lado del servidor y herramientas de replay de changesets. |
| **Integrations** | React, Vue, Web Components, plantillas de frameworks, temas, localización y plugins personalizados. | Presets Pro y paquetes de despliegue empresarial. |
@@ -307,7 +307,7 @@ Este repositorio contiene el núcleo open source de Univer y plugins OSS de prim
| **Base** | SDK core, sistema de plugins, motor de renderizado, motor de fórmulas, Facade API, temas, i18n y adaptadores de frameworks. | Presets Pro y paquetes de despliegue empresarial. |
| **Sheets** | Edición básica de hojas de cálculo, fórmulas, formato numérico, filtro/ordenación, validación de datos, formato condicional, notas, tablas, hipervínculos, comentarios, dibujo, buscar y reemplazar. | Colaboración, historial de edición, importación/exportación, impresión, gráficos, tablas dinámicas, sparklines, esquemas, formas, gráficos dentro de celdas, conectores de datos, preprocesamiento de rangos y funciones mejoradas del motor de fórmulas. |
| **Docs** | Modelo de documento y UI de edición, listas, hipervínculos, comentarios, inserción rápida e integración de dibujo. | Colaboración, importación/exportación, impresión, tablas/listas mejoradas, columnas, callouts, bloques de código, citas, formas y recursos remotos de comentarios en hilos. |
-| **Slides** | Modelo de presentaciones OSS y paquetes de UI. | Paquetes Pro de modelo/UI de slides, importación/exportación de slides, gráficos, tablas y UI reutilizable de editor de formas. |
+| **Slides** | — | Paquetes de modelo/UI de slides, importación/exportación de slides, gráficos, tablas y UI reutilizable de editor de formas. |
| **Bases** | Arquitectura de plugins extensible para productos personalizados centrados en datos. | Modelo core de base de datos Base, comandos, mutations, integración de fórmulas, UI de workbench, editores de campos e integración con el motor de renderizado. |
| **Servidor y runtime** | Runtime headless en Node.js, patrones RPC/Web Worker y primitivas de automatización orientada al servidor. | Servidor de colaboración, cliente de colaboración para Node.js, servicios SSR, delegación de cómputo, cálculo del lado del servidor y herramientas de replay de changesets de colaboración. |
diff --git a/docs/readme/ja-JP.md b/docs/readme/ja-JP.md
index b3b10a4ac3..d279c9306b 100644
--- a/docs/readme/ja-JP.md
+++ b/docs/readme/ja-JP.md
@@ -292,7 +292,7 @@ API 互換性、experimental API、internal API、deprecation rules について
| --- | --- | --- |
| **Sheets** | ワークブック、ワークシート、範囲、選択、数式、数値書式、フィルター、ソート、データ検証、条件付き書式、ハイパーリンク、コメント、検索と置換、ノート、テーブル、描画連携、拡張可能な UI プラグイン。 | リアルタイム共同編集、編集履歴、インポート/エクスポート、印刷、チャート、ピボットテーブル、スパークライン、アウトライン、図形、セル内グラフィックス、データコネクタ、サーバーサイド計算、強化された数式機能。 |
| **Docs** | リッチドキュメントモデル、編集 UI、リスト、ハイパーリンク、描画連携、コメント、クイック挿入、共有ドキュメントアーキテクチャ。 | 共同編集、インポート/エクスポート、印刷、強化されたテーブルとリスト、段組み、コールアウト、コードブロック、引用ブロック、図形、リモートコメントリソース。 |
-| **Slides** | プレゼンテーションデータモデルと編集 UI パッケージ。 | Pro スライドモデルと UI、スライドのインポート/エクスポート、チャートとテーブルのモデル/UI プラグイン、共有の図形編集基盤。 |
+| **Slides** | — | スライドモデルと UI、スライドのインポート/エクスポート、チャートとテーブルのモデル/UI プラグイン、共有の図形編集基盤。 |
| **Bases** | Univer のプラグイン、コマンド、モデルのアーキテクチャ上に、カスタムの構造化データ体験を構築できます。 | Base データベースモデル、コマンド、数式連携、ワークベンチ UI、フィールドエディタ、レンダリングエンジンビュー。 |
| **Runtime** | ブラウザアプリ、Node.js ヘッドレス利用、Web Worker/RPC パターン、複数インスタンス、サーバー向け自動化。 | 共同編集クライアント/サーバーパッケージ、Node.js 共同編集クライアント、Pro サーバーサービス、SSR、計算委譲、サーバーサイド計算、changeset replay ツール。 |
| **Integrations** | React、Vue、Web Components、フレームワークテンプレート、テーマ、ローカライズ、カスタムプラグイン。 | Pro presets とエンタープライズデプロイパッケージ。 |
@@ -308,7 +308,7 @@ Sheets、Docs、Slides は Univer の共通アーキテクチャ上でスプレ
| **Foundation** | Core SDK、プラグインシステム、レンダリングエンジン、数式エンジン、Facade API、テーマ、i18n、フレームワークアダプタ。 | Pro presets とエンタープライズデプロイパッケージ。 |
| **Sheets** | コアのスプレッドシート編集、数式、数値書式、フィルター/ソート、データ検証、条件付き書式、ノート、テーブル、ハイパーリンク、コメント、描画、検索と置換。 | 共同編集、編集履歴、インポート/エクスポート、印刷、チャート、ピボットテーブル、スパークライン、アウトライン、図形、セル内グラフィックス、データコネクタ、範囲の前処理、強化された数式エンジン機能。 |
| **Docs** | ドキュメントモデルと編集 UI、リスト、ハイパーリンク、コメント、クイック挿入、描画連携。 | 共同編集、インポート/エクスポート、印刷、強化されたテーブル/リスト、段組み、コールアウト、コードブロック、引用ブロック、図形、リモートスレッドコメントリソース。 |
-| **Slides** | OSS のプレゼンテーションモデルと UI パッケージ。 | Pro スライドモデル/UI パッケージ、スライドのインポート/エクスポート、チャート、テーブル、再利用可能な図形エディタ UI。 |
+| **Slides** | — | スライドモデル/UI パッケージ、スライドのインポート/エクスポート、チャート、テーブル、再利用可能な図形エディタ UI。 |
| **Bases** | カスタムのデータ中心プロダクト向けの拡張可能なプラグインアーキテクチャ。 | Base データベースコアモデル、コマンド、ミューテーション、数式連携、ワークベンチ UI、フィールドエディタ、レンダリングエンジン連携。 |
| **Server and runtime** | Node.js ヘッドレスランタイム、RPC/Web Worker パターン、サーバー向け自動化のプリミティブ。 | 共同編集サーバー、Node.js 共同編集クライアント、SSR サービス、計算委譲、サーバーサイド計算、共同編集 changeset replay ツール。 |
diff --git a/docs/readme/ko-KR.md b/docs/readme/ko-KR.md
index 299d157ab7..2c3f4609fb 100644
--- a/docs/readme/ko-KR.md
+++ b/docs/readme/ko-KR.md
@@ -292,7 +292,7 @@ API 호환성 기대치, experimental APIs, internal APIs, deprecation rules는
| --- | --- | --- |
| **Sheets** | 워크북, 워크시트, 범위, 선택, 수식, 숫자 서식, 필터링, 정렬, 데이터 유효성 검사, 조건부 서식, 하이퍼링크, 댓글, 찾기/바꾸기, 노트, 테이블, drawing integration, 확장 가능한 UI 플러그인. | 실시간 협업, 편집 기록, import/export, printing, charts, pivot tables, sparklines, outlines, shapes, in-cell graphics, data connectors, server-side calculation, 향상된 formula 기능. |
| **Docs** | 리치 문서 모델, 편집 UI, 목록, 하이퍼링크, drawing integration, 댓글, quick insert, 공유 문서 아키텍처. | 협업, import/export, printing, 향상된 tables/lists, columns, callouts, code blocks, quotes, shapes, remote comment resources. |
-| **Slides** | 프레젠테이션 데이터 모델과 편집 UI 패키지. | Pro slide model/UI, slide import/export, chart/table model 및 UI plugins, 공유 shape editing infrastructure. |
+| **Slides** | — | Slide model/UI, slide import/export, chart/table model 및 UI plugins, 공유 shape editing infrastructure. |
| **Bases** | Univer의 plugin, command, model 아키텍처 위에서 커스텀 structured-data 경험을 만들 수 있습니다. | Base database model, commands, formula integration, workbench UI, field editors, render-engine views. |
| **Runtime** | 브라우저 앱, Node.js headless 사용, Web Worker/RPC 패턴, multi-instance 사용, 서버 지향 자동화. | Collaboration client/server packages, Node.js collaboration client, Pro server services, SSR, computing delegation, server-side calculation, changeset replay tooling. |
| **Integrations** | React, Vue, Web Components, 프레임워크 템플릿, 테마, 로컬라이제이션, 커스텀 플러그인. | Pro presets, enterprise deployment packages. |
@@ -308,7 +308,7 @@ Sheets, Docs, Slides는 Univer의 공통 아키텍처를 기반으로 스프레
| **Foundation** | Core SDK, 플러그인 시스템, 렌더링 엔진, 수식 엔진, Facade API, 테마, i18n, framework adapters. | Pro presets, enterprise deployment packages. |
| **Sheets** | 핵심 스프레드시트 편집, 수식, 숫자 서식, filter/sort, 데이터 유효성 검사, 조건부 서식, 노트, 테이블, 하이퍼링크, 댓글, drawing, 찾기/바꾸기. | 협업, 편집 기록, import/export, print, charts, pivot tables, sparklines, outlines, shapes, in-cell graphics, data connectors, range preprocessing, 향상된 formula engine 기능. |
| **Docs** | 문서 모델과 편집 UI, 목록, 하이퍼링크, 댓글, quick insert, drawing integration. | 협업, import/export, print, 향상된 tables/lists, columns, callouts, code blocks, quotes, shapes, remote thread-comment resources. |
-| **Slides** | OSS presentation model과 UI packages. | Pro slide model/UI packages, slide import/export, charts, tables, reusable shape editor UI. |
+| **Slides** | — | Slide model/UI packages, slide import/export, charts, tables, reusable shape editor UI. |
| **Bases** | 커스텀 data-centric products를 위한 확장 가능한 plugin architecture. | Base database core model, commands, mutations, formula integration, workbench UI, field editors, render-engine integration. |
| **Server and runtime** | Node.js headless runtime, RPC/Web Worker patterns, server-oriented automation primitives. | Collaboration server, Node.js collaboration client, SSR services, computing delegation, server-side calculation, collaboration changeset replay tooling. |
diff --git a/docs/readme/zh-CN.md b/docs/readme/zh-CN.md
index f96b246a83..609798786b 100644
--- a/docs/readme/zh-CN.md
+++ b/docs/readme/zh-CN.md
@@ -288,7 +288,7 @@ univerAPI.createWorkbook({})
| --- | --- | --- |
| **Sheets** | 工作簿、工作表、区域、选择、公式、数字格式、筛选、排序、数据验证、条件格式、超链接、评论、查找替换、批注、表格、绘图集成和可扩展 UI 插件。 | 实时协同、编辑历史、导入导出、打印、图表、数据透视表、迷你图、分级显示、形状、单元格内图形、数据连接器、服务端计算和增强公式能力。 |
| **Docs** | 富文本文档模型、编辑 UI、列表、超链接、绘图集成、评论、快捷插入和共享文档架构。 | 协同、导入导出、打印、增强表格和列表、分栏、提示块、代码块、引用块、形状和远程评论资源。 |
-| **Slides** | 演示文稿数据模型和编辑 UI 包。 | Pro 演示文稿模型和 UI、幻灯片导入导出、图表和表格模型/UI 插件,以及共享形状编辑基础设施。 |
+| **Slides** | — | 演示文稿模型和 UI、幻灯片导入导出、图表和表格模型/UI 插件,以及共享形状编辑基础设施。 |
| **Bases** | 基于 Univer 的插件、命令和模型架构构建自定义结构化数据体验。 | Base 数据库模型、命令、公式集成、工作台 UI、字段编辑器和渲染引擎视图。 |
| **Runtime** | 浏览器应用、Node.js 无头使用、Web Worker/RPC 模式、多实例使用和服务端自动化。 | 协同客户端/服务端包、Node.js 协同客户端、Pro 服务端服务、SSR、计算委托、服务端计算和 changeset 回放工具。 |
| **Integrations** | React、Vue、Web Components、框架模板、主题、本地化和自定义插件。 | Pro 预设和企业部署包。 |
@@ -304,7 +304,7 @@ Sheets、Docs 和 Slides 基于 Univer 的共享架构,分别提供电子表
| **基础能力** | 核心 SDK、插件系统、渲染引擎、公式引擎、Facade API、主题、i18n 和框架适配器。 | Pro 预设和企业部署包。 |
| **Sheets** | 核心电子表格编辑、公式、数字格式、筛选/排序、数据验证、条件格式、批注、表格、超链接、评论、绘图、查找替换。 | 协同、编辑历史、导入导出、打印、图表、数据透视表、迷你图、分级显示、形状、单元格内图形、数据连接器、区域预处理和增强公式引擎能力。 |
| **Docs** | 文档模型和编辑 UI、列表、超链接、评论、快捷插入和绘图集成。 | 协同、导入导出、打印、增强表格/列表、分栏、提示块、代码块、引用块、形状和远程线程评论资源。 |
-| **Slides** | OSS 演示文稿模型和 UI 包。 | Pro 演示文稿模型/UI 包、幻灯片导入导出、图表、表格和可复用形状编辑器 UI。 |
+| **Slides** | — | 演示文稿模型/UI 包、幻灯片导入导出、图表、表格和可复用形状编辑器 UI。 |
| **Bases** | 用于自定义数据类产品的可扩展插件架构。 | Base 数据库核心模型、命令、变更、公式集成、工作台 UI、字段编辑器和渲染引擎集成。 |
| **服务端与运行时** | Node.js 无头运行时、RPC/Web Worker 模式和面向服务端自动化的基础能力。 | 协同服务端、Node.js 协同客户端、SSR 服务、计算委托、服务端计算和协同 changeset 回放工具。 |
diff --git a/docs/readme/zh-TW.md b/docs/readme/zh-TW.md
index e9ad21a20e..939047325d 100644
--- a/docs/readme/zh-TW.md
+++ b/docs/readme/zh-TW.md
@@ -291,7 +291,7 @@ univerAPI.createWorkbook({})
| --- | --- | --- |
| **Sheets** | 活頁簿、工作表、範圍、選擇、公式、數字格式、篩選、排序、資料驗證、條件格式、超連結、評論、尋找取代、註記、表格、繪圖整合和可擴充 UI 外掛。 | 即時協作、編輯歷史、匯入匯出、列印、圖表、樞紐分析表、迷你圖、大綱、形狀、儲存格內圖形、資料連接器、伺服器端計算和增強公式能力。 |
| **Docs** | 富文字文件模型、編輯 UI、列表、超連結、繪圖整合、評論、快速插入和共享文件架構。 | 協作、匯入匯出、列印、增強表格和列表、分欄、提示區塊、程式碼區塊、引用區塊、形狀和遠端評論資源。 |
-| **Slides** | 簡報資料模型和編輯 UI 套件。 | Pro 簡報模型和 UI、投影片匯入匯出、圖表和表格模型/UI 外掛,以及共享形狀編輯基礎設施。 |
+| **Slides** | — | 簡報模型和 UI、投影片匯入匯出、圖表和表格模型/UI 外掛,以及共享形狀編輯基礎設施。 |
| **Bases** | 基於 Univer 的外掛、命令和模型架構構建自訂結構化資料體驗。 | Base 資料庫模型、命令、公式整合、工作台 UI、欄位編輯器和渲染引擎視圖。 |
| **Runtime** | 瀏覽器應用、Node.js 無頭使用、Web Worker/RPC 模式、多實例使用和伺服器端自動化。 | 協作客戶端/伺服器端套件、Node.js 協作客戶端、Pro 伺服器端服務、SSR、計算委派、伺服器端計算和 changeset 回放工具。 |
| **Integrations** | React、Vue、Web Components、框架模板、主題、本地化和自訂外掛。 | Pro 預設和企業部署套件。 |
@@ -307,7 +307,7 @@ Sheets、Docs 和 Slides 基於 Univer 的共享架構,分別提供試算表
| **基礎能力** | 核心 SDK、外掛系統、渲染引擎、公式引擎、Facade API、主題、i18n 和框架適配器。 | Pro 預設和企業部署套件。 |
| **Sheets** | 核心試算表編輯、公式、數字格式、篩選/排序、資料驗證、條件格式、註記、表格、超連結、評論、繪圖、尋找取代。 | 協作、編輯歷史、匯入匯出、列印、圖表、樞紐分析表、迷你圖、大綱、形狀、儲存格內圖形、資料連接器、範圍預處理和增強公式引擎能力。 |
| **Docs** | 文件模型和編輯 UI、列表、超連結、評論、快速插入和繪圖整合。 | 協作、匯入匯出、列印、增強表格/列表、分欄、提示區塊、程式碼區塊、引用區塊、形狀和遠端執行緒評論資源。 |
-| **Slides** | OSS 簡報模型和 UI 套件。 | Pro 簡報模型/UI 套件、投影片匯入匯出、圖表、表格和可重複使用形狀編輯器 UI。 |
+| **Slides** | — | 簡報模型/UI 套件、投影片匯入匯出、圖表、表格和可重複使用形狀編輯器 UI。 |
| **Bases** | 用於自訂資料類產品的可擴充外掛架構。 | Base 資料庫核心模型、命令、變更、公式整合、工作台 UI、欄位編輯器和渲染引擎整合。 |
| **伺服器端與執行時** | Node.js 無頭執行時、RPC/Web Worker 模式和面向伺服器端自動化的基礎能力。 | 協作伺服器、Node.js 協作客戶端、SSR 服務、計算委派、伺服器端計算和協作 changeset 回放工具。 |
diff --git a/examples/index.html b/examples/index.html
index 809e325bae..cbc7b8c885 100644
--- a/examples/index.html
+++ b/examples/index.html
@@ -13,7 +13,6 @@
<nav aria-label="Product workbenches">
<a data-example="sheets" href="#sheets">Sheets</a>
<a data-example="docs" href="#docs">Docs</a>
- <a data-example="slides" href="#slides">Slides</a>
</nav>
</div>
<div class="workbench-settings" id="workbench-settings"></div>
diff --git a/examples/package.json b/examples/package.json
index 42135f688d..c98bba918a 100644
--- a/examples/package.json
+++ b/examples/package.json
@@ -36,8 +36,6 @@
"@univerjs/preset-sheets-table": "workspace:*",
"@univerjs/preset-sheets-thread-comment": "workspace:*",
"@univerjs/presets": "workspace:*",
- "@univerjs/slides": "workspace:*",
- "@univerjs/slides-ui": "workspace:*",
"@univerjs/themes": "workspace:*",
"@univerjs/ui": "workspace:*",
"react": "19.3.1",
diff --git a/examples/scripts/export-locale.mts b/examples/scripts/export-locale.mts
index 592a40e11f..1aa858a572 100644
--- a/examples/scripts/export-locale.mts
+++ b/examples/scripts/export-locale.mts
@@ -1,5 +1,4 @@
import process from 'node:process';
-
import { resolveLocaleModuleUrl } from './locale-module-url.mts';
interface ILocaleModule {
@@ -32,15 +31,6 @@ const LOCALE_SOURCES = {
'@univerjs/preset-sheets-thread-comment',
],
},
- slides: {
- directory: 'locale',
- packages: [
- '@univerjs/design',
- '@univerjs/docs-ui',
- '@univerjs/slides-ui',
- '@univerjs/ui',
- ],
- },
} as const;
const LOCALE_TAGS = new Set([
diff --git a/examples/src/dev-locale-loader.ts b/examples/src/dev-locale-loader.ts
index 5efa83d7a4..029ceb5f19 100644
--- a/examples/src/dev-locale-loader.ts
+++ b/examples/src/dev-locale-loader.ts
@@ -1,9 +1,8 @@
-import type { WorkbenchLocale } from './workbench-settings';
-
import { mergeLocales } from '@univerjs/core';
+import type { WorkbenchLocale } from './workbench-settings';
import { WORKBENCH_LOCALE_META } from './workbench-settings';
-type DevLocaleProduct = 'docs' | 'sheets' | 'slides';
+type DevLocaleProduct = 'docs' | 'sheets';
type LocalePack = Record<string, unknown>;
interface IDevLocaleResponse {
diff --git a/examples/src/main.ts b/examples/src/main.ts
index 2fc40e7174..5fbb9794c3 100644
--- a/examples/src/main.ts
+++ b/examples/src/main.ts
@@ -24,7 +24,6 @@ import './global.css';
const loaders = {
docs: () => import('./docs/mount'),
sheets: () => import('./sheets/mount'),
- slides: () => import('./slides/mount'),
} satisfies Record<string, ExampleLoader>;
type ExampleName = keyof typeof loaders;
@@ -58,7 +57,7 @@ if (location.search) {
function getExampleName(): ExampleName {
const name = location.hash.slice(1);
- if (Object.hasOwn(loaders, name)) {
+ if (Object.prototype.hasOwnProperty.call(loaders, name)) {
return name as ExampleName;
}
@@ -89,7 +88,6 @@ function renderWorkbenchSettings(currentSettings = settings) {
document.documentElement.style.setProperty('--workbench-accent', theme.primary[600]);
renderWorkbenchSettingsControl(settingsContainer, {
settings: currentSettings,
- supportsMobile: getExampleName() !== 'slides',
onDeviceChange,
onLocaleChange,
onRegionChange,
diff --git a/examples/src/slides/__tests__/create-slide-fixture.spec.ts b/examples/src/slides/__tests__/create-slide-fixture.spec.ts
deleted file mode 100644
index 7e2c937731..0000000000
--- a/examples/src/slides/__tests__/create-slide-fixture.spec.ts
+++ /dev/null
@@ -1,88 +0,0 @@
-import { PageElementType } from '@univerjs/slides';
-import { describe, expect, it } from 'vitest';
-
-import { readGeneratedSvgSize } from '../../generated-svg';
-import { createSlideFixture } from '../create-slide-fixture';
-
-function getElementBounds(element: { height?: number; left?: number; top?: number; width?: number }) {
- if (element.height == null || element.left == null || element.top == null || element.width == null) {
- throw new Error('Fixture element must define complete bounds.');
- }
-
- return {
- bottom: element.top + element.height,
- left: element.left,
- right: element.left + element.width,
- top: element.top,
- };
-}
-
-function intersects(
- first: ReturnType<typeof getElementBounds>,
- second: ReturnType<typeof getElementBounds>
-): boolean {
- return first.left < second.right && first.right > second.left && first.top < second.bottom && first.bottom > second.top;
-}
-
-describe('createSlideFixture', () => {
- it('creates fresh offline pages spanning text, shapes and images', () => {
- const first = createSlideFixture();
- const second = createSlideFixture();
- if (!first.body || !second.body) {
- throw new Error('Slides workbench fixtures must include a body.');
- }
-
- const elements = Object.values(first.body.pages).flatMap(({ pageElements }) => Object.values(pageElements));
- const elementTypes = new Set(elements.map(({ type }) => type));
- const images = elements.filter(({ type }) => type === PageElementType.IMAGE);
- const textBoxes = elements.filter(({ type }) => type === PageElementType.TEXT);
- const generatedTextBoxes = textBoxes.filter(({ id }) => id !== 'rich-copy');
-
- expect(elementTypes).toEqual(new Set([PageElementType.IMAGE, PageElementType.SHAPE, PageElementType.TEXT]));
- expect(images.every(({ image }) => image?.imageProperties?.contentUrl?.startsWith('data:image/svg+xml'))).toBe(true);
- images.forEach(({ height, image, width }) => {
- const source = image?.imageProperties?.contentUrl;
- if (!source || width == null || height == null) {
- throw new Error('Generated slide images must include a source and render dimensions.');
- }
-
- const intrinsicSize = readGeneratedSvgSize(source);
- expect(width / height).toBeCloseTo(intrinsicSize.width / intrinsicSize.height, 8);
- });
- expect(generatedTextBoxes.every(({ richText }) => {
- const style = richText?.rich?.documentStyle;
- return style?.marginBottom === 0 && style.marginLeft === 0 && style.marginRight === 0 && style.marginTop === 0;
- })).toBe(true);
- expect(textBoxes.every(({ width }) => width != null && width > 144)).toBe(true);
- expect(first.body.pages).not.toBe(second.body.pages);
- expect(JSON.stringify(first)).toBe(JSON.stringify(second));
- });
-
- it('keeps generated images centered in their frames without colliding with foreground elements', () => {
- const fixture = createSlideFixture();
- const overview = fixture.body?.pages.overview.pageElements;
- const media = fixture.body?.pages.media.pageElements;
- if (!overview || !media) {
- throw new Error('Slides workbench must include overview and media pages.');
- }
-
- const overviewFrame = getElementBounds(overview['overview-glow']);
- const overviewImage = getElementBounds(overview['overview-image']);
- expect((overviewImage.left + overviewImage.right) / 2).toBe((overviewFrame.left + overviewFrame.right) / 2);
- expect((overviewImage.top + overviewImage.bottom) / 2).toBe((overviewFrame.top + overviewFrame.bottom) / 2);
-
- const mediaFrame = getElementBounds(media['media-frame']);
- const mediaImage = getElementBounds(media['media-image']);
- expect([
- mediaImage.left - mediaFrame.left,
- mediaImage.top - mediaFrame.top,
- mediaFrame.right - mediaImage.right,
- mediaFrame.bottom - mediaImage.bottom,
- ]).toEqual([22, 22, 22, 22]);
-
- const collidingForegroundElements = Object.values(media)
- .filter(({ id, zIndex }) => id !== 'media-image' && id !== 'media-frame' && zIndex > 1)
- .filter((element) => intersects(mediaImage, getElementBounds(element)));
- expect(collidingForegroundElements).toEqual([]);
- });
-});
diff --git a/examples/src/slides/create-slide-fixture.ts b/examples/src/slides/create-slide-fixture.ts
deleted file mode 100644
index 260d13c596..0000000000
--- a/examples/src/slides/create-slide-fixture.ts
+++ /dev/null
@@ -1,603 +0,0 @@
-import type { IDocumentData, IShapeProperties, IStyleBase } from '@univerjs/core';
-import type { IPageElement, ISlideData } from '@univerjs/slides';
-import { BooleanNumber, DocumentFlavor, PresetListType } from '@univerjs/core';
-import { BasicShapes, PageElementType, PageType } from '@univerjs/slides';
-
-import { createGeneratedSvg } from '../generated-svg';
-
-const INLINE_DASHBOARD_IMAGE = createGeneratedSvg({
- width: 480,
- height: 280,
- content: [
- '<rect width="480" height="280" rx="28" fill="#18181b"/>',
- '<rect x="28" y="28" width="424" height="46" rx="12" fill="#27272a"/>',
- '<circle cx="55" cy="51" r="8" fill="#f97316"/>',
- '<circle cx="79" cy="51" r="8" fill="#facc15"/>',
- '<circle cx="103" cy="51" r="8" fill="#22c55e"/>',
- '<rect x="28" y="96" width="126" height="156" rx="16" fill="#312e81"/>',
- '<rect x="174" y="96" width="278" height="70" rx="16" fill="#4338ca"/>',
- '<rect x="174" y="186" width="82" height="66" rx="16" fill="#0ea5e9"/>',
- '<rect x="272" y="186" width="82" height="66" rx="16" fill="#14b8a6"/>',
- '<rect x="370" y="186" width="82" height="66" rx="16" fill="#f97316"/>',
- ],
-});
-
-const WHITE_TEXT: IStyleBase = {
- ff: 'Arial',
- cl: { rgb: '#f8fafc' },
-};
-
-function createTextDocument(id: string, text: string, width: number, height: number, style: IStyleBase): IDocumentData {
- const paragraphs: NonNullable<IDocumentData['body']>['paragraphs'] = [];
- const textRuns: NonNullable<IDocumentData['body']>['textRuns'] = [];
- let dataStream = '';
-
- text.split('\n').forEach((line, index) => {
- const startIndex = dataStream.length;
- dataStream += line;
- if (line.length > 0) {
- textRuns.push({ st: startIndex, ed: dataStream.length, ts: style });
- }
- paragraphs.push({ paragraphId: `${id}-paragraph-${index + 1}`, startIndex: dataStream.length });
- dataStream += '\r';
- });
-
- const sectionStartIndex = dataStream.length;
- dataStream += '\n';
-
- return {
- id: `${id}-document`,
- body: {
- dataStream,
- paragraphs,
- sectionBreaks: [{ sectionId: `${id}-section`, startIndex: sectionStartIndex }],
- textRuns,
- },
- documentStyle: {
- documentFlavor: DocumentFlavor.TRADITIONAL,
- pageSize: { height, width },
- marginBottom: 0,
- marginLeft: 0,
- marginRight: 0,
- marginTop: 0,
- },
- };
-}
-
-function createText(
- id: string,
- text: string,
- [left, top, width, height]: [number, number, number, number],
- richText: IStyleBase,
- zIndex = 3,
- transform: Partial<Pick<IPageElement, 'angle' | 'flipX' | 'flipY' | 'scaleX' | 'scaleY' | 'skewX' | 'skewY'>> = {}
-): IPageElement {
- return {
- id,
- zIndex,
- left,
- top,
- width,
- height,
- title: id,
- description: text,
- type: PageElementType.TEXT,
- richText: {
- rich: createTextDocument(id, text, width, height, richText),
- },
- ...transform,
- };
-}
-
-function createShape(
- id: string,
- shapeType: BasicShapes,
- [left, top, width, height]: [number, number, number, number],
- fill: string,
- zIndex = 2,
- shapeProperties: Omit<IShapeProperties, 'shapeBackgroundFill'> = {},
- transform: Partial<Pick<IPageElement, 'angle' | 'flipX' | 'flipY' | 'scaleX' | 'scaleY' | 'skewX' | 'skewY'>> = {}
-): IPageElement {
- return {
- id,
- zIndex,
- left,
- top,
- width,
- height,
- title: id,
- description: `${shapeType} shape`,
- type: PageElementType.SHAPE,
- shape: {
- shapeType,
- text: '',
- shapeProperties: {
- shapeBackgroundFill: { rgb: fill },
- ...shapeProperties,
- },
- },
- ...transform,
- };
-}
-
-const SLIDE_FIXTURE: ISlideData = {
- id: 'slide-workbench',
- title: 'Univer Slides workbench',
- pageSize: {
- width: 960,
- height: 540,
- },
- body: {
- pageOrder: ['overview', 'components', 'rich-text', 'media'],
- pages: {
- overview: {
- id: 'overview',
- pageType: PageType.SLIDE,
- zIndex: 1,
- title: 'Overview',
- description: 'Cover page with layered text, shapes and an inline image',
- pageBackgroundFill: { rgb: '#0f172a' },
- pageElements: {
- 'overview-edge': createShape(
- 'overview-edge',
- BasicShapes.Rect,
- [0, 0, 14, 540],
- '#6366f1',
- 1
- ),
- 'overview-glow': createShape(
- 'overview-glow',
- BasicShapes.RoundRect,
- [615, 100, 290, 330],
- 'rgba(99, 102, 241, 0.18)',
- 1,
- { radius: 28 },
- { angle: -5 }
- ),
- 'overview-tag': createShape(
- 'overview-tag',
- BasicShapes.RoundRect,
- [72, 82, 260, 34],
- '#312e81',
- 2,
- {
- radius: 17,
- outline: {
- outlineFill: { rgb: '#818cf8' },
- weight: 1,
- },
- }
- ),
- 'overview-tag-label': createText(
- 'overview-tag-label',
- 'DEVELOPER WORKBENCH',
- [92, 89, 220, 22],
- { ...WHITE_TEXT, fs: 12, bl: BooleanNumber.TRUE },
- 3
- ),
- 'overview-title': createText(
- 'overview-title',
- 'Build slides,\ninspect behavior.',
- [72, 154, 500, 150],
- { ...WHITE_TEXT, fs: 42, bl: BooleanNumber.TRUE },
- 3
- ),
- 'overview-subtitle': createText(
- 'overview-subtitle',
- 'Four compact pages exercise editing, styling, transforms, layers and local media.',
- [76, 325, 460, 72],
- { ...WHITE_TEXT, fs: 17, it: BooleanNumber.TRUE, cl: { rgb: '#cbd5e1' } },
- 3
- ),
- 'overview-image': {
- id: 'overview-image',
- zIndex: 3,
- left: 640,
- top: 195,
- width: 240,
- height: 140,
- angle: 3,
- title: 'Inline dashboard illustration',
- description: 'Deterministic SVG data URI without a network dependency',
- type: PageElementType.IMAGE,
- image: {
- imageProperties: {
- contentUrl: INLINE_DASHBOARD_IMAGE.source,
- },
- },
- },
- 'overview-footer': createText(
- 'overview-footer',
- 'Univer Slides · local fixture',
- [74, 472, 300, 24],
- { ...WHITE_TEXT, fs: 12, cl: { rgb: '#94a3b8' } },
- 3
- ),
- },
- },
- components: {
- id: 'components',
- pageType: PageType.SLIDE,
- zIndex: 2,
- title: 'Components',
- description: 'Shape, outline, typography and transform samples',
- pageBackgroundFill: { rgb: '#f8fafc' },
- pageElements: {
- 'components-title': createText(
- 'components-title',
- 'Shapes & typography',
- [54, 42, 560, 54],
- { ff: 'Arial', fs: 30, bl: BooleanNumber.TRUE, cl: { rgb: '#0f172a' } }
- ),
- 'components-rule': createShape(
- 'components-rule',
- BasicShapes.Rect,
- [54, 102, 852, 5],
- '#6366f1',
- 1
- ),
- 'components-card-1': createShape(
- 'components-card-1',
- BasicShapes.RoundRect,
- [54, 148, 252, 286],
- '#ffffff',
- 1,
- {
- radius: 20,
- outline: {
- outlineFill: { rgb: '#cbd5e1' },
- weight: 2,
- },
- }
- ),
- 'components-card-1-index': createShape(
- 'components-card-1-index',
- BasicShapes.RoundRect,
- [78, 174, 58, 48],
- '#4f46e5',
- 2,
- { radius: 14 }
- ),
- 'components-card-1-number': createText(
- 'components-card-1-number',
- '01',
- [22, 184, 180, 28],
- { ...WHITE_TEXT, fs: 20, bl: BooleanNumber.TRUE }
- ),
- 'components-card-1-copy': createText(
- 'components-card-1-copy',
- 'Rounded rectangle\nwith a visible outline',
- [78, 250, 200, 86],
- { ff: 'Arial', fs: 18, bl: BooleanNumber.TRUE, cl: { rgb: '#1e293b' } }
- ),
- 'components-card-2': createShape(
- 'components-card-2',
- BasicShapes.Rect,
- [354, 148, 252, 286],
- '#ecfeff',
- 1,
- {
- outline: {
- outlineFill: { rgb: '#06b6d4' },
- weight: 2,
- },
- }
- ),
- 'components-card-2-accent': createShape(
- 'components-card-2-accent',
- BasicShapes.Rect,
- [406, 195, 150, 92],
- '#0891b2',
- 2,
- {},
- { angle: -8, skewX: 4 }
- ),
- 'components-card-2-copy': createText(
- 'components-card-2-copy',
- 'Rotate + skew',
- [394, 310, 180, 34],
- {
- ff: 'Georgia',
- fs: 20,
- it: BooleanNumber.TRUE,
- ul: { s: BooleanNumber.TRUE },
- cl: { rgb: '#155e75' },
- }
- ),
- 'components-card-3': createShape(
- 'components-card-3',
- BasicShapes.RoundRect,
- [654, 148, 252, 286],
- '#fff7ed',
- 1,
- {
- radius: 40,
- outline: {
- outlineFill: { rgb: '#fb923c' },
- weight: 3,
- },
- }
- ),
- 'components-card-3-layer-1': createShape(
- 'components-card-3-layer-1',
- BasicShapes.RoundRect,
- [704, 194, 150, 112],
- '#fdba74',
- 2,
- { radius: 18 },
- { angle: -7 }
- ),
- 'components-card-3-layer-2': createShape(
- 'components-card-3-layer-2',
- BasicShapes.RoundRect,
- [722, 208, 150, 112],
- 'rgba(249, 115, 22, 0.78)',
- 3,
- { radius: 18 },
- { angle: 7 }
- ),
- 'components-card-3-copy': createText(
- 'components-card-3-copy',
- 'z-index layers',
- [694, 350, 176, 32],
- {
- ff: 'Arial',
- fs: 19,
- st: { s: BooleanNumber.TRUE },
- cl: { rgb: '#9a3412' },
- },
- 4
- ),
- },
- },
- 'rich-text': {
- id: 'rich-text',
- pageType: PageType.SLIDE,
- zIndex: 3,
- title: 'Rich text',
- description: 'Editable rich text and layered callout samples',
- pageBackgroundFill: { rgb: '#fff7ed' },
- pageElements: {
- 'rich-title': createText(
- 'rich-title',
- 'Editable rich text',
- [56, 42, 520, 54],
- { ff: 'Arial', fs: 30, bl: BooleanNumber.TRUE, cl: { rgb: '#7c2d12' } }
- ),
- 'rich-panel': createShape(
- 'rich-panel',
- BasicShapes.RoundRect,
- [54, 126, 542, 350],
- '#ffffff',
- 1,
- {
- radius: 24,
- outline: {
- outlineFill: { rgb: '#fed7aa' },
- weight: 2,
- },
- }
- ),
- 'rich-copy': {
- id: 'rich-copy',
- zIndex: 2,
- left: 84,
- top: 158,
- width: 480,
- height: 280,
- title: 'Rich text sample',
- description: 'Multiple runs and editable bullet paragraphs',
- type: PageElementType.TEXT,
- richText: {
- rich: {
- id: 'slide-rich-copy',
- body: {
- dataStream:
- 'Rich text block\rBold, italic, underline and color\rEditable bullet one\rEditable bullet two\r\n',
- textRuns: [
- {
- st: 0,
- ed: 14,
- ts: {
- ff: 'Arial',
- fs: 28,
- bl: BooleanNumber.TRUE,
- cl: { rgb: '#9a3412' },
- },
- },
- {
- st: 16,
- ed: 20,
- ts: { fs: 16, bl: BooleanNumber.TRUE },
- },
- {
- st: 22,
- ed: 27,
- ts: { fs: 16, it: BooleanNumber.TRUE },
- },
- {
- st: 30,
- ed: 38,
- ts: { fs: 16, ul: { s: BooleanNumber.TRUE } },
- },
- {
- st: 44,
- ed: 48,
- ts: { fs: 16, cl: { rgb: '#ea580c' } },
- },
- {
- st: 50,
- ed: 88,
- ts: { fs: 16, cl: { rgb: '#431407' } },
- },
- ],
- paragraphs: [
- { paragraphId: 'rich-heading', startIndex: 15 },
- { paragraphId: 'rich-styles', startIndex: 49 },
- {
- paragraphId: 'rich-bullet-1',
- startIndex: 69,
- bullet: {
- listType: PresetListType.BULLET_LIST,
- listId: 'slide-feature-list',
- nestingLevel: 0,
- textStyle: { fs: 16 },
- },
- },
- {
- paragraphId: 'rich-bullet-2',
- startIndex: 89,
- bullet: {
- listType: PresetListType.BULLET_LIST,
- listId: 'slide-feature-list',
- nestingLevel: 0,
- textStyle: { fs: 16 },
- },
- },
- ],
- },
- documentStyle: {
- pageSize: {
- width: undefined,
- height: undefined,
- },
- marginTop: 4,
- marginBottom: 4,
- marginLeft: 4,
- marginRight: 4,
- },
- },
- },
- },
- 'rich-callout-back': createShape(
- 'rich-callout-back',
- BasicShapes.RoundRect,
- [646, 160, 238, 210],
- '#7c2d12',
- 1,
- { radius: 26 },
- { angle: -4 }
- ),
- 'rich-callout-front': createShape(
- 'rich-callout-front',
- BasicShapes.RoundRect,
- [664, 178, 238, 210],
- '#fb923c',
- 2,
- { radius: 26 },
- { angle: 4 }
- ),
- 'rich-callout-copy': createText(
- 'rich-callout-copy',
- 'Double-click\nto edit',
- [704, 236, 168, 88],
- { ...WHITE_TEXT, fs: 25, bl: BooleanNumber.TRUE },
- 3,
- { angle: 4 }
- ),
- 'rich-note': createText(
- 'rich-note',
- 'The fixture stays small while covering run styles, lists and the Slides text editor bridge.',
- [642, 424, 270, 56],
- { ff: 'Arial', fs: 13, it: BooleanNumber.TRUE, cl: { rgb: '#9a3412' } }
- ),
- },
- },
- media: {
- id: 'media',
- pageType: PageType.SLIDE,
- zIndex: 4,
- title: 'Media and layers',
- description: 'Inline image, positioning and object samples',
- pageBackgroundFill: { rgb: '#111827' },
- pageElements: {
- 'media-title': createText(
- 'media-title',
- 'Local media, no network',
- [58, 44, 600, 52],
- { ...WHITE_TEXT, fs: 30, bl: BooleanNumber.TRUE }
- ),
- 'media-accent': createShape(
- 'media-accent',
- BasicShapes.Rect,
- [724, 40, 170, 54],
- '#14b8a6',
- 1,
- {},
- { angle: 6 }
- ),
- 'media-frame': createShape(
- 'media-frame',
- BasicShapes.RoundRect,
- [58, 132, 500, 310],
- '#312e81',
- 1,
- { radius: 28 }
- ),
- 'media-image': {
- id: 'media-image',
- zIndex: 2,
- left: 80,
- top: 154,
- width: 456,
- height: 266,
- title: 'Inline SVG dashboard',
- description: 'Same deterministic data URI at a second size',
- type: PageElementType.IMAGE,
- image: {
- imageProperties: {
- contentUrl: INLINE_DASHBOARD_IMAGE.source,
- },
- },
- },
- 'media-chip-1': createShape(
- 'media-chip-1',
- BasicShapes.RoundRect,
- [628, 162, 246, 62],
- '#1e293b',
- 1,
- { radius: 18 }
- ),
- 'media-chip-1-copy': createText(
- 'media-chip-1-copy',
- '✓ deterministic fixture',
- [652, 181, 200, 28],
- { ...WHITE_TEXT, fs: 16, cl: { rgb: '#5eead4' } }
- ),
- 'media-chip-2': createShape(
- 'media-chip-2',
- BasicShapes.RoundRect,
- [628, 246, 246, 62],
- '#1e293b',
- 1,
- { radius: 18 }
- ),
- 'media-chip-2-copy': createText(
- 'media-chip-2-copy',
- '✓ selectable objects',
- [652, 265, 200, 28],
- { ...WHITE_TEXT, fs: 16, cl: { rgb: '#a5b4fc' } }
- ),
- 'media-chip-3': createShape(
- 'media-chip-3',
- BasicShapes.RoundRect,
- [628, 330, 246, 62],
- '#1e293b',
- 1,
- { radius: 18 }
- ),
- 'media-chip-3-copy': createText(
- 'media-chip-3-copy',
- '✓ offline image data',
- [652, 349, 200, 28],
- { ...WHITE_TEXT, fs: 16, cl: { rgb: '#fdba74' } }
- ),
- },
- },
- },
- },
-};
-
-export function createSlideFixture(): ISlideData {
- return structuredClone(SLIDE_FIXTURE);
-}
diff --git a/examples/src/slides/global.css b/examples/src/slides/global.css
deleted file mode 100644
index f95765e53b..0000000000
--- a/examples/src/slides/global.css
+++ /dev/null
@@ -1,4 +0,0 @@
-@config "../../tailwind.slides.config.ts";
-@tailwind base;
-@tailwind components;
-@tailwind utilities;
diff --git a/examples/src/slides/locale-loader.dev.ts b/examples/src/slides/locale-loader.dev.ts
deleted file mode 100644
index f2107555c0..0000000000
--- a/examples/src/slides/locale-loader.dev.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import type { WorkbenchLocale } from '../workbench-settings';
-import { loadDevLocale } from '../dev-locale-loader';
-
-export function loadSlideLocale(locale: WorkbenchLocale) {
- return loadDevLocale('slides', locale);
-}
diff --git a/examples/src/slides/locale-loader.ts b/examples/src/slides/locale-loader.ts
deleted file mode 100644
index 34a11c9628..0000000000
--- a/examples/src/slides/locale-loader.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import type { WorkbenchLocale } from '../workbench-settings';
-
-interface ILocaleModule {
- default: Record<string, unknown>;
-}
-
-type LocaleLoader = () => Promise<ILocaleModule>;
-
-const SLIDE_LOCALE_LOADERS = {
- enUS: () => import('./locales/en-US'),
- frFR: () => import('./locales/fr-FR'),
- zhCN: () => import('./locales/zh-CN'),
- ruRU: () => import('./locales/ru-RU'),
- zhTW: () => import('./locales/zh-TW'),
- zhHK: () => import('./locales/zh-HK'),
- viVN: () => import('./locales/vi-VN'),
- faIR: () => import('./locales/fa-IR'),
- jaJP: () => import('./locales/ja-JP'),
- koKR: () => import('./locales/ko-KR'),
- esES: () => import('./locales/es-ES'),
- caES: () => import('./locales/ca-ES'),
- skSK: () => import('./locales/sk-SK'),
- ptBR: () => import('./locales/pt-BR'),
- deDE: () => import('./locales/de-DE'),
- itIT: () => import('./locales/it-IT'),
- idID: () => import('./locales/id-ID'),
- plPL: () => import('./locales/pl-PL'),
- arSA: () => import('./locales/ar-SA'),
-} satisfies Record<WorkbenchLocale, LocaleLoader>;
-
-export async function loadSlideLocale(locale: WorkbenchLocale) {
- return (await SLIDE_LOCALE_LOADERS[locale]()).default;
-}
diff --git a/examples/src/slides/locales/ar-SA.ts b/examples/src/slides/locales/ar-SA.ts
deleted file mode 100644
index 1620cbfb3e..0000000000
--- a/examples/src/slides/locales/ar-SA.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/ar-SA';
-import docsUI from '@univerjs/docs-ui/locale/ar-SA';
-import slidesUI from '@univerjs/slides-ui/locale/ar-SA';
-import ui from '@univerjs/ui/locale/ar-SA';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/ca-ES.ts b/examples/src/slides/locales/ca-ES.ts
deleted file mode 100644
index 8a93cd209a..0000000000
--- a/examples/src/slides/locales/ca-ES.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/ca-ES';
-import docsUI from '@univerjs/docs-ui/locale/ca-ES';
-import slidesUI from '@univerjs/slides-ui/locale/ca-ES';
-import ui from '@univerjs/ui/locale/ca-ES';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/de-DE.ts b/examples/src/slides/locales/de-DE.ts
deleted file mode 100644
index a68052b0ec..0000000000
--- a/examples/src/slides/locales/de-DE.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/de-DE';
-import docsUI from '@univerjs/docs-ui/locale/de-DE';
-import slidesUI from '@univerjs/slides-ui/locale/de-DE';
-import ui from '@univerjs/ui/locale/de-DE';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/en-US.ts b/examples/src/slides/locales/en-US.ts
deleted file mode 100644
index 23eceb1e31..0000000000
--- a/examples/src/slides/locales/en-US.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/en-US';
-import docsUI from '@univerjs/docs-ui/locale/en-US';
-import slidesUI from '@univerjs/slides-ui/locale/en-US';
-import ui from '@univerjs/ui/locale/en-US';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/es-ES.ts b/examples/src/slides/locales/es-ES.ts
deleted file mode 100644
index 42ae41a983..0000000000
--- a/examples/src/slides/locales/es-ES.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/es-ES';
-import docsUI from '@univerjs/docs-ui/locale/es-ES';
-import slidesUI from '@univerjs/slides-ui/locale/es-ES';
-import ui from '@univerjs/ui/locale/es-ES';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/fa-IR.ts b/examples/src/slides/locales/fa-IR.ts
deleted file mode 100644
index a9ed759361..0000000000
--- a/examples/src/slides/locales/fa-IR.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/fa-IR';
-import docsUI from '@univerjs/docs-ui/locale/fa-IR';
-import slidesUI from '@univerjs/slides-ui/locale/fa-IR';
-import ui from '@univerjs/ui/locale/fa-IR';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/fr-FR.ts b/examples/src/slides/locales/fr-FR.ts
deleted file mode 100644
index c255daec15..0000000000
--- a/examples/src/slides/locales/fr-FR.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/fr-FR';
-import docsUI from '@univerjs/docs-ui/locale/fr-FR';
-import slidesUI from '@univerjs/slides-ui/locale/fr-FR';
-import ui from '@univerjs/ui/locale/fr-FR';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/id-ID.ts b/examples/src/slides/locales/id-ID.ts
deleted file mode 100644
index 8c68fe58d0..0000000000
--- a/examples/src/slides/locales/id-ID.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/id-ID';
-import docsUI from '@univerjs/docs-ui/locale/id-ID';
-import slidesUI from '@univerjs/slides-ui/locale/id-ID';
-import ui from '@univerjs/ui/locale/id-ID';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/it-IT.ts b/examples/src/slides/locales/it-IT.ts
deleted file mode 100644
index d355e02041..0000000000
--- a/examples/src/slides/locales/it-IT.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/it-IT';
-import docsUI from '@univerjs/docs-ui/locale/it-IT';
-import slidesUI from '@univerjs/slides-ui/locale/it-IT';
-import ui from '@univerjs/ui/locale/it-IT';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/ja-JP.ts b/examples/src/slides/locales/ja-JP.ts
deleted file mode 100644
index a85a232a00..0000000000
--- a/examples/src/slides/locales/ja-JP.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/ja-JP';
-import docsUI from '@univerjs/docs-ui/locale/ja-JP';
-import slidesUI from '@univerjs/slides-ui/locale/ja-JP';
-import ui from '@univerjs/ui/locale/ja-JP';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/ko-KR.ts b/examples/src/slides/locales/ko-KR.ts
deleted file mode 100644
index 8c5ea8883b..0000000000
--- a/examples/src/slides/locales/ko-KR.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/ko-KR';
-import docsUI from '@univerjs/docs-ui/locale/ko-KR';
-import slidesUI from '@univerjs/slides-ui/locale/ko-KR';
-import ui from '@univerjs/ui/locale/ko-KR';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/pl-PL.ts b/examples/src/slides/locales/pl-PL.ts
deleted file mode 100644
index 55fa152124..0000000000
--- a/examples/src/slides/locales/pl-PL.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/pl-PL';
-import docsUI from '@univerjs/docs-ui/locale/pl-PL';
-import slidesUI from '@univerjs/slides-ui/locale/pl-PL';
-import ui from '@univerjs/ui/locale/pl-PL';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/pt-BR.ts b/examples/src/slides/locales/pt-BR.ts
deleted file mode 100644
index 5cafadb62b..0000000000
--- a/examples/src/slides/locales/pt-BR.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/pt-BR';
-import docsUI from '@univerjs/docs-ui/locale/pt-BR';
-import slidesUI from '@univerjs/slides-ui/locale/pt-BR';
-import ui from '@univerjs/ui/locale/pt-BR';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/ru-RU.ts b/examples/src/slides/locales/ru-RU.ts
deleted file mode 100644
index a4806b95b0..0000000000
--- a/examples/src/slides/locales/ru-RU.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/ru-RU';
-import docsUI from '@univerjs/docs-ui/locale/ru-RU';
-import slidesUI from '@univerjs/slides-ui/locale/ru-RU';
-import ui from '@univerjs/ui/locale/ru-RU';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/sk-SK.ts b/examples/src/slides/locales/sk-SK.ts
deleted file mode 100644
index a706613a8c..0000000000
--- a/examples/src/slides/locales/sk-SK.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/sk-SK';
-import docsUI from '@univerjs/docs-ui/locale/sk-SK';
-import slidesUI from '@univerjs/slides-ui/locale/sk-SK';
-import ui from '@univerjs/ui/locale/sk-SK';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/vi-VN.ts b/examples/src/slides/locales/vi-VN.ts
deleted file mode 100644
index 72835a2363..0000000000
--- a/examples/src/slides/locales/vi-VN.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/vi-VN';
-import docsUI from '@univerjs/docs-ui/locale/vi-VN';
-import slidesUI from '@univerjs/slides-ui/locale/vi-VN';
-import ui from '@univerjs/ui/locale/vi-VN';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/zh-CN.ts b/examples/src/slides/locales/zh-CN.ts
deleted file mode 100644
index 7aae3ddf67..0000000000
--- a/examples/src/slides/locales/zh-CN.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/zh-CN';
-import docsUI from '@univerjs/docs-ui/locale/zh-CN';
-import slidesUI from '@univerjs/slides-ui/locale/zh-CN';
-import ui from '@univerjs/ui/locale/zh-CN';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/zh-HK.ts b/examples/src/slides/locales/zh-HK.ts
deleted file mode 100644
index 056ffdcb23..0000000000
--- a/examples/src/slides/locales/zh-HK.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/zh-HK';
-import docsUI from '@univerjs/docs-ui/locale/zh-HK';
-import slidesUI from '@univerjs/slides-ui/locale/zh-HK';
-import ui from '@univerjs/ui/locale/zh-HK';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/locales/zh-TW.ts b/examples/src/slides/locales/zh-TW.ts
deleted file mode 100644
index 4b8b067e19..0000000000
--- a/examples/src/slides/locales/zh-TW.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { mergeLocales } from '@univerjs/core';
-import design from '@univerjs/design/locale/zh-TW';
-import docsUI from '@univerjs/docs-ui/locale/zh-TW';
-import slidesUI from '@univerjs/slides-ui/locale/zh-TW';
-import ui from '@univerjs/ui/locale/zh-TW';
-
-export default mergeLocales(
- design,
- docsUI,
- slidesUI,
- ui
-);
diff --git a/examples/src/slides/mount.ts b/examples/src/slides/mount.ts
deleted file mode 100644
index 1e99397785..0000000000
--- a/examples/src/slides/mount.ts
+++ /dev/null
@@ -1,97 +0,0 @@
-import type { MountExample } from '../mount-example';
-import type { IWorkbenchMountOptions } from '../workbench-settings';
-import { LocaleType, Univer, UniverInstanceType } from '@univerjs/core';
-import { FUniver } from '@univerjs/core/facade';
-import { UniverDocsPlugin } from '@univerjs/docs';
-import { UniverDocsUIPlugin } from '@univerjs/docs-ui';
-import { UniverDrawingPlugin } from '@univerjs/drawing';
-import { IRenderManagerService, UniverRenderEnginePlugin } from '@univerjs/engine-render';
-import { UniverSlidesPlugin } from '@univerjs/slides';
-import { UniverSlidesUIPlugin } from '@univerjs/slides-ui';
-import { UniverUIPlugin } from '@univerjs/ui';
-import { filter, firstValueFrom } from 'rxjs';
-
-import { loadSlideLocale } from 'virtual:univer-examples-slide-locale';
-import { applyWorkbenchUIChrome, createMountedUniver } from '../mount-example';
-import { getEffectiveWorkbenchRegion } from '../workbench-settings';
-import { createSlideFixture } from './create-slide-fixture';
-import '@univerjs/ui/facade';
-import './global.css';
-
-const UNIVER_LOCALES = {
- [LocaleType.ZH_CN]: LocaleType.ZH_CN,
- [LocaleType.EN_US]: LocaleType.EN_US,
- [LocaleType.AR_SA]: LocaleType.AR_SA,
- [LocaleType.FR_FR]: LocaleType.FR_FR,
- [LocaleType.RU_RU]: LocaleType.RU_RU,
- [LocaleType.ZH_TW]: LocaleType.ZH_TW,
- [LocaleType.ZH_HK]: LocaleType.ZH_HK,
- [LocaleType.VI_VN]: LocaleType.VI_VN,
- [LocaleType.FA_IR]: LocaleType.FA_IR,
- [LocaleType.JA_JP]: LocaleType.JA_JP,
- [LocaleType.KO_KR]: LocaleType.KO_KR,
- [LocaleType.ES_ES]: LocaleType.ES_ES,
- [LocaleType.CA_ES]: LocaleType.CA_ES,
- [LocaleType.SK_SK]: LocaleType.SK_SK,
- [LocaleType.PT_BR]: LocaleType.PT_BR,
- [LocaleType.DE_DE]: LocaleType.DE_DE,
- [LocaleType.IT_IT]: LocaleType.IT_IT,
- [LocaleType.ID_ID]: LocaleType.ID_ID,
- [LocaleType.PL_PL]: LocaleType.PL_PL,
-} satisfies Record<IWorkbenchMountOptions['locale'], LocaleType>;
-
-export const mount: MountExample = async (host, options) => {
- const locale = UNIVER_LOCALES[options.locale];
- const messages = await loadSlideLocale(options.locale);
- const univer = new Univer({
- locale,
- region: UNIVER_LOCALES[getEffectiveWorkbenchRegion(options)],
- locales: {
- [locale]: messages,
- },
- theme: options.theme,
- darkMode: options.darkMode,
- direction: options.direction,
- });
-
- try {
- univer.registerPlugin(UniverRenderEnginePlugin);
- univer.registerPlugin(UniverUIPlugin, {
- container: host,
- ribbonType: options.ribbonType,
- });
- univer.registerPlugin(UniverDocsPlugin);
- univer.registerPlugin(UniverDocsUIPlugin);
- univer.registerPlugin(UniverDrawingPlugin);
- univer.registerPlugin(UniverSlidesPlugin);
- univer.registerPlugin(UniverSlidesUIPlugin);
-
- const univerAPI = FUniver.newAPI(univer);
- applyWorkbenchUIChrome(univerAPI, options.uiChrome);
- const slideFixture = createSlideFixture();
- const slideId = slideFixture.id;
- univer.createUnit(UniverInstanceType.UNIVER_SLIDE, slideFixture);
-
- const renderManagerService = univer.__getInjector().get(IRenderManagerService);
- const applyProductSettings = async (nextOptions: IWorkbenchMountOptions) => {
- const renderUnit = renderManagerService.getRenderUnitById(slideId) ?? await firstValueFrom(
- renderManagerService.created$.pipe(filter(({ unitId }) => unitId === slideId))
- );
- renderUnit.scene.scale(nextOptions.zoomRatio, nextOptions.zoomRatio);
- };
-
- await applyProductSettings(options);
- return createMountedUniver(
- host,
- univer,
- univerAPI,
- options,
- loadSlideLocale,
- applyProductSettings
- );
- } catch (error) {
- univer.dispose();
- host.replaceChildren();
- throw error;
- }
-};
diff --git a/examples/src/vite-env.d.ts b/examples/src/vite-env.d.ts
index fd9a5b250c..1b5069e13c 100644
--- a/examples/src/vite-env.d.ts
+++ b/examples/src/vite-env.d.ts
@@ -7,7 +7,3 @@ declare module 'virtual:univer-examples-document-locale' {
declare module 'virtual:univer-examples-sheet-locale' {
export const loadSheetLocale: typeof import('./sheets/locale-loader').loadSheetLocale;
}
-
-declare module 'virtual:univer-examples-slide-locale' {
- export const loadSlideLocale: typeof import('./slides/locale-loader').loadSlideLocale;
-}
diff --git a/examples/src/workbench-settings-control.tsx b/examples/src/workbench-settings-control.tsx
index a392fc1edd..b28216cd72 100644
--- a/examples/src/workbench-settings-control.tsx
+++ b/examples/src/workbench-settings-control.tsx
@@ -1,4 +1,6 @@
import type { IDropdownMenuProps } from '@univerjs/design';
+import { Button, ConfigProvider, DropdownMenu, render, unmount } from '@univerjs/design';
+import { MoreDownIcon } from '@univerjs/icons';
import type {
IWorkbenchSettings,
WorkbenchDevice,
@@ -10,9 +12,6 @@ import type {
WorkbenchUIChromeMode,
WorkbenchZoomRatio,
} from './workbench-settings';
-import { Button, ConfigProvider, DropdownMenu, render, unmount } from '@univerjs/design';
-
-import { MoreDownIcon } from '@univerjs/icons';
import {
WORKBENCH_DEVICES,
WORKBENCH_DIRECTIONS,
@@ -97,7 +96,6 @@ const UI_CHROME_LABELS = {
interface IWorkbenchSettingsControlProps {
settings: IWorkbenchSettings;
- supportsMobile: boolean;
onDeviceChange: (device: WorkbenchDevice) => Promise<void>;
onLocaleChange: (locale: WorkbenchLocale) => Promise<void>;
onRegionChange: (region: WorkbenchRegion) => Promise<void>;
@@ -113,7 +111,6 @@ interface IWorkbenchSettingsControlProps {
function WorkbenchSettingsControl(props: IWorkbenchSettingsControlProps) {
const {
settings,
- supportsMobile,
onDarkModeChange,
onDeviceChange,
onDirectionChange,
@@ -138,16 +135,15 @@ function WorkbenchSettingsControl(props: IWorkbenchSettingsControlProps) {
const items: IDropdownMenuProps['items'] = [
{
type: 'item',
- children: renderSettingLabel('Device', supportsMobile ? 'Restarts example' : 'Desktop only'),
+ children: renderSettingLabel('Device', 'Restarts example'),
disabled: true,
},
{
type: 'radio',
- value: supportsMobile ? settings.device : 'desktop',
+ value: settings.device,
options: WORKBENCH_DEVICES.map((value) => ({
value,
label: DEVICE_LABELS[value],
- disabled: !supportsMobile,
})),
onSelect: (value) => onDeviceChange(value as WorkbenchDevice),
},
diff --git a/examples/tailwind.config.ts b/examples/tailwind.config.ts
index 37724b6486..4721720a84 100644
--- a/examples/tailwind.config.ts
+++ b/examples/tailwind.config.ts
@@ -1,7 +1,7 @@
import type { Config } from 'tailwindcss';
+import preset, { createTailwindContent } from '@univerjs-infra/shared/tailwind';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
-import preset, { createTailwindContent } from '@univerjs-infra/shared/tailwind';
import animate from 'tailwindcss-animate';
const configs = {
@@ -24,9 +24,6 @@ const configs = {
'../presets/packages/preset-sheets-table/tailwind.config.ts',
'../presets/packages/preset-sheets-thread-comment/tailwind.config.ts',
],
- slides: [
- '../packages/slides-ui/tailwind.config.ts',
- ],
} as const;
export type ExampleTarget = keyof typeof configs;
diff --git a/examples/tailwind.slides.config.ts b/examples/tailwind.slides.config.ts
deleted file mode 100644
index 8d10ce8034..0000000000
--- a/examples/tailwind.slides.config.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { createTailwindConfig } from './tailwind.config';
-
-export default createTailwindConfig('slides');
diff --git a/examples/vite.config.ts b/examples/vite.config.ts
index 27fafd095a..0582d3eb9b 100644
--- a/examples/vite.config.ts
+++ b/examples/vite.config.ts
@@ -6,7 +6,7 @@ import { defineConfig } from 'vite';
const DEV_LOCALE_ENDPOINT = '/__univer_examples_locale';
const DEV_LOCALE_EXPORT_SCRIPT = fileURLToPath(new URL('./scripts/export-locale.mts', import.meta.url));
-const DEV_LOCALE_PRODUCTS = new Set(['docs', 'sheets', 'slides']);
+const DEV_LOCALE_PRODUCTS = new Set(['docs', 'sheets']);
const DEV_TSX_IMPORT = fileURLToPath(import.meta.resolve('tsx'));
const DEV_LOCALE_TAGS = new Set([
'ar-SA',
@@ -29,7 +29,7 @@ const DEV_LOCALE_TAGS = new Set([
'zh-HK',
'zh-TW',
]);
-type DevLocaleProduct = 'docs' | 'sheets' | 'slides';
+type DevLocaleProduct = 'docs' | 'sheets';
const VIRTUAL_LOCALE_MODULES = {
'virtual:univer-examples-document-locale': {
@@ -42,11 +42,6 @@ const VIRTUAL_LOCALE_MODULES = {
exportName: 'loadSheetLocale',
production: fileURLToPath(new URL('./src/sheets/locale-loader.ts', import.meta.url)),
},
- 'virtual:univer-examples-slide-locale': {
- development: fileURLToPath(new URL('./src/slides/locale-loader.dev.ts', import.meta.url)),
- exportName: 'loadSlideLocale',
- production: fileURLToPath(new URL('./src/slides/locale-loader.ts', import.meta.url)),
- },
} as const;
type VirtualLocaleModule = keyof typeof VIRTUAL_LOCALE_MODULES;
diff --git a/packages/core/src/__tests__/skeleton.spec.ts b/packages/core/src/__tests__/skeleton.spec.ts
new file mode 100644
index 0000000000..2648d87df9
--- /dev/null
+++ b/packages/core/src/__tests__/skeleton.spec.ts
@@ -0,0 +1,44 @@
+/**
+ * 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 { describe, expect, it } from 'vitest';
+import { Injector } from '../common/di';
+import { LocaleService } from '../services/locale/locale.service';
+import { Skeleton } from '../skeleton';
+import { LocaleType } from '../types/enum/locale-type';
+
+describe('Skeleton', () => {
+ it('updates dirty state and releases locale data on dispose', () => {
+ const injector = new Injector([[LocaleService], [Skeleton]]);
+
+ try {
+ const localeService = injector.get(LocaleService);
+ localeService.load({ [LocaleType.EN_US]: {} });
+ localeService.setLocale(LocaleType.EN_US);
+ localeService.setDirection('ltr');
+ const skeleton = injector.get(Skeleton);
+
+ expect(skeleton.dirty).toBe(true);
+ skeleton.makeDirty(false);
+ expect(skeleton.dirty).toBe(false);
+
+ skeleton.dispose();
+ expect(skeleton.getFontLocale()).toBeNull();
+ } finally {
+ injector.dispose();
+ }
+ });
+});
diff --git a/packages/core/src/__tests__/univer-skeleton.spec.ts b/packages/core/src/__tests__/univer.spec.ts
similarity index 64%
rename from packages/core/src/__tests__/univer-skeleton.spec.ts
rename to packages/core/src/__tests__/univer.spec.ts
index 4a05f9ffaf..99201320be 100644
--- a/packages/core/src/__tests__/univer-skeleton.spec.ts
+++ b/packages/core/src/__tests__/univer.spec.ts
@@ -14,36 +14,60 @@
* limitations under the License.
*/
-import type { ILocales } from '../shared/locale';
import { defaultTheme } from '@univerjs/themes';
+import { BehaviorSubject } from 'rxjs';
import { describe, expect, it, vi } from 'vitest';
-import { Injector } from '../common/di';
-import { UniverInstanceType } from '../common/unit';
+import type { ILocales } from '../shared/locale';
+import { Inject, Injector } from '../common/di';
+import { UnitModel, UniverInstanceType } from '../common/unit';
import { COMMAND_LOG_EXECUTION_CONFIG_KEY } from '../services/command/command.service';
import { IConfigService } from '../services/config/config.service';
import { IUniverInstanceService } from '../services/instance/instance.service';
import { LocaleService } from '../services/locale/locale.service';
import { LogLevel } from '../services/log/log.service';
+import { Plugin } from '../services/plugin/plugin.service';
import { RegionService } from '../services/region/region.service';
import { IUndoRedoService, UNDO_REDO_HISTORY_LIMIT_CONFIG_KEY } from '../services/undoredo/undoredo.service';
-import { Skeleton } from '../skeleton';
import { LocaleType } from '../types/enum/locale-type';
import { Univer } from '../univer';
-describe('Skeleton', () => {
- it('should update dirty state and release locale data on dispose', () => {
- const skeleton = new Skeleton(new LocaleService());
-
- expect(skeleton.dirty).toBe(true);
- expect(skeleton.getFontLocale()).toBeUndefined();
-
- skeleton.makeDirty(false);
- expect(skeleton.dirty).toBe(false);
-
- skeleton.dispose();
- expect(skeleton.getFontLocale()).toBeNull();
- });
-});
+class TestSlideUnit extends UnitModel {
+ override type = UniverInstanceType.UNIVER_SLIDE;
+ override name$ = new BehaviorSubject('');
+ private _rev = 1;
+
+ constructor(private readonly _snapshot: { id: string; name: string }) {
+ super();
+ this.name$.next(_snapshot.name);
+ this.disposeWithMe(() => this.name$.complete());
+ }
+
+ override getUnitId() { return this._snapshot.id; }
+ override getSnapshot() { return this._snapshot; }
+ override getRev() { return this._rev; }
+ override incrementRev() { this._rev++; }
+ override setRev(rev: number) { this._rev = rev; }
+ override setName(name: string) {
+ this._snapshot.name = name;
+ this.name$.next(name);
+ }
+}
+
+class TestSlidesPlugin extends Plugin {
+ static override pluginName = 'TEST_SLIDES';
+ static override type = UniverInstanceType.UNIVER_SLIDE;
+
+ constructor(@Inject(Injector) protected readonly _injector: Injector) {
+ super();
+ }
+
+ override onStarting(): void {
+ this.disposeWithMe(this._injector.get(IUniverInstanceService).registerCtorForType(
+ UniverInstanceType.UNIVER_SLIDE,
+ TestSlideUnit
+ ));
+ }
+}
describe('Univer', () => {
it('should apply constructor config and expose locale/config methods', () => {
@@ -131,21 +155,34 @@ describe('Univer', () => {
expect(activeCallback).toHaveBeenCalledTimes(1);
});
- it('should delegate plugin registration for tuple-style APIs and support parent injector', () => {
- const parentInjector = new Injector([]);
+ it('creates slide units using the constructor registered when the plugin starts', () => {
+ const parentInjector = new Injector();
const univer = new Univer({}, parentInjector);
- const registerPluginSpy = vi
- .spyOn((univer as any)._pluginService, 'registerPlugin')
- .mockImplementation(() => undefined);
- univer.registerPlugins([
- [class FakePluginA {} as never, { enabled: true }],
- [class FakePluginB {} as never],
- ] as never);
+ try {
+ univer.registerPlugins([[TestSlidesPlugin]]);
+ const slide = univer.createUnit<{ id: string; name: string }, TestSlideUnit>(
+ UniverInstanceType.UNIVER_SLIDE,
+ { id: 'slide-1', name: 'Presentation' }
+ );
+
+ expect(slide).toBeInstanceOf(TestSlideUnit);
+ expect(slide.getSnapshot()).toEqual({ id: 'slide-1', name: 'Presentation' });
+ expect(univer.__getInjector().get(IUniverInstanceService).getUnit('slide-1')).toBe(slide);
+ } finally {
+ univer.dispose();
+ parentInjector.dispose();
+ }
+ });
- expect(registerPluginSpy).toHaveBeenCalledTimes(2);
+ it('rejects slide creation when no plugin provides the model', () => {
+ const univer = new Univer();
- registerPluginSpy.mockRestore();
- univer.dispose();
+ try {
+ expect(() => univer.createUnit(UniverInstanceType.UNIVER_SLIDE, { id: 'slide-1' }))
+ .toThrow(`[Univer]: No constructor registered for unit type ${UniverInstanceType.UNIVER_SLIDE}.`);
+ } finally {
+ univer.dispose();
+ }
});
});
diff --git a/packages/core/src/slides/slide-data-model.ts b/packages/core/src/slides/slide-data-model.ts
deleted file mode 100644
index 8baeefd389..0000000000
--- a/packages/core/src/slides/slide-data-model.ts
+++ /dev/null
@@ -1,46 +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 { Observable } from 'rxjs';
-import { UnitModel } from '../common/unit';
-
-export class SlideDataModel extends UnitModel {
- override type: number;
- override getUnitId(): string {
- throw new Error('Method not implemented.');
- }
-
- override name$: Observable<string>;
- override setName(name: string): void {
- throw new Error('Method not implemented.');
- }
-
- override getSnapshot(): object {
- throw new Error('Method not implemented.');
- }
-
- override getRev(): number {
- throw new Error('Method not implemented.');
- }
-
- override incrementRev(): void {
- throw new Error('Method not implemented.');
- }
-
- override setRev(rev: number): void {
- throw new Error('Method not implemented.');
- }
-}
diff --git a/packages/core/src/types/enum/place-holder-type.ts b/packages/core/src/types/enum/place-holder-type.ts
deleted file mode 100644
index bb0e05b39b..0000000000
--- a/packages/core/src/types/enum/place-holder-type.ts
+++ /dev/null
@@ -1,35 +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 enum PlaceholderType {
- NONE, //Default value, signifies it is not a placeholder.
- BODY, //Body text.
- CHART, //Chart or graph.
- CLIP_ART, //Clip art image.
- CENTERED_TITLE, //Title centered.
- DIAGRAM, //Diagram.
- DATE_AND_TIME, //Date and time.
- FOOTER, //Footer text.
- HEADER, //Header text.
- MEDIA, //Multimedia.
- OBJECT, //Any content type.
- PICTURE, //Picture.
- SLIDE_NUMBER, //Number of a slide.
- SUBTITLE, //Subtitle.
- TABLE, //Table.
- TITLE, //Slide title.
- SLIDE_IMAGE, //Slide image.
-}
diff --git a/packages/core/src/types/interfaces/i-document-data.ts b/packages/core/src/types/interfaces/i-document-data.ts
index 2a341066fe..5224634caf 100644
--- a/packages/core/src/types/interfaces/i-document-data.ts
+++ b/packages/core/src/types/interfaces/i-document-data.ts
@@ -1063,23 +1063,8 @@ export interface IDocDrawingPosition {
flipX?: boolean;
/** Vertical flip persisted with the document drawing transform. */
flipY?: boolean;
- // Union field properties can be only one of the following:
- // shapeProperties?: IShapeProperties;
- // chartProperties?: IChartProperties;
- // imageProperties?: IImageProperties;
}
-/**
- * ChartProperties
- */
-export interface IChartProperties {}
-
-// export enum BulletType {
-// NONE,
-// ORDERED_LIST,
-// UNORDERED_LIST,
-// }
-
/**
* Properties of text style
*/
diff --git a/packages/core/src/types/interfaces/i-image-properties.ts b/packages/core/src/types/interfaces/i-image-properties.ts
deleted file mode 100644
index 7e804c522c..0000000000
--- a/packages/core/src/types/interfaces/i-image-properties.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.
- */
-
-export interface IImageProperties {
- contentUrl: string;
- sourceUrl?: string;
- brightness?: number;
- contrast?: number;
- transparency?: number;
- cropProperties?: ICropProperties;
- angle?: number;
-}
-
-/**
- * Properties of crop image
- */
-export interface ICropProperties {
- offsetLeft: number;
- offsetRight: number;
- offsetTop: number;
- offsetBottom: number;
- angle: number;
-}
diff --git a/packages/core/src/types/interfaces/i-placeholder.ts b/packages/core/src/types/interfaces/i-placeholder.ts
deleted file mode 100644
index 4e1c80227f..0000000000
--- a/packages/core/src/types/interfaces/i-placeholder.ts
+++ /dev/null
@@ -1,23 +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 { PlaceholderType } from '../enum/place-holder-type';
-
-export interface IPlaceholder {
- type: PlaceholderType;
- index: number;
- parentObjectId: string;
-}
diff --git a/packages/core/src/types/interfaces/i-shape-properties.ts b/packages/core/src/types/interfaces/i-shape-properties.ts
deleted file mode 100644
index 4956649fee..0000000000
--- a/packages/core/src/types/interfaces/i-shape-properties.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 { BorderStyleTypes } from '../enum/border-style-types';
-import type { IColorStyle } from './i-style-data';
-
-/**
- * ShapeProperties
- */
-export interface IShapeProperties {
- shapeBackgroundFill: IColorStyle;
- radius?: number;
- outline?: IOutline;
-}
-
-export interface IOutline {
- outlineFill: IColorStyle;
- weight: number;
- dashStyle?: BorderStyleTypes;
-}
diff --git a/packages/core/src/types/interfaces/index.ts b/packages/core/src/types/interfaces/index.ts
index f06addefbc..a3e6a9e9ae 100644
--- a/packages/core/src/types/interfaces/index.ts
+++ b/packages/core/src/types/interfaces/index.ts
@@ -17,9 +17,6 @@
export * from './i-document-data';
export * from './i-document-data-interceptor';
export * from './i-drawing';
-export * from './i-image-properties';
export * from './i-mention';
export * from './i-need-check-disposable';
-export * from './i-placeholder';
-export * from './i-shape-properties';
export * from './i-style-data';
diff --git a/packages/core/src/univer.ts b/packages/core/src/univer.ts
index f51d4df854..70cfa8b6e4 100644
--- a/packages/core/src/univer.ts
+++ b/packages/core/src/univer.ts
@@ -20,7 +20,7 @@ import type { UnitModel } from './common/unit';
import type { LogLevel } from './services/log/log.service';
import type { DependencyOverride } from './services/plugin/plugin-override';
import type { Plugin, PluginCtor } from './services/plugin/plugin.service';
-import type { ILocales } from './shared';
+import type { ILocales } from './shared/locale';
import type { LocaleType } from './types/enum/locale-type';
import { Injector, touchDependencies } from './common/di';
import { UniverInstanceType } from './common/unit';
@@ -56,9 +56,8 @@ import {
UNDO_REDO_HISTORY_LIMIT_CONFIG_KEY,
} from './services/undoredo/undoredo.service';
import { UserManagerService } from './services/user-manager/user-manager.service';
-import { DisposableCollection, toDisposable } from './shared';
+import { DisposableCollection, toDisposable } from './shared/lifecycle';
import { Workbook } from './sheets/workbook';
-import { SlideDataModel } from './slides/slide-data-model';
export interface IUniverConfig {
/**
@@ -202,7 +201,6 @@ export class Univer implements IDisposable {
private _init(injector: Injector): void {
this._univerInstanceService.registerCtorForType(UniverInstanceType.UNIVER_SHEET, Workbook);
this._univerInstanceService.registerCtorForType(UniverInstanceType.UNIVER_DOC, DocumentDataModel);
- this._univerInstanceService.registerCtorForType(UniverInstanceType.UNIVER_SLIDE, SlideDataModel);
const univerInstanceService = injector.get(IUniverInstanceService) as UniverInstanceService;
univerInstanceService.__setCreateHandler(
diff --git a/packages/engine-render/src/base-object.ts b/packages/engine-render/src/base-object.ts
index 7d8ff23963..039450c2e8 100644
--- a/packages/engine-render/src/base-object.ts
+++ b/packages/engine-render/src/base-object.ts
@@ -15,6 +15,7 @@
*/
import type { IGroupBaseBound, ITransformState, Nullable } from '@univerjs/core';
+import { Disposable, EventSubject } from '@univerjs/core';
import type { IDragEvent, IMouseEvent, IPointerEvent, IWheelEvent } from './basics/i-events';
import type { IObjectFullState, ITransformChangeState } from './basics/interfaces';
import type { ITransformerConfig } from './basics/transformer-config';
@@ -23,9 +24,8 @@ import type { UniverRenderingContext } from './context';
import type { Engine } from './engine';
import type { Layer } from './layer';
import type { Scene } from './scene';
-import { Disposable, EventSubject } from '@univerjs/core';
-import { getRenderTransformBaseOnParentBound, getRotatedBoundInGroup } from './basics';
import { CURSOR_TYPE, RENDER_CLASS_TYPE } from './basics/const';
+import { getRenderTransformBaseOnParentBound, getRotatedBoundInGroup } from './basics/group-transform';
import { TRANSFORM_CHANGE_OBSERVABLE_TYPE } from './basics/interfaces';
import { generateRandomKey, toPx } from './basics/tools';
import { Transform } from './basics/transform';
@@ -47,8 +47,7 @@ export const BASE_OBJECT_ARRAY = [
export enum ObjectType {
UNKNOWN,
- RICH_TEXT,
- SHAPE,
+ SHAPE = 2,
IMAGE,
RECT,
CIRCLE,
diff --git a/packages/engine-render/src/basics/__tests__/quick-event.spec.ts b/packages/engine-render/src/basics/__tests__/quick-event.spec.ts
deleted file mode 100644
index a9d4f438e6..0000000000
--- a/packages/engine-render/src/basics/__tests__/quick-event.spec.ts
+++ /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 { describe, expect, it, vi } from 'vitest';
-import { attachObjectHover } from '../quick-event';
-
-function createEventSubject() {
- let listener: ((evt: unknown) => void) | undefined;
- return {
- subscribeEvent: vi.fn((callback: (evt: unknown) => void) => {
- listener = callback;
- }),
- emit: (evt: unknown) => listener?.(evt),
- };
-}
-
-describe('quick event helpers', () => {
- it('binds pointer enter and leave events to hover callbacks with the target object', () => {
- const enter = createEventSubject();
- const leave = createEventSubject();
- const object = {
- onPointerEnter$: enter,
- onPointerLeave$: leave,
- };
- const hoverIn = vi.fn();
- const hoverOut = vi.fn();
-
- attachObjectHover(object as never, hoverIn, hoverOut);
-
- const enterEvent = { offsetX: 10, offsetY: 20 };
- const leaveEvent = { offsetX: 30, offsetY: 40 };
- enter.emit(enterEvent);
- leave.emit(leaveEvent);
-
- expect(enter.subscribeEvent).toHaveBeenCalledTimes(1);
- expect(leave.subscribeEvent).toHaveBeenCalledTimes(1);
- expect(hoverIn).toHaveBeenCalledWith(object, enterEvent);
- expect(hoverOut).toHaveBeenCalledWith(object, leaveEvent);
- });
-});
diff --git a/packages/engine-render/src/basics/quick-event.ts b/packages/engine-render/src/basics/quick-event.ts
deleted file mode 100644
index e482ffaa4e..0000000000
--- a/packages/engine-render/src/basics/quick-event.ts
+++ /dev/null
@@ -1,32 +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 { BaseObject } from '../base-object';
-import type { IMouseEvent, IPointerEvent } from './i-events';
-
-export function attachObjectHover(
- o: BaseObject,
- hoverIn: (o: any, evt: IPointerEvent | IMouseEvent) => void,
- hoverOut: (o: any, evt: IPointerEvent | IMouseEvent) => void
-) {
- o.onPointerEnter$.subscribeEvent((evt) => {
- hoverIn(o, evt);
- });
-
- o.onPointerLeave$.subscribeEvent((evt) => {
- hoverOut(o, evt);
- });
-}
diff --git a/packages/engine-render/src/components/index.ts b/packages/engine-render/src/components/index.ts
deleted file mode 100644
index 6041d4b40d..0000000000
--- a/packages/engine-render/src/components/index.ts
+++ /dev/null
@@ -1,21 +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 * from './component';
-export * from './extension';
-export * from './sheets';
-export { RENDER_RAW_FORMULA_KEY } from './sheets/sheet.render-skeleton';
-export * from './slides';
diff --git a/packages/engine-render/src/components/slides/__tests__/slide.spec.ts b/packages/engine-render/src/components/slides/__tests__/slide.spec.ts
deleted file mode 100644
index 56da8e21bd..0000000000
--- a/packages/engine-render/src/components/slides/__tests__/slide.spec.ts
+++ /dev/null
@@ -1,126 +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 { afterEach, beforeEach, describe, expect, it } from 'vitest';
-import { setupRenderTestEnv } from '../../../__tests__/render-test-utils';
-import { Canvas } from '../../../canvas';
-import { Engine } from '../../../engine';
-import { MAIN_VIEW_PORT_KEY, Scene } from '../../../scene';
-import { Rect } from '../../../shape/rect';
-import { Viewport } from '../../../viewport';
-import { Slide, SLIDE_NAVIGATION_KEY } from '../slide';
-
-function createPageScene(engine: Engine, key: string, color: string) {
- const scene = new Scene(key, engine);
- scene.transformByState({
- width: 640,
- height: 360,
- scaleX: 1,
- scaleY: 1,
- });
- new Viewport(MAIN_VIEW_PORT_KEY, scene, {
- left: 0,
- top: 0,
- width: 420,
- height: 240,
- active: true,
- allowCache: true,
- bufferEdgeX: 8,
- bufferEdgeY: 6,
- });
- scene.addObject(new Rect(`${key}-rect`, {
- left: 24,
- top: 24,
- width: 120,
- height: 70,
- fill: color,
- stroke: '#222222',
- }), 1);
- return scene;
-}
-
-describe('slide', () => {
- let restoreEnv: () => void;
- let container: HTMLDivElement;
- let engine: Engine;
-
- beforeEach(() => {
- restoreEnv = setupRenderTestEnv().restore;
- container = document.createElement('div');
- container.style.width = '760px';
- container.style.height = '460px';
- document.body.appendChild(container);
- engine = new Engine('slide-engine', { elementWidth: 700, elementHeight: 420, dpr: 1 });
- engine.mount(container, false);
- });
-
- afterEach(() => {
- engine.dispose();
- restoreEnv();
- container.remove();
- document.body.innerHTML = '';
- });
-
- it('changes pages through navigation objects and supports thumbnail rendering', () => {
- const slide = new Slide('slide-main', {
- width: 640,
- height: 360,
- } as any);
- slide.enableNav();
-
- const pageA = createPageScene(engine, 'page-a', '#cc8844');
- const pageB = createPageScene(engine, 'page-b', '#4488cc');
- slide.addPageScene(pageA);
- slide.addPageScene(pageB);
-
- expect(slide.hasPage('page-a')).toBeTruthy();
- expect(slide.hasPage('page-b')).toBeTruthy();
-
- slide.activeFirstPage();
- expect(slide.getActiveSubScene()?.sceneKey).toBe('page-a');
-
- slide.showNav();
- slide.hiddenNav();
- slide.showNav();
-
- const changed: string[] = [];
- slide.slideChangePageByNavigation$.subscribeEvent((key) => {
- if (key) {
- changed.push(key);
- }
- });
-
- const rightArrow = slide.getActiveSubScene()?.getObject(SLIDE_NAVIGATION_KEY.RIGHT) as any;
- expect(rightArrow).toBeTruthy();
- rightArrow.onPointerDown$.emitEvent({} as any);
- expect(slide.getActiveSubScene()?.sceneKey).toBe('page-b');
-
- const leftArrow = slide.getActiveSubScene()?.getObject(SLIDE_NAVIGATION_KEY.LEFT) as any;
- expect(leftArrow).toBeTruthy();
- leftArrow.onPointerDown$.emitEvent({} as any);
- expect(slide.getActiveSubScene()?.sceneKey).toBe('page-a');
- expect(changed).toContain('page-b');
- expect(changed).toContain('page-a');
-
- const thumbCanvas = new Canvas({ width: 320, height: 180, pixelRatio: 1 });
- slide.renderToThumb(thumbCanvas.getContext(), 'page-a', 0.5, 0.5);
- thumbCanvas.dispose();
-
- slide.disableNav();
- slide.removeNavigation();
- slide.dispose();
- });
-});
diff --git a/packages/engine-render/src/components/slides/index.ts b/packages/engine-render/src/components/slides/index.ts
deleted file mode 100644
index 38ff198729..0000000000
--- a/packages/engine-render/src/components/slides/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 * from './slide';
diff --git a/packages/engine-render/src/components/slides/slide.ts b/packages/engine-render/src/components/slides/slide.ts
deleted file mode 100644
index 84664b9b06..0000000000
--- a/packages/engine-render/src/components/slides/slide.ts
+++ /dev/null
@@ -1,225 +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 { IMouseEvent, IPointerEvent } from '../../basics/i-events';
-import type { UniverRenderingContext } from '../../context';
-import type { Scene } from '../../scene';
-import { COLORS, EventSubject } from '@univerjs/core';
-import { CURSOR_TYPE } from '../../basics/const';
-import { attachObjectHover } from '../../basics/quick-event';
-import { getColor } from '../../basics/tools';
-import { SceneViewer } from '../../scene-viewer';
-import { Path } from '../../shape/path';
-
-export enum SLIDE_NAVIGATION_KEY {
- LEFT = '__slideNavigationLeft__',
- RIGHT = '__slideNavigationRight__',
-}
-
-const arrowPath =
- 'M512 1024C229.248 1024 0 794.752 0 512S229.248 0 512 0s512 229.248 512 512-229.248 512-512 512z m200.746667-478.506667l1.749333-1.664 30.165333-30.165333-330.496-330.581333a42.837333 42.837333 0 0 0-60.288 0 42.538667 42.538667 0 0 0 0 60.330666l270.08 270.165334-270.08 269.952a42.496 42.496 0 0 0 0 60.288c16.64 16.64 43.861333 16.469333 60.288 0.042666l298.581334-298.368z';
-
-export class Slide extends SceneViewer {
- slideChangePageByNavigation$ = new EventSubject<Nullable<string>>();
-
- subSceneChanged$ = new EventSubject<Scene>();
-
- private _navigationEnabled = false;
-
- activeFirstPage() {
- const scenes = this.getSubScenes();
- const firstKey = scenes.keys().next().value;
- if (firstKey == null) {
- return;
- }
- this.changePage(firstKey);
- }
-
- /**
- * add pageScene to this._subScenes
- * @param pageScene
- */
- addPageScene(pageScene: Scene) {
- const key = pageScene.sceneKey;
- if (!this.getSubScene(key)) {
- this.addSubScene(pageScene);
- }
- this.addNavigation();
- this.subSceneChanged$.emitEvent(pageScene);
- }
-
- changePage(id?: string) {
- if (id === null) {
- return;
- }
- this.removeNavigation();
- this.activeSubScene(id as string);
- this.addNavigation();
- }
-
- hasPage(key: string) {
- return this.getSubScene(key);
- }
-
- addNavigation() {
- const scene = this.getActiveSubScene();
- if (scene == null || this._navigationEnabled === false) {
- return;
- }
-
- const leftArrow = new Path(SLIDE_NAVIGATION_KEY.LEFT, {
- data: arrowPath,
- width: 60,
- height: 60,
- left: 90,
- top: (this.height - 30) / 2,
- fill: this._getArrowColor(),
- flipX: true,
- });
-
- const rightArrow = new Path(SLIDE_NAVIGATION_KEY.RIGHT, {
- data: arrowPath,
- width: 60,
- height: 60,
- left: this.width - 90,
- top: (this.height - 30) / 2,
- fill: this._getArrowColor(),
- });
-
- const hoverIn = (o: Path, evt: IPointerEvent | IMouseEvent) => {
- o.setCursor(CURSOR_TYPE.POINTER);
- o.setProps({
- fill: this._getArrowColor(true),
- });
- };
-
- const hoverOut = (o: Path, evt: IPointerEvent | IMouseEvent) => {
- o.setCursor(CURSOR_TYPE.DEFAULT);
- o.setProps({
- fill: this._getArrowColor(),
- });
- };
-
- attachObjectHover(leftArrow, hoverIn, hoverOut);
- attachObjectHover(rightArrow, hoverIn, hoverOut);
-
- this._addNavTrigger(leftArrow, rightArrow);
-
- scene.addObjects([leftArrow, rightArrow], 7);
- }
-
- removeNavigation() {
- const scene = this.getActiveSubScene();
- if (scene == null || this._navigationEnabled === false) {
- return;
- }
-
- scene.getObject(SLIDE_NAVIGATION_KEY.LEFT)?.dispose();
- scene.getObject(SLIDE_NAVIGATION_KEY.RIGHT)?.dispose();
- }
-
- enableNav() {
- this._navigationEnabled = true;
- }
-
- disableNav() {
- this._navigationEnabled = false;
- }
-
- hiddenNav() {
- const scene = this.getActiveSubScene();
- if (scene == null || this._navigationEnabled === false) {
- return;
- }
-
- scene.getObject(SLIDE_NAVIGATION_KEY.LEFT)?.hide();
- scene.getObject(SLIDE_NAVIGATION_KEY.RIGHT)?.hide();
- }
-
- showNav() {
- const scene = this.getActiveSubScene();
- if (scene == null || this._navigationEnabled === false) {
- return;
- }
-
- scene.getObject(SLIDE_NAVIGATION_KEY.LEFT)?.show();
- scene.getObject(SLIDE_NAVIGATION_KEY.RIGHT)?.show();
- }
-
- renderToThumb(mainCtx: UniverRenderingContext, pageId: string, scaleX: number = 1, scaleY: number = 1) {
- const scene = this.getSubScene(pageId);
- if (scene == null) {
- return;
- }
- mainCtx.save();
- mainCtx.scale(scaleX, scaleY);
- scene.makeDirtyNoParent(true).render(mainCtx);
- mainCtx.restore();
- }
-
- private _getSubScenesIndex(key?: string) {
- if (key == null) {
- return;
- }
-
- const subScenes = Array.from(this.getSubScenes());
- const subScenesLen = subScenes.length;
- let currentIndex = 0;
- for (let i = 0; i < subScenesLen; i++) {
- const [sceneKey] = subScenes[i];
- if (key === sceneKey) {
- currentIndex = i;
- break;
- }
- }
-
- let next = currentIndex + 1;
- let prev = currentIndex - 1;
-
- next = next >= subScenesLen ? 0 : next;
-
- prev = prev < 0 ? subScenesLen - 1 : prev;
-
- return {
- nextScene: subScenes[next][1],
- previousScene: subScenes[prev][1],
- };
- }
-
- private _addNavTrigger(leftArrow: Path, rightArrow: Path) {
- leftArrow.onPointerDown$.subscribeEvent(() => {
- const result = this._getSubScenesIndex(this.getActiveSubScene()?.sceneKey);
- const prevKey = result?.previousScene.sceneKey;
- this.changePage(prevKey);
- this.slideChangePageByNavigation$.emitEvent(prevKey);
- });
-
- rightArrow.onPointerDown$.subscribeEvent(() => {
- const result = this._getSubScenesIndex(this.getActiveSubScene()?.sceneKey);
- const nextKey = result?.nextScene.sceneKey;
- this.changePage(nextKey);
- this.slideChangePageByNavigation$.emitEvent(nextKey);
- });
- }
-
- private _getArrowColor(isHover = false) {
- if (isHover) {
- return getColor(COLORS.white, 0.8);
- }
- return getColor(COLORS.white, 0.5);
- }
-}
diff --git a/packages/engine-render/src/index.ts b/packages/engine-render/src/index.ts
index 20bf9053a6..4a44c73bec 100644
--- a/packages/engine-render/src/index.ts
+++ b/packages/engine-render/src/index.ts
@@ -42,7 +42,7 @@ export {
export type { IResolvedDrawingShadow } from './basics/drawing-effect';
export { getOffsetRectForDom } from './basics/position';
export * from './canvas';
-export * from './components';
+export * from './components/component';
export type { DocsCustomBlockRenderViewportProvider, IDocsCustomBlockRenderViewport, IDocsCustomBlockRenderViewportInput } from './components/docs/custom-block-render-viewport';
export { getDocsCustomBlockRenderViewport, setDocsCustomBlockRenderViewportProvider } from './components/docs/custom-block-render-viewport';
export {
@@ -122,7 +122,28 @@ export { DataStreamTreeNode } from './components/docs/view-model/data-stream-tre
export { DocumentViewModel } from './components/docs/view-model/document-view-model';
export { DocumentEditArea } from './components/docs/view-model/document-view-model';
export { parseDataStreamToTree } from './components/docs/view-model/document-view-model';
-export { DEFAULT_PADDING_DATA } from './components/sheets/sheet.render-skeleton';
+export * from './components/extension';
+export * from './components/sheets/column-header';
+export * from './components/sheets/constants';
+export * from './components/sheets/extensions/background';
+export * from './components/sheets/extensions/border';
+export * from './components/sheets/extensions/column-header-layout';
+export * from './components/sheets/extensions/custom';
+export * from './components/sheets/extensions/font';
+export * from './components/sheets/extensions/marker';
+export * from './components/sheets/extensions/row-header-layout';
+export * from './components/sheets/extensions/sheet-extension';
+export * from './components/sheets/interfaces';
+export * from './components/sheets/row-header';
+export * from './components/sheets/sheet-component';
+export * from './components/sheets/sheet.render-skeleton';
+export { RENDER_RAW_FORMULA_KEY } from './components/sheets/sheet.render-skeleton';
+export * from './components/sheets/spreadsheet';
+export { calculateCellImageRect } from './components/sheets/util';
+export type { ICellImageRectConfig } from './components/sheets/util';
+export * from './components/sheets/watermark/type';
+export * from './components/sheets/watermark/util';
+export * from './components/sheets/watermark/watermark-layer';
export type { IUniverEngineRenderConfig } from './config/config';
export * from './context';
export * from './custom';
diff --git a/packages/engine-render/src/render-manager/render-manager.service.ts b/packages/engine-render/src/render-manager/render-manager.service.ts
index 09e8b0a95d..fdefdc641c 100644
--- a/packages/engine-render/src/render-manager/render-manager.service.ts
+++ b/packages/engine-render/src/render-manager/render-manager.service.ts
@@ -23,11 +23,6 @@ import type {
UnitModel,
} from '@univerjs/core';
import type { Observable } from 'rxjs';
-import type { BaseObject } from '../base-object';
-import type { DocComponent } from '../components/docs/doc-component';
-import type { SheetComponent } from '../components/sheets/sheet-component';
-import type { Slide } from '../components/slides/slide';
-import type { IRender } from './render-unit';
import {
createIdentifier,
Disposable,
@@ -40,11 +35,15 @@ import {
UniverInstanceType,
} from '@univerjs/core';
import { merge, Subject } from 'rxjs';
+import type { BaseObject } from '../base-object';
+import type { DocComponent } from '../components/docs/doc-component';
+import type { SheetComponent } from '../components/sheets/sheet-component';
+import type { IRender } from './render-unit';
import { Engine } from '../engine';
import { Scene } from '../scene';
import { RenderUnit } from './render-unit';
-export type RenderComponentType = SheetComponent | DocComponent | Slide | BaseObject;
+export type RenderComponentType = SheetComponent | DocComponent | BaseObject;
export interface IRenderManagerService extends IDisposable {
addRender(unitId: string, renderer: IRender): void;
@@ -378,8 +377,7 @@ function getRenderDependencyIdentifierKey(identifier: DependencyIdentifier<unkno
export const IRenderManagerService = createIdentifier<IRenderManagerService>('engine-render.render-manager.service');
export function isDisposable(thing: unknown): thing is IDisposable {
- // eslint-disable-next-line ts/no-explicit-any
- return !!thing && typeof (thing as any).dispose === 'function';
+ return !!thing && typeof (thing as Partial<IDisposable>).dispose === 'function';
}
export function getCurrentTypeOfRenderer(
diff --git a/packages/engine-render/src/shape/__tests__/rich-text.spec.ts b/packages/engine-render/src/shape/__tests__/rich-text.spec.ts
deleted file mode 100644
index 2bba1ed5d1..0000000000
--- a/packages/engine-render/src/shape/__tests__/rich-text.spec.ts
+++ /dev/null
@@ -1,183 +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 { BooleanNumber } from '@univerjs/core';
-import { describe, expect, it, vi } from 'vitest';
-import { RichText } from '../rich-text';
-
-const h = vi.hoisted(() => ({
- documentSkeletonCreateMock: vi.fn(),
- documentViewModelCtorMock: vi.fn(),
- documentsCtorMock: vi.fn(),
- documentsRenderMock: vi.fn(),
- updatePageSizeMock: vi.fn(),
- makeDirtyMock: vi.fn(),
- calculateMock: vi.fn(),
- skeletonData: {
- pages: [
- { width: 120, height: 40 },
- ],
- } as any,
-}));
-
-vi.mock('../../components/docs/view-model/document-view-model', () => ({
- DocumentViewModel: class {
- constructor(model: any) {
- h.documentViewModelCtorMock(model);
- }
- },
-}));
-
-vi.mock('../../components/docs/layout/doc-skeleton', () => ({
- DocumentSkeleton: {
- create: (viewModel: any, localeService: any) => {
- h.documentSkeletonCreateMock(viewModel, localeService);
- return {
- getViewModel: () => ({
- getDataModel: () => ({
- updateDocumentDataPageSize: (...args: any[]) => h.updatePageSizeMock(...args),
- }),
- }),
- getSkeletonData: () => h.skeletonData,
- makeDirty: (...args: any[]) => h.makeDirtyMock(...args),
- calculate: (...args: any[]) => h.calculateMock(...args),
- };
- },
- },
-}));
-
-vi.mock('../../components/docs/document', () => ({
- Documents: class {
- constructor(key: string, skeleton: any, config: any) {
- h.documentsCtorMock(key, skeleton, config);
- }
-
- render(ctx: any) {
- h.documentsRenderMock(ctx);
- }
- },
-}));
-
-function createCtx() {
- return {
- save: vi.fn(),
- restore: vi.fn(),
- transform: vi.fn(),
- } as any;
-}
-
-describe('rich text shape', () => {
- it('builds document data from plain text and exposes getters/json', () => {
- h.skeletonData = { pages: [{ width: 120, height: 40 }] } as any;
- const rich = new RichText({} as any, 'rt-1', {
- text: 'hello',
- fs: 14,
- ff: 'Arial',
- it: BooleanNumber.FALSE,
- bl: BooleanNumber.TRUE,
- zIndex: 2,
- left: 0,
- top: 0,
- width: 120,
- height: 40,
- } as any);
-
- expect(rich.fs).toBe(14);
- expect(rich.text).toContain('hello');
- expect(rich.documentData.body?.dataStream).toContain('hello');
- expect(h.documentSkeletonCreateMock).toHaveBeenCalled();
- expect(h.documentsCtorMock).toHaveBeenCalled();
- expect(rich.getDocsSkeletonPageSize()).toEqual({ width: 120, height: 40 });
-
- rich.setProps({ left: 10, top: 20, zIndex: 9, fs: 99, text: 'ignore' } as any);
- expect((rich as any)._left).toBe(10);
- expect(rich.fs).toBe(14);
-
- const json = rich.toJson();
- expect(json).toEqual(expect.objectContaining({
- fs: 14,
- text: expect.any(String),
- }));
- });
-
- it('covers render branches and draw delegation', () => {
- const rich = new RichText({} as any, 'rt-2', {
- text: 'abc',
- fs: 12,
- zIndex: 1,
- width: 100,
- height: 30,
- } as any);
- const ctx = createCtx();
-
- const makeDirtySpy = vi.spyOn(rich, 'makeDirty');
- (rich as any)._visible = false;
- rich.render(ctx);
- expect(makeDirtySpy).toHaveBeenCalledWith(false);
-
- (rich as any)._visible = true;
- vi.spyOn(rich, 'isRender').mockReturnValue(true);
- (rich as any)._strokeWidth = 1;
- (rich as any).width = 10;
- (rich as any).height = 10;
- rich.render(ctx, {
- viewBound: {
- left: 100,
- right: 200,
- top: 100,
- bottom: 200,
- },
- } as any);
- expect(h.documentsRenderMock).not.toHaveBeenCalled();
-
- (rich.isRender as any).mockReturnValue(false);
- rich.render(ctx);
- expect(ctx.save).toHaveBeenCalled();
- expect(ctx.transform).toHaveBeenCalled();
- expect(ctx.restore).toHaveBeenCalled();
- expect(h.documentsRenderMock).toHaveBeenCalled();
- });
-
- it('refreshes skeleton/documents and resizes to content', () => {
- const rich = new RichText({} as any, 'rt-3', {
- text: 'refresh',
- fs: 12,
- zIndex: 1,
- width: 80,
- height: 20,
- } as any);
-
- const transformSpy = vi.spyOn(rich, 'transformByState');
- const createCountBefore = h.documentSkeletonCreateMock.mock.calls.length;
-
- rich.refreshDocumentByDocData();
- expect(h.documentSkeletonCreateMock.mock.calls.length).toBeGreaterThan(createCountBefore);
- expect(h.updatePageSizeMock).toHaveBeenCalled();
- expect(h.calculateMock).toHaveBeenCalled();
-
- h.skeletonData = { pages: [{ width: 80, height: 66 }] } as any;
- rich.resizeToContentSize();
- expect(transformSpy).toHaveBeenCalledWith(expect.objectContaining({ height: 66 }));
-
- h.skeletonData = { pages: [{ width: 0, height: 0 }] } as any;
- const callCount = transformSpy.mock.calls.length;
- rich.resizeToContentSize();
- expect(transformSpy.mock.calls.length).toBe(callCount);
-
- (rich as any)._documentSkeleton = { getSkeletonData: () => null };
- expect(rich.getDocsSkeletonPageSize()).toBeUndefined();
- });
-});
diff --git a/packages/engine-render/src/shape/index.ts b/packages/engine-render/src/shape/index.ts
index 3134b33476..2e51818cc2 100644
--- a/packages/engine-render/src/shape/index.ts
+++ b/packages/engine-render/src/shape/index.ts
@@ -20,11 +20,11 @@ export * from './control';
export * from './dashedrect';
export * from './drawing';
export * from './image';
-export { type ILineProps, Line } from './line';
+export type { ILineProps } from './line';
+export { Line } from './line';
export * from './path';
export * from './rect';
export * from './regular-polygon';
-export * from './rich-text';
export * from './scroll-bar';
export * from './shape';
export * from './text';
diff --git a/packages/engine-render/src/shape/rich-text.ts b/packages/engine-render/src/shape/rich-text.ts
deleted file mode 100644
index c95eca5c71..0000000000
--- a/packages/engine-render/src/shape/rich-text.ts
+++ /dev/null
@@ -1,388 +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 {
- IBorderData,
- IColorStyle,
- IDocumentData,
- IStyleBase,
- ITextDecoration,
- ITransformState,
- LocaleService,
- Nullable,
-} from '@univerjs/core';
-import type { BASE_OBJECT_ARRAY } from '../base-object';
-import type { IViewportInfo } from '../basics/vector2';
-import type { UniverRenderingContext } from '../context';
-import { BooleanNumber, DEFAULT_EMPTY_DOCUMENT_VALUE, DocumentDataModel } from '@univerjs/core';
-import { BaseObject, ObjectType } from '../base-object';
-import { TRANSFORM_CHANGE_OBSERVABLE_TYPE } from '../basics/interfaces';
-import { Documents } from '../components/docs/document';
-import { DocumentSkeleton } from '../components/docs/layout/doc-skeleton';
-import { DocumentViewModel } from '../components/docs/view-model/document-view-model';
-
-export interface IRichTextProps extends ITransformState, IStyleBase {
- text?: string;
- richText?: IDocumentData;
- zIndex: number;
- forceRender?: boolean;
-}
-
-export type RichtextObjectJSONType = {
- [key in typeof BASE_OBJECT_ARRAY[number]]: number;
-} & {
- text: string;
- fs: number;
- richText?: unknown;
-};
-export const RICHTEXT_OBJECT_ARRAY = ['text', 'richText', 'fs'];
-
-export class RichText extends BaseObject {
- private _documentData!: IDocumentData;
-
- private _documentSkeleton!: DocumentSkeleton;
-
- private _documents!: Documents;
-
- documentModel!: DocumentDataModel;
-
- /**
- * fontFamily
- */
- private _ff?: Nullable<string>;
-
- /**
- * fontSize
- * pt
- */
- private _fs?: number = 12;
-
- /**
- * italic
- * 0: false
- * 1: true
- */
- private _it?: BooleanNumber = BooleanNumber.FALSE;
-
- /**
- * bold
- * 0: false
- * 1: true
- */
- private _bl?: BooleanNumber = BooleanNumber.FALSE;
-
- /**
- * underline
- */
- private _ul?: ITextDecoration = {
- s: BooleanNumber.FALSE,
- };
-
- /**
- * strikethrough
- */
- private _st?: ITextDecoration = {
- s: BooleanNumber.FALSE,
- };
-
- /**
- * overline
- */
- private _ol?: ITextDecoration = {
- s: BooleanNumber.FALSE,
- };
-
- /**
- * background
- */
- private _bg?: Nullable<IColorStyle>;
-
- /**
- * border
- */
- private _bd?: Nullable<IBorderData>;
-
- /**
- * foreground
- */
- private _cl?: Nullable<IColorStyle>;
-
- override objectType = ObjectType.RICH_TEXT;
-
- constructor(
- private _localeService: LocaleService,
- key?: string,
- props?: IRichTextProps
- ) {
- super(key);
- if (props?.richText) {
- this._documentData = props.richText;
- } else if (props) {
- this._fs = props.fs;
- this._ff = props.ff;
- this._it = props.it;
- this._bl = props.bl;
- this._ul = props.ul;
- this._st = props.st;
- this._ol = props.ol;
- this._bg = props.bg;
- this._bd = props.bd;
- this._cl = props.cl;
-
- this._documentData = this._convertToDocumentData(props.text || '');
- }
-
- const docModel = this.documentModel = new DocumentDataModel(this._documentData);
- const docViewModel = new DocumentViewModel(docModel);
-
- this._documentSkeleton = DocumentSkeleton.create(docViewModel, this._localeService);
-
- this._documents = new Documents(`${this.oKey}_DOCUMENTS`, this._documentSkeleton, {
- pageMarginLeft: 0,
- pageMarginTop: 0,
- });
-
- this._initialProps(props);
-
- this.onTransformChange$.subscribeEvent((changeState) => {
- const { type } = changeState;
- if (type === TRANSFORM_CHANGE_OBSERVABLE_TYPE.resize || type === TRANSFORM_CHANGE_OBSERVABLE_TYPE.all) {
- docModel.updateDocumentDataPageSize(this.width);
- this._documentSkeleton.makeDirty(true);
- this._documentSkeleton.calculate();
- const size = this.getDocsSkeletonPageSize();
- this.height = size?.height || this.height;
- this._setTransForm();
-
- this.refreshDocumentByDocData();
- }
- });
- }
-
- get fs(): number {
- return this._fs!;
- }
-
- get text(): string {
- const textBody = this._documentData.body;
- if (!textBody) return '';
- const texts = [];
- if (textBody.textRuns) {
- for (const run of textBody.textRuns) {
- const st = run.st || 0;
- const ed = run.ed || 0;
- texts.push(textBody.dataStream.slice(st, ed));
- }
- }
- return texts.join('');
- }
-
- get documentData() {
- return this._documentData;
- }
-
- /**
- * get last page size
- */
- getDocsSkeletonPageSize() {
- const skeletonData = this._documentSkeleton?.getSkeletonData();
-
- if (!skeletonData) {
- return;
- }
- const { pages } = skeletonData;
- const lastPage = pages[pages.length - 1];
- const { width, height } = lastPage;
-
- return { width, height };
- }
-
- /**
- * this[`_${key}`] = props[key];
- * @param props
- */
- setProps(props?: IRichTextProps) {
- if (!props) {
- return;
- }
-
- const themeKeys = Object.keys(props);
- if (themeKeys.length === 0) {
- return;
- }
- themeKeys.forEach((key) => {
- // @ts-ignore
- if (props[key] === undefined) {
- return true;
- }
-
- if (RICHTEXT_OBJECT_ARRAY.indexOf(key) === -1) {
- // @ts-ignore
- this[`_${key}`] = props[key];
- }
- });
- this.makeDirty(true);
- return this;
- }
-
- override render(mainCtx: UniverRenderingContext, bounds?: IViewportInfo) {
- if (!this.visible) {
- this.makeDirty(false);
- return this;
- }
-
- // Temporarily ignore the on-demand display of elements within a group:this.isInGroup
- if (this.isRender(bounds)) {
- const { top, left, bottom, right } = bounds!.viewBound;
-
- if (
- this.width + this.strokeWidth < left ||
- right < 0 ||
- this.height + this.strokeWidth < top ||
- bottom < 0
- ) {
- // console.warn('ignore object', this);
- return this;
- }
- }
-
- const m = this.transform.getMatrix();
- mainCtx.save();
- mainCtx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
- this._draw(mainCtx);
- mainCtx.restore();
- this.makeDirty(false);
- return this;
- }
-
- override toJson(): RichtextObjectJSONType {
- const props: Record<string, any> = {};
- RICHTEXT_OBJECT_ARRAY.forEach((key) => {
- // @ts-ignore
- if (this[key]) {
- // @ts-ignore
- props[key] = this[key];
- }
- });
- return {
- ...super.toJson(),
- ...props,
- } as RichtextObjectJSONType;
- }
-
- protected _draw(ctx: UniverRenderingContext) {
- this._documents.render(ctx);
- }
-
- private _convertToDocumentData(text: string) {
- const contentLength = text.length;
- const documentData: IDocumentData = {
- id: 'd',
- body: {
- dataStream: `${text}${DEFAULT_EMPTY_DOCUMENT_VALUE}`,
- textRuns: [
- {
- ts: {
- fs: this._fs || 14,
- ff: this._ff,
- it: this._it,
- bl: this._bl,
- ul: this._ul,
- st: this._st,
- ol: this._ol,
- bg: this._bg,
- bd: this._bd,
- cl: this._cl,
- },
- st: 0,
- ed: contentLength,
- },
- ],
- },
- documentStyle: {
- pageSize: {
- width: Number.POSITIVE_INFINITY,
- height: Number.POSITIVE_INFINITY,
- },
- },
- };
-
- return documentData;
- }
-
- private _initialProps(props?: IRichTextProps) {
- this._documentSkeleton
- .getViewModel()
- .getDataModel()
- .updateDocumentDataPageSize(props?.width, props?.height);
-
- this._documentSkeleton.calculate();
-
- const contentSize = this.getDocsSkeletonPageSize();
-
- // this[pKey] = option[pKey]
- this.transformByState({
- width: contentSize?.width || 0,
- height: contentSize?.height || 0,
- left: props?.left || 0,
- top: props?.top || 0,
- angle: props?.angle,
- });
-
- // this[`_${key}`] = props[key];
- this.setProps(props);
-
- this.makeDirty(true);
- }
-
- /**
- * After changing editor size & end of editing, update skeleton of doc.
- */
- // TODO: This method should be invoked when _documentData changed.
- // _documentData changed ---> update _documentSkeleton & _documentSkeleton
- // now it is invoked when transformByState(change editor size) & end of editing
- refreshDocumentByDocData() {
- const docModel = this.documentModel = new DocumentDataModel(this._documentData);
- const docViewModel = new DocumentViewModel(docModel);
-
- this._documentSkeleton = DocumentSkeleton.create(docViewModel, this._localeService);
-
- this._documents = new Documents(`${this.oKey}_DOCUMENTS`, this._documentSkeleton, {
- pageMarginLeft: 0,
- pageMarginTop: 0,
- });
-
- this._documentSkeleton
- .getViewModel()
- .getDataModel()
- .updateDocumentDataPageSize(this.width, Infinity);
-
- this._documentSkeleton.calculate();
- }
-
- /**
- * invoked when end editing.
- */
- resizeToContentSize() {
- const contentSize = this.getDocsSkeletonPageSize();
- if (contentSize && contentSize.width !== 0 && contentSize.height !== 0) {
- this.transformByState({
- // width: contentSize?.width || 0,
- height: contentSize?.height || 0,
- });
- }
- }
-}
diff --git a/packages/slides-ui/README.md b/packages/slides-ui/README.md
index 94b88d5718..a3fd5e9053 100644
--- a/packages/slides-ui/README.md
+++ b/packages/slides-ui/README.md
@@ -1,41 +1,3 @@
# @univerjs/slides-ui
-[![npm version](https://img.shields.io/npm/v/@univerjs/slides-ui?style=flat-square)](https://npmjs.com/package/@univerjs/slides-ui)
-[![license](https://img.shields.io/npm/l/@univerjs/slides-ui?style=flat-square)](https://npmjs.com/package/@univerjs/slides-ui)
-[![downloads](https://img.shields.io/npm/dm/@univerjs/slides-ui?style=flat-square)](https://npmjs.com/package/@univerjs/slides-ui)
-
-`@univerjs/slides-ui` adds the presentation editor UI layer for Univer Slides.
-
-## Package Overview
-
-| Package | UMD global | CSS | Locales | Facade entry |
-| --- | --- | :---: | :---: | :---: |
-| `@univerjs/slides-ui` | `UniverSlidesUi` | Yes | Yes | No |
-
-## Installation
-
-```sh
-pnpm add @univerjs/slides-ui
-# or
-npm install @univerjs/slides-ui
-```
-
-Keep all `@univerjs/*` packages on the same version.
-
-## Usage
-
-```ts
-import '@univerjs/slides-ui/lib/index.css';
-import EnUS from '@univerjs/slides-ui/locale/en-US';
-import { UniverSlidesUIPlugin } from '@univerjs/slides-ui';
-
-univer.registerPlugin(UniverSlidesUIPlugin);
-
-// Merge EnUS into your Univer locale map when this package contributes UI text.
-```
-
-## Resources
-
-- [Documentation](https://docs.univer.ai)
-- [NPM package](https://npmjs.com/package/@univerjs/slides-ui)
-- [GitHub repository](https://github.com/dream-num/univer)
+This package has moved to [`@univerjs-pro/slides-ui`](https://www.npmjs.com/package/@univerjs-pro/slides-ui).
diff --git a/packages/slides-ui/package.json b/packages/slides-ui/package.json
deleted file mode 100644
index 6bf9fcc3ee..0000000000
--- a/packages/slides-ui/package.json
+++ /dev/null
@@ -1,96 +0,0 @@
-{
- "name": "@univerjs/slides-ui",
- "version": "1.3.1",
- "private": false,
- "description": "Presentation editor UI layer for Univer Slides.",
- "author": "DreamNum Co., Ltd. <[email protected]>",
- "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": [
- "univer",
- "slides",
- "presentation",
- "editor",
- "ui"
- ],
- "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": "tsrs --noEmit",
- "build:bundle": "univer-cli build",
- "build:types": "tsrs -p tsconfig.node.json",
- "build": "pnpm run build:bundle && pnpm run build:types"
- },
- "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/drawing": "workspace:*",
- "@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "1.47.0",
- "@univerjs/slides": "workspace:*",
- "@univerjs/ui": "workspace:*"
- },
- "devDependencies": {
- "@univerjs-infra/shared": "workspace:*",
- "postcss": "^8.5.32",
- "react": "18.3.1",
- "rxjs": "7.8.2",
- "tailwindcss": "3.4.18",
- "tsrs": "0.20.1-ts7.1.0-beta",
- "vitest": "^5.0.5"
- }
-}
diff --git a/packages/slides-ui/postcss.config.mjs b/packages/slides-ui/postcss.config.mjs
deleted file mode 100644
index 7d59f53133..0000000000
--- a/packages/slides-ui/postcss.config.mjs
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from '@univerjs-infra/shared/postcss';
diff --git a/packages/slides-ui/src/commands/operations/__tests__/slide-element.operation.spec.ts b/packages/slides-ui/src/commands/operations/__tests__/slide-element.operation.spec.ts
deleted file mode 100644
index b4f442a5ff..0000000000
--- a/packages/slides-ui/src/commands/operations/__tests__/slide-element.operation.spec.ts
+++ /dev/null
@@ -1,482 +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 { IPageElement, ISlideData, ISlidePage, SlideDataModel } from '@univerjs/slides';
-import {
- ICommandService,
- IImageIoService,
- ImageSourceType,
- ImageUploadStatusType,
- IUniverInstanceService,
- LocaleService,
- Univer,
- UniverInstanceType,
-} from '@univerjs/core';
-import { ObjectType } from '@univerjs/engine-render';
-import { BasicShapes, PageElementType, PageType, UniverSlidesPlugin } from '@univerjs/slides';
-import { DesktopSidebarService, ILocalFileService, ISidebarService } from '@univerjs/ui';
-import { afterEach, beforeEach, describe, expect, it } from 'vitest';
-import { CanvasView } from '../../../controllers/canvas-view';
-import { ActivateSlidePageOperation } from '../activate.operation';
-import { AppendSlideOperation } from '../append-slide.operation';
-import { DeleteSlideElementOperation } from '../delete-element.operation';
-import { InsertSlideFloatImageCommand } from '../insert-image.operation';
-import {
- InsertSlideShapeEllipseCommand,
- InsertSlideShapeEllipseOperation,
- InsertSlideShapeRectangleCommand,
- InsertSlideShapeRectangleOperation,
- ToggleSlideEditSidebarOperation,
-} from '../insert-shape.operation';
-import { SlideAddTextCommand, SlideAddTextOperation } from '../insert-text.operation';
-import { SetSlidePageThumbOperation } from '../set-thumb.operation';
-import { UpdateSlideElementOperation } from '../update-element.operation';
-
-const unitId = 'slide-command-unit';
-const pageId = 'page-1';
-
-class TestCanvasView {
- static thumbUnitIds: string[] = [];
- static activatedPages: string[] = [];
- static activeObjectIds: string[] = [];
- static clearedControls = 0;
- static activateCreatedObject = false;
-
- constructor(@IUniverInstanceService private readonly _instanceService: IUniverInstanceService) {}
-
- static reset() {
- this.thumbUnitIds = [];
- this.activatedPages = [];
- this.activeObjectIds = [];
- this.clearedControls = 0;
- this.activateCreatedObject = false;
- }
-
- createObjectToPage() {
- if (TestCanvasView.activateCreatedObject) {
- return { oKey: 'created-object' } as never;
- }
-
- return null;
- }
-
- setObjectActiveByPage(object: { oKey?: string }) {
- TestCanvasView.activeObjectIds.push(object.oKey ?? '');
- }
-
- removeObjectById() {
- // render boundary is not part of the data-model behavior under test
- }
-
- appendPage(unitId: string) {
- const slide = this._instanceService.getUnit<SlideDataModel>(unitId);
- const page = slide?.getBlankPage();
- if (page) {
- slide?.appendPage(page);
- }
- }
-
- activePage(pageId: string, unitId: string) {
- const slide = this._instanceService.getUnit<SlideDataModel>(unitId);
- slide?.setActivePage(slide.getPage(pageId) ?? null);
- TestCanvasView.activatedPages.push(pageId);
- }
-
- getRenderUnitByPageId(pageId: string, unitId: string) {
- const slide = this._instanceService.getUnit<SlideDataModel>(unitId);
- if (!slide?.getPage(pageId)) {
- return null;
- }
-
- return {
- scene: {
- getTransformer: () => ({
- clearControls: () => {
- TestCanvasView.clearedControls += 1;
- },
- }),
- },
- };
- }
-
- createThumbs(unitId: string) {
- TestCanvasView.thumbUnitIds.push(unitId);
- }
-}
-
-class TestLocalFileService implements ILocalFileService {
- static files: File[] = [];
-
- static reset() {
- this.files = [];
- }
-
- openFile(): Promise<File[]> {
- return Promise.resolve(TestLocalFileService.files);
- }
-
- downloadFile(): void {
- // not used by slide image insertion
- }
-}
-
-class TestImageIoService {
- saveImage(): Promise<unknown> {
- return Promise.resolve({
- imageId: 'image-1',
- imageSourceType: ImageSourceType.BASE64,
- source: 'data:image/png;base64,ZmFrZQ==',
- base64Cache: 'data:image/png;base64,ZmFrZQ==',
- status: ImageUploadStatusType.SUCCUSS,
- });
- }
-}
-
-class TestImage {
- width = 64;
- height = 32;
- onload: (() => void) | null = null;
- onerror: ((error: unknown) => void) | null = null;
-
- set src(_value: string) {
- queueMicrotask(() => this.onload?.());
- }
-}
-
-function createSlideSnapshot(): Partial<ISlideData> {
- return {
- id: unitId,
- title: 'Command test deck',
- pageSize: { width: 960, height: 540 },
- body: {
- pageOrder: [pageId, 'page-2'],
- pages: {
- [pageId]: {
- id: pageId,
- pageType: PageType.SLIDE,
- zIndex: 1,
- title: 'Overview',
- description: '',
- pageBackgroundFill: { rgb: '#ffffff' },
- pageElements: {
- 'title-text': {
- id: 'title-text',
- zIndex: 1,
- left: 40,
- top: 40,
- width: 400,
- height: 60,
- title: 'Title',
- description: '',
- type: PageElementType.TEXT,
- richText: { text: 'Quarterly review' },
- },
- 'old-shape': {
- id: 'old-shape',
- zIndex: 2,
- left: 100,
- top: 120,
- width: 80,
- height: 80,
- title: 'Old shape',
- description: '',
- type: PageElementType.SHAPE,
- shape: {
- shapeType: BasicShapes.Rect,
- text: '',
- shapeProperties: {
- shapeBackgroundFill: { rgb: 'rgb(0,0,255)' },
- },
- },
- },
- },
- },
- 'page-2': {
- id: 'page-2',
- pageType: PageType.SLIDE,
- zIndex: 2,
- title: 'Appendix',
- description: '',
- pageBackgroundFill: { rgb: '#ffffff' },
- pageElements: {},
- },
- },
- },
- };
-}
-
-function getActivePage(slide: SlideDataModel): ISlidePage {
- return slide.getActivePage()!;
-}
-
-function getElementIds(page: ISlidePage): string[] {
- const ids: string[] = [];
- for (const id in page.pageElements) {
- ids.push(id);
- }
- return ids;
-}
-
-function findElementAddedAfter(page: ISlidePage, beforeIds: string[]): IPageElement {
- for (const id in page.pageElements) {
- if (!beforeIds.includes(id)) {
- return page.pageElements[id];
- }
- }
-
- throw new Error('No new slide element was added.');
-}
-
-describe('slide element operations', () => {
- let univer: Univer;
- let commandService: ICommandService;
- let slide: SlideDataModel;
- let originalImage: typeof Image;
-
- beforeEach(() => {
- univer = new Univer();
- univer.registerPlugin(UniverSlidesPlugin);
- TestCanvasView.reset();
- TestLocalFileService.reset();
- originalImage = globalThis.Image;
- (globalThis as unknown as { Image: typeof Image }).Image = TestImage as unknown as typeof Image;
-
- const injector = univer.__getInjector();
- injector.add([CanvasView, { useClass: TestCanvasView as never }]);
- injector.add([ISidebarService, { useClass: DesktopSidebarService }]);
- injector.add([ILocalFileService, { useClass: TestLocalFileService }]);
- injector.add([IImageIoService, { useClass: TestImageIoService as never }]);
-
- slide = univer.createUnit<ISlideData, SlideDataModel>(UniverInstanceType.UNIVER_SLIDE, createSlideSnapshot());
- injector.get(IUniverInstanceService).focusUnit(unitId);
- commandService = injector.get(ICommandService);
- commandService.registerCommand(SlideAddTextOperation);
- commandService.registerCommand(SlideAddTextCommand);
- commandService.registerCommand(InsertSlideShapeRectangleOperation);
- commandService.registerCommand(InsertSlideShapeRectangleCommand);
- commandService.registerCommand(InsertSlideShapeEllipseOperation);
- commandService.registerCommand(InsertSlideShapeEllipseCommand);
- commandService.registerCommand(UpdateSlideElementOperation);
- commandService.registerCommand(DeleteSlideElementOperation);
- commandService.registerCommand(AppendSlideOperation);
- commandService.registerCommand(ActivateSlidePageOperation);
- commandService.registerCommand(SetSlidePageThumbOperation);
- commandService.registerCommand(InsertSlideFloatImageCommand);
- commandService.registerCommand(ToggleSlideEditSidebarOperation);
- injector.get(LocaleService).load({});
- });
-
- afterEach(() => {
- (globalThis as unknown as { Image: typeof Image }).Image = originalImage;
- univer.dispose();
- });
-
- it('adds a text box to the active slide with the entered content', async () => {
- const page = getActivePage(slide);
- const beforeIds = getElementIds(page);
-
- const result = await commandService.executeCommand(SlideAddTextOperation.id, {
- unitId,
- text: 'Revenue is up',
- });
-
- expect(result).toBe(true);
- const element = findElementAddedAfter(page, beforeIds);
- expect(element).toMatchObject({
- zIndex: 3,
- type: PageElementType.TEXT,
- richText: {
- text: 'Revenue is up',
- fs: 30,
- },
- });
- });
-
- it('adds rectangle and ellipse shapes to the active slide', async () => {
- const page = getActivePage(slide);
- const beforeRectangleIds = getElementIds(page);
-
- await commandService.executeCommand(InsertSlideShapeRectangleCommand.id);
- const rectangle = findElementAddedAfter(page, beforeRectangleIds);
-
- const beforeEllipseIds = getElementIds(page);
- await commandService.executeCommand(InsertSlideShapeEllipseCommand.id);
- const ellipse = findElementAddedAfter(page, beforeEllipseIds);
-
- expect(rectangle).toMatchObject({
- zIndex: 3,
- type: PageElementType.SHAPE,
- shape: {
- shapeType: BasicShapes.Rect,
- },
- });
- expect(ellipse).toMatchObject({
- zIndex: 4,
- type: PageElementType.SHAPE,
- shape: {
- shapeType: BasicShapes.Ellipse,
- },
- });
- });
-
- it('uses the focused slide when adding text from the user command', async () => {
- const page = getActivePage(slide);
- const beforeIds = getElementIds(page);
-
- const result = await commandService.executeCommand(SlideAddTextCommand.id);
-
- expect(result).toBe(true);
- const element = findElementAddedAfter(page, beforeIds);
- expect(element).toMatchObject({
- type: PageElementType.TEXT,
- richText: { text: 'A New Text' },
- });
- });
-
- it('updates an existing slide element without replacing the rest of its content', async () => {
- const result = await commandService.executeCommand(UpdateSlideElementOperation.id, {
- unitId,
- oKey: 'title-text',
- props: {
- left: 120,
- title: 'Updated title box',
- },
- });
-
- expect(result).toBe(true);
- expect(slide.getElement(pageId, 'title-text')).toMatchObject({
- left: 120,
- title: 'Updated title box',
- type: PageElementType.TEXT,
- richText: { text: 'Quarterly review' },
- });
- });
-
- it('removes the selected element from the active slide', async () => {
- const result = await commandService.executeCommand(DeleteSlideElementOperation.id, {
- unitId,
- id: 'old-shape',
- });
-
- expect(result).toBe(true);
- expect(slide.getElement(pageId, 'old-shape')).toBeUndefined();
- expect(slide.getElement(pageId, 'title-text')).toBeDefined();
- });
-
- it('appends a new page after the active slide', async () => {
- expect(slide.getPageOrder()).toEqual([pageId, 'page-2']);
-
- const result = await commandService.executeCommand(AppendSlideOperation.id, { unitId });
-
- expect(result).toBe(true);
- expect(slide.getPageOrder()).toHaveLength(3);
- expect(slide.getPageOrder()?.[0]).toBe(pageId);
- expect(slide.getPageOrder()?.[1]).not.toBe('page-2');
- expect(slide.getPageOrder()?.[2]).toBe('page-2');
- });
-
- it('activates another page after clearing the current page controls', async () => {
- const result = await commandService.executeCommand(ActivateSlidePageOperation.id, {
- unitId,
- id: 'page-2',
- });
-
- expect(result).toBe(true);
- expect(slide.getActivePage()?.id).toBe('page-2');
- expect(TestCanvasView.clearedControls).toBe(1);
- expect(TestCanvasView.activatedPages).toEqual(['page-2']);
- });
-
- it('does not activate a missing page renderer', async () => {
- const result = await commandService.executeCommand(ActivateSlidePageOperation.id, {
- unitId: 'missing-slide',
- id: 'page-2',
- });
-
- expect(result).toBe(false);
- expect(slide.getActivePage()?.id).toBe(pageId);
- });
-
- it('creates thumbnails for the current deck', async () => {
- const result = await commandService.executeCommand(SetSlidePageThumbOperation.id, { unitId });
-
- expect(result).toBe(true);
- expect(TestCanvasView.thumbUnitIds).toEqual([unitId]);
- });
-
- it('keeps the deck unchanged when the user cancels image selection', async () => {
- const page = getActivePage(slide);
- const beforeIds = getElementIds(page);
-
- const result = await commandService.executeCommand(InsertSlideFloatImageCommand.id);
-
- expect(result).toBe(false);
- expect(getElementIds(page)).toEqual(beforeIds);
- });
-
- it('adds the selected image to the active slide and selects the created object', async () => {
- const page = getActivePage(slide);
- const beforeIds = getElementIds(page);
- TestCanvasView.activateCreatedObject = true;
- TestLocalFileService.files = [new File(['fake image'], 'chart.png', { type: 'image/png' })];
-
- const result = await commandService.executeCommand(InsertSlideFloatImageCommand.id);
-
- expect(result).toBe(true);
- const element = findElementAddedAfter(page, beforeIds);
- expect(element).toMatchObject({
- id: 'image-1',
- zIndex: 3,
- width: 64,
- height: 32,
- type: PageElementType.IMAGE,
- image: {
- imageProperties: {
- imageSourceType: ImageSourceType.BASE64,
- source: 'data:image/png;base64,ZmFrZQ==',
- base64Cache: 'data:image/png;base64,ZmFrZQ==',
- },
- },
- });
- expect(TestCanvasView.activeObjectIds).toEqual(['created-object']);
- });
-
- it('opens and closes the slide edit sidebar for the selected object type', async () => {
- const sidebarService = univer.__getInjector().get(ISidebarService);
- const objectTypes = [
- { type: ObjectType.RECT, title: 'slides-ui.sidebar.shape' },
- { type: ObjectType.IMAGE, title: 'slides-ui.sidebar.image' },
- { type: ObjectType.RICH_TEXT, title: 'slides-ui.sidebar.text' },
- ];
-
- for (const objectType of objectTypes) {
- await commandService.executeCommand(ToggleSlideEditSidebarOperation.id, {
- visible: '1',
- objectType: objectType.type,
- });
-
- expect(sidebarService.visible).toBe(true);
- expect(sidebarService.options.header?.title).toBe(objectType.title);
- }
-
- await commandService.executeCommand(ToggleSlideEditSidebarOperation.id, {
- visible: '',
- objectType: ObjectType.RECT,
- });
-
- expect(sidebarService.visible).toBe(false);
- });
-});
diff --git a/packages/slides-ui/src/commands/operations/activate.operation.ts b/packages/slides-ui/src/commands/operations/activate.operation.ts
deleted file mode 100644
index 7f0f50588f..0000000000
--- a/packages/slides-ui/src/commands/operations/activate.operation.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 { IAccessor, IOperation } from '@univerjs/core';
-import type { SlideDataModel } from '@univerjs/slides';
-import { CommandType, IUniverInstanceService } from '@univerjs/core';
-import { CanvasView } from '../../controllers/canvas-view';
-
-export interface IActiveSlidePageOperationParams {
- unitId: string;
- id: string;
-}
-export const ActivateSlidePageOperation: IOperation<IActiveSlidePageOperationParams> = {
- id: 'slide.operation.activate-slide',
- type: CommandType.OPERATION,
- handler: (accessor: IAccessor, params: IActiveSlidePageOperationParams) => {
- const unitId = params.unitId;
- const canvasView = accessor.get(CanvasView);
- const univerInstanceService = accessor.get(IUniverInstanceService);
- // const model = univerInstanceService.getCurrentUnitOfType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE);
-
- const model = univerInstanceService.getUnit<SlideDataModel>(unitId);
- const pageId = model?.getActivePage()?.id;
-
- if (!pageId) return false;
-
- const page = canvasView.getRenderUnitByPageId(pageId, unitId);
- if (!page) return false;
- const transformer = page.scene?.getTransformer();
- if (transformer) {
- transformer.clearControls();
- }
-
- canvasView.activePage(params.id, unitId);
- return true;
- },
-};
diff --git a/packages/slides-ui/src/commands/operations/append-slide.operation.ts b/packages/slides-ui/src/commands/operations/append-slide.operation.ts
deleted file mode 100644
index 2f025be6ec..0000000000
--- a/packages/slides-ui/src/commands/operations/append-slide.operation.ts
+++ /dev/null
@@ -1,43 +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 { IOperation } from '@univerjs/core';
-import type { SlideDataModel } from '@univerjs/slides';
-import { CommandType, IUniverInstanceService } from '@univerjs/core';
-import { CanvasView } from '../../controllers/canvas-view';
-
-export interface IAppendSlideOperationParams {
- unitId: string;
-}
-
-export const AppendSlideOperation: IOperation<IAppendSlideOperationParams> = {
- id: 'slide.operation.append-slide',
- type: CommandType.OPERATION,
- handler: (accessor, params: IAppendSlideOperationParams) => {
- const unitId = params.unitId;
- const univerInstanceService = accessor.get(IUniverInstanceService);
- // const slideData = univerInstanceService.getCurrentUnitOfType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE);
-
- const slideData = univerInstanceService.getUnit<SlideDataModel>(unitId);
-
- if (!slideData) return false;
-
- const canvasView = accessor.get(CanvasView);
- canvasView.appendPage(unitId);
-
- return true;
- },
-};
diff --git a/packages/slides-ui/src/commands/operations/delete-element.operation.ts b/packages/slides-ui/src/commands/operations/delete-element.operation.ts
deleted file mode 100644
index 70020b573d..0000000000
--- a/packages/slides-ui/src/commands/operations/delete-element.operation.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 { ICommand } from '@univerjs/core';
-import type { SlideDataModel } from '@univerjs/slides';
-import { CommandType, IUniverInstanceService } from '@univerjs/core';
-import { CanvasView } from '../../controllers/canvas-view';
-
-export interface IDeleteElementOperationParams {
- unitId: string;
- id: string;
-};
-
-export const DeleteSlideElementOperation: ICommand<IDeleteElementOperationParams> = {
- id: 'slide.operation.delete-element',
- type: CommandType.OPERATION,
- handler: (accessor, params) => {
- if (!params?.id) return false;
-
- const unitId = params.unitId;
- const univerInstanceService = accessor.get(IUniverInstanceService);
- // const slideData = univerInstanceService.getCurrentUnitOfType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE);
-
- const slideData = univerInstanceService.getUnit<SlideDataModel>(unitId);
-
- if (!slideData) return false;
-
- const activePage = slideData.getActivePage()!;
-
- delete activePage.pageElements[params.id];
-
- slideData.updatePage(activePage.id, activePage);
-
- const canvasview = accessor.get(CanvasView);
- canvasview.removeObjectById(params.id, activePage.id, unitId);
-
- return true;
- },
-};
diff --git a/packages/slides-ui/src/commands/operations/insert-image.operation.ts b/packages/slides-ui/src/commands/operations/insert-image.operation.ts
deleted file mode 100644
index 69e6224c44..0000000000
--- a/packages/slides-ui/src/commands/operations/insert-image.operation.ts
+++ /dev/null
@@ -1,84 +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 type { SlideDataModel } from '@univerjs/slides';
-import { CommandType, IImageIoService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
-import { DRAWING_IMAGE_ALLOW_IMAGE_LIST, getImageSize } from '@univerjs/drawing';
-import { PageElementType } from '@univerjs/slides';
-import { ILocalFileService } from '@univerjs/ui';
-import { CanvasView } from '../../controllers/canvas-view';
-
-export const InsertSlideFloatImageCommand: ICommand<{}> = {
- id: 'slide.command.insert-float-image',
- type: CommandType.COMMAND,
- handler: async (accessor, params) => {
- const univerInstanceService = accessor.get(IUniverInstanceService);
- const unitId = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SLIDE)?.getUnitId();
- if (!unitId) return false;
-
- const fileOpenerService = accessor.get(ILocalFileService);
- const files = await fileOpenerService.openFile({
- multiple: true,
- accept: DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image) => `.${image.replace('image/', '')}`).join(','),
- });
- if (files.length !== 1) return false;
-
- const imageIoService = accessor.get(IImageIoService);
- const imageParam = await imageIoService.saveImage(files[0]);
- if (!imageParam) return false;
-
- const { imageId, imageSourceType, source, base64Cache } = imageParam;
- const { width, height, image } = await getImageSize(base64Cache || '');
-
- const slideData = univerInstanceService.getUnit<SlideDataModel>(unitId);
- if (!slideData) return false;
-
- const activePage = slideData.getActivePage()!;
- const elements = Object.values(activePage.pageElements);
- const maxIndex = (elements?.length) ? Math.max(...elements.map((element) => element.zIndex)) : 20;
- const data = {
- id: imageId,
- zIndex: maxIndex + 1,
- left: 0,
- top: 0,
- width,
- height,
- title: '',
- description: '',
- type: PageElementType.IMAGE,
- image: {
- imageProperties: {
- contentUrl: base64Cache,
- imageSourceType,
- source,
- base64Cache,
- image,
- },
- },
- };
- activePage.pageElements[imageId] = data;
- slideData.updatePage(activePage.id, activePage);
-
- const canvasView = accessor.get(CanvasView);
- const sceneObject = canvasView.createObjectToPage(data, activePage.id, unitId);
- if (sceneObject) {
- canvasView.setObjectActiveByPage(sceneObject, activePage.id, unitId);
- }
-
- return true;
- },
-};
diff --git a/packages/slides-ui/src/commands/operations/insert-shape.operation.ts b/packages/slides-ui/src/commands/operations/insert-shape.operation.ts
deleted file mode 100644
index 16c9a49f7b..0000000000
--- a/packages/slides-ui/src/commands/operations/insert-shape.operation.ts
+++ /dev/null
@@ -1,194 +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 type { SlideDataModel } from '@univerjs/slides';
-import { CommandType, generateRandomId, ICommandService, IUniverInstanceService, LocaleService } from '@univerjs/core';
-import { ObjectType } from '@univerjs/engine-render';
-import { BasicShapes, PageElementType } from '@univerjs/slides';
-import { ISidebarService } from '@univerjs/ui';
-import { CanvasView } from '../../controllers/canvas-view';
-import { COMPONENT_SLIDE_SIDEBAR } from '../../views/sidebar/Sidebar';
-
-export interface IInsertShapeOperationParams {
- unitId: string;
-};
-
-export const InsertSlideShapeRectangleCommand: ICommand = {
- id: 'slide.command.insert-float-shape.rectangle',
- type: CommandType.COMMAND,
- handler: async (accessor: IAccessor) => {
- const commandService = accessor.get(ICommandService);
- const instanceService = accessor.get(IUniverInstanceService);
- const unitId = instanceService.getFocusedUnit()?.getUnitId();
- return commandService.executeCommand(InsertSlideShapeRectangleOperation.id, { unitId });
- },
-};
-
-export const InsertSlideShapeRectangleOperation: ICommand<IInsertShapeOperationParams> = {
- id: 'slide.operation.insert-float-shape.rectangle',
- type: CommandType.OPERATION,
- handler: async (accessor, params: IInsertShapeOperationParams) => {
- const id = generateRandomId(6);
-
- const univerInstanceService = accessor.get(IUniverInstanceService);
- // const slideData = univerInstanceService.getCurrentUnitOfType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE);
-
- const unitId = params.unitId;
- const slideData = univerInstanceService.getUnit<SlideDataModel>(unitId);
-
- if (!slideData) return false;
-
- const activePage = slideData.getActivePage()!;
- const elements = Object.values(activePage.pageElements);
- const maxIndex = (elements?.length) ? Math.max(...elements.map((element) => element.zIndex)) : 20;
- const data = {
- id,
- zIndex: maxIndex + 1,
- left: 378,
- top: 142,
- width: 250,
- height: 250,
- title: id,
- description: '',
- type: PageElementType.SHAPE,
- shape: {
- shapeType: BasicShapes.Rect,
- text: '',
- shapeProperties: {
- shapeBackgroundFill: {
- rgb: 'rgb(0,0,255)',
- },
- },
- },
- };
- activePage.pageElements[id] = data;
- slideData.updatePage(activePage.id, activePage);
-
- const canvasview = accessor.get(CanvasView);
- const sceneObject = canvasview.createObjectToPage(data, activePage.id, unitId);
- if (sceneObject) {
- canvasview.setObjectActiveByPage(sceneObject, activePage.id, unitId);
- }
-
- return true;
- },
-};
-
-export interface IToggleSlideEditSidebarOperation {
- visible: string;
- objectType: ObjectType;
-}
-
-export const ToggleSlideEditSidebarOperation: ICommand = {
- id: 'sidebar.operation.slide-shape',
- type: CommandType.COMMAND,
- handler: async (accessor: IAccessor, params: IToggleSlideEditSidebarOperation) => {
- const { visible, objectType } = params;
-
- const sidebarService = accessor.get(ISidebarService);
- const localeService = accessor.get(LocaleService);
-
- let title = '';
- let children = '';
- if (objectType === ObjectType.RECT) {
- title = 'slides-ui.sidebar.shape';
- children = COMPONENT_SLIDE_SIDEBAR;
- } else if (objectType === ObjectType.IMAGE) {
- title = 'slides-ui.sidebar.image';
- children = COMPONENT_SLIDE_SIDEBAR;
- } else if (objectType === ObjectType.RICH_TEXT) {
- title = 'slides-ui.sidebar.text';
- children = COMPONENT_SLIDE_SIDEBAR;
- }
-
- if (visible) {
- sidebarService.open({
- header: { title: localeService.t(title) },
- children: { label: children },
- onClose: () => {
- // drawingManagerService.focusDrawing(null);
- },
- width: 360,
- });
- } else {
- sidebarService.close();
- }
- return true;
- },
-};
-
-export const InsertSlideShapeEllipseCommand: ICommand = {
- id: 'slide.command.insert-float-shape.ellipse',
- type: CommandType.COMMAND,
- handler: async (accessor: IAccessor) => {
- const commandService = accessor.get(ICommandService);
- const instanceService = accessor.get(IUniverInstanceService);
- const unitId = instanceService.getFocusedUnit()?.getUnitId();
- return commandService.executeCommand(InsertSlideShapeEllipseOperation.id, { unitId });
- },
-};
-
-export const InsertSlideShapeEllipseOperation: ICommand<IInsertShapeOperationParams> = {
- id: 'slide.operation.insert-float-shape.ellipse',
- type: CommandType.OPERATION,
- handler: async (accessor, params: IInsertShapeOperationParams) => {
- const id = generateRandomId(6);
-
- const univerInstanceService = accessor.get(IUniverInstanceService);
- // const slideData = univerInstanceService.getCurrentUnitOfType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE);
-
- const unitId = params.unitId;
- const slideData = univerInstanceService.getUnit<SlideDataModel>(unitId);
-
- if (!slideData) return false;
-
- const activePage = slideData.getActivePage()!;
- const elements = Object.values(activePage.pageElements);
- const maxIndex = (elements?.length) ? Math.max(...elements.map((element) => element.zIndex)) : 20;
- const data = {
- id,
- zIndex: maxIndex + 1,
- left: 378,
- top: 142,
- width: 250,
- height: 250,
- title: id,
- description: '',
- type: PageElementType.SHAPE,
- shape: {
- shapeType: BasicShapes.Ellipse,
- text: '',
- shapeProperties: {
- radius: 100,
- shapeBackgroundFill: {
- rgb: 'rgb(0,0,255)',
- },
- },
- },
- };
- activePage.pageElements[id] = data;
- slideData.updatePage(activePage.id, activePage);
-
- const canvasview = accessor.get(CanvasView);
- const sceneObject = canvasview.createObjectToPage(data, activePage.id, unitId);
- if (sceneObject) {
- canvasview.setObjectActiveByPage(sceneObject, activePage.id, unitId);
- }
-
- return true;
- },
-};
diff --git a/packages/slides-ui/src/commands/operations/insert-text.operation.ts b/packages/slides-ui/src/commands/operations/insert-text.operation.ts
deleted file mode 100644
index 8a45e34d9e..0000000000
--- a/packages/slides-ui/src/commands/operations/insert-text.operation.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 type { ICommand } from '@univerjs/core';
-import type { IPageElement, SlideDataModel } from '@univerjs/slides';
-import { CommandType, generateRandomId, ICommandService, IUniverInstanceService } from '@univerjs/core';
-import { PageElementType } from '@univerjs/slides';
-import { CanvasView } from '../../controllers/canvas-view';
-
-export interface ISlideAddTextParam {
- text: string;
- unitId: string;
-};
-
-export const SlideAddTextCommand: ICommand = {
- id: 'slide.command.add-text',
- type: CommandType.COMMAND,
- handler: async (accessor) => {
- const commandService = accessor.get(ICommandService);
- const univerInstanceService = accessor.get(IUniverInstanceService);
- const unitId = univerInstanceService.getFocusedUnit()?.getUnitId();
- return await commandService.executeCommand(SlideAddTextOperation.id, { unitId });
- },
-
-};
-
-export const SlideAddTextOperation: ICommand<ISlideAddTextParam> = {
- id: 'slide.operation.add-text',
- type: CommandType.OPERATION,
- handler: async (accessor, params: ISlideAddTextParam) => {
- const unitId = params.unitId;
-
- const elementId = generateRandomId(6);
- const defaultWidth = 220;
- const defaultheight = 40;
- const left = 230;
- const top = 142;
- const textContent = params?.text || 'A New Text';
-
- const univerInstanceService = accessor.get(IUniverInstanceService);
- // const slideData = univerInstanceService.getCurrentUnitOfType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE);
-
- const slideData = univerInstanceService.getUnit<SlideDataModel>(unitId);
- if (!slideData) return false;
-
- const activePage = slideData.getActivePage()!;
-
- const elements = Object.values(activePage.pageElements);
- const maxIndex = (elements?.length) ? Math.max(...elements.map((element) => element.zIndex)) : 21;
- const elementData: IPageElement = {
- id: elementId,
- zIndex: maxIndex + 1,
- left,
- top,
- width: defaultWidth,
- height: defaultheight,
- title: 'text',
- description: '',
- type: PageElementType.TEXT,
- richText: {
- text: textContent,
- fs: 30,
- cl: {
- rgb: 'rgb(51, 51, 51)',
- },
- bl: 1,
- },
- };
-
- activePage.pageElements[elementId] = elementData;
- slideData.updatePage(activePage.id, activePage);
-
- const canvasview = accessor.get(CanvasView);
- const sceneObject = canvasview.createObjectToPage(elementData, activePage.id, unitId);
- // make object active: a control rect wrap the object.
- if (sceneObject) {
- canvasview.setObjectActiveByPage(sceneObject, activePage.id, unitId);
- }
-
- return true;
- },
-};
diff --git a/packages/slides-ui/src/commands/operations/set-thumb.operation.ts b/packages/slides-ui/src/commands/operations/set-thumb.operation.ts
deleted file mode 100644
index ad347db300..0000000000
--- a/packages/slides-ui/src/commands/operations/set-thumb.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, IOperation } from '@univerjs/core';
-import { CommandType } from '@univerjs/core';
-import { CanvasView } from '../../controllers/canvas-view';
-
-export interface ISlideSetThumbParam {
- unitId: string;
-}
-
-export const SetSlidePageThumbOperation: IOperation = {
- id: 'slide.operation.set-slide-page-thumb',
- type: CommandType.OPERATION,
- handler: (accessor: IAccessor, params: ISlideSetThumbParam) => {
- const canvasView = accessor.get(CanvasView);
- canvasView.createThumbs(params.unitId);
- return true;
- },
-};
diff --git a/packages/slides-ui/src/commands/operations/text-edit.operation.ts b/packages/slides-ui/src/commands/operations/text-edit.operation.ts
deleted file mode 100644
index d8b37d6eec..0000000000
--- a/packages/slides-ui/src/commands/operations/text-edit.operation.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 { IOperation } from '@univerjs/core';
-import { CommandType } from '@univerjs/core';
-
-export const SetTextEditArrowOperation: IOperation<any> = {
- id: 'slide.operation.edit-arrow',
- type: CommandType.OPERATION,
- handler: () => true,
-};
diff --git a/packages/slides-ui/src/commands/operations/update-element.operation.ts b/packages/slides-ui/src/commands/operations/update-element.operation.ts
deleted file mode 100644
index f451d12669..0000000000
--- a/packages/slides-ui/src/commands/operations/update-element.operation.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 { ICommand } from '@univerjs/core';
-import type { SlideDataModel } from '@univerjs/slides';
-import { CommandType, IUniverInstanceService, merge } from '@univerjs/core';
-
-export interface IUpdateElementOperationParams {
- unitId: string;
- oKey: string;
- props: Record<string, any>;
-};
-
-export const UpdateSlideElementOperation: ICommand<IUpdateElementOperationParams> = {
- id: 'slide.operation.update-element',
- type: CommandType.OPERATION,
- handler: (accessor, params: IUpdateElementOperationParams) => {
- const { oKey, props } = params!;
- const univerInstanceService = accessor.get(IUniverInstanceService);
- // const slideData = univerInstanceService.getCurrentUnitOfType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE);
-
- const unitId = params?.unitId;
- const slideData = univerInstanceService.getUnit<SlideDataModel>(unitId);
- if (!slideData) return false;
-
- const activePage = slideData.getActivePage()!;
- activePage.pageElements[oKey] = merge(activePage.pageElements[oKey], props);
- slideData.updatePage(activePage.id, activePage);
-
- return true;
- },
-};
diff --git a/packages/slides-ui/src/config/config.ts b/packages/slides-ui/src/config/config.ts
deleted file mode 100644
index d93bd01d75..0000000000
--- a/packages/slides-ui/src/config/config.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.
- */
-
-import type { DependencyOverride } from '@univerjs/core';
-import type { MenuConfig } from '@univerjs/ui';
-
-export const SLIDES_UI_PLUGIN_CONFIG_KEY = 'slides-ui.config';
-
-export const configSymbol = Symbol(SLIDES_UI_PLUGIN_CONFIG_KEY);
-
-export interface IUniverSlidesUIConfig {
- override?: DependencyOverride;
- menu?: MenuConfig;
-}
-
-export const defaultPluginConfig: IUniverSlidesUIConfig = {};
diff --git a/packages/slides-ui/src/const.ts b/packages/slides-ui/src/const.ts
deleted file mode 100644
index 9ff39868e3..0000000000
--- a/packages/slides-ui/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.
- */
-
-import { createInternalEditorID } from '@univerjs/core';
-
-export const SLIDE_EDITOR_ID = createInternalEditorID('SLIDE_EDITOR');
diff --git a/packages/slides-ui/src/controllers/__tests__/slide-editing-render-business.spec.ts b/packages/slides-ui/src/controllers/__tests__/slide-editing-render-business.spec.ts
deleted file mode 100644
index 5d177e6d29..0000000000
--- a/packages/slides-ui/src/controllers/__tests__/slide-editing-render-business.spec.ts
+++ /dev/null
@@ -1,139 +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, Injector } from '@univerjs/core';
-import type { IRenderContext, IRichTextProps } from '@univerjs/engine-render';
-import type { ISlideData } from '@univerjs/slides';
-import {
- ICommandService,
- IUniverInstanceService,
- LocaleService,
- Univer,
- UniverInstanceType,
-} from '@univerjs/core';
-import {
- DocSelectionManagerService,
- DocStateEmitService,
- RichTextEditingMutation,
-} from '@univerjs/docs';
-import { EditorService, IEditorService, ReplaceSnapshotCommand } from '@univerjs/docs-ui';
-import { IRenderManagerService, RichText } from '@univerjs/engine-render';
-import { SlideDataModel } from '@univerjs/slides';
-import { DesktopLayoutService, ILayoutService } from '@univerjs/ui';
-import { afterEach, beforeEach, describe, expect, it } from 'vitest';
-import { SLIDE_EDITOR_ID } from '../../const';
-import { ISlideEditorBridgeService, SlideEditorBridgeService } from '../../services/slide-editor-bridge.service';
-import { ISlideEditorManagerService, SlideEditorManagerService } from '../../services/slide-editor-manager.service';
-import { SlideEditingRenderController } from '../slide-editing.render-controller';
-
-const unitId = 'slide-unit';
-
-function createSlideSnapshot(): Partial<ISlideData> {
- return {
- id: unitId,
- title: 'Editor test deck',
- pageSize: { width: 960, height: 540 },
- body: {
- pageOrder: [],
- pages: {},
- },
- };
-}
-
-function createRichText(injector: Injector, id: string, text: string, top: number): RichText {
- const props: IRichTextProps = {
- text,
- zIndex: 1,
- left: 10,
- top,
- width: 200,
- height: 40,
- };
-
- return injector.createInstance(RichText, injector.get(LocaleService), id, props);
-}
-
-describe('SlideEditingRenderController', () => {
- let univer: Univer;
- let controller: SlideEditingRenderController;
-
- beforeEach(() => {
- univer = new Univer();
- const injector = univer.__getInjector();
- const renderManagerService = {
- getRenderUnitById: () => null,
- } as unknown as IRenderManagerService;
-
- injector.add([IRenderManagerService, { useValue: renderManagerService }]);
- injector.add([DocSelectionManagerService]);
- injector.add([DocStateEmitService]);
- injector.add([IEditorService, { useClass: EditorService }]);
- injector.add([ILayoutService, { useClass: DesktopLayoutService }]);
- injector.add([ISlideEditorBridgeService, { useClass: SlideEditorBridgeService }]);
- injector.add([ISlideEditorManagerService, { useClass: SlideEditorManagerService }]);
-
- const instanceService = injector.get(IUniverInstanceService);
- instanceService.registerCtorForType(UniverInstanceType.UNIVER_SLIDE, SlideDataModel);
- const commandService = injector.get(ICommandService);
- commandService.registerCommand(RichTextEditingMutation);
- commandService.registerCommand(ReplaceSnapshotCommand);
-
- const slide = univer.createUnit<ISlideData, SlideDataModel>(UniverInstanceType.UNIVER_SLIDE, createSlideSnapshot());
- controller = injector.createInstance(SlideEditingRenderController, {
- unitId,
- unit: slide,
- } as IRenderContext<SlideDataModel>);
- });
-
- afterEach(() => {
- controller?.dispose();
- univer.dispose();
- });
-
- it('keeps the registered editor unit while replacing its snapshot', () => {
- const injector = univer.__getInjector();
- const instanceService = injector.get(IUniverInstanceService);
- const editorBridgeService = injector.get(ISlideEditorBridgeService);
- const firstText = createRichText(injector, 'first', 'First text', 20);
- const secondText = createRichText(injector, 'second', 'Second text', 80);
-
- editorBridgeService.setEditorRect({
- scene: null as never,
- engine: null as never,
- unitId,
- pageId: 'page-1',
- richTextObj: firstText,
- });
-
- const editorDocument = instanceService.getUnit<DocumentDataModel>(SLIDE_EDITOR_ID, UniverInstanceType.UNIVER_DOC);
- expect(editorDocument?.getBody()?.dataStream).toBe('First text\r\n');
-
- editorBridgeService.setEditorRect({
- scene: null as never,
- engine: null as never,
- unitId,
- pageId: 'page-1',
- richTextObj: secondText,
- });
-
- expect(instanceService.getUnit(SLIDE_EDITOR_ID, UniverInstanceType.UNIVER_DOC)).toBe(editorDocument);
- expect(editorDocument?.getBody()?.dataStream).toBe('Second text\r\n');
- expect(instanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC)).toBe(editorDocument);
-
- firstText.dispose();
- secondText.dispose();
- });
-});
diff --git a/packages/slides-ui/src/controllers/canvas-view.ts b/packages/slides-ui/src/controllers/canvas-view.ts
deleted file mode 100644
index d2a97de241..0000000000
--- a/packages/slides-ui/src/controllers/canvas-view.ts
+++ /dev/null
@@ -1,79 +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 { BaseObject, IRenderModule } from '@univerjs/engine-render';
-import type { IPageElement } from '@univerjs/slides';
-import type { PageID } from '../type';
-import { RxDisposable } from '@univerjs/core';
-import { IRenderManagerService } from '@univerjs/engine-render';
-import { SlideRenderController } from './slide.render-controller';
-
-export class CanvasView extends RxDisposable implements IRenderModule {
- constructor(
- // this controller needs by commands. root injector. T
- // That means this controller is not init by renderUnit ---> no renderContext.
- // private readonly _renderContext: IRenderContext<UnitModel>,
- @IRenderManagerService private readonly _renderManagerService: IRenderManagerService
- ) {
- super();
- }
-
- private _getSlideRenderControllerFromRenderUnit(unitId: string) {
- const renderUnit = this._renderManagerService
- .getRenderUnitById(unitId)!;
- const slideRC = renderUnit.with(SlideRenderController);
- return slideRC;
- }
-
- createThumbs(unitId: string) {
- const slideRC = this._getSlideRenderControllerFromRenderUnit(unitId);
- slideRC.createThumbs();
- }
-
- activePage(pageId: string, unitId: string) {
- const slideRC = this._getSlideRenderControllerFromRenderUnit(unitId);
- slideRC.activePage(pageId);
- }
-
- getRenderUnitByPageId(pageId: PageID, unitId: string) {
- const slideRC = this._getSlideRenderControllerFromRenderUnit(unitId);
- return slideRC.getPageRenderUnit(pageId);
- }
-
- createObjectToPage(element: IPageElement, pageID: PageID, unitId: string): Nullable<BaseObject> {
- const slideRC = this._getSlideRenderControllerFromRenderUnit(unitId);
- return slideRC.createObjectToPage(element, pageID);
- }
-
- setObjectActiveByPage(obj: BaseObject, pageID: PageID, unitId: string) {
- const slideRC = this._getSlideRenderControllerFromRenderUnit(unitId);
- return slideRC.setObjectActiveByPage(obj, pageID);
- }
-
- removeObjectById(id: string, pageID: PageID, unitId: string) {
- const slideRC = this._getSlideRenderControllerFromRenderUnit(unitId);
- slideRC.removeObjectById(id, pageID);
- }
-
- /**
- * append blank page
- */
- appendPage(unitId: string) {
- const slideRC = this._getSlideRenderControllerFromRenderUnit(unitId);
- slideRC.appendPage();
- }
-}
diff --git a/packages/slides-ui/src/controllers/components.controller.ts b/packages/slides-ui/src/controllers/components.controller.ts
deleted file mode 100644
index 2a03249d72..0000000000
--- a/packages/slides-ui/src/controllers/components.controller.ts
+++ /dev/null
@@ -1,48 +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, Inject } from '@univerjs/core';
-import { AddImageIcon, GraphIcon, TextIcon } from '@univerjs/icons';
-import { ComponentManager, IconManager } from '@univerjs/ui';
-import { COMPONENT_SLIDE_IMAGE_POPUP_MENU } from '../views/image-popup-menu/component-name';
-import { SlideImagePopupMenu } from '../views/image-popup-menu/ImagePopupMenu';
-import Sidebar, { COMPONENT_SLIDE_SIDEBAR } from '../views/sidebar/Sidebar';
-
-export class ComponentsController extends Disposable {
- constructor(
- @Inject(ComponentManager) private readonly _componentManager: ComponentManager,
- @Inject(IconManager) private readonly _iconManager: IconManager
- ) {
- super();
-
- this._registerComponents();
- this._registerIcons();
- }
-
- private _registerComponents(): void {
- const componentManager = this._componentManager;
- this.disposeWithMe(componentManager.register(COMPONENT_SLIDE_IMAGE_POPUP_MENU, SlideImagePopupMenu));
- this.disposeWithMe(componentManager.register(COMPONENT_SLIDE_SIDEBAR, Sidebar));
- }
-
- private _registerIcons(): void {
- this.disposeWithMe(this._iconManager.register({
- AddImageIcon,
- TextIcon,
- GraphIcon,
- }));
- }
-}
diff --git a/packages/slides-ui/src/controllers/shortcuts/editor.shortcuts.ts b/packages/slides-ui/src/controllers/shortcuts/editor.shortcuts.ts
deleted file mode 100644
index a464c6a70f..0000000000
--- a/packages/slides-ui/src/controllers/shortcuts/editor.shortcuts.ts
+++ /dev/null
@@ -1,146 +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 { IShortcutItem } from '@univerjs/ui';
-import { DeleteLeftCommand } from '@univerjs/docs-ui';
-import { DeviceInputEventType } from '@univerjs/engine-render';
-import { KeyCode, MetaKeys } from '@univerjs/ui';
-import { SetTextEditArrowOperation } from '../../commands/operations/text-edit.operation';
-import {
- whenEditorActivated,
- whenFormulaEditorFocused,
-} from './utils';
-
-export const ARROW_SELECTION_KEYCODE_LIST = [
- KeyCode.ARROW_DOWN,
- KeyCode.ARROW_UP,
- KeyCode.ARROW_LEFT,
- KeyCode.ARROW_RIGHT,
-];
-
-export const MOVE_SELECTION_KEYCODE_LIST = [KeyCode.ENTER, KeyCode.TAB, ...ARROW_SELECTION_KEYCODE_LIST];
-
-export function generateArrowSelectionShortCutItem() {
- const shortcutList: IShortcutItem[] = [];
-
- for (const keycode of ARROW_SELECTION_KEYCODE_LIST) {
- shortcutList.push({
- id: SetTextEditArrowOperation.id,
- binding: keycode,
- preconditions: (contextService) => whenEditorActivated(contextService),
- staticParameters: {
- visible: false,
- eventType: DeviceInputEventType.Keyboard,
- keycode,
- isShift: false,
- },
- });
-
- shortcutList.push({
- id: SetTextEditArrowOperation.id,
- binding: keycode | MetaKeys.SHIFT,
- preconditions: (contextService) => whenEditorActivated(contextService),
- staticParameters: {
- visible: false,
- eventType: DeviceInputEventType.Keyboard,
- keycode,
- isShift: true,
- },
- });
- }
-
- return shortcutList;
-}
-
-// export const StartEditWithF2Shortcut: IShortcutItem = {
-// id: SetCellEditVisibleWithF2Operation.id,
-// binding: KeyCode.F2,
-// description: 'shortcut.sheet.start-editing',
-// group: '4_sheet-edit',
-// preconditions: whenSheetEditorFocused,
-// staticParameters: {
-// visible: true,
-// eventType: DeviceInputEventType.Keyboard,
-// keycode: KeyCode.F2,
-// },
-// };
-
-// export const EditorCursorEnterShortcut: IShortcutItem = {
-// id: SetCellEditVisibleOperation.id,
-// binding: KeyCode.ENTER,
-// description: 'shortcut.sheet.toggle-editing',
-// group: '4_sheet-edit',
-// preconditions: (contextService) => whenEditorDidNotInputFormulaActivated(contextService),
-// staticParameters: {
-// visible: false,
-// eventType: DeviceInputEventType.Keyboard,
-// keycode: KeyCode.ENTER,
-// },
-// };
-
-// export const EditorCursorTabShortcut: IShortcutItem = {
-// id: SetCellEditVisibleOperation.id,
-// binding: KeyCode.TAB,
-// preconditions: (contextService) => whenEditorDidNotInputFormulaActivated(contextService),
-// staticParameters: {
-// visible: false,
-// eventType: DeviceInputEventType.Keyboard,
-// keycode: KeyCode.TAB,
-// },
-// };
-
-// export const EditorCursorEscShortcut: IShortcutItem = {
-// id: SetCellEditVisibleOperation.id,
-// binding: KeyCode.ESC,
-// description: 'shortcut.sheet.abort-editing',
-// group: '4_sheet-edit',
-// preconditions: (contextService) => whenEditorDidNotInputFormulaActivated(contextService),
-// staticParameters: {
-// visible: false,
-// eventType: DeviceInputEventType.Keyboard,
-// keycode: KeyCode.ESC,
-// },
-// };
-
-// export const EditorBreakLineShortcut: IShortcutItem = {
-// id: BreakLineCommand.id,
-// description: 'shortcut.sheet.break-line',
-// group: '4_sheet-edit',
-// preconditions: (contextService) => whenSheetEditorActivated(contextService),
-// binding: KeyCode.ENTER | MetaKeys.ALT,
-// };
-
-export const EditorDeleteLeftShortcut: IShortcutItem = {
- id: DeleteLeftCommand.id,
- preconditions: (contextService) => {
- return whenEditorActivated(contextService) || whenFormulaEditorFocused(contextService);
- },
- binding: KeyCode.BACKSPACE,
-};
-
-// export const EditorDeleteLeftShortcutInActive: IShortcutItem = {
-// id: SetCellEditVisibleOperation.id,
-// description: 'shortcut.sheet.delete-and-start-editing',
-// group: '4_sheet-edit',
-// preconditions: (contextService) =>
-// whenSheetEditorFocused(contextService) && !whenFormulaEditorFocused(contextService),
-// binding: KeyCode.BACKSPACE,
-// staticParameters: {
-// visible: true,
-// eventType: DeviceInputEventType.Keyboard,
-// keycode: KeyCode.BACKSPACE,
-// },
-// };
diff --git a/packages/slides-ui/src/controllers/shortcuts/utils.ts b/packages/slides-ui/src/controllers/shortcuts/utils.ts
deleted file mode 100644
index 104668bf65..0000000000
--- a/packages/slides-ui/src/controllers/shortcuts/utils.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 { IContextService } from '@univerjs/core';
-import {
- EDITOR_ACTIVATED,
- FOCUSING_COMMON_DRAWINGS,
- FOCUSING_EDITOR_INPUT_FORMULA,
- FOCUSING_EDITOR_STANDALONE,
- FOCUSING_SLIDE,
- FOCUSING_UNIVER_EDITOR,
- FORMULA_EDITOR_ACTIVATED,
-} from '@univerjs/core';
-
-export function whenSheetFocused(contextService: IContextService) {
- return contextService.getContextValue(FOCUSING_SLIDE);
-}
-
-// FIXME: why coupled with sheet editors?
-
-/**
- * Requires the currently focused unit to be Workbook and the sheet editor is focused but not activated.
- * @param contextService
- * @returns If the sheet editor is focused but not activated.
- */
-export function whenSheetEditorFocused(contextService: IContextService): boolean {
- return (
- contextService.getContextValue(FOCUSING_SLIDE) &&
- contextService.getContextValue(FOCUSING_UNIVER_EDITOR) &&
- !contextService.getContextValue(EDITOR_ACTIVATED) &&
- !contextService.getContextValue(FOCUSING_COMMON_DRAWINGS)
- );
-}
-
-export function whenSheetEditorFocusedAndFxNotFocused(contextService: IContextService): boolean {
- return (
- contextService.getContextValue(FOCUSING_SLIDE) &&
- contextService.getContextValue(FOCUSING_UNIVER_EDITOR) &&
- !contextService.getContextValue(EDITOR_ACTIVATED) &&
- !contextService.getContextValue(FORMULA_EDITOR_ACTIVATED) &&
- !contextService.getContextValue(FOCUSING_COMMON_DRAWINGS)
- );
-}
-
-/**
- * Requires the currently focused unit to be Workbook and the sheet editor is activated.
- * @param contextService
- * @returns If the sheet editor is activated.
- */
-export function whenSheetEditorActivated(contextService: IContextService) {
- return (
- contextService.getContextValue(FOCUSING_SLIDE) &&
- contextService.getContextValue(FOCUSING_UNIVER_EDITOR) &&
- contextService.getContextValue(EDITOR_ACTIVATED)
- );
-}
-
-export function whenEditorActivated(contextService: IContextService) {
- return contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && contextService.getContextValue(EDITOR_ACTIVATED);
-}
-
-/**
- * Requires the currently focused editor is a formula editor.
- * @param contextService
- * @returns If the formula editor is focused.
- */
-export function whenFormulaEditorFocused(contextService: IContextService) {
- return (
- contextService.getContextValue(FORMULA_EDITOR_ACTIVATED) &&
- contextService.getContextValue(FOCUSING_UNIVER_EDITOR)
- );
-}
-
-/**
- * Requires the currently focused editor is a formula editor, and it is activated.
- * @param contextService
- * @returns If the formula editor is activated.
- */
-export function whenFormulaEditorActivated(contextService: IContextService) {
- return (
- contextService.getContextValue(FOCUSING_SLIDE) &&
- contextService.getContextValue(EDITOR_ACTIVATED) &&
- contextService.getContextValue(FOCUSING_EDITOR_INPUT_FORMULA) &&
- contextService.getContextValue(FOCUSING_UNIVER_EDITOR)
- );
-}
-
-/**
- * Requires the currently focused editor is not a formula editor, and it is activated.
- * @param contextService
- * @returns If the editor is activated and the editor is not the formula editor.
- */
-export function whenEditorDidNotInputFormulaActivated(contextService: IContextService) {
- return (
- contextService.getContextValue(FOCUSING_SLIDE) &&
- contextService.getContextValue(FOCUSING_UNIVER_EDITOR) &&
- contextService.getContextValue(EDITOR_ACTIVATED) &&
- !contextService.getContextValue(FOCUSING_EDITOR_INPUT_FORMULA) &&
- !contextService.getContextValue(FOCUSING_EDITOR_STANDALONE)
- );
-}
diff --git a/packages/slides-ui/src/controllers/slide-editing.render-controller.ts b/packages/slides-ui/src/controllers/slide-editing.render-controller.ts
deleted file mode 100644
index f97052f38d..0000000000
--- a/packages/slides-ui/src/controllers/slide-editing.render-controller.ts
+++ /dev/null
@@ -1,902 +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,
- IDisposable,
- IDocumentBody,
- IPosition,
- Nullable,
- UnitModel,
-} from '@univerjs/core';
-import type { IDocObjectParam, IEditorInputConfig } from '@univerjs/docs-ui';
-import type {
- DocBackground,
- Documents,
- DocumentSkeleton,
- IDocumentLayoutObject,
- IRenderContext,
- IRenderModule,
- Scene,
-} from '@univerjs/engine-render';
-import type { SlideDataModel } from '@univerjs/slides';
-import type { IEditorBridgeServiceVisibleParam } from '../services/slide-editor-bridge.service';
-import {
- createParagraphId,
- DEFAULT_EMPTY_DOCUMENT_VALUE,
- Direction,
- Disposable,
- DisposableCollection,
- EDITOR_ACTIVATED,
- FOCUSING_EDITOR_STANDALONE,
- FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE,
- HorizontalAlign,
- ICommandService,
- IContextService,
- Inject,
- IUndoRedoService,
- IUniverInstanceService,
- LocaleService,
- toDisposable,
- UniverInstanceType,
- VerticalAlign,
- WrapStrategy,
-} from '@univerjs/core';
-import {
- DocSelectionManagerService,
- DocSkeletonManagerService,
- RichTextEditingMutation,
-} from '@univerjs/docs';
-import {
- DOCS_COMPONENT_MAIN_LAYER_INDEX,
- DOCS_VIEW_KEY,
- DocSelectionRenderService,
- IEditorService,
- MoveCursorOperation,
- MoveSelectionOperation,
- ReplaceSnapshotCommand,
- VIEWPORT_KEY,
-} from '@univerjs/docs-ui';
-import {
- convertTextRotation,
- DeviceInputEventType,
- FIX_ONE_PIXEL_BLUR_OFFSET,
- fixLineWidthByScale,
- getCurrentTypeOfRenderer,
- IRenderManagerService,
- Rect,
- ScrollBar,
-} from '@univerjs/engine-render';
-import { ILayoutService, KeyCode } from '@univerjs/ui';
-import { filter } from 'rxjs';
-import { SetTextEditArrowOperation } from '../commands/operations/text-edit.operation';
-import { SLIDE_EDITOR_ID } from '../const';
-import { ISlideEditorBridgeService } from '../services/slide-editor-bridge.service';
-import { ISlideEditorManagerService } from '../services/slide-editor-manager.service';
-import { CursorChange } from '../type';
-
-const HIDDEN_EDITOR_POSITION = -1000;
-
-const EDITOR_INPUT_SELF_EXTEND_GAP = 5;
-
-const EDITOR_BORDER_SIZE = 2;
-
-interface ICanvasOffset {
- left: number;
- top: number;
-}
-
-export class SlideEditingRenderController extends Disposable implements IRenderModule {
- /**
- * It is used to distinguish whether the user has actively moved the cursor in the editor, mainly through mouse clicks.
- */
- private _cursorChange: CursorChange = CursorChange.InitialState;
-
- /** If the corresponding unit is active and prepared for editing. */
- private _isUnitEditing = false;
-
- private _d: Nullable<IDisposable>;
-
- constructor(
- private readonly _renderContext: IRenderContext<UnitModel>,
- @ILayoutService private readonly _layoutService: ILayoutService,
- @IUndoRedoService private readonly _undoRedoService: IUndoRedoService,
- @IContextService private readonly _contextService: IContextService,
- @IUniverInstanceService private readonly _instanceSrv: IUniverInstanceService,
- @IRenderManagerService private readonly _renderManagerService: IRenderManagerService,
- @ISlideEditorBridgeService private readonly _editorBridgeService: ISlideEditorBridgeService,
- @ISlideEditorManagerService private readonly _cellEditorManagerService: ISlideEditorManagerService,
- @Inject(DocSelectionManagerService) private readonly _textSelectionManagerService: DocSelectionManagerService,
- @ICommandService private readonly _commandService: ICommandService,
- @Inject(LocaleService) protected readonly _localService: LocaleService,
- @IEditorService private readonly _editorService: IEditorService
- ) {
- super();
-
- // EditingRenderController is per unit. It should only handle keyboard events when the unit is
- // the current of its type.
- this.disposeWithMe(this._instanceSrv.getCurrentTypeOfUnit$<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE).subscribe((slideDataModel) => {
- if (slideDataModel && slideDataModel.getUnitId() === this._renderContext.unitId) {
- this._d = this._init();
- } else {
- this._disposeCurrent();
-
- // Force ending editor when he switch to another workbook.
- if (this._isUnitEditing) {
- this._handleEditorInvisible({
- visible: false,
- eventType: DeviceInputEventType.Keyboard,
- keycode: KeyCode.ESC,
- unitId: this._renderContext.unitId,
- });
-
- this._isUnitEditing = false;
- }
- }
- }));
- this._initEditorVisibilityListener();
- }
-
- override dispose(): void {
- super.dispose();
- this._disposeCurrent();
- }
-
- private _disposeCurrent(): void {
- this._d?.dispose();
- this._d = null;
- }
-
- private _init(): IDisposable {
- const d = new DisposableCollection();
- this._subscribeToCurrentCell(d);
- this._initialKeyboardListener(d);
- this._initialCursorSync(d);
- this._listenEditorFocus(d);
- this._commandExecutedListener(d);
-
- // FIXME: we should not use React component to create editor render, it would make the control
- // flow not controllable.
- setTimeout(() => {
- this._cursorStateListener(d);
- }, 1000);
-
- return d;
- }
-
- private _initEditorVisibilityListener(): void {
- this.disposeWithMe(this._editorBridgeService.visible$
- // .pipe(distinctUntilChanged((prev, curr) => prev.visible === curr.visible))
- .subscribe((param) => {
- if (param.visible) {
- this._isUnitEditing = true;
- this._handleEditorVisible(param);
- } else if (this._isUnitEditing) {
- this._handleEditorInvisible(param);
- this._isUnitEditing = false;
- }
- }));
- }
-
- private _listenEditorFocus(d: DisposableCollection) {
- const renderConfig = this._getEditorObject();
- if (!renderConfig) return;
-
- d.add(renderConfig.document.onPointerDown$.subscribeEvent(() => {
- // ...
- }));
- }
-
- private _getEditorSkeleton(editorId: string) {
- return this._renderManagerService.getRenderUnitById(editorId)?.with(DocSkeletonManagerService).getSkeleton();
- }
-
- private _getEditorViewModel(editorId: string) {
- return this._renderManagerService.getRenderUnitById(editorId)?.with(DocSkeletonManagerService).getViewModel();
- }
-
- private _initialCursorSync(d: DisposableCollection) {
- d.add(this._cellEditorManagerService.focus$.pipe(filter((f) => !!f)).subscribe(() => {
- getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC, this._instanceSrv, this._renderManagerService)
- ?.with(DocSelectionRenderService)
- .sync();
- }));
- }
-
- /**
- * Set editorUnitId to curr doc.
- * @param d DisposableCollection
- */
- private _subscribeToCurrentCell(d: DisposableCollection) {
- // first part of editing.
- // startEditing --> _updateEditor --> slide-editor-bridge.service.ts@setEditorRect---> currentEditRectState$.next(editCellState)
- // 2nd part is startEditing --> changeVisible
- d.add(this._editorBridgeService.currentEditRectState$.subscribe((editCellState) => {
- if (editCellState == null) {
- return;
- }
-
- if (
- this._contextService.getContextValue(FOCUSING_EDITOR_STANDALONE) ||
- this._contextService.getContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE)
- ) {
- return;
- }
-
- const {
- position: { startX, endX },
- documentLayoutObject: { textRotation, wrapStrategy, documentModel },
- scaleX,
- editorUnitId,
- } = editCellState;
- const { vertexAngle: angle } = convertTextRotation(textRotation);
- documentModel!.updateDocumentId(editorUnitId);
-
- if (wrapStrategy === WrapStrategy.WRAP && angle === 0) {
- documentModel!.updateDocumentDataPageSize((endX - startX) / scaleX);
- }
-
- const snapshot = documentModel!.getSnapshot();
- const editorDocument = this._instanceSrv.getUnit(editorUnitId, UniverInstanceType.UNIVER_DOC);
- if (editorDocument == null) {
- this._instanceSrv.createUnit(UniverInstanceType.UNIVER_DOC, snapshot);
- } else {
- this._commandService.syncExecuteCommand(ReplaceSnapshotCommand.id, {
- unitId: editorUnitId,
- snapshot,
- });
- }
- this._instanceSrv.setCurrentUnitForType(editorUnitId);
- this._textSelectionManagerService.replaceDocRanges([{
- startOffset: 0,
- endOffset: 0,
- }]);
-
- // the valid pos of activate:
- // EditorContainer.tsx cellEditorManagerService.setFocus(true) -->
- // ---> _focus$.next --> editingRenderController
- // _textSelectionRenderManager.sync() --> _updateInputPosition --> activate(left, top)
-
- getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC, this._instanceSrv, this._renderManagerService)
- ?.with(DocSelectionRenderService)
- .activate(HIDDEN_EDITOR_POSITION, HIDDEN_EDITOR_POSITION);
- }));
- }
-
- /**
- * Set size and pos of editing area.
- * @param positionFromEditRectState
- * @param canvasOffset
- * @param documentSkeleton
- * @param documentLayoutObject
- * @param scaleX
- * @param scaleY
- */
- private _fitTextSize(
- positionFromEditRectState: IPosition,
- canvasOffset: ICanvasOffset,
- documentSkeleton: DocumentSkeleton,
- documentLayoutObject: IDocumentLayoutObject,
- scaleX: number = 1,
- scaleY: number = 1
- ) {
- //size & pos derives from [email protected]
- const { startX, startY, endX, endY } = positionFromEditRectState;
- const documentDataModel = documentLayoutObject.documentModel;
-
- if (documentDataModel == null) {
- return;
- }
-
- const { actualWidth, actualHeight } = this._predictingSize(
- positionFromEditRectState,
- canvasOffset,
- documentSkeleton,
- documentLayoutObject,
- scaleX,
- scaleY
- );
- const { verticalAlign, paddingData, fill } = documentLayoutObject;
-
- let editorWidth = endX - startX;
-
- let editorHeight = endY - startY;
-
- if (editorWidth < actualWidth) {
- editorWidth = actualWidth;
- }
-
- if (editorHeight < actualHeight) {
- editorHeight = actualHeight;
- // To restore the page margins for the skeleton.
- documentDataModel.updateDocumentDataMargin(paddingData);
- } else {
- // Set the top margin under vertical alignment.
- let offsetTop = 0;
-
- if (verticalAlign === VerticalAlign.MIDDLE) {
- offsetTop = (editorHeight - actualHeight) / 2 / scaleY;
- } else if (verticalAlign === VerticalAlign.TOP) {
- offsetTop = paddingData.t || 0;
- } else { // VerticalAlign.UNSPECIFIED follow the same rule as HorizontalAlign.BOTTOM.
- offsetTop = (editorHeight - actualHeight) / scaleY - (paddingData.b || 0);
- }
-
- // offsetTop /= scaleY;
- offsetTop = offsetTop < (paddingData.t || 0) ? paddingData.t || 0 : offsetTop;
-
- documentDataModel.updateDocumentDataMargin({
- t: offsetTop,
- });
- }
-
- // re-calculate skeleton(viewModel for component)
- documentSkeleton.calculate();
-
- this._editAreaProcessing(editorWidth, editorHeight, positionFromEditRectState, canvasOffset, fill, scaleX, scaleY);
- }
-
- /**
- * Mainly used to pre-calculate the width of the editor,
- * to determine whether it needs to be automatically widened.
- */
- private _predictingSize(
- actualRangeWithCoord: IPosition,
- canvasOffset: ICanvasOffset,
- documentSkeleton: DocumentSkeleton,
- documentLayoutObject: IDocumentLayoutObject,
- scaleX: number = 1,
- scaleY: number = 1
- ) {
- // startX and startY are the width and height after scaling.
- const { startX, endX } = actualRangeWithCoord;
-
- const { textRotation, wrapStrategy } = documentLayoutObject;
-
- const documentDataModel = documentLayoutObject.documentModel;
-
- const { vertexAngle: angle } = convertTextRotation(textRotation);
-
- const clientWidth = document.body.clientWidth;
-
- if (wrapStrategy === WrapStrategy.WRAP && angle === 0) {
- const { actualWidth, actualHeight } = documentSkeleton.getActualSize();
- // The skeleton obtains the original volume, which needs to be multiplied by the magnification factor.
- return {
- actualWidth: actualWidth * scaleX,
- actualHeight: actualHeight * scaleY,
- };
- }
-
- documentDataModel?.updateDocumentDataPageSize((clientWidth - startX - canvasOffset.left) / scaleX);
- documentSkeleton.calculate();
-
- const size = documentSkeleton.getActualSize();
-
- let editorWidth = endX - startX;
-
- if (editorWidth < size.actualWidth * scaleX + EDITOR_INPUT_SELF_EXTEND_GAP * scaleX) {
- editorWidth = size.actualWidth * scaleX + EDITOR_INPUT_SELF_EXTEND_GAP * scaleX;
- }
-
- // Scaling is handled by the renderer, so the skeleton only accepts the original width and height, which need to be divided by the magnification factor.
- documentDataModel?.updateDocumentDataPageSize(editorWidth / scaleX);
-
- /**
- * Do not rely on cell layout logic, depend on the document's internal alignment logic.
- */
- documentDataModel?.updateDocumentRenderConfig({
- horizontalAlign: HorizontalAlign.UNSPECIFIED,
- cellValueType: undefined,
- });
-
- return {
- actualWidth: editorWidth,
- actualHeight: size.actualHeight * scaleY,
- };
- }
-
- /**
- * control the size of editing area
- */
- // eslint-disable-next-line max-lines-per-function
- private _editAreaProcessing(
- editorWidth: number,
- editorHeight: number,
- positionFromEditRectState: IPosition,
- canvasOffset: ICanvasOffset,
- fill: Nullable<string>,
- scaleX: number = 1,
- scaleY: number = 1
- ) {
- const editorObject = this._getEditorObject();
-
- if (editorObject == null) {
- return;
- }
-
- function pxToNum(width: string): number {
- return Number.parseInt(width.replace('px', ''));
- }
-
- const engine = this._renderContext.engine;
- const canvasElement = engine.getCanvasElement();
- const canvasClientRect = canvasElement.getBoundingClientRect();
-
- // We should take the scale into account when canvas is scaled by CSS.
- const widthOfCanvas = pxToNum(canvasElement.style.width); // declared width
- const { top, left, width } = canvasClientRect; // real width affected by scale
- const scaleAdjust = width / widthOfCanvas;
-
- let { startX, startY } = positionFromEditRectState;
-
- startX += canvasOffset.left;
- startY += canvasOffset.top;
-
- const { document: documentComponent, scene: editorScene, engine: docEngine } = editorObject;
-
- const viewportMain = editorScene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
-
- const clientHeight =
- document.body.clientHeight -
- startY -
- canvasOffset.top -
- EDITOR_BORDER_SIZE * 2;
-
- const clientWidth = document.body.clientWidth - startX - canvasOffset.left;
-
- let physicHeight = editorHeight;
-
- let scrollBar = viewportMain?.getScrollBar() as Nullable<ScrollBar>;
-
- if (physicHeight > clientHeight) {
- physicHeight = clientHeight;
-
- if (scrollBar == null) {
- if (viewportMain) {
- const sb = new ScrollBar(viewportMain, { enableHorizontal: false, barSize: 8 });
- }
- } else {
- viewportMain?.resetCanvasSizeAndUpdateScroll();
- }
- } else {
- scrollBar = null;
- viewportMain?.getScrollBar()?.dispose();
- }
-
- editorWidth += scrollBar?.barSize || 0;
-
- editorWidth = Math.min(editorWidth, clientWidth);
-
- startX -= FIX_ONE_PIXEL_BLUR_OFFSET;
-
- startY -= FIX_ONE_PIXEL_BLUR_OFFSET;
-
- // physicHeight = editorHeight;
-
- this._addBackground(editorScene, editorWidth / scaleX, editorHeight / scaleY, fill);
-
- const { scaleX: precisionScaleX, scaleY: precisionScaleY } = editorScene.getPrecisionScale();
-
- editorScene.transformByState({
- width: editorWidth * scaleAdjust / scaleX,
- height: editorHeight * scaleAdjust / scaleY,
- scaleX: scaleX * scaleAdjust,
- scaleY: scaleY * scaleAdjust,
- });
-
- documentComponent.resize(editorWidth / scaleX, editorHeight / scaleY);
-
- /**
- * sometimes requestIdleCallback is invalid, so use setTimeout to ensure the successful execution of the resizeBySize method.
- * resize canvas
- * When modifying the selection area for a formula, it is necessary to add a setTimeout to ensure successful updating.
- */
- setTimeout(() => {
- docEngine.resizeBySize(
- fixLineWidthByScale(editorWidth, precisionScaleX),
- fixLineWidthByScale(physicHeight, precisionScaleY)
- );
- }, 0);
-
- const contentBoundingRect = this._layoutService.getContentElement().getBoundingClientRect();
- const canvasBoundingRect = canvasElement.getBoundingClientRect();
- startX = startX * scaleAdjust + (canvasBoundingRect.left - contentBoundingRect.left);
- startY = startY * scaleAdjust + (canvasBoundingRect.top - contentBoundingRect.top);
-
- // Update cell editor container position and size.
- this._cellEditorManagerService.setState({
- startX,
- startY,
- endX: editorWidth * scaleAdjust + startX,
- endY: physicHeight * scaleAdjust + startY,
- show: true,
- });
- }
-
- /**
- * Since the document does not support cell background color, an additional rect needs to be added.
- */
- private _addBackground(scene: Scene, editorWidth: number, editorHeight: number, fill?: Nullable<string>) {
- const fillRectKey = '_backgroundRectHelperColor_';
- const rect = scene.getObject(fillRectKey) as Rect;
-
- if (rect == null && fill == null) {
- return;
- }
-
- if (rect == null) {
- scene.addObjects(
- [
- new Rect(fillRectKey, {
- width: editorWidth,
- height: editorHeight,
- fill,
- evented: false,
- }),
- ],
- DOCS_COMPONENT_MAIN_LAYER_INDEX
- );
- } else if (fill == null) {
- rect.dispose();
- } else {
- rect.setProps({
- fill,
- });
-
- rect.transformByState({
- width: editorWidth,
- height: editorHeight,
- });
- }
- }
-
- /**
- * Show input area, resize input area and then place input to right place.
- * @TODO why do resize in show input area?
- * @param param
- */
- // handleVisible is the 2nd part of editing.
- // first part: startEditing --> _updateEditor
- // 2nd part: startEditing --> changeVisible --> slide-editor-bridge.render-controller.ts@changeVisible --> _editorBridgeService.changeVisible
- private _handleEditorVisible(param: IEditorBridgeServiceVisibleParam) {
- const { eventType } = param;
-
- // Change `CursorChange` to changed status, when formula bar clicked.
- this._cursorChange =
- [DeviceInputEventType.PointerDown, DeviceInputEventType.Dblclick].includes(eventType)
- ? CursorChange.CursorChange
- : CursorChange.StartEditor;
-
- const editCellState = this._editorBridgeService.getEditRectState();
- if (editCellState == null) {
- return;
- }
-
- const {
- position,
- documentLayoutObject,
- slideCardOffset: canvasOffset,
- scaleX,
- scaleY,
- editorUnitId,
- unitId,
- } = editCellState;
-
- const editorObject = this._getEditorObject();
-
- if (editorObject == null) {
- return;
- }
-
- const { scene } = editorObject;
-
- this._contextService.setContextValue(EDITOR_ACTIVATED, true);
-
- const { documentModel: documentDataModel } = documentLayoutObject;
- const skeleton = this._getEditorSkeleton(editorUnitId);
- if (!skeleton || !documentDataModel) {
- return;
- }
-
- // core function! set editing area size and pos
- this._fitTextSize(position, canvasOffset, skeleton, documentLayoutObject, scaleX, scaleY);
-
- // TODO: @JOCS, Get the position close to the cursor after clicking on the cell.
- const cursor = documentDataModel.getBody()!.dataStream.length - 2 || 0;
-
- scene.getViewport(VIEWPORT_KEY.VIEW_MAIN)?.scrollToViewportPos({
- viewportScrollX: Number.POSITIVE_INFINITY,
- });
-
- this._textSelectionManagerService.replaceDocRanges([
- {
- startOffset: cursor,
- endOffset: cursor,
- },
- ]);
-
- this._renderManagerService.getRenderUnitById(unitId)?.scene.resetCursor();
- }
-
- private _resetBodyStyle(body: IDocumentBody, removeStyle = false) {
- body.dataStream = DEFAULT_EMPTY_DOCUMENT_VALUE;
-
- if (body.textRuns != null) {
- if (body.textRuns.length === 1 && !removeStyle) {
- body.textRuns[0].st = 0;
- body.textRuns[0].ed = 1;
- } else {
- body.textRuns = undefined;
- }
- }
-
- if (body.paragraphs != null) {
- if (body.paragraphs.length === 1) {
- body.paragraphs[0].startIndex = 0;
- } else {
- body.paragraphs = [
- {
- startIndex: 0,
- paragraphId: createParagraphId(new Set()),
- },
- ];
- }
- }
-
- if (body.sectionBreaks != null) {
- body.sectionBreaks = undefined;
- }
-
- if (body.tables != null) {
- body.tables = undefined;
- }
-
- if (body.customRanges != null) {
- body.customRanges = undefined;
- }
-
- if (body.customBlocks != null) {
- body.customBlocks = undefined;
- }
- }
-
- /**
- * Should activate the editor when the user inputs text.
- * @param d DisposableCollection
- */
- private _initialKeyboardListener(d: DisposableCollection) {
- // d.add(this._textSelectionRenderManager.onInputBefore$.subscribe((config) => {
- // // const isFocusFormulaEditor = this._contextService.getContextValue(FORMULA_EDITOR_ACTIVATED);
- // // const isFocusSheets = this._contextService.getContextValue(FOCUSING_SHEET);
-
- // // // TODO@Jocs: should get editor instead of current doc
- // // const unitId = this._instanceSrv.getCurrentUniverDocInstance()?.getUnitId();
- // // if (unitId && isFocusSheets && !isFocusFormulaEditor && this._editorService.isSheetEditor(unitId)) {
- // // this._showEditorByKeyboard(config);
- // // }
- // }));
- }
-
- private _showEditorByKeyboard(config: Nullable<IEditorInputConfig>) {
- if (config == null) {
- //..
- }
-
- // const event = config.event as KeyboardEvent;
-
- // this._commandService.executeCommand(SetCellEditVisibleOperation.id, {
- // visible: true,
- // eventType: DeviceInputEventType.Keyboard,
- // keycode: event.which,
- // unitId: this._context.unitId,
- // });
- }
-
- private _commandExecutedListener(d: DisposableCollection) {
- const moveCursorOP = [SetTextEditArrowOperation.id];
- const editedMutations = [RichTextEditingMutation.id];
-
- d.add(this._commandService.onCommandExecuted((command: ICommandInfo) => {
- // Only should do something when it is the current editor.
- // FIXME: listen to command execution is pretty expensive. We should
- // have multi editor instances and only handle event from a single editor.
- if (this._editorService.getFocusId() !== SLIDE_EDITOR_ID) {
- // if (this._editorService.getFocusId() !== this._renderContext.unitId) {
- return;
- }
-
- if (moveCursorOP.includes(command.id)) {
- this._moveCursorCmdHandler(command);
- }
-
- if (editedMutations.includes(command.id)) {
- if (this._editorBridgeService.isVisible()) {
- this._editingChangedHandler();
- }
- }
- }));
- }
-
- private _moveCursorCmdHandler(command: ICommandInfo) {
- const params = command.params as IEditorBridgeServiceVisibleParam & { isShift: boolean };
- const { keycode, isShift } = params;
-
- /**
- * After the user enters the editor and actively moves the editor selection area with the mouse,
- * the up, down, left, and right keys can no longer switch editing cells,
- * but move the cursor within the editor instead.
- */
- if (keycode != null && this._cursorChange === CursorChange.CursorChange) {
- this._moveInEditor(keycode, isShift);
- } else {
- // TODO @Jocs: After we merging editor related controllers, this seems verbose.
- this._editorBridgeService.changeVisible(params);
- }
- }
-
- private _editingChangedHandler() {
- const editRect = this._editorBridgeService.getEditorRect();
- if (!editRect) {
- return;
- }
- const editingRichText = editRect.richTextObj;
- editingRichText.refreshDocumentByDocData();
- editingRichText.resizeToContentSize();
-
- const { unitId } = this._renderContext;
- this._handleEditorVisible({ visible: true, eventType: 3, unitId });
- }
-
- private _getEditorObject() {
- return getEditorObject(this._editorBridgeService.getCurrentEditorId(), this._renderManagerService);
- }
-
- private async _handleEditorInvisible(param: IEditorBridgeServiceVisibleParam) {
- const { keycode } = param;
-
- this._cursorChange = CursorChange.InitialState;
-
- this._exitInput(param);
-
- const editCellState = this._editorBridgeService.getEditRectState();
- if (editCellState == null) {
- return;
- }
-
- // const { unitId, documentLayoutObject } = editCellState;
-
- // If neither the formula bar editor nor the cell editor has been edited,
- // it is considered that the content has not changed and returns directly.
- const editorIsDirty = this._editorBridgeService.getEditorDirty();
- if (editorIsDirty === false) {
- this._moveCursor(keycode);
- return;
- }
-
- // moveCursor need to put behind of SetRangeValuesCommand, fix https://github.com/dream-num/univer/issues/1155
- this._moveCursor(keycode);
- }
-
- private _exitInput(param: IEditorBridgeServiceVisibleParam) {
- this._contextService.setContextValue(EDITOR_ACTIVATED, false);
-
- this._cellEditorManagerService.setState({
- show: param.visible,
- });
- const editorUnitId = this._editorBridgeService.getCurrentEditorId();
- if (editorUnitId == null) {
- return;
- }
- this._undoRedoService.clearUndoRedo(editorUnitId);
- }
-
- private _moveCursor(keycode?: KeyCode) {
- if (keycode == null) {
- return;
- }
-
- let direction = Direction.LEFT;
-
- switch (keycode) {
- case KeyCode.ENTER:
- direction = Direction.DOWN;
- break;
- case KeyCode.TAB:
- direction = Direction.RIGHT;
- break;
- case KeyCode.ARROW_DOWN:
- direction = Direction.DOWN;
- break;
- case KeyCode.ARROW_UP:
- direction = Direction.UP;
- break;
- case KeyCode.ARROW_LEFT:
- direction = Direction.LEFT;
- break;
- case KeyCode.ARROW_RIGHT:
- direction = Direction.RIGHT;
- break;
- }
- }
-
- /**
- * The user's operations follow the sequence of opening the editor and then moving the cursor.
- * The logic here predicts the user's first cursor movement behavior based on this rule
- */
- private _cursorStateListener(d: DisposableCollection) {
- const editorObject = this._getEditorObject();
- if (!editorObject) {
- return;
- }
- const { document: documentComponent } = editorObject;
-
- d.add(toDisposable(documentComponent.onPointerDown$.subscribeEvent(() => {
- if (this._cursorChange === CursorChange.StartEditor) {
- this._cursorChange = CursorChange.CursorChange;
- }
- })));
- }
-
- // TODO: @JOCS, is it necessary to move these commands MoveSelectionOperation\MoveCursorOperation to shortcut? and use multi-commands?
- private _moveInEditor(keycode: KeyCode, isShift: boolean) {
- let direction = Direction.LEFT;
- if (keycode === KeyCode.ARROW_DOWN) {
- direction = Direction.DOWN;
- } else if (keycode === KeyCode.ARROW_UP) {
- direction = Direction.UP;
- } else if (keycode === KeyCode.ARROW_RIGHT) {
- direction = Direction.RIGHT;
- }
-
- if (isShift) {
- this._commandService.executeCommand(MoveSelectionOperation.id, {
- direction,
- });
- } else {
- this._commandService.executeCommand(MoveCursorOperation.id, {
- direction,
- });
- }
- }
-}
-
-export function getEditorObject(
- unitId: Nullable<string>,
- renderManagerService: IRenderManagerService
-): Nullable<IDocObjectParam> {
- if (unitId == null) {
- return;
- }
-
- const currentRender = renderManagerService.getRenderUnitById(unitId);
-
- if (currentRender == null) {
- return;
- }
-
- const { mainComponent, scene, engine, components } = currentRender;
-
- const document = mainComponent as Documents;
- const docBackground = components.get(DOCS_VIEW_KEY.BACKGROUND) as DocBackground;
-
- return {
- document,
- docBackground,
- scene,
- engine,
- };
-}
diff --git a/packages/slides-ui/src/controllers/slide-editor-bridge.render-controller.ts b/packages/slides-ui/src/controllers/slide-editor-bridge.render-controller.ts
deleted file mode 100644
index 42c1754dba..0000000000
--- a/packages/slides-ui/src/controllers/slide-editor-bridge.render-controller.ts
+++ /dev/null
@@ -1,227 +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, UnitModel } from '@univerjs/core';
-import type { BaseObject, IRenderContext, IRenderModule, RichText, Scene, Slide } from '@univerjs/engine-render';
-import type { SlideDataModel } from '@univerjs/slides';
-import type { ISetEditorInfo } from '../services/slide-editor-bridge.service';
-import type { ISlideRichTextProps } from '../type';
-import { DisposableCollection, ICommandService, IUniverInstanceService, RxDisposable, UniverInstanceType } from '@univerjs/core';
-import { DeviceInputEventType, ObjectType } from '@univerjs/engine-render';
-import { Subject } from 'rxjs';
-import { UpdateSlideElementOperation } from '../commands/operations/update-element.operation';
-import { ISlideEditorBridgeService } from '../services/slide-editor-bridge.service';
-
-// interface ICanvasOffset {
-// left: number;
-// top: number;
-// }
-
-// enum CursorChange {
-// InitialState,
-// StartEditor,
-// CursorChange,
-// }
-
-export class SlideEditorBridgeRenderController extends RxDisposable implements IRenderModule {
- /**
- * It is used to distinguish whether the user has actively moved the cursor in the editor, mainly through mouse clicks.
- */
- // private _cursorChange: CursorChange = CursorChange.InitialState;
-
- /** If the corresponding unit is active and prepared for editing. */
- // private _isUnitEditing = false;
-
- setSlideTextEditor$: Subject<ISlideRichTextProps> = new Subject();
-
- private _curRichText = null as RichText | null;
-
- private _d: Nullable<IDisposable>;
-
- constructor(
- private readonly _renderContext: IRenderContext<UnitModel>,
- @IUniverInstanceService private readonly _instanceSrv: IUniverInstanceService,
- @ICommandService private readonly _commandService: ICommandService,
- @ISlideEditorBridgeService private readonly _editorBridgeService: ISlideEditorBridgeService
- ) {
- super();
-
- this.disposeWithMe(this._instanceSrv.getCurrentTypeOfUnit$<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE).subscribe((slideDataModel) => {
- if (slideDataModel && slideDataModel.getUnitId() === this._renderContext.unitId) {
- this._d = this._init();
- } else {
- this._disposeCurrent();
- }
- }));
- }
-
- private _init(): IDisposable {
- const d = new DisposableCollection();
- this._initEventListener(d);
- return d;
- }
-
- private _disposeCurrent(): void {
- this._d?.dispose();
- this._d = null;
- }
-
- private _setEditorRect(pageId: string, targetObject: RichText) {
- this._curRichText = targetObject as RichText;
- const { scene, engine } = this._renderContext;
- const unitId = this._renderContext.unitId;
-
- const setEditorRect: ISetEditorInfo = {
- scene,
- engine,
- unitId,
- pageId,
- richTextObj: targetObject,
- };
-
- this._editorBridgeService.setEditorRect(setEditorRect);
- }
-
- private _initEventListener(d: DisposableCollection) {
- const listenersForPageScene = (scene: Scene) => {
- const transformer = scene.getTransformer();
- if (!transformer) return;
-
- d.add(transformer.clearControl$.subscribe(() => {
- this.setEditorVisible(false);
- this.pickOtherObjects();
- }));
- d.add(transformer.createControl$.subscribe(() => {
- this.setEditorVisible(false);
- }));
-
- // d.add(transformer.changeStart$.subscribe((param: IChangeObserverConfig) => {
- // const target = param.target;
- // if (!target) return;
- // if (target === this._curRichText) {
- // // do nothing
- // } else {
- // this.pickOtherObjects();
- // }
- // }));
-
- d.add(scene.onDblclick$.subscribeEvent(() => {
- transformer.clearControls();
- const selectedObjects = transformer.getSelectedObjectMap();
- const object = selectedObjects.values().next().value as Nullable<BaseObject>;
- if (!object) return;
-
- if (object.objectType !== ObjectType.RICH_TEXT) {
- this.pickOtherObjects();
- } else {
- this.startEditing(scene.sceneKey, object as RichText);
- }
- }));
-
- d.add(this._instanceSrv.focused$.subscribe((fc: Nullable<string>) => {
- this.endEditing();
- }));
- };
-
- // const model = this._instanceSrv.getCurrentUnitOfType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE);
- // const pagesMap = model?.getPages() ?? {};
- // const pages = Object.values(pagesMap);
-
- const { mainComponent } = this._renderContext;
- const slide = mainComponent as Slide;
-
- // for new pages created by user
- // TODO: better only one pageScene listener. but how?
- // TODO: this controller is in render stage. but default page created in ready stage.
- slide.subSceneChanged$.subscribeEvent((pageScene: Scene) => {
- listenersForPageScene(pageScene);
- });
-
- // for default pages that already exist
- const pageSceneList = Array.from((mainComponent as Slide).getSubScenes().values());
- for (let i = 0; i < pageSceneList.length; i++) {
- const pageScene = pageSceneList[i] as Scene;
- listenersForPageScene(pageScene);
- }
- }
-
- pickOtherObjects() {
- this.endEditing();
- }
-
- /**
- * invoked when picking other object.
- *
- * save editing state to curr richText.
- */
- endEditing() {
- if (!this._curRichText) return;
- this.setEditorVisible(false);
- const curRichText = this._curRichText;
-
- const slideData = this._instanceSrv.getCurrentUnitOfType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE);
- if (!slideData) return false;
- curRichText.refreshDocumentByDocData();
- curRichText.resizeToContentSize();
-
- const richText: Record<string, any> = {
- bl: 1,
- fs: curRichText.fs,
- text: curRichText.text,
- };
- const textRuns = curRichText.documentData.body?.textRuns;
- if (textRuns && textRuns.length) {
- const textRun = textRuns[0];
- const ts = textRun.ts;
-
- richText.cl = ts?.cl;
- }
-
- this._commandService.executeCommand(UpdateSlideElementOperation.id, {
- unitId: this._renderContext.unitId,
- oKey: curRichText?.oKey,
- props: {
- richText,
- },
- });
- this._curRichText = null;
- }
-
- /**
- * TODO calling twice ????
- * editingParam derives from RichText object.
- *
- * TODO @lumixraku need scale param
- * @param target
- */
- startEditing(pageId: string, target: RichText) {
- // this.setSlideTextEditor$.next({ content, rect });
-
- this._setEditorRect(pageId, target);
- this.setEditorVisible(true);
- }
-
- setEditorVisible(visible: boolean) {
- // if editor is visible, hide curr RichTerxtObject
- if (visible) {
- this._curRichText?.hide();
- } else {
- this._curRichText?.show();
- }
- const { unitId } = this._renderContext;
- this._editorBridgeService.changeVisible({ visible, eventType: DeviceInputEventType.PointerDown, unitId });
- }
-}
diff --git a/packages/slides-ui/src/controllers/slide.render-controller.ts b/packages/slides-ui/src/controllers/slide.render-controller.ts
deleted file mode 100644
index d8aa79d7bf..0000000000
--- a/packages/slides-ui/src/controllers/slide.render-controller.ts
+++ /dev/null
@@ -1,471 +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 { EventState, IColorStyle, Nullable, UnitModel } from '@univerjs/core';
-import type { BaseObject, IRenderContext, IRenderModule, IWheelEvent } from '@univerjs/engine-render';
-import type { IPageElement, ISlidePage, SlideDataModel } from '@univerjs/slides';
-import type { PageID } from '../type';
-import { debounce, getColorStyle, Inject, Injector, IUniverInstanceService, RxDisposable, UniverInstanceType } from '@univerjs/core';
-import {
- getCurrentTypeOfRenderer,
- IRenderManagerService,
- Rect,
- Scene,
- ScrollBar,
- Slide,
- Viewport,
-} from '@univerjs/engine-render';
-import { ObjectProvider, SLIDE_KEY } from '@univerjs/slides';
-
-export class SlideRenderController extends RxDisposable implements IRenderModule {
- private _objectProvider: ObjectProvider | null = null;
-
- constructor(
- private readonly _renderContext: IRenderContext<UnitModel>,
- @Inject(Injector) private readonly _injector: Injector,
- @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
- @IRenderManagerService private readonly _renderManagerService: IRenderManagerService
-
- ) {
- super();
- this._objectProvider = this._injector.createInstance(ObjectProvider);
- this._addNewRender();
- }
-
- private _addNewRender() {
- const { unitId, engine, scene } = this._renderContext;
- const slideDataModel = this._getCurrUnitModel();
-
- if (!slideDataModel) return;
-
- // createRender moved to slideRenderService@this._instanceSrv.getAllUnitsForType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE).forEach((slideModel)
- // this._renderManagerService.createRender(unitId);
-
- //#region scene subscribe
- // const { engine, scene } = currentRender;
- const observer = engine.onTransformChange$.subscribeEvent(() => {
- this._scrollToCenter();
- // add once
- observer?.unsubscribe();
- });
- engine.onTransformChange$.subscribeEvent(() => {
- setTimeout(() => {
- this.createThumbs();
- }, 300);
- });
-
- const viewMain = new Viewport(SLIDE_KEY.VIEW, scene, {
- left: 0,
- top: 0,
- bottom: 0,
- right: 0,
- explicitViewportWidthSet: false,
- explicitViewportHeightSet: false,
- isWheelPreventDefaultX: true,
- });
- scene.attachControl();
- scene.onMouseWheel$.subscribeEvent((evt: unknown, state: EventState) => {
- const e = evt as IWheelEvent;
- if (e.ctrlKey) {
- const deltaFactor = Math.abs(e.deltaX);
- let scrollNum = deltaFactor < 40 ? 0.2 : deltaFactor < 80 ? 0.4 : 0.2;
- scrollNum *= e.deltaY > 0 ? -1 : 1;
- if (scene.scaleX < 1) {
- scrollNum /= 2;
- }
-
- if (scene.scaleX + scrollNum > 4) {
- scene.scale(4, 4);
- } else if (scene.scaleX + scrollNum < 0.1) {
- scene.scale(0.1, 0.1);
- } else {
- const value = e.deltaY > 0 ? 0.1 : -0.1;
- // scene.scaleBy(scrollNum, scrollNum);
- e.preventDefault();
- }
- } else {
- viewMain.onMouseWheel(e, state);
- }
- });
- scene.onFileLoaded$.subscribeEvent(() => {
- this._refreshThumb();
- });
- //#endregion
-
- ScrollBar.attachTo(viewMain);
- // this._renderManagerService.setCurrent(unitId);
-
- // #region create slide
- const slide = this._createSlide(scene);
- this._renderContext.mainComponent = slide;
- this._createSlidePages(slideDataModel, slide);
- this.createThumbs();
- // #endregion
-
- engine.runRenderLoop(() => {
- scene.render();
- });
- }
-
- private _scrollToCenter() {
- const mainScene = this._currentRender()?.scene;
- const viewMain = mainScene?.getViewport(SLIDE_KEY.VIEW);
- const getCenterPositionViewPort = this._getCenterPositionViewPort(mainScene);
- if (!viewMain || !getCenterPositionViewPort) return;
- const { left: viewPortLeft, top: viewPortTop } = getCenterPositionViewPort;
-
- const { x, y } = viewMain.transViewportScroll2ScrollValue(viewPortLeft, viewPortTop);
-
- viewMain.scrollToBarPos({
- x,
- y,
- });
- }
-
- private _currentRender() {
- return getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_SLIDE, this._univerInstanceService, this._renderManagerService);
- }
-
- private _refreshThumb = debounce(() => {
- this.createThumbs();
- }, 300);
-
- /**
- * @param mainScene
- */
- private _createSlide(mainScene: Scene) {
- const model = this._univerInstanceService.getCurrentUnitOfType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE)!;
-
- const { width: sceneWidth, height: sceneHeight } = mainScene;
-
- const pageSize = model.getPageSize();
-
- const { width = 100, height = 100 } = pageSize;
-
- const slideComponent = new Slide(SLIDE_KEY.COMPONENT, {
- left: (sceneWidth - width) / 2,
- top: (sceneHeight - height) / 2,
- width,
- height,
- zIndex: 10,
- });
-
- // slideComponent.enableNav();
-
- slideComponent.enableSelectedClipElement();
-
- mainScene.addObject(slideComponent);
-
- return slideComponent;
- }
-
- private _addBackgroundRect(scene: Scene, fill: IColorStyle) {
- const model = this._univerInstanceService.getCurrentUnitOfType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE)!;
-
- const pageSize = model.getPageSize();
-
- const { width: pageWidth = 0, height: pageHeight = 0 } = pageSize;
-
- const page = new Rect('canvas', {
- left: 0,
- top: 0,
- width: pageWidth,
- height: pageHeight,
- strokeWidth: 1,
- stroke: 'rgba(198,198,198,1)',
- fill: getColorStyle(fill) || 'rgba(255,255,255,1)',
- zIndex: 0,
- evented: false,
- });
- scene.addObject(page, 0);
- }
-
- private _getCenterPositionViewPort(mainScene?: Scene) {
- if (!mainScene) return { left: 0, top: 0 };
- const { width, height } = mainScene;
-
- const engine = mainScene.getEngine();
-
- const canvasWidth = engine?.width || 0;
- const canvasHeight = engine?.height || 0;
-
- return {
- left: (width - canvasWidth) / 2,
- top: (height - canvasHeight) / 2,
- };
- }
-
- private _thumbSceneRender(pageId: string, slide: Slide) {
- const render = this._renderManagerService.getRenderUnitById(pageId);
-
- if (render == null) {
- return;
- }
-
- const { engine: thumbEngine } = render;
-
- if (thumbEngine == null) {
- return;
- }
-
- const { width, height } = slide;
-
- const { width: pageWidth = width, height: pageHeight = height } = thumbEngine;
-
- const thumbContext = thumbEngine.getCanvas().getContext();
-
- slide.renderToThumb(thumbContext, pageId, pageWidth / width, pageHeight / height);
- }
-
- /**
- * CreateScene by pages, and activate first one.
- * @param slideDataModel
- * @param slide
- */
- private _createSlidePages(slideDataModel: SlideDataModel, slide: Slide) {
- const pages = slideDataModel.getPages();
-
- const pageOrder = slideDataModel.getPageOrder();
-
- if (!pages || !pageOrder) {
- return;
- }
-
- if (pageOrder.length === 0) {
- return;
- }
-
- for (let i = 0, len = pageOrder.length; i < len; i++) {
- const pageId = pageOrder[i];
-
- this.createPageScene(pageId, pages[pageId]);
-
- this._createThumb(pageId);
- }
-
- // setTimeout(() => {
- // for (let i = 0, len = pageOrder.length; i < len; i++) {
- // const pageId = pageOrder[i];
-
- // this._thumbSceneRender(pageId, slide);
- // }
- // }, 0);
-
- slide.activeFirstPage();
- }
-
- private _createThumb(pageId: string) {
- this._renderManagerService.createRender(pageId);
- }
-
- /**
- * SlideDataModel is UnitModel
- */
- private _getCurrUnitModel() {
- // return this._univerInstanceService.getCurrentUnitOfType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE)!;
-
- return this._renderContext.unit as SlideDataModel;
- }
-
- activePage(_pageId?: string) {
- let pageId = _pageId;
- const model = this._getCurrUnitModel();
- let page: Nullable<ISlidePage>;
- if (pageId) {
- page = model.getPage(pageId);
- } else {
- const pageElements = model.getPages();
- const pageOrder = model.getPageOrder();
- if (pageOrder == null || pageElements == null) {
- return;
- }
- page = pageElements[pageOrder[0]];
-
- pageId = page.id;
- }
-
- const render = this._currentRender();
-
- if (page == null || render == null || render.mainComponent == null) {
- return;
- }
-
- const { id } = page;
-
- const slide = render.mainComponent as Slide;
-
- model.setActivePage(page);
-
- if (slide?.hasPage(id)) {
- slide.changePage(id);
- return;
- }
-
- this.createPageScene(id, page);
- }
-
- createThumbs() {
- const slideDataModel = this._getCurrUnitModel();
- const pageOrder = slideDataModel.getPageOrder();
-
- const render = this._currentRender();
-
- if (!pageOrder || !render) {
- return;
- }
-
- if (pageOrder.length === 0) {
- return;
- }
-
- for (let i = 0, len = pageOrder.length; i < len; i++) {
- const pageId = pageOrder[i];
-
- this._thumbSceneRender(pageId, render.mainComponent as Slide);
- }
- }
-
- /**
- * Create scene by page and set to _sceneMap.
- * @param pageId
- * @param page
- */
- createPageScene(pageId: string, page: ISlidePage): Nullable<Scene> {
- // const render = this._currentRender();
- const render = this._renderContext;
- if (!render || !this._objectProvider) {
- return;
- }
-
- const { scene: mainScene, mainComponent } = render;
-
- const slide = mainComponent as Slide;
- const { width, height } = slide;
-
- const pageScene = new Scene(pageId, slide, {
- width,
- height,
- });
-
- const viewMain = new Viewport(`PageViewer_${pageId}`, pageScene, {
- left: 0,
- top: 0,
- bottom: 0,
- right: 0,
- explicitViewportWidthSet: false,
- explicitViewportHeightSet: false,
- });
- viewMain.closeClip();
-
- const { pageElements, pageBackgroundFill } = page;
-
- // SceneViewers
- const objects = this._objectProvider.convertToRenderObjects(pageElements, mainScene);
- if (!objects || !slide) return;
-
- this._addBackgroundRect(pageScene, pageBackgroundFill);
- pageScene.addObjects(objects);
-
- pageScene.initTransformer();
- objects.forEach((object) => {
- pageScene.attachTransformerTo(object);
- });
-
- const transformer = pageScene.getTransformer();
-
- transformer?.changeEnd$.subscribe(() => {
- this._thumbSceneRender(pageId, slide);
- });
-
- transformer?.clearControl$.subscribe(() => {
- this._thumbSceneRender(pageId, slide);
- });
-
- // add SubScene
- slide.addPageScene(pageScene);
-
- return pageScene;
- }
-
- /**
- * Get pageScene from Slide.
- * @param pageId
- * @returns {Scene, Engine, UnitModel} scene & engine & unit from renderContext
- */
- getPageRenderUnit(pageId: PageID) {
- //pageScene was added to the mainComponent(Slide) in createPageScene --> slide.addPageScene
- const subsceneMap = (this._renderContext.mainComponent as Slide).getSubScenes();
- const pageScene = subsceneMap.get(pageId) as unknown as Scene;
- const { engine, unit } = this._renderContext;
- return {
- scene: pageScene,
- engine,
- unit,
- };
- }
-
- createObjectToPage(element: IPageElement, pageID: PageID): Nullable<BaseObject> {
- const { scene } = this.getPageRenderUnit(pageID);
-
- if (!scene || !this._objectProvider) {
- return;
- }
- const object = this._objectProvider.convertToRenderObject(element, scene);
- if (object) {
- scene.addObject(object);
- scene.attachTransformerTo(object);
- scene.getLayer().makeDirty();
- return object;
- }
- }
-
- setObjectActiveByPage(obj: BaseObject, pageID: PageID) {
- const { scene } = this.getPageRenderUnit(pageID);
- if (!scene) return;
- const transformer = scene.getTransformer();
- transformer?.activeAnObject(obj);
- }
-
- removeObjectById(id: string, pageID: PageID) {
- const { scene } = this.getPageRenderUnit(pageID);
- if (!scene) return;
- scene.removeObject(id);
- const transformer = scene.getTransformer();
- transformer?.clearControls();
- }
-
- appendPage() {
- const model = this._getCurrUnitModel();
- const page = model.getBlankPage();
- const render = this._currentRender();
-
- if (page == null || render == null || render.mainComponent == null) {
- return;
- }
-
- const { id: pageId } = page;
-
- const slide = render.mainComponent as Slide;
- const scene = this.createPageScene(pageId, page);
-
- if (slide && scene) {
- slide.addPageScene(scene);
- }
-
- model.appendPage(page);
- model.setActivePage(page);
- }
-}
diff --git a/packages/slides-ui/src/controllers/ui.controller.ts b/packages/slides-ui/src/controllers/ui.controller.ts
deleted file mode 100644
index 04e09eea49..0000000000
--- a/packages/slides-ui/src/controllers/ui.controller.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 { Disposable, ICommandService, Inject, Injector } from '@univerjs/core';
-import { BuiltInUIPart, connectInjector, IMenuManagerService, IShortcutService, IUIPartsService } from '@univerjs/ui';
-import { ActivateSlidePageOperation } from '../commands/operations/activate.operation';
-import { AppendSlideOperation } from '../commands/operations/append-slide.operation';
-import { DeleteSlideElementOperation } from '../commands/operations/delete-element.operation';
-import { InsertSlideFloatImageCommand } from '../commands/operations/insert-image.operation';
-import {
- InsertSlideShapeEllipseCommand,
- InsertSlideShapeEllipseOperation,
- InsertSlideShapeRectangleCommand,
- InsertSlideShapeRectangleOperation,
- ToggleSlideEditSidebarOperation,
-} from '../commands/operations/insert-shape.operation';
-import { SlideAddTextCommand, SlideAddTextOperation } from '../commands/operations/insert-text.operation';
-import { SetSlidePageThumbOperation } from '../commands/operations/set-thumb.operation';
-import { SetTextEditArrowOperation } from '../commands/operations/text-edit.operation';
-import { UpdateSlideElementOperation } from '../commands/operations/update-element.operation';
-import { menuSchema } from '../menu/schema';
-import { SlideEditorContainer } from '../views/editor-container/EditorContainer';
-import { SlideSideBar } from '../views/slide-bar/SlideBar';
-import { EditorDeleteLeftShortcut, generateArrowSelectionShortCutItem } from './shortcuts/editor.shortcuts';
-
-/**
- * This controller registers UI parts of slide workbench to the base-ui workbench.
- */
-export class SlidesUIController extends Disposable {
- constructor(
- @Inject(Injector) protected readonly _injector: Injector,
- @IMenuManagerService protected readonly _menuManagerService: IMenuManagerService,
- @IUIPartsService protected readonly _uiPartsService: IUIPartsService,
- @ICommandService protected readonly _commandService: ICommandService,
- @IShortcutService protected readonly _shortcutService: IShortcutService
- ) {
- super();
-
- this._initCommands();
- this._initUIComponents();
- this._initMenus();
- this._initShortcuts();
- }
-
- private _initMenus(): void {
- this._menuManagerService.mergeMenu(menuSchema);
- }
-
- private _initCommands(): void {
- [
- AppendSlideOperation,
- ActivateSlidePageOperation,
- SetSlidePageThumbOperation,
- InsertSlideFloatImageCommand,
- SlideAddTextOperation,
- SlideAddTextCommand,
- InsertSlideShapeEllipseCommand,
- InsertSlideShapeEllipseOperation,
- InsertSlideShapeRectangleOperation,
- InsertSlideShapeRectangleCommand,
- ToggleSlideEditSidebarOperation,
- DeleteSlideElementOperation,
- UpdateSlideElementOperation,
-
- // commands for editor
- SetTextEditArrowOperation,
-
- ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
- }
-
- protected _initUIComponents(): void {
- this.disposeWithMe(
- this._uiPartsService.registerComponent(BuiltInUIPart.LEFT_SIDEBAR, () => connectInjector(SlideSideBar, this._injector))
- );
-
- this.disposeWithMe(
- this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(SlideEditorContainer, this._injector))
- );
- }
-
- private _initShortcuts(): void {
- [
- EditorDeleteLeftShortcut,
- ...generateArrowSelectionShortCutItem(),
- ].forEach((item) => {
- this.disposeWithMe(this._shortcutService.registerShortcut(item));
- });
- }
-}
diff --git a/packages/slides-ui/src/global.css b/packages/slides-ui/src/global.css
deleted file mode 100644
index 7c05d4ddc4..0000000000
--- a/packages/slides-ui/src/global.css
+++ /dev/null
@@ -1,2 +0,0 @@
-@tailwind components;
-@tailwind utilities;
diff --git a/packages/slides-ui/src/index.ts b/packages/slides-ui/src/index.ts
deleted file mode 100644
index 1cf54e678b..0000000000
--- a/packages/slides-ui/src/index.ts
+++ /dev/null
@@ -1,41 +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 { ActivateSlidePageOperation } from './commands/operations/activate.operation';
-export { AppendSlideOperation } from './commands/operations/append-slide.operation';
-export { DeleteSlideElementOperation } from './commands/operations/delete-element.operation';
-export { InsertSlideFloatImageCommand } from './commands/operations/insert-image.operation';
-export {
- InsertSlideShapeEllipseCommand,
- InsertSlideShapeEllipseOperation,
- InsertSlideShapeRectangleCommand,
- InsertSlideShapeRectangleOperation,
-} from './commands/operations/insert-shape.operation';
-export { SlideAddTextCommand, SlideAddTextOperation } from './commands/operations/insert-text.operation';
-export { SetSlidePageThumbOperation } from './commands/operations/set-thumb.operation';
-export { UpdateSlideElementOperation } from './commands/operations/update-element.operation';
-export type { IUniverSlidesUIConfig } from './config/config';
-export { SLIDE_EDITOR_ID } from './const';
-export { CanvasView } from './controllers/canvas-view';
-export { SlidesUIController } from './controllers/ui.controller';
-export { SLIDES_IMAGE_MENU_ID } from './menu/image.menu';
-export { menuSchema as SlidesUIMenuSchema } from './menu/schema';
-export { SHAPE_MENU_ID } from './menu/shape.menu';
-export { UniverSlidesUIPlugin } from './plugin';
-export { ISlideEditorBridgeService } from './services/slide-editor-bridge.service';
-export { SlideCanvasPopMangerService } from './services/slide-popup-manager.service';
diff --git a/packages/slides-ui/src/locale/ar-SA.ts b/packages/slides-ui/src/locale/ar-SA.ts
deleted file mode 100644
index b5ea25c489..0000000000
--- a/packages/slides-ui/src/locale/ar-SA.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: 'إلحاق شريحة',
-
- text: {
- insert: {
- title: 'إدراج نص',
- },
- },
-
- shape: {
- insert: {
- title: 'إدراج شكل',
- rectangle: 'إدراج مستطيل',
- ellipse: 'إدراج قطع ناقص',
- },
- },
-
- image: {
- insert: {
- title: 'إدراج صورة',
- float: 'إدراج صورة عائمة',
- },
- },
-
- popup: {
- edit: 'تحرير',
- delete: 'حذف',
- },
-
- sidebar: {
- text: 'تحرير النص',
- shape: 'تحرير الشكل',
- image: 'تحرير الصورة',
- },
-
- 'image-panel': {
- arrange: {
- title: 'ترتيب',
- forward: 'إحضار إلى الأمام',
- backward: 'إرسال إلى الخلف',
- front: 'إحضار إلى المقدمة',
- back: 'إرسال إلى المؤخرة',
- },
- transform: {
- title: 'تحويل',
- width: 'العرض (بكسل)',
- height: 'الارتفاع (بكسل)',
- x: 'X (بكسل)',
- y: 'Y (بكسل)',
- rotate: 'تدوير (°)',
- },
- },
- panel: {
- fill: {
- title: 'لون التعبئة',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/ca-ES.ts b/packages/slides-ui/src/locale/ca-ES.ts
deleted file mode 100644
index 336f903d53..0000000000
--- a/packages/slides-ui/src/locale/ca-ES.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: 'Afegeix diapositiva',
-
- text: {
- insert: {
- title: 'Insereix text',
- },
- },
-
- shape: {
- insert: {
- title: 'Insereix forma',
- rectangle: 'Insereix rectangle',
- ellipse: 'Insereix el·lipse',
- },
- },
-
- image: {
- insert: {
- title: 'Insereix imatge',
- float: 'Insereix imatge flotant',
- },
- },
-
- popup: {
- edit: 'Edita',
- delete: 'Elimina',
- },
-
- sidebar: {
- text: 'Edita text',
- shape: 'Edita forma',
- image: 'Edita imatge',
- },
-
- 'image-panel': {
- arrange: {
- title: 'Organitza',
- forward: 'Porta endavant',
- backward: 'Envia enrere',
- front: 'Porta al davant',
- back: 'Envia al fons',
- },
- transform: {
- title: 'Transforma',
- width: 'Amplada (px)',
- height: 'Alçada (px)',
- x: 'X (px)',
- y: 'Y (px)',
- rotate: 'Gira (°)',
- },
- },
- panel: {
- fill: {
- title: 'Color de farciment',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/de-DE.ts b/packages/slides-ui/src/locale/de-DE.ts
deleted file mode 100644
index f4652f87db..0000000000
--- a/packages/slides-ui/src/locale/de-DE.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: 'Folie anhängen',
-
- text: {
- insert: {
- title: 'Text einfügen',
- },
- },
-
- shape: {
- insert: {
- title: 'Form einfügen',
- rectangle: 'Rechteck einfügen',
- ellipse: 'Ellipse einfügen',
- },
- },
-
- image: {
- insert: {
- title: 'Bild einfügen',
- float: 'Schwebendes Bild einfügen',
- },
- },
-
- popup: {
- edit: 'Bearbeiten',
- delete: 'Löschen',
- },
-
- sidebar: {
- text: 'Text bearbeiten',
- shape: 'Form bearbeiten',
- image: 'Bild bearbeiten',
- },
-
- 'image-panel': {
- arrange: {
- title: 'Anordnen',
- forward: 'Nach vorne',
- backward: 'Nach hinten',
- front: 'In den Vordergrund',
- back: 'In den Hintergrund',
- },
- transform: {
- title: 'Transformieren',
- width: 'Breite (px)',
- height: 'Höhe (px)',
- x: 'X (px)',
- y: 'Y (px)',
- rotate: 'Drehen (°)',
- },
- },
- panel: {
- fill: {
- title: 'Füllfarbe',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/en-US.ts b/packages/slides-ui/src/locale/en-US.ts
deleted file mode 100644
index 8172c2e4f3..0000000000
--- a/packages/slides-ui/src/locale/en-US.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.
- */
-
-const locale = {
- 'slides-ui': {
- append: 'Append Slide',
-
- text: {
- insert: {
- title: 'Insert Text',
- },
- },
-
- shape: {
- insert: {
- title: 'Insert Shape',
- rectangle: 'Insert Rectangle',
- ellipse: 'Insert Ellipse',
- },
- },
-
- image: {
- insert: {
- title: 'Insert Image',
- float: 'Insert Float Image',
- },
- },
-
- popup: {
- edit: 'Edit',
- delete: 'Delete',
- },
-
- sidebar: {
- text: 'Edit Text',
- shape: 'Edit Shape',
- image: 'Edit Image',
- },
-
- 'image-panel': {
- arrange: {
- title: 'Arrange',
- forward: 'Bring Forward',
- backward: 'Send Backward',
- front: 'Bring to Front',
- back: 'Send to Back',
- },
- transform: {
- title: 'Transform',
- width: 'Width (px)',
- height: 'Height (px)',
- x: 'X (px)',
- y: 'Y (px)',
- rotate: 'Rotate (°)',
- },
- },
- panel: {
- fill: {
- title: 'Fill Color',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/es-ES.ts b/packages/slides-ui/src/locale/es-ES.ts
deleted file mode 100644
index 09aa287cb4..0000000000
--- a/packages/slides-ui/src/locale/es-ES.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: 'Añadir diapositiva',
-
- text: {
- insert: {
- title: 'Insertar texto',
- },
- },
-
- shape: {
- insert: {
- title: 'Insertar forma',
- rectangle: 'Insertar rectángulo',
- ellipse: 'Insertar elipse',
- },
- },
-
- image: {
- insert: {
- title: 'Insertar imagen',
- float: 'Insertar imagen flotante',
- },
- },
-
- popup: {
- edit: 'Editar',
- delete: 'Eliminar',
- },
-
- sidebar: {
- text: 'Editar texto',
- shape: 'Editar forma',
- image: 'Editar imagen',
- },
-
- 'image-panel': {
- arrange: {
- title: 'Organizar',
- forward: 'Traer adelante',
- backward: 'Enviar atrás',
- front: 'Traer al frente',
- back: 'Enviar al fondo',
- },
- transform: {
- title: 'Transformar',
- width: 'Ancho (px)',
- height: 'Alto (px)',
- x: 'X (px)',
- y: 'Y (px)',
- rotate: 'Rotar (°)',
- },
- },
- panel: {
- fill: {
- title: 'Color de relleno',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/fa-IR.ts b/packages/slides-ui/src/locale/fa-IR.ts
deleted file mode 100644
index 60f6289171..0000000000
--- a/packages/slides-ui/src/locale/fa-IR.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: 'اضافه کردن اسلاید',
-
- text: {
- insert: {
- title: 'درج متن',
- },
- },
-
- shape: {
- insert: {
- title: 'درج شکل',
- rectangle: 'درج مستطیل',
- ellipse: 'بیضی را درج کنید',
- },
- },
-
- image: {
- insert: {
- title: 'درج تصویر',
- float: 'درج تصویر شناور',
- },
- },
-
- popup: {
- edit: 'ویرایش',
- delete: 'حذف',
- },
-
- sidebar: {
- text: 'ویرایش متن',
- shape: 'ویرایش شکل',
- image: 'ویرایش تصویر',
- },
-
- 'image-panel': {
- arrange: {
- title: 'ترتیب‌دهی',
- forward: 'آوردن به جلو',
- backward: 'فرستادن به عقب',
- front: 'آوردن به جلوی همه',
- back: 'فرستادن به پشت همه',
- },
- transform: {
- title: 'تبدیل',
- width: 'عرض (px)',
- height: 'ارتفاع (px)',
- x: 'X (px)',
- y: 'Y (px)',
- rotate: 'چرخش (°)',
- },
- },
- panel: {
- fill: {
- title: 'رنگ پر کردن',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/fr-FR.ts b/packages/slides-ui/src/locale/fr-FR.ts
deleted file mode 100644
index ec4cf25103..0000000000
--- a/packages/slides-ui/src/locale/fr-FR.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: 'Ajouter une diapositive',
-
- text: {
- insert: {
- title: 'Insérer du texte',
- },
- },
-
- shape: {
- insert: {
- title: 'Insérer une forme',
- rectangle: 'Insérer un rectangle',
- ellipse: 'Insérer une ellipse',
- },
- },
-
- image: {
- insert: {
- title: 'Insérer une image',
- float: 'Insérer une image flottante',
- },
- },
-
- popup: {
- edit: 'Éditer',
- delete: 'Supprimer',
- },
-
- sidebar: {
- text: 'Éditer le texte',
- shape: 'Éditer la forme',
- image: 'Éditer l\'image',
- },
-
- 'image-panel': {
- arrange: {
- title: 'Arranger',
- forward: 'Avancer',
- backward: 'Reculer',
- front: 'Mettre au premier plan',
- back: 'Mettre à l\'arrière-plan',
- },
- transform: {
- title: 'Transformer',
- width: 'Largeur (px)',
- height: 'Hauteur (px)',
- x: 'X (px)',
- y: 'Y (px)',
- rotate: 'Pivoter (°)',
- },
- },
- panel: {
- fill: {
- title: 'Couleur de remplissage',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/id-ID.ts b/packages/slides-ui/src/locale/id-ID.ts
deleted file mode 100644
index 62664fda53..0000000000
--- a/packages/slides-ui/src/locale/id-ID.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: 'Tambah Slide',
-
- text: {
- insert: {
- title: 'Sisipkan Teks',
- },
- },
-
- shape: {
- insert: {
- title: 'Sisipkan Bentuk',
- rectangle: 'Sisipkan Persegi Panjang',
- ellipse: 'Sisipkan Elips',
- },
- },
-
- image: {
- insert: {
- title: 'Sisipkan Gambar',
- float: 'Sisipkan Gambar Mengambang',
- },
- },
-
- popup: {
- edit: 'Edit',
- delete: 'Hapus',
- },
-
- sidebar: {
- text: 'Edit Teks',
- shape: 'Edit Bentuk',
- image: 'Edit Gambar',
- },
-
- 'image-panel': {
- arrange: {
- title: 'Atur',
- forward: 'Bawa ke Depan',
- backward: 'Kirim ke Belakang',
- front: 'Bawa ke Paling Depan',
- back: 'Kirim ke Paling Belakang',
- },
- transform: {
- title: 'Transformasi',
- width: 'Lebar (px)',
- height: 'Tinggi (px)',
- x: 'X (px)',
- y: 'Y (px)',
- rotate: 'Putar (°)',
- },
- },
- panel: {
- fill: {
- title: 'Warna Isi',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/it-IT.ts b/packages/slides-ui/src/locale/it-IT.ts
deleted file mode 100644
index 2a175c42d0..0000000000
--- a/packages/slides-ui/src/locale/it-IT.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: 'Aggiungi Diapositiva',
-
- text: {
- insert: {
- title: 'Inserisci Testo',
- },
- },
-
- shape: {
- insert: {
- title: 'Inserisci Forma',
- rectangle: 'Inserisci Rettangolo',
- ellipse: 'Inserisci Ellisse',
- },
- },
-
- image: {
- insert: {
- title: 'Inserisci Immagine',
- float: 'Inserisci Immagine Fluttuante',
- },
- },
-
- popup: {
- edit: 'Modifica',
- delete: 'Elimina',
- },
-
- sidebar: {
- text: 'Modifica Testo',
- shape: 'Modifica Forma',
- image: 'Modifica Immagine',
- },
-
- 'image-panel': {
- arrange: {
- title: 'Disposizione',
- forward: 'Porta Avanti',
- backward: 'Manda Indietro',
- front: 'Porta in Primo Piano',
- back: 'Manda in Secondo Piano',
- },
- transform: {
- title: 'Trasforma',
- width: 'Larghezza (px)',
- height: 'Altezza (px)',
- x: 'X (px)',
- y: 'Y (px)',
- rotate: 'Ruota (°)',
- },
- },
- panel: {
- fill: {
- title: 'Colore Riempimento',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/ja-JP.ts b/packages/slides-ui/src/locale/ja-JP.ts
deleted file mode 100644
index e0b15545bc..0000000000
--- a/packages/slides-ui/src/locale/ja-JP.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: 'スライドを追加',
-
- text: {
- insert: {
- title: 'テキストの挿入',
- },
- },
-
- shape: {
- insert: {
- title: '図形の挿入',
- rectangle: '四角形を挿入',
- ellipse: '楕円を挿入',
- },
- },
-
- image: {
- insert: {
- title: '画像の挿入',
- float: 'フローティング画像を挿入',
- },
- },
-
- popup: {
- edit: '編集',
- delete: '削除',
- },
-
- sidebar: {
- text: 'テキスト編集',
- shape: '図形編集',
- image: '画像編集',
- },
-
- 'image-panel': {
- arrange: {
- title: '配置',
- forward: '前面へ移動',
- backward: '背面へ移動',
- front: '最前面へ移動',
- back: '最背面へ移動',
- },
- transform: {
- title: '変形',
- width: '幅 (px)',
- height: '高さ (px)',
- x: 'X座標 (px)',
- y: 'Y座標 (px)',
- rotate: '回転 (°)',
- },
- },
- panel: {
- fill: {
- title: '塗りつぶしの色',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/ko-KR.ts b/packages/slides-ui/src/locale/ko-KR.ts
deleted file mode 100644
index 8d9db1eb23..0000000000
--- a/packages/slides-ui/src/locale/ko-KR.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: '슬라이드 추가',
-
- text: {
- insert: {
- title: '텍스트 삽입',
- },
- },
-
- shape: {
- insert: {
- title: '도형 삽입',
- rectangle: '사각형 삽입',
- ellipse: '타원 삽입',
- },
- },
-
- image: {
- insert: {
- title: '이미지 삽입',
- float: '플로팅 이미지 삽입',
- },
- },
-
- popup: {
- edit: '편집',
- delete: '삭제',
- },
-
- sidebar: {
- text: '텍스트 편집',
- shape: '도형 편집',
- image: '이미지 편집',
- },
-
- 'image-panel': {
- arrange: {
- title: '정렬',
- forward: '앞으로 가져오기',
- backward: '뒤로 보내기',
- front: '맨 앞으로 가져오기',
- back: '맨 뒤로 보내기',
- },
- transform: {
- title: '변형',
- width: '너비 (px)',
- height: '높이 (px)',
- x: 'X 좌표 (px)',
- y: 'Y 좌표 (px)',
- rotate: '회전 (°)',
- },
- },
- panel: {
- fill: {
- title: '채우기 색상',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/pl-PL.ts b/packages/slides-ui/src/locale/pl-PL.ts
deleted file mode 100644
index bbb4eb2dc5..0000000000
--- a/packages/slides-ui/src/locale/pl-PL.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: 'Dodaj slajd',
-
- text: {
- insert: {
- title: 'Wstaw tekst',
- },
- },
-
- shape: {
- insert: {
- title: 'Wstaw kształt',
- rectangle: 'Wstaw prostokąt',
- ellipse: 'Wstaw elipsę',
- },
- },
-
- image: {
- insert: {
- title: 'Wstaw obraz',
- float: 'Wstaw obraz swobodny',
- },
- },
-
- popup: {
- edit: 'Edytuj',
- delete: 'Usuń',
- },
-
- sidebar: {
- text: 'Edytuj tekst',
- shape: 'Edytuj kształt',
- image: 'Edytuj obraz',
- },
-
- 'image-panel': {
- arrange: {
- title: 'Rozmieść',
- forward: 'Przesuń do przodu',
- backward: 'Przesuń do tyłu',
- front: 'Przesuń na wierzch',
- back: 'Przesuń na spód',
- },
- transform: {
- title: 'Przekształć',
- width: 'Szerokość (px)',
- height: 'Wysokość (px)',
- x: 'X (px)',
- y: 'Y (px)',
- rotate: 'Obrót (°)',
- },
- },
- panel: {
- fill: {
- title: 'Kolor wypełnienia',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/pt-BR.ts b/packages/slides-ui/src/locale/pt-BR.ts
deleted file mode 100644
index d0bdad1a43..0000000000
--- a/packages/slides-ui/src/locale/pt-BR.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: 'Adicionar Slide',
-
- text: {
- insert: {
- title: 'Inserir Texto',
- },
- },
-
- shape: {
- insert: {
- title: 'Inserir Forma',
- rectangle: 'Inserir Retângulo',
- ellipse: 'Inserir Elipse',
- },
- },
-
- image: {
- insert: {
- title: 'Inserir Imagem',
- float: 'Inserir Imagem Flutuante',
- },
- },
-
- popup: {
- edit: 'Editar',
- delete: 'Excluir',
- },
-
- sidebar: {
- text: 'Editar Texto',
- shape: 'Editar Forma',
- image: 'Editar Imagem',
- },
-
- 'image-panel': {
- arrange: {
- title: 'Organizar',
- forward: 'Trazer para Frente',
- backward: 'Enviar para Trás',
- front: 'Trazer para a Frente',
- back: 'Enviar para Trás',
- },
- transform: {
- title: 'Transformar',
- width: 'Largura (px)',
- height: 'Altura (px)',
- x: 'X (px)',
- y: 'Y (px)',
- rotate: 'Rotacionar (°)',
- },
- },
- panel: {
- fill: {
- title: 'Cor de Preenchimento',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/ru-RU.ts b/packages/slides-ui/src/locale/ru-RU.ts
deleted file mode 100644
index aa6d6c2f46..0000000000
--- a/packages/slides-ui/src/locale/ru-RU.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: 'Добавить слайд',
-
- text: {
- insert: {
- title: 'Вставить текст',
- },
- },
-
- shape: {
- insert: {
- title: 'Вставить фигуру',
- rectangle: 'Вставить прямоугольник',
- ellipse: 'Вставить эллипс',
- },
- },
-
- image: {
- insert: {
- title: 'Вставить изображение',
- float: 'Вставить плавающее изображение',
- },
- },
-
- popup: {
- edit: 'Изменить',
- delete: 'Удалить',
- },
-
- sidebar: {
- text: 'Изменить текст',
- shape: 'Изменить фигуру',
- image: 'Изменить изображение',
- },
-
- 'image-panel': {
- arrange: {
- title: 'Упорядочить',
- forward: 'Переложить вперёд',
- backward: 'Переложить назад',
- front: 'На передний план',
- back: 'На задний план',
- },
- transform: {
- title: 'Преобразование',
- width: 'Ширина (пкс)',
- height: 'Высота (пкс)',
- x: 'X (пкс)',
- y: 'Y (пкс)',
- rotate: 'Повернуть (°)',
- },
- },
- panel: {
- fill: {
- title: 'Цвет заливки',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/sk-SK.ts b/packages/slides-ui/src/locale/sk-SK.ts
deleted file mode 100644
index 537d325c09..0000000000
--- a/packages/slides-ui/src/locale/sk-SK.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: 'Pridať snímku',
-
- text: {
- insert: {
- title: 'Vložiť text',
- },
- },
-
- shape: {
- insert: {
- title: 'Vložiť tvar',
- rectangle: 'Vložiť obdĺžnik',
- ellipse: 'Vložiť elipsu',
- },
- },
-
- image: {
- insert: {
- title: 'Vložiť obrázok',
- float: 'Vložiť plávajúci obrázok',
- },
- },
-
- popup: {
- edit: 'Upraviť',
- delete: 'Odstrániť',
- },
-
- sidebar: {
- text: 'Upraviť text',
- shape: 'Upraviť tvar',
- image: 'Upraviť obrázok',
- },
-
- 'image-panel': {
- arrange: {
- title: 'Usporiadať',
- forward: 'Posunúť dopredu',
- backward: 'Posunúť dozadu',
- front: 'Presunúť do popredia',
- back: 'Presunúť do pozadia',
- },
- transform: {
- title: 'Transformovať',
- width: 'Šírka (px)',
- height: 'Výška (px)',
- x: 'X (px)',
- y: 'Y (px)',
- rotate: 'Otočiť (°)',
- },
- },
- panel: {
- fill: {
- title: 'Farba výplne',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/types.ts b/packages/slides-ui/src/locale/types.ts
deleted file mode 100644
index b83cb8e9ce..0000000000
--- a/packages/slides-ui/src/locale/types.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 type { LocaleLeafKeys } from '@univerjs/core';
-import type enUS from './en-US';
-
-export type LocaleKey = LocaleLeafKeys<typeof enUS>;
diff --git a/packages/slides-ui/src/locale/vi-VN.ts b/packages/slides-ui/src/locale/vi-VN.ts
deleted file mode 100644
index 70e0ea961e..0000000000
--- a/packages/slides-ui/src/locale/vi-VN.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: 'Thêm trang chiếu',
-
- text: {
- insert: {
- title: 'Chèn văn bản',
- },
- },
-
- shape: {
- insert: {
- title: 'Chèn hình',
- rectangle: 'Chèn hình chữ nhật',
- ellipse: 'Chèn hình elip',
- },
- },
-
- image: {
- insert: {
- title: 'Chèn hình ảnh',
- float: 'Chèn hình ảnh nổi',
- },
- },
-
- popup: {
- edit: 'Chỉnh sửa',
- delete: 'Xóa',
- },
-
- sidebar: {
- text: 'Chỉnh sửa văn bản',
- shape: 'Chỉnh sửa hình',
- image: 'Chỉnh sửa hình ảnh',
- },
-
- 'image-panel': {
- arrange: {
- title: 'Sắp xếp',
- forward: 'Chuyển lên trên',
- backward: 'Chuyển xuống dưới',
- front: 'Đưa lên trên cùng',
- back: 'Đưa xuống dưới cùng',
- },
- transform: {
- title: 'Biến đổi',
- width: 'Chiều rộng (px)',
- height: 'Chiều cao (px)',
- x: 'X (px)',
- y: 'Y (px)',
- rotate: 'Xoay (°)',
- },
- },
- panel: {
- fill: {
- title: 'Màu tô',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/zh-CN.ts b/packages/slides-ui/src/locale/zh-CN.ts
deleted file mode 100644
index b29e983486..0000000000
--- a/packages/slides-ui/src/locale/zh-CN.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: '新增幻灯片',
-
- text: {
- insert: {
- title: '插入文本',
- },
- },
-
- shape: {
- insert: {
- title: '插入图形',
- rectangle: '插入矩形',
- ellipse: '插入椭圆',
- },
- },
-
- image: {
- insert: {
- title: '插入图片',
- float: '插入浮动图片',
- },
- },
-
- popup: {
- edit: '编辑',
- delete: '删除',
- },
-
- sidebar: {
- text: '编辑文本',
- shape: '编辑图形',
- image: '编辑图片',
- },
-
- 'image-panel': {
- arrange: {
- title: '排列',
- forward: '上移一层',
- backward: '下移一层',
- front: '置于顶层',
- back: '置于底层',
- },
- transform: {
- title: '变换',
- width: '宽度 (px)',
- height: '高度 (px)',
- x: 'X (px)',
- y: 'Y (px)',
- rotate: '旋转 (°)',
- },
- },
- panel: {
- fill: {
- title: '填充',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/zh-HK.ts b/packages/slides-ui/src/locale/zh-HK.ts
deleted file mode 100644
index 2c045f6067..0000000000
--- a/packages/slides-ui/src/locale/zh-HK.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: '新增投影片',
-
- text: {
- insert: {
- title: '插入文字',
- },
- },
-
- shape: {
- insert: {
- title: '插入圖形',
- rectangle: '插入矩形',
- ellipse: '插入橢圓',
- },
- },
-
- image: {
- insert: {
- title: '插入圖片',
- float: '插入浮動圖片',
- },
- },
-
- popup: {
- edit: '編輯',
- delete: '刪除',
- },
-
- sidebar: {
- text: '編輯文字',
- shape: '編輯圖形',
- image: '編輯圖片',
- },
-
- 'image-panel': {
- arrange: {
- title: '排列',
- forward: '上移一層',
- backward: '下移一層',
- front: '至頂',
- back: '至底',
- },
- transform: {
- title: '變換',
- width: '寬度 (px)',
- height: '高度 (px)',
- x: 'X (px)',
- y: 'Y (px)',
- rotate: '旋轉 (°)',
- },
- },
- panel: {
- fill: {
- title: '填色',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/locale/zh-TW.ts b/packages/slides-ui/src/locale/zh-TW.ts
deleted file mode 100644
index 2c045f6067..0000000000
--- a/packages/slides-ui/src/locale/zh-TW.ts
+++ /dev/null
@@ -1,80 +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 = {
- 'slides-ui': {
- append: '新增投影片',
-
- text: {
- insert: {
- title: '插入文字',
- },
- },
-
- shape: {
- insert: {
- title: '插入圖形',
- rectangle: '插入矩形',
- ellipse: '插入橢圓',
- },
- },
-
- image: {
- insert: {
- title: '插入圖片',
- float: '插入浮動圖片',
- },
- },
-
- popup: {
- edit: '編輯',
- delete: '刪除',
- },
-
- sidebar: {
- text: '編輯文字',
- shape: '編輯圖形',
- image: '編輯圖片',
- },
-
- 'image-panel': {
- arrange: {
- title: '排列',
- forward: '上移一層',
- backward: '下移一層',
- front: '至頂',
- back: '至底',
- },
- transform: {
- title: '變換',
- width: '寬度 (px)',
- height: '高度 (px)',
- x: 'X (px)',
- y: 'Y (px)',
- rotate: '旋轉 (°)',
- },
- },
- panel: {
- fill: {
- title: '填色',
- },
- },
- },
-};
-
-export default locale;
diff --git a/packages/slides-ui/src/menu/image.menu.ts b/packages/slides-ui/src/menu/image.menu.ts
deleted file mode 100644
index 65a910c263..0000000000
--- a/packages/slides-ui/src/menu/image.menu.ts
+++ /dev/null
@@ -1,43 +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 { IMenuItem } from '@univerjs/ui';
-import type { LocaleKey } from '../locale/types';
-import { UniverInstanceType } from '@univerjs/core';
-import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
-import { InsertSlideFloatImageCommand } from '../commands/operations/insert-image.operation';
-
-export const SLIDES_IMAGE_MENU_ID = 'slide.menu.image';
-
-export function SlideImageMenuFactory(accessor: IAccessor): IMenuItem<LocaleKey> {
- return {
- id: SLIDES_IMAGE_MENU_ID,
- type: MenuItemType.SUBITEMS,
- icon: 'AddImageIcon',
- tooltip: 'slides-ui.image.insert.title',
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SLIDE),
- };
-}
-
-export function UploadSlideFloatImageMenuFactory(_accessor: IAccessor): IMenuItem<LocaleKey> {
- return {
- id: InsertSlideFloatImageCommand.id,
- title: 'slides-ui.image.insert.float',
- type: MenuItemType.BUTTON,
- hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SLIDE),
- };
-}
diff --git a/packages/slides-ui/src/menu/popup-menu.controller.ts b/packages/slides-ui/src/menu/popup-menu.controller.ts
deleted file mode 100644
index 2f8d2e774c..0000000000
--- a/packages/slides-ui/src/menu/popup-menu.controller.ts
+++ /dev/null
@@ -1,201 +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 { BaseObject, ObjectType, Scene } from '@univerjs/engine-render';
-import type { SlideDataModel } from '@univerjs/slides';
-import { FOCUSING_COMMON_DRAWINGS, ICommandService, IContextService, Inject, IUniverInstanceService, RxDisposable, toDisposable, UniverInstanceType } from '@univerjs/core';
-import { IRenderManagerService } from '@univerjs/engine-render';
-import { ISidebarService } from '@univerjs/ui';
-import { DeleteSlideElementOperation } from '../commands/operations/delete-element.operation';
-import { ToggleSlideEditSidebarOperation } from '../commands/operations/insert-shape.operation';
-import { UpdateSlideElementOperation } from '../commands/operations/update-element.operation';
-import { CanvasView } from '../controllers/canvas-view';
-import { SlideCanvasPopMangerService } from '../services/slide-popup-manager.service';
-import { COMPONENT_SLIDE_IMAGE_POPUP_MENU } from '../views/image-popup-menu/component-name';
-
-export class SlidePopupMenuController extends RxDisposable {
- private _initImagePopupMenu = new Set<string>();
-
- constructor(
- @Inject(SlideCanvasPopMangerService) private readonly _canvasPopManagerService: SlideCanvasPopMangerService,
- @IRenderManagerService private readonly _renderManagerService: IRenderManagerService,
- @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
- @IContextService private readonly _contextService: IContextService,
- @Inject(CanvasView) private readonly _canvasView: CanvasView,
- @ISidebarService private readonly _sidebarService: ISidebarService,
- @ICommandService private readonly _commandService: ICommandService
- ) {
- super();
-
- this._init();
- }
-
- private _init(): void {
- this._univerInstanceService.getAllUnitsForType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE).forEach((slide) => this._create(slide));
- }
-
- private _create(slide: Nullable<SlideDataModel>) {
- if (!slide) {
- return;
- }
-
- const unitId = slide.getUnitId();
-
- if (this._renderManagerService.has(unitId) && !this._initImagePopupMenu.has(unitId)) {
- this._popupMenuListener(unitId);
- this._initImagePopupMenu.add(unitId);
- }
- }
-
- private _hasCropObject(scene: Scene) {
- // const objects = scene.getAllObjects();
-
- // for (const object of objects) {
- // if (object instanceof ImageCropperObject) {
- // return true;
- // }
- // }
-
- // return false;
- }
-
- // eslint-disable-next-line max-lines-per-function
- private _popupMenuListener(unitId: string) {
- const model = this._univerInstanceService.getCurrentUnitOfType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE);
- const pages = model?.getPages() ?? {};
-
- // eslint-disable-next-line max-lines-per-function
- Object.keys(pages).forEach((pageId) => {
- const page = this._canvasView.getRenderUnitByPageId(pageId, unitId);
- const transformer = page.scene?.getTransformer();
-
- if (!transformer) return;
-
- let singletonPopupDisposer: IDisposable;
- this.disposeWithMe(
- toDisposable(
- transformer.createControl$.subscribe(() => {
- // this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, true);
-
- // if (this._hasCropObject(scene)) {
- // return;
- // }
-
- const selectedObjects = transformer.getSelectedObjectMap();
- if (selectedObjects.size > 1) {
- singletonPopupDisposer?.dispose();
- return;
- }
-
- const object = selectedObjects.values().next().value as Nullable<BaseObject>;
- if (!object) {
- return;
- }
-
- const oKey = object.oKey;
- // const drawingParam = this._drawingManagerService.getDrawingOKey(oKey);
- // if (!drawingParam) {
- // return;
- // }
-
- // const { unitId, subUnitId, drawingId } = drawingParam;
- singletonPopupDisposer?.dispose();
- singletonPopupDisposer = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object, {
- componentKey: COMPONENT_SLIDE_IMAGE_POPUP_MENU,
- direction: 'horizontal',
- offset: [2, 0],
- extraProps: {
- menuItems: this._getMenuItemsByObjectType(object.objectType, oKey, unitId),
- },
- }));
-
- if (this._sidebarService.visible) {
- this._commandService.executeCommand(ToggleSlideEditSidebarOperation.id, {
- visible: true,
- objectType: object.objectType,
- });
- }
-
- // this._drawingManagerService.focusDrawing([{
- // unitId,
- // subUnitId,
- // drawingId,
- // }]);
- })
- )
- );
- this.disposeWithMe(
- transformer.clearControl$.subscribe(() => {
- singletonPopupDisposer?.dispose();
- this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, false);
- // this._drawingManagerService.focusDrawing(null);
- })
- );
- this.disposeWithMe(
- transformer.changing$.subscribe(() => {
- singletonPopupDisposer?.dispose();
-
- const selectedObjects = transformer.getSelectedObjectMap();
- if (selectedObjects.size > 1) {
- singletonPopupDisposer?.dispose();
- return;
- }
-
- const object = selectedObjects.values().next().value as Nullable<BaseObject>;
- if (!object) {
- return;
- }
-
- this._commandService.executeCommand(UpdateSlideElementOperation.id, {
- unitId,
- oKey: object.oKey,
- props: {
- width: object.width,
- height: object.height,
- left: object.left,
- top: object.top,
- },
- });
- })
- );
- });
- }
-
- private _getMenuItemsByObjectType(objectType: ObjectType, oKey: string, unitId: string) {
- const menuItems = [{
- label: 'slides-ui.popup.edit',
- index: 0,
- commandId: ToggleSlideEditSidebarOperation.id,
- commandParams: {
- visible: true,
- objectType,
- },
- disable: false,
- }, {
- label: 'slides-ui.popup.delete',
- index: 5,
- commandId: DeleteSlideElementOperation.id,
- commandParams: {
- id: oKey,
- unitId,
- },
- disable: false,
- }];
-
- return menuItems;
- }
-}
diff --git a/packages/slides-ui/src/menu/schema.ts b/packages/slides-ui/src/menu/schema.ts
deleted file mode 100644
index 5eea43eecd..0000000000
--- a/packages/slides-ui/src/menu/schema.ts
+++ /dev/null
@@ -1,56 +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 } from '@univerjs/ui';
-import { InsertSlideFloatImageCommand } from '../commands/operations/insert-image.operation';
-import { InsertSlideShapeEllipseCommand, InsertSlideShapeRectangleCommand } from '../commands/operations/insert-shape.operation';
-import { SlideAddTextCommand } from '../commands/operations/insert-text.operation';
-import { SlideImageMenuFactory, SLIDES_IMAGE_MENU_ID, UploadSlideFloatImageMenuFactory } from './image.menu';
-import { SHAPE_MENU_ID, SlideShapeMenuFactory, UploadSlideFloatEllipseShapeMenuFactory, UploadSlideFloatRectangleShapeMenuFactory } from './shape.menu';
-import { SlideAddTextMenuItemFactory } from './text.menu';
-
-export const menuSchema: MenuSchemaType = {
- [RibbonStartGroup.FORMAT]: {
- [SlideAddTextCommand.id]: {
- order: 0,
- gridLayout: { row: 1, column: 1, rowSpan: 2, showLabel: true },
- menuItemFactory: SlideAddTextMenuItemFactory,
- },
- [SLIDES_IMAGE_MENU_ID]: {
- order: 0,
- gridLayout: { row: 1, column: 2, rowSpan: 2, showLabel: true },
- menuItemFactory: SlideImageMenuFactory,
- [InsertSlideFloatImageCommand.id]: {
- order: 0,
- menuItemFactory: UploadSlideFloatImageMenuFactory,
- },
- },
- [SHAPE_MENU_ID]: {
- order: 0,
- gridLayout: { row: 1, column: 3, rowSpan: 2, showLabel: true },
- menuItemFactory: SlideShapeMenuFactory,
- [InsertSlideShapeRectangleCommand.id]: {
- order: 0,
- menuItemFactory: UploadSlideFloatRectangleShapeMenuFactory,
- },
- [InsertSlideShapeEllipseCommand.id]: {
- order: 0,
- menuItemFactory: UploadSlideFloatEllipseShapeMenuFactory,
- },
- },
- },
-};
diff --git a/packages/slides-ui/src/menu/shape.menu.ts b/packages/slides-ui/src/menu/shape.menu.ts
deleted file mode 100644
index 2128cecf0d..0000000000
--- a/packages/slides-ui/src/menu/shape.menu.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 { IAccessor } from '@univerjs/core';
-import type { IMenuButtonItem, IMenuItem } from '@univerjs/ui';
-import type { LocaleKey } from '../locale/types';
-import { UniverInstanceType } from '@univerjs/core';
-import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
-import {
- InsertSlideShapeEllipseCommand,
- InsertSlideShapeRectangleCommand,
-} from '../commands/operations/insert-shape.operation';
-
-export const SHAPE_MENU_ID = 'slide.menu.shape';
-
-export function SlideShapeMenuFactory(accessor: IAccessor): IMenuItem<LocaleKey> {
- return {
- id: SHAPE_MENU_ID,
- type: MenuItemType.SUBITEMS,
- icon: 'GraphIcon',
- tooltip: 'slides-ui.shape.insert.title',
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SLIDE),
- };
-}
-
-export function UploadSlideFloatRectangleShapeMenuFactory(_accessor: IAccessor): IMenuButtonItem<LocaleKey> {
- return {
- id: InsertSlideShapeRectangleCommand.id,
- title: 'slides-ui.shape.insert.rectangle',
- type: MenuItemType.BUTTON,
- hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SLIDE),
- };
-}
-
-export function UploadSlideFloatEllipseShapeMenuFactory(_accessor: IAccessor): IMenuButtonItem<LocaleKey> {
- return {
- id: InsertSlideShapeEllipseCommand.id,
- title: 'slides-ui.shape.insert.ellipse',
- type: MenuItemType.BUTTON,
- hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SLIDE),
- };
-}
diff --git a/packages/slides-ui/src/menu/text.menu.ts b/packages/slides-ui/src/menu/text.menu.ts
deleted file mode 100644
index 6f586a9d91..0000000000
--- a/packages/slides-ui/src/menu/text.menu.ts
+++ /dev/null
@@ -1,32 +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 type { LocaleKey } from '../locale/types';
-import { UniverInstanceType } from '@univerjs/core';
-import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
-import { SlideAddTextCommand } from '../commands/operations/insert-text.operation';
-
-export function SlideAddTextMenuItemFactory(_accessor: IAccessor): IMenuButtonItem<LocaleKey> {
- return {
- id: SlideAddTextCommand.id,
- type: MenuItemType.BUTTON,
- icon: 'TextIcon',
- tooltip: 'slides-ui.text.insert.title',
- hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SLIDE),
- };
-}
diff --git a/packages/slides-ui/src/models/info-bar-model.ts b/packages/slides-ui/src/models/info-bar-model.ts
deleted file mode 100644
index 7e4a5b5b41..0000000000
--- a/packages/slides-ui/src/models/info-bar-model.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 class InfoBarModel {
- constructor(private _name: string) {
- // super
- }
-
- get name(): string {
- return this._name;
- }
-
- setName(name: string) {
- this._name = name;
- }
-}
diff --git a/packages/slides-ui/src/plugin.ts b/packages/slides-ui/src/plugin.ts
deleted file mode 100644
index 5cebd53625..0000000000
--- a/packages/slides-ui/src/plugin.ts
+++ /dev/null
@@ -1,154 +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 { SlideDataModel } from '@univerjs/slides';
-import type { IUniverSlidesUIConfig } from './config/config';
-import {
- DependentOn,
- IConfigService,
- Inject,
- Injector,
- IUniverInstanceService,
- merge,
- mergeOverrideWithDependencies,
- Plugin,
- UniverInstanceType,
-} from '@univerjs/core';
-import { UniverDocsPlugin } from '@univerjs/docs';
-import { UniverDocsUIPlugin } from '@univerjs/docs-ui';
-import { UniverDrawingPlugin } from '@univerjs/drawing';
-import { IRenderManagerService, UniverRenderEnginePlugin } from '@univerjs/engine-render';
-import { UniverSlidesPlugin } from '@univerjs/slides';
-import pkg from '../package.json';
-import { defaultPluginConfig, SLIDES_UI_PLUGIN_CONFIG_KEY } from './config/config';
-import { CanvasView } from './controllers/canvas-view';
-import { ComponentsController } from './controllers/components.controller';
-import { SlideEditingRenderController } from './controllers/slide-editing.render-controller';
-import { SlideEditorBridgeRenderController } from './controllers/slide-editor-bridge.render-controller';
-import { SlideRenderController } from './controllers/slide.render-controller';
-import { SlidesUIController } from './controllers/ui.controller';
-import { SlidePopupMenuController } from './menu/popup-menu.controller';
-import { ISlideEditorBridgeService, SlideEditorBridgeService } from './services/slide-editor-bridge.service';
-import { ISlideEditorManagerService, SlideEditorManagerService } from './services/slide-editor-manager.service';
-import { SlideCanvasPopMangerService } from './services/slide-popup-manager.service';
-import { SlideRenderService } from './services/slide-render.service';
-
-@DependentOn(
- UniverDocsPlugin,
- UniverDrawingPlugin,
- UniverRenderEnginePlugin,
- UniverSlidesPlugin,
- UniverDocsUIPlugin
-)
-export class UniverSlidesUIPlugin extends Plugin {
- static override pluginName = 'UNIVER_SLIDES_UI_PLUGIN';
- static override packageName = pkg.name;
- static override version = pkg.version;
- static override type = UniverInstanceType.UNIVER_SLIDE;
-
- constructor(
- private readonly _config: Partial<IUniverSlidesUIConfig> = defaultPluginConfig,
- @Inject(Injector) override readonly _injector: Injector,
- @IRenderManagerService private readonly _renderManagerService: IRenderManagerService,
- @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
- @IConfigService private readonly _configService: IConfigService
- ) {
- super();
-
- // Manage the plugin configuration.
- const { menu, ...rest } = merge(
- {},
- defaultPluginConfig,
- this._config
- );
- if (menu) {
- this._configService.setConfig('menu', menu, { merge: true });
- }
- this._configService.setConfig(SLIDES_UI_PLUGIN_CONFIG_KEY, rest);
- }
-
- override onStarting(): void {
- this._injector.add([ComponentsController]);
- this._injector.get(ComponentsController);
- mergeOverrideWithDependencies([
- [SlideRenderService],
- [ISlideEditorBridgeService, { useClass: SlideEditorBridgeService }],
- // used by SlideUIController --> EditorContainer
- [ISlideEditorManagerService, { useClass: SlideEditorManagerService }],
- [SlideCanvasPopMangerService],
- ] as Dependency[], this._config.override)
- .forEach((d) => this._injector.add(d));
- }
-
- override onReady(): void {
- ([
- // SlideRenderService will be init in ready stage, and then calling RenderManagerService@createRender --> init all deps in this rendering register block.
-
- [SlideRenderController],
- ] as Dependency[]).forEach((m) => {
- this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SLIDE, m));
- });
-
- mergeOverrideWithDependencies([
- [CanvasView],
- // cannot register in _renderManagerService now.
- // [ISlideEditorBridgeService, { useClass: SlideEditorBridgeService }],
- // // used by SlideUIController --> EditorContainer
- // [ISlideEditorManagerService, { useClass: SlideEditorManagerService }],
-
- // SlidesUIController controller should be registered in Ready stage.
- // SlidesUIController controller would add a new RenderUnit (__INTERNAL_EDITOR__DOCS_NORMAL)
- [SlidesUIController], // editor service was create in renderManagerService
- [SlideRenderController],
- [SlidePopupMenuController],
- ] as Dependency[], this._config.override).forEach((m) => {
- this._injector.add(m);
- });
-
- this._injector.get(CanvasView);
- this._injector.get(SlideRenderService);
- }
-
- override onRendered(): void {
- ([
- // need slideEditorBridgeService
- // need TextSelectionRenderService which init by EditorContainer
- [SlideEditorBridgeRenderController],
- [SlideEditingRenderController],
- ] as Dependency[]).forEach((m) => {
- // find all renderMap and register module to each item in renderMap
- this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SLIDE, m));
- });
-
- this._markSlideAsFocused();
-
- this._injector.get(SlidesUIController);
- }
-
- override onSteady(): void {
- this._injector.get(SlidePopupMenuController);
- }
-
- private _markSlideAsFocused() {
- const currentService = this._univerInstanceService;
- try {
- const slideDataModel = currentService.getCurrentUnitOfType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE)!;
- currentService.focusUnit(slideDataModel.getUnitId());
- } catch (e) {
- }
- }
-}
diff --git a/packages/slides-ui/src/services/__tests__/slide-editor-bridge.service.spec.ts b/packages/slides-ui/src/services/__tests__/slide-editor-bridge.service.spec.ts
deleted file mode 100644
index 7742012caf..0000000000
--- a/packages/slides-ui/src/services/__tests__/slide-editor-bridge.service.spec.ts
+++ /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 { ContextService, IContextService, Injector } from '@univerjs/core';
-import { IEditorService } from '@univerjs/docs-ui';
-import { DeviceInputEventType, IRenderManagerService } from '@univerjs/engine-render';
-import { beforeEach, describe, expect, it } from 'vitest';
-import { SLIDE_EDITOR_ID } from '../../const';
-import { ISlideEditorBridgeService, SlideEditorBridgeService } from '../slide-editor-bridge.service';
-
-class TestEditorService {
- readonly focusedEditors: string[] = [];
- focusedEditor: unknown = {};
-
- getFocusEditor() {
- return this.focusedEditor;
- }
-
- focus(editorId: string) {
- this.focusedEditors.push(editorId);
- }
-}
-
-class TestRenderManagerService {
- getRenderUnitById(unitId: string) {
- if (unitId !== 'slide-1') {
- return null;
- }
-
- return {
- scene: {
- getViewport: () => ({ viewportScrollX: 5, viewportScrollY: 10 }),
- getObject: () => ({ left: 30, top: 45 }),
- },
- };
- }
-}
-
-describe('SlideEditorBridgeService', () => {
- let service: ISlideEditorBridgeService;
- let editorService: TestEditorService;
-
- beforeEach(() => {
- const injector = new Injector();
- injector.add([IEditorService, { useClass: TestEditorService as never }]);
- injector.add([IContextService, { useClass: ContextService }]);
- injector.add([IRenderManagerService, { useClass: TestRenderManagerService as never }]);
- injector.add([ISlideEditorBridgeService, { useClass: SlideEditorBridgeService }]);
- editorService = injector.get(IEditorService) as unknown as TestEditorService;
- service = injector.get(ISlideEditorBridgeService);
- });
-
- it('publishes editor visibility changes and resets dirty state when editing starts', () => {
- const states: unknown[] = [];
- service.visible$.subscribe((state) => states.push(state));
- service.changeEditorDirty(true);
-
- service.changeVisible({ visible: true, eventType: DeviceInputEventType.Dblclick, unitId: 'slide-1' });
-
- expect(service.isVisible()).toBe(true);
- expect(service.getEditorDirty()).toBe(false);
- expect(states.at(-1)).toEqual({ visible: true, eventType: DeviceInputEventType.Dblclick, unitId: 'slide-1' });
- });
-
- it('calculates editor geometry from the selected rich text object and focuses the slide editor when needed', () => {
- const states: unknown[] = [];
- service.currentEditRectState$.subscribe((state) => states.push(state));
- editorService.focusedEditor = null;
-
- const editorInfo = {
- unitId: 'slide-1',
- pageId: 'page-1',
- scene: {} as never,
- engine: {} as never,
- richTextObj: {
- left: 100,
- top: 80,
- width: 240,
- height: 60,
- documentData: {
- id: 'old-editor-id',
- body: {
- dataStream: 'Text\r\n',
- },
- documentStyle: {
- pageSize: { width: 10, height: 10 },
- },
- },
- },
- };
-
- service.setEditorRect(editorInfo as never);
-
- expect(service.getEditorRect()).toBe(editorInfo);
- expect(service.getCurrentEditorId()).toBe(SLIDE_EDITOR_ID);
- expect(editorService.focusedEditors).toEqual([SLIDE_EDITOR_ID]);
- expect(service.getEditRectState()).toMatchObject({
- unitId: 'slide-1',
- editorUnitId: SLIDE_EDITOR_ID,
- position: {
- startX: 100,
- startY: 80,
- endX: 340,
- endY: 140,
- },
- slideCardOffset: {
- left: 25,
- top: 35,
- },
- documentLayoutObject: {
- documentModel: expect.any(Object),
- },
- });
- expect(states.at(-1)).toMatchObject({
- unitId: 'slide-1',
- editorUnitId: SLIDE_EDITOR_ID,
- });
- });
-});
diff --git a/packages/slides-ui/src/services/__tests__/slide-editor-manager.service.spec.ts b/packages/slides-ui/src/services/__tests__/slide-editor-manager.service.spec.ts
deleted file mode 100644
index 40dcd5ec4f..0000000000
--- a/packages/slides-ui/src/services/__tests__/slide-editor-manager.service.spec.ts
+++ /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 { Injector } from '@univerjs/core';
-import { beforeEach, describe, expect, it } from 'vitest';
-import { ISlideEditorManagerService, SlideEditorManagerService } from '../slide-editor-manager.service';
-
-describe('SlideEditorManagerService', () => {
- let service: ISlideEditorManagerService;
-
- beforeEach(() => {
- const injector = new Injector();
- injector.add([ISlideEditorManagerService, { useClass: SlideEditorManagerService }]);
- service = injector.get(ISlideEditorManagerService);
- });
-
- it('publishes slide text editor state, bounds and focus changes', () => {
- const states: unknown[] = [];
- const rects: unknown[] = [];
- const focus: boolean[] = [];
- service.state$.subscribe((state) => states.push(state));
- service.rect$.subscribe((rect) => rects.push(rect));
- service.focus$.subscribe((value) => focus.push(value));
-
- service.setState({ show: true, startX: 12, startY: 24 });
- service.setRect({ left: 12, top: 24, width: 120, height: 32 });
- service.setFocus(true);
-
- expect(states.at(-1)).toEqual({ show: true, startX: 12, startY: 24 });
- expect(service.getState()).toEqual({ show: true, startX: 12, startY: 24 });
- expect(rects.at(-1)).toEqual({ left: 12, top: 24, width: 120, height: 32 });
- expect(service.getRect()).toEqual({ left: 12, top: 24, width: 120, height: 32 });
- expect(focus).toEqual([false, true]);
- });
-
- it('clears editor state and rect when disposed', () => {
- const states: unknown[] = [];
- const rects: unknown[] = [];
- let statesCompleted = false;
- let rectsCompleted = false;
- service.state$.subscribe({ next: (state) => states.push(state), complete: () => {
- statesCompleted = true;
- } });
- service.rect$.subscribe({ next: (rect) => rects.push(rect), complete: () => {
- rectsCompleted = true;
- } });
-
- service.setState({ show: true, startX: 1 });
- service.setRect({ left: 1, top: 2, width: 3, height: 4 });
- service.dispose();
-
- expect(service.getState()).toBeNull();
- expect(service.getRect()).toBeNull();
- expect(states).toEqual([null, { show: true, startX: 1 }]);
- expect(rects).toEqual([null, { left: 1, top: 2, width: 3, height: 4 }]);
- expect(statesCompleted).toBe(true);
- expect(rectsCompleted).toBe(true);
- });
-});
diff --git a/packages/slides-ui/src/services/__tests__/slide-popup-manager.service.spec.ts b/packages/slides-ui/src/services/__tests__/slide-popup-manager.service.spec.ts
deleted file mode 100644
index c75efca5ea..0000000000
--- a/packages/slides-ui/src/services/__tests__/slide-popup-manager.service.spec.ts
+++ /dev/null
@@ -1,157 +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, Injector, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
-import { IRenderManagerService } from '@univerjs/engine-render';
-import { ICanvasPopupService } from '@univerjs/ui';
-import { beforeEach, describe, expect, it } from 'vitest';
-import {
- SlideCanvasPopMangerService,
- transformBound2OffsetBound,
- transformPosition2Offset,
-} from '../slide-popup-manager.service';
-
-class TestCanvasPopupService {
- readonly addedPopups: unknown[] = [];
- readonly removedPopupIds: string[] = [];
-
- addPopup(popup: unknown) {
- this.addedPopups.push(popup);
- return 'popup-1';
- }
-
- removePopup(id: string) {
- this.removedPopupIds.push(id);
- }
-}
-
-class TestRenderManagerService {
- static hasRender = false;
-
- static reset() {
- this.hasRender = false;
- }
-
- getRenderUnitById(unitId: string) {
- if (!TestRenderManagerService.hasRender || unitId !== 'slide-1') {
- return null;
- }
-
- const canvasElement = document.createElement('canvas');
- canvasElement.style.width = '200px';
- canvasElement.getBoundingClientRect = () => ({
- left: 10,
- top: 20,
- width: 400,
- height: 300,
- right: 410,
- bottom: 320,
- x: 10,
- y: 20,
- toJSON: () => ({}),
- });
-
- return {
- mainComponent: { width: 300, height: 200 },
- engine: {
- getCanvasElement: () => canvasElement,
- },
- scene: {
- width: 500,
- height: 400,
- getAncestorScale: () => ({ scaleX: 2, scaleY: 3 }),
- getViewport: () => ({ viewportScrollX: 5, viewportScrollY: 10 }),
- },
- };
- }
-}
-
-class TestUniverInstanceService {
- getCurrentUnitOfType(type: UniverInstanceType) {
- return type === UniverInstanceType.UNIVER_SLIDE ? { getUnitId: () => 'slide-1' } : null;
- }
-}
-
-class TestCommandService {}
-
-describe('SlideCanvasPopMangerService', () => {
- let service: SlideCanvasPopMangerService;
- let popupService: TestCanvasPopupService;
-
- beforeEach(() => {
- TestRenderManagerService.reset();
- const injector = new Injector();
- injector.add([ICanvasPopupService, { useClass: TestCanvasPopupService as never }]);
- injector.add([IRenderManagerService, { useClass: TestRenderManagerService as never }]);
- injector.add([IUniverInstanceService, { useClass: TestUniverInstanceService as never }]);
- injector.add([ICommandService, { useClass: TestCommandService as never }]);
- injector.add([SlideCanvasPopMangerService]);
- popupService = injector.get(ICanvasPopupService) as unknown as TestCanvasPopupService;
- service = injector.get(SlideCanvasPopMangerService);
- });
-
- it('does not create a canvas popup when the current slide has no renderer', () => {
- const disposable = service.attachPopupToObject({ left: 0, top: 0, width: 10, height: 10 } as never, { componentKey: 'slide-comment' });
-
- disposable.dispose();
-
- expect(popupService.addedPopups).toEqual([]);
- expect(popupService.removedPopupIds).toEqual([]);
- });
-
- it('attaches a popup to the rendered slide object and removes it on dispose', () => {
- TestRenderManagerService.hasRender = true;
-
- const disposable = service.attachPopupToObject({ left: 15, top: 20, width: 30, height: 10 } as never, {
- componentKey: 'slide-comment',
- direction: 'horizontal',
- });
-
- expect(popupService.addedPopups).toHaveLength(1);
- expect(popupService.addedPopups[0]).toMatchObject({
- unitId: 'slide-1',
- subUnitId: 'default',
- componentKey: 'slide-comment',
- direction: 'horizontal',
- anchorRect: {
- left: 190,
- right: 430,
- top: 300,
- bottom: 480,
- },
- canvasElement: expect.any(HTMLCanvasElement),
- });
-
- disposable.dispose();
-
- expect(popupService.removedPopupIds).toEqual(['popup-1']);
- });
-
- it('converts slide coordinates to viewport offsets with scroll and scale applied', () => {
- const scene = {
- getAncestorScale: () => ({ scaleX: 2, scaleY: 3 }),
- getViewport: () => ({ viewportScrollX: 5, viewportScrollY: 10 }),
- };
-
- expect(transformPosition2Offset(15, 20, scene as never)).toEqual({ x: 20, y: 30 });
- expect(transformBound2OffsetBound({ left: 15, top: 20, right: 45, bottom: 30 }, scene as never)).toEqual({
- left: 20,
- top: 30,
- right: 80,
- bottom: 60,
- });
- });
-});
diff --git a/packages/slides-ui/src/services/__tests__/slide-render.service.spec.ts b/packages/slides-ui/src/services/__tests__/slide-render.service.spec.ts
deleted file mode 100644
index b4f2f5933c..0000000000
--- a/packages/slides-ui/src/services/__tests__/slide-render.service.spec.ts
+++ /dev/null
@@ -1,92 +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 { ContextService, IContextService, Injector, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
-import { IRenderManagerService } from '@univerjs/engine-render';
-import { Subject } from 'rxjs';
-import { beforeEach, describe, expect, it } from 'vitest';
-import { SlideRenderService } from '../slide-render.service';
-
-function createSlide(unitId: string) {
- return {
- getUnitId: () => unitId,
- };
-}
-
-class TestUniverInstanceService {
- readonly slideAdded$ = new Subject<{ unit: ReturnType<typeof createSlide> }>();
- readonly slideDisposed$ = new Subject<ReturnType<typeof createSlide>>();
- private readonly _initialSlides = [createSlide('existing-slide')];
-
- getTypeOfUnitAdded$(type: UniverInstanceType) {
- return type === UniverInstanceType.UNIVER_SLIDE ? this.slideAdded$.asObservable() : new Subject().asObservable();
- }
-
- getTypeOfUnitDisposed$(type: UniverInstanceType) {
- return type === UniverInstanceType.UNIVER_SLIDE ? this.slideDisposed$.asObservable() : new Subject().asObservable();
- }
-
- getAllUnitsForType(type: UniverInstanceType) {
- return type === UniverInstanceType.UNIVER_SLIDE ? this._initialSlides : [];
- }
-
- getUnit(unitId: string) {
- return createSlide(unitId);
- }
-}
-
-class TestRenderManagerService {
- readonly createdRenderers: string[] = [];
- readonly removedRenderers: string[] = [];
-
- createRender(unitId: string) {
- this.createdRenderers.push(unitId);
- }
-
- removeRender(unitId: string) {
- this.removedRenderers.push(unitId);
- }
-}
-
-describe('SlideRenderService', () => {
- let instanceService: TestUniverInstanceService;
- let renderManagerService: TestRenderManagerService;
-
- beforeEach(() => {
- const injector = new Injector();
- injector.add([IContextService, { useClass: ContextService }]);
- injector.add([IUniverInstanceService, { useClass: TestUniverInstanceService as never }]);
- injector.add([IRenderManagerService, { useClass: TestRenderManagerService as never }]);
- injector.add([SlideRenderService]);
- instanceService = injector.get(IUniverInstanceService) as unknown as TestUniverInstanceService;
- renderManagerService = injector.get(IRenderManagerService) as unknown as TestRenderManagerService;
- injector.get(SlideRenderService);
- });
-
- it('creates renderers for existing and newly added slide units', async () => {
- await Promise.resolve();
- instanceService.slideAdded$.next({ unit: createSlide('new-slide') });
-
- expect(renderManagerService.createdRenderers).toEqual(['existing-slide', 'new-slide']);
- });
-
- it('removes the renderer when a slide unit is disposed', async () => {
- await Promise.resolve();
- instanceService.slideDisposed$.next(createSlide('old-slide'));
-
- expect(renderManagerService.removedRenderers).toEqual(['old-slide']);
- });
-});
diff --git a/packages/slides-ui/src/services/slide-editor-bridge.service.ts b/packages/slides-ui/src/services/slide-editor-bridge.service.ts
deleted file mode 100644
index f3996020f0..0000000000
--- a/packages/slides-ui/src/services/slide-editor-bridge.service.ts
+++ /dev/null
@@ -1,279 +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, IPosition, Nullable } from '@univerjs/core';
-import type { Engine, IDocumentLayoutObject, RichText, Scene } from '@univerjs/engine-render';
-import type { KeyCode } from '@univerjs/ui';
-import type { Observable } from 'rxjs';
-import {
- createIdentifier,
- Disposable,
- DocumentDataModel,
- EDITOR_ACTIVATED,
- FOCUSING_EDITOR_STANDALONE,
- FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE,
- HorizontalAlign,
- IContextService,
- VerticalAlign,
-} from '@univerjs/core';
-import { IEditorService } from '@univerjs/docs-ui';
-import { DeviceInputEventType, IRenderManagerService } from '@univerjs/engine-render';
-import { SLIDE_KEY } from '@univerjs/slides';
-import { BehaviorSubject } from 'rxjs';
-import { SLIDE_EDITOR_ID } from '../const';
-
-// TODO same as @univerjs/slides/views/render/adaptors/index.js
-export enum SLIDE_VIEW_KEY {
- MAIN = '__SLIDERender__',
- SCENE_VIEWER = '__SLIDEViewer__',
- SCENE = '__SLIDEScene__',
- VIEWPORT = '__SLIDEViewPort_',
-}
-
-export const ISlideEditorBridgeService = createIdentifier<ISlideEditorBridgeService>('univer.slide-editor-bridge.service');
-
-export interface IEditorBridgeServiceParam {
- unitId: string;
-
- /**
- * pos and size of editing area
- */
- position: IPosition;
- slideCardOffset: { left: number; top: number };
- documentLayoutObject: IDocumentLayoutObject;
- scaleX: number;
- scaleY: number;
- editorUnitId: string;
-}
-
-export interface IEditorBridgeServiceVisibleParam {
- visible: boolean;
- eventType: DeviceInputEventType;
- unitId: string;
- keycode?: KeyCode;
-}
-
-export interface ISetEditorInfo {
- scene: Scene;
- engine: Engine;
- unitId: string;
- pageId: string;
- richTextObj: RichText;
-}
-
-export interface ISlideEditorBridgeService {
- currentEditRectState$: Observable<Nullable<IEditorBridgeServiceParam>>;
- visible$: Observable<IEditorBridgeServiceVisibleParam>;
-
- // interceptor: InterceptorManager<{
- // BEFORE_CELL_EDIT: typeof BEFORE_CELL_EDIT;
- // AFTER_CELL_EDIT: typeof AFTER_CELL_EDIT;
- // VALIDATE_CELL: typeof VALIDATE_CELL;
- // }>;
- dispose(): void;
- // refreshEditCellState(): void;
-
- setEditorRect(param: ISetEditorInfo): void;
- getEditorRect(): ISetEditorInfo;
- getEditRectState(): Readonly<Nullable<IEditorBridgeServiceParam>>;
- // // Gets the DocumentDataModel of the latest table cell based on the latest cell contents
- // getLatestEditCellState(): Readonly<Nullable<IEditorBridgeServiceParam>>;
- changeVisible(param: IEditorBridgeServiceVisibleParam): void;
- changeEditorDirty(dirtyStatus: boolean): void;
- getEditorDirty(): boolean;
- isVisible(): boolean;
- // enableForceKeepVisible(): void;
- // disableForceKeepVisible(): void;
- // isForceKeepVisible(): boolean;
- getCurrentEditorId(): Nullable<string>;
-}
-
-export class SlideEditorBridgeService extends Disposable implements ISlideEditorBridgeService, IDisposable {
- private _editorUnitId: string = SLIDE_EDITOR_ID;
-
- private _isForceKeepVisible: boolean = false;
-
- private _editorIsDirty: boolean = false;
-
- private _currentEditRectState: Nullable<IEditorBridgeServiceParam> = null;
- private readonly _currentEditRectState$ = new BehaviorSubject<Nullable<IEditorBridgeServiceParam>>(null);
- readonly currentEditRectState$ = this._currentEditRectState$.asObservable();
-
- private _visibleParam: IEditorBridgeServiceVisibleParam = {
- visible: false,
- eventType: DeviceInputEventType.Dblclick,
- unitId: '',
- };
-
- private readonly _visible$ = new BehaviorSubject<IEditorBridgeServiceVisibleParam>(this._visibleParam);
- readonly visible$ = this._visible$.asObservable();
-
- private readonly _afterVisible$ = new BehaviorSubject<IEditorBridgeServiceVisibleParam>(this._visibleParam);
- readonly afterVisible$ = this._afterVisible$.asObservable();
-
- private _currentEditRectInfo: ISetEditorInfo;
-
- constructor(
- @IEditorService private readonly _editorService: IEditorService,
- @IContextService private readonly _contextService: IContextService,
- @IRenderManagerService private readonly _renderManagerService: IRenderManagerService
- ) {
- super();
- }
-
- override dispose() {
- super.dispose();
- }
-
- getEditorRect() {
- return this._currentEditRectInfo;
- }
-
- /**
- * 1st part of startEditing.
- * @editorInfo editorInfo
- */
- setEditorRect(editorInfo: ISetEditorInfo) {
- this._currentEditRectInfo = editorInfo;
- // If there is no editor currently focused, then default to selecting the sheet editor to prevent the editorService from using the previously selected editor object.
- // todo: wzhudev: In univer mode, it is necessary to switch to the corresponding editorId based on the host's unitId.
- if (!this._editorService.getFocusEditor()) {
- this._editorService.focus(SLIDE_EDITOR_ID);
- this._contextService.setContextValue(EDITOR_ACTIVATED, false);
- this._contextService.setContextValue(FOCUSING_EDITOR_STANDALONE, false);
- this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, false);
- }
-
- const editRectState = this.getEditRectState();
- this._currentEditRectState = editRectState;
-
- // slide-editing.render-controller@_subscribeToCurrentCell(Set editorUnitId to curr doc.)
- // --> activate(-1000, -1000)
- this._currentEditRectState$.next(editRectState);
- }
-
- changeVisible(param: IEditorBridgeServiceVisibleParam) {
- /**
- * Non-sheetEditor and formula selection mode,
- * double-clicking cannot activate the sheet editor.
- */
- // const editor = this._editorService.getFocusEditor();
- // if (this._refSelectionsService.getCurrentSelections().length > 0 && editor && !editor.isSheetEditor()) {
- // return;
- // }
-
- this._visibleParam = param;
-
- // Reset the dirty status when the editor is visible.
- if (param.visible) {
- this._editorIsDirty = false;
- }
-
- // subscriber: slide-editing.render-controller.ts@_handleEditorVisible
- this._visible$.next(this._visibleParam);
- this._afterVisible$.next(this._visibleParam);
- }
-
- /**
- * get info from _currentEditRectInfo
- *
- * invoked by slide-editing.render-controller.ts@_handleEditorVisible
- * && this@setEditorRect
- */
- getEditRectState(): Readonly<Nullable<IEditorBridgeServiceParam>> {
- const editorUnitId = SLIDE_EDITOR_ID;
-
- //editorBridgeRenderController.slideTextEditor$ ---> editorBridgeRenderController@_updateEditor --> this._currentEditRectInfo = xxx
- const editorRectInfo = this._currentEditRectInfo;
- const unitId = editorRectInfo.unitId;
-
- const docData = editorRectInfo.richTextObj.documentData;
- docData.id = editorUnitId;
- docData.documentStyle = {
- ...docData.documentStyle,
- ...{
- pageSize: { width: editorRectInfo.richTextObj.width, height: Infinity },
- },
- };
-
- const docDataModel = new DocumentDataModel(docData);
- const documentLayoutObject: IDocumentLayoutObject = {
- documentModel: docDataModel,
- fontString: 'document',
- textRotation: { a: 0, v: 0 },
- wrapStrategy: 0,
- verticalAlign: VerticalAlign.TOP,
- horizontalAlign: HorizontalAlign.LEFT,
- paddingData: { t: 0, b: 1, l: 2, r: 2 },
- };
-
- // see insert-text.operation
- const editorWidth = editorRectInfo.richTextObj.width;
- const editorHeight = editorRectInfo.richTextObj.height;
- const left = editorRectInfo.richTextObj.left;
- const top = editorRectInfo.richTextObj.top;
-
- const canvasOffset = {
- left: 0,
- top: 0,
- };
- // canvasOffset will be used in slide-editing.render-controller.ts@_handleEditorVisible
- // const mainScene = this._mainScene;
- const renderUnit = this._renderManagerService.getRenderUnitById(unitId);
- const mainScene = renderUnit?.scene;
- const mainViewport = mainScene?.getViewport(SLIDE_KEY.VIEW);
- const slideMainRect = mainScene?.getObject(SLIDE_KEY.COMPONENT);
- const slidePos = {
- x: slideMainRect?.left || 0,
- y: slideMainRect?.top || 0,
- };
- const scrollX = mainViewport?.viewportScrollX || 0;
- const scrollY = mainViewport?.viewportScrollY || 0;
- canvasOffset.left = slidePos.x - scrollX;
- canvasOffset.top = slidePos.y - scrollY;
-
- return {
- position: {
- startX: left,
- startY: top,
- endX: left + editorWidth,
- endY: top + editorHeight,
- },
- scaleX: 1,
- scaleY: 1,
- slideCardOffset: canvasOffset,
- unitId,
- editorUnitId,
- documentLayoutObject,
- } as IEditorBridgeServiceParam;
- }
-
- changeEditorDirty(dirtyStatus: boolean) {
- this._editorIsDirty = dirtyStatus;
- }
-
- isVisible() {
- return this._visibleParam.visible;
- }
-
- getEditorDirty() {
- return this._editorIsDirty;
- }
-
- getCurrentEditorId() {
- return this._editorUnitId;
- }
-}
diff --git a/packages/slides-ui/src/services/slide-editor-manager.service.ts b/packages/slides-ui/src/services/slide-editor-manager.service.ts
deleted file mode 100644
index 9a7194a5c1..0000000000
--- a/packages/slides-ui/src/services/slide-editor-manager.service.ts
+++ /dev/null
@@ -1,98 +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, IPosition, Nullable } from '@univerjs/core';
-import type { Observable } from 'rxjs';
-import { createIdentifier } from '@univerjs/core';
-import { BehaviorSubject } from 'rxjs';
-
-export interface ICellEditorManagerParam extends Partial<IPosition> {
- show: boolean;
-}
-
-export interface ICellEditorBoundingClientRect {
- left: number;
- top: number;
- width: number;
- height: number;
-}
-
-export interface ISlideEditorManagerService {
- state$: Observable<Nullable<ICellEditorManagerParam>>;
- rect$: Observable<Nullable<ICellEditorBoundingClientRect>>;
- focus$: Observable<boolean>;
- dispose(): void;
- setState(param: ICellEditorManagerParam): void;
- getState(): Readonly<Nullable<ICellEditorManagerParam>>;
- setRect(param: ICellEditorBoundingClientRect): void;
- getRect(): Readonly<Nullable<ICellEditorBoundingClientRect>>;
- setFocus(param: boolean): void;
-}
-
-export class SlideEditorManagerService implements ISlideEditorManagerService, IDisposable {
- private _state: Nullable<ICellEditorManagerParam> = null;
-
- private _rect: Nullable<ICellEditorBoundingClientRect> = null;
-
- private readonly _state$ = new BehaviorSubject<Nullable<ICellEditorManagerParam>>(null);
- readonly state$ = this._state$.asObservable();
-
- private readonly _rect$ = new BehaviorSubject<Nullable<ICellEditorBoundingClientRect>>(null);
- readonly rect$ = this._rect$.asObservable();
-
- private _focus: boolean = false;
- private readonly _focus$ = new BehaviorSubject<boolean>(this._focus);
- readonly focus$ = this._focus$.asObservable();
-
- dispose(): void {
- this._state$.complete();
- this._state = null;
- this._rect$.complete();
- this._rect = null;
- }
-
- setState(param: ICellEditorManagerParam) {
- this._state = param;
-
- this._refresh(param);
- }
-
- getRect(): Readonly<Nullable<ICellEditorBoundingClientRect>> {
- return this._rect;
- }
-
- setRect(param: ICellEditorBoundingClientRect) {
- this._rect = param;
- this._rect$.next(param);
- }
-
- getState(): Readonly<Nullable<ICellEditorManagerParam>> {
- return this._state;
- }
-
- setFocus(param: boolean = false) {
- this._focus = param;
- this._focus$.next(param);
- }
-
- private _refresh(param: ICellEditorManagerParam): void {
- this._state$.next(param);
- }
-}
-
-export const ISlideEditorManagerService = createIdentifier<ISlideEditorManagerService>(
- 'univer.slide-editor-manager.service'
-);
diff --git a/packages/slides-ui/src/services/slide-popup-manager.service.ts b/packages/slides-ui/src/services/slide-popup-manager.service.ts
deleted file mode 100644
index f988c2c48f..0000000000
--- a/packages/slides-ui/src/services/slide-popup-manager.service.ts
+++ /dev/null
@@ -1,162 +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 { BaseObject, IBoundRectNoAngle, IRender, Scene } from '@univerjs/engine-render';
-import type { IPopup } from '@univerjs/ui';
-import {
- Disposable,
- DisposableCollection,
- ICommandService,
- Inject,
- IUniverInstanceService,
- UniverInstanceType,
-} from '@univerjs/core';
-import { IRenderManagerService, pxToNum } from '@univerjs/engine-render';
-import { SLIDE_KEY } from '@univerjs/slides';
-import { ICanvasPopupService } from '@univerjs/ui';
-import { BehaviorSubject } from 'rxjs';
-
-export interface ISlideCanvasPopup extends Pick<IPopup, 'direction' | 'excludeOutside' | 'componentKey' | 'offset' | 'onClickOutside' | 'hideOnInvisible'> {
- mask?: boolean;
- extraProps?: Record<string, any>;
-}
-
-export function transformBound2OffsetBound(originBound: IBoundRectNoAngle, scene: Scene): IBoundRectNoAngle {
- const topLeft = transformPosition2Offset(originBound.left, originBound.top, scene);
- const bottomRight = transformPosition2Offset(originBound.right, originBound.bottom, scene);
-
- return {
- left: topLeft.x,
- top: topLeft.y,
- right: bottomRight.x,
- bottom: bottomRight.y,
- };
-}
-
-export function transformPosition2Offset(x: number, y: number, scene: Scene) {
- const { scaleX, scaleY } = scene.getAncestorScale();
- const viewMain = scene.getViewport(SLIDE_KEY.VIEW);
- if (!viewMain) {
- return {
- x,
- y,
- };
- }
-
- const { viewportScrollX: actualScrollX, viewportScrollY: actualScrollY } = viewMain;
-
- const offsetX = (x - actualScrollX) * scaleX;
-
- const offsetY = (y - actualScrollY) * scaleY;
-
- return {
- x: offsetX,
- y: offsetY,
- };
-}
-
-export class SlideCanvasPopMangerService extends Disposable {
- constructor(
- @Inject(ICanvasPopupService) private readonly _globalPopupManagerService: ICanvasPopupService,
- @IRenderManagerService private readonly _renderManagerService: IRenderManagerService,
- @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
- @ICommandService private readonly _commandService: ICommandService
- ) {
- super();
- }
-
- private _createObjectPositionObserver(
- targetObject: BaseObject,
- currentRender: IRender
- ) {
- const calc = () => {
- const { scene, engine } = currentRender;
- const { left, top, width, height } = targetObject;
-
- const horizontalOffset = (scene.width - (currentRender.mainComponent?.width ?? 0)) / 2;
- const verticalOffset = (scene.height - (currentRender.mainComponent?.height ?? 0)) / 2;
-
- const bound: IBoundRectNoAngle = {
- left,
- right: left + width,
- top,
- bottom: top + height,
- };
- const canvasElement = engine.getCanvasElement();
- const canvasClientRect = canvasElement.getBoundingClientRect();
- const widthOfCanvas = pxToNum(canvasElement.style.width); // declared width
-
- const { scaleX, scaleY } = scene.getAncestorScale();
-
- const offsetBound = transformBound2OffsetBound(bound, scene);
- const { top: topOffset, left: leftOffset, width: domWidth } = canvasClientRect;
- const scaleAdjust = domWidth / widthOfCanvas;
-
- const position = {
- left: (offsetBound.left * scaleAdjust * scaleX) + leftOffset + horizontalOffset,
- right: (offsetBound.right * scaleAdjust * scaleX) + leftOffset + horizontalOffset,
- top: (offsetBound.top * scaleAdjust * scaleY) + topOffset + verticalOffset,
- bottom: (offsetBound.bottom * scaleAdjust * scaleY) + topOffset + verticalOffset,
- };
- return position;
- };
-
- const position = calc();
- const position$ = new BehaviorSubject(position);
- const disposable = new DisposableCollection();
-
- return {
- position,
- position$,
- disposable,
- };
- }
-
- attachPopupToObject(targetObject: BaseObject, popup: ISlideCanvasPopup): IDisposable {
- const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SLIDE)!;
- const unitId = workbook.getUnitId();
- // const subUnitId =
-
- const currentRender = this._renderManagerService.getRenderUnitById(unitId);
- if (!currentRender) {
- return {
- dispose: () => {
- // empty
- },
- };
- }
-
- const { position, position$, disposable } = this._createObjectPositionObserver(targetObject, currentRender);
-
- const id = this._globalPopupManagerService.addPopup({
- ...popup,
- unitId,
- subUnitId: 'default',
- anchorRect: position,
- anchorRect$: position$,
- canvasElement: currentRender.engine.getCanvasElement(),
- });
-
- return {
- dispose: () => {
- this._globalPopupManagerService.removePopup(id);
- position$.complete();
- disposable.dispose();
- },
- };
- }
-}
diff --git a/packages/slides-ui/src/services/slide-render.service.ts b/packages/slides-ui/src/services/slide-render.service.ts
deleted file mode 100644
index b98bd96ada..0000000000
--- a/packages/slides-ui/src/services/slide-render.service.ts
+++ /dev/null
@@ -1,97 +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 type { SlideDataModel } from '@univerjs/slides';
-import {
- IContextService,
- IUniverInstanceService,
- RxDisposable,
- UniverInstanceType,
-} from '@univerjs/core';
-import { IRenderManagerService } from '@univerjs/engine-render';
-import { takeUntil } from 'rxjs';
-
-/**
- * This controller is responsible for managing units of a specific kind to be rendered on the canvas.
- */
-export class SlideRenderService extends RxDisposable {
- // private _skeletonChangeMutations = new Set<string>();
-
- constructor(
- @IContextService private readonly _contextService: IContextService,
- @IUniverInstanceService private readonly _instanceSrv: IUniverInstanceService,
- @IRenderManagerService private readonly _renderManagerService: IRenderManagerService
- ) {
- super();
-
- // It should be initialized after all other plugins are ready.
- Promise.resolve().then(() => this._init());
- }
-
- private _init() {
- this._initSlideDataListener();
- this._initContextListener();
- }
-
- private _initSlideDataListener(): void {
- this._instanceSrv.getTypeOfUnitAdded$<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE)
- .pipe(takeUntil(this.dispose$))
- .subscribe((event) => {
- // TODO when does this function get called?
- this._createRenderer(event.unit.getUnitId());
- });
-
- this._instanceSrv.getAllUnitsForType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE).forEach((slideModel) => {
- this._createRenderer(slideModel.getUnitId());
- });
-
- this._instanceSrv.getTypeOfUnitDisposed$<Workbook>(UniverInstanceType.UNIVER_SLIDE)
- .pipe(takeUntil(this.dispose$))
- .subscribe((workbook) => this._disposeRenderer(workbook));
- }
-
- private _createRenderer(unitId: string): void {
- if (unitId == null) {
- return;
- }
-
- const model = this._instanceSrv.getUnit(unitId, UniverInstanceType.UNIVER_SLIDE);
- if (model == null) {
- return;
- }
-
- this._renderManagerService.createRender(unitId);
- }
-
- private _disposeRenderer(workbook: Workbook): void {
- const unitId = workbook.getUnitId();
- this._renderManagerService.removeRender(unitId);
- }
-
- private _initContextListener(): void {
- // If we toggle the raw formula, we need to refresh all spreadsheets.
- // this._contextService.subscribeContextValue$(RENDER_RAW_FORMULA_KEY)
- // .pipe(distinctUntilChanged(), takeUntil(this.dispose$))
- // .subscribe(() => {
- // this._renderManagerService.getRenderAll().forEach((renderer) => {
- // if (renderer.mainComponent instanceof Spreadsheet) {
- // (renderer.mainComponent as Spreadsheet).makeForceDirty(true);
- // }
- // });
- // });
- }
-}
diff --git a/packages/slides-ui/src/type.ts b/packages/slides-ui/src/type.ts
deleted file mode 100644
index 96c059bbf3..0000000000
--- a/packages/slides-ui/src/type.ts
+++ /dev/null
@@ -1,41 +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 interface ISlideRichTextProps {
- /**
- * top offset value of PPT card area(px).
- */
- top: number;
- /**
- * left offset value of PPT card area(px).
- */
- left: number;
- width: number;
- height: number;
- scaleX: number;
- scaleY: number;
- text: string;
- fs: number;
- //... align margin...
-};
-
-export enum CursorChange {
- InitialState,
- StartEditor,
- CursorChange,
-}
-
-export type PageID = string;
diff --git a/packages/slides-ui/src/views/editor-container/EditorContainer.tsx b/packages/slides-ui/src/views/editor-container/EditorContainer.tsx
deleted file mode 100644
index 3c0dea2f8e..0000000000
--- a/packages/slides-ui/src/views/editor-container/EditorContainer.tsx
+++ /dev/null
@@ -1,137 +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 } from '@univerjs/core';
-import { createParagraphId, DEFAULT_EMPTY_DOCUMENT_VALUE, DocumentFlavor, IContextService } from '@univerjs/core';
-import { borderClassName, clsx } from '@univerjs/design';
-import { IEditorService } from '@univerjs/docs-ui';
-import { FIX_ONE_PIXEL_BLUR_OFFSET } from '@univerjs/engine-render';
-import { DISABLE_AUTO_FOCUS_KEY, useDependency, useObservable } from '@univerjs/ui';
-import { useEffect, useState } from 'react';
-import { SLIDE_EDITOR_ID } from '../../const';
-import { ISlideEditorManagerService } from '../../services/slide-editor-manager.service';
-
-const HIDDEN_EDITOR_POSITION = -1000;
-
-const EDITOR_DEFAULT_POSITION = {
- width: 0,
- height: 0,
- top: HIDDEN_EDITOR_POSITION,
- left: HIDDEN_EDITOR_POSITION,
-};
-
-/**
- * Floating editor's container.
- */
-export function SlideEditorContainer() {
- const [state, setState] = useState({
- ...EDITOR_DEFAULT_POSITION,
- });
-
- const slideEditorManagerService = useDependency(ISlideEditorManagerService);
- const editorService = useDependency(IEditorService);
- const contextService = useDependency(IContextService);
-
- const disableAutoFocus = useObservable(
- () => contextService.subscribeContextValue$(DISABLE_AUTO_FOCUS_KEY),
- false,
- undefined,
- [contextService, DISABLE_AUTO_FOCUS_KEY]
- );
-
- const snapshot: IDocumentData = {
- id: SLIDE_EDITOR_ID,
- body: {
- dataStream: `${DEFAULT_EMPTY_DOCUMENT_VALUE}`,
- textRuns: [],
- paragraphs: [
- {
- startIndex: 0,
- paragraphId: createParagraphId(new Set()),
- },
- ],
- },
- documentStyle: {
- documentFlavor: DocumentFlavor.UNSPECIFIED,
- },
- };
-
- useEffect(() => {
- const subscription = slideEditorManagerService.state$.subscribe((param) => {
- if (param == null) {
- return;
- }
-
- const {
- startX = HIDDEN_EDITOR_POSITION,
- startY = HIDDEN_EDITOR_POSITION,
- endX = 0,
- endY = 0,
- show = false,
- } = param;
-
- if (!show) {
- setState({
- ...EDITOR_DEFAULT_POSITION,
- });
- } else {
- setState({
- width: endX - startX - FIX_ONE_PIXEL_BLUR_OFFSET + 2,
- height: endY - startY - FIX_ONE_PIXEL_BLUR_OFFSET + 2,
- left: startX + FIX_ONE_PIXEL_BLUR_OFFSET,
- top: startY + FIX_ONE_PIXEL_BLUR_OFFSET,
- });
-
- const editor = editorService.getEditor(SLIDE_EDITOR_ID);
-
- if (editor == null) {
- return;
- }
-
- const { left, top, width, height } = editor.getBoundingClientRect();
-
- slideEditorManagerService.setRect({ left, top, width, height });
- }
- });
-
- return () => subscription.unsubscribe();
- }, [editorService, slideEditorManagerService]);
-
- useEffect(() => {
- if (!disableAutoFocus) {
- slideEditorManagerService.setFocus(true);
- }
- }, [disableAutoFocus, state]);
-
- return (
- <div
- className={clsx('univer-absolute univer-z-10 univer-box-border univer-flex', borderClassName)}
- style={{
- left: state.left,
- top: state.top,
- width: state.width,
- height: state.height,
- }}
- >
- {/* <RichTextEditor
- editorId={SLIDE_EDITOR_ID}
- className={styles.editorInput}
- initialValue={snapshot}
- isSingle={false}
- /> */}
- </div>
- );
-};
diff --git a/packages/slides-ui/src/views/image-popup-menu/ImagePopupMenu.tsx b/packages/slides-ui/src/views/image-popup-menu/ImagePopupMenu.tsx
deleted file mode 100644
index a59f621a55..0000000000
--- a/packages/slides-ui/src/views/image-popup-menu/ImagePopupMenu.tsx
+++ /dev/null
@@ -1,129 +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 { IDrawingSearch } from '@univerjs/core';
-import { ICommandService, LocaleService } from '@univerjs/core';
-import { borderClassName, clsx, Dropdown } from '@univerjs/design';
-import { AutofillDoubleIcon, MoreDownIcon } from '@univerjs/icons';
-import { useDependency } from '@univerjs/ui';
-import { useState } from 'react';
-
-export interface IImagePopupMenuItem {
- label: string;
- index: number;
- commandId: string;
- commandParams?: IDrawingSearch[];
- disable: boolean;
-}
-
-export interface IImagePopupMenuExtraProps {
- menuItems: IImagePopupMenuItem[];
-}
-
-export interface IImagePopupMenuProps {
- popup: {
- extraProps?: IImagePopupMenuExtraProps;
- };
-}
-
-export function SlideImagePopupMenu(props: IImagePopupMenuProps) {
- const menuItems = props.popup?.extraProps?.menuItems;
- const commandService = useDependency(ICommandService);
- const localeService = useDependency(LocaleService);
- const [visible, setVisible] = useState(false);
- const [isHovered, setIsHovered] = useState(false);
-
- if (!menuItems) {
- return null;
- }
-
- const handleMouseEnter = () => {
- setIsHovered(true);
- };
-
- const handleMouseLeave = () => {
- setIsHovered(false);
- };
-
- const onVisibleChange = (visible: boolean) => {
- setVisible(visible);
- };
-
- const handleClick = (item: IImagePopupMenuItem) => {
- commandService.executeCommand(item.commandId, item.commandParams);
- setVisible(false);
- };
-
- const showMore = visible || isHovered;
-
- const availableMenu = menuItems.filter((item) => !item.disable);
-
- return (
- <div
- onMouseEnter={handleMouseEnter}
- onMouseLeave={handleMouseLeave}
- >
- <Dropdown
- align="start"
- overlay={(
- <ul
- className={clsx(`
- univer-m-0 univer-box-border univer-grid univer-list-none univer-items-center univer-gap-1
- univer-rounded-lg univer-bg-gray-0 univer-p-1.5 univer-text-sm univer-shadow-lg
- `, borderClassName)}
- >
- {availableMenu.map((item) => (
- <li
- key={item.index}
- className={`
- univer-relative univer-box-border univer-flex univer-h-8 univer-cursor-pointer
- univer-items-center univer-rounded univer-text-sm univer-transition-colors
- hover:univer-bg-gray-100
- `}
- onClick={() => handleClick(item)}
- >
- <span className="univer-px-2 univer-py-1.5 univer-align-middle">
- {localeService.t(item.label)}
- </span>
- </li>
- ))}
- </ul>
- )}
- open={visible}
- onOpenChange={onVisibleChange}
- >
- <div
- className={clsx(`
- univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1
- hover:univer-bg-gray-100
- dark:hover:!univer-bg-gray-800
- `, borderClassName, {
- 'univer-bg-gray-100 dark:!univer-bg-gray-800': visible,
- 'univer-bg-gray-0 dark:!univer-bg-gray-900': !visible,
- })}
- >
- <AutofillDoubleIcon
- className={`
- univer-fill-primary-600 univer-text-gray-900
- dark:!univer-text-gray-0
- `}
- />
- {showMore && <MoreDownIcon className="dark:!univer-text-gray-0" />}
- </div>
- </Dropdown>
- </div>
- );
-};
diff --git a/packages/slides-ui/src/views/image-popup-menu/component-name.ts b/packages/slides-ui/src/views/image-popup-menu/component-name.ts
deleted file mode 100644
index 483c88a03c..0000000000
--- a/packages/slides-ui/src/views/image-popup-menu/component-name.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 COMPONENT_SLIDE_IMAGE_POPUP_MENU = 'COMPONENT_SLIDE_IMAGE_POPUP_MENU';
diff --git a/packages/slides-ui/src/views/panels/ArrangePanel.tsx b/packages/slides-ui/src/views/panels/ArrangePanel.tsx
deleted file mode 100644
index 4727bb90a4..0000000000
--- a/packages/slides-ui/src/views/panels/ArrangePanel.tsx
+++ /dev/null
@@ -1,146 +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 { Image, Rect, RichText } from '@univerjs/engine-render';
-import type { LocaleKey } from '../../locale/types';
-import { ICommandService, LocaleService } from '@univerjs/core';
-import { Button } from '@univerjs/design';
-import { BottomIcon, MoveDownIcon, MoveUpIcon, TopmostIcon } from '@univerjs/icons';
-import { useDependency } from '@univerjs/ui';
-import { UpdateSlideElementOperation } from '../../commands/operations/update-element.operation';
-import { CanvasView } from '../../controllers/canvas-view';
-
-enum ArrangeTypeEnum {
- forward,
- backward,
- front,
- back,
-}
-
-interface IProps {
- pageId: string;
- unitId: string;
-}
-
-export default function ArrangePanel(props: IProps) {
- const { pageId, unitId } = props;
-
- const localeService = useDependency(LocaleService);
- const canvasView = useDependency(CanvasView);
- const commandService = useDependency(ICommandService);
-
- const page = canvasView.getRenderUnitByPageId(pageId, unitId);
- const scene = page?.scene;
- if (!scene) return null;
-
- const transformer = scene.getTransformer();
- if (!transformer) return null;
-
- const selectedObjects = transformer.getSelectedObjectMap();
- const object = selectedObjects.values().next().value as Nullable<Rect | RichText | Image>;
- if (!object) return null;
-
- const onArrangeBtnClick = (arrangeType: ArrangeTypeEnum) => {
- const allObjects = scene.getAllObjects();
-
- const [minZIndex, maxZIndex] = allObjects.reduce(([min, max], obj) => {
- const zIndex = obj.zIndex;
- const minZIndex = zIndex < min ? zIndex : min;
- const maxZIndex = zIndex > max ? zIndex : max;
-
- return [minZIndex, maxZIndex];
- }, [0, 0]);
-
- let zIndex = object.zIndex;
- if (arrangeType === ArrangeTypeEnum.back) {
- zIndex = minZIndex - 1;
- } else if (arrangeType === ArrangeTypeEnum.front) {
- zIndex = maxZIndex + 1;
- } else if (arrangeType === ArrangeTypeEnum.forward) {
- zIndex = object.zIndex + 1;
- } else if (arrangeType === ArrangeTypeEnum.backward) {
- zIndex = object.zIndex - 1;
- }
-
- object.setProps({
- zIndex,
- });
-
- commandService.executeCommand(UpdateSlideElementOperation.id, {
- unitId,
- oKey: object?.oKey,
- props: {
- zIndex,
- },
- });
- };
-
- return (
- <div className="univer-relative univer-w-full">
- <div className="univer-relative univer-mt-2.5 univer-flex univer-h-full">
- <div
- className={`
- univer-w-full univer-text-left univer-text-gray-600
- dark:!univer-text-gray-200
- `}
- >
- <div>{localeService.t<LocaleKey>('slides-ui.image-panel.arrange.title')}</div>
- </div>
- </div>
- <div className="univer-relative univer-mt-2.5 univer-flex univer-h-full">
- <div className="univer-w-1/2">
- <Button onClick={() => { onArrangeBtnClick(ArrangeTypeEnum.forward); }}>
- <span className="univer-flex univer-items-center univer-gap-1">
- <MoveUpIcon />
- {localeService.t<LocaleKey>('slides-ui.image-panel.arrange.forward')}
- </span>
-
- </Button>
- </div>
- <div className="univer-w-1/2">
- <Button onClick={() => { onArrangeBtnClick(ArrangeTypeEnum.backward); }}>
- <span className="univer-flex univer-items-center univer-gap-1">
- <MoveDownIcon />
- {localeService.t<LocaleKey>('slides-ui.image-panel.arrange.backward')}
- </span>
-
- </Button>
- </div>
- </div>
- <div className="univer-relative univer-mt-2.5 univer-flex univer-h-full">
- <div className="univer-w-1/2">
- <Button onClick={() => { onArrangeBtnClick(ArrangeTypeEnum.front); }}>
- <span className="univer-flex univer-items-center univer-gap-1">
- <TopmostIcon />
- {localeService.t<LocaleKey>('slides-ui.image-panel.arrange.front')}
- </span>
-
- </Button>
- </div>
- <div className="univer-w-1/2">
- <Button onClick={() => { onArrangeBtnClick(ArrangeTypeEnum.back); }}>
- <span className="univer-flex univer-items-center univer-gap-1">
- <BottomIcon />
- {localeService.t<LocaleKey>('slides-ui.image-panel.arrange.back')}
- </span>
-
- </Button>
- </div>
- </div>
- </div>
- );
-}
diff --git a/packages/slides-ui/src/views/panels/FillPanel.tsx b/packages/slides-ui/src/views/panels/FillPanel.tsx
deleted file mode 100644
index 9b5cd59c75..0000000000
--- a/packages/slides-ui/src/views/panels/FillPanel.tsx
+++ /dev/null
@@ -1,113 +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 { Rect } from '@univerjs/engine-render';
-import type { LocaleKey } from '../../locale/types';
-import { ICommandService, LocaleService } from '@univerjs/core';
-import { borderTopClassName, clsx, ColorPicker, Dropdown } from '@univerjs/design';
-import { MoreDownIcon, PaintBucketDoubleIcon } from '@univerjs/icons';
-import { useDependency } from '@univerjs/ui';
-import { useState } from 'react';
-import { UpdateSlideElementOperation } from '../../commands/operations/update-element.operation';
-import { CanvasView } from '../../controllers/canvas-view';
-
-interface IProps {
- pageId: string;
- unitId: string;
-}
-
-/**
- *
- * @param props
- */
-export default function ArrangePanel(props: IProps) {
- const { pageId, unitId } = props;
-
- const localeService = useDependency(LocaleService);
- const canvasView = useDependency(CanvasView);
- const commandService = useDependency(ICommandService);
-
- const page = canvasView.getRenderUnitByPageId(pageId, unitId);
- const scene = page?.scene;
- const transformer = scene?.getTransformer();
- const object = transformer?.getSelectedObjectMap().values().next().value as Nullable<Rect>;
- const [color, setColor] = useState<string>(object?.fill?.toString() ?? '');
-
- if (!scene || !transformer || !object) return null;
-
- /**
- *
- * @param color
- */
- function handleChangeColor(color: string) {
- object?.setProps({
- fill: color,
- });
- commandService.executeCommand(UpdateSlideElementOperation.id, {
- unitId,
- oKey: object?.oKey,
- props: {
- shape: {
- shapeProperties: {
- shapeBackgroundFill: {
- rgb: color,
- },
- },
- },
- },
- });
- setColor(color);
- }
-
- return (
- <div
- className={clsx('univer-relative univer-bottom-0 univer-mt-5 univer-w-full', borderTopClassName)}
- >
- <div className="univer-relative univer-w-full">
- <div className="univer-relative univer-mt-2.5 univer-flex univer-h-full">
- <div
- className={`
- univer-w-full univer-text-left univer-text-gray-600
- dark:!univer-text-gray-200
- `}
- >
- <div>{localeService.t<LocaleKey>('slides-ui.panel.fill.title')}</div>
- </div>
- </div>
- <div className="univer-relative univer-mt-2.5 univer-flex univer-h-full">
- <div className="univer-w-1/2">
- <Dropdown
- overlay={(
- <div className="univer-rounded-lg univer-p-4">
- <ColorPicker
- value="#fff"
- onChange={handleChangeColor}
- />
- </div>
- )}
- >
- <a className="univer-flex univer-cursor-pointer univer-items-center univer-gap-1">
- <PaintBucketDoubleIcon className="univer-fill-primary-600" />
- <MoreDownIcon />
- </a>
- </Dropdown>
- </div>
- </div>
- </div>
- </div>
- );
-}
diff --git a/packages/slides-ui/src/views/panels/TransformPanel.tsx b/packages/slides-ui/src/views/panels/TransformPanel.tsx
deleted file mode 100644
index 04797d9a5e..0000000000
--- a/packages/slides-ui/src/views/panels/TransformPanel.tsx
+++ /dev/null
@@ -1,236 +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 { BaseObject, IChangeObserverConfig, Image, Rect, RichText } from '@univerjs/engine-render';
-import type { LocaleKey } from '../../locale/types';
-import { ICommandService, LocaleService } from '@univerjs/core';
-import { borderTopClassName, clsx, InputNumber } from '@univerjs/design';
-import { useDependency } from '@univerjs/ui';
-import { useEffect, useState } from 'react';
-import { UpdateSlideElementOperation } from '../../commands/operations/update-element.operation';
-import { CanvasView } from '../../controllers/canvas-view';
-
-interface IProps {
- pageId: string;
- unitId: string;
-}
-
-export default function TransformPanel(props: IProps) {
- const { pageId, unitId } = props;
-
- const localeService = useDependency(LocaleService);
- const canvasView = useDependency(CanvasView);
- const commandService = useDependency(ICommandService);
-
- const page = canvasView.getRenderUnitByPageId(pageId, unitId);
- const scene = page?.scene;
- const transformer = scene?.getTransformer();
- const object = transformer?.getSelectedObjectMap().values().next().value as Nullable<Rect | Image | RichText>;
-
- const {
- width: originWidth = 0,
- height: originHeight = 0,
- left: originX = 0,
- top: originY = 0,
- angle: originRotation = 0,
- } = object ?? {};
-
- const [width, setWidth] = useState<number>(originWidth);
- const [height, setHeight] = useState(originHeight);
- const [xPosition, setXPosition] = useState(originX);
- const [yPosition, setYPosition] = useState(originY);
- const [rotation, setRotation] = useState(originRotation);
- // const [lockRatio, setLockRatio] = useState(transformer.keepRatio);
-
- // const handleLockRatioChange = (val: string | number | boolean) => {
- // setLockRatio(val as boolean);
- // transformer.keepRatio = val as boolean;
- // };
-
- const changeObs = (state: IChangeObserverConfig) => {
- const { objects } = state;
-
- const object = objects.values().next().value as BaseObject;
-
- const {
- width: originWidth = 0,
- height: originHeight = 0,
- left: originX = 0,
- top: originY = 0,
- angle: originRotation = 0,
- } = object;
-
- setWidth(originWidth);
- setHeight(originHeight);
- setXPosition(originX);
- setYPosition(originY);
- setRotation(originRotation);
- };
-
- useEffect(() => {
- if (!transformer) return;
- const changeStartSub = transformer.changeStart$.subscribe((state) => {
- changeObs(state);
- });
-
- const changingSub = transformer.changing$.subscribe((state) => {
- changeObs(state);
- });
-
- return () => {
- changingSub.unsubscribe();
- changeStartSub.unsubscribe();
- // focusSub.unsubscribe();
- };
- }, [transformer]);
-
- if (!scene || !transformer || !object) return null;
-
- function handleWidthChange(val: number | null) {
- if (!val || !object) return;
-
- commandService.executeCommand(UpdateSlideElementOperation.id, {
- pageId,
- oKey: object.oKey,
- props: {
- width: val,
- },
- });
- object?.resize(val, object.height);
- setWidth(val);
- transformer?.refreshControls();
- }
-
- function handleHeightChange(val: number | null) {
- if (!val || !object) return;
-
- commandService.executeCommand(UpdateSlideElementOperation.id, {
- pageId,
- oKey: object.oKey,
- props: {
- height: val,
- },
- });
- object?.resize(object.width, val);
- setHeight(val);
- transformer?.refreshControls();
- }
-
- function handleXChange(val: number | null) {
- if (!val || !object) return;
-
- commandService.executeCommand(UpdateSlideElementOperation.id, {
- pageId,
- oKey: object.oKey,
- props: {
- left: val,
- },
- });
- object?.translate(val, object.top);
- setXPosition(val);
- transformer?.refreshControls();
- }
-
- function handleYChange(val: number | null) {
- if (!val || !object) return;
-
- commandService.executeCommand(UpdateSlideElementOperation.id, {
- pageId,
- oKey: object.oKey,
- props: {
- right: val,
- },
- });
- object?.translate(object.left, val);
- setYPosition(val);
- transformer?.refreshControls();
- }
-
- function handleChangeRotation(val: number | null) {
- if (!val || !object) return;
-
- commandService.executeCommand(UpdateSlideElementOperation.id, {
- pageId,
- oKey: object.oKey,
- props: {
- angle: val,
- },
- });
- object?.transformByState({
- angle: val,
- });
- setRotation(val);
- transformer?.refreshControls();
- }
-
- return (
- <div
- className={clsx('univer-grid univer-gap-2 univer-py-2 univer-text-gray-400', borderTopClassName)}
- >
- <header
- className={`
- univer-text-gray-600
- dark:!univer-text-gray-200
- `}
- >
- <div>{localeService.t<LocaleKey>('slides-ui.image-panel.transform.title')}</div>
- </header>
-
- <div
- className={`
- univer-grid univer-grid-cols-3 univer-gap-2
- [&>div]:univer-grid [&>div]:univer-gap-2
- `}
- >
- <div>
- <span>{localeService.t<LocaleKey>('slides-ui.image-panel.transform.width')}</span>
- <InputNumber
- min={1}
- value={width}
- onChange={(val) => { handleWidthChange(val); }}
- />
- </div>
- <div>
- <span>{localeService.t<LocaleKey>('slides-ui.image-panel.transform.height')}</span>
- <InputNumber
- min={1}
- value={height}
- onChange={(val) => { handleHeightChange(val); }}
- />
- </div>
- </div>
- <div className="univer-relative univer-mt-2.5 univer-flex univer-h-full">
- <div>
- <span>{localeService.t<LocaleKey>('slides-ui.image-panel.transform.x')}</span>
- <InputNumber min={0} precision={1} value={xPosition} onChange={(val) => { handleXChange(val); }} />
- </div>
- <div>
- <span>{localeService.t<LocaleKey>('slides-ui.image-panel.transform.y')}</span>
- <InputNumber min={0} precision={1} value={yPosition} onChange={(val) => { handleYChange(val); }} />
- </div>
- <div>
- <span>{localeService.t<LocaleKey>('slides-ui.image-panel.transform.rotate')}</span>
- <InputNumber
- precision={1}
- value={rotation}
- onChange={handleChangeRotation}
- />
- </div>
- </div>
- </div>
- );
-}
diff --git a/packages/slides-ui/src/views/panels/__tests__/ArrangePanel.spec.tsx b/packages/slides-ui/src/views/panels/__tests__/ArrangePanel.spec.tsx
deleted file mode 100644
index d6b5839202..0000000000
--- a/packages/slides-ui/src/views/panels/__tests__/ArrangePanel.spec.tsx
+++ /dev/null
@@ -1,255 +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 { ISlideData, SlideDataModel } from '@univerjs/slides';
-import type { Root } from 'react-dom/client';
-import {
- ICommandService,
- IUniverInstanceService,
- LocaleService,
- LocaleType,
- Univer,
- UniverInstanceType,
-} from '@univerjs/core';
-import { BasicShapes, PageElementType, PageType, UniverSlidesPlugin } from '@univerjs/slides';
-import { RediContext } from '@univerjs/ui';
-import { act } from 'react';
-import { createRoot } from 'react-dom/client';
-import { afterEach, beforeEach, describe, expect, it } from 'vitest';
-import { UpdateSlideElementOperation } from '../../../commands/operations/update-element.operation';
-import { CanvasView } from '../../../controllers/canvas-view';
-import locale from '../../../locale/en-US';
-import ArrangePanel from '../ArrangePanel';
-
-(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
-
-const UNIT_ID = 'arrange-panel-unit';
-const PAGE_ID = 'page-1';
-const SELECTED_ID = 'selected-shape';
-
-class TestSlideObject {
- constructor(
- readonly oKey: string,
- public zIndex: number
- ) {}
-
- setProps(props: { zIndex?: number }) {
- if (typeof props.zIndex === 'number') {
- this.zIndex = props.zIndex;
- }
- }
-}
-
-class TestTransformer {
- constructor(private readonly _object: TestSlideObject) {}
-
- getSelectedObjectMap() {
- return new Map([[this._object.oKey, this._object]]);
- }
-}
-
-class TestScene {
- private readonly _transformer: TestTransformer;
-
- constructor(private readonly _objects: TestSlideObject[], selectedObject: TestSlideObject) {
- this._transformer = new TestTransformer(selectedObject);
- }
-
- getTransformer() {
- return this._transformer;
- }
-
- getAllObjects() {
- return this._objects;
- }
-}
-
-class TestCanvasView {
- static scene: TestScene | null = null;
-
- static reset() {
- this.scene = null;
- }
-
- getRenderUnitByPageId() {
- return TestCanvasView.scene
- ? { scene: TestCanvasView.scene }
- : null;
- }
-}
-
-function createSlideSnapshot(): Partial<ISlideData> {
- return {
- id: UNIT_ID,
- title: 'Arrange panel deck',
- pageSize: { width: 960, height: 540 },
- body: {
- pageOrder: [PAGE_ID],
- pages: {
- [PAGE_ID]: {
- id: PAGE_ID,
- pageType: PageType.SLIDE,
- zIndex: 1,
- title: 'Slide',
- description: '',
- pageBackgroundFill: { rgb: '#ffffff' },
- pageElements: {
- [SELECTED_ID]: {
- id: SELECTED_ID,
- zIndex: 2,
- left: 100,
- top: 100,
- width: 120,
- height: 80,
- title: 'Selected shape',
- description: '',
- type: PageElementType.SHAPE,
- shape: {
- shapeType: BasicShapes.Rect,
- text: '',
- shapeProperties: {
- shapeBackgroundFill: { rgb: '#4472c4' },
- },
- },
- },
- },
- },
- },
- },
- };
-}
-
-function createPanelTestBed() {
- const univer = new Univer();
- univer.registerPlugin(UniverSlidesPlugin);
-
- const injector = univer.__getInjector();
- injector.add([CanvasView, { useClass: TestCanvasView as never }]);
-
- const slide = univer.createUnit<ISlideData, SlideDataModel>(UniverInstanceType.UNIVER_SLIDE, createSlideSnapshot());
- injector.get(IUniverInstanceService).focusUnit(UNIT_ID);
-
- const commandService = injector.get(ICommandService);
- commandService.registerCommand(UpdateSlideElementOperation);
- injector.get(LocaleService).load({
- [LocaleType.EN_US]: locale,
- });
- injector.get(LocaleService).setLocale(LocaleType.EN_US);
-
- return { univer, injector, slide };
-}
-
-function createRenderScene(selectedZIndex: number, otherZIndexes: number[]) {
- const selectedObject = new TestSlideObject(SELECTED_ID, selectedZIndex);
- const objects = [
- selectedObject,
- ...otherZIndexes.map((zIndex, index) => new TestSlideObject(`object-${index}`, zIndex)),
- ];
- TestCanvasView.scene = new TestScene(objects, selectedObject);
-
- return selectedObject;
-}
-
-function renderPanel(root: Root, testBed: ReturnType<typeof createPanelTestBed>) {
- act(() => {
- root.render(
- <RediContext.Provider value={{ injector: testBed.injector }}>
- <ArrangePanel pageId={PAGE_ID} unitId={UNIT_ID} />
- </RediContext.Provider>
- );
- });
-}
-
-function clickButton(container: HTMLElement, text: string) {
- const button = Array.from(container.querySelectorAll('button'))
- .find((button) => button.textContent?.includes(text));
- if (!button) {
- throw new Error(`Button not found: ${text}`);
- }
-
- act(() => {
- button.click();
- });
-}
-
-describe('ArrangePanel', () => {
- let root: Root | undefined;
- let container: HTMLDivElement | undefined;
- let currentTestBed: ReturnType<typeof createPanelTestBed> | undefined;
-
- beforeEach(() => {
- TestCanvasView.reset();
- });
-
- afterEach(() => {
- act(() => {
- root?.unmount();
- });
- container?.remove();
- currentTestBed?.univer.dispose();
- root = undefined;
- container = undefined;
- currentTestBed = undefined;
- });
-
- it('moves the selected slide element above every rendered object', () => {
- currentTestBed = createPanelTestBed();
- const selectedObject = createRenderScene(2, [1, 4]);
- container = document.createElement('div');
- document.body.appendChild(container);
- root = createRoot(container);
- renderPanel(root, currentTestBed);
-
- clickButton(container, 'Bring to Front');
-
- expect(selectedObject.zIndex).toBe(5);
- expect(currentTestBed.slide.getElement(PAGE_ID, SELECTED_ID)).toMatchObject({
- zIndex: 5,
- });
- });
-
- it('moves the selected slide element one layer forward', () => {
- currentTestBed = createPanelTestBed();
- const selectedObject = createRenderScene(2, [1, 4]);
- container = document.createElement('div');
- document.body.appendChild(container);
- root = createRoot(container);
- renderPanel(root, currentTestBed);
-
- clickButton(container, 'Bring Forward');
-
- expect(selectedObject.zIndex).toBe(3);
- expect(currentTestBed.slide.getElement(PAGE_ID, SELECTED_ID)).toMatchObject({
- zIndex: 3,
- });
- });
-
- it('moves the selected slide element behind every rendered object', () => {
- currentTestBed = createPanelTestBed();
- const selectedObject = createRenderScene(2, [3, 5]);
- container = document.createElement('div');
- document.body.appendChild(container);
- root = createRoot(container);
- renderPanel(root, currentTestBed);
-
- clickButton(container, 'Send to Back');
-
- expect(selectedObject.zIndex).toBe(-1);
- expect(currentTestBed.slide.getElement(PAGE_ID, SELECTED_ID)).toMatchObject({
- zIndex: -1,
- });
- });
-});
diff --git a/packages/slides-ui/src/views/panels/__tests__/TransformPanel.spec.tsx b/packages/slides-ui/src/views/panels/__tests__/TransformPanel.spec.tsx
deleted file mode 100644
index d12d1773c3..0000000000
--- a/packages/slides-ui/src/views/panels/__tests__/TransformPanel.spec.tsx
+++ /dev/null
@@ -1,270 +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 { ISlideData, SlideDataModel } from '@univerjs/slides';
-import type { Root } from 'react-dom/client';
-import {
- ICommandService,
- IUniverInstanceService,
- LocaleService,
- LocaleType,
- Univer,
- UniverInstanceType,
-} from '@univerjs/core';
-import { BasicShapes, PageElementType, PageType, UniverSlidesPlugin } from '@univerjs/slides';
-import { RediContext } from '@univerjs/ui';
-import { act } from 'react';
-import { createRoot } from 'react-dom/client';
-import { Subject } from 'rxjs';
-import { afterEach, beforeEach, describe, expect, it } from 'vitest';
-import { UpdateSlideElementOperation } from '../../../commands/operations/update-element.operation';
-import { CanvasView } from '../../../controllers/canvas-view';
-import locale from '../../../locale/en-US';
-import TransformPanel from '../TransformPanel';
-
-(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
-
-const UNIT_ID = 'transform-panel-unit';
-const PAGE_ID = 'page-1';
-const SELECTED_ID = 'selected-shape';
-
-class TestSlideObject {
- public refreshCount = 0;
-
- constructor(
- readonly oKey: string,
- public width: number,
- public height: number,
- public left: number,
- public top: number,
- public angle: number
- ) {}
-
- resize(width: number, height: number) {
- this.width = width;
- this.height = height;
- }
-
- translate(left: number, top: number) {
- this.left = left;
- this.top = top;
- }
-
- transformByState(state: { angle?: number }) {
- if (typeof state.angle === 'number') {
- this.angle = state.angle;
- }
- }
-}
-
-class TestTransformer {
- readonly changeStart$ = new Subject<{ objects: Map<string, TestSlideObject> }>();
- readonly changing$ = new Subject<{ objects: Map<string, TestSlideObject> }>();
-
- constructor(private readonly _object: TestSlideObject) {}
-
- getSelectedObjectMap() {
- return new Map([[this._object.oKey, this._object]]);
- }
-
- refreshControls() {
- this._object.refreshCount += 1;
- }
-}
-
-class TestScene {
- private readonly _transformer: TestTransformer;
-
- constructor(selectedObject: TestSlideObject) {
- this._transformer = new TestTransformer(selectedObject);
- }
-
- getTransformer() {
- return this._transformer;
- }
-}
-
-class TestCanvasView {
- static scene: TestScene | null = null;
-
- static reset() {
- this.scene = null;
- }
-
- getRenderUnitByPageId() {
- return TestCanvasView.scene
- ? { scene: TestCanvasView.scene }
- : null;
- }
-}
-
-function createSlideSnapshot(): Partial<ISlideData> {
- return {
- id: UNIT_ID,
- title: 'Transform panel deck',
- pageSize: { width: 960, height: 540 },
- body: {
- pageOrder: [PAGE_ID],
- pages: {
- [PAGE_ID]: {
- id: PAGE_ID,
- pageType: PageType.SLIDE,
- zIndex: 1,
- title: 'Slide',
- description: '',
- pageBackgroundFill: { rgb: '#ffffff' },
- pageElements: {
- [SELECTED_ID]: {
- id: SELECTED_ID,
- zIndex: 2,
- left: 100,
- top: 120,
- width: 160,
- height: 90,
- angle: 15,
- title: 'Selected shape',
- description: '',
- type: PageElementType.SHAPE,
- shape: {
- shapeType: BasicShapes.Rect,
- text: '',
- shapeProperties: {
- shapeBackgroundFill: { rgb: '#4472c4' },
- },
- },
- },
- },
- },
- },
- },
- };
-}
-
-function createPanelTestBed() {
- const univer = new Univer();
- univer.registerPlugin(UniverSlidesPlugin);
-
- const injector = univer.__getInjector();
- injector.add([CanvasView, { useClass: TestCanvasView as never }]);
-
- const slide = univer.createUnit<ISlideData, SlideDataModel>(UniverInstanceType.UNIVER_SLIDE, createSlideSnapshot());
- injector.get(IUniverInstanceService).focusUnit(UNIT_ID);
-
- const commandService = injector.get(ICommandService);
- commandService.registerCommand(UpdateSlideElementOperation);
- injector.get(LocaleService).load({
- [LocaleType.EN_US]: locale,
- });
- injector.get(LocaleService).setLocale(LocaleType.EN_US);
-
- return { univer, injector, slide };
-}
-
-function createRenderScene() {
- const selectedObject = new TestSlideObject(SELECTED_ID, 160, 90, 100, 120, 15);
- TestCanvasView.scene = new TestScene(selectedObject);
-
- return selectedObject;
-}
-
-function renderTransformPanel(root: Root, testBed: ReturnType<typeof createPanelTestBed>) {
- act(() => {
- root.render(
- <RediContext.Provider value={{ injector: testBed.injector }}>
- <TransformPanel pageId={PAGE_ID} unitId={UNIT_ID} />
- </RediContext.Provider>
- );
- });
-}
-
-function setInputValue(input: HTMLInputElement, value: number) {
- const valueSetter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set;
-
- act(() => {
- valueSetter?.call(input, String(value));
- input.dispatchEvent(new Event('input', { bubbles: true }));
- });
-}
-
-function getInputs(container: HTMLElement) {
- const inputs = Array.from(container.querySelectorAll('input'));
- if (inputs.length !== 5) {
- throw new Error(`Expected five transform inputs, received ${inputs.length}`);
- }
-
- return inputs;
-}
-
-describe('TransformPanel', () => {
- let root: Root | undefined;
- let container: HTMLDivElement | undefined;
- let currentTestBed: ReturnType<typeof createPanelTestBed> | undefined;
-
- beforeEach(() => {
- TestCanvasView.reset();
- });
-
- afterEach(() => {
- act(() => {
- root?.unmount();
- });
- container?.remove();
- currentTestBed?.univer.dispose();
- root = undefined;
- container = undefined;
- currentTestBed = undefined;
- });
-
- it('updates the selected slide element when dimension controls change', () => {
- currentTestBed = createPanelTestBed();
- const selectedObject = createRenderScene();
- container = document.createElement('div');
- document.body.appendChild(container);
- root = createRoot(container);
- renderTransformPanel(root, currentTestBed);
-
- const [widthInput, heightInput] = getInputs(container);
- setInputValue(widthInput, 240);
- setInputValue(heightInput, 135);
-
- expect(selectedObject).toMatchObject({
- width: 240,
- height: 135,
- refreshCount: 2,
- });
- });
-
- it('updates the selected slide element when position and rotation controls change', () => {
- currentTestBed = createPanelTestBed();
- const selectedObject = createRenderScene();
- container = document.createElement('div');
- document.body.appendChild(container);
- root = createRoot(container);
- renderTransformPanel(root, currentTestBed);
-
- const [, , xInput, yInput, rotationInput] = getInputs(container);
- setInputValue(xInput, 210);
- setInputValue(yInput, 180);
- setInputValue(rotationInput, 45);
-
- expect(selectedObject).toMatchObject({
- left: 210,
- top: 180,
- angle: 45,
- refreshCount: 3,
- });
- });
-});
diff --git a/packages/slides-ui/src/views/sidebar/Sidebar.tsx b/packages/slides-ui/src/views/sidebar/Sidebar.tsx
deleted file mode 100644
index b16f9fa8c6..0000000000
--- a/packages/slides-ui/src/views/sidebar/Sidebar.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 { Nullable } from '@univerjs/core';
-import type { BaseObject } from '@univerjs/engine-render';
-import type { SlideDataModel } from '@univerjs/slides';
-import { IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
-import { ObjectType } from '@univerjs/engine-render';
-import { useDependency } from '@univerjs/ui';
-import { CanvasView } from '../../controllers/canvas-view';
-import ArrangePanel from '../panels/ArrangePanel';
-import FillPanel from '../panels/FillPanel';
-import TransformPanel from '../panels/TransformPanel';
-
-export const COMPONENT_SLIDE_SIDEBAR = 'COMPONENT_SLIDE_SIDEBAR';
-
-export default function RectSidebar() {
- const univerInstanceService = useDependency(IUniverInstanceService);
- const canvasView = useDependency(CanvasView);
-
- const currentSlide = univerInstanceService.getCurrentUnitOfType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE);
- const pageId = currentSlide?.getActivePage()?.id;
-
- // see packages/sheets-ui/src/views/permission/permission-dialog/index.tsx@SheetPermissionDialog
- // see packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/index.tsx@getUnitId
- // const unitId = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SLIDE)!.getUnitId();
- const unitId = univerInstanceService.getFocusedUnit()?.getUnitId() || '';
-
- if (!pageId || !unitId) return null;
-
- const page = canvasView.getRenderUnitByPageId(pageId, unitId);
- const transformer = page.scene?.getTransformer();
-
- if (!transformer) return null;
-
- const selectedObjects = transformer.getSelectedObjectMap();
-
- const object = selectedObjects.values().next().value as Nullable<BaseObject>;
- if (!object) {
- return null;
- }
-
- return (
- <section className="univer-p-2 univer-text-center univer-text-sm">
- <ArrangePanel pageId={pageId} unitId={unitId} />
- <TransformPanel pageId={pageId} unitId={unitId} />
- {object.objectType === ObjectType.RECT && <FillPanel pageId={pageId} unitId={unitId} />}
- </section>
- );
-}
diff --git a/packages/slides-ui/src/views/slide-bar/SlideBar.tsx b/packages/slides-ui/src/views/slide-bar/SlideBar.tsx
deleted file mode 100644
index ce9421f8a9..0000000000
--- a/packages/slides-ui/src/views/slide-bar/SlideBar.tsx
+++ /dev/null
@@ -1,130 +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/slides';
-import type { LocaleKey } from '../../locale/types';
-import { ICommandService, IUniverInstanceService, LocaleService, UniverInstanceType } from '@univerjs/core';
-import { borderClassName, clsx, scrollbarClassName } from '@univerjs/design';
-import { IRenderManagerService } from '@univerjs/engine-render';
-import { useDependency, useObservable } from '@univerjs/ui';
-import { createRef, useCallback, useEffect, useMemo, useRef } from 'react';
-import { scan } from 'rxjs';
-import { ActivateSlidePageOperation } from '../../commands/operations/activate.operation';
-import { AppendSlideOperation } from '../../commands/operations/append-slide.operation';
-import { SetSlidePageThumbOperation } from '../../commands/operations/set-thumb.operation';
-
-/**
- * This components works as the root component of the left Sidebar of Slide.
- */
-
-export function SlideSideBar() {
- const univerInstanceService = useDependency(IUniverInstanceService);
- const commandService = useDependency(ICommandService);
- const renderManagerService = useDependency(IRenderManagerService);
- const localeService = useDependency(LocaleService);
-
- const slideBarRef = useRef<HTMLDivElement>(null);
- const currentSlide = useObservable(
- () => univerInstanceService.getCurrentTypeOfUnit$<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE),
- undefined,
- false,
- [univerInstanceService]
- );
- const pages = currentSlide?.getPages();
- const pageOrder = currentSlide?.getPageOrder();
- const slideList = useMemo(() => pages && pageOrder ? pageOrder.map((id) => pages[id]) : [], [pageOrder, pages]);
-
- const initialActivePageId = currentSlide?.getActivePage()?.id ?? null;
- const activatePageId = useObservable(
- currentSlide
- ? () => currentSlide.activePage$.pipe(
- scan((previousId, page) => page?.id ?? previousId, initialActivePageId)
- )
- : null,
- initialActivePageId,
- false,
- [currentSlide, initialActivePageId]
- );
-
- const divRefs = useMemo(() => slideList.map(() => createRef<HTMLDivElement>()), [slideList]);
-
- useEffect(() => {
- divRefs.forEach((ref, index) => {
- if (ref.current) {
- const slide = slideList[index];
- renderManagerService.getRenderUnitById(slide.id)?.engine.mount(ref.current);
- }
- });
-
- if (divRefs.length > 0) {
- commandService.syncExecuteCommand(SetSlidePageThumbOperation.id, { unitId: currentSlide?.getUnitId() });
- }
- }, [divRefs, slideList, renderManagerService, commandService, currentSlide]); // Depends on changes in divRefs array
-
- 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]);
-
- if (!pages || !pageOrder) {
- return null;
- }
-
- return (
- <aside
- ref={slideBarRef}
- className={clsx(`
- univer-flex univer-h-full univer-w-64 univer-flex-col univer-overflow-y-auto univer-overflow-x-hidden
- `, scrollbarClassName)}
- >
- <div className="univer-px-4">
- <header className="univer-flex univer-justify-center univer-pt-4">
- <a
- className={clsx(`
- univer-box-border univer-block univer-h-8 univer-w-full univer-cursor-pointer
- univer-rounded-md univer-bg-gray-0 univer-text-center univer-text-sm univer-transition-colors
- `, borderClassName)}
- onClick={handleAppendSlide}
- >
- {localeService.t<LocaleKey>('slides-ui.append')}
- </a>
- </header>
-
- {slideList.map((item, index) => (
- <div
- key={item.id}
- className={clsx('univer-my-4 univer-flex univer-gap-2', {
- '[&>div]:univer-border-primary-600 [&>span]:univer-text-primary-600': item.id === activatePageId,
- })}
- onClick={() => activatePage(item.id)}
- >
- <span>{index + 1}</span>
- <div
- ref={divRefs[index]}
- className={clsx(`
- univer-relative univer-box-border univer-h-32 univer-w-52 univer-bg-gray-0
- hover:univer-border-primary-600
- `, borderClassName)}
- />
- </div>
- ))}
- </div>
- </aside>
- );
-}
diff --git a/packages/slides-ui/tailwind.config.ts b/packages/slides-ui/tailwind.config.ts
deleted file mode 100644
index 75967f186f..0000000000
--- a/packages/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/slides-ui/tsconfig.json b/packages/slides-ui/tsconfig.json
deleted file mode 100644
index d4f9172636..0000000000
--- a/packages/slides-ui/tsconfig.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "extends": "@univerjs-infra/shared/tsconfigs/base",
- "compilerOptions": {
- "rootDir": "src",
- "outDir": "lib/types"
- },
- "include": ["src"]
-}
diff --git a/packages/slides-ui/tsconfig.node.json b/packages/slides-ui/tsconfig.node.json
deleted file mode 100644
index 2abfa07367..0000000000
--- a/packages/slides-ui/tsconfig.node.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "extends": "@univerjs-infra/shared/tsconfigs/node",
- "compilerOptions": {
- "rootDir": "src",
- "declaration": true,
- "emitDeclarationOnly": true,
- "noEmit": false,
- "outDir": "lib/types"
- },
- "include": [
- "src"
- ],
- "exclude": [
- "src/**/__tests__/**",
- "src/**/*.spec.ts",
- "src/**/*.test.ts"
- ]
-}
diff --git a/packages/slides-ui/vitest.config.ts b/packages/slides-ui/vitest.config.ts
deleted file mode 100644
index af97c6d7a2..0000000000
--- a/packages/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/slides/README.md b/packages/slides/README.md
index 9a87ef530e..71da454a71 100644
--- a/packages/slides/README.md
+++ b/packages/slides/README.md
@@ -1,37 +1,3 @@
# @univerjs/slides
-[![npm version](https://img.shields.io/npm/v/@univerjs/slides?style=flat-square)](https://npmjs.com/package/@univerjs/slides)
-[![license](https://img.shields.io/npm/l/@univerjs/slides?style=flat-square)](https://npmjs.com/package/@univerjs/slides)
-[![downloads](https://img.shields.io/npm/dm/@univerjs/slides?style=flat-square)](https://npmjs.com/package/@univerjs/slides)
-
-`@univerjs/slides` provides the core presentation data model and services for Univer Slides.
-
-## Package Overview
-
-| Package | UMD global | CSS | Locales | Facade entry |
-| --- | --- | :---: | :---: | :---: |
-| `@univerjs/slides` | `UniverSlides` | No | No | No |
-
-## Installation
-
-```sh
-pnpm add @univerjs/slides
-# or
-npm install @univerjs/slides
-```
-
-Keep all `@univerjs/*` packages on the same version.
-
-## Usage
-
-```ts
-import { UniverSlidesPlugin } from '@univerjs/slides';
-
-univer.registerPlugin(UniverSlidesPlugin);
-```
-
-## Resources
-
-- [Documentation](https://docs.univer.ai)
-- [NPM package](https://npmjs.com/package/@univerjs/slides)
-- [GitHub repository](https://github.com/dream-num/univer)
+This package has moved to [`@univerjs-pro/slides`](https://www.npmjs.com/package/@univerjs-pro/slides).
diff --git a/packages/slides/package.json b/packages/slides/package.json
deleted file mode 100644
index a8d44ce7b0..0000000000
--- a/packages/slides/package.json
+++ /dev/null
@@ -1,79 +0,0 @@
-{
- "name": "@univerjs/slides",
- "version": "1.3.1",
- "private": false,
- "description": "Core presentation model and services for Univer Slides.",
- "author": "DreamNum Co., Ltd. <[email protected]>",
- "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": [
- "univer",
- "slides",
- "presentation",
- "deck",
- "plugin"
- ],
- "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": "tsrs --noEmit",
- "build:bundle": "univer-cli build",
- "build:types": "tsrs -p tsconfig.node.json",
- "build": "pnpm run build:bundle && pnpm run build:types"
- },
- "peerDependencies": {
- "rxjs": ">=7.0.0"
- },
- "dependencies": {
- "@univerjs/core": "workspace:*",
- "@univerjs/engine-render": "workspace:*"
- },
- "devDependencies": {
- "@univerjs-infra/shared": "workspace:*",
- "rxjs": "7.8.2",
- "tsrs": "0.20.1-ts7.1.0-beta",
- "vitest": "^5.0.5"
- }
-}
diff --git a/packages/slides/src/basics/const/default-slide.ts b/packages/slides/src/basics/const/default-slide.ts
deleted file mode 100644
index 51075d5e55..0000000000
--- a/packages/slides/src/basics/const/default-slide.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.
- */
-
-export const DEFAULT_SLIDE = {
- id: 'default_slide',
- title: 'defaultSlide',
- pageSize: {
- width: 300,
- height: 300,
- },
-};
diff --git a/packages/slides/src/basics/const/plugin-name.ts b/packages/slides/src/basics/const/plugin-name.ts
deleted file mode 100644
index acca57a4ba..0000000000
--- a/packages/slides/src/basics/const/plugin-name.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 SLIDES_PLUGIN_NAME = 'slides';
diff --git a/packages/slides/src/basics/demo-data.ts b/packages/slides/src/basics/demo-data.ts
deleted file mode 100644
index d527b6d693..0000000000
--- a/packages/slides/src/basics/demo-data.ts
+++ /dev/null
@@ -1,219 +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 } from '@univerjs/core';
-import {
- BaselineOffset,
- BooleanNumber,
- ColumnSeparatorType,
- DocumentFlavor,
- DrawingTypeEnum,
- ObjectRelativeFromH,
- ObjectRelativeFromV,
- PositionedObjectLayoutType,
- PresetListType,
- SectionType,
- WrapTextType,
-} from '@univerjs/core';
-
-export const docsDemoData: IDocumentData = {
- id: 'd',
- drawings: {
- shapeTest1: {
- unitId: 'd',
- subUnitId: 'd',
- drawingType: DrawingTypeEnum.DRAWING_SHAPE,
- drawingId: 'shapeTest1',
- title: 'test shape',
- description: 'test shape',
- docTransform: {
- size: {
- width: 100,
- height: 400,
- },
- positionH: {
- relativeFrom: ObjectRelativeFromH.COLUMN,
- posOffset: 100,
- },
- positionV: {
- relativeFrom: ObjectRelativeFromV.PARAGRAPH,
- posOffset: 160,
- },
- angle: 0,
- // imageProperties: {
- // contentUrl: 'https://cnbabylon.com/assets/img/agents.png',
- // },
- },
- layoutType: PositionedObjectLayoutType.WRAP_SQUARE,
- behindDoc: BooleanNumber.FALSE,
- wrapText: WrapTextType.BOTH_SIDES,
- },
- },
- body: {
- dataStream: '在“第1题”工作表中完成以下操作\b上标日期列单元格数据验证,限制只能输入日期(介于1949年1月1日至2099年1月1日)\r细化埋点上报链路和指标方案梳理目前通过每日定时任务发送报告\r自2018年首届进博会举办以来,进博会已经成为全球新品的首发地、前沿技术的首选地、创新服务的首推地。中国这十年”对外开放成就展湖北展区主要以图文、图表、数据、视频、企业展品、实物模型、光电科技等体现湖北十年开放成就、重大开放平台及产业。湖北省共计17家企业、机构的展品将在这一展区展示\r国家主席习近平以视频方式出席在上海举行的第五届中国国际进口博览会开幕式并发表题为《共创开放繁荣的美好未来》的致辞中国将推动各国各方共享深化国际合作机遇,全面深入参与世界贸易组织改革谈判\r中国男排两名现役国手彭世坤和张秉龙分别效力的三得利太阳鸟和东京大熊本轮遭遇。双方经过激战,主场作战的卫冕冠军三得利技高一筹3-2逆转击败对手,力夺第3场胜利\r\n',
- textRuns: [
- {
- st: 0,
- ed: 15,
- ts: {
- fs: 12,
- bg: {
- rgb: 'rgb(200,0,90)',
- },
- cl: {
- rgb: 'rgb(255,130,0)',
- },
- },
- },
- {
- st: 17,
- ed: 18,
- ts: {
- fs: 14,
- bg: {
- rgb: 'rgb(2,128,2)',
- },
- cl: {
- rgb: 'rgb(0,1,55)',
- },
- va: BaselineOffset.SUPERSCRIPT,
- },
- },
- {
- st: 19,
- ed: 60,
- ts: {
- fs: 14,
- bg: {
- rgb: 'rgb(90,128,255)',
- },
- cl: {
- rgb: 'rgb(0,1,255)',
- },
- },
- },
-
- {
- st: 62,
- ed: 90,
- },
-
- {
- st: 92,
- ed: 233,
- },
-
- {
- st: 235,
- ed: 326,
- },
-
- {
- st: 328,
- ed: 405,
- },
- ],
- paragraphs: [
- {
- paragraphId: 'para_slides_demo_order_1',
- startIndex: 60,
- bullet: {
- listId: 'orderList',
- listType: PresetListType.ORDER_LIST,
- nestingLevel: 0,
- textStyle: {
- fs: 20,
- },
- },
- },
- {
- paragraphId: 'para_slides_demo_order_2',
- startIndex: 91,
- bullet: {
- listId: 'orderList',
- listType: PresetListType.ORDER_LIST,
- nestingLevel: 1,
- textStyle: {
- fs: 20,
- },
- },
- },
- {
- paragraphId: 'para_slides_demo_order_3',
- startIndex: 234,
- bullet: {
- listId: 'orderList',
- listType: PresetListType.ORDER_LIST,
- nestingLevel: 1,
- textStyle: {
- fs: 20,
- },
- },
- },
- {
- paragraphId: 'para_slides_demo_order_4',
- startIndex: 327,
- bullet: {
- listId: 'orderList',
- listType: PresetListType.ORDER_LIST,
- nestingLevel: 1,
- textStyle: {
- fs: 20,
- },
- },
- },
- {
- paragraphId: 'para_slides_demo_order_5',
- startIndex: 406,
- bullet: {
- listId: 'orderList',
- listType: PresetListType.ORDER_LIST,
- nestingLevel: 2,
- textStyle: {
- fs: 20,
- },
- },
- },
- ],
- sectionBreaks: [
- {
- sectionId: 'section_slides_demo',
- startIndex: 407,
- columnProperties: [
- {
- width: 200,
- paddingEnd: 20,
- },
- ],
- columnSeparatorType: ColumnSeparatorType.NONE,
- sectionType: SectionType.SECTION_TYPE_UNSPECIFIED,
- // textDirection: textDirectionDocument,
- // contentDirection: textDirection!,
- },
- ],
- },
- documentStyle: {
- pageSize: {
- width: 594.3,
- height: 840.51,
- },
- documentFlavor: DocumentFlavor.UNSPECIFIED,
- marginTop: 72,
- marginBottom: 72,
- marginRight: 90,
- marginLeft: 90,
- },
-};
diff --git a/packages/slides/src/config/config.ts b/packages/slides/src/config/config.ts
deleted file mode 100644
index 9eeea6009c..0000000000
--- a/packages/slides/src/config/config.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.
- */
-
-export const SLIDES_PLUGIN_CONFIG_KEY = 'slides.config';
-
-export const configSymbol = Symbol(SLIDES_PLUGIN_CONFIG_KEY);
-
-export interface IUniverSlidesConfig {
-}
-
-export const defaultPluginConfig: IUniverSlidesConfig = {};
diff --git a/packages/slides/src/data-model/__tests__/slide-data-model.spec.ts b/packages/slides/src/data-model/__tests__/slide-data-model.spec.ts
deleted file mode 100644
index 5d179fc46e..0000000000
--- a/packages/slides/src/data-model/__tests__/slide-data-model.spec.ts
+++ /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 { Nullable } from '@univerjs/core';
-import type { ISlideData, ISlidePage } from '../../types/interfaces/i-slide-data';
-import { afterEach, describe, expect, it } from 'vitest';
-import { PageElementType, PageType } from '../../types/interfaces/i-slide-data';
-import { SlideDataModel } from '../slide-data-model';
-
-const slideSnapshotFactory = (): Partial<ISlideData> => ({
- id: 'slide-unit',
- title: 'Quarterly review',
- pageSize: { width: 960, height: 540 },
- body: {
- pageOrder: ['page-1', 'page-2'],
- pages: {
- 'page-1': {
- id: 'page-1',
- pageType: PageType.SLIDE,
- zIndex: 1,
- title: 'Overview',
- description: 'Overview slide',
- pageBackgroundFill: { rgb: '#ffffff' },
- pageElements: {
- 'element-1': {
- id: 'element-1',
- zIndex: 1,
- title: 'Intro',
- description: 'Hero copy',
- type: PageElementType.TEXT,
- richText: { text: 'Hello Univer' },
- },
- },
- },
- 'page-2': {
- id: 'page-2',
- pageType: PageType.SLIDE,
- zIndex: 2,
- title: 'Roadmap',
- description: 'Roadmap slide',
- pageBackgroundFill: { rgb: '#f5f5f5' },
- pageElements: {},
- },
- },
- },
-});
-
-describe('SlideDataModel', () => {
- let slide: SlideDataModel;
-
- afterEach(() => {
- slide?.dispose();
- });
-
- it('should manage pages and active-page state', () => {
- slide = new SlideDataModel(slideSnapshotFactory());
- const activePages: string[] = [];
- const names: string[] = [];
- const activePageSubscription = slide.activePage$.subscribe((page: Nullable<ISlidePage>) => {
- if (page) {
- activePages.push(page.id);
- }
- });
- const nameSubscription = slide.name$.subscribe((name: string) => names.push(name));
-
- expect(slide.getUnitId()).toBe('slide-unit');
- expect(slide.getSnapshot().title).toBe('Quarterly review');
- expect(slide.getPages()).toHaveProperty('page-1');
- expect(slide.getPageOrder()).toEqual(['page-1', 'page-2']);
- expect(slide.getPage('page-1')?.title).toBe('Overview');
- expect(slide.getElementsByPage('page-1')).toHaveProperty('element-1');
- expect(slide.getElement('page-1', 'element-1')).toMatchObject({
- id: 'element-1',
- type: PageElementType.TEXT,
- });
- expect(slide.getPageSize()).toEqual({ width: 960, height: 540 });
- expect(slide.getActivePage()?.id).toBe('page-1');
- expect(slide.getRev()).toBe(0);
-
- slide.incrementRev();
- slide.setRev(5);
- expect(slide.getRev()).toBe(0);
-
- slide.setActivePage(slide.getPage('page-2')!);
- expect(slide.getActivePage()?.id).toBe('page-2');
- expect(activePages).toEqual(['page-2']);
-
- const blankPage = slide.getBlankPage();
- expect(blankPage).toMatchObject({
- pageType: PageType.SLIDE,
- zIndex: 10,
- pageBackgroundFill: { rgb: 'rgb(255,255,255)' },
- });
-
- slide.appendPage(blankPage);
- expect(slide.getPageOrder()).toEqual(['page-1', 'page-2', blankPage.id]);
- expect(slide.getPage(blankPage.id)).toEqual(blankPage);
-
- const updatedPage: ISlidePage = {
- ...blankPage,
- title: 'Agenda',
- description: 'Agenda slide',
- };
- slide.updatePage(blankPage.id, updatedPage);
- expect(slide.getPage(blankPage.id)).toEqual(updatedPage);
-
- slide.setName('Quarterly review - updated');
- expect(slide.getSnapshot().title).toBe('Quarterly review - updated');
- expect(slide.getUnitId()).toBe('slide-unit');
- expect(names.at(-1)).toBe('Quarterly review - updated');
-
- activePageSubscription.unsubscribe();
- nameSubscription.unsubscribe();
- });
-
- it('should keep empty slide snapshots stable when page collections are absent', () => {
- slide = new SlideDataModel({
- id: 'empty-slide',
- title: 'Empty deck',
- });
-
- const blankPage = slide.getBlankPage();
-
- expect(slide.getActivePage()).toBeNull();
- expect(slide.getPages()).toBeUndefined();
- expect(slide.getPageOrder()).toBeUndefined();
- expect(slide.getPage(blankPage.id)).toBeUndefined();
-
- slide.appendPage(blankPage);
- slide.updatePage(blankPage.id, blankPage);
-
- expect(slide.getPages()).toBeUndefined();
- expect(slide.getSnapshot()).toMatchObject({
- id: 'empty-slide',
- title: 'Empty deck',
- });
- });
-});
diff --git a/packages/slides/src/data-model/slide-data-model.ts b/packages/slides/src/data-model/slide-data-model.ts
deleted file mode 100644
index 3746bc6f93..0000000000
--- a/packages/slides/src/data-model/slide-data-model.ts
+++ /dev/null
@@ -1,154 +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 { Observable } from 'rxjs';
-import type { ISlideData, ISlidePage } from '../types/interfaces/i-slide-data';
-import { generateRandomId, UnitModel, UniverInstanceType } from '@univerjs/core';
-import { BehaviorSubject } from 'rxjs';
-import { DEFAULT_SLIDE } from '../basics/const/default-slide';
-import { PageType } from '../types/interfaces/i-slide-data';
-
-export class SlideDataModel extends UnitModel<ISlideData, UniverInstanceType.UNIVER_SLIDE> {
- override type: UniverInstanceType.UNIVER_SLIDE = UniverInstanceType.UNIVER_SLIDE;
- private readonly _activePage$ = new BehaviorSubject<Nullable<ISlidePage>>(null);
- private get _activePage(): Nullable<ISlidePage> {
- const activePage = this._activePage$.getValue();
-
- if (!activePage) {
- const activePageId = this.getPageOrder()?.[0];
- if (!activePageId) {
- return null;
- }
-
- return this.getPages()?.[activePageId];
- }
-
- return activePage;
- }
-
- readonly activePage$ = this._activePage$.asObservable();
-
- private readonly _name$: BehaviorSubject<string>;
- override name$: Observable<string>;
-
- private _snapshot: ISlideData;
-
- private _unitId: string;
-
- constructor(snapshot: Partial<ISlideData>) {
- super();
-
- this._snapshot = { ...DEFAULT_SLIDE, ...snapshot };
- this._unitId = this._snapshot.id ?? generateRandomId(6);
-
- this._name$ = new BehaviorSubject(this._snapshot.title);
- this.name$ = this._name$.asObservable();
- }
-
- override setName(name: string): void {
- this._snapshot.title = name;
- this._name$.next(name);
- this._unitId = this._snapshot.id ?? generateRandomId(6);
- }
-
- override getRev(): number {
- return 0; // TODO@jikkai: slide has not implement collaborative editing yet
- }
-
- override incrementRev(): void {
- // do nothing
- }
-
- override setRev(_rev: number): void {
- // do nothing
- }
-
- getSnapshot() {
- return this._snapshot;
- }
-
- getUnitId(): string {
- return this._unitId;
- }
-
- getPages() {
- return this._snapshot.body?.pages;
- }
-
- getPageOrder() {
- return this._snapshot.body?.pageOrder;
- }
-
- getPage(pageId: string) {
- const pages = this.getPages();
- return pages?.[pageId];
- }
-
- getElementsByPage(pageId: string) {
- return this.getPage(pageId)?.pageElements;
- }
-
- getElement(pageId: string, elementId: string) {
- return this.getElementsByPage(pageId)?.[elementId];
- }
-
- getPageSize() {
- return this._snapshot.pageSize;
- }
-
- getBlankPage() {
- const id = generateRandomId(6);
-
- const page = {
- id,
- pageType: PageType.SLIDE,
- zIndex: 10,
- title: id,
- description: '',
- pageBackgroundFill: {
- rgb: 'rgb(255,255,255)',
- },
- pageElements: {},
- };
-
- return page;
- }
-
- setActivePage(page: Nullable<ISlidePage>) {
- this._activePage$.next(page);
- }
-
- getActivePage() {
- return this._activePage;
- }
-
- updatePage(pageId: string, page: ISlidePage) {
- if (!this._snapshot.body) return;
-
- this._snapshot.body.pages[pageId] = page;
- }
-
- appendPage(page: ISlidePage) {
- if (!this._snapshot.body) return;
-
- this._snapshot.body.pages[page.id] = page;
-
- const activePage = this._activePage;
- const index = this._snapshot.body.pageOrder.indexOf(activePage?.id ?? '');
- this._snapshot.body.pageOrder.splice(index + 1, 0, page.id);
- }
-}
diff --git a/packages/slides/src/index.ts b/packages/slides/src/index.ts
deleted file mode 100644
index 5b22775e0b..0000000000
--- a/packages/slides/src/index.ts
+++ /dev/null
@@ -1,23 +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 { DEFAULT_SLIDE } from './basics/const/default-slide';
-export type { IUniverSlidesConfig } from './config/config';
-export { SlideDataModel } from './data-model/slide-data-model';
-export { UniverSlidesPlugin } from './plugin';
-export * from './types/enum/prst-geom-type';
-export * from './types/interfaces/i-slide-data';
-export * from './views/render';
diff --git a/packages/slides/src/plugin.ts b/packages/slides/src/plugin.ts
deleted file mode 100644
index aac4a9e110..0000000000
--- a/packages/slides/src/plugin.ts
+++ /dev/null
@@ -1,79 +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, IConfigService, Inject, Injector, IUniverInstanceService, merge, Plugin, UniverInstanceType } from '@univerjs/core';
-import { UniverRenderEnginePlugin } from '@univerjs/engine-render';
-import pkg from '../package.json';
-import { defaultPluginConfig, SLIDES_PLUGIN_CONFIG_KEY } from './config/config';
-import { SlideDataModel } from './data-model/slide-data-model';
-// import { DocSelectionManagerService } from '@univerjs/docs';
-// import { CanvasView } from './views/render';
-
-export interface IUniverSlidesConfig {}
-
-@DependentOn(UniverRenderEnginePlugin)
-export class UniverSlidesPlugin extends Plugin {
- static override pluginName = 'UNIVER_SLIDES_PLUGIN';
- static override packageName = pkg.name;
- static override version = pkg.version;
- static override type = UniverInstanceType.UNIVER_SLIDE;
-
- // private _canvasView: CanvasView | null = null;
-
- constructor(
- private readonly _config: Partial<IUniverSlidesConfig> = defaultPluginConfig,
- @Inject(Injector) override readonly _injector: Injector,
- @IConfigService private readonly _configService: IConfigService,
- @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService
- ) {
- super();
-
- // Manage the plugin configuration.
- const { ...rest } = merge(
- {},
- defaultPluginConfig,
- this._config
- );
- this._configService.setConfig(SLIDES_PLUGIN_CONFIG_KEY, rest);
-
- this._initializeDependencies(this._injector);
- }
-
- override onStarting(): void {
- // Register the SlideDataModel constructor for the UNIVER_SLIDE type.
- this._univerInstanceService.registerCtorForType(UniverInstanceType.UNIVER_SLIDE, SlideDataModel);
- }
-
- override onReady(): void {
-
- }
-
- getConfig() {
- return this._config;
- }
-
- private _initializeDependencies(slideInjector: Injector) {
- const dependencies: Dependency[] = [
- // [CanvasView],
- // [DocSelectionManagerService],
- ];
-
- dependencies.forEach((d) => {
- slideInjector.add(d);
- });
- }
-}
diff --git a/packages/slides/src/types/enum/prst-geom-type.ts b/packages/slides/src/types/enum/prst-geom-type.ts
deleted file mode 100644
index 9fd3790c64..0000000000
--- a/packages/slides/src/types/enum/prst-geom-type.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.
- */
-
-// TODO@Jocs: should be moved out of core.
-
-export enum BasicShapes {
- Line = 'line',
- LineInv = 'lineInv',
- Triangle = 'triangle',
- RtTriangle = 'rtTriangle',
- Rect = 'rect',
- Diamond = 'diamond',
- Parallelogram = 'parallelogram',
- Trapezoid = 'trapezoid',
- NonIsocelesTrapezoid = 'nonIsocelesTrapezoid',
- Pentagon = 'pentagon',
- Hexagon = 'hexagon',
- Heptagon = 'heptagon',
- Octagon = 'octagon',
- Decagon = 'decagon',
- Dodecagon = 'dodecagon',
- Star4 = 'star4',
- Star5 = 'star5',
- Star6 = 'star6',
- Star7 = 'star7',
- Star8 = 'star8',
- Star10 = 'star10',
- Star12 = 'star12',
- Star16 = 'star16',
- Star24 = 'star24',
- Star32 = 'star32',
- RoundRect = 'roundRect',
- Round1Rect = 'round1Rect',
- Round2SameRect = 'round2SameRect',
- Round2DiagRect = 'round2DiagRect',
- Ellipse = 'ellipse',
-}
-
-export enum ArrowsAndMarkersShapes {
- RightArrow = 'rightArrow',
- LeftArrow = 'leftArrow',
- UpArrow = 'upArrow',
- DownArrow = 'downArrow',
- LeftRightArrow = 'leftRightArrow',
- UpDownArrow = 'upDownArrow',
- QuadArrow = 'quadArrow',
- LeftRightUpArrow = 'leftRightUpArrow',
- BentArrow = 'bentArrow',
- UturnArrow = 'uturnArrow',
- CircularArrow = 'circularArrow',
- NotchedRightArrow = 'notchedRightArrow',
- HomePlate = 'homePlate',
- Chevron = 'chevron',
- LeftCircularArrow = 'leftCircularArrow',
- LeftRightCircularArrow = 'leftRightCircularArrow',
-}
-
-export enum OtherShapes {
- Plaque = 'plaque',
- Can = 'can',
- Cube = 'cube',
- Bevel = 'bevel',
- Donut = 'donut',
- NoSmoking = 'noSmoking',
- BlockArc = 'blockArc',
- FoldedCorner = 'foldedCorner',
-}
-
-export enum SpecialShapes {
- SmileyFace = 'smileyFace',
- Heart = 'heart',
- LightningBolt = 'lightningBolt',
- Sun = 'sun',
- Moon = 'moon',
- Cloud = 'cloud',
- Arc = 'arc',
- Backpack = 'backpack',
- Frame = 'frame',
- HalfFrame = 'halfFrame',
- Corner = 'corner',
- Chord = 'chord',
- Pie = 'pie',
- Teardrop = 'teardrop',
- WedgeRectCallout = 'wedgeRectCallout',
- WedgeRRectCallout = 'wedgeRRectCallout',
- WedgeEllipseCallout = 'wedgeEllipseCallout',
- CloudCallout = 'cloudCallout',
- BorderCallout1 = 'borderCallout1',
- BorderCallout2 = 'borderCallout2',
- BorderCallout3 = 'borderCallout3',
- AccentCallout1 = 'accentCallout1',
- AccentCallout2 = 'accentCallout2',
- AccentCallout3 = 'accentCallout3',
- Callout1 = 'callout1',
- Callout2 = 'callout2',
- Callout3 = 'callout3',
- ActionButtonBackPrevious = 'actionButtonBackPrevious',
- ActionButtonEnd = 'actionButtonEnd',
- ActionButtonForwardNext = 'actionButtonForwardNext',
- ActionButtonHelp = 'actionButtonHelp',
- ActionButtonHome = 'actionButtonHome',
- ActionButtonInformation = 'actionButtonInformation',
- ActionButtonMovie = 'actionButtonMovie',
- ActionButtonReturn = 'actionButtonReturn',
- ActionButtonSound = 'actionButtonSound',
-}
-
-/**
- * 20.1.9.18 prstGeom (Preset geometry)
- */
-export type ShapeType = BasicShapes | ArrowsAndMarkersShapes | OtherShapes | SpecialShapes;
-export type PresetGeometryType = ShapeType | 'custom';
diff --git a/packages/slides/src/types/interfaces/i-slide-data.ts b/packages/slides/src/types/interfaces/i-slide-data.ts
deleted file mode 100644
index 9c8e753e19..0000000000
--- a/packages/slides/src/types/interfaces/i-slide-data.ts
+++ /dev/null
@@ -1,187 +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 {
- IColorStyle,
- ICustomBlock,
- IDocumentData,
- IImageProperties,
- ILists,
- IPlaceholder,
- IShapeProperties,
- ISize,
- IStyleBase,
- IStyleData,
- ITransformState,
- IWorksheetData,
- LocaleType,
- Nullable,
- ThemeColorType,
-} from '@univerjs/core';
-import type { ShapeType } from '../enum/prst-geom-type';
-
-export interface ISlideData extends IReferenceSource {
- id: string; // unit id
- locale?: LocaleType;
- title: string;
- pageSize: ISize;
- body?: ISlidePageBody;
-}
-
-interface IReferenceSource {
- master?: { [id: string]: ISlidePage };
- handoutMaster?: { [id: string]: ISlidePage };
- notesMaster?: { [id: string]: ISlidePage };
- layouts?: { [id: string]: ISlidePage };
- lists?: ILists;
-}
-
-interface ISlidePageBody {
- pages: { [id: string]: ISlidePage };
- pageOrder: string[];
-}
-
-export interface ISlidePage {
- id: string;
- pageType: PageType;
- zIndex: number;
- title: string;
- description: string;
- pageBackgroundFill: IColorStyle;
- colorScheme?: ThemeColorType;
- pageElements: { [elementId: string]: IPageElement };
- // Union field properties. Properties that are specific for each page type. Masters do not require any additional properties. properties can be only one of the following:
- slideProperties?: ISlideProperties;
- layoutProperties?: ILayoutProperties;
- notesProperties?: INotesProperties;
- handoutProperties?: IHandoutProperties;
- masterProperties?: IMasterProperties;
-}
-
-interface ISlideProperties {
- layoutObjectId: string;
- masterObjectId: string;
- isSkipped: boolean;
-}
-
-interface ILayoutProperties {
- masterObjectId: string;
- name: string;
-}
-
-interface INotesProperties {
- name: string;
-}
-
-interface IHandoutProperties {
- name: string;
-}
-
-interface IMasterProperties {
- name: string;
-}
-
-export interface ISlideRichTextProps extends ITransformState, IStyleBase {
- text?: string;
- rich?: IDocumentData;
-}
-
-export interface IPageElement {
- id: string;
- zIndex: number;
- left?: number;
- top?: number;
- width?: number;
- height?: number;
- angle?: number;
- scaleX?: number;
- scaleY?: number;
- skewX?: number;
- skewY?: number;
- flipX?: boolean;
- flipY?: boolean;
-
- title: string;
- description: string;
-
- type: PageElementType;
-
- // Union field element_kind can be only one of the following:
- // elementGroup: IGroup;
- shape?: IShape;
- image?: IImage;
- richText?: ISlideRichTextProps;
-
- spreadsheet?: {
- worksheet: IWorksheetData;
- styles: Record<string, Nullable<IStyleData>>;
- };
- document?: IDocumentData;
- slide?: ISlideData;
- // video: IVideo;
- // line: ILine;
- // table: ITable;
- // chart: IChartProperties;
- customBlock?: ICustomBlock; // customBlock block customized by user through plugin
-}
-
-export enum PageType {
- SLIDE, // A slide page.
- MASTER, // A master slide page.
- LAYOUT, // A layout page.
- HANDOUT_MASTER, // A handout master page.
- NOTES_MASTER, // A notes master page.
-}
-
-export enum PageElementType {
- SHAPE,
- IMAGE,
- TEXT,
- SPREADSHEET,
- DOCUMENT,
- SLIDE,
-}
-
-/**
- * IShape
- */
-export interface IShape {
- shapeType: ShapeType;
- text: string;
- shapeProperties: IShapeProperties;
- placeholder?: IPlaceholder;
- link?: ILink;
-}
-
-export interface IImage {
- imageProperties?: IImageProperties;
- placeholder?: IPlaceholder;
- link?: ILink;
-}
-
-interface ILink {
- relativeLink: RelativeSlideLink;
- pageId?: string;
- slideIndex?: number;
-}
-
-export enum RelativeSlideLink {
- RELATIVE_SLIDE_LINK_UNSPECIFIED, // An unspecified relative slide link.
- NEXT_SLIDE, // A link to the next slide.
- PREVIOUS_SLIDE, // A link to the previous slide.
- FIRST_SLIDE, // A link to the first slide in the presentation.
- LAST_SLIDE, // A link to the last slide in the presentation.
-}
diff --git a/packages/slides/src/views/render/adaptor.ts b/packages/slides/src/views/render/adaptor.ts
deleted file mode 100644
index 001040ae5f..0000000000
--- a/packages/slides/src/views/render/adaptor.ts
+++ /dev/null
@@ -1,42 +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 { Injector, Nullable } from '@univerjs/core';
-import type { BaseObject, Scene } from '@univerjs/engine-render';
-import type { IPageElement, PageElementType } from '../../types/interfaces/i-slide-data';
-import { Registry } from '@univerjs/core';
-
-export abstract class ObjectAdaptor {
- zIndex = 0;
-
- viewKey: PageElementType | null = null;
-
- check(type: PageElementType) {
- if (type !== this.viewKey) {
- return;
- }
- return this;
- }
-
- abstract convert(pageElement: IPageElement, mainScene: Scene): Nullable<BaseObject>;
-
- create(injector: Injector): void {
- // FIXME: should not be empty
- // empty
- }
-}
-
-export const CanvasObjectProviderRegistry = Registry.create();
diff --git a/packages/slides/src/views/render/adaptors/__tests__/slide-adaptor.spec.ts b/packages/slides/src/views/render/adaptors/__tests__/slide-adaptor.spec.ts
deleted file mode 100644
index 7385078f08..0000000000
--- a/packages/slides/src/views/render/adaptors/__tests__/slide-adaptor.spec.ts
+++ /dev/null
@@ -1,156 +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 { Rect } from '@univerjs/engine-render';
-import type { IPageElement, ISlideData } from '../../../../types/interfaces/i-slide-data';
-import { ConfigService, ContextService, IConfigService, IContextService, Injector, LocaleService } from '@univerjs/core';
-import { Scene, SceneViewer } from '@univerjs/engine-render';
-import { describe, expect, it } from 'vitest';
-import { BasicShapes } from '../../../../types/enum/prst-geom-type';
-import { PageElementType, PageType } from '../../../../types/interfaces/i-slide-data';
-import { SlideAdaptor } from '../slide-adaptor';
-
-function createRenderTestBed() {
- const injector = new Injector();
-
- injector.add([LocaleService, { useClass: LocaleService }]);
- injector.add([IContextService, { useClass: ContextService }]);
- injector.add([IConfigService, { useClass: ConfigService }]);
-
- return {
- injector,
- slideAdaptor: injector.createInstance(SlideAdaptor),
- };
-}
-
-function createMainScene() {
- return new Scene(
- 'main-scene',
- new SceneViewer('main-viewer', {
- width: 960,
- height: 540,
- })
- );
-}
-
-function createDeckElement(): IPageElement {
- return {
- id: 'embedded-deck',
- zIndex: 9,
- left: 16,
- top: 24,
- width: 720,
- height: 405,
- title: 'Embedded sales deck',
- description: 'Deck inside a page element',
- type: PageElementType.SLIDE,
- slide: createEmbeddedSlideData(),
- };
-}
-
-function createEmbeddedSlideData(): ISlideData {
- return {
- id: 'sales-deck',
- title: 'Sales update',
- pageSize: { width: 720, height: 405 },
- body: {
- pageOrder: ['summary', 'pipeline'],
- pages: {
- summary: {
- id: 'summary',
- pageType: PageType.SLIDE,
- zIndex: 1,
- title: 'Summary',
- description: 'Executive summary',
- pageBackgroundFill: { rgb: '#112233' },
- pageElements: {
- 'sales-box': {
- id: 'sales-box',
- zIndex: 3,
- left: 40,
- top: 32,
- width: 180,
- height: 72,
- title: 'Revenue card',
- description: 'Revenue highlight',
- type: PageElementType.SHAPE,
- shape: {
- shapeType: BasicShapes.RoundRect,
- text: '',
- shapeProperties: {
- shapeBackgroundFill: { rgb: '#44aa88' },
- radius: 12,
- outline: {
- outlineFill: { rgb: '#0b3128' },
- weight: 2,
- },
- },
- },
- },
- },
- },
- pipeline: {
- id: 'pipeline',
- pageType: PageType.SLIDE,
- zIndex: 2,
- title: 'Pipeline',
- description: 'Next page',
- pageBackgroundFill: { rgb: '#ffeecc' },
- pageElements: {},
- },
- },
- },
- };
-}
-
-describe('SlideAdaptor', () => {
- it('converts slide pages in source order with page backgrounds and child shape styling', () => {
- const { slideAdaptor } = createRenderTestBed();
- const deck = slideAdaptor.convert(createDeckElement(), createMainScene())!;
-
- expect(deck.left).toBe(16);
- expect(deck.top).toBe(24);
- expect(deck.width).toBe(720);
- expect(deck.height).toBe(405);
- expect(deck.zIndex).toBe(9);
- expect([...deck.getSubScenes().keys()]).toEqual(['summary', 'pipeline']);
- expect(deck.getActiveSubScene()?.sceneKey).toBe('summary');
-
- const summaryScene = deck.getSubScene('summary')!;
- const summaryBackground = summaryScene.getObject('canvas') as Rect;
- expect(summaryBackground.fill).toBe('#112233');
- expect(summaryBackground.width).toBe(720);
- expect(summaryBackground.height).toBe(405);
- expect(summaryBackground.evented).toBe(false);
-
- const salesBox = summaryScene.getObject('sales-box') as Rect;
- expect(salesBox.left).toBe(40);
- expect(salesBox.top).toBe(32);
- expect(salesBox.width).toBe(180);
- expect(salesBox.height).toBe(72);
- expect(salesBox.zIndex).toBe(3);
- expect(salesBox.fill).toBe('#44aa88');
- expect(salesBox.stroke).toBe('#0b3128');
- expect(salesBox.strokeWidth).toBe(2);
- expect(salesBox.getPropByKey('radius')).toBe(12);
-
- const pipelineScene = deck.getSubScene('pipeline')!;
- expect((pipelineScene.getObject('canvas') as Rect).fill).toBe('#ffeecc');
-
- deck.changePage('pipeline');
- expect(deck.getActiveSubScene()?.sceneKey).toBe('pipeline');
- });
-});
diff --git a/packages/slides/src/views/render/adaptors/docs-adaptor.ts b/packages/slides/src/views/render/adaptors/docs-adaptor.ts
deleted file mode 100644
index 53a5cf909c..0000000000
--- a/packages/slides/src/views/render/adaptors/docs-adaptor.ts
+++ /dev/null
@@ -1,371 +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 { EventState, Injector } from '@univerjs/core';
-import type { BaseObject, IDocumentSkeletonDrawing, IPageRenderConfig, IWheelEvent } from '@univerjs/engine-render';
-import type { IPageElement } from '../../../types/interfaces/i-slide-data';
-import { DocumentDataModel, Inject, LocaleService } from '@univerjs/core';
-import {
- Documents,
- DocumentSkeleton,
- DocumentViewModel,
- Image,
- Liquid,
- PageLayoutType,
- // Rect,
- Scene,
- SceneViewer,
- ScrollBar,
- Viewport,
-} from '@univerjs/engine-render';
-import { PageElementType } from '../../../types/interfaces/i-slide-data';
-import { CanvasObjectProviderRegistry, ObjectAdaptor } from '../adaptor';
-
-export enum DOCS_VIEW_KEY {
- MAIN = '__DocsRender__',
- SCENE_VIEWER = '__DocsViewer__',
- SCENE = '__DocsScene__',
- VIEWPORT = '__DocsViewPort_',
-}
-
-export class DocsAdaptor extends ObjectAdaptor {
- override zIndex = 5;
-
- override viewKey = PageElementType.DOCUMENT;
-
- private _liquid = new Liquid();
-
- constructor(@Inject(LocaleService) private readonly _localeService: LocaleService) {
- super();
- }
-
- override check(type: PageElementType) {
- if (type !== this.viewKey) {
- return;
- }
- return this;
- }
-
- // eslint-disable-next-line max-lines-per-function
- override convert(pageElement: IPageElement, mainScene: Scene) {
- const {
- id,
- zIndex,
- left = 0,
- top = 0,
- width,
- height,
- angle,
- scaleX,
- scaleY,
- skewX,
- skewY,
- flipX,
- flipY,
- title,
- description,
- document: documentData,
- } = pageElement;
- if (documentData == null) {
- return;
- }
-
- const docDataModel = new DocumentDataModel(documentData);
- const docViewModel = new DocumentViewModel(docDataModel);
- const documentSkeleton = DocumentSkeleton.create(docViewModel, this._localeService);
-
- const documents = new Documents(DOCS_VIEW_KEY.MAIN, documentSkeleton);
-
- documentSkeleton.calculate();
-
- const sv = new SceneViewer(DOCS_VIEW_KEY.SCENE_VIEWER + id, {
- top,
- left,
- width,
- height,
- zIndex,
- angle,
- scaleX,
- scaleY,
- skewX,
- skewY,
- flipX,
- flipY,
- });
- const scene = new Scene(DOCS_VIEW_KEY.SCENE + id, sv);
-
- const viewMain = new Viewport(DOCS_VIEW_KEY.VIEWPORT + id, scene, {
- left: 0,
- top: 0,
- bottom: 0,
- right: 0,
- explicitViewportWidthSet: false,
- explicitViewportHeightSet: false,
- isWheelPreventDefaultX: true,
- });
-
- scene.attachControl();
-
- scene.onMouseWheel$.subscribeEvent((evt: unknown, state: EventState) => {
- const e = evt as IWheelEvent;
- if (e.ctrlKey) {
- const deltaFactor = Math.abs(e.deltaX);
- let scrollNum = deltaFactor < 40 ? 0.2 : deltaFactor < 80 ? 0.4 : 0.2;
- scrollNum *= e.deltaY > 0 ? -1 : 1;
- if (scene.scaleX < 1) {
- scrollNum /= 2;
- }
-
- if (scene.scaleX + scrollNum > 4) {
- scene.scale(4, 4);
- } else if (scene.scaleX + scrollNum < 0.1) {
- scene.scale(0.1, 0.1);
- } else {
- const value = e.deltaY > 0 ? 0.1 : -0.1;
- // scene.scaleBy(scrollNum, scrollNum);
- e.preventDefault();
- }
- } else {
- viewMain.onMouseWheel(e, state);
- }
- });
-
- const scrollbar = new ScrollBar(viewMain, {
- mainScene,
- });
-
- scene.addObject(documents);
-
- // documents.calculatePagePosition();
-
- // documents.enableEditor();
-
- const size = documentSkeleton.getActualSize();
-
- documents.resize(size.actualWidth, size.actualHeight);
-
- scene.transformByState({ width: size.actualWidth, height: size.actualHeight + 200 });
-
- const pageSize = documents.getSkeleton()?.getPageSize();
-
- documents.pageRender$.subscribe((config: IPageRenderConfig) => {
- const { page, pageLeft, pageTop, ctx } = config;
- const { width, height, marginBottom, marginLeft, marginRight, marginTop } = page;
- ctx.save();
- ctx.translate(pageLeft - 0.5, pageTop - 0.5);
- // Rect.drawWith(ctx, {
- // width: pageSize?.width || width,
- // height: pageSize?.height || height,
- // strokeWidth: 1,
- // stroke: 'rgba(198,198,198, 1)',
- // fill: 'rgba(255,255,255, 1)',
- // zIndex: 3,
- // });
- ctx.restore();
- });
-
- const { left: docsLeft, top: docsTop } = documents;
-
- const skeletonData = documentSkeleton.getSkeletonData();
-
- if (skeletonData == null) {
- return;
- }
-
- const { pages } = skeletonData;
- const objectList: BaseObject[] = [];
- const pageMarginCache = new Map<string, { marginLeft: number; marginTop: number }>();
-
- this._recalculateSizeBySkeleton(documents, scene, documentSkeleton);
-
- for (let i = 0, len = pages.length; i < len; i++) {
- const page = pages[i];
- const { skeDrawings, marginLeft, marginTop, pageWidth, pageHeight } = page;
-
- // cumPageLeft + = pageWidth + documents.pageMarginLeft;
-
- this._liquid.translatePagePadding(page);
-
- skeDrawings.forEach((drawing: IDocumentSkeletonDrawing) => {
- const { aLeft, aTop, height, width, drawingOrigin } = drawing;
-
- const { docTransform } = drawingOrigin;
-
- const rect = new Image(drawing.drawingId, {
- // url: docTransform.imageProperties?.contentUrl || '',
- left: aLeft + docsLeft + this._liquid.x,
- top: aTop + docsTop + this._liquid.y,
- width,
- height,
- zIndex: 11,
- });
-
- pageMarginCache.set(drawing.drawingId, {
- marginLeft: this._liquid.x,
- marginTop: this._liquid.y,
- });
-
- objectList.push(rect);
- });
-
- this._liquid.translatePage(
- page,
- documents.pageLayoutType,
- documents.pageMarginLeft,
- documents.pageMarginTop
- );
- }
-
- scene.addObjects(objectList);
- objectList.forEach((object) => {
- scene.attachTransformerTo(object);
- });
-
- scene.getTransformer()?.changing$.subscribe((state) => {
- const { objects } = state;
-
- objects.forEach((object) => {
- const { oKey, left, top, height, width } = object;
- const cache = pageMarginCache.get(oKey);
- const marginLeft = cache?.marginLeft || 0;
- const marginTop = cache?.marginTop || 0;
-
- // console.log('onChangingObservable', top, docsTop, marginTop, top - docsTop - marginTop);
-
- documentSkeleton
- ?.getViewModel()
- .getDataModel()
- .updateDrawing(oKey, {
- left: left - docsLeft - marginLeft,
- top: top - docsTop - marginTop,
- height,
- width,
- });
- });
-
- documentSkeleton?.calculate();
- });
- this._calculatePagePosition(documents, scene, viewMain);
-
- return sv;
- }
-
- private _recalculateSizeBySkeleton(docsComponent: Documents, scene: Scene, skeleton: DocumentSkeleton) {
- const pages = skeleton.getSkeletonData()?.pages;
-
- if (pages == null) {
- return;
- }
-
- let width = 0;
- let height = 0;
-
- for (let i = 0, len = pages.length; i < len; i++) {
- const page = pages[i];
- const { pageWidth, pageHeight } = page;
-
- if (docsComponent.pageLayoutType === PageLayoutType.VERTICAL) {
- height += pageHeight;
-
- height += docsComponent.pageMarginTop;
-
- if (i === len - 1) {
- height += docsComponent.pageMarginTop;
- }
-
- width = Math.max(width, pageWidth);
- } else if (docsComponent.pageLayoutType === PageLayoutType.HORIZONTAL) {
- width += pageWidth;
-
- if (i !== len - 1) {
- width += docsComponent.pageMarginLeft;
- }
- height = Math.max(height, pageHeight);
- }
- }
-
- docsComponent.resize(width, height);
-
- scene.transformByState({ width, height });
- }
-
- private _calculatePagePosition(docsComponent: Documents, scene: Scene, viewport: Viewport, zoomRatio: number = 1) {
- const parent = scene?.getParent();
-
- const { width: docsWidth, height: docsHeight, pageMarginLeft, pageMarginTop } = docsComponent;
- if (parent == null || docsWidth === Number.POSITIVE_INFINITY || docsHeight === Number.POSITIVE_INFINITY) {
- return;
- }
- const { width: engineWidth, height: engineHeight } = parent;
- let docsLeft = 0;
- let docsTop = 0;
-
- let sceneWidth = 0;
-
- let sceneHeight = 0;
-
- let scrollToX = Number.POSITIVE_INFINITY;
-
- if (engineWidth > (docsWidth + pageMarginLeft * 2) * zoomRatio) {
- docsLeft = engineWidth / 2 - (docsWidth * zoomRatio) / 2;
- docsLeft /= zoomRatio;
- sceneWidth = (engineWidth - pageMarginLeft * 2) / zoomRatio;
-
- scrollToX = 0;
- } else {
- docsLeft = pageMarginLeft;
- sceneWidth = docsWidth + pageMarginLeft * 2;
-
- scrollToX = (sceneWidth - engineWidth / zoomRatio) / 2;
- }
-
- if (engineHeight > docsHeight) {
- docsTop = engineHeight / 2 - docsHeight / 2;
- sceneHeight = (engineHeight - pageMarginTop * 2) / zoomRatio;
- } else {
- docsTop = pageMarginTop;
- sceneHeight = docsHeight + pageMarginTop * 2;
- }
-
- // this.docsLeft = docsLeft;
-
- // this.docsTop = docsTop;
-
- scene.transformByState({ width: sceneWidth, height: sceneHeight + 200 });
-
- docsComponent.translate(docsLeft, docsTop);
-
- if (scrollToX !== Number.POSITIVE_INFINITY && viewport != null) {
- const actualX = viewport.transScroll2ViewportScrollValue(scrollToX, 0).x;
- viewport.scrollToBarPos({
- x: actualX,
- });
- }
-
- return this;
- }
-}
-
-export class DocsAdaptorFactory {
- readonly zIndex = 5;
-
- create(injector: Injector): DocsAdaptor {
- const docsAdaptor = injector.createInstance(DocsAdaptor);
- return docsAdaptor;
- }
-}
-
-CanvasObjectProviderRegistry.add(new DocsAdaptorFactory());
diff --git a/packages/slides/src/views/render/adaptors/image-adaptor.ts b/packages/slides/src/views/render/adaptors/image-adaptor.ts
deleted file mode 100644
index 7816a90133..0000000000
--- a/packages/slides/src/views/render/adaptors/image-adaptor.ts
+++ /dev/null
@@ -1,86 +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 { Injector } from '@univerjs/core';
-import type { IPageElement } from '../../../types/interfaces/i-slide-data';
-import { Image } from '@univerjs/engine-render';
-import { PageElementType } from '../../../types/interfaces/i-slide-data';
-import { CanvasObjectProviderRegistry, ObjectAdaptor } from '../adaptor';
-
-export class ImageAdaptor extends ObjectAdaptor {
- override zIndex = 1;
-
- override viewKey = PageElementType.IMAGE;
-
- override check(type: PageElementType) {
- if (type !== this.viewKey) {
- return;
- }
- return this;
- }
-
- override convert(pageElement: IPageElement) {
- const {
- id,
- zIndex,
- left = 0,
- top = 0,
- width,
- height,
- angle,
- scaleX,
- scaleY,
- skewX,
- skewY,
- flipX,
- flipY,
- title,
- description,
- image = {},
- } = pageElement;
- const { imageProperties, placeholder, link } = image;
-
- const contentUrl = imageProperties?.contentUrl || '';
-
- return new Image(id, {
- url: contentUrl,
- top,
- left,
- width,
- height,
- zIndex,
- angle,
- scaleX,
- scaleY,
- skewX,
- skewY,
- flipX,
- flipY,
- forceRender: true,
- });
- }
-}
-
-export class ImageAdaptorFactory {
- readonly zIndex = 4;
-
- create(injector: Injector): ImageAdaptor {
- const imageAdaptor = injector.createInstance(ImageAdaptor);
- return imageAdaptor;
- }
-}
-
-CanvasObjectProviderRegistry.add(new ImageAdaptorFactory());
diff --git a/packages/slides/src/views/render/adaptors/index.ts b/packages/slides/src/views/render/adaptors/index.ts
deleted file mode 100644
index b79cc82027..0000000000
--- a/packages/slides/src/views/render/adaptors/index.ts
+++ /dev/null
@@ -1,22 +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 * from './docs-adaptor';
-export * from './image-adaptor';
-export * from './rich-text-adaptor';
-export * from './shape-adaptor';
-export * from './slide-adaptor';
-export * from './spreadsheet-adaptor';
diff --git a/packages/slides/src/views/render/adaptors/rich-text-adaptor.ts b/packages/slides/src/views/render/adaptors/rich-text-adaptor.ts
deleted file mode 100644
index 19698ae0a4..0000000000
--- a/packages/slides/src/views/render/adaptors/rich-text-adaptor.ts
+++ /dev/null
@@ -1,101 +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 { Injector } from '@univerjs/core';
-import type { IRichTextProps, Scene } from '@univerjs/engine-render';
-import type { IPageElement } from '../../../types/interfaces/i-slide-data';
-import { Inject, LocaleService } from '@univerjs/core';
-import { RichText } from '@univerjs/engine-render';
-import { PageElementType } from '../../../types/interfaces/i-slide-data';
-import { CanvasObjectProviderRegistry, ObjectAdaptor } from '../adaptor';
-
-export class RichTextAdaptor extends ObjectAdaptor {
- override zIndex = 2;
-
- override viewKey = PageElementType.TEXT;
-
- constructor(@Inject(LocaleService) private readonly _localeService: LocaleService) {
- super();
- }
-
- override check(type: PageElementType) {
- if (type !== this.viewKey) {
- return;
- }
- return this;
- }
-
- override convert(pageElement: IPageElement, _mainScene: Scene) {
- const {
- id,
- zIndex,
- left = 0,
- top = 0,
- width,
- height,
- angle,
- scaleX,
- scaleY,
- skewX,
- skewY,
- flipX,
- flipY,
- title,
- description,
- richText = {},
- } = pageElement;
- const { text, ff, fs, it, bl, ul, st, ol, bg, bd, cl, rich } = richText;
- let config: IRichTextProps = {
- top,
- left,
- width,
- height,
- zIndex,
- angle,
- scaleX,
- scaleY,
- skewX,
- skewY,
- flipX,
- flipY,
- forceRender: true,
- };
- let isNotNull = false;
- if (text != null) {
- config = { ...config, text, ff, fs, it, bl, ul, st, ol, bg, bd, cl };
- isNotNull = true;
- } else if (rich != null) {
- config = { ...config, richText: rich };
- isNotNull = true;
- }
-
- if (isNotNull === false) {
- return;
- }
- return new RichText(this._localeService, id, config);
- }
-}
-
-export class RichTextAdaptorFactory {
- readonly zIndex = 0;
-
- create(injector: Injector): RichTextAdaptor {
- const richTextAdaptor = injector.createInstance(RichTextAdaptor);
- return richTextAdaptor;
- }
-}
-
-CanvasObjectProviderRegistry.add(new RichTextAdaptorFactory());
diff --git a/packages/slides/src/views/render/adaptors/shape-adaptor.ts b/packages/slides/src/views/render/adaptors/shape-adaptor.ts
deleted file mode 100644
index 7c055736f0..0000000000
--- a/packages/slides/src/views/render/adaptors/shape-adaptor.ts
+++ /dev/null
@@ -1,143 +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 { Injector } from '@univerjs/core';
-import type { IPageElement } from '../../../types/interfaces/i-slide-data';
-import { getColorStyle } from '@univerjs/core';
-import { Circle, Rect } from '@univerjs/engine-render';
-import { BasicShapes } from '../../../types/enum/prst-geom-type';
-import { PageElementType } from '../../../types/interfaces/i-slide-data';
-import { CanvasObjectProviderRegistry, ObjectAdaptor } from '../adaptor';
-
-export class ShapeAdaptor extends ObjectAdaptor {
- override zIndex = 2;
-
- override viewKey = PageElementType.SHAPE;
-
- override check(type: PageElementType) {
- if (type !== this.viewKey) {
- return;
- }
- return this;
- }
-
- override convert(pageElement: IPageElement) {
- const {
- id,
- zIndex,
- left = 0,
- top = 0,
- width,
- height,
- angle,
- scaleX,
- scaleY,
- skewX,
- skewY,
- flipX,
- flipY,
- title,
- description,
- } = pageElement;
- const { shapeType, text, shapeProperties, placeholder, link } = pageElement.shape || {};
-
- const fill =
- shapeProperties == null ? '' : getColorStyle(shapeProperties.shapeBackgroundFill) || 'rgba(255,255,255,1)';
-
- const outline = shapeProperties?.outline;
- const strokeStyle: { [key: string]: string | number } = {};
- if (outline) {
- const { outlineFill, weight } = outline;
-
- strokeStyle.strokeWidth = weight;
- strokeStyle.stroke = getColorStyle(outlineFill) || 'rgba(0,0,0,1)';
- }
-
- if (shapeType === BasicShapes.Rect) {
- return new Rect(id, {
- fill,
- top,
- left,
- width,
- height,
- zIndex,
- angle,
- scaleX,
- scaleY,
- skewX,
- skewY,
- flipX,
- flipY,
- forceRender: true,
- ...strokeStyle,
- });
- }
- if (shapeType === BasicShapes.RoundRect) {
- const radius = shapeProperties?.radius || 0;
- return new Rect(id, {
- fill,
- top,
- left,
- width,
- height,
- zIndex,
- angle,
- scaleX,
- scaleY,
- skewX,
- skewY,
- flipX,
- flipY,
- forceRender: true,
- radius,
- ...strokeStyle,
- });
- }
- if (shapeType === BasicShapes.Ellipse) {
- console.warn(shapeProperties?.radius);
- const radius = shapeProperties?.radius || 0;
- return new Circle(id, {
- fill,
- top,
- left,
- width,
- height,
- zIndex,
- angle,
- scaleX,
- scaleY,
- skewX,
- skewY,
- flipX,
- flipY,
- forceRender: true,
- radius,
- ...strokeStyle,
- });
- }
- }
-}
-
-export class ShapeAdaptorFactory {
- readonly zIndex = 2;
-
- create(injector: Injector): ShapeAdaptor {
- const shapeAdaptor = injector.createInstance(ShapeAdaptor);
- return shapeAdaptor;
- }
-}
-
-CanvasObjectProviderRegistry.add(new ShapeAdaptorFactory());
diff --git a/packages/slides/src/views/render/adaptors/slide-adaptor.ts b/packages/slides/src/views/render/adaptors/slide-adaptor.ts
deleted file mode 100644
index ea1d333bc0..0000000000
--- a/packages/slides/src/views/render/adaptors/slide-adaptor.ts
+++ /dev/null
@@ -1,183 +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 { IColorStyle } from '@univerjs/core';
-import type { Engine } from '@univerjs/engine-render';
-import type { IPageElement, ISlidePage } from '../../../types/interfaces/i-slide-data';
-import { getColorStyle, Inject, Injector } from '@univerjs/core';
-import { Rect, Scene, Slide, Viewport } from '@univerjs/engine-render';
-import { SlideDataModel } from '../../../data-model/slide-data-model';
-import { PageElementType } from '../../../types/interfaces/i-slide-data';
-import { CanvasObjectProviderRegistry, ObjectAdaptor } from '../adaptor';
-import { ObjectProvider } from '../object-provider';
-
-// import { DocsAdaptor, ImageAdaptor, RichTextAdaptor, ShapeAdaptor } from './';
-
-export enum SLIDE_VIEW_KEY {
- MAIN = '__SLIDERender__',
- SCENE_VIEWER = '__SLIDEViewer__',
- SCENE = '__SLIDEScene__',
- VIEWPORT = '__SLIDEViewPort_',
-}
-
-export class SlideAdaptor extends ObjectAdaptor {
- override zIndex = 6;
-
- override viewKey = PageElementType.SLIDE;
-
- private _ObjectProvider: ObjectProvider | null = null;
-
- constructor(@Inject(Injector) private _injector: Injector) {
- super();
- }
-
- override check(type: PageElementType) {
- if (type !== this.viewKey) {
- return;
- }
- return this;
- }
-
- override convert(pageElement: IPageElement, mainScene: Scene) {
- const {
- id,
- zIndex,
- left = 0,
- top = 0,
- width,
- height,
- angle,
- scaleX,
- scaleY,
- skewX,
- skewY,
- flipX,
- flipY,
- title,
- description,
- slide: slideData,
- } = pageElement;
- if (slideData == null) {
- return;
- }
-
- const model = new SlideDataModel(slideData);
-
- const slideComponent = new Slide(SLIDE_VIEW_KEY.MAIN + id, {
- top,
- left,
- width,
- height,
- zIndex,
- angle,
- scaleX,
- scaleY,
- skewX,
- skewY,
- flipX,
- flipY,
- forceRender: true,
- });
-
- slideComponent.enableNav();
-
- slideComponent.enableSelectedClipElement();
-
- const pageOrder = model.getPageOrder();
-
- const pages = model.getPages();
-
- if (!pageOrder || !pages) {
- return slideComponent;
- }
-
- this._ObjectProvider = new ObjectProvider(this._injector);
-
- for (let i = 0, len = pageOrder.length; i < len; i++) {
- const page = pages[pageOrder[i]];
- const { id } = page;
- slideComponent.addPageScene(this._createScene(id, slideComponent, page, mainScene, model));
- }
-
- slideComponent.activeFirstPage();
-
- return slideComponent;
- }
-
- private _createScene(pageId: string, parent: Engine | Slide, page: ISlidePage, mainScene: Scene, model: SlideDataModel) {
- const { width, height } = parent;
-
- const scene = new Scene(pageId, parent, {
- width,
- height,
- });
-
- const viewMain = new Viewport(`PageViewer_${pageId}`, scene, {
- left: 0,
- top: 0,
- bottom: 0,
- right: 0,
- explicitViewportWidthSet: false,
- explicitViewportHeightSet: false,
- });
-
- viewMain.closeClip();
-
- const { pageElements, pageBackgroundFill } = page;
-
- const objects = this._ObjectProvider?.convertToRenderObjects(pageElements, mainScene);
-
- this._addBackgroundRect(scene, pageBackgroundFill, model);
-
- scene.addObjects(objects!);
-
- objects?.forEach((object) => {
- scene.attachTransformerTo(object);
- });
-
- return scene;
- }
-
- private _addBackgroundRect(scene: Scene, fill: IColorStyle, model: SlideDataModel) {
- const pageSize = model.getPageSize();
-
- const { width: pageWidth = 0, height: pageHeight = 0 } = pageSize;
-
- const page = new Rect('canvas', {
- left: 0,
- top: 0,
- width: pageWidth,
- height: pageHeight,
- strokeWidth: 1,
- stroke: 'rgba(198,198,198, 1)',
- fill: getColorStyle(fill) || 'rgba(255,255,255, 1)',
- zIndex: 0,
- evented: false,
- });
- scene.addObject(page, 0);
- }
-}
-
-export class SlideAdaptorFactory {
- readonly zIndex = 6;
-
- create(injector: Injector): SlideAdaptor {
- const slideAdaptor = injector.createInstance(SlideAdaptor);
- return slideAdaptor;
- }
-}
-
-CanvasObjectProviderRegistry.add(new SlideAdaptorFactory());
diff --git a/packages/slides/src/views/render/adaptors/spreadsheet-adaptor.ts b/packages/slides/src/views/render/adaptors/spreadsheet-adaptor.ts
deleted file mode 100644
index 38170e7e39..0000000000
--- a/packages/slides/src/views/render/adaptors/spreadsheet-adaptor.ts
+++ /dev/null
@@ -1,255 +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 { EventState } from '@univerjs/core';
-import type { IScrollObserverParam, IWheelEvent } from '@univerjs/engine-render';
-import type { IPageElement } from '../../../types/interfaces/i-slide-data';
-import { IConfigService, IContextService, Inject, Injector, LocaleService, Styles, Worksheet } from '@univerjs/core';
-import {
- getColor,
- Rect,
- Scene,
- SceneViewer,
- ScrollBar,
- Spreadsheet,
- SpreadsheetColumnHeader,
- SpreadsheetRowHeader,
- SpreadsheetSkeleton,
- Viewport,
-} from '@univerjs/engine-render';
-import { PageElementType } from '../../../types/interfaces/i-slide-data';
-import { CanvasObjectProviderRegistry, ObjectAdaptor } from '../adaptor';
-
-enum SHEET_VIEW_KEY {
- MAIN = 'spreadInSlide',
- SCENE = 'spreadInSlideScene',
- SCENE_VIEWER = 'spreadInSlideSceneViewer',
- ROW = 'spreadInSlideRow',
- COLUMN = 'spreadInSlideColumn',
- LEFT_TOP = 'spreadInSlideLeftTop',
- VIEW_MAIN = 'spreadInSlideViewMain',
- VIEW_TOP = 'spreadInSlideViewTop',
- VIEW_LEFT = 'spreadInSlideViewLeft',
- VIEW_LEFT_TOP = 'spreadInSlideViewLeftTop',
-}
-
-export class SpreadsheetAdaptor extends ObjectAdaptor {
- override zIndex = 4;
-
- override viewKey = PageElementType.SPREADSHEET;
-
- constructor(
- @Inject(LocaleService) private readonly _localeService: LocaleService,
- @IContextService private readonly _contextService: IContextService,
- @IConfigService private readonly _configService: IConfigService,
- @Inject(Injector) private readonly _injector: Injector
- ) {
- super();
- }
-
- override check(type: PageElementType) {
- if (type !== this.viewKey) {
- return;
- }
- return this;
- }
-
- override convert(pageElement: IPageElement, mainScene: Scene) {
- const {
- id,
- zIndex,
- left = 0,
- top = 0,
- width,
- height,
- angle,
- scaleX,
- scaleY,
- skewX,
- skewY,
- flipX,
- flipY,
- spreadsheet: spreadsheetModel,
- } = pageElement;
-
- if (spreadsheetModel == null) {
- return;
- }
-
- const { worksheet, styles } = spreadsheetModel;
-
- const styleModel = new Styles(styles);
- const spreadsheetSkeleton = new SpreadsheetSkeleton(
- new Worksheet(id, worksheet, styleModel), // FIXME: worksheet in slide doesn't has a Worksheet object
- styleModel,
- this._localeService,
- this._contextService,
- this._configService,
- this._injector
- );
-
- const { rowTotalHeight, columnTotalWidth, rowHeaderWidth, columnHeaderHeight } = spreadsheetSkeleton;
- const allWidth = columnTotalWidth + worksheet.rowHeader.width || 0;
- const allHeight = rowTotalHeight + worksheet.columnHeader.height || 0;
-
- const sv = new SceneViewer(SHEET_VIEW_KEY.SCENE_VIEWER + id, {
- top,
- left,
- width,
- height,
- zIndex,
- angle,
- scaleX,
- scaleY,
- skewX,
- skewY,
- flipX,
- flipY,
- forceRender: true,
- });
- const scene = new Scene(SHEET_VIEW_KEY.SCENE + id, sv, {
- width: allWidth,
- height: allHeight,
- });
- spreadsheetSkeleton.setScene(scene);
- scene.disposeWithMe(spreadsheetSkeleton);
-
- this._updateViewport(id, rowHeaderWidth, columnHeaderHeight, scene, mainScene);
- const spreadsheet = new Spreadsheet('testSheetViewer', spreadsheetSkeleton, false);
- const spreadsheetRowHeader = new SpreadsheetRowHeader(SHEET_VIEW_KEY.ROW, spreadsheetSkeleton);
- const spreadsheetColumnHeader = new SpreadsheetColumnHeader(SHEET_VIEW_KEY.COLUMN, spreadsheetSkeleton);
- const SpreadsheetLeftTopPlaceholder = new Rect(SHEET_VIEW_KEY.LEFT_TOP, {
- zIndex: 2,
- left: -1,
- top: -1,
- width: rowHeaderWidth,
- height: columnHeaderHeight,
- fill: getColor([248, 249, 250]),
- stroke: getColor([217, 217, 217]),
- strokeWidth: 1,
- });
-
- spreadsheet.zIndex = 10;
- scene.addObjects([spreadsheet], 1);
- scene.addObjects([spreadsheetRowHeader, spreadsheetColumnHeader, SpreadsheetLeftTopPlaceholder], 2);
- return sv;
- }
-
- private _updateViewport(
- id: string,
- rowHeaderWidth: number,
- columnHeaderHeight: number,
- scene: Scene,
- mainScene: Scene
- ) {
- if (mainScene == null) {
- return;
- }
- const rowHeaderWidthScale = rowHeaderWidth * scene.scaleX;
- const columnHeaderHeightScale = columnHeaderHeight * scene.scaleY;
-
- const viewMain = new Viewport(SHEET_VIEW_KEY.VIEW_MAIN + id, scene, {
- left: rowHeaderWidthScale,
- top: columnHeaderHeightScale,
- bottom: 0,
- right: 0,
- explicitViewportWidthSet: false,
- explicitViewportHeightSet: false,
- isWheelPreventDefaultX: true,
- });
- const viewTop = new Viewport(SHEET_VIEW_KEY.VIEW_TOP + id, scene, {
- left: rowHeaderWidthScale,
- height: columnHeaderHeightScale,
- top: 0,
- right: 0,
- explicitViewportWidthSet: false,
- isWheelPreventDefaultX: true,
- });
- const viewLeft = new Viewport(SHEET_VIEW_KEY.VIEW_LEFT + id, scene, {
- left: 0,
- bottom: 0,
- top: columnHeaderHeightScale,
- width: rowHeaderWidthScale,
- explicitViewportHeightSet: false,
- isWheelPreventDefaultX: true,
- });
-
- const _viewLeftTop = new Viewport(SHEET_VIEW_KEY.VIEW_LEFT_TOP + id, scene, {
- left: 0,
- top: 0,
- width: rowHeaderWidthScale,
- height: columnHeaderHeightScale,
- isWheelPreventDefaultX: true,
- });
- viewMain.onScrollAfter$.subscribeEvent((param: IScrollObserverParam) => {
- const { scrollX, scrollY, viewportScrollX, viewportScrollY } = param;
-
- viewTop
- .updateScrollVal({
- scrollX,
- viewportScrollX,
- });
-
- viewLeft
- .updateScrollVal({
- scrollY,
- viewportScrollY,
- });
- });
-
- scene.attachControl();
- const _scrollbar = new ScrollBar(viewMain, {
- mainScene,
- });
- this._bindWheel(scene, viewMain);
- }
-
- private _bindWheel(scene: Scene, viewMain: Viewport): void {
- scene.onMouseWheel$.subscribeEvent((evt: unknown, state: EventState) => {
- const e = evt as IWheelEvent;
- if (e.ctrlKey) {
- const deltaFactor = Math.abs(e.deltaX);
- let scrollNum = deltaFactor < 40 ? 0.05 : deltaFactor < 80 ? 0.02 : 0.01;
- scrollNum *= e.deltaY > 0 ? -1 : 1;
- if (scene.scaleX < 1) {
- scrollNum /= 2;
- }
-
- if (scene.scaleX + scrollNum > 4) {
- scene.scale(4, 4);
- } else if (scene.scaleX + scrollNum < 0.1) {
- scene.scale(0.1, 0.1);
- } else {
- scene.scaleBy(scrollNum, scrollNum);
- e.preventDefault();
- }
- } else {
- viewMain.onMouseWheel(e, state);
- }
- });
- }
-}
-
-export class SpreadsheetAdaptorFactory {
- readonly zIndex = 4;
-
- create(injector: Injector): SpreadsheetAdaptor {
- const spreadsheetAdaptor = injector.createInstance(SpreadsheetAdaptor);
- return spreadsheetAdaptor;
- }
-}
-
-CanvasObjectProviderRegistry.add(new SpreadsheetAdaptorFactory());
diff --git a/packages/slides/src/views/render/index.ts b/packages/slides/src/views/render/index.ts
deleted file mode 100644
index 471de8ccb3..0000000000
--- a/packages/slides/src/views/render/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.
- */
-
-// export * from '../../../../slides-ui/src/controllers/canvas-view';
-export * from './adaptor';
-
-export { SLIDE_VIEW_KEY } from './adaptors';
-export * from './object-provider';
-
-export enum SLIDE_KEY {
- COMPONENT = '__slideRender__',
- SCENE = '__mainScene__',
- VIEW = '__mainView__',
-}
-export type PageID = string;
diff --git a/packages/slides/src/views/render/object-provider.ts b/packages/slides/src/views/render/object-provider.ts
deleted file mode 100644
index 5e48229999..0000000000
--- a/packages/slides/src/views/render/object-provider.ts
+++ /dev/null
@@ -1,66 +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 { BaseObject, Scene } from '@univerjs/engine-render';
-import type { IPageElement } from '../../types/interfaces/i-slide-data';
-import type { ObjectAdaptor } from './adaptor';
-import { Inject, Injector, sortRules } from '@univerjs/core';
-import { CanvasObjectProviderRegistry } from './adaptor';
-import './adaptors';
-
-export class ObjectProvider {
- private _adaptors: ObjectAdaptor[] = [];
-
- constructor(@Inject(Injector) private readonly _injector: Injector) {
- this._adaptorLoader();
- }
-
- convertToRenderObjects(pageElements: { [elementId: string]: IPageElement }, mainScene: Scene) {
- const pageKeys = Object.keys(pageElements);
- const objects: BaseObject[] = [];
- pageKeys.forEach((key) => {
- const pageElement = pageElements[key];
- const o = this._executor(pageElement, mainScene);
- if (o != null) {
- objects.push(o);
- }
- });
- return objects;
- }
-
- convertToRenderObject(pageElement: IPageElement, mainScene: Scene) {
- return this._executor(pageElement, mainScene);
- }
-
- private _executor(pageElement: IPageElement, mainScene: Scene) {
- const { id: pageElementId, type } = pageElement;
-
- for (const adaptor of this._adaptors) {
- const o = adaptor.check(type)?.convert(pageElement, mainScene);
- if (o != null) {
- return o;
- }
- }
- }
-
- private _adaptorLoader() {
- CanvasObjectProviderRegistry.getData()
- .sort(sortRules)
- .forEach((adaptorFactory: ObjectAdaptor) => {
- this._adaptors.push(adaptorFactory.create(this._injector) as unknown as ObjectAdaptor);
- });
- }
-}
diff --git a/packages/slides/tsconfig.json b/packages/slides/tsconfig.json
deleted file mode 100644
index d4f9172636..0000000000
--- a/packages/slides/tsconfig.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "extends": "@univerjs-infra/shared/tsconfigs/base",
- "compilerOptions": {
- "rootDir": "src",
- "outDir": "lib/types"
- },
- "include": ["src"]
-}
diff --git a/packages/slides/tsconfig.node.json b/packages/slides/tsconfig.node.json
deleted file mode 100644
index 2abfa07367..0000000000
--- a/packages/slides/tsconfig.node.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "extends": "@univerjs-infra/shared/tsconfigs/node",
- "compilerOptions": {
- "rootDir": "src",
- "declaration": true,
- "emitDeclarationOnly": true,
- "noEmit": false,
- "outDir": "lib/types"
- },
- "include": [
- "src"
- ],
- "exclude": [
- "src/**/__tests__/**",
- "src/**/*.spec.ts",
- "src/**/*.test.ts"
- ]
-}
diff --git a/packages/slides/vitest.config.ts b/packages/slides/vitest.config.ts
deleted file mode 100644
index af97c6d7a2..0000000000
--- a/packages/slides/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 5488cac4f7..478f63fd38 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -523,12 +523,6 @@ importers:
'@univerjs/presets':
specifier: workspace:*
version: link:../presets
- '@univerjs/slides':
- specifier: workspace:*
- version: link:../packages/slides
- '@univerjs/slides-ui':
- specifier: workspace:*
- version: link:../packages/slides-ui
'@univerjs/themes':
specifier: workspace:*
version: link:../packages/themes
@@ -2576,80 +2570,6 @@ importers:
specifier: ^5.0.5
- packages/slides:
- dependencies:
- '@univerjs/core':
- specifier: workspace:*
- version: link:../core
- '@univerjs/engine-render':
- specifier: workspace:*
- version: link:../engine-render
- devDependencies:
- '@univerjs-infra/shared':
- specifier: workspace:*
- version: link:../../common/shared
- rxjs:
- specifier: 7.8.2
- version: 7.8.2
- tsrs:
- specifier: 0.20.1-ts7.1.0-beta
- version: 0.20.1-ts7.1.0-beta
- vitest:
- specifier: ^5.0.5
-
- packages/slides-ui:
- dependencies:
- '@univerjs/core':
- specifier: workspace:*
- version: link:../core
- '@univerjs/design':
- specifier: workspace:*
- version: link:../design
- '@univerjs/docs':
- specifier: workspace:*
- version: link:../docs
- '@univerjs/docs-ui':
- specifier: workspace:*
- version: link:../docs-ui
- '@univerjs/drawing':
- specifier: workspace:*
- version: link:../drawing
- '@univerjs/engine-render':
- specifier: workspace:*
- version: link:../engine-render
- '@univerjs/icons':
- specifier: 1.47.0
- '@univerjs/slides':
- specifier: workspace:*
- version: link:../slides
- '@univerjs/ui':
- specifier: workspace:*
- version: link:../ui
- devDependencies:
- '@univerjs-infra/shared':
- specifier: workspace:*
- version: link:../../common/shared
- postcss:
- specifier: ^8.5.32
- version: 8.5.32
- react:
- specifier: 19.3.0
- version: 19.3.0
- rxjs:
- specifier: 7.8.2
- version: 7.8.2
- tailwindcss:
- specifier: 3.4.18
- version: 3.4.18
- tsrs:
- specifier: 0.20.1-ts7.1.0-beta
- version: 0.20.1-ts7.1.0-beta
- vitest:
- specifier: ^5.0.5
-
packages/telemetry:
dependencies:
'@univerjs/core':