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

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.
Files changed (55) hide show
  1. package/dist/cdn/js/kendo-angular-editor.js +2 -2
  2. package/dist/cdn/main.js +1 -1
  3. package/dist/es/common/error-messages.js +3 -2
  4. package/dist/es/config/commands.js +2 -2
  5. package/dist/es/config/schema.js +1 -2
  6. package/dist/es/config/table-commands.js +1 -363
  7. package/dist/es/editor.component.js +99 -71
  8. package/dist/es/main.js +1 -0
  9. package/dist/es/package-metadata.js +1 -1
  10. package/dist/{es2015/config/table-nodes.d.ts → es/preventable-events/paste-event-data.js} +0 -5
  11. package/dist/es/preventable-events/paste-event.js +25 -0
  12. package/dist/es2015/common/error-messages.js +3 -2
  13. package/dist/es2015/common/paste-cleanup-settings.d.ts +14 -0
  14. package/dist/es2015/config/commands.js +2 -2
  15. package/dist/es2015/config/schema.js +1 -2
  16. package/dist/es2015/config/table-commands.d.ts +0 -36
  17. package/dist/es2015/config/table-commands.js +1 -357
  18. package/dist/es2015/editor.component.d.ts +15 -10
  19. package/dist/es2015/editor.component.js +99 -71
  20. package/dist/es2015/index.metadata.json +1 -1
  21. package/dist/es2015/main.d.ts +2 -0
  22. package/dist/es2015/main.js +1 -0
  23. package/dist/es2015/package-metadata.js +1 -1
  24. package/dist/es2015/preventable-events/paste-event-data.d.ts +21 -0
  25. package/dist/es2015/preventable-events/paste-event-data.js +4 -0
  26. package/dist/es2015/preventable-events/paste-event.d.ts +27 -0
  27. package/dist/es2015/preventable-events/paste-event.js +20 -0
  28. package/dist/fesm2015/index.js +263 -1596
  29. package/dist/fesm5/index.js +285 -1641
  30. package/dist/npm/common/error-messages.js +3 -1
  31. package/dist/npm/config/commands.js +1 -1
  32. package/dist/npm/config/schema.js +1 -2
  33. package/dist/npm/config/table-commands.js +1 -368
  34. package/dist/npm/editor.component.js +95 -67
  35. package/dist/npm/main.js +2 -0
  36. package/dist/npm/package-metadata.js +1 -1
  37. package/dist/npm/preventable-events/paste-event-data.js +6 -0
  38. package/dist/npm/preventable-events/paste-event.js +27 -0
  39. package/dist/systemjs/kendo-angular-editor.js +1 -1
  40. package/package.json +5 -5
  41. package/dist/es/config/table-nodes.js +0 -146
  42. package/dist/es/config/tables/CellSelection.js +0 -268
  43. package/dist/es/config/tables/TableMap.js +0 -333
  44. package/dist/es/config/tables/table-utils.js +0 -302
  45. package/dist/es2015/config/table-nodes.js +0 -145
  46. package/dist/es2015/config/tables/CellSelection.d.ts +0 -35
  47. package/dist/es2015/config/tables/CellSelection.js +0 -256
  48. package/dist/es2015/config/tables/TableMap.d.ts +0 -35
  49. package/dist/es2015/config/tables/TableMap.js +0 -329
  50. package/dist/es2015/config/tables/table-utils.d.ts +0 -77
  51. package/dist/es2015/config/tables/table-utils.js +0 -299
  52. package/dist/npm/config/table-nodes.js +0 -157
  53. package/dist/npm/config/tables/CellSelection.js +0 -270
  54. package/dist/npm/config/tables/TableMap.js +0 -338
  55. package/dist/npm/config/tables/table-utils.js +0 -307
@@ -5,12 +5,12 @@
5
5
  import { __decorate, __param, __metadata } from 'tslib';
6
6
  import { Inject, Optional, Input, ViewChild, ElementRef, Component, Injectable, EventEmitter, isDevMode, Output, HostBinding, ContentChild, ViewContainerRef, forwardRef, ChangeDetectorRef, NgZone, TemplateRef, Host, Directive, NgModule } from '@angular/core';
7
7
  import { FormControl, Validators, FormGroup, NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms';
8
- import { Subject, BehaviorSubject, zip, fromEvent, merge, interval } from 'rxjs';
9
- import { take, filter, auditTime, map, concatMap, takeUntil } from 'rxjs/operators';
8
+ import { Subject, BehaviorSubject, zip, fromEvent, interval } from 'rxjs';
9
+ import { take, map, filter, concatMap, takeUntil } from 'rxjs/operators';
10
10
  import { ToolBarComponent, ToolBarToolComponent, ToolBarButtonComponent, ToolBarModule } from '@progress/kendo-angular-toolbar';
11
11
  import { DialogContentBase, DialogRef, DialogService, DialogModule } from '@progress/kendo-angular-dialog';
12
- import { isDocumentAvailable, guid, KendoInput, Keys } from '@progress/kendo-angular-common';
13
- import { nodes, Schema, marks, Selection, SelectionRange, TextSelection, Fragment, Slice, NodeSelection, insertNode, expandToWordWrap, toggleInlineFormat, bold, cleanFormatting, applyLink, applyInlineStyle, insertText, italic, strikethrough, subscript, superscript, underline, removeLink, link, selectAll, isAligned, alignCenterRules, alignBlocks, alignRemoveRules, alignJustifyRules, alignLeftRules, alignRightRules, formatBlockElements, getHtml, indent, insertImage, toggleOrderedList, toggleUnorderedList, outdent, redo, setHtml, undo, hasMark, activeNode, canIndentAsListItem, canBeIndented, indentRules, hasNode, canOutdentAsListItem, outdentRules, getActiveMarks, expandSelection, addColumnBefore, addColumnAfter, addRowBefore, addRowAfter, deleteRow, deleteColumn, mergeCells, splitCell, deleteTable, getNodeFromSelection, getMark, getSelectionText, parseContent, Plugin, PluginKey, history, keymap, buildListKeymap, buildKeymap, baseKeymap, gapCursor, imageResizing, placeholder, EditorState, EditorView, hasSameMarkup, pasteCleanup, removeComments, sanitize, removeAttribute, sanitizeStyleAttr, sanitizeClassAttr } from '@progress/kendo-editor-common';
12
+ import { isDocumentAvailable, guid, PreventableEvent, hasObservers, KendoInput, Keys } from '@progress/kendo-angular-common';
13
+ import { nodes, Schema, marks, createTable, insertNode, expandToWordWrap, toggleInlineFormat, bold, cleanFormatting, applyLink, applyInlineStyle, insertText, italic, strikethrough, subscript, superscript, underline, removeLink, link, selectAll, isAligned, alignCenterRules, alignBlocks, alignRemoveRules, alignJustifyRules, alignLeftRules, alignRightRules, formatBlockElements, getHtml, indent, insertImage, toggleOrderedList, toggleUnorderedList, outdent, redo, setHtml, undo, addColumnBefore, addColumnAfter, addRowBefore, addRowAfter, deleteRow, deleteColumn, mergeCells, splitCell, deleteTable, hasMark, activeNode, canIndentAsListItem, canBeIndented, indentRules, hasNode, canOutdentAsListItem, outdentRules, getActiveMarks, expandSelection, getNodeFromSelection, getMark, getSelectionText, pasteCleanup, parseContent, AllSelection, TextSelection, Plugin, PluginKey, history, keymap, buildListKeymap, buildKeymap, baseKeymap, gapCursor, imageResizing, tableEditing, placeholder, EditorState, EditorView, removeComments, sanitize, removeAttribute, sanitizeStyleAttr, sanitizeClassAttr } from '@progress/kendo-editor-common';
14
14
  export { Schema, 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';
15
15
  import { validatePackage } from '@progress/kendo-licensing';
16
16
  import { LocalizationService, L10N_PREFIX, RTL, MessageService, ComponentMessages } from '@progress/kendo-angular-l10n';
@@ -27,7 +27,7 @@ const packageMetadata = {
27
27
  name: '@progress/kendo-angular-editor',
28
28
  productName: 'Kendo UI for Angular',
29
29
  productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
30
- publishDate: 1637941374,
30
+ publishDate: 1641984793,
31
31
  version: '',
32
32
  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'
33
33
  };
@@ -70,1554 +70,77 @@ const getAttributes = (dom) => {
70
70
  /**
71
71
  * @hidden
72
72
  */
73
- const serializeDOMAttrs = (el) => Array.from(el.attributes)
74
- .reduce((acc, curr) => Object.assign({}, acc, { [curr.name]: curr.value }), {});
75
- /**
76
- * @hidden
77
- */
78
- const commonAttributes = () => {
79
- return Object.assign({}, createDefaultAttributes(['class', 'id', 'style']));
80
- };
81
- /**
82
- * @hidden
83
- */
84
- const createDefaultAttributes = (attrs = []) => {
85
- return Object.assign({}, attrs.reduce((acc, curr) => (Object.assign({}, acc, { [curr]: { default: null } })), {}));
86
- };
87
- /**
88
- * @hidden
89
- */
90
- const hole = 0;
91
- /**
92
- * @hidden
93
- */
94
- const isSchemaNode = (schemaNodeName) => (node) => node.type.name === schemaNodeName;
95
- /**
96
- * @hidden
97
- */
98
- const isTable = isSchemaNode('table');
99
- /**
100
- * @hidden
101
- */
102
- const isTableBody = isSchemaNode('table_body');
103
- /**
104
- * @hidden
105
- */
106
- const isTableHead = isSchemaNode('table_head');
107
- /**
108
- * @hidden
109
- */
110
- const isTableFoot = isSchemaNode('table_foot');
111
- /**
112
- * @hidden
113
- */
114
- const isTableRow = isSchemaNode('table_row');
115
- /**
116
- * @hidden
117
- */
118
- const isTableCell = isSchemaNode('table_cell');
119
- /**
120
- * @hidden
121
- */
122
- const isTableHeaderCell = isSchemaNode('table_header');
123
-
124
- const createSemanticNode = (tagName) => ({
125
- // Uncaught SyntaxError: Mixing inline and block content (in content expression '(block | inline)*')
126
- // content: '(block | inline)*',
127
- content: 'block*',
128
- group: 'block',
129
- attrs: Object.assign({}, commonAttributes()),
130
- parseDOM: [{
131
- tag: tagName,
132
- getAttrs: getAttributes
133
- }],
134
- toDOM: node => hasAttrs(node.attrs) ? [tagName, getAttrs(node.attrs), hole] : [tagName, hole]
135
- });
136
- /**
137
- * @hidden
138
- */
139
- const semanticTagNames = ['article', 'main', 'nav', 'header', 'footer', 'aside', 'section'];
140
- const ɵ1 = (acc, curr) => Object.assign(acc, { [curr]: createSemanticNode(curr) });
141
- /**
142
- * @hidden
143
- */
144
- const semanticNodes = semanticTagNames.reduce(ɵ1, {});
145
-
146
- /**
147
- * @hidden
148
- */
149
- function outerWidth(element) {
150
- let width = element.offsetWidth;
151
- const style = getComputedStyle(element);
152
- width += parseFloat(style.marginLeft) || 0 + parseFloat(style.marginRight) || 0;
153
- return width;
154
- }
155
- /**
156
- * @hidden
157
- */
158
- const removeEntries = (obj, predicate) => Object.keys(obj)
159
- .filter(key => predicate(key))
160
- .reduce((acc, curr) => Object.assign(acc, { [curr]: obj[curr] }), {});
161
- /**
162
- * @hidden
163
- */
164
- const removeEmptyEntries = (obj) => {
165
- const predicate = key => obj[key] !== null && obj[key] !== undefined && obj[key] !== '';
166
- return removeEntries(obj, predicate);
167
- };
168
- /**
169
- * @hidden
170
- */
171
- const isNullOrUndefined = (value) => value === undefined || value === null;
172
- /**
173
- * @hidden
174
- */
175
- const isPresent = (value) => !isNullOrUndefined(value);
176
- /**
177
- * @hidden
178
- */
179
- const detectIE = () => {
180
- if (!isDocumentAvailable()) {
181
- return false;
182
- }
183
- const ua = window.navigator.userAgent;
184
- const msie = ua.indexOf('MSIE ');
185
- const trident = ua.indexOf('Trident/');
186
- return msie > 0 || trident > 0;
187
- };
188
- /**
189
- * @hidden
190
- */
191
- const safeString = (value) => (isNullOrUndefined(value) ? '' : value.toString());
192
- /**
193
- * @hidden
194
- */
195
- const first = (arr) => arr[0];
196
- /**
197
- * @hidden
198
- */
199
- const last = (arr) => arr[arr.length - 1];
200
- /**
201
- * @hidden
202
- */
203
- const split = (splitter) => (value) => value.split(splitter);
204
- /**
205
- * @hidden
206
- */
207
- const trim = (value) => value.trim();
208
- /**
209
- * @hidden
210
- */
211
- const filter$1 = (predicate) => (arr) => arr.filter(predicate);
212
- /**
213
- * @hidden
214
- */
215
- const getUniqueStyleValues = (style, cssStyle) => {
216
- if (style.hasNodesWithoutMarks) {
217
- return '';
218
- }
219
- const uniqueMarkValues = style.marks
220
- .filter(m => m.type.name === 'style')
221
- .map(m => m.attrs.style)
222
- .map(safeString)
223
- .map(split(';'))
224
- .map(filter$1((m) => m.includes(cssStyle)))
225
- // guards against empty array
226
- .map((cssStyleValues) => (cssStyleValues.length !== 0 ? cssStyleValues : [`${cssStyle}: INVALID`]))
227
- .map(first)
228
- .map(split(':'))
229
- .map(last)
230
- .map(trim)
231
- .reduce((acc, curr) => (acc.indexOf(curr) > -1 ? acc : [...acc, curr]), []);
232
- if (uniqueMarkValues.indexOf('INVALID') > -1 || uniqueMarkValues.length !== 1) {
233
- return '';
234
- }
235
- return uniqueMarkValues[0];
236
- };
237
- /**
238
- * @hidden
239
- */
240
- const conditionallyExecute = (fn) => (condition) => (param) => (condition ? fn(param) : param);
241
- /**
242
- * @hidden
243
- */
244
- const pipe = (...fns) => x => fns.reduce((y, f) => f(y), x);
245
-
246
- const setCellAttrs = nodeAttributes => {
247
- let attrs = Object.assign({}, nodeAttributes);
248
- if (nodeAttributes.colspan !== 1) {
249
- attrs.colspan = nodeAttributes.colspan;
250
- }
251
- else {
252
- attrs.colspan = null;
253
- }
254
- if (nodeAttributes.rowspan !== 1) {
255
- attrs.rowspan = nodeAttributes.rowspan;
256
- }
257
- else {
258
- attrs.rowspan = null;
259
- }
260
- return removeEmptyEntries(attrs);
261
- };
262
- const ɵ1$1 = node => ['table', removeEmptyEntries(node.attrs), 0], ɵ2 = node => ['tr', removeEmptyEntries(node.attrs), 0], ɵ3 = node => ['td', setCellAttrs(node.attrs), 0], ɵ4 = node => ['th', setCellAttrs(node.attrs), 0], ɵ5 = node => ['tbody', removeEmptyEntries(node.attrs), 0], ɵ6 = node => ['tfoot', removeEmptyEntries(node.attrs), 0], ɵ7 = node => ['thead', removeEmptyEntries(node.attrs), 0], ɵ8 = node => ['col', removeEmptyEntries(node.attrs)], ɵ9 = node => ['colgroup', removeEmptyEntries(node.attrs), 0];
263
- /**
264
- * @hidden
265
- */
266
- const tableNodes = {
267
- // all table node names must start with table - this is needed for the commands to work properly
268
- table: {
269
- attrs: Object.assign({}, commonAttributes(), createDefaultAttributes(['cellspacing', 'cellpadding'])),
270
- content: '(table_body | table_head | table_foot | table_colgroup)+',
271
- tableRole: 'table',
272
- isolating: true,
273
- group: 'block',
274
- parseDOM: [
275
- {
276
- getAttrs: serializeDOMAttrs,
277
- tag: 'table'
278
- }
279
- ],
280
- toDOM: ɵ1$1
281
- },
282
- table_row: {
283
- content: '(table_cell | table_header)*',
284
- attrs: Object.assign({}, commonAttributes()),
285
- tableRole: 'row',
286
- parseDOM: [
287
- {
288
- getAttrs: serializeDOMAttrs,
289
- tag: 'tr'
290
- }
291
- ],
292
- toDOM: ɵ2
293
- },
294
- table_cell: {
295
- content: 'block+',
296
- attrs: Object.assign({}, commonAttributes(), createDefaultAttributes(['headers']), {
297
- // this is needed for the commands
298
- colspan: { default: 1 }, rowspan: { default: 1 } }),
299
- tableRole: 'cell',
300
- isolating: true,
301
- parseDOM: [
302
- {
303
- getAttrs: serializeDOMAttrs,
304
- tag: 'td'
305
- }
306
- ],
307
- toDOM: ɵ3
308
- },
309
- table_header: {
310
- content: 'block+',
311
- attrs: Object.assign({}, commonAttributes(), createDefaultAttributes(['headers', 'abbr', 'scope']), { colspan: { default: 1 }, rowspan: { default: 1 } }),
312
- tableRole: 'header_cell',
313
- isolating: true,
314
- parseDOM: [
315
- {
316
- getAttrs: serializeDOMAttrs,
317
- tag: 'th'
318
- }
319
- ],
320
- toDOM: ɵ4
321
- },
322
- table_body: {
323
- attrs: Object.assign({}, commonAttributes()),
324
- content: 'table_row+',
325
- isolating: true,
326
- parseDOM: [
327
- {
328
- getAttrs: serializeDOMAttrs,
329
- tag: 'tbody'
330
- }
331
- ],
332
- toDOM: ɵ5
333
- },
334
- table_foot: {
335
- attrs: Object.assign({}, commonAttributes()),
336
- content: 'table_row+',
337
- isolating: true,
338
- parseDOM: [
339
- {
340
- getAttrs: serializeDOMAttrs,
341
- tag: 'tfoot'
342
- }
343
- ],
344
- toDOM: ɵ6
345
- },
346
- table_head: {
347
- attrs: Object.assign({}, commonAttributes()),
348
- content: 'table_row+',
349
- isolating: true,
350
- parseDOM: [
351
- {
352
- getAttrs: serializeDOMAttrs,
353
- tag: 'thead'
354
- }
355
- ],
356
- toDOM: ɵ7
357
- },
358
- table_col: {
359
- attrs: Object.assign({}, commonAttributes(), createDefaultAttributes(['span'])),
360
- selectable: false,
361
- atom: true,
362
- parseDOM: [
363
- {
364
- getAttrs: serializeDOMAttrs,
365
- tag: 'col'
366
- }
367
- ],
368
- toDOM: ɵ8
369
- },
370
- table_colgroup: {
371
- attrs: Object.assign({}, commonAttributes(), createDefaultAttributes(['span'])),
372
- content: 'table_col*',
373
- selectable: false,
374
- parseDOM: [
375
- {
376
- getAttrs: serializeDOMAttrs,
377
- tag: 'colgroup'
378
- }
379
- ],
380
- toDOM: ɵ9
381
- }
382
- };
383
-
384
- /**
385
- * @hidden
386
- */
387
- const marks$1 = marks;
388
- const nodes$1 = Object.assign(nodes, tableNodes, semanticNodes);
389
- /**
390
- * @hidden
391
- */
392
- const schema = new Schema({
393
- marks: marks$1,
394
- nodes: Object.assign({}, nodes$1, { blockquote: Object.assign({}, nodes$1.blockquote, { content: 'inline*' }) })
395
- });
396
-
397
- // Because working with row and column-spanning cells is not quite
398
- // trivial, this code builds up a descriptive structure for a given
399
- // table node. The structures are cached with the (persistent) table
400
- // nodes as key, so that they only have to be recomputed when the
401
- // content of the table changes.
402
- //
403
- // This does mean that they have to store table-relative, not
404
- // document-relative positions. So code that uses them will typically
405
- // compute the start position of the table and offset positions passed
406
- // to or gotten from this structure by that amount.
407
- let readFromCache;
408
- let addToCache;
409
- // Prefer using a weak map to cache table maps. Fall back on a
410
- // fixed-size cache if that's not supported.
411
- if (typeof WeakMap !== 'undefined') {
412
- let cache = new WeakMap();
413
- readFromCache = key => cache.get(key);
414
- addToCache = (key, value) => {
415
- cache.set(key, value);
416
- return value;
417
- };
418
- }
419
- else {
420
- let cache = [];
421
- let cacheSize = 10;
422
- let cachePos = 0;
423
- readFromCache = key => {
424
- for (let i = 0; i < cache.length; i += 2) {
425
- if (cache[i] === key) {
426
- return cache[i + 1];
427
- }
428
- }
429
- };
430
- addToCache = (key, value) => {
431
- if (cachePos === cacheSize) {
432
- cachePos = 0;
433
- }
434
- cache[cachePos++] = key;
435
- return (cache[cachePos++] = value);
436
- };
437
- }
438
- const findWidth = (table) => {
439
- let width = -1;
440
- let hasRowSpan = false;
441
- for (let row = 0; row < table.childCount; row++) {
442
- const rowNode = table.child(row);
443
- let rowWidth = 0;
444
- if (hasRowSpan) {
445
- for (let j = 0; j < row; j++) {
446
- const prevRow = table.child(j);
447
- for (let i = 0; i < prevRow.childCount; i++) {
448
- const cell = prevRow.child(i);
449
- if (j + cell.attrs.rowspan > row) {
450
- rowWidth += cell.attrs.colspan;
451
- }
452
- }
453
- }
454
- }
455
- // check if the cell spans accross multiple columns
456
- for (let i = 0; i < rowNode.childCount; i++) {
457
- const cell = rowNode.child(i);
458
- rowWidth += cell.attrs.colspan;
459
- if (cell.attrs.rowspan > 1) {
460
- hasRowSpan = true;
461
- }
462
- }
463
- if (width === -1) {
464
- width = rowWidth;
465
- }
466
- else if (width !== rowWidth) {
467
- width = Math.max(width, rowWidth);
468
- }
469
- }
470
- return width;
471
- };
472
- const freshColWidth = attrs => {
473
- if (attrs.colwidth) {
474
- return attrs.colwidth.slice();
475
- }
476
- const result = [];
477
- for (let i = 0; i < attrs.colspan; i++) {
478
- result.push(0);
479
- }
480
- return result;
481
- };
482
- const findBadColWidths = (map$$1, colWidths, table) => {
483
- if (!map$$1.problems) {
484
- map$$1.problems = [];
485
- }
486
- for (let i = 0, seen = {}; i < map$$1.map.length; i++) {
487
- const pos = map$$1.map[i];
488
- if (seen[pos]) {
489
- continue;
490
- }
491
- seen[pos] = true;
492
- let node = table.nodeAt(pos);
493
- let updated = null;
494
- for (let j = 0; j < node.attrs.colspan; j++) {
495
- const col = (i + j) % map$$1.width;
496
- const colWidth = colWidths[col * 2];
497
- if (colWidth != null && (!node.attrs.colwidth || node.attrs.colwidth[j] !== colWidth)) {
498
- (updated || (updated = freshColWidth(node.attrs)))[j] = colWidth;
499
- }
500
- }
501
- if (updated) {
502
- map$$1.problems.unshift({ type: 'colwidth mismatch', pos, colwidth: updated });
503
- }
504
- }
505
- };
506
- // Compute a table map.
507
- const computeMap = tableNode => {
508
- if (!isTable(tableNode) && !isTableBody(tableNode) && !isTableHead(tableNode) && !isTableFoot(tableNode)) {
509
- throw new RangeError('Not a table node: ' + tableNode.type.name);
510
- }
511
- const width = findWidth(tableNode);
512
- const height = tableNode.childCount;
513
- const map$$1 = [];
514
- let mapPos = 0;
515
- let problems = null;
516
- const colWidths = [];
517
- for (let i = 0, e = width * height; i < e; i++) {
518
- map$$1[i] = 0;
519
- }
520
- for (let row = 0, pos = 0; row < height; row++) {
521
- const rowNode = tableNode.child(row);
522
- pos++;
523
- for (let i = 0;; i++) {
524
- while (mapPos < map$$1.length && map$$1[mapPos] !== 0) {
525
- mapPos++;
526
- }
527
- if (i === rowNode.childCount) {
528
- break;
529
- }
530
- const cellNode = rowNode.child(i);
531
- const { colspan, rowspan, colwidth } = cellNode.attrs;
532
- for (let h = 0; h < rowspan; h++) {
533
- if (h + row >= height) {
534
- (problems || (problems = [])).push({ type: 'overlong_rowspan', pos, n: rowspan - h });
535
- break;
536
- }
537
- const start = mapPos + h * width;
538
- for (let w = 0; w < colspan; w++) {
539
- if (map$$1[start + w] === 0) {
540
- map$$1[start + w] = pos;
541
- }
542
- else {
543
- (problems || (problems = [])).push({ type: 'collision', row, pos, n: colspan - w });
544
- }
545
- const colW = colwidth && colwidth[w];
546
- if (colW) {
547
- const widthIndex = ((start + w) % width) * 2, prev = colWidths[widthIndex];
548
- if (prev == null || (prev !== colW && colWidths[widthIndex + 1] === 1)) {
549
- colWidths[widthIndex] = colW;
550
- colWidths[widthIndex + 1] = 1;
551
- }
552
- else if (prev === colW) {
553
- colWidths[widthIndex + 1]++;
554
- }
555
- }
556
- }
557
- }
558
- mapPos += colspan;
559
- pos += cellNode.nodeSize;
560
- }
561
- const expectedPos = (row + 1) * width;
562
- let missing = 0;
563
- while (mapPos < expectedPos) {
564
- if (map$$1[mapPos++] === 0) {
565
- missing++;
566
- }
567
- }
568
- if (missing) {
569
- (problems || (problems = [])).push({ type: 'missing', row, n: missing });
570
- }
571
- pos++;
572
- }
573
- const tableMap = new TableMap(width, height, map$$1, problems);
574
- let badWidths = false;
575
- // For columns that have defined widths, but whose widths disagree
576
- // between rows, fix up the cells whose width doesn't match the
577
- // computed one.
578
- for (let i = 0; !badWidths && i < colWidths.length; i += 2) {
579
- if (colWidths[i] != null && colWidths[i + 1] < height) {
580
- badWidths = true;
581
- }
582
- }
583
- if (badWidths) {
584
- findBadColWidths(tableMap, colWidths, tableNode);
585
- }
586
- return tableMap;
587
- };
588
- /**
589
- * @hidden
590
- */
591
- class Rect {
592
- constructor(left, top, right, bottom) {
593
- this.left = left;
594
- this.top = top;
595
- this.right = right;
596
- this.bottom = bottom;
597
- }
598
- }
599
- /**
600
- * @hidden
601
- */
602
- class TableMap {
603
- // :: (Node) → TableMap
604
- // Find the table map for the given table node.
605
- static get(table) {
606
- return readFromCache(table) || addToCache(table, computeMap(table));
607
- }
608
- constructor(width, height, map$$1, problems) {
609
- // :: number The width of the table
610
- this.width = width;
611
- // :: number The table's height
612
- this.height = height;
613
- // :: [number] A width * height array with the start position of
614
- // the cell covering that part of the table in each slot
615
- this.map = map$$1;
616
- // An optional array of problems (cell overlap or non-rectangular
617
- // shape) for the table, used by the table normalizer.
618
- this.problems = problems;
619
- }
620
- // :: (number) → Rect
621
- // Find the dimensions of the cell at the given position.
622
- findCell(pos) {
623
- for (let i = 0; i < this.map.length; i++) {
624
- const curPos = this.map[i];
625
- if (curPos !== pos) {
626
- continue;
627
- }
628
- const left = i % this.width;
629
- const top = Math.floor(i / this.width);
630
- let right = left + 1;
631
- let bottom = top + 1;
632
- for (let j = 1; right < this.width && this.map[i + j] === curPos; j++) {
633
- right++;
634
- }
635
- for (let j = 1; bottom < this.height && this.map[i + this.width * j] === curPos; j++) {
636
- bottom++;
637
- }
638
- return new Rect(left, top, right, bottom);
639
- }
640
- throw new RangeError('No cell with offset ' + pos + ' found');
641
- }
642
- // :: (number) → number
643
- // Find the left side of the cell at the given position.
644
- colCount(pos) {
645
- for (let i = 0; i < this.map.length; i++) {
646
- if (this.map[i] === pos) {
647
- return i % this.width;
648
- }
649
- }
650
- throw new RangeError('No cell with offset ' + pos + ' found');
651
- }
652
- // :: (number, string, number) → ?number
653
- // Find the next cell in the given direction, starting from the cell
654
- // at `pos`, if any.
655
- nextCell(pos, axis, dir) {
656
- const { left, right, top, bottom } = this.findCell(pos);
657
- if (axis === 'horiz') {
658
- if (dir < 0 ? left === 0 : right === this.width) {
659
- return null;
660
- }
661
- return this.map[top * this.width + (dir < 0 ? left - 1 : right)];
662
- }
663
- else {
664
- if (dir < 0 ? top === 0 : bottom === this.height) {
665
- return null;
666
- }
667
- return this.map[left + this.width * (dir < 0 ? top - 1 : bottom)];
668
- }
669
- }
670
- // :: (number, number) → Rect
671
- // Get the rectangle spanning the two given cells.
672
- rectBetween(a, b) {
673
- const { left: leftA, right: rightA, top: topA, bottom: bottomA } = this.findCell(a);
674
- const { left: leftB, right: rightB, top: topB, bottom: bottomB } = this.findCell(b);
675
- return new Rect(Math.min(leftA, leftB), Math.min(topA, topB), Math.max(rightA, rightB), Math.max(bottomA, bottomB));
676
- }
677
- // :: (Rect) → [number]
678
- // Return the position of all cells that have the top left corner in
679
- // the given rectangle.
680
- cellsInRect(rect) {
681
- const result = [];
682
- const seen = {};
683
- for (let row = rect.top; row < rect.bottom; row++) {
684
- for (let col = rect.left; col < rect.right; col++) {
685
- const index = row * this.width + col, pos = this.map[index];
686
- if (seen[pos]) {
687
- continue;
688
- }
689
- seen[pos] = true;
690
- if ((col !== rect.left || !col || this.map[index - 1] !== pos) &&
691
- (row !== rect.top || !row || this.map[index - this.width] !== pos)) {
692
- result.push(pos);
693
- }
694
- }
695
- }
696
- return result;
697
- }
698
- // :: (number, number, Node) → number
699
- // Return the position at which the cell at the given row and column
700
- // starts, or would start, if a cell started there.
701
- positionAt(row, col, table) {
702
- for (let i = 0, rowStart = 0;; i++) {
703
- const rowEnd = rowStart + table.child(i).nodeSize;
704
- if (i === row) {
705
- let index = col + row * this.width, rowEndIndex = (row + 1) * this.width;
706
- // Skip past cells from previous rows (via rowspan)
707
- while (index < rowEndIndex && this.map[index] < rowStart) {
708
- index++;
709
- }
710
- return index === rowEndIndex ? rowEnd - 1 : this.map[index];
711
- }
712
- rowStart = rowEnd;
713
- }
714
- }
715
- }
716
-
717
- /**
718
- * @hidden
719
- */
720
- // ::- A [`Selection`](http://prosemirror.net/docs/ref/#state.Selection)
721
- // subclass that represents a cell selection spanning part of a table.
722
- // With the plugin enabled, these will be created when the user
723
- // selects across cells, and will be drawn by giving selected cells a
724
- // `selectedCell` CSS class.
725
- class CellSelection extends Selection {
726
- // :: (ResolvedPos, ?ResolvedPos) → CellSelection
727
- // Returns the smallest column selection that covers the given anchor
728
- // and head cell.
729
- static colSelection($anchorCell, $headCell = $anchorCell) {
730
- let map$$1 = TableMap.get($anchorCell.node(-1));
731
- let start = $anchorCell.start(-1);
732
- let anchorRect = map$$1.findCell($anchorCell.pos - start);
733
- let headRect = map$$1.findCell($headCell.pos - start);
734
- let doc = $anchorCell.node(0);
735
- if (anchorRect.top <= headRect.top) {
736
- if (anchorRect.top > 0) {
737
- $anchorCell = doc.resolve(start + map$$1.map[anchorRect.left]);
738
- }
739
- if (headRect.bottom < map$$1.height) {
740
- $headCell = doc.resolve(start + map$$1.map[map$$1.width * (map$$1.height - 1) + headRect.right - 1]);
741
- }
742
- }
743
- else {
744
- if (headRect.top > 0) {
745
- $headCell = doc.resolve(start + map$$1.map[headRect.left]);
746
- }
747
- if (anchorRect.bottom < map$$1.height) {
748
- $anchorCell = doc.resolve(start + map$$1.map[map$$1.width * (map$$1.height - 1) + anchorRect.right - 1]);
749
- }
750
- }
751
- return new CellSelection($anchorCell, $headCell);
752
- }
753
- // :: (ResolvedPos, ?ResolvedPos) → CellSelection
754
- // Returns the smallest row selection that covers the given anchor
755
- // and head cell.
756
- static rowSelection($anchorCell, $headCell = $anchorCell) {
757
- let map$$1 = TableMap.get($anchorCell.node(-1));
758
- let start = $anchorCell.start(-1);
759
- let anchorRect = map$$1.findCell($anchorCell.pos - start);
760
- let headRect = map$$1.findCell($headCell.pos - start);
761
- let doc = $anchorCell.node(0);
762
- if (anchorRect.left <= headRect.left) {
763
- if (anchorRect.left > 0) {
764
- $anchorCell = doc.resolve(start + map$$1.map[anchorRect.top * map$$1.width]);
765
- }
766
- if (headRect.right < map$$1.width) {
767
- $headCell = doc.resolve(start + map$$1.map[map$$1.width * (headRect.top + 1) - 1]);
768
- }
769
- }
770
- else {
771
- if (headRect.left > 0) {
772
- $headCell = doc.resolve(start + map$$1.map[headRect.top * map$$1.width]);
773
- }
774
- if (anchorRect.right < map$$1.width) {
775
- $anchorCell = doc.resolve(start + map$$1.map[map$$1.width * (anchorRect.top + 1) - 1]);
776
- }
777
- }
778
- return new CellSelection($anchorCell, $headCell);
779
- }
780
- static fromJSON(doc, json) {
781
- return new CellSelection(doc.resolve(json.anchor), doc.resolve(json.head));
782
- }
783
- // :: (Node, number, ?number) → CellSelection
784
- static create(doc, anchorCell, headCell = anchorCell) {
785
- return new CellSelection(doc.resolve(anchorCell), doc.resolve(headCell));
786
- }
787
- // :: (ResolvedPos, ?ResolvedPos)
788
- // A table selection is identified by its anchor and head cells. The
789
- // positions given to this constructor should point _before_ two
790
- // cells in the same table. They may be the same, to select a single
791
- // cell.
792
- constructor($anchorCell, $headCell = $anchorCell) {
793
- let table = $anchorCell.node(-1), map$$1 = TableMap.get(table), start = $anchorCell.start(-1);
794
- let rect = map$$1.rectBetween($anchorCell.pos - start, $headCell.pos - start);
795
- let doc = $anchorCell.node(0);
796
- let cells = map$$1.cellsInRect(rect).filter(p => p !== $headCell.pos - start);
797
- // Make the head cell the first range, so that it counts as the
798
- // primary part of the selection
799
- cells.unshift($headCell.pos - start);
800
- let ranges = cells.map(pos => {
801
- let cell = table.nodeAt(pos), from = pos + start + 1;
802
- return new SelectionRange(doc.resolve(from), doc.resolve(from + cell.content.size));
803
- });
804
- super(ranges[0].$from, ranges[0].$to, ranges);
805
- // :: ResolvedPos
806
- // A resolved position pointing _in front of_ the anchor cell (the one
807
- // that doesn't move when extending the selection).
808
- this.$anchorCell = $anchorCell;
809
- // :: ResolvedPos
810
- // A resolved position pointing in front of the head cell (the one
811
- // moves when extending the selection).
812
- this.$headCell = $headCell;
813
- }
814
- map(doc, mapping) {
815
- let $anchorCell = doc.resolve(mapping.map(this.$anchorCell.pos));
816
- let $headCell = doc.resolve(mapping.map(this.$headCell.pos));
817
- if (pointsAtCell($anchorCell) && pointsAtCell($headCell) && inSameTable($anchorCell, $headCell)) {
818
- let tableChanged = this.$anchorCell.node(-1) !== $anchorCell.node(-1);
819
- if (tableChanged && this.isRowSelection()) {
820
- return CellSelection.rowSelection($anchorCell, $headCell);
821
- }
822
- else {
823
- if (tableChanged && this.isColSelection()) {
824
- return CellSelection.colSelection($anchorCell, $headCell);
825
- }
826
- else {
827
- return new CellSelection($anchorCell, $headCell);
828
- }
829
- }
830
- }
831
- return TextSelection.between($anchorCell, $headCell);
832
- }
833
- // :: () → Slice
834
- // Returns a rectangular slice of table rows containing the selected
835
- // cells.
836
- content() {
837
- let table = this.$anchorCell.node(-1), map$$1 = TableMap.get(table), start = this.$anchorCell.start(-1);
838
- let rect = map$$1.rectBetween(this.$anchorCell.pos - start, this.$headCell.pos - start);
839
- let seen = {}, rows = [];
840
- for (let row = rect.top; row < rect.bottom; row++) {
841
- let rowContent = [];
842
- for (let index = row * map$$1.width + rect.left, col = rect.left; col < rect.right; col++, index++) {
843
- let pos = map$$1.map[index];
844
- if (!seen[pos]) {
845
- seen[pos] = true;
846
- let cellRect = map$$1.findCell(pos), cell = table.nodeAt(pos);
847
- let extraLeft = rect.left - cellRect.left, extraRight = cellRect.right - rect.right;
848
- if (extraLeft > 0 || extraRight > 0) {
849
- let attrs = cell.attrs;
850
- if (extraLeft > 0) {
851
- attrs = removeColSpan(attrs, 0, extraLeft);
852
- }
853
- if (extraRight > 0) {
854
- attrs = removeColSpan(attrs, attrs.colspan - extraRight, extraRight);
855
- }
856
- if (cellRect.left < rect.left) {
857
- cell = cell.type.createAndFill(attrs);
858
- }
859
- else {
860
- cell = cell.type.create(attrs, cell.content);
861
- }
862
- }
863
- if (cellRect.top < rect.top || cellRect.bottom > rect.bottom) {
864
- let attrs = setAttr(cell.attrs, 'rowspan', Math.min(cellRect.bottom, rect.bottom) - Math.max(cellRect.top, rect.top));
865
- if (cellRect.top < rect.top) {
866
- cell = cell.type.createAndFill(attrs);
867
- }
868
- else {
869
- cell = cell.type.create(attrs, cell.content);
870
- }
871
- }
872
- rowContent.push(cell);
873
- }
874
- }
875
- rows.push(table.child(row).copy(Fragment.from(rowContent)));
876
- }
877
- const fragment = this.isColSelection() && this.isRowSelection() ? table : rows;
878
- return new Slice(Fragment.from(fragment), 1, 1);
879
- }
880
- replace(tr, content = Slice.empty) {
881
- let mapFrom = tr.steps.length;
882
- let ranges = this.ranges;
883
- for (let i = 0; i < ranges.length; i++) {
884
- let { $from, $to } = ranges[i];
885
- let mapping = tr.mapping.slice(mapFrom);
886
- tr.replace(mapping.map($from.pos), mapping.map($to.pos), i ? Slice.empty : content);
887
- }
888
- let sel = Selection.findFrom(tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)), -1);
889
- if (sel) {
890
- tr.setSelection(sel);
891
- }
892
- }
893
- replaceWith(tr, node) {
894
- this.replace(tr, new Slice(Fragment.from(node), 0, 0));
895
- }
896
- forEachCell(f) {
897
- let table = this.$anchorCell.node(-1);
898
- let map$$1 = TableMap.get(table);
899
- let start = this.$anchorCell.start(-1);
900
- let cells = map$$1.cellsInRect(map$$1.rectBetween(this.$anchorCell.pos - start, this.$headCell.pos - start));
901
- for (let i = 0; i < cells.length; i++) {
902
- f(table.nodeAt(cells[i]), start + cells[i]);
903
- }
904
- }
905
- // :: () → bool
906
- // True if this selection goes all the way from the top to the
907
- // bottom of the table.
908
- isColSelection() {
909
- let anchorTop = this.$anchorCell.index(-1), headTop = this.$headCell.index(-1);
910
- if (Math.min(anchorTop, headTop) > 0) {
911
- return false;
912
- }
913
- let anchorBot = anchorTop + this.$anchorCell.nodeAfter.attrs.rowspan;
914
- let headBot = headTop + this.$headCell.nodeAfter.attrs.rowspan;
915
- return Math.max(anchorBot, headBot) === this.$headCell.node(-1).childCount;
916
- }
917
- // :: () → bool
918
- // True if this selection goes all the way from the left to the
919
- // right of the table.
920
- isRowSelection() {
921
- let map$$1 = TableMap.get(this.$anchorCell.node(-1));
922
- let start = this.$anchorCell.start(-1);
923
- let anchorLeft = map$$1.colCount(this.$anchorCell.pos - start);
924
- let headLeft = map$$1.colCount(this.$headCell.pos - start);
925
- if (Math.min(anchorLeft, headLeft) > 0) {
926
- return false;
927
- }
928
- let anchorRight = anchorLeft + this.$anchorCell.nodeAfter.attrs.colspan;
929
- let headRight = headLeft + this.$headCell.nodeAfter.attrs.colspan;
930
- return Math.max(anchorRight, headRight) === map$$1.width;
931
- }
932
- eq(other) {
933
- return (other instanceof CellSelection && other.$anchorCell.pos === this.$anchorCell.pos && other.$headCell.pos === this.$headCell.pos);
934
- }
935
- toJSON() {
936
- return { type: 'cell', anchor: this.$anchorCell.pos, head: this.$headCell.pos };
937
- }
938
- getBookmark() {
939
- return new CellBookmark(this.$anchorCell.pos, this.$headCell.pos);
940
- }
941
- }
942
- CellSelection.prototype.visible = false;
943
- Selection.jsonID('table_cell', CellSelection);
944
- class CellBookmark {
945
- constructor(anchor, head) {
946
- this.anchor = anchor;
947
- this.head = head;
948
- }
949
- map(mapping) {
950
- return new CellBookmark(mapping.map(this.anchor), mapping.map(this.head));
951
- }
952
- resolve(doc) {
953
- let $anchorCell = doc.resolve(this.anchor), $headCell = doc.resolve(this.head);
954
- if ($anchorCell.parent.type.spec.tableRole === 'row' &&
955
- $headCell.parent.type.spec.tableRole === 'row' &&
956
- $anchorCell.index() < $anchorCell.parent.childCount &&
957
- $headCell.index() < $headCell.parent.childCount &&
958
- inSameTable($anchorCell, $headCell)) {
959
- return new CellSelection($anchorCell, $headCell);
960
- }
961
- else {
962
- return Selection.near($headCell, 1);
963
- }
964
- }
965
- }
966
-
967
- /**
968
- * @hidden
969
- */
970
- const findParentNodeClosestToPos = ($pos, predicate) => {
971
- for (let i = $pos.depth; i > 0; i--) {
972
- const node = $pos.node(i);
973
- if (predicate(node)) {
974
- return {
975
- start: $pos.start(i),
976
- pos: i > 0 ? $pos.before(i) : 0,
977
- depth: i,
978
- node
979
- };
980
- }
981
- }
982
- };
983
- /**
984
- * @hidden
985
- */
986
- const createTable = (nodes$$1, rows, columns) => {
987
- const { table, table_body, table_row, table_cell } = nodes$$1;
988
- const tableRows = [];
989
- let cells;
990
- for (let r = 0; r < rows + 1; r++) {
991
- cells = [];
992
- for (let c = 0; c < columns + 1; c++) {
993
- cells.push(table_cell.createAndFill());
994
- }
995
- tableRows.push(table_row.createAndFill(undefined, cells));
996
- }
997
- const body = table_body.createAndFill(undefined, tableRows);
998
- return table.createAndFill(undefined, body);
999
- };
1000
- /**
1001
- * @hidden
1002
- */
1003
- const isInTable = (state) => {
1004
- const $head = state.selection.$head;
1005
- for (let d = $head.depth; d > 0; d--) {
1006
- if (isTableRow($head.node(d))) {
1007
- return true;
1008
- }
1009
- }
1010
- return false;
1011
- };
1012
- /**
1013
- * @hidden
1014
- */
1015
- const setAttr = (attrs, name, value) => {
1016
- const result = {};
1017
- // tslint:disable-next-line
1018
- for (const prop in attrs) {
1019
- result[prop] = attrs[prop];
1020
- }
1021
- result[name] = value;
1022
- return result;
1023
- };
1024
- const cellNear = ($pos) => {
1025
- for (let after = $pos.nodeAfter, pos = $pos.pos; after; after = after.firstChild, pos++) {
1026
- const role = after.type.spec.tableRole;
1027
- if (role === 'cell' || role === 'header_cell') {
1028
- return $pos.doc.resolve(pos);
1029
- }
1030
- }
1031
- for (let before = $pos.nodeBefore, pos = $pos.pos; before; before = before.lastChild, pos--) {
1032
- const role = before.type.spec.tableRole;
1033
- if (role === 'cell' || role === 'header_cell') {
1034
- return $pos.doc.resolve(pos - before.nodeSize);
1035
- }
1036
- }
1037
- };
1038
- const cellAround = ($pos) => {
1039
- for (let d = $pos.depth - 1; d > 0; d--) {
1040
- if (isTableRow($pos.node(d))) {
1041
- return $pos.node(0).resolve($pos.before(d + 1));
1042
- }
1043
- }
1044
- return null;
1045
- };
1046
- const selectionCell = (sel) => {
1047
- if (sel instanceof CellSelection && sel.$anchorCell) {
1048
- return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;
1049
- }
1050
- else if (sel instanceof NodeSelection && sel.node && isTableCell(sel.node)) {
1051
- return sel.$anchor;
1052
- }
1053
- return cellAround(sel.$head) || cellNear(sel.$head);
1054
- };
1055
- /**
1056
- * @hidden
1057
- */
1058
- // Helper to get the selected rectangle in a table, if any. Adds table
1059
- // map, table node, and table start offset to the object for
1060
- // convenience.
1061
- const selectedRect = (sel) => {
1062
- // create arr of rect for each table section
1063
- // there has to be a rect for thead, tbody and tfoot(if each exists)
1064
- // and NOT for colgroups
1065
- const $pos = selectionCell(sel);
1066
- const table = $pos.node(-1);
1067
- const tableStart = $pos.start(-1);
1068
- const map$$1 = TableMap.get(table);
1069
- const rect = sel instanceof CellSelection
1070
- ? map$$1.rectBetween(sel.$anchorCell.pos - tableStart, sel.$headCell.pos - tableStart)
1071
- : map$$1.findCell($pos.pos - tableStart);
1072
- rect.tableStart = tableStart;
1073
- rect.map = map$$1;
1074
- rect.table = table;
1075
- return rect;
1076
- };
1077
- /**
1078
- * @hidden
1079
- */
1080
- // this has to be removed since the schema should not have roles inside NodeSpec.
1081
- const tableNodeTypes = (schema) => {
1082
- let result = schema.cached.tableNodeTypes;
1083
- if (!result) {
1084
- result = schema.cached.tableNodeTypes = {};
1085
- // tslint:disable-next-line
1086
- for (const name in schema.nodes) {
1087
- const type = schema.nodes[name];
1088
- const role = type.spec.tableRole;
1089
- if (role) {
1090
- result[role] = type;
1091
- }
1092
- }
1093
- }
1094
- return result;
1095
- };
1096
- /**
1097
- * @hidden
1098
- */
1099
- const rowIsHeader = (map$$1, table, row) => {
1100
- const headerCell = tableNodeTypes(table.type.schema).header_cell;
1101
- for (let col = 0; col < map$$1.width; col++) {
1102
- if (table.nodeAt(map$$1.map[col + row * map$$1.width]).type !== headerCell) {
1103
- return false;
1104
- }
1105
- }
1106
- return true;
1107
- };
1108
- /**
1109
- * @hidden
1110
- */
1111
- const addColSpan = (attrs, pos, n = 1) => {
1112
- const result = setAttr(attrs, 'colspan', attrs.colspan + n);
1113
- if (result.colwidth) {
1114
- result.colwidth = result.colwidth.slice();
1115
- for (let i = 0; i < n; i++) {
1116
- result.colwidth.splice(pos, 0, 0);
1117
- }
1118
- }
1119
- return result;
1120
- };
1121
- /**
1122
- * @hidden
1123
- */
1124
- const removeColSpan = (attrs, pos, n = 1) => {
1125
- const result = setAttr(attrs, 'colspan', attrs.colspan - n);
1126
- if (result.colwidth) {
1127
- result.colwidth = result.colwidth.slice();
1128
- result.colwidth.splice(pos, n);
1129
- if (!result.colwidth.some(w => w > 0)) {
1130
- result.colwidth = null;
1131
- }
1132
- }
1133
- return result;
1134
- };
1135
- /**
1136
- * @hidden
1137
- */
1138
- const isCellEmpty = cell => {
1139
- const c = cell.content;
1140
- return c.childCount === 1 && c.firstChild.isTextblock && c.firstChild.childCount === 0;
1141
- };
1142
- const cellWrapping = ($pos) => {
1143
- for (let d = $pos.depth; d > 0; d--) {
1144
- // Sometimes the cell can be in the same depth.
1145
- const role = $pos.node(d).type.spec.tableRole;
1146
- if (role === 'cell' || role === 'header_cell') {
1147
- return $pos.node(d);
1148
- }
1149
- }
1150
- return null;
1151
- };
1152
- /**
1153
- * @hidden
1154
- */
1155
- // Split a selected cell, whose rowpan or colspan is greater than one,
1156
- // into smaller cells with the cell type (th, td) returned by getType function.
1157
- const splitCellWithType = getCellType => {
1158
- return (state, dispatch) => {
1159
- const sel = state.selection;
1160
- let cellNode;
1161
- let cellPos;
1162
- if (!(sel instanceof CellSelection)) {
1163
- cellNode = cellWrapping(sel.$from);
1164
- if (!cellNode) {
1165
- return false;
1166
- }
1167
- cellPos = cellAround(sel.$from).pos;
1168
- }
1169
- else {
1170
- if (sel.$anchorCell.pos !== sel.$headCell.pos) {
1171
- return false;
1172
- }
1173
- cellNode = sel.$anchorCell.nodeAfter;
1174
- cellPos = sel.$anchorCell.pos;
1175
- }
1176
- if (cellNode.attrs.colspan === 1 && cellNode.attrs.rowspan === 1) {
1177
- return false;
1178
- }
1179
- if (dispatch) {
1180
- let baseAttrs = cellNode.attrs;
1181
- const attrs = [];
1182
- const colwidth = baseAttrs.colwidth;
1183
- if (baseAttrs.rowspan > 1) {
1184
- baseAttrs = setAttr(baseAttrs, 'rowspan', 1);
1185
- }
1186
- if (baseAttrs.colspan > 1) {
1187
- baseAttrs = setAttr(baseAttrs, 'colspan', 1);
1188
- }
1189
- const rect = selectedRect(state);
1190
- const tr = state.tr;
1191
- for (let i = 0; i < rect.right - rect.left; i++) {
1192
- attrs.push(colwidth ? setAttr(baseAttrs, 'colwidth', colwidth && colwidth[i] ? [colwidth[i]] : null) : baseAttrs);
1193
- }
1194
- let lastCell;
1195
- for (let row = rect.top; row < rect.bottom; row++) {
1196
- let pos = rect.map.positionAt(row, rect.left, rect.table);
1197
- if (row === rect.top) {
1198
- pos += cellNode.nodeSize;
1199
- }
1200
- for (let col = rect.left, i = 0; col < rect.right; col++, i++) {
1201
- if (col === rect.left && row === rect.top) {
1202
- continue;
1203
- }
1204
- tr.insert((lastCell = tr.mapping.map(pos + rect.tableStart, 1)), getCellType({ node: cellNode, row, col }).createAndFill(attrs[i]));
1205
- }
1206
- }
1207
- tr.setNodeMarkup(cellPos, getCellType({ node: cellNode, row: rect.top, col: rect.left }), attrs[0]);
1208
- if (sel instanceof CellSelection) {
1209
- tr.setSelection(new CellSelection(tr.doc.resolve(sel.$anchorCell.pos), lastCell && tr.doc.resolve(lastCell)));
1210
- }
1211
- dispatch(tr);
1212
- }
1213
- return true;
1214
- };
1215
- };
1216
- /**
1217
- * @hidden
1218
- */
1219
- const pointsAtCell = ($pos) => {
1220
- return isTableRow($pos.parent) && $pos.nodeAfter;
1221
- };
1222
- /**
1223
- * @hidden
1224
- */
1225
- const inSameTable = ($a, $b) => {
1226
- return $a.depth === $b.depth && $a.pos >= $b.start(-1) && $a.pos <= $b.end(-1);
1227
- };
1228
- /**
1229
- * @hidden
1230
- */
1231
- const cellsOverlapRectangle = ({ width, height, map: map$$1 }, rect) => {
1232
- let indexTop = rect.top * width + rect.left;
1233
- let indexLeft = indexTop;
1234
- let indexBottom = (rect.bottom - 1) * width + rect.left;
1235
- let indexRight = indexTop + (rect.right - rect.left - 1);
1236
- for (let i = rect.top; i < rect.bottom; i++) {
1237
- if ((rect.left > 0 && map$$1[indexLeft] === map$$1[indexLeft - 1]) || (rect.right < width && map$$1[indexRight] === map$$1[indexRight + 1])) {
1238
- return true;
1239
- }
1240
- indexLeft += width;
1241
- indexRight += width;
1242
- }
1243
- for (let i = rect.left; i < rect.right; i++) {
1244
- if ((rect.top > 0 && map$$1[indexTop] === map$$1[indexTop - width]) ||
1245
- (rect.bottom < height && map$$1[indexBottom] === map$$1[indexBottom + width])) {
1246
- return true;
1247
- }
1248
- indexTop++;
1249
- indexBottom++;
1250
- }
1251
- return false;
1252
- };
1253
-
1254
- /**
1255
- * @hidden
1256
- */
1257
- const insertTable = (attrs) => (state, dispatch) => {
1258
- const newTable = createTable(state.schema.nodes, attrs.rows, attrs.cols);
1259
- if (newTable) {
1260
- insertNode(newTable, true)(state, dispatch);
1261
- }
1262
- };
1263
- const addTableGroupColumn = (tr, { left, right }, col, mainTable, requiredGroup, doc) => {
1264
- let refColumn = col > 0 ? -1 : 0;
1265
- // not sure if this should be deleted
1266
- // if (columnIsHeader(map, table, col + refColumn)) {
1267
- // refColumn = col === 0 || col === map.width ? null : 0;
1268
- // }
1269
- let rect;
1270
- mainTable.node.descendants((tableChildNode, offset) => {
1271
- if (requiredGroup(tableChildNode)) {
1272
- let i = -1;
1273
- tableChildNode.firstChild.descendants((childNode, pos) => {
1274
- if (isTableCell(childNode) || isTableHeaderCell(childNode)) {
1275
- i = i + 1;
1276
- if (i === right || i === left) {
1277
- const selection = new Selection(doc.resolve(pos + offset + mainTable.start), doc.resolve(pos + offset + mainTable.start));
1278
- rect = selectedRect(selection);
1279
- }
1280
- }
1281
- });
1282
- }
1283
- });
1284
- // Do nothing if thead, tfoot or tbody is missing
1285
- if (!rect) {
1286
- return tr;
1287
- }
1288
- for (let row = 0; row < rect.map.height; row++) {
1289
- const index = row * rect.map.width + col;
1290
- // If this position falls inside a col-spanning cell
1291
- if (col > 0 && col < rect.map.width && rect.map.map[index - 1] === rect.map.map[index]) {
1292
- const pos = rect.map.map[index];
1293
- const cell = rect.table.nodeAt(pos);
1294
- tr.setNodeMarkup(tr.mapping.map(rect.tableStart + pos), null, addColSpan(cell.attrs, col - rect.map.colCount(pos)));
1295
- // Skip ahead if rowspan > 1
1296
- row += cell.attrs.rowspan - 1;
1297
- }
1298
- else {
1299
- const type = rect.table.nodeAt(rect.map.map[index + refColumn]).type;
1300
- const pos = rect.map.positionAt(row, col, rect.table);
1301
- tr.insert(tr.mapping.map(rect.tableStart + pos), type.createAndFill());
1302
- }
1303
- }
1304
- return tr;
1305
- };
1306
- const removeTableGroupColumn = (tr, { right, left }, mainTable, requiredGroup, doc) => {
1307
- let rect;
1308
- mainTable.node.descendants((tableChildNode, offset) => {
1309
- if (requiredGroup(tableChildNode)) {
1310
- let i = -1;
1311
- tableChildNode.firstChild.descendants((childNode, pos) => {
1312
- if (isTableCell(childNode) || isTableHeaderCell(childNode)) {
1313
- i = i + 1;
1314
- if (i >= left && i < right) {
1315
- const resolvedPos = doc.resolve(pos + offset + mainTable.start + childNode.nodeSize);
1316
- const selection = new Selection(resolvedPos, resolvedPos);
1317
- rect = selectedRect(selection);
1318
- }
1319
- }
1320
- });
1321
- }
1322
- });
1323
- // Do nothing if thead, tfoot or tbody is missing
1324
- if (!rect) {
1325
- return;
1326
- }
1327
- for (let i = rect.right - 1;; i--) {
1328
- removeColumn(tr, rect, i);
1329
- if (i === rect.left) {
1330
- break;
1331
- }
1332
- rect.table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
1333
- rect.map = TableMap.get(rect.table);
1334
- }
1335
- return;
1336
- };
1337
- const removeColumn = (tr, { map: map$$1, table, tableStart }, col) => {
1338
- for (let row = 0; row < map$$1.height;) {
1339
- const index = row * map$$1.width + col;
1340
- const pos = map$$1.map[index];
1341
- const cell = table.nodeAt(pos);
1342
- // If this is part of a col-spanning cell
1343
- if ((col > 0 && map$$1.map[index - 1] === pos) || (col < map$$1.width - 1 && map$$1.map[index + 1] === pos)) {
1344
- tr.setNodeMarkup(tr.mapping.map(tableStart + pos), null, removeColSpan(cell.attrs, col - map$$1.colCount(pos)));
1345
- }
1346
- else {
1347
- const start = tr.mapping.map(tableStart + pos);
1348
- tr.delete(start, start + cell.nodeSize);
1349
- }
1350
- row += cell.attrs.rowspan;
1351
- }
1352
- };
1353
- /**
1354
- * @hidden
1355
- */
1356
- // Command to add a column before the column with the selection.
1357
- const addColumnBefore$1 = (state, dispatch) => {
1358
- if (!isInTable(state)) {
1359
- return false;
1360
- }
1361
- if (dispatch) {
1362
- const rect = selectedRect(state.selection);
1363
- const mainTable = findParentNodeClosestToPos(state.selection.$anchor, isTable);
1364
- const tHeadTr = addTableGroupColumn(state.tr, rect, rect.left, mainTable, isTableHead, state.doc);
1365
- const tBodyTr = addTableGroupColumn(tHeadTr, rect, rect.left, mainTable, isTableBody, state.doc);
1366
- const tFootTr = addTableGroupColumn(tBodyTr, rect, rect.left, mainTable, isTableFoot, state.doc);
1367
- dispatch(tFootTr);
1368
- }
1369
- return true;
73
+ const commonAttributes = () => {
74
+ return Object.assign({}, createDefaultAttributes(['class', 'id', 'style']));
1370
75
  };
1371
76
  /**
1372
77
  * @hidden
1373
78
  */
1374
- // Command to add a column after the column with the selection.
1375
- const addColumnAfter$1 = (state, dispatch) => {
1376
- if (!isInTable(state)) {
1377
- return false;
1378
- }
1379
- if (dispatch) {
1380
- const rect = selectedRect(state.selection);
1381
- const mainTable = findParentNodeClosestToPos(state.selection.$anchor, isTable);
1382
- const theadTr = addTableGroupColumn(state.tr, rect, rect.right, mainTable, isTableHead, state.doc);
1383
- const tBodyTr = addTableGroupColumn(theadTr, rect, rect.right, mainTable, isTableBody, state.doc);
1384
- const tFootTr = addTableGroupColumn(tBodyTr, rect, rect.right, mainTable, isTableFoot, state.doc);
1385
- dispatch(tFootTr);
1386
- }
1387
- return true;
1388
- };
1389
- const addRow = (tr, { map: map$$1, tableStart, table }, row) => {
1390
- let rowPos = tableStart;
1391
- for (let i = 0; i < row; i++) {
1392
- rowPos += table.child(i).nodeSize;
1393
- }
1394
- const cells = [];
1395
- let refRow = row > 0 ? -1 : 0;
1396
- if (rowIsHeader(map$$1, table, row + refRow)) {
1397
- refRow = row === 0 || row === map$$1.height ? null : 0;
1398
- }
1399
- for (let col = 0, index = map$$1.width * row; col < map$$1.width; col++, index++) {
1400
- // Covered by a rowspan cell
1401
- if (row > 0 && row < map$$1.height && map$$1.map[index] === map$$1.map[index - map$$1.width]) {
1402
- const pos = map$$1.map[index];
1403
- const attrs = table.nodeAt(pos).attrs;
1404
- tr.setNodeMarkup(tableStart + pos, null, setAttr(attrs, 'rowspan', attrs.rowspan + 1));
1405
- col += attrs.colspan - 1;
1406
- }
1407
- else {
1408
- const type = refRow == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map$$1.map[index + refRow * map$$1.width]).type;
1409
- cells.push(type.createAndFill());
1410
- }
1411
- }
1412
- tr.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells));
1413
- return tr;
79
+ const createDefaultAttributes = (attrs = []) => {
80
+ return Object.assign({}, attrs.reduce((acc, curr) => (Object.assign({}, acc, { [curr]: { default: null } })), {}));
1414
81
  };
1415
82
  /**
1416
83
  * @hidden
1417
84
  */
1418
- // Add a table row before the selection.
1419
- const addRowBefore$1 = (state, dispatch) => {
1420
- if (!isInTable(state)) {
1421
- return false;
1422
- }
1423
- if (dispatch) {
1424
- const rect = selectedRect(state.selection);
1425
- dispatch(addRow(state.tr, rect, rect.top));
1426
- }
1427
- return true;
1428
- };
85
+ const hole = 0;
86
+
87
+ const createSemanticNode = (tagName) => ({
88
+ // Uncaught SyntaxError: Mixing inline and block content (in content expression '(block | inline)*')
89
+ // content: '(block | inline)*',
90
+ content: 'block*',
91
+ group: 'block',
92
+ attrs: Object.assign({}, commonAttributes()),
93
+ parseDOM: [{
94
+ tag: tagName,
95
+ getAttrs: getAttributes
96
+ }],
97
+ toDOM: node => hasAttrs(node.attrs) ? [tagName, getAttrs(node.attrs), hole] : [tagName, hole]
98
+ });
1429
99
  /**
1430
100
  * @hidden
1431
101
  */
1432
- // Add a table row after the selection.
1433
- const addRowAfter$1 = (state, dispatch) => {
1434
- if (!isInTable(state)) {
1435
- return false;
1436
- }
1437
- if (dispatch) {
1438
- const rect = selectedRect(state.selection);
1439
- dispatch(addRow(state.tr, rect, rect.bottom));
1440
- }
1441
- return true;
1442
- };
102
+ const semanticTagNames = ['article', 'main', 'nav', 'header', 'footer', 'aside', 'section'];
103
+ const ɵ1 = (acc, curr) => Object.assign(acc, { [curr]: createSemanticNode(curr) });
1443
104
  /**
1444
105
  * @hidden
1445
106
  */
1446
- // Command function that removes the selected columns from a table.
1447
- const deleteColumn$1 = (state, dispatch) => {
1448
- if (!isInTable(state)) {
1449
- return false;
1450
- }
1451
- if (dispatch) {
1452
- const rect = selectedRect(state.selection);
1453
- // if only one column left - delete the whole table
1454
- if (rect.left === 0 && rect.right === rect.map.width) {
1455
- return deleteTable$1(state, dispatch);
1456
- }
1457
- const mainTable = findParentNodeClosestToPos(state.selection.$anchor, isTable);
1458
- const tr = state.tr;
1459
- removeTableGroupColumn(tr, rect, mainTable, isTableFoot, tr.doc);
1460
- removeTableGroupColumn(tr, rect, mainTable, isTableBody, tr.doc);
1461
- removeTableGroupColumn(tr, rect, mainTable, isTableHead, tr.doc);
1462
- dispatch(tr);
1463
- }
1464
- return true;
1465
- };
1466
- const removeRow = (tr, { map: map$$1, table, tableStart }, row) => {
1467
- let rowPos = 0;
1468
- for (let i = 0; i < row; i++) {
1469
- rowPos += table.child(i).nodeSize;
1470
- }
1471
- const nextRow = rowPos + table.child(row).nodeSize;
1472
- const mapFrom = tr.mapping.maps.length;
1473
- tr.delete(rowPos + tableStart, nextRow + tableStart);
1474
- for (let col = 0, index = row * map$$1.width; col < map$$1.width; col++, index++) {
1475
- const pos = map$$1.map[index];
1476
- if (row > 0 && pos === map$$1.map[index - map$$1.width]) {
1477
- // If this cell starts in the row above, simply reduce its rowspan
1478
- const attrs = table.nodeAt(pos).attrs;
1479
- tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + tableStart), null, setAttr(attrs, 'rowspan', attrs.rowspan - 1));
1480
- col += attrs.colspan - 1;
1481
- }
1482
- else if (row < map$$1.width && pos === map$$1.map[index + map$$1.width]) {
1483
- // Else, if it continues in the row below, it has to be moved down
1484
- const cell = table.nodeAt(pos);
1485
- const copy = cell.type.create(setAttr(cell.attrs, 'rowspan', cell.attrs.rowspan - 1), cell.content);
1486
- const newPos = map$$1.positionAt(row + 1, col, table);
1487
- tr.insert(tr.mapping.slice(mapFrom).map(tableStart + newPos), copy);
1488
- col += cell.attrs.colspan - 1;
1489
- }
1490
- }
1491
- };
107
+ const semanticNodes = semanticTagNames.reduce(ɵ1, {});
108
+
1492
109
  /**
1493
110
  * @hidden
1494
111
  */
1495
- // Remove the selected rows from a table.
1496
- const deleteRow$1 = (state, dispatch) => {
1497
- if (!isInTable(state)) {
1498
- return false;
1499
- }
1500
- if (dispatch) {
1501
- const rect = selectedRect(state.selection);
1502
- const tr = state.tr;
1503
- if (rect.top === 0 && rect.bottom === rect.map.height) {
1504
- const mainTable = findParentNodeClosestToPos(state.selection.$anchor, isTable);
1505
- if (mainTable.node.childCount === 1) {
1506
- deleteTable$1(state, dispatch);
1507
- }
1508
- else {
1509
- deleteTableElement(n => n.type.name === rect.table.type.name)(state, dispatch);
1510
- }
1511
- return true;
1512
- }
1513
- for (let i = rect.bottom - 1;; i--) {
1514
- removeRow(tr, rect, i);
1515
- if (i === rect.top) {
1516
- break;
1517
- }
1518
- rect.table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
1519
- rect.map = TableMap.get(rect.table);
1520
- }
1521
- dispatch(tr);
1522
- }
1523
- return true;
1524
- };
112
+ const marks$1 = marks;
113
+ const nodes$1 = Object.assign(nodes, semanticNodes);
1525
114
  /**
1526
115
  * @hidden
1527
116
  */
1528
- // Merge the selected cells into a single cell. Only available when
1529
- // the selected cells' outline forms a rectangle.
1530
- const mergeCells$1 = (state, dispatch) => {
1531
- const sel = state.selection;
1532
- if (!(sel instanceof CellSelection) || sel.$anchorCell.pos === sel.$headCell.pos) {
1533
- return false;
1534
- }
1535
- const rect = selectedRect(state.selection);
1536
- const { map: map$$1 } = rect;
1537
- if (cellsOverlapRectangle(map$$1, rect)) {
1538
- return false;
1539
- }
1540
- if (dispatch) {
1541
- const tr = state.tr;
1542
- const seen = {};
1543
- let content = Fragment.empty;
1544
- let mergedPos;
1545
- let mergedCell;
1546
- for (let row = rect.top; row < rect.bottom; row++) {
1547
- for (let col = rect.left; col < rect.right; col++) {
1548
- const cellPos = map$$1.map[row * map$$1.width + col], cell = rect.table.nodeAt(cellPos);
1549
- if (seen[cellPos]) {
1550
- continue;
1551
- }
1552
- seen[cellPos] = true;
1553
- if (mergedPos === null) {
1554
- mergedPos = cellPos;
1555
- mergedCell = cell;
1556
- }
1557
- else {
1558
- if (!isCellEmpty(cell)) {
1559
- content = content.append(cell.content);
1560
- }
1561
- const mapped = tr.mapping.map(cellPos + rect.tableStart);
1562
- tr.delete(mapped, mapped + cell.nodeSize);
1563
- }
1564
- }
1565
- }
1566
- tr.setNodeMarkup(mergedPos + rect.tableStart, null, setAttr(addColSpan(mergedCell.attrs, mergedCell.attrs.colspan, rect.right - rect.left - mergedCell.attrs.colspan), 'rowspan', rect.bottom - rect.top));
1567
- if (content.size) {
1568
- const end = mergedPos + 1 + mergedCell.content.size;
1569
- const start = isCellEmpty(mergedCell) ? mergedPos + 1 : end;
1570
- tr.replaceWith(start + rect.tableStart, end + rect.tableStart, content);
1571
- }
1572
- tr.setSelection(new CellSelection(tr.doc.resolve(mergedPos + rect.tableStart)));
1573
- dispatch(tr);
1574
- }
1575
- return true;
1576
- };
117
+ const schema = new Schema({
118
+ marks: marks$1,
119
+ nodes: Object.assign({}, nodes$1, { blockquote: Object.assign({}, nodes$1.blockquote, { content: 'inline*' }) })
120
+ });
121
+
1577
122
  /**
1578
123
  * @hidden
1579
124
  */
1580
- // Split a selected cell, whose rowpan or colspan is greater than one,
1581
- // into smaller cells. Use the first cell type for the new cells.
1582
- const splitCell$1 = (state, dispatch) => {
1583
- const nodeTypes = tableNodeTypes(state.schema);
1584
- return splitCellWithType(({ node }) => {
1585
- return nodeTypes[node.type.spec.tableRole];
1586
- })(state, dispatch);
1587
- };
1588
- const deleteTableElement = (selector) => (state, dispatch) => {
1589
- const $pos = state.selection.$anchor;
1590
- for (let d = $pos.depth; d > 0; d--) {
1591
- const node = $pos.node(d);
1592
- if (selector(node)) {
1593
- if (dispatch) {
1594
- const tr = state.tr;
1595
- tr.delete($pos.before(d), $pos.after(d)).scrollIntoView();
1596
- dispatch(tr);
1597
- }
1598
- return true;
1599
- }
125
+ const insertTable = (attrs) => (state, dispatch) => {
126
+ const newTable = createTable(state.schema.nodes, attrs.rows, attrs.cols);
127
+ if (newTable) {
128
+ insertNode(newTable, true)(state, dispatch);
1600
129
  }
1601
- return false;
1602
130
  };
1603
- /**
1604
- * @hidden
1605
- */
1606
- // Deletes the table around the selection, if any.
1607
- const deleteTable$1 = deleteTableElement(isTable);
1608
131
 
1609
132
  const alignRemove = (state, dispatch) => alignBlocks(alignRemoveRules)(state, dispatch);
1610
- const ɵ1$5 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, bold, { applyToWord })), ɵ2$4 = (options) => cleanFormatting(options), ɵ3$4 = attrs => expandToWordWrap(applyLink, { mark: 'link', attrs: attrs.value, applyToWord: attrs.applyToWord }), ɵ4$2 = attrs => expandToWordWrap(applyInlineStyle, { style: 'font-family', value: attrs.value, applyToWord: attrs.applyToWord }), ɵ5$2 = attrs => expandToWordWrap(applyInlineStyle, { style: 'font-size', value: attrs.value + 'px', applyToWord: attrs.applyToWord }), ɵ6$1 = attrs => expandToWordWrap(applyLink, { mark: 'link', attrs: attrs, applyToWord: attrs.applyToWord }), ɵ7$1 = text => insertText(text), ɵ8$1 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, italic, { applyToWord })), ɵ9$1 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, strikethrough, { applyToWord })), ɵ10 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, subscript, { applyToWord })), ɵ11 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, superscript, { applyToWord })), ɵ12 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, underline, { applyToWord })), ɵ13 = () => removeLink(link), ɵ14 = attrs => expandToWordWrap(applyInlineStyle, { style: 'color', value: attrs.value, applyToWord: attrs.applyToWord }), ɵ15 = attrs => expandToWordWrap(applyInlineStyle, { style: 'background-color', value: attrs.value, applyToWord: attrs.applyToWord }), ɵ16 = () => (state, dispatch) => selectAll(state, dispatch);
133
+ const ɵ1$1 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, bold, { applyToWord })), ɵ2 = (options) => cleanFormatting(options), ɵ3 = attrs => expandToWordWrap(applyLink, { mark: 'link', attrs: attrs.value, applyToWord: attrs.applyToWord }), ɵ4 = attrs => expandToWordWrap(applyInlineStyle, { style: 'font-family', value: attrs.value, applyToWord: attrs.applyToWord }), ɵ5 = attrs => expandToWordWrap(applyInlineStyle, { style: 'font-size', value: attrs.value + 'px', applyToWord: attrs.applyToWord }), ɵ6 = attrs => expandToWordWrap(applyLink, { mark: 'link', attrs: attrs, applyToWord: attrs.applyToWord }), ɵ7 = text => insertText(text), ɵ8 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, italic, { applyToWord })), ɵ9 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, strikethrough, { applyToWord })), ɵ10 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, subscript, { applyToWord })), ɵ11 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, superscript, { applyToWord })), ɵ12 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, underline, { applyToWord })), ɵ13 = () => removeLink(link), ɵ14 = attrs => expandToWordWrap(applyInlineStyle, { style: 'color', value: attrs.value, applyToWord: attrs.applyToWord }), ɵ15 = attrs => expandToWordWrap(applyInlineStyle, { style: 'background-color', value: attrs.value, applyToWord: attrs.applyToWord }), ɵ16 = () => (state, dispatch) => selectAll(state, dispatch);
1611
134
  const inlineCommand = {
1612
- bold: ɵ1$5,
1613
- cleanFormatting: ɵ2$4,
1614
- createLink: ɵ3$4,
1615
- fontFamily: ɵ4$2,
1616
- fontSize: ɵ5$2,
1617
- insertFile: ɵ6$1,
1618
- insertText: ɵ7$1,
1619
- italic: ɵ8$1,
1620
- strikethrough: ɵ9$1,
135
+ bold: ɵ1$1,
136
+ cleanFormatting: ɵ2,
137
+ createLink: ɵ3,
138
+ fontFamily: ɵ4,
139
+ fontSize: ɵ5,
140
+ insertFile: ɵ6,
141
+ insertText: ɵ7,
142
+ italic: ɵ8,
143
+ strikethrough: ɵ9,
1621
144
  subscript: ɵ10,
1622
145
  superscript: ɵ11,
1623
146
  underline: ɵ12,
@@ -1645,7 +168,7 @@ const blockCommand = {
1645
168
  setHTML: ɵ29,
1646
169
  undo: ɵ30
1647
170
  };
1648
- const ɵ31 = attr => insertTable(attr), ɵ32 = () => addColumnBefore$1, ɵ33 = () => addColumnAfter$1, ɵ34 = () => addRowBefore$1, ɵ35 = () => addRowAfter$1, ɵ36 = () => deleteRow$1, ɵ37 = () => deleteColumn$1, ɵ38 = () => mergeCells$1, ɵ39 = () => splitCell$1, ɵ40 = () => deleteTable$1;
171
+ const ɵ31 = attr => insertTable(attr), ɵ32 = () => addColumnBefore, ɵ33 = () => addColumnAfter, ɵ34 = () => addRowBefore, ɵ35 = () => addRowAfter, ɵ36 = () => deleteRow, ɵ37 = () => deleteColumn, ɵ38 = () => mergeCells, ɵ39 = () => splitCell, ɵ40 = () => deleteTable;
1649
172
  const tableCommand = {
1650
173
  insertTable: ɵ31,
1651
174
  addColumnBefore: ɵ32,
@@ -1928,6 +451,106 @@ const disabledToolBarState = {
1928
451
  selectAll: { selected: false, disabled: true }
1929
452
  };
1930
453
 
454
+ /**
455
+ * @hidden
456
+ */
457
+ function outerWidth(element) {
458
+ let width = element.offsetWidth;
459
+ const style = getComputedStyle(element);
460
+ width += parseFloat(style.marginLeft) || 0 + parseFloat(style.marginRight) || 0;
461
+ return width;
462
+ }
463
+ /**
464
+ * @hidden
465
+ */
466
+ const removeEntries = (obj, predicate) => Object.keys(obj)
467
+ .filter(key => predicate(key))
468
+ .reduce((acc, curr) => Object.assign(acc, { [curr]: obj[curr] }), {});
469
+ /**
470
+ * @hidden
471
+ */
472
+ const removeEmptyEntries = (obj) => {
473
+ const predicate = key => obj[key] !== null && obj[key] !== undefined && obj[key] !== '';
474
+ return removeEntries(obj, predicate);
475
+ };
476
+ /**
477
+ * @hidden
478
+ */
479
+ const isNullOrUndefined = (value) => value === undefined || value === null;
480
+ /**
481
+ * @hidden
482
+ */
483
+ const isPresent = (value) => !isNullOrUndefined(value);
484
+ /**
485
+ * @hidden
486
+ */
487
+ const detectIE = () => {
488
+ if (!isDocumentAvailable()) {
489
+ return false;
490
+ }
491
+ const ua = window.navigator.userAgent;
492
+ const msie = ua.indexOf('MSIE ');
493
+ const trident = ua.indexOf('Trident/');
494
+ return msie > 0 || trident > 0;
495
+ };
496
+ /**
497
+ * @hidden
498
+ */
499
+ const safeString = (value) => (isNullOrUndefined(value) ? '' : value.toString());
500
+ /**
501
+ * @hidden
502
+ */
503
+ const first = (arr) => arr[0];
504
+ /**
505
+ * @hidden
506
+ */
507
+ const last = (arr) => arr[arr.length - 1];
508
+ /**
509
+ * @hidden
510
+ */
511
+ const split = (splitter) => (value) => value.split(splitter);
512
+ /**
513
+ * @hidden
514
+ */
515
+ const trim = (value) => value.trim();
516
+ /**
517
+ * @hidden
518
+ */
519
+ const filter$1 = (predicate) => (arr) => arr.filter(predicate);
520
+ /**
521
+ * @hidden
522
+ */
523
+ const getUniqueStyleValues = (style, cssStyle) => {
524
+ if (style.hasNodesWithoutMarks) {
525
+ return '';
526
+ }
527
+ const uniqueMarkValues = style.marks
528
+ .filter(m => m.type.name === 'style')
529
+ .map(m => m.attrs.style)
530
+ .map(safeString)
531
+ .map(split(';'))
532
+ .map(filter$1((m) => m.includes(cssStyle)))
533
+ // guards against empty array
534
+ .map((cssStyleValues) => (cssStyleValues.length !== 0 ? cssStyleValues : [`${cssStyle}: INVALID`]))
535
+ .map(first)
536
+ .map(split(':'))
537
+ .map(last)
538
+ .map(trim)
539
+ .reduce((acc, curr) => (acc.indexOf(curr) > -1 ? acc : [...acc, curr]), []);
540
+ if (uniqueMarkValues.indexOf('INVALID') > -1 || uniqueMarkValues.length !== 1) {
541
+ return '';
542
+ }
543
+ return uniqueMarkValues[0];
544
+ };
545
+ /**
546
+ * @hidden
547
+ */
548
+ const conditionallyExecute = (fn) => (condition) => (param) => (condition ? fn(param) : param);
549
+ /**
550
+ * @hidden
551
+ */
552
+ const pipe = (...fns) => x => fns.reduce((y, f) => f(y), x);
553
+
1931
554
  /**
1932
555
  * @hidden
1933
556
  */
@@ -2533,7 +1156,7 @@ const tablesStyles = `
2533
1156
  */
2534
1157
  const rtlStyles = 'body { direction: rtl }';
2535
1158
 
2536
- const ɵ0$6 = (arg) => `plugins must be a function, but received ${JSON.stringify(arg)}.`;
1159
+ const ɵ0$2 = (arg) => `plugins must be a function, but received ${JSON.stringify(arg)}.`, ɵ1$2 = (arg) => `pastedContent must be a function, but received ${JSON.stringify(arg)}.`;
2537
1160
  /* tslint:disable:variable-name */
2538
1161
  /**
2539
1162
  * @hidden
@@ -2541,7 +1164,8 @@ const ɵ0$6 = (arg) => `plugins must be a function, but received ${JSON.stringif
2541
1164
  const EditorErrorMessages = {
2542
1165
  schemaType: 'Expected value of type Schema. See http://www.telerik.com/kendo-angular-ui/components/editor/schema/',
2543
1166
  setSchemaOnce: 'The Schema cannot be changed dynamically. See http://www.telerik.com/kendo-angular-ui/components/editor/schema/',
2544
- pluginsCallbackType: ɵ0$6,
1167
+ pluginsCallbackType: ɵ0$2,
1168
+ pastedContentCallbackType: ɵ1$2,
2545
1169
  setPluginsOnce: 'The plugins cannot be changed dynamically. See http://www.telerik.com/kendo-angular-ui/components/editor/plugins/',
2546
1170
  setPlaceHolderOnce: 'The placeholder cannot be changed dynamically. See http://www.telerik.com/kendo-angular-ui/components/editor/placeholder/',
2547
1171
  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/'
@@ -2562,16 +1186,32 @@ EditorToolsService = __decorate([
2562
1186
  Injectable()
2563
1187
  ], EditorToolsService);
2564
1188
 
1189
+ /**
1190
+ * The Editor [`paste`]({% slug api_editor_editorcomponent %}#toc-paste) event.
1191
+ */
1192
+ class EditorPasteEvent extends PreventableEvent {
1193
+ /**
1194
+ * Constructs the event arguments for the `paste` event.
1195
+ * @hidden
1196
+ */
1197
+ constructor(cleanedHtml, originalHtml, originalEvent) {
1198
+ super();
1199
+ this.cleanedHtml = cleanedHtml;
1200
+ this.originalHtml = originalHtml;
1201
+ this.originalEvent = originalEvent;
1202
+ }
1203
+ }
1204
+
2565
1205
  var EditorComponent_1;
2566
1206
  const EMPTY_PARAGRAPH = '<p></p>';
2567
1207
  const defaultPasteCleanupSettings = {
2568
1208
  convertMsLists: false,
2569
1209
  removeAttributes: [],
2570
1210
  removeHtmlComments: false,
2571
- removeInvalidHTML: false,
1211
+ removeInvalidHTML: true,
2572
1212
  removeMsClasses: false,
2573
1213
  removeMsStyles: false,
2574
- stripTags: ['']
1214
+ stripTags: []
2575
1215
  };
2576
1216
  const removeCommentsIf = conditionallyExecute(removeComments);
2577
1217
  const removeInvalidHTMLIf = conditionallyExecute(sanitize);
@@ -2607,14 +1247,6 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
2607
1247
  * @default false
2608
1248
  */
2609
1249
  this.applyToWord = false;
2610
- /**
2611
- * By design, the Editor emits `valueChange`, updates the model and the ToolBar state on each keystroke.
2612
- * 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.
2613
- * 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.
2614
- * The specified interval (in milliseconds) should be a positive number.
2615
- * By default the `updateInterval` is set to 100 miliseconds. If set to zero the delay will be disabled entirely.
2616
- */
2617
- this.updateInterval = 100;
2618
1250
  /**
2619
1251
  * By default, whitespace is collapsed as per HTML's rules.
2620
1252
  * Set to `true` to preserve whitespace, but normalize newlines to spaces.
@@ -2640,6 +1272,11 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
2640
1272
  * Fires when the content area of the Editor is focused ([see example]({% slug overview_editor %}#toc-events)).
2641
1273
  */
2642
1274
  this.onFocus = new EventEmitter();
1275
+ /**
1276
+ * Fires when the user performs paste in the content area of the Editor ([see example]({% slug overview_editor %}#toc-events)).
1277
+ * The event is preventable. If you cancel it, the Editor content will not change.
1278
+ */
1279
+ this.paste = new EventEmitter();
2643
1280
  /**
2644
1281
  * Fires when the content area of the Editor is blurred ([see example]({% slug overview_editor %}#toc-events)).
2645
1282
  */
@@ -2655,10 +1292,76 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
2655
1292
  this.valueModified = new Subject();
2656
1293
  this._readonly = false;
2657
1294
  this._placeholder = '';
1295
+ this.inForm = false;
2658
1296
  this.afterViewInit = new Subject();
2659
1297
  this.contentAreaLoaded = new Subject();
2660
- this.onChangeCallback = (_) => { }; // tslint:disable-line:no-empty
1298
+ this.dispatchTransaction = (tr) => {
1299
+ const docChanged = tr.docChanged;
1300
+ if (this.disabled || (this.readonly && docChanged)) {
1301
+ return;
1302
+ }
1303
+ if (docChanged) {
1304
+ const doc = tr.doc;
1305
+ const html = getHtml({ doc });
1306
+ this.trOnChange = tr;
1307
+ this.htmlOnChange = html;
1308
+ this.ngZone.run(() => {
1309
+ this.valueModified.next(html);
1310
+ });
1311
+ }
1312
+ if (!docChanged || this.inForm) {
1313
+ this.view.updateState(this.view.state.apply(tr));
1314
+ }
1315
+ };
1316
+ this.transformPastedHTML = (dirtyHtml) => {
1317
+ const pasteCleanupSettings = Object.assign({}, defaultPasteCleanupSettings, this.pasteCleanupSettings);
1318
+ const html = pipe(removeInvalidHTMLIf(pasteCleanupSettings.removeInvalidHTML), removeCommentsIf(pasteCleanupSettings.removeHtmlComments))(dirtyHtml);
1319
+ const clean = pasteCleanup(html, {
1320
+ convertMsLists: pasteCleanupSettings.convertMsLists,
1321
+ stripTags: pasteCleanupSettings.stripTags.join('|'),
1322
+ attributes: getPasteCleanupAttributes(pasteCleanupSettings)
1323
+ });
1324
+ if (hasObservers(this.paste)) {
1325
+ const event = new EditorPasteEvent(clean, dirtyHtml, this._pasteEvent);
1326
+ this.ngZone.run(() => this.paste.emit(event));
1327
+ return event.isDefaultPrevented() ? '' : event.cleanedHtml;
1328
+ }
1329
+ return clean;
1330
+ };
1331
+ this.changeValue = (value) => {
1332
+ const prev = this._value;
1333
+ this._value = value;
1334
+ if (!this._view) {
1335
+ return;
1336
+ }
1337
+ if (this.htmlOnChange === value && this.trOnChange) {
1338
+ this.view.updateState(this.view.state.apply(this.trOnChange));
1339
+ }
1340
+ else {
1341
+ if ((prev || '') !== (value || '')) {
1342
+ const iframeContentWindowNotPresent = this.iframe && !this.container.element.nativeElement.contentWindow;
1343
+ if (iframeContentWindowNotPresent) {
1344
+ return;
1345
+ }
1346
+ const state = this.view.state;
1347
+ const nextDoc = parseContent(value || '', state.schema, { preserveWhitespace: this.preserveWhitespace });
1348
+ const tr = state.tr
1349
+ .setSelection(new AllSelection(state.doc))
1350
+ .replaceSelectionWith(nextDoc);
1351
+ this.view.updateState(state.apply(tr));
1352
+ }
1353
+ }
1354
+ this.trOnChange = null;
1355
+ this.htmlOnChange = null;
1356
+ };
1357
+ this.onChangeCallback = (value) => {
1358
+ this.changeValue(value);
1359
+ };
2661
1360
  this.onTouchedCallback = (_) => { }; // tslint:disable-line:no-empty
1361
+ this.onPaste = (_view, nativeEvent) => {
1362
+ this._pasteEvent = nativeEvent;
1363
+ return false;
1364
+ };
2662
1365
  validatePackage(packageMetadata);
2663
1366
  this.direction = localization.rtl ? 'rtl' : 'ltr';
2664
1367
  // https://stackoverflow.com/questions/56572483/chrome-is-synchronously-handling-iframe-loading-whereas-firefox-handles-it-asyn
@@ -2668,25 +1371,12 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
2668
1371
  * Sets the value of the Editor ([see example]({% slug overview_editor %}#toc-basic-usage)).
2669
1372
  */
2670
1373
  set value(value) {
2671
- if (this._previousValue === value) {
2672
- return;
2673
- }
2674
- this._value = value;
2675
- this._previousValue = value;
2676
- if (this._view) {
2677
- const iframeContentWindowNotPresent = this.iframe && !this.container.element.nativeElement.contentWindow;
2678
- if (iframeContentWindowNotPresent) {
2679
- return;
2680
- }
2681
- this.exec('setHTML', {
2682
- content: this._value || '',
2683
- parseOptions: {
2684
- preserveWhitespace: this.preserveWhitespace
2685
- }
2686
- });
2687
- }
1374
+ this.changeValue(value);
2688
1375
  }
2689
1376
  get value() {
1377
+ if (this.trOnChange) {
1378
+ return this.htmlOnChange;
1379
+ }
2690
1380
  let value = this._view ? this.getSource() : this._value;
2691
1381
  if (value === EMPTY_PARAGRAPH) {
2692
1382
  return this._value ? '' : this._value;
@@ -2876,6 +1566,9 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
2876
1566
  }
2877
1567
  }
2878
1568
  ngOnChanges(changes) {
1569
+ if (changes.value && this.view) {
1570
+ this.changeValue(changes.value.currentValue);
1571
+ }
2879
1572
  if (changes.iframe && !changes.iframe.isFirstChange()) {
2880
1573
  this.ngZone.onStable.pipe(take(1)).subscribe(() => this.initialize());
2881
1574
  }
@@ -2961,8 +1654,6 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
2961
1654
  const command = editorCommands[commandName](attr);
2962
1655
  // Executes a ProseMirror command.
2963
1656
  command(this._view.state, this._view.dispatch, this._view);
2964
- // See the `dispatchTransaction` comments.
2965
- // this.stateChange.emit(updateToolBar(this.view));
2966
1657
  }
2967
1658
  /**
2968
1659
  * Opens a dialog.
@@ -3047,6 +1738,7 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
3047
1738
  * @hidden
3048
1739
  */
3049
1740
  writeValue(value) {
1741
+ this.inForm = true;
3050
1742
  // To avoid confusion, non-existent values are always undefined.
3051
1743
  this.value = value === null ? undefined : value;
3052
1744
  }
@@ -3074,7 +1766,6 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
3074
1766
  return;
3075
1767
  }
3076
1768
  const currentSchema = this.schema || schema;
3077
- const that = this;
3078
1769
  const containerNativeElement = this.container.element.nativeElement;
3079
1770
  const contentNode = parseContent((this.value || '').trim(), currentSchema, { preserveWhitespace: this.preserveWhitespace });
3080
1771
  if (this.iframe) {
@@ -3116,16 +1807,13 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
3116
1807
  }
3117
1808
  })
3118
1809
  }),
3119
- new Plugin({
3120
- key: new PluginKey('editor-filter-disabled-state'),
3121
- filterTransaction: () => !this.disabled
3122
- }),
3123
1810
  history(),
3124
1811
  keymap(buildListKeymap(currentSchema)),
3125
1812
  keymap(buildKeymap(currentSchema, { applyToWord: this.applyToWord })),
3126
1813
  keymap(baseKeymap),
3127
1814
  gapCursor(),
3128
- imageResizing()
1815
+ imageResizing(),
1816
+ tableEditing()
3129
1817
  ];
3130
1818
  if (this.placeholder) {
3131
1819
  defaultPlugins.push(placeholder(this.placeholder));
@@ -3145,31 +1833,10 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
3145
1833
  this._view = new EditorView({ mount: this.viewMountElement }, {
3146
1834
  state,
3147
1835
  editable: () => !this.readonly,
3148
- dispatchTransaction: function (tr) {
3149
- // `this` is bound to the view instance.
3150
- this.updateState(this.state.apply(tr));
3151
- // that.cdr.detectChanges();
3152
- // When the user utilizes keyboard shortcuts&mdash;for example, `Ctrl`+`b`&mdash;
3153
- // `tr.docChanged` is `true` and the toolbar is not updated.
3154
- // A possible future solution is to move the keymaps to the service.
3155
- // if (!tr.docChanged) {
3156
- // that.stateChange.emit(updateToolBar(that.view));
3157
- // }
3158
- const value = that.value;
3159
- if (!hasSameMarkup(value, that._previousValue, this.state.schema)) {
3160
- that._previousValue = value;
3161
- that.ngZone.run(() => that.valueModified.next(value));
3162
- }
3163
- },
3164
- transformPastedHTML: (html) => {
3165
- const pasteCleanupSettings = Object.assign({}, defaultPasteCleanupSettings, this.pasteCleanupSettings);
3166
- const clean = pipe(removeCommentsIf(pasteCleanupSettings.removeHtmlComments), removeInvalidHTMLIf(pasteCleanupSettings.removeInvalidHTML))(html);
3167
- const attributes = getPasteCleanupAttributes(pasteCleanupSettings);
3168
- return pasteCleanup(clean, {
3169
- convertMsLists: pasteCleanupSettings.convertMsLists,
3170
- stripTags: pasteCleanupSettings.stripTags.join('|'),
3171
- attributes
3172
- });
1836
+ dispatchTransaction: this.dispatchTransaction,
1837
+ transformPastedHTML: this.transformPastedHTML,
1838
+ handleDOMEvents: {
1839
+ paste: this.onPaste
3173
1840
  }
3174
1841
  });
3175
1842
  });
@@ -3210,7 +1877,7 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
3210
1877
  this.cdr.detectChanges();
3211
1878
  }
3212
1879
  }));
3213
- this.subs.add(merge(this.valueModified.pipe(filter(() => this.updateInterval > 0), auditTime(this.updateInterval)), this.valueModified.pipe(filter(() => this.updateInterval === 0))).subscribe((value) => {
1880
+ this.subs.add(this.valueModified.subscribe((value) => {
3214
1881
  this.onChangeCallback(value);
3215
1882
  this.valueChange.emit(value);
3216
1883
  this.cdr.markForCheck();
@@ -3303,10 +1970,6 @@ __decorate([
3303
1970
  __metadata("design:type", String),
3304
1971
  __metadata("design:paramtypes", [String])
3305
1972
  ], EditorComponent.prototype, "placeholder", null);
3306
- __decorate([
3307
- Input(),
3308
- __metadata("design:type", Number)
3309
- ], EditorComponent.prototype, "updateInterval", void 0);
3310
1973
  __decorate([
3311
1974
  Input(),
3312
1975
  __metadata("design:type", Object)
@@ -3327,6 +1990,10 @@ __decorate([
3327
1990
  Output('focus'),
3328
1991
  __metadata("design:type", EventEmitter)
3329
1992
  ], EditorComponent.prototype, "onFocus", void 0);
1993
+ __decorate([
1994
+ Output(),
1995
+ __metadata("design:type", EventEmitter)
1996
+ ], EditorComponent.prototype, "paste", void 0);
3330
1997
  __decorate([
3331
1998
  Output('blur'),
3332
1999
  __metadata("design:type", EventEmitter)
@@ -3574,7 +2241,7 @@ EditorComponent = EditorComponent_1 = __decorate([
3574
2241
  <div *ngIf="!iframe" #content [attr.dir]="direction" class="k-editor-content"></div>
3575
2242
 
3576
2243
  <div class="k-editor-content" *ngIf="iframe">
3577
- <iframe #content frameborder="0" class="k-iframe" (load)="iframeOnLoad()"></iframe>
2244
+ <iframe #content srcdoc="<!DOCTYPE html>" frameborder="0" class="k-iframe" (load)="iframeOnLoad()"></iframe>
3578
2245
  </div>
3579
2246
 
3580
2247
  <ng-container #dialogsContainer></ng-container>
@@ -7062,4 +5729,4 @@ EditorModule = __decorate([
7062
5729
  * Generated bundle index. Do not edit.
7063
5730
  */
7064
5731
 
7065
- export { ColorPickerDialogComponent, FileLinkDialogComponent, FontFamilyDialogComponent, FontSizeDialogComponent, FormatDialogComponent, ImageDialogComponent, InsertTableDialogComponent, SourceDialogComponent, CustomMessagesComponent, EditorLocalizationService, LocalizedMessagesDirective, Messages, EditorAlignCenterButtonDirective, EditorAlignJustifyButtonDirective, EditorAlignLeftButtonDirective, EditorAlignRightButtonDirective, EditorBackColorDirective, EditorColorPickerComponent, EditorForeColorDirective, EditorCleanFormattingButtonDirective, FontFamilyDropDownListComponent, EditorFontFamilyComponent, FontSizeDropDownListComponent, EditorFontSizeComponent, FormatDropDownListComponent, EditorFormatComponent, EditorRedoButtonDirective, EditorUndoButtonDirective, EditorInsertImageButtonDirective, EditorIndentButtonDirective, EditorOutdentButtonDirective, EditorCreateLinkButtonDirective, EditorInsertFileButtonDirective, EditorUnlinkButtonDirective, EditorInsertOrderedListButtonDirective, EditorInsertUnorderedListButtonDirective, EditorPrintDirective, EditorSelectAllButtonDirective, DropDownToolDirective, EditorCommandBase, EditorCommandButton, EditorCommandDialog, EditorViewSourceButtonDirective, EditorAddColumnAfterButtonDirective, EditorAddColumnBeforeButtonDirective, EditorAddRowAfterButtonDirective, EditorAddRowBeforeButtonDirective, EditorDeleteColumnButtonDirective, EditorDeleteRowButtonDirective, EditorDeleteTableButtonDirective, EditorInsertTableButtonComponent, EditorMergeCellsButtonDirective, EditorSplitCellButtonDirective, PopupTableGridComponent, EditorToolsService, EditorBoldButtonDirective, EditorItalicButtonDirective, EditorStrikethroughButtonDirective, EditorSubscriptButtonDirective, EditorSuperscriptButtonDirective, EditorUnderlineButtonDirective, EditorComponent, EditorModule, schema };
5732
+ export { ColorPickerDialogComponent, FileLinkDialogComponent, FontFamilyDialogComponent, FontSizeDialogComponent, FormatDialogComponent, ImageDialogComponent, InsertTableDialogComponent, SourceDialogComponent, CustomMessagesComponent, EditorLocalizationService, LocalizedMessagesDirective, Messages, EditorAlignCenterButtonDirective, EditorAlignJustifyButtonDirective, EditorAlignLeftButtonDirective, EditorAlignRightButtonDirective, EditorBackColorDirective, EditorColorPickerComponent, EditorForeColorDirective, EditorCleanFormattingButtonDirective, FontFamilyDropDownListComponent, EditorFontFamilyComponent, FontSizeDropDownListComponent, EditorFontSizeComponent, FormatDropDownListComponent, EditorFormatComponent, EditorRedoButtonDirective, EditorUndoButtonDirective, EditorInsertImageButtonDirective, EditorIndentButtonDirective, EditorOutdentButtonDirective, EditorCreateLinkButtonDirective, EditorInsertFileButtonDirective, EditorUnlinkButtonDirective, EditorInsertOrderedListButtonDirective, EditorInsertUnorderedListButtonDirective, EditorPrintDirective, EditorSelectAllButtonDirective, DropDownToolDirective, EditorCommandBase, EditorCommandButton, EditorCommandDialog, EditorViewSourceButtonDirective, EditorAddColumnAfterButtonDirective, EditorAddColumnBeforeButtonDirective, EditorAddRowAfterButtonDirective, EditorAddRowBeforeButtonDirective, EditorDeleteColumnButtonDirective, EditorDeleteRowButtonDirective, EditorDeleteTableButtonDirective, EditorInsertTableButtonComponent, EditorMergeCellsButtonDirective, EditorSplitCellButtonDirective, PopupTableGridComponent, EditorToolsService, EditorBoldButtonDirective, EditorItalicButtonDirective, EditorStrikethroughButtonDirective, EditorSubscriptButtonDirective, EditorSuperscriptButtonDirective, EditorUnderlineButtonDirective, EditorComponent, EditorModule, schema, EditorPasteEvent };