RakuyoKit / JSONPreview

🎨 A view that previews JSON in highlighted form, it also provides the ability to format and collapse nodes.
MIT License
65 stars 13 forks source link

auto wrap #15

Closed sjustfly closed 3 months ago

sjustfly commented 3 months ago

If it supports both auto wrap and non auto wrap, it would be perfect

rakuyoMo commented 3 months ago

If it supports both auto wrap and non auto wrap, it would be perfect

Early versions used non-auto-wrap mode, but later changed to auto-wrap mode due to certain functions.

Today I will re-evaluate the possibility of supporting non-word wrapping and the amount of changes. The relevant progress will be synchronized in this post.

rakuyoMo commented 3 months ago

The end result should be similar to the Github app. But I don't have a good idea yet, and it may take some time to implement this function.

sjustfly commented 3 months ago

@rakuyoMo Here is a library for JS's code editor, whose TextView supports automatic or non line wrapping. You can refer to it for more information

https://github.com/simonbs/Runestone

rakuyoMo commented 3 months ago

@rakuyoMo Here is a library for JS's code editor, whose TextView supports automatic or non line wrapping. You can refer to it for more information

https://github.com/simonbs/Runestone

I know this library, and I saw its implementation this afternoon. Its TextView is implemented on the basis of UIScrollView with UITextInput, etc., instead of using UITextView directly. If I want to implement a "UITextView" myself by referring to its method, the changes will be very large and the workload will be huge. This is not realistic, so it is a pity that it cannot give me much help.

I'll continue trying to make this work tomorrow, I currently have two directions:

  1. Put a UIScrollView on the outer layer of the existing JSONTextView. This may be relatively easy to implement, but the amount of changes is not small, and its application in UITableView needs to be tested.

  2. Find a suitable time to update the contentSize of JSONTextView. I tried several times today, but they all failed to achieve the effect I wanted. At present, this road seems to be unworkable, but if the right time can be found, this will be the method with the least amount of changes. If the first path doesn't work, I might take some time to delve deeper into this method.


By the way, I suspect that github's iOS App also uses this library. But unfortunately it did not publicly declare which third-party libraries it used, so this conjecture cannot be verified.

rakuyoMo commented 3 months ago

Implemented in #22

sjustfly commented 3 months ago

The issue has been fixed, and no other problems have been found.