Parcourir la source

Stub indent conversion.

Maciej Gołaszewski il y a 6 ans
Parent
commit
d76a5593c6

+ 1 - 1
packages/ckeditor5-core/tests/manual/article.html

@@ -8,7 +8,7 @@
 </head>
 <div id="editor">
 	<h2>Heading 1</h2>
-	<p>Paragraph</p>
+	<p style="margin-left:2em;">Paragraph</p>
 	<p><strong>Bold</strong> <i>Italic</i> <a href="https://ckeditor.com">Link</a></p>
 	<ul>
 		<li>UL List item 1</li>

+ 37 - 1
packages/ckeditor5-core/tests/manual/article.js

@@ -56,9 +56,45 @@ class IndentOutdent extends Plugin {
 	}
 }
 
+class IndentBlock extends Plugin {
+	init() {
+		const schema = this.editor.model.schema;
+		const conversion = this.editor.conversion;
+
+		schema.extend( 'paragraph', { allowAttributes: 'indent' } );
+		schema.extend( 'heading1', { allowAttributes: 'indent' } );
+
+		conversion.for( 'upcast' ).attributeToAttribute( {
+			view: {
+				styles: {
+					'margin-left': /[\s\S]+/
+				}
+			},
+			model: {
+				key: 'indent',
+				value: viewElement => {
+					return viewElement.getStyle( 'margin-left' );
+				}
+			}
+		} );
+
+		conversion.for( 'downcast' ).attributeToAttribute( {
+			model: 'indent',
+			view: modelAttributeValue => {
+				return {
+					key: 'style',
+					value: {
+						'margin-left': modelAttributeValue
+					}
+				};
+			}
+		} );
+	}
+}
+
 ClassicEditor
 	.create( document.querySelector( '#editor' ), {
-		plugins: [ ArticlePluginSet, IndentOutdent ],
+		plugins: [ ArticlePluginSet, IndentOutdent, IndentBlock ],
 		toolbar: [
 			'heading',
 			'|',