mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 02:06:29 +00:00
Slight refactor
This commit is contained in:
@@ -278,19 +278,20 @@ function handleAttachmentDrop (codeEditor, storageKey, noteKey, dropEvent) {
|
|||||||
let promise
|
let promise
|
||||||
if (dropEvent.dataTransfer.files.length > 0) {
|
if (dropEvent.dataTransfer.files.length > 0) {
|
||||||
promise = Promise.all(Array.from(dropEvent.dataTransfer.files).map(file => {
|
promise = Promise.all(Array.from(dropEvent.dataTransfer.files).map(file => {
|
||||||
var filePath = file.path
|
const filePath = file.path
|
||||||
if (file.type.startsWith('image')) {
|
const fileType = file.type // EX) 'image/gif' or 'text/html'
|
||||||
if (file.type === 'image/gif' || file.type === 'image/svg+xml') {
|
if (fileType.startsWith('image')) {
|
||||||
return copyAttachment(file.path, storageKey, noteKey).then(fileName => ({
|
if (fileType === 'image/gif' || fileType === 'image/svg+xml') {
|
||||||
|
return copyAttachment(filePath, storageKey, noteKey).then(fileName => ({
|
||||||
fileName,
|
fileName,
|
||||||
title: path.basename(file.path),
|
title: path.basename(filePath),
|
||||||
isImage: true
|
isImage: true
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
return getOrientation(file)
|
return getOrientation(file)
|
||||||
.then((orientation) => {
|
.then((orientation) => {
|
||||||
if (orientation === -1) { // The image rotation is correct and does not need adjustment
|
if (orientation === -1) { // The image rotation is correct and does not need adjustment
|
||||||
return copyAttachment(file.path, storageKey, noteKey)
|
return copyAttachment(filePath, storageKey, noteKey)
|
||||||
} else {
|
} else {
|
||||||
return fixRotate(file).then(data => copyAttachment({
|
return fixRotate(file).then(data => copyAttachment({
|
||||||
type: 'base64',
|
type: 'base64',
|
||||||
@@ -308,9 +309,9 @@ function handleAttachmentDrop (codeEditor, storageKey, noteKey, dropEvent) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return copyAttachment(file.path, storageKey, noteKey).then(fileName => ({
|
return copyAttachment(filePath, storageKey, noteKey).then(fileName => ({
|
||||||
fileName,
|
fileName,
|
||||||
title: path.basename(file.path),
|
title: path.basename(filePath),
|
||||||
isImage: false
|
isImage: false
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user