Permalink
Browse files

Item1396: Wysiwyg edtor should handle links.

Fix provided by Colas. There might be one minor issue in that
HTML markup in the link text is converted to tml,  and then not
converted back to html during the next edit pass.

git-svn-id: http://svn.foswiki.org/trunk@14646 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information...
GeorgeClark GeorgeClark
GeorgeClark authored and GeorgeClark committed Apr 22, 2012
1 parent e0f04fa commit 9c9ec60b16c4637b897a0adc36bc2ef128f54868
@@ -950,15 +950,15 @@ sub _isConvertableTableRow {
$kid->_removePWrapper();
$kid->_moveClassToSpan('WYSIWYG_TT');
$kid->_moveClassToSpan('WYSIWYG_COLOR');
( $flags, $text ) = $kid->_flatten($options | $WC::IN_TABLE);
( $flags, $text ) = $kid->_flatten( $options | $WC::IN_TABLE );
$text = _TDtrim($text);
$text = "*$text*" if length($text);
}
elsif ( $kid->{tag} eq 'td' ) {
$kid->_removePWrapper();
$kid->_moveClassToSpan('WYSIWYG_TT');
$kid->_moveClassToSpan('WYSIWYG_COLOR');
( $flags, $text ) = $kid->_flatten($options | $WC::IN_TABLE);
( $flags, $text ) = $kid->_flatten( $options | $WC::IN_TABLE );
$text = _TDtrim($text);
}
elsif ( !$kid->{tag} ) {
@@ -1131,8 +1131,9 @@ sub _deduceAlignment {
sub _H {
my ( $this, $options, $depth ) = @_;
my ( $flags, $contents ) = $this->_flatten($options);
return ( 0, undef ) if ( ($flags & $WC::BLOCK_TML)
|| ($flags & $WC::IN_TABLE));
return ( 0, undef )
if ( ( $flags & $WC::BLOCK_TML )
|| ( $flags & $WC::IN_TABLE ) );
my $notoc = '';
if ( $this->hasClass('notoc') ) {
$notoc = '!!';
@@ -1408,6 +1409,13 @@ sub _handleA {
if ( $text eq $href ) {
return ( 0, $WC::CHECKw . '[' . $nop . '[' . $href . ']]' );
}
# we must quote square brackets in [[...][...]] notation
$text =~ s/[[]/[/g;
$text =~ s/[]]/]/g;
$href =~ s/[[]/%5B/g;
$href =~ s/[]]/%5D/g;
return ( 0,
$WC::CHECKw . '[' . $nop . '[' . $href . '][' . $text . ']]' );
}
@@ -1685,8 +1693,7 @@ sub _handlePRE {
}
unless ( $options & $WC::NO_BLOCK_TML ) {
my ( $flags, $text ) =
$this->_flatten(
$options | $WC::NO_TML | $WC::BR2NL | $WC::KEEP_WS );
$this->_flatten( $options | $WC::NO_TML | $WC::BR2NL | $WC::KEEP_WS );
my $p = _htmlParams( $this->{attrs}, $options );
return ( $WC::BLOCK_TML, "<$tag$p>$text</$tag>" );
}
@@ -420,6 +420,17 @@ s/<([A-Za-z]+[^>]*?)((?:\s+\/)?)>/"<" . $this->_appendClassToTag($1, 'TMLhtml')
$text =~ s#%($colourMatch)%(.*?)%ENDCOLOR%#
_getNamedColour($1, $2)#oge;
# Handle [[]]
#$text =~ s/(\[\[([^\]]*)\]\])/$this->_liftOut($2, 'LINK', 'span', $2)/ge;
# Handle [[][]] links by letting the WYSIWYG handle them as standard links
$text =~
s/\[\[([^]]*)\]\[([^]]*)\]\]/$this->_liftOutGeneral("<a href=\"$1\">$2<\/a>", { tag => 'NONE', protect => 0, tmltag => 0 } )/ge;
# let WYSIWYG-editable A tags untouched for the editor
$text =~
s/(\<a(\s+(href|target|title|class)=("(?:[^"\\]++|\\.)*+"|'(?:[^'\\]++|\\.)*+'|\S+))+\s*\>.*?\<\/a\s*\>)/$this->_liftOutGeneral($1, { tag => 'NONE', protect => 0, tmltag => 0 } )/gei;
# Convert Foswiki tags to spans outside protected text
$text = $this->_processTags($text);
@@ -797,13 +808,11 @@ s/((^|(?<=[-*\s(]))$Foswiki::regex{linkProtocolPattern}:[^\s<>"]+[^\s*.,!?;:)<])
$text =~ s(${WC::STARTWW}\=([^\s]+?|[^\s].*?[^\s])\=$WC::ENDWW)
(CGI::span({class => 'WYSIWYG_TT'}, $1))gem;
# Handle [[][]] and [[]] links
# Handle [[]] links
$text =~ s/(\[\[[^\]]*\]\])/$this->_liftOut($1, 'LINK')/ge;
# We do _not_ support [[http://link text]] syntax
# [[][]]
$text =~ s/(\[\[[^\]]*\](\[[^\]]*\])?\])/$this->_liftOut($1, 'LINK')/ge;
$text =~
s/$WC::STARTWW(($Foswiki::regex{webNameRegex}\.)?$Foswiki::regex{wikiWordRegex}($Foswiki::regex{anchorRegex})?)/$this->_liftOut($1, 'LINK')/geom;
@@ -1349,7 +1349,7 @@ Inside
exec => $ROUNDTRIP,
name => "WikiTagsInHTMLParam",
html => "${linkon}[[%!page!%/Burble/Barf][Burble]]${linkoff}",
tml => '[[%!page!%/Burble/Barf][Burble]]',
tml => '[[Burble.Barf][Burble]]',
},
{
exec => $HTML2TML,
@@ -2521,11 +2521,55 @@ BLAH
html => '<p>
Blah'
. encodedWhitespace('n')
. '<span class="WYSIWYG_PROTECTED">&#60;a&nbsp;href=&#34;%SCRIPTURLPATH{&#34;edit&#34;}%/%WEB%/%TOPIC%?t=%GM%NOP%TIME{&#34;$epoch&#34;}%&#34;&#62;</span>edit<span
class="WYSIWYG_PROTECTED">&#60;/a&#62;</span>'
. '<a href="%SCRIPTURLPATH{"edit"}%/%WEB%/%TOPIC%?t=%GM%NOP%TIME{"$epoch"}%">edit</a>'
. encodedWhitespace('n') . 'Blah
</p>
',
},
{
name => 'Item1396_MacrosRemainSticky',
exec => $TML2HTML | $HTML2TML | $ROUNDTRIP,
tml => <<'BLAH',
[[%ATTACHURL%/LinkEditingInWysiwyg-4.patch][LinkEditingInWysiwyg-4.patch]]
BLAH
finaltml => <<'BLAH',
[[%ATTACHURL%/LinkEditingInWysiwyg-4.patch][LinkEditingInWysiwyg-4.patch]]
BLAH
html => <<'BLAH',
<p><a href="%ATTACHURL%/LinkEditingInWysiwyg-4.patch">LinkEditingInWysiwyg-4.patch</a>
</p>
BLAH
},
{
name => 'Item1396_TitleRemainSticky',
exec => $TML2HTML | $HTML2TML | $ROUNDTRIP,
tml => <<'BLAH',
<a href="http://some.website.org/" target="_blank" title="Test">Another html link</a>
BLAH
finaltml => <<'BLAH',
<a href="http://some.website.org/" target="_blank" title="Test">Another html link</a>
BLAH
html => <<'BLAH',
<p><a href="http://some.website.org/" target="_blank" title="Test">Another html link</a>
</p>
BLAH
},
{
# Issue is that the <b> markup inserted by TinyMCE editor is converted to
# TML markup, but on the next pass, the TML is NOT converted to HTML
# Reversing the order, Starting with *Bold* does not show bold in TMCE
name => 'Item1396_BoldInLink_FAILS',
exec => $TML2HTML | $HTML2TML | $ROUNDTRIP,
tml => <<'BLAH',
[[Main/WebHome][A <b>BOLD</b> WebHome]]
BLAH
finaltml => <<'BLAH',
[[Main/WebHome][A *BOLD* WebHome]]
BLAH
html => <<'BLAH',
<p><a href="Main/WebHome">A <b>BOLD</b> WebHome</a>
</p>
BLAH
},
{
name => 'Item4903',

0 comments on commit 9c9ec60

Please sign in to comment.