@@ -2,17 +2,41 @@ import { useEffect, useRef, useState } from "preact/hooks";
2
2
import AceEditor from "ace-builds" ;
3
3
import ace from "ace-builds" ;
4
4
import Dracula from "ace-builds/src-noconflict/theme-dracula" ;
5
- import ' ace-builds/src-noconflict/ext-language_tools' ;
5
+ import " ace-builds/src-noconflict/ext-language_tools" ;
6
6
import { transform } from "../../../core/transform.ts" ;
7
7
import { DataObject } from "../../../core/types.ts" ;
8
8
import { SerialOperations } from "../../../core/types.ts" ;
9
9
10
- ace . config . set ( 'basePath' , 'https://esm.sh/ace-builds@1.35.4/src-noconflict' ) ;
11
- ace . config . setModuleUrl ( 'ace/mode/yaml' , 'https://cdn.jsdelivr.net/npm/ace-builds@1.4.12/src-noconflict/mode-yaml.js' ) ;
10
+ ace . config . set ( "basePath" , "https://esm.sh/ace-builds@1.35.4/src-noconflict" ) ;
11
+ ace . config . setModuleUrl (
12
+ "ace/mode/yaml" ,
13
+ "https://cdn.jsdelivr.net/npm/ace-builds@1.4.12/src-noconflict/mode-yaml.js"
14
+ ) ;
12
15
13
16
const Playground = ( ) => {
14
- const [ input , setInput ] = useState < string > ( "{}" ) ;
15
- const [ transforms , setTransforms ] = useState < string > ( "" ) ;
17
+ const [ input , setInput ] = useState < string > ( `{
18
+ "name": {
19
+ "first": " malory",
20
+ "last": "Archer"
21
+ },
22
+ "exes": [
23
+ " Nikolai Jakov ",
24
+ "Len Trexler",
25
+ "Burt Reynolds"
26
+ ],
27
+ "lastEx": 2
28
+ }` ) ;
29
+ const [ transforms , setTransforms ] = useState < string > (
30
+ `lastEx : derived.lastEx + 5
31
+ modified : derived.lastEx
32
+ original : input.lastEx
33
+ nameObject :
34
+ name : input.name.first | trim | capitalize + ' ' + input.name.last
35
+ age : 25
36
+ ex1 : '=>' + input.exes[0] | rtrim
37
+ isMinor : derived.nameObject.age > 18
38
+ nameLength : derived.nameObject.name | length
39
+ nameUpper : derived.nameObject.name | upper` ) ;
16
40
const [ output , setOutput ] = useState < string > ( "" ) ;
17
41
const [ mergeMethod , setMergeMethod ] = useState < string > ( "overwrite" ) ;
18
42
const [ errorMessage , setErrorMessage ] = useState < string > ( "" ) ;
@@ -27,11 +51,11 @@ const Playground = () => {
27
51
maxLines : 15 ,
28
52
enableBasicAutocompletion : true ,
29
53
enableLiveAutocompletion : true ,
30
- enableSnippets : true
54
+ enableSnippets : true ,
31
55
} ) ;
32
56
editor . setTheme ( Dracula ) ;
33
57
editor . setValue ( transforms , - 1 ) ;
34
- ace . config . loadModule ( ' ace/mode/yaml' , ( yamlMode : any ) => {
58
+ ace . config . loadModule ( " ace/mode/yaml" , ( yamlMode : any ) => {
35
59
editor . session . setMode ( new yamlMode . Mode ( ) ) ;
36
60
} ) ;
37
61
editor . session . on ( "change" , async ( ) => {
0 commit comments