mirror of
https://github.com/tinymce/tinymce.git
synced 2025-07-21 11:32:37 +00:00
TINY-12536: Loader catches and reports errors from tinymce.init
(#10473)
This commit is contained in:
6
.changes/unreleased/mcagar-TINY-12536-2025-07-16.yaml
Normal file
6
.changes/unreleased/mcagar-TINY-12536-2025-07-16.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
project: mcagar
|
||||||
|
kind: Fixed
|
||||||
|
body: Loader will catch errors thrown by `tinymce.init` and report them to the caller.
|
||||||
|
time: 2025-07-16T14:36:55.407731349+10:00
|
||||||
|
custom:
|
||||||
|
Issue: TINY-12536
|
@ -1,5 +1,5 @@
|
|||||||
import { TestLogs } from '@ephox/agar';
|
import { TestLogs } from '@ephox/agar';
|
||||||
import { Arr, Fun, FutureResult, Global, Id, Optional, Result } from '@ephox/katamari';
|
import { Arr, Fun, FutureResult, Global, Id, Optional, Result, Type } from '@ephox/katamari';
|
||||||
import { Attribute, DomEvent, Insert, Remove, SelectorFilter, SugarBody, SugarElement, SugarHead, SugarShadowDom } from '@ephox/sugar';
|
import { Attribute, DomEvent, Insert, Remove, SelectorFilter, SugarBody, SugarElement, SugarHead, SugarShadowDom } from '@ephox/sugar';
|
||||||
|
|
||||||
import { Editor } from '../alien/EditorTypes';
|
import { Editor } from '../alien/EditorTypes';
|
||||||
@ -74,7 +74,8 @@ const setup = (callbacks: Callbacks, settings: Record<string, any>, elementOpt:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Agar v. ??? supports logging
|
// Agar v. ??? supports logging
|
||||||
const onFailure = (err: Error | string, logs?: TestLogs) => {
|
const onFailure = (errU: unknown, logs?: TestLogs) => {
|
||||||
|
const err = Type.isString(errU) || errU instanceof Error ? errU : String(errU);
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('Tiny Loader error: ', err);
|
console.log('Tiny Loader error: ', err);
|
||||||
// Do no teardown so that the failed test still shows the editor. Important for selection
|
// Do no teardown so that the failed test still shows the editor. Important for selection
|
||||||
@ -88,31 +89,34 @@ const setup = (callbacks: Callbacks, settings: Record<string, any>, elementOpt:
|
|||||||
callbacks.preInit(tinymce, settings);
|
callbacks.preInit(tinymce, settings);
|
||||||
|
|
||||||
const targetSettings = SugarShadowDom.isInShadowRoot(target) ? ({ target: target.dom }) : ({ selector: '#' + randomId });
|
const targetSettings = SugarShadowDom.isInShadowRoot(target) ? ({ target: target.dom }) : ({ selector: '#' + randomId });
|
||||||
|
try {
|
||||||
|
Promise.resolve(tinymce.init({
|
||||||
|
promotion: false,
|
||||||
|
license_key: 'gpl',
|
||||||
|
...settings,
|
||||||
|
...targetSettings,
|
||||||
|
setup: (editor: Editor) => {
|
||||||
|
// Execute the setup called by the test.
|
||||||
|
settingsSetup(editor);
|
||||||
|
|
||||||
tinymce.init({
|
editor.once('SkinLoaded', () => {
|
||||||
promotion: false,
|
setTimeout(() => {
|
||||||
license_key: 'gpl',
|
try {
|
||||||
...settings,
|
callbacks.run(editor, onSuccess, onFailure);
|
||||||
...targetSettings,
|
} catch (e: any) {
|
||||||
setup: (editor: Editor) => {
|
onFailure(e);
|
||||||
// Execute the setup called by the test.
|
}
|
||||||
settingsSetup(editor);
|
}, 100);
|
||||||
|
});
|
||||||
|
|
||||||
editor.once('SkinLoaded', () => {
|
editor.once('SkinLoadError', (e) => {
|
||||||
setTimeout(() => {
|
callbacks.failure(e.message);
|
||||||
try {
|
});
|
||||||
callbacks.run(editor, onSuccess, onFailure);
|
}
|
||||||
} catch (e: any) {
|
})).catch(onFailure);
|
||||||
onFailure(e);
|
} catch (err: unknown) {
|
||||||
}
|
onFailure(err);
|
||||||
}, 100);
|
}
|
||||||
});
|
|
||||||
|
|
||||||
editor.once('SkinLoadError', (e) => {
|
|
||||||
callbacks.failure(e.message);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!Global.tinymce) {
|
if (!Global.tinymce) {
|
||||||
|
Reference in New Issue
Block a user