-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
11 changed files
with
193 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,8 @@ | |
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"CKEditorBundle": { | ||
"Theme": "Dark" | ||
} | ||
} |
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,39 @@ | ||
namespace Sitko.Blazor.CKEditor; | ||
|
||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using ScriptInjector; | ||
|
||
class CKEditorLoader : ICKEditorLoader | ||
{ | ||
private TaskCompletionSource? loadTaskSource; | ||
private readonly IScriptInjector scriptInjector; | ||
private readonly ICKEditorOptionsProvider optionsProvider; | ||
|
||
public CKEditorLoader(IScriptInjector scriptInjector, ICKEditorOptionsProvider optionsProvider) | ||
{ | ||
this.scriptInjector = scriptInjector; | ||
this.optionsProvider = optionsProvider; | ||
} | ||
|
||
public Task LoadAsync() | ||
{ | ||
if (loadTaskSource is null) | ||
{ | ||
loadTaskSource = new TaskCompletionSource(); | ||
var scripts = new List<InjectRequest> | ||
{ | ||
ScriptInjectRequest.FromResource("BlazorCkEditor", GetType().Assembly, "ckeditor.js"), | ||
ScriptInjectRequest.FromUrl(optionsProvider.Options.EditorClassName, | ||
optionsProvider.Options.ScriptPath), | ||
}; | ||
return scriptInjector.InjectAsync(scripts, _ => | ||
{ | ||
loadTaskSource.SetResult(); | ||
return Task.CompletedTask; | ||
}); | ||
} | ||
|
||
return loadTaskSource.Task; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,15 @@ | ||
namespace Sitko.Blazor.CKEditor; | ||
|
||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
using JetBrains.Annotations; | ||
|
||
[PublicAPI] | ||
public class CKEditorOptions | ||
{ | ||
[Required] public virtual string ScriptPath { get; set; } = ""; | ||
[Required] public virtual string StylePath { get; set; } = ""; | ||
public virtual Dictionary<string, string> GetAdditionalScripts(CKEditorConfig? config) => new(); | ||
[Required] public virtual string EditorClassName { get; set; } = ""; | ||
public virtual CKEditorConfig? CKEditorConfig { get; set; } | ||
} |
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,8 @@ | ||
namespace Sitko.Blazor.CKEditor; | ||
|
||
using System.Threading.Tasks; | ||
|
||
public interface ICKEditorLoader | ||
{ | ||
Task LoadAsync(); | ||
} |
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
File renamed without changes.