Skip to content

Instantly share code, notes, and snippets.

@Mykola-Veryha
Created June 5, 2020 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mykola-Veryha/09f55b2a7b9e2f39da1da058797a47aa to your computer and use it in GitHub Desktop.
Save Mykola-Veryha/09f55b2a7b9e2f39da1da058797a47aa to your computer and use it in GitHub Desktop.
Drupal 8 CKEditor filter
<?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