YUI 富文本编辑器在最新的 Firefox 上损坏

YUI rich text editor broken on latest Firefox

嗯,这几天我观察到 YUI 2.9 富文本编辑器在最新的 Firefox 58 版中是灰色的。

根据一些 Whosebug 链接,我尝试修补 YUI 库 javascript 文件,但其中大部分是用于修复过去类似的 IE 问题。

任何人都可以分享一些类似事情的经验吗?

我也遇到了。参见 this bug report

你可以直接修改 _setInitialContent 方法来删​​除 FF 特殊外壳。

以下对我有用(SimpleHTMLEditor 是我编辑器的子类):

SimpleHTMLEditor.prototype._setInitialContent = function (raw) {
    YAHOO.log('Populating editor body with contents of the text area', 'info', 'SimpleEditor');

    var value = ((this._textarea) ? this.get('element').value : this.get('element').innerHTML),
        doc = null;

    if (value === '') {
        value = '<br>';
    }

    var html = Lang.substitute(this.get('html'), {
        TITLE: this.STR_TITLE,
        CONTENT: this._cleanIncomingHTML(value),
        CSS: this.get('css'),
        HIDDEN_CSS: ((this.get('hiddencss')) ? this.get('hiddencss') : '/* No Hidden CSS */'),
        EXTRA_CSS: ((this.get('extracss')) ? this.get('extracss') : '/* No Extra CSS */')
    }),
        check = true;

    html = html.replace(/RIGHT_BRACKET/gi, '{');
    html = html.replace(/LEFT_BRACKET/gi, '}');

    if (document.compatMode != 'BackCompat') {
        YAHOO.log('Adding Doctype to editable area', 'info', 'SimpleEditor');
        html = this._docType + "\n" + html;
    } else {
        YAHOO.log('DocType skipped because we are in BackCompat Mode.', 'warn', 'SimpleEditor');
    }

    try {
        //Adobe AIR Code
        if (this.browser.air) {
            doc = this._getDoc().implementation.createHTMLDocument();
            var origDoc = this._getDoc();
            origDoc.open();
            origDoc.close();
            doc.open();
            doc.write(html);
            doc.close();
            var node = origDoc.importNode(doc.getElementsByTagName("html")[0], true);
            origDoc.replaceChild(node, origDoc.getElementsByTagName("html")[0]);
            origDoc.body._rteLoaded = true;
        } else {
            doc = this._getDoc();
            doc.open();
            doc.write(html);
            doc.close();
        }
    } catch (e) {
        YAHOO.log('Setting doc failed.. (_setInitialContent)', 'error', 'SimpleEditor');
        //Safari will only be here if we are hidden
        check = false;
    }
    this.get('iframe').setStyle('visibility', '');
    if (check) {
        this._checkLoaded(raw);
    }
}