Курсив
Подчеркните смысл с помощью курсива.
Попробуйте
Выделите «Yurich» и нажмите Курсив, чтобы получить <em>Yurich</em>.
Интерактивный пример
Результат примера
Добавьте в редактор
Включите Italic и свяжите кнопку с toggleItalic. Обработчик onMouseDown сохраняет выделение.
import { EditorContent, EditorProvider, Italic, useEditor, useIsActive } from 'yurich';
export function ItalicEditor() {
const editor = useEditor({
extensions: [Italic],
initialValue: "<p>Напишите Yurich курсивом.</p>",
});
const active = useIsActive(editor, 'toggleItalic');
return (
<EditorProvider editor={editor}>
<button
type="button"
aria-pressed={active}
onMouseDown={event => event.preventDefault()}
onClick={() => editor.execute('toggleItalic')}
>
Курсив
</button>
<EditorContent ariaLabel="Редактор" />
</EditorProvider>
);
}
Особенности поведения
Сочетание Mod+I также работает. Входной <i> становится <em>.