PostMessage API
PostMessage API is used to interact with parent frame when Collabora Online’s browser part is enclosed in one. This is useful for hosts wanting to integrate Collabora Online in them.
This API is mostly based on WOPI specification with few extensions/modifications. All messages sent are in this form :
{
"MessageId": "<MessageId>",
"SendTime": "<Timestamp when message is sent>",
"Values": {
"<key>": "<value>"
}
}
SendTime
is the timestamp returned by browsers’ Date.now(). The post messages sent from the WOPI host should also be in same form.
It is to be noted that as mentioned in WOPI specs, Collabora Online frame will ignore all post messages coming from the host frame if Host_PostmessageReady has not been received. Further, since for embedding Collabora Online as an iframe WOPI implementation is a must, it is required that PostMessageOrigin
property is present in WOPI host’s CheckFileInfo response. Otherwise, no post messages will be emitted.
Initialization
MessageId |
Values |
Description |
---|---|---|
|
Status: <String>
DocumentLoadedTime: <Timestamp>
|
If status is Supported values are: Accompanying keys: |
MessageId |
Values |
Description |
---|---|---|
|
See WOPI docs for detail. |
Query
You can query data from the editor using post message API. All responses are returned with query’s MessageId suffixed with ‘_Resp’ as shown below Getters
WOPI Host to Editor
MessageId |
Values |
Description |
---|---|---|
|
Queries the editor for
currently active views of
the document. Response is
returned in form of
|
|
|
Queries the editor for all
the supported export
formats for currently
opened document. Response
is returned in form of
|
|
|
Queries the editor for
current user activity state
(is idle or active).
Response is returned in
form of
|
Getters response
Editor to WOPI host
MessageId |
Values |
Description |
---|---|---|
|
ViewId: <Number>
UserId: <String>
UserName: <String>
Color: <Number>
ReadOnly: <Boolean>
IsCurrentView: <Boolean>
|
Give details of all current views when queried using Get_Views |
|
Label: <String>
Format: <String>
|
Response to query Label would contain a localized string explaining about the format. Format is the file extension of the format which is required while requesting export of the document. |
|
State: <String>
Elapsed: <Number>
|
Response to query State would contain a non-localized string with the activity state (“active” or “idle”). Elapsed is the number of seconds since the last activity of the user. |
Session Management
WOPI Host to editor
MessageId |
Values |
Description |
---|---|---|
|
|
Remove the session. |
|
|
Reset the access token. The new one will be used from now on. |
Editor to WOPI Host
MessageId |
Values |
Description |
---|---|---|
|
ViewId: <Number>
UserId: <String>
UserName: <String>
Color: <Number>
ReadOnly:<Boolean>
Deprecated: true;
|
A new member is added. |
|
ViewId: <Number>
Deprecated: true;
|
View with This message is deprecated, instead implement just
handling of |
|
Reason: <String>
|
The session has closed.
The reason fied details the origin:
|
|
See
|
Complete information about the currently connected views. |
|
Indicates that user become idle.
It happens after longer inactivity time defined
in the configuration file |
|
|
Indicates that user become active again. It happens after user clicked on the idle screen. |
Actions
WOPI host to editor
MessageId |
Values |
Description |
---|---|---|
|
DontTerminateEdit: <boolean>
DontSaveIfUnmodified: <boolean>
Notify: <boolean>
ExtendedData: <String>
|
Saves the document.
|
|
Filename: <String>
Notify: <boolean>
|
Creates copy of the document with given Filename.
|
|
Follow: <Boolean>
ViewId: <Number>
|
Turn on or off the follow user feature. When When |
|
Closes the document. |
|
|
Allows closing documents before they are completely loaded. |
|
|
Switch to fullscreen mode. |
|
|
StartSlideNumber: <Number>
CurrentSlide: <Boolean>
|
Start the presentation in Impress.
|
|
Prints the document. |
|
|
Format: <String>
Notify: <boolean>
|
Downloads the document in format specified by |
|
url: <String>
|
Downloads image from the url and inserts it to the document. This is usually the response to a successful UI_InsertGraphic |
|
url: <String>
|
Downloads multimedia from the url and inserts it to the document. This may be the response to a successful UI_InsertFile. Since 24.04.10. |
|
Label: <String>
|
Shows an in-progress overlay, just like what appears when saving the document, with the given Label. |
|
Hides any in-progress overlay, if present. |
|
|
Mode: 'classic' | 'notebookbar'
|
Changes the user interface: Classic Toolbar or Notebookbar. |
|
Mimetype: <string>
Data: <string>
|
Pastes the data directly to the document bypassing the internal paste mechanism.
Example: |
WOPI editor to host (Response)
MessageId |
Values |
Description |
---|---|---|
|
success: <boolean>
result: <string>
errorMsg: <string>
errorType: <string>
|
Acknowledgment when load finishes.
|
|
success: <boolean>
result: <string>
errorMsg: <string>
fileName: <string>
|
Acknowledgment when save finishes. This response is only
emitted if
|
|
FollowedViewId: <Number>
IsFollowUser: <Boolean>
IsFollowEditor: <Boolean>
|
Notification about current following state.
If both |
|
Mode: <string>
|
Notification about UI mode switch (Tabbed/Compact)
|
Version Restore
WOPI host to editor
MessageId |
Values |
Description |
---|---|---|
|
Status: <string>
|
The Only possible value is This message is sent by the host before actually restoring the document and after user showed the intent to restore the document. This is so such that if there are any unsaved changes, Online can save them to storage before document is restored. |
Editor to WOPI host
MessageId |
Values |
Description |
---|---|---|
|
Status: <string>
|
This is the reply for the
Possible values for It means that host can go ahead with restoring the document to an earlier revision. |
Note
These messages are only emitted if App_LoadingStatus contains VersionStates in Features. Otherwise, host can immediately restore the version to earlier revision.
Miscellaneous
WOPI host to editor
MessageId |
Values |
Description |
---|---|---|
id: <string>
imgurl: <string>
hint: <string>
accessKey: <string>
mobile: <boolean>
tablet: <boolean>
label: <string>
insertBefore: <string>
unoCommand: <string>
|
Inserts a button to the top toolbar. It responds with Clicked_Button post message
event on which hosts can react accordingly (except when the This is used by accelerator definitions class. Users can press alt or alt+shift and use this key.
One should be careful to not introduce conflicting access keys.
|
|
|
id: <string>
|
Hides a button from the toolbar.
|
|
id: <string>
|
Hides a button from the toolbar.
|
|
id: <string>
|
Removes a button from the toolbar.
|
|
id: <string>
|
Hide the UI for a command. This include the menu items and toolbar buttons.
|
|
id: <string>
|
Show the UI for a command. The reverse of
|
|
Hide the notebook bar buttons. This is equivalent to double clicking on the name. Click on the name will show it again. This also hide the button strip in the classic UI. |
|
|
Show the notebook bar buttons. This is the equivalent of clicking on the name. This also show the button strip in classic UI. |
|
|
Hides the status bar |
|
|
Shows the status bar |
|
|
id: <string>
|
Removes an element from the status bar. |
|
Hides the menu bar. |
|
|
Shows the menu bar. |
|
|
This restores focus to the application, activating it, and removing any overlay indicating quiescence, and re-connecting to the server if necessary. Useful after leaving the application for a lengthy period, or when wanting to restore browser focus after presenting an overlaid dialog. |
|
|
Hides the horizontal document ruler (Writer only) |
|
|
Shows the horizontal document ruler (Writer only) |
|
|
id: <string>
|
Hides an item from the menu.
|
|
id: <string>
|
Shows an item from the menu. id` is the item ID as defined in the browser/src/control/Control.Menubar.js. |
|
id: <string>
|
Show the sidebar. By default it will show the last one before it was hidden.
Since 24.04.10. |
|
Hide the sidebar. Since 24.04.10. |
|
|
action: <string>
disable: <Boolean>
|
Disable the default handler and action for a UI command.
|
|
Command: <string>
Args: <object>
|
Send an UNO command to the editor. See examples in browser/html/framed.doc.html. |
|
list:
[{
type: <identifier>,
msg: <string>
},
{
type: <identifier>,
msg: <string>
}.....]
|
Send list to override error messages available in the editor. list:
[{
type: 'loadfailed',
msg: 'your custom msg'
}]
To get list of error messages available to override, please checkout browser/src/errormessages.js. |
|
Indicate that the device uses on screen keyboard (like a tablet). This is useful if the detection failed to identify the device is a tablet. This is useful if the device environment is unusual, and should only be used with great caution. |
|
|
Indicate that the device is not a tablet. This is the opposite of |
Finding status bar element IDs
Status bar button IDs are defined in the onDocLayerInit
function in
Control.StatusBar.js.
Note that they usually don’t change but there is no guarantee that they
are stable.
Editor to WOPI host
MessageId |
Values |
Description |
---|---|---|
id: <string>
|
This event is emitted when the custom button added via Insert_Button is clicked. |
|
|
Type: 'print'|'slideshow'|'export'
URL: <string>
|
This event is emitted when the user chooses ‘Print’ or ‘Show slideshow’ or ‘Download As |
|
Requests WOPI host to open a popup window where user can pick another document to view & edit. |
|
|
Requests WOPI host to open a new browser tab and create a new
document. The document type is passed as |
|
|
Args: {format: '<extension>' }
|
Requests WOPI host to create appropriate UI, so
that the user can choose path and File
name for creating a copy of the current
file. Response to this query is sent via Optional arguments: file extension. When this parameter is passed a dropdown appears and the newly saved file is loaded in the integration instead of downloaded. |
|
Requests WOPI host to open a popup window where user can
pick an image to insert.
A successful pick would lead to the WOPI host sending a
|
|
|
callback: <string>
mimeTypeFilter: <array_of_strings>
|
Requests WOPI host to open a popup window where user can pick a file to insert. A successful pick would lead to the WOPI host sending a postMessage defined in ‘callback’ argument back. Required arguments:
Since 24.04.10. |
|
Notifies WOPI host that the user clicked on the ‘cancel’ option when opening a password protected file, instead of providing the password to decrypt it. |
|
|
Notifies WOPI host that the user clicked a hyperlink
and confirmed they really want to leave the document to
follow the hyperlink. This is especially useful for
integrations that embed Collabora Online into an The integration using this most probably also wants to
trigger the |
|
|
Notification to update the modified status of the document.
Note that this notification may be published without a
change from the prior value, so care must be taken to check
the |
Calling Python scripts
WOPI host to editor
MessageId |
Values |
Description |
---|---|---|
|
script. The Values
ScriptFile: <string>
Function: <string>
Values: <object>
|
Calls a Python parameter contains an object with named parameters that are passed to the script. |
Editor to WOPI host
MessageId |
Values |
Description |
---|---|---|
|
commandName: <string>
Values: <object>
|
Returns the result The URL of the script called
|
Mentions
Note
Mentions are only working in Writer for now
Editor to WOPI host
MessageId |
Values |
Description |
---|---|---|
|
type: autocomplete
text: <string>
|
When user starts typing with “@”, CollaboraOnline will send this postMessage with partial text followed by “@” to get the list of usernames from the integrator |
type: selected
username: <string>
|
When user selects the a username from list given by the integrator this message gets fired |
WOPI host to editor
MessageId |
Values |
Description |
---|---|---|
|
list: [{
username: "example-username1",
profile: "link-to-the-profile"
},
{
username: "example-username2",
profile: "link-to-the-profile"
}.....]
|
Based on UI_Mention message of type autocomplete,
integrator should send this message with list of
user object. Each user object contains
|