Skip to content

Commit

Permalink
Item2174: Firefox doesn't delete empty spans. IE and Opera do. It is …
Browse files Browse the repository at this point in the history
…important to delete spans that encode TML whitespace if they are empty, because if the user deletes a space that encodes a whole lot of TML whitespace, then all of the TML whitespace must be delete. It mustn't magically reappear when the topic is saved.

git-svn-id: http://svn.foswiki.org/trunk@9887 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelTempest authored and MichaelTempest committed Nov 6, 2010
1 parent f3a281a commit 85c7111
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions TinyMCEPlugin/data/System/TinyMCEPlugin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ Another great Foswiki extension from the <a style="text-decoration:none" href="h
| Version: | %$VERSION% |
| Release: | %$RELEASE% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| ? | Foswikitask:Item2174: JS fix for deleting encoded-TML-whitespace on Firefox |
| 04 Nov 2010 | Foswikitask:Item9706: Upgrade to !TinyMCE 3.3.9.2<br/>\
Foswikitask:Item9953: Fix JS error transitioning to !WikiText from fullscreen<br/>\
Foswikitask:Item9952: Fix bold & italics buttons not activating on already bolded/italicised text properly<br/>\
Expand Down
17 changes: 17 additions & 0 deletions TinyMCEPlugin/pub/System/TinyMCEPlugin/foswiki_tiny_src.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ var FoswikiTiny = {

initialisedFromServer: false,

removeErasedSpans: function(ed, o) {
// forced_root_block makes TMCE insert &nbsp; into empty spans.
// TML2HTML emits spans with the WYSIWYG_HIDDENWHITESPACE class
// that contain a single space.
// Some browsers (e.g. IE8 and Opera 10.60) remove the span if
// the user deletes the space within the span.
// Other browsers (e.g. various versions of Firefox) do not.
//
// This function removes spans with this class that contain
// only a &nbsp; as the &nbsp; is assumed to come from the
// forced_root_block code.
o.content = o.content.replace(/<span[^>]*class=['"][^'">]*WYSIWYG_HIDDENWHITESPACE[^>]+>&nbsp;<\/span>/g, '');
},

// Set up content for the initial edit
setUpContent: function(editor_id, body, doc) {
// If we haven't done it before, then transform from TML
Expand All @@ -97,6 +111,9 @@ var FoswikiTiny = {
if (FoswikiTiny.initialisedFromServer) return;
var editor = tinyMCE.getInstanceById(editor_id);
FoswikiTiny.switchToWYSIWYG(editor);

// Also add the handler for cleaning up after force_root_blocks
editor.onGetContent.add(FoswikiTiny.removeErasedSpans);
FoswikiTiny.initialisedFromServer = true;
},

Expand Down

0 comments on commit 85c7111

Please sign in to comment.