Skip to content

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

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

Vanessa86f326d393d1
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts
index bee224d455..169961d23c 100644
--- a/app/src/protyle/util/editorCommonEvent.ts
+++ b/app/src/protyle/util/editorCommonEvent.ts
@@ -1062,6 +1062,11 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
let dragoverElement: Element;
let disabledPosition: string;
editorElement.addEventListener("dragover", (event: DragEvent & { target: HTMLElement }) => {
+ if (protyle.disabled) {
+ event.preventDefault();
+ event.stopPropagation();
+ return;
+ }
const contentRect = protyle.contentElement.getBoundingClientRect();
if (event.clientY < contentRect.top + Constants.SIZE_SCROLL_TB || event.clientY > contentRect.bottom - Constants.SIZE_SCROLL_TB) {
protyle.contentElement.scroll({
@@ -1263,7 +1268,12 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
dragoverElement = targetElement;
}
});
- editorElement.addEventListener("dragleave", () => {
+ editorElement.addEventListener("dragleave", (event) => {
+ if (protyle.disabled) {
+ event.preventDefault();
+ event.stopPropagation();
+ return;
+ }
editorElement.querySelectorAll(".dragover__left, .dragover__right, .dragover__bottom, .dragover__top").forEach((item: HTMLElement) => {
item.classList.remove("dragover__top", "dragover__bottom", "dragover__left", "dragover__right");
});
diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts
index 42d9e7e74b..6926286780 100644
--- a/app/src/protyle/util/onGet.ts
+++ b/app/src/protyle/util/onGet.ts
@@ -326,6 +326,9 @@ export const disabledProtyle = (protyle: IProtyle) => {
protyle.wysiwyg.element.querySelectorAll('[contenteditable="true"][spellcheck]').forEach(item => {
item.setAttribute("contenteditable", "false");
});
+ protyle.wysiwyg.element.querySelectorAll('.protyle-action[draggable="true"]').forEach(item => {
+ item.setAttribute("draggable", "false");
+ });
if (protyle.breadcrumb) {
protyle.breadcrumb.element.parentElement.querySelector('[data-type="readonly"] use').setAttribute("xlink:href", "#iconLock");
protyle.breadcrumb.element.parentElement.querySelector('[data-type="readonly"]').setAttribute("aria-label", window.siyuan.config.editor.readOnly ? window.siyuan.languages.tempUnlock : window.siyuan.languages.unlockEdit);
@@ -360,6 +363,9 @@ export const enableProtyle = (protyle: IProtyle) => {
item.setAttribute("contenteditable", "true");
}
});
+ protyle.wysiwyg.element.querySelectorAll('.protyle-action[draggable="false"]').forEach(item => {
+ item.setAttribute("draggable", "true");
+ });
if (protyle.breadcrumb) {
protyle.breadcrumb.element.parentElement.querySelector('[data-type="readonly"] use').setAttribute("xlink:href", "#iconUnlock");
protyle.breadcrumb.element.parentElement.querySelector('[data-type="readonly"]').setAttribute("aria-label", window.siyuan.config.editor.readOnly ? window.siyuan.languages.cancelTempUnlock : window.siyuan.languages.lockEdit);