1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-07-15 16:04:01 +00:00

insert library file (#4780)

* insert library file

* optimize code

* fix code
This commit is contained in:
songjiaqi1 2021-01-12 11:25:46 +08:00 committed by GitHub
parent 66433c6796
commit 57c8fe631d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,6 +26,7 @@ const { siteRoot, serviceUrl, seafileCollabServer } = window.app.config;
const userInfo = window.app.userInfo;
const userName = userInfo.username;
let dirPath = Utils.getDirName(filePath);
const IMAGE_SUFFIXES = ['png', 'PNG', 'jpg', 'JPG', 'gif', 'GIF'];
function getImageFileNameWithTimestamp() {
var d = Date.now();
@ -730,8 +731,15 @@ class MarkdownEditor extends React.Component {
}
getInsertLink = (repoID, filePath) => {
const innerURL = serviceUrl + '/lib/' + repoID + '/file' + Utils.encodePath(filePath);
const fileName = Utils.getFileName(filePath);
const suffix = fileName.slice(fileName.indexOf('.') + 1);
if (IMAGE_SUFFIXES.includes(suffix)) {
seafileAPI.getFileDownloadLink(repoID, filePath).then((res) => {
window.richMarkdownEditor.addLink(fileName, res.data, true);
});
return;
}
let innerURL = serviceUrl + '/lib/' + repoID + '/file' + Utils.encodePath(filePath);
window.richMarkdownEditor.addLink(fileName, innerURL);
}