Skip to content

Commit d2446d6

Browse files
authored
fix: Add class to tooltip DOM element distinguish errors from warnings (#4810)
* Add class to tooltip DOM element distinguish errors from warnings * Move ClassName to constant + handle undefined / null annotation ClassName
1 parent 57ded09 commit d2446d6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/ace/mouse/default_gutter_handler.js

+6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ function GutterHandler(mouseHandler) {
8787
tooltipAnnotation = annotation.text.join("<br/>");
8888

8989
tooltip.setHtml(tooltipAnnotation);
90+
91+
var annotationClassName = annotation.className;
92+
if (annotationClassName) {
93+
tooltip.setClassName(annotationClassName.trim());
94+
}
95+
9096
tooltip.show();
9197
editor._signal("showGutterTooltip", tooltip);
9298
editor.on("mousewheel", hideTooltip);

lib/ace/tooltip.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ define(function(require, exports, module) {
3434
var oop = require("./lib/oop");
3535
var dom = require("./lib/dom");
3636

37+
var CLASSNAME = "ace_tooltip";
38+
3739
/**
3840
* @class Tooltip
3941
**/
@@ -52,7 +54,7 @@ function Tooltip (parentNode) {
5254
(function() {
5355
this.$init = function() {
5456
this.$element = dom.createElement("div");
55-
this.$element.className = "ace_tooltip";
57+
this.$element.className = CLASSNAME;
5658
this.$element.style.display = "none";
5759
this.$parentNode.appendChild(this.$element);
5860
return this.$element;
@@ -114,6 +116,7 @@ function Tooltip (parentNode) {
114116
this.hide = function() {
115117
if (this.isOpen) {
116118
this.getElement().style.display = "none";
119+
this.getElement().className = CLASSNAME;
117120
this.isOpen = false;
118121
}
119122
};

0 commit comments

Comments
 (0)