editate 0.6.11 → 0.6.12

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/lib/doc/node.d.ts CHANGED
@@ -1,3 +1,8 @@
1
- import { BlockNode, DocNode, Node, DomPosition } from './types.js';
1
+ import { BlockNode, DocNode, InlineNode, Node, Path, DomPosition } from './types.js';
2
2
  export declare const getNodeSize: (node: Node) => number;
3
+ export declare const getChildAt: <T extends BlockNode>({ children }: T, offset: number) => [node: T["children"][number], offset: number, index: number] | null;
4
+ export declare const getBlockAt: (node: DocNode | BlockNode, offset: number) => [node: BlockNode, offset: number, path: Path];
5
+ export declare const getLeafAt: (node: DocNode | BlockNode, offset: number) => [node: InlineNode, offset: number] | null;
3
6
  export declare const offsetToPosition: (node: DocNode | BlockNode, offset: number) => DomPosition;
7
+ export declare function iterNode<T extends Node>(node: T, start: number, end: number): Generator<[node: Node, offset: number], void, void>;
8
+ export declare function iterLeaf<T extends Node>(node: T, start: number, end: number): Generator<[node: InlineNode, offset: number], void, void>;
@@ -23,13 +23,13 @@ type FormatOperation = Readonly<{
23
23
  key: string;
24
24
  value: unknown;
25
25
  }>;
26
- declare const OP_SET_NODE_ATTR = "set_node_attr";
27
- type SetNodeAttrOperation = Readonly<{
28
- type: typeof OP_SET_NODE_ATTR;
26
+ declare const OP_PATCH_NODE = "patch_node";
27
+ type PatchNodeOperation = Readonly<{
28
+ type: typeof OP_PATCH_NODE;
29
29
  path: Path;
30
30
  key: string;
31
31
  value: unknown;
32
32
  }>;
33
- export type Operation = DeleteOperation | InsertTextOperation | InsertNodeOperation | FormatOperation | SetNodeAttrOperation;
33
+ export type Operation = DeleteOperation | InsertTextOperation | InsertNodeOperation | FormatOperation | PatchNodeOperation;
34
34
  export declare const rebase: (position: number, ops: readonly Operation[]) => number;
35
35
  export {};
@@ -1,13 +1,12 @@
1
- import { DocNode, Node, TextNode } from './types.js';
2
- type Flatten<T> = T extends any ? T : never;
3
- export type InferBlockNode<T extends Node> = Flatten<T extends {
1
+ import { Node, TextNode } from './types.js';
2
+ export type InferBlockNode<T extends Node> = T extends {
4
3
  children: readonly (infer N extends Node)[];
5
- } ? T | InferBlockNode<N> : never>;
6
- export type InferInlineNode<T extends Node> = Flatten<T extends {
4
+ } ? T | InferBlockNode<N> : never;
5
+ export type InferInlineNode<T extends Node> = T extends {
7
6
  children: readonly (infer N extends Node)[];
8
- } ? InferInlineNode<N> : T>;
9
- export type InferVoidNode<T extends DocNode> = Exclude<InferInlineNode<T>, TextNode>;
10
- export type InferTextNode<T extends DocNode> = Extract<InferInlineNode<T>, TextNode>;
7
+ } ? InferInlineNode<N> : T;
8
+ export type InferVoidNode<T extends Node> = Exclude<InferInlineNode<T>, TextNode>;
9
+ export type InferTextNode<T extends Node> = Extract<InferInlineNode<T>, TextNode>;
11
10
  type FlattenAllNodes<T extends Node> = T extends any ? T | (T extends {
12
11
  children: readonly (infer N extends Node)[];
13
12
  } ? FlattenAllNodes<N> : never) : never;