Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #86 from ckeditor/t/18
Browse files Browse the repository at this point in the history
Clicking a media preview link should not open a new browser tab unless the media is already selected. Closes #18.
  • Loading branch information
oleq authored Jun 12, 2019
2 parents c3babe6 + 4150eb8 commit 12bd564
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/mediaregistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ class Media {
tag: 'a',
attributes: {
class: 'ck-media__placeholder__url',
target: 'new',
target: '_blank',
rel: 'noopener noreferrer',
href: this.url
},
children: [
Expand Down
2 changes: 1 addition & 1 deletion tests/mediaembedediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ describe( 'MediaEmbedEditing', () => {
'<div[^>]+>' +
'<div class="ck ck-media__placeholder ck-reset_all">' +
'<div class="ck-media__placeholder__icon">.*</div>' +
`<a class="ck-media__placeholder__url" href="${ expectedUrl }" target="new">` +
`<a class="ck-media__placeholder__url" href="${ expectedUrl }" rel="noopener noreferrer" target="_blank">` +
`<span class="ck-media__placeholder__url__text">${ expectedUrl }</span>` +
'<span class="ck ck-tooltip ck-tooltip_s">' +
'<span class="ck ck-tooltip__text">Open media in new tab</span>' +
Expand Down
6 changes: 6 additions & 0 deletions theme/mediaembedediting.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@
.ck-editor__editable:not(.ck-read-only) .ck-media__wrapper > *:not(.ck-media__placeholder) {
pointer-events: none;
}

/* Disable all mouse interaction when the widget is not selected (e.g. to avoid opening links by accident).
https://github.com/ckeditor/ckeditor5-media-embed/issues/18 */
.ck-editor__editable:not(.ck-read-only) .ck-widget:not(.ck-widget_selected) .ck-media__placeholder {
pointer-events: none;
}

0 comments on commit 12bd564

Please sign in to comment.