{"payload":{"allShortcutsEnabled":false,"fileTree":{"src/editor":{"items":[{"name":"utils","path":"src/editor/utils","contentType":"directory"},{"name":"editor.js","path":"src/editor/editor.js","contentType":"file"},{"name":"editorconfig.jsdoc","path":"src/editor/editorconfig.jsdoc","contentType":"file"},{"name":"editorui.js","path":"src/editor/editorui.js","contentType":"file"},{"name":"editorwithui.jsdoc","path":"src/editor/editorwithui.jsdoc","contentType":"file"}],"totalCount":5},"src":{"items":[{"name":"editor","path":"src/editor","contentType":"directory"},{"name":"command.js","path":"src/command.js","contentType":"file"},{"name":"commandcollection.js","path":"src/commandcollection.js","contentType":"file"},{"name":"editingkeystrokehandler.js","path":"src/editingkeystrokehandler.js","contentType":"file"},{"name":"multicommand.js","path":"src/multicommand.js","contentType":"file"},{"name":"pendingactions.js","path":"src/pendingactions.js","contentType":"file"},{"name":"plugin.js","path":"src/plugin.js","contentType":"file"},{"name":"plugincollection.js","path":"src/plugincollection.js","contentType":"file"}],"totalCount":8},"":{"items":[{"name":".github","path":".github","contentType":"directory"},{"name":"docs","path":"docs","contentType":"directory"},{"name":"lang","path":"lang","contentType":"directory"},{"name":"src","path":"src","contentType":"directory"},{"name":"tests","path":"tests","contentType":"directory"},{"name":"theme","path":"theme","contentType":"directory"},{"name":".editorconfig","path":".editorconfig","contentType":"file"},{"name":".eslintrc.js","path":".eslintrc.js","contentType":"file"},{"name":".gitattributes","path":".gitattributes","contentType":"file"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".stylelintrc","path":".stylelintrc","contentType":"file"},{"name":".travis.yml","path":".travis.yml","contentType":"file"},{"name":"CHANGELOG.md","path":"CHANGELOG.md","contentType":"file"},{"name":"CONTRIBUTING.md","path":"CONTRIBUTING.md","contentType":"file"},{"name":"LICENSE.md","path":"LICENSE.md","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"package.json","path":"package.json","contentType":"file"}],"totalCount":17}},"fileTreeProcessingTime":12.07537,"foldersToFetch":[],"repo":{"id":64463708,"defaultBranch":"master","name":"ckeditor5-core","ownerLogin":"ckeditor","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2016-07-29T08:18:21.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/825710?v=4","public":true,"private":false,"isOrgOwned":true},"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"1443cb6402123c5321a4145d03649e410feb903b","listCacheKey":"v0:1588365837.0","canEdit":false,"refType":"tree","currentOid":"1443cb6402123c5321a4145d03649e410feb903b"},"path":"src/editor/editor.js","currentUser":null,"blob":{"rawLines":["/**"," * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved."," * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license"," */","","/**"," * @module core/editor/editor"," */","","import Config from '@ckeditor/ckeditor5-utils/src/config';","import EditingController from '@ckeditor/ckeditor5-engine/src/controller/editingcontroller';","import PluginCollection from '../plugincollection';","import CommandCollection from '../commandcollection';","import Locale from '@ckeditor/ckeditor5-utils/src/locale';","import DataController from '@ckeditor/ckeditor5-engine/src/controller/datacontroller';","import Conversion from '@ckeditor/ckeditor5-engine/src/conversion/conversion';","import Model from '@ckeditor/ckeditor5-engine/src/model/model';","import EditingKeystrokeHandler from '../editingkeystrokehandler';","","import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';","import mix from '@ckeditor/ckeditor5-utils/src/mix';","import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';","","/**"," * Class representing a basic, generic editor."," *"," * Check out the list of its subclasses to learn about specific editor implementations."," *"," * All editor implementations (like {@link module:editor-classic/classiceditor~ClassicEditor} or"," * {@link module:editor-inline/inlineeditor~InlineEditor}) should extend this class. They can add their"," * own methods and properties."," *"," * When you are implementing a plugin, then this editor represents the API"," * which your plugin can expect to get when using its {@link module:core/plugin~Plugin#editor} property."," *"," * This API should be sufficient in order to implement the \"editing\" part of your feature"," * (schema definition, conversion, commands, keystrokes, etc.)."," * It does not define the editor UI, which is available only if the"," * the specific editor implements also the {@link module:core/editor/editorwithui~EditorWithUI} interface"," * (as most editor implementations do)."," *"," * @abstract"," * @mixes module:utils/observablemixin~ObservableMixin"," */","export default class Editor {","\t/**","\t * Creates a new instance of the Editor class.","\t *","\t * Usually, not to be used directly. See the static {@link module:core/editor/editor~Editor.create `create()`} method.","\t *","\t * @param {Object} [config] The editor config.","\t */","\tconstructor( config ) {","\t\tconst availablePlugins = this.constructor.builtinPlugins;","","\t\t/**","\t\t * Holds all configurations specific to this editor instance.","\t\t *","\t\t *\t\teditor.config.get( 'image.toolbar' );","\t\t *\t\t// -> [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ]","\t\t *","\t\t * @readonly","\t\t * @member {module:utils/config~Config}","\t\t */","\t\tthis.config = new Config( config, this.constructor.defaultConfig );","","\t\tthis.config.define( 'plugins', availablePlugins );","","\t\t/**","\t\t * The plugins loaded and in use by this editor instance.","\t\t *","\t\t *\t\teditor.plugins.get( 'Clipboard' ); // -> instance of the Clipboard plugin.","\t\t *","\t\t * @readonly","\t\t * @member {module:core/plugincollection~PluginCollection}","\t\t */","\t\tthis.plugins = new PluginCollection( this, availablePlugins );","","\t\t/**","\t\t * Commands registered to the editor.","\t\t *","\t\t * Use the shorthand {@link #execute `editor.execute()`} method to execute commands:","\t\t *","\t\t *\t\t// Execute the bold command:","\t\t *\t\teditor.execute( 'bold' );","\t\t *","\t\t *\t\t// Check the state of the bold command:","\t\t *\t\teditor.commands.get( 'bold' ).value;","\t\t *","\t\t * @readonly","\t\t * @member {module:core/commandcollection~CommandCollection}","\t\t */","\t\tthis.commands = new CommandCollection();","","\t\tconst languageConfig = this.config.get( 'language' ) || {};","","\t\t/**","\t\t * @readonly","\t\t * @member {module:utils/locale~Locale}","\t\t */","\t\tthis.locale = new Locale( {","\t\t\tuiLanguage: typeof languageConfig === 'string' ? languageConfig : languageConfig.ui,","\t\t\tcontentLanguage: this.config.get( 'language.content' )","\t\t} );","","\t\t/**","\t\t * Shorthand for {@link module:utils/locale~Locale#t}.","\t\t *","\t\t * @see module:utils/locale~Locale#t","\t\t * @method #t","\t\t */","\t\tthis.t = this.locale.t;","","\t\t/**","\t\t * Indicates the editor life-cycle state.","\t\t *","\t\t * The editor is in one of the following states:","\t\t *","\t\t * * `initializing` - during the editor initialization (before {@link module:core/editor/editor~Editor.create `Editor.create()`})","\t\t * finished its job,","\t\t * * `ready` - after the promise returned by the {@link module:core/editor/editor~Editor.create `Editor.create()`}","\t\t * method is resolved,","\t\t * * `destroyed` - once the {@link #destroy `editor.destroy()`} method was called.","\t\t *","\t\t * @observable","\t\t * @member {'initializing'|'ready'|'destroyed'} #state","\t\t */","\t\tthis.set( 'state', 'initializing' );","\t\tthis.once( 'ready', () => ( this.state = 'ready' ), { priority: 'high' } );","\t\tthis.once( 'destroy', () => ( this.state = 'destroyed' ), { priority: 'high' } );","","\t\t/**","\t\t * Defines whether this editor is in read-only mode.","\t\t *","\t\t * In read-only mode the editor {@link #commands commands} are disabled so it is not possible","\t\t * to modify the document by using them. Also, the editable element(s) become non-editable.","\t\t *","\t\t * In order to make the editor read-only, you can set this value directly:","\t\t *","\t\t *\t\teditor.isReadOnly = true;","\t\t *","\t\t * @observable","\t\t * @member {Boolean} #isReadOnly","\t\t */","\t\tthis.set( 'isReadOnly', false );","","\t\t/**","\t\t * The editor's model.","\t\t *","\t\t * The central point of the editor's abstract data model.","\t\t *","\t\t * @readonly","\t\t * @member {module:engine/model/model~Model}","\t\t */","\t\tthis.model = new Model();","","\t\t/**","\t\t * The {@link module:engine/controller/datacontroller~DataController data controller}.","\t\t * Used e.g. for setting and retrieving editor data.","\t\t *","\t\t * @readonly","\t\t * @member {module:engine/controller/datacontroller~DataController}","\t\t */","\t\tthis.data = new DataController( this.model );","","\t\t/**","\t\t * The {@link module:engine/controller/editingcontroller~EditingController editing controller}.","\t\t * Controls user input and rendering the content for editing.","\t\t *","\t\t * @readonly","\t\t * @member {module:engine/controller/editingcontroller~EditingController}","\t\t */","\t\tthis.editing = new EditingController( this.model );","\t\tthis.editing.view.document.bind( 'isReadOnly' ).to( this );","","\t\t/**","\t\t * Conversion manager through which you can register model to view and view to model converters.","\t\t *","\t\t * See {@link module:engine/conversion/conversion~Conversion}'s documentation to learn how to add converters.","\t\t *","\t\t * @readonly","\t\t * @member {module:engine/conversion/conversion~Conversion}","\t\t */","\t\tthis.conversion = new Conversion( [ this.editing.downcastDispatcher, this.data.downcastDispatcher ], this.data.upcastDispatcher );","\t\tthis.conversion.addAlias( 'dataDowncast', this.data.downcastDispatcher );","\t\tthis.conversion.addAlias( 'editingDowncast', this.editing.downcastDispatcher );","","\t\t/**","\t\t * Instance of the {@link module:core/editingkeystrokehandler~EditingKeystrokeHandler}.","\t\t *","\t\t * It allows setting simple keystrokes:","\t\t *","\t\t *\t\t// Execute the bold command on Ctrl+E:","\t\t *\t\teditor.keystrokes.set( 'Ctrl+E', 'bold' );","\t\t *","\t\t *\t\t// Execute your own callback:","\t\t *\t\teditor.keystrokes.set( 'Ctrl+E', ( data, cancel ) => {","\t\t *\t\t\tconsole.log( data.keyCode );","\t\t *","\t\t *\t\t\t// Prevent default (native) action and stop the underlying keydown event","\t\t *\t\t\t// so no other editor feature will interfere.","\t\t *\t\t\tcancel();","\t\t *\t\t} );","\t\t *","\t\t * Note: Certain, typing oriented keystrokes (like Backspace or Enter) are handled","\t\t * by low level mechanism and trying to listen to them via the keystroke handler will not work reliably.","\t\t * To handle those specific keystrokes see the events fired by the","\t\t * {@link module:engine/view/document~Document editing view document} (`editor.editing.view.document`).","\t\t *","\t\t * @readonly","\t\t * @member {module:core/editingkeystrokehandler~EditingKeystrokeHandler}","\t\t */","\t\tthis.keystrokes = new EditingKeystrokeHandler( this );","\t\tthis.keystrokes.listenTo( this.editing.view.document );","\t}","","\t/**","\t * Loads and initializes plugins specified in the config.","\t *","\t * @returns {Promise.} A promise which resolves","\t * once the initialization is completed providing an array of loaded plugins.","\t */","\tinitPlugins() {","\t\tconst config = this.config;","\t\tconst plugins = config.get( 'plugins' ) || [];","\t\tconst removePlugins = config.get( 'removePlugins' ) || [];","\t\tconst extraPlugins = config.get( 'extraPlugins' ) || [];","","\t\treturn this.plugins.init( plugins.concat( extraPlugins ), removePlugins );","\t}","","\t/**","\t * Destroys the editor instance, releasing all resources used by it.","\t *","\t * **Note** The editor cannot be destroyed during the initialization phase so if it is called","\t * while the editor {@link #state is being initialized}, it will wait for the editor initialization before destroying it.","\t *","\t * @fires destroy","\t * @returns {Promise} A promise that resolves once the editor instance is fully destroyed.","\t */","\tdestroy() {","\t\tlet readyPromise = Promise.resolve();","","\t\tif ( this.state == 'initializing' ) {","\t\t\treadyPromise = new Promise( resolve => this.once( 'ready', resolve ) );","\t\t}","","\t\treturn readyPromise","\t\t\t.then( () => {","\t\t\t\tthis.fire( 'destroy' );","\t\t\t\tthis.stopListening();","\t\t\t\tthis.commands.destroy();","\t\t\t} )","\t\t\t.then( () => this.plugins.destroy() )","\t\t\t.then( () => {","\t\t\t\tthis.model.destroy();","\t\t\t\tthis.data.destroy();","\t\t\t\tthis.editing.destroy();","\t\t\t\tthis.keystrokes.destroy();","\t\t\t} );","\t}","","\t/**","\t * Executes specified command with given parameters.","\t *","\t * Shorthand for:","\t *","\t *\t\teditor.commands.get( commandName ).execute( ... );","\t *","\t * @param {String} commandName Name of command to execute.","\t * @param {*} [...commandParams] Command parameters.","\t */","\texecute( ...args ) {","\t\ttry {","\t\t\tthis.commands.execute( ...args );","\t\t} catch ( err ) {","\t\t\t// @if CK_DEBUG // throw err;","\t\t\t/* istanbul ignore next */","\t\t\tCKEditorError.rethrowUnexpectedError( err, this );","\t\t}","\t}","","\t/**","\t * Creates and initializes a new editor instance.","\t *","\t * This is an abstract method. Every editor type needs to implement its own initialization logic.","\t *","\t * See the `create()` methods of the existing editor types to learn how to use them:","\t *","\t * * {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`}","\t * * {@link module:editor-balloon/ballooneditor~BalloonEditor.create `BalloonEditor.create()`}","\t * * {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`}","\t * * {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`}","\t *","\t * @abstract","\t * @method module:core/editor/editor~Editor.create","\t */","}","","mix( Editor, ObservableMixin );","","/**"," * Fired when {@link module:engine/controller/datacontroller~DataController#event:ready data} and all additional"," * editor components are ready."," *"," * Note: This event is most useful for plugin developers. When integrating the editor with your website or"," * application you do not have to listen to `editor#ready` because when the promise returned by the static"," * {@link module:core/editor/editor~Editor.create `Editor.create()`} event is resolved, the editor is already ready."," * In fact, since the first moment when the editor instance is available to you is inside `then()`'s callback,"," * you cannot even add a listener to the `editor#ready` event."," *"," * See also the {@link #state `editor.state`} property."," *"," * @event ready"," */","","/**"," * Fired when this editor instance is destroyed. The editor at this point is not usable and this event should be used to"," * perform the clean-up in any plugin."," *"," *"," * See also the {@link #state `editor.state`} property."," *"," * @event destroy"," */","","/**"," * This error is thrown when a user tries to use a `