fnp
/
fnpeditor.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
a72a2ac
)
Jumping to paren parent on text unwrap
author
Aleksander Łukasz
<aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 16 Jul 2013 15:09:50 +0000
(17:09 +0200)
committer
Aleksander Łukasz
<aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 16 Jul 2013 15:09:50 +0000
(17:09 +0200)
modules/documentCanvas/canvas/canvas.test3.js
patch
|
blob
|
history
modules/documentCanvas/canvas/documentElement.js
patch
|
blob
|
history
modules/documentCanvas/canvasManager.js
patch
|
blob
|
history
diff --git
a/modules/documentCanvas/canvas/canvas.test3.js
b/modules/documentCanvas/canvas/canvas.test3.js
index
c4dc610
..
23061d9
100644
(file)
--- a/
modules/documentCanvas/canvas/canvas.test3.js
+++ b/
modules/documentCanvas/canvas/canvas.test3.js
@@
-576,10
+576,11
@@
describe('Canvas', function() {
section = c.doc(),
text = section.children()[1].children()[0];
section = c.doc(),
text = section.children()[1].children()[0];
- text.unwrap();
+
var newTextContainer =
text.unwrap();
expect(section.children().length).to.equal(1, 'section has one child');
expect(section.children()[0].getText()).to.equal('Alice has a cat');
expect(section.children().length).to.equal(1, 'section has one child');
expect(section.children()[0].getText()).to.equal('Alice has a cat');
+ expect(newTextContainer.sameNode(c.doc())).to.equal(true, 'unwrap returns new text parent DocumentNodeElement');
})
});
});
})
});
});
diff --git
a/modules/documentCanvas/canvas/documentElement.js
b/modules/documentCanvas/canvas/documentElement.js
index
669e06a
..
230e987
100644
(file)
--- a/
modules/documentCanvas/canvas/documentElement.js
+++ b/
modules/documentCanvas/canvas/documentElement.js
@@
-315,8
+315,10
@@
$.extend(DocumentTextElement.prototype, {
}
},
unwrap: function() {
}
},
unwrap: function() {
- var parent = this.parent();
+ var parent = this.parent(),
+ toret;
if(parent.children().length === 1) {
if(parent.children().length === 1) {
+ toret = parent.parent();
var grandParent = parent.parent();
if(grandParent) {
var grandParentChildren = grandParent.children(),
var grandParent = parent.parent();
if(grandParent) {
var grandParentChildren = grandParent.children(),
@@
-336,6
+338,7
@@
$.extend(DocumentTextElement.prototype, {
parent.after(this);
}
parent.detach();
parent.after(this);
}
parent.detach();
+ return toret;
}
},
split: function(params) {
}
},
split: function(params) {
diff --git
a/modules/documentCanvas/canvasManager.js
b/modules/documentCanvas/canvasManager.js
index
a480d2a
..
a306d14
100644
(file)
--- a/
modules/documentCanvas/canvasManager.js
+++ b/
modules/documentCanvas/canvasManager.js
@@
-194,7
+194,9
@@
Manager.prototype.command = function(command, params) {
if(this.canvas.list.areItemsOfTheSameList({element1: parent1, element2: parent2})) {
this.canvas.list.extractItems({element1: parent1, element2: parent2});
} else if(!cursor.isSelecting()) {
if(this.canvas.list.areItemsOfTheSameList({element1: parent1, element2: parent2})) {
this.canvas.list.extractItems({element1: parent1, element2: parent2});
} else if(!cursor.isSelecting()) {
- cursor.getPosition().element.unwrap();
+ var toUnwrap = cursor.getPosition().element,
+ parent = toUnwrap.unwrap();
+ this.canvas.setCurrentElement(parent);
}
} else if(command === 'wrap-node') {
if(this.canvas.list.areItemsOfTheSameList({element1: parent1, element2: parent2})) {
}
} else if(command === 'wrap-node') {
if(this.canvas.list.areItemsOfTheSameList({element1: parent1, element2: parent2})) {