From 237f2ddcf565d8de8b3ed1df95a6cd47a1dbff24 Mon Sep 17 00:00:00 2001 From: Soltus Date: Tue, 9 Apr 2024 20:07:39 +0800 Subject: [PATCH 1/2] https://github.com/Hi-Windom/Sillot/issues/621 --- app/src/protyle/util/compatibility.ts | 2 +- app/src/protyle/wysiwyg/index.ts | 62 +++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts index 85df9b9ab0..21ab805a4a 100644 --- a/app/src/protyle/util/compatibility.ts +++ b/app/src/protyle/util/compatibility.ts @@ -25,7 +25,7 @@ export const openByMobile = (uri: string, from?: string) => { if (!existingUri) { toolbarConsole.classList.add("fn__none"); toolbarOpenBy.classList.remove("fn__none"); - + toolbarOpenBy.removeAttribute("data-refBlockId"); // 避免冲突 toolbarOpenBy.addEventListener("click", () => { toolbarOpenBy.classList.add("fn__none"); toolbarConsole.classList.remove("fn__none"); diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index b87b179771..6b755a85e2 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -2005,9 +2005,63 @@ if (tableElement && tableElement.isSameNode(item) && item.querySelector(".table } checkFold(refBlockId, (zoomIn, action) => { /// #if MOBILE - openMobileFileById(protyle.app, refBlockId, zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]); - activeBlur(); - hideKeyboardToolbar(); + console.warn(`refBlockId : ${refBlockId}`); // 文档中直接点击双链 + const toolbarOpenBy = document.querySelector("#toolbarOpenBy"); + const toolbarConsole = document.querySelector("#toolbarConsole"); + if (toolbarOpenBy && toolbarConsole) { + const existingUri = toolbarOpenBy.getAttribute("data-refBlockId"); + + // 只有在首次调用时才更新uri和绑定事件 + if (!existingUri) { + toolbarConsole.classList.add("fn__none"); + toolbarOpenBy.classList.remove("fn__none"); + toolbarOpenBy.removeAttribute("data-uri"); // 避免冲突 + toolbarOpenBy.addEventListener("click", () => { + toolbarOpenBy.classList.add("fn__none"); + toolbarConsole.classList.remove("fn__none"); + const updatedUri = toolbarOpenBy.getAttribute("data-refBlockId"); + if (updatedUri) { + console.warn(`refBlockId : ${updatedUri} -> openMobileFileById() ? (toolbarOpenBy && toolbarConsole)`); + toolbarOpenBy.removeAttribute("data-refBlockId"); + openMobileFileById(protyle.app, updatedUri, zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]); + activeBlur(); + hideKeyboardToolbar(); + } + }); + + // 更新"data-refBlockId"值 + toolbarOpenBy.setAttribute("data-refBlockId", refBlockId); + if ( + !toolbarOpenBy.classList.contains("flash-blue") + ) { + toolbarOpenBy.classList.add("flash-blue"); + setTimeout(() => { + toolbarOpenBy.classList.remove("flash-blue"); + }, 200); + } + } else { + // 更新"data-refBlockId"值 + toolbarOpenBy.setAttribute("data-refBlockId", refBlockId); + if ( + !toolbarOpenBy.classList.contains("flash-blue") + ) { + toolbarOpenBy.classList.add("flash-blue"); + setTimeout(() => { + toolbarOpenBy.classList.remove("flash-blue"); + }, 200); + } + } + } else { + // 如果找不到元素,则直接调用 + toolbarOpenBy.removeAttribute("data-refBlockId"); + console.warn(`refBlockId : ${refBlockId} -> openMobileFileById() ? not(toolbarOpenBy && toolbarConsole)`); + openMobileFileById(protyle.app, refBlockId, zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]); + activeBlur(); + hideKeyboardToolbar(); + } + // openMobileFileById(protyle.app, refBlockId, zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]); + // activeBlur(); + // hideKeyboardToolbar(); /// #else if (event.shiftKey) { openFileById({ @@ -2070,6 +2124,7 @@ if (tableElement && tableElement.isSameNode(item) && item.querySelector(".table excludeIDs: [blockElement.getAttribute("data-node-id")] }, (response) => { checkFold(response.data[0], (zoomIn) => { + console.warn(`response.data[0] : ${response.data[0]}`); openMobileFileById(protyle.app, response.data[0], zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]); activeBlur(); hideKeyboardToolbar(); @@ -2189,6 +2244,7 @@ if (tableElement && tableElement.isSameNode(item) && item.querySelector(".table const embedId = embedItemElement.getAttribute("data-id"); checkFold(embedId, (zoomIn, action) => { /// #if MOBILE + console.warn(`embedId : ${embedId}`); openMobileFileById(protyle.app, embedId, zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]); activeBlur(); hideKeyboardToolbar(); From c84a7e5921e18b7a632710386ac5463c777ab24c Mon Sep 17 00:00:00 2001 From: Soltus Date: Tue, 9 Apr 2024 20:40:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/package.json b/app/package.json index c08efc7502..4e47f554c7 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "sillot", - "version": "0.28.23", + "version": "0.28.24", "syv": "3.0.8", "sypv": "[3.0.7, 3.0.6]", "description": "Build Your Eternal Digital Garden",