Skip to content

Commit

Permalink
fix: insertComponent exception v2.15.3
Browse files Browse the repository at this point in the history
  • Loading branch information
JiHong88 committed Jun 1, 2019
1 parent 16c081f commit b4e47ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/suneditor.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@ export default function (context, pluginCallButtons, plugins, lang) {
*/
insertComponent: function (element) {
let oNode = null;
const formatEl = util.getFormatElement(this.getSelectionNode());
const selectionNode = this.getSelectionNode();
const formatEl = util.getFormatElement(selectionNode);

if (util.isListCell(formatEl)) {
if (/^HR$/i.test(element.nodeName)) {
Expand All @@ -581,7 +582,7 @@ export default function (context, pluginCallButtons, plugins, lang) {
formatEl.parentNode.insertBefore(newLi, formatEl.nextElementSibling);
this.setRange(textNode, 1, textNode, 1);
} else {
this.insertNode(element, this.getSelectionNode());
this.insertNode(element, selectionNode === formatEl ? null : selectionNode);
oNode = util.createElement('LI');
formatEl.parentNode.insertBefore(oNode, formatEl.nextElementSibling);
}
Expand Down

0 comments on commit b4e47ce

Please sign in to comment.