-
Notifications
You must be signed in to change notification settings - Fork 141
Adds foundation for rich text feature with styleRanges approach #354
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
base: main
Are you sure you want to change the base?
Conversation
🤩🤩🤩 Amazing! I look forward to reviewing this soon! |
Thanks, could be exactly what's needed for lojjic/aframe-troika-text#85 and more! |
Based on the discussion that prompted this update, Yes, this PR is just move towards true rich text with a markdown or HTM type syntax. #334 |
Aploogies for the delay on this, I haven't forgotten about it but haven't found time to dig in yet. Soon, I hope. 🙂 |
Hey thanks, looking forward to it being merged whenever you have time for a proper review. I don't want to rely on a fork in the long run! I may add a minor cleanup commit but all the logic has been working good for my use cases. One consideration about this update is the I was considering how to get styleRanges[].fontSize working and it may be tricky because it seems the font dimensions may be calculated only only once for each character. Seems the area may be in TextBuilder around line 270. I think it would need to be re calculated or kept in memory with fontGlyphMaps. just considering how that feature would work with this API since fontSize is the next most useful property to support. |
Apologies again for the delay!
I do think we should remove it. My main concern is that it introduces ambiguity where the Of course pure diffs are more verbose and harder to write as a user, but I'm increasingly thinking users shouldn't ever be writing them -- we'd expose and document it but only as a hook for other tools. I've already prototyped a simple htm binding to produce the indexed diff format that I think would work nicely as the default user-facing API. Would you mind adjusting this PR to remove |
Okay, i agree, length does add some complexity that can be handled better at a higher level and more reliably parse those style diff edge cases. And yea styleRanges was just intended as a hook for other tools. There honestly isn't that much that needs to be removed, see latest commit. The example api changes to this:
|
@lojjic I am thinking about the higher level syntax; I'd love get an idea of the API for your POC if you are willing to share an example? would it parse html like: |
Added small update to return to the default color and font with styleRanges using a 'false' value. Thought is any other styleRanges keys added could optionally follow this approach to returning a range to the default value, but not required that they do like the previous 'length' prop approach. This way the example can retain the colorCycle animation.
|
Could it be possible to add inline images to the text with this feature? |
IDK about full color images but a custom icon font could render single color vector images inline |
Adds feature for Rich Text using
styleRanges
APIExample
color
andfont
propertieslength
property should return to previous style for each supported propertyAlso addressed:
TODOs noted
fontSize
([Feature Request] troika-three-text sizeRanges similar to colorRanges #278)Resolve bug noted in TextExample and FontResolver regarding length property and undefined valueAddresses Issues:
#278
#65