Sha256: 97d3eebf949e6dc0fe38b9e0a9564b9c95225a53b0e0349ac43eaab3f0650995

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

window.Spina = {}

Trix.config.blockAttributes = $.extend Trix.config.blockAttributes, {
  h1:
    tagName: 'h1'
    singleLine: true
    leaf: true
  h2:
    tagName: 'h2'
    singleLine: true
    leaf: true
  h3:
    tagName: 'h3'
    singleLine: true
    leaf: true
  h4:
    tagName: 'h4'
    singleLine: true
    leaf: true
  h5:
    tagName: 'h5'
    singleLine: true
    leaf: true
  h6:
    tagName: 'h6'
    singleLine: true
    leaf: true
}

class Spina.TrixAttachment
  @photoSelect: (e) ->
    editor_id = $(this).closest('trix-toolbar').data('editor-id')
    $.get("/admin/photos/wysihtml5_select/#{editor_id}")

  @photoInsert: (e, url) ->
    length = this.editor.getDocument().toString().length
    this.editor.setSelectedRange(length - 1)
    this.editor.insertHTML "<img src='#{ url }' />"

document.addEventListener 'trix-file-accept', (e) ->
  e.preventDefault()

$(document).on 'click', '.js-trix-photo', Spina.TrixAttachment.photoSelect

$(document).on 'photo-insert', 'trix-editor', Spina.TrixAttachment.photoInsert

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spina-0.9.0 app/assets/javascripts/spina/admin/spina.trix.js.coffee
spina-0.8.3 app/assets/javascripts/spina/admin/spina.trix.js.coffee
spina-0.8.2 app/assets/javascripts/spina/admin/spina.trix.js.coffee
spina-0.8.1 app/assets/javascripts/spina/admin/spina.trix.js.coffee
spina-0.8.0 app/assets/javascripts/spina/admin/spina.trix.js.coffee
spina-0.7.0 app/assets/javascripts/spina/admin/spina.trix.js.coffee