8
0

imageresizeui.js 2.6 KB

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