Skip to content

Instantly share code, notes, and snippets.

View AntonioPrimera's full-sized avatar
🛎️
LaraBell

Antonio Primera AntonioPrimera

🛎️
LaraBell
View GitHub Profile
@AntonioPrimera
AntonioPrimera / html_purifier_config_for_trix_editor.php
Created January 12, 2018 12:56
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');
@AntonioPrimera
AntonioPrimera / trix-content-after-htmlpurifier.html
Created January 11, 2018 17:54
Trix editor content after purifying it with htmlpurifier
<div>
<span data-trix-cursor-target="left" data-trix-serialize="false"></span>
<a href="/storage/images/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png" tabindex="-1" data-trix-attachment="{"contentType":"image/png","filename":"image_01.png","filesize":380974,"height":479,"href":"/storage/images/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png","url":"/storage/images/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png","width":468}" data-trix-content-type="image/png" data-trix-id="253" contenteditable="false">
</a><figure class="attachment attachment--preview attachment--png"><a href="/storage/images/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png" tabindex="-1" data-trix-attachment="{"contentType":"image/png","filename":"image_01.png","filesize":380974,"height":479,"href":"/storage/images/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png","url":"/storage/images/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png","width":468}" data-trix-content-type="image/png" data-trix-id="253" contenteditable="false">
<img src="/storage/image
@AntonioPrimera
AntonioPrimera / HtmlPurifier.php
Created January 11, 2018 17:51
HtmlPurifier - Trix Editor
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');
@AntonioPrimera
AntonioPrimera / trix-content-after-sb-purify.html
Created January 10, 2018 23:54
Trix editor content after sanitizing with stevebauman/purify
<div><span></span>
<a href="/storage/original/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png" data-trix-attachment="{&quot;contentType&quot;:&quot;image/png&quot;,&quot;filename&quot;:&quot;image_01.png&quot;,&quot;filesize&quot;:294205,&quot;height&quot;:318,&quot;href&quot;:&quot;/storage/original/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png&quot;,&quot;url&quot;:&quot;/storage/original/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png&quot;,&quot;width&quot;:500}" data-trix-content-type="image/png">
</a>
<figure class="attachment attachment--preview attachment--png">
<a href="/storage/original/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png" data-trix-attachment="{&quot;contentType&quot;:&quot;image/png&quot;,&quot;filename&quot;:&quot;image_01.png&quot;,&quot;filesize&quot;:294205,&quot;height&quot;:318,&quot;href&quot;:&quot;/storage/original/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png&quot;,&quot;url&quot;:&quot;/storage/original/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png&quot;,&quot;width&quot;:500}" d
@AntonioPrimera
AntonioPrimera / trix-content-before-sb-purify.html
Created January 10, 2018 23:52
Trix editor content before sanitizing with stevebauman/purify
<div><!--block-->
<span data-trix-cursor-target="left" data-trix-serialize="false"></span>
<a href="/storage/images/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png" tabindex="-1" data-trix-attachment="{&quot;contentType&quot;:&quot;image/png&quot;,&quot;filename&quot;:&quot;image_01.png&quot;,&quot;filesize&quot;:380974,&quot;height&quot;:479,&quot;href&quot;:&quot;/storage/images/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png&quot;,&quot;url&quot;:&quot;/storage/images/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png&quot;,&quot;width&quot;:468}" data-trix-content-type="image/png" data-trix-id="253" contenteditable="false">
<figure class="attachment attachment--preview attachment--png">
<img src="/storage/images/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png" data-trix-mutable="true" width="468" height="479" data-trix-store-key="imageElement/253/https://sef.dev/storage/images/csj7OIvDjJoyY6ifud9DdhhCcn3FkODBWnqIq6kF.png/409/418">
<figcaption class="attachment__caption" data-trix-placeholder="Add a caption…">