An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:lipstick: Improve touch feedback when resizing dialogs and panels https://github.com/siyuan-note/siyuan/issues/19313
Vanessa3a8c543b8f93
diff --git a/app/src/assets/scss/business/_resize.scss b/app/src/assets/scss/business/_resize.scssindex 3be8a34f56..01e91a69a5 100644--- a/app/src/assets/scss/business/_resize.scss+++ b/app/src/assets/scss/business/_resize.scss@@ -81,3 +81,145 @@cursor: move;}}++// 高亮只附着在当前命中的把手上,不覆盖窗口内容或改变定位参照。+.touch-resize-active {+ background-color: var(--b3-theme-primary-lighter);+}++// 边缘使用居中的圆角线段,角落使用相邻的局部线段,装饰不参与命中测试。+.resize__r, .resize__l, .resize__t, .resize__d,+.resize__rd, .resize__ld, .resize__rt, .resize__lt {+ &.touch-resize-active {+ background-color: transparent;+ }+}++.resize__r, .resize__l, .resize__t, .resize__d {+ &.touch-resize-active::after {+ content: "";+ position: absolute;+ pointer-events: none;+ background-color: var(--b3-theme-primary-lighter);+ border-radius: 2px;+ }+}++.resize__r.touch-resize-active::after,+.resize__l.touch-resize-active::after {+ width: 3px;+ height: min(96px, 100%);+ top: max(0px, calc(50% - 48px));+}++.resize__r.touch-resize-active::after { left: 4px; }+.resize__l.touch-resize-active::after { right: 4px; }++.resize__t.touch-resize-active::after,+.resize__d.touch-resize-active::after {+ height: 3px;+ width: min(96px, 100%);+ left: max(0px, calc(50% - 48px));+}++.resize__t.touch-resize-active::after { bottom: 4px; }+.resize__d.touch-resize-active::after { top: 4px; }++[data-touch-resize-corner].touch-resize-active::after {+ display: none;+}++// 角把手向窗口内部延伸两段线,在点击位置连接圆角,外侧留出 4px 间距。+.resize__rd, .resize__ld, .resize__rt, .resize__lt {+ &.touch-resize-active::after {+ content: "";+ position: absolute;+ pointer-events: none;+ box-sizing: border-box;+ width: 104px;+ height: 104px;+ border: 0 solid var(--b3-theme-primary-lighter);+ }+}++.resize__rd.touch-resize-active::after {+ right: calc(100% - 15px);+ bottom: calc(100% - 15px);+ border-right-width: 3px;+ border-bottom-width: 3px;+ border-bottom-right-radius: 12px;+}++.resize__ld.touch-resize-active::after {+ left: calc(100% - 15px);+ bottom: calc(100% - 15px);+ border-left-width: 3px;+ border-bottom-width: 3px;+ border-bottom-left-radius: 12px;+}++.resize__rt.touch-resize-active::after {+ right: calc(100% - 15px);+ top: calc(100% - 15px);+ border-right-width: 3px;+ border-top-width: 3px;+ border-top-right-radius: 12px;+}++.resize__lt.touch-resize-active::after {+ left: calc(100% - 15px);+ top: calc(100% - 15px);+ border-left-width: 3px;+ border-top-width: 3px;+ border-top-left-radius: 12px;+}++@media (any-pointer: coarse) {+ // 扩大弹窗外侧的触摸把手,避免侵占内部按钮和滚动条。+ .b3-dialog {+ .resize__r {+ width: 14px;+ right: -14px;+ }++ .resize__l {+ width: 14px;+ left: -14px;+ }++ .resize__t {+ height: 14px;+ top: -14px;+ }++ .resize__d {+ height: 14px;+ bottom: -14px;+ }++ .resize__rd, .resize__ld, .resize__rt, .resize__lt {+ width: 24px;+ height: 24px;+ }++ .resize__rd {+ right: -16px;+ bottom: -16px;+ }++ .resize__ld {+ left: -16px;+ bottom: -16px;+ }++ .resize__rt {+ right: -16px;+ top: -16px;+ }++ .resize__lt {+ left: -16px;+ top: -16px;+ }+ }+}diff --git a/app/src/util/touchDragBridge.ts b/app/src/util/touchDragBridge.tsindex 8e5cb1b7ff..07b55be3d7 100644--- a/app/src/util/touchDragBridge.ts+++ b/app/src/util/touchDragBridge.ts@@ -183,6 +183,9 @@ export const isLastPointerMouse = (): boolean => {return lastPointerType === "mouse";};+let touchResizeHandle: HTMLElement | null = null;+let touchResizeEdges: HTMLElement[] = [];+// 触摸起始:先判断是否命中原生 Drag API(draggable="true"),命中则走原生路径;否则判断手动 mousedown 白名单const handleTouchStart = (e: TouchEvent) => {if (e.touches.length !== 1) return;@@ -246,6 +249,30 @@ const handleTouchStart = (e: TouchEvent) => {view: window,});target.dispatchEvent(mouseEvent);+ // 仅在触摸命中可操作边界后提示,不改变鼠标反馈或内容区的长按行为。+ if (!isMouseInput(touch) && document.onmousemove) {+ touchResizeHandle = target.closest<HTMLElement>(+ ".layout__resize, .layout__dockresize, " ++ ".b3-dialog .resize__rd, .b3-dialog .resize__ld, .b3-dialog .resize__rt, " ++ ".b3-dialog .resize__lt, .b3-dialog .resize__r, .b3-dialog .resize__l, " ++ ".b3-dialog .resize__t, .b3-dialog .resize__d",+ );+ if (touchResizeHandle) {+ touchResizeHandle.classList.add("touch-resize-active");+ // 角把手在相邻边缘显示局部高亮,让手指外侧也能看到反馈。+ const corner = ["rd", "ld", "rt", "lt"].find(direction =>+ touchResizeHandle.classList.contains(`resize__${direction}`));+ if (corner) {+ touchResizeEdges = Array.from(touchResizeHandle.parentElement.children)+ .filter((child): child is HTMLElement => child instanceof HTMLElement &&+ [...corner].some(direction => child.classList.contains(`resize__${direction}`)));+ touchResizeEdges.forEach(edge => {+ edge.dataset.touchResizeCorner = corner;+ edge.classList.add("touch-resize-active");+ });+ }+ }+ }manualState = {startX: touch.clientX,startY: touch.clientY,@@ -1062,6 +1089,13 @@ const handleCancel = () => {// 取消手动桥接(mousedown)路径:派发 mouseup 以触发各组件注册的清理回调(如 Outline.bindSort 的 mouseup 会清空 document.onmousemove 等),并复位状态// event.ts 的 touchend 会无条件前置调用它,确保 Outline.bindSort 等注册的 onmousemove/onmouseup 不残留,避免被后续事件误触发(创建拖拽 ghost、启动滚动动画等)export const cancelManualTouch = () => {+ touchResizeHandle?.classList.remove("touch-resize-active");+ touchResizeHandle = null;+ touchResizeEdges.forEach(edge => {+ edge.classList.remove("touch-resize-active");+ delete edge.dataset.touchResizeCorner;+ });+ touchResizeEdges = [];if (manualState && document.onmouseup && typeof document.onmouseup === "function") {document.onmouseup(new MouseEvent("mouseup", {bubbles: true}));}@@ -1113,6 +1147,11 @@ export const initTouchDragBridge = () => {document.addEventListener("keydown", handleDragKey, {capture: true});document.addEventListener("keyup", handleDragKey, {capture: true});document.addEventListener("visibilitychange", handleVisibilityChange);+ window.addEventListener("blur", () => {+ if (touchResizeHandle) {+ cancelManualTouch();+ }+ });// 触摸事件桥接:原生 Drag API(draggable="true")与手动 mousedown 拖拽(dock/outline/resize 把手)统一入口document.addEventListener("touchstart", handleTouchStart, {passive: false});