CKeditor中的粘贴选项在Chrome和firefox中似乎不起作用

CKeditor中的粘贴选项在Chrome和firefox中似乎不起作用,ckeditor,copy-paste,paste,Ckeditor,Copy Paste,Paste,使用在线编辑器 我看到过去的选项(粘贴、作为纯文本粘贴和从word粘贴)没有从剪贴板复制。 我给出错误“您的浏览器不允许您以这种方式粘贴纯文本。按Ctrl+Shift+V组合键粘贴,但它似乎在IE(提示允许访问)中有效,而在Chrome或Firefox中无效 这是一个bug还是需要通过浏览器或编辑器进行一些配置。因为我记得几个月前我用过同样的行为,它会弹出一个弹出窗口,将你的内容粘贴到编辑器中 谢谢, Vijai Chrome不允许这样做,因为这是一个安全漏洞。有人可能会窃取您复制的数据,所以c

使用在线编辑器 我看到过去的选项(粘贴、作为纯文本粘贴和从word粘贴)没有从剪贴板复制。 我给出错误“您的浏览器不允许您以这种方式粘贴纯文本。按Ctrl+Shift+V组合键粘贴,但它似乎在IE(提示允许访问)中有效,而在Chrome或Firefox中无效

这是一个bug还是需要通过浏览器或编辑器进行一些配置。因为我记得几个月前我用过同样的行为,它会弹出一个弹出窗口,将你的内容粘贴到编辑器中

谢谢,
Vijai Chrome不允许这样做,因为这是一个安全漏洞。有人可能会窃取您复制的数据,所以chrome和大多数其他浏览器不允许您这样做。按ctrl-shift键和v键将其粘贴。

根据官方编辑团队的说法:目前没有解决此问题的方法。 请参阅此链接:

我认为目前最好的解决方案是使用以下方法删除它们:

removeButtons : "Paste,PasteText,PasteFromWord"

我建议每个面临这个问题的人继续评论他们,这样他们就会为这个问题做点什么或尝试使用较低版本。

只需将此代码添加到config.js:

CKEDITOR.on("instanceReady", function(event) {
    event.editor.on("beforeCommandExec", function(event) {
        // Show the paste dialog for the paste buttons and right-click paste
        if (event.data.name == "paste") {
            event.editor._.forcePasteDialog = true;
        }
        // Don't show the paste dialog for Ctrl+Shift+V
        if (event.data.name == "pastetext" && event.data.commandData.from == "keystrokeHandler") {
            event.cancel();
        }
    })
});
使用编辑器

我们有同样的问题。添加了插件和图像上传下载API动作

然后从编辑器中删除过去的按钮

config.removeButtons = 'Paste,PasteText,PasteFromWord';
将以下代码添加到CKEditor config.js中

config.extraPlugins = 'uploadimage';
config.uploadUrl = '/uploader/upload.php';
config.filebrowserUploadUrl = '/uploader/upload.php';
之后,使用CTRL+V从word文档中删除图像

我正在使用MVC5。因此,配置是

config.extraPlugins = 'uploadimage';
config.uploadUrl = '/CkEditorUploadSupport/UploadImage';
config.filebrowserUploadUrl = '/CkEditorUploadSupport/UploadImage';
MVC控制器代码;(项目控制器文件夹下的控制器名称“CkEditorUploadSupport”)

public JsonResult UploadImage()
{
if(System.Web.HttpContext.Current.Request.Files.AllKeys.Any())
{
var file=System.Web.HttpContext.Current.Request.Files[“upload”];
var targetLocation=@“D:\CKTestFolder”;
如果(!Directory.Exists(targetLocation))
{
CreateDirectory(targetLocation);
}

var模式=新正则表达式(@“[:!@$%^&*()}{124;\”":?>谢谢你的回复,如果是这样的话,CKeditor应该删除这三个选项,对吗?因为看起来他们有,但它只会给用户带来错误。好吧,它对IE有效。但是他们可以让它只出现在IE上。是的,如果可能的话,你能指出一个地方,我可以从CKeditor团队那里得到正式的文字或确认,这样我就可以请将其提交给我的团队流程。或者对其进行重新分级的现有缺陷也可以正常工作。还有一件事,我们项目中使用的当前CKeditor似乎没有限制我们这样做(在同一个浏览器上)。因此,我假设此限制适用于当前版本的ckeditor,我是否可以在ckeditor发行说明中找到此限制。我使用的是ckeditor 4.6。@Oceanvijai嗯,无论ckeditor的版本如何,它都不应该在Chrome上工作,但您可以尝试通过以下地址与他们联系:
     public JsonResult UploadImage()
    {
        if (System.Web.HttpContext.Current.Request.Files.AllKeys.Any())
        {
            var file = System.Web.HttpContext.Current.Request.Files["upload"];
            
            var targetLocation = @"D:\CKTestFolder";

            if (!Directory.Exists(targetLocation))
            {
                Directory.CreateDirectory(targetLocation);
            }
            var pattern = new Regex(@"[:!@#$%^&*()}{|\"":?><\[\]\\;'/,~]");

            var modifiedFileName = pattern.Replace(file.FileName, "");
            modifiedFileName = modifiedFileName.Replace("\"", " ");
            modifiedFileName = modifiedFileName.Replace("4â€Â", " ");

            // Some browsers send file names with full path.
            // We are only interested in the file name.
            var physicalPath = Path.Combine(targetLocation, modifiedFileName);
            var fileName = Path.GetFileName(physicalPath);
            var newName = fileName;


            while (System.IO.File.Exists(physicalPath))
            {
                var newFileName = Path.GetFileNameWithoutExtension(fileName)
                                  + "_" + RandomString(3) +
                                  Path.GetExtension(fileName);
                physicalPath = Path.Combine(targetLocation, newFileName);
                newName = newFileName;
            }

            file.SaveAs(physicalPath);

            var response = new
            {
                uploaded = 1,
                fileName = newName,
                url = "/CkEditorUploadSupport/OpenImage?imageName=" + newName
            };

            return Json(response);
        }

        var response2 = new
        {
            uploaded = 0,
            message = "Upload Error.."
        };

        return Json(response2);
    }

    public ActionResult OpenImage(string imageName)
    {
        var targetLocation = @"D:\CKTestFolder";

        var physicalPath = Path.Combine(targetLocation, imageName);

        if (!System.IO.File.Exists(physicalPath))
        {
            var response2 = new
            {
                uploaded = 0,
                message = "File Not Found"
            };

            return Json(response2);
        }

        string mimeType = MimeMapping.GetMimeMapping(imageName);
        return base.File(physicalPath, mimeType);
    }

    private static Random random = new Random();

    public static string RandomString(int length)
    {
        const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        return new string(Enumerable.Repeat(chars, length)
            .Select(s => s[random.Next(s.Length)]).ToArray());
    }