Skip to content

Commit

Permalink
Fixed bug with the IE selection implementation when it was feeded an …
Browse files Browse the repository at this point in the history
…document range.

Fixed bug where block elements formatting wasn't properly removed by removeformat on all browsers.
Fixed bug where selection location was lost if you performed a manual cleanup.
Reduced the LegacyInput.js a bit in size.
  • Loading branch information
spocke committed Jan 28, 2010
1 parent 632ee8f commit 18cb083
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 56 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Expand Up @@ -3,6 +3,9 @@ Version 3.3b2 (2010-xx-xx)
Fixed bug where merging of span elements could occur on bookmark nodes.
Fixed bug where classes wasn't properly removed when removeformat was used on IE 6.
Fixed bug where multiple calls to an tinyMCE.init with mode set to exact could produce the same unique ID.
Fixed bug with the IE selection implementation when it was feeded an document range.
Fixed bug where block elements formatting wasn't properly removed by removeformat on all browsers.
Fixed bug where selection location was lost if you performed a manual cleanup.
Version 3.3b1 (2010-01-25)
Added new text formatting engine. Fixes a lot of browser quirks and adds new possibilities.
Added new advlist plugin that enables you to set the formats of list elements.
Expand Down
2 changes: 1 addition & 1 deletion jscripts/tiny_mce/classes/Editor.js
Expand Up @@ -919,7 +919,7 @@
blockquote : {block : 'blockquote', wrapper : 1},

removeformat : [
{selector : 'b,strong,em,i,font,u,strike', remove : 'all', split : true, expand : false, deep : true},
{selector : 'b,strong,em,i,font,u,strike', remove : 'all', split : true, expand : false, block_expand : true, deep : true},
{selector : 'span', attributes : ['style', 'class'], remove : 'empty', split : true, expand : false, deep : true},
{selector : '*', attributes : ['style', 'class'], expand : false, deep : true}
]
Expand Down
2 changes: 1 addition & 1 deletion jscripts/tiny_mce/classes/EditorCommands.js
Expand Up @@ -223,7 +223,7 @@

mceCleanup : function() {
storeSelection();
editor.setContent(editor.getContent({cleanup : TRUE}));
editor.setContent(editor.getContent({cleanup : TRUE}), {cleanup : TRUE});
restoreSelection();
},

Expand Down
8 changes: 5 additions & 3 deletions jscripts/tiny_mce/classes/Formatter.js
Expand Up @@ -797,6 +797,7 @@
endContainer = rng.endContainer,
endOffset = rng.endOffset, sibling, lastIdx;

// This function walks up the tree if there is no siblings before/after the node
function findParentContainer(container, child_name, sibling_name, root) {
var parent, child;

Expand All @@ -805,8 +806,9 @@
for (;;) {
// Check if we can move up are we at root level or body level
parent = container.parentNode;

if (parent == root || isBlock(parent))

// Stop expanding on block elements or root depending on format
if (parent == root || (!format[0].block_expand && isBlock(parent)))
return container;

for (sibling = parent[child_name]; sibling && sibling != container; sibling = sibling[sibling_name]) {
Expand Down Expand Up @@ -858,7 +860,7 @@
// Example * becomes !: !<p><b><i>*text</i><i>text*</i></b></p>!
// This will reduce the number of wrapper elements that needs to be created
// Move start point up the tree
if (format[0].inline) {
if (format[0].inline || format[0].block_expand) {
startContainer = findParentContainer(startContainer, 'firstChild', 'nextSibling');
endContainer = findParentContainer(endContainer, 'lastChild', 'previousSibling');
}
Expand Down
100 changes: 49 additions & 51 deletions jscripts/tiny_mce/classes/LegacyInput.js
Expand Up @@ -8,55 +8,53 @@
* Contributing: http://tinymce.moxiecode.com/contributing
*/

(function() {
tinymce.onAddEditor.add(function(tinymce, ed) {
var filters, fontSizes, dom, settings = ed.settings;

fontSizes = tinymce.explode(settings.font_size_style_values);

function replaceWithSpan(node, styles) {
dom.replace(dom.create('span', {
style : styles
}), node, 1);
};

filters = {
font : function(dom, node) {
replaceWithSpan(node, {
backgroundColor : node.style.backgroundColor,
color : node.color,
fontFamily : node.face,
fontSize : fontSizes[parseInt(node.size) - 1]
});
},

u : function(dom, node) {
replaceWithSpan(node, {
textDecoration : 'underline'
});
},

strike : function(dom, node) {
replaceWithSpan(node, {
textDecoration : 'line-through'
});
}
};

function convert() {
dom = ed.dom;

if (settings.convert_fonts_to_spans) {
tinymce.each(dom.select('font,u,strike'), function(node) {
filters[node.nodeName.toLowerCase()](ed.dom, node);
});
}
};

ed.onSetContent.add(convert);

ed.onInit.add(function() {
ed.selection.onSetContent.add(convert);
});
tinymce.onAddEditor.add(function(tinymce, ed) {
var filters, fontSizes, dom, settings = ed.settings;

fontSizes = tinymce.explode(settings.font_size_style_values);

function replaceWithSpan(node, styles) {
dom.replace(dom.create('span', {
style : styles
}), node, 1);
};

filters = {
font : function(dom, node) {
replaceWithSpan(node, {
backgroundColor : node.style.backgroundColor,
color : node.color,
fontFamily : node.face,
fontSize : fontSizes[parseInt(node.size) - 1]
});
},

u : function(dom, node) {
replaceWithSpan(node, {
textDecoration : 'underline'
});
},

strike : function(dom, node) {
replaceWithSpan(node, {
textDecoration : 'line-through'
});
}
};

function convert() {
dom = ed.dom;

if (settings.convert_fonts_to_spans) {
tinymce.each(dom.select('font,u,strike'), function(node) {
filters[node.nodeName.toLowerCase()](ed.dom, node);
});
}
};

ed.onSetContent.add(convert);

ed.onInit.add(function() {
ed.selection.onSetContent.add(convert);
});
})(tinymce);
});
8 changes: 8 additions & 0 deletions jscripts/tiny_mce/classes/dom/TridentSelection.js
Expand Up @@ -139,6 +139,14 @@
eo = rng.endOffset;
ieRng = body.createTextRange();

// If document selection move caret to first node in document
if (sc == doc || ec == doc) {
ieRng = body.createTextRange();
ieRng.collapse();
ieRng.select();
return;
}

// If child index resolve it
if (sc.nodeType == 1 && sc.hasChildNodes()) {
lastIndex = sc.childNodes.length - 1;
Expand Down

0 comments on commit 18cb083

Please sign in to comment.