Coretan
Coret teks tanpa menghapusnya.
Coba sendiri
Pilih “Yurich” dan klik Coret. Keluaran memuat <s>Yurich</s> dan teksnya tetap ada.
Contoh interaktif
Hasil contoh
Tambahkan ke editor
Aktifkan Strikethrough dan panggil toggleStrikethrough.
import { EditorContent, EditorProvider, Strikethrough, useEditor, useIsActive } from 'yurich';
export function StrikethroughEditor() {
const editor = useEditor({
extensions: [Strikethrough],
initialValue: "<p>Coret Yurich dan lihat apa yang tersisa.</p>",
});
const active = useIsActive(editor, 'toggleStrikethrough');
return (
<EditorProvider editor={editor}>
<button
type="button"
aria-pressed={active}
onMouseDown={event => event.preventDefault()}
onClick={() => editor.execute('toggleStrikethrough')}
>
Coret
</button>
<EditorContent ariaLabel="Editor" />
</EditorProvider>
);
}
Perilaku yang perlu diperhatikan
Pintasannya Mod+Shift+S. Tag <del> dari HTML masukan menjadi <s>.