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:
parent
66433c6796
commit
57c8fe631d
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user