1.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 console, window, document */
  6. import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
  7. import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
  8. ClassicEditor
  9. .create( document.querySelector( '#editor' ), {
  10. plugins: [ ArticlePluginSet ],
  11. toolbar: {
  12. items: [
  13. 'heading',
  14. 'bold',
  15. 'italic',
  16. 'link',
  17. 'bulletedList',
  18. 'numberedList',
  19. 'blockQuote',
  20. 'undo',
  21. 'redo'
  22. ]
  23. },
  24. image: {
  25. toolbar: [
  26. 'imageStyle:full',
  27. 'imageStyle:side',
  28. '|',
  29. 'imageTextAlternative'
  30. ]
  31. }
  32. } )
  33. .then( editor => {
  34. window.editor = editor;
  35. const schema = editor.model.schema;
  36. schema.addAttributeCheck( ( ctx, attributeName ) => {
  37. if ( ctx.endsWith( 'heading1 $text' ) && [ 'linkHref', 'italic' ].includes( attributeName ) ) {
  38. return false;
  39. }
  40. if ( ctx.endsWith( 'heading2 $text' ) && attributeName == 'italic' ) {
  41. return false;
  42. }
  43. if ( ctx.endsWith( 'heading2 $text' ) && attributeName == 'italic' ) {
  44. return false;
  45. }
  46. if ( ctx.endsWith( 'blockQuote listItem $text' ) && attributeName == 'linkHref' ) {
  47. return false;
  48. }
  49. if ( ctx.endsWith( 'paragraph $text' ) && attributeName == 'bold' ) {
  50. return false;
  51. }
  52. } );
  53. schema.addChildCheck( ( ctx, childDef ) => {
  54. if ( ctx.endsWith( '$root' ) && childDef.name == 'heading3' ) {
  55. return false;
  56. }
  57. } );
  58. } )
  59. .catch( err => {
  60. console.error( err.stack );
  61. } );