Created
June 5, 2020 16:28
-
-
Save Mykola-Veryha/09f55b2a7b9e2f39da1da058797a47aa to your computer and use it in GitHub Desktop.
Drupal 8 CKEditor filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\MODULE_NAME\Plugin\Filter; | |
use Drupal\filter\FilterProcessResult; | |
use Drupal\filter\Plugin\FilterBase; | |
/** | |
* Provides a filter to limit allowed HTML tags. | |
* | |
* @Filter( | |
* id = "filter_font_family", | |
* title = @Translation("Font family filter"), | |
* type = Drupal\filter\Plugin\FilterInterface::TYPE_HTML_RESTRICTOR, | |
* settings = {}, | |
* weight = -10 | |
* ) | |
*/ | |
class FontFamilyFilter extends FilterBase { | |
/** | |
* {@inheritdoc} | |
*/ | |
public function process($text, $langcode) { | |
return new FilterProcessResult($text); | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function getHTMLRestrictions() { | |
$restrictions = []; | |
$restrictions['forbidden_tags'][] = 'font face'; | |
return $restrictions; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment