@prosekit/vue 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.
@@ -18,6 +18,7 @@ import type { Decoration } from '@prosekit/pm/view';
18
18
  import type { DecorationSource } from '@prosekit/pm/view';
19
19
  import { DefineComponent } from 'vue';
20
20
  import { Editor } from '@prosekit/core';
21
+ import type { EditorState } from '@prosekit/pm/state';
21
22
  import type { EditorView } from '@prosekit/pm/view';
22
23
  import { Extension } from '@prosekit/core';
23
24
  import { ExtensionTyping } from '@prosekit/core';
@@ -33,6 +34,7 @@ import { PopoverProps as PopoverProps_2 } from '@prosekit/lit/popover';
33
34
  import { PositioningOptions } from '@prosekit/lit/autocomplete-popover';
34
35
  import { PositioningOptions as PositioningOptions_alias_1 } from '@prosekit/lit/inline-popover';
35
36
  import { Priority } from '@prosekit/core';
37
+ import type { ProseMirrorNode } from '@prosekit/pm/model';
36
38
  import { PublicProps } from 'vue';
37
39
  import type { Ref } from 'vue';
38
40
  import { RendererElement } from 'vue';
@@ -196,6 +198,15 @@ export declare type ResizableHandleProps = PropsWithClass<ResizableHandleProps_2
196
198
 
197
199
  export declare type ResizableProps = PropsWithClass<ResizableProps_2>;
198
200
 
201
+ /**
202
+ * Calls the given handler whenever the editor document changes.
203
+ *
204
+ * @public
205
+ */
206
+ declare function useDocChange(handler: (doc: ProseMirrorNode) => void, options?: UseExtensionOptions): void;
207
+ export { useDocChange }
208
+ export { useDocChange as useDocChange_alias_1 }
209
+
199
210
  /**
200
211
  * Retrieves the editor instance from the nearest ProseKit component.
201
212
  *
@@ -262,6 +273,15 @@ export declare function useNodeViewFactory(): NodeViewFactory;
262
273
  */
263
274
  export declare function usePriorityExtension<T extends Extension = Extension>(extension: MaybeRefOrGetter<T | null>, priority: Priority | null | undefined): ComputedRef<T | null>;
264
275
 
276
+ /**
277
+ * Calls the given handler whenever the editor state changes.
278
+ *
279
+ * @public
280
+ */
281
+ declare function useStateUpdate(handler: (state: EditorState) => void, options?: UseExtensionOptions): void;
282
+ export { useStateUpdate }
283
+ export { useStateUpdate as useStateUpdate_alias_1 }
284
+
265
285
  export declare function useVueNodeViewCreator(renderVueRenderer: VueRendererResult['renderVueRenderer'], removeVueRenderer: VueRendererResult['removeVueRenderer']): NodeViewFactory;
266
286
 
267
287
  export declare function useVueRenderer(): VueRendererResult;
@@ -6,5 +6,7 @@ export { useEditor } from './_tsup-dts-rollup';
6
6
  export { useExtension } from './_tsup-dts-rollup';
7
7
  export { UseExtensionOptions } from './_tsup-dts-rollup';
8
8
  export { useKeymap } from './_tsup-dts-rollup';
9
+ export { useStateUpdate } from './_tsup-dts-rollup';
10
+ export { useDocChange } from './_tsup-dts-rollup';
9
11
  export { VueNodeViewComponent } from './_tsup-dts-rollup';
10
12
  export { VueNodeViewProps } from './_tsup-dts-rollup';
@@ -313,10 +313,26 @@ function useKeymap(keymap, options) {
313
313
  const extension = computed3(() => defineKeymap(toValue3(keymap)));
314
314
  return useExtension(extension, options);
315
315
  }
316
+
317
+ // src/hooks/use-state-update.ts
318
+ import { defineUpdateHandler as defineUpdateHandler2 } from "@prosekit/core";
319
+ function useStateUpdate(handler, options) {
320
+ const extension = defineUpdateHandler2((view) => handler(view.state));
321
+ return useExtension(extension, options);
322
+ }
323
+
324
+ // src/hooks/use-doc-change.ts
325
+ import { defineDocChangeHandler } from "@prosekit/core";
326
+ function useDocChange(handler, options) {
327
+ const extension = defineDocChangeHandler((view) => handler(view.state.doc));
328
+ return useExtension(extension, options);
329
+ }
316
330
  export {
317
331
  ProseKit,
318
332
  defineVueNodeView,
333
+ useDocChange,
319
334
  useEditor,
320
335
  useExtension,
321
- useKeymap
336
+ useKeymap,
337
+ useStateUpdate
322
338
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/vue",
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",