Merge pull request #4452 from sbwalker/dev
remove ITextEditorProvider interface
This commit is contained in:
commit
4a35d7364b
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Providers;
|
||||
using Oqtane.Services;
|
||||
using Oqtane.Shared;
|
||||
|
@ -51,6 +52,10 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
services.AddScoped<IVisitorService, VisitorService>();
|
||||
services.AddScoped<ISyncService, SyncService>();
|
||||
|
||||
// providers
|
||||
services.AddScoped<ITextEditor, Oqtane.Modules.Controls.QuillJSTextEditor>();
|
||||
services.AddScoped<ITextEditor, Oqtane.Modules.Controls.TextAreaTextEditor>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,14 +131,14 @@
|
|||
<Section Name="Functionality" Heading="Functionality" ResourceKey="Functionality">
|
||||
<div class="container">
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="textEditorProvider" HelpText="Select the text editor for the site" ResourceKey="TextEditorProvider">Text Editor: </Label>
|
||||
<Label Class="col-sm-3" For="textEditor" HelpText="Select the text editor for the site" ResourceKey="TextEditor">Text Editor: </Label>
|
||||
<div class="col-sm-9">
|
||||
<select id="textEditorProvider" class="form-select" @bind="@_textEditorProvider" required>
|
||||
@if (_textEditorProviders != null)
|
||||
<select id="textEditor" class="form-select" @bind="@_textEditor" required>
|
||||
@if (_textEditors != null)
|
||||
{
|
||||
@foreach (var provider in _textEditorProviders)
|
||||
@foreach (var textEditor in _textEditors)
|
||||
{
|
||||
<option value="@provider.EditorType">@provider.Name</option>
|
||||
<option value="@textEditor.Value">@textEditor.Key</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
|
@ -428,8 +428,8 @@
|
|||
private string _containertype = "";
|
||||
private string _admincontainertype = "";
|
||||
|
||||
private IEnumerable<ITextEditorProvider> _textEditorProviders;
|
||||
private string _textEditorProvider = "";
|
||||
private Dictionary<string, string> _textEditors = new Dictionary<string, string>();
|
||||
private string _textEditor = "";
|
||||
private string _imageFiles = string.Empty;
|
||||
private string _uploadableFiles = string.Empty;
|
||||
|
||||
|
@ -515,8 +515,12 @@
|
|||
_admincontainertype = (!string.IsNullOrEmpty(site.AdminContainerType)) ? site.AdminContainerType : Constants.DefaultAdminContainer;
|
||||
|
||||
// functionality
|
||||
_textEditorProviders = ServiceProvider.GetServices<ITextEditorProvider>();
|
||||
_textEditorProvider = SettingService.GetSetting(settings, "TextEditorProvider", Constants.DefaultTextEditorProvider);
|
||||
var textEditors = ServiceProvider.GetServices<ITextEditor>();
|
||||
foreach (var textEditor in textEditors)
|
||||
{
|
||||
_textEditors.Add(textEditor.Name, Utilities.GetFullTypeName(textEditor.GetType().AssemblyQualifiedName));
|
||||
}
|
||||
_textEditor = SettingService.GetSetting(settings, "TextEditor", Constants.DefaultTextEditor);
|
||||
_imageFiles = SettingService.GetSetting(settings, "ImageFiles", Constants.ImageFiles);
|
||||
_imageFiles = (string.IsNullOrEmpty(_imageFiles)) ? Constants.ImageFiles : _imageFiles;
|
||||
_uploadableFiles = SettingService.GetSetting(settings, "UploadableFiles", Constants.UploadableFiles);
|
||||
|
@ -724,7 +728,7 @@
|
|||
settings = SettingService.SetSetting(settings, "NotificationRetention", _retention.ToString(), true);
|
||||
|
||||
// functionality
|
||||
settings = SettingService.SetSetting(settings, "TextEditorProvider", _textEditorProvider);
|
||||
settings = SettingService.SetSetting(settings, "TextEditor", _textEditor);
|
||||
settings = SettingService.SetSetting(settings, "ImageFiles", (_imageFiles != Constants.ImageFiles) ? _imageFiles.Replace(" ", "") : "", false);
|
||||
settings = SettingService.SetSetting(settings, "UploadableFiles", (_uploadableFiles != Constants.UploadableFiles) ? _uploadableFiles.Replace(" ", "") : "", false);
|
||||
|
||||
|
|
|
@ -177,6 +177,8 @@
|
|||
</div>
|
||||
|
||||
@code {
|
||||
public string Name => "QuillJS";
|
||||
|
||||
private string resourceType = "Oqtane.Modules.Controls.QuillJSTextEditor, Oqtane.Client";
|
||||
|
||||
private bool _settingsLoaded;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</div>
|
||||
|
||||
@code {
|
||||
private string _textEditorProvider;
|
||||
private string _textEditorType;
|
||||
private RenderFragment _textEditorComponent;
|
||||
private ITextEditor _textEditor;
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
|||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_textEditorProvider = await GetTextEditorType();
|
||||
_textEditorType = await GetTextEditorType();
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
|
@ -63,9 +63,9 @@
|
|||
|
||||
private void CreateTextEditor(RenderTreeBuilder builder)
|
||||
{
|
||||
if(!string.IsNullOrEmpty(_textEditorProvider))
|
||||
if(!string.IsNullOrEmpty(_textEditorType))
|
||||
{
|
||||
var editorType = Type.GetType(_textEditorProvider);
|
||||
var editorType = Type.GetType(_textEditorType);
|
||||
if (editorType != null)
|
||||
{
|
||||
builder.OpenComponent(0, editorType);
|
||||
|
@ -111,18 +111,18 @@
|
|||
|
||||
private async Task<string> GetTextEditorType()
|
||||
{
|
||||
const string EditorSettingName = "TextEditorProvider";
|
||||
const string EditorSettingName = "TextEditor";
|
||||
|
||||
if(!string.IsNullOrEmpty(Provider))
|
||||
{
|
||||
var provider = ServiceProvider.GetServices<ITextEditorProvider>().FirstOrDefault(i => i.Name.Equals(Provider, StringComparison.OrdinalIgnoreCase));
|
||||
var provider = ServiceProvider.GetServices<ITextEditor>().FirstOrDefault(i => i.Name.Equals(Provider, StringComparison.OrdinalIgnoreCase));
|
||||
if(provider != null)
|
||||
{
|
||||
return provider.EditorType;
|
||||
return Utilities.GetFullTypeName(provider.GetType().AssemblyQualifiedName);
|
||||
}
|
||||
}
|
||||
|
||||
var settings = await SettingService.GetSiteSettingsAsync(PageState.Site.SiteId);
|
||||
return SettingService.GetSetting(settings, EditorSettingName, Constants.DefaultTextEditorProvider);
|
||||
return SettingService.GetSetting(settings, EditorSettingName, Constants.DefaultTextEditor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
</div>
|
||||
|
||||
@code {
|
||||
public string Name => "TextArea";
|
||||
|
||||
private ElementReference _editor;
|
||||
private string _content;
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
using Oqtane.Interfaces;
|
||||
|
||||
namespace Oqtane.Providers
|
||||
{
|
||||
public class QuillJSTextEditorProvider : ITextEditorProvider
|
||||
{
|
||||
public string Name => "QuillJS";
|
||||
|
||||
public string EditorType => "Oqtane.Modules.Controls.QuillJSTextEditor, Oqtane.Client";
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
using Oqtane.Interfaces;
|
||||
|
||||
namespace Oqtane.Providers
|
||||
{
|
||||
public class TextAreaTextEditorProvider : ITextEditorProvider
|
||||
{
|
||||
public string Name => "TextArea";
|
||||
|
||||
public string EditorType => "Oqtane.Modules.Controls.TextAreaTextEditor, Oqtane.Client";
|
||||
}
|
||||
}
|
|
@ -426,10 +426,10 @@
|
|||
<data name="Runtime.Text" xml:space="preserve">
|
||||
<value>Interactivity:</value>
|
||||
</data>
|
||||
<data name="TextEditorProvider.HelpText" xml:space="preserve">
|
||||
<data name="TextEditor.HelpText" xml:space="preserve">
|
||||
<value>Select the text editor for the site</value>
|
||||
</data>
|
||||
<data name="TextEditorProvider.Text" xml:space="preserve">
|
||||
<data name="TextEditor.Text" xml:space="preserve">
|
||||
<value>Text Editor:</value>
|
||||
</data>
|
||||
<data name="Functionality" xml:space="preserve">
|
||||
|
|
|
@ -102,7 +102,10 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
services.AddScoped<ISearchResultsService, SearchResultsService>();
|
||||
services.AddScoped<ISearchService, SearchService>();
|
||||
services.AddScoped<ISearchProvider, DatabaseSearchProvider>();
|
||||
|
||||
|
||||
// providers
|
||||
services.AddScoped<ITextEditor, Oqtane.Modules.Controls.QuillJSTextEditor>();
|
||||
services.AddScoped<ITextEditor, Oqtane.Modules.Controls.TextAreaTextEditor>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
@ -150,10 +153,6 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
services.AddTransient<IUpgradeManager, UpgradeManager>();
|
||||
services.AddTransient<IUserManager, UserManager>();
|
||||
|
||||
// providers
|
||||
services.AddTransient<ITextEditorProvider, QuillJSTextEditorProvider>();
|
||||
services.AddTransient<ITextEditorProvider, TextAreaTextEditorProvider>();
|
||||
|
||||
// obsolete - replaced by ITenantManager
|
||||
services.AddTransient<ITenantResolver, TenantResolver>();
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ namespace Oqtane.Interfaces
|
|||
/// </summary>
|
||||
public interface ITextEditor
|
||||
{
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// initializes the editor with the initialize content.
|
||||
/// </summary>
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
namespace Oqtane.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Rich text editor provider interface.
|
||||
/// </summary>
|
||||
public interface ITextEditorProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// The text editor provider name.
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The text editor type full name.
|
||||
/// </summary>
|
||||
string EditorType { get; }
|
||||
}
|
||||
}
|
|
@ -81,7 +81,7 @@ namespace Oqtane.Shared
|
|||
public const string DefaultSearchProviderName = "DatabaseSearchProvider";
|
||||
|
||||
public static readonly string[] InternalPagePaths = { "login", "register", "reset", "404" };
|
||||
public const string DefaultTextEditorProvider = "Oqtane.Modules.Controls.QuillJSTextEditor, Oqtane.Client";
|
||||
public const string DefaultTextEditor = "Oqtane.Modules.Controls.QuillJSTextEditor, Oqtane.Client";
|
||||
|
||||
// Obsolete constants
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user