tomvanenckevort / Codery.TextCount

Umbraco data type which wraps existing text data type controls and shows text counts and limits while you type.
1 stars 3 forks source link

TextCount RTEs do not work with macros #4

Closed ZacP closed 6 years ago

ZacP commented 6 years ago

Hi,

The TextCount RTE macros don't display correctly. Instead of showing the macro, it just shows the bolded text "Macro Alias: {MacroName}".

Wrapping the output with umbraco.library.RenderMacro does not fix the problem either.

We tested this side by side with a normal RTE and a TextCount RTE. The normal RTE displays the macro correctly on the front end. The TextCount RTE does not display the macro correctly on the front end (although it does display it correctly in the umbraco admin).

ZacP commented 6 years ago

We were able to fix this via a regex hack, that detects the commented out macro and temp macro text and fixes them to display the macro correctly.

    static Regex FixMacroMarkup = new Regex("<div[^>]+umb-macro-holder[^>]+><!-- | --><ins>Macro alias.*?<\\/ins><\\/div>| --><ins>.*?<\\/ins><\\/div>", RegexOptions.Singleline);

    /// <summary>
    /// Adds a hack for the text count RTE macro rendering
    /// </summary>
    /// <param name="data"></param>
    /// <param name="nodeId"></param>
    /// <returns></returns>
    public static IHtmlString RenderRteForTextCount(IHtmlString input)
    {
        return new HtmlString(FixMacroMarkup.Replace(input.ToString(), ""));
    }
tomvanenckevort commented 6 years ago

Hi Zac,

Thanks for reporting the issue. I will try to reproduce it here and see if I can include a fix for it.

tomvanenckevort commented 6 years ago

Hi Zac,

I've been able to fix the bug and I have released a new version on NuGet: 1.0.14.

Thanks again for reporting the issue.

tomvanenckevort commented 6 years ago

And I should have added as well that you might have to save & publish the RTEs again after upgrading, to make sure the macro syntax in the RTE is saved correctly in the database.