0
votes

I'm attempting to use the async flag provided by the CKE Command definition as seen in the example here.

I have the command, which opens a jQuery UI dialog, where some data is input from the user. This part works fine. When the dialog is closed (i.e. user clicks OK or Cancel) I try to do as the CKE example shows and manually call editor.fire("afterCommandExec"), which results in the following error:

Uncaught TypeError: Cannot read property 'command' of undefined

It's coming from here: http://docs.cksource.com/ckeditor_api/symbols/src/plugins_undo_plugin.js.html (line 69)

if ( undoManager.enabled && event.data.command.canUndo !== false )
        undoManager.save();

I understand why the error is happening: no event data is being sent along with the call to fire(). However, their example has no event data sent either. I can manually fire the event with the command as data and it seems to work:

editor.fire("afterCommandExec", {
    command: editor.getCommand('link')
});

However, that doesn't seem like the right way to do this. What am I doing wrong?

1
Can you provide a complete example? (with the error.. but at least a complete code). - Dekel
It's tough because it's in a large project with a lot of libraries, but this is similar to what would be happening: jsfiddle.net/leetbruh/hdhyg7hh - Scott C

1 Answers

0
votes

I would say that the example is a minimal code about how to use, not a real working example and that's why it might not work.

If your error comes from the Undo system, mark that your command doesn't use it with canUndo = false and handle yourself the addition to the undo stack instead of relying on it automatically.