import { useState, useRef } from 'react'; import { View, Text, Card, Button, Screen } from '@idealyst/components'; import { MarkdownEditor } from '../index'; import type { MarkdownEditorRef } from '../types'; const SAMPLE_MARKDOWN = `# Welcome to the Editor This is a **rich text** editor that works with *markdown*. ## Features - Bold, italic, underline formatting - Headings (H1-H6) - Bullet and numbered lists - Task lists - Code blocks - Blockquotes - Links ### Code Example \`\`\`typescript const greeting = "Hello, World!"; console.log(greeting); \`\`\` > This is a blockquote with some important information. Try editing this content! `; /** * Basic usage example */ function BasicEditorExample() { const [content, setContent] = useState(SAMPLE_MARKDOWN); return ( Basic Editor A simple controlled editor with markdown input/output ); } /** * Controlled editor with ref methods */ function ControlledEditorExample() { const [content, setContent] = useState(''); const [output, setOutput] = useState(''); const editorRef = useRef(null); const handleClear = () => { editorRef.current?.clear(); setOutput(''); }; const handleGetContent = async () => { const markdown = await editorRef.current?.getMarkdown(); setOutput(markdown ?? ''); }; const handleSetContent = () => { editorRef.current?.setMarkdown('# New Content\n\nThis was set programmatically.'); }; return ( Editor with Ref Methods Use ref methods to programmatically control the editor {output ? ( Output: {output} ) : null} ); } /** * Read-only mode example */ function ReadOnlyEditorExample() { return ( Read-Only Mode Use editable=false for a rich markdown viewer ); } /** * Custom toolbar configuration */ function CustomToolbarExample() { const [content, setContent] = useState(''); return ( Custom Toolbar Configure which toolbar items appear and their position ); } /** * Disabled toolbar items example */ function DisabledItemsExample() { const [content, setContent] = useState(''); return ( Disabled Toolbar Items Disable specific toolbar items while keeping them visible (grayed out) ); } /** * Editor with all examples combined */ export function MarkdownEditorExamples() { return ( Markdown Editor A cross-platform WYSIWYG markdown editor. Uses Tiptap on web and 10tap-editor on native. Features • Markdown input/output - no HTML exposed to consumers • Rich text editing with formatting toolbar • Controlled and uncontrolled modes • Ref methods for programmatic control • Configurable toolbar items and position • Disable specific toolbar items • Theme integration via Unistyles ); } export default MarkdownEditorExamples;