Procházet zdrojové kódy

Updated: Autoformat feature with InlineEngine (for tests).

Maksymilian Barnaś před 9 roky
rodič
revize
fdb1ae36c8
1 změnil soubory, kde provedl 13 přidání a 1 odebrání
  1. 13 1
      packages/ckeditor5-autoformat/src/autoformat.js

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

@@ -4,9 +4,11 @@
  */
 
 import AutoformatEngine from './autoformatengine.js';
+import InlineEngine from './inlineengine.js';
 import Feature from '../core/feature.js';
 import HeadingEngine from '../heading/headingengine.js';
 import ListEngine from '../list/listengine.js';
+import BoldEngine from '../basic-styles/boldengine.js';
 
 /**
  * Includes set of predefined Autoformatting actions:
@@ -22,7 +24,7 @@ export default class Autoformat extends Feature {
 	 * @inheritDoc
 	 */
 	static get requires() {
-		return [ HeadingEngine, ListEngine ];
+		return [ HeadingEngine, ListEngine, BoldEngine ];
 	}
 
 	/**
@@ -31,6 +33,7 @@ export default class Autoformat extends Feature {
 	init() {
 		this._addListAutoformats();
 		this._addHeadingAutoformats();
+		this._addInlineBold();
 	}
 
 	/**
@@ -72,4 +75,13 @@ export default class Autoformat extends Feature {
 			} );
 		} );
 	}
+
+	_addInlineBold() {
+		new InlineEngine( this.editor, /\*\*/, ( context ) => {
+			const { batch, range } = context;
+
+			batch.remove( range );
+			this.editor.execute( 'bold' );
+		} );
+	}
 }