ckfinder.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* globals console, window, document */
  6. import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
  7. import CKFinder from '../../src/ckfinder';
  8. import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
  9. import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud-services-config';
  10. ClassicEditor
  11. .create( document.querySelector( '#editor' ), {
  12. cloudServices: CS_CONFIG,
  13. plugins: [ ArticlePluginSet, CKFinder ],
  14. toolbar: [ 'heading', '|', 'undo', 'redo', 'ckfinder' ],
  15. image: {
  16. toolbar: [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ]
  17. },
  18. ckfinder: {
  19. // openerMethod: 'popup'
  20. }
  21. } )
  22. .then( editor => {
  23. window.editor = editor;
  24. const button = document.querySelector( '#opener-method' );
  25. const label = document.querySelector( '#opener-method-label' );
  26. button.addEventListener( 'click', () => {
  27. const method = editor.config.get( 'ckfinder.openerMethod' );
  28. const isPopup = method === 'popup';
  29. const newMethod = isPopup ? 'modal' : 'popup';
  30. editor.config.set( 'ckfinder.openerMethod', newMethod );
  31. button.innerText = 'Switch to ' + ( isPopup ? 'popup' : 'modal' );
  32. label.innerText = newMethod;
  33. } );
  34. } )
  35. .catch( err => {
  36. console.error( err.stack );
  37. } );