| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- /**
- * @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 InlineCreator from '/tests/ckeditor5/creator/manual/_utils/creator/inlinecreator.js';
- import testUtils from '/tests/utils/_utils/utils.js';
- let editor, editable, observer;
- function initEditor() {
- CKEDITOR.create( '#editor', {
- creator: InlineCreator,
- toolbar: [ 'bold', 'italic' ]
- } )
- .then( ( newEditor ) => {
- console.log( 'Editor was initialized', newEditor );
- console.log( 'You can now play with it using global `editor` and `editable` variable.' );
- 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 );
|