@sobree/core 0.1.30 → 0.1.31
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.
- package/dist/doc/api.d.ts +14 -0
- package/dist/editor/internal/positionMap.d.ts +12 -14
- package/dist/index.js +2138 -2135
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/doc/api.d.ts
CHANGED
|
@@ -50,6 +50,20 @@ export type BlockExpectations = Record<string, number>;
|
|
|
50
50
|
export interface InlinePosition {
|
|
51
51
|
block: BlockRef;
|
|
52
52
|
offset: number;
|
|
53
|
+
/**
|
|
54
|
+
* Set when the position is inside a table cell: the rendered cell address
|
|
55
|
+
* the `offset` is measured within — `row` (the cell's `<tr>` index in the
|
|
56
|
+
* table), `col` (its cell index in that row), `blockIndex` (which content
|
|
57
|
+
* block inside the cell). Absent for ordinary block positions, where
|
|
58
|
+
* `offset` is the character offset into `block` itself. Lets caret capture
|
|
59
|
+
* / restore (e.g. undo) land back in the same cell instead of collapsing to
|
|
60
|
+
* the table boundary.
|
|
61
|
+
*/
|
|
62
|
+
cell?: {
|
|
63
|
+
row: number;
|
|
64
|
+
col: number;
|
|
65
|
+
blockIndex: number;
|
|
66
|
+
};
|
|
53
67
|
}
|
|
54
68
|
/**
|
|
55
69
|
* Inclusive range from `from` to `to` — both inline positions. Single-
|
|
@@ -12,24 +12,22 @@ export declare function positionFromDomPoint(hosts: readonly HTMLElement[], regi
|
|
|
12
12
|
export declare function rangeFromDomRange(hosts: readonly HTMLElement[], registry: BlockRegistry, range: Range): ApiRange | null;
|
|
13
13
|
/** Read `window.getSelection()` as a model `Selection`. */
|
|
14
14
|
export declare function selectionFromDom(hosts: readonly HTMLElement[], registry: BlockRegistry): Selection;
|
|
15
|
-
/** Resolve an `InlinePosition` to a DOM `{ node, offset }` point.
|
|
16
|
-
|
|
15
|
+
/** Resolve an `InlinePosition` to a DOM `{ node, offset }` point. Locates the
|
|
16
|
+
* block by its stable `data-block-id` — robust to paper / column / list
|
|
17
|
+
* nesting, where the block is never a direct host child. */
|
|
18
|
+
export declare function domPointFromPosition(hosts: readonly HTMLElement[], pos: InlinePosition): {
|
|
17
19
|
node: Node;
|
|
18
20
|
offset: number;
|
|
19
21
|
} | null;
|
|
20
22
|
/** Apply a model `Selection` to `window.getSelection()`. */
|
|
21
|
-
export declare function applySelectionToDom(hosts: readonly HTMLElement[],
|
|
23
|
+
export declare function applySelectionToDom(hosts: readonly HTMLElement[], selection: Selection): boolean;
|
|
22
24
|
/** Total character-count length of a block, per the counting rules above. */
|
|
23
25
|
export declare function blockLength(blockEl: Element): number;
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
export declare function countBlocks(hosts: readonly HTMLElement[]): number;
|
|
30
|
-
/**
|
|
31
|
-
* Return the DOM element that hosts a given block index. For list-item
|
|
32
|
-
* blocks this is the `<li>`; for everything else it's the direct host
|
|
33
|
-
* child.
|
|
34
|
-
*/
|
|
26
|
+
/** The DOM element for body block `index` via the positional `data-block-index`
|
|
27
|
+
* stamp. Requires `data-block-id` too, so table cell paragraphs (which carry a
|
|
28
|
+
* cell-internal `data-block-index` but no id) can't shadow a body block. Valid
|
|
29
|
+
* against a freshly-rendered DOM (index === body position). */
|
|
35
30
|
export declare function blockElementAtIndex(hosts: readonly HTMLElement[], index: number): HTMLElement | null;
|
|
31
|
+
/** Count distinct blocks in the rendered DOM. Dedups by id so a block split
|
|
32
|
+
* across a page boundary (two fragments, one id) counts once. */
|
|
33
|
+
export declare function countBlocks(hosts: readonly HTMLElement[]): number;
|