2023-01-16 22:26:34 +00:00
|
|
|
ace.define("ace/ext/linking",["require","exports","module","ace/editor","ace/config"], function(require, exports, module){var Editor = require("../editor").Editor;
|
2014-07-08 20:15:22 +00:00
|
|
|
require("../config").defineOptions(Editor.prototype, "editor", {
|
|
|
|
enableLinking: {
|
2023-01-16 22:26:34 +00:00
|
|
|
set: function (val) {
|
2014-07-08 20:15:22 +00:00
|
|
|
if (val) {
|
|
|
|
this.on("click", onClick);
|
|
|
|
this.on("mousemove", onMouseMove);
|
2023-01-16 22:26:34 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-07-08 20:15:22 +00:00
|
|
|
this.off("click", onClick);
|
|
|
|
this.off("mousemove", onMouseMove);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
value: false
|
|
|
|
}
|
2020-04-14 12:14:48 +00:00
|
|
|
});
|
2017-02-05 20:05:00 +00:00
|
|
|
exports.previousLinkingHover = false;
|
2014-07-08 20:15:22 +00:00
|
|
|
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);
|
2017-02-05 20:05:00 +00:00
|
|
|
if (exports.previousLinkingHover && exports.previousLinkingHover != token) {
|
|
|
|
editor._emit("linkHoverOut");
|
|
|
|
}
|
2023-01-16 22:26:34 +00:00
|
|
|
editor._emit("linkHover", { position: docPos, token: token });
|
2017-02-05 20:05:00 +00:00
|
|
|
exports.previousLinkingHover = token;
|
2023-01-16 22:26:34 +00:00
|
|
|
}
|
|
|
|
else if (exports.previousLinkingHover) {
|
2017-02-05 20:05:00 +00:00
|
|
|
editor._emit("linkHoverOut");
|
|
|
|
exports.previousLinkingHover = false;
|
2014-07-08 20:15:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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);
|
2023-01-16 22:26:34 +00:00
|
|
|
editor._emit("linkClick", { position: docPos, token: token });
|
2014-07-08 20:15:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-14 12:14:48 +00:00
|
|
|
}); (function() {
|
|
|
|
ace.require(["ace/ext/linking"], function(m) {
|
|
|
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
|
|
module.exports = m;
|
|
|
|
}
|
|
|
|
});
|
2014-07-08 20:15:22 +00:00
|
|
|
})();
|
|
|
|
|