Hi, there were questions about using UNO commands in our code. I answered on our Telegram channel but I decided to create this post to make it archived:
-
What is UNO command?
UNO commands are commands to trigger some actions/dialogs inside LibreOffice, our “core”. Example command:.uno:SetOptimalRowHeight
-
How to send UNO command to the server?
You can call it on a “map” object which is accessible from many places:map.sendUnoCommand('.uno:SetOptimalRowHeight');
-
How to get UNO command result?
Here is an example of catching a command state updates:
online/Control.Toolbar.js at 585974e3715c56897093d8c1ecd0d1c2f65b4631 · CollaboraOnline/online · GitHub
map.on('commandresult', onCommandResult);
registers a callback which will receive notification about all command results.
If you want to query command state only one time, there is a helper already:
map['stateChangeHandler'].getItemValue('.uno:DeletePage');
-
Where is any UNO commands documentation?
You need to look into LibreOffice codebase and documentation. Example:
https://wiki.documentfoundation.org/Development/DispatchCommands
This is a list of UNO commands with short description, under “SDI” link you can find declaration with required parameters and result type.