Skip to content

Commit

Permalink
Merge pull request #15226 from ckeditor/ck/14683-style-anchor-leads-t…
Browse files Browse the repository at this point in the history
…o-unusable-behaviour

Fix (html-support): Additional attributes for the link element (e.g. CSS class) should not be applied after pressing Enter. Closes #14683.
  • Loading branch information
niegowski authored Oct 25, 2023
2 parents 89eb065 + 966738e commit 9c02cc4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/ckeditor5-html-support/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@ckeditor/ckeditor5-paste-from-office": "40.0.0",
"@ckeditor/ckeditor5-remove-format": "40.0.0",
"@ckeditor/ckeditor5-source-editing": "40.0.0",
"@ckeditor/ckeditor5-style": "40.0.0",
"@ckeditor/ckeditor5-table": "40.0.0",
"@ckeditor/ckeditor5-theme-lark": "40.0.0",
"@ckeditor/ckeditor5-typing": "40.0.0",
Expand Down
5 changes: 1 addition & 4 deletions packages/ckeditor5-html-support/src/schemadefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,7 @@ export default {
model: 'htmlA',
view: 'a',
priority: 5,
coupledAttribute: 'linkHref',
attributeProperties: {
copyOnEnter: true
}
coupledAttribute: 'linkHref'
},
{
model: 'htmlStrong',
Expand Down
55 changes: 55 additions & 0 deletions packages/ckeditor5-html-support/tests/tickets/14683.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/* global document */

import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import LinkEditing from '@ckeditor/ckeditor5-link/src/linkediting';
import Style from '@ckeditor/ckeditor5-style/src/styleediting';
import { getData, setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
import GeneralHtmlSupport from '../../src/generalhtmlsupport';

describe( 'bug #14683', () => {
let editor, model, editorElement;

beforeEach( async () => {
editorElement = document.createElement( 'div' );
document.body.appendChild( editorElement );

editor = await ClassicTestEditor.create( editorElement, {
plugins: [ Paragraph, LinkEditing, GeneralHtmlSupport, Style ],
style: {
definitions: [
{
name: 'Button',
element: 'a',
classes: [ 'button' ]
}
]
}
} );

model = editor.model;
} );

afterEach( async () => {
editorElement.remove();

await editor.destroy();
} );

it( 'should not copy additional attributes for the link element after pressing Enter', () => {
setData( model, '<paragraph><$text linkHref="example.com">foo[]</$text></paragraph>' );

editor.commands.get( 'style' ).execute( { styleName: 'Button' } );
editor.commands.get( 'enter' ).execute();

expect( getData( model ) ).to.equal(
'<paragraph><$text htmlA="{"classes":["button"]}" linkHref="example.com">foo</$text></paragraph>' +
'<paragraph>[]</paragraph>'
);
} );
} );

0 comments on commit 9c02cc4

Please sign in to comment.