Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
node_modules
26 changes: 15 additions & 11 deletions visual-editor/src/components/Preview/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,21 @@ export function Preview({ data, previewUrl }: PreviewProps) {
}

// On écrit le contenu dans l'iframe
const iframeDocument = iframe.current!.contentDocument!
iframeDocument.open()
iframeDocument.write(await r.text())
iframeDocument.close()
const root = iframeDocument.querySelector('#ve-components') as HTMLElement
initialHTML.current = Array.from(root.children).reduce(
(acc, v, k) => ({ ...acc, [data[k]!._id]: v.outerHTML }),
{}
)
root.innerHTML = ''
setIframeRoot(root)
try {
const iframeDocument = iframe.current!.contentDocument!
iframeDocument.open()
iframeDocument.write(await r.text())
iframeDocument.close()
const root = iframeDocument.querySelector('#ve-components') as HTMLElement
initialHTML.current = Array.from(root.children).reduce(
(acc, v, k) => ({ ...acc, [data[k]!._id]: v.outerHTML }),
{}
)
root.innerHTML = ''
setIframeRoot(root)
} catch (e) {
return
}
}, [])

const previewMode = usePreviewMode()
Expand Down
4 changes: 2 additions & 2 deletions visual-editor/src/fields/TextAlign.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ const Component: FieldComponent<FieldArgs, string> = ({
options,
}) => {
const alignements = Object.keys(AlignmentIcons) as FieldValue[]
const id = useUniqId()
const id = useUniqId('textaligninput')
return (
<Field label={options.label}>
<AlignmentButtons>
{alignements.map((alignment) => (
<AlignmentButton<FieldValue>
key={alignment}
name={id}
id={id}
value={alignment}
checked={value === alignment}
onChange={onChange}
Expand Down
3 changes: 1 addition & 2 deletions visual-editor/src/fields/shared/AlignmentButton.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import type { FunctionComponent } from 'react'
import styled from '@emotion/styled'
import { capitalize } from 'src/functions/string'
import { prevent } from 'src/functions/functions'

type Props<T extends unknown> = {
value: T
checked: boolean
icon: FunctionComponent
onChange: (v: T) => void
name?: string
id?: string
}

export function AlignmentButton<T extends unknown>({
Expand Down