8
0

imageresizeui.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 document, console, window */
  6. import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
  7. import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
  8. import Indent from '@ckeditor/ckeditor5-indent/src/indent';
  9. import IndentBlock from '@ckeditor/ckeditor5-indent/src/indentblock';
  10. import EasyImage from '@ckeditor/ckeditor5-easy-image/src/easyimage';
  11. import ImageResize from '../../src/imageresize';
  12. import ImageResizeEditing from '../../src/imageresize/imageresizeediting';
  13. import ImageResizeUI from '../../src/imageresize/imageresizeui';
  14. import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud-services-config';
  15. const commonConfig = {
  16. plugins: [
  17. ArticlePluginSet,
  18. ImageResize,
  19. Indent,
  20. IndentBlock,
  21. EasyImage
  22. ],
  23. toolbar: [ 'heading', '|', 'bold', 'italic', 'link',
  24. 'bulletedList', 'numberedList', 'blockQuote', 'insertTable', 'undo', 'redo', 'outdent', 'indent' ],
  25. table: {
  26. contentToolbar: [ 'tableColumn', 'tableRow', 'mergeTableCells' ],
  27. tableToolbar: [ 'bold', 'italic' ]
  28. },
  29. cloudServices: CS_CONFIG
  30. };
  31. // Editor 1
  32. const imageConfig1 = {
  33. resizeUnit: '%',
  34. resizeOptions: [
  35. {
  36. name: 'imageResize:original',
  37. value: null
  38. },
  39. {
  40. name: 'imageResize:50',
  41. value: '50'
  42. },
  43. {
  44. name: 'imageResize:75',
  45. value: '75'
  46. }
  47. ],
  48. toolbar: [ 'imageStyle:alignLeft', 'imageStyle:full', 'imageStyle:side', '|', 'imageResize' ],
  49. styles: [
  50. 'full',
  51. 'alignLeft',
  52. 'side' // Purposely using side image instead right aligned image to make sure it works well with both style types.
  53. ]
  54. };
  55. const config1 = {
  56. ...commonConfig,
  57. plugins: [
  58. ArticlePluginSet,
  59. Indent,
  60. IndentBlock,
  61. EasyImage,
  62. ImageResizeEditing,
  63. ImageResizeUI
  64. ],
  65. image: imageConfig1
  66. };
  67. ClassicEditor
  68. .create( document.querySelector( '#editor1' ), config1 )
  69. .then( editor => {
  70. window.editor1 = editor;
  71. } )
  72. .catch( err => {
  73. console.error( err.stack );
  74. } );
  75. // Editor 2
  76. const imageConfig2 = {
  77. resizeUnit: '%',
  78. resizeOptions: [
  79. {
  80. name: 'imageResize:original',
  81. value: null,
  82. icon: 'original'
  83. },
  84. {
  85. name: 'imageResize:50',
  86. value: '50',
  87. icon: 'medium'
  88. },
  89. {
  90. name: 'imageResize:75',
  91. value: '75',
  92. icon: 'large'
  93. }
  94. ],
  95. toolbar: [
  96. 'imageStyle:alignLeft',
  97. 'imageStyle:full',
  98. 'imageStyle:side', '|',
  99. 'imageResize:50',
  100. 'imageResize:75',
  101. 'imageResize:original'
  102. ],
  103. disableResizeHandles: true,
  104. styles: [
  105. 'full',
  106. 'alignLeft',
  107. 'side' // Purposely using side image instead right aligned image to make sure it works well with both style types.
  108. ]
  109. };
  110. const config2 = {
  111. ...commonConfig,
  112. image: imageConfig2
  113. };
  114. ClassicEditor
  115. .create( document.querySelector( '#editor2' ), config2 )
  116. .then( editor => {
  117. window.editor2 = editor;
  118. } )
  119. .catch( err => {
  120. console.error( err.stack );
  121. } );