@progress/kendo-angular-editor 2.5.0 → 3.0.0-dev.202112211443

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.
@@ -2,7 +2,7 @@
2
2
  * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
- var ɵ0 = function (arg) { return "plugins must be a function, but received " + JSON.stringify(arg) + "."; };
5
+ var ɵ0 = function (arg) { return "plugins must be a function, but received " + JSON.stringify(arg) + "."; }, ɵ1 = function (arg) { return "pastedContent must be a function, but received " + JSON.stringify(arg) + "."; };
6
6
  /* tslint:disable:variable-name */
7
7
  /**
8
8
  * @hidden
@@ -11,8 +11,9 @@ export var EditorErrorMessages = {
11
11
  schemaType: 'Expected value of type Schema. See http://www.telerik.com/kendo-angular-ui/components/editor/schema/',
12
12
  setSchemaOnce: 'The Schema cannot be changed dynamically. See http://www.telerik.com/kendo-angular-ui/components/editor/schema/',
13
13
  pluginsCallbackType: ɵ0,
14
+ pastedContentCallbackType: ɵ1,
14
15
  setPluginsOnce: 'The plugins cannot be changed dynamically. See http://www.telerik.com/kendo-angular-ui/components/editor/plugins/',
15
16
  setPlaceHolderOnce: 'The placeholder cannot be changed dynamically. See http://www.telerik.com/kendo-angular-ui/components/editor/placeholder/',
16
17
  printTool: 'The Print tool and functionality are supported only in iframe mode. See https://www.telerik.com/kendo-angular-ui-develop/components/editor/api/EditorPrintButtonDirective/'
17
18
  };
18
- export { ɵ0 };
19
+ export { ɵ0, ɵ1 };
@@ -5,12 +5,12 @@
5
5
  import * as tslib_1 from "tslib";
6
6
  import { Component, HostBinding, ViewChild, ContentChild, ViewContainerRef, Output, ElementRef, EventEmitter, forwardRef, Input, ChangeDetectorRef, NgZone, isDevMode } from '@angular/core';
7
7
  import { NG_VALUE_ACCESSOR } from '@angular/forms';
8
- import { BehaviorSubject, fromEvent, merge, Subject, zip } from 'rxjs';
9
- import { map, filter, auditTime, take } from 'rxjs/operators';
8
+ import { BehaviorSubject, fromEvent, Subject, zip } from 'rxjs';
9
+ import { map, filter, take } from 'rxjs/operators';
10
10
  import { ToolBarComponent } from '@progress/kendo-angular-toolbar';
11
11
  import { DialogService } from '@progress/kendo-angular-dialog';
12
- import { isDocumentAvailable, KendoInput } from '@progress/kendo-angular-common';
13
- import { buildKeymap, buildListKeymap, hasSameMarkup, getHtml, pasteCleanup, sanitize, removeComments, sanitizeClassAttr, sanitizeStyleAttr, removeAttribute, placeholder, EditorView, EditorState, baseKeymap, keymap, history, parseContent, Plugin, PluginKey, TextSelection, Schema, gapCursor, getSelectionText, imageResizing } from '@progress/kendo-editor-common';
12
+ import { hasObservers, isDocumentAvailable, KendoInput } from '@progress/kendo-angular-common';
13
+ import { buildKeymap, buildListKeymap, getHtml, pasteCleanup, sanitize, removeComments, sanitizeClassAttr, sanitizeStyleAttr, removeAttribute, placeholder, EditorView, EditorState, baseKeymap, keymap, history, parseContent, Plugin, PluginKey, TextSelection, Schema, AllSelection, gapCursor, getSelectionText, imageResizing } from '@progress/kendo-editor-common';
14
14
  import { validatePackage } from '@progress/kendo-licensing';
15
15
  import { packageMetadata } from './package-metadata';
16
16
  import { schema } from './config/schema';
@@ -25,15 +25,16 @@ import { EditorLocalizationService } from './localization/editor-localization.se
25
25
  import { defaultStyle, tablesStyles, rtlStyles } from './common/styles';
26
26
  import { EditorErrorMessages } from './common/error-messages';
27
27
  import { EditorToolsService } from './tools/tools.service';
28
+ import { EditorPasteEvent } from './preventable-events/paste-event';
28
29
  var EMPTY_PARAGRAPH = '<p></p>';
29
30
  var defaultPasteCleanupSettings = {
30
31
  convertMsLists: false,
31
32
  removeAttributes: [],
32
33
  removeHtmlComments: false,
33
- removeInvalidHTML: false,
34
+ removeInvalidHTML: true,
34
35
  removeMsClasses: false,
35
36
  removeMsStyles: false,
36
- stripTags: ['']
37
+ stripTags: []
37
38
  };
38
39
  var removeCommentsIf = conditionallyExecute(removeComments);
39
40
  var removeInvalidHTMLIf = conditionallyExecute(sanitize);
@@ -74,14 +75,6 @@ var EditorComponent = /** @class */ (function () {
74
75
  * @default false
75
76
  */
76
77
  this.applyToWord = false;
77
- /**
78
- * By design, the Editor emits `valueChange`, updates the model and the ToolBar state on each keystroke.
79
- * When you are interested in ignoring the new values for a given amout of time and take only the most recent one, you can use the `updateInterval` property.
80
- * A possible use case is to get the new values and to update the ToolBar state at a maximum rate per second in order to speed up your application.
81
- * The specified interval (in milliseconds) should be a positive number.
82
- * By default the `updateInterval` is set to 100 miliseconds. If set to zero the delay will be disabled entirely.
83
- */
84
- this.updateInterval = 100;
85
78
  /**
86
79
  * By default, whitespace is collapsed as per HTML's rules.
87
80
  * Set to `true` to preserve whitespace, but normalize newlines to spaces.
@@ -107,6 +100,11 @@ var EditorComponent = /** @class */ (function () {
107
100
  * Fires when the content area of the Editor is focused ([see example]({% slug overview_editor %}#toc-events)).
108
101
  */
109
102
  this.onFocus = new EventEmitter();
103
+ /**
104
+ * Fires when the user performs paste in the content area of the Editor ([see example]({% slug overview_editor %}#toc-events)).
105
+ * The event is preventable. If you cancel it, the Editor content will not change.
106
+ */
107
+ this.paste = new EventEmitter();
110
108
  /**
111
109
  * Fires when the content area of the Editor is blurred ([see example]({% slug overview_editor %}#toc-events)).
112
110
  */
@@ -122,10 +120,73 @@ var EditorComponent = /** @class */ (function () {
122
120
  this.valueModified = new Subject();
123
121
  this._readonly = false;
124
122
  this._placeholder = '';
123
+ this.inForm = false;
125
124
  this.afterViewInit = new Subject();
126
125
  this.contentAreaLoaded = new Subject();
127
- this.onChangeCallback = function (_) { }; // tslint:disable-line:no-empty
126
+ this.dispatchTransaction = function (tr) {
127
+ var docChanged = tr.docChanged;
128
+ if (docChanged) {
129
+ var doc = tr.doc;
130
+ var html_1 = getHtml({ doc: doc });
131
+ _this.trOnChange = tr;
132
+ _this.htmlOnChange = html_1;
133
+ _this.ngZone.run(function () {
134
+ _this.valueModified.next(html_1);
135
+ });
136
+ }
137
+ if (!docChanged || _this.inForm) {
138
+ _this.view.updateState(_this.view.state.apply(tr));
139
+ }
140
+ };
141
+ this.transformPastedHTML = function (dirtyHtml) {
142
+ var pasteCleanupSettings = tslib_1.__assign({}, defaultPasteCleanupSettings, _this.pasteCleanupSettings);
143
+ var html = pipe(removeInvalidHTMLIf(pasteCleanupSettings.removeInvalidHTML), removeCommentsIf(pasteCleanupSettings.removeHtmlComments))(dirtyHtml);
144
+ var clean = pasteCleanup(html, {
145
+ convertMsLists: pasteCleanupSettings.convertMsLists,
146
+ stripTags: pasteCleanupSettings.stripTags.join('|'),
147
+ attributes: getPasteCleanupAttributes(pasteCleanupSettings)
148
+ });
149
+ if (hasObservers(_this.paste)) {
150
+ var event_1 = new EditorPasteEvent(clean, dirtyHtml, _this._pasteEvent);
151
+ _this.ngZone.run(function () { return _this.paste.emit(event_1); });
152
+ return event_1.isDefaultPrevented() ? '' : event_1.cleanedHtml;
153
+ }
154
+ return clean;
155
+ };
156
+ this.changeValue = function (value) {
157
+ var prev = _this._value;
158
+ _this._value = value;
159
+ if (!_this._view) {
160
+ return;
161
+ }
162
+ if (_this.htmlOnChange === value && _this.trOnChange) {
163
+ _this.view.updateState(_this.view.state.apply(_this.trOnChange));
164
+ }
165
+ else {
166
+ if ((prev || '') !== (value || '')) {
167
+ var iframeContentWindowNotPresent = _this.iframe && !_this.container.element.nativeElement.contentWindow;
168
+ if (iframeContentWindowNotPresent) {
169
+ return;
170
+ }
171
+ var state = _this.view.state;
172
+ var nextDoc = parseContent(value || '', state.schema, { preserveWhitespace: _this.preserveWhitespace });
173
+ var tr = state.tr
174
+ .setSelection(new AllSelection(state.doc))
175
+ .replaceSelectionWith(nextDoc);
176
+ _this.view.updateState(state.apply(tr));
177
+ }
178
+ }
179
+ _this.trOnChange = null;
180
+ _this.htmlOnChange = null;
181
+ };
182
+ this.onChangeCallback = function (value) {
183
+ _this.changeValue(value);
184
+ };
128
185
  this.onTouchedCallback = function (_) { }; // tslint:disable-line:no-empty
186
+ this.onPaste = function (_view, nativeEvent) {
187
+ _this._pasteEvent = nativeEvent;
188
+ return false;
189
+ };
129
190
  validatePackage(packageMetadata);
130
191
  this.direction = localization.rtl ? 'rtl' : 'ltr';
131
192
  // https://stackoverflow.com/questions/56572483/chrome-is-synchronously-handling-iframe-loading-whereas-firefox-handles-it-asyn
@@ -134,6 +195,9 @@ var EditorComponent = /** @class */ (function () {
134
195
  EditorComponent_1 = EditorComponent;
135
196
  Object.defineProperty(EditorComponent.prototype, "value", {
136
197
  get: function () {
198
+ if (this.trOnChange) {
199
+ return this.htmlOnChange;
200
+ }
137
201
  var value = this._view ? this.getSource() : this._value;
138
202
  if (value === EMPTY_PARAGRAPH) {
139
203
  return this._value ? '' : this._value;
@@ -146,23 +210,7 @@ var EditorComponent = /** @class */ (function () {
146
210
  * Sets the value of the Editor ([see example]({% slug overview_editor %}#toc-basic-usage)).
147
211
  */
148
212
  set: function (value) {
149
- if (this._previousValue === value) {
150
- return;
151
- }
152
- this._value = value;
153
- this._previousValue = value;
154
- if (this._view) {
155
- var iframeContentWindowNotPresent = this.iframe && !this.container.element.nativeElement.contentWindow;
156
- if (iframeContentWindowNotPresent) {
157
- return;
158
- }
159
- this.exec('setHTML', {
160
- content: this._value || '',
161
- parseOptions: {
162
- preserveWhitespace: this.preserveWhitespace
163
- }
164
- });
165
- }
213
+ this.changeValue(value);
166
214
  },
167
215
  enumerable: true,
168
216
  configurable: true
@@ -423,6 +471,9 @@ var EditorComponent = /** @class */ (function () {
423
471
  };
424
472
  EditorComponent.prototype.ngOnChanges = function (changes) {
425
473
  var _this = this;
474
+ if (changes.value && this.view) {
475
+ this.changeValue(changes.value.currentValue);
476
+ }
426
477
  if (changes.iframe && !changes.iframe.isFirstChange()) {
427
478
  this.ngZone.onStable.pipe(take(1)).subscribe(function () { return _this.initialize(); });
428
479
  }
@@ -508,8 +559,6 @@ var EditorComponent = /** @class */ (function () {
508
559
  var command = editorCommands[commandName](attr);
509
560
  // Executes a ProseMirror command.
510
561
  command(this._view.state, this._view.dispatch, this._view);
511
- // See the `dispatchTransaction` comments.
512
- // this.stateChange.emit(updateToolBar(this.view));
513
562
  };
514
563
  /**
515
564
  * Opens a dialog.
@@ -594,6 +643,7 @@ var EditorComponent = /** @class */ (function () {
594
643
  * @hidden
595
644
  */
596
645
  EditorComponent.prototype.writeValue = function (value) {
646
+ this.inForm = true;
597
647
  // To avoid confusion, non-existent values are always undefined.
598
648
  this.value = value === null ? undefined : value;
599
649
  };
@@ -622,7 +672,6 @@ var EditorComponent = /** @class */ (function () {
622
672
  return;
623
673
  }
624
674
  var currentSchema = this.schema || schema;
625
- var that = this;
626
675
  var containerNativeElement = this.container.element.nativeElement;
627
676
  var contentNode = parseContent((this.value || '').trim(), currentSchema, { preserveWhitespace: this.preserveWhitespace });
628
677
  if (this.iframe) {
@@ -666,7 +715,7 @@ var EditorComponent = /** @class */ (function () {
666
715
  }),
667
716
  new Plugin({
668
717
  key: new PluginKey('editor-filter-disabled-state'),
669
- filterTransaction: function () { return !_this.disabled; }
718
+ filterTransaction: function () { return !_this.disabled || _this.inForm; }
670
719
  }),
671
720
  history(),
672
721
  keymap(buildListKeymap(currentSchema)),
@@ -693,31 +742,10 @@ var EditorComponent = /** @class */ (function () {
693
742
  _this._view = new EditorView({ mount: _this.viewMountElement }, {
694
743
  state: state,
695
744
  editable: function () { return !_this.readonly; },
696
- dispatchTransaction: function (tr) {
697
- // `this` is bound to the view instance.
698
- this.updateState(this.state.apply(tr));
699
- // that.cdr.detectChanges();
700
- // When the user utilizes keyboard shortcuts&mdash;for example, `Ctrl`+`b`&mdash;
701
- // `tr.docChanged` is `true` and the toolbar is not updated.
702
- // A possible future solution is to move the keymaps to the service.
703
- // if (!tr.docChanged) {
704
- // that.stateChange.emit(updateToolBar(that.view));
705
- // }
706
- var value = that.value;
707
- if (!hasSameMarkup(value, that._previousValue, this.state.schema)) {
708
- that._previousValue = value;
709
- that.ngZone.run(function () { return that.valueModified.next(value); });
710
- }
711
- },
712
- transformPastedHTML: function (html) {
713
- var pasteCleanupSettings = tslib_1.__assign({}, defaultPasteCleanupSettings, _this.pasteCleanupSettings);
714
- var clean = pipe(removeCommentsIf(pasteCleanupSettings.removeHtmlComments), removeInvalidHTMLIf(pasteCleanupSettings.removeInvalidHTML))(html);
715
- var attributes = getPasteCleanupAttributes(pasteCleanupSettings);
716
- return pasteCleanup(clean, {
717
- convertMsLists: pasteCleanupSettings.convertMsLists,
718
- stripTags: pasteCleanupSettings.stripTags.join('|'),
719
- attributes: attributes
720
- });
745
+ dispatchTransaction: _this.dispatchTransaction,
746
+ transformPastedHTML: _this.transformPastedHTML,
747
+ handleDOMEvents: {
748
+ paste: _this.onPaste
721
749
  }
722
750
  });
723
751
  });
@@ -758,7 +786,7 @@ var EditorComponent = /** @class */ (function () {
758
786
  _this.cdr.detectChanges();
759
787
  }
760
788
  }));
761
- this.subs.add(merge(this.valueModified.pipe(filter(function () { return _this.updateInterval > 0; }), auditTime(this.updateInterval)), this.valueModified.pipe(filter(function () { return _this.updateInterval === 0; }))).subscribe(function (value) {
789
+ this.subs.add(this.valueModified.subscribe(function (value) {
762
790
  _this.onChangeCallback(value);
763
791
  _this.valueChange.emit(value);
764
792
  _this.cdr.markForCheck();
@@ -852,10 +880,6 @@ var EditorComponent = /** @class */ (function () {
852
880
  tslib_1.__metadata("design:type", String),
853
881
  tslib_1.__metadata("design:paramtypes", [String])
854
882
  ], EditorComponent.prototype, "placeholder", null);
855
- tslib_1.__decorate([
856
- Input(),
857
- tslib_1.__metadata("design:type", Number)
858
- ], EditorComponent.prototype, "updateInterval", void 0);
859
883
  tslib_1.__decorate([
860
884
  Input(),
861
885
  tslib_1.__metadata("design:type", Object)
@@ -876,6 +900,10 @@ var EditorComponent = /** @class */ (function () {
876
900
  Output('focus'),
877
901
  tslib_1.__metadata("design:type", EventEmitter)
878
902
  ], EditorComponent.prototype, "onFocus", void 0);
903
+ tslib_1.__decorate([
904
+ Output(),
905
+ tslib_1.__metadata("design:type", EventEmitter)
906
+ ], EditorComponent.prototype, "paste", void 0);
879
907
  tslib_1.__decorate([
880
908
  Output('blur'),
881
909
  tslib_1.__metadata("design:type", EventEmitter)
@@ -983,7 +1011,7 @@ var EditorComponent = /** @class */ (function () {
983
1011
  }
984
1012
  ],
985
1013
  /* tslint:disable:max-line-length */
986
- template: "\n <ng-container\n kendoEditorLocalizedMessages\n i18n-alignCenter=\"kendo.editor.alignCenter|The title of the tool that aligns text in the center.\"\n alignCenter=\"Center text\"\n i18n-alignJustify=\"kendo.editor.alignJustify|The title of the tool that justifies text both left and right.\"\n alignJustify=\"Justify\"\n i18n-alignLeft=\"kendo.editor.alignLeft|The title of the tool that aligns text on the left.\"\n alignLeft=\"Align text left\"\n i18n-alignRight=\"kendo.editor.alignRight|The title of the tool that aligns text on the right.\"\n alignRight=\"Align text right\"\n i18n-backColor=\"kendo.editor.backColor|The title of the tool that changes the text background color.\"\n backColor=\"Background color\"\n i18n-bold=\"kendo.editor.bold|The title of the tool that makes text bold.\"\n bold=\"Bold\"\n i18n-cleanFormatting=\"kendo.editor.cleanFormatting|The title of the Clean Formatting tool.\"\n cleanFormatting=\"Clean formatting\"\n i18n-createLink=\"kendo.editor.createLink|The title of the tool that creates hyperlinks.\"\n createLink=\"Insert link\"\n i18n-dialogApply=\"kendo.editor.dialogApply|The label of the **Apply** button in all editor dialogs.\"\n dialogApply=\"Apply\"\n i18n-dialogCancel=\"kendo.editor.dialogCancel|The label of the **Cancel** button in all editor dialogs.\"\n dialogCancel=\"Cancel\"\n i18n-dialogInsert=\"kendo.editor.dialogInsert|The label of the **Insert** button in all editor dialogs.\"\n dialogInsert=\"Insert\"\n i18n-dialogUpdate=\"kendo.editor.dialogUpdate|The label of the **Update** button in all editor dialogs.\"\n dialogUpdate=\"Update\"\n i18n-fileText=\"kendo.editor.fileText|The caption for the file text in the insertFile dialog.\"\n fileText=\"Text\"\n i18n-fileTitle=\"kendo.editor.fileTitle|The caption for the file Title in the insertFile dialog.\"\n fileTitle=\"Title\"\n i18n-fileWebAddress=\"kendo.editor.fileWebAddress|The caption for the file URL in the insertFile dialog.\"\n fileWebAddress=\"Web address\"\n i18n-fontFamily=\"kendo.editor.fontFamily|The title of the tool that changes the text font.\"\n fontFamily=\"Select font family\"\n i18n-fontSize=\"kendo.editor.fontSize|The title of the tool that changes the text size.\"\n fontSize=\"Select font size\"\n i18n-foreColor=\"kendo.editor.foreColor|The title of the tool that changes the text color.\"\n foreColor=\"Color\"\n i18n-format=\"kendo.editor.format|The title of the tool that lets users choose block formats.\"\n format=\"Format\"\n i18n-imageAltText=\"kendo.editor.imageAltText|The caption for the image alternate text in the insertImage dialog.\"\n imageAltText=\"Alternate text\"\n i18n-imageHeight=\"kendo.editor.imageHeight|The caption for the image height in the insertImage dialog.\"\n imageHeight=\"Height (px)\"\n i18n-imageWebAddress=\"kendo.editor.imageWebAddress|The caption for the image URL in the insertImage dialog.\"\n imageWebAddress=\"Web address\"\n i18n-imageWidth=\"kendo.editor.imageWidth|The caption for the image width in the insertImage dialog.\"\n imageWidth=\"Width (px)\"\n i18n-indent=\"kendo.editor.indent|The title of the tool that indents the content.\"\n indent=\"Indent\"\n i18n-insertFile=\"kendo.editor.insertFile|The title of the tool that inserts links to files.\"\n insertFile=\"Insert file\"\n i18n-insertImage=\"kendo.editor.insertImage|The title of the tool that inserts images.\"\n insertImage=\"Insert image\"\n i18n-insertOrderedList=\"kendo.editor.insertOrderedList|The title of the tool that inserts an ordered list.\"\n insertOrderedList=\"Insert ordered list\"\n i18n-insertUnorderedList=\"kendo.editor.insertUnorderedList|The title of the tool that inserts an unordered list.\"\n insertUnorderedList=\"Insert unordered list\"\n i18n-italic=\"kendo.editor.italic|The title of the tool that makes text italicized.\"\n italic=\"Italic\"\n i18n-linkOpenInNewWindow=\"kendo.editor.linkOpenInNewWindow|The caption for the checkbox for opening the link in a new window in the createLink dialog.\"\n linkOpenInNewWindow=\"Open link in new window\"\n i18n-linkText=\"kendo.editor.linkText|The caption for the link text in the createLink dialog.\"\n linkText=\"Text\"\n i18n-linkTitle=\"kendo.editor.linkTitle|The caption for the link title in the createLink dialog.\"\n linkTitle=\"Title\"\n i18n-linkWebAddress=\"kendo.editor.linkWebAddress|The caption for the URL in the createLink dialog.\"\n linkWebAddress=\"Web address\"\n i18n-outdent=\"kendo.editor.outdent|The title of the tool that outdents the content.\"\n outdent=\"Outdent\"\n i18n-print=\"kendo.editor.print|The title of the print tool.\"\n print=\"Print\"\n i18n-redo=\"kendo.editor.redo|The title of the tool that undos the last action.\"\n redo=\"Redo\"\n i18n-selectAll=\"kendo.editor.selectAll|The title of the tool that selects all content.\"\n selectAll=\"Select All\"\n i18n-strikethrough=\"kendo.editor.strikethrough|The title of the tool that strikes through text.\"\n strikethrough=\"Strikethrough\"\n i18n-subscript=\"kendo.editor.subscript|The title of the tool that makes text subscript.\"\n subscript=\"Subscript\"\n i18n-superscript=\"kendo.editor.superscript|The title of the tool that makes text superscript.\"\n superscript=\"Superscript\"\n i18n-underline=\"kendo.editor.underline|The title of the tool that underlines text.\"\n underline=\"Underline\"\n i18n-unlink=\"kendo.editor.unlink|The title of the tool that removes hyperlinks.\"\n unlink=\"Remove Link\"\n i18n-undo=\"kendo.editor.undo|The title of the tool that undos the last action.\"\n undo=\"Undo\"\n i18n-viewSource=\"kendo.editor.viewSource|The title of the tool that shows the editor value as HTML.\"\n viewSource=\"View source\"\n i18n-insertTable=\"kendo.editor.insertTable|The title of the tool that inserts table.\"\n insertTable=\"Insert Table\"\n i18n-addColumnBefore=\"kendo.editor.addColumnBefore|The title of the tool that adds new column before currently selected column.\"\n addColumnBefore=\"Add column before\"\n i18n-addColumnAfter=\"kendo.editor.addColumnAfter|The title of the tool that adds new column after currently selected column.\"\n addColumnAfter=\"Add column after\"\n i18n-addRowBefore=\"kendo.editor.addRowBefore|The title of the tool that adds new row before currently selected row.\"\n addRowBefore=\"Add row before\"\n i18n-addRowAfter=\"kendo.editor.addRowAfter|The title of the tool that adds new row after currently selected row.\"\n addRowAfter=\"Add row after\"\n i18n-deleteColumn=\"kendo.editor.deleteColumn|The title of the tool that deletes a table column.\"\n deleteColumn=\"Delete column\"\n i18n-deleteRow=\"kendo.editor.deleteRow|The title of the tool that deletes a table row.\"\n deleteRow=\"Delete row\"\n i18n-deleteTable=\"kendo.editor.deleteTable|The title of the tool that deletes a table.\"\n deleteTable=\"Delete table\"\n >\n </ng-container>\n\n <ng-content select=\"kendo-toolbar\"></ng-content>\n <kendo-toolbar [overflow]=\"true\" [tabindex]=\"readonly ? -1 : 0\" *ngIf=\"!userToolBarElement\" #defaultToolbar>\n <kendo-toolbar-buttongroup>\n <kendo-toolbar-button kendoEditorBoldButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorItalicButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorUnderlineButton></kendo-toolbar-button>\n </kendo-toolbar-buttongroup>\n <kendo-toolbar-dropdownlist kendoEditorFormat></kendo-toolbar-dropdownlist>\n <kendo-toolbar-buttongroup>\n <kendo-toolbar-button kendoEditorAlignLeftButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorAlignCenterButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorAlignRightButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorAlignJustifyButton></kendo-toolbar-button>\n </kendo-toolbar-buttongroup>\n <kendo-toolbar-buttongroup>\n <kendo-toolbar-button kendoEditorInsertUnorderedListButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorInsertOrderedListButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorIndentButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorOutdentButton></kendo-toolbar-button>\n </kendo-toolbar-buttongroup>\n <kendo-toolbar-buttongroup>\n <kendo-toolbar-button kendoEditorCreateLinkButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorUnlinkButton></kendo-toolbar-button>\n </kendo-toolbar-buttongroup>\n <kendo-toolbar-button kendoEditorInsertImageButton></kendo-toolbar-button>\n </kendo-toolbar>\n\n <div *ngIf=\"!iframe\" #content [attr.dir]=\"direction\" class=\"k-editor-content\"></div>\n\n <div class=\"k-editor-content\" *ngIf=\"iframe\">\n <iframe #content frameborder=\"0\" class=\"k-iframe\" (load)=\"iframeOnLoad()\"></iframe>\n </div>\n\n <ng-container #dialogsContainer></ng-container>\n ",
1014
+ template: "\n <ng-container\n kendoEditorLocalizedMessages\n i18n-alignCenter=\"kendo.editor.alignCenter|The title of the tool that aligns text in the center.\"\n alignCenter=\"Center text\"\n i18n-alignJustify=\"kendo.editor.alignJustify|The title of the tool that justifies text both left and right.\"\n alignJustify=\"Justify\"\n i18n-alignLeft=\"kendo.editor.alignLeft|The title of the tool that aligns text on the left.\"\n alignLeft=\"Align text left\"\n i18n-alignRight=\"kendo.editor.alignRight|The title of the tool that aligns text on the right.\"\n alignRight=\"Align text right\"\n i18n-backColor=\"kendo.editor.backColor|The title of the tool that changes the text background color.\"\n backColor=\"Background color\"\n i18n-bold=\"kendo.editor.bold|The title of the tool that makes text bold.\"\n bold=\"Bold\"\n i18n-cleanFormatting=\"kendo.editor.cleanFormatting|The title of the Clean Formatting tool.\"\n cleanFormatting=\"Clean formatting\"\n i18n-createLink=\"kendo.editor.createLink|The title of the tool that creates hyperlinks.\"\n createLink=\"Insert link\"\n i18n-dialogApply=\"kendo.editor.dialogApply|The label of the **Apply** button in all editor dialogs.\"\n dialogApply=\"Apply\"\n i18n-dialogCancel=\"kendo.editor.dialogCancel|The label of the **Cancel** button in all editor dialogs.\"\n dialogCancel=\"Cancel\"\n i18n-dialogInsert=\"kendo.editor.dialogInsert|The label of the **Insert** button in all editor dialogs.\"\n dialogInsert=\"Insert\"\n i18n-dialogUpdate=\"kendo.editor.dialogUpdate|The label of the **Update** button in all editor dialogs.\"\n dialogUpdate=\"Update\"\n i18n-fileText=\"kendo.editor.fileText|The caption for the file text in the insertFile dialog.\"\n fileText=\"Text\"\n i18n-fileTitle=\"kendo.editor.fileTitle|The caption for the file Title in the insertFile dialog.\"\n fileTitle=\"Title\"\n i18n-fileWebAddress=\"kendo.editor.fileWebAddress|The caption for the file URL in the insertFile dialog.\"\n fileWebAddress=\"Web address\"\n i18n-fontFamily=\"kendo.editor.fontFamily|The title of the tool that changes the text font.\"\n fontFamily=\"Select font family\"\n i18n-fontSize=\"kendo.editor.fontSize|The title of the tool that changes the text size.\"\n fontSize=\"Select font size\"\n i18n-foreColor=\"kendo.editor.foreColor|The title of the tool that changes the text color.\"\n foreColor=\"Color\"\n i18n-format=\"kendo.editor.format|The title of the tool that lets users choose block formats.\"\n format=\"Format\"\n i18n-imageAltText=\"kendo.editor.imageAltText|The caption for the image alternate text in the insertImage dialog.\"\n imageAltText=\"Alternate text\"\n i18n-imageHeight=\"kendo.editor.imageHeight|The caption for the image height in the insertImage dialog.\"\n imageHeight=\"Height (px)\"\n i18n-imageWebAddress=\"kendo.editor.imageWebAddress|The caption for the image URL in the insertImage dialog.\"\n imageWebAddress=\"Web address\"\n i18n-imageWidth=\"kendo.editor.imageWidth|The caption for the image width in the insertImage dialog.\"\n imageWidth=\"Width (px)\"\n i18n-indent=\"kendo.editor.indent|The title of the tool that indents the content.\"\n indent=\"Indent\"\n i18n-insertFile=\"kendo.editor.insertFile|The title of the tool that inserts links to files.\"\n insertFile=\"Insert file\"\n i18n-insertImage=\"kendo.editor.insertImage|The title of the tool that inserts images.\"\n insertImage=\"Insert image\"\n i18n-insertOrderedList=\"kendo.editor.insertOrderedList|The title of the tool that inserts an ordered list.\"\n insertOrderedList=\"Insert ordered list\"\n i18n-insertUnorderedList=\"kendo.editor.insertUnorderedList|The title of the tool that inserts an unordered list.\"\n insertUnorderedList=\"Insert unordered list\"\n i18n-italic=\"kendo.editor.italic|The title of the tool that makes text italicized.\"\n italic=\"Italic\"\n i18n-linkOpenInNewWindow=\"kendo.editor.linkOpenInNewWindow|The caption for the checkbox for opening the link in a new window in the createLink dialog.\"\n linkOpenInNewWindow=\"Open link in new window\"\n i18n-linkText=\"kendo.editor.linkText|The caption for the link text in the createLink dialog.\"\n linkText=\"Text\"\n i18n-linkTitle=\"kendo.editor.linkTitle|The caption for the link title in the createLink dialog.\"\n linkTitle=\"Title\"\n i18n-linkWebAddress=\"kendo.editor.linkWebAddress|The caption for the URL in the createLink dialog.\"\n linkWebAddress=\"Web address\"\n i18n-outdent=\"kendo.editor.outdent|The title of the tool that outdents the content.\"\n outdent=\"Outdent\"\n i18n-print=\"kendo.editor.print|The title of the print tool.\"\n print=\"Print\"\n i18n-redo=\"kendo.editor.redo|The title of the tool that undos the last action.\"\n redo=\"Redo\"\n i18n-selectAll=\"kendo.editor.selectAll|The title of the tool that selects all content.\"\n selectAll=\"Select All\"\n i18n-strikethrough=\"kendo.editor.strikethrough|The title of the tool that strikes through text.\"\n strikethrough=\"Strikethrough\"\n i18n-subscript=\"kendo.editor.subscript|The title of the tool that makes text subscript.\"\n subscript=\"Subscript\"\n i18n-superscript=\"kendo.editor.superscript|The title of the tool that makes text superscript.\"\n superscript=\"Superscript\"\n i18n-underline=\"kendo.editor.underline|The title of the tool that underlines text.\"\n underline=\"Underline\"\n i18n-unlink=\"kendo.editor.unlink|The title of the tool that removes hyperlinks.\"\n unlink=\"Remove Link\"\n i18n-undo=\"kendo.editor.undo|The title of the tool that undos the last action.\"\n undo=\"Undo\"\n i18n-viewSource=\"kendo.editor.viewSource|The title of the tool that shows the editor value as HTML.\"\n viewSource=\"View source\"\n i18n-insertTable=\"kendo.editor.insertTable|The title of the tool that inserts table.\"\n insertTable=\"Insert Table\"\n i18n-addColumnBefore=\"kendo.editor.addColumnBefore|The title of the tool that adds new column before currently selected column.\"\n addColumnBefore=\"Add column before\"\n i18n-addColumnAfter=\"kendo.editor.addColumnAfter|The title of the tool that adds new column after currently selected column.\"\n addColumnAfter=\"Add column after\"\n i18n-addRowBefore=\"kendo.editor.addRowBefore|The title of the tool that adds new row before currently selected row.\"\n addRowBefore=\"Add row before\"\n i18n-addRowAfter=\"kendo.editor.addRowAfter|The title of the tool that adds new row after currently selected row.\"\n addRowAfter=\"Add row after\"\n i18n-deleteColumn=\"kendo.editor.deleteColumn|The title of the tool that deletes a table column.\"\n deleteColumn=\"Delete column\"\n i18n-deleteRow=\"kendo.editor.deleteRow|The title of the tool that deletes a table row.\"\n deleteRow=\"Delete row\"\n i18n-deleteTable=\"kendo.editor.deleteTable|The title of the tool that deletes a table.\"\n deleteTable=\"Delete table\"\n >\n </ng-container>\n\n <ng-content select=\"kendo-toolbar\"></ng-content>\n <kendo-toolbar [overflow]=\"true\" [tabindex]=\"readonly ? -1 : 0\" *ngIf=\"!userToolBarElement\" #defaultToolbar>\n <kendo-toolbar-buttongroup>\n <kendo-toolbar-button kendoEditorBoldButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorItalicButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorUnderlineButton></kendo-toolbar-button>\n </kendo-toolbar-buttongroup>\n <kendo-toolbar-dropdownlist kendoEditorFormat></kendo-toolbar-dropdownlist>\n <kendo-toolbar-buttongroup>\n <kendo-toolbar-button kendoEditorAlignLeftButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorAlignCenterButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorAlignRightButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorAlignJustifyButton></kendo-toolbar-button>\n </kendo-toolbar-buttongroup>\n <kendo-toolbar-buttongroup>\n <kendo-toolbar-button kendoEditorInsertUnorderedListButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorInsertOrderedListButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorIndentButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorOutdentButton></kendo-toolbar-button>\n </kendo-toolbar-buttongroup>\n <kendo-toolbar-buttongroup>\n <kendo-toolbar-button kendoEditorCreateLinkButton></kendo-toolbar-button>\n <kendo-toolbar-button kendoEditorUnlinkButton></kendo-toolbar-button>\n </kendo-toolbar-buttongroup>\n <kendo-toolbar-button kendoEditorInsertImageButton></kendo-toolbar-button>\n </kendo-toolbar>\n\n <div *ngIf=\"!iframe\" #content [attr.dir]=\"direction\" class=\"k-editor-content\"></div>\n\n <div class=\"k-editor-content\" *ngIf=\"iframe\">\n <iframe #content srcdoc=\"<!DOCTYPE html>\" frameborder=\"0\" class=\"k-iframe\" (load)=\"iframeOnLoad()\"></iframe>\n </div>\n\n <ng-container #dialogsContainer></ng-container>\n ",
987
1015
  styles: [
988
1016
  "\n >>> .k-editor-content > .ProseMirror {\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n outline: none;\n overflow: auto;\n }\n\n .k-iframe {\n width: 100%;\n height: 100%;\n display: block;\n }\n "
989
1017
  ]
package/dist/es/main.js CHANGED
@@ -6,3 +6,4 @@ export { EditorComponent } from './editor.component';
6
6
  export { EditorModule } from './editor.module';
7
7
  export { schema, Schema } from './config/schema';
8
8
  export { EditorState, Plugin, PluginKey, Transaction, EditorView, Decoration, DecorationSet, NodeType, Node, MarkType, Mark, InputRule, inputRules, wrappingInputRule, textblockTypeInputRule, keymap, baseKeymap, history, dropCursor, gapCursor, tableNodes, getSelectionText } from '@progress/kendo-editor-common';
9
+ export { EditorPasteEvent } from './preventable-events/paste-event';
@@ -9,7 +9,7 @@ export var packageMetadata = {
9
9
  name: '@progress/kendo-angular-editor',
10
10
  productName: 'Kendo UI for Angular',
11
11
  productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
12
- publishDate: 1638198421,
12
+ publishDate: 1640097479,
13
13
  version: '',
14
14
  licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/?utm_medium=product&utm_source=kendoangular&utm_campaign=kendo-ui-angular-purchase-license-keys-warning'
15
15
  };
@@ -0,0 +1,4 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
@@ -0,0 +1,25 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import * as tslib_1 from "tslib";
6
+ import { PreventableEvent } from "@progress/kendo-angular-common";
7
+ /**
8
+ * The Editor [`paste`]({% slug api_editor_editorcomponent %}#toc-paste) event.
9
+ */
10
+ var EditorPasteEvent = /** @class */ (function (_super) {
11
+ tslib_1.__extends(EditorPasteEvent, _super);
12
+ /**
13
+ * Constructs the event arguments for the `paste` event.
14
+ * @hidden
15
+ */
16
+ function EditorPasteEvent(cleanedHtml, originalHtml, originalEvent) {
17
+ var _this = _super.call(this) || this;
18
+ _this.cleanedHtml = cleanedHtml;
19
+ _this.originalHtml = originalHtml;
20
+ _this.originalEvent = originalEvent;
21
+ return _this;
22
+ }
23
+ return EditorPasteEvent;
24
+ }(PreventableEvent));
25
+ export { EditorPasteEvent };
@@ -2,7 +2,7 @@
2
2
  * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
- const ɵ0 = (arg) => `plugins must be a function, but received ${JSON.stringify(arg)}.`;
5
+ const ɵ0 = (arg) => `plugins must be a function, but received ${JSON.stringify(arg)}.`, ɵ1 = (arg) => `pastedContent must be a function, but received ${JSON.stringify(arg)}.`;
6
6
  /* tslint:disable:variable-name */
7
7
  /**
8
8
  * @hidden
@@ -11,8 +11,9 @@ export const EditorErrorMessages = {
11
11
  schemaType: 'Expected value of type Schema. See http://www.telerik.com/kendo-angular-ui/components/editor/schema/',
12
12
  setSchemaOnce: 'The Schema cannot be changed dynamically. See http://www.telerik.com/kendo-angular-ui/components/editor/schema/',
13
13
  pluginsCallbackType: ɵ0,
14
+ pastedContentCallbackType: ɵ1,
14
15
  setPluginsOnce: 'The plugins cannot be changed dynamically. See http://www.telerik.com/kendo-angular-ui/components/editor/plugins/',
15
16
  setPlaceHolderOnce: 'The placeholder cannot be changed dynamically. See http://www.telerik.com/kendo-angular-ui/components/editor/placeholder/',
16
17
  printTool: 'The Print tool and functionality are supported only in iframe mode. See https://www.telerik.com/kendo-angular-ui-develop/components/editor/api/EditorPrintButtonDirective/'
17
18
  };
18
- export { ɵ0 };
19
+ export { ɵ0, ɵ1 };
@@ -8,12 +8,16 @@
8
8
  export interface PasteCleanupSettings {
9
9
  /**
10
10
  * If set to `true`, MS Word lists will be converted into HTML lists.
11
+ *
12
+ * @default false
11
13
  */
12
14
  convertMsLists?: boolean;
13
15
  /**
14
16
  * If set to `true`, comments will be removed from the HTML.
15
17
  *
16
18
  * For example `<!-- comment --> <p> content </p>` will result in `<p> content </p>`
19
+ *
20
+ * @default false
17
21
  */
18
22
  removeHtmlComments?: boolean;
19
23
  /**
@@ -21,6 +25,8 @@ export interface PasteCleanupSettings {
21
25
  * > Child nodes of removed tags will be kept in place.
22
26
  *
23
27
  * For example when `stripTags: ['span']`, `<p><span lang=EN-US>content</span></p>` will result in `<p>content</p>`
28
+ *
29
+ * @default []
24
30
  */
25
31
  stripTags?: string[];
26
32
  /**
@@ -32,12 +38,16 @@ export interface PasteCleanupSettings {
32
38
  *
33
39
  * For example when `removeAttributes: ['lang']`, `<p><span lang=EN-US>content</span></p>`
34
40
  * will result in `<p><span>content</span></p>`
41
+ *
42
+ * @default []
35
43
  */
36
44
  removeAttributes?: string[] | 'all';
37
45
  /**
38
46
  * If set to `true`, class attributes starting with 'Mso' will be removed from the HTML.
39
47
  *
40
48
  * For example `<p class="MsoNormal">pasted from MS Word</p>` will result in `<p>pasted from MS Word</p>`
49
+ *
50
+ * @default false
41
51
  */
42
52
  removeMsClasses?: boolean;
43
53
  /**
@@ -45,12 +55,16 @@ export interface PasteCleanupSettings {
45
55
  *
46
56
  * For example `<p><span style="color:#7C7C7C; mso-themecolor:accent3; mso-themeshade:191;">content</span></p>`
47
57
  * will result in `<p><span style="color: #7C7C7C; background: silver;">content</span></p>`
58
+ *
59
+ * @default false
48
60
  */
49
61
  removeMsStyles?: boolean;
50
62
  /**
51
63
  * Determines whether invalid HTML should be removed.
52
64
  *
53
65
  * For example `<p>content <o:p>, <w:sdtPr></p>` will result in `<p>content </p>`
66
+ *
67
+ * @default true
54
68
  */
55
69
  removeInvalidHTML?: boolean;
56
70
  }
@@ -16,6 +16,7 @@ import { PluginsFn } from './common/plugins-function';
16
16
  import { ApplyToWordOptions } from './common/apply-to-word-options';
17
17
  import { EditorResizableOptions } from './common/resizable-options.interface';
18
18
  import { EditorToolsService } from './tools/tools.service';
19
+ import { EditorPasteEvent } from './preventable-events/paste-event';
19
20
  /**
20
21
  * Represents the [Kendo UI Editor component for Angular]({% slug overview_editor %}).
21
22
  */
@@ -70,14 +71,6 @@ export declare class EditorComponent implements AfterViewInit, ControlValueAcces
70
71
  * The hint, which is displayed when the component is empty.
71
72
  */
72
73
  placeholder: string;
73
- /**
74
- * By design, the Editor emits `valueChange`, updates the model and the ToolBar state on each keystroke.
75
- * When you are interested in ignoring the new values for a given amout of time and take only the most recent one, you can use the `updateInterval` property.
76
- * A possible use case is to get the new values and to update the ToolBar state at a maximum rate per second in order to speed up your application.
77
- * The specified interval (in milliseconds) should be a positive number.
78
- * By default the `updateInterval` is set to 100 miliseconds. If set to zero the delay will be disabled entirely.
79
- */
80
- updateInterval: number;
81
74
  /**
82
75
  * By default, whitespace is collapsed as per HTML's rules.
83
76
  * Set to `true` to preserve whitespace, but normalize newlines to spaces.
@@ -107,6 +100,11 @@ export declare class EditorComponent implements AfterViewInit, ControlValueAcces
107
100
  * Fires when the content area of the Editor is focused ([see example]({% slug overview_editor %}#toc-events)).
108
101
  */
109
102
  onFocus: EventEmitter<undefined>;
103
+ /**
104
+ * Fires when the user performs paste in the content area of the Editor ([see example]({% slug overview_editor %}#toc-events)).
105
+ * The event is preventable. If you cancel it, the Editor content will not change.
106
+ */
107
+ paste: EventEmitter<EditorPasteEvent>;
110
108
  /**
111
109
  * Fires when the content area of the Editor is blurred ([see example]({% slug overview_editor %}#toc-events)).
112
110
  */
@@ -159,13 +157,16 @@ export declare class EditorComponent implements AfterViewInit, ControlValueAcces
159
157
  private subs;
160
158
  private _view;
161
159
  private _value;
162
- private _previousValue;
163
160
  private _disabled;
164
161
  private _readonly;
165
162
  private _schema;
166
163
  private _plugins;
167
164
  private _placeholder;
168
165
  private _styleObserver;
166
+ private trOnChange;
167
+ private htmlOnChange;
168
+ private inForm;
169
+ private _pasteEvent;
169
170
  private afterViewInit;
170
171
  private contentAreaLoaded;
171
172
  constructor(dialogService: DialogService, localization: LocalizationService, cdr: ChangeDetectorRef, ngZone: NgZone, element: ElementRef, toolsService: EditorToolsService);
@@ -279,8 +280,12 @@ export declare class EditorComponent implements AfterViewInit, ControlValueAcces
279
280
  */
280
281
  isEmpty(): boolean;
281
282
  private initialize;
283
+ private dispatchTransaction;
284
+ private transformPastedHTML;
285
+ private changeValue;
286
+ private onChangeCallback;
282
287
  private normalizeSize;
283
288
  private normalizeProperties;
284
- private onChangeCallback;
285
289
  private onTouchedCallback;
290
+ private onPaste;
286
291
  }