summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuiza Pagliari <lpagliari@gmail.com>2016-08-22 18:52:01 -0300
committerGitHub <noreply@github.com>2016-08-22 18:52:01 -0300
commit45266f90a3c70fe11e78f9bcc7f9b69359b7fef5 (patch)
tree2742d4a47c0b98a1700c6f1e31c7a3f3ab0b45bc /src
parentbd20d44e895c004c4847daabdba28d20c54e7f0a (diff)
parentea562250d9c4a5e3190c5be05b1e2fb3d6afe519 (diff)
downloadetherpad-lite-45266f90a3c70fe11e78f9bcc7f9b69359b7fef5.zip
Merge pull request #3042 from storytouch/fix_dnd
Perform DnD in one changeset, so UNDO works properly. Fix #3041
Diffstat (limited to 'src')
-rw-r--r--src/static/js/ace2_inner.js45
1 files changed, 29 insertions, 16 deletions
diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js
index f8a8d847..def7b090 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 <style>,
+ // in order to make content be observed by incorporateUserChanges() (see
+ // observeSuspiciousNodes() for more info)
+ var selection = getSelection();
+ if (selection){
+ var firstLineSelected = topLevel(selection.startPoint.node);
+ var lastLineSelected = topLevel(selection.endPoint.node);
+
+ var lineBeforeSelection = firstLineSelected.previousSibling;
+ var lineAfterSelection = lastLineSelected.nextSibling;
+
+ var neighbor = lineBeforeSelection || lineAfterSelection;
+ neighbor.appendChild(document.createElement('style'));
+ }
+
// Call drop hook
hooks.callAll('aceDrop', {
editorInfo: editorInfo,
@@ -5051,6 +5054,16 @@ function Ace2Inner(){
}
}
+ function topLevel(n)
+ {
+ if ((!n) || n == root) return null;
+ while (n.parentNode != root)
+ {
+ n = n.parentNode;
+ }
+ return n;
+ }
+
function handleIEOuterClick(evt)
{
if ((evt.target.tagName || '').toLowerCase() != "html")