Skip to content

Commit

Permalink
Fix display for other file types besides Elm modules
Browse files Browse the repository at this point in the history
The previous implementation only considered Elm modules in the setup of the Monaco editor and surroundings, resulting in suboptimal visuals.
The changes in this commit expand support to other file types, specifically JSON, XML, Markdown, HTML, and CSS.
Also, display the 'Format' and 'Compile' buttons only when these are usable on the file currently open in the editor.
  • Loading branch information
Viir committed May 3, 2024
1 parent ed91a57 commit 0cf8621
Show file tree
Hide file tree
Showing 5 changed files with 476 additions and 262 deletions.
40 changes: 40 additions & 0 deletions implement/example-apps/elm-editor/src/Frontend/FileEditor.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module Frontend.FileEditor exposing (..)


type FileContentType
= ElmContent
| JsonContent
| XmlContent
| MarkdownContent
| HtmlContent
| CssContent


fileContentTypeFromFileName : String -> Maybe FileContentType
fileContentTypeFromFileName fileName =
case fileName |> String.split "." |> List.reverse of
[] ->
Nothing

fileExtension :: _ ->
case String.toLower fileExtension of
"elm" ->
Just ElmContent

"json" ->
Just JsonContent

"xml" ->
Just XmlContent

"md" ->
Just MarkdownContent

"html" ->
Just HtmlContent

"css" ->
Just CssContent

_ ->
Nothing
Loading

0 comments on commit 0cf8621

Please sign in to comment.