PageEditor: drop video items only on the HTML moodboard tab

Early-returns in both gallery-drop handlers when the item's mediaClass
is "video" and the active tab can't render video:

- 3D tab: already branches image vs dimensional; video would fall into
  the image branch and try to uploadPlaneFromMediaToken against a video
  URL. Skip it.
- 2D / Konva moodboard: their drop listeners call addImage
  unconditionally, which would load the video URL into an HTMLImageElement
  and fail. Skip unless the active tab is MOODBOARD_HTML.

Gallery drag is globally enabled in the sibling commit, so this is the
failsafe that keeps drops on non-video tabs from producing broken state.
This commit is contained in:
Tanish Manku committed 2026-04-23 14:28:11 -07:00
1 parent 9e07954d4f
commit f260e1cee4
1 file changed
+10
@@ -315,6 +315,10 @@ export const PageEditor = () => {
if (tabStore.activeTabId === "3D") {
handler = onImageDrop(
(item: GalleryItem, position: { x: number; y: number }) => {
// Video drops are only handled on the HTML moodboard. Drop on 3D
// silently — the gallery allows the drag globally, but only tabs
// that know how to render video should consume it.
if (item.mediaClass === "video") return;
console.log("3D Drop debug (event):", {
editorEngine,
camera: editorEngine?.camera,
@@ -407,6 +411,12 @@ export const PageEditor = () => {
const activeTab = tabStore.activeTabId;
handler = onImageDrop(
(item: GalleryItem, position: { x: number; y: number }) => {
// Only the HTML moodboard renders videos. Silently ignore video
// drops on the Konva 2D canvas and the Konva moodboard, which
// would otherwise try to load the video URL as an image.
if (item.mediaClass === "video" && activeTab !== "MOODBOARD_HTML") {
return;
}
// Find the drop target element. For the HTML moodboard tab there's
// no <canvas>; use the HTML stage container element instead.
const target: Element | null =