@prosekit/solid 0.3.3 → 0.3.5

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