Skip to content

Commit 2d09798

Browse files
add debug layer
1 parent fe06f1d commit 2d09798

2 files changed

Lines changed: 45 additions & 19 deletions

File tree

editor-packages/editor-canvas/canvas/canvas.tsx

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -522,24 +522,29 @@ export function Canvas({
522522
<>
523523
<>
524524
{debug === true && (
525-
<DebugInfoContainer>
526-
<div>zoom: {zoom}</div>
527-
<div>offset: {offset.join(", ")}</div>
528-
<div>isPanning: {isPanning ? "true" : "false"}</div>
529-
<div>isZooming: {isZooming ? "true" : "false"}</div>
530-
<div>isDragging: {isDragging ? "true" : "false"}</div>
531-
<div>
532-
isMovingSelections: {isMovingSelections ? "true" : "false"}
533-
</div>
534-
<div>
535-
isTransforming: {is_canvas_transforming ? "true" : "false"}
536-
</div>
537-
<div>marquee: {marquee ? marquee.join(", ") : "null"}</div>
538-
<div>hoveringLayer: {hoveringLayer?.node?.id}</div>
539-
<div>selectedNodes: {selectedNodes.join(", ")}</div>
540-
<div>initial-transform (xy): {initialTransform.xy.join(", ")}</div>
541-
<div>initial-transform (scale): {initialTransform.scale}</div>
542-
</DebugInfoContainer>
525+
<Debug
526+
infos={[
527+
{ label: "zoom", value: zoom },
528+
{ label: "offset", value: offset.join(", ") },
529+
{ label: "isPanning", value: isPanning },
530+
{ label: "isZooming", value: isZooming },
531+
{ label: "isDragging", value: isDragging },
532+
{ label: "isMovingSelections", value: isMovingSelections },
533+
{ label: "isTransforming", value: is_canvas_transforming },
534+
{ label: "selectedNodes", value: selectedNodes.join(", ") },
535+
{ label: "hoveringLayer", value: hoveringLayer?.node?.id },
536+
{ label: "marquee", value: marquee?.join(", ") },
537+
{ label: "viewbound", value: viewbound.join(", ") },
538+
{
539+
label: "initial-transform (xy)",
540+
value: initialTransform ? initialTransform.xy.join(", ") : null,
541+
},
542+
{
543+
label: "initial-transform (zoom)",
544+
value: initialTransform ? initialTransform.scale : null,
545+
},
546+
]}
547+
/>
543548
)}
544549
{/* <ContextMenuProvider> */}
545550
<Container
@@ -822,6 +827,27 @@ const viewbound_not_measured = (viewbound: Box) => {
822827
);
823828
};
824829

830+
function Debug({
831+
infos,
832+
}: {
833+
infos: { label: string; value: string | number | boolean }[];
834+
}) {
835+
return (
836+
<DebugInfoContainer>
837+
{infos.map(({ label, value }, i) => {
838+
if (value === undefined || value === null) {
839+
return <></>;
840+
}
841+
return (
842+
<div key={i}>
843+
{label}: {JSON.stringify(value)}
844+
</div>
845+
);
846+
})}
847+
</DebugInfoContainer>
848+
);
849+
}
850+
825851
const DebugInfoContainer = styled.div`
826852
position: absolute;
827853
top: 12px;

editor-packages/editor-isolated-inspection/scaffold/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ function VisualContentArea() {
183183
renderItem={renderItem}
184184
renderFrameTitle={() => <></>}
185185
readonly
186-
// debug
186+
debug
187187
config={{
188188
can_highlight_selected_layer: true,
189189
marquee: {

0 commit comments

Comments
 (0)