@@ -0,0 +1,77 @@
1+module Editor.Component where
4+import CSS.Safer (cssSafer)
5+import Data.Nullable (Nullable, notNull)
6+import Editor (defineThemeImpl, editor, initMonaco, nightOwlTheme, purescriptSyntax, registerLanguageImpl, setMonarchTokensProviderImpl, vsCodeTheme)
8+import Effect.Aff (Aff)
9+import Effect.Class (liftEffect)
10+import Effect.Uncurried (mkEffectFn2)
11+import Foreign (unsafeToForeign)
12+import React.Basic (ReactComponent, element, fragment)
13+import React.Basic.Hooks (Ref, component, writeRef)
14+import React.Basic.Hooks as React
15+import React.Basic.Hooks.Aff (useAff)
16+import React.Helpers (wrapperDiv)
17+import Theme.Styles (makeStyles, useTheme)
18+import Theme.Types (CSSTheme)
20+darkThemeName ∷ String
21+darkThemeName = "NightOwl"
23+lightThemeName ∷ String
24+lightThemeName = "VSCode"
29+ defineThemeImpl monaco darkThemeName nightOwlTheme # liftEffect
30+ defineThemeImpl monaco lightThemeName vsCodeTheme # liftEffect
31+ registerLanguageImpl monaco "purescript" # liftEffect
32+ setMonarchTokensProviderImpl monaco "purescript" purescriptSyntax # liftEffect
34+mkEditor ∷ Effect (ReactComponent { editorRef ∷ Ref (Nullable _) })
37+ makeStyles \(theme ∷ CSSTheme) ->
41+ , boxSizing: "border-box"
42+ , padding: "35px 40px"
45+ , borderRadius: "32px"
46+ , backgroundColor: theme.backgroundColour
49+ component "Editor" \{ editorRef } -> React.do
51+ useAff unit initEditor
54+ themeName = if theme.isLight then lightThemeName else darkThemeName
57+ [ wrapperDiv { className: classes.wrapper }
62+ { fontFamily: "PragmataPro"
63+ , fontLigatures: true
68+ , lineDecorationsWidth: 0
69+ , lineNumbersMinChars: 0
70+ , minimap: { enabled: false }
72+ , language: "purescript"
73+ -- https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-custom-languages
75+ mkEffectFn2 \_ -> notNull >>> writeRef editorRef