@syncfusion/ej2-richtexteditor 27.1.52 → 27.1.57

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 (43) hide show
  1. package/dist/ej2-richtexteditor.min.js +10 -0
  2. package/dist/ej2-richtexteditor.umd.min.js +2 -2
  3. package/dist/ej2-richtexteditor.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-richtexteditor.es2015.js +244 -60
  5. package/dist/es6/ej2-richtexteditor.es2015.js.map +1 -1
  6. package/dist/es6/ej2-richtexteditor.es5.js +245 -59
  7. package/dist/es6/ej2-richtexteditor.es5.js.map +1 -1
  8. package/dist/global/ej2-richtexteditor.min.js +2 -2
  9. package/dist/global/ej2-richtexteditor.min.js.map +1 -1
  10. package/dist/global/index.d.ts +1 -1
  11. package/package.json +13 -13
  12. package/src/common/config.d.ts +7 -0
  13. package/src/common/config.js +12 -0
  14. package/src/editor-manager/base/editor-manager.js +1 -1
  15. package/src/editor-manager/base/interface.d.ts +2 -2
  16. package/src/editor-manager/plugin/clearformat.js +1 -1
  17. package/src/editor-manager/plugin/dom-node.js +1 -1
  18. package/src/editor-manager/plugin/image.js +2 -0
  19. package/src/editor-manager/plugin/inserthtml.d.ts +1 -0
  20. package/src/editor-manager/plugin/inserthtml.js +34 -10
  21. package/src/editor-manager/plugin/link.js +2 -2
  22. package/src/editor-manager/plugin/lists.js +1 -1
  23. package/src/editor-manager/plugin/ms-word-clean-up.d.ts +1 -0
  24. package/src/editor-manager/plugin/ms-word-clean-up.js +16 -0
  25. package/src/editor-manager/plugin/selection-commands.js +2 -2
  26. package/src/editor-manager/plugin/toolbar-status.js +1 -1
  27. package/src/editor-manager/plugin/undo.js +3 -3
  28. package/src/rich-text-editor/actions/enter-key.js +10 -5
  29. package/src/rich-text-editor/actions/html-editor.js +2 -2
  30. package/src/rich-text-editor/actions/import-export.js +1 -1
  31. package/src/rich-text-editor/actions/paste-clean-up.js +1 -1
  32. package/src/rich-text-editor/actions/resize.d.ts +3 -0
  33. package/src/rich-text-editor/actions/resize.js +17 -0
  34. package/src/rich-text-editor/base/interface.d.ts +13 -1
  35. package/src/rich-text-editor/base/rich-text-editor.js +11 -0
  36. package/src/rich-text-editor/renderer/audio-module.js +7 -1
  37. package/src/rich-text-editor/renderer/image-module.js +57 -20
  38. package/src/rich-text-editor/renderer/link-module.js +8 -1
  39. package/src/rich-text-editor/renderer/slash-menu.js +1 -1
  40. package/src/rich-text-editor/renderer/table-module.js +3 -2
  41. package/src/rich-text-editor/renderer/video-module.js +8 -2
  42. package/src/selection/selection.d.ts +5 -0
  43. package/src/selection/selection.js +44 -1
@@ -8,7 +8,7 @@ import { Button, CheckBox } from '@syncfusion/ej2-buttons';
8
8
  import { RenderType, ImageInputSource } from '../base/enum';
9
9
  import { dispatchEvent, parseHtml, hasClass, convertToBlob } from '../base/util';
10
10
  import { isIDevice } from '../../common/util';
11
- import { imageResizeFactor } from '../../common/config';
11
+ import { iframeResizeFactor, imageResizeFactor } from '../../common/config';
12
12
  /**
13
13
  * `Image` module is used to handle image actions.
14
14
  */
@@ -208,8 +208,14 @@ var Image = /** @class */ (function () {
208
208
  if (this.parent.formatter.getUndoRedoStack().length === 0) {
209
209
  this.parent.formatter.saveData();
210
210
  }
211
- this.pageX = this.getPointX(e);
212
- this.pageY = this.getPointY(e);
211
+ if (this.parent.iframeSettings.enable) {
212
+ this.pageX = e.screenX;
213
+ this.pageY = e.screenY;
214
+ }
215
+ else {
216
+ this.pageX = this.getPointX(e);
217
+ this.pageY = this.getPointY(e);
218
+ }
213
219
  e.preventDefault();
214
220
  e.stopImmediatePropagation();
215
221
  this.resizeBtnInit();
@@ -474,29 +480,50 @@ var Image = /** @class */ (function () {
474
480
  return;
475
481
  }
476
482
  if (this.resizeBtnStat.botRight || this.resizeBtnStat.botLeft || this.resizeBtnStat.topRight || this.resizeBtnStat.topLeft) {
477
- var pageX = this.getPointX(e);
478
- var pageY = this.getPointY(e);
479
- var resizeFactor = this.getResizeFactor(this.currentResizeHandler);
480
- var diffX = (pageX - this.pageX);
481
- var diffY = (pageY - this.pageY);
482
- var currentWidth = this.imgEle.clientWidth;
483
- var currentHeight = this.imgEle.clientHeight;
484
- var width = diffX * resizeFactor[0] + currentWidth;
485
- var height = diffY * resizeFactor[1] + currentHeight;
486
- var dimensions = this.adjustDimensions(width, height, diffX, diffY, this.aspectRatio);
487
- this.pageX = pageX;
488
- this.pageY = pageY;
489
- this.imgDupMouseMove(dimensions.width + 'px', dimensions.height + 'px', e);
483
+ if (this.parent.iframeSettings.enable) {
484
+ var resizeFactor = this.getResizeFactor(this.currentResizeHandler);
485
+ var currentScreenX = e.screenX;
486
+ var currentScreenY = e.screenY;
487
+ var currentWidth = this.imgEle.clientWidth;
488
+ var currentHeight = this.imgEle.clientHeight;
489
+ var deltaX = currentScreenX - this.pageX;
490
+ var deltaY = currentScreenY - this.pageY;
491
+ var width = deltaX * resizeFactor[0] + currentWidth;
492
+ var height = deltaY * resizeFactor[1] + currentHeight;
493
+ var dimensions = this.adjustDimensions(width, height, deltaX, deltaY, this.aspectRatio);
494
+ this.pageX = currentScreenX;
495
+ this.pageY = currentScreenY;
496
+ this.imgDupMouseMove(dimensions.width + 'px', dimensions.height + 'px', e);
497
+ this.parent.autoResize();
498
+ }
499
+ else {
500
+ var pageX = this.getPointX(e);
501
+ var pageY = this.getPointY(e);
502
+ var resizeFactor = this.getResizeFactor(this.currentResizeHandler);
503
+ var diffX = (pageX - this.pageX);
504
+ var diffY = (pageY - this.pageY);
505
+ var currentWidth = this.imgEle.clientWidth;
506
+ var currentHeight = this.imgEle.clientHeight;
507
+ var width = diffX * resizeFactor[0] + currentWidth;
508
+ var height = diffY * resizeFactor[1] + currentHeight;
509
+ var dimensions = this.adjustDimensions(width, height, diffX, diffY, this.aspectRatio);
510
+ this.pageX = pageX;
511
+ this.pageY = pageY;
512
+ this.imgDupMouseMove(dimensions.width + 'px', dimensions.height + 'px', e);
513
+ }
490
514
  }
491
515
  };
492
516
  Image.prototype.adjustDimensions = function (width, height, diffX, diffY, aspectRatio) {
493
517
  width = (width < 16) ? 16 : width;
494
518
  height = (height < 16) ? 16 : height;
495
- var isWidthPrimary = Math.abs(diffX) > Math.abs(diffY);
519
+ var isWidthPrimary = width > height;
496
520
  var dimensions = this.adjustDimensionsByAspectRatio(width, height, aspectRatio, isWidthPrimary);
497
521
  return dimensions;
498
522
  };
499
523
  Image.prototype.getResizeFactor = function (value) {
524
+ if (this.parent.iframeSettings.enable) {
525
+ return iframeResizeFactor[value];
526
+ }
500
527
  return imageResizeFactor[value];
501
528
  };
502
529
  Image.prototype.findAspectRatio = function (image) {
@@ -568,11 +595,15 @@ var Image = /** @class */ (function () {
568
595
  }
569
596
  };
570
597
  Image.prototype.openImgLink = function (e) {
598
+ var sanitizedHTML = this.parent.htmlEditorModule.sanitizeHelper(e.selectParent[0].parentNode.outerHTML);
599
+ var tempEle = document.createElement('div');
600
+ tempEle.innerHTML = sanitizedHTML;
571
601
  var target = e.selectParent[0].parentNode.target === '' ? '_self' : '_blank';
572
602
  this.parent.formatter.process(this.parent, e.args, e.args, {
573
- url: e.selectParent[0].parentNode.href, target: target, selectNode: e.selectNode,
603
+ url: tempEle.firstChild.href, target: target, selectNode: e.selectNode,
574
604
  subCommand: e.args.item.subCommand
575
605
  });
606
+ tempEle.remove();
576
607
  };
577
608
  Image.prototype.editImgLink = function (e) {
578
609
  var selectParentEle = e.selectParent[0].parentNode;
@@ -659,7 +690,7 @@ var Image = /** @class */ (function () {
659
690
  }
660
691
  }
661
692
  if (originalEvent.keyCode === 8 || originalEvent.keyCode === 46) {
662
- if (selectNodeEle && selectNodeEle[0].nodeName === 'IMG' && selectNodeEle.length < 1) {
693
+ if (selectNodeEle && selectNodeEle[0] && selectNodeEle[0].nodeName === 'IMG' && selectNodeEle.length < 1) {
663
694
  if (!isNOU(this.parent.formatter.editorManager.nodeSelection)) {
664
695
  save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
665
696
  }
@@ -1586,6 +1617,9 @@ var Image = /** @class */ (function () {
1586
1617
  proxy.uploadUrl.cssClass = (proxy.parent.insertImageSettings.display === 'inline' ?
1587
1618
  classes.CLS_IMGINLINE : classes.CLS_IMGBREAK);
1588
1619
  proxy.dialogObj.hide({ returnValue: false });
1620
+ if (proxy.dialogObj !== null) {
1621
+ return;
1622
+ }
1589
1623
  proxy.parent.formatter.process(proxy.parent, this.args, this.args.originalEvent, proxy.uploadUrl);
1590
1624
  proxy.uploadUrl.url = '';
1591
1625
  if (proxy.contentModule.getEditPanel().querySelector('.e-img-resize')) {
@@ -1616,8 +1650,11 @@ var Image = /** @class */ (function () {
1616
1650
  maxHeight: proxy.parent.insertImageSettings.maxHeight
1617
1651
  }
1618
1652
  };
1619
- proxy.parent.formatter.process(proxy.parent, this.args, this.args.originalEvent, value);
1620
1653
  proxy.dialogObj.hide({ returnValue: false });
1654
+ if (proxy.dialogObj !== null) {
1655
+ return;
1656
+ }
1657
+ proxy.parent.formatter.process(proxy.parent, this.args, this.args.originalEvent, value);
1621
1658
  }
1622
1659
  };
1623
1660
  Image.prototype.imgsizeInput = function (e) {
@@ -427,6 +427,9 @@ var Link = /** @class */ (function () {
427
427
  if (document.body.contains(proxy.dialogObj.element)) {
428
428
  this.selfLink.dialogObj.hide({ returnValue: false });
429
429
  }
430
+ if (this.selfLink.dialogObj !== null) {
431
+ return;
432
+ }
430
433
  if (isIDevice() && proxy.parent.iframeSettings.enable) {
431
434
  select('iframe', proxy.parent.element).contentWindow.focus();
432
435
  }
@@ -491,11 +494,15 @@ var Link = /** @class */ (function () {
491
494
  Link.prototype.openLink = function (e) {
492
495
  var selectParentEle = this.getAnchorNode(e.selectParent[0]);
493
496
  if (selectParentEle.classList.contains('e-rte-anchor') || selectParentEle.tagName === 'A') {
497
+ var sanitizedHTML = this.parent.htmlEditorModule.sanitizeHelper(selectParentEle.outerHTML);
498
+ var tempEle = document.createElement('div');
499
+ tempEle.innerHTML = sanitizedHTML;
494
500
  this.parent.formatter.process(this.parent, e.args, e.args, {
495
- url: selectParentEle.href, text: selectParentEle.innerText,
501
+ url: tempEle.firstChild.href, text: selectParentEle.innerText,
496
502
  target: selectParentEle.target === '' ? '_self' : '_blank', selectNode: e.selectNode,
497
503
  subCommand: e.args.item.subCommand
498
504
  });
505
+ tempEle.remove();
499
506
  }
500
507
  };
501
508
  Link.prototype.getAnchorNode = function (element) {
@@ -9,7 +9,7 @@ var SlashMenu = /** @class */ (function () {
9
9
  this.parent = options;
10
10
  this.currentDocument = this.parent.element.ownerDocument;
11
11
  this.L10n = serviceLocator.getService('rteLocale');
12
- this.savedSelection = new NodeSelection();
12
+ this.savedSelection = new NodeSelection(this.parent.inputElement);
13
13
  this.defaultItems = defaultSlashMenuDataModel;
14
14
  this.injectibleItems = injectibleSlashMenuDataModel;
15
15
  this.parent.on(events.modelChanged, this.onPropertyChanged, this);
@@ -1419,7 +1419,8 @@ var Table = /** @class */ (function () {
1419
1419
  else {
1420
1420
  var tableReBox = _this.contentModule.getEditPanel().querySelector('.e-table-box');
1421
1421
  var tableWidth = parseInt(getComputedStyle(_this.curTable).width, 10);
1422
- var tableHeight = parseInt(getComputedStyle(_this.curTable).height, 10);
1422
+ var tableHeight = !isNaN(parseInt(_this.curTable.style.height, 10)) ?
1423
+ parseInt(_this.curTable.style.height, 10) : parseInt(getComputedStyle(_this.curTable).height, 10);
1423
1424
  var paddingSize = +getComputedStyle(_this.contentModule.getEditPanel()).paddingRight.match(/\d/g).join('');
1424
1425
  var rteWidth = _this.contentModule.getEditPanel().offsetWidth -
1425
1426
  (_this.contentModule.getEditPanel().offsetWidth -
@@ -1564,7 +1565,7 @@ var Table = /** @class */ (function () {
1564
1565
  _this.curTable.style.height = tableHeight + mouseY + 'px';
1565
1566
  if (!isNOU(tableReBox)) {
1566
1567
  tableReBox.classList.add('e-rbox-select');
1567
- tableReBox.style.cssText = 'top: ' + (_this.calcPos(_this.curTable).top + tableHeight - 4) +
1568
+ tableReBox.style.cssText = 'top: ' + (_this.calcPos(_this.curTable).top + parseInt(getComputedStyle(_this.curTable).height, 10) - 4) +
1568
1569
  'px; left:' + (_this.calcPos(_this.curTable).left + tableWidth - 4) + 'px;';
1569
1570
  }
1570
1571
  if (_this.curTable.closest('li')) {
@@ -670,7 +670,7 @@ var Video = /** @class */ (function () {
670
670
  this.undoStack({ subCommand: (originalEvent.keyCode === 90 ? 'undo' : 'redo') });
671
671
  }
672
672
  if (originalEvent.keyCode === 8 || originalEvent.keyCode === 46) {
673
- if (selectNodeEle && (selectNodeEle[0].nodeName === 'VIDEO' || this.isEmbedVidElem(selectNodeEle[0])) && selectNodeEle.length < 1) {
673
+ if (selectNodeEle && selectNodeEle[0] && (selectNodeEle[0].nodeName === 'VIDEO' || this.isEmbedVidElem(selectNodeEle[0])) && selectNodeEle.length < 1) {
674
674
  if (!isNullOrUndefined(this.parent.formatter.editorManager.nodeSelection)) {
675
675
  save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
676
676
  }
@@ -1446,6 +1446,9 @@ var Video = /** @class */ (function () {
1446
1446
  maxHeight: proxy.parent.insertVideoSettings.maxHeight
1447
1447
  };
1448
1448
  proxy.dialogObj.hide({ returnValue: false });
1449
+ if (proxy.dialogObj !== null) {
1450
+ return;
1451
+ }
1449
1452
  proxy.parent.formatter.process(proxy.parent, this.args, this.args.originalEvent, proxy.uploadUrl);
1450
1453
  proxy.uploadUrl.url = '';
1451
1454
  }
@@ -1472,8 +1475,11 @@ var Video = /** @class */ (function () {
1472
1475
  maxHeight: proxy.parent.insertVideoSettings.maxHeight
1473
1476
  }
1474
1477
  };
1475
- proxy.parent.formatter.process(proxy.parent, this.args, this.args.originalEvent, value);
1476
1478
  proxy.dialogObj.hide({ returnValue: false });
1479
+ if (proxy.dialogObj !== null) {
1480
+ return;
1481
+ }
1482
+ proxy.parent.formatter.process(proxy.parent, this.args, this.args.originalEvent, value);
1477
1483
  }
1478
1484
  };
1479
1485
  /* eslint-disable */
@@ -12,6 +12,8 @@ export declare class NodeSelection {
12
12
  endOffset: number;
13
13
  startNodeName: string[];
14
14
  endNodeName: string[];
15
+ editableElement: HTMLElement | HTMLBodyElement;
16
+ constructor(editElement?: HTMLElement | HTMLBodyElement);
15
17
  private saveInstance;
16
18
  private documentFromRange;
17
19
  getRange(docElement: Document): Range;
@@ -231,4 +233,7 @@ export declare class NodeSelection {
231
233
 
232
234
  */
233
235
  setCursorPoint(docElement: Document, element: Element, point: number): void;
236
+ private isTableOrImageStart;
237
+ private isTableOrImageEnd;
238
+ private processedTableImageCursor;
234
239
  }
@@ -3,9 +3,10 @@ import { isNullOrUndefined } from '@syncfusion/ej2-base';
3
3
  * `Selection` module is used to handle RTE Selections.
4
4
  */
5
5
  var NodeSelection = /** @class */ (function () {
6
- function NodeSelection() {
6
+ function NodeSelection(editElement) {
7
7
  this.startNodeName = [];
8
8
  this.endNodeName = [];
9
+ this.editableElement = editElement;
9
10
  }
10
11
  NodeSelection.prototype.saveInstance = function (range, body) {
11
12
  this.range = range.cloneRange();
@@ -85,6 +86,9 @@ var NodeSelection = /** @class */ (function () {
85
86
  return false;
86
87
  };
87
88
  NodeSelection.prototype.getNode = function (startNode, endNode, nodeCollection) {
89
+ if (this.editableElement && (!this.editableElement.contains(startNode) || this.editableElement === startNode)) {
90
+ return null;
91
+ }
88
92
  if (endNode === startNode &&
89
93
  (startNode.nodeType === 3 || !startNode.firstChild || nodeCollection.indexOf(startNode.firstChild) !== -1
90
94
  || this.isChildNode(nodeCollection, startNode))) {
@@ -119,6 +123,12 @@ var NodeSelection = /** @class */ (function () {
119
123
  || range.startContainer;
120
124
  var endNode = range.endContainer.childNodes[(range.endOffset > 0) ? (range.endOffset - 1) : range.endOffset]
121
125
  || range.endContainer;
126
+ var tableCursor = this.processedTableImageCursor(range);
127
+ if (tableCursor.start || tableCursor.end) {
128
+ if (tableCursor.startName === 'TABLE' || tableCursor.endName === 'TABLE') {
129
+ return [];
130
+ }
131
+ }
122
132
  if ((startNode === endNode || (startNode.nodeName === 'BR' && startNode === range.endContainer.childNodes[range.endOffset])) &&
123
133
  startNode.childNodes.length === 0) {
124
134
  return [startNode];
@@ -438,6 +448,39 @@ var NodeSelection = /** @class */ (function () {
438
448
  selection.removeAllRanges();
439
449
  selection.addRange(range);
440
450
  };
451
+ NodeSelection.prototype.isTableOrImageStart = function (range) {
452
+ var customHandlerElements = ['TABLE'];
453
+ var startContainer = range.startContainer;
454
+ var startOffset = range.startOffset;
455
+ var isCursorAtStart = range.collapsed && (startContainer.nodeType === 1) &&
456
+ startContainer.isContentEditable && startContainer.childNodes[startOffset] &&
457
+ (customHandlerElements.indexOf(startContainer.childNodes[startOffset].nodeName) > -1);
458
+ if (isCursorAtStart) {
459
+ return { start: isCursorAtStart, startNodeName: startContainer.childNodes[startOffset].nodeName };
460
+ }
461
+ else {
462
+ return { start: false, startNodeName: '' };
463
+ }
464
+ };
465
+ NodeSelection.prototype.isTableOrImageEnd = function (range) {
466
+ var customHandlerElements = ['TABLE'];
467
+ var startContainer = range.startContainer;
468
+ var startOffset = range.startOffset;
469
+ var isCursorAtEnd = range.collapsed && (startContainer.nodeType === 1) &&
470
+ startContainer.isContentEditable && startContainer.childNodes[startOffset - 1] &&
471
+ (customHandlerElements.indexOf(startContainer.childNodes[startOffset - 1].nodeName) > -1);
472
+ if (isCursorAtEnd) {
473
+ return { end: isCursorAtEnd, endNodeName: startContainer.childNodes[startOffset - 1].nodeName };
474
+ }
475
+ else {
476
+ return { end: false, endNodeName: '' };
477
+ }
478
+ };
479
+ NodeSelection.prototype.processedTableImageCursor = function (range) {
480
+ var _a = this.isTableOrImageStart(range), start = _a.start, startNodeName = _a.startNodeName;
481
+ var _b = this.isTableOrImageEnd(range), end = _b.end, endNodeName = _b.endNodeName;
482
+ return { start: start, startName: startNodeName, end: end, endName: endNodeName };
483
+ };
441
484
  return NodeSelection;
442
485
  }());
443
486
  export { NodeSelection };