@prosekit/svelte 0.2.1 → 0.2.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.
@@ -0,0 +1,9 @@
1
+ import type { ProseMirrorNode } from '@prosekit/pm/model';
2
+ import { type UseExtensionOptions } from './use-extension';
3
+ /**
4
+ * Calls the given handler whenever the editor document changes.
5
+ *
6
+ * @public
7
+ */
8
+ export declare function useDocChange(handler: (doc: ProseMirrorNode) => void, options?: UseExtensionOptions): void;
9
+ //# sourceMappingURL=use-doc-change.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-doc-change.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-doc-change.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAGzD,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAExE;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,EACvC,OAAO,CAAC,EAAE,mBAAmB,QAI9B"}
@@ -0,0 +1,12 @@
1
+ import { defineDocChangeHandler } from '@prosekit/core';
2
+ import { readable } from 'svelte/store';
3
+ import { useExtension } from './use-extension';
4
+ /**
5
+ * Calls the given handler whenever the editor document changes.
6
+ *
7
+ * @public
8
+ */
9
+ export function useDocChange(handler, options) {
10
+ const extension = defineDocChangeHandler((view) => handler(view.state.doc));
11
+ return useExtension(readable(extension), options);
12
+ }
@@ -0,0 +1,9 @@
1
+ import type { EditorState } from '@prosekit/pm/state';
2
+ import { type UseExtensionOptions } from './use-extension';
3
+ /**
4
+ * Calls the given handler whenever the editor state changes.
5
+ *
6
+ * @public
7
+ */
8
+ export declare function useStateUpdate(handler: (state: EditorState) => void, options?: UseExtensionOptions): void;
9
+ //# sourceMappingURL=use-state-update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-state-update.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-state-update.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGrD,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAExE;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,EACrC,OAAO,CAAC,EAAE,mBAAmB,QAI9B"}
@@ -0,0 +1,12 @@
1
+ import { defineUpdateHandler } from '@prosekit/core';
2
+ import { readable } from 'svelte/store';
3
+ import { useExtension } from './use-extension';
4
+ /**
5
+ * Calls the given handler whenever the editor state changes.
6
+ *
7
+ * @public
8
+ */
9
+ export function useStateUpdate(handler, options) {
10
+ const extension = defineUpdateHandler((view) => handler(view.state));
11
+ return useExtension(readable(extension), options);
12
+ }
@@ -2,5 +2,7 @@ export { ProseKit } from './components/prosekit';
2
2
  export { useEditor } from './hooks/use-editor';
3
3
  export { useExtension, type UseExtensionOptions } from './hooks/use-extension';
4
4
  export { useKeymap } from './hooks/use-keymap';
5
+ export { useStateUpdate } from './hooks/use-state-update';
6
+ export { useDocChange } from './hooks/use-doc-change';
5
7
  export type { PropsWithClass } from './types';
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA"}
@@ -2,3 +2,5 @@ export { ProseKit } from './components/prosekit';
2
2
  export { useEditor } from './hooks/use-editor';
3
3
  export { useExtension } from './hooks/use-extension';
4
4
  export { useKeymap } from './hooks/use-keymap';
5
+ export { useStateUpdate } from './hooks/use-state-update';
6
+ export { useDocChange } from './hooks/use-doc-change';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/svelte",
3
3
  "type": "module",
4
- "version": "0.2.1",
4
+ "version": "0.2.3",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -108,7 +108,8 @@
108
108
  ],
109
109
  "dependencies": {
110
110
  "@prosekit/core": "^0.2.7",
111
- "@prosekit/lit": "^0.2.1"
111
+ "@prosekit/lit": "^0.2.1",
112
+ "@prosekit/pm": "^0.1.1"
112
113
  },
113
114
  "peerDependencies": {
114
115
  "svelte": ">= 3.0.0"