【问题标题】:Add blockquote to djangocms-text-ckeditor将块引用添加到 djangocms-text-ckeditor
【发布时间】:2017-04-16 01:45:57
【问题描述】:

有人知道如何将 HTML 元素 blockquote 添加到 djangocms-text-ckeditor,以便用户可以从下拉列表中进行选择,而不是直接修改 HTML 代码?

我很确定这是受支持的,就像我添加 html 时一样:

<blockquote>Text goes here...</blockquote>

直接到源面板,格式化好显示:

我尝试在设置中添加自定义样式,如下所示:

CKEDITOR_SETTINGS = {            
    'stylesSet': [
        {'name': 'PullQuote', 'element': 'blockquote', 'styles': {'color': 'Blue'}}
    ],
}

但这不起作用。我知道语法是正确的,因为当我将元素更改为“h1”时它工作正常。

我不是 100% 如何修改段落格式下拉菜单,但如果可能的话,blockquote 住在这里更有意义。

任何帮助将不胜感激。

更新

我意识到我一定误解了stylesSet 的作用。如果我添加上述设置,然后手动输入 blockquote 的 html,然后我可以选择此块引用的样式,将其变为蓝色。这不是我想要做的,但很有意义。

所以我想我希望将blockquote 添加到段落格式中。现在我不清楚这是否受支持,就像我尝试将以下内容添加到我的设置中一样:

CKEDITOR_SETTINGS = {    
    'format_tags': 'p;h1;h2;h3;h4;h5;h6;pre;address;div;blockquote', 
}

也就是说,将blockquote 添加到默认值的末尾,编辑器无法完全加载。如果我只删除单词blockquote,那么编辑器会按预期工作。

如果是这样的话,那就太可惜了,因为我将不得不创建一个子插件,纯粹是为了添加 blockquote,这似乎有点矫枉过正。

【问题讨论】:

    标签: django djangocms-text-ckeditor


    【解决方案1】:

    似乎要将此功能添加到默认编辑器中,您必须更新 settings.py 文件中的配置。 The documentation for django-ckeditor 是我开始的地方。

    settings.py

    CKEDITOR_CONFIGS = {
        'default': {
            'toolbar_CustomConfig': [
                {'name': 'clipboard', 'items': ['Undo', 'Redo']},
                {'name': 'yourcustomtools', 'items': [
                    'Preview',
                    'Maximize',
                ]},
                '/',
                {'name': 'styles', 'items': ['Styles', 'Format']},
                {'name': 'basicstyles',
                 'items': ['Bold', 'Italic', 'Underline', 'Strike', '-', 'RemoveFormat']},
                {'name': 'paragraph',
                 'items': ['NumberedList', 'BulletedList', 'Blockquote']},
                {'name': 'links', 'items': ['Link', 'Unlink', 'Anchor']},
                {'name': 'insert',
                 'items': ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar']},
                {'name': 'colors', 'items': ['TextColor', 'BGColor']},
            ],
            'toolbar': 'CustomConfig',  # put selected toolbar config here
            'tabSpaces': 4,
        }
    }
    

    这应该是常规条形加块引用的所有功能(加上有序和无序列表)。

    【讨论】:

      【解决方案2】:

      因此,由于偶然发现了这个解决方案,我设法解决了自己的问题:

      Load blockquote plugin in CKEditor

      我必须在工具栏中启用块引用,我已使用以下设置完成。

      CKEDITOR_SETTINGS = {    
          'toolbar_CMS': [
              ['Undo', 'Redo'],
              ['cmsplugins', '-', 'ShowBlocks'],
              ['Format', 'Styles'],
              ['TextColor', 'BGColor', '-', 'PasteText', 'PasteFromWord'],
              ['Maximize', ''],
              '/',
              ['Bold', 'Italic', 'Underline', '-', 'Subscript', 'Superscript', '-', 'RemoveFormat'],
              ['JustifyLeft', 'JustifyCenter', 'JustifyRight'],
              ['HorizontalRule'],
              ['Link', 'Unlink'],
              ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Table', 'Blockquote'],
              ['Source'],
          ]
      }
      

      【讨论】:

        猜你喜欢
        • 2015-01-14
        • 1970-01-01
        • 2013-07-05
        • 2014-01-31
        • 2015-10-21
        • 2014-07-13
        • 1970-01-01
        • 1970-01-01
        • 2018-10-23
        相关资源
        最近更新 更多