Skip to content

Commit

Permalink
2.44.11
Browse files Browse the repository at this point in the history
  • Loading branch information
JiHong88 committed Apr 20, 2023
2 parents 90fe1ed + 2849aed commit e789cee
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 75 deletions.
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
@@ -1,6 +1,6 @@
{
"name": "suneditor",
"version": "2.44.10",
"version": "2.44.11",
"description": "Pure JavaScript based WYSIWYG web editor",
"author": "JiHong.Lee",
"license": "MIT",
Expand Down
8 changes: 4 additions & 4 deletions sample/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@
<div class="inline-margin"></div>
<textarea id="editor_classic" style="display:none;">
<p>SunEditor</p>
<div class="se-component se-image-container __se__float-right" contenteditable="false"><figure style="margin: auto;"><img src="http://suneditor.com/docs/cat.jpg" data-align="right" alt="Tabby" data-rotate="" data-proportion="false" data-rotatex="" data-rotatey="" origin-size="640,426" data-origin="640,426" style="transform: rotate(0deg);" data-index="0" data-file-name="cat.jpg" data-file-size="0" data-size="," data-percentage="auto,auto"><figcaption contenteditable="true" style="margin-top: 0px;"><p>Insert description</p></figcaption></figure></div>
<p>Here is an example of math -&gt; <span class="katex" contenteditable="false" data-exp="\displaystyle\sum_{i=1}^{k+1}i" data-font-size="1.5em" style="font-size: 1.5em;"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="0" displaystyle="true"><munderover><mo></mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mrow><mi>k</mi><mo>+</mo><mn>1</mn></mrow></munderover><mi>i</mi></mstyle></mrow><annotation encoding="application/x-tex">\displaystyle\sum_{i=1}^{k+1}i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3.1137820000000005em;vertical-align:-1.277669em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.8361130000000003em;"><span style="top:-1.872331em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathdefault mtight">i</span><span class="mrel mtight">=</span><span class="mord mtight">1</span></span></span></span><span style="top:-3.050005em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op"></span></span></span><span style="top:-4.300005em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathdefault mtight" style="margin-right:0.03148em;">k</span><span class="mbin mtight">+</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:1.277669em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.16666666666666666em;"></span><span class="mord mathdefault">i</span></span></span></span> 123</p>
<div class="se-component se-image-container __se__float-center"><figure style="margin: auto;"><img src="http://suneditor.com/docs/cat.jpg" data-align="right" alt="Tabby" data-rotate="" data-proportion="false" data-rotatex="" data-rotatey="" origin-size="640,426" data-origin="640,426" style="transform: rotate(0deg);" data-index="0" data-file-name="cat.jpg" data-file-size="0" data-size="," data-percentage="auto,auto"><figcaption style="margin-top: 0px;"><p>Insert description</p></figcaption></figure></div>
<p>Here is an example of math -&gt; <span class="katex" data-exp="\displaystyle\sum_{i=1}^{k+1}i" data-font-size="1.5em" style="font-size: 1.5em;"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="0" displaystyle="true"><munderover><mo></mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mrow><mi>k</mi><mo>+</mo><mn>1</mn></mrow></munderover><mi>i</mi></mstyle></mrow><annotation encoding="application/x-tex">\displaystyle\sum_{i=1}^{k+1}i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3.1137820000000005em;vertical-align:-1.277669em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.8361130000000003em;"><span style="top:-1.872331em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathdefault mtight">i</span><span class="mrel mtight">=</span><span class="mord mtight">1</span></span></span></span><span style="top:-3.050005em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op"></span></span></span><span style="top:-4.300005em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathdefault mtight" style="margin-right:0.03148em;">k</span><span class="mbin mtight">+</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:1.277669em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.16666666666666666em;"></span><span class="mord mathdefault">i</span></span></span></span> 123</p>
<h3>The Suneditor is based on pure JavaScript, with no dependencies.</h3>
<pre>Suneditor is a lightweight, flexible, customizable WYSIWYG text editor for your web applications.</pre>
<blockquote><p>Supports Chrome, Safari, Opera, Firefox, Edge, IE11, Mobile web browser.</p></blockquote>
Expand Down Expand Up @@ -168,7 +168,7 @@ <h3>The Suneditor is based on pure JavaScript, with no dependencies.</h3>
<div class="inline-margin"></div>
<textarea id="editor_inline3" style="display:none;">
<p><br></p>
<div class="se-component se-image-container __se__float-right" contenteditable="false"><figure style="margin: auto;"><img src="http://suneditor.com/docs/cat2.jpg" data-align="right" alt="Cat" data-rotate="" data-proportion="false" data-rotatex="" data-rotatey="" origin-size="640,959" data-origin="640,959" style="width: 640px; max-width: 100%;"><figcaption contenteditable="true" style="margin-top: 0px;"><p>Insert description</p></figcaption></figure></div>
<div class="se-component se-image-container __se__float-right"><figure style="margin: auto;"><img src="http://suneditor.com/docs/cat2.jpg" data-align="right" alt="Cat" data-rotate="" data-proportion="false" data-rotatex="" data-rotatey="" origin-size="640,959" data-origin="640,959" style="width: 640px; max-width: 100%;"><figcaption style="margin-top: 0px;"><p>Insert description</p></figcaption></figure></div>
<p><br></p>
</textarea>
</div>
Expand All @@ -177,7 +177,7 @@ <h3>The Suneditor is based on pure JavaScript, with no dependencies.</h3>
<div class="inline-margin"></div>
<textarea id="editor_balloon" style="display:none;">
<p><br></p>
<div class="se-component se-image-container __se__float-right" contenteditable="false"><figure style="margin: auto;"><img src="http://suneditor.com/docs/cat1.jpg" data-align="right" alt="Cat paw" data-rotate="" data-proportion="false" data-rotatex="" data-rotatey="" origin-size="640,426" data-origin="640,426" style="width: 640px; max-width: 100%;"><figcaption contenteditable="true" style="margin-top: 0px;"><p>Insert description</p></figcaption></figure></div>
<div class="se-component se-image-container __se__float-right"><figure style="margin: auto;"><img src="http://suneditor.com/docs/cat1.jpg" data-align="right" alt="Cat paw" data-rotate="" data-proportion="false" data-rotatex="" data-rotatey="" origin-size="640,426" data-origin="640,426" style="width: 640px; max-width: 100%;"><figcaption style="margin-top: 0px;"><p>Insert description</p></figcaption></figure></div>
<h3>The Suneditor is based on pure JavaScript, with no dependencies.</h3>
<p>Suneditor is a lightweight, flexible, customizable WYSIWYG text editor for your web applications.</p>
<pre>Supports Chrome, Safari, Opera, Firefox, Edge, IE11, Mobile web browser.</pre>
Expand Down
7 changes: 6 additions & 1 deletion src/assets/css/suneditor-contents.css
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,13 @@
.sun-editor-editable figure {
display: block;
outline: none;
margin: 0;
padding: 0;
margin: 0;
}
.sun-editor-editable .__se__float-left figure,
.sun-editor-editable .__se__float-right figure,
.sun-editor-editable .__se__float-center figure {
margin: auto !important;
}
.sun-editor-editable figure figcaption {
padding: 1em .5em;
Expand Down
2 changes: 1 addition & 1 deletion src/assets/css/suneditor.css
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
.sun-editor .se-list-layer.se-list-line {width:125px;}
.sun-editor .se-list-layer.se-list-line hr {border-width: 1px 0 0; height: 1px;}
/* submenu layer - align */
.sun-editor .se-list-layer.se-list-align .se-list-inner {left:9px; width:125px;}
.sun-editor .se-list-layer.se-list-align .se-list-inner {left:9px;}
/** submenu layer - format block, paragraph style, text style */
.sun-editor .se-list-layer.se-list-format {min-width:156px;}
.sun-editor .se-list-layer.se-list-format li {padding:0; width:100%;}
Expand Down
6 changes: 3 additions & 3 deletions src/lang/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@
altText: 'Alternativer Text'
},
videoBox: {
title: 'Video enfügen',
title: 'Video einfügen',
file: 'Datei auswählen',
url: 'Video-URL, YouTube/Vimeo'
},
audioBox: {
title: 'Audio enfügen',
title: 'Audio einfügen',
file: 'Datei auswählen',
url: 'Audio-URL'
},
Expand Down Expand Up @@ -185,4 +185,4 @@
}

return lang;
}));
}));
75 changes: 33 additions & 42 deletions src/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1792,30 +1792,30 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
} else if (container.nodeType === 3 || util.isBreak(container) || insertListCell) {
const depthFormat = util.getParentElement(container, function (current) { return this.isRangeFormatElement(current) || this.isListCell(current); }.bind(util));
afterNode = util.splitElement(container, r.offset, !depthFormat ? 0 : util.getElementDepth(depthFormat) + 1);
if (afterNode) {
if (insertListCell) {
if (line.contains(container)) {
const subList = util.isList(line.lastElementChild);
let newCell = null;
if (!isEdge) {
if (!afterNode) {
tempAfterNode = afterNode = line;
} else if (insertListCell) {
if (line.contains(container)) {
const subList = util.isList(line.lastElementChild);
let newCell = null;
if (!isEdge) {
newCell = line.cloneNode(false);
newCell.appendChild(afterNode.textContent.trim() ? afterNode : util.createTextNode(util.zeroWidthSpace));
}
if (subList) {
if (!newCell) {
newCell = line.cloneNode(false);
newCell.appendChild(afterNode.textContent.trim() ? afterNode : util.createTextNode(util.zeroWidthSpace));
}
if (subList) {
if (!newCell) {
newCell = line.cloneNode(false);
newCell.appendChild(util.createTextNode(util.zeroWidthSpace));
}
newCell.appendChild(line.lastElementChild);
}
if (newCell) {
line.parentNode.insertBefore(newCell, line.nextElementSibling);
tempAfterNode = afterNode = newCell;
newCell.appendChild(util.createTextNode(util.zeroWidthSpace));
}
newCell.appendChild(line.lastElementChild);
}
if (newCell) {
line.parentNode.insertBefore(newCell, line.nextElementSibling);
tempAfterNode = afterNode = newCell;
}
} else {
afterNode = afterNode.previousSibling;
}
} else {
afterNode = afterNode.previousSibling;
}
}
}
Expand Down Expand Up @@ -2135,7 +2135,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re

const range = this.getRange();
const isStartEdge = range.startOffset === 0;
const isEndEdge = core.isEdgePoint(range.endContainer, range.endOffset);
const isEndEdge = core.isEdgePoint(range.endContainer, range.endOffset, 'end');
let prevContainer = null;
let startPrevEl = null;
let endNextEl = null;
Expand Down Expand Up @@ -3288,7 +3288,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
if (!isRemoveNode && parentCon === endCon.parentNode && parentCon.nodeName === newInnerNode.nodeName) {
if (util.onlyZeroWidthSpace(startCon.textContent.slice(0, startOff)) && util.onlyZeroWidthSpace(endCon.textContent.slice(endOff))) {
const children = parentCon.childNodes;
let sameTag = true;
let sameTag = false;

for (let i = 0, len = children.length, c, s, e, z; i < len; i++) {
c = children[i];
Expand Down Expand Up @@ -5141,12 +5141,12 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
const renderHTML = util.createElement('DIV');
renderHTML.innerHTML = contents;

const figcaptions = util.getListChildren(renderHTML, function (current) {
return /FIGCAPTION/i.test(current.nodeName);
const editableEls = util.getListChildren(renderHTML, function (current) {
return current.hasAttribute('contenteditable');
});

for (let i = 0, len = figcaptions.length; i < len; i++) {
figcaptions[i].removeAttribute('contenteditable');
for (let i = 0, len = editableEls.length; i < len; i++) {
editableEls[i].removeAttribute('contenteditable');
}

if (options.fullPage && !onlyContents) {
Expand Down Expand Up @@ -5373,13 +5373,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
if (util.isFigures(tagName)) {
const sv = m.match(/style\s*=\s*(?:"|')[^"']*(?:"|')/);
if (!v) v = [];
if (sv) {
const wsize = sv[0].match(/width\s?:\s?(\d+)(px|%)/);
const hsize = sv[0].match(/height\s?:\s?(\d+)(px|%)/);
const w_ = wsize && wsize[1] && wsize[2] ? wsize[1] + wsize[2] : 'auto';
const h_ = hsize && hsize[1] && hsize[2] ? hsize[1] + hsize[2] : 'auto';
v.push('style="width:'+ w_ + '; height:'+ h_ + ';"');
}
if (sv) v.push(sv[0]);
}

if (v) {
Expand Down Expand Up @@ -6454,11 +6448,6 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
if (options.showPathLabel) context.element.navigation.textContent = core._variable.currentNodes.join(' > ');
},

_cancelCaptionEdit: function () {
this.setAttribute('contenteditable', false);
this.removeEventListener('blur', event._cancelCaptionEdit);
},

_buttonsEventHandler: function (e) {
let target = e.target;
if (core._bindControllersOff) e.stopPropagation();
Expand Down Expand Up @@ -6510,6 +6499,11 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re

onMouseDown_wysiwyg: function (e) {
if (core.isReadOnly || util.isNonEditable(context.element.wysiwyg)) return;
if (util._isExcludeSelectionElement(e.target)) {
e.preventDefault();
return;
}

_w.setTimeout(core._editorRange.bind(core));

// user event
Expand All @@ -6528,8 +6522,6 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
if (core._isBalloon) {
event._hideToolbar();
}

if (/FIGURE/i.test(e.target.nodeName)) e.preventDefault();
},

onClick_wysiwyg: function (e) {
Expand All @@ -6556,9 +6548,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
}

const figcaption = util.getParentElement(targetElement, 'FIGCAPTION');
if (figcaption && (util.isNonEditable(figcaption) || !figcaption.getAttribute("contenteditable"))) {
if (figcaption && util.isNonEditable(figcaption)) {
e.preventDefault();
figcaption.setAttribute('contenteditable', true);
figcaption.focus();

if (core._isInline && !core._inlineToolbarAttr.isShow) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function (core, change) {

function pushStack () {
core._checkComponents();
const current = core.getContents(true);
const current = editor.wysiwyg.innerHTML;
if (!current || (!!stack[stackIndex] && current === stack[stackIndex].contents)) return;

stackIndex++;
Expand Down
4 changes: 4 additions & 0 deletions src/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,10 @@ const util = {
}.bind(this));
},

_isExcludeSelectionElement: function (element) {
return !/FIGCAPTION/i.test(element.nodeName) && (this.isComponent(element) || /FIGURE/i.test(element.nodeName));
},

/**
* @description Nodes that need to be added without modification when changing text nodes
* @param {Node} element Element to check
Expand Down
9 changes: 1 addition & 8 deletions src/plugins/dialog/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,6 @@ export default {
// caption
if (contextImage._captionChecked) {
contextImage._caption = this.plugins.component.create_caption.call(this);
contextImage._caption.setAttribute('contenteditable', false);
cover.appendChild(contextImage._caption);
}

Expand Down Expand Up @@ -869,7 +868,7 @@ export default {
contextImage._cover = this.util.getParentElement(element, 'FIGURE');
contextImage._container = this.util.getParentElement(element, this.util.isMediaComponent);
contextImage._caption = this.util.getChildElement(contextImage._cover, 'FIGCAPTION');
contextImage._align = element.style.float || element.getAttribute('data-align') || 'none';
contextImage._align = element.getAttribute('data-align') || element.style.float || 'none';
element.style.float = '';
this.plugins.anchor.setCtx(contextImage._linkElement, contextImage.anchorCtx);

Expand Down Expand Up @@ -1068,12 +1067,6 @@ export default {
if (!cover) cover = contextImage._cover;
if (!container) container = contextImage._container;

if (align && align !== 'none') {
cover.style.margin = 'auto';
} else {
cover.style.margin = '0';
}

if (/%$/.test(element.style.width) && align === 'center') {
container.style.minWidth = '100%';
cover.style.width = container.style.width;
Expand Down
Loading

0 comments on commit e789cee

Please sign in to comment.