Skip to content

Commit

Permalink
Renamed selectFiles command
Browse files Browse the repository at this point in the history
  • Loading branch information
cesardeazevedo committed Aug 18, 2024
1 parent 0fbd4bb commit b8d5c40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ function App() {
}>
Add Bolt11
</MenuButton>
<MenuButton onClick={() => editor.chain().selectFile().run()}>Add Media</MenuButton>
<MenuButton onClick={() => editor.chain().selectFiles().run()}>Add Media</MenuButton>
<MenuButton onClick={() => editor.chain().uploadFiles().run()}>Upload</MenuButton>
<MenuButton disabled={isPending} onClick={() => { }}>
Sign
Expand Down
14 changes: 7 additions & 7 deletions src/extensions/FileUploadExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { VideoAttributes } from './VideoExtension'
declare module '@tiptap/core' {
interface Commands<ReturnType> {
fileUpload: {
selectFile: () => ReturnType
selectFiles: () => ReturnType
uploadFiles: () => ReturnType
}
}
Expand Down Expand Up @@ -50,14 +50,14 @@ export const FileUploadExtension = Extension.create<FileUploadOptions>({
async hash(file: File) {
return bufferToHex(await crypto.subtle.digest('SHA-256', await file.arrayBuffer()))
},
onDrop() {},
onComplete() {},
onDrop() { },
onComplete() { },
}
},

addCommands() {
return {
selectFile: () => (props) => {
selectFiles: () => (props) => {
props.tr.setMeta('selectFiles', true)
return true
},
Expand All @@ -80,7 +80,7 @@ export const FileUploadExtension = Extension.create<FileUploadOptions>({
apply(tr) {
setTimeout(() => {
if (tr.getMeta('selectFiles')) {
uploader.selectFile()
uploader.selectFiles()
tr.setMeta('selectFiles', null)
} else if (tr.getMeta('uploadFiles')) {
uploader.uploadFiles()
Expand All @@ -104,7 +104,7 @@ class Uploader {
constructor(
public editor: Editor,
private options: FileUploadOptions,
) {}
) { }

get view() {
return this.editor.view
Expand Down Expand Up @@ -201,7 +201,7 @@ class Uploader {
}
}

selectFile() {
selectFiles() {
const input = document.createElement('input')
input.type = 'file'
input.multiple = true
Expand Down

0 comments on commit b8d5c40

Please sign in to comment.