View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
05331Bug reportsSurvey participants (Tokens)public2021-03-08 20:08
Reportermot Assigned Tomot  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Summary05331: FCKEditor / Whitespace Indent mangeled for Email Templates
Description

The WYSIWYG editor is adding an immense amount of tabs in front of each line that is part of a HTML source document when saving.

That's a burden if you create email templates with a more profiled HTML as per opened element/tag, limesurvey will have it indented with one tab per opened element which will be passed into the text/plain variant of the email.

Steps To Reproduce
  1. Create an email invitation with nested HTML elements and text therein.
  2. Send invitation.
  3. Check mail in it's plain text view.
Additional Information

It would be ok for me if the editor while the source view is being activated will not mangle the input but take it as is. Then email templates at least can be designed in an editor apart from the webapp and then tested for use.

TagsNo tags attached.
Attached Files
limesurvey-email-tabs.png (19,960 bytes)   
limesurvey-email-tabs.png (19,960 bytes)   
Selection_011.png (87,442 bytes)   
Selection_011.png (87,442 bytes)   
05331-00-email-altbody-text-whitespace-formatting.diff (1,945 bytes)   
### Eclipse Workspace Patch 1.0
#P Limesurvey 1.x trunk stable
Index: admin/scripts/ckeditor.36/limesurvey-config.js
===================================================================
--- admin/scripts/ckeditor.36/limesurvey-config.js	(revision 10545)
+++ admin/scripts/ckeditor.36/limesurvey-config.js	(working copy)
@@ -70,4 +70,49 @@
 
    	config.extraPlugins = "limereplacementfields,ajax";
 
-};
\ No newline at end of file
+};
+
+/**
+ * CKEDITOR HTML writer configuration
+ *
+ * better html to text conversion (alternative text body 
+ *   for HTML emails)
+ *
+ * #05331
+ */
+CKEDITOR.on( 'instanceReady', function( ev )
+{
+	// only valid for email-message editors
+	if (! ev.editor.name.match(/^(email|message)_/)) return;
+	
+	var writer = ev.editor.dataProcessor.writer;
+	
+	writer.indentationChars = '';
+	
+	var tagsDouble = {'p': 1, 'h1':1, 'h2':1, 'h3':1, 'h4':1, 'h5':1, 'h6':1};
+	var tagsBlank = CKEDITOR.tools.extend( {}, CKEDITOR.dtd.$nonBodyContent);
+	
+	for ( var e in tagsDouble )
+	{
+		writer.setRules( e,
+		{
+			indent : 0,
+			breakBeforeOpen : 0,
+			breakAfterOpen : 0,
+			breakBeforeClose : 1,
+			breakAfterClose : 1
+		});
+	}
+	
+	for ( var e in tagsBlank )
+	{
+		writer.setRules( e,
+		{
+			indent : 0,
+			breakBeforeOpen : 0,
+			breakAfterOpen : 0,
+			breakBeforeClose : 0,
+			breakAfterClose : 0
+		});
+	}
+});
\ No newline at end of file
Index: common_functions.php
===================================================================
--- common_functions.php	(revision 10545)
+++ common_functions.php	(working copy)
@@ -4304,7 +4304,7 @@
     if ($ishtml) {
         $mail->IsHTML(true);
     	$mail->Body = $body;
-        $mail->AltBody = strip_tags(br2nl(html_entity_decode($body,ENT_QUOTES,'UTF-8')));
+        $mail->AltBody = strip_tags(html_entity_decode($body,ENT_QUOTES,'UTF-8'));
     } else
        {
         $mail->IsHTML(false);
05331-01-email-altbody-text-whitespace-formatting.diff (1,960 bytes)   
### Eclipse Workspace Patch 1.0
#P Limesurvey 1.x trunk stable
Index: admin/scripts/ckeditor.36/limesurvey-config.js
===================================================================
--- admin/scripts/ckeditor.36/limesurvey-config.js	(revision 10598)
+++ admin/scripts/ckeditor.36/limesurvey-config.js	(working copy)
@@ -70,4 +70,49 @@
 
    	config.extraPlugins = "limereplacementfields,ajax";
 
-};
\ No newline at end of file
+};
+
+/**
+ * CKEDITOR HTML writer configuration
+ *
+ * better html to text conversion (alternative text body 
+ *   for HTML emails)
+ *
+ * #05331
+ */
+CKEDITOR.on( 'instanceReady', function( ev )
+{
+	// only valid for email-message editors
+	if (! ev.editor.name.match(/^(email|message)_/)) return;
+	
+	var writer = ev.editor.dataProcessor.writer;
+	
+	writer.indentationChars = '';
+	
+	var tagsDouble = {'p': 1, 'div':1, 'h1':1, 'h2':1, 'h3':1, 'h4':1, 'h5':1, 'h6':1};
+	var tagsBlank = CKEDITOR.tools.extend( {}, CKEDITOR.dtd.$nonBodyContent);
+	
+	for ( var e in tagsDouble )
+	{
+		writer.setRules( e,
+		{
+			indent : 0,
+			breakBeforeOpen : 1,
+			breakAfterOpen : 0,
+			breakBeforeClose : 1,
+			breakAfterClose : 1
+		});
+	}
+	
+	for ( var e in tagsBlank )
+	{
+		writer.setRules( e,
+		{
+			indent : 0,
+			breakBeforeOpen : 0,
+			breakAfterOpen : 0,
+			breakBeforeClose : 0,
+			breakAfterClose : 0
+		});
+	}
+});
\ No newline at end of file
Index: common_functions.php
===================================================================
--- common_functions.php	(revision 10598)
+++ common_functions.php	(working copy)
@@ -4304,7 +4304,7 @@
     if ($ishtml) {
         $mail->IsHTML(true);
     	$mail->Body = $body;
-        $mail->AltBody = strip_tags(br2nl(html_entity_decode($body,ENT_QUOTES,'UTF-8')));
+        $mail->AltBody = trim(strip_tags(html_entity_decode($body,ENT_QUOTES,'UTF-8')));
     } else
        {
         $mail->IsHTML(false);
Bug heat4
Complete LimeSurvey version number (& build)10377
I will donate to the project if issue is resolvedNo
BrowserFirefox
Database type & versionMysql 5 Family
Server OS (if known)Linux
Webserver software & version (if known)Apache 2.2
PHP Version5.3.6

Users monitoring this issue

There are no users monitoring this issue.

Activities

mot

mot

2011-07-08 13:27

reporter   ~15678

This is merely a feature request: Ability to have a non-WYSIWYG editor for HTML emails and the ability to have another field for the plain text variant. This would enable full control of the email messages send out.

For the current status quo:

Using the default template editor and sending out db-stored message templates even increases the problem currently. Some issues should be able to catch with a more intelligent <br /> to "\n" conversion as FCK Editor seems to enter a "\n" after each <br /> for the source and the HTML to plain text conversion will take both, <br /> and "\n" as a new line.

The other issue of indents can probably be fixed as well as the FCK Editor provides an option to re-format the HTML source in a different way - at least to a certain extend (covering indentation and line breaks up to be configureable per tag):

For version 3 of the editor, output can be configured as this:

http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Output_Formatting

c_schmitz

c_schmitz

2011-07-08 17:19

administrator   ~15695

Feel free to take a shot at it.

mot

mot

2011-07-20 18:17

reporter   ~15809

Last edited: 2011-07-21 14:05

Attached a patch which pretty well does this now. For the email-messages CKEditor instances, the HTML writer will be re-configured to produce HTML that can be better converted into the plain-text altbody for HTML emails.

Next to changes in the CKEditor writer configuration, the routine that creates the altbody (SendEmailMessage()) should not replace BR's with a newline because BR's already had a newline directly after them. Part of the patch as well.

mot

mot

2011-07-28 10:39

reporter   ~15875

Attached another patch with slight modifications I came aware about with more thorough testing in a live-case scenario.

c_schmitz

c_schmitz

2011-08-02 17:18

administrator   ~15934

1.91+ version released.

Issue History

Date Modified Username Field Change
2011-07-08 11:54 mot New Issue
2011-07-08 11:54 mot File Added: limesurvey-email-tabs.png
2011-07-08 13:27 mot Note Added: 15678
2011-07-08 17:19 c_schmitz Assigned To => mot
2011-07-08 17:19 c_schmitz Status new => assigned
2011-07-08 17:19 c_schmitz Note Added: 15695
2011-07-20 18:09 mot File Added: Selection_011.png
2011-07-20 18:13 mot File Added: 05331-00-email-altbody-text-whitespace-formatting.diff
2011-07-20 18:17 mot Note Added: 15809
2011-07-21 14:04 mot Note Edited: 15809
2011-07-21 14:04 mot Note Edited: 15809
2011-07-21 14:05 mot Note Edited: 15809
2011-07-21 14:05 mot Note Edited: 15809
2011-07-21 14:05 mot Note Edited: 15809
2011-07-28 10:37 mot File Added: 05331-01-email-altbody-text-whitespace-formatting.diff
2011-07-28 10:39 mot Note Added: 15875
2011-07-28 19:03 mot Resolution open => fixed
2011-07-28 19:16 mot Status assigned => resolved
2011-08-02 17:18 c_schmitz Note Added: 15934
2011-08-02 17:18 c_schmitz Status resolved => closed
2016-12-08 10:39 c_schmitz Category Tokens => Survey participants (Tokens)