8
0
Просмотр исходного кода

Merge branch 'master' into t/ckeditor5/488

Szymon Cofalik 8 лет назад
Родитель
Сommit
70d3308359

+ 13 - 10
packages/ckeditor5-basic-styles/src/bold/boldediting.js

@@ -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 BOLD = 'bold';
@@ -32,14 +30,19 @@ export default class BoldEditing extends Plugin {
 		editor.model.schema.extend( '$text', { allowAttributes: BOLD } );
 
 		// Build converter from model to view for data and editing pipelines.
-		editor.conversion.for( 'downcast' )
-			.add( downcastAttributeToElement( BOLD, { view: 'strong' } ) );
-
-		// Build converter from view to model for data pipeline.
-		editor.conversion.for( 'upcast' )
-			.add( upcastElementToAttribute( { view: 'b', model: BOLD } ) )
-			.add( upcastElementToAttribute( { view: 'strong', model: BOLD } ) )
-			.add( upcastElementToAttribute( { view: { style: { 'font-weight': 'bold' } }, model: BOLD } ) );
+
+		editor.conversion.attributeToElement( {
+			model: BOLD,
+			view: 'strong',
+			upcastAlso: [
+				'b',
+				{
+					style: {
+						'font-weight': 'bold'
+					}
+				}
+			]
+		} );
 
 		// Create bold command.
 		editor.commands.add( BOLD, new AttributeCommand( editor, BOLD ) );

+ 9 - 10
packages/ckeditor5-basic-styles/src/code/codeediting.js

@@ -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 CODE = 'code';
@@ -32,14 +30,15 @@ export default class CodeEditing extends Plugin {
 		// Allow code attribute on text nodes.
 		editor.model.schema.extend( '$text', { allowAttributes: CODE } );
 
-		// Build converter from model to view for data and editing pipelines.
-		editor.conversion.for( 'downcast' )
-			.add( downcastAttributeToElement( CODE, { view: 'code' } ) );
-
-		// Build converter from view to model for data pipeline.
-		editor.conversion.for( 'upcast' )
-			.add( upcastElementToAttribute( { view: 'code', model: CODE } ) )
-			.add( upcastElementToAttribute( { view: { style: { 'word-wrap': 'break-word' } }, model: CODE } ) );
+		editor.conversion.attributeToElement( {
+			model: CODE,
+			view: 'code',
+			upcastAlso: {
+				style: {
+					'word-wrap': 'break-word'
+				}
+			}
+		} );
 
 		// Create code command.
 		editor.commands.add( CODE, new AttributeCommand( editor, CODE ) );

+ 12 - 11
packages/ckeditor5-basic-styles/src/italic/italicediting.js

@@ -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 ITALIC = 'italic';
@@ -32,15 +30,18 @@ export default class ItalicEditing extends Plugin {
 		// Allow italic attribute on text nodes.
 		editor.model.schema.extend( '$text', { allowAttributes: ITALIC } );
 
-		// Build converter from model to view for data and editing pipelines.
-		editor.conversion.for( 'downcast' )
-			.add( downcastAttributeToElement( ITALIC, { view: 'i' } ) );
-
-		// Build converter from view to model for data pipeline.
-		editor.conversion.for( 'upcast' )
-			.add( upcastElementToAttribute( { view: 'em', model: ITALIC } ) )
-			.add( upcastElementToAttribute( { view: 'i', model: ITALIC } ) )
-			.add( upcastElementToAttribute( { view: { style: { 'font-style': 'italic' } }, model: ITALIC } ) );
+		editor.conversion.attributeToElement( {
+			model: ITALIC,
+			view: 'i',
+			upcastAlso: [
+				'em',
+				{
+					style: {
+						'font-style': 'italic'
+					}
+				}
+			]
+		} );
 
 		// Create italic command.
 		editor.commands.add( ITALIC, new AttributeCommand( editor, ITALIC ) );

+ 13 - 12
packages/ckeditor5-basic-styles/src/strikethrough/strikethroughediting.js

@@ -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 ) );

+ 9 - 10
packages/ckeditor5-basic-styles/src/underline/underlineediting.js

@@ -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 UNDERLINE = 'underline';
@@ -32,14 +30,15 @@ export default class UnderlineEditing extends Plugin {
 		// Allow strikethrough attribute on text nodes.
 		editor.model.schema.extend( '$text', { allowAttributes: UNDERLINE } );
 
-		// Build converter from model to view for data and editing pipelines.
-		editor.conversion.for( 'downcast' )
-			.add( downcastAttributeToElement( UNDERLINE, { view: 'u' } ) );
-
-		// Build converter from view to model for data pipeline.
-		editor.conversion.for( 'upcast' )
-			.add( upcastElementToAttribute( { view: 'u', model: UNDERLINE } ) )
-			.add( upcastElementToAttribute( { view: { style: { 'text-decoration': 'underline' } }, model: UNDERLINE } ) );
+		editor.conversion.attributeToElement( {
+			model: UNDERLINE,
+			view: 'u',
+			upcastAlso: {
+				style: {
+					'text-decoration': 'underline'
+				}
+			}
+		} );
 
 		// Create underline command.
 		editor.commands.add( UNDERLINE, new AttributeCommand( editor, UNDERLINE ) );

+ 1 - 1
packages/ckeditor5-basic-styles/theme/icons/bold.svg

@@ -1 +1 @@
-<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.967 16.819H6.71c-.614 0-1.053-.138-1.316-.413C5.131 16.13 5 15.692 5 15.09V4.62c0-.615.135-1.057.404-1.326.269-.269.704-.404 1.306-.404h4.513c.665 0 1.242.042 1.73.124.487.082.924.24 1.31.475a3.44 3.44 0 0 1 1.454 1.743c.133.365.2.75.2 1.155 0 1.393-.697 2.413-2.09 3.06 1.83.582 2.745 1.716 2.745 3.4 0 .78-.2 1.481-.598 2.105a3.592 3.592 0 0 1-1.615 1.382 5.743 5.743 0 0 1-1.464.376 14.91 14.91 0 0 1-1.928.109zm-.21-6.185H7.823V14.7h3.03c1.907 0 2.86-.687 2.86-2.061 0-.704-.247-1.213-.74-1.53-.495-.317-1.233-.475-2.214-.475zM7.823 5.009V8.61h2.584c.703 0 1.246-.066 1.63-.2.383-.132.676-.386.878-.76.159-.266.238-.563.238-.893 0-.703-.25-1.17-.75-1.401-.501-.231-1.264-.347-2.29-.347h-2.29z" fill="#464646" fill-rule="evenodd"/></svg>
+<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg"><path d="M10.187 17H5.773c-.637 0-1.092-.138-1.364-.415-.273-.277-.409-.718-.409-1.323V4.738c0-.617.14-1.062.419-1.332.279-.27.73-.406 1.354-.406h4.68c.69 0 1.288.041 1.793.124.506.083.96.242 1.36.478.341.197.644.447.906.75a3.262 3.262 0 0 1 .808 2.162c0 1.401-.722 2.426-2.167 3.075C15.05 10.175 16 11.315 16 13.01a3.756 3.756 0 0 1-2.296 3.504 6.1 6.1 0 0 1-1.517.377c-.571.073-1.238.11-2 .11zm-.217-6.217H7v4.087h3.069c1.977 0 2.965-.69 2.965-2.072 0-.707-.256-1.22-.768-1.537-.512-.319-1.277-.478-2.296-.478zM7 5.13v3.619h2.606c.729 0 1.292-.067 1.69-.2a1.6 1.6 0 0 0 .91-.765c.165-.267.247-.566.247-.897 0-.707-.26-1.176-.778-1.409-.519-.232-1.31-.348-2.375-.348H7z" fill="#000" fill-rule="evenodd"/></svg>