diff --git a/src/components/Editing/CustomEditor.tsx b/src/components/Editing/CustomEditor.tsx index 5cca8c77e727ab1eeb31868d77e68d48fb46a273..fa27851c672aeec349b16738916ada5fa1be0eb8 100644 --- a/src/components/Editing/CustomEditor.tsx +++ b/src/components/Editing/CustomEditor.tsx @@ -22,8 +22,23 @@ const CustomEditor: React.FC<CustomEditorProps> = ({ const [editorState, setEditorState] = useState<EditorState>(baseState) const handleStateChange = (state: EditorState) => { + let options = { + entityStyleFn: (entity: any) => { + const entityType = entity.get('type').toLowerCase() + if (entityType === 'link') { + const data = entity.getData() + return { + element: 'a', + attributes: { + target: data.targetOption, + href: data.href, + }, + } + } + }, + } setEditorState(state) - handleChange(stateToHTML(editorState.getCurrentContent()), editorType) + handleChange(stateToHTML(state.getCurrentContent(), options), editorType) } return (