Skip to content
Permalink
Browse files

fix: cursor is wrong after blockquote command exec

  • Loading branch information...
sohee-lee7 committed Nov 14, 2018
1 parent e1d0a02 commit 91195f00fbe40b1134545811336f4829a1f27f8b
Showing with 20 additions and 1 deletion.
  1. +20 −1 src/js/markdownCommands/blockquote.js
@@ -49,7 +49,16 @@ const Blockquote = CommandManager.command('markdown', /** @lends Blockquote */{

doc.replaceRange(resultText.join('\n'), from, to);

range.to.ch += 1;
if (isNeedToRemove) {
const length = textLinesToModify.length;
if (this._isBlockquoteWithSpace(textLinesToModify[length - 1])) {
range.to.ch -= 2;
} else {
range.to.ch -= 1;
}
} else {
range.to.ch += 2;
}

doc.setCursor(range.to);

@@ -90,6 +99,16 @@ const Blockquote = CommandManager.command('markdown', /** @lends Blockquote */{
*/
_removeBlockquote(textArr) {
return textArr.map(text => text.replace(BlockquoteRegex, ''));
},

/**
* check text start '> '
* @param {string} text - text
* @returns {boolean} - if text start '> ', true
* @private
*/
_isBlockquoteWithSpace(text) {
return /^> /.test(text);
}
});

0 comments on commit 91195f0

Please sign in to comment.
You can’t perform that action at this time.