Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function htmlPurifier()
- {
- $config = \HTMLPurifier_Config::createDefault();
- $config->set('HTML.DefinitionID', 'basecamp-trix-editor');
- $config->set('HTML.DefinitionRev', 1);
- if ($def = $config->maybeGetRawHTMLDefinition()) {
- $def->addElement('figure', 'Block', 'Flow', 'Common');
- $def->addAttribute('figure', 'class', 'Text');
- $def->addElement('figcaption', 'Block', 'Flow', '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');
- }
- $purifier = new \HTMLPurifier($config);
- $original = file_get_contents(base_path('/reference/trix-output-original.html'));
- $processed = $purifier->purify($original);
- return view('Home.htmlPurifier', compact('original', 'processed'));
- }
Add Comment
Please, Sign In to add comment