mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-29 04:48:48 +01:00
This commit is contained in:
parent
7828afcd64
commit
b803b356ce
2 changed files with 13 additions and 2 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -686,8 +686,18 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
// https://github.com/siyuan-note/siyuan/issues/5547
|
||||
// https://github.com/siyuan-note/siyuan/issues/6796
|
||||
const previousSibling = hasPreviousSibling(range.startContainer) as HTMLElement;
|
||||
if (range.toString() === "" && event.key === "Backspace" &&
|
||||
range.startOffset === range.startContainer.textContent.length &&
|
||||
range.startContainer.textContent.endsWith("\n"+Constants.ZWSP)) {
|
||||
range.setStart(range.startContainer, range.startOffset - 1);
|
||||
range.collapse(true);
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
// https://github.com/siyuan-note/siyuan/issues/5547
|
||||
if (range.startOffset === 1 && range.startContainer.textContent === Constants.ZWSP &&
|
||||
previousSibling && previousSibling.nodeType !== 3 &&
|
||||
event.key === "Backspace" // https://github.com/siyuan-note/siyuan/issues/6786
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue