1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-31 22:54:11 +00:00

markdown view update (#6705)

* markdown view update

* code normal

* code normal

* code normal

* code normal
This commit is contained in:
yinjianfei-user
2024-09-07 16:29:45 +08:00
committed by GitHub
parent 05e85730dc
commit e595e72141
14 changed files with 207 additions and 81 deletions

View File

@@ -91,6 +91,7 @@ class LibContentView extends React.Component {
asyncOperationProgress: 0,
asyncOperatedFilesLength: 0,
viewId: '0000',
currentDirent: null
};
this.oldonpopstate = window.onpopstate;
@@ -466,7 +467,7 @@ class LibContentView extends React.Component {
window.history.pushState({ url: url, path: path }, path, url);
};
showFile = (filePath) => {
showFile = (filePath, noRedirection) => {
let repoID = this.props.repoID;
if (this.state.isTreePanelShown) {
@@ -514,6 +515,8 @@ class LibContentView extends React.Component {
});
});
if (noRedirection) return;
// update location
let repoInfo = this.state.currentRepoInfo;
let url = siteRoot + 'library/' + repoID + '/' + encodeURIComponent(repoInfo.repo_name) + Utils.encodePath(filePath);
@@ -1504,6 +1507,7 @@ class LibContentView extends React.Component {
this.showDir(direntPath);
} else { // is file
if (this.state.isTreePanelShown && Utils.isMarkdownFile(direntPath)) {
this.setState({ currentDirent: dirent });
this.showColumnMarkdownFile(direntPath);
} else {
let url = siteRoot + 'lib/' + repoID + '/file' + Utils.encodePath(direntPath);
@@ -1885,7 +1889,7 @@ class LibContentView extends React.Component {
const url = siteRoot + 'lib/' + repoID + '/file' + Utils.encodePath(filePath);
w.location.href = url;
} else {
this.showFile(filePath);
this.showFile(filePath, true);
}
}).catch(error => {
let errMessage = Utils.getErrorMsg(error);
@@ -1893,6 +1897,13 @@ class LibContentView extends React.Component {
});
};
onCloseMarkdownViewDialog = () => {
this.setState({
isViewFile: false,
path: '/'
});
};
onTreeNodeCollapse = (node) => {
let tree = treeHelper.collapseNode(this.state.treeData, node);
this.setState({ treeData: tree });
@@ -2179,7 +2190,7 @@ class LibContentView extends React.Component {
}
let enableDirPrivateShare = false;
let { currentRepoInfo, userPerm, isCopyMoveProgressDialogShow, isDeleteFolderDialogOpen } = this.state;
let { currentRepoInfo, userPerm, isCopyMoveProgressDialogShow, isDeleteFolderDialogOpen, currentDirent } = this.state;
let showShareBtn = Utils.isHasPermissionToShare(currentRepoInfo, userPerm);
let isRepoOwner = currentRepoInfo.owner_email === username;
let isVirtual = currentRepoInfo.is_virtual;
@@ -2256,6 +2267,7 @@ class LibContentView extends React.Component {
fullDirentList={this.state.direntList}
sortBy={this.state.sortBy}
sortOrder={this.state.sortOrder}
currentDirent={currentDirent}
sortItems={this.sortItems}
updateDirent={this.updateDirent}
onDirentClick={this.onDirentClick}
@@ -2291,6 +2303,7 @@ class LibContentView extends React.Component {
onUploadFile={this.onUploadFile}
onUploadFolder={this.onUploadFolder}
eventBus={this.props.eventBus}
onCloseMarkdownViewDialog={this.onCloseMarkdownViewDialog}
/>
{canUpload && this.state.pathExist && !this.state.isViewFile && (
<FileUploader