Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues

Vanessa215f9de4cab2
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index d7bf22a9a4..c0ea8a8aea 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -28,7 +28,7 @@ import {
getLastBlock, getNextBlock,
getPreviousHeading,
getTopAloneElement,
- hasNextSibling,
+ hasNextSibling, hasPreviousSibling,
isNotEditBlock
} from "./getBlock";
import {transaction, updateTransaction} from "./transaction";
@@ -1183,11 +1183,16 @@ export class WYSIWYG {
// https://github.com/siyuan-note/siyuan/issues/3257
if (range.toString() === "" && range.startContainer.nodeType === 3 && !protyle.toolbar.isNewEmptyInline &&
// https://github.com/siyuan-note/siyuan/issues/4118
- range.startOffset >= range.startContainer.textContent.length && !hasNextSibling(range.startContainer) &&
+ range.startOffset >= range.startContainer.textContent.length &&
protyle.toolbar.getCurrentType(range).length > 0) {
// 粗体等行内元素粘贴
- range.setEndAfter(range.startContainer.parentElement);
- range.collapse(false);
+ if (!hasNextSibling(range.startContainer)) {
+ range.setEndAfter(range.startContainer.parentElement);
+ range.collapse(false);
+ } else if (!hasPreviousSibling(range.startContainer)) {
+ range.setStartBefore(range.startContainer.parentElement);
+ range.collapse(true);
+ }
}
paste(protyle, event);
});