mirror of
https://github.com/sparksuite/simplemde-markdown-editor.git
synced 2025-06-30 06:31:00 -06:00
Merge pull request #93 from brondsem/start_end_same
Don't increment both start and end points if they are the same object
This commit is contained in:
commit
2fd52aa629
@ -399,8 +399,10 @@ function _replaceSelection(cm, active, start, end) {
|
||||
cm.replaceSelection(start + text + end);
|
||||
|
||||
startPoint.ch += start.length;
|
||||
if(startPoint !== endPoint) {
|
||||
endPoint.ch += start.length;
|
||||
}
|
||||
}
|
||||
cm.setSelection(startPoint, endPoint);
|
||||
cm.focus();
|
||||
}
|
||||
@ -552,11 +554,15 @@ function _toggleBlock(editor, type, start_chars, end_chars) {
|
||||
|
||||
if(type == "bold" || type == "strikethrough") {
|
||||
startPoint.ch -= 2;
|
||||
if(startPoint !== endPoint) {
|
||||
endPoint.ch -= 2;
|
||||
}
|
||||
} else if(type == "italic") {
|
||||
startPoint.ch -= 1;
|
||||
if(startPoint !== endPoint) {
|
||||
endPoint.ch -= 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
text = cm.getSelection();
|
||||
if(type == "bold") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user