Plone 5:为什么TinyMCE禁用自定义内联样式?

时间:2015-11-20 13:51:29

标签: tinymce plone plone-5.x

我在TinyMCE和Plone 5上存在问题,但我不确定问题的核心是Plone CMS还是TinyMCE。

我在TinyMCE控制面板配置中添加自定义样式(" TinyMCE设置" - >"内联样式")。

新配置如下:

Bold|bold|bold
Italic|italic|italic
Underline|underline|underline
Strikethrough|strikethrough|strikethrough
Superscript|superscript|superscript
Subscript|subscript|subscript
Code|code|code
Custom style|customClass|custom-class

然后TinyMCE编辑器正确呈现菜单:

enter image description here

但新闻条目已被禁用"点击它将无效。 检查TinyMCE菜单的标记我发现:

<div aria-checked="false" aria-disabled="true" role="menuitem" id="mceu_155" class="mce-menu-item mce-menu-item-preview mce-stack-layout-item mce-last mce-disabled" tabindex="-1">
    <i class="mce-ico mce-i-custom-class"></i>&nbsp;
    <span id="mceu_155-text" class="mce-text">Custom style</span>
</div>

所以:TinyMCE正在禁用它。这个问题似乎与我使用的课程有关,而不是我给的名字或缺少的图标。 如果我使用另一种风格的副本,比如......

...
Custom style|italic|custom-class

......它有效。如果我使用另一个知道Plone类的话就像......

...
Custom style|discreet|custom-class

......但是不允许其他类别。

这与TinyMCE内部相关吗?是不是TinyMCE&#34;测试&#34;启用/禁用它们的类? 或者这个问题与Plone有关吗?

1 个答案:

答案 0 :(得分:6)

经过大量的调试,在模型+ Plone JSON conf + TinyMCE地狱中失去自己,我找到了的解决方案 usecase:

拥有额外的工作内联风格是“内联样式”配置的问题......

enter image description here

...和“格式”配置......

enter image description here

所以:您也可以通过提供registry.xml通用设置轻松配置,如下所示:

<registry>

    <record name="plone.inline_styles" interface="Products.CMFPlone.interfaces.controlpanel.ITinyMCESchema" field="inline_styles">
        <value>
            <element>Bold|bold|bold</element>
            <element>Italic|italic|italic</element>
            <element>Underline|underline|underline</element>
            <element>Strikethrough|strikethrough|strikethrough</element>
            <element>Superscript|superscript|superscript</element>
            <element>Subscript|subscript|subscript</element>
            <element>Code|code|code</element>
            <element>Foo Bar Baz|foo|foo</element>
        </value>
    </record>

    <record name="plone.formats" interface="Products.CMFPlone.interfaces.controlpanel.ITinyMCESchema" field="formats">
        <value>{
    "clearfix": {
        "classes": "clearfix",
        "block": "div"
    },
    "discreet": {
        "inline": "span",
        "classes": "discreet"
    },
    "foo": {
        "inline": "span",
        "classes": "foo"
    }
}
</value>
    </record>

</registry>

注意:这与“格式”菜单的内容相关。

enter image description here

由于TinyMCE importcss插件,可以从++plone++static/tinymce-styles.css样式表自动加载样式。

有关详情,请参阅https://github.com/plone/Products.CMFPlone/issues/492https://github.com/plone/Products.CMFPlone/issues/1264