Skip to content

Read Mode / Edit Mode

Set the current mode

To get the reference to the editor, see Get Editor reference.

You can change the mode as follows:

editor.setEditable(true);

Retrieve the current mode

In order to find the current mode of the editor you can use:

const isEditable = editor.isEditable(); // Returns true or false

You can also get notified when the editor’s read only mode has changed:

const removeEditableListener = editor.registerEditableListener(
(isEditable) => {
// The editor's mode is passed in!
console.log(isEditable);
},
);
// Do not forget to unregister the listener when no longer needed!
removeEditableListener();

Launch in Read mode

To launch the editor in Read mode, set the editable flag in the initialConfig.

const initialConfig = {
theme: theme,
namespace: 'pg_demo',
nodes: [HorizontalRuleNode],
editable: false,
onError: (error: Error) => {
throw error;
}
};