@progress/kendo-angular-editor 2.5.0-dev.202111240844 → 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.
- package/dist/cdn/js/kendo-angular-editor.js +2 -2
- package/dist/cdn/main.js +1 -1
- package/dist/es/common/error-messages.js +3 -2
- package/dist/es/editor.component.js +102 -69
- package/dist/es/index.js +1 -0
- package/dist/es/main.js +1 -0
- package/dist/es/package-metadata.js +1 -1
- package/dist/es/preventable-events/paste-event-data.js +4 -0
- package/dist/es/preventable-events/paste-event.js +25 -0
- package/dist/es/tools/alignment/editor-align-center-button.directive.js +5 -3
- package/dist/es/tools/alignment/editor-align-justify-button.directive.js +5 -3
- package/dist/es/tools/alignment/editor-align-left-button.directive.js +5 -3
- package/dist/es/tools/alignment/editor-align-right-button.directive.js +5 -3
- package/dist/es/tools/editor-clean-formatting-button.directive.js +5 -3
- package/dist/es/tools/fontfamily/editor-fontfamily.component.js +9 -3
- package/dist/es/tools/fontsize/editor-fontsize.component.js +9 -3
- package/dist/es/tools/format/editor-format.component.js +9 -3
- package/dist/es/tools/history/editor-redo-button.directive.js +5 -3
- package/dist/es/tools/history/editor-undo-button.directive.js +5 -3
- package/dist/es/tools/image/editor-insert-image-button.directive.js +5 -3
- package/dist/es/tools/indentation/editor-indent-button.directive.js +5 -3
- package/dist/es/tools/indentation/editor-outdent-button.directive.js +5 -3
- package/dist/es/tools/link/editor-create-link-button.directive.js +5 -3
- package/dist/es/tools/link/editor-insert-file-button.directive.js +5 -3
- package/dist/es/tools/link/editor-unlink-button.directive.js +5 -3
- package/dist/es/tools/list/editor-insert-ordered-list-button.directive.js +5 -3
- package/dist/es/tools/list/editor-insert-unordered-list-button.directive.js +5 -3
- package/dist/es/tools/print/editor-print-button.directive.js +5 -3
- package/dist/es/tools/select-all/select-all-button.directive.js +5 -3
- package/dist/es/tools/shared/editor-command-base.js +3 -1
- package/dist/es/tools/shared/editor-command-button.js +3 -2
- package/dist/es/tools/shared/editor-command-dialog.js +3 -2
- package/dist/es/tools/source/editor-view-source-button.directive.js +5 -3
- package/dist/es/tools/tables/editor-add-column-after-button.directive.js +5 -3
- package/dist/es/tools/tables/editor-add-column-before-button.directive.js +5 -3
- package/dist/es/tools/tables/editor-add-row-after-button.directive.js +5 -3
- package/dist/es/tools/tables/editor-add-row-before-button.directive.js +5 -3
- package/dist/es/tools/tables/editor-delete-column-button.directive.js +5 -3
- package/dist/es/tools/tables/editor-delete-row-button.directive.js +5 -3
- package/dist/es/tools/tables/editor-delete-table-button.directive.js +5 -3
- package/dist/es/tools/tables/editor-merge-cells-button.directive.js +5 -3
- package/dist/es/tools/tables/editor-split-cell-button.directive.js +5 -3
- package/dist/es/tools/tools.service.js +20 -0
- package/dist/es/tools/typographical-emphasis/editor-bold-button.directive.js +5 -3
- package/dist/es/tools/typographical-emphasis/editor-italic-button.directive.js +5 -3
- package/dist/es/tools/typographical-emphasis/editor-strikethrough-button.directive.js +5 -3
- package/dist/es/tools/typographical-emphasis/editor-subscript-button.directive.js +5 -3
- package/dist/es/tools/typographical-emphasis/editor-superscript-button.directive.js +5 -3
- package/dist/es/tools/typographical-emphasis/editor-underline-button.directive.js +5 -3
- package/dist/es2015/common/error-messages.js +3 -2
- package/dist/es2015/common/paste-cleanup-settings.d.ts +14 -0
- package/dist/es2015/editor.component.d.ts +18 -11
- package/dist/es2015/editor.component.js +102 -69
- package/dist/es2015/index.d.ts +1 -0
- package/dist/es2015/index.js +1 -0
- package/dist/es2015/index.metadata.json +1 -1
- package/dist/es2015/main.d.ts +2 -0
- package/dist/es2015/main.js +1 -0
- package/dist/es2015/package-metadata.js +1 -1
- package/dist/es2015/preventable-events/paste-event-data.d.ts +21 -0
- package/dist/es2015/preventable-events/paste-event-data.js +4 -0
- package/dist/es2015/preventable-events/paste-event.d.ts +27 -0
- package/dist/es2015/preventable-events/paste-event.js +20 -0
- package/dist/es2015/tools/alignment/editor-align-center-button.directive.d.ts +2 -1
- package/dist/es2015/tools/alignment/editor-align-center-button.directive.js +5 -3
- package/dist/es2015/tools/alignment/editor-align-justify-button.directive.d.ts +2 -1
- package/dist/es2015/tools/alignment/editor-align-justify-button.directive.js +5 -3
- package/dist/es2015/tools/alignment/editor-align-left-button.directive.d.ts +2 -1
- package/dist/es2015/tools/alignment/editor-align-left-button.directive.js +5 -3
- package/dist/es2015/tools/alignment/editor-align-right-button.directive.d.ts +2 -1
- package/dist/es2015/tools/alignment/editor-align-right-button.directive.js +5 -3
- package/dist/es2015/tools/editor-clean-formatting-button.directive.d.ts +2 -1
- package/dist/es2015/tools/editor-clean-formatting-button.directive.js +5 -3
- package/dist/es2015/tools/fontfamily/editor-fontfamily.component.d.ts +3 -1
- package/dist/es2015/tools/fontfamily/editor-fontfamily.component.js +9 -3
- package/dist/es2015/tools/fontsize/editor-fontsize.component.d.ts +3 -1
- package/dist/es2015/tools/fontsize/editor-fontsize.component.js +9 -3
- package/dist/es2015/tools/format/editor-format.component.d.ts +3 -1
- package/dist/es2015/tools/format/editor-format.component.js +9 -3
- package/dist/es2015/tools/history/editor-redo-button.directive.d.ts +2 -1
- package/dist/es2015/tools/history/editor-redo-button.directive.js +5 -3
- package/dist/es2015/tools/history/editor-undo-button.directive.d.ts +2 -1
- package/dist/es2015/tools/history/editor-undo-button.directive.js +5 -3
- package/dist/es2015/tools/image/editor-insert-image-button.directive.d.ts +2 -1
- package/dist/es2015/tools/image/editor-insert-image-button.directive.js +5 -3
- package/dist/es2015/tools/indentation/editor-indent-button.directive.d.ts +2 -1
- package/dist/es2015/tools/indentation/editor-indent-button.directive.js +5 -3
- package/dist/es2015/tools/indentation/editor-outdent-button.directive.d.ts +2 -1
- package/dist/es2015/tools/indentation/editor-outdent-button.directive.js +5 -3
- package/dist/es2015/tools/link/editor-create-link-button.directive.d.ts +2 -1
- package/dist/es2015/tools/link/editor-create-link-button.directive.js +5 -3
- package/dist/es2015/tools/link/editor-insert-file-button.directive.d.ts +2 -1
- package/dist/es2015/tools/link/editor-insert-file-button.directive.js +5 -3
- package/dist/es2015/tools/link/editor-unlink-button.directive.d.ts +2 -1
- package/dist/es2015/tools/link/editor-unlink-button.directive.js +5 -3
- package/dist/es2015/tools/list/editor-insert-ordered-list-button.directive.d.ts +2 -1
- package/dist/es2015/tools/list/editor-insert-ordered-list-button.directive.js +5 -3
- package/dist/es2015/tools/list/editor-insert-unordered-list-button.directive.d.ts +2 -1
- package/dist/es2015/tools/list/editor-insert-unordered-list-button.directive.js +5 -3
- package/dist/es2015/tools/print/editor-print-button.directive.d.ts +2 -1
- package/dist/es2015/tools/print/editor-print-button.directive.js +5 -3
- package/dist/es2015/tools/select-all/select-all-button.directive.d.ts +2 -1
- package/dist/es2015/tools/select-all/select-all-button.directive.js +5 -3
- package/dist/es2015/tools/shared/editor-command-base.d.ts +3 -1
- package/dist/es2015/tools/shared/editor-command-base.js +3 -1
- package/dist/es2015/tools/shared/editor-command-button.d.ts +3 -1
- package/dist/es2015/tools/shared/editor-command-button.js +3 -2
- package/dist/es2015/tools/shared/editor-command-dialog.d.ts +3 -1
- package/dist/es2015/tools/shared/editor-command-dialog.js +3 -2
- package/dist/es2015/tools/source/editor-view-source-button.directive.d.ts +2 -1
- package/dist/es2015/tools/source/editor-view-source-button.directive.js +5 -3
- package/dist/es2015/tools/tables/editor-add-column-after-button.directive.d.ts +2 -1
- package/dist/es2015/tools/tables/editor-add-column-after-button.directive.js +5 -3
- package/dist/es2015/tools/tables/editor-add-column-before-button.directive.d.ts +2 -1
- package/dist/es2015/tools/tables/editor-add-column-before-button.directive.js +5 -3
- package/dist/es2015/tools/tables/editor-add-row-after-button.directive.d.ts +2 -1
- package/dist/es2015/tools/tables/editor-add-row-after-button.directive.js +5 -3
- package/dist/es2015/tools/tables/editor-add-row-before-button.directive.d.ts +2 -1
- package/dist/es2015/tools/tables/editor-add-row-before-button.directive.js +5 -3
- package/dist/es2015/tools/tables/editor-delete-column-button.directive.d.ts +2 -1
- package/dist/es2015/tools/tables/editor-delete-column-button.directive.js +5 -3
- package/dist/es2015/tools/tables/editor-delete-row-button.directive.d.ts +2 -1
- package/dist/es2015/tools/tables/editor-delete-row-button.directive.js +5 -3
- package/dist/es2015/tools/tables/editor-delete-table-button.directive.d.ts +2 -1
- package/dist/es2015/tools/tables/editor-delete-table-button.directive.js +5 -3
- package/dist/es2015/tools/tables/editor-merge-cells-button.directive.d.ts +2 -1
- package/dist/es2015/tools/tables/editor-merge-cells-button.directive.js +5 -3
- package/dist/es2015/tools/tables/editor-split-cell-button.directive.d.ts +2 -1
- package/dist/es2015/tools/tables/editor-split-cell-button.directive.js +5 -3
- package/dist/es2015/tools/tools.service.d.ts +11 -0
- package/dist/es2015/tools/tools.service.js +22 -0
- package/dist/es2015/tools/typographical-emphasis/editor-bold-button.directive.d.ts +2 -1
- package/dist/es2015/tools/typographical-emphasis/editor-bold-button.directive.js +5 -3
- package/dist/es2015/tools/typographical-emphasis/editor-italic-button.directive.d.ts +2 -1
- package/dist/es2015/tools/typographical-emphasis/editor-italic-button.directive.js +5 -3
- package/dist/es2015/tools/typographical-emphasis/editor-strikethrough-button.directive.d.ts +2 -1
- package/dist/es2015/tools/typographical-emphasis/editor-strikethrough-button.directive.js +5 -3
- package/dist/es2015/tools/typographical-emphasis/editor-subscript-button.directive.d.ts +2 -1
- package/dist/es2015/tools/typographical-emphasis/editor-subscript-button.directive.js +5 -3
- package/dist/es2015/tools/typographical-emphasis/editor-superscript-button.directive.d.ts +2 -1
- package/dist/es2015/tools/typographical-emphasis/editor-superscript-button.directive.js +5 -3
- package/dist/es2015/tools/typographical-emphasis/editor-underline-button.directive.d.ts +2 -1
- package/dist/es2015/tools/typographical-emphasis/editor-underline-button.directive.js +5 -3
- package/dist/fesm2015/index.js +301 -186
- package/dist/fesm5/index.js +302 -186
- package/dist/npm/common/error-messages.js +3 -1
- package/dist/npm/editor.component.js +98 -65
- package/dist/npm/index.js +2 -0
- package/dist/npm/main.js +2 -0
- package/dist/npm/package-metadata.js +1 -1
- package/dist/npm/preventable-events/paste-event-data.js +6 -0
- package/dist/npm/preventable-events/paste-event.js +27 -0
- package/dist/npm/tools/alignment/editor-align-center-button.directive.js +5 -3
- package/dist/npm/tools/alignment/editor-align-justify-button.directive.js +5 -3
- package/dist/npm/tools/alignment/editor-align-left-button.directive.js +5 -3
- package/dist/npm/tools/alignment/editor-align-right-button.directive.js +5 -3
- package/dist/npm/tools/editor-clean-formatting-button.directive.js +5 -3
- package/dist/npm/tools/fontfamily/editor-fontfamily.component.js +9 -3
- package/dist/npm/tools/fontsize/editor-fontsize.component.js +9 -3
- package/dist/npm/tools/format/editor-format.component.js +9 -3
- package/dist/npm/tools/history/editor-redo-button.directive.js +5 -3
- package/dist/npm/tools/history/editor-undo-button.directive.js +5 -3
- package/dist/npm/tools/image/editor-insert-image-button.directive.js +5 -3
- package/dist/npm/tools/indentation/editor-indent-button.directive.js +5 -3
- package/dist/npm/tools/indentation/editor-outdent-button.directive.js +5 -3
- package/dist/npm/tools/link/editor-create-link-button.directive.js +5 -3
- package/dist/npm/tools/link/editor-insert-file-button.directive.js +5 -3
- package/dist/npm/tools/link/editor-unlink-button.directive.js +5 -3
- package/dist/npm/tools/list/editor-insert-ordered-list-button.directive.js +5 -3
- package/dist/npm/tools/list/editor-insert-unordered-list-button.directive.js +5 -3
- package/dist/npm/tools/print/editor-print-button.directive.js +5 -3
- package/dist/npm/tools/select-all/select-all-button.directive.js +5 -3
- package/dist/npm/tools/shared/editor-command-base.js +3 -1
- package/dist/npm/tools/shared/editor-command-button.js +3 -2
- package/dist/npm/tools/shared/editor-command-dialog.js +3 -2
- package/dist/npm/tools/source/editor-view-source-button.directive.js +5 -3
- package/dist/npm/tools/tables/editor-add-column-after-button.directive.js +5 -3
- package/dist/npm/tools/tables/editor-add-column-before-button.directive.js +5 -3
- package/dist/npm/tools/tables/editor-add-row-after-button.directive.js +5 -3
- package/dist/npm/tools/tables/editor-add-row-before-button.directive.js +5 -3
- package/dist/npm/tools/tables/editor-delete-column-button.directive.js +5 -3
- package/dist/npm/tools/tables/editor-delete-row-button.directive.js +5 -3
- package/dist/npm/tools/tables/editor-delete-table-button.directive.js +5 -3
- package/dist/npm/tools/tables/editor-merge-cells-button.directive.js +5 -3
- package/dist/npm/tools/tables/editor-split-cell-button.directive.js +5 -3
- package/dist/npm/tools/tools.service.js +22 -0
- package/dist/npm/tools/typographical-emphasis/editor-bold-button.directive.js +5 -3
- package/dist/npm/tools/typographical-emphasis/editor-italic-button.directive.js +5 -3
- package/dist/npm/tools/typographical-emphasis/editor-strikethrough-button.directive.js +5 -3
- package/dist/npm/tools/typographical-emphasis/editor-subscript-button.directive.js +5 -3
- package/dist/npm/tools/typographical-emphasis/editor-superscript-button.directive.js +5 -3
- package/dist/npm/tools/typographical-emphasis/editor-underline-button.directive.js +5 -3
- package/dist/systemjs/kendo-angular-editor.js +1 -1
- package/package.json +4 -4
|
@@ -6,12 +6,12 @@ import * as tslib_1 from "tslib";
|
|
|
6
6
|
var EditorComponent_1;
|
|
7
7
|
import { Component, HostBinding, ViewChild, ContentChild, ViewContainerRef, Output, ElementRef, EventEmitter, forwardRef, Input, ChangeDetectorRef, NgZone, isDevMode } from '@angular/core';
|
|
8
8
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
9
|
-
import { BehaviorSubject, fromEvent,
|
|
10
|
-
import { map, filter,
|
|
9
|
+
import { BehaviorSubject, fromEvent, Subject, zip } from 'rxjs';
|
|
10
|
+
import { map, filter, take } from 'rxjs/operators';
|
|
11
11
|
import { ToolBarComponent } from '@progress/kendo-angular-toolbar';
|
|
12
12
|
import { DialogService } from '@progress/kendo-angular-dialog';
|
|
13
|
-
import { isDocumentAvailable, KendoInput } from '@progress/kendo-angular-common';
|
|
14
|
-
import { buildKeymap, buildListKeymap,
|
|
13
|
+
import { hasObservers, isDocumentAvailable, KendoInput } from '@progress/kendo-angular-common';
|
|
14
|
+
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';
|
|
15
15
|
import { validatePackage } from '@progress/kendo-licensing';
|
|
16
16
|
import { packageMetadata } from './package-metadata';
|
|
17
17
|
import { schema } from './config/schema';
|
|
@@ -25,15 +25,17 @@ import { L10N_PREFIX, LocalizationService } from '@progress/kendo-angular-l10n';
|
|
|
25
25
|
import { EditorLocalizationService } from './localization/editor-localization.service';
|
|
26
26
|
import { defaultStyle, tablesStyles, rtlStyles } from './common/styles';
|
|
27
27
|
import { EditorErrorMessages } from './common/error-messages';
|
|
28
|
+
import { EditorToolsService } from './tools/tools.service';
|
|
29
|
+
import { EditorPasteEvent } from './preventable-events/paste-event';
|
|
28
30
|
const EMPTY_PARAGRAPH = '<p></p>';
|
|
29
31
|
const defaultPasteCleanupSettings = {
|
|
30
32
|
convertMsLists: false,
|
|
31
33
|
removeAttributes: [],
|
|
32
34
|
removeHtmlComments: false,
|
|
33
|
-
removeInvalidHTML:
|
|
35
|
+
removeInvalidHTML: true,
|
|
34
36
|
removeMsClasses: false,
|
|
35
37
|
removeMsStyles: false,
|
|
36
|
-
stripTags: [
|
|
38
|
+
stripTags: []
|
|
37
39
|
};
|
|
38
40
|
const removeCommentsIf = conditionallyExecute(removeComments);
|
|
39
41
|
const removeInvalidHTMLIf = conditionallyExecute(sanitize);
|
|
@@ -52,12 +54,13 @@ const ɵ0 = getPasteCleanupAttributes;
|
|
|
52
54
|
* Represents the [Kendo UI Editor component for Angular]({% slug overview_editor %}).
|
|
53
55
|
*/
|
|
54
56
|
let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
55
|
-
constructor(dialogService, localization, cdr, ngZone, element) {
|
|
57
|
+
constructor(dialogService, localization, cdr, ngZone, element, toolsService) {
|
|
56
58
|
this.dialogService = dialogService;
|
|
57
59
|
this.localization = localization;
|
|
58
60
|
this.cdr = cdr;
|
|
59
61
|
this.ngZone = ngZone;
|
|
60
62
|
this.element = element;
|
|
63
|
+
this.toolsService = toolsService;
|
|
61
64
|
/**
|
|
62
65
|
* If set to `false`, the Editor will run in style non-encapsulated mode. This means
|
|
63
66
|
* that the styles of the page will be persisted in the Editor and its content will be affected by them.
|
|
@@ -69,14 +72,6 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
69
72
|
* @default false
|
|
70
73
|
*/
|
|
71
74
|
this.applyToWord = false;
|
|
72
|
-
/**
|
|
73
|
-
* By design, the Editor emits `valueChange`, updates the model and the ToolBar state on each keystroke.
|
|
74
|
-
* 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.
|
|
75
|
-
* 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.
|
|
76
|
-
* The specified interval (in milliseconds) should be a positive number.
|
|
77
|
-
* By default the `updateInterval` is set to 100 miliseconds. If set to zero the delay will be disabled entirely.
|
|
78
|
-
*/
|
|
79
|
-
this.updateInterval = 100;
|
|
80
75
|
/**
|
|
81
76
|
* By default, whitespace is collapsed as per HTML's rules.
|
|
82
77
|
* Set to `true` to preserve whitespace, but normalize newlines to spaces.
|
|
@@ -102,6 +97,11 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
102
97
|
* Fires when the content area of the Editor is focused ([see example]({% slug overview_editor %}#toc-events)).
|
|
103
98
|
*/
|
|
104
99
|
this.onFocus = new EventEmitter();
|
|
100
|
+
/**
|
|
101
|
+
* Fires when the user performs paste in the content area of the Editor ([see example]({% slug overview_editor %}#toc-events)).
|
|
102
|
+
* The event is preventable. If you cancel it, the Editor content will not change.
|
|
103
|
+
*/
|
|
104
|
+
this.paste = new EventEmitter();
|
|
105
105
|
/**
|
|
106
106
|
* Fires when the content area of the Editor is blurred ([see example]({% slug overview_editor %}#toc-events)).
|
|
107
107
|
*/
|
|
@@ -117,10 +117,73 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
117
117
|
this.valueModified = new Subject();
|
|
118
118
|
this._readonly = false;
|
|
119
119
|
this._placeholder = '';
|
|
120
|
+
this.inForm = false;
|
|
120
121
|
this.afterViewInit = new Subject();
|
|
121
122
|
this.contentAreaLoaded = new Subject();
|
|
122
|
-
this.
|
|
123
|
+
this.dispatchTransaction = (tr) => {
|
|
124
|
+
const docChanged = tr.docChanged;
|
|
125
|
+
if (docChanged) {
|
|
126
|
+
const doc = tr.doc;
|
|
127
|
+
const html = getHtml({ doc });
|
|
128
|
+
this.trOnChange = tr;
|
|
129
|
+
this.htmlOnChange = html;
|
|
130
|
+
this.ngZone.run(() => {
|
|
131
|
+
this.valueModified.next(html);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
if (!docChanged || this.inForm) {
|
|
135
|
+
this.view.updateState(this.view.state.apply(tr));
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
this.transformPastedHTML = (dirtyHtml) => {
|
|
139
|
+
const pasteCleanupSettings = Object.assign({}, defaultPasteCleanupSettings, this.pasteCleanupSettings);
|
|
140
|
+
const html = pipe(removeInvalidHTMLIf(pasteCleanupSettings.removeInvalidHTML), removeCommentsIf(pasteCleanupSettings.removeHtmlComments))(dirtyHtml);
|
|
141
|
+
const clean = pasteCleanup(html, {
|
|
142
|
+
convertMsLists: pasteCleanupSettings.convertMsLists,
|
|
143
|
+
stripTags: pasteCleanupSettings.stripTags.join('|'),
|
|
144
|
+
attributes: getPasteCleanupAttributes(pasteCleanupSettings)
|
|
145
|
+
});
|
|
146
|
+
if (hasObservers(this.paste)) {
|
|
147
|
+
const event = new EditorPasteEvent(clean, dirtyHtml, this._pasteEvent);
|
|
148
|
+
this.ngZone.run(() => this.paste.emit(event));
|
|
149
|
+
return event.isDefaultPrevented() ? '' : event.cleanedHtml;
|
|
150
|
+
}
|
|
151
|
+
return clean;
|
|
152
|
+
};
|
|
153
|
+
this.changeValue = (value) => {
|
|
154
|
+
const prev = this._value;
|
|
155
|
+
this._value = value;
|
|
156
|
+
if (!this._view) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (this.htmlOnChange === value && this.trOnChange) {
|
|
160
|
+
this.view.updateState(this.view.state.apply(this.trOnChange));
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
if ((prev || '') !== (value || '')) {
|
|
164
|
+
const iframeContentWindowNotPresent = this.iframe && !this.container.element.nativeElement.contentWindow;
|
|
165
|
+
if (iframeContentWindowNotPresent) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const state = this.view.state;
|
|
169
|
+
const nextDoc = parseContent(value || '', state.schema, { preserveWhitespace: this.preserveWhitespace });
|
|
170
|
+
const tr = state.tr
|
|
171
|
+
.setSelection(new AllSelection(state.doc))
|
|
172
|
+
.replaceSelectionWith(nextDoc);
|
|
173
|
+
this.view.updateState(state.apply(tr));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
this.trOnChange = null;
|
|
177
|
+
this.htmlOnChange = null;
|
|
178
|
+
};
|
|
179
|
+
this.onChangeCallback = (value) => {
|
|
180
|
+
this.changeValue(value);
|
|
181
|
+
};
|
|
123
182
|
this.onTouchedCallback = (_) => { }; // tslint:disable-line:no-empty
|
|
183
|
+
this.onPaste = (_view, nativeEvent) => {
|
|
184
|
+
this._pasteEvent = nativeEvent;
|
|
185
|
+
return false;
|
|
186
|
+
};
|
|
124
187
|
validatePackage(packageMetadata);
|
|
125
188
|
this.direction = localization.rtl ? 'rtl' : 'ltr';
|
|
126
189
|
// https://stackoverflow.com/questions/56572483/chrome-is-synchronously-handling-iframe-loading-whereas-firefox-handles-it-asyn
|
|
@@ -130,25 +193,12 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
130
193
|
* Sets the value of the Editor ([see example]({% slug overview_editor %}#toc-basic-usage)).
|
|
131
194
|
*/
|
|
132
195
|
set value(value) {
|
|
133
|
-
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
this._value = value;
|
|
137
|
-
this._previousValue = value;
|
|
138
|
-
if (this._view) {
|
|
139
|
-
const iframeContentWindowNotPresent = this.iframe && !this.container.element.nativeElement.contentWindow;
|
|
140
|
-
if (iframeContentWindowNotPresent) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
this.exec('setHTML', {
|
|
144
|
-
content: this._value || '',
|
|
145
|
-
parseOptions: {
|
|
146
|
-
preserveWhitespace: this.preserveWhitespace
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
196
|
+
this.changeValue(value);
|
|
150
197
|
}
|
|
151
198
|
get value() {
|
|
199
|
+
if (this.trOnChange) {
|
|
200
|
+
return this.htmlOnChange;
|
|
201
|
+
}
|
|
152
202
|
let value = this._view ? this.getSource() : this._value;
|
|
153
203
|
if (value === EMPTY_PARAGRAPH) {
|
|
154
204
|
return this._value ? '' : this._value;
|
|
@@ -326,6 +376,7 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
326
376
|
this.subs.add(this.localization.changes.subscribe(({ rtl }) => {
|
|
327
377
|
this.direction = rtl ? 'rtl' : 'ltr';
|
|
328
378
|
}));
|
|
379
|
+
this.subs.add(this.toolsService.needsCheck.subscribe(() => this.cdr.markForCheck()));
|
|
329
380
|
}
|
|
330
381
|
ngAfterViewInit() {
|
|
331
382
|
this.afterViewInit.next();
|
|
@@ -337,6 +388,9 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
337
388
|
}
|
|
338
389
|
}
|
|
339
390
|
ngOnChanges(changes) {
|
|
391
|
+
if (changes.value && this.view) {
|
|
392
|
+
this.changeValue(changes.value.currentValue);
|
|
393
|
+
}
|
|
340
394
|
if (changes.iframe && !changes.iframe.isFirstChange()) {
|
|
341
395
|
this.ngZone.onStable.pipe(take(1)).subscribe(() => this.initialize());
|
|
342
396
|
}
|
|
@@ -422,8 +476,6 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
422
476
|
const command = editorCommands[commandName](attr);
|
|
423
477
|
// Executes a ProseMirror command.
|
|
424
478
|
command(this._view.state, this._view.dispatch, this._view);
|
|
425
|
-
// See the `dispatchTransaction` comments.
|
|
426
|
-
// this.stateChange.emit(updateToolBar(this.view));
|
|
427
479
|
}
|
|
428
480
|
/**
|
|
429
481
|
* Opens a dialog.
|
|
@@ -508,6 +560,7 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
508
560
|
* @hidden
|
|
509
561
|
*/
|
|
510
562
|
writeValue(value) {
|
|
563
|
+
this.inForm = true;
|
|
511
564
|
// To avoid confusion, non-existent values are always undefined.
|
|
512
565
|
this.value = value === null ? undefined : value;
|
|
513
566
|
}
|
|
@@ -535,7 +588,6 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
535
588
|
return;
|
|
536
589
|
}
|
|
537
590
|
const currentSchema = this.schema || schema;
|
|
538
|
-
const that = this;
|
|
539
591
|
const containerNativeElement = this.container.element.nativeElement;
|
|
540
592
|
const contentNode = parseContent((this.value || '').trim(), currentSchema, { preserveWhitespace: this.preserveWhitespace });
|
|
541
593
|
if (this.iframe) {
|
|
@@ -579,7 +631,7 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
579
631
|
}),
|
|
580
632
|
new Plugin({
|
|
581
633
|
key: new PluginKey('editor-filter-disabled-state'),
|
|
582
|
-
filterTransaction: () => !this.disabled
|
|
634
|
+
filterTransaction: () => !this.disabled || this.inForm
|
|
583
635
|
}),
|
|
584
636
|
history(),
|
|
585
637
|
keymap(buildListKeymap(currentSchema)),
|
|
@@ -606,31 +658,10 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
606
658
|
this._view = new EditorView({ mount: this.viewMountElement }, {
|
|
607
659
|
state,
|
|
608
660
|
editable: () => !this.readonly,
|
|
609
|
-
dispatchTransaction:
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
// When the user utilizes keyboard shortcuts—for example, `Ctrl`+`b`—
|
|
614
|
-
// `tr.docChanged` is `true` and the toolbar is not updated.
|
|
615
|
-
// A possible future solution is to move the keymaps to the service.
|
|
616
|
-
// if (!tr.docChanged) {
|
|
617
|
-
// that.stateChange.emit(updateToolBar(that.view));
|
|
618
|
-
// }
|
|
619
|
-
const value = that.value;
|
|
620
|
-
if (!hasSameMarkup(value, that._previousValue, this.state.schema)) {
|
|
621
|
-
that._previousValue = value;
|
|
622
|
-
that.ngZone.run(() => that.valueModified.next(value));
|
|
623
|
-
}
|
|
624
|
-
},
|
|
625
|
-
transformPastedHTML: (html) => {
|
|
626
|
-
const pasteCleanupSettings = Object.assign({}, defaultPasteCleanupSettings, this.pasteCleanupSettings);
|
|
627
|
-
const clean = pipe(removeCommentsIf(pasteCleanupSettings.removeHtmlComments), removeInvalidHTMLIf(pasteCleanupSettings.removeInvalidHTML))(html);
|
|
628
|
-
const attributes = getPasteCleanupAttributes(pasteCleanupSettings);
|
|
629
|
-
return pasteCleanup(clean, {
|
|
630
|
-
convertMsLists: pasteCleanupSettings.convertMsLists,
|
|
631
|
-
stripTags: pasteCleanupSettings.stripTags.join('|'),
|
|
632
|
-
attributes
|
|
633
|
-
});
|
|
661
|
+
dispatchTransaction: this.dispatchTransaction,
|
|
662
|
+
transformPastedHTML: this.transformPastedHTML,
|
|
663
|
+
handleDOMEvents: {
|
|
664
|
+
paste: this.onPaste
|
|
634
665
|
}
|
|
635
666
|
});
|
|
636
667
|
});
|
|
@@ -671,7 +702,7 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
671
702
|
this.cdr.detectChanges();
|
|
672
703
|
}
|
|
673
704
|
}));
|
|
674
|
-
this.subs.add(
|
|
705
|
+
this.subs.add(this.valueModified.subscribe((value) => {
|
|
675
706
|
this.onChangeCallback(value);
|
|
676
707
|
this.valueChange.emit(value);
|
|
677
708
|
this.cdr.markForCheck();
|
|
@@ -764,10 +795,6 @@ tslib_1.__decorate([
|
|
|
764
795
|
tslib_1.__metadata("design:type", String),
|
|
765
796
|
tslib_1.__metadata("design:paramtypes", [String])
|
|
766
797
|
], EditorComponent.prototype, "placeholder", null);
|
|
767
|
-
tslib_1.__decorate([
|
|
768
|
-
Input(),
|
|
769
|
-
tslib_1.__metadata("design:type", Number)
|
|
770
|
-
], EditorComponent.prototype, "updateInterval", void 0);
|
|
771
798
|
tslib_1.__decorate([
|
|
772
799
|
Input(),
|
|
773
800
|
tslib_1.__metadata("design:type", Object)
|
|
@@ -788,6 +815,10 @@ tslib_1.__decorate([
|
|
|
788
815
|
Output('focus'),
|
|
789
816
|
tslib_1.__metadata("design:type", EventEmitter)
|
|
790
817
|
], EditorComponent.prototype, "onFocus", void 0);
|
|
818
|
+
tslib_1.__decorate([
|
|
819
|
+
Output(),
|
|
820
|
+
tslib_1.__metadata("design:type", EventEmitter)
|
|
821
|
+
], EditorComponent.prototype, "paste", void 0);
|
|
791
822
|
tslib_1.__decorate([
|
|
792
823
|
Output('blur'),
|
|
793
824
|
tslib_1.__metadata("design:type", EventEmitter)
|
|
@@ -875,6 +906,7 @@ EditorComponent = EditorComponent_1 = tslib_1.__decorate([
|
|
|
875
906
|
selector: 'kendo-editor',
|
|
876
907
|
providers: [
|
|
877
908
|
EditorLocalizationService,
|
|
909
|
+
EditorToolsService,
|
|
878
910
|
{
|
|
879
911
|
provide: LocalizationService,
|
|
880
912
|
useExisting: EditorLocalizationService
|
|
@@ -1034,7 +1066,7 @@ EditorComponent = EditorComponent_1 = tslib_1.__decorate([
|
|
|
1034
1066
|
<div *ngIf="!iframe" #content [attr.dir]="direction" class="k-editor-content"></div>
|
|
1035
1067
|
|
|
1036
1068
|
<div class="k-editor-content" *ngIf="iframe">
|
|
1037
|
-
<iframe #content frameborder="0" class="k-iframe" (load)="iframeOnLoad()"></iframe>
|
|
1069
|
+
<iframe #content srcdoc="<!DOCTYPE html>" frameborder="0" class="k-iframe" (load)="iframeOnLoad()"></iframe>
|
|
1038
1070
|
</div>
|
|
1039
1071
|
|
|
1040
1072
|
<ng-container #dialogsContainer></ng-container>
|
|
@@ -1061,7 +1093,8 @@ EditorComponent = EditorComponent_1 = tslib_1.__decorate([
|
|
|
1061
1093
|
LocalizationService,
|
|
1062
1094
|
ChangeDetectorRef,
|
|
1063
1095
|
NgZone,
|
|
1064
|
-
ElementRef
|
|
1096
|
+
ElementRef,
|
|
1097
|
+
EditorToolsService])
|
|
1065
1098
|
], EditorComponent);
|
|
1066
1099
|
export { EditorComponent };
|
|
1067
1100
|
export { ɵ0 };
|
package/dist/es2015/index.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export { EditorInsertTableButtonComponent } from './tools/tables/editor-insert-t
|
|
|
61
61
|
export { EditorMergeCellsButtonDirective } from './tools/tables/editor-merge-cells-button.directive';
|
|
62
62
|
export { EditorSplitCellButtonDirective } from './tools/tables/editor-split-cell-button.directive';
|
|
63
63
|
export { PopupTableGridComponent } from './tools/tables/popup-table-grid.component';
|
|
64
|
+
export { EditorToolsService } from './tools/tools.service';
|
|
64
65
|
export { EditorBoldButtonDirective } from './tools/typographical-emphasis/editor-bold-button.directive';
|
|
65
66
|
export { EditorItalicButtonDirective } from './tools/typographical-emphasis/editor-italic-button.directive';
|
|
66
67
|
export { EditorStrikethroughButtonDirective } from './tools/typographical-emphasis/editor-strikethrough-button.directive';
|
package/dist/es2015/index.js
CHANGED
|
@@ -60,6 +60,7 @@ export { EditorInsertTableButtonComponent } from './tools/tables/editor-insert-t
|
|
|
60
60
|
export { EditorMergeCellsButtonDirective } from './tools/tables/editor-merge-cells-button.directive';
|
|
61
61
|
export { EditorSplitCellButtonDirective } from './tools/tables/editor-split-cell-button.directive';
|
|
62
62
|
export { PopupTableGridComponent } from './tools/tables/popup-table-grid.component';
|
|
63
|
+
export { EditorToolsService } from './tools/tools.service';
|
|
63
64
|
export { EditorBoldButtonDirective } from './tools/typographical-emphasis/editor-bold-button.directive';
|
|
64
65
|
export { EditorItalicButtonDirective } from './tools/typographical-emphasis/editor-italic-button.directive';
|
|
65
66
|
export { EditorStrikethroughButtonDirective } from './tools/typographical-emphasis/editor-strikethrough-button.directive';
|