diff --git a/lib/client/vanilla/editor.tsx b/lib/client/vanilla/editor.tsx index db443290..3930db83 100644 --- a/lib/client/vanilla/editor.tsx +++ b/lib/client/vanilla/editor.tsx @@ -209,9 +209,9 @@ function Editor({ standaloneServer = false }) { const _components = getComponents() if (_components.length === 0) { canvasRef.current!.innerHTML = html - } else if (isElementTopHalf(hoveredComponent!, e)) { + } else if (hoveredComponent && isElementTopHalf(hoveredComponent!, e)) { hoveredComponent!.insertAdjacentHTML('beforebegin', html) - } else if (!isElementTopHalf(hoveredComponent!, e)) { + } else if (hoveredComponent && !isElementTopHalf(hoveredComponent!, e)) { hoveredComponent!.insertAdjacentHTML('afterend', html) }