@@ -4,13 +4,17 @@ description: "Follow this guide to set up Novel with Tailwindcss"
4
4
---
5
5
6
6
<Info >
7
- This example demonstrates the use of Shadcn-ui for ui, but alternative libraries and components
8
- can also be employed.
7
+ This example demonstrates the use of Shadcn-ui for ui, but alternative
8
+ libraries and components can also be employed.
9
9
</Info >
10
10
11
- <Card title = ' Shadcn-ui' icon = ' link' href = ' https://ui.shadcn.com/docs/installation' >
12
- You can find more info about installing shadcn-ui here. You will need to add the following
13
- components: <b >Button, Separator, Popover, Command, Dialog,</b >
11
+ <Card
12
+ title = " Shadcn-ui"
13
+ icon = " link"
14
+ href = " https://ui.shadcn.com/docs/installation"
15
+ >
16
+ You can find more info about installing shadcn-ui here. You will need to add
17
+ the following components: <b >Button, Separator, Popover, Command, Dialog,</b >
14
18
</Card >
15
19
16
20
This example will use the same stucture from here: [ Anatomy] ( /quickstart#anatomy ) \
@@ -76,70 +80,40 @@ You can find the full example here: [Tailwind Example](https://github.com/steven
76
80
## Create Menus
77
81
78
82
<CardGroup cols = { 2 } >
79
- <Card title = ' Slash Command' href = ' /guides/tailwind/slash-command' icon = ' terminal' >
83
+ <Card
84
+ title = " Slash Command"
85
+ href = " /guides/tailwind/slash-command"
86
+ icon = " terminal"
87
+ >
80
88
Slash commands are a way to quickly insert content into the editor.
81
89
</Card >
82
- <Card title = ' Bubble Menu' href = ' /guides/tailwind/bubble-menu' icon = ' square-caret-down' >
90
+ <Card
91
+ title = " Bubble Menu"
92
+ href = " /guides/tailwind/bubble-menu"
93
+ icon = " square-caret-down"
94
+ >
83
95
The bubble menu is a context menu that appears when you select text.
84
96
</Card >
85
97
</CardGroup >
86
98
87
99
## Add Editor Props
88
100
89
- ` defaultEditorProps ` are required to fix the slash command keyboard navigation. For any custom use case you can write your own or extend the default props.
90
-
91
- ``` tsx novel/src/editor.tsx
92
- export const defaultEditorProps: EditorProviderProps [" editorProps" ] = {
93
- handleDOMEvents: {
94
- keydown : (_view , event ) => {
95
- // prevent default event listeners from firing when slash command is active
96
- if ([" ArrowUp" , " ArrowDown" , " Enter" ].includes (event .key )) {
97
- const slashCommand = document .querySelector (" #slash-command" );
98
- if (slashCommand ) {
99
- return true ;
100
- }
101
- }
102
- },
103
- },
104
- handlePaste : (view , event ) => {
105
- if (event .clipboardData && event .clipboardData .files && event .clipboardData .files [0 ]) {
106
- event .preventDefault ();
107
- const file = event .clipboardData .files [0 ];
108
- const pos = view .state .selection .from ;
109
-
110
- startImageUpload (file , view , pos );
111
- return true ;
112
- }
113
- return false ;
114
- },
115
- handleDrop : (view , event , _slice , moved ) => {
116
- if (! moved && event .dataTransfer && event .dataTransfer .files && event .dataTransfer .files [0 ]) {
117
- event .preventDefault ();
118
- const file = event .dataTransfer .files [0 ];
119
- const coordinates = view .posAtCoords ({
120
- left: event .clientX ,
121
- top: event .clientY ,
122
- });
123
- // here we deduct 1 from the pos or else the image will create an extra node
124
- startImageUpload (file , view , coordinates ?.pos || 0 - 1 );
125
- return true ;
126
- }
127
- return false ;
128
- },
129
- };
130
- ```
101
+ ` handleCommandNavigation ` is required for fixing the arrow navigation in the / command;
131
102
132
103
``` tsx
104
+ import { handleCommandNavigation } from " novel/extensions" ;
133
105
import { defaultEditorProps , EditorContent } from " novel" ;
134
106
135
107
<EditorContent
136
108
...
137
- editorProps = { {
138
- ... defaultEditorProps ,
139
- attributes: {
140
- class: ` prose-lg prose-stone dark:prose-invert prose-headings:font-title font-default focus:outline-none max-w-full ` ,
141
- },
142
- }}
109
+ editorProps = { {
110
+ handleDOMEvents: {
111
+ keydown : (_view , event ) => handleCommandNavigation (event ),
112
+ },
113
+ attributes: {
114
+ class: ` prose prose-lg dark:prose-invert prose-headings:font-title font-default focus:outline-none max-w-full ` ,
115
+ }
116
+ }}
143
117
/>
144
118
```
145
119
@@ -223,24 +197,24 @@ import { defaultEditorProps, EditorContent } from "novel";
223
197
ul [data-type = " taskList" ] li > label input [type = " checkbox" ] {
224
198
-webkit-appearance : none ;
225
199
appearance : none ;
226
- background-color : var (--novel-white );
200
+ background-color : hsl ( var (--background ) );
227
201
margin : 0 ;
228
202
cursor : pointer ;
229
203
width : 1.2em ;
230
204
height : 1.2em ;
231
205
position : relative ;
232
206
top : 5px ;
233
- border : 2px solid var (--novel-stone-900 );
207
+ border : 2px solid hsl ( var (--border ) );
234
208
margin-right : 0.3rem ;
235
209
display : grid ;
236
210
place-content : center ;
237
211
238
212
&:hover {
239
- background-color: var (--novel-stone-50 );
213
+ background-color: hsl ( var (--accent ) );
240
214
}
241
215
242
216
&:active {
243
- background-color : var (--novel-stone-200 );
217
+ background-color : hsl ( var (--accent ) );
244
218
}
245
219
246
220
&::before {
@@ -260,7 +234,7 @@ import { defaultEditorProps, EditorContent } from "novel";
260
234
}
261
235
262
236
ul [data-type = " taskList" ] li [data-checked = " true" ] > div > p {
263
- color : var (--novel-stone-400 );
237
+ color : var (--muted-foreground );
264
238
text-decoration : line-through ;
265
239
text-decoration-thickness : 2px ;
266
240
}
0 commit comments