Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 76e1aeb

Browse files
authoredMar 18, 2025
feat(blazorui): add BitMarkdownEditor component bitfoundation#10230 (bitfoundation#10268)
1 parent afbe87e commit 76e1aeb

File tree

13 files changed

+495
-1
lines changed

13 files changed

+495
-1
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@namespace Bit.BlazorUI
2+
@inherits BitComponentBase
3+
4+
<div @ref="RootElement"
5+
@attributes="HtmlAttributes"
6+
id="@_Id"
7+
style="@StyleBuilder.Value"
8+
class="@ClassBuilder.Value"
9+
dir="@Dir?.ToString().ToLower()">
10+
<textarea @ref="_textAreaRef" class="bit-mde-txa" />
11+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
namespace Bit.BlazorUI;
2+
3+
/// <summary>
4+
/// BitMarkdownEditor is a simple editor like GitHub md editor.
5+
/// </summary>
6+
public partial class BitMarkdownEditor : BitComponentBase
7+
{
8+
private ElementReference _textAreaRef = default!;
9+
10+
11+
12+
[Inject] private IJSRuntime _js { get; set; } = default!;
13+
14+
15+
16+
/// <summary>
17+
/// Returns the current value of the editor.
18+
/// </summary>
19+
public async ValueTask<string> GetValue()
20+
{
21+
return await _js.BitMarkdownEditorGetValue(_Id);
22+
}
23+
24+
25+
26+
protected override string RootElementClass => "bit-mde";
27+
28+
protected override Task OnAfterRenderAsync(bool firstRender)
29+
{
30+
if (firstRender)
31+
{
32+
_js.BitMarkdownEditorInit(_Id, _textAreaRef);
33+
}
34+
35+
return base.OnAfterRenderAsync(firstRender);
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@import '../../../Bit.BlazorUI/Styles/functions.scss';
2+
3+
.bit-mde {
4+
width: 100%;
5+
box-sizing: border-box;
6+
}
7+
8+
.bit-mde-txa {
9+
width: 100%;
10+
height: 100%;
11+
padding: spacing(1);
12+
}

0 commit comments

Comments
 (0)