Skip to content

Commit

Permalink
Merge pull request #510 from thematters/develop
Browse files Browse the repository at this point in the history
Release: v0.3.0-alpha.3
  • Loading branch information
robertu7 authored Aug 4, 2024
2 parents 9fd0f54 + cfed34e commit 3087beb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@matters/matters-editor",
"version": "0.3.0-alpha.2",
"version": "0.3.0-alpha.3",
"description": "Editor for matters.news",
"author": "https://github.com/thematters",
"homepage": "https://github.com/thematters/matters-editor",
Expand Down
18 changes: 11 additions & 7 deletions src/editors/extensions/pasteDropFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type PasteDropFileOptions = {
// drop event handler
onDrop: (editor: Editor, files: File[], pos: number) => void
// accepted mime types
mimeTypes: string[]
mimeTypes?: string[]
}

const pluginName = 'pasteDropFile'
Expand All @@ -27,9 +27,11 @@ const makePlugin = ({
key: new PluginKey(pluginName),
props: {
handleDrop(view, event) {
const files = Array.from(event.dataTransfer?.files || []).filter(
(file) => mimeTypes.includes(file.type),
)
let files = Array.from(event.dataTransfer?.files || [])

if (mimeTypes) {
files = files.filter((file) => mimeTypes.includes(file.type))
}

if (files.length <= 0) return

Expand All @@ -44,9 +46,11 @@ const makePlugin = ({
return true
},
handlePaste(view, event) {
const files = Array.from(event.clipboardData?.files || []).filter(
(file) => mimeTypes.includes(file.type),
)
let files = Array.from(event.clipboardData?.files || [])

if (mimeTypes) {
files = files.filter((file) => mimeTypes.includes(file.type))
}

if (files.length <= 0) return

Expand Down

0 comments on commit 3087beb

Please sign in to comment.