有谁知道如何将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,这似乎有点过头了。
发布于 2020-11-11 05:13:46
似乎要将此功能添加到默认编辑器中,您必须更新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,
}
}这应该是常规栏加上块引用的所有功能(加上有序和无序列表)。
发布于 2016-12-01 20:54:46
因此,由于偶然发现了这个解决方案,我设法解决了自己的问题:
Load blockquote plugin in CKEditor
我必须在工具栏中启用blockquote,这是我使用以下设置完成的。
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'],
]
}https://stackoverflow.com/questions/40910343
复制相似问题