@tinymce/tinymce-angular 3.6.0 → 4.2.0

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,7 @@
1
- import { __decorate, __extends, __assign, __param } from 'tslib';
2
- import { EventEmitter, Output, InjectionToken, forwardRef, ElementRef, NgZone, Inject, PLATFORM_ID, Optional, Input, Component, NgModule } from '@angular/core';
1
+ import { EventEmitter, Output, InjectionToken, forwardRef, ElementRef, NgZone, Inject, PLATFORM_ID, Optional, Component, Input, NgModule } from '@angular/core';
3
2
  import { isPlatformBrowser, CommonModule } from '@angular/common';
4
3
  import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
4
+ import { __extends, __assign } from 'tslib';
5
5
 
6
6
  /**
7
7
  * Copyright (c) 2017-present, Ephox, Inc.
@@ -61,6 +61,7 @@ var Events = /** @class */ (function () {
61
61
  this.onGetContent = new EventEmitter();
62
62
  this.onHide = new EventEmitter();
63
63
  this.onInit = new EventEmitter();
64
+ this.onInitNgModel = new EventEmitter();
64
65
  this.onLoadContent = new EventEmitter();
65
66
  this.onNodeChange = new EventEmitter();
66
67
  this.onPostProcess = new EventEmitter();
@@ -82,195 +83,72 @@ var Events = /** @class */ (function () {
82
83
  this.onUndo = new EventEmitter();
83
84
  this.onVisualAid = new EventEmitter();
84
85
  }
85
- __decorate([
86
- Output()
87
- ], Events.prototype, "onBeforePaste", void 0);
88
- __decorate([
89
- Output()
90
- ], Events.prototype, "onBlur", void 0);
91
- __decorate([
92
- Output()
93
- ], Events.prototype, "onClick", void 0);
94
- __decorate([
95
- Output()
96
- ], Events.prototype, "onContextMenu", void 0);
97
- __decorate([
98
- Output()
99
- ], Events.prototype, "onCopy", void 0);
100
- __decorate([
101
- Output()
102
- ], Events.prototype, "onCut", void 0);
103
- __decorate([
104
- Output()
105
- ], Events.prototype, "onDblclick", void 0);
106
- __decorate([
107
- Output()
108
- ], Events.prototype, "onDrag", void 0);
109
- __decorate([
110
- Output()
111
- ], Events.prototype, "onDragDrop", void 0);
112
- __decorate([
113
- Output()
114
- ], Events.prototype, "onDragEnd", void 0);
115
- __decorate([
116
- Output()
117
- ], Events.prototype, "onDragGesture", void 0);
118
- __decorate([
119
- Output()
120
- ], Events.prototype, "onDragOver", void 0);
121
- __decorate([
122
- Output()
123
- ], Events.prototype, "onDrop", void 0);
124
- __decorate([
125
- Output()
126
- ], Events.prototype, "onFocus", void 0);
127
- __decorate([
128
- Output()
129
- ], Events.prototype, "onFocusIn", void 0);
130
- __decorate([
131
- Output()
132
- ], Events.prototype, "onFocusOut", void 0);
133
- __decorate([
134
- Output()
135
- ], Events.prototype, "onKeyDown", void 0);
136
- __decorate([
137
- Output()
138
- ], Events.prototype, "onKeyPress", void 0);
139
- __decorate([
140
- Output()
141
- ], Events.prototype, "onKeyUp", void 0);
142
- __decorate([
143
- Output()
144
- ], Events.prototype, "onMouseDown", void 0);
145
- __decorate([
146
- Output()
147
- ], Events.prototype, "onMouseEnter", void 0);
148
- __decorate([
149
- Output()
150
- ], Events.prototype, "onMouseLeave", void 0);
151
- __decorate([
152
- Output()
153
- ], Events.prototype, "onMouseMove", void 0);
154
- __decorate([
155
- Output()
156
- ], Events.prototype, "onMouseOut", void 0);
157
- __decorate([
158
- Output()
159
- ], Events.prototype, "onMouseOver", void 0);
160
- __decorate([
161
- Output()
162
- ], Events.prototype, "onMouseUp", void 0);
163
- __decorate([
164
- Output()
165
- ], Events.prototype, "onPaste", void 0);
166
- __decorate([
167
- Output()
168
- ], Events.prototype, "onSelectionChange", void 0);
169
- __decorate([
170
- Output()
171
- ], Events.prototype, "onActivate", void 0);
172
- __decorate([
173
- Output()
174
- ], Events.prototype, "onAddUndo", void 0);
175
- __decorate([
176
- Output()
177
- ], Events.prototype, "onBeforeAddUndo", void 0);
178
- __decorate([
179
- Output()
180
- ], Events.prototype, "onBeforeExecCommand", void 0);
181
- __decorate([
182
- Output()
183
- ], Events.prototype, "onBeforeGetContent", void 0);
184
- __decorate([
185
- Output()
186
- ], Events.prototype, "onBeforeRenderUI", void 0);
187
- __decorate([
188
- Output()
189
- ], Events.prototype, "onBeforeSetContent", void 0);
190
- __decorate([
191
- Output()
192
- ], Events.prototype, "onChange", void 0);
193
- __decorate([
194
- Output()
195
- ], Events.prototype, "onClearUndos", void 0);
196
- __decorate([
197
- Output()
198
- ], Events.prototype, "onDeactivate", void 0);
199
- __decorate([
200
- Output()
201
- ], Events.prototype, "onDirty", void 0);
202
- __decorate([
203
- Output()
204
- ], Events.prototype, "onExecCommand", void 0);
205
- __decorate([
206
- Output()
207
- ], Events.prototype, "onGetContent", void 0);
208
- __decorate([
209
- Output()
210
- ], Events.prototype, "onHide", void 0);
211
- __decorate([
212
- Output()
213
- ], Events.prototype, "onInit", void 0);
214
- __decorate([
215
- Output()
216
- ], Events.prototype, "onLoadContent", void 0);
217
- __decorate([
218
- Output()
219
- ], Events.prototype, "onNodeChange", void 0);
220
- __decorate([
221
- Output()
222
- ], Events.prototype, "onPostProcess", void 0);
223
- __decorate([
224
- Output()
225
- ], Events.prototype, "onPostRender", void 0);
226
- __decorate([
227
- Output()
228
- ], Events.prototype, "onPreInit", void 0);
229
- __decorate([
230
- Output()
231
- ], Events.prototype, "onPreProcess", void 0);
232
- __decorate([
233
- Output()
234
- ], Events.prototype, "onProgressState", void 0);
235
- __decorate([
236
- Output()
237
- ], Events.prototype, "onRedo", void 0);
238
- __decorate([
239
- Output()
240
- ], Events.prototype, "onRemove", void 0);
241
- __decorate([
242
- Output()
243
- ], Events.prototype, "onReset", void 0);
244
- __decorate([
245
- Output()
246
- ], Events.prototype, "onSaveContent", void 0);
247
- __decorate([
248
- Output()
249
- ], Events.prototype, "onSetAttrib", void 0);
250
- __decorate([
251
- Output()
252
- ], Events.prototype, "onObjectResizeStart", void 0);
253
- __decorate([
254
- Output()
255
- ], Events.prototype, "onObjectResized", void 0);
256
- __decorate([
257
- Output()
258
- ], Events.prototype, "onObjectSelected", void 0);
259
- __decorate([
260
- Output()
261
- ], Events.prototype, "onSetContent", void 0);
262
- __decorate([
263
- Output()
264
- ], Events.prototype, "onShow", void 0);
265
- __decorate([
266
- Output()
267
- ], Events.prototype, "onSubmit", void 0);
268
- __decorate([
269
- Output()
270
- ], Events.prototype, "onUndo", void 0);
271
- __decorate([
272
- Output()
273
- ], Events.prototype, "onVisualAid", void 0);
86
+ Events.propDecorators = {
87
+ onBeforePaste: [{ type: Output }],
88
+ onBlur: [{ type: Output }],
89
+ onClick: [{ type: Output }],
90
+ onContextMenu: [{ type: Output }],
91
+ onCopy: [{ type: Output }],
92
+ onCut: [{ type: Output }],
93
+ onDblclick: [{ type: Output }],
94
+ onDrag: [{ type: Output }],
95
+ onDragDrop: [{ type: Output }],
96
+ onDragEnd: [{ type: Output }],
97
+ onDragGesture: [{ type: Output }],
98
+ onDragOver: [{ type: Output }],
99
+ onDrop: [{ type: Output }],
100
+ onFocus: [{ type: Output }],
101
+ onFocusIn: [{ type: Output }],
102
+ onFocusOut: [{ type: Output }],
103
+ onKeyDown: [{ type: Output }],
104
+ onKeyPress: [{ type: Output }],
105
+ onKeyUp: [{ type: Output }],
106
+ onMouseDown: [{ type: Output }],
107
+ onMouseEnter: [{ type: Output }],
108
+ onMouseLeave: [{ type: Output }],
109
+ onMouseMove: [{ type: Output }],
110
+ onMouseOut: [{ type: Output }],
111
+ onMouseOver: [{ type: Output }],
112
+ onMouseUp: [{ type: Output }],
113
+ onPaste: [{ type: Output }],
114
+ onSelectionChange: [{ type: Output }],
115
+ onActivate: [{ type: Output }],
116
+ onAddUndo: [{ type: Output }],
117
+ onBeforeAddUndo: [{ type: Output }],
118
+ onBeforeExecCommand: [{ type: Output }],
119
+ onBeforeGetContent: [{ type: Output }],
120
+ onBeforeRenderUI: [{ type: Output }],
121
+ onBeforeSetContent: [{ type: Output }],
122
+ onChange: [{ type: Output }],
123
+ onClearUndos: [{ type: Output }],
124
+ onDeactivate: [{ type: Output }],
125
+ onDirty: [{ type: Output }],
126
+ onExecCommand: [{ type: Output }],
127
+ onGetContent: [{ type: Output }],
128
+ onHide: [{ type: Output }],
129
+ onInit: [{ type: Output }],
130
+ onInitNgModel: [{ type: Output }],
131
+ onLoadContent: [{ type: Output }],
132
+ onNodeChange: [{ type: Output }],
133
+ onPostProcess: [{ type: Output }],
134
+ onPostRender: [{ type: Output }],
135
+ onPreInit: [{ type: Output }],
136
+ onPreProcess: [{ type: Output }],
137
+ onProgressState: [{ type: Output }],
138
+ onRedo: [{ type: Output }],
139
+ onRemove: [{ type: Output }],
140
+ onReset: [{ type: Output }],
141
+ onSaveContent: [{ type: Output }],
142
+ onSetAttrib: [{ type: Output }],
143
+ onObjectResizeStart: [{ type: Output }],
144
+ onObjectResized: [{ type: Output }],
145
+ onObjectSelected: [{ type: Output }],
146
+ onSetContent: [{ type: Output }],
147
+ onShow: [{ type: Output }],
148
+ onSubmit: [{ type: Output }],
149
+ onUndo: [{ type: Output }],
150
+ onVisualAid: [{ type: Output }]
151
+ };
274
152
  return Events;
275
153
  }());
276
154
  var validEvents = [
@@ -346,12 +224,29 @@ var validEvents = [
346
224
  *
347
225
  */
348
226
  var bindHandlers = function (ctx, editor) {
349
- validEvents.forEach(function (eventName) {
227
+ var allowedEvents = getValidEvents(ctx);
228
+ allowedEvents.forEach(function (eventName) {
350
229
  var eventEmitter = ctx[eventName];
351
230
  editor.on(eventName.substring(2), function (event) { return ctx.ngZone.run(function () { return eventEmitter.emit({ event: event, editor: editor }); }); });
352
231
  });
353
232
  };
354
233
  var ɵ0$1 = bindHandlers;
234
+ var getValidEvents = function (ctx) {
235
+ var ignoredEvents = parseStringProperty(ctx.ignoreEvents, []);
236
+ var allowedEvents = parseStringProperty(ctx.allowedEvents, validEvents).filter(function (event) { return validEvents.includes(event) && !ignoredEvents.includes(event); });
237
+ return allowedEvents;
238
+ };
239
+ var ɵ1 = getValidEvents;
240
+ var parseStringProperty = function (property, defaultValue) {
241
+ if (typeof property === 'string') {
242
+ return property.split(',').map(function (value) { return value.trim(); });
243
+ }
244
+ if (Array.isArray(property)) {
245
+ return property;
246
+ }
247
+ return defaultValue;
248
+ };
249
+ var ɵ2 = parseStringProperty;
355
250
  var unique = 0;
356
251
  var uuid = function (prefix) {
357
252
  var date = new Date();
@@ -360,27 +255,27 @@ var uuid = function (prefix) {
360
255
  unique++;
361
256
  return prefix + '_' + random + unique + String(time);
362
257
  };
363
- var ɵ1 = uuid;
258
+ var ɵ3 = uuid;
364
259
  var isTextarea = function (element) {
365
260
  return typeof element !== 'undefined' && element.tagName.toLowerCase() === 'textarea';
366
261
  };
367
- var ɵ2 = isTextarea;
262
+ var ɵ4 = isTextarea;
368
263
  var normalizePluginArray = function (plugins) {
369
264
  if (typeof plugins === 'undefined' || plugins === '') {
370
265
  return [];
371
266
  }
372
267
  return Array.isArray(plugins) ? plugins : plugins.split(' ');
373
268
  };
374
- var ɵ3 = normalizePluginArray;
269
+ var ɵ5 = normalizePluginArray;
375
270
  var mergePlugins = function (initPlugins, inputPlugins) {
376
271
  return normalizePluginArray(initPlugins).concat(normalizePluginArray(inputPlugins));
377
272
  };
378
- var ɵ4 = mergePlugins;
273
+ var ɵ6 = mergePlugins;
379
274
  // tslint:disable-next-line:no-empty
380
275
  var noop = function () { };
381
- var ɵ5 = noop;
276
+ var ɵ7 = noop;
382
277
  var isNullOrUndefined = function (value) { return value === null || value === undefined; };
383
- var ɵ6 = isNullOrUndefined;
278
+ var ɵ8 = isNullOrUndefined;
384
279
 
385
280
  /**
386
281
  * Copyright (c) 2017-present, Ephox, Inc.
@@ -455,7 +350,7 @@ var EditorComponent = /** @class */ (function (_super) {
455
350
  _this.cloudChannel = '5';
456
351
  _this.apiKey = 'no-api-key';
457
352
  _this.id = '';
458
- _this.modelEvents = 'change keyup undo redo';
353
+ _this.modelEvents = 'change input undo redo';
459
354
  _this.onTouchedCallback = noop;
460
355
  _this.onChangeCallback = noop;
461
356
  _this._elementRef = elementRef;
@@ -473,14 +368,14 @@ var EditorComponent = /** @class */ (function (_super) {
473
368
  this._editor.setMode(val ? 'readonly' : 'design');
474
369
  }
475
370
  },
476
- enumerable: true,
371
+ enumerable: false,
477
372
  configurable: true
478
373
  });
479
374
  Object.defineProperty(EditorComponent.prototype, "editor", {
480
375
  get: function () {
481
376
  return this._editor;
482
377
  },
483
- enumerable: true,
378
+ enumerable: false,
484
379
  configurable: true
485
380
  });
486
381
  EditorComponent.prototype.writeValue = function (value) {
@@ -502,7 +397,7 @@ var EditorComponent = /** @class */ (function (_super) {
502
397
  this._editor.setMode(isDisabled ? 'readonly' : 'design');
503
398
  }
504
399
  else if (isDisabled) {
505
- this.init = __assign({}, this.init, { readonly: true });
400
+ this.init = __assign(__assign({}, this.init), { readonly: true });
506
401
  }
507
402
  };
508
403
  EditorComponent.prototype.ngAfterViewInit = function () {
@@ -537,7 +432,7 @@ var EditorComponent = /** @class */ (function (_super) {
537
432
  };
538
433
  EditorComponent.prototype.initialise = function () {
539
434
  var _this = this;
540
- 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) {
435
+ 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) {
541
436
  _this._editor = editor;
542
437
  editor.on('init', function (e) {
543
438
  _this.initEditor(editor);
@@ -566,7 +461,15 @@ var EditorComponent = /** @class */ (function (_super) {
566
461
  _this.ngZone.run(function () { return _this.onChangeCallback(editor.getContent({ format: _this.outputFormat })); });
567
462
  });
568
463
  if (typeof this.initialValue === 'string') {
569
- this.ngZone.run(function () { return editor.setContent(_this.initialValue); });
464
+ this.ngZone.run(function () {
465
+ editor.setContent(_this.initialValue);
466
+ if (editor.getContent() !== _this.initialValue) {
467
+ _this.onChangeCallback(editor.getContent({ format: _this.outputFormat }));
468
+ }
469
+ if (_this.onInitNgModel !== undefined) {
470
+ _this.onInitNgModel.emit(editor);
471
+ }
472
+ });
570
473
  }
571
474
  };
572
475
  EditorComponent.ctorParameters = function () { return [
@@ -575,65 +478,49 @@ var EditorComponent = /** @class */ (function (_super) {
575
478
  { type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] },
576
479
  { type: String, decorators: [{ type: Optional }, { type: Inject, args: [TINYMCE_SCRIPT_SRC,] }] }
577
480
  ]; };
578
- __decorate([
579
- Input()
580
- ], EditorComponent.prototype, "disabled", null);
581
- __decorate([
582
- Input()
583
- ], EditorComponent.prototype, "cloudChannel", void 0);
584
- __decorate([
585
- Input()
586
- ], EditorComponent.prototype, "apiKey", void 0);
587
- __decorate([
588
- Input()
589
- ], EditorComponent.prototype, "init", void 0);
590
- __decorate([
591
- Input()
592
- ], EditorComponent.prototype, "id", void 0);
593
- __decorate([
594
- Input()
595
- ], EditorComponent.prototype, "initialValue", void 0);
596
- __decorate([
597
- Input()
598
- ], EditorComponent.prototype, "outputFormat", void 0);
599
- __decorate([
600
- Input()
601
- ], EditorComponent.prototype, "inline", void 0);
602
- __decorate([
603
- Input()
604
- ], EditorComponent.prototype, "tagName", void 0);
605
- __decorate([
606
- Input()
607
- ], EditorComponent.prototype, "plugins", void 0);
608
- __decorate([
609
- Input()
610
- ], EditorComponent.prototype, "toolbar", void 0);
611
- __decorate([
612
- Input()
613
- ], EditorComponent.prototype, "modelEvents", void 0);
614
- EditorComponent = __decorate([
615
- Component({
616
- selector: 'editor',
617
- template: '<ng-template></ng-template>',
618
- providers: [EDITOR_COMPONENT_VALUE_ACCESSOR],
619
- styles: [':host { display: block; }']
620
- }),
621
- __param(2, Inject(PLATFORM_ID)),
622
- __param(3, Optional()), __param(3, Inject(TINYMCE_SCRIPT_SRC))
623
- ], EditorComponent);
481
+ EditorComponent.decorators = [
482
+ { type: Component, args: [{
483
+ selector: 'editor',
484
+ template: '<ng-template></ng-template>',
485
+ providers: [EDITOR_COMPONENT_VALUE_ACCESSOR],
486
+ styles: [':host { display: block; }']
487
+ },] }
488
+ ];
489
+ EditorComponent.ctorParameters = function () { return [
490
+ { type: ElementRef },
491
+ { type: NgZone },
492
+ { type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] },
493
+ { type: String, decorators: [{ type: Optional }, { type: Inject, args: [TINYMCE_SCRIPT_SRC,] }] }
494
+ ]; };
495
+ EditorComponent.propDecorators = {
496
+ disabled: [{ type: Input }],
497
+ cloudChannel: [{ type: Input }],
498
+ apiKey: [{ type: Input }],
499
+ init: [{ type: Input }],
500
+ id: [{ type: Input }],
501
+ initialValue: [{ type: Input }],
502
+ outputFormat: [{ type: Input }],
503
+ inline: [{ type: Input }],
504
+ tagName: [{ type: Input }],
505
+ plugins: [{ type: Input }],
506
+ toolbar: [{ type: Input }],
507
+ modelEvents: [{ type: Input }],
508
+ allowedEvents: [{ type: Input }],
509
+ ignoreEvents: [{ type: Input }]
510
+ };
624
511
  return EditorComponent;
625
512
  }(Events));
626
513
 
627
514
  var EditorModule = /** @class */ (function () {
628
515
  function EditorModule() {
629
516
  }
630
- EditorModule = __decorate([
631
- NgModule({
632
- imports: [CommonModule, FormsModule],
633
- declarations: [EditorComponent],
634
- exports: [EditorComponent]
635
- })
636
- ], EditorModule);
517
+ EditorModule.decorators = [
518
+ { type: NgModule, args: [{
519
+ imports: [CommonModule, FormsModule],
520
+ declarations: [EditorComponent],
521
+ exports: [EditorComponent]
522
+ },] }
523
+ ];
637
524
  return EditorModule;
638
525
  }());
639
526