Skip to content

Commit

Permalink
Merge pull request #2465 from umbraco/v15/feature/tiptap-paste-files
Browse files Browse the repository at this point in the history
Tiptap: allow images to be uploaded from the clipboard
  • Loading branch information
iOvergaard authored Oct 16, 2024
2 parents 4c1c309 + 4f6fc30 commit 9d818b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ export class UmbTemporaryFileManager<
for (const item of queue) {
if (!item.temporaryUnique) throw new Error(`Unique is missing for item ${item}`);

const { error } = await this.#temporaryFileRepository.upload(item.temporaryUnique, item.file);
//await new Promise((resolve) => setTimeout(resolve, (Math.random() + 0.5) * 1000)); // simulate small delay so that the upload badge is properly shown
const { error } = await this.#temporaryFileRepository
.upload(item.temporaryUnique, item.file)
.catch(() => ({ error: true }));

let status: TemporaryFileStatus;
if (error) {
Expand Down
7 changes: 7 additions & 0 deletions src/packages/tiptap/extensions/core/media-upload.extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ export default class UmbTiptapMediaUploadExtensionApi extends UmbTiptapExtension

self.#uploadTemporaryFile(files, this.editor);
});

host.addEventListener('paste', (event) => {
const files = event.clipboardData?.files;
if (!files) return;

self.#uploadTemporaryFile(files, this.editor);
});
},
}),
];
Expand Down

0 comments on commit 9d818b2

Please sign in to comment.