Keep marking the copy source's first cell after the selection moves on

Copying a range showed the dashed marquee around the whole source, but the
distinct border on its first (anchor) cell disappeared the moment you
selected something else -- that border was drawn from the *live* selection's
anchor, which had just moved to the new (paste-destination) cell.

- ClipboardData now also stores the copy/cut selection's own anchor -- the
  cell the drag/shift-selection actually started from, which isn't always
  rect's top-left corner (a drag can start at any corner).
- clipboardRect exposes it; TableGrid renders a second small overlay,
  .clip-anchor, positioned on just that one cell -- independent of the
  current selection, so it stays visible for as long as the marquee does.

Verified interactively: copy B2:B5, click a cell elsewhere -- the marquee
and the solid border on B2 both remain, while the new cell gets its own
live-selection border.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
wkh
2026-09-02 10:35:35 +02:00
co-authored by Claude Sonnet 5
parent 47afe8fc20
commit fafb118db6
3 changed files with 56 additions and 2 deletions
+10 -2
View File
@@ -93,6 +93,11 @@ interface ClipboardData {
cells: Map<string, ClipboardCell>;
/** cut (Strg+X) vs. copy (Strg+C) -- a cut buffer is consumed by its first paste. */
cut: boolean;
/** the copy/cut selection's own anchor -- the *first* cell picked, which is
* not necessarily `rect`'s top-left corner (a drag can start anywhere).
* Kept so the source marker can still point it out after the current
* selection has moved elsewhere -- see `clipboardRect`. */
anchor: CellCoord;
}
/**
@@ -884,10 +889,12 @@ function createStore() {
// ---- clipboard (copy / cut / paste) --------------------------
/** True while a copy/cut buffer is held (enables "Einfügen" in menus). */
const hasClipboard = computed(() => clipboard.value !== null);
/** Source rectangle of the current buffer -- drives the dashed source marker. */
/** Source rectangle of the current buffer -- drives the dashed source marker
* and its anchor-cell indicator (which stays put once the live selection
* has moved on to pick a paste destination). */
const clipboardRect = computed(() => {
const cb = clipboard.value;
return cb ? { tableId: cb.tableId, ...cb.rect, cut: cb.cut } : null;
return cb ? { tableId: cb.tableId, ...cb.rect, cut: cb.cut, anchor: cb.anchor } : null;
});
function copyOrCut(cut: boolean) {
@@ -912,6 +919,7 @@ function createStore() {
height: r.r1 - r.r0 + 1,
cells,
cut,
anchor: { ...s.anchor },
};
}
const copySelection = () => copyOrCut(false);