mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
ce9d590f34
Closes #4431 - The PSM does not reset on a transition from editor (existing post) to editor (new post). If the existing post had a cover image, the image uploader would not be reset during the transition and appear slightly broken in the editor for the new post. - In this PR: A reference to the uploader is saved, allowing the route for editor/new to instruct the PSM controller to have the uploader reset.
35 lines
947 B
JavaScript
35 lines
947 B
JavaScript
import uploader from 'ghost/assets/lib/uploader';
|
|
|
|
var PostImageUploader = Ember.Component.extend({
|
|
classNames: ['image-uploader', 'js-post-image-upload'],
|
|
|
|
setup: function () {
|
|
var $this = this.$(),
|
|
self = this;
|
|
|
|
this.set('uploaderReference', uploader.call($this, {
|
|
editor: true,
|
|
fileStorage: this.get('config.fileStorage')
|
|
}));
|
|
|
|
$this.on('uploadsuccess', function (event, result) {
|
|
if (result && result !== '' && result !== 'http://') {
|
|
self.sendAction('uploaded', result);
|
|
}
|
|
});
|
|
|
|
$this.find('.js-cancel').on('click', function () {
|
|
self.sendAction('canceled');
|
|
});
|
|
}.on('didInsertElement'),
|
|
|
|
removeListeners: function () {
|
|
var $this = this.$();
|
|
|
|
$this.off();
|
|
$this.find('.js-cancel').off();
|
|
}.on('willDestroyElement')
|
|
});
|
|
|
|
export default PostImageUploader;
|