mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 07:27:04 +00:00
Revert "Feat wiki editor title seperation"
This commit is contained in:
14
frontend/package-lock.json
generated
14
frontend/package-lock.json
generated
@@ -14,7 +14,7 @@
|
||||
"@gatsbyjs/reach-router": "1.3.9",
|
||||
"@seafile/react-image-lightbox": "2.0.2",
|
||||
"@seafile/resumablejs": "1.1.16",
|
||||
"@seafile/sdoc-editor": "0.5.70",
|
||||
"@seafile/sdoc-editor": "0.5.69",
|
||||
"@seafile/seafile-calendar": "0.0.12",
|
||||
"@seafile/seafile-editor": "1.0.99",
|
||||
"@uiw/codemirror-extensions-langs": "^4.19.4",
|
||||
@@ -4617,15 +4617,9 @@
|
||||
"integrity": "sha512-8rBbmAEuuwOAGHYGCtEzpx+bxAcGS+V30otMmhRe7bPAdh4E57RWgCa8x7pkzHGFlY1t5d+ILz1gojvPVMYQig=="
|
||||
},
|
||||
"node_modules/@seafile/sdoc-editor": {
|
||||
<<<<<<< HEAD
|
||||
"version": "0.5.69",
|
||||
"resolved": "https://registry.npmjs.org/@seafile/sdoc-editor/-/sdoc-editor-0.5.69.tgz",
|
||||
"integrity": "sha512-9MFvdCuvFGPulhWHFR94AJlxpTl2OwxNewr/BazaJJK2tpdSCZLtY18zpLJotNWjyrALmpJwej7jVbauFhPP1w==",
|
||||
=======
|
||||
"version": "0.5.70",
|
||||
"resolved": "https://registry.npmjs.org/@seafile/sdoc-editor/-/sdoc-editor-0.5.70.tgz",
|
||||
"integrity": "sha512-V7QecojmGV/6D1F/eOGHSCeOpvJVMee6E3FArWDnf+IRYUs2rvvSKZ/STM2eutIHdjEH5SijkUCs9WySmdDDdA==",
|
||||
>>>>>>> 06c9fcc2d (feat: update @seafile/sddoc-editor@0.5.70)
|
||||
"dependencies": {
|
||||
"@seafile/print-js": "1.6.5",
|
||||
"@seafile/react-image-lightbox": "2.0.4",
|
||||
@@ -31298,15 +31292,9 @@
|
||||
"integrity": "sha512-8rBbmAEuuwOAGHYGCtEzpx+bxAcGS+V30otMmhRe7bPAdh4E57RWgCa8x7pkzHGFlY1t5d+ILz1gojvPVMYQig=="
|
||||
},
|
||||
"@seafile/sdoc-editor": {
|
||||
<<<<<<< HEAD
|
||||
"version": "0.5.69",
|
||||
"resolved": "https://registry.npmjs.org/@seafile/sdoc-editor/-/sdoc-editor-0.5.69.tgz",
|
||||
"integrity": "sha512-9MFvdCuvFGPulhWHFR94AJlxpTl2OwxNewr/BazaJJK2tpdSCZLtY18zpLJotNWjyrALmpJwej7jVbauFhPP1w==",
|
||||
=======
|
||||
"version": "0.5.70",
|
||||
"resolved": "https://registry.npmjs.org/@seafile/sdoc-editor/-/sdoc-editor-0.5.70.tgz",
|
||||
"integrity": "sha512-V7QecojmGV/6D1F/eOGHSCeOpvJVMee6E3FArWDnf+IRYUs2rvvSKZ/STM2eutIHdjEH5SijkUCs9WySmdDDdA==",
|
||||
>>>>>>> 06c9fcc2d (feat: update @seafile/sddoc-editor@0.5.70)
|
||||
"requires": {
|
||||
"@seafile/print-js": "1.6.5",
|
||||
"@seafile/react-image-lightbox": "2.0.4",
|
||||
|
@@ -9,7 +9,7 @@
|
||||
"@gatsbyjs/reach-router": "1.3.9",
|
||||
"@seafile/react-image-lightbox": "2.0.2",
|
||||
"@seafile/resumablejs": "1.1.16",
|
||||
"@seafile/sdoc-editor": "0.5.70",
|
||||
"@seafile/sdoc-editor": "0.5.69",
|
||||
"@seafile/seafile-calendar": "0.0.12",
|
||||
"@seafile/seafile-editor": "1.0.99",
|
||||
"@uiw/codemirror-extensions-langs": "^4.19.4",
|
||||
|
@@ -5,7 +5,7 @@ import { Modal } from 'reactstrap';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import wikiAPI from '../../utils/wiki-api';
|
||||
import SDocServerApi from '../../utils/sdoc-server-api';
|
||||
import { wikiId, siteRoot, lang, isWiki2, seadocServerUrl, gettext } from '../../utils/constants';
|
||||
import { wikiId, siteRoot, lang, isWiki2, seadocServerUrl } from '../../utils/constants';
|
||||
import WikiConfig from './models/wiki-config';
|
||||
import toaster from '../../components/toast';
|
||||
import SidePanel from './side-panel';
|
||||
@@ -172,24 +172,7 @@ class Wiki extends Component {
|
||||
});
|
||||
};
|
||||
|
||||
onUpdatePage = (pageId, newPage) => {
|
||||
if (newPage.name === '') {
|
||||
toaster.danger(gettext('Page name cannot be empty'));
|
||||
return;
|
||||
}
|
||||
const { config } = this.state
|
||||
let pages = config.pages;
|
||||
let newPages = pages.map(page => {
|
||||
if (page.id === pageId) {
|
||||
return { ...page, ...newPage };
|
||||
}
|
||||
return page;
|
||||
});
|
||||
const newConfig = { ...config, pages: newPages };
|
||||
this.saveWikiConfig(newConfig);
|
||||
};
|
||||
render() {
|
||||
|
||||
return (
|
||||
<div id="main" className="wiki-main">
|
||||
<SidePanel
|
||||
@@ -200,7 +183,6 @@ class Wiki extends Component {
|
||||
saveWikiConfig={this.saveWikiConfig}
|
||||
setCurrentPage={this.setCurrentPage}
|
||||
currentPageId={this.state.currentPageId}
|
||||
onUpdatePage={this.onUpdatePage}
|
||||
/>
|
||||
<MainPanel
|
||||
path={this.state.path}
|
||||
@@ -213,7 +195,6 @@ class Wiki extends Component {
|
||||
permission={this.state.permission}
|
||||
seadoc_access_token={this.state.seadoc_access_token}
|
||||
assets_url={this.state.assets_url}
|
||||
onUpdatePage={this.onUpdatePage}
|
||||
/>
|
||||
<MediaQuery query="(max-width: 767.8px)">
|
||||
<Modal isOpen={!this.state.closeSideBar} toggle={this.onCloseSide} contentClassName="d-none"></Modal>
|
||||
|
@@ -1,13 +1,11 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { SdocWikiViewer } from '@seafile/sdoc-editor';
|
||||
import { Input } from 'reactstrap';
|
||||
import { gettext, username } from '../../utils/constants';
|
||||
import Loading from '../../components/loading';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import Account from '../../components/common/account';
|
||||
import WikiTopNav from './top-nav';
|
||||
import { getCurrentPageConfig } from './utils';
|
||||
|
||||
const propTypes = {
|
||||
path: PropTypes.string.isRequired,
|
||||
@@ -20,7 +18,6 @@ const propTypes = {
|
||||
assets_url: PropTypes.string,
|
||||
config: PropTypes.object,
|
||||
currentPageId: PropTypes.string,
|
||||
onUpdatePage: PropTypes.func,
|
||||
};
|
||||
|
||||
class MainPanel extends Component {
|
||||
@@ -29,51 +26,36 @@ class MainPanel extends Component {
|
||||
super(props);
|
||||
this.state = {
|
||||
docUuid: '',
|
||||
currentPageConfig: {},
|
||||
};
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps(props, state) {
|
||||
const { seadoc_access_token, currentPageId, config } = props;
|
||||
const appConfig = window.app.config;
|
||||
const { seadoc_access_token } = props;
|
||||
const config = window.app.config;
|
||||
const pageOptions = window.app.pageOptions;
|
||||
const { assetsUrl, seadocServerUrl: sdocServer, } = window.wiki.config;
|
||||
window.seafile = {
|
||||
...window.seafile, // need docUuid
|
||||
...appConfig,
|
||||
...config,
|
||||
...pageOptions,
|
||||
sdocServer,
|
||||
assetsUrl: assetsUrl || props.assets_url,
|
||||
accessToken: seadoc_access_token,
|
||||
serviceUrl: appConfig.serviceURL,
|
||||
assets_url: appConfig.assetsUrl,
|
||||
serviceUrl: config.serviceURL,
|
||||
assets_url: config.assetsUrl,
|
||||
};
|
||||
const currentPageConfig = getCurrentPageConfig(config.pages, currentPageId)
|
||||
return { ...props, docUuid: window.seafile.docUuid, currentPageConfig };
|
||||
}
|
||||
|
||||
handleRenameDocument = (e) => {
|
||||
const newName = e.target.value.trim()
|
||||
const { currentPageConfig } = this.state
|
||||
const { id, name, icon } = currentPageConfig
|
||||
if (newName === name) return;
|
||||
const pageConfig = { name: newName, icon }
|
||||
this.props.onUpdatePage(id, pageConfig)
|
||||
// Reset title if name is empty
|
||||
if (!newName) e.target.value = name;
|
||||
return { ...props, docUuid: window.seafile.docUuid };
|
||||
}
|
||||
|
||||
render() {
|
||||
const { permission, pathExist, isDataLoading, isViewFile, config } = this.props;
|
||||
const { currentPageConfig } = this.state
|
||||
const { permission, pathExist, isDataLoading, isViewFile } = this.props;
|
||||
const isViewingFile = pathExist && !isDataLoading && isViewFile;
|
||||
const isReadOnly = !(permission === 'rw');
|
||||
|
||||
return (
|
||||
<div className="wiki2-main-panel">
|
||||
<div className='wiki2-main-panel-north'>
|
||||
<WikiTopNav
|
||||
config={config}
|
||||
config={this.props.config}
|
||||
currentPageId={this.props.currentPageId}
|
||||
/>
|
||||
{username &&
|
||||
@@ -87,14 +69,13 @@ class MainPanel extends Component {
|
||||
}
|
||||
{this.props.pathExist && this.props.isDataLoading && <Loading />}
|
||||
{isViewingFile && Utils.isSdocFile(this.props.path) && (
|
||||
<div>
|
||||
<SdocWikiViewer
|
||||
document={this.props.editorContent}
|
||||
showOutline={false}
|
||||
showToolbar={false}
|
||||
docUuid={this.state.docUuid}
|
||||
isWikiReadOnly={isReadOnly}
|
||||
topSlot={<Input className='sf-wiki-title' bsSize="lg" onChange={this.handleRenameDocument} defaultValue={currentPageConfig.name} />}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -28,7 +28,6 @@ const propTypes = {
|
||||
saveWikiConfig: PropTypes.func.isRequired,
|
||||
setCurrentPage: PropTypes.func.isRequired,
|
||||
currentPageId: PropTypes.string,
|
||||
onUpdatePage: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
class SidePanel extends Component {
|
||||
@@ -102,6 +101,19 @@ class SidePanel extends Component {
|
||||
this.props.saveWikiConfig(config, onSuccess, errorCallback);
|
||||
};
|
||||
|
||||
onUpdatePage = (pageId, newPage) => {
|
||||
if (newPage.name === '') {
|
||||
toaster.danger(gettext('Page name cannot be empty'));
|
||||
return;
|
||||
}
|
||||
const { config } = this.props;
|
||||
let pages = config.pages;
|
||||
let currentPage = pages.find(page => page.id === pageId);
|
||||
Object.assign(currentPage, newPage);
|
||||
config.pages = pages;
|
||||
this.props.saveWikiConfig(config);
|
||||
};
|
||||
|
||||
movePage = ({ moved_view_id, target_view_id, source_view_folder_id, target_view_folder_id, move_position }) => {
|
||||
let config = deepCopy(this.props.config);
|
||||
let { navigation } = config;
|
||||
@@ -274,7 +286,7 @@ class SidePanel extends Component {
|
||||
};
|
||||
|
||||
renderFolderView = () => {
|
||||
const { config, onUpdatePage } = this.props;
|
||||
const { config } = this.props;
|
||||
const { pages, navigation } = config;
|
||||
return (
|
||||
<div className="wiki2-pages-container">
|
||||
@@ -284,7 +296,7 @@ class SidePanel extends Component {
|
||||
views={pages}
|
||||
onToggleAddView={this.openAddPageDialog}
|
||||
onDeleteView={this.confirmDeletePage}
|
||||
onUpdatePage={onUpdatePage}
|
||||
onUpdatePage={this.onUpdatePage}
|
||||
onSelectView={this.props.setCurrentPage}
|
||||
onMoveView={this.movePage}
|
||||
movePageOut={this.movePageOut}
|
||||
|
@@ -43,8 +43,4 @@ const getIconURL = (repoId, fileName) => {
|
||||
return serviceURL + '/lib/' + repoId + '/file/_Internal/Wiki/Icon/' + fileName + '?raw=1';
|
||||
};
|
||||
|
||||
const getCurrentPageConfig = (pages,pageId) => {
|
||||
return pages.filter(page => page.id === pageId)[0]
|
||||
}
|
||||
|
||||
export { generatorBase64Code, generateUniqueId, isObjectNotEmpty, getIconURL, getCurrentPageConfig };
|
||||
export { generatorBase64Code, generateUniqueId, isObjectNotEmpty, getIconURL };
|
||||
|
@@ -61,13 +61,6 @@ img[src=""] {
|
||||
}
|
||||
}
|
||||
|
||||
.main-panel-center .cur-view-content .sf-wiki-title {
|
||||
border: none;
|
||||
padding: 0 50px;
|
||||
padding-left: 142px;
|
||||
font-weight: bold;
|
||||
font-size: 26pt;
|
||||
}
|
||||
|
||||
/* reset article h1 */
|
||||
.wiki2-main-panel .article h1 {
|
||||
@@ -226,15 +219,11 @@ img[src=""] {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.sdoc-editor-container .sdoc-editor-content {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.sdoc-editor-container .sdoc-editor-content .article {
|
||||
padding: 15px 142px 0px 142px;
|
||||
width: 100%;
|
||||
box-shadow: none;
|
||||
border: none;
|
||||
padding: 52px 142px 0;
|
||||
}
|
||||
|
||||
.sdoc-editor-container .sdoc-editor-content .sdoc-side-toolbar-container {
|
||||
|
@@ -427,7 +427,7 @@ class Wiki2PagesView(APIView):
|
||||
folder_id = request.data.get('folder_id', None)
|
||||
wiki_config = get_wiki_config(repo_id, request.user.username)
|
||||
|
||||
navigation = wiki_config.get('navigation', [])
|
||||
navigation = wiki_config.get('navigation')
|
||||
if not folder_id:
|
||||
page_ids = {element.get('id') for element in navigation if element.get('type') != 'folder'}
|
||||
else:
|
||||
|
Reference in New Issue
Block a user