insertElementAtSelection 停止工作

insertElementAtSelection stopped working

在我名为 PasteHyperlink 的 Thunderbird 插件中,我有一个例程将 html 元素插入到消息撰写 Window 中。

这曾经在 Thunderbird 中有效,但现在我得到这个 js 错误:

Error: TypeError: thiseditor.insertElementAtSelection is not a function

但是,thiseditor 似乎被定义了,因为它没有启动警报。

这是我已简化为基本功能的函数代码:

var thiseditor = gMsgCompose.editor;
if (!thiseditor){ alert("Dude, the gMsgCompose.editor is broken") };    
let link = thiseditor.document.createElement("a");  
link.setAttribute("href", "http://whosebug.com");

link.textContent = "Display Text"; 
thiseditor.insertElementAtSelection(link, false); 

MDN has this documentation,但我在任何地方都找不到任何关于 Thunderbird 45 中为什么会出现问题或发生了哪些变化的内容。

为什么它停止工作,我应该怎么做?

好吧,我想我明白了。我改变了这个:

var thiseditor = gMsgCompose.editor;

对此:

var thiseditor = gMsgCompose.editor.QueryInterface(Components.interfaces.nsIHTMLEditor);

有趣的是,第一种方法在很长一段时间内都有效。不过,我不知道 Thunderbird 发生了什么变化。