app/assets/javascripts/spina/admin/trix.coffee.erb in spina-0.12.0 vs app/assets/javascripts/spina/admin/trix.coffee.erb in spina-1.0.0
- old
+ new
@@ -27,21 +27,18 @@
breakOnReturn: true
group: false
}
class Spina.TrixAttachment
- @photoSelect: (e) ->
- console.log 'hi'
+ @imageSelect: (e) ->
editor_id = $(this).closest('trix-toolbar').data('trix-editor-id')
- $.get("<%= Spina::Engine.routes.url_helpers.trix_select_admin_photos_path('') %>/#{editor_id}")
+ $.get("<%= Spina::Engine.routes.url_helpers.admin_media_picker_path %>" + "?trix_editor_id=#{editor_id}")
- @photoInsert: (e, url) ->
- length = this.editor.getDocument().toString().length
- this.editor.setSelectedRange(length - 1)
+ @imageInsert: (e, url) ->
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 'click', '.js-trix-image', Spina.TrixAttachment.imageSelect
-$(document).on 'photo-insert', 'trix-editor', Spina.TrixAttachment.photoInsert
+$(document).on 'image-insert', 'trix-editor', Spina.TrixAttachment.imageInsert