@sobree/core 0.1.31 → 0.1.32

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.
@@ -8,6 +8,17 @@ import { BlockRegistry } from './blockRegistry';
8
8
  * `offset = 0` — block-internal table addressing is a future extension.
9
9
  */
10
10
  export declare function positionFromDomPoint(hosts: readonly HTMLElement[], registry: BlockRegistry, node: Node, domOffset: number): InlinePosition | null;
11
+ /**
12
+ * Registry-free `(node, offset)` → block descriptor (`blockId` + offset, plus a
13
+ * cell address inside a table). The id-based core of {@link positionFromDomPoint},
14
+ * also used to save/restore a selection across a DOM rebuild (repagination)
15
+ * where raw node references don't survive.
16
+ */
17
+ interface BlockPoint {
18
+ blockId: string;
19
+ offset: number;
20
+ cell?: CellAddress;
21
+ }
11
22
  /** Build an API `Range` from a live DOM `Range`. */
12
23
  export declare function rangeFromDomRange(hosts: readonly HTMLElement[], registry: BlockRegistry, range: Range): ApiRange | null;
13
24
  /** Read `window.getSelection()` as a model `Selection`. */
@@ -21,6 +32,15 @@ export declare function domPointFromPosition(hosts: readonly HTMLElement[], pos:
21
32
  } | null;
22
33
  /** Apply a model `Selection` to `window.getSelection()`. */
23
34
  export declare function applySelectionToDom(hosts: readonly HTMLElement[], selection: Selection): boolean;
35
+ export interface SelectionDescriptor {
36
+ start: BlockPoint;
37
+ end: BlockPoint;
38
+ collapsed: boolean;
39
+ }
40
+ /** Capture the live selection as a {@link SelectionDescriptor}, or null. */
41
+ export declare function captureSelectionDescriptor(hosts: readonly HTMLElement[]): SelectionDescriptor | null;
42
+ /** Restore a {@link SelectionDescriptor} to the live DOM (after a rebuild). */
43
+ export declare function applySelectionDescriptor(hosts: readonly HTMLElement[], desc: SelectionDescriptor | null): boolean;
24
44
  /** Total character-count length of a block, per the counting rules above. */
25
45
  export declare function blockLength(blockEl: Element): number;
26
46
  /** The DOM element for body block `index` via the positional `data-block-index`
@@ -31,3 +51,5 @@ export declare function blockElementAtIndex(hosts: readonly HTMLElement[], index
31
51
  /** Count distinct blocks in the rendered DOM. Dedups by id so a block split
32
52
  * across a page boundary (two fragments, one id) counts once. */
33
53
  export declare function countBlocks(hosts: readonly HTMLElement[]): number;
54
+ type CellAddress = NonNullable<InlinePosition["cell"]>;
55
+ export {};