diff --git a/src/components/BootstrapBlazor.SummerNote/BootstrapBlazor.SummerNote.csproj b/src/components/BootstrapBlazor.SummerNote/BootstrapBlazor.SummerNote.csproj index a8482506..4d6acc24 100644 --- a/src/components/BootstrapBlazor.SummerNote/BootstrapBlazor.SummerNote.csproj +++ b/src/components/BootstrapBlazor.SummerNote/BootstrapBlazor.SummerNote.csproj @@ -1,7 +1,7 @@ - 9.0.8 + 9.0.9 diff --git a/src/components/BootstrapBlazor.SummerNote/Components/Editor/Editor.razor b/src/components/BootstrapBlazor.SummerNote/Components/Editor/Editor.razor index 6b88d260..dfce498f 100644 --- a/src/components/BootstrapBlazor.SummerNote/Components/Editor/Editor.razor +++ b/src/components/BootstrapBlazor.SummerNote/Components/Editor/Editor.razor @@ -7,6 +7,6 @@ { } -
+
diff --git a/src/components/BootstrapBlazor.SummerNote/Components/Editor/Editor.razor.cs b/src/components/BootstrapBlazor.SummerNote/Components/Editor/Editor.razor.cs index aa397c8c..ce6d38cf 100644 --- a/src/components/BootstrapBlazor.SummerNote/Components/Editor/Editor.razor.cs +++ b/src/components/BootstrapBlazor.SummerNote/Components/Editor/Editor.razor.cs @@ -13,6 +13,10 @@ namespace BootstrapBlazor.Components; /// public partial class Editor { + private string? ClassString => CssBuilder.Default("editor") + .AddClass(CssClass).AddClass(ValidCss) + .Build(); + /// /// 获得 Editor 样式 /// @@ -182,20 +186,10 @@ protected override async Task InvokeInitAsync() /// /// [JSInvokable] - public async Task Update(string value) + public void Update(string value) { - Value = value; - _lastValue = Value; - - if (ValueChanged.HasDelegate) - { - await ValueChanged.InvokeAsync(Value); - } - - if (OnValueChanged != null) - { - await OnValueChanged.Invoke(value); - } + CurrentValue = value; + _lastValue = value; } /// diff --git a/src/components/BootstrapBlazor.SummerNote/Components/Editor/Editor.razor.js b/src/components/BootstrapBlazor.SummerNote/Components/Editor/Editor.razor.js index a9223e64..82b241c1 100644 --- a/src/components/BootstrapBlazor.SummerNote/Components/Editor/Editor.razor.js +++ b/src/components/BootstrapBlazor.SummerNote/Components/Editor/Editor.razor.js @@ -1,4 +1,4 @@ -import '../../js/summernote-bs5.min.js' +import '../../js/summernote-bs5.min.js' import { addLink, addScript } from '../../../BootstrapBlazor/modules/utility.js' import Data from '../../../BootstrapBlazor/modules/data.js' import EventHandler from '../../../BootstrapBlazor/modules/event-handler.js' @@ -175,7 +175,11 @@ export function getCode(id) { } export function reset(id) { - const editor = Data.get(id) + const editor = Data.get(id); + if (!editor.$editor) { + return; + } + const context = editor.$editor.data('summernote') const showSubmit = editor.el.getAttribute("data-bb-submit") === "true" diff --git a/src/components/BootstrapBlazor.SummerNote/wwwroot/css/editor.css b/src/components/BootstrapBlazor.SummerNote/wwwroot/css/editor.css index 3df9f422..6cd4a8be 100644 --- a/src/components/BootstrapBlazor.SummerNote/wwwroot/css/editor.css +++ b/src/components/BootstrapBlazor.SummerNote/wwwroot/css/editor.css @@ -1,4 +1,4 @@ -.editor .editor-body { +.editor .editor-body { cursor: pointer; min-height: 50px; height: auto; @@ -58,6 +58,16 @@ display: block; } +.editor.is-invalid .note-frame, +.editor.is-invalid > .form-control { + border: 1px solid var(--bs-danger) !important; +} + +.editor.is-valid .note-frame, +.editor.is-valid > .form-control { + border: 1px solid var(--bs-success) !important; +} + .modal-body .note-form-group:not(:last-child) { margin-bottom: 0.5rem; }