diff --git a/frontend/package-lock.json b/frontend/package-lock.json index d0fc9f9f6e..3404c28137 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -18,7 +18,7 @@ "@seafile/resumablejs": "1.1.16", "@seafile/sdoc-editor": "1.0.95", "@seafile/seafile-calendar": "0.0.28", - "@seafile/seafile-editor": "^1.0.116", + "@seafile/seafile-editor": "^1.0.118", "@seafile/sf-metadata-ui-component": "^0.0.40", "@uiw/codemirror-extensions-langs": "^4.19.4", "@uiw/react-codemirror": "^4.19.4", @@ -4990,9 +4990,9 @@ } }, "node_modules/@seafile/seafile-editor": { - "version": "1.0.116", - "resolved": "https://registry.npmjs.org/@seafile/seafile-editor/-/seafile-editor-1.0.116.tgz", - "integrity": "sha512-Gx01/IfSfAxYUP1oB57k7HfRvxvazyKYTfCe7vmh3mC7ylQohd/dT2HNFHi7uqFGcOq9OmCUd7mfu/mbCb9Cvg==", + "version": "1.0.118", + "resolved": "https://registry.npmjs.org/@seafile/seafile-editor/-/seafile-editor-1.0.118.tgz", + "integrity": "sha512-eDE+/NV+TZlJ+kXMF7cKFAVkSEJAUxfTsjIJMiazvblcIxZit5oW7sOZoZU2XexhPgIfNeB/z+8KQcceMM+qiA==", "dependencies": { "@seafile/react-image-lightbox": "2.0.5", "classnames": "2.3.2", diff --git a/frontend/package.json b/frontend/package.json index f6eecc9ed6..c581e24176 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -13,7 +13,7 @@ "@seafile/resumablejs": "1.1.16", "@seafile/sdoc-editor": "1.0.95", "@seafile/seafile-calendar": "0.0.28", - "@seafile/seafile-editor": "^1.0.116", + "@seafile/seafile-editor": "^1.0.118", "@seafile/sf-metadata-ui-component": "^0.0.40", "@uiw/codemirror-extensions-langs": "^4.19.4", "@uiw/react-codemirror": "^4.19.4", diff --git a/frontend/src/index.js b/frontend/src/index.js index 7a4713008b..4777bf7990 100644 --- a/frontend/src/index.js +++ b/frontend/src/index.js @@ -5,13 +5,20 @@ import { I18nextProvider } from 'react-i18next'; import i18n from './_i18n/i18n-seafile-editor'; import MarkdownEditor from './pages/markdown-editor'; import Loading from './components/loading'; +import { CollaboratorsProvider, EnableMetadataProvider } from './metadata'; import './index.css'; +const { repoID } = window.app.pageOptions; + ReactDom.render( }> - + + + + + , document.getElementById('root') diff --git a/frontend/src/pages/markdown-editor/header-toolbar/button-group.js b/frontend/src/pages/markdown-editor/header-toolbar/button-group.js index d728a61299..c4631f459f 100644 --- a/frontend/src/pages/markdown-editor/header-toolbar/button-group.js +++ b/frontend/src/pages/markdown-editor/header-toolbar/button-group.js @@ -1,10 +1,11 @@ import React from 'react'; import PropTypes from 'prop-types'; +import classnames from 'classnames'; class ButtonGroup extends React.PureComponent { render() { return ( -
+
{this.props.children}
); diff --git a/frontend/src/pages/markdown-editor/header-toolbar/header-toolbar.js b/frontend/src/pages/markdown-editor/header-toolbar/header-toolbar.js index 9741d63e4d..4600820de5 100644 --- a/frontend/src/pages/markdown-editor/header-toolbar/header-toolbar.js +++ b/frontend/src/pages/markdown-editor/header-toolbar/header-toolbar.js @@ -1,5 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; +import { EXTERNAL_EVENTS, EventBus } from '@seafile/seafile-editor'; import { gettext, canGenerateShareLink, isPro, mediaUrl, canLockUnlockFile } from '../../../utils/constants'; import ButtonGroup from './button-group'; import ButtonItem from './button-item'; @@ -7,11 +8,15 @@ import CollabUsersButton from './collab-users-button'; import MoreMenu from './more-menu'; import FileInfo from './file-info'; import Icon from '../../../components/icon'; +import EmbeddedFileDetails from '../../../components/dirent-detail/embedded-file-details'; +import { seafileAPI } from '../../../utils/seafile-api'; +import { Utils } from '../../../utils/utils'; +import Dirent from '../../../../src/models/dirent'; import '../css/header-toolbar.css'; const { seafileCollabServer } = window.app.config; -const { canDownloadFile } = window.app.pageOptions; +const { canDownloadFile, repoID, filePath } = window.app.pageOptions; const propTypes = { editorApi: PropTypes.object.isRequired, @@ -37,6 +42,10 @@ class HeaderToolbar extends React.Component { constructor(props) { super(props); + this.dirPath = filePath.substring(0, filePath.lastIndexOf('/') || 0) || '/'; + this.isFileInfoShow = false; + this.currentDirent = null; + this.helpInfoToggleSubscribe = null; } downloadFile = () => { @@ -53,6 +62,60 @@ class HeaderToolbar extends React.Component { window.location.href = editorApi.getParentDictionaryUrl(); }; + componentDidMount() { + this.getDirentList(); + + const eventBus = EventBus.getInstance(); + this.helpInfoToggleSubscribe = eventBus.subscribe(EXTERNAL_EVENTS.ON_HELP_INFO_TOGGLE, this.handleHelpClick); + } + + componentWillUnmount() { + this.helpInfoToggleSubscribe && this.helpInfoToggleSubscribe(); + } + + handleHelpClick = () => { + this.isFileInfoShow = false; + }; + + getDirentList = () => { + return seafileAPI.listDir(repoID, this.dirPath, { 'with_thumbnail': true }).then(res => { + const direntList = res.data.dirent_list || []; + for (let i = 0; i < direntList.length; i++) { + const item = direntList[i]; + const dirent = new Dirent(item); + if (Utils.joinPath(item.parent_dir, item.name) === filePath) { + this.currentDirent = dirent; + break; + } + } + }).catch((err) => { + Utils.getErrorMsg(err, true); + }); + }; + + onArticleInfoToggle = () => { + const repoInfo = { permission: this.currentDirent.permission }; + const eventBus = EventBus.getInstance(); + + eventBus.dispatch(EXTERNAL_EVENTS.ON_ARTICLE_INFO_TOGGLE, this.isFileInfoShow ? null : { + component: EmbeddedFileDetails, + props: { + repoID: repoID, + repoInfo: repoInfo, + dirent: this.currentDirent, + path: filePath, + onClose: this.onArticleInfoToggle, + width: 300, + component: { + headerComponent: { + closeIcon: () + } + } + } + }); + this.isFileInfoShow = !this.isFileInfoShow; + }; + render() { let { contentChanged, saving, isLocked, lockedByMe } = this.props; @@ -94,6 +157,12 @@ class HeaderToolbar extends React.Component { onMouseDown={this.props.toggleLockFile} /> )} + {canGenerateShareLink && (