javascript 从版本 3 升级到版本 4 后,tinyMCE 无法再拖放图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21082723/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 20:00:34  来源:igfitidea点击:

tinyMCE can no longer drag and drop images after upgrading from version 3 to version 4

javascriptjquerytinymcebase64image-uploading

提问by chiliNUT

My website was using the version 3 of tiny mce. One feature it had was that a user could drag an image into the editor, and it would automatically convert it to a base64 data-uri and insert it into the editor. I have just upgraded to version 4, and this functionality seems to be completely gone.

我的网站使用的是 tiny mce 的第 3 版。它的一个功能是用户可以将图像拖到编辑器中,它会自动将其转换为 base64 数据 uri 并将其插入到编辑器中。我刚刚升级到版本4,这个功能好像完全没有了。

AFAIK, it was not a plugin or anything controlling this, just part of the default functionality, because I was still able to do it when initializing with minimal options, like this:

AFAIK,它不是插件或任何控制它的东西,只是默认功能的一部分,因为在使用最少的选项初始化时我仍然能够做到这一点,如下所示:

  tinyMCE.init({mode: "none"});
  tinyMCE.execCommand('mceAddControl', false, 'selector');

Was this feature removed from version 4, or is there a way to turn it back on?

此功能是从第 4 版中删除的,还是有办法将其重新打开?

I really want to upgrade to 4, but this is the only thing stopping me, as the image feature is crucial for my application.

我真的很想升级到 4,但这是唯一阻止我的事情,因为图像功能对我的应用程序至关重要。

Thanks!

谢谢!

回答by Christophe Eblé

If you want to enable the image drag & drop feature you have to do it explicitly with the code below.

如果要启用图像拖放功能,则必须使用以下代码明确执行。

tinymce.init({
    ...
    paste_data_images: true
});

回答by apifeez

You have to add following property to enable drag and drop

您必须添加以下属性才能启用拖放

tinymce.init({
            selector: "#imgedit",  // change this value according to your HTML
            plugins: "paste",
            menubar: "edit",
            toolbar: "paste",
            paste_data_images: true
});

and if you want to add drag and drop with insert url of image functionality then add below line of code

如果您想添加带有图像功能插入 url 的拖放,请添加以下代码行

tinymce.init({
            selector: "#imgedit",  // change this value according to your HTML
            toolbar: "image,paste",
            plugins: "image,paste",
            menubar: "insert,edit",
            paste_data_images: true,
});