mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 19:52:01 +03:00
5db6fc4f18
closes #4368, fixes #1240 (spellcheck), fixes #4974 & fixes #4983 (caret positioning bugs) - Drop CodeMirror in favour of a plain text area - Use rangyinputs to handle selections cross-browser - Create an API for interacting with the textarea - Replace marker manager with a much simpler image manager - Reimplement shortcuts, including some bug fixes
42 lines
1.5 KiB
JavaScript
42 lines
1.5 KiB
JavaScript
import Ember from 'ember';
|
|
import uploader from 'ghost/assets/lib/uploader';
|
|
|
|
var Preview = Ember.Component.extend({
|
|
didInsertElement: function () {
|
|
this.set('scrollWrapper', this.$().closest('.entry-preview-content'));
|
|
Ember.run.scheduleOnce('afterRender', this, this.dropzoneHandler);
|
|
},
|
|
|
|
adjustScrollPosition: function () {
|
|
var scrollWrapper = this.get('scrollWrapper'),
|
|
scrollPosition = this.get('scrollPosition');
|
|
|
|
scrollWrapper.scrollTop(scrollPosition);
|
|
}.observes('scrollPosition'),
|
|
|
|
dropzoneHandler: function () {
|
|
var dropzones = $('.js-drop-zone');
|
|
|
|
uploader.call(dropzones, {
|
|
editor: true,
|
|
fileStorage: this.get('config.fileStorage')
|
|
});
|
|
|
|
dropzones.on('uploadstart', Ember.run.bind(this, 'sendAction', 'uploadStarted'));
|
|
dropzones.on('uploadfailure', Ember.run.bind(this, 'sendAction', 'uploadFinished'));
|
|
dropzones.on('uploadsuccess', Ember.run.bind(this, 'sendAction', 'uploadFinished'));
|
|
dropzones.on('uploadsuccess', Ember.run.bind(this, 'sendAction', 'uploadSuccess'));
|
|
|
|
// Set the current height so we can listen
|
|
this.set('height', this.$().height());
|
|
},
|
|
|
|
// fire off 'enable' API function from uploadManager
|
|
// might need to make sure markdown has been processed first
|
|
reInitDropzones: function () {
|
|
Ember.run.scheduleOnce('afterRender', this, this.dropzoneHandler);
|
|
}.observes('markdown')
|
|
});
|
|
|
|
export default Preview;
|