editate 0.6.1 → 0.6.3

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/README.md CHANGED
@@ -213,6 +213,7 @@ export const App = () => {
213
213
  - Solid ([Demo](https://inokawa.github.io/editate/solid), [Source](./examples/solid))
214
214
  - Angular ([Demo](https://inokawa.github.io/editate/angular), [Source](./examples/angular))
215
215
  - Preact ([Demo](https://inokawa.github.io/editate/preact), [Source](./examples/preact))
216
+ - Alpine ([Demo](https://inokawa.github.io/editate/alpine), [Source](./examples/alpine))
216
217
  - Vanilla ([Demo](https://inokawa.github.io/editate/vanilla), [Source](./examples/vanilla))
217
218
 
218
219
  ...and more! Contribution welcome!
package/lib/commands.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Editor } from "./editor.js";
2
- import type { DocNode, InferBlockNode, InferInlineNode, Path, Range, TextNode } from "./doc/types.js";
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], path?: Path): void;
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], path?: Path): void;
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.error
30
+ * @default console.warn
31
31
  */
32
- onError?: (message: string) => void;
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, doc: Fragment, element: Element) => void;
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 {};