Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BitMarkdownEditor component (#10230) #10268

Merged
merged 2 commits into from
Mar 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@namespace Bit.BlazorUI
@inherits BitComponentBase

<div @ref="RootElement"
@attributes="HtmlAttributes"
id="@_Id"
style="@StyleBuilder.Value"
class="@ClassBuilder.Value"
dir="@Dir?.ToString().ToLower()">
<textarea @ref="_textAreaRef" class="bit-mde-txa" />
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace Bit.BlazorUI;

/// <summary>
/// BitMarkdownEditor is a simple editor like GitHub md editor.
/// </summary>
public partial class BitMarkdownEditor : BitComponentBase
{
private ElementReference _textAreaRef = default!;



[Inject] private IJSRuntime _js { get; set; } = default!;



/// <summary>
/// Returns the current value of the editor.
/// </summary>
public async ValueTask<string> GetValue()
{
return await _js.BitMarkdownEditorGetValue(_Id);
}



protected override string RootElementClass => "bit-mde";

protected override Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
_js.BitMarkdownEditorInit(_Id, _textAreaRef);
}

return base.OnAfterRenderAsync(firstRender);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@import '../../../Bit.BlazorUI/Styles/functions.scss';

.bit-mde {
width: 100%;
box-sizing: border-box;
}

.bit-mde-txa {
width: 100%;
height: 100%;
padding: spacing(1);
}
Loading