mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-03-14 00:39:57 -04:00
Properly fix issue with Project#exportJSON() creating separate projects on import.
This commit is contained in:
parent
612cf396cf
commit
0b4bc678bc
2 changed files with 6 additions and 6 deletions
src
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue