问题
On a plain TYPO3 8 installation, I want ckeditor to allow the img tag in the source, without enabling the image plugin. The default configuration of ckeditor in TYPO3 removes the image plugin, which causes img tags to be removed as well.
According to the ckeditor documentation, this can be achieved with the property
config.extraAllowedContent = 'img'
but it does not work in my custom yaml configuration. img tags are always striped when I switch from source to wysiwyg mode.
If I enable the image plugin, img tags are kept. But I do not want to give to the editors this button as an option.
What am I doing wrong?
Here is my test yaml configuration. At the bottom is the extraAllowedContent option
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
回答1:
Based on @ikon answer, I managed to make the extraAllowedContent to work. Instead of
extraAllowedContent:
- img
it was enough to use
extraAllowedContent:
- img[!src,alt,width,height]
This keeps the img tags intact, without needing the image plugin
回答2:
In order to achieve this you need to switch to the custom mode of AFC: https://sdk.ckeditor.com/samples/acfcustom.html .
Use:
allowedContent: - img[!src,alt,width,height]
to allow images.
It might be tricky than to make configuration/filtering fitting to your presets: you have to add other allowed tags to allowedContent
list as well, otherwise the buttons for tables, list etc would not be rendered.
Avoid using
allowedContent: truebecause it would allow everything!
来源:https://stackoverflow.com/questions/49422412/typo3-ckeditor-allow-img-tag-without-enabling-image-plugin