Skip to content

Commit

Permalink
Switched from DataProcessor to lib.parseFunc_RTE
Browse files Browse the repository at this point in the history
  • Loading branch information
stephankellermayr committed Jun 26, 2024
1 parent 0d96497 commit b628dc5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
39 changes: 39 additions & 0 deletions Classes/UserFunc/ParseFuncRte.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace Quellenform\Iconpack\UserFunc;

/*
* This file is part of the "iconpack" Extension for TYPO3 CMS.
*
* Conceived and written by Stephan Kellermayr
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/

use Quellenform\Iconpack\Html\IconpackHtmlParser;
use TYPO3\CMS\Core\Html\HtmlParser;
use TYPO3\CMS\Core\Utility\GeneralUtility;

final class ParseFuncRte
{

/**
* This replaces all <span> 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
);
}
}
17 changes: 10 additions & 7 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down Expand Up @@ -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

0 comments on commit b628dc5

Please sign in to comment.