Skip to content

Commit

Permalink
2.37.2
Browse files Browse the repository at this point in the history
  • Loading branch information
JiHong88 authored Mar 29, 2021
2 parents 81031af + 3a036bd commit aea3644
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "suneditor",
"version": "2.37.1",
"version": "2.37.2",
"description": "Pure JavaScript based WYSIWYG web editor",
"main": "src/suneditor.js",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion dist/css/suneditor.min.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/suneditor.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"sideEffects": [
"./src/assets/css/*.css"
],
"version": "2.37.1",
"version": "2.37.2",
"description": "Pure JavaScript based WYSIWYG web editor",
"main": "src/suneditor.js",
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions src/assets/css/suneditor-contents.css
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@

/* ol, ul */
.sun-editor-editable ol {
list-style-position: inside;
list-style-position: outside;
display: block;
list-style-type: decimal;
margin-block-start: 1em;
Expand All @@ -114,7 +114,7 @@
padding-inline-start: 40px;
}
.sun-editor-editable ul {
list-style-position: inside;
list-style-position: outside;
display: block;
list-style-type: disc;
margin-block-start: 1em;
Expand Down
40 changes: 33 additions & 7 deletions src/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
underline: options.textTags.underline,
italic: options.textTags.italic,
strike: options.textTags.strike,
subscript: 'SUB',
superscript: 'SUP'
subscript: options.textTags.sub,
superscript: options.textTags.sup
},

/**
Expand Down Expand Up @@ -1673,6 +1673,11 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re

// --- insert node ---
try {
if (util.isWysiwygDiv(afterNode) || parentNode === context.element.wysiwyg.parentNode) {
parentNode = context.element.wysiwyg;
afterNode = null;
}

if (util.isFormatElement(oNode) || util.isRangeFormatElement(oNode) || (!util.isListCell(parentNode) && util.isComponent(oNode))) {
const oldParent = parentNode;
if (util.isList(afterNode)) {
Expand All @@ -1695,10 +1700,24 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
afterNode = parentNode.nextElementSibling;
parentNode = parentNode.parentNode;
}

if (util.isWysiwygDiv(parentNode) && (oNode.nodeType === 3 || util.isBreak(oNode))) {
const fNode = util.createElement(options.defaultTag);
fNode.appendChild(oNode);
oNode = fNode;
}

parentNode.insertBefore(oNode, parentNode === afterNode ? parentNode.lastChild : afterNode);
} catch (e) {
parentNode.appendChild(oNode);
} finally {
if ((util.isFormatElement(oNode) || util.isComponent(oNode)) && startCon === endCon) {
const cItem = util.getFormatElement(commonCon, null);
if (cItem && cItem.nodeType === 1 && util.onlyZeroWidthSpace(cItem.textContent)) {
util.removeItem(cItem);
}
}

if (freeFormat && (util.isFormatElement(oNode) || util.isRangeFormatElement(oNode))) {
oNode = this._setIntoFreeFormat(oNode);
}
Expand Down Expand Up @@ -5049,12 +5068,12 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
if (k === 'all') {
allAttr = _attr[k] + '|';
} else {
tagsAttr[k] = new wRegExp('((?:' + _attr[k] + '|' + defaultAttr + ')\s*=\s*"[^"]*")', 'ig');
tagsAttr[k] = new wRegExp('((?:' + _attr[k] + '|' + defaultAttr + ')\\s*=\\s*[^\\s]*\\S)', 'ig');
}
}
}

this._attributesWhitelistRegExp = new wRegExp('((?:' + allAttr + defaultAttr + ')\s*=\s*"[^"]*")', 'ig');
this._attributesWhitelistRegExp = new wRegExp('((?:' + allAttr + defaultAttr + ')\\s*=\\s*[^\\s]*\\S)', 'ig');
this._attributesTagsWhitelist = tagsAttr;

// set modes
Expand Down Expand Up @@ -6964,8 +6983,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
if (MSData) {
cleanData = cleanData.replace(/\n/g, ' ');
plainText = plainText.replace(/\n/g, ' ');
} else {
plainText = plainText.replace(/\n/g, '');
} else if (plainText === cleanData) {
cleanData = plainText.replace(/\n/g, '<br>');
}

cleanData = core.cleanHTML(cleanData, core.pasteTagsWhitelistRegExp);
Expand Down Expand Up @@ -7709,13 +7728,20 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
if (!core.checkCharCount(checkHTML, null)) return;
}

let c, a, t, firstCon;
let c, a, t, prev, firstCon;
while ((c = domTree[0])) {
if (prev && prev.nodeType === 3 && a && a.nodeType === 1 && util.isBreak(c)) {
prev = c;
util.removeItem(c);
continue;
}
t = core.insertNode(c, a, false);
a = t.container || t;
if (!firstCon) firstCon = t;
prev = c;
}

if (prev.nodeType === 3 && a.nodeType === 1) a = prev;
const offset = a.nodeType === 3 ? (t.endOffset || a.textContent.length): a.childNodes.length;
if (rangeSelection) core.setRange(firstCon.container || firstCon, firstCon.startOffset || 0, a, offset);
else core.setRange(a, offset, a, offset);
Expand Down

0 comments on commit aea3644

Please sign in to comment.