本文介绍了Ace编辑器-更改CTRL + H绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究 Ace编辑器和 + 的实现,非常适合内置的查找"对话框,但是我试图找到一种方法来更改 + 的 + 并防止默认行为.

I'm working on an implementation of Ace Editor and + works great for the built-in "Find" dialog, however I'm trying to find a way to change out the + for + and prevent default behavior.

我查看了有关使用键绑定的文档和论坛,但是我无法确定调用哪种方法来实例化替换"对话框或如何覆盖它.

I've looked over docs and forums about working with the keybindings but I can't identify what method is being called to instantiate the 'replace' dialog or how to overwrite it.

推荐答案

已定义替换命令此处.可以使用以下代码将 + 更改为 +

Replace command is defined here. it is possible to use the following code to change + for +

editor.commands.addCommand({
    name: "replace",
    bindKey: {win: "Ctrl-R", mac: "Command-Option-F"},
    exec: function(editor) {
        require("ace/config").loadModule("ace/ext/searchbox", function(e) {
             e.Search(editor, true)
             // take care of keybinding inside searchbox
             // this is too hacky :(
             var kb = editor.searchBox.$searchBarKb
             command = kb.commandKeyBinding["ctrl-h"]
             if (command && command.bindKey.indexOf("Ctrl-R") == -1) {
                 command.bindKey += "|Ctrl-R"
                 kb.addCommand(command)
             }
         });
    }
});

但是带有内部命令的部分非常难看,我建议在ace存储库中发布一个问题,使其使用普通名称,或者自动选择replace命令键

but the part with inner command is quite ugly, i'd suggest to make an issue on ace repository to either use normal name for it, or pick up replace commands key automatically

这篇关于Ace编辑器-更改CTRL + H绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 09:05