【问题标题】:YUI rich text editor broken on latest FirefoxYUI 富文本编辑器在最新的 Firefox 上损坏
【发布时间】:2020-04-08 16:15:43
【问题描述】:

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

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

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

【问题讨论】:

  • 有人盲目地否决了这篇文章,然后有人帮我指出了确切的事情。如果人们无法提供帮助或不想投票,为什么他们也会在没有评论的情况下投反对票?

标签: javascript yui


【解决方案1】:

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

【讨论】:

  • 非常感谢您指出修复。但是你能告诉我_setInitialContent里面的变化吗?我已尝试删除或检查 (navigator.userAgent.indexOf('Firefox/1.5') != -1) 和 else 声明 this.get('iframe').get('element').src = 'data:text/html;charset=utf-8,' + encodeURIComponent(html);,但没有任何帮助。是的,我正在编辑yui/editor/editor.js 文件。
  • 好的。所以你继承了编辑器类。我正在尝试直接编辑 yui/editor/editor.js 。我可以看到你在 try-catch 之前没有if (this.browser.ie || this.browser.webkit || this.browser.opera || (navigator.userAgent.indexOf('Firefox/1.5') != -1)) {
  • 基本上问题是您省略了将 data: 附加到 iframe 的代码,原始代码就是这种情况:this.get('iframe').get('element').src = 'data:text/html;charset=utf-8,' + encodeURIComponent(html); 但不幸的是,这对我不起作用.有什么线索吗?
  • 好的。有效!!我服务器的 yui 文件夹中有一些 patch 文件夹。好像有的开发者之前已经对 YUI 打了补丁,不再使用原来的 yui/editor/editor-min.js 文件了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-18
  • 1970-01-01
  • 2010-10-12
  • 1970-01-01
相关资源
最近更新 更多