@prosekit/preact 0.4.5 → 0.4.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.
@@ -21,7 +21,6 @@ import { BlockHandlePopoverEvents } from '@prosekit/web/block-handle';
21
21
  import { BlockHandlePopoverProps as BlockHandlePopoverProps_2 } from '@prosekit/web/block-handle';
22
22
  import { ComponentChildren } from 'preact';
23
23
  import { ComponentType } from 'preact';
24
- import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
25
24
  import { Editor } from '@prosekit/core';
26
25
  import type { EditorState } from '@prosekit/pm/state';
27
26
  import { Extension } from '@prosekit/core';
@@ -31,7 +30,6 @@ import { InlinePopoverElement } from '@prosekit/web/inline-popover';
31
30
  import { InlinePopoverEvents } from '@prosekit/web/inline-popover';
32
31
  import { InlinePopoverProps as InlinePopoverProps_2 } from '@prosekit/web/inline-popover';
33
32
  import { Keymap } from '@prosekit/core';
34
- import { Options } from 'tsup';
35
33
  import { PopoverContentElement } from '@prosekit/web/popover';
36
34
  import { PopoverContentEvents } from '@prosekit/web/popover';
37
35
  import { PopoverContentProps as PopoverContentProps_2 } from '@prosekit/web/popover';
@@ -173,10 +171,6 @@ export declare type CreateProps<Props extends {
173
171
  [EventName in keyof Events]: CustomEvent;
174
172
  }> = Props & CreateEventProps<Events>;
175
173
 
176
- export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
177
-
178
- export { default_alias_1 }
179
-
180
174
  /**
181
175
  * @internal
182
176
  */
@@ -74,8 +74,7 @@ function createComponent(tagName, displayName, propNames, eventNames) {
74
74
  const fixedEventHandlers = {};
75
75
  for (const eventName of eventNames) {
76
76
  fixedEventHandlers[eventName] = (event) => {
77
- var _a, _b;
78
- (_b = (_a = eventHandlersRef.current)[eventName]) == null ? void 0 : _b.call(_a, event);
77
+ eventHandlersRef.current[eventName]?.(event);
79
78
  };
80
79
  }
81
80
  for (const [name, handler] of Object.entries(fixedEventHandlers)) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-FEWLACYV.js";
3
+ } from "./chunk-YJQWSMJE.js";
4
4
  import "./chunk-V253IGNY.js";
5
5
 
6
6
  // src/components/autocomplete/autocomplete-empty.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-FEWLACYV.js";
3
+ } from "./chunk-YJQWSMJE.js";
4
4
  import "./chunk-V253IGNY.js";
5
5
 
6
6
  // src/components/block-handle/block-handle-add.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-FEWLACYV.js";
3
+ } from "./chunk-YJQWSMJE.js";
4
4
  import "./chunk-V253IGNY.js";
5
5
 
6
6
  // src/components/inline-popover/inline-popover.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-FEWLACYV.js";
3
+ } from "./chunk-YJQWSMJE.js";
4
4
  import "./chunk-V253IGNY.js";
5
5
 
6
6
  // src/components/popover/popover-content.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-FEWLACYV.js";
3
+ } from "./chunk-YJQWSMJE.js";
4
4
  import "./chunk-V253IGNY.js";
5
5
 
6
6
  // src/components/resizable/resizable-handle.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-FEWLACYV.js";
3
+ } from "./chunk-YJQWSMJE.js";
4
4
  import "./chunk-V253IGNY.js";
5
5
 
6
6
  // src/components/table-handle/table-handle-column-root.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-FEWLACYV.js";
3
+ } from "./chunk-YJQWSMJE.js";
4
4
  import "./chunk-V253IGNY.js";
5
5
 
6
6
  // src/components/tooltip/tooltip-content.gen.ts
@@ -1,10 +1,10 @@
1
1
  export { ProseKit } from './_tsup-dts-rollup.js';
2
2
  export { ProseKitProps } from './_tsup-dts-rollup.js';
3
+ export { useDocChange } from './_tsup-dts-rollup.js';
3
4
  export { useEditor } from './_tsup-dts-rollup.js';
4
5
  export { useExtension } from './_tsup-dts-rollup.js';
5
6
  export { UseExtensionOptions } from './_tsup-dts-rollup.js';
6
7
  export { useKeymap } from './_tsup-dts-rollup.js';
7
8
  export { useStateUpdate } from './_tsup-dts-rollup.js';
8
- export { useDocChange } from './_tsup-dts-rollup.js';
9
9
  export { PropsWithChildren } from './_tsup-dts-rollup.js';
10
10
  export { PropsWithClass } from './_tsup-dts-rollup.js';
@@ -4,56 +4,28 @@ import {
4
4
  } from "./chunk-V253IGNY.js";
5
5
 
6
6
  // src/components/prosekit.ts
7
- import { h } from "preact";
7
+ import {
8
+ h
9
+ } from "preact";
8
10
  var ProseKit = (props) => {
9
11
  const { editor, children } = props;
10
12
  return h(EditorContextProvider, { value: editor, children });
11
13
  };
12
14
 
13
- // src/hooks/use-editor.ts
14
- import {
15
- ProseKitError,
16
- defineMountHandler,
17
- defineUpdateHandler,
18
- union
19
- } from "@prosekit/core";
20
- import { useEffect, useReducer } from "preact/hooks";
21
- function useEditor(options) {
22
- var _a;
23
- const update = (_a = options == null ? void 0 : options.update) != null ? _a : false;
24
- const editor = useEditorContext();
25
- if (!editor) {
26
- throw new ProseKitError(
27
- "useEditor must be used within the ProseKit component"
28
- );
29
- }
30
- const forceUpdate = useForceUpdate();
31
- useEffect(() => {
32
- if (update) {
33
- const extension = union(
34
- defineMountHandler(forceUpdate),
35
- defineUpdateHandler(forceUpdate)
36
- );
37
- return editor.use(extension);
38
- }
39
- }, [editor, update, forceUpdate]);
40
- return editor;
41
- }
42
- function useForceUpdate() {
43
- const [, dispatch] = useReducer((x) => x + 1, 0);
44
- return dispatch;
45
- }
15
+ // src/hooks/use-doc-change.ts
16
+ import { defineDocChangeHandler } from "@prosekit/core";
17
+ import { useMemo as useMemo2 } from "preact/hooks";
46
18
 
47
19
  // src/hooks/use-editor-extension.ts
48
20
  import {
49
21
  EditorNotFoundError
50
22
  } from "@prosekit/core";
51
- import { useEffect as useEffect2 } from "preact/hooks";
23
+ import { useEffect } from "preact/hooks";
52
24
  function useEditorExtension(editor, extension) {
53
25
  if (!editor) {
54
26
  throw new EditorNotFoundError();
55
27
  }
56
- useEffect2(() => {
28
+ useEffect(() => {
57
29
  if (extension) {
58
30
  return editor.use(extension);
59
31
  }
@@ -61,7 +33,9 @@ function useEditorExtension(editor, extension) {
61
33
  }
62
34
 
63
35
  // src/hooks/use-priority-extension.ts
64
- import { withPriority } from "@prosekit/core";
36
+ import {
37
+ withPriority
38
+ } from "@prosekit/core";
65
39
  import { useMemo } from "preact/hooks";
66
40
  function usePriorityExtension(extension, priority) {
67
41
  return useMemo(() => {
@@ -73,36 +47,72 @@ function usePriorityExtension(extension, priority) {
73
47
  function useExtension(extension, options) {
74
48
  const editorContext = useEditorContext();
75
49
  useEditorExtension(
76
- (options == null ? void 0 : options.editor) || editorContext,
77
- usePriorityExtension(extension, options == null ? void 0 : options.priority)
50
+ options?.editor || editorContext,
51
+ usePriorityExtension(extension, options?.priority)
78
52
  );
79
53
  }
80
54
 
81
- // src/hooks/use-keymap.ts
82
- import { defineKeymap } from "@prosekit/core";
83
- import { useMemo as useMemo2 } from "preact/hooks";
84
- function useKeymap(keymap, options) {
85
- const extension = useMemo2(() => defineKeymap(keymap), [keymap]);
55
+ // src/hooks/use-doc-change.ts
56
+ function useDocChange(handler, options) {
57
+ const extension = useMemo2(
58
+ () => defineDocChangeHandler((view) => handler(view.state.doc)),
59
+ [handler]
60
+ );
86
61
  return useExtension(extension, options);
87
62
  }
88
63
 
89
- // src/hooks/use-state-update.ts
90
- import { defineUpdateHandler as defineUpdateHandler2 } from "@prosekit/core";
64
+ // src/hooks/use-editor.ts
65
+ import {
66
+ defineMountHandler,
67
+ defineUpdateHandler,
68
+ ProseKitError,
69
+ union
70
+ } from "@prosekit/core";
71
+ import {
72
+ useEffect as useEffect2,
73
+ useReducer
74
+ } from "preact/hooks";
75
+ function useEditor(options) {
76
+ const update = options?.update ?? false;
77
+ const editor = useEditorContext();
78
+ if (!editor) {
79
+ throw new ProseKitError(
80
+ "useEditor must be used within the ProseKit component"
81
+ );
82
+ }
83
+ const forceUpdate = useForceUpdate();
84
+ useEffect2(() => {
85
+ if (update) {
86
+ const extension = union(
87
+ defineMountHandler(forceUpdate),
88
+ defineUpdateHandler(forceUpdate)
89
+ );
90
+ return editor.use(extension);
91
+ }
92
+ }, [editor, update, forceUpdate]);
93
+ return editor;
94
+ }
95
+ function useForceUpdate() {
96
+ const [, dispatch] = useReducer((x) => x + 1, 0);
97
+ return dispatch;
98
+ }
99
+
100
+ // src/hooks/use-keymap.ts
101
+ import {
102
+ defineKeymap
103
+ } from "@prosekit/core";
91
104
  import { useMemo as useMemo3 } from "preact/hooks";
92
- function useStateUpdate(handler, options) {
93
- const extension = useMemo3(
94
- () => defineUpdateHandler2((view) => handler(view.state)),
95
- [handler]
96
- );
105
+ function useKeymap(keymap, options) {
106
+ const extension = useMemo3(() => defineKeymap(keymap), [keymap]);
97
107
  return useExtension(extension, options);
98
108
  }
99
109
 
100
- // src/hooks/use-doc-change.ts
101
- import { defineDocChangeHandler } from "@prosekit/core";
110
+ // src/hooks/use-state-update.ts
111
+ import { defineUpdateHandler as defineUpdateHandler2 } from "@prosekit/core";
102
112
  import { useMemo as useMemo4 } from "preact/hooks";
103
- function useDocChange(handler, options) {
113
+ function useStateUpdate(handler, options) {
104
114
  const extension = useMemo4(
105
- () => defineDocChangeHandler((view) => handler(view.state.doc)),
115
+ () => defineUpdateHandler2((view) => handler(view.state)),
106
116
  [handler]
107
117
  );
108
118
  return useExtension(extension, options);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/preact",
3
3
  "type": "module",
4
- "version": "0.4.5",
4
+ "version": "0.4.7",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -71,9 +71,9 @@
71
71
  ],
72
72
  "dependencies": {
73
73
  "react-merge-refs": "^2.1.1",
74
- "@prosekit/core": "^0.7.13",
74
+ "@prosekit/core": "^0.7.14",
75
75
  "@prosekit/pm": "^0.1.9",
76
- "@prosekit/web": "^0.5.1"
76
+ "@prosekit/web": "^0.5.3"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "preact": ">= 10.11.0"
@@ -84,15 +84,15 @@
84
84
  }
85
85
  },
86
86
  "devDependencies": {
87
- "preact": "^10.24.3",
87
+ "preact": "^10.25.4",
88
88
  "tsup": "^8.3.5",
89
- "typescript": "^5.6.3",
90
- "vitest": "^2.1.6",
89
+ "typescript": "~5.7.2",
90
+ "vitest": "^2.1.8",
91
91
  "@prosekit/dev": "0.0.0"
92
92
  },
93
93
  "scripts": {
94
- "build:tsup": "tsup",
95
- "build:tsc": "tsc -b tsconfig.json"
94
+ "build:tsc": "tsc -b tsconfig.json",
95
+ "build:tsup": "tsup"
96
96
  },
97
97
  "types": "./dist/prosekit-preact.d.ts",
98
98
  "typesVersions": {