FilterTemplates.php in Wysiwyg API template plugin 8.2
Same filename and directory in other branches
File
modules/wysiwyg_template_core/src/Plugin/Filter/FilterTemplates.phpView source
<?php
namespace Drupal\wysiwyg_template_core\Plugin\Filter;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
/**
* Provides a filter to remove WYSIWYG-specific markup from rendering.
*
* @Filter(
* id = "filter_wysiwyg_cleanup",
* title = @Translation("Cleanup Wysiwyg templates"),
* description = @Translation("Wysiwyg templates can contain code and attributes that are important for editing but should be removed on public pages."),
* type = Drupal\filter\Plugin\FilterInterface::TYPE_HTML_RESTRICTOR,
* weight = 10
* )
*/
class FilterTemplates extends FilterBase {
/**
* {@inheritdoc}
*/
public function process($text, $langcode) : FilterProcessResult {
// @todo While this was how the filter worked in 7.x, this should be ported
// to use the attribute filtering logic in core.
// @see \Drupal\filter\Plugin\Filter\FilterHtml
$text = str_replace([
'contenteditable="true"',
'contenteditable="false"',
], '', $text);
return new FilterProcessResult($text);
}
}
Classes
Name | Description |
---|---|
FilterTemplates | Provides a filter to remove WYSIWYG-specific markup from rendering. |