feat: allows soft breaks in rich text

This commit is contained in:
James
2021-04-02 09:57:39 -04:00
parent 81ee84b38b
commit ecd277da7d

View File

@@ -118,7 +118,13 @@ const RichText: React.FC<Props> = (props) => {
].filter(Boolean).join(' ');
const editor = useMemo(() => {
let CreatedEditor = withHTML(withHistory(withReact(createEditor())));
let CreatedEditor = withHTML(
withHistory(
withReact(
createEditor(),
),
),
);
CreatedEditor = enablePlugins(CreatedEditor, elements);
CreatedEditor = enablePlugins(CreatedEditor, leaves);
@@ -228,6 +234,11 @@ const RichText: React.FC<Props> = (props) => {
readOnly={readOnly}
onBlur={onBlur}
onKeyDown={(event) => {
if (event.key === 'Enter' && event.shiftKey) {
event.preventDefault();
editor.insertText('\n');
}
Object.keys(hotkeys).forEach((hotkey) => {
if (isHotkey(hotkey, event as any)) {
event.preventDefault();