Platinum Partner

Mozilla: Getting Editor From An Iframe

Seems like getting an editor from a designMode/contenteditable iframe is harder than it should be in firefox:

First the docshell:

const Ci = Components.interfaces;
const Cc = Components.classes;

var editframe = window.frames[0];
var editdoc = editframe.document;

var docshell = editframe.QueryInterface(Ci.nsIInterfaceRequestor)
                        .getInterface(Ci.nsIWebNavigation)
                        .QueryInterface(Ci.nsIDocShell)


And now the editor (expanded)

var editor = editframe.QueryInterface(Ci.nsIInterfaceRequestor)
                      .getInterface(Ci.nsIWebNavigation)
                      .QueryInterface(Ci.nsIInterfaceRequestor)
                      .getInterface(Ci.nsIEditingSession)
                      .getEditorForWindow(editframe);

// -- OR --
var editor = docshell.QueryInterface(Ci.nsIInterfaceRequestor)
                     .getInterface(Ci.nsIEditingSession)
                     .getEditorForWindow(editframe);

// If you want:
editor.QueryInterface(Ci.nsIHTMLEditor);
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}