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 590 forks source link

onChange called on init when view == null #611

Open fedotxxl opened 2 years ago

fedotxxl commented 2 years ago
  1. Create h1 opened, save
  2. Open, collapse h1, don't save
  3. Refresh

In this case, h1 state will be read from localStorage, differ from JSON persisted state and onChange callback triggered. The problem is that view is not ready and getting value will result to Cannot read properties of undefined (reading 'state')

Solution add this.view check?

  handleChange = () => {
    if (!this.props.onChange || !this.view) return;

    this.props.onChange(() => {
      return this.value();
    });
  };
came commented 2 years ago

I am getting the same error occasionally. And yes, it looks like it has something to do with h1 getting collapsed.

BR, Carsten