Ver código fonte

Fixed: engine.model.Document was JSON-ized to empty object.

Szymon Cofalik 9 anos atrás
pai
commit
9a79327ba3

+ 2 - 3
packages/ckeditor5-engine/src/model/document.js

@@ -162,7 +162,6 @@ export default class Document {
 		this.version++;
 
 		if ( operation.delta ) {
-			// Right now I can't imagine operations without deltas, but let's be safe.
 			this.history.addDelta( operation.delta );
 		}
 
@@ -288,9 +287,9 @@ export default class Document {
 		const json = clone( this );
 
 		// Due to circular references we need to remove parent reference.
-		json.selection = '[engine.model.Selection]';
+		json.selection = '[engine.model.DocumentSelection]';
 
-		return {};
+		return json;
 	}
 
 	/**

+ 5 - 0
packages/ckeditor5-engine/tests/model/document/document.js

@@ -15,6 +15,7 @@ import Batch from '/ckeditor5/engine/model/batch.js';
 import Delta from '/ckeditor5/engine/model/delta/delta.js';
 import CKEditorError from '/ckeditor5/utils/ckeditorerror.js';
 import count from '/ckeditor5/utils/count.js';
+import { jsonParseStringify } from '/tests/engine/model/_utils/utils.js';
 
 describe( 'Document', () => {
 	let doc;
@@ -253,4 +254,8 @@ describe( 'Document', () => {
 			expect( doc._getDefaultRoot() ).to.equal( rootA );
 		} );
 	} );
+
+	it( 'should be correctly converted to json', () => {
+		expect( jsonParseStringify( doc ).selection ).to.equal( '[engine.model.DocumentSelection]' );
+	} );
 } );