@@ -4,8 +4,7 @@ import Prelude
44
55import Ace.Editor as Editor
66import Ace.EditSession as Session
7- import Ace.Halogen.Component (AceState (), AceQuery (TextChanged, GetText), initialAceState )
8- import qualified Ace.Halogen.Component as Ace
7+ import Ace.Halogen.Component (AceState (), AceQuery (TextChanged, GetText), aceConstructor )
98
109import Control.Monad.Aff (Aff (), runAff )
1110import Control.Monad.Eff (Eff ())
@@ -23,7 +22,7 @@ import qualified Halogen.HTML.Indexed as H
2322-- Effects
2423import Control.Monad.Eff.Random (RANDOM ())
2524import Control.Monad.Eff.Ref (REF ())
26- import Ace.Types (ACE ())
25+ import Ace.Types (ACE (), Editor () )
2726import Data.Date (Now ())
2827
2928
@@ -61,23 +60,18 @@ ui = parentComponent' render eval peek
6160 render :: State -> MainHtml MainAff
6261 render state =
6362 H .div_
64- [ H .slot AceSlot \_ ->
65- { component :
66- Ace .aceComponent
67- (\editor -> liftEff $ do
68- session <- Editor .getSession editor
69- Session .setMode " ace/mode/yaml" session
70- Editor .setValue state.text Nothing editor
71- pure unit
72- )
73- Nothing
74- , initialState :
75- initialAceState
76- }
63+ [ H.Slot $ aceConstructor AceSlot (initEditor state) Nothing
7764 , H .div_
7865 [ H .text state.text ]
7966 ]
8067
68+ initEditor :: State -> Editor -> MainAff Unit
69+ initEditor state editor = liftEff $ do
70+ session <- Editor .getSession editor
71+ Session .setMode " ace/mode/yaml" session
72+ Editor .setValue state.text Nothing editor
73+ pure unit
74+
8175 eval :: EvalParent Query State AceState Query AceQuery MainAff AceSlot
8276 eval (UpdateText next) = do
8377 pure next
0 commit comments