Hello,
I, ve been dealing with this issue and i can't seem to solve it on my own. In our email template we have a module where the user can write long text and for that i ve created a rich text editor in the form. The problem is that if the user writes text without first opening "source code" mode, the text gets wrapped with following tags: <!DOCTYPE html> <html> <head> </head> <body> <p>test</p> </body> </html> (see picture attached). How can i prevent the rich text editor from doing it?
I have also tried to prevent this by using a function written a in a library which is referenced to at the beginning of the javascript template file
<%
loadLibrary("lf:queryJS");
eval(xtk.javascript.get("lf:newsletter_libclaudiotest").data);
%>
and then used the function where the text editor is used <p><%= formatRichTextFields(block.@main) %></p>
here is the function itself:
function formatRichTextFields(sContentArg) {
var sContent = "" + sContentArg;
// Remove <html>, <head>, and <body> tags
sContent = sContent.replace(/<!DOCTYPE html>/ig, '');
sContent = sContent.replace(/<html[^>]*>/ig, '').replace(/<\/html>/ig, '');
sContent = sContent.replace(/<head[^>]*>/ig, '').replace(/<\/head>/ig, '');
sContent = sContent.replace(/<body[^>]*>/ig, '').replace(/<\/body>/ig, '');
return sContent;
}
My questions are:
1) is there a way to prevent rich text editor from creating these HTML tags?
2) if not, why isn't my function doing its job?
Cheers
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Cl4ud,
Unfortunately, there isn’t a direct configuration in Adobe Campaign Classic v7 (or v8) to prevent the DCE from adding these tags when text is entered in the visual mode. This behavior is baked into how the editor processes content—it assumes you’re creating a complete HTML document. However, here are some potential workarounds to minimize or avoid this:
function formatRichTextFields(sContentArg) {
var sContent = String(sContentArg || ""); // Handle null/undefined
logInfo("Before: " + sContent); // Debug raw input
sContent = sContent.replace(/<!DOCTYPE[^>]*>/ig, '');
sContent = sContent.replace(/<html[^>]*>/ig, '').replace(/<\/html>/ig, '');
sContent = sContent.replace(/<head[^>]*>/ig, '').replace(/<\/head>/ig, '');
sContent = sContent.replace(/<body[^>]*>/ig, '').replace(/<\/body>/ig, '');
logInfo("After: " + sContent); // Debug cleaned output
return sContent.trim(); // Remove extra whitespace
}
Use it in your template:
<p><%= formatRichTextFields(block.@main) %></p>
Then:
Hi @Cl4ud,
Unfortunately, there isn’t a direct configuration in Adobe Campaign Classic v7 (or v8) to prevent the DCE from adding these tags when text is entered in the visual mode. This behavior is baked into how the editor processes content—it assumes you’re creating a complete HTML document. However, here are some potential workarounds to minimize or avoid this:
function formatRichTextFields(sContentArg) {
var sContent = String(sContentArg || ""); // Handle null/undefined
logInfo("Before: " + sContent); // Debug raw input
sContent = sContent.replace(/<!DOCTYPE[^>]*>/ig, '');
sContent = sContent.replace(/<html[^>]*>/ig, '').replace(/<\/html>/ig, '');
sContent = sContent.replace(/<head[^>]*>/ig, '').replace(/<\/head>/ig, '');
sContent = sContent.replace(/<body[^>]*>/ig, '').replace(/<\/body>/ig, '');
logInfo("After: " + sContent); // Debug cleaned output
return sContent.trim(); // Remove extra whitespace
}
Use it in your template:
<p><%= formatRichTextFields(block.@main) %></p>
Then:
Thank you very much for ur contribution Sushant
I have decided to make it easy for me and convince the marketers populating the deliveries with content to only use source code mode when adding text. i will remind them several time during the next month or so until this becomes a routine for them.
Thank you again and we can close this
Views
Likes
Replies
Views
Likes
Replies