Sha256: 303dc94d6d7bbcc8c246fe42cf99ddbdf509f0a7afe31af43fcf07f9091afd16

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

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 "<img src='#{ url }' />"

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spina-1.0.3 app/assets/javascripts/spina/admin/trix.coffee.erb
spina-1.0.2 app/assets/javascripts/spina/admin/trix.coffee.erb
spina-1.0.1 app/assets/javascripts/spina/admin/trix.coffee.erb
spina-1.0.0 app/assets/javascripts/spina/admin/trix.coffee.erb