【问题标题】:TYPO3 ckeditor: allow img tag without enabling image pluginTYPO3 ckeditor:允许 img 标签而不启用图像插件
【发布时间】:2018-08-31 12:31:49
【问题描述】:

在普通的 TYPO3 8 安装中,我希望 ckeditor 允许源中的 img 标签,而不启用图像插件。 TYPO3中ckeditor的默认配置去掉了图片插件,导致img标签也被去掉了。

根据ckeditor文档,这可以通过属性来实现

config.extraAllowedContent = 'img'

但它在我的自定义 yaml 配置中不起作用。当我从源代码切换到所见即所得模式时,img 标签总是条带化。

如果我启用图像插件,则会保留 img 标签。但我不想把这个按钮作为选项提供给编辑。

我做错了什么?

这是我的测试 yaml 配置。底部是 extraAllowedContent 选项

imports:
    - { resource: "EXT:rte_ckeditor/Configuration/RTE/Processing.yaml" }
    - { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Base.yaml" }
    - { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Plugins.yaml" }
editor:
  config:
    contentsCss: ["EXT:rte_ckeditor/Resources/Public/Css/contents.css", "EXT:tucmmforumhook/Resources/Public/Styles/Tucmain.css"]
    stylesSet:
      - { name: "XYZ Text", element: "span", attributes: { class: "highlighted red"} }
      - { name: "Button", element: "a", attributes: { class: "button"} }
      - { name: "Checklist", element: "ul", attributes: { class: "check-list"} }
    format_tags: "p;h2;h3;h4;h5"
    toolbarGroups:
      - { name: styles, groups: [ styles, format ] }
      - { name: basicstyles, groups: [ basicstyles ] }
      - { name: paragraph, groups: [ list, indent, blocks, align ] }
      - { name: links, groups: [ links ] }
      - { name: clipboard, groups: [ clipboard, cleanup, undo ] }
      - { name: editing, groups: [ spellchecker ] }
      - { name: insert, groups: [ insert ] }
      - { name: tools, groups: [ table, specialchar ] }
      - { name: document, groups: [ mode ] }
    justifyClasses:
      - text-left
      - text-center
      - text-right
      - text-justify
    extraPlugins:
      - justify
    removePlugins:
      - image
    removeButtons:
      - Strike
      - Anchor
      - Outdent
      - Indent
      - Blockquote
      - JustifyBlock

    extraAllowedContent:
      - img

【问题讨论】:

    标签: ckeditor typo3


    【解决方案1】:

    根据@ikon 的回答,我设法使 extraAllowedContent 起作用。而不是

    extraAllowedContent:
      - img
    

    足够用了

    extraAllowedContent:
      - img[!src,alt,width,height]
    

    这样可以保持 img 标签完好无损,不需要图像插件

    【讨论】:

      【解决方案2】:

      为了实现这一点,您需要切换到 AFC 的自定义模式: https://sdk.ckeditor.com/samples/acfcustom.html

      用途:

      允许的内容:
      - img[!src,alt,width,height]

      允许图像。 这可能比让配置/过滤适合您的预设更棘手:您还必须将其他允许的标签添加到allowedContentlist,否则表格、列表等按钮将不会呈现。

      避免使用

      allowedContent: true
      因为它允许一切!

      【讨论】:

      • 感谢@ikon 的回复。首先,让我说您的方法导致了正确的结果,但是当您指出我们自己时,我将不得不为我的所有标签添加更多配置设置。鉴于您的回复,我设法使 extraAllowedContent 配置工作。基本上,仅指定 img 是不够的,我必须添加示例的其余部分。我会自己添加这个问题的答案。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-15
      • 2019-08-12
      • 2013-04-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多