Execute JavaScript in compose window

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Execute JavaScript in compose window

guiraud.sabrina
Hi I'm trying to write an Asciidoctor plugin and until now I can format my mail with asciidoctor.js and display it in the compose windows.

To use some special syntax highlighting, I need to run some javascript from the compose windows. Is it possible, does the compose window can interpret javascript?

thank you

Hi I'm trying to write an Asciidoctor plugin and until now I can format my mail with asciidoctor.js and display it in the compose windows.

To use some special syntax highlighting, I need to run some javascript from the compose windows. Is it possible, does the compose window can interpret javascript?

thank you
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Execute JavaScript in compose window

gNeandr-13
Not totally clear what/how you want to achieve.
AFAIU you try to enter special codes in the compose window and expect to
"interpret" that. The only way I see, you need to write an addon
accessing the content of the compose window, interpret with your code
and write the new content back. So you need an addon with a special
key/button to start some js op.


On 21.12.2017 11:53, [hidden email] wrote:

> Hi I'm trying to write an Asciidoctor plugin and until now I can format my mail with asciidoctor.js and display it in the compose windows.
>
> To use some special syntax highlighting, I need to run some javascript from the compose windows. Is it possible, does the compose window can interpret javascript?
>
> thank you
>
> Hi I'm trying to write an Asciidoctor plugin and until now I can format my mail with asciidoctor.js and display it in the compose windows.
>
> To use some special syntax highlighting, I need to run some javascript from the compose windows. Is it possible, does the compose window can interpret javascript?
>
> thank you
>

_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Execute JavaScript in compose window

guiraud.sabrina
I enter some asciidoctor code in the compose window

[source, javascript]
----
if(true)
{
 return true;
}
----

I click on my addon button then the text is processed to html 5 I can then replace my text with this pretty text.
BUT in the Html5 there is a script:
<script>hljs.initHighlighting()</script>
 that starts and replaces on the fly the dom with code highlighted with highlight.js

my problem is that this code does not start as TB seems to block javascript execution in composewindow.

I've found a solution for now: Parse the Html rendered with asciidoctor and use the hljs.highlightAuto(block.textContent) capability to render programatically text, I would call this after calling asciidoctor rendering.

I've heard that there could be a javascript engine with the mail template but not sure what it is.
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Execute JavaScript in compose window

Joshua Cranmer 🐧
In reply to this post by guiraud.sabrina
On 12/21/2017 5:53 AM, [hidden email] wrote:
> Hi I'm trying to write an Asciidoctor plugin and until now I can  > format my mail with asciidoctor.js and display it in the compose >
windows. > > To use some special syntax highlighting, I need to run some
 > javascript from the compose windows. Is it possible, does the compose
 > window can interpret javascript?

Some technical details: the message text in the compose window is an
independent docshell (essentially, an <iframe>) that disables JS. It's
possible for addons to manipulate the contents of the iframe, and you
can certainly insert arbitrary JS in the chrome context of the window
itself, but you can't insert JS into the message text itself and have it
run.


--
Joshua Cranmer
Thunderbird and DXR developer
Source code archæologist

_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Execute JavaScript in compose window

guiraud.sabrina
indeed, I agree with you

So I parse the document from my XUL JS and command highlight JS programmatically:

codes = doc.getElementsByTagName('code');
for(var i=0;i<codes.length;i++){
        var result = hljs.highlightAuto(codes.item(i).textContent);
        console.log(result);
        codes.item(i).innerHTML=result.value;
}

thx
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird