1
0
Fork 0
mirror of https://github.com/overleaf/overleaf.git synced 2024-12-21 12:03:16 -05:00
overleaf/services/web/public/js/ace/ext-linking.js

52 lines
1.4 KiB
JavaScript
Raw Normal View History

2014-07-16 06:07:18 -04:00
ace.define("ace/ext/linking",["require","exports","module","ace/editor","ace/config"], function(require, exports, module) {
2014-07-09 12:59:04 -04:00
var Editor = require("ace/editor").Editor;
require("../config").defineOptions(Editor.prototype, "editor", {
enableLinking: {
set: function(val) {
if (val) {
this.on("click", onClick);
this.on("mousemove", onMouseMove);
} else {
this.off("click", onClick);
this.off("mousemove", onMouseMove);
}
},
value: false
}
})
function onMouseMove(e) {
var editor = e.editor;
var ctrl = e.getAccelKey();
if (ctrl) {
var editor = e.editor;
var docPos = e.getDocumentPosition();
var session = editor.session;
var token = session.getTokenAt(docPos.row, docPos.column);
editor._emit("linkHover", {position: docPos, token: token});
}
}
function onClick(e) {
var ctrl = e.getAccelKey();
var button = e.getButton();
if (button == 0 && ctrl) {
var editor = e.editor;
var docPos = e.getDocumentPosition();
var session = editor.session;
var token = session.getTokenAt(docPos.row, docPos.column);
editor._emit("linkClick", {position: docPos, token: token});
}
}
});
(function() {
2014-07-16 06:07:18 -04:00
ace.require(["ace/ext/linking"], function() {});
2014-07-09 12:59:04 -04:00
})();