8
0
Просмотр исходного кода

Added Markers Collection to DocumentFragment.

Oskar Wróbel 8 лет назад
Родитель
Сommit
6aab0362ce

+ 13 - 0
packages/ckeditor5-engine/src/model/documentfragment.js

@@ -7,6 +7,7 @@
  * @module module:engine/model/documentfragment
  */
 
+import MarkerCollection from './markercollection';
 import NodeList from './nodelist';
 import Element from './element';
 import Text from './text';
@@ -15,6 +16,10 @@ import isIterable from '@ckeditor/ckeditor5-utils/src/isiterable';
 /**
  * DocumentFragment represents a part of model which does not have a common root but it's top-level nodes
  * can be seen as siblings. In other words, it is a detached part of model tree, without a root.
+ *
+ * DocumentFragment has own {@link module:engine/model/markercollection~MarkerCollection}. Markers from this collection
+ * will be set to the {@link module:engine/model/document~Document#markers document markers} by a
+ * {@link module:engine/model/writer~writer.insert} function.
  */
 export default class DocumentFragment {
 	/**
@@ -25,6 +30,14 @@ export default class DocumentFragment {
 	 */
 	constructor( children ) {
 		/**
+		 * DocumentFragment markers collection.
+		 *
+		 * @readonly
+		 * @member {module:engine/model/markercollection~MarkerCollection}
+		 */
+		this.markers = new MarkerCollection();
+
+		/**
 		 * List of nodes contained inside the document fragment.
 		 *
 		 * @private

+ 7 - 0
packages/ckeditor5-engine/tests/model/documentfragment.js

@@ -6,6 +6,7 @@
 import Element from '../../src/model/element';
 import Text from '../../src/model/text';
 import DocumentFragment from '../../src/model/documentfragment';
+import MarkerCollection from '../../src/model/markercollection';
 import { jsonParseStringify } from '../../tests/model/_utils/utils';
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 
@@ -29,6 +30,12 @@ describe( 'DocumentFragment', () => {
 			expect( frag.getChild( 2 ) ).to.have.property( 'data' ).that.equals( 'yy' );
 		} );
 
+		it( 'should have markers collection', () => {
+			let frag = new DocumentFragment();
+
+			expect( frag ).to.have.property( 'markers' ).to.instanceof( MarkerCollection );
+		} );
+
 		it( 'should have root property, equal to itself', () => {
 			let frag = new DocumentFragment();