merge installation and the getting started guide
This commit is contained in:
52
docs/src/docPages/installation/svelte.md
Normal file
52
docs/src/docPages/installation/svelte.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# Svelte
|
||||
|
||||
## toc
|
||||
|
||||
## Introduction
|
||||
The following guide describes how to integrate tiptap with your Svelte project.
|
||||
|
||||
TODO
|
||||
|
||||
Svelte REPL: https://svelte.dev/repl/c839da77db2444e5b23a752266613639?version=3.31.2
|
||||
|
||||
App.svelte
|
||||
```html
|
||||
<script>
|
||||
import Editor from './Editor.svelte';
|
||||
</script>
|
||||
|
||||
<Editor />
|
||||
```
|
||||
|
||||
Editor.svelte
|
||||
```html
|
||||
<script type="module">
|
||||
import { onMount } from 'svelte'
|
||||
import { Editor } from '@tiptap/core'
|
||||
import { defaultExtensions } from '@tiptap/starter-kit'
|
||||
|
||||
let element
|
||||
let editor
|
||||
|
||||
onMount(() => {
|
||||
editor = new Editor({
|
||||
element: element,
|
||||
extensions: defaultExtensions(),
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
{#if editor}
|
||||
<button on:click={editor.chain().focus().toggleBold().run()} class:error={editor.isActive('bold')}>
|
||||
bold
|
||||
</button>
|
||||
<button on:click={editor.chain().focus().toggleItalic().run()} class:error={editor.isActive('italic')}>
|
||||
italic
|
||||
</button>
|
||||
<button on:click={editor.chain().focus().toggleStrike().run()} class:error={editor.isActive('strike')}>
|
||||
strike
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
<div bind:this={element} />
|
||||
```
|
||||
Reference in New Issue
Block a user