Properly fix issue with Project#exportJSON() creating separate projects on import.

This commit is contained in:
Jürg Lehni 2013-05-28 07:42:38 -07:00
parent 612cf396cf
commit 0b4bc678bc
2 changed files with 6 additions and 6 deletions
src

View file

@ -310,13 +310,17 @@ Base.inject(/** @lends Base# */{
// identifier), see if _serialize didn't already add the class,
// e.g. for classes that do not support compact form.
var name = obj.constructor.name;
if (name && !compact && res[0] !== name)
if (name && !compact && !res._compact && res[0] !== name)
res.unshift(name);
} else if (Array.isArray(obj)) {
res = [];
for (var i = 0, l = obj.length; i < l; i++)
res[i] = Base.serialize(obj[i], options, compact,
dictionary);
// Mark array as compact, so obj._serialize handling above
// doesn't add the constructor name again.
if (compact)
res._compact = true;
} else if (Base.isPlainObject(obj)) {
res = {};
for (var i in obj)

View file

@ -69,7 +69,7 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
// into the active project automatically. We might want to add proper
// project serialization later, but deserialization of a layers array
// will always work.
return Base.serialize(this.layers, options, false, dictionary);
return Base.serialize(this.layers, options, true, dictionary);
},
/**
@ -266,10 +266,6 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
// DOCS: Figure out a way to group these together with importSVG / exportSVG
importJSON: function(json) {
json = typeof json === 'string' ? JSON.parse(json) : json;
// Unbox project data, as we don't want to create a new project object.
if (json[0] === 'Project')
json = json[1];
this.activate();
return Base.importJSON(json);
},