From d2446d68e7ace4d1a860de6a5a3e5031f074161b Mon Sep 17 00:00:00 2001 From: Ben Souchet Date: Tue, 31 May 2022 22:33:35 +0200 Subject: [PATCH] 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 --- lib/ace/mouse/default_gutter_handler.js | 6 ++++++ lib/ace/tooltip.js | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ace/mouse/default_gutter_handler.js b/lib/ace/mouse/default_gutter_handler.js index 34c4482a6c8..2e7e2181bd2 100644 --- a/lib/ace/mouse/default_gutter_handler.js +++ b/lib/ace/mouse/default_gutter_handler.js @@ -87,6 +87,12 @@ function GutterHandler(mouseHandler) { tooltipAnnotation = annotation.text.join("
"); tooltip.setHtml(tooltipAnnotation); + + var annotationClassName = annotation.className; + if (annotationClassName) { + tooltip.setClassName(annotationClassName.trim()); + } + tooltip.show(); editor._signal("showGutterTooltip", tooltip); editor.on("mousewheel", hideTooltip); diff --git a/lib/ace/tooltip.js b/lib/ace/tooltip.js index cc17e6e5839..4ca9fecb9f9 100644 --- a/lib/ace/tooltip.js +++ b/lib/ace/tooltip.js @@ -34,6 +34,8 @@ define(function(require, exports, module) { var oop = require("./lib/oop"); var dom = require("./lib/dom"); +var CLASSNAME = "ace_tooltip"; + /** * @class Tooltip **/ @@ -52,7 +54,7 @@ function Tooltip (parentNode) { (function() { this.$init = function() { this.$element = dom.createElement("div"); - this.$element.className = "ace_tooltip"; + this.$element.className = CLASSNAME; this.$element.style.display = "none"; this.$parentNode.appendChild(this.$element); return this.$element; @@ -114,6 +116,7 @@ function Tooltip (parentNode) { this.hide = function() { if (this.isOpen) { this.getElement().style.display = "none"; + this.getElement().className = CLASSNAME; this.isOpen = false; } };