Skip to content

Commit f23e7e0

Browse files
committed
export code editor
1 parent 8200273 commit f23e7e0

File tree

9 files changed

+468
-454
lines changed

9 files changed

+468
-454
lines changed

package-lock.json

Lines changed: 58 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@
5757
"lint-staged": "^12.5.0",
5858
"glob": "^10.3.3",
5959
"moment": "^2.29.4",
60-
"monaco-editor": "0.39.0",
61-
"monaco-yaml": "4.0.4",
60+
"monaco-editor": "0.44.0",
61+
"monaco-yaml": "5.1.1",
62+
"react-monaco-editor": "^0.55.0",
6263
"prettier": "^3.1.1",
6364
"react-select": "5.2.2",
6465
"react-ga4": "^1.4.1",
@@ -86,7 +87,6 @@
8687
"@typeform/embed-react": "2.20.0"
8788
},
8889
"dependencies": {
89-
"react-monaco-editor": "^0.54.0",
9090
"fast-json-patch": "^3.1.1",
9191
"jsonpath-plus": "^7.2.0",
9292
"sass": "^1.69.7",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { MODES } from '../Constants'
2+
import { Action, CodeEditorState, CodeEditorThemesKeys } from './types'
3+
4+
export const CodeEditorReducer = (state: CodeEditorState, action: Action) => {
5+
switch (action.type) {
6+
case 'changeLanguage':
7+
return { ...state, mode: action.value }
8+
case 'setDiff':
9+
return { ...state, diffMode: action.value }
10+
case 'setTheme':
11+
return { ...state, theme: action.value }
12+
case 'setCode':
13+
return { ...state, code: action.value }
14+
case 'setHeight':
15+
return { ...state, height: action.value.toString() }
16+
default:
17+
return state
18+
}
19+
}
20+
21+
export const initialState = (mode, theme, value, diffView, noParsing): CodeEditorState => ({
22+
mode,
23+
theme: theme || CodeEditorThemesKeys.vs,
24+
code: value,
25+
diffMode: diffView,
26+
noParsing: [MODES.JSON, MODES.YAML].includes(mode) ? noParsing : true,
27+
})

0 commit comments

Comments
 (0)