/** * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ /** * @module utils/version */ /* globals window, global */ import CKEditorError from './ckeditorerror'; const version = '19.0.0'; /* istanbul ignore next */ const windowOrGlobal = typeof window === 'object' ? window : global; /* istanbul ignore next */ if ( windowOrGlobal.CKEDITOR_VERSION ) { /** * This error is thrown when due to a mistake in how CKEditor 5 was installed or initialized, some * of its modules were duplicated (evaluated and executed twice). Module duplication leads to inevitable runtime * errors. * * There are many situations in which some modules can be loaded twice. In the worst case scenario, * you may need to check your project for each of these issues and fix them all. * * # Trying to add a plugin to an existing build * * If you import an existing CKEditor 5 build and a plugin like this: * * import ClassicEditor from '@ckeditor/ckeditor5-build-classic'; * import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight'; * * Then your project loads some CKEditor 5 packages twice. How does it happen? * * The build package contains a file which is already compiled with webpack. This means * that it contains all the necessary code from e.g. `@ckeditor/ckeditor5-engine` and `@ckeditor/ckeditor5-utils`. * * However, the `Highlight` plugin imports some of the modules from these packages, too. If you ask webpack to * build such a project, you will end up with the modules being included (and run) twice — first, because they are * included inside the build package, and second, because they are required by the `Highlight` plugin. * * Therefore, **you must never add plugins to an existing build** unless your plugin has no dependencies. * * Adding plugins to a build is done by taking the source version of this build (so, before it was built with webpack) * and adding plugins there. In this situation, webpack will know that it only needs to load each plugin once. * * Read more in the {@glink builds/guides/integration/installing-plugins "Installing plugins"} guide. * * # Confused an editor build with an editor implementation * * This scenario is very similar to the previous one, but has a different origin. * * Let's assume that you wanted to use CKEditor 5 from source, as explained in the * {@glink builds/guides/integration/advanced-setup#scenario-2-building-from-source "Building from source"} section * or in the {@glink framework/guides/quick-start "Quick start"} guide of CKEditor 5 Framework. * * The correct way to do so is to import an editor and plugins and run them together like this: * * import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'; * import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials'; * import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; * import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold'; * import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic'; * * ClassicEditor * .create( document.querySelector( '#editor' ), { * plugins: [ Essentials, Paragraph, Bold, Italic ], * toolbar: [ 'bold', 'italic' ] * } ) * .then( editor => { * console.log( 'Editor was initialized', editor ); * } ) * .catch( error => { * console.error( error.stack ); * } ); * * However, you might have mistakenly imported a build instead of the source `ClassicEditor`. In this case * your imports will look like this: * * import ClassicEditor from '@ckeditor/ckeditor5-build-classic'; * import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials'; * import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; * import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold'; * import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic'; * * This creates the same situation as in the previous section because you use a build together with source plugins. * * Remember: `@ckeditor/ckeditor5-build-*` packages contain editor builds and `@ckeditor/ckeditor5-editor-*` contain source editors. * * # Loading two or more builds on one page * * If you use CKEditor 5 builds, you might have loaded two (or more) `ckeditor.js` files on one web page. * Check your web page for duplicated `