Jan*_*pák 1 ckeditor ckeditor5
我们正在尝试将 CKEditor 5 实施到我们的应用程序中,但我们在文档方面遇到了一些困难。
我们想禁用放置事件到编辑区域或以某种方式控制它。有活动吗?
我们正在尝试editor.model.document.on('clipboardInput')或editor.model.document.on('dragover')没有任何运气。这些事件不会被触发。
您需要在视图层而不是模型上监听dragover和drop事件。
我准备了一个简单的函数,可以作为插件加载到 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' } );
}
Run Code Online (Sandbox Code Playgroud)
您可以在线查看它是如何工作的 – https://jsfiddle.net/pomek/qz0o9ku0/。
| 归档时间: |
|
| 查看次数: |
954 次 |
| 最近记录: |