@syncfusion/ej2-richtexteditor 21.1.37 → 21.1.41

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 (28) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/ej2-richtexteditor.min.js +2 -2
  3. package/dist/ej2-richtexteditor.umd.min.js +2 -2
  4. package/dist/ej2-richtexteditor.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-richtexteditor.es2015.js +222 -114
  6. package/dist/es6/ej2-richtexteditor.es2015.js.map +1 -1
  7. package/dist/es6/ej2-richtexteditor.es5.js +209 -102
  8. package/dist/es6/ej2-richtexteditor.es5.js.map +1 -1
  9. package/dist/global/ej2-richtexteditor.min.js +2 -2
  10. package/dist/global/ej2-richtexteditor.min.js.map +1 -1
  11. package/dist/global/index.d.ts +1 -1
  12. package/package.json +11 -11
  13. package/src/editor-manager/plugin/clearformat-exec.js +1 -1
  14. package/src/editor-manager/plugin/clearformat.d.ts +1 -1
  15. package/src/editor-manager/plugin/clearformat.js +2 -2
  16. package/src/editor-manager/plugin/ms-word-clean-up.js +4 -3
  17. package/src/editor-manager/plugin/selection-commands.d.ts +1 -0
  18. package/src/editor-manager/plugin/selection-commands.js +102 -63
  19. package/src/editor-manager/plugin/table.js +13 -2
  20. package/src/editor-manager/plugin/video.js +2 -1
  21. package/src/rich-text-editor/actions/paste-clean-up.d.ts +2 -0
  22. package/src/rich-text-editor/actions/paste-clean-up.js +60 -23
  23. package/src/rich-text-editor/actions/xhtml-validation.js +2 -1
  24. package/src/rich-text-editor/base/rich-text-editor.js +17 -0
  25. package/src/rich-text-editor/base/util.js +2 -1
  26. package/src/rich-text-editor/renderer/iframe-content-renderer.js +1 -1
  27. package/src/rich-text-editor/renderer/image-module.js +2 -2
  28. package/src/rich-text-editor/renderer/video-module.js +2 -2
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * filename: index.d.ts
3
- * version : 21.1.37
3
+ * version : 21.1.41
4
4
  * Copyright Syncfusion Inc. 2001 - 2020. All rights reserved.
5
5
  * Use of this code is subject to the terms of our license.
6
6
  * A copy of the current license can be obtained at any time by e-mailing
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "_from": "@syncfusion/ej2-richtexteditor@*",
3
- "_id": "@syncfusion/ej2-richtexteditor@21.1.35",
3
+ "_id": "@syncfusion/ej2-richtexteditor@21.1.39",
4
4
  "_inBundle": false,
5
- "_integrity": "sha512-F/5VcsdfdmCxlBaWhXV6UM+g6JFmLoXeNBgeq6nIX8nmDsEmMR2oDs5KYgepEcm303Ba49JWT0mTsz4Pf5RGSg==",
5
+ "_integrity": "sha512-1yzkKVbNyZA0gMw+vopynAV+gSdjT/dVWTUJWrcpOE1pW28aAQtqOIl3YSRcJh2slRth9Rx1n8PO16POav8VIQ==",
6
6
  "_location": "/@syncfusion/ej2-richtexteditor",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
@@ -26,8 +26,8 @@
26
26
  "/@syncfusion/ej2-react-richtexteditor",
27
27
  "/@syncfusion/ej2-vue-richtexteditor"
28
28
  ],
29
- "_resolved": "https://nexus.syncfusion.com/repository/ej2-hotfix-new/@syncfusion/ej2-richtexteditor/-/ej2-richtexteditor-21.1.35.tgz",
30
- "_shasum": "778a7276199c001b34a3cea2d27f950fd49041d1",
29
+ "_resolved": "https://nexus.syncfusion.com/repository/ej2-hotfix-new/@syncfusion/ej2-richtexteditor/-/ej2-richtexteditor-21.1.39.tgz",
30
+ "_shasum": "f7145d7b3ec260b94a5bd07f1cde7ee04271faf3",
31
31
  "_spec": "@syncfusion/ej2-richtexteditor@*",
32
32
  "_where": "/jenkins/workspace/elease-automation_release_21.1.1/packages/included",
33
33
  "author": {
@@ -38,13 +38,13 @@
38
38
  },
39
39
  "bundleDependencies": false,
40
40
  "dependencies": {
41
- "@syncfusion/ej2-base": "~21.1.37",
41
+ "@syncfusion/ej2-base": "~21.1.40",
42
42
  "@syncfusion/ej2-buttons": "~21.1.37",
43
- "@syncfusion/ej2-filemanager": "~21.1.37",
44
- "@syncfusion/ej2-inputs": "~21.1.37",
45
- "@syncfusion/ej2-navigations": "~21.1.37",
46
- "@syncfusion/ej2-popups": "~21.1.37",
47
- "@syncfusion/ej2-splitbuttons": "~21.1.37"
43
+ "@syncfusion/ej2-filemanager": "~21.1.41",
44
+ "@syncfusion/ej2-inputs": "~21.1.39",
45
+ "@syncfusion/ej2-navigations": "~21.1.39",
46
+ "@syncfusion/ej2-popups": "~21.1.41",
47
+ "@syncfusion/ej2-splitbuttons": "~21.1.41"
48
48
  },
49
49
  "deprecated": false,
50
50
  "description": "Essential JS 2 RichTextEditor component",
@@ -70,6 +70,6 @@
70
70
  "url": "git+https://github.com/syncfusion/ej2-javascript-ui-controls.git"
71
71
  },
72
72
  "typings": "index.d.ts",
73
- "version": "21.1.37",
73
+ "version": "21.1.41",
74
74
  "sideEffects": false
75
75
  }
@@ -34,7 +34,7 @@ var ClearFormatExec = /** @class */ (function () {
34
34
  };
35
35
  ClearFormatExec.prototype.applyClear = function (e) {
36
36
  if (e.subCommand === 'ClearFormat') {
37
- ClearFormat.clear(this.parent.currentDocument, this.parent.editableElement, e.enterAction, e.selector);
37
+ ClearFormat.clear(this.parent.currentDocument, this.parent.editableElement, e.enterAction, e.selector, e.subCommand);
38
38
  if (e.callBack) {
39
39
  e.callBack({
40
40
  requestType: e.subCommand,
@@ -16,7 +16,7 @@ export declare class ClearFormat {
16
16
  * @hidden
17
17
 
18
18
  */
19
- static clear(docElement: Document, endNode: Node, enterAction: string, selector?: string): void;
19
+ static clear(docElement: Document, endNode: Node, enterAction: string, selector?: string, command?: string): void;
20
20
  private static reSelection;
21
21
  private static clearBlocks;
22
22
  private static spliceParent;
@@ -22,7 +22,7 @@ var ClearFormat = /** @class */ (function () {
22
22
  * @hidden
23
23
 
24
24
  */
25
- ClearFormat.clear = function (docElement, endNode, enterAction, selector) {
25
+ ClearFormat.clear = function (docElement, endNode, enterAction, selector, command) {
26
26
  this.domNode = new DOMNode(endNode, docElement);
27
27
  this.defaultTag = enterAction === 'P' ? this.defaultTag : 'div';
28
28
  var nodeSelection = new NodeSelection();
@@ -32,7 +32,7 @@ var ClearFormat = /** @class */ (function () {
32
32
  nodeSelection.getSelectionNodeCollectionBr(range);
33
33
  var save = nodeSelection.save(range, docElement);
34
34
  var cursorRange = false;
35
- if (range.collapsed) {
35
+ if (range.collapsed && command !== 'ClearFormat') {
36
36
  cursorRange = true;
37
37
  range = nodeCutter.GetCursorRange(docElement, range, nodes[0]);
38
38
  }
@@ -123,6 +123,7 @@ var MsWordPaste = /** @class */ (function () {
123
123
  if (!isNOU(imgElem[i].getAttribute('v:shapes')) &&
124
124
  imgElem[i].getAttribute('v:shapes').indexOf('Picture') < 0 &&
125
125
  imgElem[i].getAttribute('v:shapes').indexOf('圖片') < 0 &&
126
+ imgElem[i].getAttribute('v:shapes').indexOf('Grafik') < 0 &&
126
127
  imgElem[i].getAttribute('v:shapes').indexOf('Image') < 0) {
127
128
  detach(imgElem[i]);
128
129
  }
@@ -217,7 +218,7 @@ var MsWordPaste = /** @class */ (function () {
217
218
  MsWordPaste.prototype.hexConversion = function (rtfData) {
218
219
  // eslint-disable-next-line
219
220
  var picHead = /\{\\pict[\s\S]+?\\bliptag\-?\d+(\\blipupi\-?\d+)?(\{\\\*\\blipuid\s?[\da-fA-F]+)?[\s\}]*?/;
220
- // eslint-disable-next-line security/detect-non-literal-regexp
221
+ // eslint-disable-next-line
221
222
  var pic = new RegExp('(?:(' + picHead.source + '))([\\da-fA-F\\s]+)\\}', 'g');
222
223
  var fullImg = rtfData.match(pic);
223
224
  var imgType;
@@ -281,9 +282,9 @@ var MsWordPaste = /** @class */ (function () {
281
282
  MsWordPaste.prototype.removeUnwantedElements = function (elm) {
282
283
  var innerElement = elm.innerHTML;
283
284
  for (var i = 0; i < this.removableElements.length; i++) {
284
- // eslint-disable-next-line security/detect-non-literal-regexp
285
+ // eslint-disable-next-line
285
286
  var regExpStartElem = new RegExp('<' + this.removableElements[i] + '>', 'g');
286
- // eslint-disable-next-line security/detect-non-literal-regexp
287
+ // eslint-disable-next-line
287
288
  var regExpEndElem = new RegExp('</' + this.removableElements[i] + '>', 'g');
288
289
  innerElement = innerElement.replace(regExpStartElem, '');
289
290
  innerElement = innerElement.replace(regExpEndElem, '');
@@ -21,6 +21,7 @@ export declare class SelectionCommands {
21
21
  private static removeFormat;
22
22
  private static insertFormat;
23
23
  private static applyStyles;
24
+ private static getPriorityFormatNode;
24
25
  private static getInsertNode;
25
26
  private static getChildNode;
26
27
  private static applySelection;
@@ -96,18 +96,13 @@ var SelectionCommands = /** @class */ (function () {
96
96
  isSubSup = formatNode === null ? false : true;
97
97
  }
98
98
  }
99
- else if ((format === 'fontsize' || format === 'fontname' || format === 'fontcolor' || format === 'backgroundcolor') && range.startContainer.parentElement === endNode) {
100
- formatNode = null;
101
- }
102
99
  if (index === 0 && formatNode === null) {
103
100
  isFormat = true;
104
101
  }
105
102
  if (formatNode !== null && (!isFormat || isFontStyle)) {
106
103
  nodes[index] = this.removeFormat(nodes, index, formatNode, isCursor, isFormat, isFontStyle, range, nodeCutter, format, value, domSelection, endNode, domNode);
107
104
  }
108
- else if (range.startContainer.parentElement !== endNode ||
109
- (range.commonAncestorContainer !== endNode && range.startContainer.parentElement === endNode)
110
- || (range.commonAncestorContainer === endNode || nodes.length === 1)) {
105
+ else {
111
106
  nodes[index] = this.insertFormat(docElement, nodes, index, formatNode, isCursor, isFormat, isFontStyle, range, nodeCutter, format, value, painterValues, domNode, endNode);
112
107
  }
113
108
  domSelection = this.applySelection(nodes, domSelection, nodeCutter, index, isCollapsed);
@@ -259,6 +254,27 @@ var SelectionCommands = /** @class */ (function () {
259
254
  nodes[index] = lastNode.firstChild;
260
255
  }
261
256
  }
257
+ else if (isFontStyle && !nodes[index].contains(formatNode) && nodes[index].nodeType === 3 &&
258
+ nodes[index].textContent !== formatNode.textContent) {
259
+ // If the selection is within the format node .
260
+ var isFullNodeSelected = nodes[index].textContent === nodes[index].wholeText;
261
+ var nodeTraverse = nodes[index];
262
+ var styleElement = this.GetFormatNode(format, value);
263
+ // while loop and traverse back until text content does not match with parent text content
264
+ while (nodeTraverse && nodeTraverse.textContent === nodeTraverse.parentElement.textContent) {
265
+ nodeTraverse = nodeTraverse.parentElement;
266
+ }
267
+ if (isFullNodeSelected && formatNode.textContent !== nodeTraverse.textContent) {
268
+ var nodeArray = [];
269
+ var priorityNode = this.getPriorityFormatNode(nodeTraverse, endNode);
270
+ if (priorityNode && priorityNode.textContent === nodeTraverse.textContent) {
271
+ nodeTraverse = priorityNode;
272
+ }
273
+ nodeArray.push(nodeTraverse);
274
+ this.applyStyles(nodeArray, 0, styleElement);
275
+ return nodes[index];
276
+ }
277
+ }
262
278
  var fontStyle;
263
279
  if (format === 'backgroundcolor') {
264
280
  fontStyle = formatNode.style.fontSize;
@@ -405,23 +421,9 @@ var SelectionCommands = /** @class */ (function () {
405
421
  return nodes[index];
406
422
  };
407
423
  SelectionCommands.insertFormat = function (docElement, nodes, index, formatNode, isCursor, isFormat, isFontStyle, range, nodeCutter, format, value, painterValues, domNode, endNode) {
408
- var rootElementNode;
409
424
  if (!isCursor) {
410
425
  if ((formatNode === null && isFormat) || isFontStyle) {
411
426
  if (nodes[index].nodeName !== 'BR') {
412
- if (format === 'fontsize' || format === 'fontname' || format === 'fontcolor' || format === 'backgroundcolor') {
413
- var rangeNode = nodes[index];
414
- while (rangeNode && !domNode.isBlockNode(rangeNode) && rangeNode !== endNode) {
415
- if (domNode.isBlockNode(rangeNode.parentElement)) {
416
- rootElementNode = rangeNode;
417
- }
418
- rangeNode = rangeNode.parentElement;
419
- }
420
- if (rootElementNode && rootElementNode.nodeType !== 3) {
421
- nodeCutter.SplitNode(range, rootElementNode, true).cloneNode(true);
422
- nodeCutter.SplitNode(range, rootElementNode, false).cloneNode(false);
423
- }
424
- }
425
427
  nodes[index] = nodeCutter.GetSpliceNode(range, nodes[index]);
426
428
  nodes[index].textContent = nodeCutter.TrimLineBreak(nodes[index].textContent);
427
429
  }
@@ -431,57 +433,63 @@ var SelectionCommands = /** @class */ (function () {
431
433
  }
432
434
  else if (!(isFontStyle === true && value === '')) {
433
435
  var element = this.GetFormatNode(format, value);
434
- if (value === 'formatPainter' || format === 'fontsize' || format === 'fontcolor' || format === 'fontname' || format === 'backgroundcolor') {
435
- if (format !== 'fontname' && format !== 'backgroundcolor') {
436
- var liElement = nodes[index].parentElement;
437
- var parentElement = nodes[index].parentElement;
438
- while (!isNOU(parentElement) && parentElement.tagName.toLowerCase() !== 'li') {
439
- parentElement = parentElement.parentElement;
440
- liElement = parentElement;
436
+ if (value === 'formatPainter' || isFontStyle) {
437
+ var liElement = nodes[index].parentElement;
438
+ var parentElement = nodes[index].parentElement;
439
+ while (!isNOU(parentElement) && parentElement.tagName.toLowerCase() !== 'li') {
440
+ parentElement = parentElement.parentElement;
441
+ liElement = parentElement;
442
+ }
443
+ if (!isNOU(liElement) && liElement.tagName.toLowerCase() === 'li' &&
444
+ liElement.textContent.trim() === nodes[index].textContent.trim()) {
445
+ if (format === 'fontsize') {
446
+ liElement.style.fontSize = value;
441
447
  }
442
- if (!isNOU(liElement) && liElement.tagName.toLowerCase() === 'li' &&
443
- liElement.textContent.trim() === nodes[index].textContent.trim()) {
444
- if (format === 'fontsize') {
445
- liElement.style.fontSize = value;
446
- }
447
- else {
448
- liElement.style.color = value;
449
- liElement.style.textDecoration = 'inherit';
450
- }
448
+ else if (format === 'fontcolor') {
449
+ liElement.style.color = value;
450
+ liElement.style.textDecoration = 'inherit';
451
451
  }
452
452
  }
453
- if (rootElementNode && rootElementNode.nodeType !== 3 && rootElementNode.nodeName !== 'A') {
454
- var save = new NodeSelection();
455
- save.save(range, docElement);
456
- domNode.setMarker(save);
457
- var cloneNode = rootElementNode.cloneNode(true);
458
- element.appendChild(cloneNode);
459
- domNode.replaceWith(rootElementNode, element.outerHTML);
460
- var currentStartNode = endNode.querySelector('.e-editor-select-start');
461
- var currrentEndNode = endNode.querySelector('.e-editor-select-end');
462
- if (index === 0) {
463
- nodes[index] = currentStartNode ? currentStartNode.lastChild : nodes[index];
464
- }
465
- if (range.startContainer.parentElement === endNode) {
466
- if (nodes.length > 1) {
467
- nodes[nodes.length - 1] = currrentEndNode ? currrentEndNode.lastChild : nodes[index];
453
+ if (value === 'formatPainter') {
454
+ return this.insertFormatPainterElem(nodes, index, range, nodeCutter, painterValues, domNode);
455
+ }
456
+ var currentNode = nodes[index];
457
+ var priorityNode = this.getPriorityFormatNode(currentNode, endNode);
458
+ // 1. Checking is there any priority node present in the selection range. (Use case for nested styles);
459
+ // 2 Or font style is applied. (Use case not a nested style)
460
+ if (!isNOU(priorityNode) || isFontStyle) {
461
+ var currentFormatNode = isNOU(priorityNode) ? currentNode : priorityNode;
462
+ currentFormatNode = !isNOU(priorityNode) && priorityNode.style.fontSize !== '' ?
463
+ currentFormatNode.firstChild : currentFormatNode;
464
+ if (isNOU(priorityNode) || format === 'fontsize') {
465
+ while (currentFormatNode) {
466
+ var isSameTextContent = currentFormatNode.parentElement.textContent.trim()
467
+ === nodes[index].textContent.trim();
468
+ if (!domNode.isBlockNode(currentFormatNode.parentElement) && isSameTextContent) {
469
+ currentFormatNode = currentFormatNode.parentElement;
470
+ }
471
+ else {
472
+ break;
473
+ }
468
474
  }
469
475
  }
470
- domNode.saveMarker(save, null);
471
- }
472
- else {
473
- if (value === 'formatPainter') {
474
- return this.insertFormatPainterElem(nodes, index, range, nodeCutter, painterValues, domNode);
476
+ var nodeList = [];
477
+ // Since color is different for different themnes, we need to wrap the fontColor over the text node.
478
+ if (format === 'fontcolor') {
479
+ var closestAnchor = closest(nodes[index].parentElement, 'A');
480
+ if (!isNOU(closestAnchor) && closestAnchor.firstChild.textContent.trim()
481
+ === nodes[index].textContent.trim()) {
482
+ currentFormatNode = nodes[index];
483
+ }
475
484
  }
476
- else {
477
- nodes[index] = this.applyStyles(nodes, index, element);
485
+ if (nodes[index].textContent.trim() !== currentFormatNode.textContent.trim()) {
486
+ currentFormatNode = nodes[index];
478
487
  }
488
+ nodeList[0] = currentFormatNode;
489
+ this.applyStyles(nodeList, 0, element);
479
490
  }
480
- if (format === 'fontsize') {
481
- var bg = closest(nodes[index].parentElement, 'span[style*=' + 'background-color' + ']');
482
- if (!isNOU(bg)) {
483
- nodes[index].parentElement.style.backgroundColor = bg.style.backgroundColor;
484
- }
491
+ else {
492
+ nodes[index] = this.applyStyles(nodes, index, element);
485
493
  }
486
494
  }
487
495
  else {
@@ -514,6 +522,37 @@ var SelectionCommands = /** @class */ (function () {
514
522
  }
515
523
  return nodes[index];
516
524
  };
525
+ SelectionCommands.getPriorityFormatNode = function (node, endNode) {
526
+ var isFormatted = new IsFormatted();
527
+ var fontSizeNode = isFormatted.getFormattedNode(node, 'fontsize', endNode);
528
+ var fontColorNode;
529
+ var backgroundColorNode;
530
+ var fontNameNode;
531
+ if (isNOU(fontSizeNode)) {
532
+ backgroundColorNode = isFormatted.getFormattedNode(node, 'backgroundcolor', endNode);
533
+ if (isNOU(backgroundColorNode)) {
534
+ fontNameNode = isFormatted.getFormattedNode(node, 'fontname', endNode);
535
+ if (isNOU(fontNameNode)) {
536
+ fontColorNode = isFormatted.getFormattedNode(node, 'fontcolor', endNode);
537
+ if (isNOU(fontColorNode)) {
538
+ return null;
539
+ }
540
+ else {
541
+ return fontColorNode;
542
+ }
543
+ }
544
+ else {
545
+ return fontNameNode;
546
+ }
547
+ }
548
+ else {
549
+ return backgroundColorNode;
550
+ }
551
+ }
552
+ else {
553
+ return fontSizeNode;
554
+ }
555
+ };
517
556
  SelectionCommands.getInsertNode = function (docElement, range, format, value) {
518
557
  var element = this.GetFormatNode(format, value);
519
558
  element.innerHTML = '&#8203;';
@@ -348,8 +348,19 @@ var TableCommand = /** @class */ (function () {
348
348
  if (j === 0 || allCells[maxI][j] !== allCells[maxI][j - 1]) {
349
349
  if (1 < parseInt(allCells[maxI][j].getAttribute('rowspan'), 10)) {
350
350
  var rowSpanVal = parseInt(allCells[maxI][j].getAttribute('rowspan'), 10) - 1;
351
- //eslint-disable-next-line
352
- 1 === rowSpanVal ? allCells[maxI][j].removeAttribute('rowspan') : allCells[maxI][j].setAttribute('rowspan', rowSpanVal.toString());
351
+ /* eslint-disable */
352
+ if (1 === rowSpanVal) {
353
+ allCells[maxI][j].removeAttribute('rowspan');
354
+ var cell = allCells[maxI][j].cloneNode(true);
355
+ allCells = this.getCorrespondingColumns();
356
+ if (allCells[rowSpanVal][j] && allCells[rowSpanVal][j].parentElement) {
357
+ allCells[rowSpanVal][j].parentElement.insertBefore(cell, allCells[rowSpanVal][j]);
358
+ }
359
+ }
360
+ else {
361
+ allCells[maxI][j].setAttribute('rowspan', rowSpanVal.toString());
362
+ }
363
+ /* eslint-enable */
353
364
  }
354
365
  }
355
366
  // eslint-disable-next-line max-len
@@ -161,8 +161,9 @@ var VideoCommand = /** @class */ (function () {
161
161
  : (Browser.isIE ? selectedNode : !e.item.isEmbedUrl ? selectedNode.lastElementChild : selectedNode.querySelector('iframe'));
162
162
  videoElm_1.addEventListener(videoElm_1.tagName !== 'IFRAME' ? 'loadeddata' : 'load', function () {
163
163
  if (e.value !== 'VideoReplace' || !isReplaced) {
164
- if (e.item.isEmbedUrl && videoElm_1)
164
+ if (e.item.isEmbedUrl && videoElm_1) {
165
165
  videoElm_1.classList.add('e-rte-embed-url');
166
+ }
166
167
  e.callBack({
167
168
  requestType: 'Videos',
168
169
  editorMode: 'HTML',
@@ -27,6 +27,7 @@ export declare class PasteCleanup {
27
27
  private destroy;
28
28
  private removeEventListener;
29
29
  private pasteClean;
30
+ private fireFoxImageUpload;
30
31
  private splitBreakLine;
31
32
  private makeSpace;
32
33
  private imgUploading;
@@ -55,6 +56,7 @@ export declare class PasteCleanup {
55
56
  private destroyDialog;
56
57
  private cleanAppleClass;
57
58
  private formatting;
59
+ private setImageProperties;
58
60
  private addTempClass;
59
61
  private removeTempClass;
60
62
  private sanitizeHelper;
@@ -5,6 +5,7 @@ import { isNullOrUndefined as isNOU, isNullOrUndefined, detach, extend, addClass
5
5
  import { getUniqueID, Browser } from '@syncfusion/ej2-base';
6
6
  import { CLS_RTE_PASTE_KEEP_FORMAT, CLS_RTE_PASTE_REMOVE_FORMAT, CLS_RTE_PASTE_PLAIN_FORMAT } from '../base/classes';
7
7
  import { CLS_RTE_PASTE_OK, CLS_RTE_PASTE_CANCEL, CLS_RTE_DIALOG_MIN_HEIGHT } from '../base/classes';
8
+ import { CLS_RTE_IMAGE, CLS_IMGINLINE, CLS_IMGBREAK } from '../base/classes';
8
9
  import { pasteCleanupGroupingTags } from '../../common/config';
9
10
  import { NodeSelection } from '../../selection/selection';
10
11
  import * as EVENTS from './../../common/constant';
@@ -120,14 +121,22 @@ var PasteCleanup = /** @class */ (function () {
120
121
  this.parent.trigger(events.afterPasteCleanup, { value: value }, function (updatedArgs) {
121
122
  value = updatedArgs.value;
122
123
  });
124
+ var tempDivElem = this.parent.createElement('div');
125
+ tempDivElem.innerHTML = value;
126
+ var isValueNotEmpty = tempDivElem.textContent !== '' || !isNOU(tempDivElem.querySelector('img')) ||
127
+ !isNOU(tempDivElem.querySelector('table'));
123
128
  if (this.parent.pasteCleanupSettings.prompt) {
124
- e.args.preventDefault();
125
- var tempDivElem = this.parent.createElement('div');
126
- tempDivElem.innerHTML = value;
127
- if (tempDivElem.textContent !== '' || !isNOU(tempDivElem.querySelector('img')) ||
128
- !isNOU(tempDivElem.querySelector('table'))) {
129
+ if (isValueNotEmpty) {
130
+ e.args.preventDefault();
129
131
  this.pasteDialog(value, args);
130
132
  }
133
+ else if (Browser.userAgent.indexOf('Firefox') !== -1) {
134
+ this.fireFoxImageUpload();
135
+ }
136
+ }
137
+ else if (!isValueNotEmpty && !this.parent.pasteCleanupSettings.plainText &&
138
+ Browser.userAgent.indexOf('Firefox') !== -1) {
139
+ this.fireFoxImageUpload();
131
140
  }
132
141
  else if (this.parent.pasteCleanupSettings.plainText) {
133
142
  e.args.preventDefault();
@@ -143,6 +152,31 @@ var PasteCleanup = /** @class */ (function () {
143
152
  }
144
153
  }
145
154
  };
155
+ PasteCleanup.prototype.fireFoxImageUpload = function () {
156
+ var _this = this;
157
+ // Timeout 500 is added to capture after default paste image from file manager is completed.
158
+ setTimeout(function () {
159
+ if (Browser.userAgent.indexOf('Firefox') !== -1) {
160
+ var currentFocusNode = _this.nodeSelectionObj.getRange(_this.contentRenderer.getDocument()).startContainer;
161
+ if (currentFocusNode.nodeName !== '#text') {
162
+ currentFocusNode = currentFocusNode.childNodes[_this.nodeSelectionObj.getRange(_this.contentRenderer.getDocument()).startOffset];
163
+ }
164
+ if (currentFocusNode.previousSibling.nodeName === 'IMG') {
165
+ currentFocusNode.previousSibling.classList.add('pasteContent_Img');
166
+ currentFocusNode.previousSibling.classList.add(CLS_RTE_IMAGE);
167
+ if (_this.parent.insertImageSettings.display === 'inline') {
168
+ currentFocusNode.previousSibling.classList.add(CLS_IMGINLINE);
169
+ }
170
+ else {
171
+ currentFocusNode.previousSibling.classList.add(CLS_IMGBREAK);
172
+ }
173
+ currentFocusNode.previousSibling.classList.add();
174
+ _this.setImageProperties(currentFocusNode.previousSibling);
175
+ }
176
+ }
177
+ _this.imgUploading(_this.parent.inputElement);
178
+ }, 500);
179
+ };
146
180
  PasteCleanup.prototype.splitBreakLine = function (value) {
147
181
  var enterSplitText = value.split('\n');
148
182
  var contentInnerElem = '';
@@ -626,24 +660,7 @@ var PasteCleanup = /** @class */ (function () {
626
660
  var allImg = clipBoardElem.querySelectorAll('img');
627
661
  for (var i = 0; i < allImg.length; i++) {
628
662
  allImg[i].classList.add('pasteContent_Img');
629
- if (this.parent.insertImageSettings.width !== 'auto') {
630
- allImg[i].setAttribute('width', this.parent.insertImageSettings.width);
631
- }
632
- if (this.parent.insertImageSettings.minWidth !== '0' && this.parent.insertImageSettings.minWidth !== 0) {
633
- allImg[i].style.minWidth = this.parent.insertImageSettings.minWidth.toString();
634
- }
635
- if (this.parent.insertImageSettings.maxWidth !== null) {
636
- allImg[i].style.maxWidth = this.parent.getInsertImgMaxWidth().toString();
637
- }
638
- if (this.parent.insertImageSettings.height !== 'auto') {
639
- allImg[i].setAttribute('height', this.parent.insertImageSettings.height);
640
- }
641
- if (this.parent.insertImageSettings.minHeight !== '0' && this.parent.insertImageSettings.minHeight !== 0) {
642
- allImg[i].style.minHeight = this.parent.insertImageSettings.minHeight.toString();
643
- }
644
- if (this.parent.insertImageSettings.maxHeight !== null) {
645
- allImg[i].style.maxHeight = this.parent.insertImageSettings.maxHeight.toString();
646
- }
663
+ this.setImageProperties(allImg[i]);
647
664
  }
648
665
  this.addTempClass(clipBoardElem);
649
666
  if (clipBoardElem.textContent !== '' || !isNOU(clipBoardElem.querySelector('img')) ||
@@ -660,6 +677,26 @@ var PasteCleanup = /** @class */ (function () {
660
677
  }
661
678
  }
662
679
  };
680
+ PasteCleanup.prototype.setImageProperties = function (allImg) {
681
+ if (this.parent.insertImageSettings.width !== 'auto') {
682
+ allImg.setAttribute('width', this.parent.insertImageSettings.width);
683
+ }
684
+ if (this.parent.insertImageSettings.minWidth !== '0' && this.parent.insertImageSettings.minWidth !== 0) {
685
+ allImg.style.minWidth = this.parent.insertImageSettings.minWidth.toString();
686
+ }
687
+ if (this.parent.insertImageSettings.maxWidth !== null) {
688
+ allImg.style.maxWidth = this.parent.getInsertImgMaxWidth().toString();
689
+ }
690
+ if (this.parent.insertImageSettings.height !== 'auto') {
691
+ allImg.setAttribute('height', this.parent.insertImageSettings.height);
692
+ }
693
+ if (this.parent.insertImageSettings.minHeight !== '0' && this.parent.insertImageSettings.minHeight !== 0) {
694
+ allImg.style.minHeight = this.parent.insertImageSettings.minHeight.toString();
695
+ }
696
+ if (this.parent.insertImageSettings.maxHeight !== null) {
697
+ allImg.style.maxHeight = this.parent.insertImageSettings.maxHeight.toString();
698
+ }
699
+ };
663
700
  PasteCleanup.prototype.addTempClass = function (clipBoardElem) {
664
701
  var allChild = clipBoardElem.children;
665
702
  for (var i = 0; i < allChild.length; i++) {
@@ -145,7 +145,8 @@ var XhtmlValidation = /** @class */ (function () {
145
145
  var childEle = ele.childNodes[j];
146
146
  if (childEle.nodeType !== 3 && childEle.nodeName !== 'TABLE' && childEle.nodeName !== 'TBODY' &&
147
147
  childEle.nodeName !== 'THEAD' && childEle.nodeName !== 'TH' && childEle.nodeName !== 'TR' &&
148
- childEle.nodeName !== 'TD' && childEle.hasAttribute(attrName)) {
148
+ childEle.nodeName !== 'TD' && childEle.hasAttribute(attrName) &&
149
+ !childEle.classList.contains('e-mention-chip')) {
149
150
  childEle.removeAttribute(attrName);
150
151
  }
151
152
  if (childEle.hasChildNodes()) {
@@ -755,6 +755,9 @@ var RichTextEditor = /** @class */ (function (_super) {
755
755
  if ((!isNOU(this.placeHolderWrapper)) && (this.inputElement.textContent.length !== 1)) {
756
756
  this.placeHolderWrapper.style.display = 'none';
757
757
  }
758
+ else if (this.iframeSettings.enable && this.inputElement.classList.contains("e-rte-placeholder")) {
759
+ removeClass([this.inputElement], "e-rte-placeholder");
760
+ }
758
761
  else {
759
762
  this.setPlaceHolder();
760
763
  }
@@ -1458,6 +1461,17 @@ var RichTextEditor = /** @class */ (function (_super) {
1458
1461
  this.inputElement.setAttribute('placeholder', this.placeholder);
1459
1462
  }
1460
1463
  }
1464
+ if (this.placeholder && this.iframeSettings.enable) {
1465
+ if (this.inputElement.textContent.length === 0 && this.inputElement.childNodes.length < 2 && !isNOU(this.inputElement.firstChild) && (this.inputElement.firstChild.nodeName === 'BR' ||
1466
+ ((this.inputElement.firstChild.nodeName === 'P' || this.inputElement.firstChild.nodeName === 'DIV') && !isNOU(this.inputElement.firstChild.firstChild) &&
1467
+ this.inputElement.firstChild.firstChild.nodeName === 'BR'))) {
1468
+ addClass([this.inputElement], "e-rte-placeholder");
1469
+ this.inputElement.setAttribute('placeholder', this.placeholder);
1470
+ }
1471
+ else {
1472
+ removeClass([this.inputElement], "e-rte-placeholder");
1473
+ }
1474
+ }
1461
1475
  };
1462
1476
  RichTextEditor.prototype.setWidth = function (width) {
1463
1477
  if (width !== 'auto') {
@@ -2183,6 +2197,9 @@ var RichTextEditor = /** @class */ (function (_super) {
2183
2197
  clearInterval(this.timeInterval);
2184
2198
  this.timeInterval = null;
2185
2199
  }
2200
+ if (!isNOU(this.placeHolderWrapper) && this.element.querySelector('[title = Preview]')) {
2201
+ this.placeHolderWrapper.style.display = "none";
2202
+ }
2186
2203
  EventHandler.remove(document, 'mousedown', this.onDocumentClick);
2187
2204
  }
2188
2205
  else {
@@ -512,8 +512,9 @@ export function decode(value) {
512
512
  export function sanitizeHelper(value, parent) {
513
513
  if (parent.enableHtmlSanitizer) {
514
514
  var item = SanitizeHtmlHelper.beforeSanitize();
515
- if (item.selectors.tags[2] && item.selectors.tags[2].indexOf('iframe') > -1)
515
+ if (item.selectors.tags[2] && item.selectors.tags[2].indexOf('iframe') > -1) {
516
516
  item.selectors.tags[2] = 'iframe:not(.e-rte-embed-url)';
517
+ }
517
518
  var beforeEvent = {
518
519
  cancel: false,
519
520
  helper: null