Tebal
Tebalkan teks yang dipilih.
Coba sendiri
Pilih “Yurich” lalu klik Tebal. Keluaran memuat <strong>Yurich</strong>. Klik lagi untuk melepas format.
Contoh interaktif
Hasil contoh
Tambahkan ke editor
Tambahkan Bold ke extensions dan hubungkan tombol ke toggleBold.
import { EditorContent, EditorProvider, Bold, useEditor, useIsActive } from 'yurich';
export function BoldEditor() {
const editor = useEditor({
extensions: [Bold],
initialValue: "<p>Yurich layak diberi sedikit penekanan.</p>",
});
const active = useIsActive(editor, 'toggleBold');
return (
<EditorProvider editor={editor}>
<button
type="button"
aria-pressed={active}
onMouseDown={event => event.preventDefault()}
onClick={() => editor.execute('toggleBold')}
>
Tebal
</button>
<EditorContent ariaLabel="Editor" />
</EditorProvider>
);
}
Perilaku yang perlu diperhatikan
Pintasan Mod+B menjalankan perintah yang sama. Kursor saja tidak mengubah format.