Skip to content

Commit

Permalink
Merge pull request #12073 from ckeditor/ck/12046-link-manual-decorato…
Browse files Browse the repository at this point in the history
…r-downcast

Fix (link): Link manual decorators should be properly down-casted on the document selection. Closes #12046.
  • Loading branch information
arkflpc authored Jul 18, 2022
2 parents 6309fff + 497f157 commit 0e7794b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ckeditor5-link/src/linkediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export default class LinkEditing extends Plugin {
model: decorator.id,
view: ( manualDecoratorValue, { writer, schema }, { item } ) => {
// Manual decorators for block links are handled e.g. in LinkImageEditing.
if ( !schema.isInline( item ) ) {
if ( !( item.is( 'selection' ) || schema.isInline( item ) ) ) {
return;
}

Expand Down
8 changes: 8 additions & 0 deletions packages/ckeditor5-link/tests/linkediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,14 @@ describe( 'LinkEditing', () => {
await editor.destroy();
} );
} );

it( 'should downcast manual decorator on document selection', () => {
setModelData( model, '<paragraph><$text linkHref="url" linkIsExternal="true">foo[]bar</$text></paragraph>' );

expect( getViewData( editor.editing.view ) ).to.equal(
'<p><a class="ck-link_selected" href="url" rel="noopener noreferrer" target="_blank">foo{}bar</a></p>'
);
} );
} );

describe( 'link following', () => {
Expand Down

0 comments on commit 0e7794b

Please sign in to comment.