@sobree/core 0.1.24 → 0.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,37 @@
1
+ import { Selection } from '../doc/api';
1
2
  /**
2
- * History config + depth shape. Phase 1b.6+ backed by Y.UndoManager;
3
- * the snapshot-specific types (HistoryEntry, SnapshotPosition,
4
- * SnapshotSelection) that lived here in Phase 1a are no longer needed.
3
+ * Selection inside an editable textbox frame. Frame bodies aren't body
4
+ * registry blocks, so the public `Selection` model can't address them —
5
+ * but undo/redo still needs to put the caret (or range) back. The editor
6
+ * captures this on a frame edit and restores it on undo, exactly as it
7
+ * does the body `Selection`; `History` treats the stashed value as opaque.
8
+ * A collapsed caret has `start === end`.
5
9
  */
10
+ export interface FrameSelection {
11
+ kind: "frame-selection";
12
+ /** `data-anchor-id` of the frame the selection was in. */
13
+ frameId: string;
14
+ /** Character offset of the selection start across the frame's text. */
15
+ start: number;
16
+ /** Character offset of the selection end (=== start for a caret). */
17
+ end: number;
18
+ }
19
+ /**
20
+ * What the editor stashes for an undo step: a body `Selection` (incl.
21
+ * `null` when focus is outside) or a {@link FrameSelection}. Restored
22
+ * verbatim on undo/redo so the cursor lands where the body's would.
23
+ */
24
+ export type CapturedSelection = Selection | FrameSelection;
25
+ /**
26
+ * Both ends of an undo step's cursor: where it sat BEFORE the edit and
27
+ * AFTER it. Undo restores `before` (you land where you started the edit);
28
+ * redo restores `after` (you land where the edit left you) — Word/Docs
29
+ * behaviour. Stashed on each `Y.UndoManager` stack item's meta.
30
+ */
31
+ export interface UndoSelections {
32
+ before: CapturedSelection;
33
+ after: CapturedSelection;
34
+ }
6
35
  export interface HistoryConfig {
7
36
  /** Hard cap on entry count (per stack). UndoManager doesn't expose
8
37
  * a max-depth knob directly — kept here for forward-compat in case