mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Merge pull request #4473 from ErisDS/editor-fix
Fix issue with editor and images
This commit is contained in:
commit
09bd71fcdb
2 changed files with 34 additions and 6 deletions
|
@ -55,7 +55,8 @@ Codemirror = Ember.TextArea.extend(MarkerManager, {
|
||||||
},
|
},
|
||||||
|
|
||||||
afterRenderEvent: function () {
|
afterRenderEvent: function () {
|
||||||
var codemirror;
|
var self = this,
|
||||||
|
codemirror;
|
||||||
|
|
||||||
// replaces CodeMirror with TouchEditor only if we're on mobile
|
// replaces CodeMirror with TouchEditor only if we're on mobile
|
||||||
mobileCodeMirror.createIfMobile();
|
mobileCodeMirror.createIfMobile();
|
||||||
|
@ -68,6 +69,10 @@ Codemirror = Ember.TextArea.extend(MarkerManager, {
|
||||||
if (this.get('focus') && this.get('focusCursorAtEnd')) {
|
if (this.get('focus') && this.get('focusCursorAtEnd')) {
|
||||||
codemirror.execCommand('goDocEnd');
|
codemirror.execCommand('goDocEnd');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
codemirror.eachLine(function initMarkers() {
|
||||||
|
self.initMarkers.apply(self, arguments);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// this needs to be placed on the 'afterRender' queue otherwise CodeMirror gets wonky
|
// this needs to be placed on the 'afterRender' queue otherwise CodeMirror gets wonky
|
||||||
|
@ -117,10 +122,6 @@ Codemirror = Ember.TextArea.extend(MarkerManager, {
|
||||||
self.sendAction('onFocusIn');
|
self.sendAction('onFocusIn');
|
||||||
});
|
});
|
||||||
|
|
||||||
codemirror.eachLine(function initMarkers() {
|
|
||||||
self.initMarkers.apply(self, arguments);
|
|
||||||
});
|
|
||||||
|
|
||||||
return codemirror;
|
return codemirror;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ CasperTest.begin('Ghost editor functions correctly', 20, function suite(test) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
CasperTest.begin('Image Uploads', 20, function suite(test) {
|
CasperTest.begin('Image Uploads', 24, function suite(test) {
|
||||||
test.assertHTMLEquals = function (equals, message) {
|
test.assertHTMLEquals = function (equals, message) {
|
||||||
test.assertEvalEquals(function () {
|
test.assertEvalEquals(function () {
|
||||||
return document.querySelector('.entry-preview .rendered-markdown').innerHTML
|
return document.querySelector('.entry-preview .rendered-markdown').innerHTML
|
||||||
|
@ -243,6 +243,33 @@ CasperTest.begin('Image Uploads', 20, function suite(test) {
|
||||||
var imageJQuerySelector = '.entry-preview img.js-upload-target[src="' + imageURL + '"]';
|
var imageJQuerySelector = '.entry-preview img.js-upload-target[src="' + imageURL + '"]';
|
||||||
test.assertExists(imageJQuerySelector, 'Uploaded image tag properly links to inputted image URL');
|
test.assertExists(imageJQuerySelector, 'Uploaded image tag properly links to inputted image URL');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Save the post with the image
|
||||||
|
casper.thenClick('.js-publish-button');
|
||||||
|
|
||||||
|
casper.waitForSelector('.notification-success', function onSuccess() {
|
||||||
|
test.assertUrlMatch(/ghost\/editor\/\d+\/$/, 'got an id on our URL');
|
||||||
|
}, casper.failOnTimeout(test, 'Post was not successfully created'));
|
||||||
|
|
||||||
|
casper.thenTransitionAndWaitForScreenLoad('content', function canTransition() {
|
||||||
|
test.assert(true, 'Can transition to content screen');
|
||||||
|
test.assertUrlMatch(/ghost\/\d+\/$/, 'content transitions to correct url');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Edit the draft post we just created
|
||||||
|
casper.thenClick('.content-preview a.post-edit');
|
||||||
|
|
||||||
|
casper.then(function () {
|
||||||
|
casper.writeContentToCodeMirror('abcdefghijklmnopqrstuvwxyz');
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.waitForSelectorTextChange('.entry-preview .rendered-markdown', function onSuccess() {
|
||||||
|
test.assertSelectorHasText(
|
||||||
|
'.entry-preview .rendered-markdown',//
|
||||||
|
'abcdefghijklmnopqrstuvwxyz',
|
||||||
|
'Editor HTML preview has correct text after editing.'
|
||||||
|
);
|
||||||
|
}, casper.failOnTimeout(test, 'markdown did not re-render'));
|
||||||
});
|
});
|
||||||
|
|
||||||
CasperTest.begin('Tag editor', 7, function suite(test) {
|
CasperTest.begin('Tag editor', 7, function suite(test) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue