Changeset 8111
- Timestamp:
- 07/10/10 14:53:09 (23 months ago)
- Location:
- trunk/WysiwygPlugin
- Files:
-
- 4 edited
-
lib/Foswiki/Plugins/WysiwygPlugin.pm (modified) (3 diffs)
-
lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm (modified) (1 diff)
-
lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm (modified) (1 diff)
-
test/unit/WysiwygPlugin/TranslatorTests.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin.pm
r7948 r8111 101 101 102 102 #my ($text, $exclusions) = @_; 103 my $disabled = wysiwygEditingDisabledForThisContent($_[0], $_[1]); 104 return $disabled if $disabled; 105 106 # Check that the topic text can be converted to HTML. This is an 107 # *expensive* process, to be avoided if possible (hence all the 108 # earlier checks) 109 my $impossible = wysiwygEditingNotPossibleForThisContent( $_[0] ); 110 return $impossible if $impossible; 111 112 return 0; 113 } 114 115 sub wysiwygEditingDisabledForThisContent { 116 #my ($text, $exclusions) = @_; 103 117 104 118 my $exclusions = $_[1]; … … 161 175 print STDERR "WYSIWYG_DEBUG: <sticky> inside <$tag>\n" 162 176 if (WHY); 163 return " <sticky> inside <$tag>";177 return "<sticky> inside <$tag>"; 164 178 } 165 179 } … … 182 196 print STDERR "WYSIWYG_DEBUG: <verbatim> inside <$tag>\n" 183 197 if (WHY); 184 return " <verbatim> inside <$tag>";198 return "<verbatim> inside <$tag>"; 185 199 } 186 200 } 187 201 } 188 202 189 # Look for combinations of literal and other markup that cause 190 # problems together 191 for my $tag ( keys %xmltag ) { 192 while ( $text =~ /<$tag\b[^>]*>(.*?)<\/$tag>/gsi ) { 193 my $inner = $1; 194 if ( $inner =~ /<literal\b[^>]*>/i ) { 195 print STDERR "WYSIWYG_DEBUG: <literal> inside <$tag>\n" 196 if (WHY); 197 return "<literal> inside <$tag>"; 198 } 199 } 200 } 201 202 # Check that the topic text can be converted to HTML. This is an 203 # *expensive* process, to be avoided if possible (hence all the 204 # earlier checks) 203 return 0; 204 } 205 206 sub wysiwygEditingNotPossibleForThisContent { 205 207 eval { 206 208 require Foswiki::Plugins::WysiwygPlugin::Handlers; -
trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm
r7928 r8111 1557 1557 my ( $this, $options ) = @_; 1558 1558 1559 if ( $this->hasClass('WYSIWYG_WARNING') ) { 1560 return ( 0, '' ); 1561 } 1562 1559 1563 if ( $this->hasClass('TMLverbatim') ) { 1560 1564 return $this->_verbatim( 'verbatim', $options ); -
trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
r8110 r8111 100 100 return '' unless $content; 101 101 102 $content =~ s/[$TT0$TT1$TT2]/?/go; 103 104 # Render TML constructs to tagged HTML 105 $content = $this->_getRenderedVersion($content); 106 107 # Substitute back in protected elements 108 $content = $this->_dropBack($content); 109 110 if ( $content =~ /[$TT0$TT1$TT2]/o ) { 111 112 # There should never be any of these in the text at this point. 113 # If there are, then the conversion failed. 114 die("Invalid characters in HTML after conversion") 115 if $options->{dieOnError}; 116 117 # Encode the original TML as verbatim-style HTML, 118 # so that the user has uncorrupted TML, at least. 119 my $originalContent = $_[1]; 120 $originalContent =~ s/[$TT0$TT1$TT2]/?/go; 121 $originalContent = _protectVerbatimChars($originalContent); 122 $content = 123 CGI::div( { class => 'WYSIWYG_PROTECTED' }, $originalContent ); 102 my $disabled = 103 Foswiki::Plugins::WysiwygPlugin::wysiwygEditingDisabledForThisContent( 104 $content); 105 if ($disabled) { 106 107 # encode the content verbatim-style, so that the user has uncorrupted HTML 108 $content =~ s/[$TT0$TT1$TT2]/?/go; 109 $content = CGI::div( 110 { class => 'WYSIWYG_WARNING foswikiBroadcastMessage' }, 111 Foswiki::Func::renderText( 112 Foswiki::Func::expandCommonVariables( <<"WARNING" ) ) ) 113 *%MAKETEXT{"Conversion to HTML for WYSIWYG editing is disabled because of the topic content."}%* 114 115 %MAKETEXT{"This is why the conversion is disabled:"}% $disabled 116 117 %MAKETEXT{"(This message will be removed automatically)"}% 118 WARNING 119 . CGI::div( { class => 'WYSIWYG_PROTECTED' }, 120 _protectVerbatimChars($content) ); 121 } 122 else { 123 124 # Convert TML to HTML for wysiwyg editing 125 126 $content =~ s/[$TT0$TT1$TT2]/?/go; 127 128 # Render TML constructs to tagged HTML 129 $content = $this->_getRenderedVersion($content); 130 131 # Substitute back in protected elements 132 $content = $this->_dropBack($content); 133 134 if ( $content =~ /[$TT0$TT1$TT2]/o ) { 135 136 # There should never be any of these in the text at this point. 137 # If there are, then the conversion failed. 138 die("Invalid characters in HTML after conversion") 139 if $options->{dieOnError}; 140 141 # Encode the original TML as verbatim-style HTML, 142 # so that the user has uncorrupted TML, at least. 143 my $originalContent = $_[1]; 144 $originalContent =~ s/[$TT0$TT1$TT2]/?/go; 145 $originalContent = _protectVerbatimChars($originalContent); 146 $content = 147 CGI::div( { class => 'WYSIWYG_PROTECTED' }, $originalContent ); 148 } 124 149 } 125 150 -
trunk/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm
r7928 r8111 2017 2017 }, 2018 2018 { 2019 exec => $ROUNDTRIP | $CANNOTWYSIWYG,2019 exec => $ROUNDTRIP, 2020 2020 name => 'verbatimInsideLiteralItem1980', 2021 2021 tml => <<'GLUED', … … 2048 2048 }, 2049 2049 { 2050 exec => $ROUNDTRIP | $CANNOTWYSIWYG,2050 exec => $ROUNDTRIP, 2051 2051 name => 'stickyInsideLiteral', 2052 2052 tml => <<'GLUED', … … 2619 2619 else { 2620 2620 $this->assert_tml_equals( $finaltml, $tx, $args->{name} ); 2621 $this->assert( !$notEditable, 2621 if ($html =~ /WYSIWYG_WARNING/) { 2622 # The HTML contains a warning message saying that this TML 2623 # cannot be edited as HTML, and all of the TML is protected 2624 # as if the whole topic were in a <sticky> block 2625 } 2626 else { 2627 # This TML really is editable in the WYSIWYG editor 2628 $this->assert( !$notEditable, 2622 2629 "$args->{name} TML is wysiwyg-editable, but notWysiwygEditable() reports: $notEditable" 2623 ); 2630 ); 2631 } 2624 2632 } 2625 2633
Note: See TracChangeset
for help on using the changeset viewer.
