-
-
Notifications
You must be signed in to change notification settings - Fork 311
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
Alternative approach to "fill in the blank" #1838
Comments
Thanks for your interest and sharing this idea. That's something interesting and worth thinking about a bit more. Could you expand a bit on what issues you see with the current implementation of It seems that you're arguing for a different implementation of I don't think there's anything unsolvable, but there are some cases that are worth thinking about in advance. I would put them in three categories:
I'm not sure what you mean by that. Note that while being edited, an expression is represented as I'm happy to answer any questions you may have if you want to explore this further. |
If I understand correctly, the current implementation of \placeholder{} renders a MathfieldBox with dimensions equal to the editable mathfield. Speaking of, you can get rid of the height here, and instead put the \u200b 0 width space. Right now the height is too large, causing all sorts of alignment issues. This more or less fixes the current vertical alignment issue, but it still has the following issue: There is also a horizontal bug on first load that I can't figure out. Currently, a mathfield is delicately positioned on top of the box described above. What's strange is that the positioning logic seems to be running twice on load, and both of these give "incorrect" positions. On click anywhere in the broader math field, it runs again correctly. I stepped through the positioning to see if maybe the underlying MathfieldBox was out of place while the DOM was loading, but is positioned correctly. More broadly, I think that keeping this correspondence between the position of the box and the position of the math field is tricky. As far as the points you raised, I would propose:
I brought up RegEx because I tried to hack this solution using the \enclose tag, but quickly discovered you could not navigate inside an \enclose anyways. Maybe we can think about this more once you've had a chance to fix the current placeholder bug? Also, if you have any leads on the remaining alignment issues I can take another stab at it. |
@arnog I went ahead and built a prototype of this. Basically I:
promptMode: Screen.Recording.2023-02-20.at.16.24.04.movScreen.Recording.2023-02-20.at.16.20.58.movThings still not working / todo:
History bug: Screen.Recording.2023-02-20.at.16.23.22.movhttps://github.com/WildYellowfin/mathlive/tree/prompt |
That's looking good! The issue with copy/paste and undo buffer would seem to indicate a problem with the JSON serialization. I had a quick look at your code, but I didn't see anything obviously wrong. If this has the same functionality as I don't know if |
Yeah, I was intending to eventually merge this into the placeholder, but since this was my first time getting stuck into the source I wanted to build a prototype separately first - just to make sure the approach was sound. I just had a look to figure out how I'll try and push something by Thursday, and take another look at the JSON + maybe make a few tests. |
@WildYellowfin yes, |
@arnog just following up for help with one of the last remaining bugs I'm having. As I described above, undo / redo destroys the prompts, as does copy and paste. I've also discovered that any inline shortcuts will also break a prompt. I tried to see if this behavior generalized, and found that it also affects \enclose atoms. I suspect it applies to any atom with an I've traced the issue to here. This 'cursor.parent' does not have a This does not affect the |
Problems with both undo/redo and copy/paste point to an issue with the JSON serialization (which is used by both mechanism). This mechanism is also used by inline shortcut resolution. When serializing to JSON, the content of any branch is automatically included by default in the serialization (see I suspect that |
This is also happening to the |
Fixed! I didn't realize there was a global |
Oh, yes, sorry, I had forgotten that, but glad you solved it! Yeah, open an issue for the enclose atom and I'll have a look at it. |
No worries! I found the enclose issue also, in |
Hi @arnog. I've added an optional I don't really know how the actual drawing works in mathlive, so I wanted to check. |
@WildYellowfin for more complex rendering (i.e. one that cannot be handled with CSS) you would want to extend the |
This has now been merged into the main branch. Thanks for your contribution! |
I'd like to suggest an alternative approach to the "fill in the blank" feature. The current placeholder solution uses hacky getBoundingClientRect() stuff that doesn't seem stable. I also don't think putting nested math fields inside a read-only is a solid approach.
Instead I would make a new \prompt[id?][style?] command and a prompt mode. In prompt mode, the typical focus UI would be disabled, and selection would be controlled to give the illusion that the non-prompt parts are read only.
\prompts would basically be boxes, and inherit border styling from the math field. They would also inherit the :focus-within styles.
Prompts can be controlled by RegExing the global latex (I feel like there's a better solution, but don't know the library well).
I'm fairly new here, so I want to know how feasible this is. Given a few pointers I'd be happy to build this.
The text was updated successfully, but these errors were encountered: