Jelajahi Sumber

Used the ckeditor5/namespace module in the base Editor class to check for possible build version collisions and broken builds.

Aleksander Nowodzinski 7 tahun lalu
induk
melakukan
845d838875

+ 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 'ckeditor5/src/namespace';
+
 /**
  * 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,

+ 3 - 0
packages/ckeditor5-core/tests/manual/article.html

@@ -1,3 +1,6 @@
+<script>
+	window.CKEDITOR_VERSION = 'foo';
+</script>
 <div id="editor">
 	<h2>Heading 1</h2>
 	<p>Paragraph</p>

+ 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 thrown in the console. The error is a safeguard against duplicated/invalid editor builds.