# editor

Source: https://developers.inkdrop.app/states/editor

An [app state](https://developers.inkdrop.app/guides/flux-architecture) of the editor.
You can obtain the `editor` state and integrate it with React components.

---

## Data Structure

- **changed** (boolean)

  `true` if the note has been changed.
  The editor will save the note if `changed` is true when it is closed.
- **needsUpdatingDate** (boolean)

  Whether the note's `updatedAt` field needs to be updated or not.
- **viewMode** ('preview' | 'sideBySide' | 'edit')

  The editor view mode which represents either `'preview'`, `'sideBySide'` or `'edit'`.
- **openingNoteId** (string | undefined)

  When the app is trying to open a note, it indicates its' note ID, otherwise `undefined`.
- **readOnly** (boolean)

  true if the editor is in read only mode.
- **savingNoteId** (string | undefined)

  When the app is saving the note, it indicates its' note ID, otherwise will be `undefined`.
- **lastError** (AssistiveError | undefined)

  The last error that occurred.

Get the `editor` state manually:

```js
const { editor } = env.store.getState()
```

Connect the state with your React component:

```js
import { useSelector } from 'react-redux'
const selector = ({ editor }) => editor
const MyComponent = props => {
  const editor = useSelector(selector)
  // render
}
```
