कोड ब्लॉक
कई लाइन का कोड अलग ब्लॉक में दिखाएँ।
आज़माएँ
उदाहरण में कोड ब्लॉक दबाएँ। परिणाम है <pre>editor.execute('toggleBold');</pre>।
लाइव उदाहरण
उदाहरण का परिणाम
एडिटर में जोड़ें
CodeBlock चालू करें और अलग <pre> बनाने के लिए toggleCodeBlock चलाएँ।
import { EditorContent, EditorProvider, CodeBlock, useEditor, useIsActive } from 'yurich';
export function CodeBlockEditor() {
const editor = useEditor({
extensions: [CodeBlock],
initialValue: "<p>editor.execute('toggleBold');</p>",
});
const active = useIsActive(editor, 'toggleCodeBlock');
return (
<EditorProvider editor={editor}>
<button
type="button"
aria-pressed={active}
onMouseDown={event => event.preventDefault()}
onClick={() => editor.execute('toggleCodeBlock')}
>
कोड ब्लॉक
</button>
<EditorContent ariaLabel="एडिटर" />
</EditorProvider>
);
}
ध्यान देने योग्य व्यवहार
ब्लॉक में सादा टेक्स्ट पेस्ट करने पर लाइन ब्रेक बने रहते हैं। सिंटैक्स हाइलाइटिंग ऐप में जोड़ सकते हैं।