readium / swift-toolkit

A toolkit for ebooks, audiobooks and comics written in Swift
https://readium.org/mobile/
BSD 3-Clause "New" or "Revised" License
222 stars 96 forks source link

Logic behind the selected text information for remote server #425

Closed vedat73 closed 1 month ago

vedat73 commented 1 month ago

Describe the bug

Hello. I want to know what is the main logic to recognize user selected text within the reading screen. I did create a custom selection menu bar instead of displaying the default one when user select a word or words within the reading screen. According to this issue, you explained how can we manage to hide default menu view and create a custom one. And we are using the following function to achieve this goal.

func navigator(_ navigator: SelectableNavigator, shouldShowMenuForSelection selection: Selection)

Everything is good about creating a custom view until it comes to saving selection data to a remote server for future use. Because I don’t know the logic behind of the recognizing the selected text, I can’t find which kind of data should be stored in the remote server for future usage.

Thanks in advance

How to reproduce?

  1. Open demo app
  2. Open a book
  3. Select a word/words

Readium version

2.7.1

OS version

iOS 17.2

Testing device

iPhone 15 Pro

Environment

macOS: 14.4.1
platform: arm64
Xcode 15.2

Additional context

No response

mickael-menu commented 1 month ago

You can store a Locator as a JSON object (see https://github.com/readium/architecture/tree/master/models/locators and https://github.com/readium/swift-toolkit/blob/develop/Documentation/Guides/Getting%20Started.md#locator).

The Locator is in selection.locator. You can use the Locator later to go to the selection location, draw a highlight, etc.

vedat73 commented 1 month ago

@mickael-menu thanks for your quick response