TypeError: window.tinyMCE.execInstanceCommand is not a function

最后都变了- 提交于 2019-12-05 04:22:14
Scott B

I had the same problem. Change your code to this and it should work:

if(window.tinyMCE) {

    /* get the TinyMCE version to account for API diffs */
    var tmce_ver=window.tinyMCE.majorVersion;

    if (tmce_ver>="4") {
        window.tinyMCE.execCommand('mceInsertContent', false, tagtext);
    } else {
        window.tinyMCE.execInstanceCommand('content', 'mceInsertContent', false, tagtext);
    }

    tinyMCEPopup.editor.execCommand('mceRepaint');
    tinyMCEPopup.close();
    }
    return;
}

Note: since .js files are cached, you'll need to do a hard refresh to get this to work. If you are still seeing the same console errors, that would likely be the cause.

Scott B's answer is partially innacurate.

The point of execInstanceCommand in TinyMCE version 3 was to execute a command on a specific instance of TinyMCE in the document. Calling execCommand without specifying an instance will either use the focused instance or the first instance in the document, if none is currently focused.

To specify the instance you would like to execute your command on in TinyMCE version 4, call execCommand on the desired editor instance like so:

tinyMCE.get(editorId).execCommand(...);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!