Skip to content

Commit

Permalink
fix: wiki cn input
Browse files Browse the repository at this point in the history
  • Loading branch information
libra-co committed Jun 13, 2024
1 parent 0e5fac3 commit 97aeb82
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions frontend/src/pages/wiki2/main-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,32 @@ class MainPanel extends Component {
serviceUrl: appConfig.serviceURL,
assets_url: appConfig.assetsUrl,
};
const currentPageConfig = getCurrentPageConfig(config.pages, currentPageId)
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
const { nativeEvent: { isComposing } } = e;
console.log('e', e);
console.log('isComposing', isComposing);
if (isComposing) return;

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;
}
console.log('newName', newName);
const pageConfig = { name: newName, icon };
this.props.onUpdatePage(id, pageConfig);
};

handleCompositionEnd = (e) => {

};

render() {
const { permission, pathExist, isDataLoading, isViewFile, config } = this.props;
const { currentPageConfig } = this.state
const { currentPageConfig } = this.state;
const isViewingFile = pathExist && !isDataLoading && isViewFile;
const isReadOnly = !(permission === 'rw');

Expand All @@ -92,7 +100,7 @@ class MainPanel extends Component {
document={this.props.editorContent}
docUuid={this.state.docUuid}
isWikiReadOnly={isReadOnly}
topSlot={<Input className='sf-wiki-title' bsSize="lg" onChange={this.handleRenameDocument} defaultValue={currentPageConfig.name} />}
topSlot={<Input className='sf-wiki-title' onCompositionEnd={this.handleRenameDocument} bsSize="lg" onChange={this.handleRenameDocument} defaultValue={currentPageConfig.name} />}
/>
</div>
)}
Expand Down

0 comments on commit 97aeb82

Please sign in to comment.