Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#11970 closed Bug (fixed)

CKEditor paste event not fired when pasting with SHIFT+INS in IE9

Reported by: Henning Owned by: Piotr Jasiun
Priority: Normal Milestone: CKEditor 4.4.4
Component: General Version: 4.0 Beta
Keywords: IE Support Cc:

Description

I don't get CKEditor's 'paste' event fired when pasting with SHIFT+INS using

  • Internet Explorer 9
  • CKEditor 4.3.2 FF and Chrome fire the paste event.

See the small example code below. Paste alert is not displayed.

Browsing thru clipboard\plugin.js, this seems to be a complex matter. I do get the paste event in IE9 when removing the following line from the onKey function, but cannot oversee the side effects of this:

case CKEDITOR.SHIFT + 45: SHIFT+INS


<!DOCTYPE html>
<html>
  <head>
    <title>A Simple Page with CKEditor</title>
    <script src="ckeditor/ckeditor.js"></script>
  </head>
  <body>
    <form>
      <textarea id="editor1" name="editor1" rows="10" cols="80">
         This is my textarea to be replaced with CKEditor.
      </textarea>
      <script>
        // Replace the <textarea id="editor1"> with a CKEditor
        // instance, using default configuration.
        var myEditor = CKEDITOR.replace('editor1');
        myEditor.on('paste', function (evt) {
             alert("paste 1");
        });
      </script>
    </form>
  </body>
</html>

Change History (9)

comment:1 Changed 10 years ago by Jakub Ś

Keywords: IE added; paste insert clipboard removed
Status: newconfirmed
Version: 4.3.24.0 Beta

I see this somewhat works in CKEditor 3.6.6 - when you use SHIFT+Insert, browser asks if it should allow clipboard access. If you click allow you will get text pasted and alert box shown.

Starting from CKEditor 4.0 beta, content is pasted but no alert box is shown what means that paste event is not captured for SHIFT+Insert on IE.

Someone on SO had same problem: http://stackoverflow.com/questions/19269234/ckeditor-capturing-on-paste-event-including-shift-insert

comment:2 Changed 10 years ago by Jakub Ś

This workaround mentioned on SO really seems to work:

editor.on('key', function(ev) {
				if (ev.data.keyCode == 2228269 && CKEDITOR.env.ie) {
					setTimeout(function() {
						var event = {
							'type': 'html',
							'dataValue': editor.getData()
						};
						editor.editable().setHtml('');
						editor.fire('paste', event);
					}, 100);
				}
			});
			
			editor.on('paste', function(ev) {
				alert('we are in the on paste event!');
			});

comment:3 Changed 10 years ago by Wiktor Walc

Keywords: Support added

comment:4 Changed 10 years ago by Henning

The workaround is ok when you just want to get a paste event at some point of time. It is not sufficient if you want to use undo and paste features provided by other plugins, because the workarounded paste event fires too late. Hence we decided to cancel the SHIFT+INS key event, and must use CTRL+V instead, which, however, is not _nice_.

comment:5 Changed 10 years ago by Piotr Jasiun

Owner: set to Piotr Jasiun
Status: confirmedreview

The reason of the issue it this fix: https://github.com/ckeditor/ckeditor-dev/blob/master/plugins/clipboard/plugin.js#L471-L472

I've fixed it and pushed changes to t/11970.

Version 0, edited 10 years ago by Piotr Jasiun (next)

comment:6 Changed 10 years ago by Jonathan

I applied the fix that was committed and it appears to resolve the issue. I've tested it out on IE8 and IE11.

comment:7 Changed 10 years ago by Piotrek Koszuliński

Milestone: CKEditor 4.4.4
Status: reviewreview_passed

@pjasiun: Comment in the code must be added.

comment:8 Changed 10 years ago by Piotr Jasiun

Resolution: fixed
Status: review_passedclosed

Comment added and ticket masterized (git:7c0da96).

comment:9 Changed 10 years ago by Henning

Thanks a lot! We'll try when we update to >= 4.4.4

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy