Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
docs: add more docs (#671)
Wenzhao Hu743dcec03c69
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.mdnew file mode 100644index 0000000000..423cd2379a--- /dev/null+++ b/CODE_OF_CONDUCT.md@@ -0,0 +1,46 @@+# Contributor Covenant Code of Conduct++## Our Pledge++In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.++## Our Standards++Examples of behavior that contributes to creating a positive environment include:++- Using welcoming and inclusive language+- Being respectful of differing viewpoints and experiences+- Gracefully accepting constructive criticism+- Focusing on what is best for the community+- Showing empathy towards other community members++Examples of unacceptable behavior by participants include:++- The use of sexualized language or imagery and unwelcome sexual attention or advances+- Trolling, insulting/derogatory comments, and personal or political attacks+- Public or private harassment+- Publishing others' private information, such as a physical or electronic address, without explicit permission+- Other conduct which could reasonably be considered inappropriate in a professional setting++## Our Responsibilities++Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.++Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.++## Scope++This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.++## Enforcement++Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [[email protected]](mailto:[email protected]). The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.++Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.++## Attribution++This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version].++[homepage]: http://contributor-covenant.org+[version]: http://contributor-covenant.org/version/1/4/diff --git a/apps/docs/docs/tutorial/architecture/architecture.md b/apps/docs/docs/tutorial/architecture/architecture.mdindex 553a4c2ce5..1c6aeb62ad 100644--- a/apps/docs/docs/tutorial/architecture/architecture.md+++ b/apps/docs/docs/tutorial/architecture/architecture.md@@ -4,66 +4,77 @@ sidebar_position: 1# Univer 架构-## Univer 架构设计的核心需求+这篇文档介绍 Univer 的整体架构。-1. **100% 拥抱 web 技术栈**。Univer 需要运行在相当多的环境里,要满足快速的迭代需求并让客户、ISV、社区拥有二次开发的能力,能同时满足这些需求的只有以 web 技术为核心的技术栈。-2. **插件化和高度可扩展性**。Univer 的各个模块应当尽可能地以插件的方式存在,尽可能解耦插件之间的耦合关系,做到降低适配不同的用户需求、不同的运行环境的成本,同时降低二次开发的门槛。-3. **层次结构和单向依赖**。Univer 的模块之间不允许循环依赖,这使得我们可以按照不同环境的需要加载所需的层次和模块。-4. **面向多平台做设计**。解耦代码和具体运行环境的耦合关系,方便迁移到不同的运行环境当中。-5. **面向高可测试性做设计**。各个模块直接尽可能基于接口建立依赖关系,方便独立测试。---## 插件和依赖注入+## Univer 代码的组织方式<img width="962" alt="" src="/img/architecture.png" />### 插件-Univer 的模块需按照 **业务类型(Sheet / Doc / Slide)、关注面(配置管理 / UI / 快捷键 / canvas 渲染)、功能(Sheet 基本操作 / Sheet 条件格式 / Sheet 筛选、运行环境(桌面端 / 移动端 / Node.js 等)** 等因素综合考虑,拆分成各个插件(plugin),组合成为一个 Univer 应用。+Univer 的模块按照多种因素综合考虑拆分成了各个插件(plugin),多个插件组合成为一个 Univer 应用。++插件化架构为 Univer 带来这些以下优势:++1. 无论运行在什么环境下,Univer 都可以通过加载不同的插件来满足不同的需求(例如在 Node.js 环境下,可以不加载 UI 相关的插件)从而减少冗余代码带来的开销+2. 你可以按照自己的需要选择加载哪些插件,减少不必要的代码。+3. 插件化架构使得 Univer 更容易修改和扩展,你可以自行开发插件来满足自己的需求,而不必更改 Univer 本身的代码。+4. 插件化架构可以让 Univer 各个模块的职责及依赖关系更加明确,更易于理解、修改、测试和维护。++### 拆分插件的考虑因素++插件的划分是相当灵活的,你完全可以有自己的一套依据。不过以下是我们(Univer 核心团队)所使用的一些依据:++* 是否存在在某些环境下需要加载而在另一环境下不需要加载的模块,如果存在这样的模块,这些模块适宜放在一个单独的插件中。例如 Node.js 中不需要加载 UI 相关的模块,因此 sheet 基本功能中和 UI 相关的部分被拆分到 @univerjs/sheet-ui 中。+* 可以按照不同的文档类型划分,例如 @univerjs/sheet 和 @univerjs/doc 就是按照文档类型划分的。+* 一些复杂的功能可以单独划分成一个插件,例如 @univerjs/sheet-numfmt 就是一个单独的插件,它提供了修改数字格式的功能。+* 一些通用的底层能力可以单独划分成一个插件,例如 @univerjs/design 提供设计系统相关的能力,例如主题、颜色、组件等等、@univerjs/rpc 提供 RPC 能力等等++### 插件的类型-基于插件的设计能够使得 Univer 能够满足多样的运行环境(PC browser / Node / 移动端)、不同的功能需求、不同的配置要求、二次开发、三方插件等需要。+Univer 对插件的类型做了区分,这使得 Univer 能够在最合适的时机初始化插件,从而尽可能节约插件的内存占用。-典型的插件及扩展能力可以参考文档 [Plugin 扩展能力](https://github.com/dream-num/univer/wiki/%5BWIP%5D-Plugin-%E6%89%A9%E5%B1%95%E8%83%BD%E5%8A%9B)。+目前有以下几种类型:++* `PluginType.Univer` Univer 核心插件,这些插件会在 Univer 实例创建的时候就开始加载并触发 `onStarting` 生命周期+* `PluginType.Doc` Doc 文档类型插件+* `PluginType.Sheet` Sheet 文档类型插件++除了 `PluginType.Univer` 之外的插件只会在对应类型的文件第一次被创建的时候开始加载并经历其生命周期。++:::note+关于生命周期的介绍请参考下面的 “插件生命周期” 一节。+:::### 依赖注入-插件内部可以根据实际需要将代码划分为下面 “层次结构” 一节中介绍的各个层次的模块,这些模块中的 service 和 controller 需要加入 Univer 的依赖注入系统,这样 Univer 就能自动解析这些模块之间的依赖关系并实例化这些模块。依赖注入系统的文档参考 [redi - redi](https://redi.wendell.fun/zh-CN)。+插件内部可以划分为多个模块(划分的方式可参考下面 “层次结构” 的介绍)这些模块中可以加入 Univer 的依赖注入系统,这样 Univer 就能自动解析这些模块之间的依赖关系并实例化这些模块,从而大大降低在一个复杂系统中管理依赖的复杂度。目前 Univer 官方插件均接入了依赖注入系统。++我们使用的依赖注入工具为 [redi](https://redi.wendell.fun/zh-CN),可以参考 redi 的文档了解依赖注入的基本概念,以及如何使用它。### 插件的公有私有模块-可以通过在每个插件的 index.ts 文件中导出这些模块的依赖注入标识符 identifier。如果一个模块的 identifier 被导出,那么其它的插件就可以 import 这些模块的 identifier,从而建立对这些模块的依赖关系,这些模块也就成为前一个插件的公有模块,反之就是私有模块。如果你熟悉 Angular 的话,很容易发现这跟 NgModule 的概念非常相似,只不过我们不用申明 exports 字段,而是用 es module 的 export 来区分公有模块。+如果一个插件想要暴露一些接口给其他插件使用,插件可以在它的模块出口文件(一般是 index.ts 文件)中导出这些模块的依赖注入标识符(identifier)。如果一个模块的 identifier 被导出,那么其它的插件就可以注入这些模块的 identifier,从而建立对这些模块的依赖关系,这些模块也就成为前一个插件的公有模块,反之就是私有模块。如果你熟悉 Angular 的话,很容易发现这跟 NgModule 的概念非常相似,只不过我们不用 exports 字段来声明一个模块的公有模块,而是用 es module 的 export 来暴露模块并将其视为公有模块。### 插件生命周期-插件有如下四个生命周期+Univer 的插件存在生命周期,通过使用生命周期,Univer 使得插件的行为更好预测,避免时序相关的逻辑错误。-```ts-export const enum LifecycleStages {- Starting,- Ready,- Rendered,- Steady,-}-```+插件有如下四个生命周期:* `Starting` plugin 挂载到 Univer 实例上的第一个生命周期,此时 Univer 业务实例尚未被创建。Plugin 在此生命周期中应该将自己模块加入到依赖注入系统当中。不建议在此生命周期之外初始化插件内部模块。* `Ready` Univer 的第一个业务实例已经创建,plugin 可以在此生命周期做大部分初始化工作。* `Rendered` 第一次渲染已经完成,plugin 可以在此生命周期进行需要依赖 DOM 的初始化工作。* `Steady` 在 `Rendered` 一段时间之后触发,plugin 可以在此生命周期进行非首屏必须的工作,以提升加载性能。-对应的,Plugin 类型上有四个生命周期勾子+对应的,Plugin 类型上有四个生命周期勾子,各个 plugin 可以通过覆盖这些方法来在各个声明周期执行相应的逻辑.+```ts-/**- * Plug-in base class, all plug-ins must inherit from this base class. Provide basic methods.- */export abstract class Plugin {onStarting(_injector: Injector): void {}-onReady(): void {}-onRendered(): void {}-onSteady(): void {}}```@@ -89,17 +100,13 @@ export class YourService {}```-### 划分插件的依据--插件划分的主要依据是:在某些场景下,一些模块是否需要加载。例如在 Node.js 端运行时,可能不需要加载 UI 相关的模块,这样就可以将 UI 相关的模块放在一个插件中,然后在 Node.js 端不加载这个插件;又例如想让用户自行选择是否加载一个功能,那么就可以将这个功能放在一个插件中。--## 层次结构+### 模块分层插件内部的模块应当归属于以下层次:-* View 处理渲染和交互,包括 canvas 渲染和 React 组件+* View 处理渲染和交互,包括 Canvas 渲染和 React 组件* Controller 封装业务逻辑(特别是功能逻辑),派发 Command 等* Command 通过命令模式执行逻辑,修改下面 Service / Model 等层次的状态或数据* Service 按照关注点封装功能给上层模块使用,存储应用内部状态,操作底层数据等等@@ -107,64 +114,34 @@ export class YourService {层次之间需要保持单向依赖关系,除部分 Controller 作为 MVVM 中的 view-model 之外可能持有对 UI 层对象的引用,其他层次禁止引用上层模块的代码。-注意:插件的代码并非只能属于一个层次,例如一个插件可能同时提供 View 和 Controller。+通过模块分层和限制单向依赖,再搭配良好的模块划分,Univer 能够最大程度的做到在不同宿主中的代码复用。-## 命令系统 Command+:::info+如果你使用 Univer CLI 来初始化插件,Univer CLI 将会帮你划分目录。+:::-对应用状态和数据的变更需要通过命令系统执行。Univer core 中提供了命令服务,其依赖注入 token 为 `ICommandService`。上层模块可以将业务逻辑封装在 Command 里,并通过命令系统获取到其他 services 从而执行业务逻辑。基于命令系统,Univer 可以通过简单的方式实现协同编辑、宏录制、撤销重做、跟随浏览等能力。+## 命令系统-plugin 可以通过 `ICommandService` 提供的 `registerCommand` 接口注册命令,并通过 `executeCommand` 接口执行命令:+在 Univer 当中,对应用状态和数据的变更需要通过命令系统执行。命令系统本身是对应用逻辑的抽象,解耦逻辑的执行过程和其参数,Univer 在此基础上实现协同编辑、宏录制、撤销重做、跟随浏览等能力。-```ts-export interface ICommand<P extends object = object, R = boolean> {- /**- * ${businessName}.${type}.${name}- */- readonly id: string;- readonly type: CommandType;+@univerjs/core 中提供了命令服务,插件可以将业务逻辑封装在命令里,并通过依赖注入系统获取到其他模块从而执行业务逻辑。- handler(accessor: IAccessor, params?: P): Promise<R>;-- /** When this command is unregistered, this function would be called. */- onDispose?: () => void;-}+插件可以通过 `ICommandService` 提供的 `registerCommand` 接口注册命令,并通过 `executeCommand` 接口执行命令:-export interface ICommandService {- registerCommand(command: ICommand): IDisposable;-- executeCommand<P extends object = object, R = boolean>(- id: string,- params?: P,- options?: IExecutionOptions- ): Promise<R> | R;-}-```--`Command` 一共有三种类型--```ts-export const enum CommandType {- /** Command could generate some operations or mutations. */- COMMAND = 0,- /** An operation that do not require conflict resolve. */- OPERATION = 1,- /** An operation that need to be resolved before applied on peer client. */- MUTATION = 2,-}-```+`Command` 一共有三种类型:* `COMMAND` 负责根据特定的业务逻辑创建、编排和执行 `MUTATION` 或 `OPERATION`,例如一个 **删除行 `COMMAND`** 会生成一个 **删除行 `MUTATION`** 和用于 undo 的一个 **插入行 `MUTATION`** 及一个 **设置单元格内容 `MUTATION`*** `COMMAND` 是业务逻辑的主要承载者,如果对于一个 _用户操作行为_ 需要根据应用的状态来触发不同的 _底层行为_ —— 例如 _用户点击加粗文字按钮_ 时 需要根据当前选区范围来决定 _加粗操作的生效范围_ —— 相应的判断应该由 `COMMAND` 完成* 可以派发其他 `COMMAND` `OPERATION` `MUTATION`* 允许异步执行-* `MUTATION` 是对落盘数据所做的变更,涉及协同编辑的冲突处理,例如插入行列,修改单元格内容,修改筛选范围等等操作+* `MUTATION` 是对落盘数据所做的变更,例如插入行列,修改单元格内容,修改筛选范围等等操作。如果你想给 Univer 加入协同编辑的能力,那么它就是冲突处理的最小单元。* 不可以再派发其他任何命令* **必须同步执行*** `OPERATION` 是对不落盘数据(或称应用状态)所做的变更,不涉及冲突处理,例如修改滚动位置、修改侧边栏状态等等* 不可以再派发其他任何命令* **必须同步执行**-### 协同编辑+### 事件监听`ICommandService` 提供事件监听接口,插件可监听哪些命令被执行了,以及执行的参数是什么。实际上,命令执行后会派发这样一个事件:@@ -184,96 +161,21 @@ export interface ICommandInfo<T extends object = object> {}```-对于协同编辑而言 collaboration-plugin 可以监听所有 `MUTATION` 类型命令,并通过协同编辑算法将 `MUTATION` 发送到其他协同端,再通过 `ICommandService` 重新执行这些 `MUTATION`。--### 操作录制和回放+通过监听事件的执行,可以以非侵入式的方式扩展 Univer 的能力,例如:-通过监听 `OPERATION` 和 `MUTATION` 的执行,插件可以将用户的操作行为记录下来,并且可以在此基础上实现:--* 协同光标-* 类似于飞书视频的 Magic Share+* **协同编辑**:一个协同编辑插件可以监听所有 `MUTATION` 类型命令,并通过协同编辑算法将 `MUTATION` 发送到其他协同端,再通过 `ICommandService` 重新执行这些 `MUTATION`。+* **协同光标**:监听选区变化的 `OPERATION` 并发送到其他端,其他端通过解析参数来绘制协同光标+* **Live Share**:监听滚动和缩放 `OPERATION` 并发送到观众端,观众可以同步演示者的浏览位置* 宏录制-* AppScript等等。-## 交互--Univer 提供了一些机制简化 UI 的开发,降低菜单、快捷键等在不同的设备以及交互组件内的工作量。功能插件无需关心 UI 上的细节,只需要专注于业务逻辑即可。--### ShortcutService--通过向 `IShortcutService` 注入 `IShortcutItem` 可以注册一个快捷键,并且配置它的键位、优先级、触发条件、执行的 Command 等。--```ts-export interface IShortcutItem<P extends object = object> {- /** This should reuse the corresponding command's id. */- id: string;- description?: string;-- priority?: number;- /** A callback that will be triggered to examine if the shortcut should be invoked. */- preconditions?: (contextService: IContextService) => boolean;-- /** A command can be bound to several bindings, with different static parameters perhaps. */- binding: number;- mac?: number;- win?: number;- linux?: number;+## 服务化- /** Static parameters of this shortcut. Would be send to `CommandService.executeCommand`. */- staticParameters?: P;-}--export interface IShortcutService {- registerShortcut(shortcut: IShortcutItem): IDisposable;-- getCommandShortcut(id: string): string | null;-}-```--### MenuService+### 关注点分离-通过向 `IMenuService` 注册 `IMenuItem` 可以配置一个菜单项。+在介绍“模块分层”时,我们提到的 Univer 模块层次中有一层名为 service,这一层的模块被称为服务,它们的职责是封装一些通用的功能。Univer 在架构上鼓励按照[关注点分离](https://zh.wikipedia.org/zh-sg/%E5%85%B3%E6%B3%A8%E7%82%B9%E5%88%86%E7%A6%BB)的原则将功能封装到不同的服务中,这样可以使得服务更加专注于某一特定的功能,从而使得服务更加易于理解、修改、测试和维护。-```ts-interface IMenuItemBase<V> {- /** ID of the menu item. Normally it should be the same as the ID of the command that it would invoke. */- id: string;- title: string;- description?: string;- icon?: string;- tooltip?: string;+### 抽象依赖- /** In what menu should the item display. */- positions: OneOrMany<MenuPosition | string>;-- /** @deprecated this type seems unnecessary */- type: MenuItemType;- /**- * Custom label component id.- * */- label?:- | string- | {- name: string;- props?: Record<string, string | number>;- };-- hidden$?: Observable<boolean>;- disabled$?: Observable<boolean>;-- /** On observable value that should emit the value of the corresponding selection component. */- value$?: Observable<V>;-}--export interface IMenuService {- menuChanged$: Observable<void>;-- addMenuItem(item: IMenuItem): IDisposable;-- /** Get menu items for display at a given position or a submenu. */- getMenuItems(position: MenuPosition | string): Array<IDisplayMenuItem<IMenuItem>>;- getMenuItem(id: string): IMenuItem | null;-}-```\ No newline at end of file+在封装服务时,可以采用抽象依赖的原则,将服务对其他服务的依赖抽象为接口,从而使得服务更加易于测试和维护。\ No newline at end of filediff --git a/apps/docs/docs/tutorial/plugins/common/core.md b/apps/docs/docs/tutorial/plugins/common/core.mdindex b034215f99..824771ce60 100644--- a/apps/docs/docs/tutorial/plugins/common/core.md+++ b/apps/docs/docs/tutorial/plugins/common/core.md@@ -22,30 +22,10 @@ sidebar_position: 1@univerjs/core 的 API 请参考 API 文档。-## Univer Sheet--### Models--`core` 跟 sheet 相关的模块主要是基数据结构和一个 `SheetInterceptorService`:+## Univer Sheet Models* UniverSheet 类型,它负责管理 Sheet 相关的 plugin* Workbook 类型,它是一个工作簿,包含多个 Worksheet,存储工作簿的元数据* Worksheet 类型,它是一个工作表,存储每个子表的数据-* `SheetInterceptorService`,允许其他插件干预从 Worksheet 上取值的行为--### `SheetInterceptorService`--`SheetInterceptorService` 是 core 提供的一个较为特殊的服务,它允许上层业务修改从 Worksheet 中获取单元格数据、获取行列隐藏信息等操作的结果,以及在特定的 command 执行时补充 mutation 或者 operation。这个服务的主要目的是为了实现一些特殊的功能,例如:--1. sheet 公式-2. sheet 条件格式-3. sheet 数据验证-4. sheet 数据透视表--等等。--**何时使用 `SheetInterceptorService`,何时不要使用?**--当各个功能需要操作同一块数据或者状态,但是它们之前并没有明确的依赖关系时使用 `SheetInterceptorService`,例如:数据透视表、公式、条件格式、数据验证、单元格原始数据都可能影响其他功能对单元格内容的取值结果,但是它们之间并没有明确的依赖关系,因此使用 `SheetInterceptorService` 来实现这些功能是比较合适的。-如果一个功能明确地依赖其他功能,例如公式需要在下拉填充或复制粘贴功能被调用时做一些操作,那么公式模块应该直接依赖下拉填充和复制粘贴模块,而不是通过 `SheetInterceptorService` 来实现。+## Univer Doc Modelsdiff --git a/apps/docs/docs/tutorial/plugins/common/design.md b/apps/docs/docs/tutorial/plugins/common/design.mdindex bddc62594a..8c56630420 100644--- a/apps/docs/docs/tutorial/plugins/common/design.md+++ b/apps/docs/docs/tutorial/plugins/common/design.md@@ -4,6 +4,12 @@ sidebar_position: 9# @univerjs/design-为了让 Univer 的插件 UI 能够有更好的一致性,也为了降低用户自定义开发时的工作量,我们提供了一些基础的设计规范和组件。组件基于 React 和 less 开发,可以访问组件库网站了解更多信息。+为了让 Univer 的插件 UI 能够有更好的一致性,也为了降低用户自定义开发时的工作量,我们提供了一些基础的设计规范和组件。-TODO 添加组件库网站的地址+组件基于 React 和 less 开发,可以访问[组件库网站](https://univer-design.vercel.app/?path=/docs/design-design-token-default--docs)了解更多信息。++++:::note+如果你只需要扩展工具栏、右键菜单等,可以直接使用 @univerjs/ui 提供的扩展接口,无需自行实现 UI。请参考[扩展 UI](/docs/turorial/plugins/extend/ui)。+:::diff --git a/apps/docs/docs/tutorial/plugins/common/icon.md b/apps/docs/docs/tutorial/plugins/common/icon.mdindex dfa15018f8..79f362de96 100644--- a/apps/docs/docs/tutorial/plugins/common/icon.md+++ b/apps/docs/docs/tutorial/plugins/common/icon.md@@ -6,4 +6,4 @@ sidebar_position: 10-出于和提供 [@univerjs/design](/docs/tutorial/plugins/common/design) 同样的目的,我们也提供了一些基础图标,可以访问[图标库网站](https://univer-icons.vercel.app/)了解更多信息。+出于和 [@univerjs/design](/docs/tutorial/plugins/common/design) 相似的目的,我们也提供了一些基础图标。你可以访问[图标库网站](https://univer-icons.vercel.app/)了解更多信息。diff --git a/apps/docs/docs/tutorial/plugins/common/network.md b/apps/docs/docs/tutorial/plugins/common/network.mddeleted file mode 100644index 160a7fd082..0000000000--- a/apps/docs/docs/tutorial/plugins/common/network.md+++ /dev/null@@ -1,5 +0,0 @@-----sidebar_position: 7------# @univerjs/network\ No newline at end of filediff --git a/apps/docs/docs/tutorial/plugins/common/rpc.md b/apps/docs/docs/tutorial/plugins/common/rpc.mdindex 2606ecf9bb..c51f1c4967 100644--- a/apps/docs/docs/tutorial/plugins/common/rpc.md+++ b/apps/docs/docs/tutorial/plugins/common/rpc.md@@ -1,5 +1,5 @@----sidebar_position: 5+sidebar_position: 6---# @univerjs/rpcdiff --git a/apps/docs/docs/tutorial/plugins/common/ui.md b/apps/docs/docs/tutorial/plugins/common/ui.mdindex 4e13c23e55..7a27c1f9f5 100644--- a/apps/docs/docs/tutorial/plugins/common/ui.md+++ b/apps/docs/docs/tutorial/plugins/common/ui.md@@ -4,9 +4,27 @@ sidebar_position: 2# @univerjs/ui-@univerjs/ui 提供了 Univer Sheet 的 UI 实现,以及面向用户的交互能力,包括:+@univerjs/ui 定义了基本的 UI 服务,并基于 React 提供了一套桌面端的 Workbench 实现。-* UI- * 工具栏、右键菜单、侧边栏等-* 剪贴板访问-* 快捷键系统++## UI 服务++UI 服务定义了一些在客户端运行,但与特定的宿主无关(例如桌面端浏览器、移动端 webview 等)的 UI 服务。通过注入这些服务,业务功能可以在不同的宿主中调用相同的接口,而不用关心宿主的差异。++这些 UI 服务包括:++* 菜单服务,用于注册菜单项以及其对应的 command+* 快捷键服务,用于注册快捷键以及其对应的 command+* 剪贴板服务,从剪贴板读取或写入数据+* 弹窗服务,包括 confirm 和 dialog 等++等等。++## Workbench++除了 UI 服务之外,@univerjs/ui 还基于 React 实现了工作区,包括标题栏、工具栏、正文区域、右键菜单、侧边栏等等。业务可以通过 Workbench 提供的 API 来自定义渲染内容。++---+++@univerjs/ui 的 API 请参考 API 文档。\ No newline at end of filediff --git a/apps/docs/docs/tutorial/plugins/sheet/base-sheets.md b/apps/docs/docs/tutorial/plugins/sheet/base-sheets.mddeleted file mode 100644index 2b99f4634d..0000000000--- a/apps/docs/docs/tutorial/plugins/sheet/base-sheets.md+++ /dev/null@@ -1,12 +0,0 @@-----sidebar_position: 1------# @univerjs/sheets--承载 sheet 的主要(基础)业务逻辑,base-sheets 被设计为 UI 无关。--@univerjs/sheets 为 Univer Sheet 提供了以下能力:--* 提供核心能力,例如数字格式,选区管理等等-* 更改电子表格数据的 commands / mutationsdiff --git a/apps/docs/docs/tutorial/plugins/sheet/sheets-formula-ui.md b/apps/docs/docs/tutorial/plugins/sheet/sheets-formula-ui.mddeleted file mode 100644index 28bcfaa97e..0000000000--- a/apps/docs/docs/tutorial/plugins/sheet/sheets-formula-ui.md+++ /dev/null@@ -1,5 +0,0 @@-----sidebar_position: 4------# @univerjs/sheets-formula-ui\ No newline at end of filediff --git a/apps/docs/docs/tutorial/plugins/sheet/sheets-ui.md b/apps/docs/docs/tutorial/plugins/sheet/sheets-ui.mdnew file mode 100644index 0000000000..589169d71b--- /dev/null+++ b/apps/docs/docs/tutorial/plugins/sheet/sheets-ui.md@@ -0,0 +1,12 @@+---+sidebar_position: 2+---++# @univerjs/sheets-ui++@univerjs/sheets-ui 提供了 sheet 的 UI,包括:++* sheet 基础功能的快捷键+* 复制粘贴服务,业务可以调用复制粘贴服务提供的方法来自定义某项功能的复制粘贴行为+* 下拉填充服务,业务可以调用下拉填充服务提供的方法来自定义某项功能的下拉填充行为+* 单元格编辑器服务diff --git a/apps/docs/docs/tutorial/plugins/sheet/sheets.md b/apps/docs/docs/tutorial/plugins/sheet/sheets.mdnew file mode 100644index 0000000000..7e4f6ae8d4--- /dev/null+++ b/apps/docs/docs/tutorial/plugins/sheet/sheets.md@@ -0,0 +1,33 @@+---+sidebar_position: 1+---++# @univerjs/sheets++@univerjs/sheet 承载 sheet 的主要(基础)业务逻辑,base-sheets 被设计为 UI 无关,因此也可以运行在 Node.js 环境中,借此可以实现协同编辑等功能。++@univerjs/sheets 为 Univer Sheet 提供了以下能力:++* 提供核心能力,例如数字格式、选区管理、权限等等+* 更改电子表格数据的 commands / mutations++++## `SheetInterceptorService`++`SheetInterceptorService` 是 @univerjs/sheets 提供的一个较为特殊的服务,它允许上层业务修改从 Worksheet 中获取单元格数据、获取行列隐藏信息等操作的结果,以及在特定的 command 执行时补充 mutation 或者 operation。这个服务的主要目的是为了实现一些特殊的功能,例如:++1. sheet 公式+2. sheet 条件格式+3. sheet 数据验证+4. sheet 数据透视表++等等。++具体的使用方法请参考 API 文档。++### **何时使用 `SheetInterceptorService`,何时不要使用?**++当各个功能需要操作同一块数据或者状态,但是它们之前并没有明确的依赖关系时使用 `SheetInterceptorService`,例如:数据透视表、公式、条件格式、数据验证、单元格原始数据都可能影响其他功能对单元格内容的取值结果,但是它们之间并没有明确的依赖关系,因此使用 `SheetInterceptorService` 来实现这些功能是比较合适的。++如果一个功能明确地依赖其他功能,例如公式需要在下拉填充或复制粘贴功能被调用时做一些操作,那么公式模块应该直接依赖下拉填充和复制粘贴模块,而不是通过 `SheetInterceptorService` 来实现。diff --git a/apps/docs/docs/tutorial/plugins/sheet/ui-sheets.md b/apps/docs/docs/tutorial/plugins/sheet/ui-sheets.mddeleted file mode 100644index 9df06d774a..0000000000--- a/apps/docs/docs/tutorial/plugins/sheet/ui-sheets.md+++ /dev/null@@ -1,12 +0,0 @@-----sidebar_position: 2------# @univerjs/ui-sheets--ui-plugin-sheets 提供了 sheet 的 UI,包括:--* sheet 快捷键-* 复制粘贴-* sheet 的 UI 组件-* 单元格编辑器diff --git a/apps/docs/docs/tutorial/roadmap.md b/apps/docs/docs/tutorial/roadmap.mdindex 1c1191cb74..46cabce012 100644--- a/apps/docs/docs/tutorial/roadmap.md+++ b/apps/docs/docs/tutorial/roadmap.md@@ -4,8 +4,14 @@ sidebar_position: 9# 路线图+这里是 Univer 后续的开发计划。++你可以通过 Feature Request 向我们提交你的需求,请参考[贡献指南](/docs/tutorial/contributing),我们会结合社区的反馈调整开发计划。+## 2024 Q1### Univer Sheet### Univer Doc++## 2024 Q2\ No newline at end of filediff --git a/apps/docs/docs/tutorial/specs.md b/apps/docs/docs/tutorial/specs.mdindex 3e1fb34b6b..24fac08354 100644--- a/apps/docs/docs/tutorial/specs.md+++ b/apps/docs/docs/tutorial/specs.md@@ -4,21 +4,59 @@ sidebar_position: 3# 功能一览-Univer 致力于为用户实现完整的办公文档解决方案,以下是我们目前已经实现的产品和特性。想要了解后续的开发计划,请参考[路线图](/docs/tutorial/roadmap)。你也可以通过 Feature Request 的方式提交你的需求,请参考[贡献指南](/docs/tutorial/contributing)。+Univer 致力于为用户实现完整的办公文档解决方案,以下是我们目前已经实现的产品和特性。++想要了解后续的开发计划,请参考[路线图](/docs/tutorial/roadmap)。你也可以通过 Feature Request 的方式提交你的需求,请参考[贡献指南](/docs/tutorial/contributing),我们会结合社区的反馈调整开发计划。## 通用能力-* 撤消重做-* 复制粘贴+### 编辑操作++- 撤消、重做+- 复制粘贴++### 浏览++- 基于 Canvas,支持多种文档类型的高性能渲染引擎+- 滚动和缩放++### UI++- 可配置的工作区,包括标题栏、工具栏、侧边栏、状态栏、右键菜单等+- 跨操作系统的快捷键支持+- 快捷键面板## Univer Sheet### 编辑操作-* 单元格编辑-* 下拉填充+- 新建、删除、移动子表+- 单元格样式:加粗、斜体、下划线、删除线、字体、字号、字体颜色、背景颜色、边框样式、对齐方式、文字旋转+- 合并单元格:合并和取消合并单元格,按照不同的方向合并单元格+- 行列操作:插入、删除与移动行列,修改行高列宽+- 复制粘贴:仅粘贴值、仅粘贴样式、仅粘贴公式、仅粘贴列宽、仅粘贴边框样式+- 清除内容:仅清除内容、仅清除样式、清除全部+- 单元格编辑:单元格编辑器,单元格内富文本+- 插入和删除单元格+- 下拉填充+- 格式刷++### 浏览++- 冻结行列+- 统计栏+ - 求和、最大值、最小值、平均值、计数### 数据与计算-* 公式-* 数字格式+- 公式+ - Fx 栏(公式编辑器)+ - 公式高亮+ - 内置多种公式+ - 基于 Web Worker 的公式计算(可选)+- 数字格式+ - 常规、会计、货币、日期、千分位符++### 自动化++- Uniscript 脚本 (alpha)diff --git a/apps/docs/docusaurus.config.ts b/apps/docs/docusaurus.config.tsindex 1816a41fc5..cfb4bd596d 100644--- a/apps/docs/docusaurus.config.ts+++ b/apps/docs/docusaurus.config.ts@@ -53,25 +53,25 @@ const config: Config = {},plugins: [- ...packages.map((name) => [- 'docusaurus-plugin-typedoc',- {- id: `api/${name}`,- entryPoints: [`../../packages/${name}/src/index.ts`],- tsconfig: `../../packages/${name}/tsconfig.json`,- exclude: ['node_modules/**/*', '**/*+(.spec|.e2e|.test).ts'],- excludePrivate: true,- excludeExternals: true,- excludeInternal: true,- cleanOutputDir: true,- skipErrorChecking: true,- out: `api/${name}`,- sidebar: {- categoryLabel: name,- fullNames: true,- },- },- ]),+ // ...packages.map((name) => [+ // 'docusaurus-plugin-typedoc',+ // {+ // id: `api/${name}`,+ // entryPoints: [`../../packages/${name}/src/index.ts`],+ // tsconfig: `../../packages/${name}/tsconfig.json`,+ // exclude: ['node_modules/**/*', '**/*+(.spec|.e2e|.test).ts'],+ // excludePrivate: true,+ // excludeExternals: true,+ // excludeInternal: true,+ // cleanOutputDir: true,+ // skipErrorChecking: true,+ // out: `api/${name}`,+ // sidebar: {+ // categoryLabel: name,+ // fullNames: true,+ // },+ // },+ // ]),],presets: [@@ -114,12 +114,12 @@ const config: Config = {position: 'left',label: '指南',},- {- type: 'docSidebar',- sidebarId: 'apiSidebar',- position: 'left',- label: 'API',- },+ // {+ // type: 'docSidebar',+ // sidebarId: 'apiSidebar',+ // position: 'left',+ // label: 'API',+ // },{to: 'playground',position: 'left',diff --git a/apps/docs/static/img/design.jpeg b/apps/docs/static/img/design.jpegnew file mode 100644index 0000000000..18ba3e7871Binary files /dev/null and b/apps/docs/static/img/design.jpeg differ