@@ -9,7 +9,7 @@ import { ThemeContext, ContentDensityContext, TextDirectionContext } from "@site
9
9
import { encodeToBase64 , decodeFromBase64 } from "./share.js" ;
10
10
import clsx from "clsx" ;
11
11
import ShareIcon from "@ui5/webcomponents-icons/dist/v5/share-2.svg" ;
12
- import { Splitter } from 'react-splitter-light ' ;
12
+ import Splitter from './Splitter.js ' ;
13
13
import DownloadIcon from "@ui5/webcomponents-icons/dist/v5/download-from-cloud.svg" ;
14
14
import EditIcon from "@ui5/webcomponents-icons/dist/v5/edit.svg" ;
15
15
import ActionIcon from "@ui5/webcomponents-icons/dist/v5/action.svg" ;
@@ -40,10 +40,10 @@ const getProjectFromPool = () => {
40
40
41
41
// return a project element to the pool for reuse
42
42
const returnProjectToPool = ( project ) => {
43
- projectPool . push ( project ) ;
43
+ projectPool . push ( project ) ;
44
44
}
45
45
46
- export default function Editor ( { html, js, css, mainFile = "main.js" , canShare = false , standalone = false , mainFileSelected = false } ) {
46
+ export default function Editor ( { html, js, css, mainFile = "main.js" , canShare = false , standalone = false , mainFileSelected = false } ) {
47
47
const projectContainerRef = useRef ( null ) ;
48
48
const projectRef = useRef ( null ) ;
49
49
const previewRef = useRef ( null ) ;
@@ -54,12 +54,12 @@ export default function Editor({html, js, css, mainFile = "main.js", canShare =
54
54
// name is set on iframe so it can be passed back in resize message to identify which iframe is resized
55
55
const iframeId = useId ( ) ;
56
56
const [ editorVisible , setEditorVisible ] = useState ( false ) ;
57
- const { siteConfig, siteMetadata} = useDocusaurusContext ( ) ;
57
+ const { siteConfig, siteMetadata } = useDocusaurusContext ( ) ;
58
58
const { theme, setTheme } = useContext ( ThemeContext ) ;
59
59
const { contentDensity, setContentDensity } = useContext ( ContentDensityContext ) ;
60
60
const { textDirection, setTextDirection } = useContext ( TextDirectionContext ) ;
61
61
const [ copied , setCopied ] = useState ( false ) ;
62
- const [ activeExample , setActiveExample ] = useState ( "" ) ;
62
+ const [ activeExample , setActiveExample ] = useState ( "" ) ;
63
63
64
64
function calcImports ( ) {
65
65
if ( process . env . NODE_ENV === 'development' || siteConfig . customFields . ui5DeploymentType === "nightly" ) {
@@ -240,7 +240,7 @@ export default function Editor({html, js, css, mainFile = "main.js", canShare =
240
240
content : addHeadContent ( fixAssetPaths ( _html ) ) ,
241
241
} ,
242
242
"playground-support.js" : {
243
- content : playgroundSupport ( { theme, textDirection, contentDensity, iframeId} ) ,
243
+ content : playgroundSupport ( { theme, textDirection, contentDensity, iframeId } ) ,
244
244
hidden : true ,
245
245
} ,
246
246
[ mainFile ] : {
@@ -275,7 +275,7 @@ ${fixAssetPaths(_js)}`,
275
275
// if the saved project has a main from an old default, and the default project has a main.tsx file, restore the saved one
276
276
delete newConfig . files [ "main.tsx" ] ;
277
277
}
278
- newConfig . files = { ...newConfig . files , ...savedConfig } ;
278
+ newConfig . files = { ...newConfig . files , ...savedConfig } ;
279
279
} catch ( e ) {
280
280
console . log ( e ) ;
281
281
}
@@ -289,10 +289,10 @@ ${fixAssetPaths(_js)}`,
289
289
sharedConfig [ "index.html" ] . content = addHeadContent ( fixAssetPaths ( sharedConfig [ "index.html" ] . content ) ) ;
290
290
const oldMainFile = sharedConfig [ "main.js" ] || sharedConfig [ "main.ts" ] ;
291
291
if ( oldMainFile && newConfig . files [ "main.tsx" ] ) {
292
- // if the shared project has a main from an old default, and the default project has a main.tsx file, restore the saved one
292
+ // if the shared project has a main from an old default, and the default project has a main.tsx file, restore the saved one
293
293
delete newConfig . files [ "main.tsx" ] ;
294
294
}
295
- newConfig . files = { ...newConfig . files , ...sharedConfig } ;
295
+ newConfig . files = { ...newConfig . files , ...sharedConfig } ;
296
296
} catch ( e ) {
297
297
console . log ( e ) ;
298
298
}
@@ -316,10 +316,10 @@ ${fixAssetPaths(_js)}`,
316
316
317
317
// algolia search opens the search on key `/` because this custom element is the event target but has no `isContentEditable`
318
318
Object . defineProperty ( fileEditorRef . current , "isContentEditable" , {
319
- configurable : true ,
320
- get ( ) {
321
- return true ;
322
- } ,
319
+ configurable : true ,
320
+ get ( ) {
321
+ return true ;
322
+ } ,
323
323
} ) ;
324
324
325
325
tabBarRef . current . editor = fileEditorRef . current ;
@@ -347,7 +347,7 @@ ${fixAssetPaths(_js)}`,
347
347
// setting has changed but exising project config is there
348
348
// update the playground-support.js only with the new settings so refresh works correctly
349
349
const newConfig = JSON . parse ( JSON . stringify ( projectRef . current . config ) ) ;
350
- newConfig . files [ "playground-support.js" ] . content = playgroundSupport ( { theme, textDirection, contentDensity, iframeId} ) ;
350
+ newConfig . files [ "playground-support.js" ] . content = playgroundSupport ( { theme, textDirection, contentDensity, iframeId } ) ;
351
351
projectRef . current . config = newConfig ;
352
352
} , [ theme , contentDensity , textDirection ] ) ;
353
353
@@ -362,19 +362,16 @@ ${fixAssetPaths(_js)}`,
362
362
function optionalSplitter ( editor , preview ) {
363
363
return (
364
364
< >
365
- { standalone
365
+ { standalone
366
366
?
367
- < div style = { { width : "100%" } } >
368
- < Splitter >
369
- { preview }
370
- { editor }
371
- </ Splitter >
372
- </ div >
367
+ < div >
368
+ < Splitter preview = { preview } editor = { editor } > </ Splitter >
369
+ </ div >
373
370
:
374
- < div >
375
- { editor }
376
- { preview }
377
- </ div >
371
+ < div >
372
+ { editor }
373
+ { preview }
374
+ </ div >
378
375
}
379
376
</ >
380
377
)
@@ -384,10 +381,10 @@ ${fixAssetPaths(_js)}`,
384
381
return (
385
382
< >
386
383
< playground-preview class = { clsx ( styles . previewResultHidden , {
387
- [ styles [ 'preview-standalone' ] ] : standalone ,
388
- [ styles [ 'preview-sample' ] ] : ! standalone ,
389
- } ) }
390
- style = { standalone ? undefined : { height : "unset" , minHeight : "7rem" } } ref = { previewRef }
384
+ [ styles [ 'preview-standalone' ] ] : standalone ,
385
+ [ styles [ 'preview-sample' ] ] : ! standalone ,
386
+ } ) }
387
+ style = { standalone ? undefined : { height : "unset" , minHeight : "7rem" } } ref = { previewRef }
391
388
> </ playground-preview >
392
389
</ >
393
390
)
@@ -401,7 +398,7 @@ ${fixAssetPaths(_js)}`,
401
398
[ styles [ 'editor-standalone' ] ] : standalone ,
402
399
[ styles [ 'editor-sample' ] ] : ! standalone ,
403
400
} ) }
404
- style = { { display : editorVisible | standalone ? "block" : "none" } } >
401
+ style = { { display : editorVisible | standalone ? "block" : "none" } } >
405
402
< playground-tab-bar editable-file-system ref = { tabBarRef } > </ playground-tab-bar >
406
403
< playground-file-editor line-numbers ref = { fileEditorRef } > </ playground-file-editor >
407
404
</ div >
@@ -436,37 +433,37 @@ ${fixAssetPaths(_js)}`,
436
433
437
434
{ canShare
438
435
?
439
- < >
440
- < div className = { `${ styles . editor__toolbar } ` } >
441
- < ExamplesMenu loadHelloWorld = { loadHelloWorld } loadCounter = { loadCounter } initialActiveState = { getExampleMenuInitialState ( ) } />
442
- < div >
443
- < button
444
- className = { `button button--secondary ${ styles . previewResult__download } ` }
445
- onClick = { download }
446
- >
447
- < DownloadIcon className = { `${ styles . btn__icon } ` } />
448
- Download
449
- { copied
450
- ? < div style = { { position : "absolute" } } >
451
- < span className = { styles [ "copy-status" ] } > ✔ Link copied</ span >
452
- </ div >
436
+ < >
437
+ < div className = { `${ styles . editor__toolbar } ` } >
438
+ < ExamplesMenu loadHelloWorld = { loadHelloWorld } loadCounter = { loadCounter } initialActiveState = { getExampleMenuInitialState ( ) } />
439
+ < div >
440
+ < button
441
+ className = { `button button--secondary ${ styles . previewResult__download } ` }
442
+ onClick = { download }
443
+ >
444
+ < DownloadIcon className = { `${ styles . btn__icon } ` } />
445
+ Download
446
+ { copied
447
+ ? < div style = { { position : "absolute" } } >
448
+ < span className = { styles [ "copy-status" ] } > ✔ Link copied</ span >
449
+ </ div >
453
450
: < > </ >
454
- }
455
- </ button >
456
-
457
- < button
458
- className = { `button button--secondary ${ styles . previewResult__share } ` }
459
- onClick = { share }
460
- >
461
- < ShareIcon className = { `${ styles . btn__icon } ` } />
462
- Share
463
- </ button >
464
-
465
- </ div >
451
+ }
452
+ </ button >
453
+
454
+ < button
455
+ className = { `button button--secondary ${ styles . previewResult__share } ` }
456
+ onClick = { share }
457
+ >
458
+ < ShareIcon className = { `${ styles . btn__icon } ` } />
459
+ Share
460
+ </ button >
461
+
466
462
</ div >
467
- </ >
463
+ </ div >
464
+ </ >
468
465
:
469
- < > </ >
466
+ < > </ >
470
467
}
471
468
472
469
< div
@@ -477,37 +474,37 @@ ${fixAssetPaths(_js)}`,
477
474
style = { { border : "1px solid hsla(203, 50%, 30%, 0.15)" , boxShadow : "var(--ifm-color-secondary) 0 0 3px 0" , borderRadius : "0.5rem" , overflow : "hidden" } }
478
475
>
479
476
{ optionalSplitter ( preview ( ) , editor ( ) ) }
480
- < div className = { `${ styles . previewResult__actions } ${ ( canShare ? styles . previewResult__hasShare : "" ) } ` } >
481
- { standalone
482
- ?
477
+ < div className = { `${ styles . previewResult__actions } ${ ( canShare ? styles . previewResult__hasShare : "" ) } ` } >
478
+ { standalone
479
+ ?
483
480
< > </ >
484
- :
485
- < >
486
- < button
487
- className = { `button button--secondary ${ styles . previewResult__downloadSample } ` }
488
- onClick = { download }
489
- >
490
- < DownloadIcon className = { `${ styles [ "btn__icon--edit" ] } ` } />
491
- Download
492
- </ button >
493
-
494
- < button
495
- className = { `button button--secondary ${ styles . previewResult__downloadSample } ` }
496
- onClick = { openInNewTab }
497
- >
498
- < ActionIcon className = { `${ styles [ "btn__icon--edit" ] } ` } />
499
- Open in Playground
500
- </ button >
501
-
502
- < button
503
- className = { `button ${ ( editorVisible ? "button--secondary" : "button--secondary" ) } ${ styles . previewResult__toggleCodeEditor } ${ ( canShare ? styles . previewResult__hasShare : "" ) } ` }
504
- onClick = { toggleEditor }
505
- >
506
- { editorVisible ? < HideIcon className = { `${ styles [ "btn__icon--edit" ] } ` } /> : < EditIcon className = { `${ styles [ "btn__icon--edit" ] } ` } /> }
507
- { editorVisible ? "Hide code" : "Edit" }
508
- </ button >
509
- </ >
510
- }
481
+ :
482
+ < >
483
+ < button
484
+ className = { `button button--secondary ${ styles . previewResult__downloadSample } ` }
485
+ onClick = { download }
486
+ >
487
+ < DownloadIcon className = { `${ styles [ "btn__icon--edit" ] } ` } />
488
+ Download
489
+ </ button >
490
+
491
+ < button
492
+ className = { `button button--secondary ${ styles . previewResult__downloadSample } ` }
493
+ onClick = { openInNewTab }
494
+ >
495
+ < ActionIcon className = { `${ styles [ "btn__icon--edit" ] } ` } />
496
+ Open in Playground
497
+ </ button >
498
+
499
+ < button
500
+ className = { `button ${ ( editorVisible ? "button--secondary" : "button--secondary" ) } ${ styles . previewResult__toggleCodeEditor } ${ ( canShare ? styles . previewResult__hasShare : "" ) } ` }
501
+ onClick = { toggleEditor }
502
+ >
503
+ { editorVisible ? < HideIcon className = { `${ styles [ "btn__icon--edit" ] } ` } /> : < EditIcon className = { `${ styles [ "btn__icon--edit" ] } ` } /> }
504
+ { editorVisible ? "Hide code" : "Edit" }
505
+ </ button >
506
+ </ >
507
+ }
511
508
</ div >
512
509
513
510
</ div >
0 commit comments