canWrite()

Determines whether content is editable.

Copy
<input disabled={!Scrivito.canWrite()} />

Scrivito.canWrite determines whether any content is currently editable. For this to be true, the UI must be present, and the editor must be on a working copy (i.e. not the published content) and have permission to change its content. This check is useful when providing custom editing components and custom dialogs.

Returns

booleantrue if any content is editable, otherwise false.

Copy
Scrivito.registerComponent('YesOrNoTab', ({ page }) => (
  // ...
    <input
      type="checkbox"
      checked={page.get('yesOrNo') === 'yes'}
      disabled={!Scrivito.canWrite()}
      onChange={e => page.update({ yesOrNo: e.target.checked ? 'yes' : 'no' })}
    />
  // ...
));