Răsfoiți Sursa

Moved Schema to treeModel namespace. Moved Command and AttributeCommand to command namespace.

Szymon Cofalik 9 ani în urmă
părinte
comite
d48ae676cd

+ 1 - 1
packages/ckeditor5-engine/src/bold/boldfeature.js

@@ -6,7 +6,7 @@
 'use strict';
 
 import Feature from '../feature.js';
-import AttributeCommand from '../attributecommand.js';
+import AttributeCommand from '../command/attributecommand.js';
 
 /**
  * Bold feature.

+ 4 - 4
packages/ckeditor5-engine/src/attributecommand.js → packages/ckeditor5-engine/src/command/attributecommand.js

@@ -6,14 +6,14 @@
 'use strict';
 
 import Command from './command.js';
-import TreeWalker from './treemodel/treewalker.js';
-import Range from './treemodel/range.js';
+import TreeWalker from '../treemodel/treewalker.js';
+import Range from '../treemodel/range.js';
 
 /**
- * An extension of basic {@link core.Command} class, which provides utilities typical of commands that sets an
+ * An extension of basic {@link core.command.Command} class, which provides utilities typical of commands that sets an
  * attribute on specific elements.
  *
- * @class core.AttributeCommand
+ * @class core.command.AttributeCommand
  */
 
 export default class AttributeCommand extends Command {

+ 3 - 3
packages/ckeditor5-engine/src/command.js → packages/ckeditor5-engine/src/command/command.js

@@ -5,13 +5,13 @@
 
 'use strict';
 
-import EmitterMixin from './emittermixin.js';
-import utils from './utils.js';
+import EmitterMixin from '../emittermixin.js';
+import utils from '../utils.js';
 
 /**
  * The base class for CKEditor commands.
  *
- * @class core.Command
+ * @class core.command.Command
  */
 
 export default class Command {

+ 1 - 1
packages/ckeditor5-engine/src/treemodel/document.js

@@ -17,7 +17,7 @@ import EmitterMixin from '../emittermixin.js';
 import CKEditorError from '../ckeditorerror.js';
 import utils from '../utils.js';
 import CharacterProxy from './characterproxy.js';
-import Schema from '../schema.js';
+import Schema from './schema.js';
 
 const graveyardSymbol = Symbol( 'graveyard' );
 

+ 87 - 87
packages/ckeditor5-engine/src/schema.js → packages/ckeditor5-engine/src/treemodel/schema.js

@@ -5,11 +5,95 @@
 
 'use strict';
 
-import clone from './lib/lodash/clone.js';
-import CKEditorError from './ckeditorerror.js';
+import clone from '../lib/lodash/clone.js';
+import CKEditorError from '../ckeditorerror.js';
+
+export class SchemaItem {
+	constructor( schema ) {
+		if ( !schema ) {
+			/**
+			 * Schema item must have schema instance.
+			 *
+			 * @error schema-item-no-schema
+			 */
+			throw new CKEditorError( 'schema-item-no-schema: Schema item must have schema instance.' );
+		}
+
+		this._schema = schema;
+		this._allowed = [];
+		this._disallowed = [];
+	}
+
+	addAllowed( path, attribute ) {
+		this._addPath( '_allowed', path, attribute );
+	}
+
+	addDisallowed( path, attribute ) {
+		this._addPath( '_disallowed', path, attribute );
+	}
+
+	_addPath( member, path, attribute ) {
+		if ( typeof path === 'string' ) {
+			path = path.split( ' ' );
+		}
+
+		path = path.slice();
+
+		this[ member ].push( { path, attribute } );
+	}
+
+	_getPaths( type, attribute ) {
+		let source = type === 'ALLOW' ? this._allowed : this._disallowed;
+		let paths = [];
+
+		for ( let item of source ) {
+			if ( item.attribute === attribute ) {
+				paths.push( item.path.slice() );
+			}
+		}
+
+		return paths;
+	}
+
+	_hasMatchingPath( type, checkPath, attribute ) {
+		const itemPaths = this._getPaths( type, attribute );
+
+		checkPath = checkPath.slice();
+
+		for ( let itemPath of itemPaths ) {
+			for ( let checkName of checkPath ) {
+				let baseChain = this._schema._baseChains[ checkName ];
+
+				if ( baseChain.indexOf( itemPath[ 0 ] ) > -1 ) {
+					itemPath.shift();
+				}
+			}
+
+			if ( itemPath.length === 0 ) {
+				return true;
+			}
+		}
+
+		return false;
+	}
+
+	/**
+	 * Custom toJSON method to solve child-parent circular dependencies.
+	 *
+	 * @returns {Object} Clone of this object with the parent property replaced with its name.
+	 */
+	toJSON() {
+		const json = clone( this );
+
+		// Due to circular references we need to remove parent reference.
+		json._schema = '[treeModel.Schema]';
+
+		return json;
+	}
+}
 
 /**
- * @class core.Schema
+ * @class core.treeModel.Schema
  */
 export default class Schema {
 	constructor() {
@@ -124,87 +208,3 @@ export default class Schema {
 		return path;
 	}
 }
-
-export class SchemaItem {
-	constructor( schema ) {
-		if ( !schema ) {
-			/**
-			 * Schema item must have schema instance.
-			 *
-			 * @error schema-item-no-schema
-			 */
-			throw new CKEditorError( 'schema-item-no-schema: Schema item must have schema instance.' );
-		}
-
-		this._schema = schema;
-		this._allowed = [];
-		this._disallowed = [];
-	}
-
-	addAllowed( path, attribute ) {
-		this._addPath( '_allowed', path, attribute );
-	}
-
-	addDisallowed( path, attribute ) {
-		this._addPath( '_disallowed', path, attribute );
-	}
-
-	_addPath( member, path, attribute ) {
-		if ( typeof path === 'string' ) {
-			path = path.split( ' ' );
-		}
-
-		path = path.slice();
-
-		this[ member ].push( { path, attribute } );
-	}
-
-	_getPaths( type, attribute ) {
-		let source = type === 'ALLOW' ? this._allowed : this._disallowed;
-		let paths = [];
-
-		for ( let item of source ) {
-			if ( item.attribute === attribute ) {
-				paths.push( item.path.slice() );
-			}
-		}
-
-		return paths;
-	}
-
-	_hasMatchingPath( type, checkPath, attribute ) {
-		const itemPaths = this._getPaths( type, attribute );
-
-		checkPath = checkPath.slice();
-
-		for ( let itemPath of itemPaths ) {
-			for ( let checkName of checkPath ) {
-				let baseChain = this._schema._baseChains[ checkName ];
-
-				if ( baseChain.indexOf( itemPath[ 0 ] ) > -1 ) {
-					itemPath.shift();
-				}
-			}
-
-			if ( itemPath.length === 0 ) {
-				return true;
-			}
-		}
-
-		return false;
-	}
-
-	/**
-	 * Custom toJSON method to solve child-parent circular dependencies.
-	 *
-	 * @returns {Object} Clone of this object with the parent property replaced with its name.
-	 */
-	toJSON() {
-		const json = clone( this );
-
-		// Due to circular references we need to remove parent reference.
-		json._schema = '[treeModel.Schema]';
-
-		return json;
-	}
-}

+ 1 - 1
packages/ckeditor5-engine/tests/attributecommand.js

@@ -6,7 +6,7 @@
 'use strict';
 
 import Editor from '/ckeditor5/core/editor.js';
-import AttributeCommand from '/ckeditor5/core/attributecommand.js';
+import AttributeCommand from '/ckeditor5/core/command/attributecommand.js';
 import Text from '/ckeditor5/core/treemodel/text.js';
 import Range from '/ckeditor5/core/treemodel/range.js';
 import Position from '/ckeditor5/core/treemodel/position.js';

+ 1 - 1
packages/ckeditor5-engine/tests/command.js

@@ -6,7 +6,7 @@
 'use strict';
 
 import Editor from '/ckeditor5/core/editor.js';
-import Command from '/ckeditor5/core/command.js';
+import Command from '/ckeditor5/core/command/command.js';
 
 let element, editor, command;
 

+ 1 - 1
packages/ckeditor5-engine/tests/editor/editor.js

@@ -13,7 +13,7 @@ import Editor from '/ckeditor5/core/editor.js';
 import EditorConfig from '/ckeditor5/core/editorconfig.js';
 import Plugin from '/ckeditor5/core/plugin.js';
 import Locale from '/ckeditor5/core/locale.js';
-import Command from '/ckeditor5/core/command.js';
+import Command from '/ckeditor5/core/command/command.js';
 import CKEditorError from '/ckeditor5/core/ckeditorerror.js';
 
 const pluginClasses = {};

+ 2 - 2
packages/ckeditor5-engine/tests/schema/schema.js

@@ -5,8 +5,8 @@
 
 'use strict';
 
-import Schema from '/ckeditor5/core/schema.js';
-import { SchemaItem as SchemaItem } from '/ckeditor5/core/schema.js';
+import Schema from '/ckeditor5/core/treemodel/schema.js';
+import { SchemaItem as SchemaItem } from '/ckeditor5/core/treemodel/schema.js';
 import Document from '/ckeditor5/core/treemodel/document.js';
 import Element from '/ckeditor5/core/treemodel/element.js';
 import Position from '/ckeditor5/core/treemodel/position.js';

+ 2 - 2
packages/ckeditor5-engine/tests/schema/schemaitem.js

@@ -5,8 +5,8 @@
 
 'use strict';
 
-import Schema from '/ckeditor5/core/schema.js';
-import { SchemaItem as SchemaItem } from '/ckeditor5/core/schema.js';
+import Schema from '/ckeditor5/core/treemodel/schema.js';
+import { SchemaItem as SchemaItem } from '/ckeditor5/core/treemodel/schema.js';
 import CKEditorError from '/ckeditor5/core/ckeditorerror.js';
 
 let schema, item;