0

I'm searching for a way to get the data of the cut event in CKEditor. And i was looking within the sourcecode posted on github. But after trying to get the data on IE8, Mozilla(Mac) with the follow 2 examples

    editor.editable().on('cut', function (ev) {
        console.log(ev.dataValue);
    });

    editor.editable().on('cut', function (ev) {
        console.log(ev.data.dataValue);
    });

I couldn't find out what is the problem for not retrieving the data. Does somebody know how to retrieve the data from the cut event in CKEditor?

Spons
  • 1,593
  • 1
  • 17
  • 46

1 Answers1

1

You can't.

CKEditor utilizes native document.execCommand for clipboard operations. It doesn't store what is cut/copied but the browser does. All browsers except IE won't let you manipulate clipboard data (IE will display a prompt first). In fact, CKEditor has (almost) nothing to do with cutting process.

In IE and Webkit, you can try onbeforecut event to listen on and access editor's selection with editor.getSelection() (i.e. editor.getSelection().getSelectedText()).

oleq
  • 15,697
  • 1
  • 38
  • 65
  • I did already find the editor.getSelection().getSelectedText(); indeed. But it seemed curious that the dataValue wasn't filled. – Spons Mar 18 '13 at 14:53
  • dataValue isn't filled because CKEditor *never* handles cutting process. The browser is responsible for controlling the clipboard. It's totally native. – oleq Mar 18 '13 at 14:59