दस्तावेज़

इनलाइन फ़ॉर्मैट बनाएँ

पंक्ति के एक हिस्से पर फ़ॉर्मैट लगाने के लिए mark() इस्तेमाल करें। Yurich चुनें और हाइलाइट दबाएँ। चुना हुआ शब्द <mark> में आएगा।

लाइव उदाहरण
उदाहरण का परिणाम
import { mark, EditorContent, EditorProvider, useEditor, useIsActive } from 'yurich';

const Highlight = mark({ name: 'highlight', tag: 'mark', shortcut: 'Mod+Shift+H' });

export function HighlightEditor() {
  const editor = useEditor({
    extensions: [Highlight],
    initialValue: "<p>Yurich पर थोड़ा ज़ोर दें।</p>",
  });
  const active = useIsActive(editor, 'toggleHighlight');

  return (
    <EditorProvider editor={editor}>
      <button
        type="button"
        aria-pressed={active}
        onMouseDown={event => event.preventDefault()}
        onClick={() => editor.execute('toggleHighlight')}
      >
        हाइलाइट
      </button>
      <EditorContent ariaLabel="एडिटर" />
    </EditorProvider>
  );
}

नतीजा

editor.getHTML() से मिले HTML में केवल Yurich <mark> टैग में है।

<p><mark>Yurich</mark> पर थोड़ा ज़ोर दें।</p>

नीचे editor.getJSON() से मिले दस्तावेज़ ट्री में Yurich का टेक्स्ट नोड है। इसके marks में mark() से रजिस्टर किया गया फ़ॉर्मैट नाम highlight है।

{
  "type": "text",
  "text": "Yurich",
  "marks": [{ "type": "highlight" }]
}

टैग के नाम छोटे अक्षरों में लिखें। समान इनपुट टैग के लिए mark() में aliases इस्तेमाल करें।

एक्सटेंशन की जाँच करें