Hi,

Thank you all for your suggestions !
I tested every single suggestion and came to an end of the only one
solution that works (at least until we have a better way to do).

First thing is to put:
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js";
></script>
Directly on the template (yes, I don't like this solution but it's the only
way for now).

Even so, will not work for we Office Add-In.

office.js requires a initialize function and this is the only way to work:

window.onload = function()
{
Office.initialize = function () { };
}

After that, we have access to Word Add-In and I already tested and create a
table directly on the document thru Apache Royale Button :)

I have a lot of ugly tests that I need to clean up now and a lot of
office.js functions to implement.
After that I will open a github project so any one that build a office.js
with Apache Royale without effort :)

Thank you all.
Now I have a lot to do to polish this Add-In.

Maria Jose Esteve <[email protected]> escreveu no dia quarta, 20/10/2021
à(s) 00:10:

> I had not read... "only for external scripts"…. how do you specify @Brian?
>
> Thx
> Hiedra
>
> De: Maria Jose Esteve <[email protected]>
> Enviado el: miércoles, 20 de octubre de 2021 0:52
> Para: [email protected]
> Asunto: RE: [EXTERNAL] Re: RE: Strangled with a new Royale wrapper
> component
>
>
> Hello,
>
> I wish I could get to an "end" point with this problem, although it seems
> it won't be today 😝
>
> I've read Harb's article (with some tests, none of them definitive) and
> I've added, manually, the "defer" attribute to the script where the
> dependencies are added and, to test, also to the body script where the
> App.Start() is launched but nothing seems to work for me. (It only works in
> Firefox, but before including "defer" it also worked 98% of the time)
>
> I keep getting errors when running from localhost:
>
>
>   <script type="text/javascript"
> src="./library/closure/goog/base.js"></script>
>   <script type="text/javascript" defer>
> // generated by Royale
> goog.addDependency('../../../App.js', ['App'],
> ['org.apache.royale.community.beads.models
>
>
> <body>
>   <script type="text/javascript" defer>
>     new App().start();
>   </script>
>
>
>
>
> [cid:[email protected]]
>
>
>
> @Brian, could you specify how you have implemented it in the pom?
>
>
>
> Thx.
>
>
>
> Hiedra.
>
>
>
> -----Mensaje original-----
> De: Brian Raymes <[email protected]<mailto:[email protected]
> >>
> Enviado el: martes, 19 de octubre de 2021 23:42
> Para: [email protected]<mailto:[email protected]>
> Asunto: RE: [EXTERNAL] Re: RE: Strangled with a new Royale wrapper
> component
>
>
>
> What I have done to solve this issue is simply added the "defer" attribute
> to the script block for App.js (using maven-replacer-plugin with maven at
> package time).
>
>
>
> https://www.w3schools.com/tags/att_script_defer.asp
>
>
>
> "The script is downloaded in parallel to parsing the page, and executed
> after the page has finished parsing"
>
>
>
>
>
> Brian
>
>
>
> -----Original Message-----
>
> From: Yishay Weiss <[email protected]<mailto:[email protected]>>
>
> Sent: Tuesday, October 19, 2021 3:43 AM
>
> To: [email protected]<mailto:[email protected]>
>
> Subject: [EXTERNAL] Re: RE: Strangled with a new Royale wrapper component
>
>
>
> > Maybe there is a way to make App.start() wait until all the js are
> loaded?
>
>
>
> FWIW, this has already been discussed [1] extensively. I think the
> conclusion was that in most cases loading order will not be so so
> important, unless a JS lib is called right at the start. The easiest
> workaround for now I think is to time the methods calls carefully, e.g.
> after a user click.
>
>
>
> [1]
> https://lists.apache.org/thread.html/r2f2d8f68936f9bbf061a80a8ff996bc0398e74c6349ad6e28402d4d0%40%3Cdev.royale.apache.org%3E
>
>
>
> On 2021/10/19 10:18:03, Maria Jose Esteve <[email protected]<mailto:
> [email protected]>> wrote:
>
> > Exactly, that's what happens to me when I launch against localhost, the
> js hasn't loaded yet but I don't know how to fix it. I tried monitoring the
> network and I see it loads but App loads before.... In theory the scripts
> inside the "body" shouldn't they run after all the js have loaded?
>
> > I've tried to force it, with a custom loader in js but nothing worked,
>
> > probably because I'm not doing it correctly :( Maybe there is a way to
> make App.start() wait until all the js are loaded?
>
> >
>
> > Hiedra
>
> >
>
> > -----Mensaje original-----
>
> > De: Yishay Weiss <[email protected]<mailto:[email protected]>>
> Enviado el: martes, 19 de
>
> > octubre de 2021 12:05
>
> > Para: [email protected]<mailto:[email protected]>
>
> > Asunto: RE: Strangled with a new Royale wrapper component
>
> >
>
> > *method later
>
> >
>
> > From: Yishay Weiss<mailto:[email protected]>
>
> > Sent: Tuesday, October 19, 2021 1:04 PM
>
> > To: [email protected]<mailto:[email protected]<mailto:
> [email protected]%3cmailto:[email protected]>>
>
> > Subject: RE: Strangled with a new Royale wrapper component
>
> >
>
> > Are you sure "resources/office/office.js" is being loaded in time? IIRC
> you can look in the html elements panel and look for the <script> element.
> Also, keep in mind that loading a script is an async operation so maybe
> calling the method layer will help?
>
> >
>
> > Just some quick thoughts.
>
> >
>
> >
>
> >
>
> > From: Hugo Ferreira<mailto:[email protected]>
>
> > Sent: Tuesday, October 19, 2021 3:48 AM
>
> > To: Apache Royale Development<mailto:[email protected]>
>
> > Subject: Strangled with a new Royale wrapper component
>
> >
>
> > Hi,
>
> >
>
> > I'm strangled with an issue.
>
> > I'm developing a wrapper for office.js (office web add-In).
>
> >
>
> > I have this file OfficeAddIn.as in src root folder with the following
> content:
>
> >
>
> > package
>
> > {
>
> > import org.apache.royale.events.EventDispatcher;
>
> >
>
> > /**
>
> > * @externs
>
> > */
>
> > COMPILE::JS
>
> > public class OfficeAddIn extends EventDispatcher {
>
> > /**
>
> > * <inject_script>
>
> > * var script = document.createElement("script");
>
> > * script.setAttribute("src", "resources/office/office.js");
>
> > * document.head.appendChild(script);
>
> > * </inject_script>
>
> > */
>
> > public function OfficeAddIn(){}
>
> >
>
> > public static function writeData():void {} } }
>
> >
>
> > At runtime when I run the writeData method from actionscript code, I
>
> > get the following error: ReferenceError: Can't find variable:
>
> > OfficeAddIn
>
> >
>
> > It's not my first Royale wrapper and I copied from the first one.
>
> >
>
> > Thanks in advance,
>
> > Hugo.
>
> >
>
> >
>
> >
>

Reply via email to