Add markdown rendering for messages that have it.
This commit is contained in:
parent
eb9e82483b
commit
590764adc4
7
elm.json
7
elm.json
|
@ -15,11 +15,14 @@
|
|||
"elm/json": "1.1.2",
|
||||
"elm/svg": "1.0.1",
|
||||
"elm/time": "1.0.0",
|
||||
"elm/url": "1.0.0"
|
||||
"elm/url": "1.0.0",
|
||||
"hecrj/html-parser": "2.0.0"
|
||||
},
|
||||
"indirect": {
|
||||
"elm/bytes": "1.0.7",
|
||||
"elm/virtual-dom": "1.0.2"
|
||||
"elm/parser": "1.1.0",
|
||||
"elm/virtual-dom": "1.0.2",
|
||||
"rtfeldman/elm-hex": "1.0.0"
|
||||
}
|
||||
},
|
||||
"test-dependencies": {
|
||||
|
|
|
@ -6,6 +6,8 @@ import Scylla.Fnv as Fnv
|
|||
import Scylla.Login exposing (Username)
|
||||
import Scylla.Http exposing (fullMediaUrl)
|
||||
import Scylla.Api exposing (ApiUrl)
|
||||
import Html.Parser
|
||||
import Html.Parser.Util
|
||||
import Svg
|
||||
import Svg.Attributes
|
||||
import Url.Builder
|
||||
|
@ -195,9 +197,15 @@ messageTextView : Model -> RoomEvent -> Maybe (Html Msg)
|
|||
messageTextView m re =
|
||||
let
|
||||
body = Decode.decodeValue (Decode.field "body" Decode.string) re.content
|
||||
customHtml = Maybe.map Html.Parser.Util.toVirtualDom
|
||||
<| Maybe.andThen (Result.toMaybe << Html.Parser.run )
|
||||
<| Result.toMaybe
|
||||
<| Decode.decodeValue (Decode.field "formatted_body" Decode.string) re.content
|
||||
wrap mtext = span [] [ text mtext ]
|
||||
in
|
||||
Maybe.map wrap <| Result.toMaybe body
|
||||
case customHtml of
|
||||
Just c -> Just <| div [ class "markdown-wrapper" ] c
|
||||
Nothing -> Maybe.map wrap <| Result.toMaybe body
|
||||
|
||||
messageImageView : Model -> RoomEvent -> Maybe (Html Msg)
|
||||
messageImageView m re =
|
||||
|
|
|
@ -184,6 +184,12 @@ table.events-table {
|
|||
}
|
||||
}
|
||||
|
||||
div.markdown-wrapper {
|
||||
p {
|
||||
margin: 0px;
|
||||
}
|
||||
}
|
||||
|
||||
span.sender-wrapper {
|
||||
border-radius: 2px;
|
||||
padding-left: 5px;
|
||||
|
|
Loading…
Reference in New Issue
Block a user