FIX: blockquote button implementation
Previously clicking on blockquote in the middle of sentence would result in incorrect formatting
This commit is contained in:
parent
5897ae945a
commit
e2f57a154b
|
@ -78,7 +78,7 @@ class Toolbar {
|
||||||
group: 'insertions',
|
group: 'insertions',
|
||||||
icon: 'quote-right',
|
icon: 'quote-right',
|
||||||
shortcut: 'Shift+9',
|
shortcut: 'Shift+9',
|
||||||
perform: e => e.applySurround('> ', '', 'code_text')
|
perform: e => e.applyList('> ', 'blockquote_text')
|
||||||
});
|
});
|
||||||
|
|
||||||
this.addButton({id: 'code', group: 'insertions', shortcut: 'Shift+C', action: 'formatCode'});
|
this.addButton({id: 'code', group: 'insertions', shortcut: 'Shift+C', action: 'formatCode'});
|
||||||
|
|
|
@ -1129,6 +1129,7 @@ en:
|
||||||
options: "Options"
|
options: "Options"
|
||||||
whisper: "whisper"
|
whisper: "whisper"
|
||||||
unlist: "unlisted"
|
unlist: "unlisted"
|
||||||
|
blockquote_text: "Blockquote"
|
||||||
|
|
||||||
add_warning: "This is an official warning."
|
add_warning: "This is an official warning."
|
||||||
toggle_whisper: "Toggle Whisper"
|
toggle_whisper: "Toggle Whisper"
|
||||||
|
|
|
@ -515,29 +515,37 @@ third line`
|
||||||
|
|
||||||
|
|
||||||
testCase('quote button', function(assert, textarea) {
|
testCase('quote button', function(assert, textarea) {
|
||||||
click('button.quote');
|
|
||||||
andThen(() => {
|
|
||||||
assert.equal(this.get('value'), 'hello world.');
|
|
||||||
});
|
|
||||||
|
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
textarea.selectionStart = 6;
|
textarea.selectionStart = 6;
|
||||||
textarea.selectionEnd = 11;
|
textarea.selectionEnd = 9;
|
||||||
});
|
});
|
||||||
|
|
||||||
click('button.quote');
|
click('button.quote');
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
assert.equal(this.get('value'), 'hello > world.');
|
assert.equal(this.get('value'), 'hello\n\n> wor\n\nld.');
|
||||||
assert.equal(textarea.selectionStart, 6);
|
assert.equal(textarea.selectionStart, 7);
|
||||||
assert.equal(textarea.selectionEnd, 13);
|
assert.equal(textarea.selectionEnd, 12);
|
||||||
|
});
|
||||||
|
|
||||||
|
click('button.quote');
|
||||||
|
|
||||||
|
andThen(() => {
|
||||||
|
assert.equal(this.get('value'), 'hello\n\nwor\n\nld.');
|
||||||
|
assert.equal(textarea.selectionStart, 7);
|
||||||
|
assert.equal(textarea.selectionEnd, 10);
|
||||||
|
});
|
||||||
|
|
||||||
|
andThen(() => {
|
||||||
|
textarea.selectionStart = 15;
|
||||||
|
textarea.selectionEnd = 15;
|
||||||
});
|
});
|
||||||
|
|
||||||
click('button.quote');
|
click('button.quote');
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
assert.equal(this.get('value'), 'hello world.');
|
assert.equal(this.get('value'), 'hello\n\nwor\n\nld.\n\n> Blockquote');
|
||||||
assert.equal(textarea.selectionStart, 6);
|
|
||||||
assert.equal(textarea.selectionEnd, 11);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testCase(`bullet button with no selection`, function(assert, textarea) {
|
testCase(`bullet button with no selection`, function(assert, textarea) {
|
||||||
|
|
Loading…
Reference in New Issue