Esempio n. 1
0
        public bool HasSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType)
        {
            if (!element.StartTag.Contains(caretPosition))
            {
                return(false);
            }

            string url = (element.GetAttribute("src") ?? element.GetAttribute("href"))?.Value;

            if (string.IsNullOrEmpty(url) || (!url.Contains("://") && !url.StartsWith("//")))
            {
                return(false);
            }

            return(element.IsElement("style") || element.IsElement("script"));
        }
        public bool HasSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType)
        {
            if (!element.IsElement("img"))
            {
                return(false);
            }

            AttributeNode src = element.GetAttribute("src");

            if (src == null)
            {
                return(false);
            }

            return(src.Value.StartsWith("data:image/", StringComparison.Ordinal));
        }
Esempio n. 3
0
        public bool HasSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType)
        {
            if (!element.IsElement("img"))
            {
                return(false);
            }

            if (element.Parent.IsElement("picture"))
            {
                return(false);
            }

            var src = element.GetAttribute("src");

            if (string.IsNullOrEmpty(src?.Value))
            {
                src = element.GetAttribute("data-src");
            }

            var srcValue = src?.Value?.ToUpperInvariant() ?? string.Empty;

            return(!string.IsNullOrEmpty(srcValue) && !srcValue.Contains(".SVG"));
        }