diff --git a/frontend/src/pages/content.jsx b/frontend/src/pages/content.jsx index fdeac18..b637e82 100644 --- a/frontend/src/pages/content.jsx +++ b/frontend/src/pages/content.jsx @@ -958,7 +958,6 @@ export function ContentBoard({ const [pickTarget, setPickTarget] = useState(""); const dragRef = useRef(null); const carryRef = useRef(null); - const armListCarryRef = useRef(null); const releaseRef = useRef(null); const placeUseRef = useRef(null); const rootRef = useRef(null); @@ -1201,21 +1200,14 @@ export function ContentBoard({ if (target.closest("button, input, textarea, select, label, .direction-column, .preview-row__actions, .handle, .row-menu")) return null; return target; } - function onPointerDownCapture(event) { - if (!rowTarget(event)) return; - armListCarryRef.current?.(event); - } function blockRowMouseDown(event) { if (event.button !== 0 || !rowTarget(event)) return; event.preventDefault(); - if (!carryRef.current) armListCarryRef.current?.(event); } - node.addEventListener("pointerdown", onPointerDownCapture, true); node.addEventListener("mousedown", blockRowMouseDown, true); node.addEventListener("dragover", place); node.addEventListener("drop", drop); return () => { - node.removeEventListener("pointerdown", onPointerDownCapture, true); node.removeEventListener("mousedown", blockRowMouseDown, true); node.removeEventListener("dragover", place); node.removeEventListener("drop", drop); @@ -1601,7 +1593,7 @@ export function ContentBoard({ function beginCarryPointer(event, payload) { if (carryRef.current || pending || (event.button != null && event.button !== 0)) return; const target = event.target?.nodeType === 1 ? event.target : event.target?.parentElement; - if (!target?.closest || target.closest("button, input, textarea, select, label")) return; + if (!target?.closest || target.closest("button:not(.handle), input, textarea, select, label")) return; event.preventDefault(); event.stopPropagation(); const opener = target.closest("a.preview-row__title, a.preview-row__text, .use-chip__title"); @@ -1712,6 +1704,7 @@ export function ContentBoard({ carried.release = false; carried.place = false; carried.chapterId = ""; + carried.reorderTarget = null; paintAssignTarget(found.useId); setIndicator({ kind: "use", bindingId: found.useId }); return; @@ -1736,6 +1729,14 @@ export function ContentBoard({ carried.place = false; carried.chapterId = ""; paintAssignTarget(""); + if (carried.reorder) { + const sectionId = sectionUnder(y) || carried.reorder.sectionId; + const index = indexAt(sectionId, y); + carried.reorderTarget = { sectionId, index }; + setIndicator({ sectionId, index, kind: "order" }); + return; + } + carried.reorderTarget = null; setIndicator(null); } function cleanup() { @@ -1813,6 +1814,16 @@ export function ContentBoard({ placeUseRef.current?.(useId, carried); return; } + if (carried.reorder && carried.reorderTarget?.index != null) { + finishDrag({ + bindingId: carried.reorder.bindingId, + sectionId: carried.reorder.sectionId, + targetSectionId: carried.reorderTarget.sectionId, + index: carried.reorderTarget.index, + moved: true, + }); + return; + } if (release && (carried.source === "attachment" || carried.source === "evidence")) { releaseRef.current?.({ ...carried, place: carried.place, chapterId: carried.chapterId }); } @@ -1844,22 +1855,6 @@ export function ContentBoard({ window.addEventListener("mouseup", onMouseUp, true); } - armListCarryRef.current = (event) => { - if (carryRef.current || !canEdit || pending || picking) return; - const target = event.target?.nodeType === 1 ? event.target : event.target?.parentElement; - const row = target?.closest?.("li.preview-row"); - if (!row) return; - if (target.closest(".use-chip, .unit-detail")) return; - const binding = source.find((item) => item.id === row.getAttribute("data-binding")); - if (!binding?.element) return; - beginCarryPointer(event, { - source: "list", - elementId: binding.element.id, - bindingId: binding.id, - title: binding.element.title, - }); - }; - function bindingByElement(elementId) { return source.find((item) => item.element?.id === elementId) || null; } @@ -2332,7 +2327,7 @@ export function ContentBoard({ selectedId === binding.id ? "is-selected" : "", picking && picked.has(binding.id) ? "is-picked" : "", picking ? "preview-row--picking" : "", - canSort && custom ? "preview-row--ordered" : "", + (canEdit || (canSort && custom)) ? "preview-row--ordered" : "", ].filter(Boolean).join(" "); function openFromList(event) { const row = event.currentTarget.closest(".preview-row"); @@ -2350,16 +2345,6 @@ export function ContentBoard({ key={binding.id} data-binding={binding.id} className={rowClass} - onPointerDown={(event) => { - if (!canEdit || pending || picking || event.button !== 0) return; - if (event.target.closest("button, input, textarea, select, label, .use-chip, .unit-detail, .entry-mark")) return; - beginCarryPointer(event, { - source: "list", - elementId: element.id, - bindingId: binding.id, - title: element.title, - }); - }} > {indicator?.kind === "order" && indicator?.sectionId === section.id && indicator.index === index ?
: null} {picking ? ( @@ -2387,16 +2372,30 @@ export function ContentBoard({ ) : (