लिंक
चयन या कर्सर की जगह URL जोड़ें।
आज़माएँ
“फ़ॉर्मैटिंग गाइड” चुनकर लिंक जोड़ें में https://example.com लिखें। लिंक के भीतर कर्सर रखकर लिंक हटाएँ दबाने से वह हट जाता है।
लाइव उदाहरण
उदाहरण का परिणाम
एडिटर में जोड़ें
Link चालू करें और editor.execute('setLink', { href }) चलाएँ। URL माँगते समय उदाहरण चयन बनाए रखता है।
import { EditorContent, EditorProvider, Link, useEditor, useIsActive } from 'yurich';
export function LinkEditor() {
const editor = useEditor({
extensions: [Link],
initialValue: "<p>सारे बटन दबाने से पहले फ़ॉर्मैटिंग गाइड पढ़ें।</p>",
});
const active = useIsActive(editor, 'link');
function addLink() {
const href = window.prompt("लिंक का URL", 'https://example.com');
if (href) editor.execute('setLink', { href });
}
return (
<EditorProvider editor={editor}>
<div role="group" aria-label="लिंक">
<button
type="button"
onMouseDown={event => event.preventDefault()}
onClick={addLink}
>
लिंक जोड़ें
</button>
<button
type="button"
disabled={!active}
onMouseDown={event => event.preventDefault()}
onClick={() => editor.execute('removeLink')}
>
लिंक हटाएँ
</button>
</div>
<EditorContent ariaLabel="एडिटर" />
</EditorProvider>
);
}
ध्यान देने योग्य व्यवहार
http://, https:// और mailto: मान्य हैं। चयन न हो तो URL ही लिंक का दिखने वाला टेक्स्ट होता है।