Item12278: TML WikiWord links need better handling by TMCE to avoid inconsistent links.

pencil
Priority: Enhancement
Current State: Closed
Released In: 1.1.7
Target Release: patch
Applies To: Extension
Component: WysiwygPlugin
Branches: Release01x01 trunk
Reported By: GeorgeClark
Waiting For:
Last Change By: GeorgeClark
Several recent tasks improved Link handling in Wysiwyg editing, by recognizing those links as real HTML links. This has caused some unanticipated behavior.

Topic contains an in-line wikiword SomeWikiWord, when edited it is rendered as <a href="SomeWikiWord">SomeWikiWord</a> which displays like any other html link. If the user changes the link texst "AnotherWikiWord", the editor saves <a href="SomeWikiWord">AnotherWikiWord</a>, which is ultimately saved as [[SomeWikiWord][AnotherWikiWord]]

Proposed solution is to stash the original wikiword in as a class in the link.

<a class="TMLwikiwordSomeWikiWord" href="SomeWikiWord">AnotherWikiWord</a>

During save, HTML2TML/Node.pm recovers the original wikiword. If the link text is still a WikiWord, and the href matches the original WikiWord, then copy the LinkText into the Href.

-- GeorgeClark - 30 Nov 2012

This fix seems to work.
diff --git a/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm b/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm
index c0f93f0..34a2272 100644
--- a/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm
+++ b/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm
@@ -1431,6 +1431,13 @@ sub _handleA {
           (      $this->{attrs}->{class}
               && $this->{attrs}->{class} =~ m/\bTMLlink\b/ );
 
+        my $origWikiword;
+        if (   $this->{attrs}->{class}
+            && $this->{attrs}->{class} =~ m/\bTMLwikiword(.*)\s?/ )
+        {
+            $origWikiword = $1;
+        }
+
 # SMELL:  Item11814 - decoding corrupts URL's that must be encoded,  ex. embedded Newline
 # No unit test covers why the decode is required.  However restricting it to known
 # protocols fixes Item11814.  Need to figure out if this can just be removed?
@@ -1452,6 +1459,14 @@ sub _handleA {
             $cleantext =~ s/<nop>//g;
             $cleantext =~ s/^$this->{context}->{web}\.//;
 
+            if (   $origWikiword
+                && $href eq $origWikiword
+                && $cleantext =~ m/^(\w+\.)?($reww)$/ )
+            {
+                $topic = $2;
+                $href  = $text;
+            }
+
             # if the clean text is the known topic we can ignore it
             if ( ( $cleantext eq $href || $href =~ /\.$cleantext$/ )
                 && !$forceTML )
diff --git a/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm b/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
index bcb2ca4..511a3f3 100644
--- a/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
+++ b/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
@@ -902,7 +902,7 @@ s/((^|(?<=[-*\s(]))$Foswiki::regex{linkProtocolPattern}:[^\s<>"]+[^\s*.,!?;:)<])
  # Need to also include protected content marker as part of start wikiword delim
         my $startww = qr/$WC::STARTWW|(?<=$TT2)/;
         $text =~
-s/$startww(($Foswiki::regex{webNameRegex}\.)?$Foswiki::regex{wikiWordRegex}($Foswiki::regex{anchorRegex})?)/$this->_liftOutSquab($1,$1)/geom;
+s/$startww(($Foswiki::regex{webNameRegex}\.)?$Foswiki::regex{wikiWordRegex}($Foswiki::regex{anchorRegex})?)/$this->_liftOutSquab($1,$1,'TMLwikiword'.$1)/geom;
         Foswiki::putBackBlocks( \$text, $removed, 'noautolink' );
     }

-- GeorgeClark - 30 Nov 2012

This is checked into the trunk wysiwyg editor. I'd like to pull this into 1.1.7, as the current behavior is quite confusing.

-- GeorgeClark - 18 Dec 2012
 

ItemTemplate edit

Summary TML WikiWord links need better handling by TMCE to avoid inconsistent links.
ReportedBy GeorgeClark
Codebase 1.1.6, 1.1.6 dev, 1.1.5, trunk
SVN Range
AppliesTo Extension
Component WysiwygPlugin
Priority Enhancement
CurrentState Closed
WaitingFor
Checkins distro:a410316589f3 distro:e76a88ffd86e distro:12c25ce34685
TargetRelease patch
ReleasedIn 1.1.7
CheckinsOnBranches Release01x01 trunk
trunkCheckins distro:a410316589f3 distro:12c25ce34685
Release01x01Checkins distro:e76a88ffd86e
Topic revision: r7 - 01 Feb 2013, GeorgeClark
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