2023-09-11 13:15:50 +01:00
|
|
|
<script lang="ts">
|
2025-11-21 12:18:04 +01:00
|
|
|
import { Editor } from '@cio/ui/custom/editor';
|
2025-12-02 09:54:38 +01:00
|
|
|
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 {
|
2025-11-21 12:18:04 +01:00
|
|
|
placeholder?: string | ((node: any) => string);
|
|
|
|
|
// Content of the editor
|
2025-12-02 09:54:38 +01:00
|
|
|
content?: HTMLContent;
|
2025-11-21 12:18:04 +01:00
|
|
|
// 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
|
2025-12-02 09:54:38 +01:00
|
|
|
onChange?: (content: HTMLContent) => void;
|
2025-11-21 12:18:04 +01:00
|
|
|
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 = '',
|
2025-11-21 12:18:04 +01:00
|
|
|
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>
|
|
|
|
|
|
2025-11-21 12:18:04 +01:00
|
|
|
<Editor
|
2026-03-09 11:18:22 +01:00
|
|
|
{content}
|
2025-11-21 12:18:04 +01:00
|
|
|
{showToolBar}
|
|
|
|
|
{editable}
|
|
|
|
|
{enablePersistence}
|
|
|
|
|
{contentStorageKey}
|
|
|
|
|
{editableStorageKey}
|
|
|
|
|
class={className}
|
|
|
|
|
{editorClass}
|
|
|
|
|
{placeholder}
|
|
|
|
|
onContentChange={onChange}
|
|
|
|
|
onEditorReady={onReady}
|
|
|
|
|
{onEditorDestroy}
|
|
|
|
|
/>
|