tinymce / tinymce-react

Offical TinyMCE React component
MIT License
937 stars 152 forks source link

Error TS for use readonly with React JS (Editor) #526

Closed JeremyMAQUAIRE closed 1 month ago

JeremyMAQUAIRE commented 1 month ago
 <Editor
    apiKey={config.REACT_APP_TINYMCE}
    initialValue={user.textConsigne}
    init={{
      language: 'fr_FR',
      height: 550,
      menubar: false,
      toolbar: false,
      readonly: true,
      content_style:
        'body { font-family:Helvetica,Arial,sans-serif; font-size:12px }',
    }}
  />

Hello,

I would like to add the readOnly attribute to true in the init part but I have a TS error that I cannot correct =>

Unable to assign type 'true' to type 'undefined'.ts(2322) (property) readonly: boolean

Thanks for your help

danoaky-tiny commented 1 month ago

The init.readonly prop is overridden by the integration, this is why it's typed as undefined. Use disabled instead. See: https://www.tiny.cloud/docs/tinymce/latest/react-ref/#init