private void InsertSuggestedUrl(string matchText, GlossaryLinkItem linkItem, MarkupRange markupRange) { if (GlossarySettings.AutoLinkTermsOnlyOnce && TermAlreadyLinked(matchText, linkItem.Url)) { return; } // Make sure we're not in the title and not in a hyperlink already IHTMLElement parentElement = _blogPostHtmlEditorControl.PostTitleElement; IHTMLElement currentElement = markupRange.ParentElement(); while (currentElement != null) { if (parentElement == currentElement) { return; // in the title } if (currentElement.tagName.ToLower(CultureInfo.InvariantCulture) == "a") { return; // in an anchor } currentElement = currentElement.parentElement; } if (_linkIgnoreWord != null && matchText.ToLower(CultureInfo.CurrentCulture) == _linkIgnoreWord.ToLower(CultureInfo.CurrentCulture)) { return; } _blogPostHtmlEditorControl.InsertLink(linkItem.Url, matchText, linkItem.Title, linkItem.Rel, linkItem.OpenInNewWindow, markupRange); _blogPostHtmlEditorControl.SelectedMarkupRange.Collapse(false); }
private void IgnoreSuggestedUrl(string matchText, GlossaryLinkItem linkItem, MarkupRange markupRange) { IHTMLElement parent = markupRange.ParentElement(); while (parent != null && !(parent is IHTMLAnchorElement)) { parent = parent.parentElement; } if (parent != null && matchText.ToLower(CultureInfo.CurrentCulture) == parent.innerText.ToLower(CultureInfo.CurrentCulture)) { _linkIgnoreWord = matchText; } }
private void MatchUrl(string htmlText, MatchAction action) { int length; GlossaryLinkItem linkItem = GlossaryManager.Instance.SuggestLink(htmlText, out length); if (linkItem != null && length > 0) { string matchText = htmlText.Substring(htmlText.Length - length, length); MarkupRange insertMarkupRange = _blogPostHtmlEditorControl.SelectedMarkupRange.Clone(); for (int i = 0; i < length; i++) { insertMarkupRange.Start.MoveUnit(_MOVEUNIT_ACTION.MOVEUNIT_PREVCHAR); } action(matchText, linkItem, insertMarkupRange); } }
public override bool FindLink(string linkText, HyperlinkForm caller) { using (SelectGlossaryLinkForm glossaryForm = new SelectGlossaryLinkForm()) { if (linkText != String.Empty) { glossaryForm.SetSelected(linkText); } if (DialogResult.OK == glossaryForm.ShowDialog()) { GlossaryLinkItem chosen = glossaryForm.SelectedEntry; caller.LinkText = chosen.Text; caller.Hyperlink = chosen.Url; caller.LinkTitle = chosen.Title; caller.IsInGlossary = true; return(true); } } return(false); }