100 lines
5.1 KiB
Plaintext
100 lines
5.1 KiB
Plaintext
@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);
|
|
}
|
|
}
|
|
}
|