X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/bbb810b9417335d3a6fbfeb300de8f12e4cd091a..1a51f254c2c899b068ecfca66fd472ae79fadda3:/src/editor/modules/documentCanvas/canvas/genericElement.js
diff --git a/src/editor/modules/documentCanvas/canvas/genericElement.js b/src/editor/modules/documentCanvas/canvas/genericElement.js
index e0fc84b..4dfbe59 100644
--- a/src/editor/modules/documentCanvas/canvas/genericElement.js
+++ b/src/editor/modules/documentCanvas/canvas/genericElement.js
@@ -33,7 +33,7 @@ $.extend(generic, {
}
}.bind(this));
- this.commentsView = new CommentsView(this.wlxmlNode, {});
+ this.commentsView = new CommentsView(this.wlxmlNode, this.canvas.metadata.user);
this.addToGutter(this.commentsView);
this.commentTip = $('
');
this.addWidget(this.commentTip);
@@ -80,13 +80,18 @@ $.extend(generic, {
return toret;
},
- getVerticallyFirstTextElement: function() {
+ getVerticallyFirstTextElement: function(params) {
var toret;
+
+ params = _.extend({
+ considerChildren: true
+ }, params);
+
this.children().some(function(child) {
if(child instanceof documentElement.DocumentTextElement) {
toret = child;
return true; // break
- } else {
+ } else if(params.considerChildren) {
toret = child.getVerticallyFirstTextElement();
if(toret) {
return true; // break
@@ -154,9 +159,12 @@ $.extend(generic, {
}
},
onNodeTextChange: function(event) {
- var toSet = event.meta.node.getText();
- this.children().some(function(child) {
- if(child.wlxmlNode.sameNode(event.meta.node)) {
+ var node = event.meta.node,
+ toSet = node.getText(),
+ handled;
+
+ handled = this.children().some(function(child) {
+ if(child.wlxmlNode.sameNode(node)) {
if(toSet === '') {
toSet = utils.unicode.ZWS;
}
@@ -166,6 +174,10 @@ $.extend(generic, {
return true;
}
});
+
+ if(!handled && node.parent() && node.parent().is('comment') && this.wlxmlNode.sameNode(node.parent().parent())) {
+ this.commentsView.render();
+ }
},
onStateChange: function(changes) {