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

Vanessa926c13317ddc
diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts
index cd26b11ec3..1c4428fb68 100644
--- a/app/src/mobile/util/keyboardToolbar.ts
+++ b/app/src/mobile/util/keyboardToolbar.ts
@@ -508,9 +508,10 @@ export const activeBlur = () => {
export const initKeyboardToolbar = () => {
let preventRender = false;
document.addEventListener("selectionchange", () => {
- if (!preventRender) {
- renderKeyboardToolbar();
+ if (preventRender || (getCurrentEditor()?.protyle?.toolbar.isMultiSelectMode())) {
+ return;
}
+ renderKeyboardToolbar();
}, false);
window.siyuan.mobile.size.isLandscape = window.matchMedia && window.matchMedia("(orientation: landscape)").matches;
if (window.siyuan.mobile.size.isLandscape) {
diff --git a/app/src/mobile/util/touch.ts b/app/src/mobile/util/touch.ts
index c8470b9b92..233acd1bbd 100644
--- a/app/src/mobile/util/touch.ts
+++ b/app/src/mobile/util/touch.ts
@@ -37,7 +37,24 @@ export const handleTouchEnd = (event: TouchEvent) => {
const currentTime = Date.now();
const editor = getCurrentEditor();
if (Math.abs(clientX - event.changedTouches[0].clientX) < 5 && Math.abs(clientY - event.changedTouches[0].clientY) < 5) {
- if (currentTime - time > Constants.TIMEOUT_LONGPRESS) {
+ if (editor && editor.protyle.toolbar.isMultiSelectMode()) {
+ // 多选模式
+ const blockElement = hasClosestBlock(target);
+ if (blockElement) {
+ blockElement.querySelectorAll(".protyle-wysiwyg--select").forEach(item => {
+ item.classList.remove("protyle-wysiwyg--select");
+ });
+ const blockParentElement = hasClosestByClassName(blockElement.parentElement, "protyle-wysiwyg--select");
+ if (blockParentElement) {
+ blockParentElement.classList.remove("protyle-wysiwyg--select");
+ }
+ blockElement.classList.toggle("protyle-wysiwyg--select");
+ editor.protyle.toolbar.subElement.querySelector(".multiSelectCount").textContent =
+ editor.protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").length.toString();
+ event.stopImmediatePropagation();
+ event.preventDefault();
+ }
+ } else if (currentTime - time > Constants.TIMEOUT_LONGPRESS) {
// 长按
if (isIPhone() && !isChromeBrowser() && !window.siyuan.touchDragActive) {
target.dispatchEvent(new MouseEvent("contextmenu", {
@@ -48,7 +65,7 @@ export const handleTouchEnd = (event: TouchEvent) => {
}));
}
// 超长按
- if (currentTime - time > 2000 && editor && !editor.protyle.toolbar.isMultiSelectMode()) {
+ if (currentTime - time > 2000) {
const blockElement = hasClosestBlock(target);
if (blockElement) {
const protyle = editor.protyle;
@@ -57,23 +74,6 @@ export const handleTouchEnd = (event: TouchEvent) => {
}
event.stopImmediatePropagation();
event.preventDefault();
- } else if (editor && editor.protyle.toolbar.isMultiSelectMode()) {
- // 多选模式
- const blockElement = hasClosestBlock(target);
- if (blockElement) {
- blockElement.querySelectorAll(".protyle-wysiwyg--select").forEach(item => {
- item.classList.remove("protyle-wysiwyg--select");
- });
- const blockParentElement = hasClosestByClassName(blockElement.parentElement, "protyle-wysiwyg--select");
- if (blockParentElement) {
- blockParentElement.classList.remove("protyle-wysiwyg--select");
- }
- blockElement.classList.toggle("protyle-wysiwyg--select");
- editor.protyle.toolbar.subElement.querySelector(".multiSelectCount").textContent =
- editor.protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").length.toString();
- event.stopImmediatePropagation();
- event.preventDefault();
- }
}
return;
}
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 10d535a2b9..11e72adb57 100644
--- a/app/src/protyle/toolbar/index.ts
+++ b/app/src/protyle/toolbar/index.ts
@@ -46,6 +46,7 @@ import {confirmDialog} from "../../dialog/confirmDialog";
import {paste, pasteAsPlainText, pasteEscaped} from "../util/paste";
import {escapeHtml} from "../../util/escape";
import {resizeSide} from "../../history/resizeSide";
+import {activeBlur} from "../../mobile/util/keyboardToolbar";
export class Toolbar {
public element: HTMLElement;
@@ -1418,6 +1419,7 @@ export class Toolbar {
});
setPosition(this.subElement, 8, 8);
this.element.classList.add("fn__none");
+ activeBlur();
}
public isMultiSelectMode() {