2023-05-12 14:12:28 +08:00
|
|
|
import React, { Fragment } from 'react';
|
|
|
|
import { SimpleEditor } from '@seafile/sdoc-editor';
|
|
|
|
import ExternalOperations from './external-operations';
|
2023-11-22 11:29:01 +08:00
|
|
|
import { Utils } from '../../../utils/utils';
|
2023-05-12 14:12:28 +08:00
|
|
|
|
|
|
|
export default class SdocEditor extends React.Component {
|
2023-06-30 21:51:27 +08:00
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2023-07-22 15:54:25 +08:00
|
|
|
const { isStarred, isSdocDraft } = window.app.pageOptions;
|
2023-06-30 21:51:27 +08:00
|
|
|
this.state = {
|
2023-07-22 15:54:25 +08:00
|
|
|
isStarred: isStarred,
|
|
|
|
isDraft: isSdocDraft
|
2023-06-30 21:51:27 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-11-22 11:29:01 +08:00
|
|
|
componentDidMount() {
|
2024-01-05 11:49:34 +08:00
|
|
|
this.onSetFavicon();
|
2023-11-22 11:29:01 +08:00
|
|
|
}
|
|
|
|
|
2023-06-30 21:51:27 +08:00
|
|
|
toggleStar = (isStarred) => {
|
|
|
|
this.setState({isStarred: isStarred});
|
2023-09-13 08:40:50 +08:00
|
|
|
};
|
2023-06-30 21:51:27 +08:00
|
|
|
|
2023-07-22 15:54:25 +08:00
|
|
|
unmarkDraft = () => {
|
|
|
|
this.setState({isDraft: false});
|
2023-09-13 08:40:50 +08:00
|
|
|
};
|
2023-07-22 15:54:25 +08:00
|
|
|
|
2024-01-05 11:49:34 +08:00
|
|
|
onSetFavicon = (suffix) => {
|
|
|
|
let { docName } = window.seafile;
|
|
|
|
if (suffix) {
|
|
|
|
docName = docName + suffix;
|
|
|
|
}
|
|
|
|
const fileIcon = Utils.getFileIconUrl(docName, 192);
|
|
|
|
document.getElementById('favicon').href = fileIcon;
|
|
|
|
};
|
|
|
|
|
|
|
|
onNewNotification = () => {
|
|
|
|
this.onSetFavicon('_notification');
|
|
|
|
};
|
|
|
|
|
2023-05-12 14:12:28 +08:00
|
|
|
render() {
|
2023-08-10 18:05:01 +08:00
|
|
|
const { repoID, docPath, docName, docPerm } = window.seafile;
|
2023-07-22 15:54:25 +08:00
|
|
|
const { isStarred, isDraft } = this.state;
|
2023-05-12 14:12:28 +08:00
|
|
|
return (
|
|
|
|
<Fragment>
|
2023-07-22 15:54:25 +08:00
|
|
|
<SimpleEditor isStarred={isStarred} isDraft={isDraft} />
|
2023-06-30 21:51:27 +08:00
|
|
|
<ExternalOperations
|
|
|
|
repoID={repoID}
|
|
|
|
docPath={docPath}
|
2023-08-10 18:05:01 +08:00
|
|
|
docName={docName}
|
2023-08-11 16:33:06 +08:00
|
|
|
docPerm={docPerm}
|
2023-06-30 21:51:27 +08:00
|
|
|
isStarred={isStarred}
|
|
|
|
toggleStar={this.toggleStar}
|
2023-07-22 15:54:25 +08:00
|
|
|
unmarkDraft={this.unmarkDraft}
|
2024-01-05 11:49:34 +08:00
|
|
|
onNewNotification={this.onNewNotification}
|
2023-06-30 21:51:27 +08:00
|
|
|
/>
|
2023-05-12 14:12:28 +08:00
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|