mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
absolute path
This commit is contained in:
committed by
Junyoung Choi
parent
7106f042da
commit
9d47f319a0
@@ -458,17 +458,15 @@ function getAbsolutePathsOfAttachmentsInContent (markdownContent, storagePath) {
|
|||||||
*/
|
*/
|
||||||
function importAttachments (markDownContent, filepath, storageKey, noteKey) {
|
function importAttachments (markDownContent, filepath, storageKey, noteKey) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const nameRegex = /(!\[.*?]\()(.+?\..+?)(\))/g
|
const nameRegex = /(!\[.+?]\()(.+?\..+?)(\))/g
|
||||||
let attachName = nameRegex.exec(markDownContent)
|
let attachName = nameRegex.exec(markDownContent)
|
||||||
const promiseArray = []
|
const promiseArray = []
|
||||||
const beginPath = filepath.match(/\/.+\//)[0]
|
const attachPath = []
|
||||||
const endPath = []
|
|
||||||
const groupIndex = 2
|
const groupIndex = 2
|
||||||
|
|
||||||
while (attachName) {
|
while (attachName) {
|
||||||
endPath.push(attachName[groupIndex])
|
attachPath.push(attachName[groupIndex])
|
||||||
const finalPath = path.join(beginPath, attachName[groupIndex])
|
promiseArray.push(this.copyAttachment(attachName[groupIndex], storageKey, noteKey))
|
||||||
promiseArray.push(this.copyAttachment(finalPath, storageKey, noteKey))
|
|
||||||
attachName = nameRegex.exec(markDownContent)
|
attachName = nameRegex.exec(markDownContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,10 +480,10 @@ function importAttachments (markDownContent, filepath, storageKey, noteKey) {
|
|||||||
promiseArray[j]
|
promiseArray[j]
|
||||||
.then((fileName) => {
|
.then((fileName) => {
|
||||||
const newPath = path.join(STORAGE_FOLDER_PLACEHOLDER, noteKey, fileName)
|
const newPath = path.join(STORAGE_FOLDER_PLACEHOLDER, noteKey, fileName)
|
||||||
markDownContent = markDownContent.replace(endPath[j], newPath)
|
markDownContent = markDownContent.replace(attachPath[j], newPath)
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.error('File does not exist in path: ' + endPath[j])
|
console.error('File does not exist in path: ' + attachPath[j])
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
numResolvedPromises++
|
numResolvedPromises++
|
||||||
|
|||||||
Reference in New Issue
Block a user