Hi
I'm totaly new to Umbraco (and razor and Angular) but found this thread after having the same issue. Seems like it works allright except for one thing that I can't really figure out the correct solution for.
Text that is entered in the editor is rendered undecoded ( the < and > is displayed as < and > etc)
I only render it in the Partial View Macro as:
< div>@Model.MacroParameters["Text"]< /div>
My question is: Do you decode it when rendered or did I miss something when creating the plugin. shouldn't the text be decoded when it is stored and not when rendered?
And how do you do that ?
/J
Edited:
To output the html correctly I had to do:
new HtmlString(WebUtility.HtmlDecode((string)Model.MacroParameters["Content"]))
Otherwise the allready encoded text will be encoded again resulting in &lt; when a < is rendered.
I think the value should allready have been decoded so you only had to do:
new HtmlString(Model.MacroParameters["Content"]), but I don't know how to do that.
I'm currently struggling with the same problem as Johan, the text in my macro is rendered as text and not HTML. I've tried doing the following to pick out the HTML:
var text = Model.MacroParameters.ContainsKey("text") != null ? WebUtility.HtmlDecode((string)Model.MacroParameters["text"]) : "";
Which is then used in the template with @text but this still renders as text.
I also tried your suggestion Morten (Html.Raw) but this gives a partial view script error, I'm not sure if I got the syntax wrong because I'm a bit of an Umbraco beginner.
"The Razor syntax @ operator HTML-encodes text before rendering it to the HTTP response. This causes the text to be displayed as regular text in the web page instead of being interpreted as HTML markup."
Any other idea on how to get this to render as I am struggling to find a way?
Any suggestion how to implement this into v8? They have made some changes, if I follow the instructions above it doesn't work. Error 404 not found for /umbraco/Rte when I try to create an instance of the macro. Thanks
TinyMCE as macro parameter
Has anyone implemented the richtext editor as a parameter in macros?
I tried to created a new property editor with the standard rte.html, but it throws a lot of JS errors, and it does not work:
Hi Morten Christensen
Are you able to achieve this? Please share how to do this.
Thanks Manish
Hello Manish,
Yes I actually did! Here is the solution:
In App_Plugins, create a new Folder called RichTextMacro (or whatever your like).
package.manifest
RichTextMacro.controller.js
RichTextMacro.html
Now, do an App Recycle in IIS, and clear cache in your browser. The macro can now be added as an macro param.
Thanks Morten, just what I needed!
Have you though about creating a package for this?
Hi Søren,
Yes I did :) But havn't got the time for it yet.
That is a thing of beauty!
Thanks for this Morten
I have added this code but when i am adding this macro it is showing nothing
Do you get any JS errors?
Also, if you are using Chrome, you will have to do a hard clear cache in the browser.
Yes it is appearing now, after i had a cup of coffee.
Thans
Cool! :)
One more thing that it is showing semi colon default. Can you please guide me on this too
Manish
It looks like you have an extra semicolon in the macro you are adding.
working fine now just left one semicolon in code.
Thank you very much for your help Morten !!
Hi I'm totaly new to Umbraco (and razor and Angular) but found this thread after having the same issue. Seems like it works allright except for one thing that I can't really figure out the correct solution for.
Text that is entered in the editor is rendered undecoded ( the < and > is displayed as < and > etc)
I only render it in the Partial View Macro as:
< div>@Model.MacroParameters["Text"]< /div>
My question is: Do you decode it when rendered or did I miss something when creating the plugin. shouldn't the text be decoded when it is stored and not when rendered?
And how do you do that ?
/J
Edited: To output the html correctly I had to do: new HtmlString(WebUtility.HtmlDecode((string)Model.MacroParameters["Content"]))
Otherwise the allready encoded text will be encoded again resulting in &lt; when a < is rendered.
I think the value should allready have been decoded so you only had to do: new HtmlString(Model.MacroParameters["Content"]), but I don't know how to do that.
Does it work if you use:
I'm currently struggling with the same problem as Johan, the text in my macro is rendered as text and not HTML. I've tried doing the following to pick out the HTML:
Which is then used in the template with @text but this still renders as text.
I also tried your suggestion Morten (Html.Raw) but this gives a partial view script error, I'm not sure if I got the syntax wrong because I'm a bit of an Umbraco beginner.
Hey,
I created the custom macro parameter Successfully from the example above.
No matter what I try I still get Html tags .
Thanks.
Is there any way to use the mceImage/MediaPicker with this solution?
Tried to add
mceImage
to thetoolbar:..
parameter but it does not appear there.Edit: Nevermind, I was just to stupid to realize that I don't need to add the umbracoAlias to the toolbar parameter, but instead the
frontendCommand
.Will not work as according to https://msdn.microsoft.com/en-us/library/gg568896(v=vs.99).aspx
"The Razor syntax @ operator HTML-encodes text before rendering it to the HTTP response. This causes the text to be displayed as regular text in the web page instead of being interpreted as HTML markup."
Any other idea on how to get this to render as I am struggling to find a way?
Had the same issue just now. Instead of only using
@Html.Raw()
use something like this:Is bit ugly, but it works.
Any suggestion how to implement this into v8? They have made some changes, if I follow the instructions above it doesn't work. Error 404 not found for /umbraco/Rte when I try to create an instance of the macro. Thanks
Hi Erik
Had a similar issue when updating my Editor Notes package:
https://github.com/marcemarc/EditorNotes/commit/513e25164faef949ab599a46554b46dc9256932b
Try setting the view to be:
instead of 'rte'
and the toolbar I think has some different options: try:
and after the dimensions, add the new mode setting to be classic:
I can't think of anything else I had to change...
maybe that will work!
regards
Marc
To Render RTE Content passed by Macro-Paraemter and also render internal links! use this code (V8):
This was working in v10 but I've upgraded to v13 and it's not working.
Has anyone got it working in v13?
Cheers Tony
In v13 you can use blocks in the RTE instead. Much better, and not deprecated like Macros are.
Yes but that's a massive amount of work to convert the macros and then the existing content.
A quick fix would be appreciated before we plan for all that work in the next upgrade.
is working on a reply...