Test Enterprise-Class Web CMS Scrivito Free for 30 Days
Test Scrivito Free for 30 Days

canWrite()

Determines whether content is editable.

<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 can be useful when providing custom editing components and custom dialogs.

Returns

booleantrue if any content is editable, otherwise false.

Example

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' })}
    />
  // ...
));