Ver código fonte

Renamed DataInterface to DataApiMixin and elementInterface to ElementApiMixin.

Oskar Wróbel 8 anos atrás
pai
commit
8604e2b530

+ 2 - 2
packages/ckeditor5-core/src/editor/editor.js

@@ -21,8 +21,8 @@ import mix from '@ckeditor/ckeditor5-utils/src/mix';
 
 /**
  * Class representing the base of the editor. It is the API all plugins can expect to get when using editor property.
- * Editors implementation (like {@link module:editor-classic/classiceditor~ClassicEditor Classic Editor} or
- * {@link module:editor-inline/inlineeditor~InlineEditor Inline Editor}) should extend this class. They can add their
+ * Editors implementation (like {@link module:editor-classic/classiceditor~ClassicEditor} or
+ * {@link module:editor-inline/inlineeditor~InlineEditor}) should extend this class. They can add their
  * own methods and properties.
  *
  * @mixes module:utils/observablemixin~ObservableMixin

+ 4 - 4
packages/ckeditor5-core/src/editor/utils/attachtoform.js

@@ -14,18 +14,18 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
  * Checks if editor is initialized on textarea element that belongs to a form. If yes - updates editor's element
  * contents before submitting the form.
  *
- * This helper requires {@link module:core/editor/utils/elementinterface~ElementInterface ElementInterface}.
+ * This helper requires {@link module:core/editor/utils/elementapimixin~ElementApi ElementApi interface}.
  *
  * @param {module:core/editor/editor~Editor} editor Editor instance.
  */
 export default function attachToForm( editor ) {
 	if ( !isFunction( editor.updateElement ) ) {
 		/**
-		 * {@link module:core/editor/utils/elementinterface~ElementInterface ElementInterface} is required.
+		 * {@link module:core/editor/utils/elementapimixin~ElementApi ElementApi interface} is required.
 		 *
-		 * @error attachtoform-missing-elementinterface
+		 * @error attachtoform-missing-elementapi-interface
 		 */
-		throw new CKEditorError( 'attachtoform-missing-elementinterface: Element interface is required.' );
+		throw new CKEditorError( 'attachtoform-missing-elementapi-interface: ElementApi interface is required.' );
 	}
 
 	const element = editor.element;

+ 8 - 8
packages/ckeditor5-core/src/editor/utils/datainterface.js

@@ -4,17 +4,17 @@
  */
 
 /**
- * @module core/editor/utils/datainterface
+ * @module core/editor/utils/dataapimixin
  */
 
 /**
- * Interface provides methods for setting and getting data to/from editor main root element of the model tree
+ * Mixin provides methods for setting and getting data to/from editor main root element of the model tree
  * using {@link module:core/editor/editor~Editor#data data pipeline}.
  *
- * @mixin DataInterface
- * @implements module:core/editor/utils/datainterface~Data
+ * @mixin DataApiMixin
+ * @implements module:core/editor/utils/dataapimixin~DataApi
  */
-const DataInterface = {
+const DataApiMixin = {
 	/**
 	 * Sets the data in the editor's main root.
 	 *
@@ -35,10 +35,10 @@ const DataInterface = {
 	}
 };
 
-export default DataInterface;
+export default DataApiMixin;
 
 /**
- * Interface representing classes which mix in {@link module:core/editor/utils/datainterface~DataInterface}.
+ * Interface representing classes which mix in {@link module:core/editor/utils/dataapimixin~DataApiMixin}.
  *
- * @interface Data
+ * @interface DataApi
  */

+ 15 - 16
packages/ckeditor5-core/src/editor/utils/elementinterface.js

@@ -7,24 +7,16 @@ import getDataFromElement from '@ckeditor/ckeditor5-utils/src/dom/getdatafromele
 import setDataInElement from '@ckeditor/ckeditor5-utils/src/dom/setdatainelement';
 
 /**
- * @module core/editor/utils/elementinterface
+ * @module core/editor/utils/elementapimixin
  */
 
 /**
- * Interface provides method for setting and getting data from/to element on which editor has been initialized.
+ * Mixin provides method for setting and getting data from/to element on which editor has been initialized.
  *
- * @mixin ElementInterface
- * @implements module:core/editor/utils/elementinterface~Element
+ * @mixin ElementApiMixin
+ * @implements module:core/editor/utils/elementapimixin~ElementApi
  */
-const ElementInterface = {
-	/**
-	 * The element on which the editor has been initialized.
-	 *
-	 * @readonly
-	 * @member {HTMLElement} #element
-	 */
-	element: null,
-
+const ElementApiMixin = {
 	/**
 	 * Updates the {@link #element editor element}'s content with the data.
 	 *
@@ -44,10 +36,17 @@ const ElementInterface = {
 	}
 };
 
-export default ElementInterface;
+export default ElementApiMixin;
+
+/**
+ * Interface representing classes which mix in {@link module:core/editor/utils/elementapimixin~ElementApiMixin}.
+ *
+ * @interface ElementApi
+ */
 
 /**
- * Interface representing classes which mix in {@link module:core/editor/utils/elementinterface~ElementInterface}.
+ * The element on which the editor has been initialized.
  *
- * @interface Element
+ * @readonly
+ * @member {HTMLElement} #element
  */

+ 6 - 6
packages/ckeditor5-core/tests/_utils-tests/classictesteditor.js

@@ -15,8 +15,8 @@ import ClassicTestEditorUI from '../../tests/_utils/classictesteditorui';
 import BoxedEditorUIView from '@ckeditor/ckeditor5-ui/src/editorui/boxed/boxededitoruiview';
 import InlineEditableUIView from '@ckeditor/ckeditor5-ui/src/editableui/inline/inlineeditableuiview';
 
-import DataInterface from '../../src/editor/utils/datainterface';
-import ElementInterface from '../../src/editor/utils/elementinterface';
+import DataApiMixin from '../../src/editor/utils/dataapimixin';
+import ElementApiMixin from '../../src/editor/utils/elementapimixin';
 import RootElement from '@ckeditor/ckeditor5-engine/src/model/rootelement';
 
 import { getData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
@@ -59,12 +59,12 @@ describe( 'ClassicTestEditor', () => {
 			expect( editor.model.document.getRoot( 'main' ) ).to.instanceof( RootElement );
 		} );
 
-		it( 'mixes DataInterface', () => {
-			expect( testUtils.isMixed( ClassicTestEditor, DataInterface ) ).to.true;
+		it( 'mixes DataApiMixin', () => {
+			expect( testUtils.isMixed( ClassicTestEditor, DataApiMixin ) ).to.true;
 		} );
 
-		it( 'mixes ElementInterface', () => {
-			expect( testUtils.isMixed( ClassicTestEditor, ElementInterface ) ).to.true;
+		it( 'mixes ElementApiMixin', () => {
+			expect( testUtils.isMixed( ClassicTestEditor, ElementApiMixin ) ).to.true;
 		} );
 	} );
 

+ 3 - 3
packages/ckeditor5-core/tests/_utils-tests/modeltesteditor.js

@@ -9,7 +9,7 @@ import ModelTestEditor from '../../tests/_utils/modeltesteditor';
 
 import Plugin from '../../src/plugin';
 import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
-import DataInterface from '../../src/editor/utils/datainterface';
+import DataApiMixin from '../../src/editor/utils/dataapimixin';
 import RootElement from '@ckeditor/ckeditor5-engine/src/model/rootelement';
 
 import { getData, setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
@@ -44,8 +44,8 @@ describe( 'ModelTestEditor', () => {
 			expect( editor.model.document.getRoot( 'main' ) ).to.instanceof( RootElement );
 		} );
 
-		it( 'mixes DataInterface', () => {
-			expect( testUtils.isMixed( ModelTestEditor, DataInterface ) ).to.true;
+		it( 'mixes DataApiMixin', () => {
+			expect( testUtils.isMixed( ModelTestEditor, DataApiMixin ) ).to.true;
 		} );
 	} );
 

+ 3 - 3
packages/ckeditor5-core/tests/_utils-tests/virtualtesteditor.js

@@ -8,7 +8,7 @@ import VirtualTestEditor from '../../tests/_utils/virtualtesteditor';
 
 import Plugin from '../../src/plugin';
 import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
-import DataInterface from '../../src/editor/utils/datainterface';
+import DataApiMixin from '../../src/editor/utils/dataapimixin';
 import RootElement from '@ckeditor/ckeditor5-engine/src/model/rootelement';
 
 import testUtils from '../../tests/_utils/utils';
@@ -31,8 +31,8 @@ describe( 'VirtualTestEditor', () => {
 			expect( editor.model.document.getRoot( 'main' ) ).to.instanceof( RootElement );
 		} );
 
-		it( 'mixes DataInterface', () => {
-			expect( testUtils.isMixed( VirtualTestEditor, DataInterface ) ).to.true;
+		it( 'mixes DataApiMixin', () => {
+			expect( testUtils.isMixed( VirtualTestEditor, DataApiMixin ) ).to.true;
 		} );
 	} );
 

+ 4 - 4
packages/ckeditor5-core/tests/_utils/classictesteditor.js

@@ -4,8 +4,8 @@
  */
 
 import Editor from '../../src/editor/editor';
-import ElementInterface from '../../src/editor/utils/elementinterface';
-import DataInterface from '../../src/editor/utils/datainterface';
+import ElementApiMixin from '../../src/editor/utils/elementapimixin';
+import DataApiMixin from '../../src/editor/utils/dataapimixin';
 import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
 import ClassicTestEditorUI from './classictesteditorui';
 import BoxedEditorUIView from '@ckeditor/ckeditor5-ui/src/editorui/boxed/boxededitoruiview';
@@ -82,5 +82,5 @@ export default class ClassicTestEditor extends Editor {
 	}
 }
 
-mix( ClassicTestEditor, DataInterface );
-mix( ClassicTestEditor, ElementInterface );
+mix( ClassicTestEditor, DataApiMixin );
+mix( ClassicTestEditor, ElementApiMixin );

+ 2 - 2
packages/ckeditor5-core/tests/_utils/modeltesteditor.js

@@ -4,7 +4,7 @@
  */
 
 import Editor from '../../src/editor/editor';
-import DataInterface from '../../src/editor/utils/datainterface';
+import DataApiMixin from '../../src/editor/utils/dataapimixin';
 import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 
@@ -53,4 +53,4 @@ export default class ModelTestEditor extends Editor {
 	}
 }
 
-mix( ModelTestEditor, DataInterface );
+mix( ModelTestEditor, DataApiMixin );

+ 2 - 2
packages/ckeditor5-core/tests/_utils/virtualtesteditor.js

@@ -4,7 +4,7 @@
  */
 
 import Editor from '../../src/editor/editor';
-import DataInterface from '../../src/editor/utils/datainterface';
+import DataApiMixin from '../../src/editor/utils/dataapimixin';
 import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 
@@ -50,4 +50,4 @@ export default class VirtualTestEditor extends Editor {
 	}
 }
 
-mix( VirtualTestEditor, DataInterface );
+mix( VirtualTestEditor, DataApiMixin );

+ 4 - 4
packages/ckeditor5-core/tests/editor/utils/attachtoform.js

@@ -4,7 +4,7 @@
  */
 
 import attachToForm from '../../../src/editor/utils/attachtoform';
-import ElementInterface from '../../../src/editor/utils/elementinterface';
+import ElementApiMixin from '../../../src/editor/utils/elementapimixin';
 import Editor from '../../../src/editor/editor';
 import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
@@ -28,7 +28,7 @@ describe( 'attachToForm()', () => {
 		} );
 
 		class CustomEditor extends Editor {}
-		mix( CustomEditor, ElementInterface );
+		mix( CustomEditor, ElementApiMixin );
 
 		editor = new CustomEditor();
 		editor.data.processor = new HtmlDataProcessor();
@@ -45,10 +45,10 @@ describe( 'attachToForm()', () => {
 		return editor.destroy();
 	} );
 
-	it( 'should throw an error when is used with editor without `ElementInterface`', () => {
+	it( 'should throw an error when is used with editor without `ElementApiMixin`', () => {
 		expect( () => {
 			attachToForm( new Editor() );
-		} ).to.throw( CKEditorError, /^attachtoform-missing-elementinterface/ );
+		} ).to.throw( CKEditorError, /^attachtoform-missing-elementapi-interface/ );
 	} );
 
 	it( 'should update editor#element after the "submit" event', () => {

+ 3 - 3
packages/ckeditor5-core/tests/editor/utils/datainterface.js

@@ -3,18 +3,18 @@
  * For licensing, see LICENSE.md.
  */
 
-import DataInterface from '../../../src/editor/utils/datainterface';
+import DataApiMixin from '../../../src/editor/utils/dataapimixin';
 import Editor from '../../../src/editor/editor';
 import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 import { getData, setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
-describe( 'DataInterface', () => {
+describe( 'DataApiMixin', () => {
 	let editor;
 
 	beforeEach( () => {
 		class CustomEditor extends Editor {}
-		mix( CustomEditor, DataInterface );
+		mix( CustomEditor, DataApiMixin );
 
 		editor = new CustomEditor();
 		editor.data.processor = new HtmlDataProcessor();

+ 3 - 7
packages/ckeditor5-core/tests/editor/utils/elementinterface.js

@@ -5,17 +5,17 @@
 
 /* global document */
 
-import ElementInterface from '../../../src/editor/utils/elementinterface';
+import ElementApiMixin from '../../../src/editor/utils/elementapimixin';
 import Editor from '../../../src/editor/editor';
 import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 
-describe( 'ElementInterface', () => {
+describe( 'ElementApiMixin', () => {
 	let editor;
 
 	beforeEach( () => {
 		class CustomEditor extends Editor {}
-		mix( CustomEditor, ElementInterface );
+		mix( CustomEditor, ElementApiMixin );
 
 		editor = new CustomEditor();
 		editor.data.processor = new HtmlDataProcessor();
@@ -27,10 +27,6 @@ describe( 'ElementInterface', () => {
 		editor.destroy();
 	} );
 
-	it( 'should add #element property to editor', () => {
-		expect( editor ).have.property( 'element', null );
-	} );
-
 	describe( 'loadDataFromElement()', () => {
 		it( 'should be added to editor interface', () => {
 			expect( editor ).have.property( 'loadDataFromElement' ).to.be.a( 'function' );