繁体   English   中英

TinyMCE:j 未定义

[英]TinyMCE: j is undefined

这段代码有什么问题? 插入图像后,我得到“J 是未定义的消息”。 我认为这发生在我尝试关闭自身时。

var ImageDialog = 
{
    init : function()
    {
        var f = document.forms[0], ed = tinyMCEPopup.editor;
        e = ed.selection.getNode();
        if (e.nodeName == 'IMG')
        {
            f.src.value = ed.dom.getAttrib(e, 'src');
        }
    },

    update : function()
    {
        var f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, args = {}, el;

        tinyMCEPopup.restoreSelection();

        if (f.src.value === '')
        {
            if (ed.selection.getNode().nodeName == 'IMG')
            {
                ed.dom.remove(ed.selection.getNode());
                ed.execCommand('mceRepaint');
            }

            tinyMCEPopup.close();
            return;
        }

        tinymce.extend(args,
        {
            src : f.src.value
        });

        el = ed.selection.getNode();

        if (el && el.nodeName == 'IMG')
        {
            ed.dom.setAttribs(el, args);
            tinyMCEPopup.editor.execCommand('mceRepaint');
            tinyMCEPopup.editor.focus();
        }
        else
        {
            ed.execCommand('mceInsertContent', false, '<img src="'+args['src']+'" id="_mce_temp_rob" alt="" />', {skip_undo : 1});
            ed.undoManager.add();
            ed.focus();
            ed.selection.select(ed.dom.select('#_mce_temp_rob')[0]);
            ed.selection.collapse(0);
            ed.dom.setAttrib('_mce_temp_rob', 'id', '');
            tinyMCEPopup.storeSelection();
        }

        tinyMCEPopup.close();
    },

    getImageData : function()
    {
        var f = document.forms[0];
        this.preloadImg = new Image();
        this.preloadImg.src = tinyMCEPopup.editor.documentBaseURI.toAbsolute(f.src.value);
    }
};

tinyMCEPopup.onInit.add(ImageDialog.init, ImageDialog);

这是一个 tinymce 错误。 在内部,tinymce 代码在粘贴时使用<span id="mce_marker"></span>来记住插入符号的位置。 在验证生成的片段时,粘贴后,跨度被视为无效并被删除,从而通过删除标记来破坏代码。 此问题将在下一个官方 tinymce 次要版本中修复。 此类问题有一些解决方法。 一种是添加以将idmce-data-type属性添加到spans作为有效元素(初始化设置) 例子:

// The valid_elements option defines which elements will remain in the edited text when the editor saves.
    valid_elements: "@[id|class|title|style]," +
    "a[name|href|target|title]," +
    "#p,-ol,-ul,-li,br,img[src],-sub,-sup,-b,-i,-u" +
    "-span[data-mce-type]",

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM