Kaynağa Gözat

Added MT test for ClassicCreator.

Aleksander Nowodzinski 9 yıl önce
ebeveyn
işleme
3f171d0152

+ 17 - 0
packages/ckeditor5-editor-classic/tests/classiccreator.html

@@ -0,0 +1,17 @@
+<head>
+	<link rel="stylesheet" href="%APPS_DIR%ckeditor/build/amd/theme/ckeditor.css">
+</head>
+
+<p>
+	<button id="destroyEditor">Destroy editor</button>
+	<button id="initEditor">Init editor</button>
+</p>
+
+<div id="editor">
+	<h1>Hello world!</h1>
+	<p>This is an editor instance.</p>
+</div>
+
+<div style="height: 1500px; width: 1500px; background: #eee; outline: 2px dashed #ddd; margin: 1em 0; padding: 1em;">
+	* I'm a dummy div to enable scrolling in this test. *
+</div>

+ 49 - 0
packages/ckeditor5-editor-classic/tests/classiccreator.js

@@ -0,0 +1,49 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* global console:false */
+
+'use strict';
+
+import CKEDITOR from '/ckeditor.js';
+import ClassicCreator from '/ckeditor5/creator-classic/classiccreator.js';
+import testUtils from '/tests/utils/_utils/utils.js';
+
+let editor, editable, observer;
+
+function initEditor() {
+	CKEDITOR.create( '#editor', {
+		creator: ClassicCreator,
+		toolbar: [ 'bold', 'italic' ]
+	} )
+	.then( ( newEditor ) => {
+		console.log( 'Editor was initialized', newEditor );
+		console.log( 'You can now play with it using global `editor` and `editable` variables.' );
+
+		window.editor = editor = newEditor;
+		window.editable = editable = editor.editables.get( 0 );
+
+		observer = testUtils.createObserver();
+		observer.observe( 'Editable', editable );
+	} );
+}
+
+function destroyEditor() {
+	editor.destroy()
+		.then( () => {
+			window.editor = editor = null;
+			window.editable = editable = null;
+
+			observer.stopListening();
+			observer = null;
+
+			console.log( 'Editor was destroyed' );
+		} );
+}
+
+document.getElementById( 'initEditor' ).addEventListener( 'click', initEditor );
+document.getElementById( 'destroyEditor' ).addEventListener( 'click', destroyEditor );
+
+initEditor();

+ 3 - 0
packages/ckeditor5-editor-classic/tests/classiccreator.md

@@ -0,0 +1,3 @@
+@bender-ui: collapsed
+
+1. Click "Init editor".