Ordne Dokumente nur am Dokument-Symbol zu und halte das Ablageziel beim Loslassen fest.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
e3274bce21
commit
a5350bc76e
2 files changed
+48
-24
No files matched your search
@@ -905,6 +905,7 @@ function EntryMark({ element, context, assignable = false, dropId = "", hot = fa
|
|||||||
<TypeGlyph name="image" tone="dark" size={14} />
|
<TypeGlyph name="image" tone="dark" size={14} />
|
||||||
</span>
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
|
{dropId ? <span className="entry-mark__drop" aria-hidden="true" /> : null}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1113,9 +1114,9 @@ export function ContentBoard({
|
|||||||
carried.moved = true;
|
carried.moved = true;
|
||||||
document.body.classList.add("is-carrying");
|
document.body.classList.add("is-carrying");
|
||||||
}
|
}
|
||||||
const mark = event.target?.closest?.("[data-assign-drop]");
|
const mark = event.target?.closest?.(".entry-mark[data-assign-drop]");
|
||||||
const useId = mark?.getAttribute("data-assign-drop") || "";
|
const useId = mark?.getAttribute("data-assign-drop") || "";
|
||||||
const blocked = !useId || useId === carried.bindingId || useId === carried.hostBindingId || carried.sourceNode?.contains(mark);
|
const blocked = !useId || useId === carried.bindingId || useId === carried.hostBindingId || carried.sourceRow?.contains(mark);
|
||||||
if (!blocked) {
|
if (!blocked) {
|
||||||
carried.useBindingId = useId;
|
carried.useBindingId = useId;
|
||||||
carried.release = false;
|
carried.release = false;
|
||||||
@@ -1169,10 +1170,10 @@ export function ContentBoard({
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (carried.settled) return;
|
if (carried.settled) return;
|
||||||
carried.settled = true;
|
carried.settled = true;
|
||||||
const mark = event.target?.closest?.("[data-assign-drop]");
|
const mark = event.target?.closest?.(".entry-mark[data-assign-drop]");
|
||||||
const useId = mark?.getAttribute("data-assign-drop") || "";
|
const useId = mark?.getAttribute("data-assign-drop") || "";
|
||||||
const section = event.target?.closest?.("[data-section]");
|
const section = event.target?.closest?.("[data-section]");
|
||||||
const assign = useId && useId !== carried.bindingId && useId !== carried.hostBindingId && !carried.sourceNode?.contains(mark);
|
const assign = useId && useId !== carried.bindingId && useId !== carried.hostBindingId && !carried.sourceRow?.contains(mark);
|
||||||
carryRef.current = null;
|
carryRef.current = null;
|
||||||
setIndicator(null);
|
setIndicator(null);
|
||||||
setCarrying(null);
|
setCarrying(null);
|
||||||
@@ -1623,8 +1624,15 @@ export function ContentBoard({
|
|||||||
const root = rootRef.current;
|
const root = rootRef.current;
|
||||||
if (!root) return;
|
if (!root) return;
|
||||||
root.querySelectorAll(".preview-row.is-assign-target").forEach((row) => row.classList.remove("is-assign-target"));
|
root.querySelectorAll(".preview-row.is-assign-target").forEach((row) => row.classList.remove("is-assign-target"));
|
||||||
|
root.querySelectorAll(".entry-mark.is-assign-hot").forEach((mark) => mark.classList.remove("is-assign-hot"));
|
||||||
if (!bindingId) return;
|
if (!bindingId) return;
|
||||||
root.querySelector(`.preview-row[data-binding="${bindingId}"]`)?.classList.add("is-assign-target");
|
const row = root.querySelector(`.preview-row[data-binding="${bindingId}"]`);
|
||||||
|
if (!row) return;
|
||||||
|
if (carried.source === "list") {
|
||||||
|
row.querySelector(":scope > .entry-mark")?.classList.add("is-assign-hot");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
row.classList.add("is-assign-target");
|
||||||
}
|
}
|
||||||
function beginCarryMotion() {
|
function beginCarryMotion() {
|
||||||
document.body.classList.add("is-carrying");
|
document.body.classList.add("is-carrying");
|
||||||
@@ -1649,26 +1657,34 @@ export function ContentBoard({
|
|||||||
function assignIdAt(x, y) {
|
function assignIdAt(x, y) {
|
||||||
const root = rootRef.current;
|
const root = rootRef.current;
|
||||||
if (!root) return "";
|
if (!root) return "";
|
||||||
const marks = root.querySelectorAll("[data-assign-drop]");
|
const marks = carried.source === "list"
|
||||||
|
? root.querySelectorAll(".preview-row:not(.is-carry-source) > .entry-mark[data-assign-drop]")
|
||||||
|
: root.querySelectorAll(".entry-mark[data-assign-drop]");
|
||||||
|
let best = "";
|
||||||
|
let bestArea = Number.POSITIVE_INFINITY;
|
||||||
for (const mark of marks) {
|
for (const mark of marks) {
|
||||||
if (carried.sourceNode?.contains(mark)) continue;
|
if (carried.sourceRow?.contains(mark)) continue;
|
||||||
const rect = mark.getBoundingClientRect();
|
const rect = mark.getBoundingClientRect();
|
||||||
if (rect.width < 1 || rect.height < 1) continue;
|
if (rect.width < 1 || rect.height < 1) continue;
|
||||||
if (x < rect.left || x > rect.right || y < rect.top || y > rect.bottom) continue;
|
if (x < rect.left || x > rect.right || y < rect.top || y > rect.bottom) continue;
|
||||||
const useId = mark.getAttribute("data-assign-drop") || "";
|
const useId = mark.getAttribute("data-assign-drop") || "";
|
||||||
if (!useId || useId === carried.bindingId || useId === carried.hostBindingId) continue;
|
if (!useId || useId === carried.bindingId || useId === carried.hostBindingId) continue;
|
||||||
return useId;
|
const area = rect.width * rect.height;
|
||||||
|
if (area < bestArea) {
|
||||||
|
best = useId;
|
||||||
|
bestArea = area;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return best;
|
||||||
}
|
}
|
||||||
function hitAt(x, y) {
|
function hitAt(x, y) {
|
||||||
const direct = assignIdAt(x, y);
|
const direct = assignIdAt(x, y);
|
||||||
if (direct) return { useId: direct };
|
if (direct) return { useId: direct };
|
||||||
const nodes = document.elementsFromPoint(x, y);
|
const nodes = document.elementsFromPoint(x, y);
|
||||||
for (const node of nodes) {
|
for (const node of nodes) {
|
||||||
if (carried.sourceNode?.contains(node)) continue;
|
if (carried.sourceRow?.contains(node)) continue;
|
||||||
const mark = node.closest?.("[data-assign-drop]");
|
const mark = node.closest?.(".entry-mark[data-assign-drop]");
|
||||||
if (!mark || carried.sourceNode?.contains(mark)) continue;
|
if (!mark || carried.sourceRow?.contains(mark)) continue;
|
||||||
const useId = mark.getAttribute("data-assign-drop") || "";
|
const useId = mark.getAttribute("data-assign-drop") || "";
|
||||||
if (!useId || useId === carried.bindingId || useId === carried.hostBindingId) continue;
|
if (!useId || useId === carried.bindingId || useId === carried.hostBindingId) continue;
|
||||||
return { useId };
|
return { useId };
|
||||||
@@ -1709,7 +1725,7 @@ export function ContentBoard({
|
|||||||
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) {
|
||||||
carried.release = false;
|
carried.release = false;
|
||||||
paintAssignTarget(carried.useBindingId);
|
paintAssignTarget(carried.useBindingId);
|
||||||
setIndicator({ kind: "use", bindingId: carried.useBindingId });
|
setIndicator({ kind: "use", bindingId: carried.useBindingId });
|
||||||
@@ -2313,7 +2329,6 @@ export function ContentBoard({
|
|||||||
"preview-row",
|
"preview-row",
|
||||||
draggingId === binding.id ? "is-dragging" : "",
|
draggingId === binding.id ? "is-dragging" : "",
|
||||||
carrying && (binding.id === carrying.bindingId || binding.id === carrying.hostBindingId) ? "is-carry-source" : "",
|
carrying && (binding.id === carrying.bindingId || binding.id === carrying.hostBindingId) ? "is-carry-source" : "",
|
||||||
indicator?.kind === "use" && indicator.bindingId === binding.id ? "is-assign-target" : "",
|
|
||||||
selectedId === binding.id ? "is-selected" : "",
|
selectedId === binding.id ? "is-selected" : "",
|
||||||
picking && picked.has(binding.id) ? "is-picked" : "",
|
picking && picked.has(binding.id) ? "is-picked" : "",
|
||||||
picking ? "preview-row--picking" : "",
|
picking ? "preview-row--picking" : "",
|
||||||
@@ -2334,7 +2349,6 @@ 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;
|
||||||
@@ -2437,7 +2451,7 @@ export function ContentBoard({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{(switches, lists) => (
|
{(switches, lists) => (
|
||||||
<div className="preview-row__body" data-assign-drop={assignDropId || undefined}>
|
<div className="preview-row__body">
|
||||||
<div className="preview-row__headline">
|
<div className="preview-row__headline">
|
||||||
<Link
|
<Link
|
||||||
className="preview-row__title"
|
className="preview-row__title"
|
||||||
|
|||||||
+18
-8
@@ -1372,18 +1372,28 @@ body.is-carrying .entry-mark[data-assign-drop] {
|
|||||||
outline: 2px solid var(--accent);
|
outline: 2px solid var(--accent);
|
||||||
outline-offset: 2px;
|
outline-offset: 2px;
|
||||||
}
|
}
|
||||||
body.is-list-intent .preview-row:not(.is-carry-source)[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) .entry-mark[data-assign-drop],
|
body.is-list-carry .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] {
|
z-index: 2;
|
||||||
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-intent .preview-row:not(.is-carry-source) > .entry-mark[data-assign-drop] .entry-mark__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) > .entry-mark[data-assign-drop] .entry-mark__drop {
|
||||||
body.is-list-carry .preview-row:not(.is-carry-source) .preview-row__body[data-assign-drop] {
|
display: block;
|
||||||
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); }
|
||||||
.entry-mark.is-assign-hot { background: var(--accent-light); }
|
.entry-mark.is-assign-hot { background: var(--accent-light); }
|
||||||
|
.entry-mark__drop {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
inset: -6px;
|
||||||
|
border: 2px dashed var(--accent);
|
||||||
|
border-radius: 12px;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
.entry-mark.is-assign-hot .entry-mark__drop {
|
||||||
|
border-style: solid;
|
||||||
|
background: var(--accent-light);
|
||||||
|
}
|
||||||
.preview-row__title, .preview-row__text { touch-action: none; }
|
.preview-row__title, .preview-row__text { touch-action: none; }
|
||||||
.content-section.is-release-target {
|
.content-section.is-release-target {
|
||||||
background: var(--accent-light);
|
background: var(--accent-light);
|
||||||
|
|||||||
Reference in new issue
Block a user