|
|
@@ -8,8 +8,6 @@
|
|
|
*/
|
|
|
|
|
|
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
|
|
|
-import { downcastAttributeToElement } from '@ckeditor/ckeditor5-engine/src/conversion/downcast-converters';
|
|
|
-import { upcastElementToAttribute } from '@ckeditor/ckeditor5-engine/src/conversion/upcast-converters';
|
|
|
import AttributeCommand from '../attributecommand';
|
|
|
|
|
|
const STRIKETHROUGH = 'strikethrough';
|
|
|
@@ -33,16 +31,19 @@ export default class StrikethroughEditing extends Plugin {
|
|
|
// Allow strikethrough attribute on text nodes.
|
|
|
editor.model.schema.extend( '$text', { allowAttributes: STRIKETHROUGH } );
|
|
|
|
|
|
- // Build converter from model to view for data and editing pipelines.
|
|
|
- editor.conversion.for( 'downcast' )
|
|
|
- .add( downcastAttributeToElement( STRIKETHROUGH, { view: 's' } ) );
|
|
|
-
|
|
|
- // Build converter from view to model for data pipeline.
|
|
|
- editor.conversion.for( 'upcast' )
|
|
|
- .add( upcastElementToAttribute( { view: 's', model: STRIKETHROUGH } ) )
|
|
|
- .add( upcastElementToAttribute( { view: 'del', model: STRIKETHROUGH } ) )
|
|
|
- .add( upcastElementToAttribute( { view: 'strike', model: STRIKETHROUGH } ) )
|
|
|
- .add( upcastElementToAttribute( { view: { style: { 'text-decoration': 'line-through' } }, model: STRIKETHROUGH } ) );
|
|
|
+ editor.conversion.attributeToElement( {
|
|
|
+ model: STRIKETHROUGH,
|
|
|
+ view: 's',
|
|
|
+ upcastAlso: [
|
|
|
+ 'del',
|
|
|
+ 'strike',
|
|
|
+ {
|
|
|
+ style: {
|
|
|
+ 'text-decoration': 'line-through'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ } );
|
|
|
|
|
|
// Create strikethrough command.
|
|
|
editor.commands.add( STRIKETHROUGH, new AttributeCommand( editor, STRIKETHROUGH ) );
|