two-step-caret.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /* global console, document */
  6. import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
  7. import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';
  8. import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  9. import Underline from '@ckeditor/ckeditor5-basic-styles/src/underline';
  10. import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
  11. import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
  12. import TwoStepCaretMovement from '../../src/twostepcaretmovement';
  13. ClassicEditor
  14. .create( document.querySelector( '#editor-ltr' ), {
  15. plugins: [ Essentials, Paragraph, Underline, Bold, Italic, TwoStepCaretMovement ],
  16. toolbar: [ 'undo', 'redo', '|', 'bold', 'underline', 'italic' ]
  17. } )
  18. .then( editor => {
  19. const twoStepCaretMovement = editor.plugins.get( TwoStepCaretMovement );
  20. twoStepCaretMovement.registerAttribute( 'italic' );
  21. twoStepCaretMovement.registerAttribute( 'underline' );
  22. } )
  23. .catch( err => {
  24. console.error( err.stack );
  25. } );
  26. ClassicEditor
  27. .create( document.querySelector( '#editor-rtl' ), {
  28. language: {
  29. content: 'he'
  30. },
  31. plugins: [ Essentials, Paragraph, Underline, Bold, Italic, TwoStepCaretMovement ],
  32. toolbar: [ 'undo', 'redo', '|', 'bold', 'underline', 'italic' ]
  33. } )
  34. .then( editor => {
  35. const twoStepCaretMovement = editor.plugins.get( TwoStepCaretMovement );
  36. twoStepCaretMovement.registerAttribute( 'italic' );
  37. twoStepCaretMovement.registerAttribute( 'underline' );
  38. } )
  39. .catch( err => {
  40. console.error( err.stack );
  41. } );