mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
markdown shortcuts: Set cursor position for link insertion shortcut.
For link insertion shortcut without text selection,set the cursor position between "[]" rather than selecting "url" in "[](url)" string.
This commit is contained in:
@@ -713,12 +713,16 @@ exports.handle_keydown = function (event) {
|
|||||||
// where "url" should be automatically selected.
|
// where "url" should be automatically selected.
|
||||||
// Position of cursor depends on whether browser supports exec
|
// Position of cursor depends on whether browser supports exec
|
||||||
// command or not. So set cursor position accrodingly.
|
// command or not. So set cursor position accrodingly.
|
||||||
if (document.queryCommandEnabled('insertText')) {
|
if (range.length > 0) {
|
||||||
txt.selectionStart = position - 4;
|
if (document.queryCommandEnabled('insertText')) {
|
||||||
txt.selectionEnd = position - 1;
|
txt.selectionStart = position - 4;
|
||||||
|
txt.selectionEnd = position - 1;
|
||||||
|
} else {
|
||||||
|
txt.selectionStart = position + range.length + 3;
|
||||||
|
txt.selectionEnd = position + range.length + 6;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
txt.selectionStart = position + range.length + 3;
|
textarea.caret(textarea.caret() - 6);
|
||||||
txt.selectionEnd = position + range.length + 6;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user