Guest User

Untitled

a guest
Jan 21st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. public function htmlPurifier()
  2. {
  3. $config = \HTMLPurifier_Config::createDefault();
  4. $config->set('HTML.DefinitionID', 'basecamp-trix-editor');
  5. $config->set('HTML.DefinitionRev', 1);
  6.  
  7. if ($def = $config->maybeGetRawHTMLDefinition()) {
  8. $def->addElement('figure', 'Block', 'Flow', 'Common');
  9. $def->addAttribute('figure', 'class', 'Text');
  10.  
  11. $def->addElement('figcaption', 'Block', 'Flow', 'Common');
  12. $def->addAttribute('figcaption', 'class', 'Text');
  13. $def->addAttribute('figcaption', 'data-trix-placeholder', 'Text');
  14.  
  15. $def->addAttribute('a', 'rel', 'Text');
  16. $def->addAttribute('a', 'tabindex', 'Text');
  17. $def->addAttribute('a', 'contenteditable', 'Enum#true,false');
  18. $def->addAttribute('a', 'data-trix-attachment', 'Text');
  19. $def->addAttribute('a', 'data-trix-content-type', 'Text');
  20. $def->addAttribute('a', 'data-trix-id', 'Number');
  21.  
  22. $def->addElement('span', 'Block', 'Flow', 'Common');
  23. $def->addAttribute('span', 'data-trix-cursor-target', 'Enum#right,left');
  24. $def->addAttribute('span', 'data-trix-serialize', 'Enum#true,false');
  25.  
  26. $def->addAttribute('img', 'data-trix-mutable', 'Enum#true,false');
  27. $def->addAttribute('img', 'data-trix-store-key', 'Text');
  28.  
  29. }
  30.  
  31. $purifier = new \HTMLPurifier($config);
  32. $original = file_get_contents(base_path('/reference/trix-output-original.html'));
  33. $processed = $purifier->purify($original);
  34.  
  35. return view('Home.htmlPurifier', compact('original', 'processed'));
  36. }
Add Comment
Please, Sign In to add comment