Skip to content

Commit

Permalink
chore: refactor code with creator suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoRepo committed Nov 27, 2024
1 parent 63985eb commit a8324e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,9 @@
</li>
}
<li><button type="button" class="dropdown-item" @onclick="FeatureDialog.Open">Experimental Features</button></li>
<li><button id="convert" type="button" class="dropdown-item" @onclick="ConvertContent">@ConvertLabel <i class="lab"></i></button></li>
</ul>
</div>
<div class="btn-group position-absolute bottom-0 m-5 extra-buttons">
<button id="btnConvert" class="btn btn-primary btn-outlined btn-sm" type="button" @onclick="convertContent">
<i class="lab"></i>
@BtnConvertLabel
</button>
</div>
</div>
<div class="form-floating mb-3">
<InputText type="url" class="form-control" id="preview" placeholder="Preview-Url" @bind-Value="model.PreviewImageUrl" />
Expand Down Expand Up @@ -141,7 +136,7 @@

private string? originalContent = null;
private bool IsContentConverted => !string.IsNullOrWhiteSpace(originalContent);
private string BtnConvertLabel => !IsContentConverted ? "Convert to markdown" : "Restore";
private string ConvertLabel => !IsContentConverted ? "Convert to markdown" : "Restore";

private bool canSubmit = true;
private IPagedList<ShortCode> shortCodes = PagedList<ShortCode>.Empty;
Expand Down Expand Up @@ -219,7 +214,7 @@
/// <summary>
/// Convert content from HTML to Markdown and viceversa
/// </summary>
private void convertContent()
private void ConvertContent()
{
if (IsContentConverted)
{
Expand All @@ -228,7 +223,7 @@
}
else
{
originalContent = model.Content; //keep the original inserted content
originalContent = model.Content;
var converter = new ReverseMarkdown.Converter();
model.Content = converter.Convert(model.Content);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public void ShouldTransformHtmlToMarkdown()
var cut = Render<CreateNewBlogPost>();
var content = cut.Find("#content");
content.Input("<h3>My Content</h3>");
var btnConvert = cut.Find("#btnConvert");
var btnConvert = cut.Find("#convert");
btnConvert.Click();
content.TextContent.ShouldBeEquivalentTo("### My Content");
btnConvert.TextContent.Trim().ShouldBeEquivalentTo("Restore");
Expand All @@ -305,7 +305,7 @@ public void ShouldRestoreMarkdownToHtml()
var content = cut.Find("#content");

content.Input(htmlContent);
var btnConvert = cut.Find("#btnConvert");
var btnConvert = cut.Find("#convert");
btnConvert.Click();
content.TextContent.ShouldBeEquivalentTo(markdownContent);
btnConvert.TextContent.Trim().ShouldBeEquivalentTo("Restore");
Expand Down

0 comments on commit a8324e6

Please sign in to comment.