mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 10:28:27 +00:00
Merge pull request #1425 from eikek/fix/pdf-view
Use iframe for cross-browser pdf view (pdfjs)
This commit is contained in:
@ -85,12 +85,12 @@ view texts flags settings model pos attach =
|
|||||||
, style "max-height" "calc(100vh - 140px)"
|
, style "max-height" "calc(100vh - 140px)"
|
||||||
, style "min-height" "500px"
|
, style "min-height" "500px"
|
||||||
]
|
]
|
||||||
[ embed
|
[ Data.UiSettings.pdfView settings
|
||||||
[ src <| Data.UiSettings.pdfUrl settings flags fileUrl
|
flags
|
||||||
, class "absolute h-full w-full top-0 left-0 mx-0 py-0"
|
fileUrl
|
||||||
|
[ class "absolute h-full w-full top-0 left-0 mx-0 py-0"
|
||||||
, id "ds-pdf-view-iframe"
|
, id "ds-pdf-view-iframe"
|
||||||
]
|
]
|
||||||
[]
|
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ module Data.UiSettings exposing
|
|||||||
, merge
|
, merge
|
||||||
, mergeDefaults
|
, mergeDefaults
|
||||||
, pdfUrl
|
, pdfUrl
|
||||||
|
, pdfView
|
||||||
, storedUiSettingsDecoder
|
, storedUiSettingsDecoder
|
||||||
, storedUiSettingsEncode
|
, storedUiSettingsEncode
|
||||||
, tagColor
|
, tagColor
|
||||||
@ -41,8 +42,8 @@ import Data.ItemTemplate exposing (ItemTemplate)
|
|||||||
import Data.Pdf exposing (PdfMode)
|
import Data.Pdf exposing (PdfMode)
|
||||||
import Data.UiTheme exposing (UiTheme)
|
import Data.UiTheme exposing (UiTheme)
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import Html exposing (Attribute)
|
import Html exposing (Attribute, Html, embed, iframe)
|
||||||
import Html.Attributes as HA
|
import Html.Attributes as HA exposing (src)
|
||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
import Json.Decode.Pipeline as P
|
import Json.Decode.Pipeline as P
|
||||||
import Json.Encode as Encode
|
import Json.Encode as Encode
|
||||||
@ -426,6 +427,33 @@ pdfUrl settings flags originalUrl =
|
|||||||
Data.Pdf.serverUrl originalUrl
|
Data.Pdf.serverUrl originalUrl
|
||||||
|
|
||||||
|
|
||||||
|
pdfView : UiSettings -> Flags -> String -> List (Attribute msg) -> Html msg
|
||||||
|
pdfView settings flags originalUrl attrs =
|
||||||
|
let
|
||||||
|
url =
|
||||||
|
pdfUrl settings flags originalUrl
|
||||||
|
|
||||||
|
native =
|
||||||
|
embed (src url :: attrs) []
|
||||||
|
|
||||||
|
fallback =
|
||||||
|
iframe (src url :: attrs) []
|
||||||
|
in
|
||||||
|
case settings.pdfMode of
|
||||||
|
Data.Pdf.Detect ->
|
||||||
|
if flags.pdfSupported then
|
||||||
|
native
|
||||||
|
|
||||||
|
else
|
||||||
|
fallback
|
||||||
|
|
||||||
|
Data.Pdf.Native ->
|
||||||
|
native
|
||||||
|
|
||||||
|
Data.Pdf.Server ->
|
||||||
|
fallback
|
||||||
|
|
||||||
|
|
||||||
getUiLanguage : Flags -> UiSettings -> UiLanguage -> UiLanguage
|
getUiLanguage : Flags -> UiSettings -> UiLanguage -> UiLanguage
|
||||||
getUiLanguage flags settings default =
|
getUiLanguage flags settings default =
|
||||||
case flags.account of
|
case flags.account of
|
||||||
|
Reference in New Issue
Block a user