|
|
@@ -1043,13 +1043,14 @@ describe( 'CodeBlockEditing', () => {
|
|
|
|
|
|
// https://github.com/ckeditor/ckeditor5/issues/5924
|
|
|
it( 'should upcast using only the first class from config as a defining language class', () => {
|
|
|
+ // "baz" is the first class configured for the "baz" language.
|
|
|
return ClassicTestEditor.create( '<pre><code class="baz">foo</code></pre>', {
|
|
|
plugins: [ CodeBlockEditing ],
|
|
|
codeBlock: {
|
|
|
languages: [
|
|
|
{ language: 'foo', label: 'Foo', class: 'foo' },
|
|
|
{ language: 'baz', label: 'Baz', class: 'baz bar' },
|
|
|
- { language: 'bar', label: 'Bar', class: 'bar' },
|
|
|
+ { language: 'qux', label: 'Qux', class: 'qux' },
|
|
|
]
|
|
|
}
|
|
|
} ).then( editor => {
|
|
|
@@ -1060,6 +1061,27 @@ describe( 'CodeBlockEditing', () => {
|
|
|
return editor.destroy();
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+ // https://github.com/ckeditor/ckeditor5/issues/5924
|
|
|
+ it( 'should not upcast if the class is not the first (defining) language class', () => {
|
|
|
+ // "bar" is the second class configured for the "baz" language.
|
|
|
+ return ClassicTestEditor.create( '<pre><code class="bar">foo</code></pre>', {
|
|
|
+ plugins: [ CodeBlockEditing ],
|
|
|
+ codeBlock: {
|
|
|
+ languages: [
|
|
|
+ { language: 'foo', label: 'Foo', class: 'foo' },
|
|
|
+ { language: 'baz', label: 'Baz', class: 'baz bar' },
|
|
|
+ { language: 'qux', label: 'Qux', class: 'qux' },
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ } ).then( editor => {
|
|
|
+ model = editor.model;
|
|
|
+
|
|
|
+ expect( getModelData( model ) ).to.equal( '<codeBlock language="foo">[]foo</codeBlock>' );
|
|
|
+
|
|
|
+ return editor.destroy();
|
|
|
+ } );
|
|
|
+ } );
|
|
|
} );
|
|
|
} );
|
|
|
|