Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#11970 closed Bug (fixed)

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

Reported by: Henning Owned by: pjasiun
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 3 years ago by j.swiderski

  • Keywords IE added; paste insert clipboard removed
  • Status changed from new to confirmed
  • Version changed from 4.3.2 to 4.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 3 years ago by j.swiderski

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 3 years ago by wwalc

  • Keywords Support added

comment:4 Changed 3 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 3 years ago by pjasiun

  • Owner set to pjasiun
  • Status changed from confirmed to review

The reason of the issue is 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.

Last edited 3 years ago by pjasiun (previous) (diff)

comment:6 Changed 3 years ago by jbalinski

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 3 years ago by Reinmar

  • Milestone set to CKEditor 4.4.4
  • Status changed from review to review_passed

@pjasiun: Comment in the code must be added.

comment:8 Changed 3 years ago by pjasiun

  • Resolution set to fixed
  • Status changed from review_passed to closed

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

comment:9 Changed 3 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 – 2016 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy