@syncfusion/ej2-richtexteditor 27.1.52 → 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.
- package/dist/ej2-richtexteditor.min.js +10 -0
- package/dist/ej2-richtexteditor.umd.min.js +2 -2
- package/dist/ej2-richtexteditor.umd.min.js.map +1 -1
- package/dist/es6/ej2-richtexteditor.es2015.js +141 -37
- package/dist/es6/ej2-richtexteditor.es2015.js.map +1 -1
- package/dist/es6/ej2-richtexteditor.es5.js +143 -37
- package/dist/es6/ej2-richtexteditor.es5.js.map +1 -1
- package/dist/global/ej2-richtexteditor.min.js +2 -2
- package/dist/global/ej2-richtexteditor.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +12 -12
- package/src/editor-manager/base/editor-manager.js +1 -1
- package/src/editor-manager/base/interface.d.ts +2 -2
- package/src/editor-manager/plugin/clearformat.js +1 -1
- package/src/editor-manager/plugin/dom-node.js +1 -1
- package/src/editor-manager/plugin/image.js +2 -0
- package/src/editor-manager/plugin/inserthtml.d.ts +1 -0
- package/src/editor-manager/plugin/inserthtml.js +34 -10
- package/src/editor-manager/plugin/link.js +2 -2
- package/src/editor-manager/plugin/lists.js +1 -1
- package/src/editor-manager/plugin/selection-commands.js +2 -2
- package/src/editor-manager/plugin/toolbar-status.js +1 -1
- package/src/editor-manager/plugin/undo.js +3 -3
- package/src/rich-text-editor/actions/enter-key.js +10 -5
- package/src/rich-text-editor/actions/html-editor.js +2 -2
- package/src/rich-text-editor/actions/import-export.js +1 -1
- package/src/rich-text-editor/actions/paste-clean-up.js +1 -1
- package/src/rich-text-editor/actions/resize.d.ts +3 -0
- package/src/rich-text-editor/actions/resize.js +13 -0
- package/src/rich-text-editor/base/interface.d.ts +13 -1
- package/src/rich-text-editor/base/rich-text-editor.js +11 -0
- package/src/rich-text-editor/renderer/image-module.js +6 -2
- package/src/rich-text-editor/renderer/link-module.js +5 -1
- package/src/rich-text-editor/renderer/slash-menu.js +1 -1
- package/src/rich-text-editor/renderer/video-module.js +1 -1
- package/src/selection/selection.d.ts +5 -0
- package/src/selection/selection.js +44 -1
|
@@ -4251,9 +4251,10 @@ const PASTE_SOURCE = ['word', 'excel', 'onenote'];
|
|
|
4251
4251
|
* `Selection` module is used to handle RTE Selections.
|
|
4252
4252
|
*/
|
|
4253
4253
|
class NodeSelection {
|
|
4254
|
-
constructor() {
|
|
4254
|
+
constructor(editElement) {
|
|
4255
4255
|
this.startNodeName = [];
|
|
4256
4256
|
this.endNodeName = [];
|
|
4257
|
+
this.editableElement = editElement;
|
|
4257
4258
|
}
|
|
4258
4259
|
saveInstance(range, body) {
|
|
4259
4260
|
this.range = range.cloneRange();
|
|
@@ -4333,6 +4334,9 @@ class NodeSelection {
|
|
|
4333
4334
|
return false;
|
|
4334
4335
|
}
|
|
4335
4336
|
getNode(startNode, endNode, nodeCollection) {
|
|
4337
|
+
if (this.editableElement && (!this.editableElement.contains(startNode) || this.editableElement === startNode)) {
|
|
4338
|
+
return null;
|
|
4339
|
+
}
|
|
4336
4340
|
if (endNode === startNode &&
|
|
4337
4341
|
(startNode.nodeType === 3 || !startNode.firstChild || nodeCollection.indexOf(startNode.firstChild) !== -1
|
|
4338
4342
|
|| this.isChildNode(nodeCollection, startNode))) {
|
|
@@ -4367,6 +4371,12 @@ class NodeSelection {
|
|
|
4367
4371
|
|| range.startContainer;
|
|
4368
4372
|
const endNode = range.endContainer.childNodes[(range.endOffset > 0) ? (range.endOffset - 1) : range.endOffset]
|
|
4369
4373
|
|| range.endContainer;
|
|
4374
|
+
const tableCursor = this.processedTableImageCursor(range);
|
|
4375
|
+
if (tableCursor.start || tableCursor.end) {
|
|
4376
|
+
if (tableCursor.startName === 'TABLE' || tableCursor.endName === 'TABLE') {
|
|
4377
|
+
return [];
|
|
4378
|
+
}
|
|
4379
|
+
}
|
|
4370
4380
|
if ((startNode === endNode || (startNode.nodeName === 'BR' && startNode === range.endContainer.childNodes[range.endOffset])) &&
|
|
4371
4381
|
startNode.childNodes.length === 0) {
|
|
4372
4382
|
return [startNode];
|
|
@@ -4686,6 +4696,39 @@ class NodeSelection {
|
|
|
4686
4696
|
selection.removeAllRanges();
|
|
4687
4697
|
selection.addRange(range);
|
|
4688
4698
|
}
|
|
4699
|
+
isTableOrImageStart(range) {
|
|
4700
|
+
const customHandlerElements = ['TABLE'];
|
|
4701
|
+
const startContainer = range.startContainer;
|
|
4702
|
+
const startOffset = range.startOffset;
|
|
4703
|
+
const isCursorAtStart = range.collapsed && (startContainer.nodeType === 1) &&
|
|
4704
|
+
startContainer.isContentEditable && startContainer.childNodes[startOffset] &&
|
|
4705
|
+
(customHandlerElements.indexOf(startContainer.childNodes[startOffset].nodeName) > -1);
|
|
4706
|
+
if (isCursorAtStart) {
|
|
4707
|
+
return { start: isCursorAtStart, startNodeName: startContainer.childNodes[startOffset].nodeName };
|
|
4708
|
+
}
|
|
4709
|
+
else {
|
|
4710
|
+
return { start: false, startNodeName: '' };
|
|
4711
|
+
}
|
|
4712
|
+
}
|
|
4713
|
+
isTableOrImageEnd(range) {
|
|
4714
|
+
const customHandlerElements = ['TABLE'];
|
|
4715
|
+
const startContainer = range.startContainer;
|
|
4716
|
+
const startOffset = range.startOffset;
|
|
4717
|
+
const isCursorAtEnd = range.collapsed && (startContainer.nodeType === 1) &&
|
|
4718
|
+
startContainer.isContentEditable && startContainer.childNodes[startOffset - 1] &&
|
|
4719
|
+
(customHandlerElements.indexOf(startContainer.childNodes[startOffset - 1].nodeName) > -1);
|
|
4720
|
+
if (isCursorAtEnd) {
|
|
4721
|
+
return { end: isCursorAtEnd, endNodeName: startContainer.childNodes[startOffset - 1].nodeName };
|
|
4722
|
+
}
|
|
4723
|
+
else {
|
|
4724
|
+
return { end: false, endNodeName: '' };
|
|
4725
|
+
}
|
|
4726
|
+
}
|
|
4727
|
+
processedTableImageCursor(range) {
|
|
4728
|
+
const { start, startNodeName } = this.isTableOrImageStart(range);
|
|
4729
|
+
const { end, endNodeName } = this.isTableOrImageEnd(range);
|
|
4730
|
+
return { start, startName: startNodeName, end, endName: endNodeName };
|
|
4731
|
+
}
|
|
4689
4732
|
}
|
|
4690
4733
|
|
|
4691
4734
|
/**
|
|
@@ -5038,7 +5081,7 @@ class ToolbarStatus {
|
|
|
5038
5081
|
static get(docElement, rootNode, formatNode, fontSize, fontName, documentNode) {
|
|
5039
5082
|
let formatCollection = JSON.parse(JSON.stringify(statusCollection));
|
|
5040
5083
|
const nodeCollection = JSON.parse(JSON.stringify(statusCollection));
|
|
5041
|
-
const nodeSelection = new NodeSelection();
|
|
5084
|
+
const nodeSelection = new NodeSelection(rootNode);
|
|
5042
5085
|
const range = nodeSelection.getRange(docElement);
|
|
5043
5086
|
const nodes = documentNode ? [documentNode] : range.collapsed ? nodeSelection.getNodeCollection(range) :
|
|
5044
5087
|
nodeSelection.getSelectionNodeCollectionBr(range);
|
|
@@ -6636,11 +6679,15 @@ class Link {
|
|
|
6636
6679
|
openLink(e) {
|
|
6637
6680
|
const selectParentEle = this.getAnchorNode(e.selectParent[0]);
|
|
6638
6681
|
if (selectParentEle.classList.contains('e-rte-anchor') || selectParentEle.tagName === 'A') {
|
|
6682
|
+
const sanitizedHTML = this.parent.htmlEditorModule.sanitizeHelper(selectParentEle.outerHTML);
|
|
6683
|
+
const tempEle = document.createElement('div');
|
|
6684
|
+
tempEle.innerHTML = sanitizedHTML;
|
|
6639
6685
|
this.parent.formatter.process(this.parent, e.args, e.args, {
|
|
6640
|
-
url:
|
|
6686
|
+
url: tempEle.firstChild.href, text: selectParentEle.innerText,
|
|
6641
6687
|
target: selectParentEle.target === '' ? '_self' : '_blank', selectNode: e.selectNode,
|
|
6642
6688
|
subCommand: e.args.item.subCommand
|
|
6643
6689
|
});
|
|
6690
|
+
tempEle.remove();
|
|
6644
6691
|
}
|
|
6645
6692
|
}
|
|
6646
6693
|
getAnchorNode(element) {
|
|
@@ -7435,11 +7482,15 @@ class Image$1 {
|
|
|
7435
7482
|
}
|
|
7436
7483
|
}
|
|
7437
7484
|
openImgLink(e) {
|
|
7485
|
+
const sanitizedHTML = this.parent.htmlEditorModule.sanitizeHelper(e.selectParent[0].parentNode.outerHTML);
|
|
7486
|
+
const tempEle = document.createElement('div');
|
|
7487
|
+
tempEle.innerHTML = sanitizedHTML;
|
|
7438
7488
|
const target = e.selectParent[0].parentNode.target === '' ? '_self' : '_blank';
|
|
7439
7489
|
this.parent.formatter.process(this.parent, e.args, e.args, {
|
|
7440
|
-
url:
|
|
7490
|
+
url: tempEle.firstChild.href, target: target, selectNode: e.selectNode,
|
|
7441
7491
|
subCommand: e.args.item.subCommand
|
|
7442
7492
|
});
|
|
7493
|
+
tempEle.remove();
|
|
7443
7494
|
}
|
|
7444
7495
|
editImgLink(e) {
|
|
7445
7496
|
const selectParentEle = e.selectParent[0].parentNode;
|
|
@@ -7526,7 +7577,7 @@ class Image$1 {
|
|
|
7526
7577
|
}
|
|
7527
7578
|
}
|
|
7528
7579
|
if (originalEvent.keyCode === 8 || originalEvent.keyCode === 46) {
|
|
7529
|
-
if (selectNodeEle && selectNodeEle[0].nodeName === 'IMG' && selectNodeEle.length < 1) {
|
|
7580
|
+
if (selectNodeEle && selectNodeEle[0] && selectNodeEle[0].nodeName === 'IMG' && selectNodeEle.length < 1) {
|
|
7530
7581
|
if (!isNullOrUndefined(this.parent.formatter.editorManager.nodeSelection)) {
|
|
7531
7582
|
save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
|
|
7532
7583
|
}
|
|
@@ -10837,7 +10888,7 @@ class Video {
|
|
|
10837
10888
|
this.undoStack({ subCommand: (originalEvent.keyCode === 90 ? 'undo' : 'redo') });
|
|
10838
10889
|
}
|
|
10839
10890
|
if (originalEvent.keyCode === 8 || originalEvent.keyCode === 46) {
|
|
10840
|
-
if (selectNodeEle && (selectNodeEle[0].nodeName === 'VIDEO' || this.isEmbedVidElem(selectNodeEle[0])) && selectNodeEle.length < 1) {
|
|
10891
|
+
if (selectNodeEle && selectNodeEle[0] && (selectNodeEle[0].nodeName === 'VIDEO' || this.isEmbedVidElem(selectNodeEle[0])) && selectNodeEle.length < 1) {
|
|
10841
10892
|
if (!isNullOrUndefined(this.parent.formatter.editorManager.nodeSelection)) {
|
|
10842
10893
|
save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
|
|
10843
10894
|
}
|
|
@@ -15545,7 +15596,7 @@ class SlashMenu {
|
|
|
15545
15596
|
this.parent = options;
|
|
15546
15597
|
this.currentDocument = this.parent.element.ownerDocument;
|
|
15547
15598
|
this.L10n = serviceLocator.getService('rteLocale');
|
|
15548
|
-
this.savedSelection = new NodeSelection();
|
|
15599
|
+
this.savedSelection = new NodeSelection(this.parent.inputElement);
|
|
15549
15600
|
this.defaultItems = defaultSlashMenuDataModel;
|
|
15550
15601
|
this.injectibleItems = injectibleSlashMenuDataModel;
|
|
15551
15602
|
this.parent.on(modelChanged, this.onPropertyChanged, this);
|
|
@@ -21627,7 +21678,7 @@ class DOMNode {
|
|
|
21627
21678
|
*/
|
|
21628
21679
|
constructor(parent, currentDocument) {
|
|
21629
21680
|
this.parent = parent;
|
|
21630
|
-
this.nodeSelection = new NodeSelection();
|
|
21681
|
+
this.nodeSelection = new NodeSelection(parent);
|
|
21631
21682
|
this.currentDocument = currentDocument;
|
|
21632
21683
|
this.tableSelection = new TableSelection(parent, currentDocument);
|
|
21633
21684
|
}
|
|
@@ -22942,7 +22993,7 @@ class Lists {
|
|
|
22942
22993
|
if (e.event.which === 8) {
|
|
22943
22994
|
this.backspaceList(e);
|
|
22944
22995
|
}
|
|
22945
|
-
if ((e.event.which === 46 && e.event.action === 'delete')
|
|
22996
|
+
if ((e.event.which === 46 && e.event.action === 'delete')) {
|
|
22946
22997
|
const range = this.parent.nodeSelection.getRange(this.parent.currentDocument);
|
|
22947
22998
|
const commonAncestor = range.commonAncestorContainer;
|
|
22948
22999
|
const startEle = range.startContainer;
|
|
@@ -24461,7 +24512,7 @@ class InsertHtml {
|
|
|
24461
24512
|
node = insertNode;
|
|
24462
24513
|
}
|
|
24463
24514
|
}
|
|
24464
|
-
const nodeSelection = new NodeSelection();
|
|
24515
|
+
const nodeSelection = new NodeSelection(editNode);
|
|
24465
24516
|
const nodeCutter = new NodeCutter();
|
|
24466
24517
|
let range = nodeSelection.getRange(docElement);
|
|
24467
24518
|
if (range.startContainer === editNode && range.startContainer === range.endContainer && range.startOffset === 0 &&
|
|
@@ -24825,6 +24876,24 @@ class InsertHtml {
|
|
|
24825
24876
|
this.cursorPos(lastSelectionNode, node, nodeSelection, docElement, editNode, enterAction);
|
|
24826
24877
|
}
|
|
24827
24878
|
this.alignCheck(editNode);
|
|
24879
|
+
const currentRange = nodeSelection.getRange(docElement);
|
|
24880
|
+
this.listCleanUp(currentRange);
|
|
24881
|
+
}
|
|
24882
|
+
static listCleanUp(range) {
|
|
24883
|
+
if (range.startContainer.parentElement.closest('ol,ul') !== null && range.endContainer.parentElement.closest('ol,ul') !== null) {
|
|
24884
|
+
const liElems = range.startContainer.parentElement.closest('ol,ul').querySelectorAll('li');
|
|
24885
|
+
if (liElems.length > 0) {
|
|
24886
|
+
liElems.forEach((item) => {
|
|
24887
|
+
if (!isNullOrUndefined(item.firstChild) && (item.firstChild.nodeName === 'OL' || item.firstChild.nodeName === 'UL')) {
|
|
24888
|
+
item.style.listStyleType = 'none';
|
|
24889
|
+
}
|
|
24890
|
+
const nestedLi = Array.from(item.children).find((child) => child.tagName === 'LI' && (child.parentElement && child.parentElement.tagName !== 'OL' && child.parentElement.tagName !== 'UL'));
|
|
24891
|
+
if (nestedLi) {
|
|
24892
|
+
item.parentNode.replaceChild(nestedLi, item);
|
|
24893
|
+
}
|
|
24894
|
+
});
|
|
24895
|
+
}
|
|
24896
|
+
}
|
|
24828
24897
|
}
|
|
24829
24898
|
static placeCursorEnd(lastSelectionNode, node, nodeSelection, docElement, editNode) {
|
|
24830
24899
|
lastSelectionNode = lastSelectionNode.nodeName === 'BR' ? (isNullOrUndefined(lastSelectionNode.previousSibling) ? lastSelectionNode.parentNode
|
|
@@ -24889,7 +24958,7 @@ class InsertHtml {
|
|
|
24889
24958
|
blockNode = range.endContainer;
|
|
24890
24959
|
range.setEnd(blockNode, range.endContainer.textContent.length);
|
|
24891
24960
|
}
|
|
24892
|
-
if (blockNode && blockNode.nodeName === 'BODY' && range.startContainer === range.endContainer && range.startContainer.nodeType === 1) {
|
|
24961
|
+
if (blockNode && blockNode.nodeName === 'BODY' || blockNode.nodeName === 'DIV' && range.startContainer === range.endContainer && range.startContainer.nodeType === 1) {
|
|
24893
24962
|
blockNode = range.startContainer;
|
|
24894
24963
|
}
|
|
24895
24964
|
if (blockNode && blockNode.closest('LI') && editNode.contains(blockNode.closest('LI')) && blockNode.nodeName !== 'TD' && blockNode.nodeName !== 'TH' && blockNode.nodeName !== 'TR' && node && node.firstElementChild &&
|
|
@@ -24909,12 +24978,12 @@ class InsertHtml {
|
|
|
24909
24978
|
tempSpan.parentNode.replaceChild(node, tempSpan);
|
|
24910
24979
|
}
|
|
24911
24980
|
else {
|
|
24912
|
-
const nodeSelection = new NodeSelection();
|
|
24981
|
+
const nodeSelection = new NodeSelection(editNode);
|
|
24913
24982
|
const currentNode = this.getNodeCollection(range, nodeSelection, node)[this.getNodeCollection(range, nodeSelection, node).length - 1];
|
|
24914
24983
|
let splitedElm;
|
|
24915
|
-
if ((currentNode.nodeName === 'BR' || currentNode.nodeName === 'HR' ||
|
|
24984
|
+
if (currentNode && ((currentNode.nodeName === 'BR' || currentNode.nodeName === 'HR' ||
|
|
24916
24985
|
(currentNode.nodeName === '#text' && !isNullOrUndefined(currentNode.parentElement) && currentNode.parentElement.nodeName === 'LI')) &&
|
|
24917
|
-
(!isNullOrUndefined(currentNode.parentElement) && currentNode.parentElement.textContent.trim().length === 0)) {
|
|
24986
|
+
(!isNullOrUndefined(currentNode.parentElement) && currentNode.parentElement.textContent.trim().length === 0))) {
|
|
24918
24987
|
splitedElm = currentNode;
|
|
24919
24988
|
if (currentNode.parentElement.nodeName === 'LI' && !isNullOrUndefined(currentNode.nextSibling) &&
|
|
24920
24989
|
currentNode.nextSibling.nodeName === 'BR') {
|
|
@@ -24927,16 +24996,20 @@ class InsertHtml {
|
|
|
24927
24996
|
return;
|
|
24928
24997
|
}
|
|
24929
24998
|
}
|
|
24930
|
-
else if ((currentNode.nodeName === '#text' || currentNode.nodeName === 'BR') && !isNullOrUndefined(currentNode.parentElement) &&
|
|
24999
|
+
else if (currentNode && ((currentNode.nodeName === '#text' || currentNode.nodeName === 'BR') && !isNullOrUndefined(currentNode.parentElement) &&
|
|
24931
25000
|
(currentNode.parentElement.nodeName === 'LI' || currentNode.parentElement.closest('LI') || (blockNode === editNode && currentNode.parentElement === blockNode)) &&
|
|
24932
|
-
currentNode.parentElement.textContent.trim().length > 0) {
|
|
25001
|
+
currentNode.parentElement.textContent.trim().length > 0)) {
|
|
24933
25002
|
splitedElm = currentNode;
|
|
24934
25003
|
if (currentNode.parentElement.nodeName === 'LI' && !isNullOrUndefined(currentNode.nextSibling) &&
|
|
24935
25004
|
currentNode.nextSibling.nodeName === 'BR') {
|
|
24936
25005
|
detach(currentNode.nextSibling);
|
|
24937
25006
|
}
|
|
24938
25007
|
if (!range.collapsed) {
|
|
25008
|
+
const startContainer = range.startContainer;
|
|
25009
|
+
const startOffset = range.startOffset;
|
|
24939
25010
|
this.removeListfromPaste(range);
|
|
25011
|
+
range.setStart(startContainer, startOffset);
|
|
25012
|
+
range.setEnd(startContainer, startOffset);
|
|
24940
25013
|
}
|
|
24941
25014
|
range.insertNode(node);
|
|
24942
25015
|
this.contentsDeleted = true;
|
|
@@ -24976,9 +25049,9 @@ class InsertHtml {
|
|
|
24976
25049
|
}
|
|
24977
25050
|
// eslint-disable-next-line
|
|
24978
25051
|
static getImmediateBlockNode(node, editNode) {
|
|
24979
|
-
|
|
25052
|
+
while (node && BLOCK_TAGS.indexOf(node.nodeName.toLocaleLowerCase()) < 0) {
|
|
24980
25053
|
node = node.parentNode;
|
|
24981
|
-
}
|
|
25054
|
+
}
|
|
24982
25055
|
return node;
|
|
24983
25056
|
}
|
|
24984
25057
|
static removingComments(elm) {
|
|
@@ -25092,7 +25165,7 @@ class InsertHtml {
|
|
|
25092
25165
|
const value = range.startContainer;
|
|
25093
25166
|
if (!isNullOrUndefined(value) && value.nodeName === 'LI' && !isNullOrUndefined(value.parentElement) && (value.parentElement.nodeName === 'OL' || value.parentElement.nodeName === 'UL') && value.textContent.trim() === '') {
|
|
25094
25167
|
value.parentElement.querySelectorAll('li').forEach((item) => {
|
|
25095
|
-
if (item.textContent.trim() === '') {
|
|
25168
|
+
if (item.textContent.trim() === '' && item !== value) {
|
|
25096
25169
|
item.remove();
|
|
25097
25170
|
}
|
|
25098
25171
|
});
|
|
@@ -25194,7 +25267,7 @@ class LinkCommand {
|
|
|
25194
25267
|
}
|
|
25195
25268
|
}
|
|
25196
25269
|
else {
|
|
25197
|
-
const domSelection = new NodeSelection();
|
|
25270
|
+
const domSelection = new NodeSelection(this.parent.editableElement);
|
|
25198
25271
|
let range = domSelection.getRange(this.parent.currentDocument);
|
|
25199
25272
|
if (range.endContainer.nodeName === '#text' && range.startContainer.textContent.length === (range.endOffset + 1) &&
|
|
25200
25273
|
range.endContainer.textContent.charAt(range.endOffset) === ' ' && (!isNullOrUndefined(range.endContainer.nextSibling) && range.endContainer.nextSibling.nodeName === 'A')) {
|
|
@@ -25240,7 +25313,7 @@ class LinkCommand {
|
|
|
25240
25313
|
}
|
|
25241
25314
|
}
|
|
25242
25315
|
createLinkNode(e) {
|
|
25243
|
-
const domSelection = new NodeSelection();
|
|
25316
|
+
const domSelection = new NodeSelection(this.parent.editableElement);
|
|
25244
25317
|
const nodeCutter = new NodeCutter();
|
|
25245
25318
|
const range = domSelection.getRange(this.parent.currentDocument);
|
|
25246
25319
|
const nodes = this.getSelectionNodes(domSelection.getNodeCollection(range));
|
|
@@ -25811,6 +25884,8 @@ class ImageCommand {
|
|
|
25811
25884
|
(Browser.isIE ? selectedNode.previousSibling : selectedNode.previousElementSibling);
|
|
25812
25885
|
const onImageLoadEvent = () => {
|
|
25813
25886
|
if (!isNullOrUndefined(this.parent.currentDocument)) {
|
|
25887
|
+
imgElm.setAttribute('width', this.calculateStyleValue(imgElm.offsetWidth));
|
|
25888
|
+
imgElm.setAttribute('height', this.calculateStyleValue(imgElm.offsetHeight));
|
|
25814
25889
|
e.callBack({
|
|
25815
25890
|
requestType: (e.value === 'Replace') ? (e.item.subCommand = 'Replace', 'Replace') : 'Images',
|
|
25816
25891
|
editorMode: 'HTML',
|
|
@@ -27634,7 +27709,7 @@ class SelectionCommands {
|
|
|
27634
27709
|
if (format === 'backgroundcolor' && value === '') {
|
|
27635
27710
|
value = 'transparent';
|
|
27636
27711
|
}
|
|
27637
|
-
let domSelection = new NodeSelection();
|
|
27712
|
+
let domSelection = new NodeSelection(endNode);
|
|
27638
27713
|
const domNode = new DOMNode(endNode, docElement);
|
|
27639
27714
|
const nodeCutter = new NodeCutter();
|
|
27640
27715
|
const isFormatted = new IsFormatted();
|
|
@@ -27843,7 +27918,7 @@ class SelectionCommands {
|
|
|
27843
27918
|
if (cursorNodes.length === 1 && range.startOffset === 0 && (cursorNodes[0].nodeName === 'BR' || (isNullOrUndefined(cursorNodes[0].nextSibling) ? false : cursorNodes[0].nextSibling.nodeName === 'BR'))) {
|
|
27844
27919
|
detach(cursorNodes[0].nodeName === '#text' ? cursorNodes[0].nextSibling : cursorNodes[0]);
|
|
27845
27920
|
}
|
|
27846
|
-
if (!isNullOrUndefined(cursorNodes[0].parentElement) && IsFormatted.inlineTags.
|
|
27921
|
+
if (!isNullOrUndefined(cursorNodes[0] && cursorNodes[0].parentElement) && IsFormatted.inlineTags.
|
|
27847
27922
|
indexOf((cursorNodes[0].parentElement).tagName.toLowerCase()) !== -1 && cursorNodes[0].textContent.includes('\u200B')) {
|
|
27848
27923
|
const element = this.GetFormatNode(format, value);
|
|
27849
27924
|
const tempNode = cursorNodes[0];
|
|
@@ -28751,7 +28826,7 @@ class ClearFormat$1 {
|
|
|
28751
28826
|
static clear(docElement, endNode, enterAction, selector, command) {
|
|
28752
28827
|
this.domNode = new DOMNode(endNode, docElement);
|
|
28753
28828
|
this.defaultTag = enterAction === 'P' ? this.defaultTag : 'div';
|
|
28754
|
-
const nodeSelection = new NodeSelection();
|
|
28829
|
+
const nodeSelection = new NodeSelection(endNode);
|
|
28755
28830
|
const nodeCutter = new NodeCutter();
|
|
28756
28831
|
let range = nodeSelection.getRange(docElement);
|
|
28757
28832
|
const nodes = range.collapsed ? nodeSelection.getSelectionNodeCollection(range) :
|
|
@@ -29180,7 +29255,7 @@ class UndoRedoManager {
|
|
|
29180
29255
|
if (!this.parent.currentDocument) {
|
|
29181
29256
|
return;
|
|
29182
29257
|
}
|
|
29183
|
-
let range = new NodeSelection().getRange(this.parent.currentDocument);
|
|
29258
|
+
let range = new NodeSelection(this.parent.editableElement).getRange(this.parent.currentDocument);
|
|
29184
29259
|
const currentContainer = this.parent.editableElement === range.startContainer.parentElement ?
|
|
29185
29260
|
range.startContainer.parentElement : range.startContainer;
|
|
29186
29261
|
for (let i = currentContainer.childNodes.length - 1; i >= 0; i--) {
|
|
@@ -29190,8 +29265,8 @@ class UndoRedoManager {
|
|
|
29190
29265
|
detach(currentContainer.childNodes[i]);
|
|
29191
29266
|
}
|
|
29192
29267
|
}
|
|
29193
|
-
range = new NodeSelection().getRange(this.parent.currentDocument);
|
|
29194
|
-
const save = new NodeSelection().save(range, this.parent.currentDocument);
|
|
29268
|
+
range = new NodeSelection(this.parent.editableElement).getRange(this.parent.currentDocument);
|
|
29269
|
+
const save = new NodeSelection(this.parent.editableElement).save(range, this.parent.currentDocument);
|
|
29195
29270
|
const clonedElement = this.parent.editableElement.cloneNode(true);
|
|
29196
29271
|
const fragment = document.createDocumentFragment();
|
|
29197
29272
|
while (clonedElement.firstChild) {
|
|
@@ -31168,7 +31243,7 @@ class EditorManager {
|
|
|
31168
31243
|
constructor(options) {
|
|
31169
31244
|
this.currentDocument = options.document;
|
|
31170
31245
|
this.editableElement = options.editableElement;
|
|
31171
|
-
this.nodeSelection = new NodeSelection();
|
|
31246
|
+
this.nodeSelection = new NodeSelection(this.editableElement);
|
|
31172
31247
|
this.nodeCutter = new NodeCutter();
|
|
31173
31248
|
this.domNode = new DOMNode(this.editableElement, this.currentDocument);
|
|
31174
31249
|
this.observer = new Observer(this);
|
|
@@ -31836,7 +31911,7 @@ class HtmlEditor {
|
|
|
31836
31911
|
if (this.parent.isDestroyed) {
|
|
31837
31912
|
return;
|
|
31838
31913
|
}
|
|
31839
|
-
this.nodeSelectionObj = new NodeSelection();
|
|
31914
|
+
this.nodeSelectionObj = new NodeSelection(this.parent.inputElement);
|
|
31840
31915
|
this.parent.on(initialLoad, this.instantiateRenderer, this);
|
|
31841
31916
|
this.parent.on(htmlToolbarClick, this.onToolbarClick, this);
|
|
31842
31917
|
this.parent.on(keyDown, this.onKeyDown, this);
|
|
@@ -32543,7 +32618,7 @@ class HtmlEditor {
|
|
|
32543
32618
|
urlText = urlText.slice(0, urlTextRange);
|
|
32544
32619
|
// eslint-disable-next-line
|
|
32545
32620
|
const regex = new RegExp(/([^\S]|^)(((https?\:\/\/)|(www\.))(\S+))/gi);
|
|
32546
|
-
if (selectNodeEle[0].nodeName !== 'A' && urlText.match(regex)) {
|
|
32621
|
+
if (selectNodeEle[0] && selectNodeEle[0].nodeName !== 'A' && urlText.match(regex)) {
|
|
32547
32622
|
const selection = this.nodeSelectionObj.save(range, this.parent.contentModule.getDocument());
|
|
32548
32623
|
const url = urlText.indexOf('http') > -1 ? urlText : 'http://' + urlText;
|
|
32549
32624
|
const selectParent = this.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range);
|
|
@@ -32902,7 +32977,7 @@ class PasteCleanup {
|
|
|
32902
32977
|
this.isDestroyed = false;
|
|
32903
32978
|
}
|
|
32904
32979
|
addEventListener() {
|
|
32905
|
-
this.nodeSelectionObj = new NodeSelection();
|
|
32980
|
+
this.nodeSelectionObj = new NodeSelection(this.parent.inputElement);
|
|
32906
32981
|
if (this.parent.isDestroyed) {
|
|
32907
32982
|
return;
|
|
32908
32983
|
}
|
|
@@ -34056,6 +34131,8 @@ class Resize {
|
|
|
34056
34131
|
this.parent = parent;
|
|
34057
34132
|
this.addEventListener();
|
|
34058
34133
|
this.isDestroyed = false;
|
|
34134
|
+
this.isResizing = false;
|
|
34135
|
+
this.iframeMouseUpBoundFn = this.iframeMouseUp.bind(this);
|
|
34059
34136
|
}
|
|
34060
34137
|
addEventListener() {
|
|
34061
34138
|
if (this.parent.isDestroyed) {
|
|
@@ -34075,12 +34152,14 @@ class Resize {
|
|
|
34075
34152
|
this.parent.rootContainer.classList.add('e-resize-enabled');
|
|
34076
34153
|
if (this.parent.iframeSettings.enable) {
|
|
34077
34154
|
this.parent.inputElement.classList.add('e-resize-enabled');
|
|
34155
|
+
this.parent.contentModule.getDocument().addEventListener('mouseup', this.iframeMouseUpBoundFn);
|
|
34078
34156
|
}
|
|
34079
34157
|
this.touchStartEvent = (Browser.info.name === 'msie') ? 'pointerdown' : 'touchstart';
|
|
34080
34158
|
EventHandler.add(this.resizer, 'mousedown', this.resizeStart, this);
|
|
34081
34159
|
EventHandler.add(this.resizer, this.touchStartEvent, this.resizeStart, this);
|
|
34082
34160
|
}
|
|
34083
34161
|
resizeStart(e) {
|
|
34162
|
+
this.isResizing = false;
|
|
34084
34163
|
if (e.cancelable) {
|
|
34085
34164
|
e.preventDefault();
|
|
34086
34165
|
}
|
|
@@ -34094,6 +34173,7 @@ class Resize {
|
|
|
34094
34173
|
});
|
|
34095
34174
|
}
|
|
34096
34175
|
performResize(e) {
|
|
34176
|
+
this.isResizing = true;
|
|
34097
34177
|
const args = { event: e, requestType: 'editor' };
|
|
34098
34178
|
this.parent.trigger(onResize, args, (resizingArgs) => {
|
|
34099
34179
|
if (resizingArgs.cancel) {
|
|
@@ -34123,6 +34203,7 @@ class Resize {
|
|
|
34123
34203
|
this.parent.refreshUI();
|
|
34124
34204
|
}
|
|
34125
34205
|
stopResize(e) {
|
|
34206
|
+
this.isResizing = false;
|
|
34126
34207
|
this.parent.refreshUI();
|
|
34127
34208
|
this.unwireResizeEvents();
|
|
34128
34209
|
const args = { event: e, requestType: 'editor' };
|
|
@@ -34172,6 +34253,7 @@ class Resize {
|
|
|
34172
34253
|
}
|
|
34173
34254
|
if (this.parent.iframeSettings.enable && !isNullOrUndefined(this.parent.inputElement)) {
|
|
34174
34255
|
this.parent.inputElement.classList.remove('e-resize-enabled');
|
|
34256
|
+
this.parent.contentModule.getDocument().removeEventListener('mouseup', this.iframeMouseUpBoundFn);
|
|
34175
34257
|
}
|
|
34176
34258
|
if (this.resizer) {
|
|
34177
34259
|
EventHandler.remove(this.resizer, 'mousedown', this.resizeStart);
|
|
@@ -34179,6 +34261,12 @@ class Resize {
|
|
|
34179
34261
|
detach(this.resizer);
|
|
34180
34262
|
}
|
|
34181
34263
|
this.parent.off(destroy, this.destroy);
|
|
34264
|
+
this.iframeMouseUpBoundFn = null;
|
|
34265
|
+
}
|
|
34266
|
+
iframeMouseUp(e) {
|
|
34267
|
+
if (this.isResizing) {
|
|
34268
|
+
this.stopResize(e);
|
|
34269
|
+
}
|
|
34182
34270
|
}
|
|
34183
34271
|
/**
|
|
34184
34272
|
* For internal use only - Get the module name.
|
|
@@ -35682,7 +35770,7 @@ class ImportExport {
|
|
|
35682
35770
|
saveUrl: this.parent.importWord.serviceUrl
|
|
35683
35771
|
},
|
|
35684
35772
|
success: (args) => {
|
|
35685
|
-
this.parent.executeCommand('
|
|
35773
|
+
this.parent.executeCommand('importWord', args.e.currentTarget.response, { undo: true });
|
|
35686
35774
|
}
|
|
35687
35775
|
});
|
|
35688
35776
|
this.parent.setProperties({ enableXhtml: true }, true);
|
|
@@ -36972,11 +37060,16 @@ class EnterKeyAction {
|
|
|
36972
37060
|
else if (!isNullOrUndefined(currentParent) && currentParent !== this.parent.inputElement && currentParent.nodeName !== 'BR') {
|
|
36973
37061
|
if (currentParent.textContent.trim().length === 0 || (currentParent.textContent.trim().length === 1 &&
|
|
36974
37062
|
currentParent.textContent.charCodeAt(0) === 8203)) {
|
|
36975
|
-
|
|
36976
|
-
|
|
36977
|
-
|
|
36978
|
-
|
|
36979
|
-
|
|
37063
|
+
if (currentParent.childElementCount > 1 && currentParent.lastElementChild.nodeName === 'IMG') {
|
|
37064
|
+
this.insertBRElement();
|
|
37065
|
+
}
|
|
37066
|
+
else {
|
|
37067
|
+
const newElem = this.parent.formatter.editorManager.nodeCutter.SplitNode(this.range, currentParent, true).cloneNode(true);
|
|
37068
|
+
this.parent.formatter.editorManager.domNode.insertAfter(newElem, currentParent);
|
|
37069
|
+
const outerBRElem = this.parent.createElement('br');
|
|
37070
|
+
newElem.parentElement.insertBefore(outerBRElem, newElem);
|
|
37071
|
+
this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), newElem, 0);
|
|
37072
|
+
}
|
|
36980
37073
|
}
|
|
36981
37074
|
else {
|
|
36982
37075
|
let newElem;
|
|
@@ -37519,6 +37612,17 @@ let RichTextEditor = class RichTextEditor extends Component {
|
|
|
37519
37612
|
* @public
|
|
37520
37613
|
*/
|
|
37521
37614
|
executeCommand(commandName, value, option) {
|
|
37615
|
+
if (commandName === 'importWord') {
|
|
37616
|
+
const importContainer = this.createElement('div');
|
|
37617
|
+
importContainer.innerHTML = value;
|
|
37618
|
+
const tableElement = importContainer.querySelectorAll('table:not(.e-rte-table):not(.e-rte-paste-table)');
|
|
37619
|
+
for (let i = 0; i < tableElement.length; i++) {
|
|
37620
|
+
tableElement[i].classList.add('e-rte-paste-table');
|
|
37621
|
+
}
|
|
37622
|
+
value = importContainer.innerHTML;
|
|
37623
|
+
importContainer.remove();
|
|
37624
|
+
commandName = 'insertHTML';
|
|
37625
|
+
}
|
|
37522
37626
|
value = this.htmlPurifier(commandName, value);
|
|
37523
37627
|
let internalValue;
|
|
37524
37628
|
if (this.editorMode === 'HTML') {
|