mirror of
				https://github.com/TheAnachronism/docspell.git
				synced 2025-10-31 17:50:11 +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 "min-height" "500px" | ||||
|                 ] | ||||
|                 [ embed | ||||
|                     [ src <| Data.UiSettings.pdfUrl settings flags fileUrl | ||||
|                     , class "absolute h-full w-full top-0 left-0 mx-0 py-0" | ||||
|                 [ Data.UiSettings.pdfView settings | ||||
|                     flags | ||||
|                     fileUrl | ||||
|                     [ class "absolute h-full w-full top-0 left-0 mx-0 py-0" | ||||
|                     , id "ds-pdf-view-iframe" | ||||
|                     ] | ||||
|                     [] | ||||
|                 ] | ||||
|         ] | ||||
|  | ||||
|   | ||||
| @@ -24,6 +24,7 @@ module Data.UiSettings exposing | ||||
|     , merge | ||||
|     , mergeDefaults | ||||
|     , pdfUrl | ||||
|     , pdfView | ||||
|     , storedUiSettingsDecoder | ||||
|     , storedUiSettingsEncode | ||||
|     , tagColor | ||||
| @@ -41,8 +42,8 @@ import Data.ItemTemplate exposing (ItemTemplate) | ||||
| import Data.Pdf exposing (PdfMode) | ||||
| import Data.UiTheme exposing (UiTheme) | ||||
| import Dict exposing (Dict) | ||||
| import Html exposing (Attribute) | ||||
| import Html.Attributes as HA | ||||
| import Html exposing (Attribute, Html, embed, iframe) | ||||
| import Html.Attributes as HA exposing (src) | ||||
| import Json.Decode as Decode | ||||
| import Json.Decode.Pipeline as P | ||||
| import Json.Encode as Encode | ||||
| @@ -426,6 +427,33 @@ pdfUrl settings flags 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 settings default = | ||||
|     case flags.account of | ||||
|   | ||||
		Reference in New Issue
	
	Block a user