Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Same component for display and edit mode #423

Closed
anothermohit opened this issue May 28, 2016 · 3 comments
Closed

Same component for display and edit mode #423

anothermohit opened this issue May 28, 2016 · 3 comments

Comments

@anothermohit
Copy link

anothermohit commented May 28, 2016

Can I keep the display and edit modes of Editor in a single react component? The display mode would load the initial editor state from the database (convertFromRaw) and clicking on an edit button (for the writer only) would make the content Editable and display a submit button to update/create the content.

Not sure if I am making sense but I want to use the same React component to

  • display the editor content to readers, and
  • load editor mode for the writer (with Edit/Submit buttons)

Any example implementing this would be great (with standard practices of switching between display/Edit mode)

@anothermohit
Copy link
Author

Just found out that I can switch on display mode with this -
this.setState({ editorEnabled: !this.state.editorEnabled });

But I am still curious if this approach is recommended or not.

@sophiebits
Copy link
Contributor

Draft doesn't do anything called editorEnabled so I'm not sure where you got that. You can set readOnly={true} on the root DraftEditor component though.

@anothermohit
Copy link
Author

Yeah, sorry about that. It's calling readOnly - https://github.com/brijeshb42/medium-draft/blob/master/src/editor.js#L284

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants