Sha256: ae8f769511b1d6171996b1500d7d2acd10c9d97b9c802c4bb48fdd93dd3690b4

Contents?: true

Size: 1.35 KB

Versions: 19

Compression:

Stored size: 1.35 KB

Contents

# https://imperavi.com/article/

uploadActiveStorage = (editor, data) ->
  for file in data.files
    upload = new ActiveStorage.DirectUpload(file, '/rails/active_storage/direct_uploads')

    upload.create (error, blob) =>
      url = '/rails/active_storage/blobs/redirect/' + blob.signed_id + '/' + blob.filename
      editor.complete({ file: { url: url, name: blob.filename, content_type: blob.content_type }}, data.e)

insertUploadByDrop = (response, e) ->
  if @app.block.is()
    instance = @app.block.get()
    target = e.target
    type = instance.getType()

    if ((type == 'card' && target && target.tagName == 'IMG' && instance.hasImage()) || type == 'image')
      return @change(response)
    else if (e && type != 'card' && instance.isEditable())
      @app.insertion.insertPoint(e)

  content_type = (response.file.content_type || '')

  unless content_type.startsWith('image') && @app.filelink
    @app.filelink._insert(response)
  else
    @insert(response)

(this.EffectiveBootstrap || {}).effective_article_editor = ($element, options) ->

  if options['active_storage']
    options['image'] = {
      upload: (editor, data) -> uploadActiveStorage(editor, data)
    }

    options['filelink'] = {
      upload: (editor, data) -> uploadActiveStorage(editor, data)
    }

  editor = ArticleEditor($element, options)
  editor.app.image.insertByDrop = insertUploadByDrop

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
effective_bootstrap-0.10.9 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.10.8 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.10.7 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.10.6 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.10.5 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.10.4 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.10.3 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.10.2 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.10.1 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.10.0 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.9.49 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.9.48 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.9.47 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.9.46 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.9.45 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.9.44 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.9.43 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.9.42 app/assets/javascripts/effective_article_editor/initialize.js.coffee
effective_bootstrap-0.9.41 app/assets/javascripts/effective_article_editor/initialize.js.coffee