代码之家  ›  专栏  ›  技术社区  ›  MadPhysicist

DjangCKEditor配置已完全启用

  •  0
  • MadPhysicist  · 技术社区  · 4 年前

    我正在使用 djangocms-text-ckeditor 在我的几个网站上。

    在其中一个上,我有以下内容 base.py

    CKEDITOR_SETTINGS = {
        'language': '{{ language }}',
        'toolbar': 'full',
        'toolbar_HTMLField': [
            ['Undo', 'Redo'],
            ['ShowBlocks'],
            ['Format', 'Styles'],
        ],
        'skin': 'moono-lisa',
        'removePlugins': ['image'],
        'extraPlugins' : [
            # these are non-standard plugins
            'codesnippet',
            'html5audio',
            'image2',
            'autogrow',
        ],
    }
    

    这提供了以下编辑器工具栏

    enter image description here

    在另一个网站上,我没有向添加任何内容 base.py 拿到这个

    enter image description here

    我的问题是如何在第一个站点中获得CMSPlugins部分。此外,如果我想显式启用所有插件,配置应该是什么样子?

    0 回复  |  直到 4 年前
        1
  •  1
  •   Dharman vijay    4 年前

    似乎没有简单的方法来实现你所需要的。这当然很奇怪 'full' 选项不包括CMSPlugins菜单。你能做的就是更换 'toolbar': 'full' 在您的 CKEDITOR_SETTINGS 具有明确的工具栏配置。如果你 真正地 需要全套选项, 它可能看起来是这样的——不过需要注意:我没有测试这个,也不完全确定其中的一些选项,所以要根据您的需求进行调整。

    # add to CKEDITOR_SETTINGS
    'toolbar_CMS': [
        [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord'],
        ['Undo', 'Redo'],
        ['cmsplugins', 'cmswidget'],
        ['Find', 'Replace'],
        ['SelectAll'], 
        ['Scayt'],
        ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'HiddenField'],
        ['Source', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates'],
        '/',
        ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript'], 
        ['CopyFormatting', 'RemoveFormat'],
        ['NumberedList', 'BulletedList'],
        ['Outdent', 'Indent'],
        ['Blockquote', 'CreateDiv'],
        ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
        ['BidiLtr', 'BidiRtl', 'Language'],
        ['Link', 'Unlink', 'Anchor'],
        ['CodeSnippet', 'Image2'],
        ['Html5audio', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe']
        '/',
        ['Styles', '-', 'Format', '-', 'Font', '-', 'FontSize'],
        ['TextColor', 'BGColor'],
        ['About'],
        ['Maximize', 'ShowBlocks']
    ]
    

    还可以看看 CKEditor Toolbar Configurator 和旧的 版本 here (我很确定Django CMS没有使用最新版本的CKEditor)。它输出JavaScript,但作为菜单图标及其名称的概述,它仍然非常有用。

    推荐文章