Comments (12)
I have pushed a branch with a solution to this:
feature/iframe_injection
from readium-shared-js.
Thanks!
This "solution" is elegant, but the navigator.epubReadingSystem object is
JSON-stringified (copied), therefore the actual instance does not
get shared amongst iframe-hosted EPUB HTML content documents. Am I right?
This is problematic, as any navigator.* object reference is meant to be
shared. We need navigator.epubReadingSystem to reflect a shared state (for
future use with widgets, etc.).
dan
On Monday, July 14, 2014, Juan Corona [email protected] wrote:
I have pushed a branch with a solution to this:
feature/iframe_injection—
Reply to this email directly or view it on GitHub
#41 (comment)
.
from readium-shared-js.
@danielweck
Yes, the epubReadingSystem is serialized into "source" text. This is how it's made available from the very start. This is not necessarily limited to JSON, as you can see by my attempt to pass along simple functions.
I'll see if I can pass along an actual instance before the iframe document is written to. (And how something like this behaves across multiple browser engines.)
from readium-shared-js.
It looks like by just simply doing
iframe.contentWindow.document.open();
iframe.contentWindow.navigator.epubReadingSystem = navigator.epubReadingSystem;
iframe.contentWindow.document.write(htmlText);
Achieves just that.
from readium-shared-js.
That would be great!
We now need to check all the features that depend on proper XHTML serialisation, like namespace-aware CSS selectors, annotations and Media Overlays -injected content, etc. We also need to thoroughly test on native apps, as the UIWebView tends to behave very differently in SDKLauncher-iOS/OSX/Android compared to pure browser implementations, especially when dealing with XHTML (e.g. self-closing tags).
from readium-shared-js.
For reference:
https://github.com/readium/readium-shared-js/blob/feature/iframe_injection/js/views/iframe_loader.js#L55
from readium-shared-js.
I am wondering whether the document.open()+write() approach has an impact on "programmatic fetching" (document / file Blobs, etc.) See readium/readium-js#54
from readium-shared-js.
I believe it will.. It calls the basic iframe loader's loadIframe
with an "empty" blob document as a source. This will throw everything off. I'm still unsure on how to test the use of the zipIframeLoader. Is it used in the chrome extension? Is it at all used from the cloud reader?
If the document.open()+write() approach is found to work on both loaders then we should refactor them to use the same approach.
from readium-shared-js.
I tried a similar approach – albeit not using document.open() + write() – to inject JavaScript before the page's JavaScript is executed and faced a problem when changing the spine item in fixed layout books. The first time we set the href of the iframe it worked properly but the second time (next spine item), my JavaScript wasn't executed. I had to recreate a new iframe for each chapter for the solution to work, but it introduced other bugs in the layout when rotating the screen.
It seems very similar to the issue Juan talked about on the mailing-list, in the mail entitled "[AppJS] Readium + MathJax & Iframe injection":
Iframes need to be destroyed and recreated on every content document change. Iframe elements once rendered cannot be re-used when switching documents, or else MathJax will not reinitialize and render MathML after the switch. This still needs to be implemented for all other views, not just reflowable views.
Did you check if the epubReadingSystem was still available when changing the spine item in a fixed-layout?
from readium-shared-js.
I remember having conversations with Boris about the pitfalls of "iframe
recycling". I'll be following this discussion very closely. Dan
On Wednesday, July 16, 2014, Mickaël Menu [email protected] wrote:
I tried a similar approach – albeit not using document.open() + write() –
to inject JavaScript before the page's JavaScript is executed and faced a
problem when changing the spine item in fixed layout books. The first time
we set the href of the iframe it worked properly but the second time (next
spine item), my JavaScript wasn't executed. I had to recreate a new iframe
for each chapter for the solution to work, but it introduced other bugs in
the layout when rotating the screen.It seems very similar to the issue Juan talked about on the mailing-list,
in the mail entitled "[AppJS] Readium + MathJax & Iframe injection":Iframes need to be destroyed and recreated on every content document
change. Iframe elements once rendered cannot be re-used when switching
documents, or else MathJax will not reinitialize and render MathML after
the switch. This still needs to be implemented for all other views, not
just reflowable views.Did you check if the epubReadingSystem was still available when changing
the spine item in a fixed-layout?—
Reply to this email directly or view it on GitHub
#41 (comment)
.
from readium-shared-js.
As verified by @aadamowski, document.write() breaks XML namespaces, see:
readium/readium-js#54
from readium-shared-js.
Fixed in
#76
from readium-shared-js.
Related Issues (20)
- Chapters getting truncated [iOS - readium-shared-js library] HOT 4
- Absolutely positioned elements are misplaced HOT 5
- Building URL query parameters strips out #fragments HOT 1
- FAQ: custom external font faces
- Hyperlinking: hash fragment identifiers are discarded by internal pagination / scroll offset logic? HOT 3
- Use of reserved word "package" HOT 2
- Turn pages very slow in big html files with Android System Webview 63 HOT 25
- calculatePageIndexDeltaByRectangles has wrong logic calculating pageIndex HOT 6
- Build output: UMD bundle HOT 4
- Internet Explorer very slow to resize document with large spines (100+ pages)
- Please help, openContentUrl() dosen't work well in Electron app when the url contains #. HOT 1
- Rangy dependency not needed strictly-speaking (SMIL experimental feature + Juan's highlighter) HOT 2
- Firefox: Resize Sensor does not trigger when content after expanded element flows into following columns in a certain way
- Highlights HOT 1
- In Redium Reader CFI - is it possible to go exact CFI location in a reflowable document when search text location are multiple in a page HOT 4
- Is there any reason why navigator.epubReadingSystem is writable? HOT 2
- Invalid location/CFI received HOT 2
- Issue with continuous scrolling using (macOs + Safari) trackpad
- The page turn is not done with the readaloud
- API Document
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from readium-shared-js.