An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Respect non-editable boundaries when detecting mobile input https://github.com/siyuan-note/siyuan/issues/18845
Daniel03b3ace1b1cf
diff --git a/app/src/mobile/util/mobileAppUtil.test.ts b/app/src/mobile/util/mobileAppUtil.test.tsindex a06fae5791..55eb36f104 100644--- a/app/src/mobile/util/mobileAppUtil.test.ts+++ b/app/src/mobile/util/mobileAppUtil.test.ts@@ -22,6 +22,49 @@ const createElement = (options: {};describe("mobile input detection", () => {+ const createEditableRoot = () => createElement({+ classNames: ["protyle-wysiwyg"],+ attributes: {contenteditable: "true", "data-readonly": "false"},+ parentElement: createElement({tagName: "BODY"}),+ });++ it("rejects non-editable render areas and their descendants", () => {+ const renderElement = createElement({+ attributes: {contenteditable: "false"},+ parentElement: createEditableRoot(),+ });+ const canvasElement = createElement({tagName: "CANVAS", parentElement: renderElement});++ assert.equal(canInput(renderElement), false);+ assert.equal(canInput(canvasElement), false);+ });++ it("accepts ordinary text inside the editable root", () => {+ const wysiwygElement = createEditableRoot();+ const textElement = createElement({tagName: "SPAN", parentElement: wysiwygElement});++ assert.equal(canInput(textElement), wysiwygElement);+ });++ it("accepts explicitly editable content inside a non-editable database", () => {+ const databaseElement = createElement({+ attributes: {contenteditable: "false"},+ parentElement: createEditableRoot(),+ });+ const editableElement = createElement({+ attributes: {contenteditable: "true"},+ parentElement: databaseElement,+ });+ const textElement = createElement({tagName: "SPAN", parentElement: editableElement});++ assert.equal(canInput(editableElement), editableElement);+ assert.equal(canInput(textElement), editableElement);+ for (const tagName of ["INPUT", "TEXTAREA"]) {+ const inputElement = createElement({tagName, parentElement: databaseElement});+ assert.equal(canInput(inputElement), inputElement);+ }+ });+it("accepts the editable Protyle root as the active element", () => {const bodyElement = createElement({tagName: "BODY"});const wysiwygElement = createElement({diff --git a/app/src/mobile/util/mobileAppUtil.ts b/app/src/mobile/util/mobileAppUtil.tsindex 5027bf6b81..9873b7a760 100644--- a/app/src/mobile/util/mobileAppUtil.ts+++ b/app/src/mobile/util/mobileAppUtil.ts@@ -32,7 +32,9 @@ export const canInput = (element: Element) => {}const wysiwygElement = hasClosestByClassName(element, "protyle-wysiwyg", true);if (wysiwygElement && wysiwygElement.getAttribute("data-readonly") === "false") {- return hasClosestByAttribute(element, "contenteditable", "true", true);+ // 按最近的编辑边界判断,避免点击不可编辑的渲染区域时唤起键盘并恢复旧光标位置。+ const editableElement = hasClosestByAttribute(element, "contenteditable", null, true);+ return editableElement && editableElement.getAttribute("contenteditable") === "true" && editableElement;}return false;};