Skip to content

Commit

Permalink
Use svelte-tiptap for readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Staab committed Aug 26, 2024
1 parent ee81a89 commit beb2ef3
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,17 @@ function MyEditor() {
### svelte

```svelte
<script>
import { Editor, type JSONContent } from '@tiptap/core'
let editor: Editor
let contentText: string = ''
let contentSchema: JSONContent
<script lang="ts">
import { onMount } from 'svelte'
import type { Readable } from 'svelte/store'
import { createEditor, type Editor, EditorContent, SvelteNodeViewRenderer } from 'svelte-tiptap'
import StarterKit from '@tiptap/starter-kit'
import { NostrExtension } from 'nostr-editor'
let editor: Readable<Editor>
onMount(() => {
editor = new Editor({
element: element,
extensions: [
StarterKit,
NostrExtension.configure({
Expand All @@ -121,24 +123,15 @@ function MyEditor() {
],
content: '',
onUpdate: () => {
contentSchema = editor.getJSON()
contentText = editor.getText()
},
onTransaction: () => {
editor = editor
contentSchema = $editor.getJSON()
contentText = $editor.getText()
},
})
})
onDestroy(() => {
if (editor) {
editor.destroy()
}
})
</script>
<main>
<div bind:this={element} />
<EditorContent editor={$editor} />
</main>
```

Expand Down

0 comments on commit beb2ef3

Please sign in to comment.