Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

T/ckeditor5/1005: Imported the module providing the CKEDITOR_VERSION global constant in the Editor class #139

Merged
merged 7 commits into from
Jul 10, 2018
4 changes: 3 additions & 1 deletion src/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion tests/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions tests/manual/version-collision.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
window.CKEDITOR_VERSION = 'the.colliding.version';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make this test more realistic. For instance, load 2 editor builds.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't do that in a manual test.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's fine for me, then.

</script>

<div id="editor">
<p>Foo</p>
</div>
24 changes: 24 additions & 0 deletions tests/manual/version-collision.js
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 0 deletions tests/manual/version-collision.md
Original file line number Diff line number Diff line change
@@ -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.