Skip to content

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

:bug: Activate mobile mind maps with a single tap https://github.com/siyuan-note/siyuan/issues/20670

Daniel6daddea1577b
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy
index 41efb4eecf..9d80def869 100644
--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy
+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy
@@ -8,7 +8,7 @@
"title": "Formatting elements",
"title-img": "background-color:#269;background-image: linear-gradient(white 2px, transparent 2px),linear-gradient(90deg, white 2px, transparent 2px),linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px);background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;background-position:-2px -2px, -2px -2px, -1px -1px, -1px -1px;",
"type": "doc",
- "updated": "20261019194432"
+ "updated": "20261019201307"
},
"Children": [
{
@@ -1961,7 +1961,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20210104091509-v1x69oc",
- "updated": "20261019142953"
+ "updated": "20261019201307"
},
"Children": [
{
@@ -2000,12 +2000,12 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20261018163000-gjcy3xw",
- "updated": "20261018200107"
+ "updated": "20261019201307"
},
"Children": [
{
"Type": "NodeText",
- "Data": "Mind maps initially leave the mouse wheel and one-finger swipes to document scrolling. On desktop, click the map to activate canvas interaction. On mobile, use the Hand Tool for one-finger panning, or double-tap a node to edit it. Turn off the Hand Tool to select or drag nodes. An active canvas has a highlighted border. Use the wheel or drag with the right mouse button to pan; the Hand Tool also allows left-button panning. Ordinary left dragging on blank canvas does not pan. Active one-finger gestures pan the canvas on touch screens. At the pan boundary, input stays with the canvas instead of scrolling the document. Click outside the map, move keyboard focus outside it, or press Esc on the canvas to return to reading. Full-screen maps stay active until you exit full screen."
+ "Data": "Mind maps initially leave the mouse wheel and one-finger swipes to document scrolling. Click the map on desktop or tap it once on mobile to activate canvas interaction. On mobile, use the Hand Tool for one-finger panning, or double-tap a node to edit it. Turn off the Hand Tool to select or drag nodes. An active canvas has a highlighted border. Use the wheel or drag with the right mouse button to pan; the Hand Tool also allows left-button panning. Ordinary left dragging on blank canvas does not pan. Active one-finger gestures pan the canvas on touch screens. At the pan boundary, input stays with the canvas instead of scrolling the document. Click outside the map, move keyboard focus outside it, or press Esc on the canvas to return to reading. Full-screen maps stay active until you exit full screen."
}
]
},
diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy
index 2aadf4fd3f..fd7fbc5630 100644
--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy
+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy
@@ -8,7 +8,7 @@
"title": "排版元素",
"title-img": "background-color: hsl(2, 57%, 40%);background-image: repeating-linear-gradient(transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(270deg, transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(125deg, transparent, transparent 2px, rgba(0,0,0,.2) 2px, rgba(0,0,0,.2) 3px, transparent 3px, transparent 5px, rgba(0,0,0,.2) 5px);",
"type": "doc",
- "updated": "20261019194453"
+ "updated": "20261019201307"
},
"Children": [
{
@@ -1964,7 +1964,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20210104091228-wdpx6ev",
- "updated": "20261019142953"
+ "updated": "20261019201307"
},
"Children": [
{
@@ -2003,12 +2003,12 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20261018163000-vnuug6c",
- "updated": "20261018200107"
+ "updated": "20261019201307"
},
"Children": [
{
"Type": "NodeText",
- "Data": "思维导图默认将鼠标滚轮和单指滑动交给文档滚动。桌面端点击导图即可操作画布;移动端可使用工具栏中的“手形工具”进行单指平移,关闭手形工具后可选择、拖动或双击编辑节点,也可在阅读时直接双击节点进入编辑。操作中的画布显示高亮边框,可用滚轮或鼠标右键拖动平移画布,启用手形工具后也可用左键拖动平移。普通模式下,空白区域的左键拖动不会平移画布。移动端操作时可用单指拖动平移画布,到达平移边界后也不会滚动文档。点击导图外部、将键盘焦点移到外部,或在画布上按 Esc 即可恢复阅读。全屏时保持画布操作,退出全屏后恢复阅读。"
+ "Data": "思维导图默认将鼠标滚轮和单指滑动交给文档滚动。桌面端点击导图、移动端轻点一次导图即可操作画布;移动端也可使用工具栏中的“手形工具”进行单指平移,关闭手形工具后可选择、拖动或双击编辑节点,也可在阅读时直接双击节点进入编辑。操作中的画布显示高亮边框,可用滚轮或鼠标右键拖动平移画布,启用手形工具后也可用左键拖动平移。普通模式下,空白区域的左键拖动不会平移画布。移动端操作时可用单指拖动平移画布,到达平移边界后也不会滚动文档。点击导图外部、将键盘焦点移到外部,或在画布上按 Esc 即可恢复阅读。全屏时保持画布操作,退出全屏后恢复阅读。"
}
]
},
diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy
index f7fd5b8adc..82b29556b8 100644
--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy
+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy
@@ -8,7 +8,7 @@
"title": "排版元素",
"title-img": "background-color: hsl(2, 57%, 40%);background-image: repeating-linear-gradient(transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(270deg, transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(125deg, transparent, transparent 2px, rgba(0,0,0,.2) 2px, rgba(0,0,0,.2) 3px, transparent 3px, transparent 5px, rgba(0,0,0,.2) 5px);",
"type": "doc",
- "updated": "20261019194453"
+ "updated": "20261019201307"
},
"Children": [
{
@@ -1962,7 +1962,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20211226122008-731sqd6",
- "updated": "20261019142953"
+ "updated": "20261019201307"
},
"Children": [
{
@@ -2001,12 +2001,12 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20261018163000-b7er7oa",
- "updated": "20261018200107"
+ "updated": "20261019201307"
},
"Children": [
{
"Type": "NodeText",
- "Data": "心智圖預設將滑鼠滾輪和單指滑動交給文件捲動。桌面版點擊心智圖即可操作畫布;行動版可使用工具列中的「手形工具」進行單指平移,關閉手形工具後可選取、拖曳或按兩下編輯節點,也可在閱讀時直接按兩下節點進入編輯。操作中的畫布顯示醒目邊框,可用滾輪或滑鼠右鍵拖曳平移畫布,啟用手形工具後也可用左鍵拖曳平移。一般模式下,空白區域的左鍵拖曳不會平移畫布。行動版操作時可用單指拖曳平移畫布,到達平移邊界後也不會捲動文件。點擊心智圖外部、將鍵盤焦點移到外部,或在畫布上按 Esc 即可恢復閱讀。全螢幕時保持畫布操作,離開全螢幕後恢復閱讀。"
+ "Data": "心智圖預設將滑鼠滾輪和單指滑動交給文件捲動。桌面版點擊心智圖、行動版輕點一次心智圖即可操作畫布;行動版也可使用工具列中的「手形工具」進行單指平移,關閉手形工具後可選取、拖曳或按兩下編輯節點,也可在閱讀時直接按兩下節點進入編輯。操作中的畫布顯示醒目邊框,可用滾輪或滑鼠右鍵拖曳平移畫布,啟用手形工具後也可用左鍵拖曳平移。一般模式下,空白區域的左鍵拖曳不會平移畫布。行動版操作時可用單指拖曳平移畫布,到達平移邊界後也不會捲動文件。點擊心智圖外部、將鍵盤焦點移到外部,或在畫布上按 Esc 即可恢復閱讀。全螢幕時保持畫布操作,離開全螢幕後恢復閱讀。"
}
]
},
diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy
index 32f9bc4705..20fbf7f618 100644
--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy
+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy
@@ -9,7 +9,7 @@
"title": "書式要素",
"title-img": "background-color:#269;background-image: linear-gradient(white 2px, transparent 2px),linear-gradient(90deg, white 2px, transparent 2px),linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px);background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;background-position:-2px -2px, -2px -2px, -1px -1px, -1px -1px;",
"type": "doc",
- "updated": "20261019194453"
+ "updated": "20261019201307"
},
"Children": [
{
@@ -2090,7 +2090,7 @@
"Properties": {
"ID": "20240530101000-ch5e4vh",
"id": "20240530101000-1ev7xub",
- "updated": "20261019142953"
+ "updated": "20261019201307"
},
"Children": [
{
@@ -2129,12 +2129,12 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20261018163000-bic9sbi",
- "updated": "20261018200107"
+ "updated": "20261019201307"
},
"Children": [
{
"Type": "NodeText",
- "Data": "マインドマップ上のマウスホイールと 1 本指のスワイプは、初期状態では文書をスクロールします。デスクトップではマップをクリックするとキャンバスを操作できます。モバイルではツールバーの「手のひらツール」で 1 本指の移動を行い、ツールをオフにするとノードを選択・ドラッグ・編集できます。閲覧中でもノードをダブルタップすると編集できます。操作中は枠が強調表示され、ホイールまたはマウスの右ボタンを押したドラッグでキャンバスを移動します。手のひらツールでは左ボタンでのドラッグも使えます。通常モードでは空白部分を左ボタンでドラッグしてもキャンバスは移動しません。タッチ画面では操作中に 1 本指でキャンバスを移動できます。移動範囲の端でも文書はスクロールしません。マップの外をクリックする、キーボードフォーカスを外に移す、またはキャンバス上で Esc を押すと閲覧に戻ります。全画面表示ではキャンバス操作を維持し、全画面表示を終了すると閲覧に戻ります。"
+ "Data": "マインドマップ上のマウスホイールと 1 本指のスワイプは、初期状態では文書をスクロールします。デスクトップではマップをクリック、モバイルではマップを 1 回タップするとキャンバスを操作できます。モバイルではツールバーの「手のひらツール」でも 1 本指の移動を行い、ツールをオフにするとノードを選択・ドラッグ・編集できます。閲覧中でもノードをダブルタップすると編集できます。操作中は枠が強調表示され、ホイールまたはマウスの右ボタンを押したドラッグでキャンバスを移動します。手のひらツールでは左ボタンでのドラッグも使えます。通常モードでは空白部分を左ボタンでドラッグしてもキャンバスは移動しません。タッチ画面では操作中に 1 本指でキャンバスを移動できます。移動範囲の端でも文書はスクロールしません。マップの外をクリックする、キーボードフォーカスを外に移す、またはキャンバス上で Esc を押すと閲覧に戻ります。全画面表示ではキャンバス操作を維持し、全画面表示を終了すると閲覧に戻ります。"
}
]
},
diff --git a/app/src/protyle/render/listMindmap/model.test.ts b/app/src/protyle/render/listMindmap/model.test.ts
index 8613db1c3d..366d0eeff4 100644
--- a/app/src/protyle/render/listMindmap/model.test.ts
+++ b/app/src/protyle/render/listMindmap/model.test.ts
@@ -3370,6 +3370,45 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
check.equal(panView.editingId, panModel.root.id);
check.equal(panView.interactionActive, true);
panView.setEditing(undefined);
+ panView.setInteractionActive(false);
+ await settle();
+ const tapNode = panHost.querySelector<HTMLElement>(`[data-mindmap-id="${panModel.root.id}"]`);
+ const tapBounds = tapNode.getBoundingClientRect();
+ for (const point of [fingerAt(1), {id: 1, x: tapBounds.left + tapBounds.width / 2,
+ y: tapBounds.top + tapBounds.height / 2}]) {
+ const beforeTapEdit = edits.length;
+ let readingOnContact = false;
+ viewport.addEventListener("pointerdown", () => readingOnContact = !panView.interactionActive, {once: true});
+ await nativeTouch([
+ {type: "touchStart", touchPoints: [point]},
+ {type: "touchEnd", touchPoints: []},
+ ]);
+ check.equal(readingOnContact, true, "touch contact leaves document scrolling available");
+ check.equal(panView.interactionActive, true, "native single tap activates blank canvas and nodes");
+ check.equal(getComputedStyle(viewport).touchAction, "none");
+ check.equal(edits.length, beforeTapEdit, "single tap does not start node editing");
+ check.deepEqual([panView.scale, panView.offsetX, panView.offsetY], readingTransform);
+ panView.setInteractionActive(false);
+ }
+ panView.setReadOnly(true);
+ await nativeTouch([
+ {type: "touchStart", touchPoints: [fingerAt(1)]},
+ {type: "touchEnd", touchPoints: []},
+ ]);
+ check.equal(panView.interactionActive, true, "single tap also activates a read-only canvas");
+ panView.setReadOnly(false);
+ panView.setLocked(true);
+ await nativeTouch([
+ {type: "touchStart", touchPoints: [fingerAt(1)]},
+ {type: "touchEnd", touchPoints: []},
+ ]);
+ check.equal(panView.interactionActive, false, "single tap preserves the saved view lock");
+ panView.setLocked(false);
+ await nativeTouch([
+ {type: "touchStart", touchPoints: [fingerAt(1)]},
+ {type: "touchCancel", touchPoints: []},
+ ]);
+ check.equal(panView.interactionActive, false, "cancelled touches do not activate the canvas");
check.equal(panModel.list.outerHTML, sourceHTML, "interaction activation and panning do not change saved data");
panView.destroy();
scrollHost.remove();
@@ -4804,7 +4843,15 @@ app.whenReady().then(async () => {
ipcMain.handle("mindmap-view-native-input", async (_event, events) => {
win.webContents.focus();
for (const event of events) {
- win.webContents.sendInputEvent(event);
+ if (event.type === "mouseWheel") {
+ // 隐藏窗口通过调试协议注入滚轮,直接交给渲染器的输入路由。
+ await win.webContents.debugger.sendCommand("Input.dispatchMouseEvent", {
+ type: "mouseWheel", x: event.x, y: event.y, buttons: 0,
+ deltaX: -event.deltaX, deltaY: -event.deltaY,
+ });
+ } else {
+ win.webContents.sendInputEvent(event);
+ }
await new Promise(resolve => setTimeout(resolve, 20));
}
});
diff --git a/app/src/protyle/render/listMindmap/view.ts b/app/src/protyle/render/listMindmap/view.ts
index 5196514b1c..8f506efdd2 100644
--- a/app/src/protyle/render/listMindmap/view.ts
+++ b/app/src/protyle/render/listMindmap/view.ts
@@ -251,6 +251,7 @@ export class ListMindmapView {
this.createToolbar();
this.listen(document, "pointerdown", this.dismissControls, {capture: true});
this.listen(options.host, "pointerdown", this.activatePointer, {capture: true});
+ this.listen(options.host, "click", this.activatePointer, {capture: true});
this.listen(options.host, "focusout", (event: FocusEvent) => {
if (event.relatedTarget instanceof Node && !options.host.contains(event.relatedTarget)) {
this.setInteractionActive(false);
@@ -468,11 +469,12 @@ export class ListMindmapView {
private activatePointer = (event: PointerEvent) => {
const target = event.target as Element;
- if (target.closest(".mindmap-view") !== this.options.host ||
+ if (this.pinching || target.closest(".mindmap-view") !== this.options.host ||
this.buttons.get("lock")?.contains(target) || this.isTemporaryPan(event)) {
return;
}
- if (event.pointerType !== "touch" || target.closest("button, input, select")) {
+ // 触屏在点按完成后激活,按下时仍允许浏览器处理文档滑动。
+ if (event.type === "click" || event.pointerType !== "touch" || target.closest("button, input, select")) {
this.setInteractionActive(true);
}
};
diff --git a/app/src/protyle/render/listMindmap/viewportFocus.test.ts b/app/src/protyle/render/listMindmap/viewportFocus.test.ts
index 795c23c678..6c68f7a4b7 100644
--- a/app/src/protyle/render/listMindmap/viewportFocus.test.ts
+++ b/app/src/protyle/render/listMindmap/viewportFocus.test.ts
@@ -240,6 +240,24 @@ test("hand-tool, right-button and primary touch panning preserve the editing foc
}
});
+test("touch activation waits for a click and ignores an unfinished pinch or a nested map", () => {
+ const {target, event} = setup();
+ target.interactionActive = false;
+ const down = event("background", {type: "pointerdown", pointerType: "touch"});
+ target.activatePointer(down);
+ assert.equal(target.interactionActive, false);
+ const click = event("background", {type: "click", pointerType: "touch"});
+ target.activatePointer(click);
+ assert.equal(target.interactionActive, true);
+ target.interactionActive = false;
+ target.pinching = true;
+ target.activatePointer(click);
+ assert.equal(target.interactionActive, false);
+ target.pinching = false;
+ target.activatePointer({...click, target: {closest: () => ({})}});
+ assert.equal(target.interactionActive, false);
+});
+
test("Ctrl and Meta right dragging preserves reading state, node selection and editor focus", () => {
for (const key of ["ctrlKey", "metaKey"]) {
for (const interactionActive of [false, true]) {