@prosekit/solid 0.3.11 → 0.3.13

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,26 @@
1
+ import {
2
+ useEditorContext
3
+ } from "./chunk-XXXIBXNC.js";
4
+
5
+ // src/components/create-component.ts
6
+ import h from "solid-js/h";
7
+ function createComponent(tagName, defaultProps) {
8
+ const propertyNames = Object.keys(defaultProps);
9
+ const hasEditor = Object.hasOwn(defaultProps, "editor");
10
+ const Component = (props) => {
11
+ const properties = {};
12
+ for (const key of Object.keys(props)) {
13
+ properties[propertyNames.includes(key) ? "prop:" + key : key] = () => props[key];
14
+ }
15
+ const editor = useEditorContext();
16
+ if (hasEditor && editor) {
17
+ properties["prop:editor"] = () => props["editor"] || editor;
18
+ }
19
+ return h(tagName, properties);
20
+ };
21
+ return Component;
22
+ }
23
+
24
+ export {
25
+ createComponent
26
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-PH5CYJHM.js";
3
+ } from "./chunk-4QNJABUA.js";
4
4
  import "./chunk-XXXIBXNC.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-PH5CYJHM.js";
3
+ } from "./chunk-4QNJABUA.js";
4
4
  import "./chunk-XXXIBXNC.js";
5
5
 
6
6
  // src/components/block-handle/block-drag-handle.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-PH5CYJHM.js";
3
+ } from "./chunk-4QNJABUA.js";
4
4
  import "./chunk-XXXIBXNC.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-PH5CYJHM.js";
3
+ } from "./chunk-4QNJABUA.js";
4
4
  import "./chunk-XXXIBXNC.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-PH5CYJHM.js";
3
+ } from "./chunk-4QNJABUA.js";
4
4
  import "./chunk-XXXIBXNC.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-PH5CYJHM.js";
3
+ } from "./chunk-4QNJABUA.js";
4
4
  import "./chunk-XXXIBXNC.js";
5
5
 
6
6
  // src/components/tooltip/tooltip-content.gen.ts
@@ -5,14 +5,16 @@ import {
5
5
 
6
6
  // src/components/prosekit.ts
7
7
  import { createComponent } from "solid-js";
8
- var ProseKit = (props) => createComponent(EditorContextProvider, {
9
- get value() {
10
- return props.editor;
11
- },
12
- get children() {
13
- return props.children;
14
- }
15
- });
8
+ var ProseKit = (props) => {
9
+ return createComponent(EditorContextProvider, {
10
+ get value() {
11
+ return props.editor;
12
+ },
13
+ get children() {
14
+ return props.children;
15
+ }
16
+ });
17
+ };
16
18
 
17
19
  // src/hooks/use-editor.ts
18
20
  import {
@@ -24,24 +26,30 @@ import {
24
26
  import { createEffect, createSignal } from "solid-js";
25
27
  function useEditor(options) {
26
28
  var _a;
27
- let update = (_a = options == null ? void 0 : options.update) != null ? _a : !1, editor = useEditorContext();
28
- if (!editor)
29
+ const update = (_a = options == null ? void 0 : options.update) != null ? _a : false;
30
+ const editor = useEditorContext();
31
+ if (!editor) {
29
32
  throw new ProseKitError(
30
33
  "useEditor must be used within the ProseKit component"
31
34
  );
32
- let [depend, forceUpdate] = useForceUpdate();
33
- return createEffect(() => {
35
+ }
36
+ const [depend, forceUpdate] = useForceUpdate();
37
+ createEffect(() => {
34
38
  if (update) {
35
- let extension = union([
39
+ const extension = union([
36
40
  defineMountHandler(forceUpdate),
37
41
  defineUpdateHandler(forceUpdate)
38
42
  ]);
39
43
  return editor.use(extension);
40
44
  }
41
- }, [editor, update, forceUpdate]), () => (depend(), editor);
45
+ }, [editor, update, forceUpdate]);
46
+ return () => {
47
+ depend();
48
+ return editor;
49
+ };
42
50
  }
43
51
  function useForceUpdate() {
44
- return createSignal(void 0, { equals: !1 });
52
+ return createSignal(void 0, { equals: false });
45
53
  }
46
54
 
47
55
  // src/hooks/use-extension.ts
@@ -54,17 +62,21 @@ import { createEffect as createEffect2, onCleanup } from "solid-js";
54
62
 
55
63
  // src/utils/to-value.ts
56
64
  function toValue(v) {
57
- return typeof v == "function" && v.length === 0 ? v() : v;
65
+ return typeof v === "function" && v.length === 0 ? v() : v;
58
66
  }
59
67
 
60
68
  // src/hooks/use-editor-extension.ts
61
69
  function useEditorExtension(editorAccessor, extensionAccessor) {
62
- let editorContext = useEditorContext();
70
+ const editorContext = useEditorContext();
63
71
  createEffect2(() => {
64
- let editor = toValue(editorAccessor) || toValue(editorContext), extension = extensionAccessor();
65
- if (!editor)
72
+ const editor = toValue(editorAccessor) || toValue(editorContext);
73
+ const extension = extensionAccessor();
74
+ if (!editor) {
66
75
  throw new EditorNotFoundError();
67
- extension && onCleanup(editor.use(extension));
76
+ }
77
+ if (extension) {
78
+ onCleanup(editor.use(extension));
79
+ }
68
80
  });
69
81
  }
70
82
 
@@ -72,7 +84,7 @@ function useEditorExtension(editorAccessor, extensionAccessor) {
72
84
  import { withPriority } from "@prosekit/core";
73
85
  function usePriorityExtension(extension, priority) {
74
86
  return () => {
75
- let ext = extension();
87
+ const ext = extension();
76
88
  return ext && priority ? withPriority(ext, priority) : ext;
77
89
  };
78
90
  }
@@ -88,20 +100,21 @@ function useExtension(extension, options) {
88
100
  // src/hooks/use-keymap.ts
89
101
  import { defineKeymap } from "@prosekit/core";
90
102
  function useKeymap(keymap, options) {
91
- return useExtension(() => defineKeymap(keymap()), options);
103
+ const extension = () => defineKeymap(keymap());
104
+ return useExtension(extension, options);
92
105
  }
93
106
 
94
107
  // src/hooks/use-state-update.ts
95
108
  import { defineUpdateHandler as defineUpdateHandler2 } from "@prosekit/core";
96
109
  function useStateUpdate(handler, options) {
97
- let extension = defineUpdateHandler2((view) => handler(view.state));
110
+ const extension = defineUpdateHandler2((view) => handler(view.state));
98
111
  return useExtension(() => extension, options);
99
112
  }
100
113
 
101
114
  // src/hooks/use-doc-change.ts
102
115
  import { defineDocChangeHandler } from "@prosekit/core";
103
116
  function useDocChange(handler, options) {
104
- let extension = defineDocChangeHandler((view) => handler(view.state.doc));
117
+ const extension = defineDocChangeHandler((view) => handler(view.state.doc));
105
118
  return useExtension(() => extension, options);
106
119
  }
107
120
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/solid",
3
3
  "type": "module",
4
- "version": "0.3.11",
4
+ "version": "0.3.13",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -65,9 +65,9 @@
65
65
  "dist"
66
66
  ],
67
67
  "dependencies": {
68
- "@prosekit/core": "^0.7.2",
69
- "@prosekit/pm": "^0.1.5",
70
- "@prosekit/web": "^0.3.1"
68
+ "@prosekit/core": "^0.7.3",
69
+ "@prosekit/pm": "^0.1.6",
70
+ "@prosekit/web": "^0.3.3"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "solid-js": ">= 1.7.0"
@@ -1,20 +0,0 @@
1
- import {
2
- useEditorContext
3
- } from "./chunk-XXXIBXNC.js";
4
-
5
- // src/components/create-component.ts
6
- import h from "solid-js/h";
7
- function createComponent(tagName, defaultProps) {
8
- let propertyNames = Object.keys(defaultProps), hasEditor = Object.hasOwn(defaultProps, "editor");
9
- return (props) => {
10
- let p = {};
11
- for (let key of Object.keys(props))
12
- p[propertyNames.includes(key) ? "prop:" + key : key] = () => props[key];
13
- let editor = useEditorContext();
14
- return hasEditor && editor && (p["prop:editor"] = () => props.editor || editor), h(tagName, p);
15
- };
16
- }
17
-
18
- export {
19
- createComponent
20
- };