Item5221: Wysiwyg tables, very difficult to get rid of paragraph html tags in table cell

pencil
Priority: Normal
Current State: Closed
Released In: 1.1.0
Target Release: minor
Applies To: Extension
Component: TinyMCEPlugin
Branches:
Reported By: TWiki:Main.KennethLavrsen
Waiting For:
Last Change By: KennethLavrsen
An annoyance more than a show stopper.

Several of my users have pointed out that once you have hit enter inside a table cell the TMCE adds html paragraph tags round the text making the text in the cell jump down. You more or less have to pickaxe your way out of that.

The only work around I have found it to change the text to heading 1 and then back to normal.
Some table text where I did not hit enter

Some text where I hit enter before the text and tried to delete it again

Some text where I hit enter

in the middle to get two lines of text

Some text where I hit
shift enter to get a BR instead

I wonder what we can do to make the editing experience a bit better. Not a release blocker.

-- TWiki:Main/KennethLavrsen - 08 Jan 2008

Yeah, it's a PITA. Note that the behviour is different on different browsers; it's all to do with the way MIDAS is implemented, I think.

Confirmed.

CC

It's interesting that our editor setup even with TMCE 3.2.7 exhibits this problem, but the following (similar) configuration does not:

-- PaulHarvey - 15 Oct 2009

Actually, the minimal config above does exhibit the problem: for some reason the <p>s are just not giving us newlines around the para in the editor. I can observe that the <p> remains in the DOM.

Will work on updating the bug upstream:

http://sourceforge.net/tracker/index.php?func=detail&aid=1703005&group_id=103281&atid=635682

-- PaulHarvey - 05 Nov 2009

We need a server-side fix in WysiwygPlugin.

-- PaulHarvey - 16 Jan 2010

Here is a possible fix; a multi-editor solution would need this to be configurable - and I'm not sure we should apply it until we get the browser-in-the-loop tests passing... OTOH it's pretty simple:

Index: test/unit/WysiwygPlugin/ExtendedTranslatorTests.pm
===================================================================
--- test/unit/WysiwygPlugin/ExtendedTranslatorTests.pm   (revision 7305)
+++ test/unit/WysiwygPlugin/ExtendedTranslatorTests.pm   (working copy)
@@ -747,6 +747,20 @@
 | Foo | a |
 HERE
     },
+    {
+        name => 'Item5221_EatUnwantedParasInTableCells',
+        exec => $HTML2TML | $ROUNDTRIP,
+        html => <<'HERE',
+<table cellspacing="1" cellpadding="0" border="1">
+<tr><th> a </th></tr>
+<tr><td> <p>1</p> </td></tr>
+</table>
+HERE
+        tml => <<'HERE',
+| *a* |
+| 1 |
+HERE
+    },
 ];
 
 sub compareTML_HTML {
Index: lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm
===================================================================
--- lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm   (revision 7305)
+++ lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm   (working copy)
@@ -872,6 +872,9 @@
 s/^($WC::NBSP|$WC::NBBR|$WC::CHECKn|$WC::CHECKs|$WC::CHECKw|$WC::CHECK1|$WC::CHECK2|$WC::TAB|\s)+//so;
     $td =~
 s/(<br \/>|<br>|$WC::NBSP|$WC::NBBR|$WC::CHECKn|$WC::CHECKs|$WC::CHECKw|$WC::CHECK1|$WC::CHECK2|$WC::TAB|\s)+$//so;
+    # Item5221: Eat impossible-to-remove-in-TinyMCE <p>...</p> surrounding table
+    # cell content, created if a user hits the return key inside a table cell
+    $td =~ s/^<p>(.*)<\/p>$/$1/so;
     return $td;
 }

-- PaulHarvey - 01 May 2010

Be careful not to destroy content like this, that has more than one <p> tag:
<table><tr><td>
<p>Line one</p>
<p>Line two</p>
</td></tr></table>

-- MichaelTempest - 01 May 2010

Fixed.

-- MichaelTempest - 16 May 2010

ItemTemplate edit

Summary Wysiwyg tables, very difficult to get rid of paragraph html tags in table cell
ReportedBy TWiki:Main.KennethLavrsen
Codebase 1.0.9, trunk
SVN Range TWiki-4.3.0, Sun, 30 Dec 2007, build 16120
AppliesTo Extension
Component TinyMCEPlugin
Priority Normal
CurrentState Closed
WaitingFor
Checkins distro:81b85965a03d distro:1d013e8f76ea
TargetRelease minor
ReleasedIn 1.1.0
Topic revision: r11 - 04 Oct 2010, KennethLavrsen
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy