import $ from 'jquery'; import { isString, escape } from 'lodash'; import coreModule from 'app/angular/core_module'; import alertDef from 'app/features/alerting/state/alertDef'; import { DashboardSrv } from 'app/features/dashboard/services/DashboardSrv'; coreModule.directive('annotationTooltip', ['$sanitize', 'dashboardSrv', '$compile', annotationTooltipDirective]); export function annotationTooltipDirective($sanitize: any, dashboardSrv: DashboardSrv, $compile: any) { function sanitizeString(str: string) { try { return $sanitize(str); } catch (err) { console.log('Could not sanitize annotation string, html escaping instead'); return escape(str); } } return { restrict: 'E', scope: { event: '=', onEdit: '&', }, link: (scope: any, element: JQuery) => { const event = scope.event; let title = event.title; let text = event.text; const dashboard = dashboardSrv.getCurrent(); let tooltip = '