Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Markup Functionality #2

Open
Tracked by #5
livrasand opened this issue Aug 20, 2023 · 2 comments
Open
Tracked by #5

Add Markup Functionality #2

livrasand opened this issue Aug 20, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@livrasand
Copy link

Hello friend, I would like to help you with the implementation of text markup. Below I'll provide a simplified example of how you can approach this functionality in your project. Please note that this is a conceptual example.

First, here's a general approach to how you might implement the text markup functionality and save the markup:

1. User Interface:

  • Add an option to select and highlight text in reading view of the .jwpub file.
  • Add a button or option to save the markup.

2. Dialing Logic:

  • When text is selected and highlighted, capture the location of the markup (for example, the range of characters selected) and the content of the marked text.
  • Store this information in a suitable data structure, such as a JSON object.

3. Marking Storage:

  • You can use a separate JSON file to store the markup information.
  • Every time the markup is saved, it updates or adds entries to the JSON file.

4. Upload Marking:

  • When opening a .jwpub file for reading, it checks if there is any associated markup information in the JSON file.
  • If there are bookmarks stored, applies the bookmarks in reading view.

Here's a simplified example of how you might structure the code:

// En el código Kotlin (app/src/main/kotlin/...):

// Almacenamiento de marcadores
val markersJsonFile = File("markers.json")

fun saveMarker(selectionRange: String, markedText: String) {
    val markers = loadMarkers()
    markers[selectionRange] = markedText
    markersJsonFile.writeText(Json.encodeToString(markers))
}

fun loadMarkers(): MutableMap<String, String> {
    if (markersJsonFile.exists()) {
        val markersJson = markersJsonFile.readText()
        return Json.decodeFromString(markersJson)
    }
    return mutableMapOf()
}

Keep in mind that you will have to adapt it to the structure of the "Open Witness Library" project.

@orangethewell
Copy link
Owner

Ooh, thank you for this! I will keep an eye on your suggestion. But there's a worry for making open witness library compatible with JW Library markups, since the backup file export markups too.

I don't know for now if I will add a new approach or try to decode the backup file approach (with seems to be very simple and optimized)

Anyway, thank you for this, I will assign a branch for this soon! 😄

@orangethewell orangethewell added the enhancement New feature or request label Nov 9, 2023
@orangethewell orangethewell self-assigned this Nov 13, 2024
@orangethewell orangethewell mentioned this issue Nov 16, 2024
54 tasks
@orangethewell
Copy link
Owner

Development for text highlighting started! Preview will come with 0.2.0! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants