0e13b643b6e88e8fd6328d50acabfda8.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ace.define("ace/ext/linking",["require","exports","module","ace/editor","ace/config"], function(require, exports, module){var Editor = require("../editor").Editor;
  2. require("../config").defineOptions(Editor.prototype, "editor", {
  3. enableLinking: {
  4. set: function (val) {
  5. if (val) {
  6. this.on("click", onClick);
  7. this.on("mousemove", onMouseMove);
  8. }
  9. else {
  10. this.off("click", onClick);
  11. this.off("mousemove", onMouseMove);
  12. }
  13. },
  14. value: false
  15. }
  16. });
  17. exports.previousLinkingHover = false;
  18. function onMouseMove(e) {
  19. var editor = e.editor;
  20. var ctrl = e.getAccelKey();
  21. if (ctrl) {
  22. var editor = e.editor;
  23. var docPos = e.getDocumentPosition();
  24. var session = editor.session;
  25. var token = session.getTokenAt(docPos.row, docPos.column);
  26. if (exports.previousLinkingHover && exports.previousLinkingHover != token) {
  27. editor._emit("linkHoverOut");
  28. }
  29. editor._emit("linkHover", { position: docPos, token: token });
  30. exports.previousLinkingHover = token;
  31. }
  32. else if (exports.previousLinkingHover) {
  33. editor._emit("linkHoverOut");
  34. exports.previousLinkingHover = false;
  35. }
  36. }
  37. function onClick(e) {
  38. var ctrl = e.getAccelKey();
  39. var button = e.getButton();
  40. if (button == 0 && ctrl) {
  41. var editor = e.editor;
  42. var docPos = e.getDocumentPosition();
  43. var session = editor.session;
  44. var token = session.getTokenAt(docPos.row, docPos.column);
  45. editor._emit("linkClick", { position: docPos, token: token });
  46. }
  47. }
  48. }); (function() {
  49. ace.require(["ace/ext/linking"], function(m) {
  50. if (typeof module == "object" && typeof exports == "object" && module) {
  51. module.exports = m;
  52. }
  53. });
  54. })();