From b628dc562487d470048e5de22ab7245e184191a8 Mon Sep 17 00:00:00 2001 From: Stephan Kellermayr Date: Wed, 26 Jun 2024 18:35:03 +0200 Subject: [PATCH] Switched from DataProcessor to lib.parseFunc_RTE --- Classes/UserFunc/ParseFuncRte.php | 39 +++++++++++++++++++++++ Configuration/TypoScript/setup.typoscript | 17 ++++++---- 2 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 Classes/UserFunc/ParseFuncRte.php diff --git a/Classes/UserFunc/ParseFuncRte.php b/Classes/UserFunc/ParseFuncRte.php new file mode 100644 index 0000000..80573db --- /dev/null +++ b/Classes/UserFunc/ParseFuncRte.php @@ -0,0 +1,39 @@ + tags that contain the "data-iconfig" attribute. + * + * @param string The content to be processed. + * @param array TypoScript properties. + * @return string The content with replaced icon-tags. + */ + public function replaceIcons(string $content, array $conf): string + { + /** @var HtmlParser $htmlParser */ + $htmlParser = GeneralUtility::makeInstance(HtmlParser::class); + return GeneralUtility::makeInstance(IconpackHtmlParser::class)->transformIconsForOutput( + $content, + $htmlParser + ); + } +} diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 5cb4b9c..9009fc9 100755 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -27,15 +27,15 @@ lib.contentElement { 5 = EXT:iconpack/Resources/Private/Partials/FluidStyledContent/ } dataProcessing { - # This is required to render icons in RTE fields! - # The output is controlled exclusively by the DataProcessor and then cleaned up by the Sanitizer. + # If you don't use 'lib.parseFunc_RTE.nonTypoTagUserFunc', this is required to render icons in RTE fields! + # The output is then controlled exclusively by the DataProcessor and then cleaned up by the Sanitizer. # # In this case the "bodytext" field is used, but you can also use your own RTE fields with this configuration. - 2212170002 = Quellenform\Iconpack\DataProcessing\IconpackProcessor - 2212170002 { - fieldName = bodytext - fieldType = rte - } + #2212170002 = Quellenform\Iconpack\DataProcessing\IconpackProcessor + #2212170002 { + # fieldName = bodytext + # fieldType = rte + #} # If you don't want to use the provided ViewHelper, you can render individual ifonfig fields directly: #[number] = Quellenform\Iconpack\DataProcessing\IconpackProcessor #[number] { @@ -66,3 +66,6 @@ lib.parseFunc_RTE.allowTags := addToList(icon, svg, use, g, line, path, polyline # Restrict various attributes in SVG elements lib.parseFunc_RTE.nonTypoTagStdWrap.HTMLparser.tags.svg.allowedAttribs = id, name, class, style, fill, viewBox, xmlns, width, height, role, aria-hidden + +# Render icons in RTE fields +lib.parseFunc_RTE.nonTypoTagUserFunc = Quellenform\Iconpack\UserFunc\ParseFuncRte->replaceIcons