This commit is contained in:
Vanessa 2022-12-06 22:46:08 +08:00
parent 7828afcd64
commit b803b356ce
2 changed files with 13 additions and 2 deletions

View file

@ -563,7 +563,8 @@ export class Toolbar {
this.range.insertNode(currentNewNode);
// https://github.com/siyuan-note/siyuan/issues/6155
if (currentNewNode.nodeType !== 3 && ["code", "tag", "kbd"].includes(type)) {
if (!hasPreviousSibling(currentNewNode)) {
const previousSibling = hasPreviousSibling(currentNewNode)
if (!previousSibling || previousSibling.textContent.endsWith("\n")) {
currentNewNode.before(document.createTextNode(Constants.ZWSP));
}
if (!currentNewNode.textContent.startsWith(Constants.ZWSP)) {