linkdecorator.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  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 Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard';
  13. import { getData as getModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  14. ClassicEditor
  15. .create( document.querySelector( '#editor' ), {
  16. plugins: [ Link, Typing, Paragraph, Clipboard, Undo, Enter ],
  17. toolbar: [ 'link', 'undo', 'redo' ],
  18. link: {
  19. decorators: [
  20. {
  21. mode: 'manual',
  22. label: 'Open in new window',
  23. attributes: {
  24. target: '_blank',
  25. rel: 'noopener noreferrer'
  26. }
  27. },
  28. {
  29. mode: 'manual',
  30. label: 'downloadable',
  31. attributes: {
  32. download: 'download'
  33. }
  34. },
  35. {
  36. mode: 'manual',
  37. label: 'gallery',
  38. attributes: {
  39. class: 'gallery'
  40. }
  41. }
  42. ]
  43. }
  44. } )
  45. .then( editor => {
  46. window.getModelData = getModelData;
  47. window.editor = editor;
  48. window.model = editor.model;
  49. } )
  50. .catch( err => {
  51. console.error( err.stack );
  52. } );