Aktiviere Dokument-Droppunkte sofort per DOM und Maus-Events, damit Zuordnen aus dem Vorgang mit echter Maus ankommt.
Deploy Development / deploy (push) Successful in 28s
Test Suite / pytest-backend (push) Successful in 2m1s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 9s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-18 14:13:22 +02:00
1 parent 0c611763c3
commit e3274bce21
2 files changed
+90 -33

No files matched your search

+82 -31
View File
@@ -1,4 +1,4 @@
import { useEffect, useRef, useState } from "react"; import { useEffect, useLayoutEffect, useRef, useState } from "react";
import { createPortal } from "react-dom"; import { createPortal } from "react-dom";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { api, fetchFile, fetchPaperless } from "../api.js"; import { api, fetchFile, fetchPaperless } from "../api.js";
@@ -1092,11 +1092,14 @@ export function ContentBoard({
window.addEventListener("keydown", onKey); window.addEventListener("keydown", onKey);
return () => { return () => {
window.removeEventListener("keydown", onKey); window.removeEventListener("keydown", onKey);
document.body.classList.remove("is-carrying", "is-assigning"); document.body.classList.remove("is-carrying", "is-assigning", "is-list-intent", "is-list-carry");
rootRef.current?.querySelectorAll(".preview-row.is-carry-source, .preview-row.is-assign-target").forEach((row) => {
row.classList.remove("is-carry-source", "is-assign-target");
});
}; };
}, []); }, []);
useEffect(() => { useLayoutEffect(() => {
const node = rootRef.current; const node = rootRef.current;
if (!node) return undefined; if (!node) return undefined;
function place(event) { function place(event) {
@@ -1173,7 +1176,9 @@ export function ContentBoard({
carryRef.current = null; carryRef.current = null;
setIndicator(null); setIndicator(null);
setCarrying(null); setCarrying(null);
document.body.classList.remove("is-carrying", "is-assigning"); document.body.classList.remove("is-carrying", "is-assigning", "is-list-intent", "is-list-carry");
carried.sourceRow?.classList.remove("is-carry-source");
rootRef.current?.querySelectorAll(".preview-row.is-assign-target").forEach((row) => row.classList.remove("is-assign-target"));
if (assign) placeUseRef.current?.(useId, carried); if (assign) placeUseRef.current?.(useId, carried);
else if ((carried.source === "attachment" || carried.source === "evidence") && (section || event.target?.closest?.("[data-release-drop]"))) { else if ((carried.source === "attachment" || carried.source === "evidence") && (section || event.target?.closest?.("[data-release-drop]"))) {
releaseRef.current?.({ releaseRef.current?.({
@@ -1202,6 +1207,7 @@ export function ContentBoard({
function blockRowMouseDown(event) { function blockRowMouseDown(event) {
if (event.button !== 0 || !rowTarget(event)) return; if (event.button !== 0 || !rowTarget(event)) return;
event.preventDefault(); event.preventDefault();
if (!carryRef.current) armListCarryRef.current?.(event);
} }
node.addEventListener("pointerdown", onPointerDownCapture, true); node.addEventListener("pointerdown", onPointerDownCapture, true);
node.addEventListener("mousedown", blockRowMouseDown, true); node.addEventListener("mousedown", blockRowMouseDown, true);
@@ -1213,7 +1219,7 @@ export function ContentBoard({
node.removeEventListener("dragover", place); node.removeEventListener("dragover", place);
node.removeEventListener("drop", drop); node.removeEventListener("drop", drop);
}; };
}, []); }, [canEdit, picking, source.length]);
async function saveMode(mode, nextDirection, nextView = viewMode) { async function saveMode(mode, nextDirection, nextView = viewMode) {
setError(""); setError("");
@@ -1598,9 +1604,10 @@ export function ContentBoard({
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
const opener = target.closest("a.preview-row__title, a.preview-row__text, .use-chip__title"); const opener = target.closest("a.preview-row__title, a.preview-row__text, .use-chip__title");
const sourceRow = target.closest(".preview-row");
const carried = { const carried = {
...payload, ...payload,
pointerId: event.pointerId, pointerId: event.pointerId ?? 1,
anchorX: event.clientX, anchorX: event.clientX,
anchorY: event.clientY, anchorY: event.clientY,
lastX: event.clientX, lastX: event.clientX,
@@ -1609,8 +1616,33 @@ export function ContentBoard({
settled: false, settled: false,
useBindingId: "", useBindingId: "",
release: false, release: false,
sourceNode: target.closest(".preview-row, .use-chip") || target, sourceNode: sourceRow || target.closest(".use-chip") || target,
sourceRow,
}; };
function paintAssignTarget(bindingId) {
const root = rootRef.current;
if (!root) return;
root.querySelectorAll(".preview-row.is-assign-target").forEach((row) => row.classList.remove("is-assign-target"));
if (!bindingId) return;
root.querySelector(`.preview-row[data-binding="${bindingId}"]`)?.classList.add("is-assign-target");
}
function beginCarryMotion() {
document.body.classList.add("is-carrying");
if (carried.source === "list") {
document.body.classList.add("is-list-carry");
carried.sourceRow?.classList.add("is-carry-source");
}
setCarrying({
source: carried.source,
bindingId: carried.bindingId || "",
hostBindingId: carried.hostBindingId || "",
});
}
function clearCarryMotion() {
paintAssignTarget("");
document.body.classList.remove("is-carrying", "is-assigning", "is-list-intent", "is-list-carry");
carried.sourceRow?.classList.remove("is-carry-source");
}
function blockBrowserGesture(native) { function blockBrowserGesture(native) {
native.preventDefault(); native.preventDefault();
} }
@@ -1664,6 +1696,7 @@ export function ContentBoard({
carried.release = false; carried.release = false;
carried.place = false; carried.place = false;
carried.chapterId = ""; carried.chapterId = "";
paintAssignTarget(found.useId);
setIndicator({ kind: "use", bindingId: found.useId }); setIndicator({ kind: "use", bindingId: found.useId });
return; return;
} }
@@ -1672,11 +1705,13 @@ export function ContentBoard({
carried.release = true; carried.release = true;
carried.place = Boolean(found.place); carried.place = Boolean(found.place);
carried.chapterId = found.chapterId || ""; carried.chapterId = found.chapterId || "";
paintAssignTarget("");
setIndicator({ kind: "release", place: carried.place, chapterId: carried.chapterId, title: found.title || "" }); setIndicator({ kind: "release", place: carried.place, chapterId: carried.chapterId, title: found.title || "" });
return; return;
} }
if (sticky && carried.useBindingId && !(x || y)) { if (sticky && carried.useBindingId && !(x || y)) {
carried.release = false; carried.release = false;
paintAssignTarget(carried.useBindingId);
setIndicator({ kind: "use", bindingId: carried.useBindingId }); setIndicator({ kind: "use", bindingId: carried.useBindingId });
return; return;
} }
@@ -1684,41 +1719,56 @@ export function ContentBoard({
carried.release = false; carried.release = false;
carried.place = false; carried.place = false;
carried.chapterId = ""; carried.chapterId = "";
paintAssignTarget("");
setIndicator(null); setIndicator(null);
} }
function cleanup() { function cleanup() {
window.removeEventListener("pointermove", track, true); window.removeEventListener("pointermove", track, true);
window.removeEventListener("pointerup", finish, true); window.removeEventListener("pointerup", finish, true);
window.removeEventListener("mousemove", onMouseMove, true);
window.removeEventListener("mouseup", onMouseUp, true);
window.removeEventListener("mousedown", blockBrowserGesture, true); window.removeEventListener("mousedown", blockBrowserGesture, true);
window.removeEventListener("dragstart", blockBrowserGesture, true); window.removeEventListener("dragstart", onDragStart, true);
window.removeEventListener("dragend", onDragEnd, true); window.removeEventListener("dragend", onDragEnd, true);
window.removeEventListener("selectstart", blockBrowserGesture, true); window.removeEventListener("selectstart", blockBrowserGesture, true);
try { carried.captureNode?.releasePointerCapture?.(carried.pointerId); } catch { /* already released */ } clearCarryMotion();
try { carried.sourceNode?.releasePointerCapture?.(carried.pointerId); } catch { /* already released */ }
document.body.classList.remove("is-carrying", "is-assigning");
if (carryRef.current === carried) carryRef.current = null; if (carryRef.current === carried) carryRef.current = null;
setCarrying(null); setCarrying(null);
setIndicator(null); setIndicator(null);
} }
function track(pointer) { function noteMove(x, y) {
if (carryRef.current !== carried || (pointer.pointerId !== carried.pointerId && pointer.pointerId !== 0)) return; if (x || y) {
if (pointer.clientX || pointer.clientY) { carried.lastX = x;
carried.lastX = pointer.clientX; carried.lastY = y;
carried.lastY = pointer.clientY;
} }
if (!carried.moved && Math.hypot(carried.lastX - carried.anchorX, carried.lastY - carried.anchorY) > 4) { if (!carried.moved && Math.hypot(carried.lastX - carried.anchorX, carried.lastY - carried.anchorY) > 3) {
carried.moved = true; carried.moved = true;
if (carried.sourceNode) carried.sourceNode.dataset.dragged = "1"; if (carried.sourceNode) carried.sourceNode.dataset.dragged = "1";
document.body.classList.add("is-carrying"); beginCarryMotion();
setCarrying({
source: carried.source,
bindingId: carried.bindingId || "",
hostBindingId: carried.hostBindingId || "",
});
} }
if (!carried.moved) return; if (!carried.moved) return false;
pointer.preventDefault();
remember(carried.lastX, carried.lastY, false); remember(carried.lastX, carried.lastY, false);
return true;
}
function track(pointer) {
if (carryRef.current !== carried || (pointer.pointerId !== carried.pointerId && pointer.pointerId !== 0)) return;
if (noteMove(pointer.clientX, pointer.clientY)) pointer.preventDefault();
}
function onMouseMove(native) {
if (carryRef.current !== carried) return;
if (noteMove(native.clientX, native.clientY)) native.preventDefault();
}
function onMouseUp(native) {
if (carryRef.current !== carried) return;
finish({ pointerId: carried.pointerId, clientX: native.clientX, clientY: native.clientY });
}
function onDragStart(native) {
native.preventDefault();
if (!carried.moved) {
carried.moved = true;
if (carried.sourceNode) carried.sourceNode.dataset.dragged = "1";
beginCarryMotion();
}
} }
function finish(pointer) { function finish(pointer) {
if (pointer && pointer.pointerId !== carried.pointerId && pointer.pointerId !== 0) return; if (pointer && pointer.pointerId !== carried.pointerId && pointer.pointerId !== 0) return;
@@ -1766,16 +1816,16 @@ export function ContentBoard({
cleanup(); cleanup();
}; };
carryRef.current = carried; carryRef.current = carried;
const captureNode = target;
carried.captureNode = captureNode || null;
try { captureNode?.setPointerCapture?.(event.pointerId); } catch { /* the window listeners still follow the pointer */ }
document.body.classList.add("is-assigning"); document.body.classList.add("is-assigning");
if (carried.source === "list") document.body.classList.add("is-list-intent");
window.addEventListener("mousedown", blockBrowserGesture, true); window.addEventListener("mousedown", blockBrowserGesture, true);
window.addEventListener("dragstart", blockBrowserGesture, true); window.addEventListener("dragstart", onDragStart, true);
window.addEventListener("dragend", onDragEnd, true); window.addEventListener("dragend", onDragEnd, true);
window.addEventListener("selectstart", blockBrowserGesture, true); window.addEventListener("selectstart", blockBrowserGesture, true);
window.addEventListener("pointermove", track, true); window.addEventListener("pointermove", track, true);
window.addEventListener("pointerup", finish, true); window.addEventListener("pointerup", finish, true);
window.addEventListener("mousemove", onMouseMove, true);
window.addEventListener("mouseup", onMouseUp, true);
} }
armListCarryRef.current = (event) => { armListCarryRef.current = (event) => {
@@ -1995,7 +2045,7 @@ export function ContentBoard({
} }
return ( return (
<div className={carrying ? `contents is-carrying${carrying.source === "list" ? " is-list-carry" : ""}` : "contents"} ref={rootRef}> <div className="contents" ref={rootRef}>
{carrying && (carrying.source === "attachment" || carrying.source === "evidence") ? ( {carrying && (carrying.source === "attachment" || carrying.source === "evidence") ? (
<div className={indicator?.kind === "release" && !indicator.place ? "release-lane is-hot" : "release-lane"} data-release-drop="1"> <div className={indicator?.kind === "release" && !indicator.place ? "release-lane is-hot" : "release-lane"} data-release-drop="1">
{indicator?.kind === "release" && indicator.place && indicator.title ? `In ${indicator.title} legen` : "In den Vorgang legen"} {indicator?.kind === "release" && indicator.place && indicator.title ? `In ${indicator.title} legen` : "In den Vorgang legen"}
@@ -2258,7 +2308,7 @@ export function ContentBoard({
: binding.origin && !section.title : binding.origin && !section.title
? `${binding.origin}${binding.shared ? " · weitere Einbindung" : ""}` ? `${binding.origin}${binding.shared ? " · weitere Einbindung" : ""}`
: ""; : "";
const assignDropId = canEdit && (!carrying || (binding.id !== carrying.bindingId && binding.id !== carrying.hostBindingId)) ? binding.id : ""; const assignDropId = canEdit ? binding.id : "";
const rowClass = [ const rowClass = [
"preview-row", "preview-row",
draggingId === binding.id ? "is-dragging" : "", draggingId === binding.id ? "is-dragging" : "",
@@ -2284,6 +2334,7 @@ export function ContentBoard({
<li <li
key={binding.id} key={binding.id}
data-binding={binding.id} data-binding={binding.id}
data-assign-drop={assignDropId || undefined}
className={rowClass} className={rowClass}
onPointerDown={(event) => { onPointerDown={(event) => {
if (!canEdit || pending || picking || event.button !== 0) return; if (!canEdit || pending || picking || event.button !== 0) return;
+8 -2
View File
@@ -1372,8 +1372,14 @@ body.is-carrying .entry-mark[data-assign-drop] {
outline: 2px solid var(--accent); outline: 2px solid var(--accent);
outline-offset: 2px; outline-offset: 2px;
} }
.contents.is-list-carry .preview-row:not(.is-carry-source) .entry-mark[data-assign-drop], body.is-list-intent .preview-row:not(.is-carry-source)[data-assign-drop],
.contents.is-list-carry .preview-row:not(.is-carry-source) .preview-row__body[data-assign-drop] { body.is-list-intent .preview-row:not(.is-carry-source) .entry-mark[data-assign-drop],
body.is-list-intent .preview-row:not(.is-carry-source) .preview-row__body[data-assign-drop] {
box-shadow: inset 0 0 0 2px var(--accent);
}
body.is-list-carry .preview-row:not(.is-carry-source)[data-assign-drop],
body.is-list-carry .preview-row:not(.is-carry-source) .entry-mark[data-assign-drop],
body.is-list-carry .preview-row:not(.is-carry-source) .preview-row__body[data-assign-drop] {
box-shadow: inset 0 0 0 2px var(--accent); box-shadow: inset 0 0 0 2px var(--accent);
} }
.preview-row.is-assign-target { background: var(--accent-light); } .preview-row.is-assign-target { background: var(--accent-light); }