Files
classroomio/apps/dashboard/src/lib/features/ui/text-editor.svelte
T

59 lines
1.5 KiB
Svelte
Raw Normal View History

2023-09-11 13:15:50 +01:00
<script lang="ts">
import { Editor } from '@cio/ui/custom/editor';
import type { HTMLContent, TiptapEditor } from '@cio/ui/custom/editor';
2020-12-29 04:01:30 +02:00
2025-11-01 15:49:29 +01:00
interface Props {
placeholder?: string | ((node: any) => string);
// Content of the editor
content?: HTMLContent;
// Whether the toolbar should be visible
showToolBar?: boolean;
// Whether the editor is editable
editable?: boolean;
// Whether to enable localStorage persistence
enablePersistence?: boolean;
// localStorage key for content persistence
contentStorageKey?: string;
// localStorage key for editable state persistence
editableStorageKey?: string;
// CSS class for the editor wrapper
class?: string;
// CSS class for the editor itself
editorClass?: string;
// Callback functions
onChange?: (content: HTMLContent) => void;
onReady?: (editor: TiptapEditor) => void;
onEditorDestroy?: () => void;
2025-11-01 15:49:29 +01:00
}
2020-12-29 04:01:30 +02:00
2025-11-01 15:49:29 +01:00
let {
2026-03-09 11:18:22 +01:00
content = '',
showToolBar = true,
editable = true,
enablePersistence = false,
contentStorageKey = 'edra-content',
editableStorageKey = 'edra-editable',
class: className = '',
editorClass = '',
placeholder = 'Welcome to ClassroomIO',
onChange,
onReady,
onEditorDestroy
2025-11-01 15:49:29 +01:00
}: Props = $props();
2020-12-29 04:01:30 +02:00
</script>
<Editor
2026-03-09 11:18:22 +01:00
{content}
{showToolBar}
{editable}
{enablePersistence}
{contentStorageKey}
{editableStorageKey}
class={className}
{editorClass}
{placeholder}
onContentChange={onChange}
onEditorReady={onReady}
{onEditorDestroy}
/>