Bläddra i källkod

Updated existing mock creator tests to the new API. Renamed ClassicCreator to LegacyCreator to avoid confusion.

Aleksander Nowodzinski 9 år sedan
förälder
incheckning
dfe55c2c22

+ 0 - 38
tests/_utils/ui/boxededitorui/boxededitorui.js

@@ -1,38 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-import EditorUI from '/ckeditor5/ui/editorui/editorui.js';
-import ControllerCollection from '/ckeditor5/ui/controllercollection.js';
-
-export default class BoxedEditorUI extends EditorUI {
-	constructor( editor ) {
-		super( editor );
-
-		this.collections.add( new ControllerCollection( 'top' ) );
-		this.collections.add( new ControllerCollection( 'editable' ) );
-
-		const config = editor.config;
-
-		/**
-		 * @property {Number} width
-		 */
-		this.set( 'width', config.get( 'ui.width' ) );
-
-		/**
-		 * @property {Number} height
-		 */
-		this.set( 'height', config.get( 'ui.height' ) );
-	}
-
-	/**
-	 * @readonly
-	 * @property {Model} viewModel
-	 */
-	get viewModel() {
-		return this;
-	}
-}

+ 0 - 40
tests/_utils/ui/boxededitorui/boxededitoruiview.js

@@ -1,40 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-import EditorUIView from '/ckeditor5/ui/editorui/editoruiview.js';
-
-export default class BoxedEditorUIView extends EditorUIView {
-	constructor( model, locale ) {
-		super( model, locale );
-
-		this.template = {
-			tag: 'div',
-
-			attributes: {
-				class: 'ck-reset ck-editor'
-			},
-
-			children: [
-				{
-					tag: 'div',
-					attributes: {
-						class: 'ck-editor-top ck-reset-all'
-					}
-				},
-				{
-					tag: 'div',
-					attributes: {
-						class: 'ck-editor-editable'
-					}
-				}
-			]
-		};
-
-		this.register( 'top', '.ck-editor-top' );
-		this.register( 'editable', '.ck-editor-editable' );
-	}
-}

+ 0 - 39
tests/_utils/ui/editableui/inline/inlineeditableuiview.js

@@ -1,39 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-import EditableUIView from '/ckeditor5/ui/editableui/editableuiview.js';
-
-export default class InlineEditableView extends EditableUIView {
-	constructor( model, locale, editableElement ) {
-		super( model, locale );
-
-		if ( editableElement ) {
-			this.element = editableElement;
-		} else {
-			const bind = this.attributeBinder;
-
-			this.template = {
-				tag: 'div',
-				attributes: {
-					contentEditable: bind.to( 'isEditable' )
-				}
-			};
-		}
-	}
-
-	init() {
-		this.setEditableElement( this.element );
-
-		super.init();
-	}
-
-	destroy() {
-		super.destroy();
-
-		this.editableElement.contentEditable = false;
-	}
-}

+ 3 - 2
tests/creator/manual/_utils/creator/inlinecreator.js

@@ -15,11 +15,12 @@ import { createEditableUI, createEditorUI } from '/ckeditor5/ui/creator-utils.js
 import EditorUIView from '/ckeditor5/ui/editorui/editoruiview.js';
 import BoxlessEditorUI from '/tests/ckeditor5/_utils/ui/boxlesseditorui/boxlesseditorui.js';
 import EditableUI from '/ckeditor5/ui/editableui/editableui.js';
-import InlineEditableUIView from '/tests/ckeditor5/_utils/ui/editableui/inline/inlineeditableuiview.js';
+import InlineEditableUIView from '/ckeditor5/ui/editableui/inline/inlineeditableuiview.js';
 import Model from '/ckeditor5/ui/model.js';
 import FloatingToolbar from '/tests/ckeditor5/_utils/ui/floatingtoolbar/floatingtoolbar.js';
 import FloatingToolbarView from '/tests/ckeditor5/_utils/ui/floatingtoolbar/floatingtoolbarview.js';
-import { imitateFeatures, imitateDestroyFeatures } from '../imitatefeatures.js';
+
+import { imitateFeatures, imitateDestroyFeatures } from '/ckeditor5/creator-classic/utils/imitatefeatures.js';
 
 export default class InlineCreator extends StandardCreator {
 	constructor( editor ) {

+ 5 - 5
tests/creator/manual/_utils/creator/classiccreator.js → tests/creator/manual/_utils/creator/legacycreator.js

@@ -12,17 +12,17 @@ import Editable from '/ckeditor5/editable.js';
 
 import { createEditableUI, createEditorUI } from '/ckeditor5/ui/creator-utils.js';
 
-import BoxedEditorUI from '/tests/ckeditor5/_utils/ui/boxededitorui/boxededitorui.js';
-import BoxedEditorUIView from '/tests/ckeditor5/_utils/ui/boxededitorui/boxededitoruiview.js';
+import BoxedEditorUI from '/ckeditor5/ui/boxededitorui/boxededitorui.js';
+import BoxedEditorUIView from '/ckeditor5/ui/boxededitorui/boxededitoruiview.js';
 import FramedEditableUI from '/tests/ckeditor5/_utils/ui/editableui/framed/framededitableui.js';
 import FramedEditableUIView from '/tests/ckeditor5/_utils/ui/editableui/framed/framededitableuiview.js';
 import Model from '/ckeditor5/ui/model.js';
 import Toolbar from '/ckeditor5/ui/bindings/toolbar.js';
 import ToolbarView from '/ckeditor5/ui/toolbar/toolbarview.js';
 
-import { imitateFeatures, imitateDestroyFeatures } from '../imitatefeatures.js';
+import { imitateFeatures, imitateDestroyFeatures } from '/ckeditor5/creator-classic/utils/imitatefeatures.js';
 
-export default class ClassicCreator extends StandardCreator {
+export default class LegacyCreator extends StandardCreator {
 	constructor( editor ) {
 		super( editor, new HtmlDataProcessor() );
 
@@ -47,7 +47,7 @@ export default class ClassicCreator extends StandardCreator {
 		// UI.
 		this._replaceElement( editor.firstElement, editor.ui.view.element );
 		this._createToolbar();
-		editor.ui.add( 'editable', createEditableUI( editor, editable, FramedEditableUI, FramedEditableUIView ) );
+		editor.ui.add( 'main', createEditableUI( editor, editable, FramedEditableUI, FramedEditableUIView ) );
 
 		// Init.
 		return super.create()

+ 6 - 5
tests/creator/manual/_utils/creator/multicreator.js

@@ -12,14 +12,15 @@ import Editable from '/ckeditor5/editable.js';
 
 import { createEditableUI, createEditorUI } from '/ckeditor5/ui/creator-utils.js';
 
-import BoxedEditorUI from '/tests/ckeditor5/_utils/ui/boxededitorui/boxededitorui.js';
-import BoxedEditorUIView from '/tests/ckeditor5/_utils/ui/boxededitorui/boxededitoruiview.js';
+import BoxedEditorUI from '/ckeditor5/ui/boxededitorui/boxededitorui.js';
+import BoxedEditorUIView from '/ckeditor5/ui/boxededitorui/boxededitoruiview.js';
 import EditableUI from '/ckeditor5/ui/editableui/editableui.js';
-import InlineEditableUIView from '/tests/ckeditor5/_utils/ui/editableui/inline/inlineeditableuiview.js';
+import InlineEditableUIView from '/ckeditor5/ui/editableui/inline/inlineeditableuiview.js';
 import Model from '/ckeditor5/ui/model.js';
 import Toolbar from '/ckeditor5/ui/bindings/toolbar.js';
 import ToolbarView from '/ckeditor5/ui/toolbar/toolbarview.js';
-import { imitateFeatures, imitateDestroyFeatures } from '../imitatefeatures.js';
+
+import { imitateFeatures, imitateDestroyFeatures } from '/ckeditor5/creator-classic/utils/imitatefeatures.js';
 
 export default class MultiCreator extends StandardCreator {
 	constructor( editor ) {
@@ -45,7 +46,7 @@ export default class MultiCreator extends StandardCreator {
 		this._createToolbar();
 
 		for ( let editable of editor.editables ) {
-			editor.ui.add( 'editable', createEditableUI( editor, editable, EditableUI, InlineEditableUIView ) );
+			editor.ui.add( 'main', createEditableUI( editor, editable, EditableUI, InlineEditableUIView ) );
 		}
 
 		editor.elements.forEach( ( element ) => {

+ 0 - 59
tests/creator/manual/_utils/imitatefeatures.js

@@ -1,59 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-import Model from '/ckeditor5/ui/model.js';
-import Button from '/ckeditor5/ui/button/button.js';
-import ButtonView from '/ckeditor5/ui/button/buttonview.js';
-
-/**
- * Immitates that some features were loaded and did their job.
- *
- * @param {ckeditor5.Editor} editor
- */
-export function imitateFeatures( editor ) {
-	const t = editor.t;
-
-	const boldModel = new Model( {
-		isEnabled: true,
-		isOn: false,
-		label: t( 'Bold' ),
-		icon: 'bold'
-	} );
-
-	boldModel.on( 'execute', () => {
-		/* global console */
-		console.log( 'bold executed' );
-
-		boldModel.isOn = !boldModel.isOn;
-	} );
-
-	editor.ui.featureComponents.add( 'bold', Button, ButtonView, boldModel );
-
-	const italicModel = new Model( {
-		isEnabled: true,
-		isOn: false,
-		label: t( 'Italic' ),
-		icon: 'italic'
-	} );
-
-	italicModel.on( 'execute', () => {
-		/* global console */
-		console.log( 'italic executed' );
-
-		italicModel.isOn = !italicModel.isOn;
-	} );
-
-	editor.ui.featureComponents.add( 'italic', Button, ButtonView, italicModel );
-
-	window.boldModel = boldModel;
-	window.italicModel = italicModel;
-}
-
-export function imitateDestroyFeatures() {
-	delete window.boldModel;
-	delete window.italicModel;
-}

+ 0 - 0
tests/creator/manual/creator-classic.html → tests/creator/manual/creator-legacy.html


+ 4 - 2
tests/creator/manual/creator-classic.js → tests/creator/manual/creator-legacy.js

@@ -8,14 +8,14 @@
 'use strict';
 
 import CKEDITOR from '/ckeditor.js';
-import ClassicCreator from '/tests/ckeditor5/creator/manual/_utils/creator/classiccreator.js';
+import LegacyCreator from '/tests/ckeditor5/creator/manual/_utils/creator/classiccreator.js';
 import testUtils from '/tests/utils/_utils/utils.js';
 
 let editor, editable, observer;
 
 function initEditor() {
 	CKEDITOR.create( '#editor', {
-		creator: ClassicCreator,
+		creator: LegacyCreator,
 		ui: {
 			width: 400,
 			height: 400
@@ -29,6 +29,8 @@ function initEditor() {
 		window.editor = editor = newEditor;
 		window.editable = editable = editor.editables.get( 0 );
 
+		console.log( window.editor, editor );
+
 		observer = testUtils.createObserver();
 		observer.observe( 'Editable', editable );
 	} );

+ 0 - 0
tests/creator/manual/creator-classic.md → tests/creator/manual/creator-legacy.md