File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -44,14 +44,23 @@ export const CodeEmbed = (props) => {
4444 previewHeight = previewHeight || parseFloat ( canvasMatch [ 2 ] ) ;
4545 }
4646
47- const largeSketch = previewWidth && previewWidth > 770 - 60 ;
48-
4947 // Quick hack to make room for DOM that gets added below the canvas by default
5048 const domMatch = / c r e a t e ( B u t t o n | S e l e c t | P | D i v | I n p u t | C o l o r P i c k e r ) / . exec ( initialCode ) ;
5149 if ( domMatch && previewHeight ) {
5250 previewHeight += 100 ;
5351 }
5452
53+ // Fallback preview size when no usable canvas dimensions are detected.
54+ // Ensures DOM-based examples (e.g., createCapture with noCanvas) are visible.
55+ const DEFAULT_PREVIEW_WIDTH = 400 ;
56+ const DEFAULT_PREVIEW_HEIGHT = 300 ;
57+ if ( previewWidth === undefined || previewHeight === undefined ) {
58+ previewWidth = previewWidth ?? DEFAULT_PREVIEW_WIDTH ;
59+ previewHeight = previewHeight ?? DEFAULT_PREVIEW_HEIGHT ;
60+ }
61+
62+ const largeSketch = previewWidth && previewWidth > 770 - 60 ;
63+
5564 const codeFrameRef = useRef ( null ) ;
5665
5766 const updateOrReRun = ( ) => {
You can’t perform that action at this time.
0 commit comments