outline / rich-markdown-editor

The open source React and Prosemirror based markdown editor that powers Outline. Want to try it out? Create an account:
https://www.getoutline.com
BSD 3-Clause "New" or "Revised" License
2.87k stars 588 forks source link

feat: render method is not arrow function #500

Closed JiangWeixian closed 3 years ago

JiangWeixian commented 3 years ago

change render = () => {} to render() {}, is able to Inheritance Inversion Editor, just like in this way

const withStick = (WrappedComponent: React.ComponentClass<any>) => {
  return class WithStickBarEditor extends WrappedComponent {
    constructor (props) {
      super(props)
    }

    render() {
      return (
        <>
          {
            this.view && <StickBlockMenu
            view={this.view}
            commands={this.commands}
            dictionary={this.dictionary(this.props.dictionary)}
            rtl={this.state.isRTL}
            onClose={this.handleCloseBlockMenu}
            uploadImage={this.props.uploadImage}
            onLinkToolbarOpen={this.handleOpenLinkMenu}
            onImageUploadStart={this.props.onImageUploadStart}
            onImageUploadStop={this.props.onImageUploadStop}
            onShowToast={this.props.onShowToast}
          />
          }
          {super.render()}
        </>
      )
    }
  }
}

const StickEditor = withStick(Editor)

rime-hoc

demo code is in https://github.com/JiangWeixian/rich-markdown-editor/tree/ext