| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- /**
- * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
- /**
- * @module enter/enter
- */
- import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
- import EnterCommand from './entercommand';
- import EnterObserver from './enterobserver';
- /**
- * The Enter feature. Handles the <kbd>Enter</kbd> and <kbd>Shift + Enter</kbd> keys in the editor.
- *
- * @extends module:core/plugin~Plugin
- */
- export default class Enter extends Plugin {
- /**
- * @inheritDoc
- */
- static get pluginName() {
- return 'Enter';
- }
- init() {
- const editor = this.editor;
- const view = editor.editing.view;
- const viewDocument = view.document;
- view.addObserver( EnterObserver );
- editor.commands.add( 'enter', new EnterCommand( editor ) );
- // TODO We may use the keystroke handler for that.
- this.listenTo( viewDocument, 'enter', ( evt, data ) => {
- editor.execute( 'enter' );
- data.preventDefault();
- view.scrollToTheSelection();
- }, { priority: 'low' } );
- }
- }
|