Document API
The Document API lists the methods and events a plugin can use when working with a text document in ONLYOFFICE Docs. To work with the document content directly, such as paragraphs and tables, run Office API code in callCommand. See Document API.
Methods
The following table lists the available methods.
| Method | Returns | Description |
|---|---|---|
| AcceptReviewChanges | None | Accepts review changes. |
| AddAddinField | AddinFieldData | Creates a new addin field with the data specified in the request. |
| AddComment | string | null | Adds a comment to the document. |
| AddContentControl | ContentControl | Adds an empty content control to the document. |
| AddContentControlCheckBox | None | Adds an empty content control checkbox to the document. |
| AddContentControlDatePicker | None | Adds an empty content control datepicker to the document. |
| AddContentControlList | None | Adds an empty content control list to the document. |
| AddContentControlPicture | None | Adds an empty content control picture to the document. |
| AddOleObject | None | Adds an OLE object to the current document position. |
| AnnotateParagraph | None | Adds annotations to the specified paragraph. |
| CanRedo | boolean | Checks if it possible to revert the user's last undone action. |
| CanUndo | boolean | Checks if it is possible to undo the user's last action. |
| ChangeComment | None | Changes the specified comment. |
| ChangeOleObject | None | Changes the OLE object with the InternalId specified in OLE object data. |
| ChangeOleObjects | None | Changes multiple OLE objects with the InternalIds specified in OLE object data. |
| CoAuthoringChatSendMessage | None | Sends a message to the co-authoring chat. |
| ConvertDocument | string | Converts a document to Markdown or HTML text. |
| EditOleObject | None | Edits an OLE object in the document. |
| EndAction | None | Specifies the end action for long operations. |
| FocusEditor | None | Returns focus to the editor. |
| GetAllAddinFields | AddinFieldData[] | Returns all addin fields from the current document. |
| GetAllComments | comment[] | Returns all the comments from the document. |
| GetAllContentControls | ContentControl[] | Returns information about all the content controls that have been added to the page. |
| GetAllForms | ContentControl[] | Returns information about all the forms that have been added to the document. |
| GetAllOleObjects | OLEObjectData[] | Returns all OLE object data for objects which can be opened by the specified plugin. |
| GetCurrentAddinField | AddinFieldData | Returns the current addin field from the document. |
| GetCurrentBookmark | string | null | Returns the current bookmark. |
| GetCurrentContentControl | string | Returns an identifier of the selected content control (i.e. the content control where the mouse cursor is currently positioned). |
| GetCurrentContentControlPr | ContentControlProperties | Returns the current content control properties. |
| GetCurrentSentence | string | Returns the current sentence. |
| GetCurrentWord | string | Returns the current word. |
| GetDocumentLang | string | Returns the document language. |
| GetFields | string[] | Returns all fields as a text. |
| GetFileHTML | string | Returns file content in the HTML format. |
| GetFileToDownload | string | Returns the current file to download in the specified format. |
| GetFontList | FontInfo[] | Returns the fonts list. |
| GetFormValue | null | string | boolean | Returns a value of the specified form. |
| GetFormsByTag | ContentControl[] | Returns information about all the forms that have been added to the document with specified tag. |
| GetImageDataFromSelection | ImageData | Returns the image data from the first of the selected drawings. |
| GetInstalledPlugins | PluginData[] | Returns all the installed plugins. |
| GetMacros | Macros | Returns the document macros. |
| GetSelectedContent | string | Returns the selected content in the specified format. |
| GetSelectedOleObjects | OLEProperties[] | Returns an array of the selected OLE objects. |
| GetSelectedText | string | Returns the selected text from the document. |
| GetSelectionType | SelectionType | Returns the type of the current selection. |
| GetVBAMacros | string | null | Returns all VBA macros from the document. |
| GetVersion | string | Returns the editor version. |
| InputText | None | Inserts text into the document. |
| InsertAndReplaceContentControls | ContentControlProperties[] | Inserts the content control containing data. |
| InsertOleObject | None | Inserts the OLE object at the current document position. |
| InstallPlugin | object | Installs a plugin using the specified plugin config. |
| IsEditingOFormMode | boolean | Checks if the document is in the editing OForm mode. |
| IsFillingFormMode | boolean | Checks if the document is in the filling form mode. |
| IsFillingOFormMode | boolean | Checks if the document is in the filling OForm mode. |
| IsFormSigned | boolean | Checks whether the specified form has been digitally signed. |
| MouseMoveWindow | None | Sends an event to the plugin when the mouse button is moved inside the plugin iframe. |
| MouseUpWindow | None | Sends an event to the plugin when the mouse button is released inside the plugin iframe. |
| MoveCursorOutsideField | None | Moves the cursor outside a field to the position before or after it. |
| MoveCursorToContentControl | None | Moves a cursor to the specified content control. |
| MoveCursorToEnd | None | Moves a cursor to the end of the current editing area (document body, footer/header, footnote, or autoshape). |
| MoveCursorToField | None | Moves the cursor to the beginning or end of a field. |
| MoveCursorToStart | None | Moves a cursor to the beginning of the current editing area (document body, footer/header, footnote, or autoshape). |
| MoveToComment | None | Moves a cursor to the specified comment. |
| MoveToNextReviewChange | None | Navigates through the review changes. |
| OnDropEvent | None | Implements the external drag&drop emulation. |
| OnEncryption | None | Encrypts the document. |
| OpenFile | None | Opens a file with fields. |
| PasteHtml | None | Pastes text in the HTML format into the document. |
| PasteText | None | Pastes text into the document. |
| PutImageDataToSelection | None | Replaces the first selected drawing with the image specified in the parameters. |
| Redo | None | Reverts the user's last undone action. |
| RejectReviewChanges | None | Rejects review changes. |
| RemoveAddinField | None | Removes the specified add-in field. |
| RemoveAnnotationRange | None | Remove a specific annotation range from the document. |
| RemoveComments | None | Removes the specified comments. |
| RemoveContentControl | ContentControlParentPr | Removes the currently selected content control retaining all its contents. |
| RemoveContentControls | None | Removes several content controls. |
| RemoveFieldWrapper | None | Removes a field wrapper, leaving only the field content. |
| RemoveOleObject | None | Removes the OLE object from the document by its internal ID. |
| RemoveOleObjects | None | Removes several OLE objects from the document by their internal IDs. |
| RemovePlugin | object | Removes a plugin with the specified GUID. |
| RemoveSelectedContent | None | Removes the selected content from the document. |
| ReplaceCurrentSentence | None | Replaces the current sentence with the specified string. |
| ReplaceCurrentWord | None | Replaces the current word with the specified string. |
| ReplaceTextSmart | boolean | Replaces each paragraph (or text in cell) in the select with the corresponding text from an array of strings. |
| SearchAndReplace | None | Finds and replaces the text. |
| SearchNext | boolean | Finds and selects the next occurrence of the text starting at the current position. |
| SelectAddinField | None | Selects the specified add-in field. |
| SelectAnnotationRange | None | Selects text in a document using a given annotation. |
| SelectContentControl | None | Selects the specified content control. |
| SelectOleObject | None | Selects the specified OLE object. |
| SetDisplayModeInReview | None | Sets the display mode for track changes. |
| SetEditingRestrictions | None | Sets the document editing restrictions. |
| SetFormValue | None | Sets a value to the specified form. |
| SetMacros | None | Sets macros to the document. |
| SetParagraphHtml | None | Replaces all content of the specified paragraph with the content parsed from the given HTML string. |
| SetPluginsOptions | None | Configures plugins from an external source. |
| SetProperties | None | Sets the properties to the document. |
| ShowButton | None | Shows or hides buttons in the header. |
| ShowError | None | Shows an error/warning message. |
| ShowInputHelper | None | Shows the input helper. |
| StartAction | None | Specifies the start action for long operations. |
| UnShowInputHelper | None | Unshows the input helper. |
| Undo | None | Undoes the user's last action. |
| UpdateAddinFields | None | Updates the addin fields with the specified data. |
| UpdatePlugin | object | Updates a plugin using the specified plugin config. |
Events
The following table lists the available events.
| Event | Description |
|---|---|
| onAddComment | The function called when a comment is added to the document with the AddComment method. |
| onBlurAnnotation | The function called when an annotation loses focus. |
| onBlurContentControl | The function called to show which content control has been blurred. |
| onChangeCommentData | The function called when the specified comment is changed with the ChangeComment method. |
| onChangeContentControl | The function called to show which content control has been changed. |
| onChangeCurrentPage | The function called when the current page has changed. |
| onChangeRestrictions | The function called when the restrictions in the editor are changed. |
| onClick | The function called when the user clicks the element. |
| onClickAnnotation | The function called when the user clicks an annotation. |
| onDocumentContentReady | The function called when the document is completely loaded. |
| onEnableMouseEvent | The function called to turn the mouse or touchpad events on/off. |
| onExternalMouseUp | The function called when the mouse button is released outside the plugin iframe. |
| onFocusAnnotation | The function called when an annotation receives focus. |
| onFocusContentControl | The function called to show which content control has been focused. |
| onHideContentControlTrack | The function called when the content control loses focus in the document. |
| onInsertOleObjects | The function called when one or more OLE objects are inserted into the document. |
| onParagraphText | The function called when the paragraph text is updated in the document. |
| onRemoveComment | The function called when the specified comment is removed with the RemoveComments method. |
| onShowContentControlTrack | The function called when the content control receives focus and its track appears. |
| onSubmitForm | The function called when the user clicks the "Complete & Submit" button. |
| onTargetPositionChanged | The function called when the target position in the editor is changed. |