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

Fill in the blank rework #1857

Merged
merged 18 commits into from
Mar 1, 2023
Merged

Fill in the blank rework #1857

merged 18 commits into from
Mar 1, 2023

Conversation

WildYellowfin
Copy link
Collaborator

@WildYellowfin WildYellowfin commented Feb 28, 2023

#1838

Summary

  • A "blank" is no longer a separate math field, but instead a styled latex element that looks like a mathfield
  • The latex syntax is \placeholder[id][correctness?]{body}. IDs are not enforced to be unique, but duplicate IDs will mess with behavior of related commands.
    • The old syntax \placeholder[id][defaultValue?]{} is still supported, but will be serialized from now on as \placeholder[id]{defaultValue}. If a body is provided, defaultValue is ignored.
    • correctness is read through this same argument space, but it is inferred to be a default value if the content is not "correct" or "incorrect".
  • Any ID'd prompt in a readOnly mathfield is editable, unless it has correctness set.

Keyboard navigation:

  • Left/right arrows + tab/shift tab move to next / previous editable prompt. Move-out fires if none
  • Up/down arrows work in fractions, matrices etc.

APIs

  • getPrompt(id): string
  • getAllPrompts(): string[]
  • setPromptContent(id, content)
  • setPromptCorrectness(id, correctness: 'correct' | 'incorrect' | undefined)

Styling

  • If not readOnly, prompts are greyed out
  • In readOnly, prompts are styled like a mathfield.
  • If correctness provided, box shadow is added. On incorrect, box will be "crossed out"
  • Correct / incorrect outline and shadow color can be set in --correct-color / incorrect-color (green/red by default)

Other:

Untitled.mov

Suggested documentation example:
\frac{\placeholder[0]{x+y}}{\placeholder[1]{\sqrt{2}}} \begin{pmatrix}
\placeholder[2][incorrect]{} & \placeholder[3]{} & \placeholder[4]{} \
\placeholder[5]{} & \placeholder[6]{} & \placeholder[7][correct]{}
\end{pmatrix}

@arnog
Copy link
Owner

arnog commented Feb 28, 2023

This looks really good. Thanks for this PR.

One small feedback: I'm wondering if it would be useful to add some other states for correctness. Currently, a prompt with a corrected property is not editable, but it seems that in some use cases it might be useful to have (i.e. so you can go back and modify your answer if it was wrong). Perhaps there could be four states: "correct", "incorrect", "correct-locked" and "incorrect-locked"? And maybe a fifth "locked", although less clear if that would be useful?

Also, there are some conflicts with the head now (sorry, I checked-in a bunch of changes recently). Do you want to go through them or would you like me to?

@WildYellowfin
Copy link
Collaborator Author

I guess I can see that being useful, it just hadn't occurred to me since its outside my use case. I might just make locked / unlocked a third argument, since I think the behavior can almost always be inferred just from correctness.

As for conflicts, they all seem trivial enough. I'll see if I can commit some conflict free version tonight.

@WildYellowfin
Copy link
Collaborator Author

Done! [locked] can now be added as a third argument, and defaults to false. I ended up removing readOnly from GlobalContext since with locked I don't think a prompt should always be non-editable in readOnly.

There is also now a setPromptLocked(id, locked).

I'm happy to maintain this as needed, since its a pretty core part of the platform we're building. Feel free to @ me on any related issues.

@arnog arnog merged commit 60b0d05 into arnog:master Mar 1, 2023
@arnog
Copy link
Owner

arnog commented Mar 3, 2023

@WildYellowfin an issue has been reported. I'm not sure why you made the change, so I reverted it for now, but happy to discuss the proper way to handle what you were trying to do (see bb3d25e).

@WildYellowfin
Copy link
Collaborator Author

@arnog ahh this wasn't an intended change. I was trying to debug the Webkit inputType issue and just forgot to remove it...

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

Successfully merging this pull request may close these issues.

[bug] Move-out event not called when caret in a matrix
2 participants