argous 1.2.206 → 1.2.208

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.
@@ -1,7 +1,9 @@
1
1
  export function server(): string;
2
2
  export function api(): string;
3
- export function headers(): {
4
- lgTkn: string;
3
+ export function headers({ token }: {
4
+ token: any;
5
+ }): {
6
+ lgTkn: any;
5
7
  };
6
8
  export function fetchToArgous(request: string, data: any): any;
7
9
  export function login(data: any): Promise<any>;
package/dist/api/index.js CHANGED
@@ -54,7 +54,10 @@ var server = function () { return "://" + config_1.getConfig()[/^[a-z]+.+\.com\.
54
54
  exports.server = server;
55
55
  var api = function () { return "" + (config_1.getConfig().ssl ? 'https' : 'http') + exports.server() + "argous/"; };
56
56
  exports.api = api;
57
- var headers = function () { return ({ lgTkn: utils_1.getCookie('lt') }); };
57
+ var headers = function (_a) {
58
+ var token = _a.token;
59
+ return ({ lgTkn: (token) ? token : utils_1.getCookie('lt') });
60
+ };
58
61
  exports.headers = headers;
59
62
  /**
60
63
  * @deprecated
@@ -285,7 +288,7 @@ var action = function (data) { return __awaiter(void 0, void 0, void 0, function
285
288
  case 0: return [4 /*yield*/, fetch(exports.api() + "agaction.rslvr", {
286
289
  method: 'POST',
287
290
  body: JSON.stringify(data),
288
- headers: exports.headers()
291
+ headers: exports.headers(data)
289
292
  })];
290
293
  case 1:
291
294
  res = _a.sent();
@@ -1,10 +1,3 @@
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
  import { Editor as TinyMCEEditor, EditorEvent, Events } from './tinymce/tinymce';
9
2
  export declare type EventHandler<A> = (a: EditorEvent<A>, editor: TinyMCEEditor) => unknown;
10
3
  declare type EEventHandler<K extends keyof Events.EditorEventMap> = EventHandler<Events.EditorEventMap[K]>;
@@ -48,6 +41,7 @@ export interface ITinyEvents {
48
41
  onBeforeSetContent: EEventHandler<'BeforeSetContent'>;
49
42
  onChange: EventHandler<unknown>;
50
43
  onClearUndos: EEventHandler<'ClearUndos'>;
44
+ onCommentChange: EventHandler<unknown>;
51
45
  onDeactivate: EEventHandler<'deactivate'>;
52
46
  onDirty: EventHandler<unknown>;
53
47
  onExecCommand: EEventHandler<'ExecCommand'>;
@@ -73,6 +67,14 @@ export interface ITinyEvents {
73
67
  onSubmit: EventHandler<unknown>;
74
68
  onUndo: EEventHandler<'Undo'>;
75
69
  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;
76
78
  }
77
79
  export interface IEvents extends INativeEvents, ITinyEvents {
78
80
  }
@@ -1,9 +1,2 @@
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
- */
9
2
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +1,3 @@
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
  import { TinyMCE as TinyMCEGlobal } from './tinymce/tinymce';
9
- declare const getTinymce: () => TinyMCEGlobal | null;
2
+ declare const getTinymce: (view: Window) => TinyMCEGlobal | null;
10
3
  export { getTinymce };
@@ -1,16 +1,8 @@
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
- */
9
2
  Object.defineProperty(exports, "__esModule", { value: true });
10
3
  exports.getTinymce = void 0;
11
- var getGlobal = function () { return (typeof window !== 'undefined' ? window : global); };
12
- var getTinymce = function () {
13
- var global = getGlobal();
4
+ var getTinymce = function (view) {
5
+ var global = view;
14
6
  return global && global.tinymce ? global.tinymce : null;
15
7
  };
16
8
  exports.getTinymce = getTinymce;
@@ -1,10 +1,3 @@
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
  import { IAllProps } from './components/Editor';
9
2
  import { IEventPropTypes } from './components/EditorPropTypes';
10
3
  import { Editor as TinyMCEEditor, EditorEvent } from './tinymce/tinymce';
@@ -16,4 +9,6 @@ export declare const uuid: (prefix: string) => string;
16
9
  export declare const isTextareaOrInput: (element: Element | null) => element is HTMLInputElement | HTMLTextAreaElement;
17
10
  export declare const mergePlugins: (initPlugins: string | string[] | undefined, inputPlugins: string | string[] | undefined) => string[];
18
11
  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;
19
14
  export {};
@@ -1,13 +1,6 @@
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
- */
9
2
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.isBeforeInputEventAvailable = exports.mergePlugins = exports.isTextareaOrInput = exports.uuid = exports.configHandlers = exports.configHandlers2 = exports.isFunction = void 0;
3
+ exports.setMode = exports.isInDoc = exports.isBeforeInputEventAvailable = exports.mergePlugins = exports.isTextareaOrInput = exports.uuid = exports.configHandlers = exports.configHandlers2 = exports.isFunction = void 0;
11
4
  var EditorPropTypes_1 = require("./components/EditorPropTypes");
12
5
  var isFunction = function (x) { return typeof x === 'function'; };
13
6
  exports.isFunction = isFunction;
@@ -34,7 +27,9 @@ var configHandlers2 = function (handlerLookup, on, off, adapter, prevProps, prop
34
27
  };
35
28
  exports.configHandlers2 = configHandlers2;
36
29
  var configHandlers = function (editor, prevProps, props, boundHandlers, lookup) {
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);
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);
38
33
  };
39
34
  exports.configHandlers = configHandlers;
40
35
  var unique = 0;
@@ -60,3 +55,28 @@ var mergePlugins = function (initPlugins, inputPlugins) { return normalizePlugin
60
55
  exports.mergePlugins = mergePlugins;
61
56
  var isBeforeInputEventAvailable = function () { return window.InputEvent && typeof InputEvent.prototype.getTargetRanges === 'function'; };
62
57
  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,14 +1,9 @@
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
  import { IEditorPropTypes } from './EditorPropTypes';
9
2
  import { IEvents } from '../Events';
10
- import { Editor as TinyMCEEditor, RawEditorOptions } from '../tinymce/tinymce';
3
+ import { ScriptItem } from '../ScriptLoader2';
4
+ import { Editor as TinyMCEEditor, TinyMCE } from '../tinymce/tinymce';
11
5
  import * as React from 'react';
6
+ declare type EditorOptions = Parameters<TinyMCE['init']>[0];
12
7
  export interface IProps {
13
8
  apiKey: string;
14
9
  id: string;
@@ -16,19 +11,18 @@ export interface IProps {
16
11
  initialValue: string;
17
12
  onEditorChange: (a: string, editor: TinyMCEEditor) => void;
18
13
  value: string;
19
- init: RawEditorOptions & {
14
+ init: EditorOptions & {
20
15
  selector?: undefined;
21
16
  target?: undefined;
22
17
  };
23
- /** @deprecated use `editor.getContent({format: 'text' })` in `onEditorChange` prop instead */
24
- outputFormat: 'html' | 'text';
25
18
  tagName: string;
26
19
  cloudChannel: string;
27
- plugins: NonNullable<RawEditorOptions['plugins']>;
28
- toolbar: NonNullable<RawEditorOptions['toolbar']>;
20
+ plugins: NonNullable<EditorOptions['plugins']>;
21
+ toolbar: NonNullable<EditorOptions['toolbar']>;
29
22
  disabled: boolean;
30
23
  textareaName: string;
31
- tinymceScriptSrc: string;
24
+ tinymceScriptSrc: string | string[] | ScriptItem[];
25
+ rollback: number | false;
32
26
  scriptLoading: {
33
27
  async?: boolean;
34
28
  defer?: boolean;
@@ -49,13 +43,19 @@ export declare class Editor extends React.Component<IAllProps> {
49
43
  private rollbackTimer;
50
44
  private valueCursor;
51
45
  constructor(props: Partial<IAllProps>);
46
+ private get view();
52
47
  componentDidUpdate(prevProps: Partial<IAllProps>): void;
53
48
  componentDidMount(): void;
54
49
  componentWillUnmount(): void;
55
- render(): React.JSX.Element;
50
+ render(): React.ReactElement<{
51
+ ref: React.RefObject<HTMLElement>;
52
+ id: string;
53
+ }, string | React.JSXElementConstructor<any>>;
54
+ private changeEvents;
55
+ private beforeInputEvent;
56
56
  private renderInline;
57
57
  private renderIframe;
58
- private getScriptSrc;
58
+ private getScriptSources;
59
59
  private getInitialValue;
60
60
  private bindHandlers;
61
61
  private rollbackChange;
@@ -65,3 +65,4 @@ export declare class Editor extends React.Component<IAllProps> {
65
65
  private handleEditorChangeSpecial;
66
66
  private initialise;
67
67
  }
68
+ export {};
@@ -1,11 +1,4 @@
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
- */
9
2
  var __extends = (this && this.__extends) || (function () {
10
3
  var extendStatics = function (d, b) {
11
4
  extendStatics = Object.setPrototypeOf ||
@@ -54,13 +47,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
54
47
  Object.defineProperty(exports, "__esModule", { value: true });
55
48
  exports.Editor = void 0;
56
49
  var EditorPropTypes_1 = require("./EditorPropTypes");
57
- var ScriptLoader_1 = require("../ScriptLoader");
50
+ var ScriptLoader2_1 = require("../ScriptLoader2");
58
51
  var TinyMCE_1 = require("../TinyMCE");
59
52
  var Utils_1 = require("../Utils");
60
- var core_1 = require("@material-ui/core");
61
53
  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'; };
64
54
  var Editor = /** @class */ (function (_super) {
65
55
  __extends(Editor, _super);
66
56
  function Editor(props) {
@@ -107,18 +97,16 @@ var Editor = /** @class */ (function (_super) {
107
97
  var editor = _this.editor;
108
98
  if (editor && editor.initialized) {
109
99
  var newContent = editor.getContent();
110
- if (_this.props.value !== undefined && _this.props.value !== newContent) {
100
+ if (_this.props.value !== undefined && _this.props.value !== newContent && _this.props.rollback !== false) {
111
101
  // start a timer and revert to the value if not applied in time
112
102
  if (!_this.rollbackTimer) {
113
- _this.rollbackTimer = window.setTimeout(_this.rollbackChange, 200);
103
+ _this.rollbackTimer = window.setTimeout(_this.rollbackChange, typeof _this.props.rollback === 'number' ? _this.props.rollback : 200);
114
104
  }
115
105
  }
116
106
  if (newContent !== _this.currentContent) {
117
107
  _this.currentContent = newContent;
118
108
  if (Utils_1.isFunction(_this.props.onEditorChange)) {
119
- var format = _this.props.outputFormat;
120
- var out = format === 'html' ? newContent : editor.getContent({ format: format });
121
- _this.props.onEditorChange(out, editor);
109
+ _this.props.onEditorChange(newContent, editor);
122
110
  }
123
111
  }
124
112
  }
@@ -128,16 +116,36 @@ var Editor = /** @class */ (function (_super) {
128
116
  _this.handleEditorChange(evt);
129
117
  }
130
118
  };
131
- _this.initialise = function () {
119
+ _this.initialise = function (attempts) {
120
+ var _a, _b, _c;
121
+ if (attempts === void 0) { attempts = 0; }
132
122
  var target = _this.elementRef.current;
133
123
  if (!target) {
134
124
  return; // Editor has been unmounted
135
125
  }
136
- var tinymce = TinyMCE_1.getTinymce();
126
+ if (!Utils_1.isInDoc(target)) {
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);
137
145
  if (!tinymce) {
138
146
  throw new Error('tinymce should have been loaded into global scope');
139
147
  }
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) {
148
+ var finalInit = __assign(__assign({}, _this.props.init), { selector: undefined, target: target, readonly: _this.props.disabled, inline: _this.inline, plugins: Utils_1.mergePlugins((_a = _this.props.init) === null || _a === void 0 ? void 0 : _a.plugins, _this.props.plugins), toolbar: (_b = _this.props.toolbar) !== null && _b !== void 0 ? _b : (_c = _this.props.init) === null || _c === void 0 ? void 0 : _c.toolbar, setup: function (editor) {
141
149
  _this.editor = editor;
142
150
  _this.bindHandlers({});
143
151
  // When running in inline mode the editor gets the initial value
@@ -168,7 +176,7 @@ var Editor = /** @class */ (function (_super) {
168
176
  editor.setDirty(false);
169
177
  }
170
178
  var disabled = (_b = _this.props.disabled) !== null && _b !== void 0 ? _b : false;
171
- editor.mode.set(disabled ? 'readonly' : 'design');
179
+ Utils_1.setMode(_this.editor, disabled ? 'readonly' : 'design');
172
180
  // ensure existing init_instance_callback is called
173
181
  if (_this.props.init && Utils_1.isFunction(_this.props.init.init_instance_callback)) {
174
182
  _this.props.init.init_instance_callback(editor);
@@ -188,6 +196,14 @@ var Editor = /** @class */ (function (_super) {
188
196
  _this.boundHandlers = {};
189
197
  return _this;
190
198
  }
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
+ });
191
207
  Editor.prototype.componentDidUpdate = function (prevProps) {
192
208
  var _this = this;
193
209
  var _a, _b;
@@ -239,26 +255,39 @@ var Editor = /** @class */ (function (_super) {
239
255
  }
240
256
  if (this.props.disabled !== prevProps.disabled) {
241
257
  var disabled = (_b = this.props.disabled) !== null && _b !== void 0 ? _b : false;
242
- this.editor.mode.set(disabled ? 'readonly' : 'design');
258
+ Utils_1.setMode(this.editor, disabled ? 'readonly' : 'design');
243
259
  }
244
260
  }
245
261
  }
246
262
  };
247
263
  Editor.prototype.componentDidMount = function () {
248
- var _a, _b, _c, _d, _e, _f;
249
- if (TinyMCE_1.getTinymce() !== null) {
264
+ var _this = this;
265
+ var _a, _b, _c, _d, _e;
266
+ if (TinyMCE_1.getTinymce(this.view) !== null) {
250
267
  this.initialise();
251
268
  }
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);
269
+ else if (Array.isArray(this.props.tinymceScriptSrc) && this.props.tinymceScriptSrc.length === 0) {
270
+ (_b = (_a = this.props).onScriptsLoadError) === null || _b === void 0 ? void 0 : _b.call(_a, new Error('No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array.'));
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);
254
283
  }
255
284
  };
256
285
  Editor.prototype.componentWillUnmount = function () {
257
286
  var _this = this;
258
287
  var editor = this.editor;
259
288
  if (editor) {
260
- editor.off(changeEvents(), this.handleEditorChange);
261
- editor.off(beforeInputEvent(), this.handleBeforeInput);
289
+ editor.off(this.changeEvents(), this.handleEditorChange);
290
+ editor.off(this.beforeInputEvent(), this.handleBeforeInput);
262
291
  editor.off('keypress', this.handleEditorChangeSpecial);
263
292
  editor.off('keydown', this.handleBeforeInputSpecial);
264
293
  editor.off('NewBlock', this.handleEditorChange);
@@ -271,8 +300,17 @@ var Editor = /** @class */ (function (_super) {
271
300
  }
272
301
  };
273
302
  Editor.prototype.render = function () {
274
- return React.createElement(React.Fragment, null,
275
- React.createElement(Tema, null, this.inline ? this.renderInline() : this.renderIframe()));
303
+ return this.inline ? this.renderInline() : this.renderIframe();
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';
276
314
  };
277
315
  Editor.prototype.renderInline = function () {
278
316
  var _a = this.props.tagName, tagName = _a === void 0 ? 'div' : _a;
@@ -289,13 +327,29 @@ var Editor = /** @class */ (function (_super) {
289
327
  id: this.id
290
328
  });
291
329
  };
292
- Editor.prototype.getScriptSrc = function () {
293
- if (typeof this.props.tinymceScriptSrc === 'string') {
294
- return this.props.tinymceScriptSrc;
330
+ Editor.prototype.getScriptSources = function () {
331
+ var _a, _b;
332
+ var async = (_a = this.props.scriptLoading) === null || _a === void 0 ? void 0 : _a.async;
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
+ });
295
347
  }
348
+ // fallback to the cloud when the tinymceScriptSrc is not specified
296
349
  var channel = this.props.cloudChannel;
297
350
  var apiKey = this.props.apiKey ? this.props.apiKey : 'no-api-key';
298
- return "https://cdn.tiny.cloud/1/" + apiKey + "/tinymce/" + channel + "/tinymce.min.js";
351
+ var cloudTinyJs = "https://cdn.tiny.cloud/1/" + apiKey + "/tinymce/" + channel + "/tinymce.min.js";
352
+ return [{ src: cloudTinyJs, async: async, defer: defer }];
299
353
  };
300
354
  Editor.prototype.getInitialValue = function () {
301
355
  if (typeof this.props.initialValue === 'string') {
@@ -316,15 +370,15 @@ var Editor = /** @class */ (function (_super) {
316
370
  var wasControlled = isValueControlled(prevProps);
317
371
  var nowControlled = isValueControlled(this.props);
318
372
  if (!wasControlled && nowControlled) {
319
- this.editor.on(changeEvents(), this.handleEditorChange);
320
- this.editor.on(beforeInputEvent(), this.handleBeforeInput);
373
+ this.editor.on(this.changeEvents(), this.handleEditorChange);
374
+ this.editor.on(this.beforeInputEvent(), this.handleBeforeInput);
321
375
  this.editor.on('keydown', this.handleBeforeInputSpecial);
322
376
  this.editor.on('keyup', this.handleEditorChangeSpecial);
323
377
  this.editor.on('NewBlock', this.handleEditorChange);
324
378
  }
325
379
  else if (wasControlled && !nowControlled) {
326
- this.editor.off(changeEvents(), this.handleEditorChange);
327
- this.editor.off(beforeInputEvent(), this.handleBeforeInput);
380
+ this.editor.off(this.changeEvents(), this.handleEditorChange);
381
+ this.editor.off(this.beforeInputEvent(), this.handleBeforeInput);
328
382
  this.editor.off('keydown', this.handleBeforeInputSpecial);
329
383
  this.editor.off('keyup', this.handleEditorChangeSpecial);
330
384
  this.editor.off('NewBlock', this.handleEditorChange);
@@ -333,19 +387,8 @@ var Editor = /** @class */ (function (_super) {
333
387
  };
334
388
  Editor.propTypes = EditorPropTypes_1.EditorPropTypes;
335
389
  Editor.defaultProps = {
336
- cloudChannel: '5'
390
+ cloudChannel: '6'
337
391
  };
338
392
  return Editor;
339
393
  }(React.Component));
340
394
  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,15 +1,8 @@
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
  import { IProps } from './Editor';
9
2
  import { IEvents } from '../Events';
10
3
  import * as PropTypes from 'prop-types';
11
4
  export declare type CopyProps<T> = {
12
- [P in keyof T]: PropTypes.Requireable<P | unknown>;
5
+ [P in keyof T]: PropTypes.Requireable<unknown>;
13
6
  };
14
7
  export declare type IEventPropTypes = CopyProps<IEvents>;
15
8
  export interface IEditorPropTypes extends IEventPropTypes, CopyProps<IProps> {
@@ -1,11 +1,4 @@
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
- */
9
2
  var __assign = (this && this.__assign) || function () {
10
3
  __assign = Object.assign || function(t) {
11
4
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -53,6 +46,7 @@ exports.eventPropTypes = {
53
46
  onClearUndos: PropTypes.func,
54
47
  onClick: PropTypes.func,
55
48
  onContextMenu: PropTypes.func,
49
+ onCommentChange: PropTypes.func,
56
50
  onCopy: PropTypes.func,
57
51
  onCut: PropTypes.func,
58
52
  onDblclick: PropTypes.func,
@@ -101,9 +95,25 @@ exports.eventPropTypes = {
101
95
  onShow: PropTypes.func,
102
96
  onSubmit: PropTypes.func,
103
97
  onUndo: PropTypes.func,
104
- onVisualAid: 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,
105
107
  };
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({
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.oneOfType([
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({
107
117
  async: PropTypes.bool,
108
118
  defer: PropTypes.bool,
109
119
  delay: PropTypes.number
@@ -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
+ import { Editor, IAllProps } from './components/Editor';
2
+ export { Editor, IAllProps };
@@ -1,11 +1,4 @@
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
- */
9
2
  Object.defineProperty(exports, "__esModule", { value: true });
10
3
  exports.Editor = void 0;
11
4
  var Editor_1 = require("./components/Editor");
@@ -12,7 +12,7 @@ export declare const getServerValue: (field: string) => Promise<any>;
12
12
  */
13
13
  export declare const setServerValue: (field: string, value: any) => Promise<any>;
14
14
  export declare const enableDebugger: () => void;
15
- export declare const serverAction: (metodo: string, dados?: {}, pgCode?: string | boolean | undefined, tratarErro?: string | boolean | undefined) => Promise<any>;
15
+ export declare const serverAction: (metodo: string, dados?: {}, pgCode?: string | boolean | undefined, tratarErro?: string | boolean | undefined, token?: string | undefined) => Promise<any>;
16
16
  export declare function setAlert(mensagem: string, type: 'error' | 'success' | 'info' | 'warning', title: string, time?: number): void;
17
17
  export declare function setError(mensagem: string, title?: string): void;
18
18
  export declare function setSuccess(mensagem: string, title: string, time?: number): void;
package/dist/utils/api.js CHANGED
@@ -127,7 +127,7 @@ var enableDebugger = function () {
127
127
  debuging = true;
128
128
  };
129
129
  exports.enableDebugger = enableDebugger;
130
- var serverAction = function (metodo, dados, pgCode, tratarErro) {
130
+ var serverAction = function (metodo, dados, pgCode, tratarErro, token) {
131
131
  if (dados === void 0) { dados = {}; }
132
132
  return __awaiter(void 0, void 0, void 0, function () {
133
133
  var code, tErro, currentProgram, _a, data, res;
@@ -147,7 +147,8 @@ var serverAction = function (metodo, dados, pgCode, tratarErro) {
147
147
  data = {
148
148
  pgCode: currentProgram,
149
149
  action: metodo,
150
- dados: dados
150
+ dados: dados,
151
+ token: token
151
152
  };
152
153
  return [4 /*yield*/, api_1.action(data)];
153
154
  case 3:
package/lib/api/index.js CHANGED
@@ -5,7 +5,7 @@ export const server = () => `://${getConfig()[/^[a-z]+.+\.com\.br$/.test(window.
5
5
 
6
6
  export const api = () => `${getConfig().ssl ? 'https' : 'http'}${server()}argous/`;
7
7
 
8
- export const headers = () => ({ lgTkn: getCookie('lt') });
8
+ export const headers = ({ token }) => ({ lgTkn: (token) ? token : getCookie('lt') });
9
9
 
10
10
  /**
11
11
  * @deprecated
@@ -137,7 +137,7 @@ export const action = async (data) => {
137
137
  const res = await fetch(`${api()}agaction.rslvr`, {
138
138
  method: 'POST',
139
139
  body: JSON.stringify(data),
140
- headers: headers()
140
+ headers: headers(data)
141
141
  });
142
142
  return await res.json();
143
143
  };