Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@editorjs/attaches",
"version": "1.3.2",
"version": "1.3.3",
"keywords": [
"codex editor",
"attaches",
Expand Down
4 changes: 4 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
border-radius: 7px;
background: var(--color-bg);

&[role="button"] {
cursor: pointer;
}

^&__file-info {
display: grid;
grid-gap: 4px;
Expand Down
13 changes: 13 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,19 @@ export default class AttachesTool {
this.nodes.wrapper.appendChild(fileInfo);

if (file.url !== undefined) {
// Make the whole box clickable in read-only mode
if (this.readOnly) {
this.nodes.wrapper.setAttribute('role', 'button');
this.nodes.wrapper.addEventListener('click', (event) => {
// Don't trigger if clicking on the actual download link
if (event.target.closest(`.${this.CSS.downloadButton}`)) {
return;
}
// Open file in new tab/window
window.open(file.url, '_blank');
});
}
Comment thread
bettysteger marked this conversation as resolved.
Outdated

const downloadIcon = make('a', this.CSS.downloadButton, {
innerHTML: IconChevronDown,
href: file.url,
Expand Down