Closed anisus closed 1 year ago
I've been looking into this one today. May not be a quick implementation, but I think I'm on the right track. I think right now I just need to figure out how to detect and assign new tokens to format, trying to do it in a similar manner to how the spellchecking extension works.
I've started over here on this branch if anyone's interested in taking a look.
@xetem Neat! I checked your branch, and I think that is a good first step, to enable Codemirror to add those decorations.
Now (if I understand your addition correctly), it will be about either expanding TextStep
to have the option of emitting those tokens (bold
, italics
, ooc
, etc.) based on our formatting rules (as "defined" in formatText.js
).
Or maybe instead of expanding TextStep, to create a similar FormatTextStep
.
But I can understand if the parser system can feel a bit complex.
I've been looking closer into this.
It seems we will run into an issue with the current parser, as it only does line-by-line parsing. The problem is that some formatting, like _italics_
is allowed to span over multiple lines:
_this text
will also be written with italics_
But in order for the parser to know that "this text" should be in italics, the parser needs to check if there is a matching end _
on some other line. And... we can't do that now.
I see a couple of options:
~~Instead of using StreamParser, writing our own custom parser as suggested in this CodeMirror topic: https://discuss.codemirror.net/t/writing-a-custom-parser-without-using-lezer-or-streamparser/4692~~
Another option is to rid ourselves with CodeMirror overall. Not sure how viable that is though.
I think it might be possible with Decorations.
Sorry if I highjacked your suggested idea! I ended up implementing it, based on your initial idea of using Decorations. However, to get it to work properly, I had to do it quite differently, and hooking it into the formatText.js function, so that it follows the same formatting rules as when displayed.
... and formatText.js is a bit of a mess (but I tried to tidy it up slightly while I was at it). But still, the feature is now complete thanks to you! :)
No worries here 😁 I too was actually looking into hooking into formatText.js, but tried doing so without changing anything about it and hit a wall. 😅
Issue
When typing formatted text in the console, such as a pose or a say message, the text formatting should be previewed directly while typing the command in the console.
See these Wolfery Forum discussions: https://forum.wolfery.com/t/feature-suggestion-preview-of-bold-cursive-etc/1623/3 https://forum.wolfery.com/t/change-of-colour-ic-vs-ooc/2157
Notes
**bold**
,_italics_
,((ooc))
and similar.:>types an ooc pose
**bold**
, the asterisks should show in the console, even if they won't appear in the chat log after being sent.)