Add mirroring of "[", "]" and "="
This commit is contained in:
parent
fd3c8d8e10
commit
09ba680f10
|
@ -17,6 +17,10 @@ import '../node_modules/jquery-contextmenu/dist/jquery.contextMenu.css';
|
|||
|
||||
moment.locale('nl')
|
||||
|
||||
function isMultiline(input) {
|
||||
return input.value.startsWith("```", 0)
|
||||
}
|
||||
|
||||
function addSaver(editor, saveUrl, page, beforeSave) {
|
||||
return {
|
||||
save() {
|
||||
|
@ -272,6 +276,24 @@ if (holder) {
|
|||
return false
|
||||
}
|
||||
|
||||
let mirror = {
|
||||
'[': ']',
|
||||
'=': '=',
|
||||
}
|
||||
|
||||
if (!isMultiline(input) && mirror.hasOwnProperty(event.key)) {
|
||||
let input = this
|
||||
let val = input.value
|
||||
let prefix = val.substring(0, input.selectionStart)
|
||||
let selection = val.substring(input.selectionStart, input.selectionEnd)
|
||||
let suffix = val.substring(input.selectionEnd)
|
||||
input.value = prefix + event.key + selection + mirror[event.key] + suffix
|
||||
input.selectionStart = prefix.length + event.key.length
|
||||
input.selectionEnd = input.selectionStart + selection.length
|
||||
$(input).trigger('input')
|
||||
return false;
|
||||
}
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user