Quick Start
This guide will walk you through the process of setting up your first ProseKit editor. We’ll create a basic editor with some common formatting options.
Installation
First, you’ll need to install the prosekit
package. You can use your preferred package manager:
A minimal editor
Now, let’s create a basic editor component. Open your project and add a component file, then replace its content with the following code based on your UI framework:
import 'prosekit/basic/style.css'
import 'prosekit/basic/typography.css'
import { defineBasicExtension } from 'prosekit/basic'
import { createEditor } from 'prosekit/core'
import { ProseKit } from 'prosekit/react'
import { useMemo } from 'react'
export default function Editor() {
const editor = useMemo(() => {
const extension = defineBasicExtension()
return createEditor({ extension })
}, [])
return (
<ProseKit editor={editor}>
<div ref={editor.mount} style={{ outline: 'auto', padding: '1rem' }}></div>
</ProseKit>
)
}
import 'prosekit/basic/style.css'
import 'prosekit/basic/typography.css'
import { useMemo } from 'preact/hooks'
import { defineBasicExtension } from 'prosekit/basic'
import { createEditor } from 'prosekit/core'
import { ProseKit } from 'prosekit/preact'
export default function Editor() {
const editor = useMemo(() => {
const extension = defineBasicExtension()
return createEditor({ extension })
}, [])
return (
<ProseKit editor={editor}>
<div ref={editor.mount} style={{ outline: 'auto', padding: '1rem' }}></div>
</ProseKit>
)
}
import 'prosekit/basic/style.css'
import 'prosekit/basic/typography.css'
import { defineBasicExtension } from 'prosekit/basic'
import { createEditor } from 'prosekit/core'
import { ProseKit } from 'prosekit/solid'
export default function Editor() {
const extension = defineBasicExtension()
const editor = createEditor({ extension })
return (
<ProseKit editor={editor}>
<div ref={editor.mount} style={{ outline: 'auto', padding: '1rem' }}></div>
</ProseKit>
)
}
<script lang="ts">
import 'prosekit/basic/style.css'
import 'prosekit/basic/typography.css'
import { defineBasicExtension } from 'prosekit/basic'
import { createEditor } from 'prosekit/core'
import { ProseKit } from 'prosekit/svelte'
const extension = defineBasicExtension()
const editor = createEditor({ extension })
const mount = (element: HTMLElement) => {
editor.mount(element)
return { destroy: () => editor.unmount() }
}
</script>
<ProseKit {editor}>
<div use:mount style="outline: auto; padding: 1rem;"></div>
</ProseKit>
<script setup lang="ts">
import 'prosekit/basic/style.css'
import 'prosekit/basic/typography.css'
import { defineBasicExtension } from 'prosekit/basic'
import { createEditor } from 'prosekit/core'
import { ProseKit } from 'prosekit/vue'
import {
ref,
watchPostEffect,
} from 'vue'
const extension = defineBasicExtension()
const editor = createEditor({ extension })
const editorRef = ref<HTMLDivElement | null>(null)
watchPostEffect((onCleanup) => {
editor.mount(editorRef.value)
onCleanup(() => editor.unmount())
})
</script>
<template>
<ProseKit :editor="editor">
<div ref="editorRef" style="outline: auto; padding: 1rem" />
</ProseKit>
</template>
This code does the following:
- Creates
extension
by callingdefineBasicExtension()
. This extension provides basic text editing features like paragraphs, headings, bold, italic, etc. - Creates
editor
by callingcreateEditor()
. The extension created in the previous step is passed to the editor. - Creates a
<ProseKit>
component. This component acts as a provider for the children and doesn’t render anything to the DOM directly. - Creates a
<div>
element that mounts the editor. Theeditor.mount()
method is used to attach the editor to this<div>
element.
What’s next?
Congratulations! You’ve successfully created your first ProseKit editor. Now you can explore the following topics:
Styling your editor Learn how to customize the appearance of your editor using CSS.
Saving and loading Discover how to save and load the editor's content.
Using extensions Explore the various extensions available in ProseKit and how to use them.
Using components Learn how to use the built-in UI components to create a more interactive editor.