코드 미러에 '단축키'행을 추가하려고합니다. 일반 <textarea id=code>
을 위해 내가 할 수있는 :와 insertAtCursor(code,'hello')
:커서에서 어떻게 문자를 추가 할 수 있습니까?
function insertAtCursor(textArea,text)
{
if (textArea.setSelectionRange)
{
textArea.value = textArea.value.substring(0,textArea.selectionStart) + text + textArea.value.substring(textArea.selectionStart,textArea.selectionEnd) + textArea.value.substring(textArea.selectionEnd,textArea.value.length);
}
else if (document.selection && document.selection.createRange)
{
textArea.focus();
var range = document.selection.createRange();
range.text = text + range.text;
}
}
어떻게이 CodeMirror 인스턴스와 함께이 작업을 수행 할 수 있습니까?
작동하지만 지금은 내가 추가 할 때 선택됩니다. 모든 수정 사항? – Sirens