private void Retrigger() { Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => { var point = _textView.BufferGraph.MapDownToInsertionPoint(_textView.Caret.Position.BufferPosition - 1, PointTrackingMode.Positive, ts => ts.ContentType.IsOfType(HtmlContentTypeDefinition.HtmlContentType)); if (point == null) { return; } var document = HtmlEditorDocument.FromTextBuffer(point.Value.Snapshot.TextBuffer); if (document == null) { return; } ElementNode element; AttributeNode attr; HtmlPositionType type = document.HtmlEditorTree.GetPositionElement(point.Value.Position, out element, out attr); if (document != null && type == HtmlPositionType.AttributeName) { WebEssentialsPackage.ExecuteCommand("Edit.ListMembers"); } }), DispatcherPriority.Background, null); }
public bool HasSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { if (element.IsRoot || (!element.StartTag.Contains(caretPosition) && !element.EndTag.Contains(caretPosition))) return false; return element.InnerRange != null && element.GetText(element.InnerRange).Trim().Length > 0; }
public void HtmlTree_PositionTypeTests2() { string html = "<html dir=rtl> </html>"; var positionTypes = new HtmlPositionType[] { HtmlPositionType.InContent, HtmlPositionType.ElementName, HtmlPositionType.ElementName, HtmlPositionType.ElementName, HtmlPositionType.ElementName, HtmlPositionType.ElementName, HtmlPositionType.AttributeName, HtmlPositionType.AttributeName, HtmlPositionType.AttributeName, HtmlPositionType.EqualsSign, HtmlPositionType.AfterEqualsSign, HtmlPositionType.AttributeValue, HtmlPositionType.AttributeValue, HtmlPositionType.AttributeValue, HtmlPositionType.InContent, HtmlPositionType.InContent, HtmlPositionType.InEndTag, HtmlPositionType.InEndTag, HtmlPositionType.InEndTag, HtmlPositionType.InEndTag, HtmlPositionType.InEndTag, HtmlPositionType.InEndTag, HtmlPositionType.InContent, }; VerifyPositions(html, positionTypes); }
public IEnumerable<ISuggestedAction> GetSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { return new ISuggestedAction[] { new HtmlMinifyLightBulbAction(textView, textBuffer, element), new HtmlExtractLightBulbAction(textView, textBuffer, element), }; }
public void HtmlTree_PositionTypeTests2() { string html = "<html dir=rtl> </html>"; var positionTypes = new HtmlPositionType[]{ HtmlPositionType.InContent, HtmlPositionType.ElementName, HtmlPositionType.ElementName, HtmlPositionType.ElementName, HtmlPositionType.ElementName, HtmlPositionType.ElementName, HtmlPositionType.AttributeName, HtmlPositionType.AttributeName, HtmlPositionType.AttributeName, HtmlPositionType.EqualsSign, HtmlPositionType.AfterEqualsSign, HtmlPositionType.AttributeValue, HtmlPositionType.AttributeValue, HtmlPositionType.AttributeValue, HtmlPositionType.InContent, HtmlPositionType.InContent, HtmlPositionType.InEndTag, HtmlPositionType.InEndTag, HtmlPositionType.InEndTag, HtmlPositionType.InEndTag, HtmlPositionType.InEndTag, HtmlPositionType.InEndTag, HtmlPositionType.InContent, }; VerifyPositions(html, positionTypes); }
public IEnumerable<ISuggestedAction> GetSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { AttributeNode src = element.GetAttribute("src"); return new ISuggestedAction[] { new HtmlBase64DecodeLightBulbAction(textView, textBuffer, element, src) }; }
public IEnumerable<ISuggestedAction> GetSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { if (HasSuggestedActions(textView, textBuffer, caretPosition, element, attribute, positionType)) { yield return new HtmlMinifyLightBulbAction(textView, textBuffer, element); yield return new HtmlExtractLightBulbAction(textView, textBuffer, element); } }
public IEnumerable<ISuggestedAction> GetSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { AttributeNode ngController = element.GetAttribute("ng-controller") ?? element.GetAttribute("data-ng-controller"); return new ISuggestedAction[] { new HtmlAngularControllerLightBulbAction(textView, textBuffer, element, ngController) }; }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { if (element.GetAttribute("ng-controller") != null) { return new HtmlAngularControllerSmartTag(textView, textBuffer, element); } return null; }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { if (element.Children.Count > 0) { return new HtmlRemoveParentSmartTag(textView, textBuffer, element); } return null; }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { if (element.InnerRange == null || element.GetText(element.InnerRange).Trim().Length == 0) return null; string displayText = element.Children.Count == 0 ? "Remove HTML tag" : "Remove and keep children"; return new HtmlRemoveParentSmartTag(textView, textBuffer, element, displayText); }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { if (element.GetAttribute("class") == null) { return new $safeitemname$SmartTag(textView, textBuffer, element); } return null; }
public bool HasSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { if (element.Name != "img") return false; AttributeNode src = element.GetAttribute("src"); return src != null && src.Value.Trim().Length > 0; }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { if (IsEnabled(element)) { return new OptimizeImageSmartTag(textView, textBuffer, element); } return null; }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { if ((element.IsStyleBlock() || element.IsJavaScriptBlock()) && element.InnerRange.Length > 5) { return new ExtractToFileSmartTag(textView, textBuffer, element); } return null; }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { if (element.IsStyleBlock() || element.IsJavaScriptBlock()) { return new HtmlMinifySmartTag(textView, textBuffer, element); } return null; }
public bool HasSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { if (!element.StartTag.Contains(caretPosition)) return false; if (element.InnerRange.Length < 5) return false; return element.IsStyleBlock() || element.IsJavaScriptBlock(); }
public void HtmlTree_PositionTypeTests7() { string html = "<a"; var positionTypes = new HtmlPositionType[] { HtmlPositionType.InContent, HtmlPositionType.ElementName, HtmlPositionType.ElementName, }; VerifyPositions(html, positionTypes); }
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); }
public IEnumerable<ISuggestedAction> GetSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { AttributeNode src = element.GetAttribute("src"); if (src.Value.StartsWith("data:image/", StringComparison.Ordinal)) { yield return new HtmlBase64DecodeLightBulbAction(textView, textBuffer, element, src); } if (!src.Value.StartsWith("http:") && !src.Value.StartsWith("https:") && !src.Value.StartsWith("//")) { yield return new HtmlOptimizeImageLightBulbAction(textView, textBuffer, element, src); } }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { AttributeNode attr = element.GetAttribute("src") ?? element.GetAttribute("href"); if (attr == null) return null; Uri url = NormalizeUrl(attr); if (url == null || (!attr.Value.StartsWith("//", StringComparison.Ordinal) && !attr.Value.Contains("://"))) return null; return new RemoteDownloaderSmartTag(textView, textBuffer, element, attr); }
public void HtmlTree_PositionTypeTests5() { string html = "<a dir="; var positionTypes = new HtmlPositionType[] { HtmlPositionType.InContent, HtmlPositionType.ElementName, HtmlPositionType.ElementName, HtmlPositionType.AttributeName, HtmlPositionType.AttributeName, HtmlPositionType.AttributeName, HtmlPositionType.EqualsSign, HtmlPositionType.AfterEqualsSign, }; VerifyPositions(html, positionTypes); }
public IEnumerable <ISuggestedAction> GetSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { AttributeNode src = element.GetAttribute("src"); if (src.Value.StartsWith("data:image/", StringComparison.Ordinal)) { yield return(new HtmlBase64DecodeLightBulbAction(textView, textBuffer, element, src)); } if (!src.Value.StartsWith("http:") && !src.Value.StartsWith("https:") && !src.Value.StartsWith("//")) { yield return(new HtmlOptimizeImageLightBulbAction(textView, textBuffer, element, src)); } }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { if ((element.IsStyleBlock() || element.IsJavaScriptBlock()) && element.InnerRange.Length > 5) { return(new ExtractToFileSmartTag(textView, textBuffer, element)); } return(null); }
public bool HasSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { return element.HasAttribute("ng-controller") || element.HasAttribute("data-ng-controller"); }
public IEnumerable <ISuggestedAction> GetSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { AttributeNode src = element.GetAttribute("src"); return(new ISuggestedAction[] { new HtmlBase64DecodeLightBulbAction(textView, textBuffer, element, src) }); }
public IEnumerable <ISuggestedAction> GetSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { AttributeNode ngController = element.GetAttribute("ng-controller") ?? element.GetAttribute("data-ng-controller"); yield return(new HtmlAngularControllerLightBulbAction(textView, textBuffer, element, ngController)); }
public override bool HasSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { return(this.IsTargetHtmlAttribute(element, attribute) && !IntellisenseHelper.IsKnownHtmlAttribute(attribute.Name)); }
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 abstract bool HasSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType);
public IEnumerable <ISuggestedAction> GetSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { if (HasSuggestedActions(textView, textBuffer, caretPosition, element, attribute, positionType)) { yield return(new HtmlMinifyLightBulbAction(textView, textBuffer, element)); yield return(new HtmlExtractLightBulbAction(textView, textBuffer, element)); } }
public void HtmlTree_PositionTypeTests12() { string html = "<a dir=\"r<a"; var positionTypes = new HtmlPositionType[]{ HtmlPositionType.InContent, HtmlPositionType.ElementName, HtmlPositionType.ElementName, HtmlPositionType.AttributeName, HtmlPositionType.AttributeName, HtmlPositionType.AttributeName, HtmlPositionType.EqualsSign, HtmlPositionType.AfterEqualsSign, HtmlPositionType.AttributeValue, HtmlPositionType.AttributeValue, HtmlPositionType.ElementName, }; VerifyPositions(html, positionTypes); }
public bool HasSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { return(element.HasAttribute("ng-controller") || element.HasAttribute("data-ng-controller")); }
public bool HasSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { if (element.Name != "img") { return(false); } AttributeNode src = element.GetAttribute("src"); return(src != null && src.Value.Trim().Length > 0); }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { if (element.Children.Count > 0) { return(new HtmlRemoveParentSmartTag(textView, textBuffer, element)); } return(null); }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { if (element.Name == "img") { return new HtmlConvertImgToFigureSmartTag(textView, textBuffer, element); } return null; }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { if (element.GetAttribute("ng-controller") != null) { return(new HtmlAngularControllerSmartTag(textView, textBuffer, element)); } return(null); }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { if (element.IsStyleBlock() || element.IsJavaScriptBlock()) { return(new HtmlMinifySmartTag(textView, textBuffer, element)); } return(null); }
public IEnumerable<ISuggestedAction> GetSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { yield return new HtmlRemoveElementLightBulbAction(textView, textBuffer, element); }
public IEnumerable <ISuggestedAction> GetSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { return(new ISuggestedAction[] { new HtmlRemoveElementLightBulbAction(textView, textBuffer, element) }); }
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)); }
public bool HasSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { if (element.IsRoot || element.EndTag == null || (!element.StartTag.Contains(caretPosition) && !element.EndTag.Contains(caretPosition))) { return(false); } return(element.InnerRange != null && element.GetText(element.InnerRange).Trim().Length > 0); }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { if (IsEnabled(element)) { return(new Base64DecodeSmartTagSmartTag(textView, textBuffer, element)); } return(null); }
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")); }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { if (element.InnerRange == null || element.GetText(element.InnerRange).Trim().Length == 0) { return(null); } string displayText = element.Children.Count == 0 ? "Remove HTML tag" : "Remove and keep children"; return(new HtmlRemoveParentSmartTag(textView, textBuffer, element, displayText)); }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { if (element.GetAttribute("class") == null) { return(new $safeitemname$SmartTag(textView, textBuffer, element)); } return(null); }
public void HtmlTree_PositionTypeTests14() { string html = "<a <a"; var positionTypes = new HtmlPositionType[]{ HtmlPositionType.InContent, HtmlPositionType.ElementName, HtmlPositionType.ElementName, HtmlPositionType.InStartTag, HtmlPositionType.ElementName, HtmlPositionType.ElementName, }; VerifyPositions(html, positionTypes); }
public bool HasSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { if (!element.StartTag.Contains(caretPosition)) { return(false); } if (element.InnerRange.Length < 5) { return(false); } return(element.IsStyleBlock() || element.IsJavaScriptBlock()); }
public IEnumerable <ISuggestedAction> GetSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { return(new ISuggestedAction[] { (TAction)Activator.CreateInstance(typeof(TAction), textView, textBuffer, element, attribute, GetCaption(element, attribute)) }); }
private void VerifyPositions(string html, HtmlPositionType[] positionTypes) { var tree = new HtmlTree(new TextStream(html), null, null, ParsingMode.Html); tree.Build(); for (int i = 0; i < html.Length; i++) { ElementNode element; AttributeNode attribute; var pos = tree.RootNode.GetPositionElement(i, out element, out attribute); Assert.Equal(positionTypes[i], pos); } }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { AttributeNode attr = element.GetAttribute("src") ?? element.GetAttribute("href"); if (attr == null) { return(null); } Uri url = NormalizeUrl(attr); if (url == null || (!attr.Value.StartsWith("//", StringComparison.Ordinal) && !attr.Value.Contains("://"))) { return(null); } return(new RemoteDownloaderSmartTag(textView, textBuffer, element, attr)); }
public IHtmlSmartTag TryCreateSmartTag(ITextView textView, ITextBuffer textBuffer, ElementNode element, AttributeNode attribute, int caretPosition, HtmlPositionType positionType) { if (element.Name == "img") { return(new HtmlConvertImgToFigureSmartTag(textView, textBuffer, element)); } return(null); }