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

Unified Editor and Viewer #17

Open
briveramelo opened this issue Sep 10, 2023 · 2 comments
Open

Unified Editor and Viewer #17

briveramelo opened this issue Sep 10, 2023 · 2 comments

Comments

@briveramelo
Copy link

Hi,

Love this tool - has great utility, thanks for making it.

I'm trying to make a text editor for journaling, where users view/edit a single block of fancy text and never see the markdown syntax. I haven't had any success, and I'm not sure if it's supported just yet. I've created a basic setup with the DemoRenderUpdater (similar to the demo scene), and then tried a few things without success:

  1. Adding the MarkdownRenderer to the InputField's "Text" GameObject (no fancy rendering occurs)
  2. Creating a sister GameObject to the InputField's "Text" GameObject called "Markdown-Text" with the TMP_Text and MarkdownRenderer components, and setting Text's alpha to 0 (fancy rendering does occur, but the caret disappears, and trying to highlight the fancy text instead highlights the ghost text)

I wonder if you have a solution to this, have considered it, or have suggestions for how to go about it.

Thanks again for making this

@briveramelo
Copy link
Author

I've thought about this a bit more, and one idea seems promising: mapping string indices between rich text and markdown text.

(relevant sidenote- i tried a 3rd idea where I apply the rich text output back to the TMP_InputField.text field, but caret position quickly gets de-synced and chaos ensues)

I noticed that text selection (highlighting, caret position) works exactly as you'd expect when you're editing an InputField with rich text. If I write a callback for modifications (eg: using the onValueChanged or onValidateInput) that applies the changes to the TMP_InputField.text field AND manages the caret position/selection, this could work.

I'll play around with this idea next chance I get

@NudeNULL
Copy link

Uhhh, I would love that!

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

No branches or pull requests

2 participants