store in localstorage

This commit is contained in:
Jordi Enric committed 2024-07-27 23:19:12 +02:00
1 parent 643c3cb8a8
commit 1059f65669
1 file changed
+7 -2
@@ -8,6 +8,9 @@ import { SlashCommand, getSlashCommandSuggestions } from './slash-commands'
import { TrailingNode } from './trailing-node'
import Placeholder from '@tiptap/extension-placeholder'
// to get local storage in SSR
const ls = typeof window !== 'undefined' ? window.localStorage : null
export function SupaEditor() {
const editor = useEditor({
extensions: [
@@ -30,8 +33,10 @@ export function SupaEditor() {
}
return true
},
content:
'<h1>Welcome to Supabase Reports v2</h1><p>Try typing a slash <code>/</code> in a new line.</p>',
content: JSON.parse(ls?.getItem('editorContent') || '{}'),
onUpdate: ({ editor }) => {
ls?.setItem('editorContent', JSON.stringify(editor.getJSON()))
},
editorProps: {
handleDOMEvents: {
keydown: (view, event) => {