editate 0.6.11 → 0.6.13
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/commands.d.ts +1 -1
- package/lib/doc/node.d.ts +6 -1
- package/lib/doc/operation.d.ts +4 -4
- package/lib/doc/types-infer.d.ts +7 -8
- package/lib/doc/types.d.ts +3 -6
- package/lib/dom/index.d.ts +3 -0
- package/lib/index.cjs +449 -420
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +451 -421
- package/lib/index.js.map +1 -1
- package/lib/keyboard.d.ts +1 -1
- package/lib/plugins/index.d.ts +1 -0
- package/lib/plugins/keymap.d.ts +1 -1
- package/lib/plugins/selectionRect.d.ts +5 -0
- package/package.json +2 -1
package/lib/commands.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare function InsertNode<T extends DocNode>(editor: Editor<T>, node: I
|
|
|
16
16
|
/**
|
|
17
17
|
* Replace text in the selection or specified range.
|
|
18
18
|
*/
|
|
19
|
-
export declare function ReplaceText(editor: Editor, text: string): void;
|
|
19
|
+
export declare function ReplaceText(editor: Editor, text: string, range?: Range): void;
|
|
20
20
|
/**
|
|
21
21
|
* Replace document in the editor.
|
|
22
22
|
*/
|
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>;
|
package/lib/doc/operation.d.ts
CHANGED
|
@@ -23,13 +23,13 @@ type FormatOperation = Readonly<{
|
|
|
23
23
|
key: string;
|
|
24
24
|
value: unknown;
|
|
25
25
|
}>;
|
|
26
|
-
declare const
|
|
27
|
-
type
|
|
28
|
-
type: typeof
|
|
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 |
|
|
33
|
+
export type Operation = DeleteOperation | InsertTextOperation | InsertNodeOperation | FormatOperation | PatchNodeOperation;
|
|
34
34
|
export declare const rebase: (position: number, ops: readonly Operation[]) => number;
|
|
35
35
|
export {};
|
package/lib/doc/types-infer.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type
|
|
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> =
|
|
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
|
|
10
|
-
export type InferTextNode<T extends
|
|
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;
|
package/lib/doc/types.d.ts
CHANGED
|
@@ -9,14 +9,11 @@ export interface BlockNode {
|
|
|
9
9
|
}
|
|
10
10
|
export type Node = BlockNode | InlineNode;
|
|
11
11
|
export interface DocNode {
|
|
12
|
-
readonly children: readonly BlockNode[];
|
|
12
|
+
readonly children: readonly BlockNode[] | readonly InlineNode[];
|
|
13
13
|
}
|
|
14
14
|
export type Fragment = DocNode["children"];
|
|
15
15
|
export type Path = readonly number[];
|
|
16
|
-
export type DomPosition = readonly [path: Path, offset: number];
|
|
17
16
|
export type Range = readonly [start: number, end: number];
|
|
18
17
|
export type Selection = readonly [anchor: number, focus: number];
|
|
19
|
-
export type
|
|
20
|
-
|
|
21
|
-
focus: DomPosition
|
|
22
|
-
];
|
|
18
|
+
export type DomPosition = readonly [path: Path, offset: number];
|
|
19
|
+
export type DomSelection = readonly [anchor: DomPosition, focus: DomPosition];
|
package/lib/dom/index.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { Parser } from './parser.js';
|
|
2
|
+
import { DomSelection } from '../doc/types.js';
|
|
1
3
|
export { createParser, TOKEN_TEXT, TOKEN_VOID, TOKEN_SOFT_BREAK, TOKEN_BLOCK, } from './parser.js';
|
|
2
4
|
export { defaultIsBlockNode } from './default.js';
|
|
5
|
+
export declare const selectionToRange: (root: Element, parse: Parser, [anchor, focus]: DomSelection, posDiff: number) => Range;
|