You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

django-ckeditor-5无法启用完整工具栏,寻求解决方案

Django CKEditor 5 完整工具栏配置方案

CKEditor 5 和 CKEditor 4 的配置逻辑完全不同,旧版CKEDITOR_CONFIGS里toolbar: 'full'的写法在 CKEditor 5 中不生效,需要改用以下配置方式:

核心配置修改

在项目的settings.py中,使用CKEDITOR_5_CONFIGS替代原CKEDITOR_CONFIGS,通过明确列出工具栏按钮实现完整功能:

CKEDITOR_5_CONFIGS = {
    'default': {
        'toolbar': {
            'items': [
                'heading', '|',
                'bold', 'italic', 'underline', 'strikethrough', 'subscript', 'superscript', '|',
                'link', 'bulletedList', 'numberedList', 'todoList', '|',
                'blockQuote', 'imageUpload', 'mediaEmbed', 'insertTable', '|',
                'fontSize', 'fontFamily', 'fontColor', 'fontBackgroundColor', '|',
                'alignment', '|',
                'undo', 'redo'
            ]
        },
        # 可选:增强图片编辑功能的工具栏配置
        'image': {
            'toolbar': [
                'imageTextAlternative', 'imageStyle:full', 'imageStyle:side'
            ]
        },
        # 可选:增强表格编辑功能的工具栏配置
        'table': {
            'contentToolbar': [
                'tableColumn', 'tableRow', 'mergeTableCells'
            ]
        }
    }
}

关键说明

  • CKEditor 5 不再支持'toolbar': 'full'这种简写,必须明确指定要显示的按钮项,用'|'分隔按钮实现分组。
  • 若需要更多功能,可直接将 CKEditor 5 支持的按钮名称加入items数组。
  • 确保项目已正确安装django-ckeditor-5包,且使用的是 CKEditor 5 对应的编辑器组件。

内容的提问来源于stack exchange,提问作者navid

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 12:40:08