Commit a1446170 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[code editor] fix codetype change from markdown to json

parent a49918b2
......@@ -111,7 +111,6 @@ renderPython s = s
-- | I took the idea from: https://github.com/satya164/react-simple-code-editor
codeEditor :: R2.Leaf Props
codeEditor = R2.leaf codeEditorCpt
codeEditorCpt :: R.Component Props
codeEditorCpt = here.component "codeEditor" cpt where
cpt {code, defaultCodeType, onChange} _ = do
......@@ -245,7 +244,6 @@ type ToolbarProps =
toolbar :: R2.Leaf ToolbarProps
toolbar = R2.leaf toolbarCpt
toolbarCpt :: R.Component ToolbarProps
toolbarCpt = here.component "toolbar" cpt where
cpt { controls: { codeS, codeType, viewType }
......@@ -294,7 +292,6 @@ type ErrorComponentProps =
errorComponent :: Record ErrorComponentProps -> R.Element
errorComponent p = R.createElement errorComponentCpt p []
errorComponentCpt :: R.Component ErrorComponentProps
errorComponentCpt = here.component "errorComponent" cpt
where
......@@ -313,7 +310,6 @@ type CodeTypeSelectorProps =
codeTypeSelector :: R2.Leaf CodeTypeSelectorProps
codeTypeSelector = R2.leaf codeTypeSelectorCpt
codeTypeSelectorCpt :: R.Component CodeTypeSelectorProps
codeTypeSelectorCpt = here.component "codeTypeSelector" cpt where
cpt { codeType, onChange } _ = do
......
......@@ -82,9 +82,11 @@ fieldsCodeEditorCpt = here.component "fieldsCodeEditorCpt" cpt
where
onChange :: Index -> FieldType -> Effect Unit
onChange idx typ = do
T.modify_ (\(FTFieldsWithIndex fs) ->
FTFieldsWithIndex $ fromMaybe fs $
List.modifyAt idx (\{ ftField: Field f} -> { idx, ftField: Field $ f { typ = typ } }) fs) fields
T.modify_ (
(\(FTFieldsWithIndex fs) ->
FTFieldsWithIndex $ fromMaybe fs $
List.modifyAt idx (\{ ftField: Field f} -> { idx, ftField: Field $ f { typ = typ } }) fs))
fields
onMoveDown :: T2.ReloadS -> Index -> Unit -> Effect Unit
onMoveDown masterKey idx _ = do
......@@ -352,7 +354,7 @@ changeCode onc (Python {python}) CE.Markdown _ = onc $ Markdown $ defaultMarkdow
changeCode onc (Markdown _) CE.Haskell c = onc $ Haskell $ defaultHaskell' { haskell = c }
changeCode onc (Markdown _) CE.Python c = onc $ Python $ defaultPython' { python = c }
changeCode onc (Markdown _) CE.JSON c = onc $ Markdown $ defaultMarkdown' { text = c }
changeCode onc (Markdown _) CE.JSON c = onc $ JSON $ defaultJSON' { desc = c }
changeCode onc (Markdown md) CE.Markdown c = onc $ Markdown $ md { text = c }
changeCode onc (JSON j) CE.Haskell _ = onc $ Haskell $ defaultHaskell' { haskell = haskell }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment