move the editor settings into editor self control.
This commit is contained in:
@ -128,7 +128,7 @@
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="textEditorProvider" HelpText="Select the text editor provider for the site" ResourceKey="TextEditorProvider">Text Editor Provider: </Label>
|
||||
<div class="col-sm-9">
|
||||
<select id="textEditorProvider" class="form-select" value="@_textEditorProvider" required @onchange="TextEditorProviderChanged">
|
||||
<select id="textEditorProvider" class="form-select" @bind="@_textEditorProvider" required>
|
||||
@if (_textEditorProviders != null)
|
||||
{
|
||||
@foreach (var provider in _textEditorProviders)
|
||||
@ -139,14 +139,6 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@if (_textEditorProviderSettings != null)
|
||||
{
|
||||
<div class="row mb-1 align-items-center">
|
||||
<div class="col-sm-9 offset-sm-3">
|
||||
@_textEditorProviderSettings
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</Section>
|
||||
<Section Name="FileExtensions" Heading="File Extensions" ResourceKey="FileExtensions">
|
||||
@ -464,8 +456,6 @@
|
||||
private string _connectionstring = string.Empty;
|
||||
private string _textEditorProvider = "";
|
||||
private IEnumerable<ITextEditorProvider> _textEditorProviders;
|
||||
private RenderFragment _textEditorProviderSettings;
|
||||
private ISettingsControl _textEditorProviderSettingsControl;
|
||||
private string _createdby;
|
||||
private DateTime _createdon;
|
||||
private string _modifiedby;
|
||||
@ -548,7 +538,6 @@
|
||||
|
||||
//text editor
|
||||
_textEditorProvider = SettingService.GetSetting(settings, "TextEditorProvider", Constants.DefaultTextEditorProvider);
|
||||
LoadTextEditorProviderSettingsControl();
|
||||
|
||||
// hosting model
|
||||
_rendermode = site.RenderMode;
|
||||
@ -732,11 +721,6 @@
|
||||
|
||||
await logger.LogInformation("Site Settings Saved {Site}", site);
|
||||
|
||||
if(_textEditorProviderSettingsControl != null)
|
||||
{
|
||||
await _textEditorProviderSettingsControl.UpdateSettings();
|
||||
}
|
||||
|
||||
NavigationManager.NavigateTo(NavigateUrl(), true); // reload
|
||||
}
|
||||
}
|
||||
@ -926,35 +910,4 @@
|
||||
_aliasname = "";
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void TextEditorProviderChanged(ChangeEventArgs e)
|
||||
{
|
||||
_textEditorProvider = e.Value.ToString();
|
||||
LoadTextEditorProviderSettingsControl();
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void LoadTextEditorProviderSettingsControl()
|
||||
{
|
||||
var provider = _textEditorProviders.FirstOrDefault(i => i.EditorType == _textEditorProvider);
|
||||
var settingsType = provider != null && !string.IsNullOrEmpty(provider.SettingsType) ? Type.GetType(provider.SettingsType) : null;
|
||||
if (settingsType != null)
|
||||
{
|
||||
_textEditorProviderSettings = builder =>
|
||||
{
|
||||
builder.OpenComponent(0, settingsType);
|
||||
builder.AddComponentReferenceCapture(1, (c) =>
|
||||
{
|
||||
_textEditorProviderSettingsControl = (ISettingsControl)c;
|
||||
});
|
||||
builder.CloseComponent();
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
_textEditorProviderSettings = null;
|
||||
_textEditorProviderSettingsControl = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,9 @@
|
||||
@inherits ModuleControlBase
|
||||
@implements ITextEditor
|
||||
@inject ISettingService SettingService
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IStringLocalizer<QuillJSTextEditor> Localizer
|
||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||
|
||||
<div class="quill-text-editor">
|
||||
<TabStrip ActiveTab="@_activetab">
|
||||
@ -97,15 +99,69 @@
|
||||
}
|
||||
</TabPanel>
|
||||
}
|
||||
@if (_hasAdminPermission)
|
||||
{
|
||||
<TabPanel Name="Settings" Heading="Settings" ResourceKey="Settings" ResourceType="@resourceType">
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="AllowFileManagement" ResourceKey="AllowFileManagement" ResourceType="@resourceType" HelpText="Specify If Editors Can Upload and Select Files">Allow File Management: </Label>
|
||||
<div class="col-sm-9">
|
||||
<input type="checkbox" id="AllowFileManagement" class="form-check-input" @bind="_allowFileManagementSetting" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="AllowRawHtml" ResourceKey="AllowRawHtml" ResourceType="@resourceType" HelpText="Specify If Editors Can Enter Raw HTML">Allow Raw HTML: </Label>
|
||||
<div class="col-sm-9">
|
||||
<input type="checkbox" id="AllowRawHtml" class="form-check-input" @bind="_allowRawHtmlSetting" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="AllowRichText" ResourceKey="AllowRichText" ResourceType="@resourceType" HelpText="Specify If Editors Can Use Rich Text Editor">Allow Rich Text: </Label>
|
||||
<div class="col-sm-9">
|
||||
<input type="checkbox" id="AllowRichText" class="form-check-input" @bind="_allowRichTextSetting" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="Theme" ResourceKey="Theme" ResourceType="@resourceType" HelpText="Specify the Rich Text Editor's Theme">Theme: </Label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="Theme" class="form-control" @bind="_themeSetting" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="DebugLevel" ResourceKey="DebugLevel" ResourceType="@resourceType" HelpText="Specify the Debug Level">Debug Level: </Label>
|
||||
<div class="col-sm-9">
|
||||
<select id="DebugLevel" class="form-select" @bind="_debugLevelSetting">
|
||||
@foreach (var level in _debugLevels)
|
||||
{
|
||||
<option value="@level">@level</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="ToolbarContent" ResourceKey="ToolbarContent" ResourceType="@resourceType" HelpText="Specify the Toolbar Content">Toolbar Content: </Label>
|
||||
<div class="col-sm-9">
|
||||
<textarea id="ToolbarContent" class="form-control" @bind="_toolbarContentSetting" rows="5" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<div class="col-sm-9 offset-sm-3">
|
||||
<button type="button" class="btn btn-success" @onclick="@(async () => await UpdateSettings())">@SharedLocalizer["Save"]</button>
|
||||
</div>
|
||||
</div>
|
||||
</TabPanel>
|
||||
}
|
||||
</TabStrip>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private string resourceType = "Oqtane.Modules.Controls.QuillJSTextEditor, Oqtane.Client";
|
||||
|
||||
private bool _initialized = false;
|
||||
|
||||
private QuillEditorInterop interop;
|
||||
private FileManager _fileManager;
|
||||
private string _activetab = "Rich";
|
||||
private bool _hasAdminPermission;
|
||||
|
||||
private bool _allowFileManagement = false;
|
||||
private bool _allowRawHtml = false;
|
||||
@ -113,6 +169,15 @@
|
||||
private string _theme = "snow";
|
||||
private string _debugLevel = "info";
|
||||
private string _toolbarContent = string.Empty;
|
||||
|
||||
//adjust settings variables won't affect UI
|
||||
private bool _allowFileManagementSetting = false;
|
||||
private bool _allowRawHtmlSetting = false;
|
||||
private bool _allowRichTextSetting = false;
|
||||
private string _themeSetting = "snow";
|
||||
private string _debugLevelSetting = "info";
|
||||
private string _toolbarContentSetting = string.Empty;
|
||||
|
||||
private bool _settingsLoaded;
|
||||
|
||||
private ElementReference _editorElement;
|
||||
@ -130,6 +195,8 @@
|
||||
private bool _contentchanged = false;
|
||||
private int _editorIndex;
|
||||
|
||||
private List<string> _debugLevels = new List<string> { "info", "log", "warn", "error" };
|
||||
|
||||
[Parameter]
|
||||
public bool ReadOnly { get; set; }
|
||||
|
||||
@ -140,9 +207,7 @@
|
||||
{
|
||||
new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill.min.js", Location = ResourceLocation.Body },
|
||||
new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill-blot-formatter.min.js", Location = ResourceLocation.Body },
|
||||
new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill-interop.js", Location = ResourceLocation.Body },
|
||||
new Resource { ResourceType = ResourceType.Stylesheet, Url = "css/quill/quill.bubble.css" },
|
||||
new Resource { ResourceType = ResourceType.Stylesheet, Url = "css/quill/quill.snow.css" }
|
||||
new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill-interop.js", Location = ResourceLocation.Body }
|
||||
};
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
@ -367,12 +432,14 @@
|
||||
try
|
||||
{
|
||||
var settings = await SettingService.GetSiteSettingsAsync(PageState.Site.SiteId);
|
||||
_allowFileManagement = SettingService.GetSetting(settings, "QuillTextEditor_AllowFileManagement", "true") == "true";
|
||||
_allowRawHtml = SettingService.GetSetting(settings, "QuillTextEditor_AllowRawHtml", "true") == "true";
|
||||
_allowRichText = SettingService.GetSetting(settings, "QuillTextEditor_AllowRichText", "true") == "true";
|
||||
_theme = SettingService.GetSetting(settings, "QuillTextEditor_Theme", "snow");
|
||||
_debugLevel = SettingService.GetSetting(settings, "QuillTextEditor_DebugLevel", "info");
|
||||
_toolbarContent = SettingService.GetSetting(settings, "QuillTextEditor_ToolbarContent", string.Empty);
|
||||
_allowFileManagementSetting = _allowFileManagement = SettingService.GetSetting(settings, "QuillTextEditor_AllowFileManagement", "true") == "true";
|
||||
_allowRawHtmlSetting = _allowRawHtml = SettingService.GetSetting(settings, "QuillTextEditor_AllowRawHtml", "true") == "true";
|
||||
_allowRichTextSetting = _allowRichText = SettingService.GetSetting(settings, "QuillTextEditor_AllowRichText", "true") == "true";
|
||||
_themeSetting = _theme = SettingService.GetSetting(settings, "QuillTextEditor_Theme", "snow");
|
||||
_debugLevelSetting = _debugLevel = SettingService.GetSetting(settings, "QuillTextEditor_DebugLevel", "info");
|
||||
_toolbarContentSetting = _toolbarContent = SettingService.GetSetting(settings, "QuillTextEditor_ToolbarContent", string.Empty);
|
||||
|
||||
_hasAdminPermission = UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin);
|
||||
|
||||
_settingsLoaded = true;
|
||||
}
|
||||
@ -381,4 +448,25 @@
|
||||
AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UpdateSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
var settings = await SettingService.GetSiteSettingsAsync(PageState.Site.SiteId);
|
||||
settings = SettingService.SetSetting(settings, "QuillTextEditor_AllowFileManagement", _allowFileManagementSetting.ToString().ToLower());
|
||||
settings = SettingService.SetSetting(settings, "QuillTextEditor_AllowRawHtml", _allowRawHtmlSetting.ToString().ToLower());
|
||||
settings = SettingService.SetSetting(settings, "QuillTextEditor_AllowRichText", _allowRichTextSetting.ToString().ToLower());
|
||||
settings = SettingService.SetSetting(settings, "QuillTextEditor_Theme", _themeSetting);
|
||||
settings = SettingService.SetSetting(settings, "QuillTextEditor_DebugLevel", _debugLevelSetting);
|
||||
settings = SettingService.SetSetting(settings, "QuillTextEditor_ToolbarContent", _toolbarContentSetting);
|
||||
await SettingService.UpdateSiteSettingsAsync(settings, PageState.Site.SiteId);
|
||||
|
||||
NavigationManager.NavigateTo(NavigationManager.Uri);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,99 +0,0 @@
|
||||
@namespace Oqtane.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@inject ISettingService SettingService
|
||||
@implements Oqtane.Interfaces.ISettingsControl
|
||||
@inject IStringLocalizer<QuillJSTextEditorSettings> Localizer
|
||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||
|
||||
<div class="container">
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="AllowFileManagement" ResourceKey="AllowFileManagement" ResourceType="@resourceType" HelpText="Specify If Editors Can Upload and Select Files">Allow File Management: </Label>
|
||||
<div class="col-sm-9">
|
||||
<input type="checkbox" id="AllowFileManagement" class="form-check-input" @bind="_allowFileManagement" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="AllowRawHtml" ResourceKey="AllowRawHtml" ResourceType="@resourceType" HelpText="Specify If Editors Can Enter Raw HTML">Allow Raw HTML: </Label>
|
||||
<div class="col-sm-9">
|
||||
<input type="checkbox" id="AllowRawHtml" class="form-check-input" @bind="_allowRawHtml" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="AllowRichText" ResourceKey="AllowRichText" ResourceType="@resourceType" HelpText="Specify If Editors Can Use Rich Text Editor">Allow Rich Text: </Label>
|
||||
<div class="col-sm-9">
|
||||
<input type="checkbox" id="AllowRichText" class="form-check-input" @bind="_allowRichText" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="Theme" ResourceKey="Theme" ResourceType="@resourceType" HelpText="Specify the Rich Text Editor's Theme">Theme: </Label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="Theme" class="form-control" @bind="_theme" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="DebugLevel" ResourceKey="DebugLevel" ResourceType="@resourceType" HelpText="Specify the Debug Level">Debug Level: </Label>
|
||||
<div class="col-sm-9">
|
||||
<select id="DebugLevel" class="form-select" @bind="_debugLevel">
|
||||
@foreach (var level in _debugLevels)
|
||||
{
|
||||
<option value="@level">@level</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="ToolbarContent" ResourceKey="ToolbarContent" ResourceType="@resourceType" HelpText="Specify the Toolbar Content">Toolbar Content: </Label>
|
||||
<div class="col-sm-9">
|
||||
<textarea id="ToolbarContent" class="form-control" @bind="_toolbarContent" rows="5" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private string resourceType = "Oqtane.Modules.Controls.QuillJSTextEditorSettings, Oqtane.Client";
|
||||
private bool _allowFileManagement;
|
||||
private bool _allowRawHtml;
|
||||
private bool _allowRichText;
|
||||
private string _theme;
|
||||
private string _debugLevel;
|
||||
private string _toolbarContent;
|
||||
|
||||
private List<string> _debugLevels = new List<string> { "info", "log", "warn", "error" };
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var settings = await SettingService.GetSiteSettingsAsync(PageState.Site.SiteId);
|
||||
_allowFileManagement = SettingService.GetSetting(settings, "QuillTextEditor_AllowFileManagement", "true") == "true";
|
||||
_allowRawHtml = SettingService.GetSetting(settings, "QuillTextEditor_AllowRawHtml", "true") == "true";
|
||||
_allowRichText = SettingService.GetSetting(settings, "QuillTextEditor_AllowRichText", "true") == "true";
|
||||
_theme = SettingService.GetSetting(settings, "QuillTextEditor_Theme", "snow");
|
||||
_debugLevel = SettingService.GetSetting(settings, "QuillTextEditor_DebugLevel", "info");
|
||||
_toolbarContent = SettingService.GetSetting(settings, "QuillTextEditor_ToolbarContent", string.Empty);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
var settings = await SettingService.GetSiteSettingsAsync(PageState.Site.SiteId);
|
||||
settings = SettingService.SetSetting(settings, "QuillTextEditor_AllowFileManagement", _allowFileManagement.ToString().ToLower());
|
||||
settings = SettingService.SetSetting(settings, "QuillTextEditor_AllowRawHtml", _allowRawHtml.ToString().ToLower());
|
||||
settings = SettingService.SetSetting(settings, "QuillTextEditor_AllowRichText", _allowRichText.ToString().ToLower());
|
||||
settings = SettingService.SetSetting(settings, "QuillTextEditor_Theme", _theme);
|
||||
settings = SettingService.SetSetting(settings, "QuillTextEditor_DebugLevel", _debugLevel);
|
||||
settings = SettingService.SetSetting(settings, "QuillTextEditor_ToolbarContent", _toolbarContent);
|
||||
await SettingService.UpdateSiteSettingsAsync(settings, PageState.Site.SiteId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
@namespace Oqtane.Modules.Controls
|
||||
@inherits ModuleControlBase
|
||||
@inject IServiceProvider ServiceProvider
|
||||
@inject ISettingService SettingService
|
||||
@inject IStringLocalizer<RichTextEditor> Localizer
|
||||
|
||||
<div class="row" style="margin-bottom: 50px;">
|
||||
@ -34,7 +35,7 @@
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_textEditorProvider = await GetTextEditorType(ServiceProvider, PageState.Site.SiteId);
|
||||
_textEditorProvider = await GetTextEditorType();
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
@ -55,22 +56,6 @@
|
||||
await base.OnAfterRenderAsync(firstRender);
|
||||
}
|
||||
|
||||
public override async Task<List<Resource>> GetResources(IServiceProvider serviceProvider, Page page)
|
||||
{
|
||||
var type = await GetTextEditorType(serviceProvider, page.SiteId);
|
||||
if (!string.IsNullOrEmpty(type))
|
||||
{
|
||||
var editorType = Type.GetType(type);
|
||||
if (editorType != null && editorType.GetInterfaces().Contains(typeof(IModuleControl)))
|
||||
{
|
||||
var control = Activator.CreateInstance(editorType) as IModuleControl;
|
||||
return await control?.GetResources(serviceProvider, page);
|
||||
}
|
||||
}
|
||||
|
||||
return await base.GetResources(serviceProvider, page);
|
||||
}
|
||||
|
||||
public async Task<string> GetHtml()
|
||||
{
|
||||
return await _textEditor.GetContent();
|
||||
@ -124,21 +109,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<string> GetTextEditorType(IServiceProvider serviceProvider, int siteId)
|
||||
private async Task<string> GetTextEditorType()
|
||||
{
|
||||
const string EditorSettingName = "TextEditorProvider";
|
||||
|
||||
if(!string.IsNullOrEmpty(Provider))
|
||||
{
|
||||
var provider = serviceProvider.GetServices<ITextEditorProvider>().FirstOrDefault(i => i.Name.Equals(Provider, StringComparison.OrdinalIgnoreCase));
|
||||
var provider = ServiceProvider.GetServices<ITextEditorProvider>().FirstOrDefault(i => i.Name.Equals(Provider, StringComparison.OrdinalIgnoreCase));
|
||||
if(provider != null)
|
||||
{
|
||||
return provider.EditorType;
|
||||
}
|
||||
}
|
||||
|
||||
var settingService = serviceProvider.GetService<ISettingService>();
|
||||
var settings = await settingService.GetSiteSettingsAsync(siteId);
|
||||
return settingService.GetSetting(settings, EditorSettingName, Constants.DefaultTextEditorProvider);
|
||||
var settings = await SettingService.GetSiteSettingsAsync(PageState.Site.SiteId);
|
||||
return SettingService.GetSetting(settings, EditorSettingName, Constants.DefaultTextEditorProvider);
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,12 @@
|
||||
|
||||
public override string Title => "Edit Html/Text";
|
||||
|
||||
public override List<Resource> Resources => new List<Resource>()
|
||||
{
|
||||
new Resource { ResourceType = ResourceType.Stylesheet, Url = "css/quill/quill.bubble.css" },
|
||||
new Resource { ResourceType = ResourceType.Stylesheet, Url = "css/quill/quill.snow.css" }
|
||||
};
|
||||
|
||||
private RichTextEditor RichTextEditorHtml;
|
||||
private string _content = null;
|
||||
private string _createdby;
|
||||
@ -60,8 +66,6 @@
|
||||
private List<Models.HtmlText> _htmltexts;
|
||||
private string _view = "";
|
||||
|
||||
public override List<string> ResourcesRegistrationTypes => new List<string> { typeof(RichTextEditor).FullName };
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
|
@ -50,8 +50,6 @@ namespace Oqtane.Modules
|
||||
|
||||
public virtual List<Resource> Resources { get; set; }
|
||||
|
||||
public virtual List<string> ResourcesRegistrationTypes { get; }
|
||||
|
||||
public virtual string RenderMode { get { return RenderModes.Interactive; } } // interactive by default
|
||||
|
||||
public virtual bool? Prerender { get { return null; } } // allows the Site Prerender property to be overridden
|
||||
@ -73,21 +71,6 @@ namespace Oqtane.Modules
|
||||
|
||||
// base lifecycle method for handling JSInterop script registration
|
||||
|
||||
public virtual async Task<List<Resource>> GetResources(IServiceProvider serviceProvider, Page page)
|
||||
{
|
||||
var resources = Resources ?? new List<Resource>();
|
||||
|
||||
if(ResourcesRegistrationTypes != null)
|
||||
{
|
||||
foreach(var type in ResourcesRegistrationTypes)
|
||||
{
|
||||
resources.AddRange(await LoadResourcesFromType(serviceProvider, page, type));
|
||||
}
|
||||
}
|
||||
|
||||
return resources;
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
@ -499,25 +482,6 @@ namespace Oqtane.Modules
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<Resource>> LoadResourcesFromType(IServiceProvider serviceProvider, Page page, string typeName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var type = Type.GetType(typeName, false, true);
|
||||
if (type != null && type.GetInterfaces().Contains(typeof(IModuleControl)))
|
||||
{
|
||||
var control = Activator.CreateInstance(type) as IModuleControl;
|
||||
return await control?.GetResources(serviceProvider, page);
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
//await Log(null, LogLevel.Error, string.Empty, ex, "Load Resources From Type {Type} Failed. {Message}", typeName, ex.Message);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
[Obsolete("ContentUrl(int fileId) is deprecated. Use FileUrl(int fileId) instead.", false)]
|
||||
public string ContentUrl(int fileid)
|
||||
{
|
||||
|
@ -117,9 +117,33 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AllowFileManagement.HelpText" xml:space="preserve">
|
||||
<value>Specify If Editors Can Upload and Select Files</value>
|
||||
</data>
|
||||
<data name="AllowFileManagement.Text" xml:space="preserve">
|
||||
<value>Allow File Management:</value>
|
||||
</data>
|
||||
<data name="AllowRawHtml.HelpText" xml:space="preserve">
|
||||
<value>Specify If Editors Can Enter Raw HTML</value>
|
||||
</data>
|
||||
<data name="AllowRawHtml.Text" xml:space="preserve">
|
||||
<value>Allow Raw HTML:</value>
|
||||
</data>
|
||||
<data name="AllowRichText.HelpText" xml:space="preserve">
|
||||
<value>Specify If Editors Can Use Rich Text Editor</value>
|
||||
</data>
|
||||
<data name="AllowRichText.Text" xml:space="preserve">
|
||||
<value>Allow Rich Text: </value>
|
||||
</data>
|
||||
<data name="Close" xml:space="preserve">
|
||||
<value>Close</value>
|
||||
</data>
|
||||
<data name="DebugLevel.HelpText" xml:space="preserve">
|
||||
<value>Specify the Debug Level</value>
|
||||
</data>
|
||||
<data name="DebugLevel.Text" xml:space="preserve">
|
||||
<value>Debug Level:</value>
|
||||
</data>
|
||||
<data name="InsertImage" xml:space="preserve">
|
||||
<value>Insert Image</value>
|
||||
</data>
|
||||
@ -129,4 +153,19 @@
|
||||
<data name="Placeholder" xml:space="preserve">
|
||||
<value>Enter Your Content...</value>
|
||||
</data>
|
||||
<data name="Settings" xml:space="preserve">
|
||||
<value>Settings</value>
|
||||
</data>
|
||||
<data name="Theme.HelpText" xml:space="preserve">
|
||||
<value>Specify the Rich Text Editor's Theme</value>
|
||||
</data>
|
||||
<data name="Theme.Text" xml:space="preserve">
|
||||
<value>Theme:</value>
|
||||
</data>
|
||||
<data name="ToolbarContent.HelpText" xml:space="preserve">
|
||||
<value>Specify the Toolbar Content</value>
|
||||
</data>
|
||||
<data name="ToolbarContent.Text" xml:space="preserve">
|
||||
<value>Toolbar Content:</value>
|
||||
</data>
|
||||
</root>
|
@ -1,156 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AllowFileManagement.HelpText" xml:space="preserve">
|
||||
<value>Specify If Editors Can Upload and Select Files</value>
|
||||
</data>
|
||||
<data name="AllowFileManagement.Text" xml:space="preserve">
|
||||
<value>Allow File Management:</value>
|
||||
</data>
|
||||
<data name="AllowRawHtml.HelpText" xml:space="preserve">
|
||||
<value>Specify If Editors Can Enter Raw HTML</value>
|
||||
</data>
|
||||
<data name="AllowRawHtml.Text" xml:space="preserve">
|
||||
<value>Allow Raw HTML:</value>
|
||||
</data>
|
||||
<data name="AllowRichText.HelpText" xml:space="preserve">
|
||||
<value>Specify If Editors Can Use Rich Text Editor</value>
|
||||
</data>
|
||||
<data name="AllowRichText.Text" xml:space="preserve">
|
||||
<value>Allow Rich Text: </value>
|
||||
</data>
|
||||
<data name="DebugLevel.HelpText" xml:space="preserve">
|
||||
<value>Specify the Debug Level</value>
|
||||
</data>
|
||||
<data name="DebugLevel.Text" xml:space="preserve">
|
||||
<value>Debug Level:</value>
|
||||
</data>
|
||||
<data name="Theme.HelpText" xml:space="preserve">
|
||||
<value>Specify the Rich Text Editor's Theme</value>
|
||||
</data>
|
||||
<data name="Theme.Text" xml:space="preserve">
|
||||
<value>Theme:</value>
|
||||
</data>
|
||||
<data name="ToolbarContent.HelpText" xml:space="preserve">
|
||||
<value>Specify the Toolbar Content</value>
|
||||
</data>
|
||||
<data name="ToolbarContent.Text" xml:space="preserve">
|
||||
<value>Toolbar Content:</value>
|
||||
</data>
|
||||
</root>
|
@ -5,7 +5,6 @@
|
||||
@using Microsoft.AspNetCore.Http.Extensions
|
||||
@using Microsoft.AspNetCore.Antiforgery
|
||||
@using Microsoft.AspNetCore.Localization
|
||||
@using Microsoft.Extensions.DependencyInjection
|
||||
@using Microsoft.Net.Http.Headers
|
||||
@using Microsoft.Extensions.Primitives
|
||||
@using Oqtane.Client
|
||||
@ -31,7 +30,6 @@
|
||||
@inject IUrlMappingRepository UrlMappingRepository
|
||||
@inject IVisitorRepository VisitorRepository
|
||||
@inject IJwtManager JwtManager
|
||||
@inject IServiceProvider ServiceProvider
|
||||
|
||||
@if (_initialized)
|
||||
{
|
||||
@ -676,7 +674,7 @@
|
||||
var obj = Activator.CreateInstance(moduletype) as IModuleControl;
|
||||
if (obj != null)
|
||||
{
|
||||
resources = AddResources(resources, await obj.GetResources(ServiceProvider, page), ResourceLevel.Module, alias, "Modules", moduletype.Namespace, site.RenderMode);
|
||||
resources = AddResources(resources, obj.Resources, ResourceLevel.Module, alias, "Modules", moduletype.Namespace, site.RenderMode);
|
||||
if (action.ToLower() == "settings" && module.ModuleDefinition != null)
|
||||
{
|
||||
// settings components are embedded within a framework settings module
|
||||
@ -684,7 +682,7 @@
|
||||
if (moduletype != null)
|
||||
{
|
||||
obj = Activator.CreateInstance(moduletype) as IModuleControl;
|
||||
resources = AddResources(resources, await obj.GetResources(ServiceProvider, page), ResourceLevel.Module, alias, "Modules", moduletype.Namespace, site.RenderMode);
|
||||
resources = AddResources(resources, obj.Resources, ResourceLevel.Module, alias, "Modules", moduletype.Namespace, site.RenderMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Modules
|
||||
{
|
||||
@ -33,17 +31,6 @@ namespace Oqtane.Modules
|
||||
/// </summary>
|
||||
List<Resource> Resources { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The component types which need to register it's own resources.
|
||||
/// </summary>
|
||||
List<string> ResourcesRegistrationTypes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Identifies all resources in a module including resources from resources registration types.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<Resource>> GetResources(IServiceProvider serviceProvider, Page page);
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the required render mode for the module control ie. Static,Interactive
|
||||
/// </summary>
|
||||
|
@ -14,10 +14,5 @@ namespace Oqtane.Interfaces
|
||||
/// The text editor type full name.
|
||||
/// </summary>
|
||||
string EditorType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The text editor settings type full name.
|
||||
/// </summary>
|
||||
string SettingsType { get; }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user