# कोड ब्लॉक {#code-block}

Source: [React एडिटर में कोड ब्लॉक जोड़ें · Yurich](https://leeyujoo.com/yurich/hi/features/code-block/)

Package: [`yurich`](https://www.npmjs.com/package/yurich)

Package version: `0.1.2`

कई लाइन का कोड अलग ब्लॉक में दिखाएँ।

## आज़माएँ {#try-it}

उदाहरण में **कोड ब्लॉक** दबाएँ। परिणाम है `<pre>editor.execute('toggleBold');</pre>`।

## एडिटर में जोड़ें {#setup}

`CodeBlock` चालू करें और अलग `<pre>` बनाने के लिए `toggleCodeBlock` चलाएँ।

```tsx
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>
  );
}
```

## ध्यान देने योग्य व्यवहार {#behavior}

ब्लॉक में सादा टेक्स्ट पेस्ट करने पर लाइन ब्रेक बने रहते हैं। सिंटैक्स हाइलाइटिंग ऐप में जोड़ सकते हैं।

[सुविधाएँ](https://leeyujoo.com/yurich/hi/features/)
