FDocumentObjectPermission
Command-backed Edit permission for one stable Document object.
Access
Access through:
Setup
Register @univerjs/docs or a preset that includes it. In plugin mode, import @univerjs/docs/facade. Additional methods below require their listed plugin packages. See Facade setup.
@univerjs/docs
FDocumentObjectPermission.canEdit
Returns the effective Edit result after applying the Document, parent, and object permissions.
canEdit(): booleanReturns
Whether the object is currently editable.
Package: @univerjs/docs · Type definitions
FDocumentObjectPermission.setEditable
Enables or disables editing for this stable Document object.
This changes only the object's Edit point. canEdit() also applies the Document unit and
parent Section or Paragraph ceilings.
setEditable(editable?: boolean): Promise<void>Parameters
editable— Optional. Default:true. Whether object editing is allowed. Defaults to true.
Returns
Resolves after the permission command finishes.
Examples
Restore editing for a paragraph
const document = univerAPI.getActiveDocument()const paragraph = document?.getParagraphs()[0]if (!paragraph) throw new Error('Paragraph not found.')await paragraph.getPermission().setEditable()Types: Promise
Package: @univerjs/docs · Type definitions
FDocumentObjectPermission.setReadOnly
Makes this stable Document object read-only.
setReadOnly(): Promise<void>Returns
Resolves after the permission command finishes.
Examples
const document = univerAPI.getActiveDocument()const section = document?.getSection(0)if (!section) throw new Error('Section not found.')await section.getPermission().setReadOnly()Types: Promise
Package: @univerjs/docs · Type definitions
你觉得这篇文档如何?