Prosemirror: Read only option

Created on 23 Jun 2016  路  3Comments  路  Source: ProseMirror/prosemirror

Prosemirror doesn't look like to have a readOnly option to disable editing. It could be useful to prevent modification while still displaying the editor.

This option could be implementing by toggling the contenteditable attribute.

Most helpful comment

Note to future web travellers passing by this place: the editable prop might be what you're looking for.

All 3 comments

If you simply toggle contentEditable, ProseMirror's key handlers will still be updating your document for a lot of keys. See this discussion and this event handler

Note to future web travellers passing by this place: the editable prop might be what you're looking for.

    const disabled = this.disabled;
    this.view = new EditorView(el, {
      state: this.state,
      dispatchTransaction: this.dispatch,
      nodeViews: this.nodeViews,
      attributes,
      editable() {
        return !disabled;
      },
    });
Was this page helpful?
0 / 5 - 0 ratings