Skip to content
Snippets Groups Projects
Commit 330e2ecb authored by Yoan VALLET's avatar Yoan VALLET
Browse files

fix(newsletter): use href for stateToHTML in order to keep links properly

parent 122e92d7
No related branches found
No related tags found
3 merge requests!30Dev,!29Dev,!27fix: use href for stateToHTML for links
......@@ -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 (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment