Skip to content

Commit 58308d0

Browse files
fix(TextAreaRichText): ensure markdown value retrieval handles undefined storage
1 parent 6f75b0d commit 58308d0

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/core/components/forms/textAreaRichText/textAreaRichText.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,23 @@ export const TextAreaRichText: React.FC<ITextAreaRichTextProps> = (props) => {
9797
return;
9898
}
9999

100-
const handlers: Record<ValueFormat, () => string> = {
100+
const handlers: Record<ValueFormat, () => string | undefined> = {
101101
html: () => editor.getHTML(),
102-
markdown: () => (editor.storage.markdown as MarkdownStorage)?.getMarkdown() ?? editor.getHTML(),
103102
text: () => editor.getText(),
103+
markdown: () => {
104+
const markdownStorage = editor.storage.markdown as MarkdownStorage | undefined;
105+
106+
if (markdownStorage) {
107+
return markdownStorage.getMarkdown();
108+
}
109+
110+
return editor.getHTML();
111+
},
104112
};
105113

106-
const getValue = handlers[valueFormat] ?? handlers.html;
114+
const value = handlers[valueFormat]() ?? editor.getHTML();
107115

108-
onChange?.(getValue());
116+
onChange?.(value);
109117
},
110118
});
111119

0 commit comments

Comments
 (0)