Search code examples
cordovatinymcecreate-react-appcapacitortinymce-react

How to Configure Local TinyMCE in create-react-app?


I am working on a React project using create-react-app which will be deployed as an iOS app using Capacitor.js (similar requirements apply to Cordova environments). I have encountered difficulties in setting up TinyMCE locally and am looking for guidance or solutions.

Problem Description: The main challenge is integrating a local instance of TinyMCE in a create-react-app environment. Despite placing the TinyMCE assets in the public folder and configuring them in TinyMCE, the editors do not initialize – they just display a blank area without any errors in the console.

I am utilizing the tinymce-react wrapper for integrating TinyMCE with React. Here's a brief overview of my current setup:

<Editor
  init={{
    base_url: '/tinymce',
    suffix: '.min',
  }}
/>

Constraints: TinyMCE Cloud: Using TinyMCE Cloud is not feasible due to the requirement for HTTP referer headers, which is problematic in a Capacitor.js/Cordova environment.

Questions: Are there established practices for successfully integrating a local TinyMCE setup within a create-react-app project, especially considering Capacitor.js/Cordova constraints?

Is there a particular configuration or setup aspect I might be overlooking for local TinyMCE integration in this scenario?

If anyone has experience deploying a create-react-app with local TinyMCE in a Capacitor.js or Cordova environment, could you share your insights or code examples?

I would greatly appreciate any help, suggestions, or pointers to relevant documentation. Alternative approaches that align with our project constraints are also welcome.

Thanks in advance for your assistance!


Solution

  • You should use tinymceScriptSrc to specify the path to TinyMCE

    <Editor
      tinymceScriptSrc='/path/to/tinymce.min.js'
    />
    

    See the tinymce-react documentation for more information.