【问题标题】:Cannot configure youtube plugin in django-ckeditor无法在 django-ckeditor 中配置 youtube 插件
【发布时间】:2019-08-03 23:52:38
【问题描述】:

我在设置和模型中做了以下操作:

settings.py

CKEDITOR_CONFIGS = {
    'special': {
        'toolbar': 'Special',
        'toolbar_Special': [
            ['Styles', 'Format', 'Bold', 'Italic', 'Underline', 'Strike', 'SpellChecker', 'Undo'],
            ['Link', 'Unlink', 'Anchor'],
            ['Image', 'Flash', 'Table', 'HorizontalRule'],
            ['TextColor', 'BGColor'],
            ['Smiley', 'SpecialChar'], ['Source'],
        ],
        'extraPlugins': 'youtube',
    }
}

models.py

class Post(models.Model):
    user    = models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE,null=True,blank=True)
    post    = RichTextUploadingField(blank=True, null=True,
                                      config_name='special',
                                      external_plugin_resources=[(
                                          'youtube',
                                          '/static/ckeditor/ckeditor/plugins/youtube_2.1.13/youtube/',
                                          'plugin.js',
                                          )],
                                      )
    date    = models.DateTimeField(auto_now_add=True)

我想在我的 ckeditor 中添加 youtube 插件。我已经从https://ckeditor.com/cke4/addon/youtube下载了。

谁能找出我代码中的问题?

谢谢

【问题讨论】:

    标签: django ckeditor


    【解决方案1】:

    你添加了吗

    config.extraPlugins = 'youtube';
    

    config.js 文件中?

    您是否在 settings.py 中配置了静态文件?

    STATIC_URL = '/static/'
    STATIC_ROOT = '/static/'
    

    还请查看此视频,它可能会对您有所帮助。 https://www.youtube.com/watch?v=L6y6cn1XUfw

    还有

    CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'CMS',
        'toolbar_CMS': [
            {
                'name': 'basicstyles',
                'groups': ['basicstyles', 'cleanup'],
                'items': ['Bold', 'Italic', 'Underline', '-', 'RemoveFormat']
            },
            {
                'name': 'paragraph',
                'groups': ['list', 'indent', 'blocks'],
                'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote']
            },
            {
                'name': 'links',
                'items': ['Link', 'Unlink']
            },
            {
                'name': 'insert',
                'items': ['Image', 'HorizontalRule', 'Table', 'Iframe', ]
            },
            {
                'name': 'colors',
                'items': ['TextColor', 'BGColor']
            },
            {
                'name': 'youtube',
                'items': ['Youtube',]
            }
        ],
        'height': 400,
        'width': '100%',
        'allowedContent': True,
        'uiColor': '#f0f0f0',
        'extraPlugins': 'link,iframe,colorbutton,autogrow,youtube',
        'autoGrow_maxHeight': 800,
        'autoGrow_minHeight': 400,
        'removePlugins': 'resize',
        'removeButtons': None,
    },
    }
    

    请确保您在项目中使用大写 Y 会有所不同。

    然后检查How can I install plugin into CkEditor, Django

    【讨论】:

    • 是的,我已经完成了与此视频完全相同的操作。但它不会来
    • 在 youtube 项目中尝试大写 Y。
    • 这里的contentsCss 是什么?
    • 我的错。您是否尝试过使用大写 Y(Youtube 而不是 youtube)
    猜你喜欢
    • 1970-01-01
    • 2015-01-01
    • 2018-06-25
    • 2014-09-26
    • 2015-01-12
    • 1970-01-01
    • 1970-01-01
    • 2018-02-16
    • 2016-07-27
    相关资源
    最近更新 更多