Make attachments textcell-specific

This commit is contained in:
Julien Rebetez 2016-02-09 15:09:11 +01:00 committed by Julien Rebetez
parent c012835e67
commit 84f38c2cf9
2 changed files with 10 additions and 6 deletions

View File

@ -70,7 +70,6 @@ define([
}
});
this.attachments = {};
// backward compat.
Object.defineProperty(this, 'cm_config', {
@ -477,8 +476,6 @@ define([
var data = {};
// deepcopy the metadata so copied cells don't share the same object
data.metadata = JSON.parse(JSON.stringify(this.metadata));
// same for attachments
data.attachments = JSON.parse(JSON.stringify(this.attachments));
data.cell_type = this.cell_type;
return data;
};
@ -491,9 +488,6 @@ define([
if (data.metadata !== undefined) {
this.metadata = data.metadata;
}
if (data.attachments !== undefined) {
this.attachments = data.attachments;
}
};

View File

@ -184,7 +184,12 @@ define([
*/
TextCell.prototype.fromJSON = function (data) {
Cell.prototype.fromJSON.apply(this, arguments);
console.log('data cell_type : ' + data.cell_type + ' this.cell_type : ' + this.cell_type);
if (data.cell_type === this.cell_type) {
if (data.attachments !== undefined) {
this.attachments = data.attachments;
}
if (data.source !== undefined) {
this.set_text(data.source);
// make this value the starting point, so that we can only undo
@ -208,6 +213,11 @@ define([
if (data.source == this.placeholder) {
data.source = "";
}
// Deepcopy the attachments so copied cells don't share the same
// objects
if (this.attachments !== undefined) {
data.attachments = JSON.parse(JSON.stringify(this.attachments));
}
return data;
};