prosekit-registry 0.0.2 → 0.0.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.
- package/package.json +2 -2
- package/README.md +0 -241
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prosekit-registry",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "The registry of ProseKit examples",
|
|
7
7
|
"license": "MIT",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"vitest-browser-vue": "^2.1.0",
|
|
84
84
|
"vue-tsc": "^3.2.6",
|
|
85
85
|
"vue-tweet": "^2.4.0",
|
|
86
|
-
"@prosekit/config-vitest": "0.0.0",
|
|
87
86
|
"@prosekit/dev": "0.0.0",
|
|
87
|
+
"@prosekit/config-vitest": "0.0.0",
|
|
88
88
|
"prosekit": "0.20.0-beta.3"
|
|
89
89
|
},
|
|
90
90
|
"scripts": {
|
package/README.md
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
# ProseKit Registry
|
|
2
|
-
|
|
3
|
-
The registry contains framework examples and shared UI components. Source files are organized in `registry/src`, with dedicated directories for each supported framework: `react`, `vue`, `svelte`, `solid`, and `preact`.
|
|
4
|
-
|
|
5
|
-
## Common Guidelines
|
|
6
|
-
|
|
7
|
-
### Same DOM Across Frameworks
|
|
8
|
-
|
|
9
|
-
All framework implementations of the same example must render identical DOM structures.
|
|
10
|
-
|
|
11
|
-
### No Props Destructuring
|
|
12
|
-
|
|
13
|
-
Avoid destructuring component props across all frameworks. Destructuring breaks reactivity in frameworks like Solid. Maintaining consistent syntax across frameworks also improves code maintainability.
|
|
14
|
-
|
|
15
|
-
**Correct:**
|
|
16
|
-
|
|
17
|
-
```tsx
|
|
18
|
-
function Foo(props: FooProps) {
|
|
19
|
-
return <div>{props.foo}</div>;
|
|
20
|
-
}
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
**Incorrect:**
|
|
24
|
-
|
|
25
|
-
```tsx
|
|
26
|
-
function Foo({ foo }: FooProps) {
|
|
27
|
-
return <div>{foo}</div>;
|
|
28
|
-
}
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### Union Call Convention
|
|
32
|
-
|
|
33
|
-
The `union` function should be called with individual arguments, not an array.
|
|
34
|
-
|
|
35
|
-
**Correct:**
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
return union(defineBasicExtension(), defineCodeBlockView());
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
**Incorrect:**
|
|
42
|
-
|
|
43
|
-
```ts
|
|
44
|
-
return union([defineBasicExtension(), defineCodeBlockView()]);
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### Default Content Location
|
|
48
|
-
|
|
49
|
-
To provide default content for an example, create a file at `registry/src/<framework>/sample/sample-doc-<example-name>.ts` and export the content using the following format:
|
|
50
|
-
|
|
51
|
-
```ts
|
|
52
|
-
import type { NodeJSON } from "prosekit/core";
|
|
53
|
-
|
|
54
|
-
export const sampleContent: NodeJSON = {
|
|
55
|
-
/* ... */
|
|
56
|
-
};
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### 'use client' Directive
|
|
60
|
-
|
|
61
|
-
Only use the `'use client'` directive in React framework index files. Do not use it in Vue, Svelte, Solid, Preact, or other frameworks as it is specific to React Server Components.
|
|
62
|
-
|
|
63
|
-
## Vue-Specific Guidelines
|
|
64
|
-
|
|
65
|
-
### Event Handlers
|
|
66
|
-
|
|
67
|
-
Use `@event-name` syntax instead of `:on-event-name` for event handlers in Vue templates.
|
|
68
|
-
|
|
69
|
-
**Good:**
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
<Component @query-change="handleQueryChange" />
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
**Bad:**
|
|
76
|
-
|
|
77
|
-
```
|
|
78
|
-
<Component :on-query-change="handleQueryChange" />
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Props Declaration
|
|
82
|
-
|
|
83
|
-
Use `const props = defineProps<Props>()` to declare component props. This provides better clarity and consistency with other frameworks' patterns.
|
|
84
|
-
|
|
85
|
-
**Good:**
|
|
86
|
-
|
|
87
|
-
```vue
|
|
88
|
-
<script setup lang="ts">
|
|
89
|
-
interface Props {
|
|
90
|
-
name: string
|
|
91
|
-
age?: number
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const props = defineProps<Props>()
|
|
95
|
-
</script>
|
|
96
|
-
|
|
97
|
-
<template>
|
|
98
|
-
<div>{{ props.name }}</div>
|
|
99
|
-
</template>
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
**Bad:**
|
|
103
|
-
|
|
104
|
-
```vue
|
|
105
|
-
<script setup lang="ts">
|
|
106
|
-
interface Props {
|
|
107
|
-
name: string
|
|
108
|
-
age?: number
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
defineProps<Props>()
|
|
112
|
-
</script>
|
|
113
|
-
|
|
114
|
-
<template>
|
|
115
|
-
<div>{{ name }}</div>
|
|
116
|
-
</template>
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Side Effects with Cleanup
|
|
120
|
-
|
|
121
|
-
Prefer `watchEffect` over `watch` to track reactive dependencies automatically.
|
|
122
|
-
|
|
123
|
-
**Good:**
|
|
124
|
-
|
|
125
|
-
```ts
|
|
126
|
-
watchEffect((onCleanup) => {
|
|
127
|
-
const value = valueRef.value;
|
|
128
|
-
// do something with value
|
|
129
|
-
onCleanup(() => {
|
|
130
|
-
// cleanup logic
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
**Bad:**
|
|
136
|
-
|
|
137
|
-
```ts
|
|
138
|
-
watch([valueRef], (newValue, oldValue, onCleanup) => {
|
|
139
|
-
// do something with newValue
|
|
140
|
-
onCleanup(() => {
|
|
141
|
-
// cleanup logic
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## Svelte-Specific Guidelines
|
|
147
|
-
|
|
148
|
-
### Syntax
|
|
149
|
-
|
|
150
|
-
Use Svelte v5 runes syntax (`$state`, `$derived`, `$props`, `$effect`) instead of legacy syntax.
|
|
151
|
-
|
|
152
|
-
**Good:**
|
|
153
|
-
|
|
154
|
-
```svelte
|
|
155
|
-
<script lang="ts">
|
|
156
|
-
interface Props {
|
|
157
|
-
name: string;
|
|
158
|
-
}
|
|
159
|
-
const props: Props = $props();
|
|
160
|
-
let count = $state(0);
|
|
161
|
-
let doubled = $derived(count * 2);
|
|
162
|
-
</script>
|
|
163
|
-
|
|
164
|
-
<div>{props.name} {doubled}</div>
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
**Bad:**
|
|
168
|
-
|
|
169
|
-
```svelte
|
|
170
|
-
<script lang="ts">
|
|
171
|
-
export let name = 'World';
|
|
172
|
-
let count = 0;
|
|
173
|
-
$: doubled = count * 2;
|
|
174
|
-
</script>
|
|
175
|
-
|
|
176
|
-
<div>{name} {doubled}</div>
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
## Solid-Specific Guidelines
|
|
180
|
-
|
|
181
|
-
### Use `attr:` for data attributes
|
|
182
|
-
|
|
183
|
-
Use `attr:` for data attributes
|
|
184
|
-
|
|
185
|
-
**Good:**
|
|
186
|
-
|
|
187
|
-
```tsx
|
|
188
|
-
<SolidComponent
|
|
189
|
-
attr:data-testid="test-id"
|
|
190
|
-
attr:data-selected={selected ? "" : undefined}
|
|
191
|
-
/>
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
**Bad:**
|
|
195
|
-
|
|
196
|
-
```tsx
|
|
197
|
-
<SolidComponent
|
|
198
|
-
data-testid="test-id"
|
|
199
|
-
data-selected={selected ? "" : undefined}
|
|
200
|
-
/>
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
### Explicitly specify the return type of components
|
|
204
|
-
|
|
205
|
-
**Good:**
|
|
206
|
-
|
|
207
|
-
```tsx
|
|
208
|
-
import type { JSX } from 'solid-js'
|
|
209
|
-
|
|
210
|
-
export default function Foo(): JSX.Element {
|
|
211
|
-
return <div>Foo</div>
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
**Bad:**
|
|
216
|
-
|
|
217
|
-
```tsx
|
|
218
|
-
export default function Foo() {
|
|
219
|
-
return <div>Foo</div>
|
|
220
|
-
}
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
### Use `For` instead of `.map()`
|
|
224
|
-
|
|
225
|
-
**Good:**
|
|
226
|
-
|
|
227
|
-
```tsx
|
|
228
|
-
<div>
|
|
229
|
-
<For each={items}>
|
|
230
|
-
{(item) => <div>{item}</div>}
|
|
231
|
-
</For>
|
|
232
|
-
</div>
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
**Bad:**
|
|
236
|
-
|
|
237
|
-
```tsx
|
|
238
|
-
<div>{items.map((item) => (
|
|
239
|
-
<div>{item}</div>)
|
|
240
|
-
)}</div>
|
|
241
|
-
```
|