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

Vanessad697f2799f38
diff --git a/app/src/boot/globalEvent/click.ts b/app/src/boot/globalEvent/click.ts
index 7e0a51bb42..4c68a9c270 100644
--- a/app/src/boot/globalEvent/click.ts
+++ b/app/src/boot/globalEvent/click.ts
@@ -1,5 +1,9 @@
import {getAllModels} from "../../layout/getAll";
-import {hasClosestByAttribute, hasClosestByClassName, hasTopClosestByClassName} from "../../protyle/util/hasClosest";
+import {
+ hasClosestByAttribute,
+ hasClosestByClassName,
+ hasTopClosestByClassName
+} from "../../protyle/util/hasClosest";
import {hideAllElements} from "../../protyle/ui/hideElements";
import {isWindow} from "../../util/functions";
import {writeText} from "../../protyle/util/compatibility";
@@ -44,6 +48,13 @@ export const globalClick = (event: MouseEvent & { target: HTMLElement }) => {
window.siyuan.layout.rightDock.hideDock();
}
+ 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)) {
+ wysiwygElement.dispatchEvent(new Event("focusin"));
+ }
+ }
const copyElement = hasTopClosestByClassName(event.target, "protyle-action__copy");
if (copyElement) {
let text = copyElement.parentElement.nextElementSibling.textContent.trimEnd();
diff --git a/app/src/protyle/breadcrumb/index.ts b/app/src/protyle/breadcrumb/index.ts
index 67df9efd83..5455696546 100644
--- a/app/src/protyle/breadcrumb/index.ts
+++ b/app/src/protyle/breadcrumb/index.ts
@@ -62,11 +62,6 @@ ${padHTML}
<button class="block__icon fn__flex-center fn__none ariaLabel" data-type="context" aria-label="${window.siyuan.languages.context}"><svg><use xlink:href="#iconAlignCenter"></use></svg></button>`;
this.element = element.firstElementChild as HTMLElement;
element.addEventListener("click", (event) => {
- /// #if !MOBILE
- if (protyle.model) {
- setPanelFocus(protyle.model.element.parentElement.parentElement);
- }
- /// #endif
let target = event.target as HTMLElement;
while (target && !target.isEqualNode(element)) {
const id = target.getAttribute("data-node-id");
diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.ts
index 1473b6f30f..d091f9e56a 100644
--- a/app/src/protyle/header/Title.ts
+++ b/app/src/protyle/header/Title.ts
@@ -49,16 +49,6 @@ export class Title {
this.rename(protyle);
});
this.editElement.addEventListener("click", () => {
- if (protyle.model) {
- setPanelFocus(protyle.model.element.parentElement.parentElement);
- updatePanelByEditor({
- protyle: protyle,
- focus: false,
- pushBackStack: false,
- reload: false,
- resize: false,
- });
- }
protyle.toolbar?.element.classList.add("fn__none");
});
this.editElement.addEventListener("input", (event: InputEvent) => {
diff --git a/app/src/protyle/preview/index.ts b/app/src/protyle/preview/index.ts
index cc219db330..ea34388d2f 100644
--- a/app/src/protyle/preview/index.ts
+++ b/app/src/protyle/preview/index.ts
@@ -74,10 +74,6 @@ export class Preview {
this.element.appendChild(previewElement);
this.element.addEventListener("click", (event) => {
- if (protyle.model) {
- setPanelFocus(protyle.model.element.parentElement.parentElement);
- updateOutline(getAllModels(), protyle.model.editor.protyle);
- }
let target = event.target as HTMLElement;
while (target && !target.isEqualNode(this.element)) {
if (target.tagName === "A") {