Skip to content

Commit

Permalink
粘贴图片改为相对路径引用
Browse files Browse the repository at this point in the history
  • Loading branch information
onblog committed Apr 15, 2020
1 parent c235a7a commit a31e543
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,6 @@ myTabs.get(0).onwheel = function (event) {
//插入本地图片
ipcRenderer.on('insert-picture-file', (event, filePaths) => {
for (let i = 0; i < filePaths.length; i++) {
//不上传图片
insertPictureToTextarea(tab, filePaths[i])
}
})
Expand All @@ -534,7 +533,7 @@ document.addEventListener('drop', (e) => {
// 拖拽的是MD文件
if (path.extname(f.path).toLocaleLowerCase() === '.md') {
openMdFiles(Array.of(f.path))
}// 拖拽的文件直接引用
}// 拖拽的图片直接引用
else if (util.isLocalPicture(f.path)) {
insertPictureToTextarea(tab, f.path)
}
Expand Down Expand Up @@ -587,6 +586,9 @@ document.addEventListener('paste', function (event) {
if (err) {
return console.error(err);
}
if (filePath.startsWith(tab.getPictureDir())){
filePath = filePath.replace(tab.getPictureDir(),'./')
}
insertPictureToTextarea(tab, filePath)
})
} else if (type === types.rtf) {
Expand Down

0 comments on commit a31e543

Please sign in to comment.