Compare commits
2 Commits
51b1fa2b17
...
16eef14e04
Author | SHA1 | Date | |
---|---|---|---|
16eef14e04 | |||
291e0a8d75 |
@ -27,9 +27,9 @@
|
||||
"devDependencies": {
|
||||
"elm": "^0.18.0",
|
||||
"elm-live": "^2.7.4",
|
||||
"elm-test": "^0.18.3",
|
||||
"elm-test": "^0.18.13",
|
||||
"gh-pages": "^0.12.0",
|
||||
"rimraf": "^2.6.1",
|
||||
"uglify-js": "^3.0.1"
|
||||
"uglify-js": "^3.15.3"
|
||||
}
|
||||
}
|
||||
|
@ -212,6 +212,8 @@ span.applink {
|
||||
display: block;
|
||||
float: left;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
object-fit: cover;
|
||||
border-radius: 50%;
|
||||
margin-top: 2px;
|
||||
}
|
||||
@ -1162,3 +1164,9 @@ audio.viewer-content {
|
||||
height: 18px;
|
||||
margin: 0 1px;
|
||||
}
|
||||
|
||||
.emoji-custom {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ accountView subView currentUser accountInfo =
|
||||
else
|
||||
text ""
|
||||
]
|
||||
, span [ class "account-note" ] (formatContent account.note [] [])
|
||||
, span [ class "account-note" ] (formatContent account.note [] account.emojis)
|
||||
]
|
||||
]
|
||||
, fields subView account
|
||||
|
@ -1,7 +1,6 @@
|
||||
module View.Formatter exposing (formatContent, textContent)
|
||||
|
||||
import Dict
|
||||
import Elmoji
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import HtmlParser
|
||||
@ -11,6 +10,8 @@ import Mastodon.Model exposing (..)
|
||||
import String.Extra exposing (replace, rightOf)
|
||||
import Types exposing (..)
|
||||
import View.Events exposing (..)
|
||||
import Regex
|
||||
import Json.Encode
|
||||
|
||||
|
||||
formatContent : String -> List Mention -> List Emoji -> List (Html Msg)
|
||||
@ -119,9 +120,32 @@ toVirtualDomEach mentions emoji node =
|
||||
text ""
|
||||
|
||||
|
||||
-- VERY janky.
|
||||
handleEmoji : String -> List Emoji -> Html Msg
|
||||
handleEmoji s emoji =
|
||||
Elmoji.text_ s -- todo
|
||||
handleEmoji s emojis =
|
||||
span [ property "innerHTML" <| Json.Encode.string <| Regex.replace Regex.All shortcodeRegex (\{match} -> displayEmoji match emojis) <| s ] []
|
||||
|
||||
|
||||
displayEmoji : String -> List Emoji -> String
|
||||
displayEmoji s emojis =
|
||||
case (lookupEmoji (String.slice 1 -1 s) emojis) of
|
||||
Just emoji ->
|
||||
"<img src=\""++emoji.url++"\" title=\""++s++"\" class=\"emoji-custom\">"
|
||||
|
||||
Nothing ->
|
||||
s
|
||||
|
||||
|
||||
lookupEmoji : String -> List Emoji -> Maybe Emoji
|
||||
lookupEmoji shortcode emojis =
|
||||
emojis
|
||||
|> List.filter (\m -> m.shortcode == shortcode)
|
||||
|> List.head
|
||||
|
||||
|
||||
shortcodeRegex : Regex.Regex
|
||||
shortcodeRegex =
|
||||
Regex.regex ":[^:]*(?:::]*)*:"
|
||||
|
||||
|
||||
toAttribute : ( String, String ) -> Attribute msg
|
||||
|
Loading…
Reference in New Issue
Block a user