Skip to content

Commit ea1030f

Browse files
committed
chore: update docs
1 parent 3b57805 commit ea1030f

File tree

1 file changed

+60
-66
lines changed

1 file changed

+60
-66
lines changed

README.md

Lines changed: 60 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
Rich text editor (WYSIWYG) written in Svelte, using [MeltUI](https://melt-ui.com/) headless UI and [tailwindcss](https://tailwindcss.com/) CSS framework.
44

5-
Built on top of [tiptap](https://tiptap.dev/) editor(headless editor) and [prosemirror](https://prosemirror.net/). Easy to use, develop and maintain. A prompt engine that helps to integrate with any AI API, and enhance the writing experience.
5+
Built on top of [tiptap](https://tiptap.dev/) editor(headless editor) and [prosemirror](https://prosemirror.net/). Easy to use, develop and maintain. A prompt engine that helps to integrate with any AI API, and enhance the writing experience.
66

7-
Dark/Light theme is supported and customizable.
7+
Dark/Light theme is supported and customizable.
88

99
## Getting started
1010

@@ -22,110 +22,110 @@ npm add @nextlint/svelte
2222
```
2323

2424
### Setup
25+
2526
Nexltint editor uses headless svelte components from MeltUI and styles it with tailwindcss. The theme tokens are inherited from [Svelte Shadcn](https://www.shadcn-svelte.com/docs/theming).
2627

2728
If you already have shadcn setup in your project then you can skip this part.
2829

29-
3030
#### 1. Install tailwindcss and postcss:
3131

3232
```sh
3333
pnpm add -D tailwindcss postcss autoprefixer sass
3434
npx tailwindcss init -p
3535
```
36+
3637
Now `tailwind.config.js` and `postcss.config.js` are created
3738

3839
#### 2. Configure tailwind.config.js:
3940

4041
```js
41-
4242
// more detail at https://www.shadcn-svelte.com/docs/installation/manual
4343

4444
/** @type {import('tailwindcss').Config} */
4545
module.exports = {
4646
content: [
47-
"./src/**/*.{svelte,js}",
48-
"./node_modules/@nextlint/svelte/dist/**/*.{svelte,ts}"
47+
'./src/**/*.{svelte,js}',
48+
'./node_modules/@nextlint/svelte/dist/**/*.{svelte,ts}'
4949
],
5050
theme: {
5151
extend: {
5252
colors: {
53-
border: "hsl(var(--border) / <alpha-value>)",
54-
input: "hsl(var(--input) / <alpha-value>)",
55-
ring: "hsl(var(--ring) / <alpha-value>)",
56-
background: "hsl(var(--background) / <alpha-value>)",
57-
foreground: "hsl(var(--foreground) / <alpha-value>)",
53+
border: 'hsl(var(--border) / <alpha-value>)',
54+
input: 'hsl(var(--input) / <alpha-value>)',
55+
ring: 'hsl(var(--ring) / <alpha-value>)',
56+
background: 'hsl(var(--background) / <alpha-value>)',
57+
foreground: 'hsl(var(--foreground) / <alpha-value>)',
5858
primary: {
59-
DEFAULT: "hsl(var(--primary) / <alpha-value>)",
60-
foreground: "hsl(var(--primary-foreground) / <alpha-value>)",
59+
DEFAULT: 'hsl(var(--primary) / <alpha-value>)',
60+
foreground: 'hsl(var(--primary-foreground) / <alpha-value>)'
6161
},
6262
secondary: {
63-
DEFAULT: "hsl(var(--secondary) / <alpha-value>)",
64-
foreground: "hsl(var(--secondary-foreground) / <alpha-value>)",
63+
DEFAULT: 'hsl(var(--secondary) / <alpha-value>)',
64+
foreground: 'hsl(var(--secondary-foreground) / <alpha-value>)'
6565
},
6666
destructive: {
67-
DEFAULT: "hsl(var(--destructive) / <alpha-value>)",
68-
foreground: "hsl(var(--destructive-foreground) / <alpha-value>)",
67+
DEFAULT: 'hsl(var(--destructive) / <alpha-value>)',
68+
foreground: 'hsl(var(--destructive-foreground) / <alpha-value>)'
6969
},
7070
muted: {
71-
DEFAULT: "hsl(var(--muted) / <alpha-value>)",
72-
foreground: "hsl(var(--muted-foreground) / <alpha-value>)",
71+
DEFAULT: 'hsl(var(--muted) / <alpha-value>)',
72+
foreground: 'hsl(var(--muted-foreground) / <alpha-value>)'
7373
},
7474
accent: {
75-
DEFAULT: "hsl(var(--accent) / <alpha-value>)",
76-
foreground: "hsl(var(--accent-foreground) / <alpha-value>)",
75+
DEFAULT: 'hsl(var(--accent) / <alpha-value>)',
76+
foreground: 'hsl(var(--accent-foreground) / <alpha-value>)'
7777
},
7878
popover: {
79-
DEFAULT: "hsl(var(--popover) / <alpha-value>)",
80-
foreground: "hsl(var(--popover-foreground) / <alpha-value>)",
79+
DEFAULT: 'hsl(var(--popover) / <alpha-value>)',
80+
foreground: 'hsl(var(--popover-foreground) / <alpha-value>)'
8181
},
8282
card: {
83-
DEFAULT: "hsl(var(--card) / <alpha-value>)",
84-
foreground: "hsl(var(--card-foreground) / <alpha-value>)",
85-
},
83+
DEFAULT: 'hsl(var(--card) / <alpha-value>)',
84+
foreground: 'hsl(var(--card-foreground) / <alpha-value>)'
85+
}
8686
},
8787
borderRadius: {
88-
lg: "var(--radius)",
89-
md: "calc(var(--radius) - 2px)",
90-
sm: "calc(var(--radius) - 4px)",
88+
lg: 'var(--radius)',
89+
md: 'calc(var(--radius) - 2px)',
90+
sm: 'calc(var(--radius) - 4px)'
9191
},
9292
fontFamily: {
93-
sans: ["Inter"],
94-
},
95-
},
93+
sans: ['Inter']
94+
}
95+
}
9696
},
97-
plugins: [],
98-
}
97+
plugins: []
98+
};
9999
```
100+
100101
Theme can customize via css tokens. The default token is located at [EditorTheme.scss](https://github.com/sveltor/nextlint/blob/main/packages/svelte/src/lib/EditorTheme.scss).
101102

102103
### Usage:
104+
103105
To use the default theme, you need to wrap your `SvelteEditor` component with `ThemeTheme`:
106+
104107
```svelte
105108
<script lang="ts">
106-
import { SvelteEditor, EditorTheme } from "@nextlint/svelte"
109+
import {SvelteEditor} from '@nextlint/svelte/EditorTheme';
110+
import EditorTheme from '@nextlint/svelte/EditorTheme';
107111
</script>
108-
109-
<div class='editor'>
112+
113+
<div class="editor">
110114
<EditorTheme>
111-
<SvelteEditor
112-
content=""
113-
placeholder="Start editing..."
114-
/>
115+
<SvelteEditor content="" placeholder="Start editing..." />
115116
</EditorTheme>
116117
</div>
117118
```
118119

119120
The `EditorTheme` basicaly just import the default theme we define in `EditorTheme.scss`:
120121

121122
```svelte
122-
123-
//EditorTheme.svelte
124-
125123
<script lang="ts">
126124
import './EditorTheme.scss';
127125
</script>
128126
127+
//EditorTheme.svelte
128+
129129
<slot />
130130
```
131131

@@ -164,10 +164,9 @@ Support upload/embed/unsplash api
164164
| **[`plugins?`](#plugins)** | `PluginsOptions` | Customize plugins options |
165165
| **[`extensions?`](#extensions)** | `Extensions` | Customize editor extension |
166166

167-
168167
### content
169168

170-
Type: `HTMLContent | JSONContent | JSONContent[] | null`
169+
Type: `HTMLContent | JSONContent | JSONContent[] | null`
171170

172171
Initialize content, can be a JSONContent or a html markup.
173172

@@ -195,7 +194,6 @@ Initialize content, can be a JSONContent or a html markup.
195194
/>
196195
```
197196

198-
199197
### placeholder
200198

201199
Type: `String | undefined`
@@ -204,27 +202,24 @@ Default: `undefined`
204202
Placeholder will display when editor content is empty
205203

206204
```svelte
207-
<SvelteEditor
208-
...
209-
content=""
210-
placeholder="Press 'space' to trigger AI prompt"
211-
/>
205+
<SvelteEditor ... content="" placeholder="Press 'space' to trigger AI prompt" />
212206
```
213207

214208
### onChange
215209

216-
Type: `(editor: Editor)=>void`
210+
Type: `(editor: Editor)=>void`
217211

218212
The callback will fire when the editor changes ( update state or selection )
219213

220214
```svelte
221-
<script lang='ts'>
215+
<script lang="ts">
222216
let editor;
223217
</script>
218+
224219
<SvelteEditor
225220
...
226-
onChange={_editor=>{
227-
editor=_editor
221+
onChange={_editor => {
222+
editor = _editor;
228223
}}
229224
/>
230225
```
@@ -237,14 +232,12 @@ Default: `undefined`
237232
The callback will fire once the editor finishes initialize
238233

239234
```svelte
240-
241235
<SvelteEditor
242236
...
243-
onCreated={editor=>{
244-
console.log("The editor is created and ready to use !")
237+
onCreated={editor => {
238+
console.log('The editor is created and ready to use !');
245239
}}
246240
/>
247-
248241
```
249242

250243
### plugins
@@ -254,11 +247,10 @@ Default: `undefined`
254247

255248
```ts
256249
type PluginOptions = {
257-
image?: ImagePluginOptions;
258-
gpt?: AskOptions;
259-
dropCursor?: DropcursorOptions;
250+
image?: ImagePluginOptions;
251+
gpt?: AskOptions;
252+
dropCursor?: DropcursorOptions;
260253
};
261-
262254
```
263255

264256
### plugins.image
@@ -300,15 +292,14 @@ Allow to integrate with any AI out side the editor.
300292
...
301293
plugins={
302294
ask: async (question:string)=>{
303-
// config any AI tool to get the result and return
295+
// config any AI tool to get the result and return
304296
// the result to the editor
305297
return 'result from any AI Backend'
306298
}
307299
}
308300
/>
309301
```
310302

311-
312303
### plugins.dropCursor
313304

314305
Type: `DropcursorOptions|undefined`
@@ -329,6 +320,9 @@ Config dropCursor color/width/class.
329320
```
330321

331322
## Contributing
323+
332324
Please follow the [contribute guideline](https://github.com/sveltor/nextlint/blob/main/CONTRIBUTING.md)
325+
333326
## License
327+
334328
The MIT License (MIT). Please see [License File](https://github.com/sveltor/nextlint/blob/main/LICENSE) for more information.

0 commit comments

Comments
 (0)