UNPKG

32.2 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms')) :
3 typeof define === 'function' && define.amd ? define('@tinymce/tinymce-angular', ['exports', '@angular/core', '@angular/common', '@angular/forms'], factory) :
4 (global = global || self, factory((global.tinymce = global.tinymce || {}, global.tinymce['tinymce-angular'] = {}), global.ng.core, global.ng.common, global.ng.forms));
5}(this, (function (exports, core, common, forms) { 'use strict';
6
7 /*! *****************************************************************************
8 Copyright (c) Microsoft Corporation. All rights reserved.
9 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
10 this file except in compliance with the License. You may obtain a copy of the
11 License at http://www.apache.org/licenses/LICENSE-2.0
12
13 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16 MERCHANTABLITY OR NON-INFRINGEMENT.
17
18 See the Apache Version 2.0 License for specific language governing permissions
19 and limitations under the License.
20 ***************************************************************************** */
21 /* global Reflect, Promise */
22
23 var extendStatics = function(d, b) {
24 extendStatics = Object.setPrototypeOf ||
25 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27 return extendStatics(d, b);
28 };
29
30 function __extends(d, b) {
31 extendStatics(d, b);
32 function __() { this.constructor = d; }
33 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34 }
35
36 var __assign = function() {
37 __assign = Object.assign || function __assign(t) {
38 for (var s, i = 1, n = arguments.length; i < n; i++) {
39 s = arguments[i];
40 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
41 }
42 return t;
43 };
44 return __assign.apply(this, arguments);
45 };
46
47 function __rest(s, e) {
48 var t = {};
49 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
50 t[p] = s[p];
51 if (s != null && typeof Object.getOwnPropertySymbols === "function")
52 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
53 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
54 t[p[i]] = s[p[i]];
55 }
56 return t;
57 }
58
59 function __decorate(decorators, target, key, desc) {
60 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
61 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
62 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
63 return c > 3 && r && Object.defineProperty(target, key, r), r;
64 }
65
66 function __param(paramIndex, decorator) {
67 return function (target, key) { decorator(target, key, paramIndex); }
68 }
69
70 function __metadata(metadataKey, metadataValue) {
71 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
72 }
73
74 function __awaiter(thisArg, _arguments, P, generator) {
75 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
76 return new (P || (P = Promise))(function (resolve, reject) {
77 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
78 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
79 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
80 step((generator = generator.apply(thisArg, _arguments || [])).next());
81 });
82 }
83
84 function __generator(thisArg, body) {
85 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
86 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
87 function verb(n) { return function (v) { return step([n, v]); }; }
88 function step(op) {
89 if (f) throw new TypeError("Generator is already executing.");
90 while (_) try {
91 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
92 if (y = 0, t) op = [op[0] & 2, t.value];
93 switch (op[0]) {
94 case 0: case 1: t = op; break;
95 case 4: _.label++; return { value: op[1], done: false };
96 case 5: _.label++; y = op[1]; op = [0]; continue;
97 case 7: op = _.ops.pop(); _.trys.pop(); continue;
98 default:
99 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
100 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
101 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
102 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
103 if (t[2]) _.ops.pop();
104 _.trys.pop(); continue;
105 }
106 op = body.call(thisArg, _);
107 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
108 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
109 }
110 }
111
112 function __exportStar(m, exports) {
113 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
114 }
115
116 function __values(o) {
117 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
118 if (m) return m.call(o);
119 if (o && typeof o.length === "number") return {
120 next: function () {
121 if (o && i >= o.length) o = void 0;
122 return { value: o && o[i++], done: !o };
123 }
124 };
125 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
126 }
127
128 function __read(o, n) {
129 var m = typeof Symbol === "function" && o[Symbol.iterator];
130 if (!m) return o;
131 var i = m.call(o), r, ar = [], e;
132 try {
133 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
134 }
135 catch (error) { e = { error: error }; }
136 finally {
137 try {
138 if (r && !r.done && (m = i["return"])) m.call(i);
139 }
140 finally { if (e) throw e.error; }
141 }
142 return ar;
143 }
144
145 function __spread() {
146 for (var ar = [], i = 0; i < arguments.length; i++)
147 ar = ar.concat(__read(arguments[i]));
148 return ar;
149 }
150
151 function __spreadArrays() {
152 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
153 for (var r = Array(s), k = 0, i = 0; i < il; i++)
154 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
155 r[k] = a[j];
156 return r;
157 };
158
159 function __await(v) {
160 return this instanceof __await ? (this.v = v, this) : new __await(v);
161 }
162
163 function __asyncGenerator(thisArg, _arguments, generator) {
164 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
165 var g = generator.apply(thisArg, _arguments || []), i, q = [];
166 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
167 function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
168 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
169 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
170 function fulfill(value) { resume("next", value); }
171 function reject(value) { resume("throw", value); }
172 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
173 }
174
175 function __asyncDelegator(o) {
176 var i, p;
177 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
178 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
179 }
180
181 function __asyncValues(o) {
182 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
183 var m = o[Symbol.asyncIterator], i;
184 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
185 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
186 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
187 }
188
189 function __makeTemplateObject(cooked, raw) {
190 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
191 return cooked;
192 };
193
194 function __importStar(mod) {
195 if (mod && mod.__esModule) return mod;
196 var result = {};
197 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
198 result.default = mod;
199 return result;
200 }
201
202 function __importDefault(mod) {
203 return (mod && mod.__esModule) ? mod : { default: mod };
204 }
205
206 function __classPrivateFieldGet(receiver, privateMap) {
207 if (!privateMap.has(receiver)) {
208 throw new TypeError("attempted to get private field on non-instance");
209 }
210 return privateMap.get(receiver);
211 }
212
213 function __classPrivateFieldSet(receiver, privateMap, value) {
214 if (!privateMap.has(receiver)) {
215 throw new TypeError("attempted to set private field on non-instance");
216 }
217 privateMap.set(receiver, value);
218 return value;
219 }
220
221 /**
222 * Copyright (c) 2017-present, Ephox, Inc.
223 *
224 * This source code is licensed under the Apache 2 license found in the
225 * LICENSE file in the root directory of this source tree.
226 *
227 */
228 var getTinymce = function () {
229 var w = typeof window !== 'undefined' ? window : undefined;
230 return w && w.tinymce ? w.tinymce : null;
231 };
232 var ɵ0 = getTinymce;
233
234 var Events = /** @class */ (function () {
235 function Events() {
236 this.onBeforePaste = new core.EventEmitter();
237 this.onBlur = new core.EventEmitter();
238 this.onClick = new core.EventEmitter();
239 this.onContextMenu = new core.EventEmitter();
240 this.onCopy = new core.EventEmitter();
241 this.onCut = new core.EventEmitter();
242 this.onDblclick = new core.EventEmitter();
243 this.onDrag = new core.EventEmitter();
244 this.onDragDrop = new core.EventEmitter();
245 this.onDragEnd = new core.EventEmitter();
246 this.onDragGesture = new core.EventEmitter();
247 this.onDragOver = new core.EventEmitter();
248 this.onDrop = new core.EventEmitter();
249 this.onFocus = new core.EventEmitter();
250 this.onFocusIn = new core.EventEmitter();
251 this.onFocusOut = new core.EventEmitter();
252 this.onKeyDown = new core.EventEmitter();
253 this.onKeyPress = new core.EventEmitter();
254 this.onKeyUp = new core.EventEmitter();
255 this.onMouseDown = new core.EventEmitter();
256 this.onMouseEnter = new core.EventEmitter();
257 this.onMouseLeave = new core.EventEmitter();
258 this.onMouseMove = new core.EventEmitter();
259 this.onMouseOut = new core.EventEmitter();
260 this.onMouseOver = new core.EventEmitter();
261 this.onMouseUp = new core.EventEmitter();
262 this.onPaste = new core.EventEmitter();
263 this.onSelectionChange = new core.EventEmitter();
264 this.onActivate = new core.EventEmitter();
265 this.onAddUndo = new core.EventEmitter();
266 this.onBeforeAddUndo = new core.EventEmitter();
267 this.onBeforeExecCommand = new core.EventEmitter();
268 this.onBeforeGetContent = new core.EventEmitter();
269 this.onBeforeRenderUI = new core.EventEmitter();
270 this.onBeforeSetContent = new core.EventEmitter();
271 this.onChange = new core.EventEmitter();
272 this.onClearUndos = new core.EventEmitter();
273 this.onDeactivate = new core.EventEmitter();
274 this.onDirty = new core.EventEmitter();
275 this.onExecCommand = new core.EventEmitter();
276 this.onGetContent = new core.EventEmitter();
277 this.onHide = new core.EventEmitter();
278 this.onInit = new core.EventEmitter();
279 this.onLoadContent = new core.EventEmitter();
280 this.onNodeChange = new core.EventEmitter();
281 this.onPostProcess = new core.EventEmitter();
282 this.onPostRender = new core.EventEmitter();
283 this.onPreInit = new core.EventEmitter();
284 this.onPreProcess = new core.EventEmitter();
285 this.onProgressState = new core.EventEmitter();
286 this.onRedo = new core.EventEmitter();
287 this.onRemove = new core.EventEmitter();
288 this.onReset = new core.EventEmitter();
289 this.onSaveContent = new core.EventEmitter();
290 this.onSetAttrib = new core.EventEmitter();
291 this.onObjectResizeStart = new core.EventEmitter();
292 this.onObjectResized = new core.EventEmitter();
293 this.onObjectSelected = new core.EventEmitter();
294 this.onSetContent = new core.EventEmitter();
295 this.onShow = new core.EventEmitter();
296 this.onSubmit = new core.EventEmitter();
297 this.onUndo = new core.EventEmitter();
298 this.onVisualAid = new core.EventEmitter();
299 }
300 Events.propDecorators = {
301 onBeforePaste: [{ type: core.Output }],
302 onBlur: [{ type: core.Output }],
303 onClick: [{ type: core.Output }],
304 onContextMenu: [{ type: core.Output }],
305 onCopy: [{ type: core.Output }],
306 onCut: [{ type: core.Output }],
307 onDblclick: [{ type: core.Output }],
308 onDrag: [{ type: core.Output }],
309 onDragDrop: [{ type: core.Output }],
310 onDragEnd: [{ type: core.Output }],
311 onDragGesture: [{ type: core.Output }],
312 onDragOver: [{ type: core.Output }],
313 onDrop: [{ type: core.Output }],
314 onFocus: [{ type: core.Output }],
315 onFocusIn: [{ type: core.Output }],
316 onFocusOut: [{ type: core.Output }],
317 onKeyDown: [{ type: core.Output }],
318 onKeyPress: [{ type: core.Output }],
319 onKeyUp: [{ type: core.Output }],
320 onMouseDown: [{ type: core.Output }],
321 onMouseEnter: [{ type: core.Output }],
322 onMouseLeave: [{ type: core.Output }],
323 onMouseMove: [{ type: core.Output }],
324 onMouseOut: [{ type: core.Output }],
325 onMouseOver: [{ type: core.Output }],
326 onMouseUp: [{ type: core.Output }],
327 onPaste: [{ type: core.Output }],
328 onSelectionChange: [{ type: core.Output }],
329 onActivate: [{ type: core.Output }],
330 onAddUndo: [{ type: core.Output }],
331 onBeforeAddUndo: [{ type: core.Output }],
332 onBeforeExecCommand: [{ type: core.Output }],
333 onBeforeGetContent: [{ type: core.Output }],
334 onBeforeRenderUI: [{ type: core.Output }],
335 onBeforeSetContent: [{ type: core.Output }],
336 onChange: [{ type: core.Output }],
337 onClearUndos: [{ type: core.Output }],
338 onDeactivate: [{ type: core.Output }],
339 onDirty: [{ type: core.Output }],
340 onExecCommand: [{ type: core.Output }],
341 onGetContent: [{ type: core.Output }],
342 onHide: [{ type: core.Output }],
343 onInit: [{ type: core.Output }],
344 onLoadContent: [{ type: core.Output }],
345 onNodeChange: [{ type: core.Output }],
346 onPostProcess: [{ type: core.Output }],
347 onPostRender: [{ type: core.Output }],
348 onPreInit: [{ type: core.Output }],
349 onPreProcess: [{ type: core.Output }],
350 onProgressState: [{ type: core.Output }],
351 onRedo: [{ type: core.Output }],
352 onRemove: [{ type: core.Output }],
353 onReset: [{ type: core.Output }],
354 onSaveContent: [{ type: core.Output }],
355 onSetAttrib: [{ type: core.Output }],
356 onObjectResizeStart: [{ type: core.Output }],
357 onObjectResized: [{ type: core.Output }],
358 onObjectSelected: [{ type: core.Output }],
359 onSetContent: [{ type: core.Output }],
360 onShow: [{ type: core.Output }],
361 onSubmit: [{ type: core.Output }],
362 onUndo: [{ type: core.Output }],
363 onVisualAid: [{ type: core.Output }]
364 };
365 return Events;
366 }());
367 var validEvents = [
368 'onActivate',
369 'onAddUndo',
370 'onBeforeAddUndo',
371 'onBeforeExecCommand',
372 'onBeforeGetContent',
373 'onBeforeRenderUI',
374 'onBeforeSetContent',
375 'onBeforePaste',
376 'onBlur',
377 'onChange',
378 'onClearUndos',
379 'onClick',
380 'onContextMenu',
381 'onCopy',
382 'onCut',
383 'onDblclick',
384 'onDeactivate',
385 'onDirty',
386 'onDrag',
387 'onDragDrop',
388 'onDragEnd',
389 'onDragGesture',
390 'onDragOver',
391 'onDrop',
392 'onExecCommand',
393 'onFocus',
394 'onFocusIn',
395 'onFocusOut',
396 'onGetContent',
397 'onHide',
398 'onInit',
399 'onKeyDown',
400 'onKeyPress',
401 'onKeyUp',
402 'onLoadContent',
403 'onMouseDown',
404 'onMouseEnter',
405 'onMouseLeave',
406 'onMouseMove',
407 'onMouseOut',
408 'onMouseOver',
409 'onMouseUp',
410 'onNodeChange',
411 'onObjectResizeStart',
412 'onObjectResized',
413 'onObjectSelected',
414 'onPaste',
415 'onPostProcess',
416 'onPostRender',
417 'onPreProcess',
418 'onProgressState',
419 'onRedo',
420 'onRemove',
421 'onReset',
422 'onSaveContent',
423 'onSelectionChange',
424 'onSetAttrib',
425 'onSetContent',
426 'onShow',
427 'onSubmit',
428 'onUndo',
429 'onVisualAid'
430 ];
431
432 /**
433 * Copyright (c) 2017-present, Ephox, Inc.
434 *
435 * This source code is licensed under the Apache 2 license found in the
436 * LICENSE file in the root directory of this source tree.
437 *
438 */
439 var bindHandlers = function (ctx, editor) {
440 validEvents.forEach(function (eventName) {
441 var eventEmitter = ctx[eventName];
442 editor.on(eventName.substring(2), function (event) { return ctx.ngZone.run(function () { return eventEmitter.emit({ event: event, editor: editor }); }); });
443 });
444 };
445 var ɵ0$1 = bindHandlers;
446 var unique = 0;
447 var uuid = function (prefix) {
448 var date = new Date();
449 var time = date.getTime();
450 var random = Math.floor(Math.random() * 1000000000);
451 unique++;
452 return prefix + '_' + random + unique + String(time);
453 };
454 var ɵ1 = uuid;
455 var isTextarea = function (element) {
456 return typeof element !== 'undefined' && element.tagName.toLowerCase() === 'textarea';
457 };
458 var ɵ2 = isTextarea;
459 var normalizePluginArray = function (plugins) {
460 if (typeof plugins === 'undefined' || plugins === '') {
461 return [];
462 }
463 return Array.isArray(plugins) ? plugins : plugins.split(' ');
464 };
465 var ɵ3 = normalizePluginArray;
466 var mergePlugins = function (initPlugins, inputPlugins) {
467 return normalizePluginArray(initPlugins).concat(normalizePluginArray(inputPlugins));
468 };
469 var ɵ4 = mergePlugins;
470 // tslint:disable-next-line:no-empty
471 var noop = function () { };
472 var ɵ5 = noop;
473 var isNullOrUndefined = function (value) { return value === null || value === undefined; };
474 var ɵ6 = isNullOrUndefined;
475
476 /**
477 * Copyright (c) 2017-present, Ephox, Inc.
478 *
479 * This source code is licensed under the Apache 2 license found in the
480 * LICENSE file in the root directory of this source tree.
481 *
482 */
483 var createState = function () {
484 return {
485 listeners: [],
486 scriptId: uuid('tiny-script'),
487 scriptLoaded: false
488 };
489 };
490 var ɵ0$2 = createState;
491 var CreateScriptLoader = function () {
492 var state = createState();
493 var injectScriptTag = function (scriptId, doc, url, callback) {
494 var scriptTag = doc.createElement('script');
495 scriptTag.referrerPolicy = 'origin';
496 scriptTag.type = 'application/javascript';
497 scriptTag.id = scriptId;
498 scriptTag.src = url;
499 var handler = function () {
500 scriptTag.removeEventListener('load', handler);
501 callback();
502 };
503 scriptTag.addEventListener('load', handler);
504 if (doc.head) {
505 doc.head.appendChild(scriptTag);
506 }
507 };
508 var load = function (doc, url, callback) {
509 if (state.scriptLoaded) {
510 callback();
511 }
512 else {
513 state.listeners.push(callback);
514 if (!doc.getElementById(state.scriptId)) {
515 injectScriptTag(state.scriptId, doc, url, function () {
516 state.listeners.forEach(function (fn) { return fn(); });
517 state.scriptLoaded = true;
518 });
519 }
520 }
521 };
522 // Only to be used by tests.
523 var reinitialize = function () {
524 state = createState();
525 };
526 return {
527 load: load,
528 reinitialize: reinitialize
529 };
530 };
531 var ɵ1$1 = CreateScriptLoader;
532 var ScriptLoader = CreateScriptLoader();
533
534 var TINYMCE_SCRIPT_SRC = new core.InjectionToken('TINYMCE_SCRIPT_SRC');
535 var EDITOR_COMPONENT_VALUE_ACCESSOR = {
536 provide: forms.NG_VALUE_ACCESSOR,
537 useExisting: core.forwardRef(function () { return EditorComponent; }),
538 multi: true
539 };
540 var EditorComponent = /** @class */ (function (_super) {
541 __extends(EditorComponent, _super);
542 function EditorComponent(elementRef, ngZone, platformId, tinymceScriptSrc) {
543 var _this = _super.call(this) || this;
544 _this.platformId = platformId;
545 _this.tinymceScriptSrc = tinymceScriptSrc;
546 _this.cloudChannel = '5';
547 _this.apiKey = 'no-api-key';
548 _this.id = '';
549 _this.modelEvents = 'change keyup undo redo';
550 _this.onTouchedCallback = noop;
551 _this.onChangeCallback = noop;
552 _this._elementRef = elementRef;
553 _this.ngZone = ngZone;
554 _this.initialise = _this.initialise.bind(_this);
555 return _this;
556 }
557 Object.defineProperty(EditorComponent.prototype, "disabled", {
558 get: function () {
559 return this._disabled;
560 },
561 set: function (val) {
562 this._disabled = val;
563 if (this._editor && this._editor.initialized) {
564 this._editor.setMode(val ? 'readonly' : 'design');
565 }
566 },
567 enumerable: false,
568 configurable: true
569 });
570 Object.defineProperty(EditorComponent.prototype, "editor", {
571 get: function () {
572 return this._editor;
573 },
574 enumerable: false,
575 configurable: true
576 });
577 EditorComponent.prototype.writeValue = function (value) {
578 if (this._editor && this._editor.initialized) {
579 this._editor.setContent(isNullOrUndefined(value) ? '' : value);
580 }
581 else {
582 this.initialValue = value === null ? undefined : value;
583 }
584 };
585 EditorComponent.prototype.registerOnChange = function (fn) {
586 this.onChangeCallback = fn;
587 };
588 EditorComponent.prototype.registerOnTouched = function (fn) {
589 this.onTouchedCallback = fn;
590 };
591 EditorComponent.prototype.setDisabledState = function (isDisabled) {
592 if (this._editor) {
593 this._editor.setMode(isDisabled ? 'readonly' : 'design');
594 }
595 else if (isDisabled) {
596 this.init = __assign(__assign({}, this.init), { readonly: true });
597 }
598 };
599 EditorComponent.prototype.ngAfterViewInit = function () {
600 if (common.isPlatformBrowser(this.platformId)) {
601 this.id = this.id || uuid('tiny-angular');
602 this.inline =
603 typeof this.inline !== 'undefined' ? (typeof this.inline === 'boolean' ? this.inline : true) : this.init && this.init.inline;
604 this.createElement();
605 if (getTinymce() !== null) {
606 this.initialise();
607 }
608 else if (this._element && this._element.ownerDocument) {
609 ScriptLoader.load(this._element.ownerDocument, this.getScriptSrc(), this.initialise);
610 }
611 }
612 };
613 EditorComponent.prototype.ngOnDestroy = function () {
614 if (getTinymce() !== null) {
615 getTinymce().remove(this._editor);
616 }
617 };
618 EditorComponent.prototype.createElement = function () {
619 var tagName = typeof this.tagName === 'string' ? this.tagName : 'div';
620 this._element = document.createElement(this.inline ? tagName : 'textarea');
621 if (this._element) {
622 this._element.id = this.id;
623 if (isTextarea(this._element)) {
624 this._element.style.visibility = 'hidden';
625 }
626 this._elementRef.nativeElement.appendChild(this._element);
627 }
628 };
629 EditorComponent.prototype.initialise = function () {
630 var _this = this;
631 var finalInit = __assign(__assign({}, this.init), { target: this._element, inline: this.inline, readonly: this.disabled, plugins: mergePlugins(this.init && this.init.plugins, this.plugins), toolbar: this.toolbar || (this.init && this.init.toolbar), setup: function (editor) {
632 _this._editor = editor;
633 editor.on('init', function (e) {
634 _this.initEditor(editor);
635 });
636 bindHandlers(_this, editor);
637 if (_this.init && typeof _this.init.setup === 'function') {
638 _this.init.setup(editor);
639 }
640 } });
641 if (isTextarea(this._element)) {
642 this._element.style.visibility = '';
643 }
644 this.ngZone.runOutsideAngular(function () {
645 getTinymce().init(finalInit);
646 });
647 };
648 EditorComponent.prototype.getScriptSrc = function () {
649 return isNullOrUndefined(this.tinymceScriptSrc) ?
650 "https://cdn.tiny.cloud/1/" + this.apiKey + "/tinymce/" + this.cloudChannel + "/tinymce.min.js" :
651 this.tinymceScriptSrc;
652 };
653 EditorComponent.prototype.initEditor = function (editor) {
654 var _this = this;
655 editor.on('blur', function () { return _this.ngZone.run(function () { return _this.onTouchedCallback(); }); });
656 editor.on(this.modelEvents, function () {
657 _this.ngZone.run(function () { return _this.onChangeCallback(editor.getContent({ format: _this.outputFormat })); });
658 });
659 if (typeof this.initialValue === 'string') {
660 this.ngZone.run(function () {
661 editor.setContent(_this.initialValue);
662 _this.onChangeCallback(editor.getContent({ format: _this.outputFormat }));
663 });
664 }
665 };
666 EditorComponent.ctorParameters = function () { return [
667 { type: core.ElementRef },
668 { type: core.NgZone },
669 { type: Object, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] },
670 { type: String, decorators: [{ type: core.Optional }, { type: core.Inject, args: [TINYMCE_SCRIPT_SRC,] }] }
671 ]; };
672 EditorComponent.decorators = [
673 { type: core.Component, args: [{
674 selector: 'editor',
675 template: '<ng-template></ng-template>',
676 providers: [EDITOR_COMPONENT_VALUE_ACCESSOR],
677 styles: [':host { display: block; }']
678 },] }
679 ];
680 EditorComponent.ctorParameters = function () { return [
681 { type: core.ElementRef },
682 { type: core.NgZone },
683 { type: Object, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] },
684 { type: String, decorators: [{ type: core.Optional }, { type: core.Inject, args: [TINYMCE_SCRIPT_SRC,] }] }
685 ]; };
686 EditorComponent.propDecorators = {
687 disabled: [{ type: core.Input }],
688 cloudChannel: [{ type: core.Input }],
689 apiKey: [{ type: core.Input }],
690 init: [{ type: core.Input }],
691 id: [{ type: core.Input }],
692 initialValue: [{ type: core.Input }],
693 outputFormat: [{ type: core.Input }],
694 inline: [{ type: core.Input }],
695 tagName: [{ type: core.Input }],
696 plugins: [{ type: core.Input }],
697 toolbar: [{ type: core.Input }],
698 modelEvents: [{ type: core.Input }]
699 };
700 return EditorComponent;
701 }(Events));
702
703 var EditorModule = /** @class */ (function () {
704 function EditorModule() {
705 }
706 EditorModule.decorators = [
707 { type: core.NgModule, args: [{
708 imports: [common.CommonModule, forms.FormsModule],
709 declarations: [EditorComponent],
710 exports: [EditorComponent]
711 },] }
712 ];
713 return EditorModule;
714 }());
715
716 exports.EditorComponent = EditorComponent;
717 exports.EditorModule = EditorModule;
718 exports.TINYMCE_SCRIPT_SRC = TINYMCE_SCRIPT_SRC;
719 exports.ɵa = Events;
720
721 Object.defineProperty(exports, '__esModule', { value: true });
722
723})));
724//# sourceMappingURL=tinymce-tinymce-angular.umd.js.map