mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-08 18:30:53 +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 { gettext } from '../../utils/constants';
|
||||||
import { Utils } from '../../utils/utils';
|
import { Utils } from '../../utils/utils';
|
||||||
import FileChooser from '../file-chooser/file-chooser';
|
import FileChooser from '../file-chooser/file-chooser';
|
||||||
import { siteRoot } from '../../utils/constants';
|
|
||||||
import '../../css/insert-repo-image-dialog.css';
|
import '../../css/insert-repo-image-dialog.css';
|
||||||
|
|
||||||
|
const { siteRoot, serviceUrl } = window.app.config;
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
repoID: PropTypes.string.isRequired,
|
repoID: PropTypes.string.isRequired,
|
||||||
filePath: PropTypes.string.isRequired,
|
filePath: PropTypes.string.isRequired,
|
||||||
@@ -24,7 +24,7 @@ class InsertRepoImageDialog extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
insertImage = () => {
|
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);
|
window.richMarkdownEditor.onInsertImage(url);
|
||||||
this.props.toggleCancel();
|
this.props.toggleCancel();
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ const MoreMenuPropTypes = {
|
|||||||
isSmallScreen: PropTypes.bool,
|
isSmallScreen: PropTypes.bool,
|
||||||
toggleShareLinkDialog: PropTypes.func,
|
toggleShareLinkDialog: PropTypes.func,
|
||||||
backToParentDirectory: PropTypes.func,
|
backToParentDirectory: PropTypes.func,
|
||||||
showFileHistory: PropTypes.func,
|
showFileHistory: PropTypes.bool,
|
||||||
toggleHistory: PropTypes.func,
|
toggleHistory: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -645,19 +645,9 @@ class MarkdownEditor extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getInsertLink = (repoID, filePath) => {
|
getInsertLink = (repoID, filePath) => {
|
||||||
seafileAPI.getShareLink(repoID, filePath).then((res) => {
|
const innerURL = serviceUrl + '/lib/' + repoID + '/file' + Utils.encodePath(filePath);
|
||||||
if (res.data.length !== 0) {
|
const fileName = Utils.getFileName(filePath);
|
||||||
let fileLink = res.data[0];
|
window.richMarkdownEditor.addLink(fileName, innerURL);
|
||||||
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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onContentChanged = (value) => {
|
onContentChanged = (value) => {
|
||||||
|
Reference in New Issue
Block a user