Skip to content

Commit 6a788a0

Browse files
INT-3347: Fix build failure due to @tinymce/miniature was missing in dependency (#592)
* INT-3347: Fix @tinymce/miniature as dev dependency breaking builds * INT-3347: Remove @tinymce/miniature from the prod code * INT-3347: Change changelog
1 parent 3b916c6 commit 6a788a0

File tree

4 files changed

+48
-11
lines changed

4 files changed

+48
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## Unreleased
88

9+
### Fixed
10+
- Project build failure caused by a missing `@tinymce/miniature` dependency. #INT-3347
11+
912
## 6.2.0 - 2025-05-29
1013

1114
### Changed

src/main/ts/Utils.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { eventPropTypes, IEventPropTypes } from './components/EditorPropTypes';
22
import { IAllProps } from './components/Editor';
33
import type { Editor as TinyMCEEditor, EditorEvent } from 'tinymce';
44
import { getTinymce } from './TinyMCE';
5-
import { TinyVer } from '@tinymce/miniature';
65

76
export const isFunction = (x: unknown): x is Function => typeof x === 'function';
87

@@ -122,8 +121,4 @@ export const getTinymceOrError = (view: Window) => {
122121
return tinymce;
123122
};
124123

125-
export const isDisabledOptionSupported = (view: Window) => {
126-
const tinymce = getTinymceOrError(view);
127-
128-
return !TinyVer.isLessThan(tinymce, '7.6.0');
129-
};
124+
export const isDisabledOptionSupported = (editor: TinyMCEEditor) => editor.options && editor.options.isRegistered('disabled');

src/main/ts/components/Editor.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export class Editor extends React.Component<IAllProps> {
225225
}
226226

227227
if (this.props.disabled !== prevProps.disabled) {
228-
if (isDisabledOptionSupported(this.view)) {
228+
if (isDisabledOptionSupported(this.editor)) {
229229
this.editor.options.set('disabled', this.props.disabled);
230230
} else {
231231
setMode(this.editor, this.props.disabled ? 'readonly' : 'design');
@@ -455,10 +455,8 @@ export class Editor extends React.Component<IAllProps> {
455455
...this.props.init as Omit<InitOptions, OmittedInitProps>,
456456
selector: undefined,
457457
target,
458-
...isDisabledOptionSupported(this.view)
459-
? { disabled: this.props.disabled, readonly: this.props.readonly }
460-
: { readonly: this.props.disabled || this.props.readonly }
461-
,
458+
disabled: this.props.disabled,
459+
readonly: this.props.readonly,
462460
inline: this.inline,
463461
plugins: mergePlugins(this.props.init?.plugins, this.props.plugins),
464462
toolbar: this.props.toolbar ?? this.props.init?.toolbar,
@@ -482,6 +480,14 @@ export class Editor extends React.Component<IAllProps> {
482480
if (this.props.init && isFunction(this.props.init.setup)) {
483481
this.props.init.setup(editor);
484482
}
483+
484+
if (this.props.disabled) {
485+
if (isDisabledOptionSupported(this.editor)) {
486+
this.editor.options.set('disabled', this.props.disabled);
487+
} else {
488+
this.editor.mode.set('readonly');
489+
}
490+
}
485491
},
486492
init_instance_callback: (editor) => {
487493
// check for changes that happened since tinymce.init() was called

src/test/ts/browser/EditorDisabledTest.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,37 @@ describe('EditorDisabledTest', () => {
7474
});
7575
});
7676
});
77+
78+
context('with TinyMCE 5', () => {
79+
Loader.withVersion('5', (render) => {
80+
it('toggling disabled prop should update the editor\'s mode', async () => {
81+
using ctx = await render({
82+
disabled: true
83+
});
84+
85+
Assertions.assertEq('mode is design', 'readonly', ctx.editor.mode.get());
86+
await ctx.reRender({
87+
disabled: false
88+
});
89+
90+
await Waiter.pTryUntil('editor\'s state should be updated', () => {
91+
Assertions.assertEq('mode is design', 'design', ctx.editor.mode.get());
92+
});
93+
});
94+
95+
it('toggling readonly prop should change the editor\'s mode', async () => {
96+
using ctx = await render({
97+
readonly: true
98+
});
99+
Assertions.assertEq('mode is readonly', 'readonly', ctx.editor.mode.get());
100+
101+
await ctx.reRender({
102+
readonly: false
103+
});
104+
await Waiter.pTryUntil('editor\'s mode should be updated', () => {
105+
Assertions.assertEq('mode is design', 'design', ctx.editor.mode.get());
106+
});
107+
});
108+
});
109+
});
77110
});

0 commit comments

Comments
 (0)