How to access nsIHTMLEditor interface in GeckoFX?

孤街醉人 提交于 2019-12-06 04:37:53

nsIHTMLEditor is likely a per browser instance rather than a global instance (like things returned by Xpcom.GetService)

One can get a nsIEditor like this by (by supplying a Window instance)

var editingSession = Xpcom.CreateInstance<nsIEditingSession>("@mozilla.org/editor/editingsession;1");
nsIEditor editor = editingSession.GetEditorForWindow((nsIDOMWindow)Window.DomWindow);
Marshal.ReleaseComObject(editingSession);

(or you can just call the nsIEditor GeckoWebBrowser.Editor property.)

You may be able to cast this nsIEditor to a nsIHtmlEditor (although I have yet to try it)

GeckoWebBrowser browser = .....;
// Untested code
nsIHTMLEditor htmlEditor = (nsIHTMLEditor)browser.Editor;

Update: The VB code from @GreenBear

Dim gEditor As nsIHTMLEditor: 
gEditor = Gbrowser.Editor: 
gEditor.DecreaseFontSize() 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!