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

Merge branch 'fix/link_in_newsletter' into 'dev'

fix: use href for stateToHTML for links

See merge request web-et-numerique/llle_project/backoffice-client!27
parents 122e92d7 330e2ecb
No related branches found
No related tags found
3 merge requests!30Dev,!29Dev,!27fix: use href for stateToHTML for links
Pipeline #21927 passed
......@@ -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