UNPKG

35.6 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 __decorate([
301 core.Output()
302 ], Events.prototype, "onBeforePaste", void 0);
303 __decorate([
304 core.Output()
305 ], Events.prototype, "onBlur", void 0);
306 __decorate([
307 core.Output()
308 ], Events.prototype, "onClick", void 0);
309 __decorate([
310 core.Output()
311 ], Events.prototype, "onContextMenu", void 0);
312 __decorate([
313 core.Output()
314 ], Events.prototype, "onCopy", void 0);
315 __decorate([
316 core.Output()
317 ], Events.prototype, "onCut", void 0);
318 __decorate([
319 core.Output()
320 ], Events.prototype, "onDblclick", void 0);
321 __decorate([
322 core.Output()
323 ], Events.prototype, "onDrag", void 0);
324 __decorate([
325 core.Output()
326 ], Events.prototype, "onDragDrop", void 0);
327 __decorate([
328 core.Output()
329 ], Events.prototype, "onDragEnd", void 0);
330 __decorate([
331 core.Output()
332 ], Events.prototype, "onDragGesture", void 0);
333 __decorate([
334 core.Output()
335 ], Events.prototype, "onDragOver", void 0);
336 __decorate([
337 core.Output()
338 ], Events.prototype, "onDrop", void 0);
339 __decorate([
340 core.Output()
341 ], Events.prototype, "onFocus", void 0);
342 __decorate([
343 core.Output()
344 ], Events.prototype, "onFocusIn", void 0);
345 __decorate([
346 core.Output()
347 ], Events.prototype, "onFocusOut", void 0);
348 __decorate([
349 core.Output()
350 ], Events.prototype, "onKeyDown", void 0);
351 __decorate([
352 core.Output()
353 ], Events.prototype, "onKeyPress", void 0);
354 __decorate([
355 core.Output()
356 ], Events.prototype, "onKeyUp", void 0);
357 __decorate([
358 core.Output()
359 ], Events.prototype, "onMouseDown", void 0);
360 __decorate([
361 core.Output()
362 ], Events.prototype, "onMouseEnter", void 0);
363 __decorate([
364 core.Output()
365 ], Events.prototype, "onMouseLeave", void 0);
366 __decorate([
367 core.Output()
368 ], Events.prototype, "onMouseMove", void 0);
369 __decorate([
370 core.Output()
371 ], Events.prototype, "onMouseOut", void 0);
372 __decorate([
373 core.Output()
374 ], Events.prototype, "onMouseOver", void 0);
375 __decorate([
376 core.Output()
377 ], Events.prototype, "onMouseUp", void 0);
378 __decorate([
379 core.Output()
380 ], Events.prototype, "onPaste", void 0);
381 __decorate([
382 core.Output()
383 ], Events.prototype, "onSelectionChange", void 0);
384 __decorate([
385 core.Output()
386 ], Events.prototype, "onActivate", void 0);
387 __decorate([
388 core.Output()
389 ], Events.prototype, "onAddUndo", void 0);
390 __decorate([
391 core.Output()
392 ], Events.prototype, "onBeforeAddUndo", void 0);
393 __decorate([
394 core.Output()
395 ], Events.prototype, "onBeforeExecCommand", void 0);
396 __decorate([
397 core.Output()
398 ], Events.prototype, "onBeforeGetContent", void 0);
399 __decorate([
400 core.Output()
401 ], Events.prototype, "onBeforeRenderUI", void 0);
402 __decorate([
403 core.Output()
404 ], Events.prototype, "onBeforeSetContent", void 0);
405 __decorate([
406 core.Output()
407 ], Events.prototype, "onChange", void 0);
408 __decorate([
409 core.Output()
410 ], Events.prototype, "onClearUndos", void 0);
411 __decorate([
412 core.Output()
413 ], Events.prototype, "onDeactivate", void 0);
414 __decorate([
415 core.Output()
416 ], Events.prototype, "onDirty", void 0);
417 __decorate([
418 core.Output()
419 ], Events.prototype, "onExecCommand", void 0);
420 __decorate([
421 core.Output()
422 ], Events.prototype, "onGetContent", void 0);
423 __decorate([
424 core.Output()
425 ], Events.prototype, "onHide", void 0);
426 __decorate([
427 core.Output()
428 ], Events.prototype, "onInit", void 0);
429 __decorate([
430 core.Output()
431 ], Events.prototype, "onLoadContent", void 0);
432 __decorate([
433 core.Output()
434 ], Events.prototype, "onNodeChange", void 0);
435 __decorate([
436 core.Output()
437 ], Events.prototype, "onPostProcess", void 0);
438 __decorate([
439 core.Output()
440 ], Events.prototype, "onPostRender", void 0);
441 __decorate([
442 core.Output()
443 ], Events.prototype, "onPreInit", void 0);
444 __decorate([
445 core.Output()
446 ], Events.prototype, "onPreProcess", void 0);
447 __decorate([
448 core.Output()
449 ], Events.prototype, "onProgressState", void 0);
450 __decorate([
451 core.Output()
452 ], Events.prototype, "onRedo", void 0);
453 __decorate([
454 core.Output()
455 ], Events.prototype, "onRemove", void 0);
456 __decorate([
457 core.Output()
458 ], Events.prototype, "onReset", void 0);
459 __decorate([
460 core.Output()
461 ], Events.prototype, "onSaveContent", void 0);
462 __decorate([
463 core.Output()
464 ], Events.prototype, "onSetAttrib", void 0);
465 __decorate([
466 core.Output()
467 ], Events.prototype, "onObjectResizeStart", void 0);
468 __decorate([
469 core.Output()
470 ], Events.prototype, "onObjectResized", void 0);
471 __decorate([
472 core.Output()
473 ], Events.prototype, "onObjectSelected", void 0);
474 __decorate([
475 core.Output()
476 ], Events.prototype, "onSetContent", void 0);
477 __decorate([
478 core.Output()
479 ], Events.prototype, "onShow", void 0);
480 __decorate([
481 core.Output()
482 ], Events.prototype, "onSubmit", void 0);
483 __decorate([
484 core.Output()
485 ], Events.prototype, "onUndo", void 0);
486 __decorate([
487 core.Output()
488 ], Events.prototype, "onVisualAid", void 0);
489 return Events;
490 }());
491 var validEvents = [
492 'onActivate',
493 'onAddUndo',
494 'onBeforeAddUndo',
495 'onBeforeExecCommand',
496 'onBeforeGetContent',
497 'onBeforeRenderUI',
498 'onBeforeSetContent',
499 'onBeforePaste',
500 'onBlur',
501 'onChange',
502 'onClearUndos',
503 'onClick',
504 'onContextMenu',
505 'onCopy',
506 'onCut',
507 'onDblclick',
508 'onDeactivate',
509 'onDirty',
510 'onDrag',
511 'onDragDrop',
512 'onDragEnd',
513 'onDragGesture',
514 'onDragOver',
515 'onDrop',
516 'onExecCommand',
517 'onFocus',
518 'onFocusIn',
519 'onFocusOut',
520 'onGetContent',
521 'onHide',
522 'onInit',
523 'onKeyDown',
524 'onKeyPress',
525 'onKeyUp',
526 'onLoadContent',
527 'onMouseDown',
528 'onMouseEnter',
529 'onMouseLeave',
530 'onMouseMove',
531 'onMouseOut',
532 'onMouseOver',
533 'onMouseUp',
534 'onNodeChange',
535 'onObjectResizeStart',
536 'onObjectResized',
537 'onObjectSelected',
538 'onPaste',
539 'onPostProcess',
540 'onPostRender',
541 'onPreProcess',
542 'onProgressState',
543 'onRedo',
544 'onRemove',
545 'onReset',
546 'onSaveContent',
547 'onSelectionChange',
548 'onSetAttrib',
549 'onSetContent',
550 'onShow',
551 'onSubmit',
552 'onUndo',
553 'onVisualAid'
554 ];
555
556 /**
557 * Copyright (c) 2017-present, Ephox, Inc.
558 *
559 * This source code is licensed under the Apache 2 license found in the
560 * LICENSE file in the root directory of this source tree.
561 *
562 */
563 var bindHandlers = function (ctx, editor, initEvent) {
564 validEvents.forEach(function (eventName) {
565 var eventEmitter = ctx[eventName];
566 if (eventName === 'onInit') {
567 ctx.ngZone.run(function () { return eventEmitter.emit({ event: initEvent, editor: editor }); });
568 }
569 else {
570 editor.on(eventName.substring(2), function (event) { return ctx.ngZone.run(function () { return eventEmitter.emit({ event: event, editor: editor }); }); });
571 }
572 });
573 };
574 var ɵ0$1 = bindHandlers;
575 var unique = 0;
576 var uuid = function (prefix) {
577 var date = new Date();
578 var time = date.getTime();
579 var random = Math.floor(Math.random() * 1000000000);
580 unique++;
581 return prefix + '_' + random + unique + String(time);
582 };
583 var ɵ1 = uuid;
584 var isTextarea = function (element) {
585 return typeof element !== 'undefined' && element.tagName.toLowerCase() === 'textarea';
586 };
587 var ɵ2 = isTextarea;
588 var normalizePluginArray = function (plugins) {
589 if (typeof plugins === 'undefined' || plugins === '') {
590 return [];
591 }
592 return Array.isArray(plugins) ? plugins : plugins.split(' ');
593 };
594 var ɵ3 = normalizePluginArray;
595 var mergePlugins = function (initPlugins, inputPlugins) {
596 return normalizePluginArray(initPlugins).concat(normalizePluginArray(inputPlugins));
597 };
598 var ɵ4 = mergePlugins;
599 // tslint:disable-next-line:no-empty
600 var noop = function () { };
601 var ɵ5 = noop;
602 var isNullOrUndefined = function (value) { return value === null || value === undefined; };
603 var ɵ6 = isNullOrUndefined;
604
605 /**
606 * Copyright (c) 2017-present, Ephox, Inc.
607 *
608 * This source code is licensed under the Apache 2 license found in the
609 * LICENSE file in the root directory of this source tree.
610 *
611 */
612 var createState = function () {
613 return {
614 listeners: [],
615 scriptId: uuid('tiny-script'),
616 scriptLoaded: false
617 };
618 };
619 var ɵ0$2 = createState;
620 var CreateScriptLoader = function () {
621 var state = createState();
622 var injectScriptTag = function (scriptId, doc, url, callback) {
623 var scriptTag = doc.createElement('script');
624 scriptTag.referrerPolicy = 'origin';
625 scriptTag.type = 'application/javascript';
626 scriptTag.id = scriptId;
627 scriptTag.src = url;
628 var handler = function () {
629 scriptTag.removeEventListener('load', handler);
630 callback();
631 };
632 scriptTag.addEventListener('load', handler);
633 if (doc.head) {
634 doc.head.appendChild(scriptTag);
635 }
636 };
637 var load = function (doc, url, callback) {
638 if (state.scriptLoaded) {
639 callback();
640 }
641 else {
642 state.listeners.push(callback);
643 if (!doc.getElementById(state.scriptId)) {
644 injectScriptTag(state.scriptId, doc, url, function () {
645 state.listeners.forEach(function (fn) { return fn(); });
646 state.scriptLoaded = true;
647 });
648 }
649 }
650 };
651 // Only to be used by tests.
652 var reinitialize = function () {
653 state = createState();
654 };
655 return {
656 load: load,
657 reinitialize: reinitialize
658 };
659 };
660 var ɵ1$1 = CreateScriptLoader;
661 var ScriptLoader = CreateScriptLoader();
662
663 var TINYMCE_SCRIPT_SRC = new core.InjectionToken('TINYMCE_SCRIPT_SRC');
664 var EDITOR_COMPONENT_VALUE_ACCESSOR = {
665 provide: forms.NG_VALUE_ACCESSOR,
666 useExisting: core.forwardRef(function () { return EditorComponent; }),
667 multi: true
668 };
669 var EditorComponent = /** @class */ (function (_super) {
670 __extends(EditorComponent, _super);
671 function EditorComponent(elementRef, ngZone, platformId, tinymceScriptSrc) {
672 var _this = _super.call(this) || this;
673 _this.platformId = platformId;
674 _this.tinymceScriptSrc = tinymceScriptSrc;
675 _this.cloudChannel = '5';
676 _this.apiKey = 'no-api-key';
677 _this.id = '';
678 _this.onTouchedCallback = noop;
679 _this.onChangeCallback = noop;
680 _this._elementRef = elementRef;
681 _this.ngZone = ngZone;
682 _this.initialise = _this.initialise.bind(_this);
683 return _this;
684 }
685 Object.defineProperty(EditorComponent.prototype, "disabled", {
686 get: function () {
687 return this._disabled;
688 },
689 set: function (val) {
690 this._disabled = val;
691 if (this._editor && this._editor.initialized) {
692 this._editor.setMode(val ? 'readonly' : 'design');
693 }
694 },
695 enumerable: true,
696 configurable: true
697 });
698 Object.defineProperty(EditorComponent.prototype, "editor", {
699 get: function () {
700 return this._editor;
701 },
702 enumerable: true,
703 configurable: true
704 });
705 EditorComponent.prototype.writeValue = function (value) {
706 if (this._editor && this._editor.initialized) {
707 this._editor.setContent(isNullOrUndefined(value) ? '' : value);
708 }
709 else {
710 this.initialValue = value === null ? undefined : value;
711 }
712 };
713 EditorComponent.prototype.registerOnChange = function (fn) {
714 this.onChangeCallback = fn;
715 };
716 EditorComponent.prototype.registerOnTouched = function (fn) {
717 this.onTouchedCallback = fn;
718 };
719 EditorComponent.prototype.setDisabledState = function (isDisabled) {
720 if (this._editor) {
721 this._editor.setMode(isDisabled ? 'readonly' : 'design');
722 }
723 else if (isDisabled) {
724 this.init = __assign({}, this.init, { readonly: true });
725 }
726 };
727 EditorComponent.prototype.ngAfterViewInit = function () {
728 if (common.isPlatformBrowser(this.platformId)) {
729 this.id = this.id || uuid('tiny-angular');
730 this.inline =
731 typeof this.inline !== 'undefined' ? (typeof this.inline === 'boolean' ? this.inline : true) : this.init && this.init.inline;
732 this.createElement();
733 if (getTinymce() !== null) {
734 this.initialise();
735 }
736 else if (this._element && this._element.ownerDocument) {
737 ScriptLoader.load(this._element.ownerDocument, this.getScriptSrc(), this.initialise);
738 }
739 }
740 };
741 EditorComponent.prototype.ngOnDestroy = function () {
742 if (getTinymce() !== null) {
743 getTinymce().remove(this._editor);
744 }
745 };
746 EditorComponent.prototype.createElement = function () {
747 var tagName = typeof this.tagName === 'string' ? this.tagName : 'div';
748 this._element = document.createElement(this.inline ? tagName : 'textarea');
749 if (this._element) {
750 this._element.id = this.id;
751 if (isTextarea(this._element)) {
752 this._element.style.visibility = 'hidden';
753 }
754 this._elementRef.nativeElement.appendChild(this._element);
755 }
756 };
757 EditorComponent.prototype.initialise = function () {
758 var _this = this;
759 var finalInit = __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) {
760 _this._editor = editor;
761 editor.on('init', function (e) {
762 _this.initEditor(e, editor);
763 });
764 if (_this.init && typeof _this.init.setup === 'function') {
765 _this.init.setup(editor);
766 }
767 } });
768 if (isTextarea(this._element)) {
769 this._element.style.visibility = '';
770 }
771 this.ngZone.runOutsideAngular(function () {
772 getTinymce().init(finalInit);
773 });
774 };
775 EditorComponent.prototype.getScriptSrc = function () {
776 return isNullOrUndefined(this.tinymceScriptSrc) ?
777 "https://cdn.tiny.cloud/1/" + this.apiKey + "/tinymce/" + this.cloudChannel + "/tinymce.min.js" :
778 this.tinymceScriptSrc;
779 };
780 EditorComponent.prototype.initEditor = function (initEvent, editor) {
781 var _this = this;
782 if (typeof this.initialValue === 'string') {
783 this.ngZone.run(function () { return editor.setContent(_this.initialValue); });
784 }
785 editor.on('blur', function () { return _this.ngZone.run(function () { return _this.onTouchedCallback(); }); });
786 editor.on('change keyup undo redo', function () {
787 _this.ngZone.run(function () { return _this.onChangeCallback(editor.getContent({ format: _this.outputFormat })); });
788 });
789 bindHandlers(this, editor, initEvent);
790 };
791 EditorComponent.ctorParameters = function () { return [
792 { type: core.ElementRef },
793 { type: core.NgZone },
794 { type: Object, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] },
795 { type: String, decorators: [{ type: core.Optional }, { type: core.Inject, args: [TINYMCE_SCRIPT_SRC,] }] }
796 ]; };
797 __decorate([
798 core.Input()
799 ], EditorComponent.prototype, "disabled", null);
800 __decorate([
801 core.Input()
802 ], EditorComponent.prototype, "cloudChannel", void 0);
803 __decorate([
804 core.Input()
805 ], EditorComponent.prototype, "apiKey", void 0);
806 __decorate([
807 core.Input()
808 ], EditorComponent.prototype, "init", void 0);
809 __decorate([
810 core.Input()
811 ], EditorComponent.prototype, "id", void 0);
812 __decorate([
813 core.Input()
814 ], EditorComponent.prototype, "initialValue", void 0);
815 __decorate([
816 core.Input()
817 ], EditorComponent.prototype, "outputFormat", void 0);
818 __decorate([
819 core.Input()
820 ], EditorComponent.prototype, "inline", void 0);
821 __decorate([
822 core.Input()
823 ], EditorComponent.prototype, "tagName", void 0);
824 __decorate([
825 core.Input()
826 ], EditorComponent.prototype, "plugins", void 0);
827 __decorate([
828 core.Input()
829 ], EditorComponent.prototype, "toolbar", void 0);
830 EditorComponent = __decorate([
831 core.Component({
832 selector: 'editor',
833 template: '<ng-template></ng-template>',
834 providers: [EDITOR_COMPONENT_VALUE_ACCESSOR],
835 styles: [':host { display: block; }']
836 }),
837 __param(2, core.Inject(core.PLATFORM_ID)),
838 __param(3, core.Optional()), __param(3, core.Inject(TINYMCE_SCRIPT_SRC))
839 ], EditorComponent);
840 return EditorComponent;
841 }(Events));
842
843 var EditorModule = /** @class */ (function () {
844 function EditorModule() {
845 }
846 EditorModule = __decorate([
847 core.NgModule({
848 imports: [common.CommonModule, forms.FormsModule],
849 declarations: [EditorComponent],
850 exports: [EditorComponent]
851 })
852 ], EditorModule);
853 return EditorModule;
854 }());
855
856 exports.EditorComponent = EditorComponent;
857 exports.EditorModule = EditorModule;
858 exports.TINYMCE_SCRIPT_SRC = TINYMCE_SCRIPT_SRC;
859 exports.ɵa = Events;
860
861 Object.defineProperty(exports, '__esModule', { value: true });
862
863})));
864//# sourceMappingURL=tinymce-tinymce-angular.umd.js.map