[Page] Update: Sync prototype editor UI components#3194
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces significant updates to the editor's UI components, including the implementation of a new PreviewPanel, modal components (UIModal, UIFormModal), and checkbox/button group controls. It also refactors the sprite and asset management logic, introduces drag-and-drop functionality for code snippets, and updates CSS variables for consistent styling. My review highlights two areas for improvement: the use of 'any' for the 'ctx' prop in the new PreviewPanel, which should be typed for better maintainability, and a potential memory leak in the snippet sidebar resize logic due to uncleaned event listeners.
| import transformerFlipArrowUrl from '@/assets/editor/custom-transformer/transformer-flip-arrow.png' | ||
|
|
||
| const props = defineProps<{ | ||
| ctx: any |
| function startSnippetSidebarResize(event: MouseEvent) { | ||
| if (!(event.currentTarget instanceof HTMLElement)) return | ||
| const codeBody = event.currentTarget.closest('.code-body') | ||
| if (!(codeBody instanceof HTMLElement)) return | ||
| event.preventDefault() | ||
| snippetSidebarResizing.value = true | ||
| const initialClientX = event.clientX | ||
| const initialWidth = snippetSidebarWidth.value | ||
| const maxWidth = Math.max(minSnippetSidebarWidth, codeBody.clientWidth - 60 - minCodeEditorWidth) | ||
|
|
||
| function handleMouseMove(moveEvent: MouseEvent) { | ||
| const offset = moveEvent.clientX - initialClientX | ||
| snippetSidebarWidth.value = Math.min(Math.max(minSnippetSidebarWidth, initialWidth + offset), maxWidth) | ||
| } | ||
|
|
||
| function endResizing() { | ||
| snippetSidebarResizing.value = false | ||
| window.removeEventListener('mousemove', handleMouseMove) | ||
| window.removeEventListener('mouseup', endResizing) | ||
| } | ||
|
|
||
| window.addEventListener('mousemove', handleMouseMove) | ||
| window.addEventListener('mouseup', endResizing) | ||
| } |
There was a problem hiding this comment.
The startSnippetSidebarResize function adds mousemove and mouseup listeners to the window object. If the component is unmounted while a resize operation is in progress, these listeners will persist, potentially causing memory leaks or unexpected behavior. Consider adding a cleanup mechanism in onBeforeUnmount.
Code Review: Prototype Editor UI SyncOverall this is a solid prototype synchronization with good accessibility throughout (ARIA roles, keyboard nav, focus management). A few structural issues are worth addressing before the pattern spreads to more components. Important: Split
|
779178a to
f07b958
Compare
Issue
N/A
Background
Continue prototype editor synchronization on a stacked branch after the current #3190 work, keeping the prototype aligned with the real Builder frontend while preserving local offline behavior.
Changes
Scope
Design System Impact