@syncfusion/ej2-richtexteditor 19.4.53 → 19.4.56

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * filename: index.d.ts
3
- * version : 19.4.53
3
+ * version : 19.4.56
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@19.4.52",
3
+ "_id": "@syncfusion/ej2-richtexteditor@19.4.55",
4
4
  "_inBundle": false,
5
- "_integrity": "sha512-xjpEWIVKc57xj8kkwLnXXg6eNcUO79Fr5P15M6qjMemiEQnHthEX6Rcu0kvO9qjQTPaKyqsJXAXJOOhmAQu0zg==",
5
+ "_integrity": "sha512-yCzpe6Glr/5vD9wGZWamZZlXj6Pij6DBLAW2/7gKcFRevy5MG22PPORfDb0WrRRYYYj+kIV2Ea/7nU5HSpmtXw==",
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": "http://nexus.syncfusion.com/repository/ej2-hotfix-new/@syncfusion/ej2-richtexteditor/-/ej2-richtexteditor-19.4.52.tgz",
30
- "_shasum": "b744ad1962f30a8e005044b4f638a796151b8ccb",
29
+ "_resolved": "http://nexus.syncfusion.com/repository/ej2-hotfix-new/@syncfusion/ej2-richtexteditor/-/ej2-richtexteditor-19.4.55.tgz",
30
+ "_shasum": "c71b371a808166cf0c76c804df45bc6723eb4027",
31
31
  "_spec": "@syncfusion/ej2-richtexteditor@*",
32
32
  "_where": "/jenkins/workspace/automation_release_19.1.0.1-ZPMUBNQ6AUYH6YGEFBPVYMEQLRRW2SLD4XCZ6GATNZJFYJ3RIAOA/packages/included",
33
33
  "author": {
@@ -39,10 +39,10 @@
39
39
  "bundleDependencies": false,
40
40
  "dependencies": {
41
41
  "@syncfusion/ej2-base": "~19.4.52",
42
- "@syncfusion/ej2-buttons": "~19.4.53",
43
- "@syncfusion/ej2-filemanager": "~19.4.52",
42
+ "@syncfusion/ej2-buttons": "~19.4.55",
43
+ "@syncfusion/ej2-filemanager": "~19.4.56",
44
44
  "@syncfusion/ej2-inputs": "~19.4.52",
45
- "@syncfusion/ej2-navigations": "~19.4.53",
45
+ "@syncfusion/ej2-navigations": "~19.4.56",
46
46
  "@syncfusion/ej2-popups": "~19.4.53",
47
47
  "@syncfusion/ej2-splitbuttons": "~19.4.52"
48
48
  },
@@ -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": "19.4.53",
73
+ "version": "19.4.56",
74
74
  "sideEffects": false
75
75
  }
@@ -218,7 +218,12 @@ var ImageCommand = /** @class */ (function () {
218
218
  ImageCommand.prototype.removeImage = function (e) {
219
219
  if (closest(e.item.selectNode[0], 'a')) {
220
220
  if (e.item.selectNode[0].parentElement.nodeName === 'A' && !isNOU(e.item.selectNode[0].parentElement.innerText)) {
221
- detach(e.item.selectNode[0]);
221
+ if (!isNOU(closest(e.item.selectNode[0], '.' + classes.CLASS_CAPTION))) {
222
+ detach(closest(e.item.selectNode[0], '.' + classes.CLASS_CAPTION));
223
+ }
224
+ else {
225
+ detach(e.item.selectNode[0]);
226
+ }
222
227
  }
223
228
  else {
224
229
  detach(closest(e.item.selectNode[0], 'a'));
@@ -374,7 +374,7 @@ var InsertHtml = /** @class */ (function () {
374
374
  var currentNode = nodes[nodes.length - 1];
375
375
  var splitedElm = void 0;
376
376
  if ((currentNode.nodeName === 'BR' || currentNode.nodeName === 'HR') && !isNOU(currentNode.parentElement) &&
377
- currentNode.parentElement.textContent.trim().length === 0 && !node.classList.contains('pasteContent')) {
377
+ currentNode.parentElement.textContent.trim().length === 0) {
378
378
  splitedElm = currentNode;
379
379
  }
380
380
  else {
@@ -74,6 +74,11 @@ var LinkCommand = /** @class */ (function () {
74
74
  else {
75
75
  var domSelection = new NodeSelection();
76
76
  var range = domSelection.getRange(this.parent.currentDocument);
77
+ if (range.endContainer.nodeName === '#text' && range.startContainer.textContent.length === (range.endOffset + 1) &&
78
+ range.endContainer.textContent.charAt(range.endOffset) === ' ' && range.endContainer.nextSibling.nodeName === 'A') {
79
+ domSelection.setSelectionText(this.parent.currentDocument, range.startContainer, range.endContainer, range.startOffset, range.endOffset + 1);
80
+ range = domSelection.getRange(this.parent.currentDocument);
81
+ }
77
82
  var text = isNOU(e.item.text) ? true : e.item.text.replace(/ /g, '').localeCompare(range.toString()
78
83
  .replace(/\n/g, ' ').replace(/ /g, '')) < 0;
79
84
  if (e.event && e.event.type === 'keydown' && (e.event.keyCode === 32
@@ -407,6 +407,14 @@ var Lists = /** @class */ (function () {
407
407
  };
408
408
  Lists.prototype.applyListsHandler = function (e) {
409
409
  var range = this.parent.nodeSelection.getRange(this.parent.currentDocument);
410
+ if (range.startContainer === range.endContainer && range.startContainer === this.parent.editableElement &&
411
+ range.startOffset === range.endOffset && range.startOffset === 0 &&
412
+ this.parent.editableElement.textContent.length === 0 && (this.parent.editableElement.childNodes[0].nodeName != 'TABLE' &&
413
+ this.parent.editableElement.childNodes[0].nodeName != 'IMG')) {
414
+ var focusNode = range.startContainer.childNodes[0];
415
+ this.parent.nodeSelection.setSelectionText(this.parent.currentDocument, focusNode, focusNode, 0, 0);
416
+ range = this.parent.nodeSelection.getRange(this.parent.currentDocument);
417
+ }
410
418
  this.saveSelection = this.parent.nodeSelection.save(range, this.parent.currentDocument);
411
419
  this.currentAction = e.subCommand;
412
420
  this.currentAction = e.subCommand = this.currentAction === 'NumberFormatList' ? 'OL' : this.currentAction === 'BulletFormatList' ? 'UL' : this.currentAction;
@@ -110,6 +110,7 @@ var SelectionCommands = /** @class */ (function () {
110
110
  };
111
111
  SelectionCommands.insertCursorNode = function (docElement, domSelection, range, isFormatted, nodeCutter, format, value, endNode) {
112
112
  var cursorNodes = domSelection.getNodeCollection(range);
113
+ var domNode = new DOMNode(endNode, docElement);
113
114
  var cursorFormat = (cursorNodes.length > 0) ?
114
115
  (cursorNodes.length > 1 && range.startContainer === range.endContainer) ?
115
116
  this.getCursorFormat(isFormatted, cursorNodes, format, endNode) :
@@ -117,12 +118,17 @@ var SelectionCommands = /** @class */ (function () {
117
118
  var cursorNode = null;
118
119
  if (cursorFormat) {
119
120
  cursorNode = cursorNodes[0];
120
- if (cursorFormat.firstChild.textContent.charCodeAt(0) === 8203) {
121
+ if (cursorFormat.firstChild.textContent.charCodeAt(0) === 8203 && cursorFormat.firstChild.nodeType === 3) {
121
122
  var isCursorEqual = false;
122
123
  var regEx = new RegExp(String.fromCharCode(8203), 'g');
123
124
  var emptySpaceNode = void 0;
124
125
  if (cursorFormat.firstChild === cursorNode) {
125
- cursorNode.textContent = cursorNode.textContent.replace(regEx, '');
126
+ cursorNode.textContent = (cursorFormat.parentElement && (domNode.isBlockNode(cursorFormat.parentElement) &&
127
+ cursorFormat.parentElement.textContent.length <= 1 ? cursorFormat.parentElement.childElementCount > 1 :
128
+ cursorFormat.childElementCount === 0) &&
129
+ (cursorFormat.parentElement.textContent.length > 1 ||
130
+ cursorFormat.parentElement.firstChild && cursorFormat.parentElement.firstChild.nodeType === 1) ?
131
+ cursorNode.textContent : cursorNode.textContent.replace(regEx, ''));
126
132
  emptySpaceNode = cursorNode;
127
133
  isCursorEqual = true;
128
134
  }
@@ -13,6 +13,7 @@ export declare class EnterKeyAction {
13
13
  private removeEventListener;
14
14
  private getRangeNode;
15
15
  private enterHandler;
16
+ private removeBRElement;
16
17
  private insertBRElement;
17
18
  private insertFocusContent;
18
19
  private createInsertElement;
@@ -1,4 +1,4 @@
1
- import { isNullOrUndefined as isNOU, detach } from '@syncfusion/ej2-base';
1
+ import { isNullOrUndefined as isNOU, detach, Browser } from '@syncfusion/ej2-base';
2
2
  import * as events from '../base/constant';
3
3
  /**
4
4
  * `EnterKey` module is used to handle enter key press actions.
@@ -123,6 +123,7 @@ var EnterKeyAction = /** @class */ (function () {
123
123
  else if (_this.range.startOffset === 0 && _this.range.endOffset === 0) {
124
124
  isFocusedFirst = true;
125
125
  }
126
+ _this.removeBRElement(nearBlockNode);
126
127
  if (((_this.range.startOffset === 0 && _this.range.endOffset === 0) || isFocusedFirst) &&
127
128
  !(!isNOU(_this.range.startContainer.previousSibling) &&
128
129
  (_this.range.startContainer.previousSibling.nodeName === 'IMG' || _this.range.startContainer.previousSibling.nodeName === 'BR'))) {
@@ -226,6 +227,7 @@ var EnterKeyAction = /** @class */ (function () {
226
227
  else {
227
228
  currentParent = _this.startNode;
228
229
  }
230
+ _this.removeBRElement(currentParent);
229
231
  var isEmptyBrInserted = false;
230
232
  var currentParentLastChild = currentParent.lastChild;
231
233
  while (!isNOU(currentParentLastChild) && !(currentParentLastChild.nodeName === '#text' || currentParentLastChild.nodeName === 'BR')) {
@@ -288,6 +290,13 @@ var EnterKeyAction = /** @class */ (function () {
288
290
  }
289
291
  }
290
292
  };
293
+ EnterKeyAction.prototype.removeBRElement = function (currentElement) {
294
+ if (Browser.userAgent.indexOf('Firefox') != -1 &&
295
+ this.range.endOffset === currentElement.textContent.length &&
296
+ currentElement.lastChild.nodeName === 'BR') {
297
+ detach(currentElement.lastChild);
298
+ }
299
+ };
291
300
  EnterKeyAction.prototype.insertBRElement = function () {
292
301
  var isEmptyBrInserted = false;
293
302
  var brElm = this.parent.createElement('br');
@@ -18,6 +18,7 @@ export declare class HtmlEditor {
18
18
  private oldRangeElement;
19
19
  private deleteRangeElement;
20
20
  private deleteOldRangeElement;
21
+ private isImageDelete;
21
22
  private saveSelection;
22
23
  xhtmlValidation: XhtmlValidation;
23
24
  constructor(parent?: IRichTextEditor, serviceLocator?: ServiceLocator);
@@ -20,6 +20,7 @@ import { ON_BEGIN } from './../../common/constant';
20
20
  var HtmlEditor = /** @class */ (function () {
21
21
  function HtmlEditor(parent, serviceLocator) {
22
22
  this.rangeCollection = [];
23
+ this.isImageDelete = false;
23
24
  this.parent = parent;
24
25
  this.locator = serviceLocator;
25
26
  this.renderFactory = this.locator.getService('rendererFactory');
@@ -105,7 +106,9 @@ var HtmlEditor = /** @class */ (function () {
105
106
  this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), range.startContainer, pointer);
106
107
  }
107
108
  if (!isNOU(range.startContainer.previousSibling) && !isNOU(range.startContainer.previousSibling.parentElement) &&
108
- range.startContainer.parentElement === range.startContainer.previousSibling.parentElement && range.startContainer.previousSibling.textContent.charCodeAt(0) === 8203) {
109
+ range.startContainer.parentElement === range.startContainer.previousSibling.parentElement &&
110
+ range.startContainer.previousSibling.textContent.charCodeAt(0) === 8203 &&
111
+ range.startContainer.previousSibling.textContent.length <= 1) {
109
112
  range.startContainer.previousSibling.textContent = range.startContainer.previousSibling.textContent.replace(regEx, '');
110
113
  }
111
114
  if (range.endContainer.textContent.charCodeAt(range.endOffset) === 8203) {
@@ -193,7 +196,9 @@ var HtmlEditor = /** @class */ (function () {
193
196
  this.oldRangeElement = null;
194
197
  this.deleteRangeElement = null;
195
198
  this.deleteOldRangeElement = null;
196
- args.preventDefault();
199
+ if (!this.isImageDelete) {
200
+ args.preventDefault();
201
+ }
197
202
  }
198
203
  };
199
204
  HtmlEditor.prototype.isOrderedList = function (editorValue) {
@@ -317,7 +322,15 @@ var HtmlEditor = /** @class */ (function () {
317
322
  return;
318
323
  }
319
324
  else {
320
- this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), this.deleteRangeElement, this.deleteRangeElement.childNodes.length);
325
+ if (currentRange.startOffset === 0 && currentRange.endOffset === 1 &&
326
+ this.deleteRangeElement.childNodes[0].nodeName === 'IMG') {
327
+ this.parent.formatter.editorManager.nodeSelection.setSelectionText(this.parent.contentModule.getDocument(), this.deleteRangeElement, this.deleteRangeElement, 0, 1);
328
+ this.isImageDelete = true;
329
+ }
330
+ else {
331
+ this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), this.deleteRangeElement, this.deleteRangeElement.childNodes.length);
332
+ this.isImageDelete = false;
333
+ }
321
334
  if (this.deleteRangeElement.querySelector('BR')) {
322
335
  detach(this.deleteRangeElement.querySelector('BR'));
323
336
  }
@@ -27,6 +27,7 @@ export declare class PasteCleanup {
27
27
  private makeSpace;
28
28
  private imgUploading;
29
29
  private getBlob;
30
+ private toolbarEnableDisable;
30
31
  private uploadMethod;
31
32
  private uploadFailure;
32
33
  private popupClose;
@@ -212,6 +212,11 @@ var PasteCleanup = /** @class */ (function () {
212
212
  }
213
213
  }
214
214
  };
215
+ PasteCleanup.prototype.toolbarEnableDisable = function (state) {
216
+ if (!this.parent.inlineMode.enable) {
217
+ this.parent.toolbarModule.baseToolbar.toolbarObj.disable(state);
218
+ }
219
+ };
215
220
  PasteCleanup.prototype.uploadMethod = function (fileList, imgElem) {
216
221
  var _this = this;
217
222
  var uploadEle = document.createElement('div');
@@ -288,6 +293,7 @@ var PasteCleanup = /** @class */ (function () {
288
293
  if (beforeUploadArgs.cancel) {
289
294
  return;
290
295
  }
296
+ _this.toolbarEnableDisable(true);
291
297
  /* eslint-disable */
292
298
  uploadObj.currentRequestHeader = beforeUploadArgs.currentRequest ?
293
299
  beforeUploadArgs.currentRequest : uploadObj.currentRequestHeader;
@@ -299,6 +305,7 @@ var PasteCleanup = /** @class */ (function () {
299
305
  }
300
306
  else {
301
307
  _this.parent.trigger(events.beforeImageUpload, args);
308
+ _this.toolbarEnableDisable(true);
302
309
  }
303
310
  },
304
311
  // eslint-disable-next-line
@@ -371,6 +378,7 @@ var PasteCleanup = /** @class */ (function () {
371
378
  popupObj.close();
372
379
  imgElem.style.opacity = '1';
373
380
  uploadObj.destroy();
381
+ this.toolbarEnableDisable(false);
374
382
  };
375
383
  PasteCleanup.prototype.refreshPopup = function (imageElement, popupObj) {
376
384
  var imgPosition = this.parent.iframeSettings.enable ? this.parent.element.offsetTop +
@@ -1059,6 +1059,7 @@ export declare class RichTextEditor extends Component<HTMLElement> implements IN
1059
1059
  * @hidden
1060
1060
  */
1061
1061
  protected eventInitializer(): void;
1062
+ cleanList(e: KeyboardEvent): void;
1062
1063
  /**
1063
1064
  * For internal use only - keydown the event handler;
1064
1065
  *
@@ -463,6 +463,27 @@ var RichTextEditor = /** @class */ (function (_super) {
463
463
  RichTextEditor.prototype.eventInitializer = function () {
464
464
  this.wireEvents();
465
465
  };
466
+ RichTextEditor.prototype.cleanList = function (e) {
467
+ var range = this.getRange();
468
+ var currentStartContainer = range.startContainer;
469
+ var currentEndContainer = range.endContainer;
470
+ var currentStartOffset = range.startOffset;
471
+ var isSameContainer = currentStartContainer === currentEndContainer ? true : false;
472
+ var currentEndOffset;
473
+ var endNode = range.endContainer.nodeName === '#text' ? range.endContainer.parentElement :
474
+ range.endContainer;
475
+ var closestLI = closest(endNode, 'LI');
476
+ if (!isNOU(closestLI) && endNode.textContent.length === range.endOffset &&
477
+ !range.collapsed) {
478
+ closestLI.textContent = closestLI.textContent.trim();
479
+ currentEndOffset = closestLI.textContent.length - 1;
480
+ var currentLastElem = closestLI;
481
+ while (currentLastElem.nodeName !== '#text') {
482
+ currentLastElem = currentLastElem.lastChild;
483
+ }
484
+ this.formatter.editorManager.nodeSelection.setSelectionText(this.contentModule.getDocument(), isSameContainer ? currentLastElem : currentStartContainer, currentLastElem, currentStartOffset, currentLastElem.textContent.length);
485
+ }
486
+ };
466
487
  /**
467
488
  * For internal use only - keydown the event handler;
468
489
  *
@@ -475,6 +496,9 @@ var RichTextEditor = /** @class */ (function (_super) {
475
496
  RichTextEditor.prototype.keyDown = function (e) {
476
497
  this.notify(events.keyDown, { member: 'keydown', args: e });
477
498
  this.restrict(e);
499
+ if (this.editorMode === 'HTML') {
500
+ this.cleanList(e);
501
+ }
478
502
  if (this.editorMode === 'HTML' && ((e.which === 8 && e.code === 'Backspace') || (e.which === 46 && e.code === 'Delete'))) {
479
503
  var range = this.getRange();
480
504
  var startNode = range.startContainer.nodeName === '#text' ? range.startContainer.parentElement :
@@ -1846,7 +1846,8 @@ var Image = /** @class */ (function () {
1846
1846
  if (activePopupElement) {
1847
1847
  activePopupElement.classList.add(classes.CLS_HIDE);
1848
1848
  }
1849
- if (e.dataTransfer.files.length > 0) { //For external image drag and drop
1849
+ var imgElement = this.parent.inputElement.ownerDocument.querySelector('.' + classes.CLS_RTE_DRAG_IMAGE);
1850
+ if (e.dataTransfer.files.length > 0 && imgElement === null) { //For external image drag and drop
1850
1851
  if (e.dataTransfer.files.length > 1) {
1851
1852
  return;
1852
1853
  }
@@ -1869,7 +1870,6 @@ var Image = /** @class */ (function () {
1869
1870
  }
1870
1871
  else { //For internal image drag and drop
1871
1872
  var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
1872
- var imgElement = this.parent.inputElement.ownerDocument.querySelector('.' + classes.CLS_RTE_DRAG_IMAGE);
1873
1873
  if (imgElement && imgElement.tagName === 'IMG') {
1874
1874
  if (imgElement.nextElementSibling) {
1875
1875
  if (imgElement.nextElementSibling.classList.contains(classes.CLS_IMG_INNER)) {
@@ -511,7 +511,7 @@ var Table = /** @class */ (function () {
511
511
  return;
512
512
  }
513
513
  var target = e.target || e.targetTouches[0].target;
514
- var closestTable = closest(target, 'table');
514
+ var closestTable = closest(target, 'table.e-rte-table');
515
515
  if (!isNOU(this.curTable) && !isNOU(closestTable) && closestTable !== this.curTable) {
516
516
  this.removeResizeElement();
517
517
  this.removeHelper(e);