11import { Modal } from "@carbon/react"
22import { InlineLoadingStatus } from "@carbon/react/lib/components/InlineLoading/InlineLoading"
3- import hljs from "highlight.js/lib/core"
4- import json from "highlight.js/lib/languages/json"
53import { useState } from "react"
64import { createPortal } from "react-dom"
7- import Editor from "react-simple-code-editor"
85import { importFlowFromJson } from "../../../singletons/store/appActions"
9-
10- hljs . registerLanguage ( "json" , json )
6+ import { ModalCodeEditor } from "../../editor/ModalCodeEditor"
117
128interface ImportFlowModalProps {
139 open : boolean
1410 setOpen : ( open : boolean ) => void
1511}
1612
17- interface JsonEditorProps {
18- content : string
19- setContent : ( content : string ) => void
20- }
21-
2213const getLoadingDescription = ( status : InlineLoadingStatus ) => {
2314 switch ( status ) {
2415 case "active" :
@@ -31,20 +22,6 @@ const getLoadingDescription = (status: InlineLoadingStatus) => {
3122 }
3223}
3324
34- const FlowJsonEditor = ( { content, setContent } : JsonEditorProps ) => {
35- return (
36- < div className = "options-modal__editor" >
37- < Editor
38- value = { content }
39- onValueChange = { ( code ) => setContent ( code ) }
40- highlight = { ( code ) => hljs . highlight ( code , { language : "json" } ) . value }
41- padding = { 16 }
42- textareaClassName = "options-modal__editor-textarea"
43- />
44- </ div >
45- )
46- }
47-
4825export const ImportFlowModal = ( { open, setOpen } : ImportFlowModalProps ) => {
4926 const [ loadingStatus , setLoadingStatus ] =
5027 useState < InlineLoadingStatus > ( "inactive" )
@@ -84,7 +61,11 @@ export const ImportFlowModal = ({ open, setOpen }: ImportFlowModalProps) => {
8461 loadingDescription = { getLoadingDescription ( loadingStatus ) }
8562 onRequestSubmit = { doImport }
8663 >
87- < FlowJsonEditor content = { content } setContent = { updateContent } />
64+ < ModalCodeEditor
65+ content = { content }
66+ setContent = { updateContent }
67+ language = "json"
68+ />
8869 </ Modal > ,
8970 document . body
9071 )
0 commit comments