防止用户将图像粘贴到 CKEditor 5

Prevent user from pasting images into CKEditor 5

我们的用户将图像复制粘贴到编辑器 (CKEditor 5) 中,这是我们不想支持的。

建议的 CKEditor 4 修复在 5 中似乎不起作用。

如何更改编辑器以禁用此功能?

这是我的配置:

const editorConfig = {
  toolbar: ['heading', 'bold', 'italic', 'bulletedList', 'numberedList'],
  removePlugins: ['Image', 'ImageToolbar', 'ImageStyle', 'ImageUpload', 'ImageCaption'],
  heading: {
    options: [
      {
        model: 'paragraph',
        title: 'Paragraph',
        class: 'ck-heading_paragraph',
      },
      {
        model: 'heading2',
        view: 'h2',
        title: 'Heading',
        class: 'ck-heading_heading2',
      },
    ],
  },
};

如果你想完全禁用图像功能,这就是 - 使图像无法以任何方式inserted/loaded编辑器,那么你应该删除ImageImageToolbarImageStyle、'ImageUpload 和来自您的编辑器的 ImageCaption 插件。实现这一点的最简单方法是使用 config.removePlugins. You can also check how to install plugins 因为卸载是相反的过程。

如果您想要禁止插入图片,但仍然支持内容中已经存在的那些图片,您需要稍微不同地处理它。您必须阻止 pasting/dropping 它们,这可以通过 features exposed by the clipboard integration. You may also want to remove the ImageUpload plugin in thi case too. Finally, you probably won't need the imageUpload button in the toolbar, so you have to reconfigure it.

来完成