mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 01:48:26 +00:00
Allow to use the browser's pdf viewer
The viewerjs library has some limitations. Sometimes PDFs are quite blurry and some content is displayed scrambled. Switching to the browsers build-in PDF viewer (for chromium and firefox) fixes this. So while on mobile the viewerjs is the only working viewer, for desktop use it might be desireable to use the browsers builtin viewer instead.
This commit is contained in:
@ -19,6 +19,8 @@
|
|||||||
increase in accuracy by about 10%.
|
increase in accuracy by about 10%.
|
||||||
- A due date that is found during text analysis is now set on the
|
- A due date that is found during text analysis is now set on the
|
||||||
item. If multiple due dates are found, the earliest one is used.
|
item. If multiple due dates are found, the earliest one is used.
|
||||||
|
- Allow to switch between viewerjs PDF viewer or the browser's builtin
|
||||||
|
viewer.
|
||||||
|
|
||||||
### Configuration Changes
|
### Configuration Changes
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ import DatePicker exposing (DatePicker)
|
|||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Html.Events exposing (onClick, onInput)
|
import Html.Events exposing (onCheck, onClick, onInput)
|
||||||
import Http
|
import Http
|
||||||
import Markdown
|
import Markdown
|
||||||
import Page exposing (Page(..))
|
import Page exposing (Page(..))
|
||||||
@ -74,6 +74,7 @@ type alias Model =
|
|||||||
, sentMailsOpen : Bool
|
, sentMailsOpen : Bool
|
||||||
, attachMeta : Dict String Comp.AttachmentMeta.Model
|
, attachMeta : Dict String Comp.AttachmentMeta.Model
|
||||||
, attachMetaOpen : Bool
|
, attachMetaOpen : Bool
|
||||||
|
, pdfNativeView : Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -160,6 +161,7 @@ emptyModel =
|
|||||||
, sentMailsOpen = False
|
, sentMailsOpen = False
|
||||||
, attachMeta = Dict.empty
|
, attachMeta = Dict.empty
|
||||||
, attachMetaOpen = False
|
, attachMetaOpen = False
|
||||||
|
, pdfNativeView = False
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -212,6 +214,7 @@ type Msg
|
|||||||
| SentMailsResp (Result Http.Error SentMails)
|
| SentMailsResp (Result Http.Error SentMails)
|
||||||
| AttachMetaClick String
|
| AttachMetaClick String
|
||||||
| AttachMetaMsg String Comp.AttachmentMeta.Msg
|
| AttachMetaMsg String Comp.AttachmentMeta.Msg
|
||||||
|
| TogglePdfNativeView
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -935,6 +938,11 @@ update key flags next msg model =
|
|||||||
Nothing ->
|
Nothing ->
|
||||||
( model, Cmd.none )
|
( model, Cmd.none )
|
||||||
|
|
||||||
|
TogglePdfNativeView ->
|
||||||
|
( { model | pdfNativeView = not model.pdfNativeView }
|
||||||
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- view
|
-- view
|
||||||
@ -1206,6 +1214,17 @@ renderAttachmentView model pos attach =
|
|||||||
, text (Util.Size.bytesReadable Util.Size.B (toFloat attach.size))
|
, text (Util.Size.bytesReadable Util.Size.B (toFloat attach.size))
|
||||||
, text ")"
|
, text ")"
|
||||||
]
|
]
|
||||||
|
, div [ class "item" ]
|
||||||
|
[ div [ class "ui slider checkbox" ]
|
||||||
|
[ input
|
||||||
|
[ type_ "checkbox"
|
||||||
|
, onCheck (\_ -> TogglePdfNativeView)
|
||||||
|
, checked model.pdfNativeView
|
||||||
|
]
|
||||||
|
[]
|
||||||
|
, label [] [ text "Native view" ]
|
||||||
|
]
|
||||||
|
]
|
||||||
, div [ class "right menu" ]
|
, div [ class "right menu" ]
|
||||||
[ a
|
[ a
|
||||||
[ classList
|
[ classList
|
||||||
@ -1234,7 +1253,7 @@ renderAttachmentView model pos attach =
|
|||||||
"Goto original file"
|
"Goto original file"
|
||||||
|
|
||||||
else
|
else
|
||||||
"This is the original file"
|
"The file was not converted."
|
||||||
)
|
)
|
||||||
, href (fileUrl ++ "/original")
|
, href (fileUrl ++ "/original")
|
||||||
, target "_new"
|
, target "_new"
|
||||||
@ -1269,7 +1288,11 @@ renderAttachmentView model pos attach =
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
[ iframe
|
[ iframe
|
||||||
[ src (fileUrl ++ "/view")
|
[ if model.pdfNativeView then
|
||||||
|
src fileUrl
|
||||||
|
|
||||||
|
else
|
||||||
|
src (fileUrl ++ "/view")
|
||||||
]
|
]
|
||||||
[]
|
[]
|
||||||
]
|
]
|
||||||
|
Reference in New Issue
Block a user