mirror of
https://github.com/discourse/discourse.git
synced 2025-04-17 18:49:02 +08:00
FIX: Error applying quotes with blank lines in front
This commit is contained in:
parent
ad71d679cf
commit
b9595966d4
@ -438,7 +438,9 @@ export default Ember.Component.extend({
|
||||
}
|
||||
|
||||
if (operation !== OP.ADDED &&
|
||||
(l.slice(0, hlen) === hval && tlen === 0 || l.slice(-tlen) === tail)) {
|
||||
(l.slice(0, hlen) === hval && tlen === 0 ||
|
||||
(tail.length && l.slice(-tlen) === tail))) {
|
||||
|
||||
operation = OP.REMOVED;
|
||||
if (tlen === 0) {
|
||||
const result = l.slice(hlen);
|
||||
@ -500,6 +502,7 @@ export default Ember.Component.extend({
|
||||
tlen,
|
||||
opts
|
||||
);
|
||||
|
||||
this.set('value', `${pre}${contents}${post}`);
|
||||
if (lines.length === 1 && tlen > 0) {
|
||||
this._selectText(sel.start + hlen, sel.value.length);
|
||||
|
@ -540,6 +540,26 @@ componentTest("quote button - empty lines", {
|
||||
}
|
||||
});
|
||||
|
||||
componentTest("quote button - selecting empty lines", {
|
||||
template: '{{d-editor value=value composerEvents=true}}',
|
||||
beforeEach() {
|
||||
this.set('value', "one\n\n\n\ntwo");
|
||||
},
|
||||
test(assert) {
|
||||
const textarea = jumpEnd(this.$('textarea.d-editor-input')[0]);
|
||||
|
||||
andThen(() => {
|
||||
textarea.selectionStart = 6;
|
||||
textarea.selectionEnd = 10;
|
||||
});
|
||||
|
||||
click('button.quote');
|
||||
andThen(() => {
|
||||
assert.equal(this.get('value'), "one\n\n\n> \n> two");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
testCase('quote button', function(assert, textarea) {
|
||||
|
||||
andThen(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user