Ver código fonte

Other: Provide configuration stub.

Maciej Gołaszewski 8 anos atrás
pai
commit
f31b5c2cb0

+ 8 - 0
packages/ckeditor5-highlight/src/highlightediting.js

@@ -21,6 +21,14 @@ export default class HighlightEditing extends Plugin {
 	init() {
 		const editor = this.editor;
 
+		editor.config.define( 'highlight', [
+			{ class: 'marker', title: 'Marker', color: '#ffff66', type: 'marker' },
+			{ class: 'marker-green', title: 'Green Marker', color: '#66ff00', type: 'marker' },
+			{ class: 'marker-pink', title: 'Pink Marker', color: '#ff6fff', type: 'marker' },
+			{ class: 'pen-red', title: 'Red Pen', color: '#ff0000', type: 'pen' },
+			{ class: 'pen-blue', title: 'Blue Pen', color: '#0000ff', type: 'pen' }
+		] );
+
 		editor.commands.add( 'highlight', new HighlightCommand( editor ) );
 	}
 }

+ 15 - 9
packages/ckeditor5-highlight/tests/highlightediting.js

@@ -56,16 +56,18 @@ describe( 'HighlightEditing', () => {
 		} );
 	} );
 
-	describe.skip( 'highlight', () => {
-		it( 'adds converters to the data pipeline', () => {
-			const data = '<p>f<mark>o</mark>o</p>';
+	describe.skip( 'data pipeline conversions', () => {
+		it( 'should convert defined marker classes', () => {
+			const data = '<p>f<mark class="marker">o</mark>o</p>';
 
 			editor.setData( data );
 
 			expect( getModelData( doc ) ).to.equal( '<paragraph>f<$text highlight="">o</$text>o</paragraph>' );
 			expect( editor.getData() ).to.equal( '<p>x</p>' );
 		} );
+	} );
 
+	describe.skip( 'editing pipeline conversion', () => {
 		it( 'adds a converter to the view pipeline for removing attribute', () => {
 			setModelData( doc, '<paragraph>f<$text highlight="">o</$text>o</paragraph>' );
 
@@ -79,12 +81,16 @@ describe( 'HighlightEditing', () => {
 		} );
 	} );
 
-	describe.skip( 'config', () => {
-		describe( 'styles', () => {
-			describe( 'default value', () => {
-				it( 'should be set', () => {
-					expect( editor.config.get( 'highlight.styles' ) ).to.deep.equal( {} );
-				} );
+	describe( 'config', () => {
+		describe( 'default value', () => {
+			it( 'should be set', () => {
+				expect( editor.config.get( 'highlight' ) ).to.deep.equal( [
+					{ class: 'marker', title: 'Marker', color: '#ffff66', type: 'marker' },
+					{ class: 'marker-green', title: 'Green Marker', color: '#66ff00', type: 'marker' },
+					{ class: 'marker-pink', title: 'Pink Marker', color: '#ff6fff', type: 'marker' },
+					{ class: 'pen-red', title: 'Red Pen', color: '#ff0000', type: 'pen' },
+					{ class: 'pen-blue', title: 'Blue Pen', color: '#0000ff', type: 'pen' }
+				] );
 			} );
 		} );
 	} );