Skip to content

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

:bug: Cancel stale focus exit after undo https://github.com/siyuan-note/siyuan/issues/19137

Daniela37861e5f114
diff --git a/app/src/boot/globalEvent/click.ts b/app/src/boot/globalEvent/click.ts
index 88776741d0..8122c8d865 100644
--- a/app/src/boot/globalEvent/click.ts
+++ b/app/src/boot/globalEvent/click.ts
@@ -30,7 +30,8 @@ export const globalClick = (event: MouseEvent & { target: HTMLElement }) => {
const protyleElement = hasClosestByClassName(event.target, "protyle", true);
if (protyleElement) {
const wysiwygElement = protyleElement.querySelector(".protyle-wysiwyg");
- if (wysiwygElement.getAttribute("data-readonly") === "true" || !wysiwygElement.contains(event.target)) {
+ if (wysiwygElement &&
+ (wysiwygElement.getAttribute("data-readonly") === "true" || !wysiwygElement.contains(event.target))) {
wysiwygElement.dispatchEvent(new Event("focusin"));
}
}
diff --git a/app/src/protyle/hint/extend.ts b/app/src/protyle/hint/extend.ts
index 5193b71446..1caca17d78 100644
--- a/app/src/protyle/hint/extend.ts
+++ b/app/src/protyle/hint/extend.ts
@@ -854,6 +854,9 @@ export const hintMoveBlock = async (pathString: string, sourceElements: Element[
if (protyle.block.showAll && editorElement.childElementCount === 0) {
const focusID = protyle.block.parent2ID;
setTimeout(() => {
+ if (!document.contains(protyle.element) || editorElement.childElementCount > 0) {
+ return;
+ }
zoomOut({
protyle,
id: focusID,
diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.ts
index a422308b81..7d2cbd5040 100644
--- a/app/src/protyle/wysiwyg/remove.ts
+++ b/app/src/protyle/wysiwyg/remove.ts
@@ -1215,7 +1215,7 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
if (protyle.block.showAll && sideElement.classList.contains("protyle-wysiwyg") && protyle.wysiwyg.element.childElementCount === 0) {
const focusID = protyle.block.parent2ID;
setTimeout(() => {
- if (document.contains(protyle.element)) {
+ if (document.contains(protyle.element) && protyle.wysiwyg.element.childElementCount === 0) {
zoomOut({
protyle,
id: focusID,