argous 1.2.206 → 1.2.207
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 +9 -7
- package/dist/components/Editor/Events.js +0 -7
- package/dist/components/Editor/TinyMCE.d.ts +1 -8
- package/dist/components/Editor/TinyMCE.js +2 -10
- package/dist/components/Editor/Utils.d.ts +2 -7
- package/dist/components/Editor/Utils.js +29 -9
- package/dist/components/Editor/components/Editor.d.ts +17 -16
- package/dist/components/Editor/components/Editor.js +92 -49
- package/dist/components/Editor/components/EditorPropTypes.d.ts +1 -8
- package/dist/components/Editor/components/EditorPropTypes.js +19 -9
- package/dist/components/Editor/index.d.ts +2 -9
- package/dist/components/Editor/index.js +0 -7
- package/lib/components/Editor/Events.ts +9 -8
- package/lib/components/Editor/ScriptLoader2.ts +161 -0
- package/lib/components/Editor/TinyMCE.ts +2 -12
- package/lib/components/Editor/Utils.ts +25 -8
- package/lib/components/Editor/components/Editor.tsx +100 -78
- package/lib/components/Editor/components/EditorPropTypes.ts +21 -12
- package/lib/components/Editor/index.tsx +2 -10
- package/package.json +1 -1
- package/lib/components/Editor/ScriptLoader.ts +0 -96
|
@@ -1,96 +0,0 @@
|
|
|
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
|
-
|
|
9
|
-
import { uuid } from './Utils';
|
|
10
|
-
|
|
11
|
-
export type callbackFn = () => void;
|
|
12
|
-
export interface IStateObj {
|
|
13
|
-
listeners: callbackFn[];
|
|
14
|
-
scriptId: string;
|
|
15
|
-
scriptLoading: boolean;
|
|
16
|
-
scriptLoaded: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const createState = (): IStateObj => ({
|
|
20
|
-
listeners: [],
|
|
21
|
-
scriptId: uuid('tiny-script'),
|
|
22
|
-
scriptLoading: false,
|
|
23
|
-
scriptLoaded: false
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
interface ScriptLoaderInterface {
|
|
27
|
-
load: (doc: Document, url: string, async: boolean, defer: boolean, delay: number, callback: callbackFn) => void;
|
|
28
|
-
reinitialize: () => void;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const CreateScriptLoader = (): ScriptLoaderInterface => {
|
|
32
|
-
let state: IStateObj = createState();
|
|
33
|
-
|
|
34
|
-
const injectScriptTag = (scriptId: string, doc: Document, url: string, async: boolean, defer: boolean, callback: callbackFn) => {
|
|
35
|
-
const scriptTag = doc.createElement('script');
|
|
36
|
-
scriptTag.referrerPolicy = 'origin';
|
|
37
|
-
scriptTag.type = 'application/javascript';
|
|
38
|
-
scriptTag.id = scriptId;
|
|
39
|
-
scriptTag.src = url;
|
|
40
|
-
scriptTag.async = async;
|
|
41
|
-
scriptTag.defer = defer;
|
|
42
|
-
|
|
43
|
-
// scriptTag.appendChild(document.createTextNode(url));
|
|
44
|
-
|
|
45
|
-
const handler = () => {
|
|
46
|
-
scriptTag.removeEventListener('load', handler);
|
|
47
|
-
callback();
|
|
48
|
-
};
|
|
49
|
-
scriptTag.addEventListener('load', handler);
|
|
50
|
-
if (doc.head) {
|
|
51
|
-
doc.head.appendChild(scriptTag);
|
|
52
|
-
}
|
|
53
|
-
// document.body.appendChild(scriptTag);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const load = (doc: Document, url: string, async: boolean, defer: boolean, delay: number, callback: callbackFn) => {
|
|
57
|
-
|
|
58
|
-
const scriptTagInjection = () => injectScriptTag(
|
|
59
|
-
state.scriptId, doc, url, async, defer,
|
|
60
|
-
() => {
|
|
61
|
-
state.listeners.forEach((fn) => fn());
|
|
62
|
-
state.scriptLoaded = true;
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
if (state.scriptLoaded) {
|
|
67
|
-
callback();
|
|
68
|
-
} else {
|
|
69
|
-
state.listeners.push(callback);
|
|
70
|
-
if (!state.scriptLoading) {
|
|
71
|
-
state.scriptLoading = true;
|
|
72
|
-
if (delay > 0) {
|
|
73
|
-
setTimeout(scriptTagInjection, delay);
|
|
74
|
-
} else {
|
|
75
|
-
scriptTagInjection();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// Only to be used by tests.
|
|
82
|
-
const reinitialize = () => {
|
|
83
|
-
state = createState();
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
return {
|
|
87
|
-
load,
|
|
88
|
-
reinitialize
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const ScriptLoader = CreateScriptLoader();
|
|
93
|
-
|
|
94
|
-
export {
|
|
95
|
-
ScriptLoader
|
|
96
|
-
};
|