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

AutoLink should work without Enter or ShiftEnter.

Maciej Gołaszewski 5 лет назад
Родитель
Сommit
a591093ad9

+ 8 - 0
packages/ckeditor5-link/src/autolink.js

@@ -140,6 +140,10 @@ export default class AutoLink extends Plugin {
 		const model = editor.model;
 		const enterCommand = editor.commands.get( 'enter' );
 
+		if ( !enterCommand ) {
+			return;
+		}
+
 		enterCommand.on( 'execute', () => {
 			const position = model.document.selection.getFirstPosition();
 
@@ -163,6 +167,10 @@ export default class AutoLink extends Plugin {
 
 		const shiftEnterCommand = editor.commands.get( 'shiftEnter' );
 
+		if ( !shiftEnterCommand ) {
+			return;
+		}
+
 		shiftEnterCommand.on( 'execute', () => {
 			const position = model.document.selection.getFirstPosition();
 

+ 8 - 0
packages/ckeditor5-link/tests/autolink.js

@@ -22,6 +22,14 @@ describe( 'AutoLink', () => {
 		expect( AutoLink.pluginName ).to.equal( 'AutoLink' );
 	} );
 
+	it( 'should be loaded without Enter & ShiftEnter features', async () => {
+		const editor = await ModelTestEditor.create( {
+			plugins: [ Paragraph, Input, LinkEditing, AutoLink ]
+		} );
+
+		await editor.destroy();
+	} );
+
 	describe( 'auto link behavior', () => {
 		let model;