wordcount.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /* globals console, window, document */
  6. import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
  7. import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
  8. import WordCount from '../../src/wordcount';
  9. ClassicEditor
  10. .create( document.querySelector( '#editor' ), {
  11. plugins: [ ArticlePluginSet, WordCount ],
  12. toolbar: [
  13. 'heading', 'bold', 'italic', 'bulletedList', 'numberedList', 'blockQuote', 'link', 'undo', 'redo'
  14. ],
  15. wordCount: {
  16. onUpdate: values => {
  17. console.log( `Values from 'onUpdate': ${ JSON.stringify( values ) }` );
  18. },
  19. container: document.getElementById( 'other-words-container' )
  20. }
  21. } )
  22. .then( editor => {
  23. window.editor = editor;
  24. document.getElementById( 'destroy-editor' ).addEventListener( 'click', () => {
  25. editor.destroy();
  26. } );
  27. } )
  28. .catch( err => {
  29. console.error( err.stack );
  30. } );