window.Spina = {} Trix.config.blockAttributes = $.extend Trix.config.blockAttributes, { heading2: tagName: "h2" terminal: true breakOnReturn: true group: false heading3: tagName: "h3" terminal: true breakOnReturn: true group: false heading4: tagName: "h4" terminal: true breakOnReturn: true group: false heading5: tagName: "h5" terminal: true breakOnReturn: true group: false heading6: tagName: "h6" terminal: true breakOnReturn: true group: false } class Spina.TrixAttachment @imageSelect: (e) -> editor_id = $(this).closest('trix-toolbar').data('trix-editor-id') $.get("<%= Spina::Engine.routes.url_helpers.admin_media_picker_path %>" + "?trix_editor_id=#{editor_id}") @imageInsert: (e, url) -> this.editor.insertHTML "" document.addEventListener 'trix-file-accept', (e) -> e.preventDefault() $(document).on 'click', '.js-trix-image', Spina.TrixAttachment.imageSelect $(document).on 'image-insert', 'trix-editor', Spina.TrixAttachment.imageInsert