@syncfusion/ej2-richtexteditor 27.1.51 → 27.1.55

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 (49) 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 +874 -238
  5. package/dist/es6/ej2-richtexteditor.es2015.js.map +1 -1
  6. package/dist/es6/ej2-richtexteditor.es5.js +267 -120
  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 +12 -12
  12. package/src/common/editor-styles.d.ts +1 -0
  13. package/src/common/editor-styles.js +1 -0
  14. package/src/common/interface.d.ts +10 -0
  15. package/src/editor-manager/base/editor-manager.js +1 -1
  16. package/src/editor-manager/base/interface.d.ts +2 -2
  17. package/src/editor-manager/plugin/alignments.js +1 -1
  18. package/src/editor-manager/plugin/clearformat.js +1 -1
  19. package/src/editor-manager/plugin/dom-node.js +1 -1
  20. package/src/editor-manager/plugin/image.js +2 -0
  21. package/src/editor-manager/plugin/indents.js +1 -1
  22. package/src/editor-manager/plugin/inserthtml.d.ts +1 -0
  23. package/src/editor-manager/plugin/inserthtml.js +49 -18
  24. package/src/editor-manager/plugin/link.js +2 -2
  25. package/src/editor-manager/plugin/lists.js +5 -4
  26. package/src/editor-manager/plugin/ms-word-clean-up.js +5 -0
  27. package/src/editor-manager/plugin/selection-commands.js +2 -2
  28. package/src/editor-manager/plugin/toolbar-status.js +1 -1
  29. package/src/editor-manager/plugin/undo.js +3 -3
  30. package/src/rich-text-editor/actions/base-toolbar.js +1 -1
  31. package/src/rich-text-editor/actions/dropdown-buttons.js +0 -6
  32. package/src/rich-text-editor/actions/enter-key.js +11 -5
  33. package/src/rich-text-editor/actions/html-editor.js +2 -2
  34. package/src/rich-text-editor/actions/import-export.js +1 -1
  35. package/src/rich-text-editor/actions/paste-clean-up.js +1 -1
  36. package/src/rich-text-editor/actions/resize.d.ts +3 -0
  37. package/src/rich-text-editor/actions/resize.js +13 -0
  38. package/src/rich-text-editor/base/interface.d.ts +13 -1
  39. package/src/rich-text-editor/base/rich-text-editor.js +19 -4
  40. package/src/rich-text-editor/renderer/content-renderer.d.ts +1 -1
  41. package/src/rich-text-editor/renderer/content-renderer.js +9 -2
  42. package/src/rich-text-editor/renderer/iframe-content-renderer.js +21 -8
  43. package/src/rich-text-editor/renderer/image-module.d.ts +2 -0
  44. package/src/rich-text-editor/renderer/image-module.js +26 -13
  45. package/src/rich-text-editor/renderer/link-module.js +6 -2
  46. package/src/rich-text-editor/renderer/slash-menu.js +1 -1
  47. package/src/rich-text-editor/renderer/video-module.js +1 -1
  48. package/src/selection/selection.d.ts +5 -0
  49. package/src/selection/selection.js +44 -1
@@ -9,6 +9,8 @@ var Resize = /** @class */ (function () {
9
9
  this.parent = parent;
10
10
  this.addEventListener();
11
11
  this.isDestroyed = false;
12
+ this.isResizing = false;
13
+ this.iframeMouseUpBoundFn = this.iframeMouseUp.bind(this);
12
14
  }
13
15
  Resize.prototype.addEventListener = function () {
14
16
  if (this.parent.isDestroyed) {
@@ -28,6 +30,7 @@ var Resize = /** @class */ (function () {
28
30
  this.parent.rootContainer.classList.add('e-resize-enabled');
29
31
  if (this.parent.iframeSettings.enable) {
30
32
  this.parent.inputElement.classList.add('e-resize-enabled');
33
+ this.parent.contentModule.getDocument().addEventListener('mouseup', this.iframeMouseUpBoundFn);
31
34
  }
32
35
  this.touchStartEvent = (Browser.info.name === 'msie') ? 'pointerdown' : 'touchstart';
33
36
  EventHandler.add(this.resizer, 'mousedown', this.resizeStart, this);
@@ -35,6 +38,7 @@ var Resize = /** @class */ (function () {
35
38
  };
36
39
  Resize.prototype.resizeStart = function (e) {
37
40
  var _this = this;
41
+ this.isResizing = false;
38
42
  if (e.cancelable) {
39
43
  e.preventDefault();
40
44
  }
@@ -49,6 +53,7 @@ var Resize = /** @class */ (function () {
49
53
  };
50
54
  Resize.prototype.performResize = function (e) {
51
55
  var _this = this;
56
+ this.isResizing = true;
52
57
  var args = { event: e, requestType: 'editor' };
53
58
  this.parent.trigger(events.onResize, args, function (resizingArgs) {
54
59
  if (resizingArgs.cancel) {
@@ -78,6 +83,7 @@ var Resize = /** @class */ (function () {
78
83
  this.parent.refreshUI();
79
84
  };
80
85
  Resize.prototype.stopResize = function (e) {
86
+ this.isResizing = false;
81
87
  this.parent.refreshUI();
82
88
  this.unwireResizeEvents();
83
89
  var args = { event: e, requestType: 'editor' };
@@ -127,6 +133,7 @@ var Resize = /** @class */ (function () {
127
133
  }
128
134
  if (this.parent.iframeSettings.enable && !isNullOrUndefined(this.parent.inputElement)) {
129
135
  this.parent.inputElement.classList.remove('e-resize-enabled');
136
+ this.parent.contentModule.getDocument().removeEventListener('mouseup', this.iframeMouseUpBoundFn);
130
137
  }
131
138
  if (this.resizer) {
132
139
  EventHandler.remove(this.resizer, 'mousedown', this.resizeStart);
@@ -134,6 +141,12 @@ var Resize = /** @class */ (function () {
134
141
  detach(this.resizer);
135
142
  }
136
143
  this.parent.off(events.destroy, this.destroy);
144
+ this.iframeMouseUpBoundFn = null;
145
+ };
146
+ Resize.prototype.iframeMouseUp = function (e) {
147
+ if (this.isResizing) {
148
+ this.stopResize(e);
149
+ }
137
150
  };
138
151
  /**
139
152
  * For internal use only - Get the module name.
@@ -246,7 +246,19 @@ export interface IRenderer {
246
246
  inlineQTBar?: BaseQuickToolbar;
247
247
  renderPanel?(): void;
248
248
  setPanel?(panel: Element): void;
249
+ /**
250
+ * Retrieves the parent element of the content editable div.
251
+ * If the editor is in iframe mode, it returns the `iframe` element.
252
+ * Otherwise, it returns the parent element with the class `e-rte-content`.
253
+ *
254
+ * @returns {Element} - The parent element of the content editable div or the `iframe` element.
255
+ */
249
256
  getPanel?(): Element;
257
+ /**
258
+ * Retrieves the content editable `div` element of the RichTextEditor.
259
+ * If the editor is in iframe mode, it returns the `body` element of the iframe.
260
+ *
261
+ */
250
262
  getEditPanel?(): Element;
251
263
  getText?(): string;
252
264
  getDocument?(): Document;
@@ -1411,7 +1423,7 @@ export declare const executeGroup: {
1411
1423
  /**
1412
1424
  * Defines types to be used as CommandName.
1413
1425
  */
1414
- export declare type CommandName = 'bold' | 'italic' | 'underline' | 'strikeThrough' | 'superscript' | 'subscript' | 'uppercase' | 'lowercase' | 'fontColor' | 'fontName' | 'fontSize' | 'backColor' | 'justifyCenter' | 'justifyFull' | 'justifyLeft' | 'justifyRight' | 'undo' | 'createLink' | 'formatBlock' | 'heading' | 'indent' | 'insertHTML' | 'insertOrderedList' | 'insertUnorderedList' | 'insertParagraph' | 'outdent' | 'redo' | 'removeFormat' | 'insertText' | 'insertImage' | 'insertAudio' | 'insertVideo' | 'insertHorizontalRule' | 'insertBrOnReturn' | 'insertCode' | 'insertTable' | 'editImage' | 'editLink' | 'applyFormatPainter' | 'copyFormatPainter' | 'escapeFormatPainter' | 'emojiPicker' | 'InlineCode';
1426
+ export declare type CommandName = 'bold' | 'italic' | 'underline' | 'strikeThrough' | 'superscript' | 'subscript' | 'uppercase' | 'lowercase' | 'fontColor' | 'fontName' | 'fontSize' | 'backColor' | 'justifyCenter' | 'justifyFull' | 'justifyLeft' | 'justifyRight' | 'undo' | 'createLink' | 'formatBlock' | 'heading' | 'indent' | 'insertHTML' | 'insertOrderedList' | 'insertUnorderedList' | 'insertParagraph' | 'outdent' | 'redo' | 'removeFormat' | 'insertText' | 'insertImage' | 'insertAudio' | 'insertVideo' | 'insertHorizontalRule' | 'insertBrOnReturn' | 'insertCode' | 'insertTable' | 'editImage' | 'editLink' | 'applyFormatPainter' | 'copyFormatPainter' | 'escapeFormatPainter' | 'emojiPicker' | 'InlineCode' | 'importWord';
1415
1427
  /**
1416
1428
  * @hidden
1417
1429
 
@@ -357,6 +357,17 @@ var RichTextEditor = /** @class */ (function (_super) {
357
357
  * @public
358
358
  */
359
359
  RichTextEditor.prototype.executeCommand = function (commandName, value, option) {
360
+ if (commandName === 'importWord') {
361
+ var importContainer = this.createElement('div');
362
+ importContainer.innerHTML = value;
363
+ var tableElement = importContainer.querySelectorAll('table:not(.e-rte-table):not(.e-rte-paste-table)');
364
+ for (var i = 0; i < tableElement.length; i++) {
365
+ tableElement[i].classList.add('e-rte-paste-table');
366
+ }
367
+ value = importContainer.innerHTML;
368
+ importContainer.remove();
369
+ commandName = 'insertHTML';
370
+ }
360
371
  value = this.htmlPurifier(commandName, value);
361
372
  var internalValue;
362
373
  if (this.editorMode === 'HTML') {
@@ -2428,7 +2439,6 @@ var RichTextEditor = /** @class */ (function (_super) {
2428
2439
  var iframeElement = this.element.querySelector('#' + this.getID() + '_rte-view');
2429
2440
  if (iframeElement) {
2430
2441
  this.setAutoHeight(iframeElement);
2431
- this.inputElement.style.overflow = 'hidden';
2432
2442
  }
2433
2443
  }
2434
2444
  }
@@ -2453,9 +2463,14 @@ var RichTextEditor = /** @class */ (function (_super) {
2453
2463
  };
2454
2464
  RichTextEditor.prototype.setAutoHeight = function (element) {
2455
2465
  if (!isNOU(element)) {
2456
- element.style.height = 'auto';
2457
- element.style.height = (this.inputElement.scrollHeight + 16) + 'px';
2458
- element.style.overflow = 'hidden';
2466
+ if (element.nodeName === 'TEXTAREA') {
2467
+ element.style.height = 'auto';
2468
+ element.style.height = (this.inputElement.scrollHeight + 16) + 'px';
2469
+ element.style.overflow = 'hidden';
2470
+ }
2471
+ else if (element.nodeName === 'IFRAME') {
2472
+ element.style.height = this.inputElement.parentElement.offsetHeight + 'px';
2473
+ }
2459
2474
  }
2460
2475
  };
2461
2476
  RichTextEditor.prototype.wireEvents = function () {
@@ -8,7 +8,7 @@ import { IRenderer, IRichTextEditor } from '../base/interface';
8
8
  export declare class ContentRender implements IRenderer {
9
9
  protected contentPanel: Element;
10
10
  protected parent: IRichTextEditor;
11
- protected editableElement: Element;
11
+ protected editableElement: HTMLElement;
12
12
  /**
13
13
  * Constructor for content renderer module
14
14
  *
@@ -1,4 +1,5 @@
1
1
  import { getEditValue } from '../base/util';
2
+ import { isNullOrUndefined as isNOU } from '@syncfusion/ej2-base';
2
3
  /**
3
4
  * Content module is used to render Rich Text Editor content
4
5
  *
@@ -30,9 +31,15 @@ var ContentRender = /** @class */ (function () {
30
31
  id: this.parent.getID() + '_rte-edit-view',
31
32
  attrs: {
32
33
  'contenteditable': 'true'
33
- },
34
- innerHTML: rteContent
34
+ }
35
35
  });
36
+ if (!isNOU(this.parent.fontFamily.default)) {
37
+ this.editableElement.style.fontFamily = this.parent.fontFamily.default;
38
+ }
39
+ if (!isNOU(this.parent.fontSize.default)) {
40
+ this.editableElement.style.fontSize = this.parent.fontSize.default;
41
+ }
42
+ this.editableElement.innerHTML = rteContent;
36
43
  div.appendChild(this.editableElement);
37
44
  this.setPanel(div);
38
45
  rteObj.rootContainer.appendChild(div);
@@ -12,9 +12,11 @@ var __extends = (this && this.__extends) || (function () {
12
12
  };
13
13
  })();
14
14
  import { ContentRender } from '../renderer/content-renderer';
15
- import { isNullOrUndefined } from '@syncfusion/ej2-base';
15
+ import { isNullOrUndefined as isNOU } from '@syncfusion/ej2-base';
16
16
  import { getEditValue } from '../base/util';
17
- var IFRAMEHEADER = "\n<!DOCTYPE html> \n <html>\n <head>\n <meta charset='utf-8' /> \n <style>\n @charset \"UTF-8\";\n body {\n font-family: \"Roboto\", sans-serif;\n font-size: 14px;\n }\n html, body{height: 100%;margin: 0;}\n body.e-cursor{cursor:default}\n span.e-selected-node\t{background-color: #939393;color: white;}\n span.e-selected-node.e-highlight {background-color: #1d9dd8;}\n body{color:#333;word-wrap:break-word;padding: 8px;box-sizing: border-box;}\n .e-rte-image, .e-rte-video {border: 0;cursor: pointer;display:\n block;float: none;height: auto;margin: 5px auto;max-width: 100%;position: relative;}\n .e-rte-audio {border: 0;cursor: pointer;display:\n block;float: none;margin: 5px auto;max-width: 100%;position: relative;}\n .e-rte-image.e-imginline, .e-rte-audio.e-audio-inline, .e-rte-video.e-video-inline {display: inline-block;float: none;\n margin-left: 5px;margin-right: 5px;max-width: calc(100% - (2 * 5px));padding: 1px;vertical-align: bottom;}\n .e-rte-image.e-imgcenter, .e-rte-video.e-video-center {cursor: pointer;display: block;float: none;margin: 5px auto;max-width: 100%;position: relative;}\n .e-rte-image.e-imgright, .e-rte-video.e-video-right { float: right; margin: 0 auto;margin-left: 5px;text-align: right;}\n .e-rte-image.e-imgleft, .e-rte-video.e-video-left {float: left;margin: 0 auto;margin-right: 5px;text-align: left;}\n .e-img-caption { display: inline-block; float: none; margin: 5px auto; max-width: 100%;position: relative;}\n .e-img-caption.e-caption-inline {display: inline-block;float: none;\n margin: 5px auto;margin-left: 5px;margin-right: 5px;max-width: calc(100% - (2 * 5px));\n position: relativetext-align: center;vertical-align: bottom;}\n .e-rte-img-caption.e-imgcenter {display: contents; margin-left: auto; margin-right: auto;}\n .e-rte-img-caption.e-imgright {display: contents; margin-left: auto; margin-right: 0;}\n .e-rte-img-caption.e-imgleft {display: contents;margin-left: 0;margin-right: auto;}\n .e-img-caption.e-rte-img-caption.e-imgbreak {display: contents;}\n .e-img-inner {box-sizing: border-box;display: block;font-size: 16px;font-weight: initial;\n margin: auto;opacity: .9;text-align: center;width: 100%;}\n .e-img-wrap {display: inline-block;margin: auto;padding: 0;text-align: center;width: 100%;}\n .e-imgleft, .e-video-left {float: left;margin: 0 5px 0 0;text-align: left;}\n .e-imgright, .e-video-right {float: right;margin: 0 0 0 5px;text-align: right;}\n .e-imgcenter, .e-video-center {cursor: pointer;display: block;float: none;height: auto;margin: 5px auto;max-width: 100%;position: relative;}\n .e-control img:not(.e-resize) {border: 2px solid transparent; z-index: 1000}\n .e-imginline , .e-audio-inline, .e-video-inline {display: inline-block;float: none;margin-left: 5px;margin-right: 5px;\n max-width: calc(100% - (2 * 5px));vertical-align: bottom;}\n .e-imgbreak, .e-audio-break, .e-video-break {border: 0;cursor: pointer;\n display: block;float: none;height: auto;margin: 5px auto;max-width: 100%;position: relative;}\n .e-rte-image.e-img-focus:not(.e-resize), .e-audio-focus:not(.e-resize), .e-video-focus:not(.e-resize) {border: solid 2px #4a90e2;}\n img.e-img-focus::selection, audio.e-audio-focus::selection, .e-video-focus::selection { background: transparent;color: transparent;}\n span.e-rte-imageboxmark, span.e-rte-videoboxmark { width: 10px; height: 10px; position: absolute; display: block;\n background: #4a90e2; border: 1px solid #fff; z-index: 1000;}\n .e-mob-rte.e-mob-span span.e-rte-imageboxmark, .e-mob-rte.e-mob-span span.e-rte-videoboxmark { background: #4a90e2; border: 1px solid #fff; }\n .e-mob-rte span.e-rte-imageboxmark, .e-mob-rte span.e-rte-videoboxmark { background: #fff; border: 1px solid #4a90e2;\n border-radius: 15px; height: 20px; width: 20px; }\n .e-mob-rte.e-mob-span span.e-rte-imageboxmark, .e-mob-rte.e-mob-span span.e-rte-videoboxmark { background: #4a90e2; border: 1px solid #fff; }\n .e-rte-content .e-content img.e-resize, .e-rte-content .e-content video.e-resize { z-index: 1000; }\n .e-rte-content { font-size: 14px; }\n .e-content { font-weight: normal; line-height: 1.5; font-size: 1em; }\n .e-img-caption .e-img-inner { outline: 0; }\n .e-rte-img-caption.e-imgleft .e-img-inner { float: left; text-align: left; }\n .e-rte-img-caption.e-imgright .e-img-inner { float: right; text-align: right; }\n .e-rte-img-caption.e-imgleft .e-img-wrap, .e-rte-img-caption.e-imgright .e-img-wrap { display: contents; }\n .e-img-caption a:focus-visible { outline: none; }\n .e-rte-img-caption .e-rte-image.e-imgright { margin-left: auto; margin-right: 0; }\n .e-rte-img-caption .e-rte-image.e-imgleft { margin: 0; }\n body{box-sizing: border-box;min-height: 100px;outline: 0 solid transparent;\n overflow-x: auto;padding: 16px;position: relative;text-align: inherit;z-index: 2;}\n p{margin: 0 0 10px;margin-bottom: 10px;}\n code{ background: #9d9d9d26; color: #ed484c;}\n li{margin-bottom: 10px;}\n table{margin-bottom: 10px;}\n h1{ font-size: 2.857em; font-weight: 600; line-height: 1.2; margin: 10px 0; }\n h2{ font-size: 2.285em; font-weight: 600; line-height: 1.2; margin: 10px 0; }\n h3{ font-size: 2em; font-weight: 600; line-height: 1.2; margin: 10px 0; }\n h4{ font-size: 1.714em; font-weight: 600; line-height: 1.2; margin: 10px 0; }\n h5{ font-size: 1.428em; font-weight: 600; line-height: 1.2; margin: 10px 0; }\n h6{ font-size: 1.142em; line-height: 600; line-height: 1.5; margin: 10px 0; }\n blockquote{margin: 10px 0;margin-left: 0;padding-left: 5px;border-left: solid 2px #5c5c5c;}\n pre{background-color: inherit;border: 0;border-radius: 0;color: #333;\n font-size: inherit;line-height: inherit;margin: 0 0 10px;overflow: visible;padding: 0;\n white-space: pre-wrap;word-break: inherit;word-wrap: break-word;}\n strong, b{font-weight: 700;}\n a{text-decoration: none;user-select: auto;}\n a:hover{text-decoration: underline;};\n p:last-child, pre:last-child, blockquote:last-child{margin-bottom: 0;}\n h3+h4, h4+h5, h5+h6{margin-top: 00.6em;}\n ul:last-child{margin-bottom: 0;}\n table { border-collapse: collapse; empty-cells: show;}\n table td,table th {border: 1px solid #BDBDBD; height: 20px; padding: 2px 5px; vertical-align: middle;}\n table.e-alternate-border tbody tr:nth-child(2n) {background-color: #F5F5F5;}\n table th {background-color: #E0E0E0;}\n table.e-dashed-border td,table.e-dashed-border th { border: 1px dashed #BDBDBD} \n table .e-cell-select {border: 1px double #4a90e2;}\n table.e-cell-select {position: relative;}\n table.e-cell-select::after { content: \"\"; position: absolute; top: 0; left: 0; right: 0; bottom: 0; border: 2px solid #4a90e2; pointer-events: none;}\n table td.e-cell-select.e-multi-cells-select, table th.e-cell-select.e-multi-cells-select {border: 1px solid #dee2e6; position: relative; }\n table td.e-cell-select.e-multi-cells-select::after, table th.e-cell-select.e-multi-cells-select::after {background-color: rgba(13, 110, 253, 0.08); content: \"\";\n position: absolute; top: 0; left: 0; width: 100%; height: 100%; bottom: 0; pointer-events: none; right: 0;}\n span.e-table-box { cursor: nwse-resize; display: block; height: 10px; position: absolute; width: 10px; }\n span.e-table-box.e-rmob {height: 14px;width: 14px;}\n .e-row-resize, .e-column-resize { background-color: transparent; background-repeat: repeat;\n bottom: 0;cursor: col-resize;height: 1px;overflow: visible;position: absolute;width: 1px; }\n .e-row-resize { cursor: row-resize; height: 1px;}\n .e-table-rhelper { cursor: col-resize; opacity: .87;position: absolute;}\n .e-table-rhelper.e-column-helper { width: 1px; }\n .e-table-rhelper.e-row-helper {height: 1px;}\n .e-reicon::before { border-bottom: 6px solid transparent; border-right: 6px solid;\n border-top: 6px solid transparent; content: ''; display: block; height: 0;\n position: absolute; right: 4px; top: 4px; width: 20px; }\n .e-reicon::after { border-bottom: 6px solid transparent; border-left: 6px solid;\n border-top: 6px solid transparent; content: ''; display: block;\n height: 0; left: 4px; position: absolute; top: 4px; width: 20px; z-index: 3; }\n .e-row-helper.e-reicon::after { top: 10px; transform: rotate(90deg); }\n .e-row-helper.e-reicon::before { left: 4px; top: -20px; transform: rotate(90deg); }\n span.e-table-box { background-color: #ffffff; border: 1px solid #BDBDBD; }\n span.e-table-box.e-rbox-select { background-color: #BDBDBD; border: 1px solid #BDBDBD; }\n .e-table-rhelper { background-color: #4a90e2;}\n .e-rtl { direction: rtl; }\n .e-rte-placeholder::before { content: attr(placeholder); opacity: 0.54; overflow: hidden; padding-top: 16px; position: absolute; text-align: start; top: 0; z-index: 1; }\n li ol, li ul { margin-block-start: 10px;}\n .e-resize-enabled, .e-count-enabled { padding-bottom: 0px; }\n td.e-multi-cells-select ::selection, th.e-multi-cells-select ::selection { background-color: transparent; }\n td.e-multi-cells-select, th.e-multi-cells-select { user-select: none !important; }\n </style>\n </head>";
17
+ import { IFRAME_EDITOR_STYLES } from '../../common/editor-styles';
18
+ var IFRAMEHEADER = "\n <!DOCTYPE html> \n <html>\n <head>\n <meta charset='utf-8' /> \n <style>" +
19
+ IFRAME_EDITOR_STYLES.replace(/[\n\t]/g, '') + "\n </style>\n </head>\n";
18
20
  /**
19
21
  * Content module is used to render Rich Text Editor content
20
22
  *
@@ -35,7 +37,7 @@ var IframeContentRender = /** @class */ (function (_super) {
35
37
  IframeContentRender.prototype.renderPanel = function () {
36
38
  var rteObj = this.parent;
37
39
  var rteContent = getEditValue(rteObj.value, rteObj);
38
- var iFrameBodyContent = '<body spellcheck="false" autocorrect="off" contenteditable="true">' +
40
+ var iFrameBodyContent = '<body contenteditable="true">' +
39
41
  rteContent + '</body></html>';
40
42
  var iFrameContent = IFRAMEHEADER + iFrameBodyContent;
41
43
  var iframe = this.parent.createElement('iframe', {
@@ -45,7 +47,7 @@ var IframeContentRender = /** @class */ (function (_super) {
45
47
  });
46
48
  iframe.setAttribute('role', 'none');
47
49
  this.setPanel(iframe);
48
- if (!isNullOrUndefined(this.parent.iframeSettings.sandbox)) {
50
+ if (!isNOU(this.parent.iframeSettings.sandbox)) {
49
51
  var sandboxValues = this.parent.iframeSettings.sandbox
50
52
  .map(function (element) { return element.toLocaleLowerCase().trim(); })
51
53
  .join(' ');
@@ -55,22 +57,33 @@ var IframeContentRender = /** @class */ (function (_super) {
55
57
  iframe.setAttribute('sandbox', sandboxValues.trim());
56
58
  }
57
59
  rteObj.rootContainer.appendChild(iframe);
58
- iframe.contentDocument.body.id = this.parent.getID() + '_rte-edit-view';
59
60
  iframe.contentDocument.body.setAttribute('aria-owns', this.parent.getID());
60
61
  iframe.contentDocument.open();
61
62
  iFrameContent = this.setThemeColor(iFrameContent, { color: '#333' });
62
63
  iframe.contentDocument.write(iFrameContent);
63
64
  iframe.contentDocument.close();
65
+ var body = iframe.contentDocument.body;
66
+ body.className = 'e-content';
67
+ if (this.parent.height === 'auto') {
68
+ body.style.overflowY = 'hidden';
69
+ }
70
+ if (!isNOU(this.parent.fontFamily.default)) {
71
+ body.style.fontFamily = this.parent.fontFamily.default;
72
+ }
73
+ if (!isNOU(this.parent.fontSize.default)) {
74
+ body.style.fontSize = this.parent.fontSize.default;
75
+ }
76
+ body.id = this.parent.getID() + '_rte-edit-view';
64
77
  if (rteObj.enableRtl) {
65
78
  this.contentPanel.contentDocument.body.setAttribute('class', 'e-rtl');
66
79
  }
67
- if (!isNullOrUndefined(iframe.contentDocument.head) && this.parent.iframeSettings.metaTags.length > 0) {
80
+ if (!isNOU(iframe.contentDocument.head) && this.parent.iframeSettings.metaTags.length > 0) {
68
81
  var head_1 = iframe.contentDocument.head;
69
82
  var metaData = this.parent.iframeSettings.metaTags;
70
83
  metaData.forEach(function (tag) {
71
84
  var meta = document.createElement('meta');
72
85
  for (var key in tag) {
73
- if (!isNullOrUndefined(tag[key])) {
86
+ if (!isNOU(tag[key])) {
74
87
  meta.setAttribute((key === 'httpEquiv') ? 'http-equiv' : key, tag[key]);
75
88
  }
76
89
  }
@@ -91,7 +104,7 @@ var IframeContentRender = /** @class */ (function (_super) {
91
104
  */
92
105
  IframeContentRender.prototype.getEditPanel = function () {
93
106
  var editNode;
94
- if (!isNullOrUndefined(this.contentPanel.contentDocument)) {
107
+ if (!isNOU(this.contentPanel.contentDocument)) {
95
108
  editNode = this.contentPanel.contentDocument.body;
96
109
  }
97
110
  else {
@@ -73,9 +73,11 @@ export declare class Image {
73
73
  private setImageHeight;
74
74
  private removeImageHeight;
75
75
  private getImageDimension;
76
+ private adjustDimensionsByAspectRatio;
76
77
  private pixToPerc;
77
78
  private imgDupMouseMove;
78
79
  private resizing;
80
+ private adjustDimensions;
79
81
  private getResizeFactor;
80
82
  private findAspectRatio;
81
83
  private cancelResizeAction;
@@ -429,6 +429,17 @@ var Image = /** @class */ (function () {
429
429
  return value;
430
430
  }
431
431
  };
432
+ Image.prototype.adjustDimensionsByAspectRatio = function (width, height, aspectRatio, isWidthPrimary) {
433
+ if (isWidthPrimary) {
434
+ height = Math.round(width / aspectRatio);
435
+ width = Math.round(height * aspectRatio);
436
+ }
437
+ else {
438
+ width = Math.round(height * aspectRatio);
439
+ height = Math.round(width / aspectRatio);
440
+ }
441
+ return { width: width, height: height };
442
+ };
432
443
  Image.prototype.pixToPerc = function (expected, parentEle) {
433
444
  return expected / parseFloat(getComputedStyle(parentEle).width) * 100;
434
445
  };
@@ -472,21 +483,19 @@ var Image = /** @class */ (function () {
472
483
  var currentHeight = this.imgEle.clientHeight;
473
484
  var width = diffX * resizeFactor[0] + currentWidth;
474
485
  var height = diffY * resizeFactor[1] + currentHeight;
475
- width = (width < 16) ? 16 : width;
476
- height = (height < 16) ? 16 : height;
477
- if (Math.abs(diffX) > Math.abs(diffY)) {
478
- height = Math.round(width / this.aspectRatio);
479
- width = Math.round(height * this.aspectRatio);
480
- }
481
- else {
482
- width = Math.round(height * this.aspectRatio);
483
- height = Math.round(width / this.aspectRatio);
484
- }
486
+ var dimensions = this.adjustDimensions(width, height, diffX, diffY, this.aspectRatio);
485
487
  this.pageX = pageX;
486
488
  this.pageY = pageY;
487
- this.imgDupMouseMove(width + 'px', height + 'px', e);
489
+ this.imgDupMouseMove(dimensions.width + 'px', dimensions.height + 'px', e);
488
490
  }
489
491
  };
492
+ Image.prototype.adjustDimensions = function (width, height, diffX, diffY, aspectRatio) {
493
+ width = (width < 16) ? 16 : width;
494
+ height = (height < 16) ? 16 : height;
495
+ var isWidthPrimary = Math.abs(diffX) > Math.abs(diffY);
496
+ var dimensions = this.adjustDimensionsByAspectRatio(width, height, aspectRatio, isWidthPrimary);
497
+ return dimensions;
498
+ };
490
499
  Image.prototype.getResizeFactor = function (value) {
491
500
  return imageResizeFactor[value];
492
501
  };
@@ -559,11 +568,15 @@ var Image = /** @class */ (function () {
559
568
  }
560
569
  };
561
570
  Image.prototype.openImgLink = function (e) {
571
+ var sanitizedHTML = this.parent.htmlEditorModule.sanitizeHelper(e.selectParent[0].parentNode.outerHTML);
572
+ var tempEle = document.createElement('div');
573
+ tempEle.innerHTML = sanitizedHTML;
562
574
  var target = e.selectParent[0].parentNode.target === '' ? '_self' : '_blank';
563
575
  this.parent.formatter.process(this.parent, e.args, e.args, {
564
- url: e.selectParent[0].parentNode.href, target: target, selectNode: e.selectNode,
576
+ url: tempEle.firstChild.href, target: target, selectNode: e.selectNode,
565
577
  subCommand: e.args.item.subCommand
566
578
  });
579
+ tempEle.remove();
567
580
  };
568
581
  Image.prototype.editImgLink = function (e) {
569
582
  var selectParentEle = e.selectParent[0].parentNode;
@@ -650,7 +663,7 @@ var Image = /** @class */ (function () {
650
663
  }
651
664
  }
652
665
  if (originalEvent.keyCode === 8 || originalEvent.keyCode === 46) {
653
- if (selectNodeEle && selectNodeEle[0].nodeName === 'IMG' && selectNodeEle.length < 1) {
666
+ if (selectNodeEle && selectNodeEle[0] && selectNodeEle[0].nodeName === 'IMG' && selectNodeEle.length < 1) {
654
667
  if (!isNOU(this.parent.formatter.editorManager.nodeSelection)) {
655
668
  save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
656
669
  }
@@ -375,7 +375,7 @@ var Link = /** @class */ (function () {
375
375
  // eslint-disable-next-line
376
376
  Link.prototype.insertlink = function (e) {
377
377
  var linkEle = this.selfLink.dialogObj.element;
378
- var linkUrl = linkEle.querySelector('.e-rte-linkurl').value;
378
+ var linkUrl = linkEle.querySelector('.e-rte-linkurl').value.trim();
379
379
  var linkText = linkEle.querySelector('.e-rte-linkText').value;
380
380
  var linkTitle;
381
381
  if (this.selfLink.parent.editorMode === 'HTML') {
@@ -491,11 +491,15 @@ var Link = /** @class */ (function () {
491
491
  Link.prototype.openLink = function (e) {
492
492
  var selectParentEle = this.getAnchorNode(e.selectParent[0]);
493
493
  if (selectParentEle.classList.contains('e-rte-anchor') || selectParentEle.tagName === 'A') {
494
+ var sanitizedHTML = this.parent.htmlEditorModule.sanitizeHelper(selectParentEle.outerHTML);
495
+ var tempEle = document.createElement('div');
496
+ tempEle.innerHTML = sanitizedHTML;
494
497
  this.parent.formatter.process(this.parent, e.args, e.args, {
495
- url: selectParentEle.href, text: selectParentEle.innerText,
498
+ url: tempEle.firstChild.href, text: selectParentEle.innerText,
496
499
  target: selectParentEle.target === '' ? '_self' : '_blank', selectNode: e.selectNode,
497
500
  subCommand: e.args.item.subCommand
498
501
  });
502
+ tempEle.remove();
499
503
  }
500
504
  };
501
505
  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);
@@ -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
  }
@@ -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 };