Comments (24)
https://github.com/readium/SDKLauncher-iOS/blob/master/Classes/EPubViewController.m#L176
[self executeJavaScript:@"JAVASCRIPT_CODE" completionHandler:nil];
Replace "JAVASCRIPT_CODE" with: ReadiumSDK.reader.plugins.highlights.addSelectionHighlight(Math.floor((Math.random()*1000000)), "test-highlight");
Note, that's how it's also done in the cloud reader / Chrome app:
https://github.com/readium/readium-js-viewer/blob/develop/src/js/EpubReader.js#L824
PS: don't forget to npm run build
readium-shared-js with the "highlights" plugin enabled in the CSON configuration:
https://github.com/readium/readium-shared-js/blob/develop/plugins/plugins.cson#L1
(then, the contents of the build-output/
folder will contain the Javascript code needed by SDKLauncher-iOS)
from sdklauncher-ios.
Thank you very much Daniel.
I going to implement step by step according to your reply,but highlight does not work on IOS.
this is the debug code
readium-shared-js/plugins/highlights/manager.js
https://github.com/readium/readium-shared-js/blob/develop/plugins/highlights/manager.js#L143
this.addSelectionHighlight = function(id, type, styles, clearSelection) {
window.webkit.messageHandlers.readium.postMessage({body: 'addSelectionHighlight'});
for(var spine in liveAnnotations) {
var annotationsForView = liveAnnotations[spine];
if (annotationsForView.getCurrentSelectionCFI()) {
var annotation = annotationsForView.addSelectionHighlight(
id, type, styles, clearSelection);
return new BookmarkData(spines[spine].idref, annotation.CFI);
}
}
return undefined;
};
the addSelectionHighlight() function cann't execute
Thanks in advance,
Kind regards
from sdklauncher-ios.
What do you mean by "cannot execute"? Is there an error like "undefined function"? Or is another exception raised?
from sdklauncher-ios.
Thank you Daniel for your fast response and help
the log print:
[Warning] WARNING! Annotations CSS not supplied. Highlighting might not work. (readium-plugin-highlights.js, line 2000) [Warning] Plugin highlights: Unable to attach to currently loaded content document. (readium-shared-js.js, line 586) Initialize the plugin before loading a content document.
from sdklauncher-ios.
Ah, sorry, there is a bug in:
https://github.com/readium/SDKLauncher-iOS/blob/develop/Resources/host_app_feedback.js#L199
=>
reader.plugins.annotations
should be replaced with reader.plugins.highlights
from sdklauncher-ios.
Thank you
I just replaced (reader.plugins.annotations replaced with reader.plugins.highlights),
but xcode print:
SDKLauncher-iOS[42000:905612] Error Domain=WKErrorDomain Code=5 "JavaScript execution returned a result of an unsupported type" UserInfo={NSLocalizedDescription=JavaScript execution returned a result of an unsupported type}
from sdklauncher-ios.
Is the error coming from SDKLauncher-iOS/Resources/host_app_feedback.js
?
Which function call? (do you have a stacktrace?)
from sdklauncher-ios.
Note that the same code is used in the cloud reader / Chrome app:
https://github.com/readium/readium-js-viewer/blob/develop/src/js/EpubReader.js#L1105
iOS:
https://github.com/readium/SDKLauncher-iOS/blob/develop/Resources/host_app_feedback.js#L199
from sdklauncher-ios.
the host_app_feedback.js file in code:
https://github.com/readium/SDKLauncher-iOS/blob/develop/Resources/host_app_feedback.js#L196
var opts = { needsFixedLayoutScalerWorkAround: true, el: "#viewport", annotationCSSUrl: '/readium_Annotations.css' //prefix + '/css/annotations.css' };
but I cannot found readium_Annotations.css file
Thank you so much Daniel
Kind regards
from sdklauncher-ios.
The /readium_Annotations.css
URL is "special", in the sense that it does not correspond to a real file name. Instead, the iOS app intercepts the HTTP request for this URL, and returns a response with the contents of the real file annotations.css
. See:
https://github.com/readium/SDKLauncher-iOS/blob/master/Classes/EPubViewController.m#L141
https://github.com/readium/readium-sdk/blob/develop/Platform/Apple/RDServices/Main/RDPackageResourceConnection.m#L193
from sdklauncher-ios.
FYI, "plugin.annotations" now renamed to "plugin.highlights".
iOS fix:
fa0ddcb
OSX fix:
readium/SDKLauncher-OSX@df7f819
Android fix:
readium/SDKLauncher-Android@aabd318
from sdklauncher-ios.
Hi Daniel
I replaced (reader.plugins.annotations replaced with reader.plugins.highlights),
https://github.com/readium/SDKLauncher-iOS/blob/develop/Resources/host_app_feedback.js#L204
but nothing happens.
[Error] TypeError: undefined is not an object (evaluating 'lastTouch.pageX') boundHighlightCallback (readium-plugin-highlights.js:1189) dispatch (readium-external-libs.js:4737) handle (readium-external-libs.js:4549)
from sdklauncher-ios.
Interesting. This looks like an iOS -specific bug (touch events). @jccr did you come across this?
from sdklauncher-ios.
It works
ReadiumSDK.reader.plugins.highlights.addSelectionHighlight(Math.floor((Math.random()*1000000)), "test-highlight")
replaced with ReadiumSDK.reader.plugins.highlights.addSelectionHighlight(Math.floor((Math.random()*1000000)), "highlight")
Thank you so much Daniel
from sdklauncher-ios.
Hi @danielweck
When change the font size,Highlighting dislocation
from sdklauncher-ios.
Hi @danielweck
When change the chapter or into other epub books,ReadiumSDK.reader.plugins.highlights.addSelectionHighlight(Math.floor((Math.random()*1000000)), "highlight") does not work.
from sdklauncher-ios.
On iOS, e.changedTouches
on line 16861 of readium-shared-js_all.js is undefined when I touch a highlight. Changing to
var lastTouch = _.last(e.originalEvent.changedTouches);
does then trigger the AnnotationHoverIn event, but there is then an exception on line 117 where
if (!this._events[evt]) return false;
because _events
is undefined. Any thoughts on a fix would be greatly appreciated.
from sdklauncher-ios.
@lwm561
When change the font size,Highlighting dislocation
Thanks for the feedback. Issue filed: readium/readium-shared-js#364
from sdklauncher-ios.
@nimisis
undefined e.changedTouches
Thank you for reporting this. Issue filed: readium/readium-shared-js#365
from sdklauncher-ios.
@nimisis I am not able to find references to if (!this._events[evt]) return false;
, could you please give me a pointer into the develop
branch? Thank you!
Daniel
from sdklauncher-ios.
@danielweck Sure, it triggered on line 117 of index.js when I was debugging with Safari, but it looks like it's at line 15105 of readium-shared-js_all.js of the single bundle or line 14898 of readium-external-libs.js of the multiple-bundles. Hope that helps!
from sdklauncher-ios.
oh, this sounds like a bug in an external library then. what revision of Readium are you using? (git commit hash)
also, would you be able to build your own readium-shared-js lib from source? (from the master or develop branch)
and finally, you should be able to use the readium-shared-js sourcemaps with your pre-built (or self-built) lib, so that the web inspector / debugger shows human-friendly code references / breakpoints.
from sdklauncher-ios.
This one - readium/readium-sdk@153ee28
Happy to try to build my own readium-shared-js lib from source, though if there are some instructions somewhere you might kindly point me to that would be much appreciated.
from sdklauncher-ios.
@nimisis build instructions in the README: https://github.com/readium/readium-shared-js/blob/develop/README.md#prerequisites
(basically: cd readium-shared-js && npm run prepare && npm run build && ls build-output/
)
from sdklauncher-ios.
Related Issues (20)
- Text selection in continuous scroll mode fails on iOS 12
- xcode project missing js and css file HOT 2
- reader not scrolling : IOS 13.x HOT 5
- 您好,如何把sdk导入到自己的项目中,我这边报错C++ requires a type specifier for all declar HOT 2
- This SDK not supported for iOS 13 but working fine in iOS 12.4.2. Please help me
- Please Provide full version HOT 2
- SDK Launcher- ios HOT 2
- Regarding exporting of annotations to our backend server. HOT 3
- ePubLibrary view with cover image HOT 3
- Errors with Book Marks HOT 5
- Swipe Navigation HOT 4
- In iOS How to get the click on the location of the information and get the selected text string? HOT 1
- Footnotes with elementCfi containing square brackets do not navigate to correct page HOT 7
- how can we calculate total no of pages in a book in Background HOT 3
- some errors about “Platform” namespace HOT 1
- Reference Cover image From Epub HOT 6
- Request a demo that runs normally HOT 2
- How to detect user pressing on link inside the book HOT 2
- I've imported the dependencies on my project. But didn't get any clue to use those sdks. Can anyone explain how to use Redium sdks with some examples stepwise? HOT 1
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 sdklauncher-ios.