-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditablePage.cs
More file actions
50 lines (45 loc) · 1.78 KB
/
EditablePage.cs
File metadata and controls
50 lines (45 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using Microsoft.AspNetCore.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CoreSharp.ContentToolsJs.Editor
{
public class EditablePageBase : ComponentBase, IDisposable
{
[Inject]
public ContentToolsJsInterop contentToolsEditor { get; set; }
public void Dispose()
{
contentToolsEditor.Reset();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
if (firstRender)
await contentToolsEditor.Initialize();
}
}
public class EditablePage : EditablePageBase
{
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender && !contentToolsEditor.HasStylesBeenset)
{
var mediaTags = new List<HtmlTag>() { HtmlTag.img, HtmlTag.iframe, HtmlTag.video };
var tableTags = new List<HtmlTag>() { HtmlTag.table };
contentToolsEditor.Styles = new List<Style>()
{
new Style("Align Left", "align-left", mediaTags),
new Style("Align Right", "align-right", mediaTags),
new Style("Full Width", "table-full-width", tableTags),
new Style("Layout Fixed", "table-layout-fixed", tableTags),
new Style("Layout Auto", "table-layout-auto", tableTags),
new Style("Content Align Top", ".table-content-alight-top", tableTags),
};
}
await base.OnAfterRenderAsync(firstRender);
}
}
}