Skip to content

Commit

Permalink
Merge pull request #27 from linc-technologies/feature/HERO-9362-tinym…
Browse files Browse the repository at this point in the history
…ce-self-hosted

feature/HERO 9362 tinymce self hosted
  • Loading branch information
hero-david authored Apr 22, 2024
2 parents 6d2fe61 + f03b141 commit f83cef3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ Or, as a shorthand using the `mut` helper:

### Including TinyMCE

TinyMCE can be used in your project by using the version from their CDN ([cloud deployment](https://www.tiny.cloud/docs/tinymce/latest/cloud-deployment-guide/))
or you can serve the assets yourself ([self hosted](https://www.tiny.cloud/docs/tinymce/latest/zip-install/)).

Using the self-hosted version has extra requirements depending on the version you are using. For example, in version 6.0
the license for the source code was MIT, and has since been changed to GPL2 for 7.0. This [blog post](https://www.tiny.cloud/blog/tinymce-free-wysiwyg-html-editor/#h_20985795323301710993368773)
by tiny explains a little bit about what this may mean for your own project. It is recommended that you seek full understanding
of your obligations when using TinyMCE, ensuring that you seek legal advice where clarification is necessary (This is not legal advice.)

#### Cloud Version

You can load TinyMCE using a free API Key by signing up for [tiny's CDN](https://www.tiny.cloud/):

```js
Expand Down Expand Up @@ -98,6 +108,27 @@ beforeModel(){
}
```

#### Self Hosting

This ember addon does not include the ability to retrieve a version of TinyMCE at build time, so you will have to
retrieve a copy of TinyMCE via another means. We recommend either:

- [Installing via NPM](https://www.tiny.cloud/docs/tinymce/6/npm-projects/)
- [Installing via ZIP](https://www.tiny.cloud/docs/tinymce/6/zip-install/)

The plugin can then be configured with a path to the main javascript file, which will change where the script is loaded from.
The following example is for a project that has the TinyMCE assets included in the `./public/assets` folder that are served
alongside the main app

```js
ENV:{
...,
tinyMCE: {
selfHostedPath: '/assets/tinymce_6.7.1/js/tinymce/tinymce.min.js',
},
}
```

### Subresource Integrity (SRI Hash)
This addon supports bring-your-own SRI Hash validation for ensuring the scripts
provided to users haven't been maliciously changed.
Expand Down
3 changes: 2 additions & 1 deletion config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module.exports = function(/* environment, appConfig */) {
load: true,
apiKey: 'no-api-key',
version: '6.3.1-12',
sriHash: ''
sriHash: '',
selfHostedPath: ''
}
};
};
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ module.exports = {
let content = '';

if (type === 'head-footer' && config['tinyMCE'] && config['tinyMCE']['load']) {
let src = `https://cdn.tiny.cloud/1/${config['tinyMCE']['apiKey']}/tinymce/${config['tinyMCE']['version']}/tinymce.min.js`;

let src = '';
if (config['tinyMCE']['selfHostedPath'] !== '') {
src = config['tinyMCE']['selfHostedPath']
} else {
src = `https://cdn.tiny.cloud/1/${config['tinyMCE']['apiKey']}/tinymce/${config['tinyMCE']['version']}/tinymce.min.js`;
}

let sriHash = '';
if (config['tinyMCE']['sriHash'] !== '') {
Expand Down

0 comments on commit f83cef3

Please sign in to comment.