Feature add Send_UNO_Command postMessage

Signed-off-by: Pouya Mozaffar Magham <pouya.mozafar@gmail.com>
Change-Id: I465293b1d2d4bdc25b237a8a7054bf428543464b
This commit is contained in:
Pouya Mozaffar Magham 2023-03-26 08:40:42 +03:30 committed by pedropintosilva
parent 6ddabcb792
commit 75219b57d3
2 changed files with 32 additions and 0 deletions

View file

@ -30,6 +30,30 @@
window.frames[0].postMessage(JSON.stringify(msg), '*');
}
function sendBoldUNOCommand() {
post({'MessageId': 'Send_UNO_Command',
'Values': { 'Command': '.uno:Bold' }
});
}
function sendInsertBookMarkUNOCommand() {
post({'MessageId': 'Send_UNO_Command',
'Values': {
'Command': '.uno:InsertBookmark',
'Args': {
Bookmark: {
type: 'string',
value: 'Test Insert BookMark'
},
BookmarkText: {
type: 'string',
value: 'Text of the Test Insert BookMark'
}
}
}
});
}
function insertText(text) {
post({'MessageId': 'CallPythonScript',
'SendTime': Date.now(),
@ -310,6 +334,12 @@
<button onclick="ShowNotebookbar(true); return false;">Tabbed Toolbar</button>
</form>
<h3>Send UNO Commands</h3>
<form id="menubar-toggle">
<button onclick="sendBoldUNOCommand(); return false;">Send Bold UNO Command (and example without args)</button>
<button onclick="sendInsertBookMarkUNOCommand(); return false;">Send InsertBookmark UNO Command (an example with args)</button>
</form>
<h3>Document frame</h3>
<h4>If the frame fails to load click <a id="link">here and accept security bits</a></h4>
<h4>If the frame still fails to load ensure you have <code>localhost:*</code> included in your <code>net.frame_ancestors</code> in coolwsd.xml</h4>

View file

@ -319,6 +319,8 @@ L.Map.WOPI = L.Handler.extend({
else if (msg.MessageId === 'Insert_Button' &&
msg.Values && msg.Values.id && msg.Values.imgurl) {
this._map.uiManager.insertButton(msg.Values);
} else if (msg.MessageId === 'Send_UNO_Command' && msg.Values && msg.Values.Command) {
this._map.sendUnoCommand(msg.Values.Command, msg.Values.Args || '');
}
else if (msg.MessageId === 'Disable_Default_UIAction') {
// Disable the default handler and action for a UI command.