8
0
Pārlūkot izejas kodu

Document interface.

Piotr Jasiun 10 gadi atpakaļ
vecāks
revīzija
ba16eb07f2

+ 38 - 0
packages/ckeditor5-utils/src/document/document.js

@@ -0,0 +1,38 @@
+/**
+ * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+'use strict';
+
+CKEDITOR.define( [ 'document/element' ], function( Element ) {
+	/**
+	 * Document model.
+	 *
+	 * @class document.Document
+	 */
+	class Document {
+		/**
+		 * Create an empty document.
+		 */
+		constructor() {
+			/**
+			 * Document tree root. Document always have an root document.
+			 *
+			 * @readonly
+			 * @property {String} root
+			 */
+			this.root = new Element( null, 'root' );
+		}
+
+		/**
+		 * This is the only entry point for all document changes.
+		 *
+		 * @param {document.Element} operation Operation to be applied.
+		 */
+		applyOperation() {
+		}
+	}
+
+	return Document;
+} );

+ 24 - 0
packages/ckeditor5-utils/tests/document/document.js

@@ -0,0 +1,24 @@
+/**
+ * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* globals describe, it, expect, bender */
+
+/* bender-tags: document */
+
+'use strict';
+
+var modules = bender.amd.require( 'document/document', 'document/element' );
+
+describe( 'constructor', function() {
+	it( 'should create Document with no data', function() {
+		var Document = modules[ 'document/document' ];
+		var Element = modules[ 'document/element' ];
+
+		var document = new Document();
+
+		expect( document ).to.have.property( 'root' ).that.is.instanceof( Element );
+		expect( document.root ).to.have.property( 'name' ).that.equal( 'root' );
+	} );
+} );