1
0
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:
杨顺强
2024-06-11 17:42:09 +08:00
committed by GitHub
parent 9029c8462e
commit 73926f6a49
8 changed files with 37 additions and 90 deletions

View File

@@ -14,7 +14,7 @@
"@gatsbyjs/reach-router": "1.3.9", "@gatsbyjs/reach-router": "1.3.9",
"@seafile/react-image-lightbox": "2.0.2", "@seafile/react-image-lightbox": "2.0.2",
"@seafile/resumablejs": "1.1.16", "@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-calendar": "0.0.12",
"@seafile/seafile-editor": "1.0.99", "@seafile/seafile-editor": "1.0.99",
"@uiw/codemirror-extensions-langs": "^4.19.4", "@uiw/codemirror-extensions-langs": "^4.19.4",
@@ -4617,15 +4617,9 @@
"integrity": "sha512-8rBbmAEuuwOAGHYGCtEzpx+bxAcGS+V30otMmhRe7bPAdh4E57RWgCa8x7pkzHGFlY1t5d+ILz1gojvPVMYQig==" "integrity": "sha512-8rBbmAEuuwOAGHYGCtEzpx+bxAcGS+V30otMmhRe7bPAdh4E57RWgCa8x7pkzHGFlY1t5d+ILz1gojvPVMYQig=="
}, },
"node_modules/@seafile/sdoc-editor": { "node_modules/@seafile/sdoc-editor": {
<<<<<<< HEAD
"version": "0.5.69", "version": "0.5.69",
"resolved": "https://registry.npmjs.org/@seafile/sdoc-editor/-/sdoc-editor-0.5.69.tgz", "resolved": "https://registry.npmjs.org/@seafile/sdoc-editor/-/sdoc-editor-0.5.69.tgz",
"integrity": "sha512-9MFvdCuvFGPulhWHFR94AJlxpTl2OwxNewr/BazaJJK2tpdSCZLtY18zpLJotNWjyrALmpJwej7jVbauFhPP1w==", "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": { "dependencies": {
"@seafile/print-js": "1.6.5", "@seafile/print-js": "1.6.5",
"@seafile/react-image-lightbox": "2.0.4", "@seafile/react-image-lightbox": "2.0.4",
@@ -31298,15 +31292,9 @@
"integrity": "sha512-8rBbmAEuuwOAGHYGCtEzpx+bxAcGS+V30otMmhRe7bPAdh4E57RWgCa8x7pkzHGFlY1t5d+ILz1gojvPVMYQig==" "integrity": "sha512-8rBbmAEuuwOAGHYGCtEzpx+bxAcGS+V30otMmhRe7bPAdh4E57RWgCa8x7pkzHGFlY1t5d+ILz1gojvPVMYQig=="
}, },
"@seafile/sdoc-editor": { "@seafile/sdoc-editor": {
<<<<<<< HEAD
"version": "0.5.69", "version": "0.5.69",
"resolved": "https://registry.npmjs.org/@seafile/sdoc-editor/-/sdoc-editor-0.5.69.tgz", "resolved": "https://registry.npmjs.org/@seafile/sdoc-editor/-/sdoc-editor-0.5.69.tgz",
"integrity": "sha512-9MFvdCuvFGPulhWHFR94AJlxpTl2OwxNewr/BazaJJK2tpdSCZLtY18zpLJotNWjyrALmpJwej7jVbauFhPP1w==", "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": { "requires": {
"@seafile/print-js": "1.6.5", "@seafile/print-js": "1.6.5",
"@seafile/react-image-lightbox": "2.0.4", "@seafile/react-image-lightbox": "2.0.4",

View File

@@ -9,7 +9,7 @@
"@gatsbyjs/reach-router": "1.3.9", "@gatsbyjs/reach-router": "1.3.9",
"@seafile/react-image-lightbox": "2.0.2", "@seafile/react-image-lightbox": "2.0.2",
"@seafile/resumablejs": "1.1.16", "@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-calendar": "0.0.12",
"@seafile/seafile-editor": "1.0.99", "@seafile/seafile-editor": "1.0.99",
"@uiw/codemirror-extensions-langs": "^4.19.4", "@uiw/codemirror-extensions-langs": "^4.19.4",

View File

@@ -5,7 +5,7 @@ import { Modal } from 'reactstrap';
import { Utils } from '../../utils/utils'; import { Utils } from '../../utils/utils';
import wikiAPI from '../../utils/wiki-api'; import wikiAPI from '../../utils/wiki-api';
import SDocServerApi from '../../utils/sdoc-server-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 WikiConfig from './models/wiki-config';
import toaster from '../../components/toast'; import toaster from '../../components/toast';
import SidePanel from './side-panel'; import SidePanel from './side-panel';
@@ -171,25 +171,8 @@ class Wiki extends Component {
callback && callback(); callback && callback();
}); });
}; };
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() {
render() {
return ( return (
<div id="main" className="wiki-main"> <div id="main" className="wiki-main">
<SidePanel <SidePanel
@@ -200,7 +183,6 @@ class Wiki extends Component {
saveWikiConfig={this.saveWikiConfig} saveWikiConfig={this.saveWikiConfig}
setCurrentPage={this.setCurrentPage} setCurrentPage={this.setCurrentPage}
currentPageId={this.state.currentPageId} currentPageId={this.state.currentPageId}
onUpdatePage={this.onUpdatePage}
/> />
<MainPanel <MainPanel
path={this.state.path} path={this.state.path}
@@ -213,7 +195,6 @@ class Wiki extends Component {
permission={this.state.permission} permission={this.state.permission}
seadoc_access_token={this.state.seadoc_access_token} seadoc_access_token={this.state.seadoc_access_token}
assets_url={this.state.assets_url} assets_url={this.state.assets_url}
onUpdatePage={this.onUpdatePage}
/> />
<MediaQuery query="(max-width: 767.8px)"> <MediaQuery query="(max-width: 767.8px)">
<Modal isOpen={!this.state.closeSideBar} toggle={this.onCloseSide} contentClassName="d-none"></Modal> <Modal isOpen={!this.state.closeSideBar} toggle={this.onCloseSide} contentClassName="d-none"></Modal>

View File

@@ -1,13 +1,11 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { SdocWikiViewer } from '@seafile/sdoc-editor'; import { SdocWikiViewer } from '@seafile/sdoc-editor';
import { Input } from 'reactstrap';
import { gettext, username } from '../../utils/constants'; import { gettext, username } from '../../utils/constants';
import Loading from '../../components/loading'; import Loading from '../../components/loading';
import { Utils } from '../../utils/utils'; import { Utils } from '../../utils/utils';
import Account from '../../components/common/account'; import Account from '../../components/common/account';
import WikiTopNav from './top-nav'; import WikiTopNav from './top-nav';
import { getCurrentPageConfig } from './utils';
const propTypes = { const propTypes = {
path: PropTypes.string.isRequired, path: PropTypes.string.isRequired,
@@ -20,7 +18,6 @@ const propTypes = {
assets_url: PropTypes.string, assets_url: PropTypes.string,
config: PropTypes.object, config: PropTypes.object,
currentPageId: PropTypes.string, currentPageId: PropTypes.string,
onUpdatePage: PropTypes.func,
}; };
class MainPanel extends Component { class MainPanel extends Component {
@@ -29,51 +26,36 @@ class MainPanel extends Component {
super(props); super(props);
this.state = { this.state = {
docUuid: '', docUuid: '',
currentPageConfig: {},
}; };
} }
static getDerivedStateFromProps(props, state) { static getDerivedStateFromProps(props, state) {
const { seadoc_access_token, currentPageId, config } = props; const { seadoc_access_token } = props;
const appConfig = window.app.config; const config = window.app.config;
const pageOptions = window.app.pageOptions; const pageOptions = window.app.pageOptions;
const { assetsUrl, seadocServerUrl: sdocServer, } = window.wiki.config; const { assetsUrl, seadocServerUrl: sdocServer, } = window.wiki.config;
window.seafile = { window.seafile = {
...window.seafile, // need docUuid ...window.seafile, // need docUuid
...appConfig, ...config,
...pageOptions, ...pageOptions,
sdocServer, sdocServer,
assetsUrl: assetsUrl || props.assets_url, assetsUrl: assetsUrl || props.assets_url,
accessToken: seadoc_access_token, accessToken: seadoc_access_token,
serviceUrl: appConfig.serviceURL, serviceUrl: config.serviceURL,
assets_url: appConfig.assetsUrl, assets_url: config.assetsUrl,
}; };
const currentPageConfig = getCurrentPageConfig(config.pages, currentPageId) return { ...props, docUuid: window.seafile.docUuid };
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;
} }
render() { render() {
const { permission, pathExist, isDataLoading, isViewFile, config } = this.props; const { permission, pathExist, isDataLoading, isViewFile } = this.props;
const { currentPageConfig } = this.state
const isViewingFile = pathExist && !isDataLoading && isViewFile; const isViewingFile = pathExist && !isDataLoading && isViewFile;
const isReadOnly = !(permission === 'rw'); const isReadOnly = !(permission === 'rw');
return ( return (
<div className="wiki2-main-panel"> <div className="wiki2-main-panel">
<div className='wiki2-main-panel-north'> <div className='wiki2-main-panel-north'>
<WikiTopNav <WikiTopNav
config={config} config={this.props.config}
currentPageId={this.props.currentPageId} currentPageId={this.props.currentPageId}
/> />
{username && {username &&
@@ -87,14 +69,13 @@ class MainPanel extends Component {
} }
{this.props.pathExist && this.props.isDataLoading && <Loading />} {this.props.pathExist && this.props.isDataLoading && <Loading />}
{isViewingFile && Utils.isSdocFile(this.props.path) && ( {isViewingFile && Utils.isSdocFile(this.props.path) && (
<div> <SdocWikiViewer
<SdocWikiViewer document={this.props.editorContent}
document={this.props.editorContent} showOutline={false}
docUuid={this.state.docUuid} showToolbar={false}
isWikiReadOnly={isReadOnly} docUuid={this.state.docUuid}
topSlot={<Input className='sf-wiki-title' bsSize="lg" onChange={this.handleRenameDocument} defaultValue={currentPageConfig.name} />} isWikiReadOnly={isReadOnly}
/> />
</div>
)} )}
</div> </div>
</div> </div>

View File

@@ -28,7 +28,6 @@ const propTypes = {
saveWikiConfig: PropTypes.func.isRequired, saveWikiConfig: PropTypes.func.isRequired,
setCurrentPage: PropTypes.func.isRequired, setCurrentPage: PropTypes.func.isRequired,
currentPageId: PropTypes.string, currentPageId: PropTypes.string,
onUpdatePage: PropTypes.func.isRequired,
}; };
class SidePanel extends Component { class SidePanel extends Component {
@@ -102,6 +101,19 @@ class SidePanel extends Component {
this.props.saveWikiConfig(config, onSuccess, errorCallback); 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 }) => { movePage = ({ moved_view_id, target_view_id, source_view_folder_id, target_view_folder_id, move_position }) => {
let config = deepCopy(this.props.config); let config = deepCopy(this.props.config);
let { navigation } = config; let { navigation } = config;
@@ -274,7 +286,7 @@ class SidePanel extends Component {
}; };
renderFolderView = () => { renderFolderView = () => {
const { config, onUpdatePage } = this.props; const { config } = this.props;
const { pages, navigation } = config; const { pages, navigation } = config;
return ( return (
<div className="wiki2-pages-container"> <div className="wiki2-pages-container">
@@ -284,7 +296,7 @@ class SidePanel extends Component {
views={pages} views={pages}
onToggleAddView={this.openAddPageDialog} onToggleAddView={this.openAddPageDialog}
onDeleteView={this.confirmDeletePage} onDeleteView={this.confirmDeletePage}
onUpdatePage={onUpdatePage} onUpdatePage={this.onUpdatePage}
onSelectView={this.props.setCurrentPage} onSelectView={this.props.setCurrentPage}
onMoveView={this.movePage} onMoveView={this.movePage}
movePageOut={this.movePageOut} movePageOut={this.movePageOut}

View File

@@ -43,8 +43,4 @@ const getIconURL = (repoId, fileName) => {
return serviceURL + '/lib/' + repoId + '/file/_Internal/Wiki/Icon/' + fileName + '?raw=1'; return serviceURL + '/lib/' + repoId + '/file/_Internal/Wiki/Icon/' + fileName + '?raw=1';
}; };
const getCurrentPageConfig = (pages,pageId) => { export { generatorBase64Code, generateUniqueId, isObjectNotEmpty, getIconURL };
return pages.filter(page => page.id === pageId)[0]
}
export { generatorBase64Code, generateUniqueId, isObjectNotEmpty, getIconURL, getCurrentPageConfig };

View File

@@ -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 */ /* reset article h1 */
.wiki2-main-panel .article h1 { .wiki2-main-panel .article h1 {
@@ -226,15 +219,11 @@ img[src=""] {
width: 100%; width: 100%;
} }
.sdoc-editor-container .sdoc-editor-content {
flex-direction: column;
}
.sdoc-editor-container .sdoc-editor-content .article { .sdoc-editor-container .sdoc-editor-content .article {
padding: 15px 142px 0px 142px;
width: 100%; width: 100%;
box-shadow: none; box-shadow: none;
border: none; border: none;
padding: 52px 142px 0;
} }
.sdoc-editor-container .sdoc-editor-content .sdoc-side-toolbar-container { .sdoc-editor-container .sdoc-editor-content .sdoc-side-toolbar-container {

View File

@@ -427,7 +427,7 @@ class Wiki2PagesView(APIView):
folder_id = request.data.get('folder_id', None) folder_id = request.data.get('folder_id', None)
wiki_config = get_wiki_config(repo_id, request.user.username) wiki_config = get_wiki_config(repo_id, request.user.username)
navigation = wiki_config.get('navigation', []) navigation = wiki_config.get('navigation')
if not folder_id: if not folder_id:
page_ids = {element.get('id') for element in navigation if element.get('type') != 'folder'} page_ids = {element.get('id') for element in navigation if element.get('type') != 'folder'}
else: else: