Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed text updating. Fixes #168 #181

Merged
merged 1 commit into from
Jun 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@ define([
].join('\n');
};

DeserializeEditorWidget.prototype.updateNode = function() {
// nop
};

return DeserializeEditorWidget;
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@ define([
].join('\n');
};

SerializeEditorWidget.prototype.updateNode = function() {
// nop
};

return SerializeEditorWidget;
});
9 changes: 5 additions & 4 deletions src/visualizers/widgets/TextEditor/TextEditorWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ define([
TextEditorWidget.prototype.addNode = function (desc) {
// Set the current text based on the given
// Create the header
var header = this.getHeader(desc) + '\n';
var header = this.getHeader(desc);

this.activeNode = desc.id;
this.editor.setValue(header + desc.text, 2);
this.editor.setValue(header + '\n' + desc.text, 2);
this.currentHeader = header;
};

TextEditorWidget.prototype.saveText = function () {
var text = this.editor.getValue().replace(this.currentHeader, '');
var text = this.editor.getValue().replace(this.currentHeader + '\n', '');
if (this.activeNode) {
this.saveTextFor(this.activeNode, text);
} else {
Expand All @@ -85,7 +85,8 @@ define([

TextEditorWidget.prototype.updateNode = function (desc) {
// Check for header changes
if (this.activeNode === desc.id) {
if (this.activeNode === desc.id &&
this.getHeader(desc) !== this.currentHeader) {
this.addNode(desc);
}
// TODO: Handle concurrent editing... Currently, last save wins and there are no
Expand Down