Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing target=_blank duplicates after clicking on it in the documenta… #9214

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/ckeditor5-link/src/linkediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ export default class LinkEditing extends Plugin {
// @param {module:utils/collection~Collection} manualDecorators
function removeLinkAttributesFromSelection( writer, manualDecorators ) {
writer.removeSelectionAttribute( 'linkHref' );
writer.removeSelectionAttribute( 'linkTarget' );

for ( const decorator of manualDecorators ) {
writer.removeSelectionAttribute( decorator.id );
Expand Down
16 changes: 16 additions & 0 deletions packages/ckeditor5-link/tests/linkediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,22 @@ describe( 'LinkEditing', () => {
expect( [ ...model.document.selection.getAttributeKeys() ] ).to.be.empty;
} );

it( 'should remove linkTarget attribute when pasting a link', () => {
editor.model.schema.extend( '$text', { allowAttributes: 'linkTarget' } );

setModelData( model, '<paragraph>foo[]</paragraph>' );

model.change( writer => {
model.insertContent( writer.createText( 'INSERTED', { linkHref: 'ckeditor.com', linkTarget: '_blank' } ) );
} );

expect( getModelData( model ) ).to.equal(
'<paragraph>foo<$text linkHref="ckeditor.com" linkTarget="_blank">INSERTED</$text>[]</paragraph>'
);

expect( [ ...model.document.selection.getAttributeKeys() ] ).to.be.empty;
} );

it( 'should remove all attributes starting with "link" (e.g. decorator attributes) when pasting a link', () => {
setModelData( model, '<paragraph>foo[]</paragraph>' );

Expand Down