Selaa lähdekoodia

Merge pull request #139 from ckeditor/t/ckeditor5/1005

Feature: Imported the module providing the `CKEDITOR_VERSION` global constant in the `Editor` class (see ckeditor/ckeditor5#1005).
Piotrek Koszuliński 7 vuotta sitten
vanhempi
sitoutus
179387f567

+ 3 - 1
packages/ckeditor5-core/src/editor/editor.js

@@ -20,6 +20,8 @@ import EditingKeystrokeHandler from '../editingkeystrokehandler';
 import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 
+import '@ckeditor/ckeditor5-utils/src/version';
+
 /**
  * Class representing a basic, generic editor.
  *
@@ -109,7 +111,7 @@ export default class Editor {
 		 *
 		 * The editor is in one of the following states:
 		 *
-		 * * `initializing` - during the editor initialization (before {@link module:core/editor/editor~Editor.create `Editor.create()`)
+		 * * `initializing` - during the editor initialization (before {@link module:core/editor/editor~Editor.create `Editor.create()`})
 		 * finished its job,
 		 * * `ready` - after the promise returned by the {@link module:core/editor/editor~Editor.create `Editor.create()`}
 		 * method is resolved,

+ 5 - 1
packages/ckeditor5-core/tests/editor/editor.js

@@ -3,7 +3,7 @@
  * For licensing, see LICENSE.md.
  */
 
-/* globals setTimeout */
+/* globals window, setTimeout */
 
 import Editor from '../../src/editor/editor';
 import Plugin from '../../src/plugin';
@@ -99,6 +99,10 @@ describe( 'Editor', () => {
 		delete Editor.build;
 	} );
 
+	it( 'imports the version helper', () => {
+		expect( window.CKEDITOR_VERSION ).to.be.a( 'string' );
+	} );
+
 	describe( 'constructor()', () => {
 		it( 'should create a new editor instance', () => {
 			const editor = new Editor();

+ 7 - 0
packages/ckeditor5-core/tests/manual/version-collision.html

@@ -0,0 +1,7 @@
+<script>
+	window.CKEDITOR_VERSION = 'the.colliding.version';
+</script>
+
+<div id="editor">
+	<p>Foo</p>
+</div>

+ 24 - 0
packages/ckeditor5-core/tests/manual/version-collision.js

@@ -0,0 +1,24 @@
+/**
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* globals console, window, document */
+
+import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
+import ArticlePluginSet from '../_utils/articlepluginset';
+
+ClassicEditor
+	.create( document.querySelector( '#editor' ), {
+		plugins: [ ArticlePluginSet ],
+		toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ],
+		image: {
+			toolbar: [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ]
+		}
+	} )
+	.then( editor => {
+		window.editor = editor;
+	} )
+	.catch( err => {
+		console.error( err.stack );
+	} );

+ 3 - 0
packages/ckeditor5-core/tests/manual/version-collision.md

@@ -0,0 +1,3 @@
+# The editor version collision
+
+**Expected**: Running this manual test **must** result in the `ckeditor-version-collision` error in the console. The error is a safeguard against duplicated/invalid editor builds.