Skip to content

Commit

Permalink
fixed component id
Browse files Browse the repository at this point in the history
  • Loading branch information
LiveDuo committed Nov 4, 2023
1 parent a651c51 commit 1019496
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/client/vanilla/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,8 @@ function ContentProvider() {
const onCanvasDrop = async (e) => {
e.preventDefault()

// const componentId = e.dataTransfer.getData('component')
// const data = await fetch(`/${componentId}.html`)
// const html = await data.text()

const html = components[0].source
const componentId = e.dataTransfer.getData('component-id')
const html = components[componentId].source

const _components = getComponents()
if (_components.length === 0) {
Expand All @@ -89,8 +86,8 @@ function ContentProvider() {
cleanCanvas()
}

const onComponentDragStart = (e, c) => {
e.dataTransfer.setData('component', c)
const onComponentDragStart = (e, i) => {
e.dataTransfer.setData('component-id', i)
}

const getElementPosition = (element) => {
Expand Down Expand Up @@ -211,7 +208,7 @@ function ContentProvider() {
className="cursor-grab mb-2"
src={placeholderImageUrl}
draggable="true"
onDragStart={(e) => onComponentDragStart(e, c)}
onDragStart={(e) => onComponentDragStart(e, i)}
/>
))}
</div>
Expand Down Expand Up @@ -254,4 +251,5 @@ function ContentProvider() {

export { ContentProvider }

export const ContentProviderReact = () => <div>todo</div>
const ContentProviderReact = () => <div>todo</div>
export { ContentProviderReact }

0 comments on commit 1019496

Please sign in to comment.