GithubHelp home page GithubHelp logo

Comments (24)

danielweck avatar danielweck commented on August 21, 2024

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.

lwm561 avatar lwm561 commented on August 21, 2024

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.

danielweck avatar danielweck commented on August 21, 2024

What do you mean by "cannot execute"? Is there an error like "undefined function"? Or is another exception raised?

from sdklauncher-ios.

lwm561 avatar lwm561 commented on August 21, 2024

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.

danielweck avatar danielweck commented on August 21, 2024

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.

lwm561 avatar lwm561 commented on August 21, 2024

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.

danielweck avatar danielweck commented on August 21, 2024

Is the error coming from SDKLauncher-iOS/Resources/host_app_feedback.js?
Which function call? (do you have a stacktrace?)

from sdklauncher-ios.

danielweck avatar danielweck commented on August 21, 2024

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

OSX:
https://github.com/readium/SDKLauncher-OSX/blob/develop/LauncherOSX/ReaderScripts/host_app_feedback.js#L196

Android:
https://github.com/readium/SDKLauncher-Android/blob/develop/SDKLauncher-Android/app/src/main/assets/readium-shared-js/host_app_feedback.js#L208

from sdklauncher-ios.

lwm561 avatar lwm561 commented on August 21, 2024

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.

danielweck avatar danielweck commented on August 21, 2024

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.

danielweck avatar danielweck commented on August 21, 2024

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.

lwm561 avatar lwm561 commented on August 21, 2024

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.

danielweck avatar danielweck commented on August 21, 2024

Interesting. This looks like an iOS -specific bug (touch events). @jccr did you come across this?

from sdklauncher-ios.

lwm561 avatar lwm561 commented on August 21, 2024

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.

lwm561 avatar lwm561 commented on August 21, 2024

Hi @danielweck
When change the font size,Highlighting dislocation

from sdklauncher-ios.

dengzhucai avatar dengzhucai commented on August 21, 2024

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.

nimisis avatar nimisis commented on August 21, 2024

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.

danielweck avatar danielweck commented on August 21, 2024

@lwm561
When change the font size,Highlighting dislocation

Thanks for the feedback. Issue filed: readium/readium-shared-js#364

from sdklauncher-ios.

danielweck avatar danielweck commented on August 21, 2024

@nimisis
undefined e.changedTouches

Thank you for reporting this. Issue filed: readium/readium-shared-js#365

from sdklauncher-ios.

danielweck avatar danielweck commented on August 21, 2024

@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.

nimisis avatar nimisis commented on August 21, 2024

@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.

danielweck avatar danielweck commented on August 21, 2024

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.

nimisis avatar nimisis commented on August 21, 2024

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.

danielweck avatar danielweck commented on August 21, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.