-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Embedded Pdf Viewer #6681
New Embedded Pdf Viewer #6681
Conversation
@@ -39,6 +41,16 @@ export default function(link: Link, options: Options) { | |||
} | |||
|
|||
if (options.pdfViewerEnabled && resource.mime === 'application/pdf') { | |||
let anchorPageNo = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this and the next few lines could probably go inside the if (options.useCustomPdfViewer) {
condition as they aren't used outside of it
That seems like a lot of hassle to have a separate package for this. Couldn't you just put it under app-desktop/gui? That way we don't need all that build setup. |
I tried doing that at first but figured out since we will be using an iframe, we need to produce a single js bundle for the viewer and app-desktop does not currently use any such bundler like webpack. Because of the way note is rendered, the note body is converted to html first and then rendered inside an iframe, thus there is no access to react or other node modules. Putting it in a separate packages also makes the viewer more modular, ability to use other modules such as react and lastly we will be able to reuse majority of the code for the fullscreen viewer. |
Thanks for clarifying, it makes sense. We need to make sure it's all setup correctly without having extra manual steps - if you start from a clean repository, then run Also I believe you should set And check setupNewRelease.ts - you need to ensure that the package version is automatically updated, and include it in app-desktop using version Finally include build instructions in the README file of the package if you haven't already done so. |
Alright I will make the changes. |
Not sure if I did something wrong but after checking out the PR and running |
That's weird, I just tried doing a fresh install for this branch, I didn't face this issue. If you could take a look if there were any errors or recheck if it has the latest code. You can also check if:
|
packages/app-desktop/package.json
Outdated
@@ -138,6 +138,7 @@ | |||
"@fortawesome/fontawesome-free": "^5.13.0", | |||
"@joeattardi/emoji-button": "^4.6.0", | |||
"@joplin/lib": "~2.9", | |||
"@joplin/pdf-viewer": "~1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember it should be ~2.9. Having all the packages at the same version makes it easier to make deployments.
const result = spawnSync('yarn', ['run', 'build'], { shell: true }); | ||
if (result.status !== 0) { | ||
const msg = []; | ||
if (result.stdout) msg.push(result.stdout.toString()); | ||
if (result.stderr) msg.push(result.stderr.toString()); | ||
console.error(msg.join('\n')); | ||
if (result.error) console.error(result.error); | ||
process.exit(result.status); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you refactor convertJsx so as not to have all this duplicated code?
packages/pdf-viewer/Page.tsx
Outdated
const [page, setPage] = useState(null); | ||
const [scale, setScale] = useState(null); | ||
const [timestamp, setTimestamp] = useState(null); | ||
const canvasEl = useRef<HTMLCanvasElement>(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
canvasRef
packages/pdf-viewer/Page.tsx
Outdated
const [scale, setScale] = useState(null); | ||
const [timestamp, setTimestamp] = useState(null); | ||
const canvasEl = useRef<HTMLCanvasElement>(null); | ||
const wrapperEl = useRef<HTMLDivElement>(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrapperRef (for consistency)
What's the status of this PR? |
Hi, sorry for the delay, was facing a few issues with my local install. Will be pushing the updates soon. |
I think it's fine now. Please resolve the conflict so that we can merge |
I think this pr makes the new editor enabled by default and there's no option to switch it off. Are you sure you want to merge like this? |
I think having a setting for this and having it disabled by default would be a safer option for now. If you think the same, please give me some more time to add the feature too. |
Hmm, I think it's ok to enable it by default because it's not too critical and it will be in the pre-release first. Or are there any particular issues you're concerned about? Or any known bug? The flag to switch it off is just for us in case there's some major issue we cannot solve quickly. In that case we can switch it off and release a new version, which gives us time to work on a fix. |
Nothing in particular. One thing that has just came to mind - how will printing work with the new viewer? I've not tried it and can't test until tomorrow afternoon |
Laurent. this looks good to me btw but I'll let you to merge this when you see fit. |
Ok thanks, let's merge then. |
@asrient, some feedback on Discord:
https://discord.com/channels/610762468960239627/610762468960239629/1007309877305159802 This is actually a good point - at a minimum we need feature parity with the previous default PDF viewer, otherwise it's a regression. Do you think this is possible? In any case, I would suggest you make a list of features of the default viewer, and then a comparison with the new viewer, so that we have some visibility on what's missing. Maybe some features aren't too much an issue, but others might be. Please let me know if you're ok with this. |
Hi, since this pr was focused to bring the basic new custom embedded viewer, it admittedly lacks some features that are required to call it complete. I have already added a few features like zoom and print and will be creating pr soon for them subsequently. I will list the formal comparison here in some time. But one thing, I don't plan on adding a thumbnail view that the previous version had in the embedded viewer, it will be part of the full screen version. |
Thanks for the update. When the list is ready could you put it in your forum category please? |
Sure, will do that. |
function build(path) { | ||
chdir(path); | ||
|
||
const result = spawnSync('yarn', ['run', 'build'], { shell: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that you were calling yarn from here... Did you notice that launching the dev desktop app now takes more than 20 seconds, while before it would take less than 2 seconds?
Please fix this as soon as possible - any build step needs to happen when running yarn install
from the root.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for this, I did notice it before but didn't know it's a wrong approach. I was thinking of optimising the built time for pdf-viewer instead.
I have posted a fix for it now: #6762
Major changes made
pdf-viewer
.Embedded viewer features implemented in this PR
resource-id#page-no
format.Things not there yet
Demo
Lazy loading of pages
Theming
Window resize - dynamic page dimension
Page Anchoring (linking)
Reference links
https://discourse.joplinapp.org/t/coding-phase-week-5-report/26531
https://discourse.joplinapp.org/t/coding-phase-week-4-report/26446
https://discourse.joplinapp.org/t/coding-phase-week-2-and-3-report/26339
https://discourse.joplinapp.org/t/coding-period-week-1-report/26146
https://discourse.joplinapp.org/t/improve-pdf-previewer/25822