Skip to content

Instantly share code, notes, and snippets.

@digitaldrreamer
Last active December 25, 2024 15:17
Show Gist options
  • Save digitaldrreamer/76e724f9a69f93bcbab15a97612c4c06 to your computer and use it in GitHub Desktop.
Save digitaldrreamer/76e724f9a69f93bcbab15a97612c4c06 to your computer and use it in GitHub Desktop.
EditorJS with Svelte 5
<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>
@digitaldrreamer
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment