Skip to content

Commit

Permalink
Merge pull request #7641 from ckeditor/i/7614
Browse files Browse the repository at this point in the history
Fix (link): Fake visual selection should not be added to the editor's data. Closes #7614.
  • Loading branch information
jodator committed Jul 17, 2020
2 parents d921aab + 95fcdf3 commit 84e2042
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/ckeditor5-link/src/linkui.js
Expand Up @@ -85,15 +85,15 @@ export default class LinkUI extends Plugin {
this._enableUserBalloonInteractions();

// Renders a fake visual selection marker on an expanded selection.
editor.conversion.for( 'downcast' ).markerToHighlight( {
editor.conversion.for( 'editingDowncast' ).markerToHighlight( {
model: VISUAL_SELECTION_MARKER_NAME,
view: {
classes: [ 'ck-fake-link-selection' ]
}
} );

// Renders a fake visual selection marker on a collapsed selection.
editor.conversion.for( 'downcast' ).markerToElement( {
editor.conversion.for( 'editingDowncast' ).markerToElement( {
model: VISUAL_SELECTION_MARKER_NAME,
view: {
name: 'span',
Expand Down
8 changes: 8 additions & 0 deletions packages/ckeditor5-link/tests/linkui.js
Expand Up @@ -481,6 +481,9 @@ describe( 'LinkUI', () => {
const markerRange = editor.model.markers.get( 'link-ui' ).getRange();

expect( markerRange.isEqual( expectedRange ) ).to.be.true;

expect( getViewData( editor.editing.view ) ).to.equal( '<p>f{<span class="ck-fake-link-selection">o</span>}o</p>' );
expect( editor.getData() ).to.equal( '<p>foo</p>' );
} );

it( 'should display a fake visual selection on a collapsed selection', () => {
Expand All @@ -498,6 +501,11 @@ describe( 'LinkUI', () => {
const markerRange = editor.model.markers.get( 'link-ui' ).getRange();

expect( markerRange.isEqual( expectedRange ) ).to.be.true;

expect( getViewData( editor.editing.view ) ).to.equal(
'<p>f{}<span class="ck-fake-link-selection ck-fake-link-selection_collapsed"></span>o</p>'
);
expect( editor.getData() ).to.equal( '<p>fo</p>' );
} );
} );

Expand Down

0 comments on commit 84e2042

Please sign in to comment.