mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-08 02:10:24 +00:00
use inner link
This commit is contained in:
@@ -4,9 +4,9 @@ import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import FileChooser from '../file-chooser/file-chooser';
|
||||
import { siteRoot } from '../../utils/constants';
|
||||
import '../../css/insert-repo-image-dialog.css';
|
||||
|
||||
const { siteRoot, serviceUrl } = window.app.config;
|
||||
const propTypes = {
|
||||
repoID: PropTypes.string.isRequired,
|
||||
filePath: PropTypes.string.isRequired,
|
||||
@@ -24,7 +24,7 @@ class InsertRepoImageDialog extends React.Component {
|
||||
}
|
||||
|
||||
insertImage = () => {
|
||||
const url = siteRoot + 'thumbnail/' + this.state.repo.repo_id + '/1024' + this.state.selectedPath;
|
||||
const url = serviceUrl + '/lib/' + this.state.repo.repo_id + '/file' + Utils.encodePath(this.state.selectedPath) + '?raw=1';
|
||||
window.richMarkdownEditor.onInsertImage(url);
|
||||
this.props.toggleCancel();
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ const MoreMenuPropTypes = {
|
||||
isSmallScreen: PropTypes.bool,
|
||||
toggleShareLinkDialog: PropTypes.func,
|
||||
backToParentDirectory: PropTypes.func,
|
||||
showFileHistory: PropTypes.func,
|
||||
showFileHistory: PropTypes.bool,
|
||||
toggleHistory: PropTypes.func,
|
||||
};
|
||||
|
||||
|
@@ -645,19 +645,9 @@ class MarkdownEditor extends React.Component {
|
||||
}
|
||||
|
||||
getInsertLink = (repoID, filePath) => {
|
||||
seafileAPI.getShareLink(repoID, filePath).then((res) => {
|
||||
if (res.data.length !== 0) {
|
||||
let fileLink = res.data[0];
|
||||
window.richMarkdownEditor.addLink(fileLink.obj_name, fileLink.link);
|
||||
} else {
|
||||
let permissions = { 'can_edit': false, 'can_download': true };
|
||||
permissions = JSON.stringify(permissions);
|
||||
seafileAPI.createShareLink(repoID, filePath, null, null, permissions).then((res) => {
|
||||
let fileLink = res.data;
|
||||
window.richMarkdownEditor.addLink(fileLink.obj_name, fileLink.link);
|
||||
});
|
||||
}
|
||||
});
|
||||
const innerURL = serviceUrl + '/lib/' + repoID + '/file' + Utils.encodePath(filePath);
|
||||
const fileName = Utils.getFileName(filePath);
|
||||
window.richMarkdownEditor.addLink(fileName, innerURL);
|
||||
}
|
||||
|
||||
onContentChanged = (value) => {
|
||||
|
Reference in New Issue
Block a user