2016-09-06 345 views
2

我使用CodeMirror进行代码编辑,当我按下INS键(插入键)时,它的行为就像在任何普通的文本编辑器中一样,在替换和插入模式之间切换,但我不想那样做。如何在CodeMirror中禁用默认插入键行为?

我希望它像正常的<textarea>一样,实际上没有任何改变。

我能以某种方式做到吗?

回答

1

我没有用过CodeMirror,但该文件在功能切换覆盖/正常插入模式 (https://codemirror.net/doc/manual.html#usage):

cm.toggleOverwrite(?value: boolean) 
    Switches between overwrite and normal insert mode (when not given an argument), or sets the overwrite mode to a specific state (when given an argument). 

你可以监听用户按下insert键和重写传入该函数的值以使其保持正常插入模式。