Skip to content

Commit b7f32d3

Browse files
committed
refactor: use props
1 parent 5362dc9 commit b7f32d3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/editor/index.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -816,15 +816,15 @@ class Editor extends React.Component<EditorProps, EditorState> {
816816
}
817817

818818
render() {
819+
const { view, fullScreen, text, html } = this.state;
820+
const { id, className = "", style, name = "textarea", autoFocus, placeholder, readOnly } = this.props;
819821
const showHideMenu = this.config.canView && this.config.canView.hideMenu && !this.config.canView.menu;
820-
const { view, fullScreen } = this.state;
821822
const getPluginAt = (at: string) => this.state.plugins[at] || [];
822823
const isShowMenu = !!view.menu;
823-
const { id } = this.props;
824824
const editorId = id ? `${id}_md` : undefined;
825825
const previewerId = id ? `${id}_html` : undefined;
826826
return (
827-
<div id={id} className={`rc-md-editor ${fullScreen ? 'full' : ''} ${this.props.className ?? ''}`} style={this.props.style} onKeyDown={this.handleKeyDown} onDrop={this.handleDrop}>
827+
<div id={id} className={`rc-md-editor ${fullScreen ? 'full' : ''} ${className}`} style={style} onKeyDown={this.handleKeyDown} onDrop={this.handleDrop}>
828828
<NavigationBar visible={isShowMenu} left={getPluginAt('left')} right={getPluginAt('right')} />
829829
<div className="editor-container">
830830
{showHideMenu && (
@@ -838,11 +838,11 @@ class Editor extends React.Component<EditorProps, EditorState> {
838838
<textarea
839839
id={editorId}
840840
ref={this.nodeMdText}
841-
name={this.props.name || 'textarea'}
842-
autoFocus={this.props.autoFocus}
843-
placeholder={this.props.placeholder}
844-
readOnly={this.props.readOnly}
845-
value={this.state.text}
841+
name={name}
842+
autoFocus={autoFocus}
843+
placeholder={placeholder}
844+
readOnly={readOnly}
845+
value={text}
846846
className={`section-container input ${this.config.markdownClass || ''}`}
847847
wrap="hard"
848848
onChange={this.handleChange}
@@ -858,7 +858,7 @@ class Editor extends React.Component<EditorProps, EditorState> {
858858
</section>
859859
<section className={`section sec-html ${view.html ? 'visible' : 'in-visible'}`}>
860860
<div id={previewerId} className="section-container html-wrap" ref={this.nodeMdPreviewWrapper} onMouseOver={() => (this.shouldSyncScroll = 'html')} onScroll={this.handlePreviewScroll}>
861-
<HtmlRender html={this.state.html} className={this.config.htmlClass} ref={this.nodeMdPreview} />
861+
<HtmlRender html={html} className={this.config.htmlClass} ref={this.nodeMdPreview} />
862862
</div>
863863
</section>
864864
</div>

0 commit comments

Comments
 (0)