@syncfusion/ej2-richtexteditor 20.1.57 → 20.1.58

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 : 20.1.57
3
+ * version : 20.1.58
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@20.1.56",
3
+ "_id": "@syncfusion/ej2-richtexteditor@20.1.57",
4
4
  "_inBundle": false,
5
- "_integrity": "sha512-K9udvx7XUSGPoZazdkTsEx9MdmT7BmM+0AwY6uejJFroduUynyhd6DLubcv53iYrQa1cf4Auu6tkHY6fSyUtgA==",
5
+ "_integrity": "sha512-LjSfZ0mNXFBjRl/Q2pYJ1j8DWpzc8y64MLCMA6oSTIFRwmngZRRXOHXBLyifrkOX2371CSCsVPSxBuUV3pU60w==",
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-20.1.56.tgz",
30
- "_shasum": "32c4413a7a28432c050fbab856829a4529d9ad74",
29
+ "_resolved": "http://nexus.syncfusion.com/repository/ej2-hotfix-new/@syncfusion/ej2-richtexteditor/-/ej2-richtexteditor-20.1.57.tgz",
30
+ "_shasum": "cebf8bcc4da40e76f00f258bbcb1e50ab2dc0d03",
31
31
  "_spec": "@syncfusion/ej2-richtexteditor@*",
32
32
  "_where": "/jenkins/workspace/automation_release_19.1.0.1-ZPMUBNQ6AUYH6YGEFBPVYMEQLRRW2SLD4XCZ6GATNZJFYJ3RIAOA/packages/included",
33
33
  "author": {
@@ -38,12 +38,12 @@
38
38
  },
39
39
  "bundleDependencies": false,
40
40
  "dependencies": {
41
- "@syncfusion/ej2-base": "~20.1.56",
41
+ "@syncfusion/ej2-base": "~20.1.57",
42
42
  "@syncfusion/ej2-buttons": "~20.1.55",
43
- "@syncfusion/ej2-filemanager": "~20.1.57",
44
- "@syncfusion/ej2-inputs": "~20.1.55",
45
- "@syncfusion/ej2-navigations": "~20.1.57",
46
- "@syncfusion/ej2-popups": "~20.1.57",
43
+ "@syncfusion/ej2-filemanager": "~20.1.58",
44
+ "@syncfusion/ej2-inputs": "~20.1.58",
45
+ "@syncfusion/ej2-navigations": "~20.1.58",
46
+ "@syncfusion/ej2-popups": "~20.1.58",
47
47
  "@syncfusion/ej2-splitbuttons": "~20.1.57"
48
48
  },
49
49
  "deprecated": false,
@@ -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": "20.1.57",
73
+ "version": "20.1.58",
74
74
  "sideEffects": false
75
75
  }
@@ -26,6 +26,7 @@ export declare class Lists {
26
26
  private spaceList;
27
27
  private enterList;
28
28
  private backspaceList;
29
+ private removeList;
29
30
  private keyDownHandler;
30
31
  private spaceKeyAction;
31
32
  private getAction;
@@ -1,5 +1,5 @@
1
1
  import * as CONSTANT from './../base/constant';
2
- import { createElement, detach, prepend, append, attributes } from '@syncfusion/ej2-base';
2
+ import { createElement, detach, prepend, append, attributes, Browser } from '@syncfusion/ej2-base';
3
3
  import { markerClassName } from './dom-node';
4
4
  import * as EVENTS from './../../common/constant';
5
5
  import { setStyleAttribute } from '@syncfusion/ej2-base';
@@ -178,6 +178,29 @@ var Lists = /** @class */ (function () {
178
178
  parentList.parentElement.insertBefore(startNode.children[1], parentList);
179
179
  }
180
180
  }
181
+ this.removeList(range, e);
182
+ };
183
+ Lists.prototype.removeList = function (range, e) {
184
+ var startNode = this.parent.domNode.getSelectedNode(range.startContainer, range.startOffset);
185
+ var endNode = this.parent.domNode.getSelectedNode(range.endContainer, range.endOffset);
186
+ startNode = startNode.nodeName === 'BR' ? startNode.parentElement : startNode;
187
+ endNode = endNode.nodeName === 'BR' ? endNode.parentElement : endNode;
188
+ if (((range.commonAncestorContainer.nodeName === 'OL' || range.commonAncestorContainer.nodeName === 'UL' || range.commonAncestorContainer.nodeName === 'LI') &&
189
+ isNOU(endNode.nextElementSibling) && endNode.textContent.length === range.endOffset &&
190
+ isNOU(startNode.previousElementSibling) && range.startOffset === 0) ||
191
+ (Browser.userAgent.indexOf('Firefox') != -1 && range.startContainer === range.endContainer && range.startContainer === this.parent.editableElement &&
192
+ range.startOffset === 0 && range.endOffset === 1)) {
193
+ if (Browser.userAgent.indexOf('Firefox') != -1) {
194
+ detach(range.commonAncestorContainer.childNodes[0]);
195
+ }
196
+ else if (range.commonAncestorContainer.nodeName === 'LI') {
197
+ detach(range.commonAncestorContainer.parentElement);
198
+ }
199
+ else {
200
+ detach(range.commonAncestorContainer);
201
+ }
202
+ e.event.preventDefault();
203
+ }
181
204
  };
182
205
  Lists.prototype.keyDownHandler = function (e) {
183
206
  if (e.event.which === 13) {
@@ -202,6 +225,7 @@ var Lists = /** @class */ (function () {
202
225
  && (commonAncestor.lastElementChild === closest(endNode, 'li')) && !range.collapsed) {
203
226
  detach(commonAncestor);
204
227
  }
228
+ this.removeList(range, e);
205
229
  }
206
230
  if (e.event.which === 9) {
207
231
  var range = this.parent.nodeSelection.getRange(this.parent.currentDocument);
@@ -417,6 +441,19 @@ var Lists = /** @class */ (function () {
417
441
  };
418
442
  Lists.prototype.applyListsHandler = function (e) {
419
443
  var range = this.parent.nodeSelection.getRange(this.parent.currentDocument);
444
+ if (Browser.userAgent.indexOf('Firefox') != -1 && range.startContainer === range.endContainer && range.startContainer === this.parent.editableElement) {
445
+ var startChildNodes = range.startContainer.childNodes;
446
+ var startNode = ((startChildNodes[(range.startOffset > 0) ? (range.startOffset - 1) : range.startOffset]) || range.startContainer);
447
+ var endNode = (range.endContainer.childNodes[(range.endOffset > 0) ? (range.endOffset - 1) : range.endOffset] || range.endContainer);
448
+ var lastSelectionNode = endNode.lastChild.nodeName === 'BR' ? (isNOU(endNode.lastChild.previousSibling) ? endNode
449
+ : endNode.lastChild.previousSibling) : endNode.lastChild;
450
+ while (!isNOU(lastSelectionNode) && lastSelectionNode.nodeName !== '#text' && lastSelectionNode.nodeName !== 'IMG' &&
451
+ lastSelectionNode.nodeName !== 'BR' && lastSelectionNode.nodeName !== 'HR') {
452
+ lastSelectionNode = lastSelectionNode.lastChild;
453
+ }
454
+ this.parent.nodeSelection.setSelectionText(this.parent.currentDocument, startNode, lastSelectionNode, 0, lastSelectionNode.textContent.length);
455
+ range = this.parent.nodeSelection.getRange(this.parent.currentDocument);
456
+ }
420
457
  if (range.startContainer === range.endContainer && range.startContainer === this.parent.editableElement &&
421
458
  range.startOffset === range.endOffset && range.startOffset === 0 &&
422
459
  this.parent.editableElement.textContent.length === 0 && (this.parent.editableElement.childNodes[0].nodeName != 'TABLE' &&
@@ -270,8 +270,16 @@ var SelectionCommands = /** @class */ (function () {
270
270
  for (; nodeTraverse && nodeTraverse.parentElement && nodeTraverse.parentElement !== endNode;
271
271
  // eslint-disable-next-line
272
272
  nodeTraverse = nodeTraverse) {
273
- if (nodeTraverse.parentElement && nodeTraverse.parentElement.tagName.toLocaleLowerCase()
274
- === formatNode.tagName.toLocaleLowerCase() &&
273
+ var nodeTraverseCondition = void 0;
274
+ if (formatNode.nodeName === 'SPAN') {
275
+ nodeTraverseCondition = nodeTraverse.parentElement.tagName.toLocaleLowerCase()
276
+ === formatNode.tagName.toLocaleLowerCase() && nodeTraverse.parentElement.getAttribute('style') === formatNodeStyles;
277
+ }
278
+ else {
279
+ nodeTraverseCondition = nodeTraverse.parentElement.tagName.toLocaleLowerCase()
280
+ === formatNode.tagName.toLocaleLowerCase();
281
+ }
282
+ if (nodeTraverse.parentElement && nodeTraverseCondition &&
275
283
  (nodeTraverse.parentElement.childElementCount > 1 || range.startOffset > 1)) {
276
284
  if (textNode.parentElement && textNode.parentElement.tagName.toLocaleLowerCase()
277
285
  === formatNode.tagName.toLocaleLowerCase()) {
@@ -153,7 +153,17 @@ var HtmlEditor = /** @class */ (function () {
153
153
  e.args.keyCode === 13) {
154
154
  this.spaceLink(e.args);
155
155
  if (this.parent.editorMode === 'HTML' && !this.parent.readonly) {
156
- this.parent.notify(events.enterHandler, { args: e.args });
156
+ var currentLength = this.parent.getText().trim().length;
157
+ var selectionLength = this.parent.getSelection().length;
158
+ var totalLength = (currentLength - selectionLength) + 1;
159
+ if (!(this.parent.maxLength === -1 || totalLength <= this.parent.maxLength) &&
160
+ e.args.keyCode === 13) {
161
+ e.args.preventDefault();
162
+ return;
163
+ }
164
+ else {
165
+ this.parent.notify(events.enterHandler, { args: e.args });
166
+ }
157
167
  }
158
168
  }
159
169
  if (e.args.action === 'space') {
@@ -452,9 +452,7 @@ var Toolbar = /** @class */ (function () {
452
452
 
453
453
  */
454
454
  Toolbar.prototype.refreshToolbarOverflow = function () {
455
- if (!this.parent.inlineMode.enable) {
456
- this.baseToolbar.toolbarObj.refreshOverflow();
457
- }
455
+ this.baseToolbar.toolbarObj.refreshOverflow();
458
456
  };
459
457
  Toolbar.prototype.isToolbarDestroyed = function () {
460
458
  return this.baseToolbar.toolbarObj && !this.baseToolbar.toolbarObj.isDestroyed;
@@ -635,7 +633,9 @@ var Toolbar = /** @class */ (function () {
635
633
  }
636
634
  };
637
635
  Toolbar.prototype.onRefresh = function () {
638
- this.refreshToolbarOverflow();
636
+ if (!this.parent.inlineMode.enable) {
637
+ this.refreshToolbarOverflow();
638
+ }
639
639
  this.parent.setContentHeight('', true);
640
640
  };
641
641
  /**
@@ -606,3 +606,8 @@ export declare const closeTableDialog: string;
606
606
 
607
607
  */
608
608
  export declare const bindCssClass: string;
609
+ /**
610
+ * @hidden
611
+
612
+ */
613
+ export declare const blockInlineEmptyNodes: string;
@@ -606,3 +606,8 @@ export var closeTableDialog = 'closeTableDialog';
606
606
 
607
607
  */
608
608
  export var bindCssClass = 'closeTableDialog';
609
+ /**
610
+ * @hidden
611
+
612
+ */
613
+ export var blockInlineEmptyNodes = "address:empty, article:empty, aside:empty, blockquote:empty,\ndetails:empty, dd:empty, div:empty, dl:empty, dt:empty, fieldset:empty, footer:empty,form:empty, h1:empty,\nh2:empty, h3:empty, h4:empty, h5:empty, h6:empty, header:empty, hgroup:empty, hr:empty, li:empty, main:empty, nav:empty,\nnoscript:empty, output:empty, p:empty, pre:empty, section:empty, td:empty, th:empty,\na:empty, abbr:empty, acronym:empty, b:empty, bdi:empty, bdo:empty, big:empty, button:empty,\ncanvas:empty, cite:empty, code:empty, data:empty, datalist:empty, del:empty, dfn:empty, em:empty, font:empty, i:empty, iframe:empty,\nins:empty, kbd:empty, label:empty, map:empty, mark:empty, meter:empty, noscript:empty, object:empty, output:empty, picture:empty, progress:empty,\nq:empty, ruby:empty, s:empty, samp:empty, script:empty, select:empty, slot:empty, small:empty, span:empty, strong:empty, strike:empty, sub:empty, sup:empty, svg:empty,\ntemplate:empty, textarea:empty, time:empty, u:empty, tt:empty, var:empty, wbr:empty";
@@ -118,6 +118,7 @@ export interface IRichTextEditor extends Component<HTMLElement> {
118
118
  getCollection?(items: string | string[]): string[];
119
119
  getRange(): Range;
120
120
  getID(): string;
121
+ getText(): string;
121
122
  updateValueData?(): void;
122
123
  getBaseToolbarObject(): BaseToolbar;
123
124
  setContentHeight(target?: string, isExpand?: boolean): void;
@@ -225,6 +226,8 @@ export interface IItemCollectionArgs {
225
226
  selectParent?: Node[];
226
227
  /** Defines the URL action details for link element */
227
228
  url?: string;
229
+ /** Defines the Display Text action details for link element */
230
+ text?: string;
228
231
  /** Defines the title of the link action details */
229
232
  title?: string;
230
233
  /** Defines the target as string for link element */
@@ -339,6 +339,35 @@ var RichTextEditor = /** @class */ (function (_super) {
339
339
  this.formatter.saveData();
340
340
  }
341
341
  }
342
+ if (this.maxLength !== -1 && !isNOU(tool.command)) {
343
+ var currentInsertContentLength = 0;
344
+ if (tool.command === 'Links') {
345
+ currentInsertContentLength = value.text.length === 0 ?
346
+ value.url.length : value.text.length;
347
+ }
348
+ if (tool.command === 'Images' || tool.command === 'Table' || tool.command === 'Files') {
349
+ currentInsertContentLength = 1;
350
+ }
351
+ if (tool.command === 'InsertHTML') {
352
+ if (!isNOU(value)) {
353
+ var tempElem = this.createElement('div');
354
+ tempElem.innerHTML = value;
355
+ currentInsertContentLength = tempElem.textContent.length;
356
+ }
357
+ else if (!isNOU(tool.value) && (tool.value === '<hr/>' || tool.value === '<br/>')) {
358
+ currentInsertContentLength = 1;
359
+ }
360
+ }
361
+ if (tool.command === 'InsertText') {
362
+ currentInsertContentLength = value.length;
363
+ }
364
+ var currentLength = this.getText().trim().length;
365
+ var selectionLength = this.getSelection().length;
366
+ var totalLength = (currentLength - selectionLength) + currentInsertContentLength;
367
+ if (!(this.maxLength === -1 || totalLength <= this.maxLength)) {
368
+ return;
369
+ }
370
+ }
342
371
  this.formatter.editorManager.execCommand(tool.command, tool.subCommand ? tool.subCommand : (value ? value : tool.value), null, null, (value ? value : tool.value), (value ? value : tool.value));
343
372
  if (option && option.undo) {
344
373
  this.formatter.saveData();
@@ -571,6 +600,17 @@ var RichTextEditor = /** @class */ (function (_super) {
571
600
  this.autoResize();
572
601
  };
573
602
  RichTextEditor.prototype.keyUp = function (e) {
603
+ if (this.editorMode === "HTML") {
604
+ var range = this.getRange();
605
+ if (Browser.userAgent.indexOf('Firefox') != -1 && range.startContainer.nodeName === '#text' &&
606
+ range.startContainer.parentElement === this.inputElement && this.enterKey !== 'BR') {
607
+ var range_1 = this.getRange();
608
+ var tempElem = this.createElement(this.enterKey);
609
+ range_1.startContainer.parentElement.insertBefore(tempElem, range_1.startContainer);
610
+ tempElem.appendChild(range_1.startContainer);
611
+ this.formatter.editorManager.nodeSelection.setSelectionText(this.contentModule.getDocument(), tempElem.childNodes[0], tempElem.childNodes[0], tempElem.childNodes[0].textContent.length, tempElem.childNodes[0].textContent.length);
612
+ }
613
+ }
574
614
  this.notify(events.keyUp, { member: 'keyup', args: e });
575
615
  if (e.code === 'KeyX' && e.which === 88 && e.keyCode === 88 && e.ctrlKey && (this.inputElement.innerHTML === '' ||
576
616
  this.inputElement.innerHTML === '<br>')) {
@@ -723,7 +763,7 @@ var RichTextEditor = /** @class */ (function (_super) {
723
763
  requestType: 'Paste'
724
764
  };
725
765
  this.trigger(events.actionBegin, evenArgs, function (pasteArgs) {
726
- var currentLength = _this.getText().trim().length;
766
+ var currentLength = _this.inputElement.textContent.length;
727
767
  var selectionLength = _this.getSelection().length;
728
768
  var pastedContentLength = (isNOU(e) || isNOU(e.clipboardData))
729
769
  ? 0 : e.clipboardData.getData('text/plain').length;
@@ -4,6 +4,7 @@
4
4
  import { isNullOrUndefined as isNOU, addClass, removeClass, selectAll, createElement } from '@syncfusion/ej2-base';
5
5
  import { Browser, detach, SanitizeHtmlHelper, extend } from '@syncfusion/ej2-base';
6
6
  import * as classes from '../base/classes';
7
+ import * as CONSTANT from '../base/constant';
7
8
  import * as model from '../models/items';
8
9
  import { toolsLocale, fontNameLocale, formatsLocale, numberFormatListLocale, bulletFormatListLocale } from '../models/default-locale';
9
10
  var undoRedoItems = ['Undo', 'Redo'];
@@ -413,6 +414,10 @@ export function updateTextNode(value, rteObj) {
413
414
  var previousParent = void 0;
414
415
  var insertElem = void 0;
415
416
  while (tempNode.firstChild) {
417
+ var emptyElem = tempNode.querySelectorAll(CONSTANT.blockInlineEmptyNodes);
418
+ for (var i = 0; i < emptyElem.length; i++) {
419
+ emptyElem[i].innerHTML = '<br>';
420
+ }
416
421
  if (rteObj.enterKey !== 'BR' && ((tempNode.firstChild.nodeName === '#text' &&
417
422
  (tempNode.firstChild.textContent.indexOf('\n') < 0 || tempNode.firstChild.textContent.trim() !== '')) ||
418
423
  inlineNode.indexOf(tempNode.firstChild.nodeName.toLocaleLowerCase()) >= 0)) {
@@ -43,6 +43,21 @@ var Formatter = /** @class */ (function () {
43
43
  || self.contentModule.getPanel() === range.commonAncestorContainer)) {
44
44
  return;
45
45
  }
46
+ if (!isNullOrUndefined(args) && self.maxLength !== -1 && !isNullOrUndefined(args.item.command)) {
47
+ var currentInsertContentLength = 0;
48
+ if (args.item.command === 'Links') {
49
+ currentInsertContentLength = value.text.length === 0 ? value.url.length : value.text.length;
50
+ }
51
+ if (args.item.command === 'Images' || args.item.command === 'Table' || args.item.command === 'Files') {
52
+ currentInsertContentLength = 1;
53
+ }
54
+ var currentLength = self.getText().trim().length;
55
+ var selectionLength = self.getSelection().length;
56
+ var totalLength = (currentLength - selectionLength) + currentInsertContentLength;
57
+ if (!(self.maxLength === -1 || totalLength <= self.maxLength)) {
58
+ return;
59
+ }
60
+ }
46
61
  if (isNullOrUndefined(args)) {
47
62
  var action_1 = event.action;
48
63
  if (action_1 !== 'tab' && action_1 !== 'enter' && action_1 !== 'space' && action_1 !== 'escape') {