Improve new component DND for both types of layout

This commit is contained in:
Andrew Kingston 2024-09-05 14:03:03 +01:00
parent 64f0671f36
commit 5e98580b60
No known key found for this signature in database
3 changed files with 5 additions and 3 deletions

View File

@ -153,7 +153,7 @@
$: builderInteractive = $: builderInteractive =
$builderStore.inBuilder && insideScreenslot && !isBlock && !instance.static $builderStore.inBuilder && insideScreenslot && !isBlock && !instance.static
$: devToolsInteractive = $devToolsStore.allowSelection && !isBlock $: devToolsInteractive = $devToolsStore.allowSelection && !isBlock
$: interactive = !isRoot && (builderInteractive || devToolsInteractive) $: interactive = builderInteractive || devToolsInteractive
$: editing = editable && selected && $builderStore.editMode $: editing = editable && selected && $builderStore.editMode
$: draggable = $: draggable =
!inDragPath && !inDragPath &&
@ -231,6 +231,7 @@
empty: emptyState, empty: emptyState,
selected, selected,
interactive, interactive,
isRoot,
draggable, draggable,
editable, editable,
isBlock, isBlock,
@ -672,6 +673,7 @@
class:parent={hasChildren} class:parent={hasChildren}
class:block={isBlock} class:block={isBlock}
class:error={errorState} class:error={errorState}
class:root={isRoot}
data-id={id} data-id={id}
data-name={name} data-name={name}
data-icon={icon} data-icon={icon}

View File

@ -19,7 +19,7 @@
newId = e.target.dataset.id newId = e.target.dataset.id
} else { } else {
// Handle normal components // Handle normal components
const element = e.target.closest(".interactive.component") const element = e.target.closest(".interactive.component:not(.root)")
newId = element?.dataset?.id newId = element?.dataset?.id
} }

View File

@ -93,7 +93,7 @@ export const styleable = (node, styles = {}) => {
node.addEventListener("mouseout", applyNormalStyles) node.addEventListener("mouseout", applyNormalStyles)
// Add builder preview click listener // Add builder preview click listener
if (newStyles.interactive) { if (newStyles.interactive && !newStyles.isRoot) {
node.addEventListener("click", selectComponent, false) node.addEventListener("click", selectComponent, false)
node.addEventListener("dblclick", editComponent, false) node.addEventListener("dblclick", editComponent, false)
} }