refactored script resource declaration to allow for bundling, made script loading async, refactored RichTextEditor to use new method

This commit is contained in:
Shaun Walker
2020-06-17 10:27:14 -04:00
parent 7c24bae753
commit 0636227284
10 changed files with 70 additions and 104 deletions

View File

@ -117,23 +117,13 @@ namespace Oqtane.UI
}
}
public async Task LoadScript(string url, string integrity, string crossorigin)
public async Task IncludeScripts(object[] scripts)
{
try
{
await _jsRuntime.InvokeVoidAsync("Oqtane.Interop.loadScript", url, integrity, crossorigin);
}
catch
{
// ignore exception
}
}
public async Task LoadBootstrapJS()
{
try
{
await _jsRuntime.InvokeVoidAsync("Oqtane.Interop.loadBootstrapJS");
await _jsRuntime.InvokeVoidAsync(
"Oqtane.Interop.includeScripts",
(object)scripts);
}
catch
{

View File

@ -33,12 +33,9 @@
// manage stylesheets for this page
string batch = DateTime.Now.ToString("yyyyMMddHHmmssfff");
var links = new List<object>();
foreach (Resource resource in PageState.Page.Resources)
foreach (Resource resource in PageState.Page.Resources.Where(item => item.ResourceType == ResourceType.Stylesheet))
{
if (resource.ResourceType == ResourceType.Stylesheet)
{
links.Add(new { id = "app-stylesheet-" + batch + "-" + (links.Count + 1).ToString("00"), rel = "stylesheet", href = resource.Url, type = "text/css", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", key = "" });
}
links.Add(new { id = "app-stylesheet-" + batch + "-" + (links.Count + 1).ToString("00"), rel = "stylesheet", href = resource.Url, type = "text/css", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", key = "" });
}
await interop.IncludeLinks(links.ToArray());
await interop.RemoveElementsById("app-stylesheet", "", "app-stylesheet-" + batch + "-00");