truerte-react 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/LICENSE.txt +22 -0
  3. package/README.md +54 -0
  4. package/lib/cjs/main/ts/EventNames.d.ts +8 -0
  5. package/lib/cjs/main/ts/EventNames.js +87 -0
  6. package/lib/cjs/main/ts/Events.d.ts +94 -0
  7. package/lib/cjs/main/ts/Events.js +2 -0
  8. package/lib/cjs/main/ts/ScriptLoader2.d.ts +10 -0
  9. package/lib/cjs/main/ts/ScriptLoader2.js +138 -0
  10. package/lib/cjs/main/ts/TrueRTE.d.ts +3 -0
  11. package/lib/cjs/main/ts/TrueRTE.js +8 -0
  12. package/lib/cjs/main/ts/Utils.d.ts +18 -0
  13. package/lib/cjs/main/ts/Utils.js +53 -0
  14. package/lib/cjs/main/ts/Uuid.d.ts +6 -0
  15. package/lib/cjs/main/ts/Uuid.js +16 -0
  16. package/lib/cjs/main/ts/components/Editor.d.ts +171 -0
  17. package/lib/cjs/main/ts/components/Editor.js +358 -0
  18. package/lib/cjs/main/ts/index.d.ts +2 -0
  19. package/lib/cjs/main/ts/index.js +5 -0
  20. package/lib/es2015/main/ts/EventNames.d.ts +8 -0
  21. package/lib/es2015/main/ts/EventNames.js +84 -0
  22. package/lib/es2015/main/ts/Events.d.ts +94 -0
  23. package/lib/es2015/main/ts/Events.js +1 -0
  24. package/lib/es2015/main/ts/ScriptLoader2.d.ts +10 -0
  25. package/lib/es2015/main/ts/ScriptLoader2.js +135 -0
  26. package/lib/es2015/main/ts/TrueRTE.d.ts +3 -0
  27. package/lib/es2015/main/ts/TrueRTE.js +5 -0
  28. package/lib/es2015/main/ts/Utils.d.ts +18 -0
  29. package/lib/es2015/main/ts/Utils.js +43 -0
  30. package/lib/es2015/main/ts/Uuid.d.ts +6 -0
  31. package/lib/es2015/main/ts/Uuid.js +12 -0
  32. package/lib/es2015/main/ts/components/Editor.d.ts +171 -0
  33. package/lib/es2015/main/ts/components/Editor.js +354 -0
  34. package/lib/es2015/main/ts/index.d.ts +2 -0
  35. package/lib/es2015/main/ts/index.js +2 -0
  36. package/package.json +63 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,58 @@
1
+ # Change log
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ The TrueRTE React component 1.0.0 is based on the TinyMCE React component 6.0.0-rc. Unreleased changes from Tiny since 5.1.0 are included in the 1.0.0 changelog.
8
+
9
+ ## 2.0.2 - 2025-08-30
10
+
11
+ ## Fixed
12
+ - Removed console log spam left over from debugging.
13
+
14
+ ## 2.0.1 - 2025-06-30
15
+
16
+ ## Fixed
17
+ - Building a project using `@truerte/truerte-react` failed without manually adding `@truerte/framework-integration-shared` as a dependency.
18
+
19
+ ## 2.0.0 - 2025-06-30
20
+
21
+ ### Removed
22
+ - Removed `propTypes` property on the Editor class.
23
+ - Removed `prop-types` dependency and some dev dependencies.
24
+ - Removed the storybook stuff – a new demo will be added soon.
25
+ - Removed an IE/old Edge specific fallback code.
26
+
27
+ ### Changed
28
+ - Renamed the prefix of the default editor wrapper element ID from `tiny-react` to `truerte-react`.
29
+ - Bumped some dependencies, including `truerte`.
30
+
31
+ ### Added
32
+ - Added support for React 19.x.
33
+ - Added support for `onResizeEditor` event.
34
+
35
+ ## Fixed
36
+ - The onEditorChange callback was called three times when content was inserted with insertContent editor API. (Not sure if this bug did exist in 1.x, but anyway tests verify it's not present now.)
37
+
38
+ ## 1.0.1 - 2025-01-11
39
+
40
+ ### Fixed
41
+ - License headers were not included in the files in the `lib` directory because the build was made before including the license headers.
42
+
43
+ ## 1.0.0 - 2025-01-11
44
+
45
+ ### Added
46
+ - Added `cdnVersion` prop.
47
+
48
+ ### Changed
49
+ - Moved ~~tinymce~~ (now truerte) dependency to peerDependencies, as well as making it optional.
50
+ - Renamed `tinymceScriptSrc` prop to `truerteScriptSrc` and restrict its type to a string.
51
+
52
+ ### Removed
53
+ - Removed `apiKey` prop.
54
+ - Removed `licenseKey` prop.
55
+ - Removed `cloudChannel` prop.
56
+
57
+ ### Improved
58
+ - Updated dependencies.
package/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Ephox Corporation DBA Tiny Technologies, Inc.
4
+ Copyright (c) 2025 TrueRTE contributors
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # Official TrueRTE React component
2
+
3
+ ## About
4
+
5
+ This package is a thin wrapper around [TrueRTE](https://github.com/TrueRTE/truerte) to make it easier to use in a React application.
6
+
7
+ - If you need full editor docs, see: [TrueRTE Documentation](https://github.com/TrueRTE/truerte/blob/master/docs/INSTALLATION_AND_USAGE.md).
8
+ - For the React quick start, see: [TrueRTE React Installation and Usage Guide](https://github.com/TrueRTE/truerte-react/blob/master/docs/INSTALLATION_AND_USAGE.md#4-quick-start).
9
+ - For the React technical reference, see: [TrueRTE React API Reference (Props)](https://github.com/TrueRTE/truerte-react/blob/master/docs/INSTALLATION_AND_USAGE.md#9-api-reference-props).
10
+ - For imperative `useRef` control patterns, see: [TrueRTE React useRef Feature Control](https://github.com/TrueRTE/truerte-react/blob/master/docs/USE_REF_FEATURE_CONTROL.md).
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install truerte truerte-react
16
+ ```
17
+
18
+ ## Quick Example
19
+
20
+ ```tsx
21
+ import { Editor } from "truerte-react";
22
+
23
+ export default function App() {
24
+ return (
25
+ <Editor
26
+ truerteScriptSrc="/truerte/truerte.min.js"
27
+ useLucideIcons={true}
28
+ init={{
29
+ height: 500,
30
+ plugins: "lists link table code",
31
+ toolbar: "undo redo | bold italic underline | bullist numlist | link table | code",
32
+ }}
33
+ />
34
+ );
35
+ }
36
+ ```
37
+
38
+ ## Issues
39
+
40
+ Have you found an issue with `truerte-react` or do you have a feature request?
41
+
42
+ - Open an [issue](https://github.com/TrueRTE/truerte-react/issues)
43
+ - Submit a [pull request](https://github.com/TrueRTE/truerte-react/pulls)
44
+
45
+ Note: For core editor issues in TrueRTE itself, please use the [TrueRTE repository](https://github.com/TrueRTE/truerte).
46
+
47
+ ## Repository
48
+
49
+ - React wrapper: [github.com/TrueRTE/truerte-react](https://github.com/TrueRTE/truerte-react)
50
+ - Core editor: [github.com/TrueRTE/truerte](https://github.com/TrueRTE/truerte)
51
+
52
+ ## License
53
+
54
+ MIT
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Official TrueRTE React component
3
+ * Copyright (c) 2026 TrueRTE contributors
4
+ * Licensed under the MIT license (https://github.com/truerte/truerte-react/blob/main/LICENSE.TXT)
5
+ */
6
+ export declare const nativeEvents: readonly ["BeforePaste", "Blur", "Click", "CompositionEnd", "CompositionStart", "CompositionUpdate", "ContextMenu", "Copy", "Cut", "Dblclick", "Drag", "DragDrop", "DragEnd", "DragGesture", "DragOver", "Drop", "Focus", "FocusIn", "FocusOut", "Input", "KeyDown", "KeyPress", "KeyUp", "MouseDown", "MouseEnter", "MouseLeave", "MouseMove", "MouseOut", "MouseOver", "MouseUp", "Paste", "SelectionChange"];
7
+ export declare const customEvents: readonly ["Activate", "AddUndo", "BeforeAddUndo", "BeforeExecCommand", "BeforeGetContent", "BeforeRenderUI", "BeforeSetContent", "Change", "ClearUndos", "CommentChange", "Deactivate", "Dirty", "ExecCommand", "GetContent", "Hide", "IconsLoadError", "Init", "LanguageLoadError", "LoadContent", "ModelLoadError", "NodeChange", "ObjectResizeStart", "ObjectResized", "ObjectSelected", "PluginLoadError", "PostProcess", "PostRender", "PreProcess", "ProgressState", "Redo", "Remove", "Reset", "ResizeEditor", "SaveContent", "SetAttrib", "SetContent", "Show", "SkinLoadError", "Submit", "ThemeLoadError", "Undo", "VisualAid"];
8
+ export declare const validEvents: readonly ["BeforePaste", "Blur", "Click", "CompositionEnd", "CompositionStart", "CompositionUpdate", "ContextMenu", "Copy", "Cut", "Dblclick", "Drag", "DragDrop", "DragEnd", "DragGesture", "DragOver", "Drop", "Focus", "FocusIn", "FocusOut", "Input", "KeyDown", "KeyPress", "KeyUp", "MouseDown", "MouseEnter", "MouseLeave", "MouseMove", "MouseOut", "MouseOver", "MouseUp", "Paste", "SelectionChange", "Activate", "AddUndo", "BeforeAddUndo", "BeforeExecCommand", "BeforeGetContent", "BeforeRenderUI", "BeforeSetContent", "Change", "ClearUndos", "CommentChange", "Deactivate", "Dirty", "ExecCommand", "GetContent", "Hide", "IconsLoadError", "Init", "LanguageLoadError", "LoadContent", "ModelLoadError", "NodeChange", "ObjectResizeStart", "ObjectResized", "ObjectSelected", "PluginLoadError", "PostProcess", "PostRender", "PreProcess", "ProgressState", "Redo", "Remove", "Reset", "ResizeEditor", "SaveContent", "SetAttrib", "SetContent", "Show", "SkinLoadError", "Submit", "ThemeLoadError", "Undo", "VisualAid"];
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ /**
3
+ * Official TrueRTE React component
4
+ * Copyright (c) 2026 TrueRTE contributors
5
+ * Licensed under the MIT license (https://github.com/truerte/truerte-react/blob/main/LICENSE.TXT)
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.validEvents = exports.customEvents = exports.nativeEvents = void 0;
9
+ exports.nativeEvents = [
10
+ 'BeforePaste',
11
+ 'Blur',
12
+ 'Click',
13
+ 'CompositionEnd',
14
+ 'CompositionStart',
15
+ 'CompositionUpdate',
16
+ 'ContextMenu',
17
+ 'Copy',
18
+ 'Cut',
19
+ 'Dblclick',
20
+ 'Drag',
21
+ 'DragDrop',
22
+ 'DragEnd',
23
+ 'DragGesture',
24
+ 'DragOver',
25
+ 'Drop',
26
+ 'Focus',
27
+ 'FocusIn',
28
+ 'FocusOut',
29
+ 'Input',
30
+ 'KeyDown',
31
+ 'KeyPress',
32
+ 'KeyUp',
33
+ 'MouseDown',
34
+ 'MouseEnter',
35
+ 'MouseLeave',
36
+ 'MouseMove',
37
+ 'MouseOut',
38
+ 'MouseOver',
39
+ 'MouseUp',
40
+ 'Paste',
41
+ 'SelectionChange',
42
+ ];
43
+ exports.customEvents = [
44
+ 'Activate',
45
+ 'AddUndo',
46
+ 'BeforeAddUndo',
47
+ 'BeforeExecCommand',
48
+ 'BeforeGetContent',
49
+ 'BeforeRenderUI',
50
+ 'BeforeSetContent',
51
+ 'Change',
52
+ 'ClearUndos',
53
+ 'CommentChange',
54
+ 'Deactivate',
55
+ 'Dirty',
56
+ 'ExecCommand',
57
+ 'GetContent',
58
+ 'Hide',
59
+ 'IconsLoadError',
60
+ 'Init',
61
+ 'LanguageLoadError',
62
+ 'LoadContent',
63
+ 'ModelLoadError',
64
+ 'NodeChange',
65
+ 'ObjectResizeStart',
66
+ 'ObjectResized',
67
+ 'ObjectSelected',
68
+ 'PluginLoadError',
69
+ 'PostProcess',
70
+ 'PostRender',
71
+ 'PreProcess',
72
+ 'ProgressState',
73
+ 'Redo',
74
+ 'Remove',
75
+ 'Reset',
76
+ 'ResizeEditor',
77
+ 'SaveContent',
78
+ 'SetAttrib',
79
+ 'SetContent',
80
+ 'Show',
81
+ 'SkinLoadError',
82
+ 'Submit',
83
+ 'ThemeLoadError',
84
+ 'Undo',
85
+ 'VisualAid',
86
+ ];
87
+ exports.validEvents = [...exports.nativeEvents, ...exports.customEvents];
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Official TrueRTE React component
3
+ * Copyright (c) 2022 Ephox Corporation DBA Tiny Technologies, Inc.
4
+ * Copyright (c) 2024 TrueRTE contributors
5
+ * Licensed under the MIT license (https://github.com/truerte/truerte-react/blob/main/LICENSE.TXT)
6
+ */
7
+ import type { Editor as TrueRTEEditor, EditorEvent, Events } from 'truerte';
8
+ import { customEvents, nativeEvents, validEvents } from './EventNames';
9
+ export type EventHandler<A> = (a: EditorEvent<A>, editor: TrueRTEEditor) => unknown;
10
+ type EEventHandler<K extends keyof Events.EditorEventMap> = EventHandler<Events.EditorEventMap[K]>;
11
+ /** Ensures that T extends U, and returns T. */
12
+ type EnsureExtends<T extends U, U> = T;
13
+ export type INativeEvents = EnsureExtends<{
14
+ onBeforePaste: EEventHandler<'beforepaste'>;
15
+ onBlur: EEventHandler<'blur'>;
16
+ onClick: EEventHandler<'click'>;
17
+ onCompositionEnd: EEventHandler<'compositionend'>;
18
+ onCompositionStart: EEventHandler<'compositionstart'>;
19
+ onCompositionUpdate: EEventHandler<'compositionupdate'>;
20
+ onContextMenu: EEventHandler<'contextmenu'>;
21
+ onCopy: EEventHandler<'copy'>;
22
+ onCut: EEventHandler<'cut'>;
23
+ onDblclick: EEventHandler<'dblclick'>;
24
+ onDrag: EEventHandler<'drag'>;
25
+ onDragDrop: EEventHandler<'dragdrop'>;
26
+ onDragEnd: EEventHandler<'dragend'>;
27
+ onDragGesture: EEventHandler<'draggesture'>;
28
+ onDragOver: EEventHandler<'dragover'>;
29
+ onDrop: EEventHandler<'drop'>;
30
+ onFocus: EEventHandler<'focus'>;
31
+ onFocusIn: EEventHandler<'focusin'>;
32
+ onFocusOut: EEventHandler<'focusout'>;
33
+ onInput: EEventHandler<'input'>;
34
+ onKeyDown: EEventHandler<'keydown'>;
35
+ onKeyPress: EEventHandler<'keypress'>;
36
+ onKeyUp: EEventHandler<'keyup'>;
37
+ onMouseDown: EEventHandler<'mousedown'>;
38
+ onMouseEnter: EEventHandler<'mouseenter'>;
39
+ onMouseLeave: EEventHandler<'mouseleave'>;
40
+ onMouseMove: EEventHandler<'mousemove'>;
41
+ onMouseOut: EEventHandler<'mouseout'>;
42
+ onMouseOver: EEventHandler<'mouseover'>;
43
+ onMouseUp: EEventHandler<'mouseup'>;
44
+ onPaste: EEventHandler<'paste'>;
45
+ onSelectionChange: EEventHandler<'selectionchange'>;
46
+ }, Record<`on${typeof nativeEvents[number]}`, unknown>>;
47
+ export type ICustomEvents = EnsureExtends<{
48
+ onActivate: EEventHandler<'activate'>;
49
+ onAddUndo: EEventHandler<'AddUndo'>;
50
+ onBeforeAddUndo: EEventHandler<'BeforeAddUndo'>;
51
+ onBeforeExecCommand: EEventHandler<'BeforeExecCommand'>;
52
+ onBeforeGetContent: EEventHandler<'BeforeGetContent'>;
53
+ onBeforeRenderUI: EventHandler<unknown>;
54
+ onBeforeSetContent: EEventHandler<'BeforeSetContent'>;
55
+ onChange: EventHandler<unknown>;
56
+ onClearUndos: EEventHandler<'ClearUndos'>;
57
+ onCommentChange: EventHandler<unknown>;
58
+ onDeactivate: EEventHandler<'deactivate'>;
59
+ onDirty: EventHandler<unknown>;
60
+ onExecCommand: EEventHandler<'ExecCommand'>;
61
+ onGetContent: EEventHandler<'GetContent'>;
62
+ onHide: EventHandler<unknown>;
63
+ onInit: EEventHandler<'init'>;
64
+ onLoadContent: EEventHandler<'LoadContent'>;
65
+ onNodeChange: EEventHandler<'NodeChange'>;
66
+ onPostProcess: EventHandler<unknown>;
67
+ onPostRender: EEventHandler<'PostRender'>;
68
+ onPreProcess: EventHandler<unknown>;
69
+ onProgressState: EEventHandler<'ProgressState'>;
70
+ onRedo: EEventHandler<'Redo'>;
71
+ onRemove: EEventHandler<'remove'>;
72
+ onReset: EventHandler<unknown>;
73
+ onResizeEditor: EventHandler<unknown>;
74
+ onSaveContent: EventHandler<unknown>;
75
+ onSetAttrib: EventHandler<unknown>;
76
+ onObjectResizeStart: EEventHandler<'ObjectResizeStart'>;
77
+ onObjectResized: EEventHandler<'ObjectResized'>;
78
+ onObjectSelected: EEventHandler<'ObjectSelected'>;
79
+ onSetContent: EEventHandler<'SetContent'>;
80
+ onShow: EventHandler<unknown>;
81
+ onSubmit: EventHandler<unknown>;
82
+ onUndo: EEventHandler<'Undo'>;
83
+ onVisualAid: EventHandler<unknown>;
84
+ onSkinLoadError: EEventHandler<'SkinLoadError'>;
85
+ onThemeLoadError: EEventHandler<'ThemeLoadError'>;
86
+ onModelLoadError: EEventHandler<'ModelLoadError'>;
87
+ onPluginLoadError: EEventHandler<'PluginLoadError'>;
88
+ onIconsLoadError: EEventHandler<'IconsLoadError'>;
89
+ onLanguageLoadError: EEventHandler<'LanguageLoadError'>;
90
+ onScriptsLoad: () => void;
91
+ onScriptsLoadError: (err: unknown) => void;
92
+ }, Record<`on${typeof customEvents[number]}`, unknown>>;
93
+ export type IEvents = EnsureExtends<INativeEvents & ICustomEvents, Record<`on${typeof validEvents[number]}`, unknown>>;
94
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ export type CallbackFn = () => void;
2
+ export interface ScriptItem {
3
+ src: string;
4
+ async?: boolean;
5
+ defer?: boolean;
6
+ }
7
+ export declare const ScriptLoader: {
8
+ loadList: (doc: Document, items: ScriptItem[], delay: number, success: () => void, failure?: (err: unknown) => void) => void;
9
+ reinitialize: () => void;
10
+ };
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScriptLoader = void 0;
4
+ /**
5
+ * Official TrueRTE React component
6
+ * Copyright (c) 2022 Ephox Corporation DBA Tiny Technologies, Inc.
7
+ * Copyright (c) 2024 TrueRTE contributors
8
+ * Licensed under the MIT license (https://github.com/truerte/truerte-react/blob/main/LICENSE.TXT)
9
+ */
10
+ const Uuid_1 = require("./Uuid");
11
+ const injectScriptTag = (doc, item, handler) => {
12
+ var _a, _b;
13
+ const scriptTag = doc.createElement('script');
14
+ scriptTag.referrerPolicy = 'origin';
15
+ scriptTag.type = 'application/javascript';
16
+ scriptTag.id = item.id;
17
+ scriptTag.src = item.src;
18
+ scriptTag.async = (_a = item.async) !== null && _a !== void 0 ? _a : false;
19
+ scriptTag.defer = (_b = item.defer) !== null && _b !== void 0 ? _b : false;
20
+ const loadHandler = () => {
21
+ scriptTag.removeEventListener('load', loadHandler);
22
+ scriptTag.removeEventListener('error', errorHandler);
23
+ handler(item.src);
24
+ };
25
+ const errorHandler = (err) => {
26
+ scriptTag.removeEventListener('load', loadHandler);
27
+ scriptTag.removeEventListener('error', errorHandler);
28
+ handler(item.src, err);
29
+ };
30
+ scriptTag.addEventListener('load', loadHandler);
31
+ scriptTag.addEventListener('error', errorHandler);
32
+ if (doc.head) {
33
+ doc.head.appendChild(scriptTag);
34
+ }
35
+ };
36
+ const createDocumentScriptLoader = (doc) => {
37
+ let lookup = {};
38
+ const scriptLoadOrErrorHandler = (src, err) => {
39
+ const item = lookup[src];
40
+ item.done = true;
41
+ item.error = err;
42
+ for (const h of item.handlers) {
43
+ h(src, err);
44
+ }
45
+ item.handlers = [];
46
+ };
47
+ const loadScripts = (items, success, failure) => {
48
+ // eslint-disable-next-line no-console
49
+ const failureOrLog = (err) => failure !== undefined ? failure(err) : console.error(err);
50
+ if (items.length === 0) {
51
+ failureOrLog(new Error('At least one script must be provided'));
52
+ return;
53
+ }
54
+ let successCount = 0;
55
+ let failed = false;
56
+ const loaded = (_src, err) => {
57
+ if (failed) {
58
+ return;
59
+ }
60
+ if (err) {
61
+ failed = true;
62
+ failureOrLog(err);
63
+ }
64
+ else if (++successCount === items.length) {
65
+ success();
66
+ }
67
+ };
68
+ for (const item of items) {
69
+ const existing = lookup[item.src];
70
+ if (existing) {
71
+ if (existing.done) {
72
+ loaded(item.src, existing.error);
73
+ }
74
+ else {
75
+ existing.handlers.push(loaded);
76
+ }
77
+ }
78
+ else {
79
+ // create a new entry
80
+ const id = (0, Uuid_1.uuid)('tiny-');
81
+ lookup[item.src] = {
82
+ id,
83
+ src: item.src,
84
+ done: false,
85
+ error: null,
86
+ handlers: [loaded],
87
+ };
88
+ injectScriptTag(doc, Object.assign({ id }, item), scriptLoadOrErrorHandler);
89
+ }
90
+ }
91
+ };
92
+ const deleteScripts = () => {
93
+ var _a;
94
+ for (const item of Object.values(lookup)) {
95
+ const scriptTag = doc.getElementById(item.id);
96
+ if (scriptTag != null && scriptTag.tagName === 'SCRIPT') {
97
+ (_a = scriptTag.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(scriptTag);
98
+ }
99
+ }
100
+ lookup = {};
101
+ };
102
+ const getDocument = () => doc;
103
+ return {
104
+ loadScripts,
105
+ deleteScripts,
106
+ getDocument
107
+ };
108
+ };
109
+ const createScriptLoader = () => {
110
+ const cache = [];
111
+ const getDocumentScriptLoader = (doc) => {
112
+ let loader = cache.find((l) => l.getDocument() === doc);
113
+ if (loader === undefined) {
114
+ loader = createDocumentScriptLoader(doc);
115
+ cache.push(loader);
116
+ }
117
+ return loader;
118
+ };
119
+ const loadList = (doc, items, delay, success, failure) => {
120
+ const doLoad = () => getDocumentScriptLoader(doc).loadScripts(items, success, failure);
121
+ if (delay > 0) {
122
+ setTimeout(doLoad, delay);
123
+ }
124
+ else {
125
+ doLoad();
126
+ }
127
+ };
128
+ const reinitialize = () => {
129
+ for (let loader = cache.pop(); loader != null; loader = cache.pop()) {
130
+ loader.deleteScripts();
131
+ }
132
+ };
133
+ return {
134
+ loadList,
135
+ reinitialize
136
+ };
137
+ };
138
+ exports.ScriptLoader = createScriptLoader();
@@ -0,0 +1,3 @@
1
+ import type { TrueRTE as TrueRTEGlobal } from 'truerte';
2
+ declare const getTrueRTE: (view: Window) => TrueRTEGlobal | null;
3
+ export { getTrueRTE };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTrueRTE = void 0;
4
+ const getTrueRTE = (view) => {
5
+ const global = view;
6
+ return global && global.truerte ? global.truerte : null;
7
+ };
8
+ exports.getTrueRTE = getTrueRTE;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Official TrueRTE React component
3
+ * Copyright (c) 2022 Ephox Corporation DBA Tiny Technologies, Inc.
4
+ * Copyright (c) 2024 TrueRTE contributors
5
+ * Licensed under the MIT license (https://github.com/truerte/truerte-react/blob/main/LICENSE.TXT)
6
+ */
7
+ import { IEvents } from './Events';
8
+ import { IAllProps } from './components/Editor';
9
+ import type { Editor as TrueRTEEditor, EditorEvent } from 'truerte';
10
+ export declare const isFunction: (x: unknown) => x is Function;
11
+ type PropLookup = <K extends keyof IAllProps>(key: K) => IAllProps[K] | undefined;
12
+ export declare const configHandlers2: <H>(handlerLookup: PropLookup, on: (name: string, handler: H) => void, off: (name: string, handler: H) => void, adapter: <K extends keyof IEvents>(lookup: PropLookup, key: K) => H, prevProps: Partial<IAllProps>, props: Partial<IAllProps>, boundHandlers: Record<string, H>) => void;
13
+ export declare const configHandlers: (editor: TrueRTEEditor, prevProps: Partial<IAllProps>, props: Partial<IAllProps>, boundHandlers: Record<string, (event: EditorEvent<any>) => unknown>, lookup: PropLookup) => void;
14
+ export declare const isTextareaOrInput: (element: Element | null) => element is (HTMLTextAreaElement | HTMLInputElement);
15
+ export declare const mergePlugins: (initPlugins: string | string[] | undefined, inputPlugins: string | string[] | undefined) => string[];
16
+ export declare const isBeforeInputEventAvailable: () => boolean;
17
+ export declare const setMode: (editor: TrueRTEEditor | undefined, mode: "readonly" | "design") => void;
18
+ export {};
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setMode = exports.isBeforeInputEventAvailable = exports.mergePlugins = exports.isTextareaOrInput = exports.configHandlers = exports.configHandlers2 = exports.isFunction = void 0;
4
+ // TODO: Use what possible from `@truerte/framework-integration-shared`
5
+ const isFunction = (x) => typeof x === 'function';
6
+ exports.isFunction = isFunction;
7
+ const isEventProp = (name) => {
8
+ return name.startsWith('on') /* && name !== 'onEditorChange' */;
9
+ };
10
+ const eventAttrToEventName = (attrName) => attrName.substring(2);
11
+ const configHandlers2 = (handlerLookup, on, off, adapter, prevProps, props, boundHandlers) => {
12
+ const prevEventKeys = Object.keys(prevProps).filter(isEventProp);
13
+ const currEventKeys = Object.keys(props).filter(isEventProp);
14
+ const removedKeys = prevEventKeys.filter((key) => props[key] === undefined);
15
+ const addedKeys = currEventKeys.filter((key) => prevProps[key] === undefined);
16
+ removedKeys.forEach((key) => {
17
+ // remove event handler
18
+ const eventName = eventAttrToEventName(key);
19
+ const wrappedHandler = boundHandlers[eventName];
20
+ off(eventName, wrappedHandler);
21
+ delete boundHandlers[eventName];
22
+ });
23
+ addedKeys.forEach((key) => {
24
+ const wrappedHandler = adapter(handlerLookup, key);
25
+ const eventName = eventAttrToEventName(key);
26
+ boundHandlers[eventName] = wrappedHandler;
27
+ on(eventName, wrappedHandler);
28
+ });
29
+ };
30
+ exports.configHandlers2 = configHandlers2;
31
+ const configHandlers = (editor, prevProps, props, boundHandlers, lookup) => (0, exports.configHandlers2)(lookup, editor.on.bind(editor), editor.off.bind(editor),
32
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
33
+ (handlerLookup, key) => (e) => { var _a; return (_a = handlerLookup(key)) === null || _a === void 0 ? void 0 : _a(e, editor); }, prevProps, props, boundHandlers);
34
+ exports.configHandlers = configHandlers;
35
+ const isTextareaOrInput = (element) => element !== null && (element.tagName.toLowerCase() === 'textarea' || element.tagName.toLowerCase() === 'input');
36
+ exports.isTextareaOrInput = isTextareaOrInput;
37
+ const normalizePluginArray = (plugins) => {
38
+ if (typeof plugins === 'undefined' || plugins === '') {
39
+ return [];
40
+ }
41
+ return Array.isArray(plugins) ? plugins : plugins.split(' ');
42
+ };
43
+ // eslint-disable-next-line max-len
44
+ const mergePlugins = (initPlugins, inputPlugins) => normalizePluginArray(initPlugins).concat(normalizePluginArray(inputPlugins));
45
+ exports.mergePlugins = mergePlugins;
46
+ const isBeforeInputEventAvailable = () => window.InputEvent && typeof InputEvent.prototype.getTargetRanges === 'function';
47
+ exports.isBeforeInputEventAvailable = isBeforeInputEventAvailable;
48
+ const setMode = (editor, mode) => {
49
+ if (editor !== undefined) {
50
+ editor.mode.set(mode);
51
+ }
52
+ };
53
+ exports.setMode = setMode;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Official TrueRTE React component
3
+ * Copyright (c) 2026 TrueRTE contributors
4
+ * Licensed under the MIT license (https://github.com/truerte/truerte-react/blob/main/LICENSE.TXT)
5
+ */
6
+ export declare const uuid: (prefix: string) => string;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /**
3
+ * Official TrueRTE React component
4
+ * Copyright (c) 2026 TrueRTE contributors
5
+ * Licensed under the MIT license (https://github.com/truerte/truerte-react/blob/main/LICENSE.TXT)
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.uuid = void 0;
9
+ let unique = 0;
10
+ const uuid = (prefix) => {
11
+ const time = Date.now();
12
+ const random = Math.floor(Math.random() * 1000000000);
13
+ unique++;
14
+ return prefix + '_' + random + unique + String(time);
15
+ };
16
+ exports.uuid = uuid;