@syncfusion/ej2-richtexteditor 19.3.55 → 19.4.47

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/.github/PULL_REQUEST_TEMPLATE/Bug.md +41 -0
  2. package/.github/PULL_REQUEST_TEMPLATE/Feature.md +27 -0
  3. package/CHANGELOG.md +37 -1
  4. package/README.md +1 -1
  5. package/dist/ej2-richtexteditor.umd.min.js +2 -2
  6. package/dist/ej2-richtexteditor.umd.min.js.map +1 -1
  7. package/dist/es6/ej2-richtexteditor.es2015.js +250 -100
  8. package/dist/es6/ej2-richtexteditor.es2015.js.map +1 -1
  9. package/dist/es6/ej2-richtexteditor.es5.js +249 -99
  10. package/dist/es6/ej2-richtexteditor.es5.js.map +1 -1
  11. package/dist/global/ej2-richtexteditor.min.js +2 -2
  12. package/dist/global/ej2-richtexteditor.min.js.map +1 -1
  13. package/dist/global/index.d.ts +1 -1
  14. package/package.json +12 -12
  15. package/src/editor-manager/plugin/inserthtml.js +9 -1
  16. package/src/editor-manager/plugin/lists.js +4 -2
  17. package/src/editor-manager/plugin/ms-word-clean-up.d.ts +1 -1
  18. package/src/editor-manager/plugin/ms-word-clean-up.js +54 -20
  19. package/src/editor-manager/plugin/selection-commands.js +10 -5
  20. package/src/editor-manager/plugin/undo.js +10 -1
  21. package/src/rich-text-editor/actions/color-picker.d.ts +1 -0
  22. package/src/rich-text-editor/actions/color-picker.js +2 -1
  23. package/src/rich-text-editor/actions/dropdown-buttons.js +0 -10
  24. package/src/rich-text-editor/actions/enter-key.d.ts +1 -0
  25. package/src/rich-text-editor/actions/enter-key.js +90 -37
  26. package/src/rich-text-editor/actions/html-editor.js +4 -3
  27. package/src/rich-text-editor/actions/quick-toolbar.js +1 -1
  28. package/src/rich-text-editor/actions/xhtml-validation.js +1 -1
  29. package/src/rich-text-editor/base/interface.d.ts +3 -1
  30. package/src/rich-text-editor/base/rich-text-editor-model.d.ts +1 -1
  31. package/src/rich-text-editor/base/rich-text-editor.d.ts +1 -1
  32. package/src/rich-text-editor/base/rich-text-editor.js +2 -2
  33. package/src/rich-text-editor/formatter/formatter.js +3 -3
  34. package/src/rich-text-editor/models/toolbar-settings-model.d.ts +1 -1
  35. package/src/rich-text-editor/models/toolbar-settings.d.ts +1 -1
  36. package/src/rich-text-editor/models/toolbar-settings.js +1 -1
  37. package/src/rich-text-editor/renderer/image-module.js +53 -7
  38. package/src/rich-text-editor/renderer/toolbar-renderer.d.ts +1 -1
  39. package/src/rich-text-editor/renderer/toolbar-renderer.js +3 -2
  40. package/src/selection/selection.js +2 -1
  41. package/styles/rich-text-editor/_fluent-definition.scss +168 -0
  42. package/styles/rich-text-editor/_layout.scss +1 -1
  43. package/styles/rich-text-editor/icons/_fluent.scss +303 -0
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * filename: index.d.ts
3
- * version : 19.3.55
3
+ * version : 19.4.47
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.3.53",
3
+ "_id": "@syncfusion/ej2-richtexteditor@19.4.40",
4
4
  "_inBundle": false,
5
- "_integrity": "sha512-/w+XuY76VuYlFVyWhywJW+qPNC4qAsf4ICsEMJiaYSD0uMlEDlQdAEw56vCbKF+gMnWRUp0uBwCcRZYKPkFifQ==",
5
+ "_integrity": "sha512-NXliovnItdi7jrn+x5uT0dk6n171w7mBNe3K8VkThnEoJ80R6o419mz36rq9IyB2jZJoDBlSO7WrU8Lel+5lWA==",
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/@syncfusion/ej2-richtexteditor/-/ej2-richtexteditor-19.3.53.tgz",
30
- "_shasum": "ebf91ca62866526e3e847bbcb454f3d193c0bab2",
29
+ "_resolved": "http://nexus.syncfusion.com/repository/ej2-hotfix-new/@syncfusion/ej2-richtexteditor/-/ej2-richtexteditor-19.4.40.tgz",
30
+ "_shasum": "6a824e374410a7eda59dc02e5886f29637159629",
31
31
  "_spec": "@syncfusion/ej2-richtexteditor@*",
32
32
  "_where": "/jenkins/workspace/automation_release_19.1.0.1-ZPMUBNQ6AUYH6YGEFBPVYMEQLRRW2SLD4XCZ6GATNZJFYJ3RIAOA/packages/included",
33
33
  "author": {
@@ -38,13 +38,13 @@
38
38
  },
39
39
  "bundleDependencies": false,
40
40
  "dependencies": {
41
- "@syncfusion/ej2-base": "~19.3.54",
42
- "@syncfusion/ej2-buttons": "~19.3.53",
43
- "@syncfusion/ej2-filemanager": "~19.3.55",
44
- "@syncfusion/ej2-inputs": "~19.3.53",
45
- "@syncfusion/ej2-navigations": "~19.3.54",
46
- "@syncfusion/ej2-popups": "~19.3.53",
47
- "@syncfusion/ej2-splitbuttons": "~19.3.53"
41
+ "@syncfusion/ej2-base": "~19.4.42",
42
+ "@syncfusion/ej2-buttons": "~19.4.42",
43
+ "@syncfusion/ej2-filemanager": "~19.4.47",
44
+ "@syncfusion/ej2-inputs": "~19.4.47",
45
+ "@syncfusion/ej2-navigations": "~19.4.47",
46
+ "@syncfusion/ej2-popups": "~19.4.47",
47
+ "@syncfusion/ej2-splitbuttons": "~19.4.47"
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": "19.3.55",
73
+ "version": "19.4.47",
74
74
  "sideEffects": false
75
75
  }
@@ -370,7 +370,15 @@ var InsertHtml = /** @class */ (function () {
370
370
  tempSpan.parentNode.replaceChild(node, tempSpan);
371
371
  }
372
372
  else {
373
- var splitedElm = nodeCutter.GetSpliceNode(range, blockNode);
373
+ var currentNode = nodes[nodes.length - 1];
374
+ var splitedElm = void 0;
375
+ if ((currentNode.nodeName === 'BR' || currentNode.nodeName === 'HR') && !isNOU(currentNode.parentElement) &&
376
+ currentNode.parentElement.textContent.trim().length === 0 && !node.classList.contains('pasteContent')) {
377
+ splitedElm = currentNode;
378
+ }
379
+ else {
380
+ splitedElm = nodeCutter.GetSpliceNode(range, blockNode);
381
+ }
374
382
  splitedElm.parentNode.replaceChild(node, splitedElm);
375
383
  }
376
384
  }
@@ -46,8 +46,9 @@ var Lists = /** @class */ (function () {
46
46
  Lists.prototype.testCurrentList = function (range) {
47
47
  var olListStartRegex = [/^[1]+[.]+$/, /^[i]+[.]+$/, /^[a]+[.]+$/];
48
48
  if (!isNullOrUndefined(range.startContainer.textContent.slice(0, range.startOffset))) {
49
+ var currentContent = range.startContainer.textContent.replace(/\u200B/g, '').slice(0, range.startOffset).trim();
49
50
  for (var i = 0; i < olListStartRegex.length; i++) {
50
- if (olListStartRegex[i].test(range.startContainer.textContent.replace(/\u200B/g, '').slice(0, range.startOffset).trim())) {
51
+ if (olListStartRegex[i].test(currentContent) && currentContent.length === 2) {
51
52
  return true;
52
53
  }
53
54
  }
@@ -89,7 +90,8 @@ var Lists = /** @class */ (function () {
89
90
  range.startContainer.parentElement.closest('LI');
90
91
  var endNode = range.endContainer.nodeName === 'LI' ? range.endContainer :
91
92
  range.endContainer.parentElement.closest('LI');
92
- if (!isNOU(startNode) && !isNOU(endNode) && startNode === endNode && startNode.tagName === 'LI' && startNode.textContent.trim() === '') {
93
+ if (!isNOU(startNode) && !isNOU(endNode) && startNode === endNode && startNode.tagName === 'LI' &&
94
+ startNode.textContent.trim() === '' && startNode.querySelectorAll('IMG').length === 0) {
93
95
  if (startNode.textContent.charCodeAt(0) === 65279) {
94
96
  startNode.textContent = '';
95
97
  }
@@ -38,7 +38,7 @@ export declare class MsWordPaste {
38
38
  private removingComments;
39
39
  private cleanUp;
40
40
  private listConverter;
41
+ private getlistStyleType;
41
42
  private makeConversion;
42
- private getListStyle;
43
43
  private getListContent;
44
44
  }
@@ -46,7 +46,7 @@ var MsWordPaste = /** @class */ (function () {
46
46
  this.parent.observer.on(EVENTS.MS_WORD_CLEANUP_PLUGIN, this.wordCleanup, this);
47
47
  };
48
48
  MsWordPaste.prototype.wordCleanup = function (e) {
49
- var wordPasteStyleConfig = e.allowedStylePropertiesArray;
49
+ var wordPasteStyleConfig = !isNOU(e.allowedStylePropertiesArray) ? e.allowedStylePropertiesArray : [];
50
50
  var listNodes = [];
51
51
  var tempHTMLContent = e.args.clipboardData.getData('text/HTML');
52
52
  var rtfData = e.args.clipboardData.getData('text/rtf');
@@ -471,8 +471,10 @@ var MsWordPaste = /** @class */ (function () {
471
471
  this.listContents = [];
472
472
  this.getListContent(listNodes[i]);
473
473
  var type = void 0;
474
+ var listStyleType = void 0;
474
475
  if (!isNOU(this.listContents[0])) {
475
476
  type = this.listContents[0].trim().length > 1 ? 'ol' : 'ul';
477
+ listStyleType = this.getlistStyleType(this.listContents[0], type);
476
478
  var tempNode = [];
477
479
  for (var j = 1; j < this.listContents.length; j++) {
478
480
  tempNode.push(this.listContents[j]);
@@ -489,7 +491,7 @@ var MsWordPaste = /** @class */ (function () {
489
491
  }
490
492
  }
491
493
  collection.push({ listType: type, content: tempNode, nestedLevel: level, class: currentClassName,
492
- listStyle: currentListStyle });
494
+ listStyle: currentListStyle, listStyleTypeName: listStyleType });
493
495
  }
494
496
  }
495
497
  stNode = listNodes.shift();
@@ -513,6 +515,45 @@ var MsWordPaste = /** @class */ (function () {
513
515
  }
514
516
  }
515
517
  };
518
+ MsWordPaste.prototype.getlistStyleType = function (listContent, type) {
519
+ var currentListClass;
520
+ if (type === 'ol') {
521
+ switch (listContent.split('.')[0]) {
522
+ case "A":
523
+ currentListClass = "upper-alpha";
524
+ break;
525
+ case "a":
526
+ currentListClass = "lower-alpha";
527
+ break;
528
+ case "I":
529
+ currentListClass = "upper-roman";
530
+ break;
531
+ case "i":
532
+ currentListClass = "lower-roman";
533
+ break;
534
+ case "α":
535
+ currentListClass = "lower-greek";
536
+ break;
537
+ default:
538
+ currentListClass = "decimal";
539
+ break;
540
+ }
541
+ }
542
+ else {
543
+ switch (listContent.split('.')[0]) {
544
+ case "o":
545
+ currentListClass = "circle";
546
+ break;
547
+ case "§":
548
+ currentListClass = "square";
549
+ break;
550
+ default:
551
+ currentListClass = "disc";
552
+ break;
553
+ }
554
+ }
555
+ return currentListClass;
556
+ };
516
557
  MsWordPaste.prototype.makeConversion = function (collection) {
517
558
  var root = createElement('div');
518
559
  var temp;
@@ -529,7 +570,7 @@ var MsWordPaste = /** @class */ (function () {
529
570
  prevList.appendChild(pElement);
530
571
  temp.appendChild(prevList);
531
572
  temp.setAttribute('level', collection[index].nestedLevel.toString());
532
- temp.style.listStyle = this.getListStyle(collection[index].listType, collection[index].nestedLevel);
573
+ temp.style.listStyleType = collection[index].listStyleTypeName;
533
574
  }
534
575
  else if (collection[index].nestedLevel === pLevel) {
535
576
  if (prevList.parentElement.tagName.toLowerCase() === collection[index].listType) {
@@ -538,6 +579,7 @@ var MsWordPaste = /** @class */ (function () {
538
579
  }
539
580
  else {
540
581
  temp = createElement(collection[index].listType);
582
+ temp.style.listStyleType = collection[index].listStyleTypeName;
541
583
  prevList.parentElement.parentElement.appendChild(temp);
542
584
  prevList = createElement('li');
543
585
  prevList.appendChild(pElement);
@@ -549,14 +591,15 @@ var MsWordPaste = /** @class */ (function () {
549
591
  if (!isNOU(prevList)) {
550
592
  for (var j = 0; j < collection[index].nestedLevel - pLevel; j++) {
551
593
  prevList.appendChild(temp = createElement(collection[index].listType));
552
- prevList = createElement('li', { styles: 'list-style-type: none;' });
594
+ prevList = createElement('li');
595
+ if (j != collection[index].nestedLevel - pLevel - 1 && collection[index].nestedLevel - pLevel > 1) {
596
+ prevList.style.listStyleType = "none";
597
+ }
553
598
  temp.appendChild(prevList);
554
599
  }
555
600
  prevList.appendChild(pElement);
556
601
  temp.setAttribute('level', collection[index].nestedLevel.toString());
557
- temp.style.listStyle = this.getListStyle(collection[index].listType, collection[index].nestedLevel);
558
- temp.childNodes[0].style.listStyle =
559
- this.getListStyle(collection[index].listType, collection[index].nestedLevel);
602
+ temp.style.listStyleType = collection[index].listStyleTypeName;
560
603
  }
561
604
  else {
562
605
  root.appendChild(temp = createElement(collection[index].listType));
@@ -564,7 +607,7 @@ var MsWordPaste = /** @class */ (function () {
564
607
  prevList.appendChild(pElement);
565
608
  temp.appendChild(prevList);
566
609
  temp.setAttribute('level', collection[index].nestedLevel.toString());
567
- temp.style.listStyle = this.getListStyle(collection[index].listType, collection[index].nestedLevel);
610
+ temp.style.listStyleType = collection[index].listStyleTypeName;
568
611
  }
569
612
  }
570
613
  else if (collection[index].nestedLevel === 1) {
@@ -573,12 +616,12 @@ var MsWordPaste = /** @class */ (function () {
573
616
  }
574
617
  else {
575
618
  root.appendChild(temp = createElement(collection[index].listType));
619
+ temp.style.listStyleType = collection[index].listStyleTypeName;
576
620
  }
577
621
  prevList = createElement('li');
578
622
  prevList.appendChild(pElement);
579
623
  temp.appendChild(prevList);
580
624
  temp.setAttribute('level', collection[index].nestedLevel.toString());
581
- temp.style.listStyle = this.getListStyle(collection[index].listType, collection[index].nestedLevel);
582
625
  }
583
626
  else {
584
627
  elem = prevList;
@@ -599,7 +642,7 @@ var MsWordPaste = /** @class */ (function () {
599
642
  prevList.appendChild(pElement);
600
643
  temp.appendChild(prevList);
601
644
  temp.setAttribute('level', collection[index].nestedLevel.toString());
602
- temp.style.listStyle = this.getListStyle(collection[index].listType, collection[index].nestedLevel);
645
+ temp.style.listStyleType = collection[index].listStyleTypeName;
603
646
  break;
604
647
  }
605
648
  }
@@ -608,21 +651,12 @@ var MsWordPaste = /** @class */ (function () {
608
651
  }
609
652
  prevList.setAttribute('class', collection[index].class);
610
653
  var currentStyle = prevList.getAttribute('style');
611
- prevList.setAttribute('style', (!isNOU(currentStyle) ? currentStyle : '') + collection[index].listStyle);
654
+ prevList.setAttribute('style', (!isNOU(currentStyle) ? currentStyle : ''));
612
655
  pLevel = collection[index].nestedLevel;
613
656
  listCount++;
614
657
  }
615
658
  return root;
616
659
  };
617
- MsWordPaste.prototype.getListStyle = function (listType, nestedLevel) {
618
- nestedLevel = (nestedLevel > 0) ? nestedLevel - 1 : nestedLevel;
619
- if (listType === 'ol') {
620
- return (nestedLevel < this.olData.length ? this.olData[nestedLevel] : this.olData[0]);
621
- }
622
- else {
623
- return (nestedLevel < this.ulData.length ? this.ulData[nestedLevel] : this.ulData[0]);
624
- }
625
- };
626
660
  MsWordPaste.prototype.getListContent = function (elem) {
627
661
  var pushContent = '';
628
662
  var firstChild = elem.firstElementChild;
@@ -188,6 +188,9 @@ var SelectionCommands = /** @class */ (function () {
188
188
  };
189
189
  SelectionCommands.removeFormat = function (nodes, index, formatNode, isCursor, isFormat, isFontStyle, range, nodeCutter, format, value, domSelection, endNode, domNode) {
190
190
  var splitNode = null;
191
+ var startText = range.startContainer.nodeName === '#text' ?
192
+ range.startContainer.textContent.substring(range.startOffset, range.startContainer.textContent.length) :
193
+ range.startContainer.textContent;
191
194
  if (!(range.startContainer === range.endContainer && range.startOffset === 0
192
195
  && range.endOffset === range.startContainer.length)) {
193
196
  var nodeIndex = [];
@@ -287,11 +290,13 @@ var SelectionCommands = /** @class */ (function () {
287
290
  for (var num = 0; num < child.length; num++) {
288
291
  if (child[num].nodeType !== 3 || (child[num].textContent && child[num].textContent.trim().length > 0)) {
289
292
  child[num] = InsertMethods.Wrap(child[num], this.GetFormatNode(format, value, formatNodeTagName, formatNodeStyles));
290
- if (num === 0) {
291
- range.setStartBefore(child[num]);
292
- }
293
- else if (num === child.length - 1) {
294
- range.setEndAfter(child[num]);
293
+ if (child[num].textContent === startText) {
294
+ if (num === 0) {
295
+ range.setStartBefore(child[num]);
296
+ }
297
+ else if (num === child.length - 1) {
298
+ range.setEndAfter(child[num]);
299
+ }
295
300
  }
296
301
  }
297
302
  }
@@ -1,4 +1,4 @@
1
- import { debounce, isNullOrUndefined } from '@syncfusion/ej2-base';
1
+ import { debounce, isNullOrUndefined, detach } from '@syncfusion/ej2-base';
2
2
  import { NodeSelection } from './../../selection/selection';
3
3
  import * as EVENTS from './../../common/constant';
4
4
  import { isIDevice, setEditFrameFocus } from '../../common/util';
@@ -96,6 +96,15 @@ var UndoRedoManager = /** @class */ (function () {
96
96
  */
97
97
  UndoRedoManager.prototype.saveData = function (e) {
98
98
  var range = new NodeSelection().getRange(this.parent.currentDocument);
99
+ var currentContainer = range.startContainer;
100
+ for (var i = currentContainer.childNodes.length - 1; i >= 0; i--) {
101
+ if (!isNullOrUndefined(currentContainer.childNodes[i]) && currentContainer.childNodes[i].nodeName === '#text' &&
102
+ currentContainer.childNodes[i].textContent.length === 0 && currentContainer.childNodes[i].nodeName !== 'IMG' &&
103
+ currentContainer.childNodes[i].nodeName !== 'BR' && currentContainer.childNodes[i].nodeName && 'HR') {
104
+ detach(currentContainer.childNodes[i]);
105
+ }
106
+ }
107
+ range = new NodeSelection().getRange(this.parent.currentDocument);
99
108
  var save = new NodeSelection().save(range, this.parent.currentDocument);
100
109
  var htmlText = this.parent.editableElement.innerHTML;
101
110
  var changEle = { text: htmlText, range: save };
@@ -5,6 +5,7 @@ import { RendererFactory } from '../services/renderer-factory';
5
5
  * `Color Picker` module is used to handle ColorPicker actions.
6
6
  */
7
7
  export declare class ColorPickerInput {
8
+ private defaultColorPicker;
8
9
  private fontColorPicker;
9
10
  private backgroundColorPicker;
10
11
  private fontColorDropDown;
@@ -77,7 +77,7 @@ var ColorPickerInput = /** @class */ (function () {
77
77
  target: (targetID)
78
78
  };
79
79
  _this.backgroundColorPicker = _this.toolbarRenderer.renderColorPicker(options, 'backgroundcolor');
80
- _this.backgroundColorDropDown = _this.toolbarRenderer.renderColorPickerDropDown(options, 'backgroundcolor', _this.backgroundColorPicker);
80
+ _this.backgroundColorDropDown = _this.toolbarRenderer.renderColorPickerDropDown(options, 'backgroundcolor', _this.backgroundColorPicker, _this.defaultColorPicker);
81
81
  break;
82
82
  }
83
83
  }
@@ -112,6 +112,7 @@ var ColorPickerInput = /** @class */ (function () {
112
112
  if (this.backgroundColorDropDown && !this.backgroundColorDropDown.isDestroyed) {
113
113
  var innerEle = this.backgroundColorDropDown.element.querySelector('.e-rte-color-content');
114
114
  if (innerEle) {
115
+ this.defaultColorPicker = innerEle.children[0].style.borderBottomColor;
115
116
  detach(innerEle);
116
117
  }
117
118
  this.backgroundColorDropDown.destroy();
@@ -206,11 +206,6 @@ var DropDownButtons = /** @class */ (function () {
206
206
  var prop = _a[_i];
207
207
  switch (prop) {
208
208
  case 'fontFamily':
209
- if (this.parent.inlineMode.enable) {
210
- if (!isNullOrUndefined(this.parent.fontFamily.default)) {
211
- this.getEditNode().style.fontFamily = this.parent.fontFamily.default;
212
- }
213
- }
214
209
  if (this.fontNameDropDown) {
215
210
  for (var _b = 0, _c = Object.keys(newProp.fontFamily); _b < _c.length; _b++) {
216
211
  var fontFamily = _c[_b];
@@ -242,11 +237,6 @@ var DropDownButtons = /** @class */ (function () {
242
237
  }
243
238
  break;
244
239
  case 'fontSize':
245
- if (this.parent.inlineMode) {
246
- if (!isNullOrUndefined(this.parent.fontSize.default)) {
247
- this.getEditNode().style.fontSize = this.parent.fontSize.default;
248
- }
249
- }
250
240
  if (this.fontSizeDropDown) {
251
241
  for (var _d = 0, _e = Object.keys(newProp.fontSize); _d < _e.length; _d++) {
252
242
  var fontSize = _e[_d];
@@ -13,6 +13,7 @@ export declare class EnterKeyAction {
13
13
  private removeEventListener;
14
14
  private getRangeNode;
15
15
  private enterHandler;
16
+ private insertBRElement;
16
17
  private insertFocusContent;
17
18
  private createInsertElement;
18
19
  }
@@ -29,9 +29,20 @@ var EnterKeyAction = /** @class */ (function () {
29
29
  EnterKeyAction.prototype.enterHandler = function (e) {
30
30
  var _this = this;
31
31
  this.getRangeNode();
32
+ var isTableEnter = true;
33
+ if (!isNOU(this.startNode.closest('TABLE')) && !isNOU(this.endNode.closest('TABLE'))) {
34
+ isTableEnter = false;
35
+ var curElement = this.startNode;
36
+ var blockElement = curElement;
37
+ while (!this.parent.formatter.editorManager.domNode.isBlockNode(curElement)) {
38
+ blockElement = curElement;
39
+ curElement = curElement.parentElement;
40
+ }
41
+ isTableEnter = blockElement.tagName === 'TD' ? false : true;
42
+ }
32
43
  if (e.args.which === 13 && e.args.code === 'Enter') {
33
- if (isNOU(this.startNode.closest('LI')) && isNOU(this.endNode.closest('LI')) && isNOU(this.startNode.closest('TABLE')) &&
34
- isNOU(this.endNode.closest('TABLE')) && isNOU(this.startNode.closest('PRE')) && isNOU(this.endNode.closest('PRE'))) {
44
+ if (isNOU(this.startNode.closest('LI')) && isNOU(this.endNode.closest('LI')) && isTableEnter &&
45
+ isNOU(this.startNode.closest('PRE')) && isNOU(this.endNode.closest('PRE'))) {
35
46
  var shiftKey_1 = e.args.shiftKey;
36
47
  var actionBeginArgs = {
37
48
  cancel: false,
@@ -89,12 +100,32 @@ var EnterKeyAction = /** @class */ (function () {
89
100
  _this.parent.formatter.editorManager.nodeSelection.setCursorPoint(_this.parent.contentModule.getDocument(), _this.range.startContainer.childNodes[_this.range.startOffset], 0);
90
101
  _this.getRangeNode();
91
102
  }
92
- if (_this.parent.enterKey === 'P' || _this.parent.enterKey === 'DIV' ||
103
+ if ((_this.parent.enterKey === 'P' && !shiftKey_1) || (_this.parent.enterKey === 'DIV' && !shiftKey_1) ||
93
104
  (_this.parent.shiftEnterKey === 'P' && shiftKey_1) ||
94
105
  (_this.parent.shiftEnterKey === 'DIV' && shiftKey_1)) {
95
- var nearBlockNode = _this.parent.formatter.editorManager.domNode.blockParentNode(_this.startNode);
106
+ var nearBlockNode = void 0;
107
+ if (isTableEnter && _this.parent.formatter.editorManager.domNode.isBlockNode(_this.startNode)) {
108
+ nearBlockNode = _this.startNode;
109
+ }
110
+ else {
111
+ nearBlockNode = _this.parent.formatter.editorManager.domNode.blockParentNode(_this.startNode);
112
+ }
96
113
  var isImageNode = false;
97
- if (_this.range.startOffset === 0 && _this.range.endOffset === 0 && !(!isNOU(_this.range.startContainer.previousSibling) && _this.range.startContainer.previousSibling.nodeName === 'IMG')) {
114
+ var isFocusedFirst = false;
115
+ if (_this.range.startOffset != 0 && _this.range.endOffset != 0 && _this.range.startContainer === _this.range.endContainer &&
116
+ !(!isNOU(nearBlockNode.childNodes[0]) && nearBlockNode.childNodes[0].nodeName === 'IMG')) {
117
+ var startNodeText = _this.range.startContainer.textContent;
118
+ var splitFirstText = startNodeText.substring(0, _this.range.startOffset);
119
+ if (splitFirstText.charCodeAt(_this.range.startOffset - 1) != 160 && splitFirstText.trim().length === 0) {
120
+ isFocusedFirst = true;
121
+ }
122
+ }
123
+ else if (_this.range.startOffset === 0 && _this.range.endOffset === 0) {
124
+ isFocusedFirst = true;
125
+ }
126
+ if (((_this.range.startOffset === 0 && _this.range.endOffset === 0) || isFocusedFirst) &&
127
+ !(!isNOU(_this.range.startContainer.previousSibling) &&
128
+ (_this.range.startContainer.previousSibling.nodeName === 'IMG' || _this.range.startContainer.previousSibling.nodeName === 'BR'))) {
98
129
  var isNearBlockLengthZero = void 0;
99
130
  var newElem = void 0;
100
131
  if (_this.range.startContainer.nodeName === 'IMG') {
@@ -103,7 +134,7 @@ var EnterKeyAction = /** @class */ (function () {
103
134
  isNearBlockLengthZero = false;
104
135
  }
105
136
  else {
106
- if (nearBlockNode.textContent.length !== 0) {
137
+ if (nearBlockNode.textContent.trim().length !== 0) {
107
138
  newElem = _this.parent.formatter.editorManager.nodeCutter.SplitNode(_this.range, nearBlockNode, false).cloneNode(true);
108
139
  isNearBlockLengthZero = false;
109
140
  }
@@ -152,7 +183,18 @@ var EnterKeyAction = /** @class */ (function () {
152
183
  }
153
184
  if (newElem.textContent.trim().length === 0) {
154
185
  var brElm = _this.parent.createElement('br');
155
- _this.startNode.appendChild(brElm);
186
+ if (_this.startNode.nodeName === 'A') {
187
+ var startParentElem = _this.startNode.parentElement;
188
+ _this.startNode.parentElement.insertBefore(brElm, _this.startNode);
189
+ detach(_this.startNode);
190
+ _this.startNode = startParentElem;
191
+ }
192
+ else {
193
+ _this.startNode.appendChild(brElm);
194
+ }
195
+ if (newElem.childNodes[0].textContent === '\n') {
196
+ detach(newElem.childNodes[0]);
197
+ }
156
198
  _this.parent.formatter.editorManager.nodeSelection.setCursorPoint(_this.parent.contentModule.getDocument(), _this.startNode, 0);
157
199
  }
158
200
  if (((_this.parent.enterKey === 'P' || _this.parent.enterKey === 'DIV') && !shiftKey_1) || ((_this.parent.shiftEnterKey === 'DIV' ||
@@ -163,12 +205,13 @@ var EnterKeyAction = /** @class */ (function () {
163
205
  }
164
206
  _this.parent.formatter.editorManager.domNode.insertAfter(insertElm, newElem);
165
207
  detach(newElem);
166
- _this.parent.formatter.editorManager.nodeSelection.setCursorPoint(_this.parent.contentModule.getDocument(), _this.parent.formatter.editorManager.domNode.isBlockNode(_this.startNode) ? insertElm : _this.startNode, 0);
208
+ _this.parent.formatter.editorManager.nodeSelection.setCursorPoint(_this.parent.contentModule.getDocument(), _this.parent.formatter.editorManager.domNode.isBlockNode(_this.startNode) ?
209
+ insertElm : _this.startNode, 0);
167
210
  }
168
211
  }
169
212
  e.args.preventDefault();
170
213
  }
171
- if (_this.parent.enterKey === 'BR' && !shiftKey_1) {
214
+ if ((_this.parent.enterKey === 'BR' && !shiftKey_1) || (_this.parent.shiftEnterKey === 'BR' && shiftKey_1)) {
172
215
  var currentParent = void 0;
173
216
  if (!_this.parent.formatter.editorManager.domNode.isBlockNode(_this.startNode)) {
174
217
  var currentNode = _this.startNode;
@@ -184,13 +227,21 @@ var EnterKeyAction = /** @class */ (function () {
184
227
  currentParent = _this.startNode;
185
228
  }
186
229
  var isEmptyBrInserted = false;
230
+ var currentParentLastChild = currentParent.lastChild;
231
+ while (!isNOU(currentParentLastChild) && !(currentParentLastChild.nodeName === '#text')) {
232
+ currentParentLastChild = currentParentLastChild.lastChild;
233
+ }
234
+ var isLastNodeLength = _this.range.startContainer === currentParentLastChild ?
235
+ _this.range.startContainer.textContent.length : currentParent.textContent.length;
187
236
  if (currentParent !== _this.parent.inputElement &&
188
237
  _this.parent.formatter.editorManager.domNode.isBlockNode(currentParent) &&
189
238
  _this.range.startOffset === _this.range.endOffset &&
190
- _this.range.startOffset === currentParent.textContent.length) {
191
- var outerBRElem = _this.parent.createElement('br');
192
- _this.parent.formatter.editorManager.domNode.insertAfter(outerBRElem, currentParent);
193
- _this.parent.formatter.editorManager.nodeSelection.setCursorPoint(_this.parent.contentModule.getDocument(), outerBRElem, 0);
239
+ _this.range.startOffset === isLastNodeLength) {
240
+ var focusBRElem = _this.parent.createElement('br');
241
+ var lineBreakBRElem = _this.parent.createElement('br');
242
+ _this.parent.formatter.editorManager.domNode.insertAfter(focusBRElem, _this.range.startContainer);
243
+ _this.parent.formatter.editorManager.domNode.insertAfter(lineBreakBRElem, _this.range.startContainer);
244
+ _this.parent.formatter.editorManager.nodeSelection.setCursorPoint(_this.parent.contentModule.getDocument(), focusBRElem, 0);
194
245
  }
195
246
  else if (!isNOU(currentParent) && currentParent !== _this.parent.inputElement && currentParent.nodeName !== 'BR') {
196
247
  if (currentParent.textContent.trim().length === 0 || (currentParent.textContent.trim().length === 1 &&
@@ -217,34 +268,12 @@ var EnterKeyAction = /** @class */ (function () {
217
268
  isEmptyBrInserted = true;
218
269
  }
219
270
  else {
220
- newElem = _this.parent.formatter.editorManager.nodeCutter.SplitNode(_this.range, currentParent, true);
221
- newElem.parentElement.insertBefore(outerBRElem, newElem);
222
- _this.insertFocusContent();
271
+ _this.insertBRElement();
223
272
  }
224
273
  }
225
274
  }
226
275
  else {
227
- var brElm = _this.parent.createElement('br');
228
- if (_this.startNode.nodeName === 'BR' && _this.endNode.nodeName === 'BR' && _this.range.startOffset === 0 && _this.range.startOffset === _this.range.endOffset) {
229
- _this.parent.formatter.editorManager.domNode.insertAfter(brElm, _this.startNode);
230
- isEmptyBrInserted = true;
231
- }
232
- else {
233
- if (_this.startNode === _this.parent.inputElement && !isNOU(_this.range.startContainer.previousSibling) &&
234
- _this.range.startContainer.previousSibling.nodeName === 'BR' && _this.range.startContainer.textContent.length === 0) {
235
- isEmptyBrInserted = true;
236
- }
237
- _this.range.insertNode(brElm);
238
- }
239
- if (isEmptyBrInserted || (!isNOU(brElm.nextElementSibling) && brElm.nextElementSibling.tagName === 'BR') || (!isNOU(brElm.nextSibling) && brElm.nextSibling.textContent.length > 0)) {
240
- _this.parent.formatter.editorManager.nodeSelection.setCursorPoint(_this.parent.contentModule.getDocument(), !isNOU(brElm.nextSibling) ? brElm.nextSibling : brElm, 0);
241
- isEmptyBrInserted = false;
242
- }
243
- else {
244
- var brElm2 = _this.parent.createElement('br');
245
- _this.range.insertNode(brElm2);
246
- _this.parent.formatter.editorManager.nodeSelection.setCursorPoint(_this.parent.contentModule.getDocument(), brElm, 0);
247
- }
276
+ _this.insertBRElement();
248
277
  }
249
278
  e.args.preventDefault();
250
279
  }
@@ -254,6 +283,30 @@ var EnterKeyAction = /** @class */ (function () {
254
283
  }
255
284
  }
256
285
  };
286
+ EnterKeyAction.prototype.insertBRElement = function () {
287
+ var isEmptyBrInserted = false;
288
+ var brElm = this.parent.createElement('br');
289
+ if (this.startNode.nodeName === 'BR' && this.endNode.nodeName === 'BR' && this.range.startOffset === 0 && this.range.startOffset === this.range.endOffset) {
290
+ this.parent.formatter.editorManager.domNode.insertAfter(brElm, this.startNode);
291
+ isEmptyBrInserted = true;
292
+ }
293
+ else {
294
+ if (this.startNode === this.parent.inputElement && !isNOU(this.range.startContainer.previousSibling) &&
295
+ this.range.startContainer.previousSibling.nodeName === 'BR' && this.range.startContainer.textContent.length === 0) {
296
+ isEmptyBrInserted = true;
297
+ }
298
+ this.range.insertNode(brElm);
299
+ }
300
+ if (isEmptyBrInserted || (!isNOU(brElm.nextElementSibling) && brElm.nextElementSibling.tagName === 'BR') || (!isNOU(brElm.nextSibling) && brElm.nextSibling.textContent.length > 0)) {
301
+ this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), !isNOU(brElm.nextSibling) ? brElm.nextSibling : brElm, 0);
302
+ isEmptyBrInserted = false;
303
+ }
304
+ else {
305
+ var brElm2 = this.parent.createElement('br');
306
+ this.range.insertNode(brElm2);
307
+ this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), brElm, 0);
308
+ }
309
+ };
257
310
  EnterKeyAction.prototype.insertFocusContent = function () {
258
311
  if (this.range.startContainer.textContent.length === 0) {
259
312
  if (this.range.startContainer.nodeName === '#text') {
@@ -149,7 +149,7 @@ var HtmlEditor = /** @class */ (function () {
149
149
  e.args.action === 'enter' ||
150
150
  e.args.keyCode === 13) {
151
151
  this.spaceLink(e.args);
152
- if (this.parent.editorMode === 'HTML' && !((this.parent.shiftEnterKey === 'BR' && e.args.shiftKey))) {
152
+ if (this.parent.editorMode === 'HTML' && !this.parent.readonly) {
153
153
  this.parent.notify(events.enterHandler, { args: e.args });
154
154
  }
155
155
  }
@@ -229,7 +229,8 @@ var HtmlEditor = /** @class */ (function () {
229
229
  if (this.rangeElement.tagName === 'OL' || this.rangeElement.tagName === 'UL') {
230
230
  var liElement = this.getRangeLiNode(currentRange.startContainer);
231
231
  if (liElement.previousElementSibling && liElement.previousElementSibling.childElementCount > 0) {
232
- this.oldRangeElement = liElement.previousElementSibling.lastElementChild;
232
+ this.oldRangeElement = liElement.previousElementSibling.lastElementChild.nodeName === 'BR' ?
233
+ liElement.previousElementSibling : liElement.previousElementSibling.lastElementChild;
233
234
  if (!isNullOrUndefined(liElement.lastElementChild)) {
234
235
  this.rangeElement = liElement.lastElementChild;
235
236
  isLiElement = true;
@@ -426,7 +427,7 @@ var HtmlEditor = /** @class */ (function () {
426
427
  var divElement = this.parent.createElement('div');
427
428
  divElement.setAttribute('class', 'pasteContent');
428
429
  divElement.style.display = 'inline';
429
- divElement.innerHTML = contentInnerElem;
430
+ divElement.innerHTML = contentInnerElem.replace('&para', '&amp;para');
430
431
  var paraElem = divElement.querySelectorAll('span, p');
431
432
  for (var i = 0; i < paraElem.length; i++) {
432
433
  var splitTextContent = paraElem[i].innerHTML.split(' ');
@@ -134,7 +134,7 @@ var QuickToolbar = /** @class */ (function () {
134
134
 
135
135
  */
136
136
  QuickToolbar.prototype.showInlineQTBar = function (x, y, target) {
137
- if (this.parent.readonly) {
137
+ if (this.parent.readonly || target.tagName.toLowerCase() === "img") {
138
138
  return;
139
139
  }
140
140
  this.inlineQTBar.showPopup(x, y, target);
@@ -29,7 +29,7 @@ var XhtmlValidation = /** @class */ (function () {
29
29
  this.ImageTags();
30
30
  this.removeTags();
31
31
  this.RemoveUnsupported();
32
- this.currentElement.innerHTML = this.selfEncloseValidation(this.currentElement.innerHTML, this.currentElement.innerText === '\n' ?
32
+ this.currentElement.innerHTML = this.selfEncloseValidation(this.currentElement.innerHTML, this.currentElement.innerText === "\n" ?
33
33
  this.currentElement.innerText.length : this.currentElement.innerText.trim().length);
34
34
  this.parent.setProperties({ value: this.currentElement.innerHTML }, true);
35
35
  }