-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a62890
commit f2ad45f
Showing
14 changed files
with
278 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.JSInterop; | ||
using System.Threading.Tasks; | ||
|
||
namespace Vditor | ||
{ | ||
public partial class Editor : ComponentBase | ||
{ | ||
[Parameter] public EventCallback<string> OnFocus { get; set; } | ||
|
||
[Parameter] public EventCallback<string> OnBlur { get; set; } | ||
|
||
[Parameter] public EventCallback<string> OnEscPress { get; set; } | ||
|
||
[Parameter] public EventCallback<string> OnCtrlEnterPress { get; set; } | ||
|
||
[Parameter] public EventCallback<string> OnSelect { get; set; } | ||
|
||
[JSInvokable] | ||
public async Task HandleRendered() | ||
{ | ||
_editorRendered = true; | ||
if (!string.IsNullOrWhiteSpace(Value) && HtmlChanged.HasDelegate) | ||
{ | ||
Html = await GetHTML(); | ||
await HtmlChanged.InvokeAsync(Html); | ||
} | ||
} | ||
|
||
[JSInvokable] | ||
public async Task HandleInput(string value) | ||
{ | ||
_value = value; | ||
_wattingUpdate = false; | ||
|
||
if (ValueChanged.HasDelegate) | ||
{ | ||
await ValueChanged.InvokeAsync(value); | ||
} | ||
|
||
if (HtmlChanged.HasDelegate) | ||
{ | ||
Html = await GetHTML(); | ||
await HtmlChanged.InvokeAsync(Html); | ||
} | ||
} | ||
|
||
[JSInvokable] | ||
public void HandleFocus(string value) | ||
{ | ||
if (OnFocus.HasDelegate) | ||
{ | ||
OnFocus.InvokeAsync(value); | ||
} | ||
} | ||
|
||
[JSInvokable] | ||
public void HandleBlur(string value) | ||
{ | ||
if (OnBlur.HasDelegate) | ||
{ | ||
OnBlur.InvokeAsync(value); | ||
} | ||
} | ||
|
||
[JSInvokable] | ||
public void HandleEscPress(string value) | ||
{ | ||
if (OnEscPress.HasDelegate) | ||
{ | ||
OnEscPress.InvokeAsync(value); | ||
} | ||
} | ||
|
||
[JSInvokable] | ||
public void HandleCtrlEnterPress(string value) | ||
{ | ||
if (OnCtrlEnterPress.HasDelegate) | ||
{ | ||
OnCtrlEnterPress.InvokeAsync(value); | ||
} | ||
} | ||
|
||
[JSInvokable] | ||
public void HandleSelect(string value) | ||
{ | ||
if (OnSelect.HasDelegate) | ||
{ | ||
OnSelect.InvokeAsync(value); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.JSInterop; | ||
using System.Threading.Tasks; | ||
|
||
namespace Vditor | ||
{ | ||
public partial class Editor : ComponentBase | ||
{ | ||
[Inject] private IJSRuntime Js { get; set; } | ||
|
||
public async Task CreateVditor() | ||
{ | ||
await Js.InvokeVoidAsync("vditorBlazor.createVditor", _ref, DotNetObjectReference.Create(this), this.Value, this.Options); | ||
} | ||
|
||
public ValueTask<string> GetValue() | ||
{ | ||
return Js.InvokeAsync<string>("vditorBlazor.getValue", _ref); | ||
} | ||
|
||
public ValueTask<string> GetHTML() | ||
{ | ||
return Js.InvokeAsync<string>("vditorBlazor.getHTML", _ref); | ||
} | ||
|
||
public async Task SetValue(string value, bool clearStack = false) | ||
{ | ||
await Js.InvokeVoidAsync("vditorBlazor.setValue", _ref, value, clearStack); | ||
} | ||
|
||
public async Task InsertValue(string value, bool render = true) | ||
{ | ||
await Js.InvokeVoidAsync("vditorBlazor.setValue", _ref, value, render); | ||
} | ||
|
||
public async Task Destroy() | ||
{ | ||
await Js.InvokeVoidAsync("vditorBlazor.destroy", _ref); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.