Last active
December 25, 2024 15:17
-
-
Save digitaldrreamer/76e724f9a69f93bcbab15a97612c4c06 to your computer and use it in GitHub Desktop.
EditorJS with Svelte 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import {onMount} from "svelte"; | |
/** | |
* @type {EditorJS | null} | |
*/ | |
let editor = $state(null); | |
/** @type {HTMLElement | null} */ | |
let editorEl = null; | |
onMount(async () => { | |
try { | |
const {default: EditorJS} = await import('@editorjs/editorjs'); | |
const {default: Header} = await import("@editorjs/header") | |
editor = new EditorJS({ | |
holder: editorEl, | |
tools: { | |
header: { | |
class: Header, | |
inlineToolbar: ['link'] | |
}, | |
} | |
}); | |
} catch (error) { | |
console.error("Failed to load EditorJS:", error); | |
} | |
}); | |
let props = $props() | |
</script> | |
<div bind:this={editorEl} class="w-full h-full {props.class}"></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: https://dev.to/digitaldrreamer/make-editorjs-work-in-sveltekit-ssr-34ho