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