mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-19 10:26:17 +00:00
@@ -127,21 +127,25 @@ class WikiMarkdownViewer extends React.Component {
|
|||||||
|
|
||||||
changeInlineNode = (item) => {
|
changeInlineNode = (item) => {
|
||||||
if (item.object == 'inline') {
|
if (item.object == 'inline') {
|
||||||
let url;
|
let url, imagePath;
|
||||||
|
|
||||||
// change image url
|
// change image url
|
||||||
if (item.type == 'image' && isPublicWiki) {
|
if (item.type == 'image' && isPublicWiki) {
|
||||||
url = item.data.src;
|
url = item.data.src;
|
||||||
const re = new RegExp(serviceURL + '/lib/' + repoID +'/file.*raw=1');
|
const re = new RegExp(serviceURL + '/lib/' + repoID +'/file.*raw=1');
|
||||||
// different repo
|
// different repo
|
||||||
if (!re.test(url)) {
|
if (re.test(url)) {
|
||||||
|
// get image path
|
||||||
|
let index = url.indexOf('/file');
|
||||||
|
let index2 = url.indexOf('?');
|
||||||
|
imagePath = url.substring(index + 5, index2);
|
||||||
|
} else if (/^\.\.\/*/.test(url) || /^\.\/*/.test(url)) {
|
||||||
|
const path = this.props.path;
|
||||||
|
const originalPath = path.slice(0, path.lastIndexOf('/')) + '/' + url;
|
||||||
|
imagePath = Utils.pathNormalize(originalPath);
|
||||||
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// get image path
|
|
||||||
let index = url.indexOf('/file');
|
|
||||||
let index2 = url.indexOf('?');
|
|
||||||
const imagePath = url.substring(index + 5, index2);
|
|
||||||
// replace url
|
|
||||||
item.data.src = serviceURL + '/view-image-via-public-wiki/?slug=' + slug + '&path=' + imagePath;
|
item.data.src = serviceURL + '/view-image-via-public-wiki/?slug=' + slug + '&path=' + imagePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -116,6 +116,7 @@ class MainPanel extends Component {
|
|||||||
latestContributor={this.props.latestContributor}
|
latestContributor={this.props.latestContributor}
|
||||||
onLinkClick={this.props.onLinkClick}
|
onLinkClick={this.props.onLinkClick}
|
||||||
isWiki={true}
|
isWiki={true}
|
||||||
|
path={this.props.path}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{(!this.props.isDataLoading && !this.props.isViewFile) && (
|
{(!this.props.isDataLoading && !this.props.isViewFile) && (
|
||||||
|
@@ -880,6 +880,21 @@ export const Utils = {
|
|||||||
return password;
|
return password;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
pathNormalize: function(originalPath) {
|
||||||
|
let oldPath = originalPath.split('/');
|
||||||
|
let newPath = [];
|
||||||
|
for (let i = 0; i < oldPath.length; i++) {
|
||||||
|
if (oldPath[i] === '.' || oldPath[i] === '') {
|
||||||
|
continue;
|
||||||
|
} else if (oldPath[i] === '..') {
|
||||||
|
newPath.pop();
|
||||||
|
} else {
|
||||||
|
newPath.push(oldPath[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newPath.join('/');
|
||||||
|
},
|
||||||
|
|
||||||
getEventData: function(event, data) {
|
getEventData: function(event, data) {
|
||||||
if (event.target.dataset) {
|
if (event.target.dataset) {
|
||||||
return event.target.dataset[data];
|
return event.target.dataset[data];
|
||||||
|
Reference in New Issue
Block a user