public void Format_RTE_Data_For_Editor_With_No_Macros() { var content = @"<p>hello world</p>"; var result = MacroTagParser.FormatRichTextContentForPersistence(content); Assert.AreEqual(@"<p>hello world</p>", content); }
public void Format_RTE_Data_For_Persistence_No_Class() { var content = @"<html> <body> <h1>asdfasdf</h1> <div att1='asdf' att2='asdfasdfasdf' att3=""sdfsdfd""> <!-- <?UMBRACO_MACRO macroAlias=""myMacro"" param1=""test1"" param2=""test2"" /> --> asdfasdf asdfas <span>asdfasdfasdf</span> <p>asdfasdf</p> </div> <span>asdfdasf</span> <div> asdfsdf </div> </body> </html>"; var result = MacroTagParser.FormatRichTextContentForPersistence(content); Assert.AreEqual(@"<html> <body> <h1>asdfasdf</h1> <?UMBRACO_MACRO macroAlias=""myMacro"" param1=""test1"" param2=""test2"" /> <span>asdfdasf</span> <div> asdfsdf </div> </body> </html>".Replace(Environment.NewLine, string.Empty), result.Replace(Environment.NewLine, string.Empty)); }
public void Format_RTE_Data_For_Persistence_Multiline_Parameters() { string content = @"<html> <body> <h1>asdfasdf</h1> <div class='umb-macro-holder mceNonEditable' att1='asdf' att2='asdfasdfasdf' att3=""sdfsdfd""> <!-- <?UMBRACO_MACRO macroAlias=""myMacro"" param1=""test1"" param2=""test2 dfdsfds"" /> --> asdfasdf asdfas <span>asdfasdfasdf</span> <p>asdfasdf</p> </div> <span>asdfdasf</span> <div> asdfsdf </div> </body> </html>"; string result = MacroTagParser.FormatRichTextContentForPersistence(content); Assert.AreEqual( @"<html> <body> <h1>asdfasdf</h1> <?UMBRACO_MACRO macroAlias=""myMacro"" param1=""test1"" param2=""test2 dfdsfds"" /> <span>asdfdasf</span> <div> asdfsdf </div> </body> </html>".Replace(Environment.NewLine, string.Empty), result.Replace(Environment.NewLine, string.Empty)); }
public void Format_RTE_Data_For_Persistence() { var content = @"<html> <body> <h1>asdfasdf</h1> <div class='umb-macro-holder mceNonEditable' att1='asdf' att2='asdfasdfasdf' att3=""sdfsdfd""> <!-- <?UMBRACO_MACRO macroAlias=""myMacro"" param1=""test1"" param2=""test2"" /> --> asdfasdf asdfas <span>asdfasdfasdf</span> <p>asdfasdf</p> </div> <span>asdfdasf</span> <div> asdfsdf </div> </body> </html>"; var result = MacroTagParser.FormatRichTextContentForPersistence(content); Assert.AreEqual( @"<html> <body> <h1>asdfasdf</h1> <?UMBRACO_MACRO macroAlias=""myMacro"" param1=""test1"" param2=""test2"" /> <span>asdfdasf</span> <div> asdfsdf </div> </body> </html>".StripNewLines(), result.StripNewLines()); }
public void Format_RTE_Data_For_Editor_With_No_Macros(string expected) { var content = expected; var result = MacroTagParser.FormatRichTextContentForPersistence(content); Assert.AreEqual(expected, result); }
/// <summary> /// Format the data for persistence /// </summary> /// <param name="editorValue"></param> /// <param name="currentValue"></param> /// <returns></returns> public override object ConvertEditorToDb(Core.Models.Editors.ContentPropertyData editorValue, object currentValue) { if (editorValue.Value == null) { return(null); } var parsed = MacroTagParser.FormatRichTextContentForPersistence(editorValue.Value.ToString()); return(parsed); }
public void Format_RTE_Data_For_Persistence_Custom_Single_Entry() { string content = @"<div class=""umb-macro-holder mceNonEditable umb-macro-mce_1""><!-- <?UMBRACO_MACRO macroAlias=""Test"" content=""1089"" textArea=""asdfasdf"" title="""" bool=""0"" number="""" contentType="""" multiContentType="""" multiProperties="""" properties="""" tabs="""" multiTabs="""" /> --><ins> <div class=""facts-box""> <div class=""fatcs-box-header""> <h3>null</h3> </div> <div class=""fatcs-box-body"">1089</div> </div> </ins></div>"; string result = MacroTagParser.FormatRichTextContentForPersistence(content); Assert.AreEqual(@"<?UMBRACO_MACRO macroAlias=""Test"" content=""1089"" textArea=""asdfasdf"" title="""" bool=""0"" number="""" contentType="""" multiContentType="""" multiProperties="""" properties="""" tabs="""" multiTabs="""" />", result); }