Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paste option in CKeditor doesnt seem to work in Chrome and firefox

Using the online ckeditor http://sdk.ckeditor.com/samples/classic.html I see the past options (Paste, Paste as plain text and paste from word) doesn't copy from clipboard. I gives the error 'Your browser does not allow you to paste plain text this way. Press Ctrl+Shift+V to paste.' But it seems to work in IE(it prompts for allow access) and not in Chrome or Firefox.

Is this a bug or some configurations needs to done from browser or ckEditor. Cause I remember I used the same behavior few months back and it used to give a popup to paste you content to the editor.

Thanks, Vijai

like image 364
Oceanvijai Avatar asked Dec 23 '22 17:12

Oceanvijai


2 Answers

Just add this code to 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();
        }
    })
});
like image 124
Mehdi Saghari Avatar answered Dec 30 '22 11:12

Mehdi Saghari


Chrome does not allow this because this is a security hole. Someone could steal your copied data so chrome and most other browsers do not allow you to do this. press ctrl shift and v to paste it.

like image 35
Jujhar Singh Avatar answered Dec 30 '22 11:12

Jujhar Singh