From b243751aa08aa2fb491b3165d4a0a02d24aa079b Mon Sep 17 00:00:00 2001 From: Xuan Sang LE Date: Fri, 12 Mar 2021 21:02:55 +0100 Subject: [PATCH] enable focus event in OnlyOffice --- OnlyOffice/README.md | 1 + OnlyOffice/build/release/OnlyOffice.zip | Bin 61091 -> 61645 bytes OnlyOffice/coffees/main.coffee | 23 +++++++++++++++++++++-- OnlyOffice/package.json | 2 +- packages.json | 2 +- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/OnlyOffice/README.md b/OnlyOffice/README.md index 4acccae..4f155e5 100644 --- a/OnlyOffice/README.md +++ b/OnlyOffice/README.md @@ -10,6 +10,7 @@ way to work with multiple documents at the same time. ![https://github.com/lxsang/antosdk-apps/blob/master/OnlyOffice/screenshot.png?raw=true](https://github.com/lxsang/antosdk-apps/blob/master/OnlyOffice/screenshot.png?raw=true) ## Change log +- v 0.1.4a: If the iframe has the same origin with the parent, enable the focus event - v 0.1.3a: Let backend generates document key, compatible with doc.iohub.dev/office - v 0.1.2a: generate document key based on username, file path and modified time - v 0.1.1a: generate document key based on username and file path diff --git a/OnlyOffice/build/release/OnlyOffice.zip b/OnlyOffice/build/release/OnlyOffice.zip index fca0f3d905f833d0c8ae05c3de680238be66be2d..cebcad66d2f813500b8fe33662727f59d64087ae 100644 GIT binary patch delta 1039 zcmZuwO=}ZD7~W*t(yz2ugY<*e={CkJY?iGJ^`mShY7bIMLr-d{WtyF2M>o4+ze17P zn@2(B2eeScix*A(0iLR$H$4{o0;MLsc@&(T4T%lzvO6=+Jnzo)yzjevhx~^xd@Q%f zcl2_>HM?uPj46HHmv)U6>$&p2y3iMoL^9R8{d-ZKg0BWKAB@B}{e2)Hjq6X}W`;N} zGeqv4dDD-bY~IB_QYWV+G8!N4#049cNHYFx+cHx^!ODA%AR%@Bp$~1~&f!AJ)v+VD z;uI+af;f~+rW93GQ?8mw2~${G_c5vz#YyL(=|d-7 zwBdGH$NBXC10}Z+I&jh3^x5Tdn)M~ncZGh)=v0n2uL(C!1`(nPl*s?g%o1LQn33}!=|YxUS=+CHCz^E@4^e}wS~HW|-G z9X1j6p~NPSKj*q*l(W+NZu6tXbDUNE_VZdK0;rZO4Y&@vV zwD){>{Q?LyvY)5%3jd^Faf&`W39?)t4jhsD^|9zdg7i-flbw1mgI-YR$8{oQhhvdw zoC`w(?lIk{y(ZK9?HkJR*zMd`j)P?^8y?Ipo``EDizck6At)U7jyP^*A$xOaK`v>z T#m=q(?xXjkD92qn4px5wjQUH0 delta 483 zcmX^6ka_W4X5IjAW)?065OD5F-Nkr?W*(fiaoq6il z%)s==cgE<>HhQlPvSD(}dugi^N(>AosksF?i6yDU`T^dIOd<@BfB{+UZnz=*oh$RIFgRfj0n=w*OkVRrnvMSrhz9_+oR$dy diff --git a/OnlyOffice/coffees/main.coffee b/OnlyOffice/coffees/main.coffee index 6f6d09b..1fe5a53 100644 --- a/OnlyOffice/coffees/main.coffee +++ b/OnlyOffice/coffees/main.coffee @@ -4,12 +4,23 @@ class OnlyOffice extends this.OS.application.BaseApplication @eid = "id#{Math.random().toString(36).replace(".","")}" main: () -> + @isActive = false @currfile = undefined + @iframe = undefined if @args and @args.length > 0 @currfile = @args[0].path.asFileHandle() @placeholder = @find "editor-area" @placeholder.id = @eid + @on "focus", (e) => + @isActive = true + if @iframe + el = $("#id_viewer_overlay", @iframe) + el = $("#ws-canvas-graphic-overlay", @iframe) if el.length is 0 + el.trigger("click") if el.length > 0 + + @on "blur", (e) => @isActive = false + @find("btn-open-file").onbtclick = (e) => @openFile() @@ -69,10 +80,15 @@ class OnlyOffice extends this.OS.application.BaseApplication @open() editorReady: () -> - console.log $('iframe[name="frameEditor"]', @scheme).contents() + @iframe = $('iframe[name="frameEditor"]', @scheme).contents()[0] + return unless @iframe + $(@iframe).on "mousedown, mouseup, click", (e) => + return if @isActive + @trigger "focus" open: () -> return unless @currfile + @iframe = undefined @exec("token", {file: @currfile.path}) .then (d) => console.log(d) @@ -196,4 +212,7 @@ OnlyOffice.dependencies = [ this.OS.register "OnlyOffice", OnlyOffice this.extensionParams = { url: "https://office.iohub.dev/web-apps/" -} \ No newline at end of file +} +# dirty hack that allow subdomain iframes access each other +# FIXME: may be the domain should be defined by ATOS API +document.domain = "iohub.dev" if document.domain is "os.iohub.dev" diff --git a/OnlyOffice/package.json b/OnlyOffice/package.json index 5ebc5b0..58cc570 100644 --- a/OnlyOffice/package.json +++ b/OnlyOffice/package.json @@ -7,7 +7,7 @@ "author": "Xuan Sang LE", "email": "mrsang@iohub.dev" }, - "version":"0.1.3-a", + "version":"0.1.4-a", "category":"Other", "icon":"icon.png", "mimes":[ diff --git a/packages.json b/packages.json index bfcb6be..5200238 100644 --- a/packages.json +++ b/packages.json @@ -165,7 +165,7 @@ "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/OnlyOffice/README.md", "category": "Other", "author": "Xuan Sang LE", - "version": "0.1.3-a", + "version": "0.1.4-a", "dependencies": [], "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/OnlyOffice/build/release/OnlyOffice.zip" },