From 5ff668d8afc3e75a992f39479aa57c6e52beac5b Mon Sep 17 00:00:00 2001 From: Marta Motyczynska Date: Tue, 24 Oct 2023 11:56:06 +0200 Subject: [PATCH 1/2] Attributes for htmlA should not be copied on enter. --- packages/ckeditor5-html-support/src/schemadefinitions.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/ckeditor5-html-support/src/schemadefinitions.ts b/packages/ckeditor5-html-support/src/schemadefinitions.ts index 049572d1d45..847d9867f63 100644 --- a/packages/ckeditor5-html-support/src/schemadefinitions.ts +++ b/packages/ckeditor5-html-support/src/schemadefinitions.ts @@ -673,10 +673,7 @@ export default { model: 'htmlA', view: 'a', priority: 5, - coupledAttribute: 'linkHref', - attributeProperties: { - copyOnEnter: true - } + coupledAttribute: 'linkHref' }, { model: 'htmlStrong', From 966738eb920e1d1aaa9139443289dc98433c5702 Mon Sep 17 00:00:00 2001 From: Marta Motyczynska Date: Wed, 25 Oct 2023 12:57:32 +0200 Subject: [PATCH 2/2] Added test. --- packages/ckeditor5-html-support/package.json | 1 + .../tests/tickets/14683.js | 55 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 packages/ckeditor5-html-support/tests/tickets/14683.js diff --git a/packages/ckeditor5-html-support/package.json b/packages/ckeditor5-html-support/package.json index 5956b974e0f..1375027f019 100644 --- a/packages/ckeditor5-html-support/package.json +++ b/packages/ckeditor5-html-support/package.json @@ -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", diff --git a/packages/ckeditor5-html-support/tests/tickets/14683.js b/packages/ckeditor5-html-support/tests/tickets/14683.js new file mode 100644 index 00000000000..6c25522b267 --- /dev/null +++ b/packages/ckeditor5-html-support/tests/tickets/14683.js @@ -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, '<$text linkHref="example.com">foo[]' ); + + editor.commands.get( 'style' ).execute( { styleName: 'Button' } ); + editor.commands.get( 'enter' ).execute(); + + expect( getData( model ) ).to.equal( + '<$text htmlA="{"classes":["button"]}" linkHref="example.com">foo' + + '[]' + ); + } ); +} );