Skip to content

Commit

Permalink
Revert "MudHighlighter: Add Markup parameter to render Text using Mar…
Browse files Browse the repository at this point in the history
…kupString" (#7004)

This reverts commit 6499da0.
  • Loading branch information
Mr-Technician authored Jun 13, 2023
1 parent 6499da0 commit e7eae4a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,23 @@
HighlightedText="@highlightedText"
UntilNextBoundary="@untilNextBoundary"
CaseSensitive="@caseSensitive"
Markup="@markup"
Class="@(untilNextBoundary ? "pa-1 mud-elevation-2 mud-theme-primary":"")" />
</MudText>
}

</MudPaper>
<MudSwitch @bind-Checked="@untilNextBoundary" Label="UntilNextBoundary" Color="Color.Primary" />
<MudSwitch @bind-Checked="@caseSensitive" Label="CaseSensitive" Color="Color.Primary" />
<MudSwitch @bind-Checked="@markup" Label="Markup" Color="Color.Primary" />


@code{
string highlightedText = "mud";
bool untilNextBoundary;
bool caseSensitive;
bool markup;
IEnumerable<string> paragraphs = new List<string>
string highlightedText = "Mud";
bool untilNextBoundary;
bool caseSensitive;
IEnumerable<string> paragraphs = new List<string>
{
$"<i>MudBlazor</i> is an ambitious <span style='color:{Colors.Purple.Default}'>Material Design</span> component framework for Blazor with an <span style='color:{Colors.Green.Default}'>emphasis</span> on <em>ease of use and clear structure</em>.",
$"MudLists are easily <span style='color:{Colors.Orange.Default}'>customizable</span> and <span style='color:{Colors.Red.Default}'>scrollable</span> lists. Make them suit your needs with <i>avatars</i>, <i>icons</i>, or something like <i>checkboxes</i>.",
$"Use <b>mud</b>-* classes to <span style='color:{Colors.Blue.Default}'>customize your MudBlazor components</span>."
"MudBlazor is an ambitious Material Design component framework for Blazor with an emphasis on ease of use and clear structure.",
"MudLists are easily customizable and scrollable lists. Make them suit your needs with avatars, icons, or something like checkboxes.",
"Use mud-* classes to customize your MudBlazor components."
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,50 +29,25 @@
<HighlighterWithTableExample/>
</SectionContent>
</DocsPageSection>
</SectionSubGroups>
</SectionSubGroups>
</DocsPageSection>

<DocsPageSection>
<SectionHeader Title="Search, appearance">
<Description></Description>
<SectionHeader Title="Style">
<Description>Style it with the Class or Style properties:</Description>
</SectionHeader>
<SectionSubGroups>
<DocsPageSection>
<SectionHeader Title="UntilNextBoundary">
<Description>Set the <code class="docs-code docs-code-primary">UntilNextBoundary</code> property to true if you want to highlight the text until the next regex boundary occurs.</Description>
</SectionHeader>
</DocsPageSection>
</SectionSubGroups>
<SectionSubGroups>
<DocsPageSection>
<SectionHeader Title="CaseSensitive">
<Description>Set the <code class="docs-code docs-code-primary">CaseSensitive</code> property to true to perform a case-sensitive highlight.</Description>
</SectionHeader>
</DocsPageSection>
</SectionSubGroups>
<SectionSubGroups>
<DocsPageSection>
<SectionHeader Title="Markup">
<Description>
Set the <code class="docs-code docs-code-primary">Markup</code> property to true to render the text using <code class="docs-code docs-code-primary">MarkupString</code>.
<br />Prevent using user-provided input as that's not very secure.
</Description>
</SectionHeader>
<SectionContent DarkenBackground="true" Code="HighlighterUntilNextBoundaryExample" ShowCode="false">
<HighlighterUntilNextBoundaryExample />
</SectionContent>
</DocsPageSection>
</SectionSubGroups>
<SectionSubGroups>
<DocsPageSection>
<SectionHeader Title="Style">
<Description>Style it with the <code class="docs-code docs-code-primary">Class</code> or <code class="docs-code docs-code-primary">Style</code> properties.</Description>
</SectionHeader>
<SectionContent DarkenBackground="true" Code="HighlighterWithCustomStyleExample" ShowCode="false">
<HighlighterWithCustomStyleExample />
</SectionContent>
</DocsPageSection>
</SectionSubGroups>
<SectionContent DarkenBackground="true" Code="HighlighterWithCustomStyleExample" ShowCode="false">
<HighlighterWithCustomStyleExample />
</SectionContent>
</DocsPageSection>

<DocsPageSection>
<SectionHeader Title="Case sensitivity">
<Description>Set the <code class="docs-code docs-code-primary">UntilNextBoundary</code> property to true if you want to highlight the text until the next regex boundary occurs, or the <code class="docs-code docs-code-primary">CaseSensitive</code> property to decide if you want to perform a case-sensitive highlight.</Description>
</SectionHeader>
<SectionContent DarkenBackground="true" Code="HighlighterUntilNextBoundaryExample" ShowCode="false">
<HighlighterUntilNextBoundaryExample />
</SectionContent>
</DocsPageSection>

<DocsPageSection>
Expand Down
19 changes: 0 additions & 19 deletions src/MudBlazor.UnitTests/Components/HighlighterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,24 +238,5 @@ public void MudHighlighterMarkupCaseSensitiveTest()
comp.SetParametersAndRender(text, highlightedText, caseInSensitive);
comp.MarkupMatches("<mark>This</mark> is <mark>this</mark>");
}

/// <summary>
/// Check rendered Text output using Markup property
/// </summary>
[Test]
public void MudHighlighterMarkupRenderTextAsMarkupStringTest()
{
var markupText = $"<i>{nameof(MudBlazor)}</i>";
var text = Parameter(nameof(MudHighlighter.Text), markupText);
var highlightedText = Parameter(nameof(MudHighlighter.HighlightedText), "mud");

var textAsMarkupFalse = Parameter(nameof(MudHighlighter.Markup), false);
var comp = Context.RenderComponent<MudHighlighter>(text, highlightedText, textAsMarkupFalse);
comp.MarkupMatches("&lt;i&gt;<mark>Mud</mark>Blazor&lt;/i&gt;");

var textAsMarkupTrue = Parameter(nameof(MudHighlighter.Markup), true);
comp = Context.RenderComponent<MudHighlighter>(text, highlightedText, textAsMarkupTrue);
comp.MarkupMatches("<i><mark>Mud</mark>Blazor</i>");
}
}
}
4 changes: 0 additions & 4 deletions src/MudBlazor/Components/Highlighter/MudHighlighter.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
{
<mark class="@Class" style="@Style" @attributes="@UserAttributes"> @fragment </mark>
}
else if (Markup)
{
@((MarkupString) fragment)
}
else
{
@fragment
Expand Down
10 changes: 0 additions & 10 deletions src/MudBlazor/Components/Highlighter/MudHighlighter.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ public partial class MudHighlighter : MudComponentBase
[Category(CategoryTypes.Highlighter.Behavior)]
public bool UntilNextBoundary { get; set; }

/// <summary>
/// If true, renders the text using <see cref="MarkupString"/>
/// </summary>
/// <remarks>
/// Prevent using user-provided input as that's not very secure.
/// </remarks>
[Parameter]
[Category(CategoryTypes.Highlighter.Appearance)]
public bool Markup { get; set; }

//TODO
//Accept regex highlightings
// [Parameter] public bool IsRegex { get; set; }
Expand Down

0 comments on commit e7eae4a

Please sign in to comment.