Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AntonioPrimera/e955fddd64f1271070cbb37806ed0451 to your computer and use it in GitHub Desktop.
Save AntonioPrimera/e955fddd64f1271070cbb37806ed0451 to your computer and use it in GitHub Desktop.
HTML Purifier config for Trix-Editor
$config = \HTMLPurifier_Config::createDefault();
$config->set('HTML.DefinitionID', 'basecamp-trix-editor');
$config->set('HTML.DefinitionRev', 1);
$config->set('HTML.TidyLevel', 'none');
if ($def = $config->maybeGetRawHTMLDefinition()) {
$def->addElement('figure', 'Inline', 'Inline', 'Common');
$def->addAttribute('figure', 'class', 'Text');
$def->addElement('figcaption', 'Inline', 'Inline', 'Common');
$def->addAttribute('figcaption', 'class', 'Text');
$def->addAttribute('figcaption', 'data-trix-placeholder', 'Text');
$def->addAttribute('a', 'rel', 'Text');
$def->addAttribute('a', 'tabindex', 'Text');
$def->addAttribute('a', 'contenteditable', 'Enum#true,false');
$def->addAttribute('a', 'data-trix-attachment', 'Text');
$def->addAttribute('a', 'data-trix-content-type', 'Text');
$def->addAttribute('a', 'data-trix-id', 'Number');
$def->addElement('span', 'Block', 'Flow', 'Common');
$def->addAttribute('span', 'data-trix-cursor-target', 'Enum#right,left');
$def->addAttribute('span', 'data-trix-serialize', 'Enum#true,false');
$def->addAttribute('img', 'data-trix-mutable', 'Enum#true,false');
$def->addAttribute('img', 'data-trix-store-key', 'Text');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment