Skip to content

Commit

Permalink
Fix: _setDefaultFormat #1401
Browse files Browse the repository at this point in the history
  • Loading branch information
JiHong88 committed May 28, 2024
1 parent 19d48a5 commit 1893dce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions sample/html/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<article class="markdown-body entry-content">
<div style="background-color: #f3f3f3; padding: 4px 20px 20px 20px;">
<h4 style="color: #b94a48;">--Value</h4>
<label><input type="checkbox" id="strictMode">&nbsp;&nbsp;strictMode&nbsp;&nbsp;&nbsp;</label><br><br>
<label><input type="checkbox" id="strictMode" checked>&nbsp;&nbsp;strictMode=false&nbsp;&nbsp;&nbsp;</label><br><br>
<label><input type="checkbox" id="defaultTag">&nbsp;&nbsp;defaultTag&nbsp;&nbsp;&nbsp;</label>
<input type="text" id="defaultTag_value" placeholder="String ('p', 'div'..)"></input>
<br><br>
Expand Down Expand Up @@ -609,7 +609,7 @@ <h2 class="sub-title">Applied options</h2>
imageTable.innerHTML = '';

var options = {
strictMode: document.getElementById('strictMode').checked ? true : undefined,
strictMode: document.getElementById('strictMode').checked ? undefined : false,
defaultTag: document.getElementById('defaultTag').checked ? document.getElementById('defaultTag_value').value : undefined,
textTags: document.getElementById('textTags').checked ? {
bold: 'b',
Expand Down
14 changes: 8 additions & 6 deletions src/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -6256,12 +6256,14 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
this._editorRange();
}

if (util.isBreak(format.nextSibling)) util.removeItem(format.nextSibling);
if (util.isBreak(format.previousSibling)) util.removeItem(format.previousSibling);
if (util.isBreak(focusNode)) {
const zeroWidth = util.createTextNode(util.zeroWidthSpace);
focusNode.parentNode.insertBefore(zeroWidth, focusNode);
focusNode = zeroWidth;
if (format) {
if (util.isBreak(format.nextSibling)) util.removeItem(format.nextSibling);
if (util.isBreak(format.previousSibling)) util.removeItem(format.previousSibling);
if (util.isBreak(focusNode)) {
const zeroWidth = util.createTextNode(util.zeroWidthSpace);
focusNode.parentNode.insertBefore(zeroWidth, focusNode);
focusNode = zeroWidth;
}
}

this.effectNode = null;
Expand Down

0 comments on commit 1893dce

Please sign in to comment.