diff --git a/public/style.css b/public/style.css index 061f452..ecf6fe9 100644 --- a/public/style.css +++ b/public/style.css @@ -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; +} diff --git a/src/View/Account.elm b/src/View/Account.elm index 8de07e5..d42e446 100644 --- a/src/View/Account.elm +++ b/src/View/Account.elm @@ -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 diff --git a/src/View/Formatter.elm b/src/View/Formatter.elm index d7b090e..6176602 100644 --- a/src/View/Formatter.elm +++ b/src/View/Formatter.elm @@ -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 -> + "" + + 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