Closed michaelpeterlee closed 5 years ago
We stopped passing the config file path to the UI as part of its URL to prevent potential XSS attack. If you'd like to load your own config while developing the UI, please make a change to this file: https://github.com/PDFTron/webviewer-ui/blob/60eeaf0f73990e39462f0d8ba8c28315f87a5bd7/src/helpers/loadScript.js#L26-L29
Instead of just calling resolve()
, try using the loadScript
function like below:
loadScript('viewer-config.js').then(resolve)
Hi Mike, just want to follow up to see how it works for you and if you have any other questions.
Thanks Zhijie, that resolves the config.
You may like to consider that as the new default and expose that somewhere else, else folks have to fiddle there to develop which is not intuitive.
Re: $(document).on('documentLoaded') Re: readerControl.docViewer.on('documentLoaded')
These listeners do not reveal any events during development in this project, yet it works when in production.
We need to develop with customisations, so can you please advise what we need to do to our external WebViewer config file to get this to work.
Hmm I can't seem to reproduce the issue. Here are the steps that I took:
config.js
inside the assets
folder.config.js
:
$(document).on('documentLoaded', () => {
console.log('document just loaded!');
});
loadScript.js
, change line 28 to
loadScript('/assets/config.js').then(resolve);
npm start
document just loaded!
in the console, which indicates that the config file is working.I'd like to confirm first that your config file is actually be requested? You can use the Chrome dev tools, network tab to check if there's a request sent to your config file. It'd be also helpful if you can send me a sample project in which I can reproduce the issue. Thanks!
To get events to fire, we have to wrap event-listener instantiations with setTimeout to apply on next clock.
documentLoaded
then fires but viewerLoaded
still does not. Investigating further now..
We replaced our viewer-config.js
with just the listeners and it works. So something is bombing silently in our config file. Thanks for your help to confirm things work after editing the loadScript helper.
Re: http://localhost:3000/#d=https://pdftron.s3.amazonaws.com/downloads/pl/demo-annotated.pdf&a=1&config=viewer-config.js
Chrome inspector reveals no network request for this resource.
Q. How do we develop in association with a custom config file ?