Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help: Thunderbird extension to insert html text in editor

67 views
Skip to first unread message

antigoon

unread,
Nov 23, 2006, 10:27:30 PM11/23/06
to
I'm a total extension DOM, XUL, and XHTML newbie.

I'm trying to paste some HTML formatted text at the cursor into Mozilla
Thunderbird email client. And it's not working.

This code works for javascript in the page to modify the current
webpage. I was changing everything in a table cell.
var code =
document.commandDispatcher.focusedWindow.document.getElementsByTagName("td");
for (var i = 0; i < code.length; i++) {
var c = code[i];
var content = c.innerHTML;
content = "<PRE>" + content + "<PRE>";

But it doesn't work on my email editor.

This works in the email editor but it only pastes plain text
var theEditor = GetCurrentEditor();
if (theEditor) theEditor.insertText (theAddress);

GetCurrentEditor seems to be defined here.(Though that may be an older
versin of the code.)
http://www.google.com/codesearch?q=+lang:javascript+GetCurrentEditor+show:-vcIh_b_gXU:IwDpVoT7jIY:MhDPevG6-kw&sa=N&cd=1&ct=rc&cs_p=http://gentoo.osuosl.org/distfiles/xulrunner-1.8.0.1-source.tar.bz2&cs_f=mozilla/editor/ui/composer/content/editorUtilities.js#a0

So I tried this and it didn't do anything.
var theEditor = GetCurrentEditor();
if (theEditor) theEditor.insertHtml(theAddress);

And I tried
var theEditor =
Components.classes["@mozilla.org/editor/htmleditor;1"].getService();
if (theEditor) {

theEditor.QueryInterface(Components.interfaces.nsIHTMLEditor);

But I didn't really know what I was doing. I was trying to use this
http://www.xulplanet.com/references/xpcomref/comps/c_editorhtmleditor1.html

Any ideas?

Thanks,
Stephen

antigoon

unread,
Nov 27, 2006, 6:36:17 PM11/27/06
to
Aha... This seems to work.

var editor = gMsgCompose.editor;
var html_editor =
editor.QueryInterface(Components.interfaces.nsIHTMLEditor);
html_editor.insertHTML(theAddress);

Steve

0 new messages