Skip to content

Commit 9cf53fc

Browse files
TINYINT-3450: Update repo details (#615)
* Update readme, contributing and metadata * More changes to package.json * Minor changes * Update package.json Co-authored-by: Millie <milliemacdonald4@gmail.com> * Fix quick start * Update test platforms config to use lambdatest * Attempt to fix failing tests * Fix other tests * Undo a mistake * Add a workaround to handle fetching licensemanager * Replace tinydrive with casechange plugin hoping that it fixes tests on firefox * Use checklist as it exists across all versions * Try formatpainter * fix lint * Load formatpainter through external_plugins --------- Co-authored-by: Millie <milliemacdonald4@gmail.com>
1 parent 3c1864c commit 9cf53fc

9 files changed

Lines changed: 149 additions & 48 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Change log
1+
# Changelog
22
All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

‎Jenkinsfile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ mixedBeehiveFlow(
55
container: [ resourceRequestMemory: '3Gi', resourceLimitMemory: '3Gi' ],
66
testPrefix: 'Tiny-React',
77
platforms: [
8-
[ browser: 'chrome', headless: true ],
8+
[ browser: 'chrome', provider: 'lambdatest', os: 'macOS Sonoma', buckets: 1 ],
99
[ browser: 'firefox', provider: 'aws', buckets: 1 ],
10-
[ browser: 'safari', provider: 'lambdatest', buckets: 1 ]
10+
[ browser: 'safari', provider: 'lambdatest', os: 'macOS Sonoma', buckets: 1 ]
1111
],
1212
customSteps: {
1313
stage("update storybook") {

‎README.md‎

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,66 @@
1-
# Official TinyMCE React component
1+
# Official React Component for TinyMCE
22

33
## About
44

5-
This package is a thin wrapper around [TinyMCE](https://github.com/tinymce/tinymce) to make it easier to use in a React application.
5+
Official React component for TinyMCE, the rich text editor. It wraps TinyMCE as a React `<Editor />` component, supporting controlled and uncontrolled usage. By default, it pulls TinyMCE from the Tiny Cloud CDN unless configured to use a different setup, such as self-hosting the [tinymce NPM package](https://www.npmjs.com/package/tinymce).
66

7-
* If you need detailed documentation on TinyMCE, see: [TinyMCE Documentation](https://www.tiny.cloud/docs/tinymce/8/).
8-
* For the TinyMCE React Quick Start, see: [TinyMCE Documentation - React Integration](https://www.tiny.cloud/docs/tinymce/8/react-cloud/).
9-
* For the TinyMCE React Technical Reference, see: [TinyMCE Documentation - TinyMCE React Technical Reference](https://www.tiny.cloud/docs/tinymce/8/react-ref/).
10-
* For our quick demos, check out the TinyMCE React [Storybook](https://tinymce.github.io/tinymce-react/).
7+
## Quickstart
118

9+
### Cloud CDN
1210

13-
### Issues
11+
1. [Sign up for a Tiny Cloud account](https://www.tiny.cloud/pricing/) to receive a Tiny Cloud API key.
12+
1. Then in your React project:
13+
1. Run `npm install @tinymce/tinymce-react`
14+
1. Include the following code:
1415

15-
Have you found an issue with tinymce-react or do you have a feature request? Open up an [issue](https://github.com/tinymce/tinymce-react/issues) and let us know or submit a [pull request](https://github.com/tinymce/tinymce-react/pulls). *Note: For issues concerning TinyMCE please visit the [TinyMCE repository](https://github.com/tinymce/tinymce).*
16+
```js
17+
import React from 'react';
18+
import { Editor } from '@tinymce/tinymce-react';
19+
20+
export default function App() {
21+
return (
22+
<>
23+
<h1>TinyMCE React demo</h1>
24+
<Editor
25+
apiKey="your-api-key"
26+
init={{
27+
plugins: 'lists link image table code help wordcount'
28+
}}
29+
/>
30+
</>
31+
);
32+
}
33+
```
34+
1. Update the `apiKey` prop on the `Editor` component to include your Tiny Cloud API key.
35+
36+
For more information: [Using TinyMCE with React - Cloud CDN](https://www.tiny.cloud/docs/tinymce/latest/react-cloud/)
37+
38+
### Self hosted via NPM package
39+
40+
Using TinyMCE from NPM in a React project requires a couple of extra steps. See the documentation for more information: [Using TinyMCE with React - Self hosted via NPM](https://www.tiny.cloud/docs/tinymce/latest/react-pm/)
41+
42+
43+
## Demos
44+
45+
For our quick demos, check out the TinyMCE React [Storybook](https://tinymce.github.io/tinymce-react/).
46+
47+
## Detailed documentation
48+
49+
* [TinyMCE React Technical Reference](https://www.tiny.cloud/docs/tinymce/latest/react-ref/).
50+
* [TinyMCE Documentation](https://www.tiny.cloud/docs/tinymce/latest/).
51+
52+
53+
## Issues
54+
55+
Have you found an issue with `tinymce-react` or do you have a feature request?
56+
Open up an [issue](https://github.com/tinymce/tinymce-react/issues) and let us know
57+
or submit a [pull request](https://github.com/tinymce/tinymce-react/pulls).
58+
59+
_Note: for issues concerning TinyMCE please visit the [TinyMCE repository](https://github.com/tinymce/tinymce)._
60+
61+
62+
## License
63+
64+
`tinymce-react` is licensed under the MIT License. See the LICENSE.txt file for details.
65+
66+
Depending on use case, the TinyMCE core editor can be used under either GPL-2.0-or-later or a commercial license. See the [tinymce package](https://www.npmjs.com/package/tinymce) for details.

‎contributing.md‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# Contributing
22

3-
This project follows the [beehive-flow](https://github.com/tinymce/beehive-flow/) branching process ("Basic process - release from main branch").
4-
Please read the [beehive-flow readme](https://github.com/tinymce/beehive-flow/blob/main/README.md) for more information.
5-
This mainly affects branching and merging for Tiny staff.
3+
External contributors are free to submit PRs against the `main` branch.
64

7-
External contributors are free to submit PRs against the `main` branch.
8-
Note that contributions will require signing of our Contributor License Agreement.
5+
In order for Tiny to accept your contribution, we will need legal permission from you to use your code. Please email `legal@tiny.cloud` with the subject `CLA request for [your Github username]`. Our legal team will send you a Contributors License Agreement (CLA) which you will need to sign and return.

‎package.json‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"description": "Official TinyMCE React Component",
2+
"description": "Official React component for the TinyMCE rich text editor.",
33
"repository": {
44
"url": "https://github.com/tinymce/tinymce-react"
55
},
@@ -22,11 +22,21 @@
2222
"build-storybook": "storybook build",
2323
"deploy-storybook": "storybook build && gh-pages -d ./storybook-static -u 'tiny-bot <no-reply@tiny.cloud>' --nojekyll"
2424
},
25-
"keywords": [],
25+
"keywords": [
26+
"tinymce",
27+
"react",
28+
"component",
29+
"editor",
30+
"wysiwyg",
31+
"rich-text-editor",
32+
"html",
33+
"contenteditable"
34+
],
2635
"author": "Ephox Corporation DBA Tiny Technologies, Inc.",
2736
"license": "MIT",
2837
"dependencies": {
29-
"prop-types": "^15.8.1"
38+
"prop-types": "^15.8.1",
39+
"tinymce-8": "npm:tinymce@^8.0.0"
3040
},
3141
"peerDependencies": {
3242
"react": "^19.0.0 || ^18.0.0 || ^17.0.1 || ^16.7.0",
@@ -74,7 +84,7 @@
7484
"tinymce-6": "npm:tinymce@^6",
7585
"tinymce-7": "npm:tinymce@^7",
7686
"tinymce-7.5": "npm:tinymce@7.5",
77-
"tinymce-8": "npm:tinymce@^8.0.0",
87+
"tinymce-premium": "^8.9.2",
7888
"typescript": "~5.8.2",
7989
"vite": "^7.1.5"
8090
},

‎src/test/ts/alien/Loader.tsx‎

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { before, context } from '@ephox/bedrock-client';
1+
import { after, before, context } from '@ephox/bedrock-client';
22
import { Fun, Optional } from '@ephox/katamari';
33
import { Remove, SugarElement, SugarNode } from '@ephox/sugar';
44
import { VersionLoader } from '@tinymce/miniature';
@@ -51,13 +51,25 @@ export const render = async (props: Partial<IAllProps> = {}, container: HTMLElem
5151
.filter(SugarNode.isHTMLElement)
5252
.map((val) => val.dom)
5353
.fold(() => reject('Could not find DOMNode'), (DOMNode) => {
54-
resolve({
55-
ref: ref as React.RefObject<Editor>,
56-
editor,
57-
DOMNode,
58-
});
59-
}
60-
);
54+
// This is a workaround to avoid a race condition occurring in tinymce 8 where licenseKeyManager is still validating the license key
55+
// after global tinymce is removed in a clean up. Specifically, it happens when unloading/loading different versions of TinyMCE
56+
if (editor.licenseKeyManager) {
57+
editor.licenseKeyManager.validate({}).then(() => {
58+
resolve({
59+
ref: ref as React.RefObject<Editor>,
60+
editor,
61+
DOMNode,
62+
});
63+
// eslint-disable-next-line no-console
64+
}).catch((reason) => console.warn(reason));
65+
} else {
66+
resolve({
67+
ref: ref as React.RefObject<Editor>,
68+
editor,
69+
DOMNode,
70+
});
71+
}
72+
});
6173
}, 0);
6274
});
6375
}
@@ -109,5 +121,13 @@ export const withVersion = (version: Version, fn: (render: RenderWithVersion) =>
109121
});
110122

111123
fn(render as RenderWithVersion);
124+
125+
after(() => {
126+
// remove script tag for version
127+
const scriptTag = document.querySelector(`script[src*="tinymce-${version}"]`);
128+
if (scriptTag) {
129+
scriptTag.remove();
130+
}
131+
});
112132
});
113133
};

‎src/test/ts/browser/EditorBehaviorTest.ts‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
import { Assertions, Waiter } from '@ephox/agar';
3-
import { describe, it } from '@ephox/bedrock-client';
3+
import { afterEach, describe, it } from '@ephox/bedrock-client';
44
import { TinyAssertions, TinySelections } from '@ephox/mcagar';
55
import { PlatformDetection } from '@ephox/sand';
66
import { EditorEvent, Events, Editor as TinyMCEEditor } from 'tinymce';
@@ -29,6 +29,10 @@ describe('EditorBehaviourTest', () => {
2929

3030
const eventStore = EventStore();
3131

32+
afterEach(() => {
33+
eventStore.clearState();
34+
});
35+
3236
VERSIONS.forEach((version) =>
3337
Loader.withVersion(version, (render) => {
3438
it('Assert structure of tinymce and tinymce-react events', async () => {
@@ -67,7 +71,6 @@ describe('EditorBehaviourTest', () => {
6771
Assertions.assertEq('First arg should be new content', '<p>Initial Content</p>', events[0].editorEvent);
6872
Assertions.assertEq('Second arg should be editor', true, isEditor(events[0].editor));
6973
});
70-
eventStore.clearState();
7174
});
7275

7376
it('onEditorChange should only fire when the editors content changes', async () => {
@@ -81,15 +84,14 @@ describe('EditorBehaviourTest', () => {
8184
eventStore.each('onEditorChange', (events) => {
8285
Assertions.assertEq('onEditorChange should have been fired once', 1, events.length);
8386
});
84-
eventStore.clearState();
8587
});
8688

8789
it('Should be able to register an event handler after initial render', async () => {
8890
using ctx = await render({ initialValue: '<p>Initial Content</p>' });
8991
await ctx.reRender({ onSetContent: eventStore.createHandler('onSetContent') });
9092

9193
TinyAssertions.assertContent(ctx.editor, '<p>Initial Content</p>');
92-
await Waiter.pWait(0); // Wait for React's state updates to complete before setting new content
94+
await Waiter.pWait(100); // Wait for React's state updates to complete before setting new content
9395
ctx.editor.setContent('<p>New Content</p>');
9496

9597
eventStore.each<SetContentEvent>('onSetContent', (events) => {
@@ -99,7 +101,6 @@ describe('EditorBehaviourTest', () => {
99101
events[0].editorEvent.content
100102
);
101103
});
102-
eventStore.clearState();
103104
});
104105

105106
it('Providing a new event handler and re-rendering should unbind old handler and bind new handler', async () => {
@@ -115,7 +116,7 @@ describe('EditorBehaviourTest', () => {
115116
eventStore.clearState();
116117
ctx.editor.setContent('<p>Initial Content</p>');
117118
await ctx.reRender({ onSetContent: eventStore.createHandler('NewHandler') });
118-
await Waiter.pWait(0); // Wait for React's state updates to complete before setting new content
119+
await Waiter.pWait(100); // Wait for React's state updates to complete before setting new content
119120
ctx.editor.setContent('<p>New Content</p>');
120121

121122
eventStore.each<SetContentEvent>('InitialHandler', (events) => {
@@ -132,18 +133,21 @@ describe('EditorBehaviourTest', () => {
132133
events[0].editorEvent.content
133134
);
134135
});
135-
136-
eventStore.clearState();
137136
});
137+
138138
it('INT-3226: onEditorChange is triggered only once after calling insertContent', async () => {
139139
using ctx = await render({ onEditorChange: eventStore.createHandler('onEditorChange') });
140140
const { editor } = ctx;
141141
editor.setContent('<p>abc</p>');
142-
await Waiter.pTryUntilPredicate('Editor content is set to correct value', () => ctx.editor.getContent() === '<p>abc</p>');
142+
await Waiter.pTryUntilPredicate('Editor content is set to correct value', () => {
143+
return ctx.editor.getContent() === '<p>abc</p>';
144+
});
143145
eventStore.clearState();
144146
TinySelections.setSelection(editor, [ 0, 0 ], 1, [ 0, 0 ], 2);
145147
editor.insertContent('e');
146-
await Waiter.pTryUntilPredicate('Editor content is set to correct value', () => ctx.editor.getContent() === '<p>aec</p>');
148+
await Waiter.pTryUntilPredicate('Editor content is set to correct value', () => {
149+
return ctx.editor.getContent() === '<p>aec</p>';
150+
});
147151
eventStore.each<string>('onEditorChange', (events) => {
148152
Assertions.assertEq(
149153
'onEditorChange should have been triggered once',

‎src/test/ts/browser/LoadTinyTest.ts‎

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('LoadTinyTest', () => {
4242

4343
CLOUD_VERSIONS.forEach((version) => {
4444
it(`Should be able to load TinyMCE from Cloud (${version})`, async () => {
45-
const apiKey = 'a-fake-api-key';
45+
const apiKey = VALID_API_KEY;
4646
using _ = await render({ apiKey, cloudChannel: version });
4747
assertTinymceVersion(version);
4848
Assertions.assertEq(
@@ -55,10 +55,24 @@ describe('LoadTinyTest', () => {
5555
it(`Should be able to load TinyMCE (${version}) in hybrid`, async () => {
5656
using _ = await render({
5757
tinymceScriptSrc: [
58-
`/project/node_modules/tinymce-${version}/tinymce.min.js`,
59-
`https://cdn.tiny.cloud/1/${VALID_API_KEY}/tinymce/${version}/cloud-plugins.min.js?tinydrive=${version}`
58+
`/project/node_modules/tinymce-${version}/tinymce.min.js`
6059
],
61-
plugins: [ 'tinydrive' ]
60+
apiKey: VALID_API_KEY,
61+
licenseKey: 'gpl',
62+
plugins: [ 'formatpainter' ],
63+
// TinyMCE 8 requires the Commercial License Key Manager to validate an apiKey. It's not
64+
// served from Tiny Cloud, so for a self-hosted core it needs to load from the local
65+
// `tinymce-premium` package instead. See https://www.tiny.cloud/docs/tinymce/latest/license-key/
66+
init: version === '8' ? {
67+
external_plugins: {
68+
licensekeymanager: '/project/node_modules/tinymce-premium/plugins/licensekeymanager/plugin.min.js',
69+
formatpainter: `https://cdn.tiny.cloud/1/${VALID_API_KEY}/tinymce-plugins/formatpainter/${version}/plugin.min.js`
70+
}
71+
} : {
72+
external_plugins: {
73+
formatpainter: `https://cdn.tiny.cloud/1/${VALID_API_KEY}/tinymce-plugins/formatpainter/${version}/plugin.min.js`,
74+
}
75+
},
6276
});
6377
assertTinymceVersion(version);
6478
Assertions.assertEq(
@@ -67,9 +81,9 @@ describe('LoadTinyTest', () => {
6781
Global.tinymce.baseURI.path
6882
);
6983
Assertions.assertEq(
70-
'The tinydrive plugin should have defaults for the cloud',
71-
`https://cdn.tiny.cloud/1/${VALID_API_KEY}/tinymce-plugins/tinydrive/${version}/plugin.min.js`,
72-
(Global.tinymce.defaultOptions || Global.tinymce.defaultSettings)?.custom_plugin_urls?.tinydrive
84+
'The formatpainter plugin should have been loaded from Cloud',
85+
`https://cdn.tiny.cloud/1/${VALID_API_KEY}/tinymce-plugins/formatpainter/${version}`,
86+
Global.tinymce.PluginManager.urls.formatpainter
7387
);
7488
});
7589
});

‎yarn.lock‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8756,9 +8756,14 @@ tinyglobby@^0.2.15:
87568756
integrity sha512-zaOHwmiP1EqTeLRXAvVriDb00JYnfEjWGPdKEuac7MiZJ5aiDMZ4Unc98Gmajn+PBljOmO1GKV6G0KwWn3+k8A==
87578757

87588758
"tinymce-8@npm:tinymce@^8.0.0":
8759-
version "8.2.0"
8760-
resolved "https://registry.yarnpkg.com/tinymce/-/tinymce-8.2.0.tgz#3fde03d91a1a8fd2d33de6a378843724e1341e2e"
8761-
integrity sha512-HZasRaAYQmePi+jjP4YFqHMtBJvbUaxDmjlXNf96uuyqsH6zZkGtJiFpsNi80Ec+L+snyF0OTDjrWVYDbkUrgQ==
8759+
version "8.9.2"
8760+
resolved "https://registry.yarnpkg.com/tinymce/-/tinymce-8.9.2.tgz#0e6cb1d0230a27afe701651c1dbd99e2dac7ffdb"
8761+
integrity sha512-Qh6ADSC0x1F/KsrupfResNJFAaINJQBtfVjx5zxxWJ0ZrGtaKldtAXDMI6uEA57s2n+0rEtXmtbitiU4zV7+0Q==
8762+
8763+
tinymce-premium@^8.9.2:
8764+
version "8.9.2"
8765+
resolved "https://registry.yarnpkg.com/tinymce-premium/-/tinymce-premium-8.9.2.tgz#e3beb35676d19709ba7ee33c5d54af46941084fa"
8766+
integrity sha512-9fx33G7Omixa7BlPqakx6xEs4jwQzA1EyPcS/5KenTWi+/yVEA2ILSkLeE4pfWW5qyY8ogdMYmGZDd476UJuEQ==
87628767

87638768
tinymce@^8.0.2:
87648769
version "8.2.0"

0 commit comments

Comments
 (0)