argous 1.2.204 → 1.2.206
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.
- package/dist/components/Editor/Events.d.ts +7 -9
- package/dist/components/Editor/Events.js +7 -0
- package/dist/components/Editor/TinyMCE.d.ts +8 -1
- package/dist/components/Editor/TinyMCE.js +10 -2
- package/dist/components/Editor/Utils.d.ts +7 -2
- package/dist/components/Editor/Utils.js +9 -29
- package/dist/components/Editor/components/Editor.d.ts +16 -17
- package/dist/components/Editor/components/Editor.js +49 -92
- package/dist/components/Editor/components/EditorPropTypes.d.ts +8 -1
- package/dist/components/Editor/components/EditorPropTypes.js +9 -19
- package/dist/components/Editor/index.d.ts +9 -2
- package/dist/components/Editor/index.js +7 -0
- package/lib/components/Editor/Events.ts +8 -9
- package/lib/components/Editor/ScriptLoader.ts +96 -0
- package/lib/components/Editor/TinyMCE.ts +12 -2
- package/lib/components/Editor/Utils.ts +8 -25
- package/lib/components/Editor/components/Editor.tsx +78 -100
- package/lib/components/Editor/components/EditorPropTypes.ts +12 -21
- package/lib/components/Editor/index.tsx +10 -2
- package/package.json +1 -1
- package/lib/components/Editor/ScriptLoader2.ts +0 -161
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017-present, Ephox, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache 2 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
1
8
|
import { Editor as TinyMCEEditor, EditorEvent, Events } from './tinymce/tinymce';
|
|
2
9
|
export declare type EventHandler<A> = (a: EditorEvent<A>, editor: TinyMCEEditor) => unknown;
|
|
3
10
|
declare type EEventHandler<K extends keyof Events.EditorEventMap> = EventHandler<Events.EditorEventMap[K]>;
|
|
@@ -41,7 +48,6 @@ export interface ITinyEvents {
|
|
|
41
48
|
onBeforeSetContent: EEventHandler<'BeforeSetContent'>;
|
|
42
49
|
onChange: EventHandler<unknown>;
|
|
43
50
|
onClearUndos: EEventHandler<'ClearUndos'>;
|
|
44
|
-
onCommentChange: EventHandler<unknown>;
|
|
45
51
|
onDeactivate: EEventHandler<'deactivate'>;
|
|
46
52
|
onDirty: EventHandler<unknown>;
|
|
47
53
|
onExecCommand: EEventHandler<'ExecCommand'>;
|
|
@@ -67,14 +73,6 @@ export interface ITinyEvents {
|
|
|
67
73
|
onSubmit: EventHandler<unknown>;
|
|
68
74
|
onUndo: EEventHandler<'Undo'>;
|
|
69
75
|
onVisualAid: EventHandler<unknown>;
|
|
70
|
-
onSkinLoadError: EEventHandler<'SkinLoadError'>;
|
|
71
|
-
onThemeLoadError: EEventHandler<'ThemeLoadError'>;
|
|
72
|
-
onModelLoadError: EEventHandler<'ModelLoadError'>;
|
|
73
|
-
onPluginLoadError: EEventHandler<'PluginLoadError'>;
|
|
74
|
-
onIconsLoadError: EEventHandler<'IconsLoadError'>;
|
|
75
|
-
onLanguageLoadError: EEventHandler<'LanguageLoadError'>;
|
|
76
|
-
onScriptsLoad: () => void;
|
|
77
|
-
onScriptsLoadError: (err: unknown) => void;
|
|
78
76
|
}
|
|
79
77
|
export interface IEvents extends INativeEvents, ITinyEvents {
|
|
80
78
|
}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2017-present, Ephox, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the Apache 2 license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017-present, Ephox, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache 2 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
1
8
|
import { TinyMCE as TinyMCEGlobal } from './tinymce/tinymce';
|
|
2
|
-
declare const getTinymce: (
|
|
9
|
+
declare const getTinymce: () => TinyMCEGlobal | null;
|
|
3
10
|
export { getTinymce };
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2017-present, Ephox, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the Apache 2 license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.getTinymce = void 0;
|
|
4
|
-
var
|
|
5
|
-
|
|
11
|
+
var getGlobal = function () { return (typeof window !== 'undefined' ? window : global); };
|
|
12
|
+
var getTinymce = function () {
|
|
13
|
+
var global = getGlobal();
|
|
6
14
|
return global && global.tinymce ? global.tinymce : null;
|
|
7
15
|
};
|
|
8
16
|
exports.getTinymce = getTinymce;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017-present, Ephox, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache 2 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
1
8
|
import { IAllProps } from './components/Editor';
|
|
2
9
|
import { IEventPropTypes } from './components/EditorPropTypes';
|
|
3
10
|
import { Editor as TinyMCEEditor, EditorEvent } from './tinymce/tinymce';
|
|
@@ -9,6 +16,4 @@ export declare const uuid: (prefix: string) => string;
|
|
|
9
16
|
export declare const isTextareaOrInput: (element: Element | null) => element is HTMLInputElement | HTMLTextAreaElement;
|
|
10
17
|
export declare const mergePlugins: (initPlugins: string | string[] | undefined, inputPlugins: string | string[] | undefined) => string[];
|
|
11
18
|
export declare const isBeforeInputEventAvailable: () => boolean;
|
|
12
|
-
export declare const isInDoc: (elem: Node) => boolean;
|
|
13
|
-
export declare const setMode: (editor: TinyMCEEditor | undefined, mode: 'readonly' | 'design') => void;
|
|
14
19
|
export {};
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2017-present, Ephox, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the Apache 2 license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
10
|
+
exports.isBeforeInputEventAvailable = exports.mergePlugins = exports.isTextareaOrInput = exports.uuid = exports.configHandlers = exports.configHandlers2 = exports.isFunction = void 0;
|
|
4
11
|
var EditorPropTypes_1 = require("./components/EditorPropTypes");
|
|
5
12
|
var isFunction = function (x) { return typeof x === 'function'; };
|
|
6
13
|
exports.isFunction = isFunction;
|
|
@@ -27,9 +34,7 @@ var configHandlers2 = function (handlerLookup, on, off, adapter, prevProps, prop
|
|
|
27
34
|
};
|
|
28
35
|
exports.configHandlers2 = configHandlers2;
|
|
29
36
|
var configHandlers = function (editor, prevProps, props, boundHandlers, lookup) {
|
|
30
|
-
return exports.configHandlers2(lookup, editor.on.bind(editor), editor.off.bind(editor),
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
32
|
-
function (handlerLookup, key) { return function (e) { var _a; return (_a = handlerLookup(key)) === null || _a === void 0 ? void 0 : _a(e, editor); }; }, prevProps, props, boundHandlers);
|
|
37
|
+
return exports.configHandlers2(lookup, editor.on.bind(editor), editor.off.bind(editor), function (handlerLookup, key) { return function (e) { var _a; return (_a = handlerLookup(key)) === null || _a === void 0 ? void 0 : _a(e, editor); }; }, prevProps, props, boundHandlers);
|
|
33
38
|
};
|
|
34
39
|
exports.configHandlers = configHandlers;
|
|
35
40
|
var unique = 0;
|
|
@@ -55,28 +60,3 @@ var mergePlugins = function (initPlugins, inputPlugins) { return normalizePlugin
|
|
|
55
60
|
exports.mergePlugins = mergePlugins;
|
|
56
61
|
var isBeforeInputEventAvailable = function () { return window.InputEvent && typeof InputEvent.prototype.getTargetRanges === 'function'; };
|
|
57
62
|
exports.isBeforeInputEventAvailable = isBeforeInputEventAvailable;
|
|
58
|
-
var isInDoc = function (elem) {
|
|
59
|
-
if (!('isConnected' in Node.prototype)) {
|
|
60
|
-
// Fallback for IE and old Edge
|
|
61
|
-
var current = elem;
|
|
62
|
-
var parent_1 = elem.parentNode;
|
|
63
|
-
while (parent_1 != null) {
|
|
64
|
-
current = parent_1;
|
|
65
|
-
parent_1 = current.parentNode;
|
|
66
|
-
}
|
|
67
|
-
return current === elem.ownerDocument;
|
|
68
|
-
}
|
|
69
|
-
return elem.isConnected;
|
|
70
|
-
};
|
|
71
|
-
exports.isInDoc = isInDoc;
|
|
72
|
-
var setMode = function (editor, mode) {
|
|
73
|
-
if (editor !== undefined) {
|
|
74
|
-
if (editor.mode != null && typeof editor.mode === 'object' && typeof editor.mode.set === 'function') {
|
|
75
|
-
editor.mode.set(mode);
|
|
76
|
-
}
|
|
77
|
-
else { // support TinyMCE 4
|
|
78
|
-
editor.setMode(mode);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
exports.setMode = setMode;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017-present, Ephox, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache 2 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
1
8
|
import { IEditorPropTypes } from './EditorPropTypes';
|
|
2
9
|
import { IEvents } from '../Events';
|
|
3
|
-
import {
|
|
4
|
-
import { Editor as TinyMCEEditor, TinyMCE } from '../tinymce/tinymce';
|
|
10
|
+
import { Editor as TinyMCEEditor, RawEditorOptions } from '../tinymce/tinymce';
|
|
5
11
|
import * as React from 'react';
|
|
6
|
-
declare type EditorOptions = Parameters<TinyMCE['init']>[0];
|
|
7
12
|
export interface IProps {
|
|
8
13
|
apiKey: string;
|
|
9
14
|
id: string;
|
|
@@ -11,18 +16,19 @@ export interface IProps {
|
|
|
11
16
|
initialValue: string;
|
|
12
17
|
onEditorChange: (a: string, editor: TinyMCEEditor) => void;
|
|
13
18
|
value: string;
|
|
14
|
-
init:
|
|
19
|
+
init: RawEditorOptions & {
|
|
15
20
|
selector?: undefined;
|
|
16
21
|
target?: undefined;
|
|
17
22
|
};
|
|
23
|
+
/** @deprecated use `editor.getContent({format: 'text' })` in `onEditorChange` prop instead */
|
|
24
|
+
outputFormat: 'html' | 'text';
|
|
18
25
|
tagName: string;
|
|
19
26
|
cloudChannel: string;
|
|
20
|
-
plugins: NonNullable<
|
|
21
|
-
toolbar: NonNullable<
|
|
27
|
+
plugins: NonNullable<RawEditorOptions['plugins']>;
|
|
28
|
+
toolbar: NonNullable<RawEditorOptions['toolbar']>;
|
|
22
29
|
disabled: boolean;
|
|
23
30
|
textareaName: string;
|
|
24
|
-
tinymceScriptSrc: string
|
|
25
|
-
rollback: number | false;
|
|
31
|
+
tinymceScriptSrc: string;
|
|
26
32
|
scriptLoading: {
|
|
27
33
|
async?: boolean;
|
|
28
34
|
defer?: boolean;
|
|
@@ -43,19 +49,13 @@ export declare class Editor extends React.Component<IAllProps> {
|
|
|
43
49
|
private rollbackTimer;
|
|
44
50
|
private valueCursor;
|
|
45
51
|
constructor(props: Partial<IAllProps>);
|
|
46
|
-
private get view();
|
|
47
52
|
componentDidUpdate(prevProps: Partial<IAllProps>): void;
|
|
48
53
|
componentDidMount(): void;
|
|
49
54
|
componentWillUnmount(): void;
|
|
50
|
-
render(): React.
|
|
51
|
-
ref: React.RefObject<HTMLElement>;
|
|
52
|
-
id: string;
|
|
53
|
-
}, string | React.JSXElementConstructor<any>>;
|
|
54
|
-
private changeEvents;
|
|
55
|
-
private beforeInputEvent;
|
|
55
|
+
render(): React.JSX.Element;
|
|
56
56
|
private renderInline;
|
|
57
57
|
private renderIframe;
|
|
58
|
-
private
|
|
58
|
+
private getScriptSrc;
|
|
59
59
|
private getInitialValue;
|
|
60
60
|
private bindHandlers;
|
|
61
61
|
private rollbackChange;
|
|
@@ -65,4 +65,3 @@ export declare class Editor extends React.Component<IAllProps> {
|
|
|
65
65
|
private handleEditorChangeSpecial;
|
|
66
66
|
private initialise;
|
|
67
67
|
}
|
|
68
|
-
export {};
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2017-present, Ephox, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the Apache 2 license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
2
9
|
var __extends = (this && this.__extends) || (function () {
|
|
3
10
|
var extendStatics = function (d, b) {
|
|
4
11
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -47,10 +54,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
47
54
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
55
|
exports.Editor = void 0;
|
|
49
56
|
var EditorPropTypes_1 = require("./EditorPropTypes");
|
|
50
|
-
var
|
|
57
|
+
var ScriptLoader_1 = require("../ScriptLoader");
|
|
51
58
|
var TinyMCE_1 = require("../TinyMCE");
|
|
52
59
|
var Utils_1 = require("../Utils");
|
|
60
|
+
var core_1 = require("@material-ui/core");
|
|
53
61
|
var React = __importStar(require("react"));
|
|
62
|
+
var changeEvents = function () { var _a, _b, _c; return ((_c = (_b = (_a = TinyMCE_1.getTinymce()) === null || _a === void 0 ? void 0 : _a.Env) === null || _b === void 0 ? void 0 : _b.browser) === null || _c === void 0 ? void 0 : _c.isIE()) ? 'change keyup compositionend setcontent' : 'change input compositionend setcontent'; };
|
|
63
|
+
var beforeInputEvent = function () { return Utils_1.isBeforeInputEventAvailable() ? 'beforeinput SelectionChange' : 'SelectionChange'; };
|
|
54
64
|
var Editor = /** @class */ (function (_super) {
|
|
55
65
|
__extends(Editor, _super);
|
|
56
66
|
function Editor(props) {
|
|
@@ -97,16 +107,18 @@ var Editor = /** @class */ (function (_super) {
|
|
|
97
107
|
var editor = _this.editor;
|
|
98
108
|
if (editor && editor.initialized) {
|
|
99
109
|
var newContent = editor.getContent();
|
|
100
|
-
if (_this.props.value !== undefined && _this.props.value !== newContent
|
|
110
|
+
if (_this.props.value !== undefined && _this.props.value !== newContent) {
|
|
101
111
|
// start a timer and revert to the value if not applied in time
|
|
102
112
|
if (!_this.rollbackTimer) {
|
|
103
|
-
_this.rollbackTimer = window.setTimeout(_this.rollbackChange,
|
|
113
|
+
_this.rollbackTimer = window.setTimeout(_this.rollbackChange, 200);
|
|
104
114
|
}
|
|
105
115
|
}
|
|
106
116
|
if (newContent !== _this.currentContent) {
|
|
107
117
|
_this.currentContent = newContent;
|
|
108
118
|
if (Utils_1.isFunction(_this.props.onEditorChange)) {
|
|
109
|
-
_this.props.
|
|
119
|
+
var format = _this.props.outputFormat;
|
|
120
|
+
var out = format === 'html' ? newContent : editor.getContent({ format: format });
|
|
121
|
+
_this.props.onEditorChange(out, editor);
|
|
110
122
|
}
|
|
111
123
|
}
|
|
112
124
|
}
|
|
@@ -116,36 +128,16 @@ var Editor = /** @class */ (function (_super) {
|
|
|
116
128
|
_this.handleEditorChange(evt);
|
|
117
129
|
}
|
|
118
130
|
};
|
|
119
|
-
_this.initialise = function (
|
|
120
|
-
var _a, _b, _c;
|
|
121
|
-
if (attempts === void 0) { attempts = 0; }
|
|
131
|
+
_this.initialise = function () {
|
|
122
132
|
var target = _this.elementRef.current;
|
|
123
133
|
if (!target) {
|
|
124
134
|
return; // Editor has been unmounted
|
|
125
135
|
}
|
|
126
|
-
|
|
127
|
-
// this is probably someone trying to help by rendering us offscreen
|
|
128
|
-
// but we can't do that because the editor iframe must be in the document
|
|
129
|
-
// in order to have state
|
|
130
|
-
if (attempts === 0) {
|
|
131
|
-
// we probably just need to wait for the current events to be processed
|
|
132
|
-
setTimeout(function () { return _this.initialise(1); }, 1);
|
|
133
|
-
}
|
|
134
|
-
else if (attempts < 100) {
|
|
135
|
-
// wait for ten seconds, polling every tenth of a second
|
|
136
|
-
setTimeout(function () { return _this.initialise(attempts + 1); }, 100);
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
// give up, at this point it seems that more polling is unlikely to help
|
|
140
|
-
throw new Error('tinymce can only be initialised when in a document');
|
|
141
|
-
}
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
var tinymce = TinyMCE_1.getTinymce(_this.view);
|
|
136
|
+
var tinymce = TinyMCE_1.getTinymce();
|
|
145
137
|
if (!tinymce) {
|
|
146
138
|
throw new Error('tinymce should have been loaded into global scope');
|
|
147
139
|
}
|
|
148
|
-
var finalInit = __assign(__assign({}, _this.props.init), { selector: undefined, target: target, readonly: _this.props.disabled, inline: _this.inline, plugins: Utils_1.mergePlugins(
|
|
140
|
+
var finalInit = __assign(__assign({}, _this.props.init), { selector: undefined, target: target, readonly: _this.props.disabled, inline: _this.inline, plugins: Utils_1.mergePlugins(_this.props.init && _this.props.init.plugins, _this.props.plugins), toolbar: _this.props.toolbar || (_this.props.init && _this.props.init.toolbar), setup: function (editor) {
|
|
149
141
|
_this.editor = editor;
|
|
150
142
|
_this.bindHandlers({});
|
|
151
143
|
// When running in inline mode the editor gets the initial value
|
|
@@ -176,7 +168,7 @@ var Editor = /** @class */ (function (_super) {
|
|
|
176
168
|
editor.setDirty(false);
|
|
177
169
|
}
|
|
178
170
|
var disabled = (_b = _this.props.disabled) !== null && _b !== void 0 ? _b : false;
|
|
179
|
-
|
|
171
|
+
editor.mode.set(disabled ? 'readonly' : 'design');
|
|
180
172
|
// ensure existing init_instance_callback is called
|
|
181
173
|
if (_this.props.init && Utils_1.isFunction(_this.props.init.init_instance_callback)) {
|
|
182
174
|
_this.props.init.init_instance_callback(editor);
|
|
@@ -196,14 +188,6 @@ var Editor = /** @class */ (function (_super) {
|
|
|
196
188
|
_this.boundHandlers = {};
|
|
197
189
|
return _this;
|
|
198
190
|
}
|
|
199
|
-
Object.defineProperty(Editor.prototype, "view", {
|
|
200
|
-
get: function () {
|
|
201
|
-
var _a, _b;
|
|
202
|
-
return (_b = (_a = this.elementRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument.defaultView) !== null && _b !== void 0 ? _b : window;
|
|
203
|
-
},
|
|
204
|
-
enumerable: false,
|
|
205
|
-
configurable: true
|
|
206
|
-
});
|
|
207
191
|
Editor.prototype.componentDidUpdate = function (prevProps) {
|
|
208
192
|
var _this = this;
|
|
209
193
|
var _a, _b;
|
|
@@ -255,39 +239,26 @@ var Editor = /** @class */ (function (_super) {
|
|
|
255
239
|
}
|
|
256
240
|
if (this.props.disabled !== prevProps.disabled) {
|
|
257
241
|
var disabled = (_b = this.props.disabled) !== null && _b !== void 0 ? _b : false;
|
|
258
|
-
|
|
242
|
+
this.editor.mode.set(disabled ? 'readonly' : 'design');
|
|
259
243
|
}
|
|
260
244
|
}
|
|
261
245
|
}
|
|
262
246
|
};
|
|
263
247
|
Editor.prototype.componentDidMount = function () {
|
|
264
|
-
var
|
|
265
|
-
|
|
266
|
-
if (TinyMCE_1.getTinymce(this.view) !== null) {
|
|
248
|
+
var _a, _b, _c, _d, _e, _f;
|
|
249
|
+
if (TinyMCE_1.getTinymce() !== null) {
|
|
267
250
|
this.initialise();
|
|
268
251
|
}
|
|
269
|
-
else if (
|
|
270
|
-
(_b = (_a = this.props
|
|
271
|
-
}
|
|
272
|
-
else if ((_c = this.elementRef.current) === null || _c === void 0 ? void 0 : _c.ownerDocument) {
|
|
273
|
-
var successHandler = function () {
|
|
274
|
-
var _a, _b;
|
|
275
|
-
(_b = (_a = _this.props).onScriptsLoad) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
276
|
-
_this.initialise();
|
|
277
|
-
};
|
|
278
|
-
var errorHandler = function (err) {
|
|
279
|
-
var _a, _b;
|
|
280
|
-
(_b = (_a = _this.props).onScriptsLoadError) === null || _b === void 0 ? void 0 : _b.call(_a, err);
|
|
281
|
-
};
|
|
282
|
-
ScriptLoader2_1.ScriptLoader.loadList(this.elementRef.current.ownerDocument, this.getScriptSources(), (_e = (_d = this.props.scriptLoading) === null || _d === void 0 ? void 0 : _d.delay) !== null && _e !== void 0 ? _e : 0, successHandler, errorHandler);
|
|
252
|
+
else if (this.elementRef.current && this.elementRef.current.ownerDocument) {
|
|
253
|
+
ScriptLoader_1.ScriptLoader.load(this.elementRef.current.ownerDocument, this.getScriptSrc(), (_b = (_a = this.props.scriptLoading) === null || _a === void 0 ? void 0 : _a.async) !== null && _b !== void 0 ? _b : false, (_d = (_c = this.props.scriptLoading) === null || _c === void 0 ? void 0 : _c.defer) !== null && _d !== void 0 ? _d : false, (_f = (_e = this.props.scriptLoading) === null || _e === void 0 ? void 0 : _e.delay) !== null && _f !== void 0 ? _f : 0, this.initialise);
|
|
283
254
|
}
|
|
284
255
|
};
|
|
285
256
|
Editor.prototype.componentWillUnmount = function () {
|
|
286
257
|
var _this = this;
|
|
287
258
|
var editor = this.editor;
|
|
288
259
|
if (editor) {
|
|
289
|
-
editor.off(
|
|
290
|
-
editor.off(
|
|
260
|
+
editor.off(changeEvents(), this.handleEditorChange);
|
|
261
|
+
editor.off(beforeInputEvent(), this.handleBeforeInput);
|
|
291
262
|
editor.off('keypress', this.handleEditorChangeSpecial);
|
|
292
263
|
editor.off('keydown', this.handleBeforeInputSpecial);
|
|
293
264
|
editor.off('NewBlock', this.handleEditorChange);
|
|
@@ -300,17 +271,8 @@ var Editor = /** @class */ (function (_super) {
|
|
|
300
271
|
}
|
|
301
272
|
};
|
|
302
273
|
Editor.prototype.render = function () {
|
|
303
|
-
return
|
|
304
|
-
|
|
305
|
-
Editor.prototype.changeEvents = function () {
|
|
306
|
-
var _a, _b, _c;
|
|
307
|
-
var isIE = (_c = (_b = (_a = TinyMCE_1.getTinymce(this.view)) === null || _a === void 0 ? void 0 : _a.Env) === null || _b === void 0 ? void 0 : _b.browser) === null || _c === void 0 ? void 0 : _c.isIE();
|
|
308
|
-
return (isIE
|
|
309
|
-
? 'change keyup compositionend setcontent CommentChange'
|
|
310
|
-
: 'change input compositionend setcontent CommentChange');
|
|
311
|
-
};
|
|
312
|
-
Editor.prototype.beforeInputEvent = function () {
|
|
313
|
-
return Utils_1.isBeforeInputEventAvailable() ? 'beforeinput SelectionChange' : 'SelectionChange';
|
|
274
|
+
return React.createElement(React.Fragment, null,
|
|
275
|
+
React.createElement(Tema, null, this.inline ? this.renderInline() : this.renderIframe()));
|
|
314
276
|
};
|
|
315
277
|
Editor.prototype.renderInline = function () {
|
|
316
278
|
var _a = this.props.tagName, tagName = _a === void 0 ? 'div' : _a;
|
|
@@ -327,29 +289,13 @@ var Editor = /** @class */ (function (_super) {
|
|
|
327
289
|
id: this.id
|
|
328
290
|
});
|
|
329
291
|
};
|
|
330
|
-
Editor.prototype.
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
var defer = (_b = this.props.scriptLoading) === null || _b === void 0 ? void 0 : _b.defer;
|
|
334
|
-
if (this.props.tinymceScriptSrc !== undefined) {
|
|
335
|
-
if (typeof this.props.tinymceScriptSrc === 'string') {
|
|
336
|
-
return [{ src: this.props.tinymceScriptSrc, async: async, defer: defer }];
|
|
337
|
-
}
|
|
338
|
-
// multiple scripts can be specified which allows for hybrid mode
|
|
339
|
-
return this.props.tinymceScriptSrc.map(function (item) {
|
|
340
|
-
if (typeof item === 'string') {
|
|
341
|
-
// async does not make sense for multiple items unless
|
|
342
|
-
// they are not dependent (which will be unlikely)
|
|
343
|
-
return { src: item, async: async, defer: defer };
|
|
344
|
-
}
|
|
345
|
-
return item;
|
|
346
|
-
});
|
|
292
|
+
Editor.prototype.getScriptSrc = function () {
|
|
293
|
+
if (typeof this.props.tinymceScriptSrc === 'string') {
|
|
294
|
+
return this.props.tinymceScriptSrc;
|
|
347
295
|
}
|
|
348
|
-
// fallback to the cloud when the tinymceScriptSrc is not specified
|
|
349
296
|
var channel = this.props.cloudChannel;
|
|
350
297
|
var apiKey = this.props.apiKey ? this.props.apiKey : 'no-api-key';
|
|
351
|
-
|
|
352
|
-
return [{ src: cloudTinyJs, async: async, defer: defer }];
|
|
298
|
+
return "https://cdn.tiny.cloud/1/" + apiKey + "/tinymce/" + channel + "/tinymce.min.js";
|
|
353
299
|
};
|
|
354
300
|
Editor.prototype.getInitialValue = function () {
|
|
355
301
|
if (typeof this.props.initialValue === 'string') {
|
|
@@ -370,15 +316,15 @@ var Editor = /** @class */ (function (_super) {
|
|
|
370
316
|
var wasControlled = isValueControlled(prevProps);
|
|
371
317
|
var nowControlled = isValueControlled(this.props);
|
|
372
318
|
if (!wasControlled && nowControlled) {
|
|
373
|
-
this.editor.on(
|
|
374
|
-
this.editor.on(
|
|
319
|
+
this.editor.on(changeEvents(), this.handleEditorChange);
|
|
320
|
+
this.editor.on(beforeInputEvent(), this.handleBeforeInput);
|
|
375
321
|
this.editor.on('keydown', this.handleBeforeInputSpecial);
|
|
376
322
|
this.editor.on('keyup', this.handleEditorChangeSpecial);
|
|
377
323
|
this.editor.on('NewBlock', this.handleEditorChange);
|
|
378
324
|
}
|
|
379
325
|
else if (wasControlled && !nowControlled) {
|
|
380
|
-
this.editor.off(
|
|
381
|
-
this.editor.off(
|
|
326
|
+
this.editor.off(changeEvents(), this.handleEditorChange);
|
|
327
|
+
this.editor.off(beforeInputEvent(), this.handleBeforeInput);
|
|
382
328
|
this.editor.off('keydown', this.handleBeforeInputSpecial);
|
|
383
329
|
this.editor.off('keyup', this.handleEditorChangeSpecial);
|
|
384
330
|
this.editor.off('NewBlock', this.handleEditorChange);
|
|
@@ -387,8 +333,19 @@ var Editor = /** @class */ (function (_super) {
|
|
|
387
333
|
};
|
|
388
334
|
Editor.propTypes = EditorPropTypes_1.EditorPropTypes;
|
|
389
335
|
Editor.defaultProps = {
|
|
390
|
-
cloudChannel: '
|
|
336
|
+
cloudChannel: '5'
|
|
391
337
|
};
|
|
392
338
|
return Editor;
|
|
393
339
|
}(React.Component));
|
|
394
340
|
exports.Editor = Editor;
|
|
341
|
+
var Tema = function (_a) {
|
|
342
|
+
var children = _a.children;
|
|
343
|
+
var theme = core_1.useTheme().palette.type;
|
|
344
|
+
return (React.createElement("div", null,
|
|
345
|
+
theme === 'dark' ? React.createElement(React.Fragment, null,
|
|
346
|
+
React.createElement("link", { rel: 'stylesheet', href: './skins/ui/dark/skin.min.css' }),
|
|
347
|
+
React.createElement("link", { rel: 'stylesheet', href: './skins/ui/dark/content.min.css' })) : React.createElement(React.Fragment, null,
|
|
348
|
+
React.createElement("link", { rel: 'stylesheet', href: './skins/ui/default/content.min.css' }),
|
|
349
|
+
React.createElement("link", { rel: 'stylesheet', href: './skins/ui/default/skin.min.css' })),
|
|
350
|
+
children));
|
|
351
|
+
};
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017-present, Ephox, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache 2 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
1
8
|
import { IProps } from './Editor';
|
|
2
9
|
import { IEvents } from '../Events';
|
|
3
10
|
import * as PropTypes from 'prop-types';
|
|
4
11
|
export declare type CopyProps<T> = {
|
|
5
|
-
[P in keyof T]: PropTypes.Requireable<unknown>;
|
|
12
|
+
[P in keyof T]: PropTypes.Requireable<P | unknown>;
|
|
6
13
|
};
|
|
7
14
|
export declare type IEventPropTypes = CopyProps<IEvents>;
|
|
8
15
|
export interface IEditorPropTypes extends IEventPropTypes, CopyProps<IProps> {
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2017-present, Ephox, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the Apache 2 license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
2
9
|
var __assign = (this && this.__assign) || function () {
|
|
3
10
|
__assign = Object.assign || function(t) {
|
|
4
11
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -46,7 +53,6 @@ exports.eventPropTypes = {
|
|
|
46
53
|
onClearUndos: PropTypes.func,
|
|
47
54
|
onClick: PropTypes.func,
|
|
48
55
|
onContextMenu: PropTypes.func,
|
|
49
|
-
onCommentChange: PropTypes.func,
|
|
50
56
|
onCopy: PropTypes.func,
|
|
51
57
|
onCut: PropTypes.func,
|
|
52
58
|
onDblclick: PropTypes.func,
|
|
@@ -95,25 +101,9 @@ exports.eventPropTypes = {
|
|
|
95
101
|
onShow: PropTypes.func,
|
|
96
102
|
onSubmit: PropTypes.func,
|
|
97
103
|
onUndo: PropTypes.func,
|
|
98
|
-
onVisualAid: PropTypes.func
|
|
99
|
-
onSkinLoadError: PropTypes.func,
|
|
100
|
-
onThemeLoadError: PropTypes.func,
|
|
101
|
-
onModelLoadError: PropTypes.func,
|
|
102
|
-
onPluginLoadError: PropTypes.func,
|
|
103
|
-
onIconsLoadError: PropTypes.func,
|
|
104
|
-
onLanguageLoadError: PropTypes.func,
|
|
105
|
-
onScriptsLoad: PropTypes.func,
|
|
106
|
-
onScriptsLoadError: PropTypes.func,
|
|
104
|
+
onVisualAid: PropTypes.func
|
|
107
105
|
};
|
|
108
|
-
exports.EditorPropTypes = __assign({ apiKey: PropTypes.string, id: PropTypes.string, inline: PropTypes.bool, init: PropTypes.object, initialValue: PropTypes.string, onEditorChange: PropTypes.func, value: PropTypes.string, tagName: PropTypes.string, cloudChannel: PropTypes.string, plugins: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), toolbar: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), disabled: PropTypes.bool, textareaName: PropTypes.string, tinymceScriptSrc: PropTypes.
|
|
109
|
-
PropTypes.string,
|
|
110
|
-
PropTypes.arrayOf(PropTypes.string),
|
|
111
|
-
PropTypes.arrayOf(PropTypes.shape({
|
|
112
|
-
src: PropTypes.string,
|
|
113
|
-
async: PropTypes.bool,
|
|
114
|
-
defer: PropTypes.bool
|
|
115
|
-
}))
|
|
116
|
-
]), rollback: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf([false])]), scriptLoading: PropTypes.shape({
|
|
106
|
+
exports.EditorPropTypes = __assign({ apiKey: PropTypes.string, id: PropTypes.string, inline: PropTypes.bool, init: PropTypes.object, initialValue: PropTypes.string, onEditorChange: PropTypes.func, outputFormat: PropTypes.oneOf(['html', 'text']), value: PropTypes.string, tagName: PropTypes.string, cloudChannel: PropTypes.string, plugins: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), toolbar: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), disabled: PropTypes.bool, textareaName: PropTypes.string, tinymceScriptSrc: PropTypes.string, scriptLoading: PropTypes.shape({
|
|
117
107
|
async: PropTypes.bool,
|
|
118
108
|
defer: PropTypes.bool,
|
|
119
109
|
delay: PropTypes.number
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017-present, Ephox, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache 2 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { Editor } from './components/Editor';
|
|
9
|
+
export { Editor };
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2017-present, Ephox, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the Apache 2 license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.Editor = void 0;
|
|
4
11
|
var Editor_1 = require("./components/Editor");
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017-present, Ephox, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache 2 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
1
9
|
import { Editor as TinyMCEEditor, EditorEvent, Events } from './tinymce/tinymce';
|
|
2
10
|
|
|
3
11
|
export type EventHandler<A> = (a: EditorEvent<A>, editor: TinyMCEEditor) => unknown;
|
|
@@ -45,7 +53,6 @@ export interface ITinyEvents {
|
|
|
45
53
|
onBeforeSetContent: EEventHandler<'BeforeSetContent'>;
|
|
46
54
|
onChange: EventHandler<unknown>;
|
|
47
55
|
onClearUndos: EEventHandler<'ClearUndos'>;
|
|
48
|
-
onCommentChange: EventHandler<unknown>;
|
|
49
56
|
onDeactivate: EEventHandler<'deactivate'>;
|
|
50
57
|
onDirty: EventHandler<unknown>;
|
|
51
58
|
onExecCommand: EEventHandler<'ExecCommand'>;
|
|
@@ -71,14 +78,6 @@ export interface ITinyEvents {
|
|
|
71
78
|
onSubmit: EventHandler<unknown>;
|
|
72
79
|
onUndo: EEventHandler<'Undo'>;
|
|
73
80
|
onVisualAid: EventHandler<unknown>;
|
|
74
|
-
onSkinLoadError: EEventHandler<'SkinLoadError'>;
|
|
75
|
-
onThemeLoadError: EEventHandler<'ThemeLoadError'>;
|
|
76
|
-
onModelLoadError: EEventHandler<'ModelLoadError'>;
|
|
77
|
-
onPluginLoadError: EEventHandler<'PluginLoadError'>;
|
|
78
|
-
onIconsLoadError: EEventHandler<'IconsLoadError'>;
|
|
79
|
-
onLanguageLoadError: EEventHandler<'LanguageLoadError'>;
|
|
80
|
-
onScriptsLoad: () => void;
|
|
81
|
-
onScriptsLoadError: (err: unknown) => void;
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
export interface IEvents extends INativeEvents, ITinyEvents {}
|