editate 0.6.5 → 0.6.7
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 +4 -2
- package/lib/commands.d.ts +2 -2
- package/lib/doc/edit.d.ts +5 -5
- package/lib/dom/index.d.ts +2 -2
- package/lib/dom/parser.d.ts +6 -1
- package/lib/dom/utils.d.ts +1 -0
- package/lib/editor.d.ts +6 -6
- package/lib/index.cjs +577 -563
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +6 -6
- package/lib/index.js +565 -555
- package/lib/index.js.map +1 -1
- package/lib/keyboard.d.ts +1 -1
- package/lib/plugins/debug.d.ts +1 -1
- package/lib/plugins/history.d.ts +1 -1
- package/lib/plugins/index.d.ts +5 -5
- package/lib/plugins/keymap.d.ts +2 -2
- package/lib/plugins/singleline.d.ts +1 -1
- package/lib/plugins/transfer/fileTransfer.d.ts +2 -2
- package/lib/plugins/transfer/htmlTransfer.d.ts +2 -2
- package/lib/plugins/transfer/index.d.ts +4 -4
- package/lib/plugins/transfer/internalTransfer.d.ts +1 -1
- package/lib/plugins/transfer/plainTransfer.d.ts +2 -2
- package/lib/presets/index.d.ts +2 -2
- package/lib/presets/plain.d.ts +1 -1
- package/package.json +6 -8
package/README.md
CHANGED
|
@@ -25,9 +25,11 @@ npm install editate
|
|
|
25
25
|
|
|
26
26
|
### Supported browsers
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
Both desktop and mobile browsers that support [beforeinput event](https://developer.mozilla.org/en-US/docs/Web/API/Element/beforeinput_event#browser_compatibility) are supported. Basically tested with Mac / Windows / iOS / Android.
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
- Chrome
|
|
31
|
+
- Safari
|
|
32
|
+
- Firefox
|
|
31
33
|
|
|
32
34
|
## Getting started
|
|
33
35
|
|
package/lib/commands.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { Editor } from './editor.js';
|
|
2
|
+
import { DocNode, InferBlockNode, InferInlineNode, Range, TextNode } from './doc/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Delete content in the selection or specified range.
|
|
5
5
|
*/
|
package/lib/doc/edit.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DocNode, Fragment, Path, BlockNode, Node, DomPosition, Range } from './types.js';
|
|
2
2
|
declare const OP_DELETE = "delete";
|
|
3
3
|
type DeleteOperation = Readonly<{
|
|
4
4
|
type: typeof OP_DELETE;
|
|
@@ -16,9 +16,9 @@ type InsertNodeOperation = Readonly<{
|
|
|
16
16
|
at: number;
|
|
17
17
|
fragment: Fragment;
|
|
18
18
|
}>;
|
|
19
|
-
declare const
|
|
20
|
-
type
|
|
21
|
-
type: typeof
|
|
19
|
+
declare const OP_FORMAT = "format";
|
|
20
|
+
type FormatOperation = Readonly<{
|
|
21
|
+
type: typeof OP_FORMAT;
|
|
22
22
|
range: Range;
|
|
23
23
|
key: string;
|
|
24
24
|
value: unknown;
|
|
@@ -30,7 +30,7 @@ type SetNodeAttrOperation = Readonly<{
|
|
|
30
30
|
key: string;
|
|
31
31
|
value: unknown;
|
|
32
32
|
}>;
|
|
33
|
-
export type Operation = DeleteOperation | InsertTextOperation | InsertNodeOperation |
|
|
33
|
+
export type Operation = DeleteOperation | InsertTextOperation | InsertNodeOperation | FormatOperation | SetNodeAttrOperation;
|
|
34
34
|
export declare const getNodeSize: (node: Node) => number;
|
|
35
35
|
export declare const offsetToPosition: (node: DocNode | BlockNode, offset: number) => DomPosition;
|
|
36
36
|
export declare const rebase: (position: number, ops: readonly Operation[]) => number;
|
package/lib/dom/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createParser } from
|
|
2
|
-
export { defaultIsBlockNode
|
|
1
|
+
export { createParser } from './parser.js';
|
|
2
|
+
export { defaultIsBlockNode } from './default.js';
|
package/lib/dom/parser.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/editor.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import { DocNode, Fragment, Selection } from './doc/types.js';
|
|
3
|
+
import { Operation } from './doc/edit.js';
|
|
4
|
+
import { Parser } from './dom/parser.js';
|
|
5
5
|
type EditorCommandOrPlugin<A extends unknown[], T extends DocNode = DocNode> = (editor: Editor<T>, ...args: A) => void | undefined;
|
|
6
6
|
type EditorQuery<A extends unknown[], V, T extends DocNode = DocNode> = (editor: Editor<T>, ...args: A) => V;
|
|
7
7
|
/**
|
|
@@ -56,10 +56,10 @@ export type CopyHook = (dataTransfer: DataTransfer) => void;
|
|
|
56
56
|
/**
|
|
57
57
|
* Functions to handle paste / drop events
|
|
58
58
|
*/
|
|
59
|
-
export type PasteHook = (dataTransfer: DataTransfer
|
|
59
|
+
export type PasteHook = (dataTransfer: DataTransfer) => string | Fragment | null;
|
|
60
60
|
type EditorHookMap = {
|
|
61
61
|
apply: (op: Operation, next: (op?: Operation) => void) => void;
|
|
62
|
-
mount: (element: HTMLElement) => void | (() => void);
|
|
62
|
+
mount: (element: HTMLElement, parser: Parser) => void | (() => void);
|
|
63
63
|
keyboard: KeyboardHook;
|
|
64
64
|
copy: CopyHook;
|
|
65
65
|
paste: PasteHook;
|