mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +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,6 +713,7 @@ exports.handle_keydown = function (event) {
|
||||
// where "url" should be automatically selected.
|
||||
// Position of cursor depends on whether browser supports exec
|
||||
// command or not. So set cursor position accrodingly.
|
||||
if (range.length > 0) {
|
||||
if (document.queryCommandEnabled('insertText')) {
|
||||
txt.selectionStart = position - 4;
|
||||
txt.selectionEnd = position - 1;
|
||||
@@ -720,6 +721,9 @@ exports.handle_keydown = function (event) {
|
||||
txt.selectionStart = position + range.length + 3;
|
||||
txt.selectionEnd = position + range.length + 6;
|
||||
}
|
||||
} else {
|
||||
textarea.caret(textarea.caret() - 6);
|
||||
}
|
||||
}
|
||||
|
||||
compose_ui.autosize_textarea();
|
||||
|
||||
Reference in New Issue
Block a user