1
0
Fork 0

Fix #27: Render universal emojis.

This commit is contained in:
Nicolas Perriault 2017-05-13 11:21:29 +02:00
parent d47a5ad7cc
commit 9753efe7e8
No known key found for this signature in database
GPG Key ID: DA5E4C83904F7A2A
3 changed files with 26 additions and 20 deletions

View File

@ -22,6 +22,7 @@
"jinjor/elm-html-parser": "1.1.5 <= v < 2.0.0",
"lukewestby/elm-http-builder": "5.1.0 <= v < 6.0.0",
"rluiten/elm-date-extra": "8.5.0 <= v < 9.0.0",
"teepark/elmoji": "2.0.2 <= v < 3.0.0",
"thebritican/elm-autocomplete": "4.0.3 <= v < 5.0.0"
},
"elm-version": "0.18.0 <= v < 0.19.0"

View File

@ -810,3 +810,11 @@ input.form-control[type=file] {
.modal-content {
flex: 1 1 auto;
}
/* Emojis */
.elmoji-img {
width: 18px;
height: 18px;
margin-right: 1px;
}

View File

@ -1,5 +1,6 @@
module View.Formatter exposing (formatContent)
import Elmoji
import Html exposing (..)
import Html.Attributes exposing (..)
import HtmlParser
@ -32,31 +33,27 @@ toVirtualDom mentions nodes =
createLinkNode : List ( String, String ) -> List HtmlParser.Node -> List Mention -> Html Msg
createLinkNode attrs children mentions =
let
maybeMention =
getMentionForLink attrs mentions
in
case maybeMention of
Just mention ->
Html.node "a"
((List.map toAttribute attrs)
++ [ onClickWithPreventAndStop (LoadAccount mention.id) ]
)
(toVirtualDom mentions children)
case (getMentionForLink attrs mentions) of
Just mention ->
Html.node "a"
((List.map toAttribute attrs)
++ [ onClickWithPreventAndStop (LoadAccount mention.id) ]
)
(toVirtualDom mentions children)
Nothing ->
Html.node "a"
((List.map toAttribute attrs)
++ [ onClickWithStop NoOp, target "_blank" ]
)
(toVirtualDom mentions children)
Nothing ->
Html.node "a"
((List.map toAttribute attrs)
++ [ onClickWithStop NoOp, target "_blank" ]
)
(toVirtualDom mentions children)
getHrefLink : List ( String, String ) -> Maybe String
getHrefLink attrs =
attrs
|> List.filter (\( name, value ) -> (name == "href"))
|> List.map (\( name, value ) -> value)
|> List.filter (\( name, _ ) -> name == "href")
|> List.map (\( _, value ) -> value)
|> List.head
@ -82,7 +79,7 @@ toVirtualDomEach mentions node =
Html.node name (List.map toAttribute attrs) (toVirtualDom mentions children)
HtmlParser.Text s ->
text s
Elmoji.text_ s
HtmlParser.Comment _ ->
text ""