DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
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);





