8
0

restricteddocumentediting.js 948 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. /**
  6. * @module core/restricteddocumentediting
  7. */
  8. import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
  9. import RestrictedDocumentCommand from './restricteddocumentcommand';
  10. /**
  11. * @extends module:core/plugin~Plugin
  12. */
  13. export default class RestrictedDocumentEditing extends Plugin {
  14. /**
  15. * @inheritDoc
  16. */
  17. static get pluginName() {
  18. return 'RestrictedDocumentEditing';
  19. }
  20. /**
  21. * @inheritDoc
  22. */
  23. init() {
  24. const editor = this.editor;
  25. editor.model.schema.extend( '$text', { allowAttributes: [ 'nonRestricted' ] } );
  26. editor.conversion.attributeToElement( {
  27. model: 'nonRestricted',
  28. view: {
  29. name: 'span',
  30. classes: 'ck-non-restricted'
  31. }
  32. } );
  33. editor.commands.add( 'nonRestricted', new RestrictedDocumentCommand( editor ) );
  34. }
  35. }