Use space as blossom server if supported

This commit is contained in:
Jon Staab
2025-04-29 12:24:20 -07:00
parent 5a7750a91b
commit 6ddba63ff9
7 changed files with 98 additions and 38 deletions
+15 -8
View File
@@ -1,22 +1,29 @@
<script lang="ts">
import {Editor} from "@welshman/editor"
import {onDestroy, onMount} from "svelte"
const {editor} = $props()
type Props = {
editor: Promise<Editor>
}
const {editor}: Props = $props()
let element: HTMLElement
onMount(() => {
if (editor.options.element) {
element?.append(editor.options.element)
}
editor.then(({options}) => {
if (options.element) {
element?.append(options.element)
}
if (editor.options.autofocus) {
;(element?.querySelector("[contenteditable]") as HTMLElement)?.focus()
}
if (options.autofocus) {
;(element?.querySelector("[contenteditable]") as HTMLElement)?.focus()
}
})
})
onDestroy(() => {
editor.destroy()
editor.then($editor => $editor.destroy())
})
</script>