input.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /**
  6. * @module typing/input
  7. */
  8. import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
  9. import InputCommand from './inputcommand';
  10. import injectUnsafeKeystrokesHandling from './utils/injectunsafekeystrokeshandling';
  11. import injectTypingMutationsHandling from './utils/injecttypingmutationshandling';
  12. /**
  13. * Handles text input coming from the keyboard or other input methods.
  14. *
  15. * @extends module:core/plugin~Plugin
  16. */
  17. export default class Input extends Plugin {
  18. /**
  19. * @inheritDoc
  20. */
  21. static get pluginName() {
  22. return 'Input';
  23. }
  24. /**
  25. * @inheritDoc
  26. */
  27. init() {
  28. const editor = this.editor;
  29. // TODO The above default configuration value should be defined using editor.config.define() once it's fixed.
  30. const inputCommand = new InputCommand( editor, editor.config.get( 'typing.undoStep' ) || 20 );
  31. editor.commands.add( 'input', inputCommand );
  32. injectUnsafeKeystrokesHandling( editor );
  33. injectTypingMutationsHandling( editor );
  34. }
  35. }