mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-12-14 08:06:22 +00:00
Update script-terminal-modal.tsx
This commit is contained in:
@@ -66,13 +66,7 @@ export function ScriptTerminalModal({
|
|||||||
|
|
||||||
const [modalHeight, setModalHeight] = useState(600)
|
const [modalHeight, setModalHeight] = useState(600)
|
||||||
const [isResizing, setIsResizing] = useState(false)
|
const [isResizing, setIsResizing] = useState(false)
|
||||||
const resizeHandlersRef = useRef<{
|
const resizeBarRef = useRef<HTMLDivElement>(null)
|
||||||
handlePointerMove: ((e: PointerEvent) => void) | null
|
|
||||||
handlePointerUp: (() => void) | null
|
|
||||||
}>({
|
|
||||||
handlePointerMove: null,
|
|
||||||
handlePointerUp: null,
|
|
||||||
})
|
|
||||||
|
|
||||||
const terminalContainerRef = useRef<HTMLDivElement>(null)
|
const terminalContainerRef = useRef<HTMLDivElement>(null)
|
||||||
|
|
||||||
@@ -301,16 +295,6 @@ export function ScriptTerminalModal({
|
|||||||
termRef.current.dispose()
|
termRef.current.dispose()
|
||||||
termRef.current = null
|
termRef.current = null
|
||||||
}
|
}
|
||||||
if (resizeHandlersRef.current.handlePointerMove) {
|
|
||||||
document.removeEventListener("pointermove", resizeHandlersRef.current.handlePointerMove)
|
|
||||||
}
|
|
||||||
if (resizeHandlersRef.current.handlePointerUp) {
|
|
||||||
document.removeEventListener("pointerup", resizeHandlersRef.current.handlePointerUp)
|
|
||||||
}
|
|
||||||
resizeHandlersRef.current = {
|
|
||||||
handlePointerMove: null,
|
|
||||||
handlePointerUp: null,
|
|
||||||
}
|
|
||||||
|
|
||||||
sessionIdRef.current = Math.random().toString(36).substring(2, 8)
|
sessionIdRef.current = Math.random().toString(36).substring(2, 8)
|
||||||
setIsComplete(false)
|
setIsComplete(false)
|
||||||
@@ -404,6 +388,7 @@ export function ScriptTerminalModal({
|
|||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
|
|
||||||
|
setIsResizing(true)
|
||||||
const startY = e.clientY
|
const startY = e.clientY
|
||||||
const startHeight = modalHeight
|
const startHeight = modalHeight
|
||||||
|
|
||||||
@@ -433,11 +418,21 @@ export function ScriptTerminalModal({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleEnd = () => {
|
const handleEnd = () => {
|
||||||
|
setIsResizing(false)
|
||||||
document.removeEventListener("pointermove", handleMove)
|
document.removeEventListener("pointermove", handleMove)
|
||||||
document.removeEventListener("pointerup", handleEnd)
|
document.removeEventListener("pointerup", handleEnd)
|
||||||
document.removeEventListener("pointercancel", handleEnd)
|
document.removeEventListener("pointercancel", handleEnd)
|
||||||
|
|
||||||
localStorage.setItem("scriptModalHeight", modalHeight.toString())
|
localStorage.setItem("scriptModalHeight", modalHeight.toString())
|
||||||
|
|
||||||
|
// Release pointer capture
|
||||||
|
if (resizeBarRef.current) {
|
||||||
|
try {
|
||||||
|
resizeBarRef.current.releasePointerCapture(e.pointerId)
|
||||||
|
} catch (err) {
|
||||||
|
// Ignore if already released
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("pointermove", handleMove)
|
document.addEventListener("pointermove", handleMove)
|
||||||
@@ -445,8 +440,12 @@ export function ScriptTerminalModal({
|
|||||||
document.addEventListener("pointercancel", handleEnd)
|
document.addEventListener("pointercancel", handleEnd)
|
||||||
|
|
||||||
// Capturar el pointer para asegurar que recibimos todos los eventos
|
// Capturar el pointer para asegurar que recibimos todos los eventos
|
||||||
if (e.currentTarget instanceof Element) {
|
if (resizeBarRef.current) {
|
||||||
e.currentTarget.setPointerCapture(e.pointerId)
|
try {
|
||||||
|
resizeBarRef.current.setPointerCapture(e.pointerId)
|
||||||
|
} catch (err) {
|
||||||
|
// Ignore if capture fails
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,11 +493,20 @@ export function ScriptTerminalModal({
|
|||||||
{/* Resize bar - visible en tablet y escritorio */}
|
{/* Resize bar - visible en tablet y escritorio */}
|
||||||
{!isMobile && (
|
{!isMobile && (
|
||||||
<div
|
<div
|
||||||
|
ref={resizeBarRef}
|
||||||
onPointerDown={handleResizeStart}
|
onPointerDown={handleResizeStart}
|
||||||
className="h-2 cursor-ns-resize flex items-center justify-center hover:bg-accent transition-colors z-50 pointer-events-auto touch-none"
|
className={`h-2 cursor-ns-resize flex items-center justify-center transition-colors z-50 select-none ${
|
||||||
style={{ touchAction: "none" }}
|
isResizing ? "bg-blue-500" : "hover:bg-accent"
|
||||||
|
}`}
|
||||||
|
style={{
|
||||||
|
touchAction: "none",
|
||||||
|
WebkitUserSelect: "none",
|
||||||
|
userSelect: "none"
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<GripHorizontal className="h-3 w-8 text-muted-foreground/50" />
|
<GripHorizontal className={`h-3 w-8 transition-colors ${
|
||||||
|
isResizing ? "text-white" : "text-muted-foreground/50"
|
||||||
|
} pointer-events-none`} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -513,7 +521,7 @@ export function ScriptTerminalModal({
|
|||||||
}}
|
}}
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="h-8 px-2.5 text-xs bg-zinc-800 hover:bg-zinc-700 border-zinc-700 text-white min-w-[60px]"
|
className="h-8 px-2 text-xs bg-zinc-800 hover:bg-zinc-700 border-zinc-700 text-white min-w-[60px]"
|
||||||
>
|
>
|
||||||
ESC
|
ESC
|
||||||
</Button>
|
</Button>
|
||||||
@@ -525,7 +533,7 @@ export function ScriptTerminalModal({
|
|||||||
}}
|
}}
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="h-8 px-2.5 text-xs bg-zinc-800 hover:bg-zinc-700 border-zinc-700 text-white min-w-[60px]"
|
className="h-8 px-2 text-xs bg-zinc-800 hover:bg-zinc-700 border-zinc-700 text-white min-w-[60px]"
|
||||||
>
|
>
|
||||||
TAB
|
TAB
|
||||||
</Button>
|
</Button>
|
||||||
@@ -597,7 +605,7 @@ export function ScriptTerminalModal({
|
|||||||
}}
|
}}
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="h-8 px-2.5 text-xs bg-zinc-800 hover:bg-zinc-700 border-zinc-700 text-white min-w-[75px]"
|
className="h-8 px-2 text-xs bg-zinc-800 hover:bg-zinc-700 border-zinc-700 text-white min-w-[75px]"
|
||||||
>
|
>
|
||||||
CTRL+C
|
CTRL+C
|
||||||
</Button>
|
</Button>
|
||||||
@@ -757,4 +765,4 @@ export function ScriptTerminalModal({
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user