FolioReaderKit icon indicating copy to clipboard operation
FolioReaderKit copied to clipboard

Feature/wkwebview

Open thilakks opened this issue 5 years ago • 36 comments

Hi We are looking for our project folio reader with wkWebview

thilakks avatar May 05 '20 09:05 thilakks

Hi @thilakks,

It is working without problems?

Or is WIP?

Thanks.

paulocoutinhox avatar May 06 '20 19:05 paulocoutinhox

Hello @hebertialmeida , thanks for the review!, I need to clarify that we were working in this feature for a specific project, so some stuff we have here are project specific, for instance we only support fixed-layout ebooks, so we did some changes that may break regular epubs. The project is on stand by, so we're not working on this at the moment. however, due to increased interest ( I just saw apple is not accepting UIWebKit anymore) and your code review I think we should end this WKWebView migration. :)

ricardohg avatar May 07 '20 04:05 ricardohg

Hi all, have you planning in the near future to finish the migration to WKWebview? And also this scrolling issue, how to fix it? I saw on google some suggestions via scroll issue, posted on this blog https://ahmedk92.github.io/2017/11/03/WKWebView-Horizontal-Paging.html

emirchelsea avatar May 07 '20 19:05 emirchelsea

As apple is rejecting apps if they are using the UIWebview, this library won't work till the migration to the WKWebview completed. So put this task on high priority otherwise in spite of being the best library, doesn't sense anything.

calebkapil avatar May 08 '20 04:05 calebkapil

I also find this repo where is the migration to WKWebview. Maybe to you guys who knows more about webviews can help to speed up process of migrations

https://github.com/pmfawkes/FolioReaderKit

emiraki avatar May 08 '20 10:05 emiraki

@ricardohg Yeah, after I posted my review I saw that it was opened by someone using your branch. I lost track of how many people have been asking about this but I haven't had time to work on that, but I can definitely help to review it.

hebertialmeida avatar May 08 '20 14:05 hebertialmeida

Hello Can you please help me out I have implemented the same and also I got crashed but I have resolved;lved that now my project is working but I think CSS and js file is not loaded properly in the collection view cell WKwebview , it looks weird can you please let me know how to resolve that issue . here is screen shot

Screenshot 2020-05-09 at 12 48 18 AM

Which method are you using to load the html?, it is working on a real device ?

ricardohg avatar May 09 '20 20:05 ricardohg

Same method that is mentioned in the file and I only changed UIwebview TO WkwebView

santosh3288 avatar May 10 '20 04:05 santosh3288

Please help me out its urgent

santosh3288 avatar May 10 '20 04:05 santosh3288

Hello everyone, does somebody know how to download epub book, save it to path and load it and then present it in FolioReader? Please help.

emirchelsea avatar May 10 '20 19:05 emirchelsea

Hi, everyone.

If you need to fix the issue with font you need do this: let headerString = "<meta name=\"viewport\" content=\"initial-scale=1.0\" />" webView?.loadHTMLString(headerString + tempHtmlContent, baseURL: baseURL)

myak0v1ev avatar May 11 '20 15:05 myak0v1ev

@hebertialmeida @ricardohg Since with WKWebview we can control javascript capability, can we utilize it to add more security to the module? We can keep javascript disabled for the WebView and temporarily toggle it back while evaluating a script from the code. This way we can be safe from any kind of script injection from the document. Thoughts?

JBenny25 avatar May 12 '20 09:05 JBenny25

@hebertialmeida What do you think? When will you be able to publish an update with WKWebview? As I am working on one project in which this SDK is the heart of it. So now I am not able to launch that app due to UIWebView. Please do the needful. Thanks.

abhijit-iOS avatar May 21 '20 12:05 abhijit-iOS

It's a great library. Please don't let it die. Please udpate it the WKWebview :(

grhashmi5 avatar May 22 '20 18:05 grhashmi5

Just thought of sharing these two forked repos - https://github.com/drasdasdasd/FolioReaderKit https://github.com/judith-bitcube/FolioReaderKit

The font size issue is solved in this repo. There are minor issues with both of these repos. but horizontal scroll is flipping through chapters and not pages.

ghost avatar May 26 '20 07:05 ghost

Since the paginationMode is missing in WkWebview, you need to add this code in your CSS file:

overflow: paged-x;
overflow: -webkit-paged-x;
overflow: -o-paged-x;

emirchelsea avatar May 26 '20 09:05 emirchelsea

If you're in a rush, consider sponsoring the repository so the contributors can spend more time during these wild times.

Parsida avatar May 26 '20 10:05 Parsida

We have very recently started the work on our iOS app to integrate folioreader. Came across this issue. @Parsida - how can we sponsor to get this issue resolved soon. If you have any suggestions please let us know.

We did contact @ricardohg to check how we can get his services to get the issue fixed. We are waiting on the response.

ghost avatar May 28 '20 19:05 ghost

@mooka-ventures Check out @hebertialmeida's page: https://github.com/sponsors/hebertialmeida

Parsida avatar May 29 '20 09:05 Parsida

Thanks, yes we are aware of that page. @Parsida we are already doing a tiny bit of sponsorship starting this month..

ghost avatar May 29 '20 16:05 ghost

Small donations from several developers that are using this repository in their projects adds up 🙌🏽

Parsida avatar May 30 '20 15:05 Parsida

We don't see any other sponsorships to the author @hebertialmeida by other developers. By the way, we tried to get some freelancer developers to help out with this but I didn't get a positive response from any till now. So we are still waiting for anyone who is ready to complete this issue. Please let us know if anyone is interested in completing this task. We can sponsor the implementation of this specific task.

ghost avatar Jun 03 '20 23:06 ghost

Hey guys, I'm open to keeping code reviewing this but at this time I can't do this implementation. If anyone wants to continue this implementation on another PR feel free to open and I can review.

hebertialmeida avatar Jun 05 '20 00:06 hebertialmeida

Alright guys. I've managed to fix the scrolling/pagination issue by injecting style tag (scrolling direction dependent) into an html. But I still have to fix the page counting issue and media overlay handling issues. I can post a PR after I will make it work, ok?

OrbitalMan avatar Jun 05 '20 18:06 OrbitalMan

Alright guys. I've managed to fix the scrolling/pagination issue by injecting style tag (scrolling direction dependent) into an html. But I still have to fix the page counting issue and media overlay handling issues. I can post a PR after I will make it work, ok?

Hello!, are you working on my branch?, did you check it is working on a real device ?

ricardohg avatar Jun 05 '20 22:06 ricardohg

Hello @ricardohg! Well, I used the most of your code - just edited it according to @hebertialmeida remarks on this PR and fixed the scrolling issue (credits to @emirchelsea). I haven't pushed it anywhere yet. I plan to push it on my fork first. https://github.com/OrbitalMan/FolioReaderKit The scrolling is confirmed to be working properly on iPhone 7, iOS 13.4.1 BTW. Upd: I will push the code after I fix the following issues:

  • You have to select a text couple of times in order to have an ability to play the audio from it.
  • The play button from menu also doesn't work before you select the text and make it to show play popup.
  • The pages counter doesn't always calculate correctly.

Also I don't see images embedded in epub content in webview. You can check by opening a book from example project app and looking at empty rect on the first page where the book cover is supposed to be shown. (I don't yet have an idea how to fix it, nor I need to fix it urgently) Upd2: Ah, I forgot to mention that I also fixed the font scale issue. (credits to @myak0v1ev)

OrbitalMan avatar Jun 06 '20 00:06 OrbitalMan

@OrbitalMan Thanks for contributing! will you open a new PR then? If so, I can review that and we can go from there.

hebertialmeida avatar Jun 09 '20 01:06 hebertialmeida

Sure @hebertialmeida! On the first commit I will make as few changes as possible for your convenience. Later I will refactor the code.

OrbitalMan avatar Jun 09 '20 11:06 OrbitalMan

Hey guys, I really think that WebKit/CSS/Javascript approach is overkill (at least for my project requirements - at least for now) - but the problem that migration just screwed up and doesn't work acceptable way. I probably will continue to fix this monster later, some day-ish... BUT! I've came up with a native approach solution!

        let textView: UITextView = UITextView()
        let xhtmlURL = Bundle.main.url(forResource: "resource", withExtension: "xhtml")!
        do {
            let xhtml = try String(contentsOf: xhtmlURL)
            let data = Data(xhtml.utf8)
            let attributedText = try NSAttributedString(data: data,
                                                        options: [.documentType: NSAttributedString.DocumentType.html],
                                                        documentAttributes: nil)
            textView.attributedText = attributedText
        } catch {
            print(error)
        }

All you need is just locate your epub's .xhtml files! (you have to unzip the epub - it's up to you how to) Although this snippet is suitable if you don't need dynamic fonts, etc and if your epub contains single xhtml resource. (and I'm totally fine with that at least for now)

Credits for the snippet go to the Hacking with Swift: https://www.hackingwithswift.com/example-code/system/how-to-convert-html-to-an-nsattributedstring

OrbitalMan avatar Jun 17 '20 20:06 OrbitalMan

@OrbitalMan

Also I don't see images embedded in epub content in webview. You can check by opening a book from example project app and looking at empty rect on the first page where the book cover is supposed to be shown. (I don't yet have an idea how to fix it, nor I need to fix it urgently)

https://developer.apple.com/forums/thread/100125 Maybe it helps! but I don't know how to do it. Thanks in advance.

silviocandido avatar Jul 23 '20 20:07 silviocandido