【问题标题】:Plone 5: why TinyMCE disable custom inline styles?Plone 5:为什么 TinyMCE 禁用自定义内联样式?
【发布时间】:2015-11-20 13:51:29
【问题描述】:

我在 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 编辑器正确渲染菜单:

但是新闻条目是“禁用的”,点击它什么也不会。 检查我发现的 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 是否以某种方式“测试”该类以启用/禁用它们? 还是这个问题与 Plone 有关?

【问题讨论】:

  • 请注意,内联样式的语法代表Your Format Title|format_id|icon。对于块样式,您只是没有图标。所以这与 Plone 4 的 tinymce.xml 不同,您可以在其中指定 Your Format Title|tag|class。这就是为什么您需要额外的 JSON 结构的原因,您可以在其中定义每种格式,并以它的 id 为键。见github.com/davilima6/smdu.participacao/blob/master/src/smdu/…

标签: tinymce plone plone-5.x


【解决方案1】:

经过大量调试,在模型+Plone JSON conf+TinyMCE 地狱中迷失自我,我找到了 那个 用例的解决方案:

拥有额外且有效的内联样式是“内联样式”配置的问题...

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

所以:您也可以通过提供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>

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

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

请参阅https://github.com/plone/Products.CMFPlone/issues/492https://github.com/plone/Products.CMFPlone/issues/1264 了解更多信息。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-14
  • 1970-01-01
  • 2017-07-14
  • 2013-03-27
  • 1970-01-01
相关资源
最近更新 更多