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.

docs: add formula and rpc docs

wzhudev6a6f09b6e8e8
diff --git a/packages/rpc/src/services/remote-instance/remote-instance.service.ts b/packages/rpc/src/services/remote-instance/remote-instance.service.ts
index 9b8b2cbde7..c05a4f5704 100644
--- a/packages/rpc/src/services/remote-instance/remote-instance.service.ts
+++ b/packages/rpc/src/services/remote-instance/remote-instance.service.ts
@@ -8,20 +8,21 @@ import {
} from '@univerjs/core';
import { createIdentifier } from '@wendellhu/redi';
-// TODO@wzhudev: add some notes here. Even I cannot understand the code in 10 seconds after days.
-
export interface IRemoteSyncMutationOptions extends IExecutionOptions {
/** If this mutation is executed after it was sent from the peer univer instance. */
fromSync?: boolean;
}
export const RemoteSyncServiceName = 'univer.remote-sync-service';
-/** This service is provided by the primary Univer.. */
+/**
+ * This service is provided by the primary Univer.
+ *
+ * Replica Univer could call this service to update mutations back to the primary Univer.
+ */
export const IRemoteSyncService = createIdentifier<IRemoteSyncService>(RemoteSyncServiceName);
export interface IRemoteSyncService {
syncMutation(params: { mutationInfo: IMutationInfo }): Promise<boolean>;
}
-
export class RemoteSyncPrimaryService implements IRemoteSyncService {
constructor(@ICommandService private readonly _commandService: ICommandService) {}
@@ -34,18 +35,18 @@ export class RemoteSyncPrimaryService implements IRemoteSyncService {
}
export const RemoteInstanceServiceName = 'univer.remote-instance-service';
-/** This service is provided by the replica Univer. */
+/**
+ * This service is provided by the replica Univer.
+ *
+ * Primary univer could call this service to init and dispose univer business instances
+ * and sync mutations to replica univer.
+ */
export const IRemoteInstanceService = createIdentifier<IRemoteInstanceService>(RemoteInstanceServiceName);
export interface IRemoteInstanceService {
createInstance(params: { unitID: string; type: DocumentType; snapshot: IWorkbookData }): Promise<boolean>;
disposeInstance(params: { unitID: string }): Promise<boolean>;
syncMutation(params: { mutationInfo: IMutationInfo }): Promise<boolean>;
}
-
-/**
- * This service runs on replica Univer and is responsible for syncing data
- * between the replica and the primary Univer.
- */
export class RemoteInstanceReplicaService implements IRemoteInstanceService {
constructor(
@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
diff --git a/packages/sheets-plugin-formula/docs/zh/model.md b/packages/sheets-plugin-formula/docs/zh/model.md
new file mode 100644
index 0000000000..67ec47ff0c
--- /dev/null
+++ b/packages/sheets-plugin-formula/docs/zh/model.md
@@ -0,0 +1,5 @@
+# 公式的模型层设计
+
+公式字符串并不像其他的功能一样作为插件 model 单独存储,而是直接存储在 `ICellData` 的 `f` 字段中,并且在 `setRangeValues` mutation 中对公式内容进行处理。
+
+把公式完全从内核中抽离出来可能是不适当的,例如不好处理并发编辑时,写入公式和写入普通 value 冲突的问题。