Skip to content

Commit

Permalink
🐛 fix #115
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Feb 8, 2020
1 parent ec0a3cb commit e82f648
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
### v2.1.11 / 2020-02-07

* [117](https://github.com/Vanessa219/vditor/issues/117) cursor moving problem near inline code `修复缺陷`
* [115](https://github.com/Vanessa219/vditor/issues/115) codeblock difference between ``` and ctrl+u `修复缺陷`
* [112](https://github.com/Vanessa219/vditor/issues/112) 列表项加代码块问题 `修复缺陷`
* [111](https://github.com/Vanessa219/vditor/issues/111) ctrl+b, ctrl+i, ctrl+s not working at starting and combining `修复缺陷`
* [109](https://github.com/Vanessa219/vditor/issues/109) tab key at list `改进功能`
Expand Down
4 changes: 4 additions & 0 deletions src/assets/scss/_wysiwyg.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
margin-bottom: 0;
}

code {
padding: 0.2em 0.4em !important;
}

& > code {
display: none;
}
Expand Down
14 changes: 7 additions & 7 deletions src/ts/wysiwyg/toolbarEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,17 @@ export const toolbarEvent = (vditor: IVditor, actionBtn: Element) => {
setCurrentToolbar(vditor.toolbar.elements, ["inline-code"]);
} else if (commandName === "code") {
const node = document.createElement("div");
if (range.collapsed) {
node.className = "vditor-wysiwyg__block";
node.setAttribute("data-type", "code-block");
node.innerHTML = `<pre data-block="0"><code></code></pre>`;
node.className = "vditor-wysiwyg__block";
node.setAttribute("data-type", "code-block");
node.setAttribute("data-block", "0");
node.setAttribute("data-marker", "```");
if (range.toString() === "") {
node.innerHTML = `<pre><code></code></pre>`;
range.insertNode(node);
range.selectNodeContents(node.firstChild.firstChild);
setSelectionFocus(range);
} else {
node.className = "vditor-wysiwyg__block";
node.setAttribute("data-type", "code-block");
node.innerHTML = `<pre data-block="0"><code>${range.toString()}</code></pre>`;
node.innerHTML = `<pre><code>${range.toString()}</code></pre>`;
range.deleteContents();
range.insertNode(node);
range.selectNodeContents(node.firstChild.firstChild);
Expand Down

0 comments on commit e82f648

Please sign in to comment.