Here describes how to use XulRunner throw XPCOM for editing html/txt nodes
nsIWebBrowser webBrowser = (nsIWebBrowser)getBrowser().getWebBrowser(); webBrowser.getContentDOMWindow(); nsIDOMWindow iDOMWindow = webBrowser.getContentDOMWindow(); nsIDOMDocument iDOMDocument = iDOMWindow.getDocument(); nsIDOMNSHTMLDocument iDOMNSHTMLDocument = (nsIDOMNSHTMLDocument)iDOMDocument.queryInterface(nsIDOMNSHTMLDocument.NS_IDOMNSHTMLDOCUMENT_IID); iDOMNSHTMLDocument.setDesignMode("on");
//here we creating editing session using component manager nsIEditingSession editingSession = (nsIEditingSession)getComponentManager(). createInstanceByContractID("@mozilla.org/editor/editingsession;1",null,nsIEditingSession.NS_IEDITINGSESSION_IID); //here we make window editable using editing session editingSession.makeWindowEditable(iDOMWindow, "html", true); //setups editor for window editingSession.setupEditorOnWindow(iDOMWindow); //getting an instance of editor for window nsIEditor editor = editingSession.getEditorForWindow(iDOMWindow); //setups editor action listeners editor.addEditActionListener(getEditActionListener()); //setup flags using which we can disable or anable some editor actions editor.setFlags(nsIPlaintextEditor.eEditorReadonlyMask); //code with whic we are getting selection controller selectionController = editor.getSelectionController(); //with this code we are getting object resizer and we can use it's for controlling resizing nsIHTMLObjectResizer htmlObjectResizer = (nsIHTMLObjectResizer) editor.queryInterface(nsIHTMLObjectResizer.NS_IHTMLOBJECTRESIZER_IID); //we disable abject resizers htmlObjectResizer.hideResizers(); htmlObjectResizer.setObjectResizingEnabled(false); //here we getting position editor and disable it's too nsIHTMLAbsPosEditor htmlAbsPosEditor = (nsIHTMLAbsPosEditor) editor.queryInterface(nsIHTMLAbsPosEditor.NS_IHTMLABSPOSEDITOR_IID); htmlAbsPosEditor.setAbsolutePositioningEnabled(false); //here we getting inline table editor and disable it's too nsIHTMLInlineTableEditor inlineTableEditor = (nsIHTMLInlineTableEditor) editor.queryInterface(nsIHTMLInlineTableEditor.NS_IHTMLINLINETABLEEDITOR_IID); inlineTableEditor.setInlineTableEditingEnabled(false);
Description of nsIEditingSession
Very Short description of interfaces that are was using in it's example