javascript - 为什么 ace 编辑器不发出 tokenizerUpdate 事件
问题描述
我里面有这段代码 compositionComplete()
this.docEditor = aceEditorBindingHandler.getEditorBySelection($(docEditorSelector);
// this.docEditor is of type AceAjax.Editor
if (this.docEditor) {
this.docEditor.getSession().on("tokenizerUpdate", () => {
// do stuff
});
}
但它永远不会被击中。
如果我将事件更改为“ change
”,则内容更改时会触发代码。
但这不是我需要的。
任何想法 ?有人吗?
解决方案
类似于 change 事件,tokenizer 更新不会被同步调用。有关其工作的演示,请参见下面的示例。
<script src=https://ajaxorg.github.io/ace-builds/src-noconflict/ace.js></script>
<script>
editor = ace.edit(null, {
mode: "ace/mode/javascript",
minLines: 5,
maxLines: 10,
})
var log = ace.edit(null, {
mode: "ace/mode/javascript",
minLines: 5,
maxLines: 10,
})
document.documentElement.appendChild(editor.container)
document.documentElement.appendChild(log.container)
editor.session.on("tokenizerUpdate", () => {
log.insert("tokenizerUpdate called " + Date.now() + "\n")
})
</script>
推荐阅读
- php - 登录后访问 Laravel 5.8 中的子页面
- sql-server - DISTINCT NULL 在 SQL Server 中返回单个 NULL
- html - qtextedit:单词中间不同颜色的字母打破了rtl方向
- java - 使用 elasticsearch 从简单的日志文件中读取
- javascript - 如何在单击时在我的用户对象中设置特定的 userId
- mysql - 如何使用一些固定值(字段或新表)优化我的数据库?
- python - 如何在 Mac 上的 Python 中检测用户输入(例如命令 - ctrl+shift+k)?
- python - 当索引为 1 时,我想在 l1 中追加到 l2
- python - 为什么 root.quit() 或 root.destroy() 不起作用,而只是两者的结合?
- html - 如何从伪类内部查找类