netresearch / t3x-rte_ckeditor_image

Image support in CKEditor for the TYPO3 ecosystem
GNU Affero General Public License v3.0
56 stars 65 forks source link

StylesSet for images #278

Open jblechinger opened 7 months ago

jblechinger commented 7 months ago

Is there any way to use RTE StylesSet's with images?

image

I already tried: - { name: "Image special style", element: "img", attributes: { 'class': 'img-style' } }

Thanks 😊

wwenzel commented 7 months ago

Unfortunally, I have the same problem. All entries in StylesSet for element: "img" are ignored (till TYPO3 V10/11 this works fine).

Is there any mistake in the notation above or is handling completly changed in TYPO3 V12?

Any help is welcome. Thanks.

wwenzel commented 7 months ago

I tried this new syntax for ckeditor5 but it also doesn't work: style: definitions: - { name: "Image special style", element: "img", classes: ['img-style' ] }

Anyone any idea whats wrong?

thommyhh commented 2 months ago

I started debugging this issue, as I ran into it.

The root problem seems to be, that the CKEditor registers image stuff, even thought the CKEditor image plugin is not loaded. The style definitions are parsed and "compiled" directly, when the style plugin is initialized. This leads to, that the registration of the typo3image model with the img tag happens to late, to make it into the compiled style definitions.

When the style is checked against the selected element, the registered model names are checked. The CKEditor core registers imageInline, imageBlock as block elements with the img tag. That's why the typo3image is not recognized, when checking the styles.

I created an extra branch (#300) and made is so far, that the styles are enabled, when an image is selected and the correct style is displayed as active. However I can't get it change the class, when choosing another one. Feel free to use my branch and give it a try.

thommyhh commented 2 months ago

@jblechinger @wwenzel It just finished my PR (#300) and the style dropdown now works again. Would you mind testing my branch?

@Gitsko Would you take a look at the PR?