Mantano / iridium

Unofficial Dart/Flutter port of some of the Readium 2 components
80 stars 27 forks source link

Disabling text selection / Copying / sharing [IOS] #80

Open KhaledAbdElNasserAhmed opened 1 year ago

KhaledAbdElNasserAhmed commented 1 year ago

Is there any way to disable text copying in IOS, can you provide any hints or methods to use to that.

jmgeffroy commented 1 year ago

Hello @KhaledAbdElNasserAhmed, we currently do not provide this. Can you please explain under which conditions text selection would be disabled? Would it be based on some metadata inside the Epub, or globally in the whole app?

KhaledAbdElNasserAhmed commented 1 year ago

Globally in the whole ereader, I am currently using your library in one of my book publishing apps, the user can select text from the whole book and paste it anywhere, which is not helpful when publishing paid books, so I was able to disable copying and screen shooting in Android in the whole epub reader but failed to do the same in IOS, any insights on how to disable text sharing / selection and copying would be wonderful.

I think it has something to do with the kwebviewer that is used in IOS.

jmgeffroy commented 1 year ago

@KhaledAbdElNasserAhmed Thank you for the explanation. Understood. You need a global setting. I'll provide it through the API.

westernbuptboy commented 1 year ago

Globally in the whole ereader, I am currently using your library in one of my book publishing apps, the user can select text from the whole book and paste it anywhere, which is not helpful when publishing paid books, so I was able to disable copying and screen shooting in Android in the whole epub reader but failed to do the same in IOS, any insights on how to disable text sharing / selection and copying would be wonderful.

I think it has something to do with the kwebviewer that is used in IOS.

Dear Developer

I found that selecting text for this project on iOS does not trigger a pop event in the code, but it is normal on Android. I see you raised this question. Do you understand how to make selected events on iOS also be captured? Thank you!。

winterdl commented 1 year ago

@KhaledAbdElNasserAhmed if you upgrade to InAppWebView 6.x and ios 13.0+, you could use this property to disable text selection: isTextInteractionEnabled: false

jmgeffroy commented 1 year ago

@winterdl Thanks for the tip. I had yet to see this beta. If I read the Apple documentation and InAppWebView source code correctly, it is available in iOS 14.5 (iOS 15 in InAppWebView's source code). I'd happily integrate this setting, but setting the minimum iOS to 15 is pretty radical. Any thoughts, @westernbuptboy @winterdl @KhaledAbdElNasserAhmed?

jmgeffroy commented 1 year ago

No big danger according to this article. I should probably move forward....

jmgeffroy commented 1 year ago

I implemented and tested it, it works as expected. I haven't found a similar option for Android. Id' like to avoid injecting JS to do this. Any hint? For now I'm not doing the PR, I'll wait until I have a clean solution for Android.

westernbuptboy commented 1 year ago

@KhaledAbdElNasserAhmed if you upgrade to InAppWebView 6.x and ios 13.0+, you could use this property to disable text selection: isTextInteractionEnabled: false

Selecting text on iOS cannot pop up a custom window, only the default window pops up. Is there a way to solve this?

westernbuptboy commented 1 year ago

maybe i find the solution update the flutter_inappwebview plugin https://github.com/pichillilorenzo/flutter_inappwebview/pull/1575