diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index f8a8d847b..def7b0900 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -1455,16 +1455,6 @@ function Ace2Inner(){ var selection = getSelection(); p.end(); - function topLevel(n) - { - if ((!n) || n == root) return null; - while (n.parentNode != root) - { - n = n.parentNode; - } - return n; - } - if (selection) { var node1 = topLevel(selection.startPoint.node); @@ -1486,12 +1476,8 @@ function Ace2Inner(){ var nds = root.getElementsByTagName("style"); for (var i = 0; i < nds.length; i++) { - var n = nds[i]; - while (n.parentNode && n.parentNode != root) - { - n = n.parentNode; - } - if (n.parentNode == root) + var n = topLevel(nds[i]); + if (n && n.parentNode == root) { observeChangesAroundNode(n); } @@ -5034,6 +5020,23 @@ function Ace2Inner(){ if(e.target.a || e.target.localName === "a"){ e.preventDefault(); } + + // Bug fix: when user drags some content and drop it far from its origin, we + // need to merge the changes into a single changeset. So mark origin with