mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 17:02:47 +00:00
add save button (#3270)
This commit is contained in:
@@ -24,6 +24,8 @@ const propTypes = {
|
|||||||
toggleCommentList: PropTypes.func.isRequired,
|
toggleCommentList: PropTypes.func.isRequired,
|
||||||
editorMode: PropTypes.string.isRequired,
|
editorMode: PropTypes.string.isRequired,
|
||||||
readOnly: PropTypes.bool.isRequired,
|
readOnly: PropTypes.bool.isRequired,
|
||||||
|
contentChanged: PropTypes.bool.isRequired,
|
||||||
|
saving: PropTypes.bool.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
const MoreMenuPropTypes = {
|
const MoreMenuPropTypes = {
|
||||||
@@ -84,6 +86,7 @@ class MarkdownViewerToolbar extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
let { contentChanged, saving } = this.props;
|
||||||
|
|
||||||
if (this.props.editorMode === 'rich') {
|
if (this.props.editorMode === 'rich') {
|
||||||
return (
|
return (
|
||||||
@@ -122,6 +125,13 @@ class MarkdownViewerToolbar extends React.Component {
|
|||||||
this.props.showFileHistory && <IconButton id={'historyButton'}
|
this.props.showFileHistory && <IconButton id={'historyButton'}
|
||||||
text={gettext('File History')} onMouseDown={this.props.toggleHistory} icon={'fa fa-history'}/>
|
text={gettext('File History')} onMouseDown={this.props.toggleHistory} icon={'fa fa-history'}/>
|
||||||
}
|
}
|
||||||
|
{ saving ?
|
||||||
|
<button type={'button'} className={'btn btn-icon btn-secondary btn-active'}>
|
||||||
|
<i className={'fa fa-spin fa-spinner'}/></button>
|
||||||
|
:
|
||||||
|
<IconButton text={gettext('Save')} id={'saveButton'} icon={'fa fa-save'} disabled={!contentChanged}
|
||||||
|
onMouseDown={window.seafileEditor && window.seafileEditor.onPlainEditorSave} isActive={contentChanged}/>
|
||||||
|
}
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
<MoreMenu
|
<MoreMenu
|
||||||
readOnly={this.props.readOnly}
|
readOnly={this.props.readOnly}
|
||||||
@@ -142,6 +152,14 @@ class MarkdownViewerToolbar extends React.Component {
|
|||||||
<div className="topbar-btn-container">
|
<div className="topbar-btn-container">
|
||||||
{this.props.collabUsers.length > 0 && <CollabUsersButton className={'collab-users-dropdown'}
|
{this.props.collabUsers.length > 0 && <CollabUsersButton className={'collab-users-dropdown'}
|
||||||
users={this.props.collabUsers} id={'usersButton'} />}
|
users={this.props.collabUsers} id={'usersButton'} />}
|
||||||
|
<ButtonGroup>
|
||||||
|
{ saving ?
|
||||||
|
<button type={'button'} className={'btn btn-icon btn-secondary btn-active'}>
|
||||||
|
<i className={'fa fa-spin fa-spinner'}/></button>
|
||||||
|
:
|
||||||
|
<IconButton id={'saveButton'} text={gettext('Save')} icon={'fa fa-save'} onMouseDown={window.seafileEditor && window.seafileEditor.onPlainEditorSave} disabled={!contentChanged} isActive={contentChanged} />
|
||||||
|
}
|
||||||
|
</ButtonGroup>
|
||||||
<MoreMenu
|
<MoreMenu
|
||||||
readOnly={this.props.readOnly}
|
readOnly={this.props.readOnly}
|
||||||
openDialogs={this.props.openDialogs}
|
openDialogs={this.props.openDialogs}
|
||||||
|
@@ -291,6 +291,8 @@ class MarkdownEditor extends React.Component {
|
|||||||
isShowComments: false,
|
isShowComments: false,
|
||||||
isShowHistory: false,
|
isShowHistory: false,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
|
contentChanged: false,
|
||||||
|
saving: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.state.collabServer) {
|
if (this.state.collabServer) {
|
||||||
@@ -450,6 +452,7 @@ class MarkdownEditor extends React.Component {
|
|||||||
{
|
{
|
||||||
case 'help':
|
case 'help':
|
||||||
window.richMarkdownEditor.showHelpDialog();
|
window.richMarkdownEditor.showHelpDialog();
|
||||||
|
this.setState({ isShowComments: false });
|
||||||
break;
|
break;
|
||||||
case 'share_link':
|
case 'share_link':
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -515,7 +518,7 @@ class MarkdownEditor extends React.Component {
|
|||||||
// case1: If file is draft file
|
// case1: If file is draft file
|
||||||
// case2: If mode == 'edit' and the file has no draft
|
// case2: If mode == 'edit' and the file has no draft
|
||||||
// case3: The length of markDownContent is 1 when clear all content in editor and the file has no draft
|
// case3: The length of markDownContent is 1 when clear all content in editor and the file has no draft
|
||||||
readOnly: !(hasPermission && (isDraft || (isEditMode && !hasDraft) || (isBlankFile && !hasDraft))),
|
readOnly: !hasPermission || hasDraft,
|
||||||
value: value,
|
value: value,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -650,6 +653,7 @@ class MarkdownEditor extends React.Component {
|
|||||||
|
|
||||||
toggleCommentList = () => {
|
toggleCommentList = () => {
|
||||||
this.setState({ isShowComments: !this.state.isShowComments });
|
this.setState({ isShowComments: !this.state.isShowComments });
|
||||||
|
window.richMarkdownEditor.handleCommentOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
getInsertLink = (repoID, filePath) => {
|
getInsertLink = (repoID, filePath) => {
|
||||||
@@ -668,6 +672,14 @@ class MarkdownEditor extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onContentChanged = (value) => {
|
||||||
|
this.setState({ contentChanged: value });
|
||||||
|
}
|
||||||
|
|
||||||
|
onSaving = (value) => {
|
||||||
|
this.setState({ saving: value });
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let component;
|
let component;
|
||||||
let sidePanel = this.state.isShowHistory ? true : false;
|
let sidePanel = this.state.isShowHistory ? true : false;
|
||||||
@@ -700,6 +712,8 @@ class MarkdownEditor extends React.Component {
|
|||||||
readOnly={this.state.readOnly}
|
readOnly={this.state.readOnly}
|
||||||
mode={this.state.mode}
|
mode={this.state.mode}
|
||||||
editorMode={this.state.editorMode}
|
editorMode={this.state.editorMode}
|
||||||
|
contentChanged={this.state.contentChanged}
|
||||||
|
saving={this.state.saving}
|
||||||
/>
|
/>
|
||||||
<SeafileEditor
|
<SeafileEditor
|
||||||
fileInfo={this.state.fileInfo}
|
fileInfo={this.state.fileInfo}
|
||||||
@@ -725,6 +739,10 @@ class MarkdownEditor extends React.Component {
|
|||||||
deleteDraft={this.deleteDraft}
|
deleteDraft={this.deleteDraft}
|
||||||
showDraftSaved={this.state.showDraftSaved}
|
showDraftSaved={this.state.showDraftSaved}
|
||||||
readOnly={this.state.readOnly}
|
readOnly={this.state.readOnly}
|
||||||
|
onContentChanged={this.onContentChanged}
|
||||||
|
onSaving={this.onSaving}
|
||||||
|
contentChanged={this.state.contentChanged}
|
||||||
|
saving={this.state.saving}
|
||||||
/>
|
/>
|
||||||
{this.state.isShowComments &&
|
{this.state.isShowComments &&
|
||||||
<div className="seafile-md-comment">
|
<div className="seafile-md-comment">
|
||||||
|
Reference in New Issue
Block a user