【问题标题】:Working with CKEditor 3's templates: Issues with preserving HTML markup使用 CKEditor 3 的模板:保留 HTML 标记的问题
【发布时间】:2013-07-11 02:14:42
【问题描述】:

我将 CKEditor 用作 ExpressionEngine 的 WYGWAM 插件的一部分,但我的核心问题是 CKEditor 问题。

我对某些 UI 元素有一些自定义 HTML 标记,到目前为止,使用 templates_files 和 CKEditor 3 Templates 使用它们没有问题。

但是,由于某种原因,并非每个 HTML 模板的所有标记都被保留。在以下应用展开/折叠手风琴列表的情况下,当转到下一个

  • 项目时,不会保留第一个“切换器”。

    代码:

    CKEDITOR.addTemplates( 'default',
    {
        imagesPath : CKEDITOR.getUrl( CKEDITOR.plugins.getPath( '../../../../wygwam_assets' ) + 'template-thumbs/' ),
    
    // Template definitions.
    templates :
        [
    
            /* toggler */
            {
                title: 'Expand & Collapse List',
                image: 'testing.png',
                description: 'Create a collapsed list of expandable items.  When each title is clicked, the content below will animate open and reveal the full content.',
                html:
                    '<div class="toggle_wrap"><ul>' +
                    '<li><div class="toggler">ITEM_TITLE</div><div class="togglee">ITEM_CONTENT</div></li>' +
    
                    '</ul></div>'
            }
        ]
    

    });

    奇怪的是,当在

  • 的最后一行的末尾按 enter 时,列表中的下一项添加了以下输出:
        <li>
            <div class="togglee">
            </div>
        </li>
    

    togglee div 就在那里!但是为什么不是toggler?!

  • 【问题讨论】:

      标签: ckeditor


      【解决方案1】:

      查看在 CKEditor 的配置中将 allowedContent 设置为 true 是否会产生影响。这用于去除样式和类属性等,因此基本上去除了默认情况下不允许的内容。

      例如

      CKEDITOR.editorConfig = function( config ) {
          config.allowedContent = true;
      };
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-03-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多