Django Ckeditor-禁用图像复制粘贴

时间:2020-11-12 14:51:58

标签: ckeditor image-upload django-ckeditor

我在模型中使用RichTextUploadField并粘贴了Google文档中的内容。我已使用forceAsPlainText从内容中删除格式。问题是,当我从文档复制图像时,源中的URL来自Google驱动器而不是服务器计算机。

我已经了解了Ckeditor的解决方案,但是其中大多数解决方案都是通过从工具栏中删除“图像”选项来完全禁用图像上传/粘贴。 我不要我只希望禁用图像复制粘贴,因此,当用户使用工具栏中的图像选项上传时,链接将来自服务器计算机。

CKEDITOR_UPLOAD_PATH = "uploads/"
CKEDITOR_IMAGE_BACKEND = "pillow"
CKEDITOR_CONFIGS = {
    "default": {
        "toolbar_DefaultToolbarConfig": [
            {
                "name": "basicstyles",
                "items": [
                    "Bold",
                    "Italic",
                    "Underline",
                    "Strike",
                    "Subscript",
                    "Superscript",
                ],
            },
            {"name": "clipboard", "items": ["Cut", "Copy", "Undo", "Redo",],},
            {
                "name": "paragraph",
                "items": [
                    "NumberedList",
                    "BulletedList",
                    "Outdent",
                    "Indent",
                    "HorizontalRule",
                    "JustifyLeft",
                    "JustifyCenter",
                    "JustifyRight",
                    "JustifyBlock",
                    "Smiley",
                    "Blockquote",
                ],
            },
            {
                "name": "paste",
                "items": ["Paste", "PasteText", "CopyFormatting", "RemoveFormat",],
            },
            {
                "name": "style",
                "items": ["FontSize", "Format", "TextColor", "BGColor",],
            },
            {
                "name": "extra",
                "items": [
                    "Link",
                    "Unlink",
                    "Image",
                    "Table",
                    "CodeSnippet",
                    "Embed",
                    "Iframe",
                    "InsertSpecialCharacter",
                ],
            },
            {"name": "replace", "items": ["Find", "Replace", "SelectAll",],},
            {"name": "source", "items": ["Maximize", "Source",],},
        ],
        "title": False,
        "toolbar": "DefaultToolbarConfig",
        "linkShowTargetTab": False,
        "linkShowAdvancedTab": False,
        "height": "250px",
        "width": "auto",
        "forcePasteAsPlainText ": True,
        "pasteDataImages": False,
        "tabSpaces": 4,
        "extraPlugins": ",".join(["codesnippet", "image2", "embed", "tableresize",]),
    }
}

这是我的ckeditor配置设置。

感谢您的帮助!

0 个答案:

没有答案