gerhardsletten / react-reader

An ePub-reader for React, powered by Epub.js
https://react-reader.metabits.no
Apache License 2.0
676 stars 130 forks source link

Cen we get Input from interactive epub to save it to backend DB? #156

Closed junior-g closed 1 year ago

junior-g commented 1 year ago

I am developing an epub reader UI for test assessments for college exams. Which will render interactive epub files to load questions and for scoring and other purpose I wanted to get answers selected for each question. So can anyone suggest some examples of how we can get inputs from interactive epub so that we can do extra processing separately?

gerhardsletten commented 1 year ago

@junior-g Not sure how well the epub standard support form-tag or inline js to handle ajax submission of form data. The underlaying library epub-js render the html-content from the epub inside a iframe, and an iframe has a sandbox attribute to allow different things. There is an open issue on epub-js for full controll of this attribute, see futurepress/epub.js/issues/1083

But epubjs support both allowScriptedContent which adds allow-scripts or allowPopups which adds allow-popups to the sandbox attribute, you can use them with react-reader this way:

<ReactReader
  epubOptions={{
    allowScriptedContent: true
  }}
/>

But if I was to develop something like this I would rather listen to the location of the epub, and when the user navigate to the end of the epub, display a custom react-view with the input-fields, since controlling state and validation is so much easier directly in react, than embedding it within the epub.

junior-g commented 1 year ago

Ya that worked thanks