How to detect CKEditor source mode on change event

偶尔善良 提交于 2019-12-03 12:09:52

Instead of using "change" event, the "key" event does fire on the source view.

Thanks for Kicker's hint

The CKEditor 4 documentation tells that the change event won't be fired in source mode.

The example from the documentation worked for me. It binds a listener to the mode event. That's fired when the mode changes. When it changes to source, attach a listener to the editor.

editor.on('mode', function() {
    if (this.mode === 'source') {
        var editable = editor.editable();
        editable.attachListener(editable, 'input', function() {
            // Handle changes made in the source mode.
        });
    }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!