editate 0.6.20 → 0.6.22

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
@@ -216,6 +216,7 @@ export const App = () => {
216
216
  - Angular ([Demo](https://inokawa.github.io/editate/angular), [Source](./examples/angular))
217
217
  - Preact ([Demo](https://inokawa.github.io/editate/preact), [Source](./examples/preact))
218
218
  - Alpine ([Demo](https://inokawa.github.io/editate/alpine), [Source](./examples/alpine))
219
+ - Marko ([Demo](https://inokawa.github.io/editate/marko), [Source](./examples/marko))
219
220
  - Vanilla ([Demo](https://inokawa.github.io/editate/vanilla), [Source](./examples/vanilla))
220
221
 
221
222
  ...and more! Contribution welcome!
@@ -31,5 +31,9 @@ type PatchNodeOperation = Readonly<{
31
31
  value: unknown;
32
32
  }>;
33
33
  export type Operation = DeleteOperation | InsertTextOperation | InsertNodeOperation | FormatOperation | PatchNodeOperation;
34
- export declare const rebase: (position: number, ops: readonly Operation[]) => number;
34
+ /**
35
+ * Remap a position through the given operation.
36
+ * @param stickBefore `true` to keep the position in place when content is inserted at it, instead of moving it after the inserted content.
37
+ */
38
+ export declare const mapPosition: (position: number, op: Operation, stickBefore?: boolean) => number;
35
39
  export {};
package/lib/editor.d.ts CHANGED
@@ -58,7 +58,11 @@ export type CopyHook = (dataTransfer: DataTransfer) => void;
58
58
  */
59
59
  export type PasteHook = (dataTransfer: DataTransfer) => string | Fragment | null;
60
60
  type EditorHookMap = {
61
- apply: (op: Operation, next: (op?: Operation) => void) => void;
61
+ /**
62
+ * Call `next(op)` to continue applying the operation, or `next()` with a nullish value to cancel it.
63
+ * If the hook returns without calling `next`, the operation is passed through as is.
64
+ */
65
+ apply: (op: Operation, next: (op?: Operation | null) => void) => void;
62
66
  mount: (element: HTMLElement, parser: Parser) => void | (() => void);
63
67
  keyboard: KeyboardHook;
64
68
  copy: CopyHook;