最新的Firefox打破了YUI富文本编辑器

时间:2018-01-22 13:38:55

标签: javascript yui

好吧,几天后我发现YUI 2.9富文本编辑器在最新的Firefox 58版本中显示为灰色。

根据少数Stackoverflow链接,我试图修补YUI库javascript文件,但其中大部分用于修复过去类似的IE问题。

有人可以与类似的事情分享一些经验吗?

1 个答案:

答案 0 :(得分:2)

我也碰到了这个。见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);
    }
}