Permalink
Browse files

Fixed bug where the editor would get auto focused on IE running in qu…

…irks mode.
  • Loading branch information...
1 parent 1aedce2 commit 5bca717f1064a19e03bd573d603c59b97538f1e9 @spocke spocke committed Jun 1, 2012
Showing with 24 additions and 19 deletions.
  1. +2 −0 changelog.txt
  2. +22 −19 jscripts/tiny_mce/classes/ForceBlocks.js
View
@@ -1,3 +1,5 @@
+Version 3.5.x (2012-xx-xx)
+ Fixed bug where the editor would get auto focused on IE running in quirks mode.
Version 3.5.2 (2012-05-31)
Added new formatChanged method to tinymce.Formatter class. Enables easier state change handling of formats.
Added new selectorChanged method to tinymce.dom.Selection class. Enables easier state change handling of matching CSS selectors.
@@ -12,7 +12,7 @@ tinymce.ForceBlocks = function(editor) {
var settings = editor.settings, dom = editor.dom, selection = editor.selection, blockElements = editor.schema.getBlockElements();
function addRootBlocks() {
- var node = selection.getStart(), rootNode = editor.getBody(), rng, startContainer, startOffset, endContainer, endOffset, rootBlockNode, tempNode, offset = -0xFFFFFF, wrapped;
+ var node = selection.getStart(), rootNode = editor.getBody(), rng, startContainer, startOffset, endContainer, endOffset, rootBlockNode, tempNode, offset = -0xFFFFFF, wrapped, isInEditorDocument;
if (!node || node.nodeType !== 1 || !settings.forced_root_block)
return;
@@ -40,6 +40,7 @@ tinymce.ForceBlocks = function(editor) {
rng.moveToElementText(node);
}
+ isInEditorDocument = rng.parentElement().ownerDocument === editor.getDoc();
tmpRng = rng.duplicate();
tmpRng.collapse(true);
startOffset = tmpRng.move('character', offset) * -1;
@@ -70,28 +71,30 @@ tinymce.ForceBlocks = function(editor) {
}
}
- if (rng.setStart) {
- rng.setStart(startContainer, startOffset);
- rng.setEnd(endContainer, endOffset);
- selection.setRng(rng);
- } else {
- try {
- rng = editor.getDoc().body.createTextRange();
- rng.moveToElementText(rootNode);
- rng.collapse(true);
- rng.moveStart('character', startOffset);
+ if (wrapped) {
+ if (rng.setStart) {
+ rng.setStart(startContainer, startOffset);
+ rng.setEnd(endContainer, endOffset);
+ selection.setRng(rng);
+ } else {
+ // Only select if the previous selection was inside the document to prevent auto focus in quirks mode
+ if (isInEditorDocument) {
+ try {
+ rng = editor.getDoc().body.createTextRange();
+ rng.moveToElementText(rootNode);
+ rng.collapse(true);
+ rng.moveStart('character', startOffset);
- if (endOffset > 0)
- rng.moveEnd('character', endOffset);
+ if (endOffset > 0)
+ rng.moveEnd('character', endOffset);
- rng.select();
- } catch (ex) {
- // Ignore
+ rng.select();
+ } catch (ex) {
+ // Ignore
+ }
+ }
}
- }
- // Only trigger nodeChange when we wrapped nodes to prevent a forever loop
- if (wrapped) {
editor.nodeChanged();
}
};

0 comments on commit 5bca717

Please sign in to comment.