From 271734b6ab0705fca51829421952c5109c29a70b Mon Sep 17 00:00:00 2001 From: Pouya Mozaffar Magham Date: Sun, 26 Mar 2023 08:40:42 +0330 Subject: [PATCH] Feature add Send_UNO_Command postMessage Signed-off-by: Pouya Mozaffar Magham Change-Id: I465293b1d2d4bdc25b237a8a7054bf428543464b --- browser/html/framed.doc.html | 30 +++++++++++++++++++++++++++++ browser/src/map/handler/Map.WOPI.js | 2 ++ 2 files changed, 32 insertions(+) diff --git a/browser/html/framed.doc.html b/browser/html/framed.doc.html index 3d606da498fec..32104ded7ea07 100644 --- a/browser/html/framed.doc.html +++ b/browser/html/framed.doc.html @@ -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 @@

UI modification

+

Send UNO Commands

+ +

Document frame

If the frame fails to load click here and accept security bits

If the frame still fails to load ensure you have localhost:* included in your net.frame_ancestors in coolwsd.xml

diff --git a/browser/src/map/handler/Map.WOPI.js b/browser/src/map/handler/Map.WOPI.js index 51ac57899aac8..fd315e2da56b9 100644 --- a/browser/src/map/handler/Map.WOPI.js +++ b/browser/src/map/handler/Map.WOPI.js @@ -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.