tinymce / tinymce-react

Offical TinyMCE React component
MIT License
938 stars 151 forks source link

How to locally import language js file? #362

Closed CaptainJon closed 1 year ago

CaptainJon commented 2 years ago

I have downloaded the language js file, but according to the document, it looks like I have to deploy the js file on a server so I could use the 'language_url' option. However the problem is my application has no access to internet due to the server problem, and i dont want to deploy it on every server where the application runs, so is there any way to import the file locally and be bundled together with the application? I tried the following way, it it has a global vars problem:

import { Editor } from '@tinymce/tinymce-react'; import tinymce from 'tinymce/tinymce'; import './zh-Hans.js'; this will lead an error 'tinymce is not defined' in React

exalate-issue-sync[bot] commented 2 years ago

Ref: INT-2954

CaptainJon commented 2 years ago

actually I was building it as a public component with some custom settings to npm so my team can use it

tiny-james commented 1 year ago

Could you link a replication showing that problem using code-sandbox?

If you can avoid it I'd avoid bundling TinyMCE and host it, however there are guides on bundling it for react here: https://www.tiny.cloud/docs/tinymce/6/react-pm-bundle/

There's a bit more information about bundling UI localizations here (not specific to react but you should be able to adapt it): https://www.tiny.cloud/docs/tinymce/6/bundling-localization/

tiny-james commented 1 year ago

Note if you aren't loading the localization from node_modules you might have to follow the zip guide: https://www.tiny.cloud/docs/tinymce/6/react-zip-bundle/

tiny-james commented 1 year ago

Since I can't do more without a replication I'm closing this.