8
0

protocol.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. /* globals console:false, window, document */
  6. import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
  7. import Enter from '@ckeditor/ckeditor5-enter/src/enter';
  8. import Typing from '@ckeditor/ckeditor5-typing/src/typing';
  9. import Link from '../../src/link';
  10. import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  11. import Undo from '@ckeditor/ckeditor5-undo/src/undo';
  12. import Superscript from '@ckeditor/ckeditor5-basic-styles/src/superscript';
  13. createEditorWithDefaultProtocol( '#editor0' );
  14. createEditorWithDefaultProtocol( '#editor1', 'http://' );
  15. createEditorWithDefaultProtocol( '#editor2', 'https://' );
  16. createEditorWithDefaultProtocol( '#editor3', 'mailto:' );
  17. function createEditorWithDefaultProtocol( editor, defaultProtocol ) {
  18. return ClassicEditor
  19. .create( document.querySelector( editor ), {
  20. plugins: [ Link, Typing, Paragraph, Undo, Enter, Superscript ],
  21. toolbar: [ 'link', 'undo', 'redo' ],
  22. link: {
  23. addTargetToExternalLinks: true,
  24. ...defaultProtocol && { defaultProtocol }
  25. }
  26. } )
  27. .then( editor => {
  28. window.editor = editor;
  29. } )
  30. .catch( err => {
  31. console.error( err.stack );
  32. } );
  33. }