mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Display search highlighting in webapp
This commit is contained in:
@ -8,6 +8,7 @@ module Comp.ItemCardList exposing
|
|||||||
, view
|
, view
|
||||||
)
|
)
|
||||||
|
|
||||||
|
import Api.Model.HighlightEntry exposing (HighlightEntry)
|
||||||
import Api.Model.ItemLight exposing (ItemLight)
|
import Api.Model.ItemLight exposing (ItemLight)
|
||||||
import Api.Model.ItemLightGroup exposing (ItemLightGroup)
|
import Api.Model.ItemLightGroup exposing (ItemLightGroup)
|
||||||
import Api.Model.ItemLightList exposing (ItemLightList)
|
import Api.Model.ItemLightList exposing (ItemLightList)
|
||||||
@ -19,6 +20,7 @@ import Data.UiSettings exposing (UiSettings)
|
|||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Html.Events exposing (onClick)
|
import Html.Events exposing (onClick)
|
||||||
|
import Markdown
|
||||||
import Ports
|
import Ports
|
||||||
import Util.List
|
import Util.List
|
||||||
import Util.String
|
import Util.String
|
||||||
@ -247,4 +249,41 @@ viewItem settings item =
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
, div
|
||||||
|
[ classList
|
||||||
|
[ ( "content search-highlight", True )
|
||||||
|
, ( "invisible hidden", item.highlighting == [] )
|
||||||
|
]
|
||||||
|
]
|
||||||
|
[ div [ class "ui list" ]
|
||||||
|
(List.map renderHighlightEntry item.highlighting)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
renderHighlightEntry : HighlightEntry -> Html Msg
|
||||||
|
renderHighlightEntry entry =
|
||||||
|
let
|
||||||
|
stripWhitespace str =
|
||||||
|
String.trim str
|
||||||
|
|> String.replace "```" ""
|
||||||
|
|> String.replace "\t" " "
|
||||||
|
|> String.replace "\n\n" "\n"
|
||||||
|
|> String.lines
|
||||||
|
|> List.map String.trim
|
||||||
|
|> String.join "\n"
|
||||||
|
in
|
||||||
|
div [ class "item" ]
|
||||||
|
[ div [ class "content" ]
|
||||||
|
(div [ class "header" ]
|
||||||
|
[ i [ class "caret right icon" ] []
|
||||||
|
, text (entry.name ++ ":")
|
||||||
|
]
|
||||||
|
:: List.map
|
||||||
|
(\str ->
|
||||||
|
Markdown.toHtml [ class "description" ] <|
|
||||||
|
(stripWhitespace str ++ "…")
|
||||||
|
)
|
||||||
|
entry.lines
|
||||||
|
)
|
||||||
]
|
]
|
||||||
|
@ -88,6 +88,22 @@
|
|||||||
right: -8px;
|
right: -8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.default-layout .ui.cards .ui.card .content.search-highlight {
|
||||||
|
background: rgba(246, 255, 158, 0.15);
|
||||||
|
font-size: smaller;
|
||||||
|
max-height: 25em;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
.default-layout .ui.cards .ui.card .content.search-highlight .ui.list .item .content .header {
|
||||||
|
}
|
||||||
|
.default-layout .ui.cards .ui.card .content.search-highlight .ui.list .item .content .description {
|
||||||
|
color: rgba(0,0,0,.55);
|
||||||
|
margin-left: 0.75em;
|
||||||
|
}
|
||||||
|
.default-layout .ui.cards .ui.card .content.search-highlight .ui.list .item .content .description strong > em {
|
||||||
|
color: rgba(0,0,0,.65);
|
||||||
|
}
|
||||||
|
|
||||||
.markdown-preview {
|
.markdown-preview {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
max-height: 300px;
|
max-height: 300px;
|
||||||
|
Reference in New Issue
Block a user