Sfoglia il codice sorgente

Fixed: regular expression.

Maksymilian Barnaś 9 anni fa
parent
commit
66192e5143

+ 5 - 5
packages/ckeditor5-autoformat/src/autoformat.js

@@ -77,7 +77,7 @@ export default class Autoformat extends Feature {
 	}
 
 	_addBoldAutoformats() {
-		// `Bold` autoformat.
+		// Bold autoformat.
 		new InlineAutoformatEngine(
 			this.editor,
 			( text ) => {
@@ -112,7 +112,7 @@ export default class Autoformat extends Feature {
 			}
 		);
 
-		// `Italic` autoformat.
+		// Italic autoformat.
 		new InlineAutoformatEngine(
 			this.editor,
 			( text ) => {
@@ -123,9 +123,9 @@ export default class Autoformat extends Feature {
 				// 	[2]: '*fox*',
 				// 	[index]: 5
 				//
-				// Value at index 1 is a "prefix". It can be empty, if the matched word is at the beginning of the line.
-				// Length of this match is used to calculate `start` index.
-				const pattern = /([^\*]|^)(\*[^\*].+?[^\*]\*)(?![^\*]|$)/g;
+				// Value at index 1 is a "prefix". It can be empty, if the matched word is at the
+				// beginning of the line. Length of the prefix is used to calculate `start` index.
+				const pattern = /([^\*]|^)(\*[^\*].+?[^\*]\*)(?:[^\*]|$)/g;
 
 				let result;
 				let remove = [];

+ 1 - 1
packages/ckeditor5-autoformat/src/inlineautoformatengine.js

@@ -26,7 +26,7 @@ export default class InlineAutoformatEngine {
 			const block = editor.document.selection.focus.parent;
 			const text = getText( block );
 
-			if ( block.name !== 'paragraph' ) {
+			if ( block.name !== 'paragraph' || !text ) {
 				return;
 			}