From 1483ad98cfe0db610f5d6621fca671f20583ba7b Mon Sep 17 00:00:00 2001 From: Ben Tran Date: Fri, 30 May 2025 08:54:32 +0930 Subject: [PATCH 1/3] INT-3347: Fix @tinymce/miniature as dev dependency breaking builds --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72cc9539..8924d07d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Fixed +- Having `@tinymce/miniature` as dev dependency broke builds. #INT-3347 + ## 6.2.0 - 2025-05-29 ### Changed diff --git a/package.json b/package.json index c844e6e1..4bed9947 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "author": "Ephox Corporation DBA Tiny Technologies, Inc.", "license": "MIT", "dependencies": { + "@tinymce/miniature": "^6.0.0", "prop-types": "^15.6.2" }, "peerDependencies": { @@ -58,7 +59,6 @@ "@storybook/react-vite": "^8.6.4", "@tinymce/beehive-flow": "^0.19.0", "@tinymce/eslint-plugin": "^2.4.0", - "@tinymce/miniature": "^6.0.0", "@types/node": "^22.13.10", "@types/prop-types": "^15.7.14", "@types/react": "^19.0.0", From 45990315c593fdf07c27188714be467dff08abda Mon Sep 17 00:00:00 2001 From: Ben Tran Date: Mon, 2 Jun 2025 14:02:29 +0930 Subject: [PATCH 2/3] INT-3347: Remove @tinymce/miniature from the prod code --- package.json | 2 +- src/main/ts/Utils.ts | 7 +---- src/main/ts/components/Editor.tsx | 16 +++++++---- src/test/ts/browser/EditorDisabledTest.ts | 33 +++++++++++++++++++++++ 4 files changed, 46 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 4bed9947..c844e6e1 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "author": "Ephox Corporation DBA Tiny Technologies, Inc.", "license": "MIT", "dependencies": { - "@tinymce/miniature": "^6.0.0", "prop-types": "^15.6.2" }, "peerDependencies": { @@ -59,6 +58,7 @@ "@storybook/react-vite": "^8.6.4", "@tinymce/beehive-flow": "^0.19.0", "@tinymce/eslint-plugin": "^2.4.0", + "@tinymce/miniature": "^6.0.0", "@types/node": "^22.13.10", "@types/prop-types": "^15.7.14", "@types/react": "^19.0.0", diff --git a/src/main/ts/Utils.ts b/src/main/ts/Utils.ts index 651ed288..dbba0d22 100644 --- a/src/main/ts/Utils.ts +++ b/src/main/ts/Utils.ts @@ -2,7 +2,6 @@ import { eventPropTypes, IEventPropTypes } from './components/EditorPropTypes'; import { IAllProps } from './components/Editor'; import type { Editor as TinyMCEEditor, EditorEvent } from 'tinymce'; import { getTinymce } from './TinyMCE'; -import { TinyVer } from '@tinymce/miniature'; export const isFunction = (x: unknown): x is Function => typeof x === 'function'; @@ -122,8 +121,4 @@ export const getTinymceOrError = (view: Window) => { return tinymce; }; -export const isDisabledOptionSupported = (view: Window) => { - const tinymce = getTinymceOrError(view); - - return !TinyVer.isLessThan(tinymce, '7.6.0'); -}; \ No newline at end of file +export const isDisabledOptionSupported = (editor: TinyMCEEditor) => editor.options && editor.options.isRegistered('disabled'); \ No newline at end of file diff --git a/src/main/ts/components/Editor.tsx b/src/main/ts/components/Editor.tsx index 8c763b78..a31a2b60 100644 --- a/src/main/ts/components/Editor.tsx +++ b/src/main/ts/components/Editor.tsx @@ -225,7 +225,7 @@ export class Editor extends React.Component { } if (this.props.disabled !== prevProps.disabled) { - if (isDisabledOptionSupported(this.view)) { + if (isDisabledOptionSupported(this.editor)) { this.editor.options.set('disabled', this.props.disabled); } else { setMode(this.editor, this.props.disabled ? 'readonly' : 'design'); @@ -455,10 +455,8 @@ export class Editor extends React.Component { ...this.props.init as Omit, selector: undefined, target, - ...isDisabledOptionSupported(this.view) - ? { disabled: this.props.disabled, readonly: this.props.readonly } - : { readonly: this.props.disabled || this.props.readonly } - , + disabled: this.props.disabled, + readonly: this.props.readonly, inline: this.inline, plugins: mergePlugins(this.props.init?.plugins, this.props.plugins), toolbar: this.props.toolbar ?? this.props.init?.toolbar, @@ -482,6 +480,14 @@ export class Editor extends React.Component { if (this.props.init && isFunction(this.props.init.setup)) { this.props.init.setup(editor); } + + if (this.props.disabled) { + if (isDisabledOptionSupported(this.editor)) { + this.editor.options.set('disabled', this.props.disabled); + } else { + this.editor.mode.set('readonly'); + } + } }, init_instance_callback: (editor) => { // check for changes that happened since tinymce.init() was called diff --git a/src/test/ts/browser/EditorDisabledTest.ts b/src/test/ts/browser/EditorDisabledTest.ts index ecc9d284..fe88ef05 100644 --- a/src/test/ts/browser/EditorDisabledTest.ts +++ b/src/test/ts/browser/EditorDisabledTest.ts @@ -74,4 +74,37 @@ describe('EditorDisabledTest', () => { }); }); }); + + context('with TinyMCE 5', () => { + Loader.withVersion('5', (render) => { + it('toggling disabled prop should update the editor\'s mode', async () => { + using ctx = await render({ + disabled: true + }); + + Assertions.assertEq('mode is design', 'readonly', ctx.editor.mode.get()); + await ctx.reRender({ + disabled: false + }); + + await Waiter.pTryUntil('editor\'s state should be updated', () => { + Assertions.assertEq('mode is design', 'design', ctx.editor.mode.get()); + }); + }); + + it('toggling readonly prop should change the editor\'s mode', async () => { + using ctx = await render({ + readonly: true + }); + Assertions.assertEq('mode is readonly', 'readonly', ctx.editor.mode.get()); + + await ctx.reRender({ + readonly: false + }); + await Waiter.pTryUntil('editor\'s mode should be updated', () => { + Assertions.assertEq('mode is design', 'design', ctx.editor.mode.get()); + }); + }); + }); + }); }); \ No newline at end of file From 6cfca16a9f6327067b0f58f0951301ebb48d5afd Mon Sep 17 00:00:00 2001 From: Ben Tran Date: Mon, 2 Jun 2025 14:10:17 +0930 Subject: [PATCH 3/3] INT-3347: Change changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8924d07d..f67b545b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased ### Fixed -- Having `@tinymce/miniature` as dev dependency broke builds. #INT-3347 +- Project build failure caused by a missing `@tinymce/miniature` dependency. #INT-3347 ## 6.2.0 - 2025-05-29