Weblah/src/lib/components/RichTextInput.svelte
Shibo Lyu db186636a3 refactor: Replace Typewriter editor with ProseMirror
Switch the rich text editor implementation from Typewriter to
ProseMirror for better document model and editing capabilities.
2025-04-11 02:58:06 +08:00

34 lines
963 B
Svelte

<script lang="ts">
import { browser } from '$app/environment';
import InputFrame from '$lib/components/InputFrame.svelte';
import type { Props as ClientInputProps } from './RichTextInput/ClientInput.svelte';
import { tw } from '$lib/tw';
interface Props extends ClientInputProps {
class?: string;
}
let { class: className = '', placeholder, children, ...clientInputProps }: Props = $props();
const loadClientComponent = async () => {
if (!browser) return;
const { default: ClientInput } = await import('./RichTextInput/ClientInput.svelte');
return ClientInput;
};
</script>
<InputFrame class={tw('overflow-y-auto', className)}>
{#await loadClientComponent()}
<div class="rich-text">
{#if children}
{@render children()}
{:else}
<p class="opacity-50">{placeholder}</p>
{/if}
</div>
{:then ClientInput}
<ClientInput {placeholder} {...clientInputProps}>
{@render children?.()}
</ClientInput>
{/await}
</InputFrame>