2015-06-12 55 views
1

我正在研究一个etherpad插件,它在文本编辑过程中提供了一种特殊的自动完成功能。为此,我需要知道用户的脱字符号在哪里。不过,我不知道用户是否用鼠标点击移动了插入符号,因为我找不到适当的钩子。如何捕捉Etherpad插件中的点击事件

作为解决此问题的第一步,我想捕获鼠标单击事件。 (如果我能听到点击事件,我仍然不确定如何找出插入位置,但至少我知道该何时处理它。)任何帮助表示赞赏。

回答

1

从ep_tasklist插件 - https://raw.githubusercontent.com/JohnMcLear/ep_tasklist/master/static/js/ace_inner.js进行一些较小的修改,将其用作您尝试完成的参考点。

点击监听事件只是绑定到内部文档体

exports.postAceInit = function(hook, context){ 
    context.ace.callWithAce(function(ace){ 
    var doc = ace.ace_getDocument(); 
    $(doc).find('#innerdocbody').on("click", underscore(SOMEFUNCTIONINCORRECTCONTEXT).bind(ace)); 
    }, 'myPlugin', true); 
} 

我以为你neeed保持王牌的情况下也是如此,如果不是你不需要使用下划线的绑定功能。 IE

exports.postAceInit = function(hook, context){ 
    context.ace.callWithAce(function(ace){ 
    var doc = ace.ace_getDocument(); 
    $(doc).find('#innerdocbody').on("click", function(){ 
     console.log("hello world") 
    }); 
    }, 'myPlugin', true); 
}