简体   繁体   English

TinyMCE:j 未定义

[英]TinyMCE: j is undefined

What's wrong with this code?这段代码有什么问题? I get "J is undefined message" after insert the image.插入图像后,我得到“J 是未定义的消息”。 I think this happends while i try to close itself.我认为这发生在我尝试关闭自身时。

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);

it's a tinymce bug.这是一个 tinymce 错误。 Internally, the tinymce code uses a <span id="mce_marker"></span> to remember the caret-position when pasting.在内部,tinymce 代码在粘贴时使用<span id="mce_marker"></span>来记住插入符号的位置。 when validating the resulting fragment, after the paste, the span is deemed invalid and removed, thus breaking the code by removing the marker.在验证生成的片段时,粘贴后,跨度被视为无效并被删除,从而通过删除标记来破坏代码。 This issue will be fixed in the next official tinymce minor release.此问题将在下一个官方 tinymce 次要版本中修复。 There are some workarounds for this kind of issue.此类问题有一些解决方法。 One is to add to add id and mce-data-type attribute to spans as valid elements (init setting) .一种是添加以将idmce-data-type属性添加到spans作为有效元素(初始化设置) Example:例子:

// 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