paste-from-office.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. /* globals ClassicEditor, console, window, document, ListStyle */
  6. import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud-services-config';
  7. ClassicEditor
  8. .create( document.querySelector( '#snippet-paste-from-office' ), {
  9. extraPlugins: [ ListStyle ],
  10. toolbar: {
  11. items: [
  12. 'heading',
  13. '|',
  14. 'fontSize',
  15. 'fontFamily',
  16. 'fontColor',
  17. 'fontBackgroundColor',
  18. '|',
  19. 'bold',
  20. 'italic',
  21. 'underline',
  22. 'strikethrough',
  23. '|',
  24. 'alignment',
  25. '|',
  26. 'numberedList',
  27. 'bulletedList',
  28. '|',
  29. 'indent',
  30. 'outdent',
  31. '|',
  32. 'link',
  33. 'imageUpload',
  34. 'insertTable',
  35. 'horizontalLine',
  36. '|',
  37. 'undo',
  38. 'redo'
  39. ],
  40. viewportTopOffset: window.getViewportTopOffsetConfig()
  41. },
  42. image: {
  43. styles: [
  44. 'full',
  45. 'alignLeft',
  46. 'alignRight'
  47. ],
  48. toolbar: [
  49. 'imageStyle:alignLeft',
  50. 'imageStyle:full',
  51. 'imageStyle:alignRight',
  52. '|',
  53. 'imageTextAlternative'
  54. ]
  55. },
  56. table: {
  57. contentToolbar: [
  58. 'tableColumn',
  59. 'tableRow',
  60. 'mergeTableCells',
  61. 'tableProperties',
  62. 'tableCellProperties'
  63. ]
  64. },
  65. fontFamily: {
  66. supportAllValues: true
  67. },
  68. fontSize: {
  69. options: [ 10, 12, 14, 'default', 18, 20, 22 ],
  70. supportAllValues: true
  71. },
  72. placeholder: 'Paste the content here to test the feature.',
  73. cloudServices: CS_CONFIG
  74. } )
  75. .then( editor => {
  76. window.editor = editor;
  77. // Prevent showing a warning notification when user is pasting a content from MS Word or Google Docs.
  78. window.preventPasteFromOfficeNotification = true;
  79. } )
  80. .catch( err => {
  81. console.error( err.stack );
  82. } );