Преглед изворни кода

Added Code Block functionality to the Autoformat docs and tests.

Aleksander Nowodzinski пре 6 година
родитељ
комит
6933db1a41

+ 2 - 1
packages/ckeditor5-autoformat/docs/_snippets/features/autoformat.js

@@ -7,11 +7,12 @@
 
 import ClassicEditor from '@ckeditor/ckeditor5-build-classic/src/ckeditor';
 import Code from '@ckeditor/ckeditor5-basic-styles/src/code';
+import CodeBlock from '@ckeditor/ckeditor5-code-block/src/codeblock';
 import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud-services-config';
 
 ClassicEditor
 	.create( document.querySelector( '#snippet-autoformat' ), {
-		plugins: ClassicEditor.builtinPlugins.concat( [ Code ] ),
+		plugins: ClassicEditor.builtinPlugins.concat( [ Code, CodeBlock ] ),
 		toolbar: {
 			items: [
 				'heading',

+ 1 - 0
packages/ckeditor5-autoformat/docs/features/autoformat.md

@@ -17,6 +17,7 @@ The following block formatting options are available:
 * Numbered list – Start a line with `1.` or `1)` followed by a space.
 * Headings – Start a line with `#` or `##` or `###` followed by a space to create a heading 1, heading 2 or heading 3 (up to heading 6 if {@link module:heading/heading~HeadingConfig#options} defines more headings).
 * Block quote – Start a line with `>` followed by a space.
+* Code block – Start a line with `` ``` ``.
 
 ## Inline formatting
 

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

@@ -155,10 +155,10 @@ export default class Autoformat extends Plugin {
 	}
 
 	/**
-	 * Adds autoformatting related to {@link module:code-block/code-block~CodeBlock}.
+	 * Adds autoformatting related to {@link module:code-block/codeblock~CodeBlock}.
 	 *
 	 * When typed:
-	 * - `\`\`\`` – A paragraph will be changed to a code block.
+	 * - `` ``` `` – A paragraph will be changed to a code block.
 	 *
 	 * @private
 	 */

+ 2 - 1
packages/ckeditor5-autoformat/tests/manual/autoformat.js

@@ -17,11 +17,12 @@ import Undo from '@ckeditor/ckeditor5-undo/src/undo';
 import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
 import Code from '@ckeditor/ckeditor5-basic-styles/src/code';
 import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
+import CodeBlock from '@ckeditor/ckeditor5-code-block/src/codeblock';
 import ShiftEnter from '@ckeditor/ckeditor5-enter/src/shiftenter';
 
 ClassicEditor
 	.create( document.querySelector( '#editor' ), {
-		plugins: [ Enter, Typing, Paragraph, Undo, Bold, Italic, Code, Heading, List, Autoformat, BlockQuote, ShiftEnter ],
+		plugins: [ Enter, Typing, Paragraph, Undo, Bold, Italic, Code, Heading, List, Autoformat, BlockQuote, CodeBlock, ShiftEnter ],
 		toolbar: [ 'heading', '|', 'numberedList', 'bulletedList', 'blockQuote', 'bold', 'italic', 'code', 'undo', 'redo' ]
 	} )
 	.then( editor => {

+ 2 - 0
packages/ckeditor5-autoformat/tests/manual/autoformat.md

@@ -16,6 +16,8 @@
 
 1. Type ``` `foobar` ``` to mark as code `foobar`. ```  ` ``` should be removed.
 
+1. Type `` ``` `` in a new line to create an empty code block. `` ``` `` should be removed.
+
 1. For every autoformat pattern: Undo until you'll see just the pattern (e.g. `- `). Typing should be then possible without triggering the autoformatting again.
 
 1. Typing a different pattern in an already converted block **must not** trigger the autoformatting. For example, typing `- ` in a heading should not convert a heading to a list.