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:
a1337ec
)
editor: fixing handling nodeTextChange on text nodes belonging to custom-rendered...
author
Aleksander Łukasz
<aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 26 May 2014 14:20:20 +0000
(16:20 +0200)
committer
Aleksander Łukasz
<aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 28 May 2014 12:45:58 +0000
(14:45 +0200)
src/editor/modules/documentCanvas/canvas/canvas.test.js
patch
|
blob
|
history
src/editor/modules/documentCanvas/canvas/documentElement.js
patch
|
blob
|
history
src/editor/modules/documentCanvas/canvas/utils.js
patch
|
blob
|
history
src/editor/modules/documentCanvas/canvas/wlxmlListener.js
patch
|
blob
|
history
diff --git
a/src/editor/modules/documentCanvas/canvas/canvas.test.js
b/src/editor/modules/documentCanvas/canvas/canvas.test.js
index
0654170
..
be4a8b9
100644
(file)
--- a/
src/editor/modules/documentCanvas/canvas/canvas.test.js
+++ b/
src/editor/modules/documentCanvas/canvas/canvas.test.js
@@
-293,7
+293,11
@@
describe('Custom elements based on wlxml class attribute', function() {
onNodeAdded: function(event) {
void(event);
this.refresh2();
onNodeAdded: function(event) {
void(event);
this.refresh2();
- }
+ },
+ onNodeTextChange: function(event) {
+ this.header.text(event.meta.node.getText());
+ },
+ children: function() { return []; }
});
var c = getCanvasFromXML('<section><div class="testClass"><a></a></div></section>', [
});
var c = getCanvasFromXML('<section><div class="testClass"><a></a></div></section>', [
@@
-309,6
+313,14
@@
describe('Custom elements based on wlxml class attribute', function() {
node.append({tagName: 'div'});
expect(header.text()).to.equal('2', 'added div');
node.append({tagName: 'div'});
expect(header.text()).to.equal('2', 'added div');
+
+ var textNode = node.append({text: 'test'});
+
+ expect(header.text()).to.equal('3', 'added text node');
+
+ textNode.setText('test2');
+
+ expect(header.text()).to.equal('test2', 'text node change handled');
});
describe('Handling unknown class', function() {
});
describe('Handling unknown class', function() {
diff --git
a/src/editor/modules/documentCanvas/canvas/documentElement.js
b/src/editor/modules/documentCanvas/canvas/documentElement.js
index
948e8df
..
99a12f5
100644
(file)
--- a/
src/editor/modules/documentCanvas/canvas/documentElement.js
+++ b/
src/editor/modules/documentCanvas/canvas/documentElement.js
@@
-226,6
+226,9
@@
$.extend(DocumentTextElement.prototype, {
this.dom.contents()[0].data = text;
}
},
this.dom.contents()[0].data = text;
}
},
+ handle: function(event) {
+ this.setText(event.meta.node.getText());
+ },
getText: function(options) {
options = _.extend({raw: false}, options || {});
var toret = this.dom.text();
getText: function(options) {
options = _.extend({raw: false}, options || {});
var toret = this.dom.text();
diff --git
a/src/editor/modules/documentCanvas/canvas/utils.js
b/src/editor/modules/documentCanvas/canvas/utils.js
index
1df3f82
..
4e262a0
100644
(file)
--- a/
src/editor/modules/documentCanvas/canvas/utils.js
+++ b/
src/editor/modules/documentCanvas/canvas/utils.js
@@
-58,7
+58,7
@@
var _getElementForTextNode = function(textNode, withParent) {
return true;
}
});
return true;
}
});
- return toret;
+ return toret
|| parentElement
;
};
var getElementForDetachedNode = function(node, originalParent) {
};
var getElementForDetachedNode = function(node, originalParent) {
diff --git
a/src/editor/modules/documentCanvas/canvas/wlxmlListener.js
b/src/editor/modules/documentCanvas/canvas/wlxmlListener.js
index
02dc657
..
d107612
100644
(file)
--- a/
src/editor/modules/documentCanvas/canvas/wlxmlListener.js
+++ b/
src/editor/modules/documentCanvas/canvas/wlxmlListener.js
@@
-75,7
+75,7
@@
var handlers = {
},
nodeTextChange: function(event) {
var element = utils.getElementForNode(event.meta.node);
},
nodeTextChange: function(event) {
var element = utils.getElementForNode(event.meta.node);
- element.
setText(event.meta.node.getText()
);
+ element.
handle(event
);
},
metadataChanged: _metadataEventHandler,
},
metadataChanged: _metadataEventHandler,