From 9f87b5ec190aa375da047b6f282cc1ceac53e808 Mon Sep 17 00:00:00 2001 From: Benni Mack Date: Mon, 5 Dec 2022 15:23:13 +0100 Subject: [PATCH] [BUGFIX] Allow
tag outside of paragraph tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit
is allowed in HTML5 outside of paragraphs, thus it should also be configured like that out-of-the-box See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure Since CKEditor5 is using
around tables, and also might add a
both variants are now enabled by default. Resolves: #99273 Releases: main, 11.5, 10.4 Change-Id: I9356cc13ccef764f475ba42cc47f43f7ecd624a1 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76923 Tested-by: Frank Nägler Reviewed-by: Stefan Bürk Tested-by: Benni Mack Tested-by: Stefan Bürk Tested-by: core-ci Reviewed-by: Benni Mack Reviewed-by: Frank Nägler --- typo3/sysext/core/Classes/Html/RteHtmlParser.php | 6 ++++-- .../core/Tests/Unit/Html/RteHtmlParserTest.php | 13 ++++++++++++- .../rte_ckeditor/Configuration/RTE/Processing.yaml | 3 ++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/typo3/sysext/core/Classes/Html/RteHtmlParser.php b/typo3/sysext/core/Classes/Html/RteHtmlParser.php index 8267ebde3a44..3b281c09d51f 100644 --- a/typo3/sysext/core/Classes/Html/RteHtmlParser.php +++ b/typo3/sysext/core/Classes/Html/RteHtmlParser.php @@ -42,13 +42,13 @@ class RteHtmlParser extends HtmlParser implements LoggerAwareInterface * List of elements that are not wrapped into a "p" tag while doing the transformation. * @var string */ - protected $blockElementList = 'DIV,TABLE,BLOCKQUOTE,PRE,UL,OL,H1,H2,H3,H4,H5,H6,ADDRESS,DL,DD,HEADER,SECTION,FOOTER,NAV,ARTICLE,ASIDE'; + protected $blockElementList = 'DIV,TABLE,BLOCKQUOTE,PRE,UL,OL,H1,H2,H3,H4,H5,H6,ADDRESS,DL,DD,HEADER,SECTION,FOOTER,NAV,ARTICLE,ASIDE,FIGURE'; /** * List of all tags that are allowed by default * @var string */ - protected $defaultAllowedTagsList = 'b,i,u,a,img,br,div,center,pre,font,hr,sub,sup,p,strong,em,li,ul,ol,blockquote,strike,span,abbr,acronym,dfn'; + protected $defaultAllowedTagsList = 'b,i,u,a,img,br,div,center,pre,figure,figcaption,font,hr,sub,sup,p,strong,em,li,ul,ol,blockquote,strike,span,abbr,acronym,dfn'; /** * Set to the TSconfig options coming from Page TSconfig @@ -111,6 +111,8 @@ class RteHtmlParser extends HtmlParser implements LoggerAwareInterface 'blockquote', 'div', 'footer', + 'figure', + 'figcaption', 'header', 'hr', 'nav', diff --git a/typo3/sysext/core/Tests/Unit/Html/RteHtmlParserTest.php b/typo3/sysext/core/Tests/Unit/Html/RteHtmlParserTest.php index c29404142ced..ce173ffaa84c 100644 --- a/typo3/sysext/core/Tests/Unit/Html/RteHtmlParserTest.php +++ b/typo3/sysext/core/Tests/Unit/Html/RteHtmlParserTest.php @@ -25,7 +25,7 @@ class RteHtmlParserTest extends UnitTestCase { protected bool $resetSingletonInstances = true; - protected array $procOptions = ['overruleMode' => 'default', 'allowTagsOutside' => 'hr,abbr']; + protected array $procOptions = ['overruleMode' => 'default', 'allowTagsOutside' => 'hr,abbr,figure']; /** * Data provider for hrTagCorrectlyTransformedOnWayToDataBase @@ -743,4 +743,15 @@ public function allowTagsOutsidePreventsWrappingTaginPTag(): void self::assertEquals('Allowed outside of p-tag', $subject->transformTextForRichTextEditor('Allowed outside of p-tag', $this->procOptions)); self::assertEquals('

Not allowed outside of p-tag

', $subject->transformTextForRichTextEditor('Not allowed outside of p-tag', $this->procOptions)); } + + /** + * @test + */ + public function tableAndFigureApplyCorrectlyOutsideOfParagraphTags(): void + { + $eventDispatcher = $this->createMock(EventDispatcherInterface::class); + $subject = new RteHtmlParser($eventDispatcher); + self::assertEquals('
' . CRLF . 'Allowed outside of p-tag
' . CRLF . '
', $subject->transformTextForRichTextEditor('
' . CRLF . 'Allowed outside of p-tag
' . CRLF . '
', $this->procOptions)); + self::assertEquals('
' . CRLF . 'Allowed outside of p-tag
' . CRLF . '
My Logo
', $subject->transformTextForRichTextEditor('
' . CRLF . 'Allowed outside of p-tag
' . CRLF . '
My Logo
', $this->procOptions)); + } } diff --git a/typo3/sysext/rte_ckeditor/Configuration/RTE/Processing.yaml b/typo3/sysext/rte_ckeditor/Configuration/RTE/Processing.yaml index 479a87ee8f61..6f4a2348dc84 100644 --- a/typo3/sysext/rte_ckeditor/Configuration/RTE/Processing.yaml +++ b/typo3/sysext/rte_ckeditor/Configuration/RTE/Processing.yaml @@ -27,6 +27,7 @@ processing: - dt - em - figure + - figcaption - footer - header - h1 @@ -66,7 +67,7 @@ processing: - var ## Tags that are allowed outside of paragraphs - allowTagsOutside: [address, article, aside, blockquote, figure, footer, header, hr, nav, section, div] + allowTagsOutside: [address, article, aside, blockquote, figure, figcaption, footer, header, hr, nav, section, div] ## allowed default attributes allowAttributes: [class, id, title, dir, lang, xml:lang, itemscope, itemtype, itemprop]