⚠️ ᴛʜɪs ʀᴇᴘᴏsɪᴛᴏʀʏ ɪs ᴅᴇᴘʀᴇᴄᴀᴛᴇᴅ⚠️ We moved all the
r2-*-swift
modules to a single repository:swift-toolkit
.
readium / r2-navigator-swift Goto Github PK
View Code? Open in Web Editor NEWLicense: BSD 3-Clause "New" or "Revised" License
License: BSD 3-Clause "New" or "Revised" License
⚠️ ᴛʜɪs ʀᴇᴘᴏsɪᴛᴏʀʏ ɪs ᴅᴇᴘʀᴇᴄᴀᴛᴇᴅ⚠️ We moved all the
r2-*-swift
modules to a single repository:swift-toolkit
.
i am using readium library for epub and i am trying with javascript to select the word by it's text-id . In landscape it's working fine for 1st page but for second page it's not working. i am using changeTextColor(fragmentId: String) function for hi-lighter , in this function fragmentId printing correctly for second page also, but text is not getting hi-lighted.
func changeTextColor(fragmentId: String) {
print(fragmentId)
let scc = "document.getElementById('\(fragmentId)').style.color='#EA4343'; setTimeout(function(){ document.getElementById('\(fragmentId)').style.color = \"#000000\";}, 1500);"
let script = "spread.eval('', \"\(scc.replacingOccurrences(of: "\"", with: "\\\""))\");"
webView.evaluateJavaScript(script, completionHandler: nil)
}
After opening a PDF book, we can't show the navigation bar by tapping on the content, starting from iOS 13.
Navigating through an RTL EPUB is currently broken in the Swift Navigator. I think it's caused by the changes I made a few months ago for the FXL 2-page spreads.
When turning an EPUB's pages with <media>
elements playing, the playback is not interrupted. It keeps going until the page is destroyed which can take 2 additional page turns for FXL.
Two questions:
this can be reproduced easily when tapping a bit quicker to get to the next or previous page.
it seems like the tap is registered while the page is still in motion and triggers the wrong action.
this also can be seen when reached the very end of a publication and trying to tap to go next, then instead the toggle navigation bar is executed.
We want to change the default value of "Publishers default" to true. I can change in the imported r2-navigator but then you need to remember this if we upgrade and thats not good.
Try to present the ebook reader
Stuck on loading screen (just an activity indicator rotates in the center of the screen)
An ebook first page should be shown
Just try to present the ebook reader
iOS 13, 12
r2-shared-swift
: 2.1.0r2-streamer-swift
: 2.1.0r2-navigator-swift
: 2.1.0r2-opds-swift
: 2.1.0r2-lcp-swift
: 2.1.0macOS: 11.6
platform: x86_64
carthage: 0.38.0
I see only this error:
❌ EPUBSpreadView.swift:162: 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}
Please, note that I am using "readium" variable in the JS that throws this error. The problem still persist If I remove all of my custom js
Hi!
I updated now to r2-navigator-swift:1.1.4
and the webview crashes sometimes now when i try to start a EPUBViewController
.
The only relevant change I did is to initialize the EPUBViewController with a resourcesServer
and configuration
object. Is there another step that I missed or something? :)
let customInsets: [UIUserInterfaceSizeClass: EPUBContentInsets] = [
.regular: (top: 64, bottom: 44)
]
var configuration = EPUBNavigatorViewController.Configuration()
configuration.contentInset = customInsets
epubViewer = EPUBNavigatorViewController(
publication: publication,
license: license,
initialLocation: initialLocation,
resourcesServer: server!,
config: configuration
)
Webview.swift
:/// A custom web view which:
/// - Forwards selection actions to an EditingActionsController.
final class WebView: WKWebView {
private let editingActions: EditingActionsController
init(editingActions: EditingActionsController) {
self.editingActions = editingActions
super.init(frame: .zero, configuration: .init()) // <<< Crashes on this line
}
2019-10-02 11:04:04.379266+0200 Test-Bibblix[78441:944383] [Assert] Cannot be called with asCopy = NO on non-main thread.
2019-10-02 11:04:04.379551+0200 Test-Bibblix[78441:944383] [Assert] Cannot be called with asCopy = NO on non-main thread.
2019-10-02 11:04:04.393334+0200 Test-Bibblix[78441:944383] [Animation] +[UIView setAnimationsEnabled:] being called from a background thread. Performing any operation from a background thread on UIView or a subclass is not supported and may result in unexpected and insidious behavior. trace=(
0 UIKitCore 0x000000010e46fdda kFixedAnimationDuration_block_invoke_5 + 107
1 libdispatch.dylib 0x000000010691cdb5 _dispatch_client_callout + 8
2 libdispatch.dylib 0x000000010691e83c _dispatch_once_callout + 66
3 UIKitCore 0x000000010e46fd6d +[UIView(Animation) setAnimationsEnabled:] + 76
4 UIKitCore 0x000000010e46febb +[UIView(Animation) performWithoutAnimation:] + 84
5 UIKitCore 0x000000010e4327a6 -[UIImageView _updateImageViewForOldImage:newImage:] + 461
6 UIKitCore 0x000000010e42d649 -[UIImageView setImage:] + 369
7 UIKitCore 0x000000010e42c680 -[UIImageView initWithImage:] + 246
8 UIKitCore 0x000000010e40a0bc CreateScrollIndicator + 401
9 UIKitCore 0x000000010e4098af -[UIScrollView _adjustScrollerIndicators:alwaysShowingThem:] + 149
10 UIKitCore 0x000000010e3f998f -[UIScrollView _updateForChangedScrollIndicatorRelatedInsets] + 165
11 WebKit 0x0000000117db06bb -[WKScrollView initWithFrame:] + 137
12 WebKit 0x0000000117cab3d8 -[WKWebView _initializeWithConfiguration:] + 4866
13 WebKit 0x0000000117cac51c -[WKWebView initWithFrame:configuration:] + 98
14 R2Navigator 0x0000000102fa425b $s11R2Navigator14EPUBSpreadViewC11publication6spread12resourcesURL15initialLocation13contentLayout18readingProgression12userSettings12animatedLoad14editingActions0K5InsetAC0A6Shared11PublicationC_AA0C0V10Foundation0H0VSgAN7LocatorVAN07ContentL5StyleOAN07ReadingN0OAA04UserP0CSbAA07EditingT10ControllerCSDySo24UIUserInterfaceSizeClassV12CoreGraphics7CGFloatV3top_A9_6bottomtGtcfc + 603
15 R2Navigator 0x0000000102fb8a74 $s11R2Navigator24EPUBReflowableSpreadViewC11publication6spread12resourcesURL15initialLocation13contentLayout18readingProgression12userSettings12animatedLoad14editingActions0L5InsetAC0A6Shared11PublicationC_AA10EPUBSpreadV10Foundation0I0VSgAN7LocatorVAN07ContentM5StyleOAN07ReadingO0OAA04UserQ0CSbAA07EditingU10ControllerCSDySo24UIUserInterfaceSizeClassV12CoreGraphics7CGFloatV3top_A9_6bottomtGtcfc + 260
16 R2Navigator 0x0000000102f92857 $s11R2Navigator27EPUBNavigatorViewControllerC010paginationD0_04pageD7AtIndex8locationAA04PageD0_So6UIViewCXcSgAA010PaginationD0C_Si0A6Shared7LocatorVtFTf4dnnn_n + 1287
17 R2Navigator 0x0000000102f8d8ff $s11R2Navigator27EPUBNavigatorViewControllerCAA010PaginationD8DelegateA2aDP010paginationD0_04pageD7AtIndex8locationAA04PageD0_So6UIViewCXcSgAA0fD0C_Si0A6Shared7LocatorVtFTW + 15
18 R2Navigator 0x0000000102f96210 $s11R2Navigator14PaginationViewC04loadD033_E5B6E692643F2C92B3A81F0E647DD191LL2at8locationAA04PageD0_So6UIViewCXcSgSi_0A6Shared7LocatorVtF + 272
19 R2Navigator 0x0000000102f95cf4 $s11R2Navigator14PaginationViewC15setCurrentIndex33_E5B6E692643F2C92B3A81F0E647DD191LL_8locationySi_0A6Shared7LocatorVSgtF + 1972
20 R2Navigator 0x0000000102f94c9c $s11R2Navigator14PaginationViewC13reloadAtIndex_8location9pageCount18readingProgressionySi_0A6Shared7LocatorVSgSiAH07ReadingL0OtF + 604
21 R2Navigator 0x0000000102f8b4c0 $s11R2Navigator27EPUBNavigatorViewControllerC13reloadSpreads33_E158D153422E135CD1F26B7E7CA576EFLL2aty0A6Shared7LocatorVSg_tF + 1280
22 R2Navigator 0x0000000102f89952 $s11R2Navigator27EPUBNavigatorViewControllerC11publication7license15initialLocation15resourcesServer6configAC0A6Shared11PublicationC_AI10DRMLicense_pSgAI7LocatorVSgAI09ResourcesK0_pAC13ConfigurationVtcfc + 978
23 R2Navigator 0x0000000102f89564 $s11R2Navigator27EPUBNavigatorViewControllerC11publication7license15initialLocation15resourcesServer6configAC0A6Shared11PublicationC_AI10DRMLicense_pSgAI7LocatorVSgAI09ResourcesK0_pAC13ConfigurationVtcfC + 100
24 Test-Bibblix 0x0000000101bf41d1 $s12Test_Bibblix18EpubViewControllerC13initNavigator11publication15initialLocation7license15callbackHandler6servery8R2Shared11PublicationC_AJ7LocatorVSgAJ10DRMLicense_pSgAA015CordovaCallbackM0_p0O8Streamer0Q6ServerCSgtF + 1361
github "weichsel/ZIPFoundation" == 0.9.8
github "krzyzanowskim/CryptoSwift" == 0.15.0
github "readium/r2-shared-swift" == 1.3.4
github "readium/r2-streamer-swift" == 1.1.6
github "readium/r2-navigator-swift" == 1.1.4
github "readium/r2-lcp-wrapper-swift" == 1.0.8
github "readium/r2-lcp-swift" == 1.1.2
github "onevcat/Kingfisher" == 4.10.1
github "jdg/MBProgressHUD"
github "stephencelis/SQLite.swift" == 0.11.5
github "swisspol/GCDWebServer" == 3.5.2
github "edrlab/Fuzi" == 2.2.2
github "tadija/AEXML" == 4.3.3
github "dexman/Minizip"
When switching to 2 columns on a reflowable EPUB, the page hangs.
This is probably caused by the recent spread refactoring because the console displays this error message:
🔴 EPUBSpreadView.swift:165: Only one-page spreads are supported with EPUBReflowableSpreadView
In the podspec the dependency to DifferenceKit is missing.
Trying to jump to a Bookmark which is located on a readingOrder
that is not already loaded doesn't work, we end up at the start of the resource.
When turning an EPUB's pages with <media>
elements playing, the playback is not interrupted. It keeps going until the page is destroyed which can take 2 additional page turns for FXL.
Two questions:
I want to know the current page and spine which user is reading. Therefore, I can show the reading progress.
TriptychView has a property (index) can do this, but It's a private property.
Hello. This issue is really simple one. I have couple of trivial compile errors then try to build project in Xcode 11 with new 5.1 Swift compiler which prevents me to use the framework as Carthage dependency.
It's seems like pdfView.canGoToNextPage()
and pdfView.canGoToPreviousPage()
couldn't be used as methods any more. Just try it by yourself.
Thanks
Repository description states "A Swift implementation of the Readium-2 streamer"
i am useing readium library for epub .when i am holding on the first word then it's getting selected and when i am touching and holding on second word then it's get selected with previous one ,like whole sentence get's selected.
There are a few issues (#101, #141) caused by events sent while the Navigator is transitioning. We could fix this class of bugs by reifying a statechart to handle the Navigator's behavior. This would also improve code readability and help with debugging.
I update r2 navigator last version(1.2.6) and r2 shared framework(1.4.3) after that can not load first two pages of EPUB but next pages are opened.
Sometimes two locaters might overlap on a single page and when you use scrollToPosition function it will snap the the previous locater that the user will be already done with
Check out the videos for more details
with snapping to the previous page (current behaviour)
Please check #93 as a suggested solution that snap the offset to the next page instead
Bug Report
i am using readium library for epub and i am trying with javascript to select the word by it's text-id . In landscape it's working fine for 1st page but for second page it's not working. i am using changeTextColor(fragmentId: String) function for hi-lighter , in this function fragmentId printing correctly for second page also, but text is not getting hi-lighted.
Second page word hi-lighter is not working in landscape
r2-shared-swift:
r2-streamer-swift:
r2-navigator-swift:
r2-opds-swift:
r2-lcp-swift:
macOS: 11.2
platform: x86_64
Xcode 12.4
Build version 12D4e
iOS version: 14.4
Model (e.g. iPhone 11 Pro Max): iPhone 12 Pro Max
Is it an emulator? Yes
func changeTextColor(fragmentId: String) {
print(fragmentId)
let scc = "document.getElementById('\(fragmentId)').style.color='#EA4343'; setTimeout(function(){ document.getElementById('\(fragmentId)').style.color = \"#000000\";}, 1500);"
let script = "spread.eval('', \"\(scc.replacingOccurrences(of: "\"", with: "\\\""))\");"
webView.evaluateJavaScript(script, completionHandler: nil)
}
As per your suggestion in the other issue i have implemented spread.eval() in spreadview.swift and it's not working for second page. readium/swift-toolkit#132
Our app is about to go live so can we have a session to resolve this issue.
i am useing readium library for epub .when i am holding on the first word then it's getting selected and when i am touching and holding on second word then it's get selected with previous one ,like whole sentence get's selected.
word selection issue
r2-shared-swift
:r2-streamer-swift
:r2-navigator-swift
:r2-opds-swift
:r2-lcp-swift
:macOS: 11.2
platform: x86_64
Xcode 12.4
Build version 12D4e
iOS version: 14.4
Model (e.g. iPhone 11 Pro Max): iPhone 12 Pro Max
Is it an emulator? Yes
in utility.js
document.addEventListener('selectionchange', debounce(50, function() {
var info = {}
var selection = document.getSelection();
if (selection && selection.rangeCount > 0) {
var rect = selection.getRangeAt(0).getBoundingClientRect();
info['text'] = selection.toString().trim();
info['frame'] = {
'x': rect.left,
'y': rect.top,
'width': rect.width,
'height': rect.height
};
}
webkit.messageHandlers.selectionChanged.postMessage(info);
}));
When calling updateUserSettingStyle
before the EPUB navigator is fully loaded and positioned to the initial location will reset the initial location to the start of the Publication
.
It would be useful to add to the Navigator API an event or an observable state to know when it is fully initialized.
If you try to go the a location on view loaded in the background it will always end up at the start of the resource.
here I am trying to go to the last locater on the resource
The reason behind this that loadView(at index: Int, location: Locator)
method will ignore the case were the view is loaded and won't create a new view with initialLocation of the parameter sent to it
check #95 as a suggested solution
I want to disable copy feature in Epub reading can anyone help me about that or send me documentation for that.
When I slide to next page, the epub could be another chapter. I want to show the chapter title on the top of my view.
I noticed that the delegate of navigator doesn't have such methods.Is there anything I can do to get noticed when page changes?
I was running the test app i have noticed that after opening some epub and navigating between chapters (webviews) that the memory kept increasing as you see in the picture even tho after navigating back to the main screen
looking at safari develop tab it seems all the previous webviews loaded in the app
and in the memory graph debugger i have noticed the webviews still allocating memory
and deinit never being called in WebView class, can you advice on this ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.