wire up a main.elm

main
Brian Hicks 2019-10-16 00:02:33 -05:00
parent bf0d39c999
commit 772ae700c4
2 changed files with 62 additions and 1 deletions

56
src/Main.elm Normal file
View File

@ -0,0 +1,56 @@
module Main exposing (main)
import Browser
import Edit.Document as Document exposing (Document(..))
import Html exposing (Html)
type alias Flags =
()
type Attr
= Bold
| Italic
type alias Model =
{ doc : Document Attr }
type Msg
= TODO
init : Flags -> ( Model, Cmd Msg )
init _ =
( { doc =
Document
[ Document.Text "Hey" [ Bold ]
, Document.Text " " []
, Document.Text "there" [ Italic ]
, Document.Text "!" []
]
}
, Cmd.none
)
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
( model, Cmd.none )
view : Model -> Html msg
view model =
Html.text <| Debug.toString model
main : Program Flags Model Msg
main =
Browser.element
{ init = init
, update = update
, view = view
, subscriptions = \_ -> Sub.none
}

View File

@ -1 +1,6 @@
require("./elm-edit-element.js");
require("./elm-edit-element.js"); // custom element
const { Elm } = require("./Main.elm");
Elm.Main.init({
node: document.getElementById("app")
});