/** * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ /** * @module restricted-editing/restrictededitingexceptionediting */ import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; import RestrictedEditingExceptionCommand from './restrictededitingexceptioncommand'; /** * @extends module:core/plugin~Plugin */ export default class RestrictedEditingExceptionEditing extends Plugin { /** * @inheritDoc */ static get pluginName() { return 'RestrictedEditingExceptionEditing'; } /** * @inheritDoc */ init() { const editor = this.editor; editor.model.schema.extend( '$text', { allowAttributes: [ 'restrictedEditingException' ] } ); editor.conversion.for( 'upcast' ).elementToAttribute( { model: 'restrictedEditingException', view: { name: 'span', classes: 'ck-restricted-editing-exception' } } ); editor.conversion.for( 'downcast' ).attributeToElement( { model: 'restrictedEditingException', view: ( modelAttributeValue, viewWriter ) => { if ( modelAttributeValue ) { // Make the restricted editing outer-most in the view. return viewWriter.createAttributeElement( 'span', { class: 'ck-restricted-editing-exception' }, { priority: -10 } ); } } } ); editor.commands.add( 'restrictedEditingException', new RestrictedEditingExceptionCommand( editor ) ); } }