Skip to content

Commit 028a77b

Browse files
author
syhxzzz
authored
feat: optimized the link filling experience when ctrl+k (#771)
1 parent 45e5485 commit 028a77b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/views/CodemirrorEditor.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,12 @@ function initEditor() {
231231
const selected = editor.getSelection()
232232
editor.replaceSelection(`~~${selected}~~`)
233233
},
234-
[`${ctrlKey}-K`]: function italic(editor) {
234+
[`${ctrlKey}-K`]: function link(editor) {
235235
const selected = editor.getSelection()
236236
editor.replaceSelection(`[${selected}]()`)
237+
// now will slightly move the cursor to the left to fill in the link
238+
const { line, ch } = editor.getCursor()
239+
editor.setCursor({ line, ch: ch - 1 })
237240
},
238241
[`${ctrlKey}-E`]: function code(editor) {
239242
const selected = editor.getSelection()

0 commit comments

Comments
 (0)