// Copyright (c) MudBlazor 2021 // MudBlazor licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Connected.Annotations; using Microsoft.AspNetCore.Components; using static Connected.Components.Splitter; namespace Connected.Components; public partial class Highlighter : UIComponent { private Memory _fragments; private string _regex; /// /// The whole text in which a fragment will be highlighted /// [Parameter] [Category(CategoryTypes.Highlighter.Behavior)] public string Text { get; set; } /// /// The fragment of text to be highlighted /// [Parameter] [Category(CategoryTypes.Highlighter.Behavior)] public string HighlightedText { get; set; } /// /// The fragments of text to be highlighted /// [Parameter] [Category(CategoryTypes.Highlighter.Behavior)] public IEnumerable HighlightedTexts { get; set; } /// /// Whether or not the highlighted text is case sensitive /// [Parameter] [Category(CategoryTypes.Highlighter.Behavior)] public bool CaseSensitive { get; set; } /// /// If true, highlights the text until the next regex boundary /// [Parameter] [Category(CategoryTypes.Highlighter.Behavior)] public bool UntilNextBoundary { get; set; } //TODO //Accept regex highlightings // [Parameter] public bool IsRegex { get; set; } protected override void OnParametersSet() { _fragments = GetFragments(Text, HighlightedText, HighlightedTexts, out _regex, CaseSensitive, UntilNextBoundary); } }