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

Use more meaningful <softBreak> instand of <break>.

Piotrek Koszuliński 7 лет назад
Родитель
Сommit
d912507110

+ 3 - 3
packages/ckeditor5-enter/src/shiftenter.js

@@ -34,20 +34,20 @@ export default class ShiftEnter extends Plugin {
 		const viewDocument = view.document;
 		const viewDocument = view.document;
 
 
 		// Configure the schema.
 		// Configure the schema.
-		schema.register( 'break', {
+		schema.register( 'softBreak', {
 			allowWhere: '$text'
 			allowWhere: '$text'
 		} );
 		} );
 
 
 		// Configure converters.
 		// Configure converters.
 		conversion.for( 'upcast' )
 		conversion.for( 'upcast' )
 			.add( upcastElementToElement( {
 			.add( upcastElementToElement( {
-				model: 'break',
+				model: 'softBreak',
 				view: 'br'
 				view: 'br'
 			} ) );
 			} ) );
 
 
 		conversion.for( 'downcast' )
 		conversion.for( 'downcast' )
 			.add( downcastElementToElement( {
 			.add( downcastElementToElement( {
-				model: 'break',
+				model: 'softBreak',
 				view: ( modelElement, viewWriter ) => viewWriter.createEmptyElement( 'br' )
 				view: ( modelElement, viewWriter ) => viewWriter.createEmptyElement( 'br' )
 			} ) );
 			} ) );
 
 

+ 4 - 4
packages/ckeditor5-enter/src/shiftentercommand.js

@@ -5,8 +5,8 @@
 import Command from '@ckeditor/ckeditor5-core/src/command';
 import Command from '@ckeditor/ckeditor5-core/src/command';
 
 
 /**
 /**
- * ShiftEnter command. It is used by the {@link module:enter/shiftenter~ShiftEnter ShiftEnterfeature} to handle
- * the <kbd>Shift+Enter</kbd> key.
+ * ShiftEnter command. It is used by the {@link module:enter/shiftenter~ShiftEnter ShiftEnter feature} to handle
+ * the <kbd>Shift</kbd>+<kbd>Enter</kbd> keystroke.
  *
  *
  * @extends module:core/command~Command
  * @extends module:core/command~Command
  */
  */
@@ -44,7 +44,7 @@ function isEnabled( schema, selection ) {
 	const anchorPos = selection.anchor;
 	const anchorPos = selection.anchor;
 
 
 	// Check whether the break element can be inserted in the current selection anchor.
 	// Check whether the break element can be inserted in the current selection anchor.
-	if ( !anchorPos || !schema.checkChild( anchorPos, 'break' ) ) {
+	if ( !anchorPos || !schema.checkChild( anchorPos, 'softBreak' ) ) {
 		return false;
 		return false;
 	}
 	}
 
 
@@ -93,7 +93,7 @@ function softBreakAction( model, writer, selection ) {
 }
 }
 
 
 function insertBreak( writer, position ) {
 function insertBreak( writer, position ) {
-	const breakLineElement = writer.createElement( 'break' );
+	const breakLineElement = writer.createElement( 'softBreak' );
 
 
 	writer.insert( breakLineElement, position );
 	writer.insert( breakLineElement, position );
 	writer.setSelection( breakLineElement, 'after' );
 	writer.setSelection( breakLineElement, 'after' );

+ 1 - 1
packages/ckeditor5-enter/tests/shiftenter-integration.js

@@ -38,7 +38,7 @@ describe( 'ShiftEnter integration', () => {
 	it( 'loads correct data', () => {
 	it( 'loads correct data', () => {
 		const options = { withoutSelection: true };
 		const options = { withoutSelection: true };
 
 
-		expect( getModelData( model, options ) ).to.equal( '<paragraph>First line.<break></break>Second line.</paragraph>' );
+		expect( getModelData( model, options ) ).to.equal( '<paragraph>First line.<softBreak></softBreak>Second line.</paragraph>' );
 		expect( getViewData( editor.editing.view, options ) ).to.equal( '<p>First line.<br></br>Second line.</p>' );
 		expect( getViewData( editor.editing.view, options ) ).to.equal( '<p>First line.<br></br>Second line.</p>' );
 	} );
 	} );
 } );
 } );

+ 12 - 12
packages/ckeditor5-enter/tests/shiftentercommand.js

@@ -81,25 +81,25 @@ describe( 'ShiftEnterCommand', () => {
 			test(
 			test(
 				'inserts in the root',
 				'inserts in the root',
 				'foo[]bar',
 				'foo[]bar',
-				'foo<break></break>[]bar'
+				'foo<softBreak></softBreak>[]bar'
 			);
 			);
 
 
 			test(
 			test(
 				'inserts inside block',
 				'inserts inside block',
 				'<p>x</p><p>foo[]bar</p><p>y</p>',
 				'<p>x</p><p>foo[]bar</p><p>y</p>',
-				'<p>x</p><p>foo<break></break>[]bar</p><p>y</p>'
+				'<p>x</p><p>foo<softBreak></softBreak>[]bar</p><p>y</p>'
 			);
 			);
 
 
 			test(
 			test(
 				'inserts at the end of block',
 				'inserts at the end of block',
 				'<p>x</p><p>foo[]</p><p>y</p>',
 				'<p>x</p><p>foo[]</p><p>y</p>',
-				'<p>x</p><p>foo<break></break>[]</p><p>y</p>'
+				'<p>x</p><p>foo<softBreak></softBreak>[]</p><p>y</p>'
 			);
 			);
 
 
 			test(
 			test(
 				'inserts at the beginning of block',
 				'inserts at the beginning of block',
 				'<p>x</p><p>[]foo</p><p>y</p>',
 				'<p>x</p><p>[]foo</p><p>y</p>',
-				'<p>x</p><p><break></break>[]foo</p><p>y</p>'
+				'<p>x</p><p><softBreak></softBreak>[]foo</p><p>y</p>'
 			);
 			);
 		} );
 		} );
 
 
@@ -107,13 +107,13 @@ describe( 'ShiftEnterCommand', () => {
 			test(
 			test(
 				'deletes the content and inserts the break when directly in the root',
 				'deletes the content and inserts the break when directly in the root',
 				'fo[ob]ar',
 				'fo[ob]ar',
-				'fo<break></break>[]ar'
+				'fo<softBreak></softBreak>[]ar'
 			);
 			);
 
 
 			test(
 			test(
 				'deletes text and adds break',
 				'deletes text and adds break',
 				'<p>ab[cd]ef</p><p>ghi</p>',
 				'<p>ab[cd]ef</p><p>ghi</p>',
-				'<p>ab<break></break>[]ef</p><p>ghi</p>'
+				'<p>ab<softBreak></softBreak>[]ef</p><p>ghi</p>'
 			);
 			);
 
 
 			test(
 			test(
@@ -131,7 +131,7 @@ describe( 'ShiftEnterCommand', () => {
 			test(
 			test(
 				'inserts break in empty element after it was fully selected',
 				'inserts break in empty element after it was fully selected',
 				'<p>x</p><p>[abcdef]</p><p>y</p>',
 				'<p>x</p><p>[abcdef]</p><p>y</p>',
-				'<p>x</p><p><break></break>[]</p><p>y</p>'
+				'<p>x</p><p><softBreak></softBreak>[]</p><p>y</p>'
 			);
 			);
 
 
 			test(
 			test(
@@ -143,25 +143,25 @@ describe( 'ShiftEnterCommand', () => {
 			test(
 			test(
 				'should insert the break in inline limit element - collapsed',
 				'should insert the break in inline limit element - collapsed',
 				'<p><inlineLimit>foo[]bar</inlineLimit></p>',
 				'<p><inlineLimit>foo[]bar</inlineLimit></p>',
-				'<p><inlineLimit>foo<break></break>[]bar</inlineLimit></p>'
+				'<p><inlineLimit>foo<softBreak></softBreak>[]bar</inlineLimit></p>'
 			);
 			);
 
 
 			test(
 			test(
 				'should insert the break in inline limit elements',
 				'should insert the break in inline limit elements',
 				'<p><inlineLimit>foo[bar]baz</inlineLimit></p>',
 				'<p><inlineLimit>foo[bar]baz</inlineLimit></p>',
-				'<p><inlineLimit>foo<break></break>[]baz</inlineLimit></p>'
+				'<p><inlineLimit>foo<softBreak></softBreak>[]baz</inlineLimit></p>'
 			);
 			);
 
 
 			test(
 			test(
 				'should insert the break at beginning of the inline limit elements',
 				'should insert the break at beginning of the inline limit elements',
 				'<p><inlineLimit>foo[bar]baz</inlineLimit></p>',
 				'<p><inlineLimit>foo[bar]baz</inlineLimit></p>',
-				'<p><inlineLimit>foo<break></break>[]baz</inlineLimit></p>'
+				'<p><inlineLimit>foo<softBreak></softBreak>[]baz</inlineLimit></p>'
 			);
 			);
 
 
 			test(
 			test(
 				'should insert the break at ending of the inline limit elements',
 				'should insert the break at ending of the inline limit elements',
 				'<p><inlineLimit>foobaz[]</inlineLimit></p>',
 				'<p><inlineLimit>foobaz[]</inlineLimit></p>',
-				'<p><inlineLimit>foobaz<break></break>[]</inlineLimit></p>'
+				'<p><inlineLimit>foobaz<softBreak></softBreak>[]</inlineLimit></p>'
 			);
 			);
 
 
 			test(
 			test(
@@ -173,7 +173,7 @@ describe( 'ShiftEnterCommand', () => {
 			test(
 			test(
 				'should break paragraph in blockLimit',
 				'should break paragraph in blockLimit',
 				'<blockLimit><p>foo[]bar</p></blockLimit>',
 				'<blockLimit><p>foo[]bar</p></blockLimit>',
-				'<blockLimit><p>foo<break></break>[]bar</p></blockLimit>'
+				'<blockLimit><p>foo<softBreak></softBreak>[]bar</p></blockLimit>'
 			);
 			);
 
 
 			test(
 			test(