-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #695 from YoranBrondsema/fix-694
Fix #694: Alignment of a section is removed when pressing "Enter"
- Loading branch information
Showing
3 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import Helpers from '../test-helpers'; | ||
|
||
const { module, test } = Helpers; | ||
|
||
let editor, editorElement; | ||
|
||
function renderEditor(...args) { | ||
editor = Helpers.mobiledoc.renderInto(editorElement, ...args); | ||
editor.selectRange(editor.post.tailPosition()); | ||
return editor; | ||
} | ||
|
||
module('Acceptance: Editor: Attributes', { | ||
beforeEach() { | ||
editorElement = $('#editor')[0]; | ||
}, | ||
afterEach() { | ||
if (editor) { editor.destroy(); } | ||
} | ||
}); | ||
|
||
test('pressing ENTER at the end of an aligned paragraph maintains the alignment (bug #694)', (assert) => { | ||
renderEditor(({post, markupSection, marker}) => { | ||
return post([ | ||
markupSection( | ||
'p', | ||
[marker('abc')], | ||
false, | ||
{ 'data-md-text-align': 'center' } | ||
) | ||
]); | ||
}); | ||
|
||
Helpers.dom.triggerEnter(editor); | ||
|
||
const firstParagraph = document.querySelector('#editor p:first-of-type'); | ||
assert.equal(firstParagraph.getAttribute('data-md-text-align'), 'center'); | ||
}); | ||
|
||
test('toggling the section inside an aligned list maintains the alignment of the list (bug #694)', (assert) => { | ||
renderEditor(({post, listSection, listItem, marker}) => { | ||
return post([ | ||
listSection( | ||
'ul', | ||
[ | ||
listItem([marker('abc')]), | ||
listItem([marker('123')]) | ||
], | ||
{ 'data-md-text-align': 'center' } | ||
) | ||
]); | ||
}); | ||
|
||
editor.run(postEditor => postEditor.toggleSection('h1')); | ||
|
||
const ul = document.querySelector('#editor ul'); | ||
assert.equal(ul.getAttribute('data-md-text-align'), 'center'); | ||
}); |