Render base grid editor partial async

This commit is contained in:
Bjarne Fyrstenborg
2021-06-22 19:37:46 +02:00
parent ff65a333e1
commit a7c5bdafe4
3 changed files with 21 additions and 15 deletions

View File

@@ -1,23 +1,27 @@
@model dynamic
@model dynamic
@try
{
string editor = EditorView(Model);
<text>@await Html.PartialAsync(editor, (object)Model)</text>
}
catch (Exception ex)
{
<pre>@ex.ToString()</pre>
}
@functions{
@functions {
public static string EditorView(dynamic contentItem)
{
string view = contentItem.editor.render != null ? contentItem.editor.render.ToString() : contentItem.editor.view.ToString();
view = view.ToLower().Replace(".html", ".cshtml");
if (!view.Contains("/")) {
if (!view.Contains("/"))
{
view = "grid/editors/" + view;
}
return view;
}
}
@try
{
string editor = EditorView(Model);
<text>@Html.Partial(editor, (object)Model)</text>
}
catch (Exception ex) {
<pre>@ex.ToString()</pre>
}

View File

@@ -1,11 +1,13 @@
@model dynamic
@model dynamic
@using Umbraco.Cms.Core.Media
@using Umbraco.Cms.Core.PropertyEditors.ValueConverters
@inject IImageUrlGenerator ImageUrlGenerator
@if (Model.value != null)
{
var url = Model.value.image;
if(Model.editor.config != null && Model.editor.config.size != null){
if (Model.editor.config != null && Model.editor.config.size != null)
{
if (Model.value.coordinates != null)
{
url = ImageCropperTemplateCoreExtensions.GetCropUrl(

View File

@@ -1,13 +1,13 @@
@using Umbraco.Cms.Core.Templates
@using Umbraco.Cms.Core.Templates
@model dynamic
@inject HtmlLocalLinkParser HtmlLocalLinkParser;
@inject HtmlUrlParser HtmlUrlParser;
@inject HtmlImageSourceParser HtmlImageSourceParser;
@{
var value = HtmlLocalLinkParser.EnsureInternalLinks(Model.value.ToString());
value = HtmlUrlParser.EnsureUrls(value);
value = HtmlImageSourceParser.EnsureImageSources(value);
}
@Html.Raw(value)