Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/components/Editor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Label } from "neetoui";
import ErrorWrapper from "components/Common/ErrorWrapper";
import useEditorWarnings from "hooks/useEditorWarnings";
import "src/styles/editor/index.scss";
import { removeEmptyTags } from "src/utils";

import { DEFAULT_EDITOR_OPTIONS } from "./constants";
import CharacterCountWrapper from "./CustomExtensions/CharacterCount";
Expand Down Expand Up @@ -107,6 +108,15 @@ const Editor = (
100
);

const handleBlur = props => {
const { editor } = props;
const trimmedContent = removeEmptyTags(editor.getHTML());

onChange(trimmedContent);
editor.commands.setContent(trimmedContent);
onBlur(props);
};

const customExtensions = useCustomExtensions({
placeholder,
extensions,
Expand Down Expand Up @@ -169,7 +179,7 @@ const Editor = (
onCreate: ({ editor }) => !autoFocus && setInitialPosition(editor),
onUpdate: debouncedOnChangeHandler,
onFocus,
onBlur,
onBlur: handleBlur,
});

useEditorState({
Expand Down
Loading