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/12139

Vanessad9535ea5410f
diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts
index 40e505de04..ae65e25231 100644
--- a/app/src/protyle/util/selection.ts
+++ b/app/src/protyle/util/selection.ts
@@ -582,6 +582,7 @@ export const focusByWbr = (element: Element, range: Range) => {
range.collapse(true);
wbrElement.remove();
focusByRange(range);
+ return range;
};
export const focusByRange = (range: Range) => {
diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.ts
index a7018094b2..a3de32fcff 100644
--- a/app/src/protyle/wysiwyg/remove.ts
+++ b/app/src/protyle/wysiwyg/remove.ts
@@ -271,14 +271,22 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
return;
}
- const isCallout = blockElement.parentElement.classList.contains("callout-content");
- if (!blockElement.previousElementSibling &&
- (blockType !== "NodeHeading" || (blockType === "NodeHeading" && type === "Delete")) &&
- (blockElement.parentElement.getAttribute("data-type") === "NodeBlockquote" || isCallout)) {
+ let isCallout = blockElement.parentElement.classList.contains("callout-content");
+ if (type === "Delete") {
+ const bqCaElement = hasClosestByClassName(blockElement, "bq") || hasClosestByClassName(blockElement, "callout");
+ if (bqCaElement) {
+ isCallout = bqCaElement.classList.contains("callout");
+ blockElement = isCallout ? bqCaElement.querySelector(".callout-content").firstElementChild : bqCaElement.firstElementChild;
+ }
+ }
+ const blockParentElement = isCallout ? blockElement.parentElement.parentElement : blockElement.parentElement;
+ if (!blockElement.previousElementSibling && (blockElement.parentElement.getAttribute("data-type") === "NodeBlockquote" || isCallout) && (
+ (type !== "Delete" && blockType !== "NodeHeading") ||
+ (type === "Delete" && blockParentElement.parentElement.classList.contains("protyle-wysiwyg"))
+ )) {
if (type !== "Delete") {
range.insertNode(document.createElement("wbr"));
}
- const blockParentElement = isCallout ? blockElement.parentElement.parentElement : blockElement.parentElement;
blockParentElement.insertAdjacentElement("beforebegin", blockElement);
if (isCallout ? blockParentElement.querySelector(".callout-content").childElementCount === 0 :
blockParentElement.childElementCount === 1) {
@@ -327,6 +335,13 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
removeLi(protyle, blockElement, range, type === "Delete");
return;
}
+ if (type === "Delete") {
+ const liElement = hasClosestByClassName(blockElement, "li");
+ if (liElement) {
+ removeLi(protyle, liElement.firstElementChild.nextElementSibling, range, true);
+ return;
+ }
+ }
const previousElement = getPreviousBlock(blockElement) as HTMLElement;
// 设置 bq 和代码块光标
// 需放在列表处理后 https://github.com/siyuan-note/siyuan/issues/11606