如果我使用像<#input“asd”>这样的标签,有没有办法避免Ace-Editor抛出错误?就像白名单建议AceEditor忽略它...无论如何,它是一个内部键,我无法避免使用它。我正在使用react。
谢谢
发布于 2018-08-07 02:31:58
我想有两种方法来解决这个问题:
1)也许你可以绑定">",获取最后输入的值,然后清除错误:
editor.commands.addCommand({
name: "dotCommand1",
bindKey: { win: ".", mac: "."},
exec: function () {
var pos = editor.selection.getCursor();
var session = editor.session;
var curLine = (session.getDocument().getLine(pos.row)).trim();
var curTokens = curLine.slice(0, pos.column).split(/\s+/);
//You can build a logic using the curTokens array and then when you find <#input "asd"> clear the errors.
// If we assume curTokens[0] to have the value
if(curTokens[0] === '<#input "asd">') {
editor.session.setAnnotations([]); // This would remove the being shown error
}
}
});2)使用on change事件并使用上面类似的逻辑,然后清除错误
editor.getSession().on('change', function () {
// same logic as above
})https://stackoverflow.com/questions/51706639
复制相似问题