|
@@ -94,6 +94,15 @@ History.prototype = {
|
|
|
|
|
|
var cmd = this.undos.pop();
|
|
|
|
|
|
+ if ( cmd.serialized ) {
|
|
|
+
|
|
|
+ var json = cmd;
|
|
|
+ cmd = new window[ json.type ](); // creates a new object of type "json.type"
|
|
|
+ cmd.editor = this.editor;
|
|
|
+ cmd.fromJSON( json );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if ( cmd !== undefined ) {
|
|
@@ -123,6 +132,15 @@ History.prototype = {
|
|
|
|
|
|
var cmd = this.redos.pop();
|
|
|
|
|
|
+ if ( cmd.serialized ) {
|
|
|
+
|
|
|
+ var json = cmd;
|
|
|
+ cmd = new window[ json.type ](); // creates a new object of type "json.type"
|
|
|
+ cmd.editor = this.editor;
|
|
|
+ cmd.fromJSON( json );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if ( cmd !== undefined ) {
|
|
@@ -148,7 +166,16 @@ History.prototype = {
|
|
|
for ( var i = 0 ; i < this.undos.length; i++ ) {
|
|
|
|
|
|
var cmd = this.undos[ i ];
|
|
|
- undos.push( cmd.toJSON() );
|
|
|
+
|
|
|
+ if ( cmd.serialized ) {
|
|
|
+
|
|
|
+ undos.push( cmd ); // add without serializing
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ undos.push( cmd.toJSON() );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -161,7 +188,17 @@ History.prototype = {
|
|
|
for ( var i = 0 ; i < this.redos.length; i++ ) {
|
|
|
|
|
|
var cmd = this.redos[ i ];
|
|
|
- redos.push( cmd.toJSON() );
|
|
|
+
|
|
|
+ if ( cmd.serialized ) {
|
|
|
+
|
|
|
+ redos.push( cmd ); // add without serializing
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ redos.push( cmd.toJSON() );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -177,10 +214,8 @@ History.prototype = {
|
|
|
|
|
|
for ( var i = 0; i < json.undos.length ; i++ ) {
|
|
|
|
|
|
- var cmd = new window[ json.undos[ i ].type ](); // creates a new object of type "json.type"
|
|
|
- cmd.fromJSON( json.undos[ i ] );
|
|
|
- cmd.editor = this.editor;
|
|
|
- this.undos.push( cmd );
|
|
|
+ json.undos[ i ].serialized = true;
|
|
|
+ this.undos.push( json.undos[ i ] );
|
|
|
|
|
|
this.idCounter = json.undos[ i ].id > this.idCounter ? json.undos[ i ].id : this.idCounter; // set last used idCounter
|
|
|
|
|
@@ -188,10 +223,8 @@ History.prototype = {
|
|
|
|
|
|
for ( var i = 0; i < json.redos.length ; i++ ) {
|
|
|
|
|
|
- var cmd = new window[ json.redos[ i ].type ](); // creates a new object of type "json.type"
|
|
|
- cmd.fromJSON( json.redos[ i ] );
|
|
|
- cmd.editor = this.editor;
|
|
|
- this.redos.push( cmd );
|
|
|
+ json.redos[ i ].serialized = true;
|
|
|
+ this.redos.push( json.redos[ i ] );
|
|
|
|
|
|
this.idCounter = json.redos[ i ].id > this.idCounter ? json.redos[ i ].id : this.idCounter; // set last used idCounter
|
|
|
|