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
feat: add disable status to doc (#1622)
Ran Luob03c70764bcf
diff --git a/packages/core/src/types/interfaces/i-document-data.ts b/packages/core/src/types/interfaces/i-document-data.tsindex 1b2325f5d9..9b7941cddb 100644--- a/packages/core/src/types/interfaces/i-document-data.ts+++ b/packages/core/src/types/interfaces/i-document-data.ts@@ -37,7 +37,7 @@ export interface IDocumentData extends IReferenceSource, IExtraModelData {settings?: IDocumentSettings;// The type of data depends on how the plug-in is definedresources?: Array<{ id?: string; name: string; data: string }>;-+ disabled?: boolean;}export interface IReferenceSource {diff --git a/packages/docs-ui/src/controllers/doc-render.controller.ts b/packages/docs-ui/src/controllers/doc-render.controller.tsindex 2b6ba0b9ae..3c5c15ac43 100644--- a/packages/docs-ui/src/controllers/doc-render.controller.ts+++ b/packages/docs-ui/src/controllers/doc-render.controller.ts@@ -143,6 +143,13 @@ export class DocRenderController extends RxDisposable {return;}+ // TODO: `disabled` is only used for read only demo, and will be removed in the future.+ const disabled = !!skeleton.getViewModel().getDataModel().getSnapshot().disabled;++ if (disabled) {+ return;+ }+skeleton.calculate();if (this._editorService.isEditor(unitId)) {diff --git a/packages/docs/src/commands/mutations/core-editing.mutation.ts b/packages/docs/src/commands/mutations/core-editing.mutation.tsindex 1ece893abf..c3d0f64aa1 100644--- a/packages/docs/src/commands/mutations/core-editing.mutation.ts+++ b/packages/docs/src/commands/mutations/core-editing.mutation.ts@@ -75,7 +75,10 @@ export const RichTextEditingMutation: IMutation<IRichTextEditingMutationParams,throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${unitId}`);}- if (actions.length === 0) {+ // TODO: `disabled` is only used for read only demo, and will be removed in the future.+ const disabled = !!documentDataModel.getSnapshot().disabled;++ if (actions.length === 0 || disabled) {// The actions' length maybe 0 when the mutation is from collaborative editing.// The return result will not be used.return {