Вам необходимо прослушивать события dragover
и drop
в слое view вместо модели .
Я подготовил простую функцию, которая может быть загружена как плагин в CKEditor 5, который отменяет эти события:
/**
* Cancel the `drop` and `dragover` events.
*
* @param {module:core/editor/editor~Editor} editor
*/
function cancelDropEvents( editor ) {
// High priority means that the callbacks below will be called before other CKEditor's plugins.
editor.editing.view.document.on( 'drop', ( evt, data ) => {
// Stop executing next callbacks.
evt.stop();
// Prevent the default event action.
data.preventDefault();
}, { priority: 'high' } );
editor.editing.view.document.on( 'dragover', ( evt, data ) => {
evt.stop();
data.preventDefault();
}, { priority: 'high' } );
}
Вы можете проверить, как это работает онлайн - https://jsfiddle.net/pomek/qz0o9ku0/.