editate 0.6.1 → 0.6.2
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 +3 -3
- package/lib/editor.d.ts +11 -5
- package/lib/index.cjs +197 -192
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +216 -211
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/commands.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Editor } from "./editor.js";
|
|
2
|
-
import type { DocNode, InferBlockNode, InferInlineNode,
|
|
2
|
+
import type { DocNode, InferBlockNode, InferInlineNode, Range, TextNode } from "./doc/types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Delete content in the selection or specified range.
|
|
5
5
|
*/
|
|
@@ -34,9 +34,9 @@ export declare function ToggleFormat<T extends DocNode>(editor: Editor<T>, key:
|
|
|
34
34
|
/**
|
|
35
35
|
* Set attr to a block node at the caret or specified position.
|
|
36
36
|
*/
|
|
37
|
-
export declare function SetBlockAttr<T extends DocNode, N extends InferBlockNode<T>, K extends Extract<keyof N, string>>(editor: Editor<T>, key: K, value: N[K],
|
|
37
|
+
export declare function SetBlockAttr<T extends DocNode, N extends InferBlockNode<T>, K extends Extract<keyof N, string>>(editor: Editor<T>, key: K, value: N[K], offset?: number): void;
|
|
38
38
|
/**
|
|
39
39
|
* Toggle attr of block node at the caret or specified position.
|
|
40
40
|
*/
|
|
41
|
-
export declare function ToggleBlockAttr<T extends DocNode, N extends InferBlockNode<T>, K extends Extract<keyof N, string>>(editor: Editor<T>, key: K, onValue: N[K], offValue: N[K],
|
|
41
|
+
export declare function ToggleBlockAttr<T extends DocNode, N extends InferBlockNode<T>, K extends Extract<keyof N, string>>(editor: Editor<T>, key: K, onValue: N[K], offValue: N[K], offset?: number): void;
|
|
42
42
|
export {};
|
package/lib/editor.d.ts
CHANGED
|
@@ -27,10 +27,17 @@ export interface EditorOptions<T extends DocNode, S extends StandardSchemaV1<T,
|
|
|
27
27
|
/**
|
|
28
28
|
* Callback invoked when errors happen.
|
|
29
29
|
*
|
|
30
|
-
* @default console.
|
|
30
|
+
* @default console.warn
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
onWarn?: (message: string) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Callback invoked when errors happen.
|
|
35
|
+
*
|
|
36
|
+
* @default `throw new Error(message)`
|
|
37
|
+
*/
|
|
38
|
+
onError?: (message: string) => never;
|
|
33
39
|
}
|
|
40
|
+
export type EditorContext<_> = {};
|
|
34
41
|
type EditorEventMap = {
|
|
35
42
|
change: () => void;
|
|
36
43
|
selectionchange: () => void;
|
|
@@ -42,11 +49,10 @@ type EditorEventMap = {
|
|
|
42
49
|
* Return `true` if you want to stop propagation.
|
|
43
50
|
*/
|
|
44
51
|
export type KeyboardHook = (keyboard: KeyboardEvent) => boolean | void;
|
|
45
|
-
export type EditorContext<_> = {};
|
|
46
52
|
/**
|
|
47
53
|
* Functions to handle copy events
|
|
48
54
|
*/
|
|
49
|
-
export type CopyHook = (dataTransfer: DataTransfer
|
|
55
|
+
export type CopyHook = (dataTransfer: DataTransfer) => void;
|
|
50
56
|
/**
|
|
51
57
|
* Functions to handle paste / drop events
|
|
52
58
|
*/
|
|
@@ -108,5 +114,5 @@ export interface Editor<T extends DocNode = DocNode> {
|
|
|
108
114
|
/**
|
|
109
115
|
* A function to initialize {@link Editor}.
|
|
110
116
|
*/
|
|
111
|
-
export declare const createEditor: <T extends DocNode, S extends StandardSchemaV1<T, T> | void = void>({ doc, readonly, schema, isBlock, onError, }: EditorOptions<T, S>) => Editor<T>;
|
|
117
|
+
export declare const createEditor: <T extends DocNode, S extends StandardSchemaV1<T, T> | void = void>({ doc, readonly, schema, isBlock, onWarn, onError, }: EditorOptions<T, S>) => Editor<T>;
|
|
112
118
|
export {};
|