#Macro in RTE throwing error
1 messages · Page 1 of 1 (latest)
I am using https://www.nuget.org/packages/Nikcio.UHeadless package for graphql
cc @mortal harness
Whats the error? And is there any error in the console?
value coming null and the only unexpected error occurred coming
If you could make a minimal reproduction i could try and troubleshoot it in a couple of weeks. (Im taking a vacation tomorrow)
@mortal harness let me know once you are back and will provide you the login
Hey i might have a little time in the weekend
this the error
StackTrace: " at Umbraco.Cms.Web.Common.Macros.MacroRenderer.<RenderAsync>d__23.MoveNext()\r\n at Umbraco.Cms.Web.Common.Macros.MacroRenderer.<RenderAsync>d__22.MoveNext()\r\n at Umbraco.Cms.Core.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.<>c__DisplayClass15_0.<RenderRteMacros>b__1(String macroAlias, Dictionary2 macroAttributes)\r\n at Umbraco.Cms.Infrastructure.Macros.MacroTagParser.ParseMacros(String text, Action1 textFoundCallback, Action`2 macroFoundCallback)\r\n at Umbraco.Cms.Core.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.RenderRteMacros(String source, Boolean preview)\r\n at Umbraco.Cms.Core.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.Convert(Object source, Boolean preview)\r\n at Umbraco.Cms.Core.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, Object inter, Boolean preview)\r\n
at Umbraco.Cms.Core.Models.PublishedContent.PublishedPropertyType.ConvertInterToObject(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, Object inter, Boolean preview)\r\n at Umbraco.Cms.Core.PublishedCache.PublishedElementPropertyBase.GetValue(String culture, String segment)"
TargetSite: {Void MoveNext()}
@mortal harness
From the stacktrace i can only see it failing inside Umbraco and not in the UHeadless code. Is there any more to the stacktrace?
You could also try and copy the BasicRichText class code so you can step through that in your own application
Ya i have done that
public CustomRichText(CreatePropertyValue createPropertyValue, IHttpContextAccessor httpContextAccessor) : base(createPropertyValue)
{
IHtmlEncodedString htmlEncodedString = createPropertyValue.Property.Value<IHtmlEncodedString>(createPropertyValue.PublishedValueFallback, createPropertyValue.Culture, createPropertyValue.Segment, createPropertyValue.Fallback);
if (htmlEncodedString != null)
{
Value = htmlEncodedString?.ToHtmlString();
SourceValue = createPropertyValue.Property.GetSourceValue(createPropertyValue.Culture)?.ToString();
}
var value = createPropertyValue.Property.GetValue().ToString();
string pattern = "((?:src)[\\s]*?)(?:\\=[\\s]*?[\\\"\\\'])[\\/*\\\\*]?(?!..+[s]?\\:[\\/]*)(.*?)(?:[\\s\\\"\\\'])";
var reg = new Regex(pattern, RegexOptions.IgnoreCase);
string prefix = string.Format("{0}://{1}/", httpContextAccessor.HttpContext.Request.Scheme, httpContextAccessor.HttpContext.Request.Host.Value);
var absoluteValue = reg.Replace(value, "$1=\"" + prefix + "$2\"");
HTMLValue = absoluteValue;
its same error Value can't be null ( parameter conten)
@mortal harness i also found issue with Preview when there multisite setup
e.g.
and domain set on home page like /au , /in
now when we use routeMode: CACHE_OR_ROUTING for preview it throwes error when using ContentByAbsoluteRoute but works for ContentbyId
Have you tried without using the BasicRichText as a base for the class?
checking
Do you have the same problem if you just use ROUTING?
no but when using routing unpublished content not coming
I am not using BasicRichText as class. This is my full class
using HotChocolate;
using Microsoft.AspNetCore.Http;
using Nikcio.UHeadless.Base.Basics.EditorsValues.RichTextEditor.Models;
using Nikcio.UHeadless.Base.Properties.Commands;
using Nikcio.UHeadless.Base.Properties.Models;
using System.Text.RegularExpressions;
using Umbraco.Cms.Core.Strings;
public class CustomRichText : PropertyValue
{
public string HTMLValue { get; set; }
public virtual string? Value { get; set; }
public virtual string? SourceValue { get; set; }
public CustomRichText(CreatePropertyValue createPropertyValue, IHttpContextAccessor httpContextAccessor) : base(createPropertyValue)
{
IHtmlEncodedString htmlEncodedString = createPropertyValue.Property.Value<IHtmlEncodedString>(createPropertyValue.PublishedValueFallback, createPropertyValue.Culture, createPropertyValue.Segment, createPropertyValue.Fallback);
if (htmlEncodedString != null)
{
Value = htmlEncodedString?.ToHtmlString();
SourceValue = createPropertyValue.Property.GetSourceValue(createPropertyValue.Culture)?.ToString();
}
var value = createPropertyValue.Property.GetValue().ToString();
string pattern = "((?:src)[\\s]*?)(?:\\=[\\s]*?[\\\"\\\'])[\\/*\\\\*]?(?!..+[s]?\\:[\\/]*)(.*?)(?:[\\s\\\"\\\'])";
var reg = new Regex(pattern, RegexOptions.IgnoreCase);
string prefix = string.Format("{0}://{1}/", httpContextAccessor.HttpContext.Request.Scheme, httpContextAccessor.HttpContext.Request.Host.Value);
var absoluteValue = reg.Replace(value, "$1=\"" + prefix + "$2\"");
HTMLValue = absoluteValue;
}
}
In this case which line does it fail on?
seems like when macro used, this content is null
That call ".Value" is using the Umbraco source code it's not the command having content as null but somewhere in the Umbraco source code the problem is
hmmm
This should be the source code: https://github.com/umbraco/Umbraco-CMS/blob/2221c4f1c719f072d660df1a9e16b2fbce3fc17b/src/Umbraco.Core/Extensions/PublishedPropertyExtension.cs#L32
The simple, flexible and friendly ASP.NET CMS used by more than 730.000 websites - umbraco/Umbraco-CMS
Similarly I think it might be the call to this in the source code that gets your preview to fail: https://github.com/umbraco/Umbraco-CMS/blob/2221c4f1c719f072d660df1a9e16b2fbce3fc17b/src/Umbraco.Core/PublishedCache/IPublishedContentCache.cs#L27
The simple, flexible and friendly ASP.NET CMS used by more than 730.000 websites - umbraco/Umbraco-CMS
preview is definitely due to multi site
It's what called from here: https://github.com/nikcio/Nikcio.UHeadless/blob/8b1e058b4e67fc79265e47492d85462d4da2ce1f/src/Nikcio.UHeadless.Content/Router/ContentRouter.cs#L109
And it's the only place where it differs from contentById